HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Some loops were made retarded..

05-04-2007, 03:01 PM#1
Toink
This loop is retarded, damn what a dumbass. It doesn't even do function calls.

Collapse JASS:
function Trig_Surrealism_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit c
local real x
local real y
local real a
local integer i
    call BJDebugMsg("Starting Loop")
    loop
        call BJDebugMsg("Start of the Loop")
        set i = i+1
        call BJDebugMsg("Set i = i+1")
        set a = ModuloReal(i*120, 360)
        call BJDebugMsg("Modulo Real")
        set x = ProjectX(GetUnitX(u), 150, a)
        call BJDebugMsg("Project X")
        set y = ProjectY(GetUnitY(u), 150, a)
        call BJDebugMsg("Project Y")
        call CreateUnit(GetOwningPlayer(u), 'e002', x, y, a)
        call BJDebugMsg("Create Unit")
        set c = GetLastCreatedUnit()
        call BJDebugMsg("Set c = Last Created Unit")
        call UnitApplyTimedLife(c, 'BTLF', 20)
        call BJDebugMsg("Apply timed life")
        call IndieSummon_SetMaster(c, u)
        call BJDebugMsg("Set Master")
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl", x, y))
        call BJDebugMsg("Loop Finished!")
        exitwhen i == 3
    endloop
    set u = null
    set c = null
endfunction

//===========================================================================
function InitTrig_Surrealism takes nothing returns nothing
    call OnAbilityEffect('A00C', "Trig_Surrealism_Actions")
endfunction

It's supposed to create 3 units, and make it an Uncontrollable Summon, thanks to Vex for that. Problem is it doesn't do shit at all! I've put in Debug messages between each function call, and doesn't call any function at all!

It just shows the messages "Starting Loop" and "Start Of Loop" from there on nothing happens.

Any advice?
05-04-2007, 03:07 PM#2
Thunder_Eye
Try setting i to 0 when declaring it
05-04-2007, 03:10 PM#3
Toink
I'll try it..

EDIT:

Awesome, here's some rep.. Thanks man, how'd you know it was cased by the declaration?

Oh, but it still had some problems.. Debug messages told me that it applied timed life, made it a uncontrollable summon. But it didn't have timed life and it was controllable.. Any ideas? :)
05-04-2007, 03:40 PM#4
Thunder_Eye
I've had the same problem with not setting loop integers before usage :P
The engine doesnt set it to 0 (as you might think), so you'll have to do it manually.

The reason that your timed life and the other thing doesnt work is because you're using CreateUnit and GetLastCreatedUnit together, which doesnt work as CreateUnit doesnt set GetLastCreatedUnit when its run (like the BJ ones)
replace
Collapse JASS:
 call CreateUnit(GetOwningPlayer(u), 'e002', x, y, a)
with
Collapse JASS:
 set c = CreateUnit(GetOwningPlayer(u), 'e002', x, y, a)
and remove
Collapse JASS:
set c = GetLastCreatedUnit()

This is how the normal GUI create unit looks:
Collapse JASS:
function CreateUnitAtLocSaveLast takes player id, integer unitid, location loc, real face returns unit
    if (unitid == 'ugol') then
        set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)
    else
        set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)
    endif

    return bj_lastCreatedUnit
endfunction

The one you are using is a native, and doesn't set bj_lastCreatedUnit to anything.
05-04-2007, 03:55 PM#5
Toink
Oh I see, thanks for the info.