well, i decided to learn vJass. Im doing some practice by converting my old gui spells into vJass.
thats the spell. basically, its proc chance increases with every missing hp and although it's a passive spell, it has 25 sec internal cooldown. It means it can proc only once every 25 sec. btw these "type: attack" and "modifiers" things are about my own attribute system. thats not necessary here, ignore it please.
I'm using Damage-Event-AIDS, Caster System, TimerUtils, GroupUtils.
thats the code:
(It's indented now.)
I'm stuck on making internal cooldown and buff ends(by the modifiers, buff duration is dynamic).
1. how to fix it?
2. how to make leakless and multi-doable this code?
3. is there anyway to optimize it? Because it looks very mess to me.
Thanks anyway.
thats the spell. basically, its proc chance increases with every missing hp and although it's a passive spell, it has 25 sec internal cooldown. It means it can proc only once every 25 sec. btw these "type: attack" and "modifiers" things are about my own attribute system. thats not necessary here, ignore it please.
I'm using Damage-Event-AIDS, Caster System, TimerUtils, GroupUtils.
thats the code:
JASS:
scope Thirst initializer Starter
////////////////////////////////////////////////////////////////////////////////////////////
globals
private constant integer SPELL_ID = 039;A02H039;
private timer cooldown
private timer duration
private trigger ta
private trigger tb
private trigger tc
private real durationr = 8.00 + ( I2R(GetHeroStr(GetEventDamageSource(), true)) * 0.05 )
private integer cooldownr = 0
endglobals
////////////////////////////////////////////////////////////////////////////////////////////
private function Actions takes nothing returns nothing
local integer level = GetUnitAbilityLevel(GetEventDamageSource(), SPELL_ID )
local integer roll = R2I(( ( ( GetUnitState(GetEventDamageSource(), UNIT_STATE_MAX_LIFE) - GetUnitState(GetEventDamageSource(), UNIT_STATE_LIFE) ) * 100.00 ) / GetUnitState(GetEventDamageSource(), UNIT_STATE_MAX_LIFE) ))
local integer random = GetRandomInt(1, 100)
if ( random <= roll ) and ( GetUnitTypeId(GetEventDamageSource()) == 039;U001039; ) and (level>0) and (cooldownr==0) then
call DisplayTimedTextToPlayer(GetOwningPlayer(GetEventDamageSource()),0,0,60,"test message")
call CasterCastAbilityLevel( GetOwningPlayer(GetEventDamageSource()), 039;A035039;, level, "unholyfrenzy", GetEventDamageSource(), true)
call TimerStart(cooldown, 25.00, false, null)
call TimerStart( duration, durationr, false, null )
call TriggerSleepAction(durationr)
call UnitRemoveAbility(GetEventDamageSource(), 039;B006039;)
set cooldownr = 25
set cooldown=NewTimer()
call SetTimerData(cooldown, cooldownr)
endif
endfunction
private function Cooldown takes nothing returns nothing
call EnableTrigger( ta )
endfunction
private function Duration takes nothing returns nothing
call UnitRemoveAbility(GetEventDamageSource(), 039;B006039;)
endfunction
////////////////////////////////////////////////////////////////////////////////////////////
private function Starter takes nothing returns nothing
set ta=CreateTrigger()
call TriggerAddAction(ta,function Actions)
call Damage_RegisterEvent(ta)
set tb=CreateTrigger()
call TriggerAddAction(tb,function Cooldown)
call TriggerRegisterTimerExpireEvent( tb, cooldown )
set tc=CreateTrigger()
call TriggerAddAction(tc,function Duration)
call TriggerRegisterTimerExpireEvent( tc, duration )
endfunction
endscope
(It's indented now.)
I'm stuck on making internal cooldown and buff ends(by the modifiers, buff duration is dynamic).
1. how to fix it?
2. how to make leakless and multi-doable this code?
3. is there anyway to optimize it? Because it looks very mess to me.
Thanks anyway.