edo494
06-28-2012, 07:43 PM
I don't know, maybe I'm idiot or blind or what, but
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetUnitLoc(gg_unit_H000_0029), bj_UNIT_FACING )
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 0.01)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_002, 2.00 )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
works properly, but
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call CreateUnit(Player(0), 'hfoo', GetUnitX( gg_unit_H000_0029), GetUnitY(gg_unit_H000_0029), 0)
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 0.01)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_002, 2.00 )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
Kills unit placed as last on my (GUI) trigger placing units at map init.(the unit is modified Knight 'h005' )
Even DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetLastCreatedUnit())) returns the other unit, also if i Set this unit into local variable it still says it's the last created unit before this one.
The spawn trigger is
spawn
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Unit - Create 1 Legionnaire for Player 1 (Red) at (Position of Spirit Healer 0029 <gen>) facing Default building facing degrees
Hero - Set (Last created unit) Hero-level to 30, Show level-up graphics
Unit - Create 20 Rifleman for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
Unit - Create 1 Knight for Player 1 (Red) at (Position of Spirit Healer 0029 <gen>) facing Default building facing degrees
Unit - Set life of (Last created unit) to 1.00%
(I know this leaks a lot but I'm going to import this to other map, this is only sandbox map)
Where can be the problem be that GetLastCreatedUnit() references to the Knight who is created at 0.00 after map init but the footman from JASS is created 2 seconds after map init and is not referenced as GetLastCreatedUnit?
P.S.:I'm still learning JASS so even if this is obvious I didn't find it after 30 minutes of trying.
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetUnitLoc(gg_unit_H000_0029), bj_UNIT_FACING )
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 0.01)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_002, 2.00 )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
works properly, but
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call CreateUnit(Player(0), 'hfoo', GetUnitX( gg_unit_H000_0029), GetUnitY(gg_unit_H000_0029), 0)
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 0.01)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_002, 2.00 )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
Kills unit placed as last on my (GUI) trigger placing units at map init.(the unit is modified Knight 'h005' )
Even DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetLastCreatedUnit())) returns the other unit, also if i Set this unit into local variable it still says it's the last created unit before this one.
The spawn trigger is
spawn
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Unit - Create 1 Legionnaire for Player 1 (Red) at (Position of Spirit Healer 0029 <gen>) facing Default building facing degrees
Hero - Set (Last created unit) Hero-level to 30, Show level-up graphics
Unit - Create 20 Rifleman for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
Unit - Create 1 Knight for Player 1 (Red) at (Position of Spirit Healer 0029 <gen>) facing Default building facing degrees
Unit - Set life of (Last created unit) to 1.00%
(I know this leaks a lot but I'm going to import this to other map, this is only sandbox map)
Where can be the problem be that GetLastCreatedUnit() references to the Knight who is created at 0.00 after map init but the footman from JASS is created 2 seconds after map init and is not referenced as GetLastCreatedUnit?
P.S.:I'm still learning JASS so even if this is obvious I didn't find it after 30 minutes of trying.