Quick summary about my experience: I've used GUI for years, but wanted to improve myself so I've learnt about the details of hashtables yesterday and then started with JASS just this morning, so sorry for any noobish mistakes.
About the spell: When beginning casting nothing happens for 3 seconds (channeling phase), then a lightning bolt strikes, damaging the area for a damage amount depending on the intelligence of the caster.
Since I want to make it MUI I've used hashtables now for the first time but have no clue if they work as intended.
However, there are two strange occurences when casting:
Thanks in advance!
About the spell: When beginning casting nothing happens for 3 seconds (channeling phase), then a lightning bolt strikes, damaging the area for a damage amount depending on the intelligence of the caster.
Since I want to make it MUI I've used hashtables now for the first time but have no clue if they work as intended.
However, there are two strange occurences when casting:
- When casting the spell for the first time, everything works as intended besides no bounty is received if a hostile unit is killed by the spell (even though bounty usually works).
- When casting the spell another time, nothing seems to work after the first part (the timer initialization) - I'm not sure what I've damaged, maybe when trying to clean up memory leaks?
Thanks in advance!
JASS:
constant function Lightstrike_ID takes nothing returns integer
return 'A03J'
endfunction
function Trig_LightningStrikeJASS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Lightstrike_ID()
endfunction
function actual_spell takes nothing returns nothing
local location targetloc
local unit caster
local unit dummy
local location casterloc
local player casterowner
local integer playerid
local real defface = 0.
local integer spelllevel
local integer inthero
local real spelldamage
set targetloc = LoadLocationHandleBJ(0, GetHandleIdBJ(GetEnumUnit()), udg_hasht1)
set caster = LoadUnitHandleBJ(1, GetHandleIdBJ(GetEnumUnit()), udg_hasht1)
set casterloc = GetUnitLoc(caster)
set casterowner = GetOwningPlayer(caster)
set playerid = GetPlayerId(casterowner)
set defface = 0.
set spelllevel = GetUnitAbilityLevel(caster,Lightstrike_ID)
set inthero = GetHeroInt(caster,true)
set spelldamage = inthero * (5 + spelllevel)
call CreateUnitAtLoc(casterowner, 'h00I', casterloc, defface)
set dummy = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy)
call UnitDamagePointLoc( dummy, 0.3, 30.00, targetloc, spelldamage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call AddSpecialEffectLocBJ( targetloc, "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" )
call DestroyEffectBJ(bj_lastCreatedEffect)
call RemoveLocation (targetloc)
call RemoveLocation (casterloc)
call FlushChildHashtableBJ(GetHandleIdBJ(GetEnumUnit()), udg_hasht1)
call GroupRemoveUnit(udg_lightningstrikegroup,GetEnumUnit())
set caster = null
set dummy = null
set casterowner = null
endfunction
function spell_init takes nothing returns nothing
local timer t=GetExpiredTimer()
call PauseTimer(t)
call DestroyTimer(t)
set t=null
call ForGroup(udg_lightningstrikegroup, function actual_spell)
endfunction
function Trig_LightningStrikeJASS_Actions takes nothing returns nothing
local timer t
local location targetloc = GetSpellTargetLoc()
local unit caster = GetSpellAbilityUnit()
call GroupAddUnit(udg_lightningstrikegroup,caster)
call SaveLocationHandleBJ(targetloc,0,GetHandleId(caster),udg_hasht1)
call SaveUnitHandleBJ(caster,1,GetHandleId(caster),udg_hasht1)
call CreateTimer()
set t = GetLastCreatedTimerBJ()
call TimerStart(t, 3.00, false, function spell_init)
set t = null
endfunction
//===========================================================================
function InitTrig_LightningStrikeJASS takes nothing returns nothing
set gg_trg_LightningStrikeJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_LightningStrikeJASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_LightningStrikeJASS, Condition( function Trig_LightningStrikeJASS_Conditions ) )
call TriggerAddAction( gg_trg_LightningStrikeJASS, function Trig_LightningStrikeJASS_Actions )
endfunction