| 05-26-2004, 02:15 AM | #1 |
I'm trying to get a loop to create 24 units and order them to finger of death then move.. but nothing seems to work right. All that happens is the units are created. They arent given the ability nor do they receive orders. What went wrong... I've tried commenting out various parts to no avail. None of the functions after the create unit function work. Code:
function beginspell_conditions takes nothing returns boolean
if (GetSpellAbilityId() == 'A000') then
return true
endif
return false
endfunction
function Trig_beginspell_Actions takes nothing returns nothing
local location targetloc=GetUnitLoc(GetSpellTargetUnit())
local location createat
local real facing = 0
local unit target=GetSpellTargetUnit()
local integer i = 1
call DisplayTextToPlayer(Player(0),0,0,"Actions initiated")
loop
exitwhen i > 24
call DisplayTextToPlayer(Player(0),0,0,"Loop run #"+ I2S(i))
set facing = (facing + 15)
set createat = PolarProjectionBJ(targetloc, 800,facing)
call CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()),'e000',createat,AngleBetweenPoints(createat,targetloc))
call UnitAddAbilityBJ( 'A001', GetLastCreatedUnit() )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "fingerofdeath", target)
call IssuePointOrderLocBJ(GetLastCreatedUnit(),"move",targetloc)
call RemoveLocation(createat)
set createat = null
set i = i+1
endloop
call RemoveLocation(targetloc)
set targetloc = null
endfunction
//init area
function InitTrig_beginspell takes nothing returns nothing
set gg_trg_beginspell = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_beginspell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction( gg_trg_beginspell, function Trig_beginspell_Actions )
call TriggerAddCondition(gg_trg_beginspell,Condition(function beginspell_conditions))
endfunction |
| 05-26-2004, 02:37 AM | #2 |
GetLastCreatedUnit doesnt recognize units created by CreateUnitAtLoc only CreateNUnitsAtLoc. Well, that explains it all. *sigh*. |
| 05-26-2004, 11:16 AM | #3 |
Just use the return value of CreateUnitAtLoc. That is the unit created. |
| 05-26-2004, 10:05 PM | #4 |
I dont know how to do that. :( Would it be like return(something? I'm still new to JASS. |
| 05-26-2004, 10:23 PM | #5 |
An example: The return value of PolarProjectionBJ up there is stored in createat. |
| 05-27-2004, 05:34 AM | #6 |
That's what I dont get...are you saying I should do like Code:
call UnitAddAbilityBJ( 'A001', CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), 'e000',createat,AngleBetweenPoints(createat,target loc))) |
| 05-27-2004, 07:08 AM | #7 |
That would work but you need the value several times in your code so better set it to a local unit variable. Like set u = CreateUnitAtLoc(...) |
| 05-27-2004, 11:18 PM | #8 |
Ah ok good. Thanks. |
