• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Why won't it recognise when the ability is used?!!??

Status
Not open for further replies.
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... :(
 
Level 6
Joined
Mar 20, 2008
Messages
208
The very first line of your code in the actions should have

call DisplayTextToPlayer(Player(0),0,0,"found")
//Player 0 is red, so pop in whatever player you are using

That will tell you if its not recognizing the ability.

Further, if that is the case, I suggest you just do

JASS:
function GoblinRemoteBombs_Conditions takes nothing returns boolean    
return GetSpellAbilityId() == 'A000' 
endfunction

and see if that helps any
 
alright, I've gotten it to sort of work, but now It's lagfest and only moves one unit. WHAT AM I DOIN WRONG!!! :cry:
JASS:
globals
constant integer GoblinRemoteBombsSpellID = 'A000'
constant integer GoblinRemoteBombsDummyID = 'h000'
constant real GoblinRemoteBombs_Accuracy = 200.
constant real GoblinRemoteBombs_Curve = 1.
constant real GoblinRemoteBombs_Speed = .01
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 height
local location Start = Location(StartX, StartY)
local location current
local location current1
local location target
    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 current = GetUnitLoc(u)
    set target = Location(TargetX, TargetY)
    set facing = AngleBetweenPoints(current, target)
    set current1 = PolarProjectionBJ(current, GoblinRemoteBombs_Speed, facing)
    call SetUnitX(u, GetLocationX(current1))
    call SetUnitY(u, GetLocationY(current1))
    set dist = DistanceBetweenPoints(current1, Start)
    set height = JumpParabola(dist, distmax, GoblinRemoteBombs_Curve)
    call SetUnitFlyHeight(u, height, 1000.)
    set u = null
    call RemoveLocation(current)
    call RemoveLocation(current1)
    set current = null
    set current1 = null
    endloop
call RemoveLocation(Start)
set Start = null
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 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 )
    set t = null
endfunction
 
Status
Not open for further replies.
Top