Когда герой наносит электрический урон тогда увеличиться шанс нанести в 2 рази больше урона
Код спелла
scope ElectricGrapple initializer I
globals
private constant integer RAWCODE = 'A000' //~The rawcode of the spell
private constant integer LIGHTNINGCODE = 'A004' //~The rawcode of the chain lightning spell
private constant integer DUMMYID = 'h001' //~The rawcode of the dummy who casts the chain lightning
private constant real DURATION = 1 //~The duration of pulling
endglobals
private constant function ChancePerLvl takes integer lvl returns integer
return ( lvl * 5 ) + 10 //~The Chance is here
endfunction
private constant function Damage takes real lvl returns real
return GetEventDamage() * lvl
endfunction
//=======================DO NOT TOUCH==============================\\
private function Conditions takes nothing returns boolean
return GetUnitTypeId(GetEventDamageSource()) != DUMMYID and GetRandomInt(1,100)<=ChancePerLvl(GetUnitAbilityLevel(GetEventDamageSource(),RAWCODE))
endfunction
private function Actions takes nothing returns nothing
local real r
local unit c
local unit d = GetEventDamageSource()
local unit u = GetTriggerUnit()
local real dx = GetUnitX(u) - GetUnitX(d)
local real dy = GetUnitY(u) - GetUnitY(d)
local real dist = SquareRoot(dx * dx + dy * dy)-100
local real angle = Atan2(GetUnitY(d)-GetUnitY(u),GetUnitX(d)-GetUnitX(u))
local texttag t = CreateTextTag()
if IsUnitType(u,UNIT_TYPE_STRUCTURE)==false then
if GetUnitAbilityLevel(d,RAWCODE)>0 then
set c = CreateUnit(GetOwningPlayer(d),DUMMYID,GetUnitX(d),GetUnitY(d),GetUnitFacing(d))
set r = GetEventDamage()+Damage(GetUnitAbilityLevel(d,RAWCODE))
call Knockback(u,dist,angle,DURATION)
call UnitAddAbility(c,'Amrf')
call UnitRemoveAbility(c,'Amrf')
call SetUnitFlyHeight(c,GetUnitFlyHeight(d),0)
call UnitAddAbility(c,LIGHTNINGCODE)
call IssueTargetOrder(c,"fingerofdeath",u)
call UnitDamageTarget(c,u,Damage(GetUnitAbilityLevel(d,RAWCODE)),true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call SetTextTagText(t,"|cffff0000"+I2S(R2I®)+"!|r", 0.023)
call SetTextTagPos(t,GetUnitX(d),GetUnitY(d),GetUnitFlyHeight(d))
call SetTextTagColor(t,255,255,255,255)
call SetTextTagFadepoint(t,3)
call SetTextTagPermanent(t,false)
call SetTextTagVelocity(t,0,0.0455)
call SetTextTagLifespan(t,4)
call SetTextTagVisibility(t,true)
endif
endif
set u = null
set d = null
set t = null
endfunction
private function I takes nothing returns nothing
local trigger g=CreateTrigger()
call Damage_RegisterEvent(g)
call TriggerAddCondition(g,Condition(function Conditions))
call TriggerAddAction(g,function Actions)
endfunction
endscope