Name | Type | is_array | initial_value |
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
// creates text tag for the spell name and damage
function CreateTextTagShort takes string color, string txt, real x, real y, real z, real size returns nothing
local integer i = 0
local texttag t = CreateTextTag()
call SetTextTagText(t, color + txt + "|r", size)
call SetTextTagPos(t, x, y, z)
call SetTextTagColor(t, 255, 255, 255, 255)
call SetTextTagLifespan(t, 4.0)
call SetTextTagFadepoint(t, 3.0)
call SetTextTagPermanent(t, false)
call SetTextTagVelocityBJ(t, 64, 90)
call SetTextTagVisibility(t, false)
loop
if IsVisibleToPlayer(x, y, Player(i)) then
call SetTextTagVisibility(t, true)
endif
set i = i + 1
exitwhen i == 8
endloop
set t = null
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//calulates the distance between to points
function DistanceBetweenPointsShort takes real dx, real dy returns real
return SquareRoot(dx * dx + dy * dy)
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//Spell Raw code (this maybe be different in your map)
function GoofyRock_RAW takes nothing returns integer
return 'A000'
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//checks if the ability being cast is Goofy Rock, if its noot Goofy Rock trigger won't fire
function GoofyRock_Cond takes nothing returns boolean
return GetSpellAbilityId() == GoofyRock_RAW()
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//Gets the level of the Goofy Rock ability and uses it for calculations later
function GoofyRock_Level takes nothing returns integer
return GetUnitAbilityLevel(GetTriggerUnit(), GoofyRock_RAW())
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
//the above function is used to determen the damage of the spell for each level
function GoofyRock_Damage takes nothing returns real
return 125.0 * GoofyRock_Level() - 25
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
function GoofyRock_Main takes nothing returns nothing
local integer i = GetRandomInt(0, 2)//33 % chance for 0, 1 and 2
local real r
local real t
local unit u = GetTriggerUnit()
local unit uu = GetSpellTargetUnit()
//|cffCCBBA1 is the text tag color //0.020 is the size of the text tag note that 0.025 is a lot bigger
call CreateTextTagShort("|cffCCBBA1", "Goofy Rock", GetUnitX(u), GetUnitY(u), 0, 0.020)
set r = DistanceBetweenPointsShort(GetUnitX(uu) - GetUnitX(u), GetUnitY(uu) - GetUnitY(u))
set t = r / 1000.0 //if the distance is 600 then r = 0.6 (1000 is the spell misile speed)
if (i == 0) then // the double damage case GetRandomInt(0, 2) - 0
call TriggerSleepAction(t)
call CreateTextTagShort("|cff706FB1", I2S(R2I(GoofyRock_Damage() * 2.0)), GetUnitX(uu), GetUnitY(uu), 0, 0.020)
call SetUnitAnimation(uu, "death")// simulates the knock of the rock (it probably is painful - rock in the head ^^)
call UnitDamageTarget(u, uu, GoofyRock_Damage() * 2.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
elseif (i == 1) then //the normal damage case GetRandomInt(0, 2) - 1
call TriggerSleepAction(t)
call CreateTextTagShort("|cff706FB1", I2S(R2I(GoofyRock_Damage())), GetUnitX(uu), GetUnitY(uu), 0, 0.020)
call SetUnitAnimation(uu, "death")
call UnitDamageTarget(u, uu, GoofyRock_Damage(), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
elseif (i == 2) then //the no damage case GetRandomInt(0, 2) - 2 (oops ^^)
call TriggerSleepAction(t - 0.45)// t - 0.45 because some distance calcualtion errors or something, dunno really (a lot of tests for this number)
//call UnitDamageTarget(u, uu, GoofyRock_Damage() * 0.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitAddAbility(uu, 'Avul') //add invulnerability to ignore the stun
call TriggerSleepAction(0.2) //for a short period
call UnitRemoveAbility(uu, 'Avul') //removes the invulnerability
call CreateTextTagShort("|cff706FB1", "oops", GetUnitX(uu), GetUnitY(uu), 0, 0.020)
endif
set u = null //cleans memmory leaks
set uu = null
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
function InitTrig_Goofy_Rock takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function GoofyRock_Cond))
call TriggerAddAction(t, function GoofyRock_Main)
endfunction
//ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
// Note: in some rare situations in case "the no damage case" the unit is stunned because
// the invulnerability ability is added too late, ussualy this happens in close range
// i tried to solve it with "call TriggerSleepAction(t - 0.45) but it is still present
// if someone come up with a solution for all ranges you can make a post or something