Hi there i have just started playing with jass again havent done mutch b4 i created 2 spells i happy with one of em but the other dosent look 100% the way i want to to how do i place the start of the lightning at the middle(heigth) of the units?
my code:
note this is my second spell so if there is any thing else wrong pls tell me!!!
if you got a good idear how to make the lightning look a bit better at the start and end pls tell me
Tnx alog!!
my code:
JASS:
function Trig_Mana_Deflector_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetAttackedUnitBJ(), 'B00M')
endfunction
function DeflectorDoDamage takes nothing returns nothing
local timer t = GetExpiredTimer()
local real damage = GetHandleReal(t, "damage")
local unit caster = GetHandleUnit(t, "caster")
local unit enemy = GetHandleUnit(t, "enemy")
local integer i = GetHandleInt(t, "i")
local lightning li
if (i == 0) then
set li = AddLightning("CHIM",true, GetUnitX(caster), GetUnitY(caster), GetUnitX(enemy), GetUnitY(enemy))
call UnitDamageTarget(caster, enemy, damage, true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
call SetHandleHandle(t, "li", li)
elseif (i == 5) then
set li = GetHandleLightning(t, "li")
call DestroyLightning(li)
call FlushHandleLocals(t)
call PauseTimer(t)
call DestroyTimer(t)
set t = null
else
set li = GetHandleLightning(t, "li")
call MoveLightning(li, true, GetUnitX(caster), GetUnitY(caster), GetUnitX(enemy), GetUnitY(enemy))
endif
set i = i + 1
call SetHandleInt(t, "i", i)
set t = null
set caster = null
set enemy = null
set li = null
endfunction
function Trig_Mana_Deflector_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetAttackedUnitBJ()
local unit enemy = GetAttacker()
local integer heroLevel = GetHeroLevel(caster)
local integer spellLevel = GetUnitAbilityLevel(caster, 'A03G')
local real damage = heroLevel * 10 + 25.0 * spellLevel
call SetHandleHandle(t, "caster", caster)
call SetHandleHandle(t, "enemy", enemy)
call SetHandleReal(t, "damage", damage)
call SetHandleInt(t, "i", 0)
call TimerStart(t, 0.10, true, function DeflectorDoDamage)
endfunction
//===========================================================================
function InitTrig_Mana_Deflector takes nothing returns nothing
set gg_trg_Mana_Deflector = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Mana_Deflector, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Mana_Deflector, Condition( function Trig_Mana_Deflector_Conditions ) )
call TriggerAddAction( gg_trg_Mana_Deflector, function Trig_Mana_Deflector_Actions )
endfunction
note this is my second spell so if there is any thing else wrong pls tell me!!!
if you got a good idear how to make the lightning look a bit better at the start and end pls tell me
Tnx alog!!