- Joined
- Feb 22, 2006
- Messages
- 960
So actually i'm learning vJass, this is my first spell i redid in vjass
Reworked somthing >.<
JASS:
struct lifestruc
unit caster
unit target
real duration
integer durationtimer
real interval
real damage
endstruct
function wait_cond takes nothing returns boolean
return (UnitHasBuffBJ(GetSpellTargetUnit(),'B001') == true)
endfunction
function LR_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function execute_lr takes nothing returns nothing
local timer t = GetExpiredTimer()
local lifestruc dat
local real lifecaster
local real lifetarget
local real lifedrain
local real lifeafter
set lifetarget = GetUnitState(dat.target,UNIT_STATE_LIFE)
call UnitDamageTarget(dat.caster,dat.target,dat.damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set lifeafter = GetUnitState(dat.target,UNIT_STATE_LIFE)
set lifedrain = lifetarget - lifeafter
set lifecaster = GetUnitState(dat.caster,UNIT_STATE_LIFE)
call SetUnitState(dat.caster,UNIT_STATE_LIFE,lifecaster+lifedrain)
if (dat.durationtimer <= 1) then
call FlushHandleLocals(t)
call DestroyTimer(t)
call lifestruc.destroy(dat)
set t = null
return
endif
set dat.durationtimer = dat.durationtimer - 1
endfunction
function LR_Actions takes nothing returns nothing
local lifestruc dat = lifestruc.create()
local timer t = CreateTimer()
set dat.caster = GetTriggerUnit()
set dat.target = GetSpellTargetUnit()
set dat.duration = 8.00
set dat.interval = 0.035
set dat.durationtimer = R2I(dat.duration/dat.interval)
set dat.damage = ((GetUnitAbilityLevelSwapped('A000', dat.caster)*50)+70)/(dat.durationtimer)
loop
exitwhen (wait_cond())
call TriggerSleepAction(0.26)
endloop
call TimerStart(t,dat.interval,true,function execute_lr)
endfunction
function InitTrig_Life_Rune takes nothing returns nothing
local trigger lr = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(lr,EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(lr, Condition(function LR_Conditions))
call TriggerAddAction(lr, function LR_Actions)
set lr = null
endfunction
Reworked somthing >.<
Last edited: