| 12-09-2008, 11:00 PM | #2 |
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 |
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. 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 |
Notice all the subtle differences. 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 |
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. |
