- Joined
- Jul 29, 2007
- Messages
- 5,174
I would have done it this way, it seems more effective to me, of course you don't have to use it or like it ^^
JASS:
function Trig_NewTrigger_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Trig_NewTrigger_Actions takes nothing returns nothing
local unit whichUnit = GetTriggerUnit()
local real a = GetUnitFacing(whichUnit) * bj_DEGTORAD
local location l = GetSpellTargetLoc()
local real x = GetLocationX(l) - 1550 * Cos(a)
local real y = GetLocationY(l) - 1550 * Sin(a)
local unit bomber = CreateUnit(GetOwningPlayer(whichUnit), 'h002', x , y, GetUnitFacing())
local real orderx = GetLocationX(l) + 10000 * Cos(a)
local real ordery = GetLocationY(l) + 10000 * Sin(a)
local real unitspeed = GetUnitMoveSpeed(bomber)
local integer i = 0
local unit bomb
local real bombx
local real bomby
call UnitApplyTimedLife(bomber, 'BTLF', 15)
call IssuePointOrder( bomber, "move", orderx, ordery)
call TriggerSleepAction(unitspeed/1300)
loop
exitwhen i > 6
set bombx = GetUnitX(bomber)
set bomby = GetUnitY(bomber)
set bomb = CreateUnit(GetOwningPlayer(whichUnit), 'h003', bombx, bomby, 0) // angle doesn't matter since the bomb is pointing down
call goingdown(bomb,10) // check my script below, 10 is actualy 50 per second because its number/0.02.
set bomb = null
set i = i+1
call TriggerSleepAction(0.3)
endloop
set whichUnit = null
call RemoveLocation(l)
set l = null
set bomber = null
endfunction
//==== Init Trigger NewTrigger ====
function InitTrig_NewTrigger takes nothing returns nothing
set gg_trg_NewTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_NewTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(gg_trg_NewTrigger, Condition(function Trig_NewTrigger_Conditions))
call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction
JASS:
//****************************************************************************************
// Move unit's height with timers
// Usage: call goingdown(whichUnit,speed)
//
// PUT ME IN YOUR HEADER
//
// This "system" just moves a unit height with timers (similiar to normal movement with timers but with height instead of x,y)
//
function goingdowntimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit whichUnit = GetHandleUnit(t, "whichUnit")
local real speed = GetHandleReal(t, "speed")
local real z = GetHandleReal(t, "z")
local real whichUnitHeight = GetUnitFlyHeight(whichUnit)
if whichUnitHeight > z+speed then
call SetUnitFlyHeight(whichUnit, whichUnitHeight-speed, 20000)
else
call FlushHandleLocals(t)
call DestroyTimer(t)
call KillUnit(whichUnit)
endif
set t = null
set whichUnit = null
endfunction
function goingdown takes unit whichUnit, real speed returns nothing
local timer t = CreateTimer()
local real x = GetUnitX(whichUnit)
local real y = GetUnitY(whichUnit)
local location whichUnitLocation = Location(x,y)
local real z = GetLocationZ(whichUnitLocation)
call SetHandleHandle(t, "whichUnit", whichUnit)
call SetHandleReal(t, "speed", speed)
call SetHandleReal(t, "z", z)
call TimerStart(t, 0.02, true, function goingdowntimer)
set t = null
set whichUnitLocation = null
endfunction