• 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] Non-errorish script doesn't work

Status
Not open for further replies.

Oli

Oli

Level 3
Joined
Aug 9, 2015
Messages
33
Hello,
recently i've encountered some problems that i've fixed with the help of some that answered my last thread [[JASS] - Indexing]. Apparentely, the script just won't work even after fixing it.

JASS:
globals
    hashtable rocketHash
endglobals

function rocket_condition takes nothing returns boolean
    if (GetSpellAbilityId() == 'A000') then
        return true
    elseif (GetSpellAbilityId() == 'A001') then
        return true
    endif
        return false
endfunction

function explosion takes nothing returns nothing
    local timer RocketTimer = GetExpiredTimer()
    local unit rocket = LoadUnitHandle(rocketHash, GetHandleId(RocketTimer), 0)
    call UnitDamagePointLoc(rocket, 0, 100, GetUnitLoc(rocket), 20, ATTACK_TYPE_PIERCE,DAMAGE_TYPE_NORMAL)
    call CreateUnitAtLoc(GetOwningPlayer(rocket), 'hpea', GetUnitLoc(rocket), 270)
    call RemoveUnit(rocket)
///Variable cleansing
    call FlushChildHashtable(rocketHash, GetHandleId(RocketTimer))
    call PauseTimer(RocketTimer)
    call DestroyTimer(RocketTimer)
    set RocketTimer = null
    set rocket = null
endfunction

function rocket_action takes nothing returns nothing
    local unit rocket = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), 'hpea', OffsetLocation(GetUnitLoc(GetTriggerUnit()), 50.00, 0), GetUnitFacing(GetTriggerUnit()))
    local timer RocketTimer = CreateTimer()
    call SaveUnitHandle(rocketHash, GetHandleId(RocketTimer), 0, rocket)
    call TimerStart(RocketTimer, 1.5, false, function explosion)
    // the height
    call IssuePointOrderLocBJ( rocket, "move", PolarProjectionBJ(GetUnitLoc(rocket), 500.00, GetUnitFacing(rocket)) )
    call SetUnitFlyHeight(rocket, GetUnitFlyHeight(GetTriggerUnit()), 0)
    call SetUnitFlyHeight(rocket, 0 , 1.5 / GetUnitFlyHeight(rocket))
    // cleaning
    set RocketTimer = null
    set rocket = null
endfunction

//===========================================================================
function InitTrig_Rockets takes nothing returns nothing
    set gg_trg_Rockets = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Rockets, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
    call TriggerAddCondition(gg_trg_Rockets, Condition(function rocket_condition))
    call TriggerAddAction(gg_trg_Rockets, function rocket_action)
endfunction

(For those who helped me on the last thread - i've merged the two triggers together.)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Alright, if it's not channeling then it shouldn't be using the channeling event. Use this instead:
EVENT_PLAYER_UNIT_SPELL_EFFECT

And your Hashtable is never initialized:
vJASS:
globals
    hashtable rocketHash = InitHashtable()
endglobals

Lastly, you're leaking a lot of Points (locations). This won't prevent it from working but it's something to note.
 

Oli

Oli

Level 3
Joined
Aug 9, 2015
Messages
33
Alright, if it's not channeling then it shouldn't be using the channeling event. Use this instead:
EVENT_PLAYER_UNIT_SPELL_EFFECT

And your Hashtable is never initialized:
vJASS:
globals
    hashtable rocketHash = InitHashtable()
endglobals

Lastly, you're leaking a lot of Points (locations). This won't prevent it from working but it's something to note.
Thank you, seems to work. Seems like making a temp loc or temp point local and cleansing it afterwards will remove the leaks?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
If a function can use a Point (Location) then there's also a version that can use x/y coordinates:
vJASS:
local real x = GetUnitX(someUnit)
local real y = GetUnitY(someUnit)
call CreateUnit(Player(0), 'hpea', x, y, 270)
vJASS:
local real x = GetLocationX(someLoc)
local real y = GetLocationY(someLoc)
call CreateUnit(Player(0), 'hpea', x, y, 270)
You can get the X/Y of a Unit/Location/Special Effect/Region, etc...
 
Status
Not open for further replies.
Top