HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Movement Help

12-09-2008, 02:43 AM#1
Dope[C]rafT
Hay there, Im currently experimenting with the WE. Im basically creating a line of units between two post units. Example, -*****- The dashes move up and down randomly in sync. When the dashes get to there position the stars are created. And when the dashes move again there destroyed and created. And so on and so on. I some what have the concept of how to do this. But I am in need of some assisstance.

Trigger:
ElecAction
Collapse Events
Unit - A unit Is issued an order targeting a point
Collapse Conditions
(Triggering unit) Equal to Electric Generator 0002 <gen>
Collapse Actions
Collapse For each (Integer A) from 1 to 1000, do (Actions)
Collapse Loop - Actions
Set Elec = (Elec + 1)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Elec Less than 10
Collapse Then - Actions
Set ElecPos[1] = ((Position of Electric Generator 0002 <gen>) offset by 256.00 towards 180.00 degrees)
Set ElecPos[2] = ((Position of Electric Generator 0002 <gen>) offset by 356.00 towards 180.00 degrees)
Set ElecPos[3] = ((Position of Electric Generator 0002 <gen>) offset by 456.00 towards 180.00 degrees)
Set ElecPos[4] = ((Position of Electric Generator 0002 <gen>) offset by 556.00 towards 180.00 degrees)
Set ElecPos[5] = ((Position of Electric Generator 0002 <gen>) offset by 656.00 towards 180.00 degrees)
Set ElecPos[6] = ((Position of Electric Generator 0002 <gen>) offset by 756.00 towards 180.00 degrees)
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[1] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[2] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[3] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[4] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[5] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Unit - Create 1 Spark for Player 12 (Brown) at ElecPos[6] facing (Position of (Triggering unit))
Unit Group - Add (Last created unit) to ElecGroup
Wait 2.00 seconds
Unit Group - Pick every unit in ElecGroup and do (Unit - Remove (Picked unit) from the game)
Set Elec = (Elec - 1)
Collapse Else - Actions
Do nothing

Well this works but how do I make the units only when the side units stop. This makes them create randomly, just when ever. Ive included a copy of my map. Please try and point me in the right direction.
Attached Files
File type: w3xTest.w3x (19.5 KB)
12-09-2008, 11:00 PM#2
Monstah
Well, for one thing I dont think you need the loop from 1 to 1000. To be honest, I don't even think it gets to a second iteration. The loop inside it seems like an infinite loop to me.

Second, the infinite loop you did can be achieved by using a timer. But if I understand it, I think you want the units to be spawned just once, each time the generators stop, right?

So, first you have to detect when the generators stop. If they always stop at the same spot, you can create a region there and have the trigger go off when the generators enter this region.

Another way I think of now (but can't test at the moment) is to give it a dummy ability based off Shadowmeld (the night elf "hide" ability). I think it only works when the unit is standing still, so you can (probably) get the event of this ability being cast.
12-10-2008, 04:01 AM#3
Dope[C]rafT
Ok I will try the Shadowmeld idea, but then how would I make it cast this spell only when it stops. How do I have an infinite Loop, actually what does 1-1000 mean? How many times the loop is played I presume.

Ok I have a new code for generating the units between the 2 post units. But I get all kind of errors with it like 'Type mismatch in assignment' and expected a name, end of line, and end loop.

Collapse JASS:
function Trig_ElecTest_Conditions takes nothing returns boolean
    if ( not ( GetTriggerUnit() == gg_unit_u000_0002 ) ) then
        return false
    endif
    return true
endfunction 

function Trig_ElecTestRemoveGroup takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_ElecTest_Actions takes nothing returns nothing
    local real A 
    local real X
    local real Y
    local unit U = gg_unit_u000_0002
    local unittype ID = "e000"
    set X = GetUnitX(U)
    set Y = GetUnitY(U)
        loop
        exitwhen A>6
        set X = X - 100
        set A = A + 1
        call CreateUnit(PLAYER_NEUTRAL_PASSIVE, ID, X, Y, 90)
        call GroupAddUnitSimple( GetLastCreatedUnit(), udg_ElecGroup )
    endloop
    call TriggerSleepAction( 3.00 )
    call ForGroupBJ( udg_ElecGroup, function Trig_ElecTestRemoveGroup )) 
endfunction 

//===========================================================================
function InitTrig_ElecTest takes nothing returns nothing
    set gg_trg_ElecTest = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ElecTest, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_ElecTest, Condition( function Trig_ElecTest_Conditions ) )
    call TriggerAddAction( gg_trg_ElecTest, function Trig_ElecTest_Actions )
endfunction
12-10-2008, 04:28 AM#4
Here-b-Trollz
Notice all the subtle differences.
Collapse JASS:
function Trig_ElecTest_Conditions takes nothing returns boolean
   return GetTriggerUnit() == gg_unit_u000_0002
endfunction 

function Trig_ElecTestRemoveGroup takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_ElecTest_Actions takes nothing returns nothing
    local unit U=gg_unit_u000_0002
    local real X=GetUnitX(U)
    local real Y=GetUnitY(U)
    local integer ID='e000'
    local integer A=0 
    loop
        exitwhen A>6
        set X = X - 100
        set A = A + 1
        call GroupAddUnit(udg_ElecGroup,CreateUnit(PLAYER_NEUTRAL_PASSIVE, ID, X, Y, 90))
    endloop
    call TriggerSleepAction( 3.00 )
    call ForGroupBJ( udg_ElecGroup, function Trig_ElecTestRemoveGroup )) 
endfunction 

//===========================================================================
function InitTrig_ElecTest takes nothing returns nothing
    set gg_trg_ElecTest = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ElecTest, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_ElecTest, Condition( function Trig_ElecTest_Conditions ) )
    call TriggerAddAction( gg_trg_ElecTest, function Trig_ElecTest_Actions )
endfunction
12-10-2008, 06:13 PM#5
Monstah
What I mean by infinite loop is that you set up a loop action once, and never exit it. So, when this trigger fires the first time, it will go looping forever (well, until you quit the mission at least).

And if you don't know what the "from 1 to 1000" does, why is it there? I think it is obvious, but it repeats the code inside it 1000 times. But since the code inside never finishes the first time, it is really unnecessary.

This doesn't happen on the JASS version tho; I think it is okay. To make it fire when the unit stops, (if I'm correct about the shadowmeld thingie) you should add an event "unit starts the effect of ability", and a condition "ability being cast == your dummy shadowmeld". Check if there's a way to null the ability's effect, tho, so it will fire the ability but not become invisible (which is what it does).

---

edit - hm, I thought the second post was you improving your own code, but I just noticed it was someone else correcting you. Anyway, yeah, notice the subtle differences. Single quotes on the integer, and setting X, Y and A at declaration. Also, you A was not set to 0, that was probably a bad thing.