So ehm, I was trying to create a random spell that I made a while ago in GUI, although in GUI I couldn't make it MUI, so now like about a half year later of not having worked with world editor, I decided to start working on my old map again, but now with JASS since I already got to knew the basics and a bit more and stuff.
So the spell I was trying to recreate was a single target spell, based of Soul Burn. Basicly, all it does is place a buff on a target unit. If this unit dies while under the effect of the buff, it'll explode and deal aoe damage equal to a certain % of it's maximum hp.
The idea I had in mind was that it would just create a funky looking special effect at the point of the target, basicly just a over-the-top buff animation, and while creating that every .5 second, it would check if the unit still had the buff, and if it was dead or alive. So the code I made is this:
So as you might guess, it just doesn't work. Now I'm not the brightest person when it comes to JASS and scripting, so I just tried to toy around with the functions, but it never changed and just did what it did in the first place, which is absolutely nothing. After a while I decided to check if the handle var system was working properly, by adding these lines at the start, before the timer even starts:
If you're too lazy to read the entire field of text: basicly they should give me the same number, however, the first one (direct use of the H2I function) gave me a 6 or 7 digit number (can't remember, see uploaded screenshot below), yet the 2nd (from the gamecache) just gave me a 0:
Basicly I have no idea what's wrong with it, but I'm probably just missing something small, which usually is my problem, so I was hoping if anyone could help me with it, it would be much appreciated =].
P.S.: Yes I made a gamecache variable for the handle vars, and the names match (that was my initial thought that might be wrong).
And all the integer codes in the configuration section are also right, I double or tripple checked those already :s.
So the spell I was trying to recreate was a single target spell, based of Soul Burn. Basicly, all it does is place a buff on a target unit. If this unit dies while under the effect of the buff, it'll explode and deal aoe damage equal to a certain % of it's maximum hp.
The idea I had in mind was that it would just create a funky looking special effect at the point of the target, basicly just a over-the-top buff animation, and while creating that every .5 second, it would check if the unit still had the buff, and if it was dead or alive. So the code I made is this:
JASS:
//Start configuration
function SpellID takes nothing returns integer
return 'A000' //Integer code of casting ability
endfunction
function DummyID takes nothing returns integer
return 'h000' //Integer code of dummy unit
endfunction
function DumAbilID takes nothing returns integer
return 'A002' //Integer code of dummy ability (ability does not deal damage, it's just for eyecandy)
endfunction
function BuffID takes nothing returns integer
return 'BNso' //Integer code of ability buff
endfunction
function ExploRad takes nothing returns real
return 400. //Real number of explosion radius
endfunction
function DmgBase takes nothing returns real
return 20. //Real number of base explosion damage in percent
endfunction
function DmgIncrement takes nothing returns real
return 1. //Real number of explosion damage increment per level in percent
endfunction
//End configuration
function Trig_Mark_of_Torment_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellID()
endfunction
function BuffAnim takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t, "Targ")
local effect e
local integer a = 1
local player p = GetHandlePlayer(t, "Player")
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real x2
local real y2
local unit array dums
call BJDebugMsg(I2S(GetUnitAbilityLevel(u, BuffID())))
if (GetUnitAbilityLevel(u, BuffID()) > 0) then
if GetUnitState(u, UNIT_STATE_LIFE) > 0 then
set e = AddSpecialEffectLoc("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl", Location(x, y))
call DestroyEffect(e)
set e = null
elseif GetUnitState(u, UNIT_STATE_LIFE) <= 0 then
loop
exitwhen a >= 5
set dums[a] = CreateUnit(p, DummyID(), x, y, 0.)
set x2 = x + ExploRad() * Cos((360 / 5) * a * bj_DEGTORAD)
set y2 = y + ExploRad() * Sin((360 / 5) * a * bj_DEGTORAD)
call UnitAddAbility(dums[a], DumAbilID())
call IssuePointOrderLoc(dums[a], "breathoffire", Location(x2, y2))
call UnitApplyTimedLife(dums[a], 'BTLF', 2.)
set a = a+1
endloop
call UnitDamagePoint(GetTriggerUnit(), 0., ExploRad(), x, y, GetUnitState(u, UNIT_STATE_LIFE)/100 * (DmgBase()+(DmgIncrement()*(GetUnitAbilityLevel(GetTriggerUnit(), SpellID())) ) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
set u = null
set p = null
set dums[1] = null
set dums[2] = null
set dums[3] = null
set dums[4] = null
set dums[5] = null
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
return
endif
elseif not (GetUnitAbilityLevel(u, BuffID()) > 0) then
set u = null
set e = null
set p = null
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
endif
endfunction
function Trig_Mark_of_Torment_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit u = GetSpellTargetUnit()
local player p = GetOwningPlayer(GetTriggerUnit())
call SetHandleHandle(t, "Targ", u)
//== Testing Handle Vars ==\\
call BJDebugMsg(I2S(H2I(u)))
call BJDebugMsg(I2S(GetStoredInteger(LocalVars(), I2S(H2I(t)), "Targ")))
//== Testing handle Vars ==\\
call SetHandleHandle(t, "Player", p)
call TimerStart(t, 0.5, true, function BuffAnim)
set t = null
endfunction
//===========================================================================
function InitTrig_Mark_of_Torment takes nothing returns nothing
set gg_trg_Mark_of_Torment = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Mark_of_Torment, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Mark_of_Torment, Condition( function Trig_Mark_of_Torment_Conditions ) )
call TriggerAddAction( gg_trg_Mark_of_Torment, function Trig_Mark_of_Torment_Actions )
endfunction
So as you might guess, it just doesn't work. Now I'm not the brightest person when it comes to JASS and scripting, so I just tried to toy around with the functions, but it never changed and just did what it did in the first place, which is absolutely nothing. After a while I decided to check if the handle var system was working properly, by adding these lines at the start, before the timer even starts:
JASS:
//== Testing Handle Vars ==\\
call BJDebugMsg(I2S(H2I(u)))
call BJDebugMsg(I2S(GetStoredInteger(LocalVars(), I2S(H2I(t)), "Targ")))
//== Testing handle Vars ==\\
If you're too lazy to read the entire field of text: basicly they should give me the same number, however, the first one (direct use of the H2I function) gave me a 6 or 7 digit number (can't remember, see uploaded screenshot below), yet the 2nd (from the gamecache) just gave me a 0:

Basicly I have no idea what's wrong with it, but I'm probably just missing something small, which usually is my problem, so I was hoping if anyone could help me with it, it would be much appreciated =].
P.S.: Yes I made a gamecache variable for the handle vars, and the names match (that was my initial thought that might be wrong).
And all the integer codes in the configuration section are also right, I double or tripple checked those already :s.