I came across this thread http://www.thehelper.net/forums/showthread.php?t=115492&page=2 with a post including a jass script for a passive spell. The spell basically reduces damage by a percentage if the unit has a passive spell learned.
I've been trying to figure out how to convert this to a self-cast buff with a short duration. After skimming through all the code I understand how it works but I'm not familiar with all the functions in jass, yet. Would anyone be willing to explain how to change this to a self-cast spell?
I've sent a PM to the kenny!, but I was hoping for a quick response so I'm posting my question here.
JASS:scope ShieldWall initializer Init globals private constant integer Abil_id = 039;----039; // Raw code of the passive ability. private constant string Sfx = "Your\\effect\\here." // May want an effect to Play private constant string Point = "chest" // Probably the best place for an attachment point. endglobals private function Percent takes integer lvl returns real return 0.20*lvl // Percentage of damaged healed. So 100 damage dealt would only be 80/60/40. endfunction private function Chance takes integer lvl returns integer return 10+(5*lvl) // Percent chance to absorb damage. endfunction private function Heal takes nothing returns boolean local unit cast = GetTriggerUnit() local real dam = GetEventDamage() local integer lvl = GetUnitAbilityLevel(cast,Abil_id) if (dam > 1) then if (GetRandomInt(1,100) <= Chance(lvl)) then call SetWidgetLife(cast,GetWidgetLife(cast)+(dam*Percent(lvl))) call DestroyEffect(AddSpecialEffectTarget(Sfx,cast,Point)) endif endif set cast = null return false endfunction private function Actions takes nothing returns nothing local unit cast = GetTriggerUnit() local trigger trig if GetUnitAbilityLevel(cast,Abil_id) == 1 then set trig = CreateTrigger() call TriggerRegisterUnitEvent(trig,cast,EVENT_UNIT_DAMAGED) call TriggerAddCondition(trig,Condition(function Heal)) endif set cast = null endfunction private function Conditions takes nothing returns boolean return GetLearnedSkill() == Abil_id and IsUnitIllusion(GetTriggerUnit()) == false endfunction private function Init takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_HERO_SKILL) call TriggerAddCondition(trig,Condition(function Conditions)) call TriggerAddAction(trig,function Actions) endfunction endscope
I've been trying to figure out how to convert this to a self-cast buff with a short duration. After skimming through all the code I understand how it works but I'm not familiar with all the functions in jass, yet. Would anyone be willing to explain how to change this to a self-cast spell?
I've sent a PM to the kenny!, but I was hoping for a quick response so I'm posting my question here.