- Joined
- Aug 9, 2015
- Messages
- 31
Hello,
The problem comes from my lack of knowledge regarding working with indexing, that is specifically, how to get a unit's index within an array(unit array) after setting it and clenase it, or if it is even necessary, as for my way of thinking, it is, because there is no other way to get a reference to it (in this particular situation)?
I want to create a script which would include these steps:
1. A unit is spawned from a dummy spell, it is set in an array
2. In another function(which triggers after a specific timer expires) the unit is removed.
The question is simple and perhaps be stupid, but for the weak scripter i am, this problem is truly a challange for me to solve, because the index is set during the game, not pre-emptively(since the start).
The problem comes from my lack of knowledge regarding working with indexing, that is specifically, how to get a unit's index within an array(unit array) after setting it and clenase it, or if it is even necessary, as for my way of thinking, it is, because there is no other way to get a reference to it (in this particular situation)?
I want to create a script which would include these steps:
1. A unit is spawned from a dummy spell, it is set in an array
2. In another function(which triggers after a specific timer expires) the unit is removed.
JASS:
function explosion takes nothing returns nothing
[S] local unit rocket = LoadUnitHandle(Rockets, p, 1)[/S]
local timer RocketTimer = GetExpiredTimer()
call UnitDamagePointLoc(rocket, 0, 100, GetUnitLoc(rocket), 20, ATTACK_TYPE_PIERCE,WEAPON_TYPE_AXE_MEDIUM_CHOP)
call CreateUnitAtLoc(GetOwningPlayer(rocket), 'hpea', GetUnitLoc(rocket), 270)
call RemoveUnit(rocket)
///Variable cleansing
[S] call FlushChildHandle(Rockets, GetHandleId(rocket))[/S]
call PauseTimer(RocketTimer)
call DestroyTimer(RocketTimer)
set RocketTimer = null
set rocket = null
endfunction
Events
A unit Begins channeling an ability
Conditions
Ability Being Cast Equal to Dommy
local unit rocket = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), 'hpea', OffsetLocation(GetUnitLoc(GetTriggerUnit()), 500.00, 0), GetUnitFacing(GetTriggerUnit()))
local timer RocketTimer = CreateTimer()
call TimerStart(RocketTimer, 1.5, false, function explosion)
call IssuePointOrderLoc(rocket, "move", PolarProjectionBJ(GetUnitLoc(rocket), 100.00, GetUnitFacing(rocket)))
call SetUnitFlyHeight(rocket, GetUnitFlyHeight(GetTriggerUnit()), 0)
call SetUnitFlyHeight(rocket, 0 , 1.5 / GetUnitFlyHeight(rocket))
[S]set Rockets[i] = rocket[/S]
The question is simple and perhaps be stupid, but for the weak scripter i am, this problem is truly a challange for me to solve, because the index is set during the game, not pre-emptively(since the start).
- There are other errors but these are suprisingly fixable for me.
Last edited: