//=====================================================
//============== Blinky Spell(Custom) =================
//================ By: Drenferalis ====================
//=====================================================
//=====================================================
//==== This spell is used for Imitating multiple =====
//== attacks within few seconds. It requires the use ==
//== of a dummy unit to imitate an attack sequence ==
//== and uses a damage target function to define how ==
//== much damage is dealt. The damage can be defined ==
//=== by changing the appropriate variables in the ===
//============= function Spell_Actions. ===============
//=====================================================
//===WARNING: DO NOT CHANGE ANYTHING EXCEPT WHAT IS====
//====LABELED WITH CHANGE OR DEFINE SUCH AS BELOW!=====
//=====================================================
//=====================================================
//=====================================================
//CHANGE 'h000' TO YOUR DUMMY UNITS RAW ID==============
//=====================================================
function DC_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h000'
endfunction
//=======================================================
//========================================================
//=======================================================
function DC_Actions takes nothing returns nothing
local real craterx
local real cratery
local unit target = GetOrderTargetUnit()
local integer DMG1
local integer TT
//=======================================================
//Define this for terrain changes=========================
//=======================================================
//Actively Changes the terrain below missle?
local boolean TC = true
//If true what type? (Uses terrain raw code.)
set TT = 'Nice'
//=======================================================
//========================================================
//=======================================================
loop
exitwhen GetUnitCurrentOrder(GetTriggerUnit()) != OrderId("attackonce")
call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
if (TC == true)then
set cratery = GetUnitY(GetTriggerUnit())
set craterx = GetUnitX(GetTriggerUnit())
call SetTerrainType(craterx,cratery,TT,-1,1,0)
endif
endloop
set DMG1 = GetUnitUserData(GetTriggerUnit())
call UnitDamageTarget(GetTriggerUnit(),target,I2R(DMG1),true,false,ATTACK_TYPE_PIERCE,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set target = null
call RemoveUnit(GetTriggerUnit())
endfunction
function Loc_trg takes nothing returns nothing
local trigger DC = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(DC,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerAddCondition(DC,Condition(function DC_Conditions))
call TriggerAddAction(DC,function DC_Actions)
set DC = null
endfunction
//Checks if the ability being cast is "Blinky"
//==========================================================
//REPLACE 'A000' WITH YOUR CUSTOM SPELL RAW ID!=============
//==========================================================
function Trig_Blinky_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
//==========================================================
//END REPLACE===============================================
//==========================================================
//The main spell is here.
function Spell_Actions takes nothing returns nothing
//Sets locals for MUI and leak removal.
local unit Blinky = GetSpellTargetUnit()
local unit Blink_E = GetSpellAbilityUnit()
local unit B_Dummy
local integer LI = 1
local location TR
local real BlinkX = GetUnitX(Blinky)
local real BlinkY = GetUnitY(Blinky)
local rect BlinkRect
local location BlinkELoc
local real Stat
local integer AL
local real BD
local real DMG
local integer Dmmy
local fogmodifier Fog
//==================================================================
//Definable Variables Below==========================================
//==================================================================
//Change to STR for Strength, AGI for Agility, and INT for intelligence.
local string Attribute = "AGI"
//Multiplier Percentage of the spell (Will be multiplied by Spell Level [eg. Mult=.1) and Spell level is 3 the final Mult will be .3])
local real Mult = 0
//Wait between movement/attacks.
local real MWait = .01
//Number of attacks
local integer NumA = 500
//Square Range of "Blink"
local integer Bx = 5000
//Dummy Unit RAW ID
set Dmmy = 'h000'
//Base Spell Damage
set BD = 5
//End of Definable Variables
//==================================================================
//===================================================================
//==================================================================
if ( Attribute == "STR")then
set Stat = I2R(GetHeroStr(Blink_E,true))
elseif (Attribute == "AGI")then
set Stat = I2R(GetHeroAgi(Blink_E,true))
elseif (Attribute == "INT")then
set Stat = I2R(GetHeroInt(Blink_E,true))
endif
set AL = GetUnitAbilityLevel(Blink_E,GetSpellAbilityId())
set DMG =((Stat*(Mult*(I2R(AL))))+BD)
call Loc_trg()
call PauseUnit(Blinky,true)
call PauseUnit(Blink_E,true)
call SetUnitInvulnerable(Blink_E,true)
set Fog = CreateFogModifierRadius(GetOwningPlayer(Blink_E),FOG_OF_WAR_VISIBLE,BlinkX,BlinkY,512,true,false)
call FogModifierStart(Fog)
loop
exitwhen LI > NumA
if GetUnitState(Blinky,UNIT_STATE_LIFE) >= 0.45 then
set BlinkX = GetUnitX(Blinky)
set BlinkY = GetUnitY(Blinky)
set BlinkRect = Rect(BlinkX-Bx*0.5,BlinkY-Bx*0.5,BlinkX+Bx*0.5,BlinkY+Bx*0.5)
set TR = Location(GetRandomReal(GetRectMinX(BlinkRect), GetRectMaxX(BlinkRect)), GetRandomReal(GetRectMinY(BlinkRect), GetRectMaxY(BlinkRect)))
call SetUnitPositionLoc(Blink_E,TR)
call SetUnitFacing(Blink_E,bj_RADTODEG*Atan2(BlinkY-GetLocationY(TR),BlinkX-GetLocationX(TR)))
set B_Dummy = CreateUnit(GetOwningPlayer(Blink_E),Dmmy,GetUnitX(Blink_E),GetUnitY(Blink_E),bj_RADTODEG*Atan2(GetUnitY(Blinky)-BlinkY,GetUnitX(Blinky)-BlinkX))
call IssueTargetOrder(B_Dummy,"attackonce",Blinky)
call SetUnitUserData(B_Dummy,R2I(DMG))
call TriggerSleepAction(MWait)
call RemoveLocation(TR)
else
call PauseUnit(Blink_E,false)
call SetUnitInvulnerable(Blink_E,false)
call DestroyFogModifier(Fog)
return
endif
set LI = LI + 1
endloop
call PauseUnit(Blink_E,false)
call DestroyFogModifier(Fog)
call SetUnitInvulnerable(Blink_E,false)
call PauseUnit(Blinky,false)
call RemoveRect(BlinkRect)
call RemoveLocation(BlinkELoc)
set Fog = null
set BlinkRect = null
set Blinky = null
set Blink_E = null
set B_Dummy = null
set BlinkELoc = null
set TR = null
set LI = 0
endfunction
//===========================================================================
function InitTrig_Blinky takes nothing returns nothing
set gg_trg_Blinky = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Blinky, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Blinky, Condition( function Trig_Blinky_Conditions ) )
call TriggerAddAction( gg_trg_Blinky, function Spell_Actions )
endfunction