- Joined
- Dec 11, 2007
- Messages
- 755
JASS:
globals
constant integer GoblinRemoteBombsSpellID = 'A000'
constant integer GoblinRemoteBombsDummyID = 'h000'
constant real GoblinRemoteBombs_Accuracy = 200.
constant real GoblinRemoteBombs_Curve = 1.
constant real GoblinRemoteBombs_Speed = 5.
endglobals
function Level_GoblinRemoteBombs takes integer level returns integer
local integer a
//------------------------------------------------------------------
if level == 1 then
set a = 5
endif
//^level 1^
if level == 2 then
set a = 8
endif
//^level 2^
if level == 3 then
set a = 11
endif
//^level 3^
return a
endfunction
function GoblinRemoteBombs_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == GoblinRemoteBombsSpellID ) ) then
return false
endif
return true
endfunction
function Move_GoblinRemoteBombs takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer level = GetHandleInt(t, "level")
local integer maxunits = GetHandleInt(t, "maxunits")
local real StartX = GetHandleReal(t, "startx")
local real StartY = GetHandleReal(t, "starty")
local integer n_loop = 1
local unit u
local real distmax
local real TargetX
local real TargetY
local real facing
local real dist
local real x
local real y
local real x1
local real y1
local real height
loop
exitwhen n_loop > maxunits
set u = GetHandleUnit(t, (I2S(n_loop) + "_unit"))
set TargetX = GetHandleReal(t, (I2S(n_loop) + "_targetx"))
set TargetY = GetHandleReal(t, (I2S(n_loop) + "_targety"))
set distmax = GetHandleReal(t,(I2S(n_loop) + "_distmax"))
set x = GetUnitX(u)
set y = GetUnitY(u)
set y1 = Sin( Deg2Rad(GetUnitFacing(u)))*GoblinRemoteBombs_Speed
set x1 = Cos( Deg2Rad(GetUnitFacing(u)))*GoblinRemoteBombs_Speed
call SetUnitX(u, x + x1)
call SetUnitY(u, y + y1)
set x = (x - StartX)
set y = (y - StartY)
set dist = SquareRoot( (x*x) + (y*y))
set height = JumpParabola(dist, distmax, GoblinRemoteBombs_Curve)
call SetUnitFlyHeight(u, height, 1000.)
set u = null
endloop
endfunction
function Cast_GoblinRemoteBombs takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetSpellAbilityUnit()
local location target = GetSpellTargetLoc()
local player Owner = GetOwningPlayer(caster)
local location p
local location cast = GetUnitLoc(caster)
local integer level = GetUnitAbilityLevel(caster, GoblinRemoteBombsSpellID)
local integer n_loop = 1
local integer maxloop = Level_GoblinRemoteBombs(level)
local unit u
local real x = GetLocationX(target)
local real y = GetLocationY(target)
local real StartX = GetLocationX(cast)
local real StartY = GetLocationY(cast)
local real x1
local real y1
local real TargetX
local real TargetY
local real distX
local real distY
local real distmax
local real facing
call SetHandleInt(t, "level", level)
call SetHandleInt(t, "maxunits", maxloop)
call SetHandleReal(t, "startx", StartX)
call SetHandleReal(t, "starty", StartY)
loop
exitwhen n_loop > maxloop
set x1 = GetRandomReal( 0 - (GoblinRemoteBombs_Accuracy), GoblinRemoteBombs_Accuracy)
set y1 = GetRandomReal( 0 - (GoblinRemoteBombs_Accuracy), GoblinRemoteBombs_Accuracy)
set TargetX = x + x1
set TargetY = y + y1
set p = Location( TargetX, TargetX)
set distX = GetLocationX(p) - x
set distY = GetLocationY(p) - y
set distmax = SquareRoot((distX * distX)+(distY * distY))
set facing = AngleBetweenPoints(cast, p)
set u = CreateUnitAtLoc(Owner, GoblinRemoteBombsDummyID, cast, facing)
call SetHandleHandle(t, (I2S(n_loop) + "_unit"), u)
call SetHandleReal(t, (I2S(n_loop) + "_targetx"), TargetX)
call SetHandleReal(t, (I2S(n_loop) + "_targety"), TargetY)
call SetHandleReal(t, (I2S(n_loop) + "_distmax"), distmax)
set n_loop = n_loop + 1
call RemoveLocation(p)
set u = null
set p = null
endloop
call TimerStart(t, 0.35, true, function Move_GoblinRemoteBombs)
call TriggerSleepAction(.5)
call FlushHandleLocals(t)
call RemoveLocation(cast)
call RemoveLocation(target)
set caster = null
set cast = null
set target = null
endfunction
function InitTrig_GoblinRemoteBombs takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( t, function Cast_GoblinRemoteBombs )
endfunction
So, why won't it recognise when the ability is used???!!!
I don't know what I'm doing wrong, and I know that this spell is prolly really inefficient, but I'm trying to use KaTTana's thingy...
Edit: O yah, I'm only about 1/2 done with the coding, but it seemed like enough so I could see the bombs move to their destination...