library BerserkersLeap initializer Init needs TimerUtils
globals
private constant integer RAWCODE = 'A000'//Put your spell's RawCode here:)
private group aGroup = CreateGroup()//Do not do anything with this:)
private constant string EFFECT = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
private group dGroup = CreateGroup()//Do not edit this
private constant integer DUMMY_ID = 'h001'//Put the dummy RAWCODE here
private constant integer DA_RAWCODE = 'A002'// Put the Dummy Abillity Rawcode here
private constant real SPEED = 10.
private timer SpellTimer
private location SpellLoc = Location( 0., 0.)
endglobals
private function Damage takes integer level returns real
return (level * 125.)
endfunction
private struct leap
private unit Caster
integer level
real CasterX
real CasterY
real TargetX
real TargetY
real Angle
real RangeFromTarget
real RangeCheck
unit Target
static method GetParabolaZ takes real x, real d, real h returns real
return (4. * h * x * (d - x) / (d * d))
endmethod
static method Actions takes nothing returns nothing
local thistype this = GetTimerData(SpellTimer)
local unit Dummy//This is just a local we'll use in the DummyCreation.
local real DummyX
local real DummyY
local real CastX
local real CastY
local real DisMissle
local real Degrees
local real DummyAngle//This is the angle the Dummies are made to shoot towards, no need to do anything here...
local integer int = 12//this is the ammount of dummies thats created that will shoot the shockwaves
set .RangeCheck = .RangeCheck + SPEED
set .CasterX = .CasterX + SPEED * Cos(.Angle * bj_DEGTORAD)
set .CasterY = .CasterY + SPEED * Sin(.Angle * bj_DEGTORAD)
call SetUnitX(.Caster, .CasterX)
call SetUnitY(.Caster, .CasterY)
set DisMissle = (.TargetX - .CasterX) + (.TargetY - .CasterY)
if 0. >= DisMissle then
set DisMissle = DisMissle * -1.
endif
call SetUnitFlyHeight( .Caster, GetParabolaZ( DisMissle, .RangeFromTarget, 550.), 0.)
if(.RangeCheck >= .RangeFromTarget) then
set Degrees = .Angle
call SetUnitFlyHeight( .Caster, 0., 0)
call SetUnitTimeScale( .Caster, 1.)
call GroupEnumUnitsInRange(aGroup, .CasterX, .CasterY, 250., null)
call DestroyEffect(AddSpecialEffect(EFFECT, .CasterX,.CasterY))
//****************************************************************************************
//***************************************** DUMMY*****************************************
//***************************************** CREATION**************************************
//***************************************** Loop ****************************************
//****************************************************************************************
loop
set int = int - 1
exitwhen int == 0
set Degrees = Degrees + 30
set DummyX = .CasterX + 100 * Cos(Degrees)
set DummyY = .CasterY + 100 * Sin(Degrees)
set Dummy = CreateUnit(GetOwningPlayer(.Caster), DUMMY_ID, DummyX, DummyY, Cos(Atan2(DummyY - .CasterY, DummyX - .CasterX)))
set CastX = DummyX + Cos(Atan2( DummyY - .CasterY, DummyX - .CasterX))
set CastY = DummyY + Sin(Atan2( DummyY - .CasterY, DummyX - .CasterX))
call UnitAddAbility( Dummy, DA_RAWCODE)
call SetUnitAbilityLevel( Dummy, DA_RAWCODE, .level)
call IssuePointOrder( Dummy, "shockwave", CastX, CastY)
call UnitApplyTimedLife( Dummy, 'BTLF', 0.50)
endloop
//****************************************************************************************
//***************************************** TARGET****************************************
//***************************************** DAMAGING**************************************
//***************************************** Loop ****************************************
//****************************************************************************************
loop
set .Target = FirstOfGroup(aGroup)
exitwhen (.Target == null)
if(IsUnitEnemy(.Target, GetOwningPlayer(.Caster)) == true) then
call UnitDamageTarget(.Caster, .Target, Damage(.level), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
endif
call GroupRemoveUnit(aGroup, .Target)
set .Target = null
endloop
call ReleaseTimer(SpellTimer)
set Dummy = null
endif
endmethod
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set SpellTimer = NewTimer()
set .Caster = GetTriggerUnit()
set .CasterX = GetUnitX(.Caster)
set .CasterY = GetUnitY(.Caster)
set .TargetX = GetSpellTargetX()
set .TargetY = GetSpellTargetY()
set .level = GetUnitAbilityLevel(.Caster, RAWCODE)
set .Angle = bj_RADTODEG * Atan2(.TargetY - .CasterY, .TargetX - .CasterX)
set .RangeFromTarget = SquareRoot((.CasterX - .TargetX) * (.CasterX - .TargetX) + (.CasterY - .TargetY) * (.CasterY - .TargetY))
call MoveLocation( SpellLoc, .TargetX, .TargetY)
call UnitAddAbility(.Caster, 'Arav')
call UnitRemoveAbility(.Caster, 'Arav')
call SetTimerData(SpellTimer, this)
call SetUnitTimeScale( .Caster, 50. * 0.01)
call TimerStart(SpellTimer, 0.01, true, function leap.Actions)
return this
endmethod
endstruct
private function C takes nothing returns boolean
if (GetSpellAbilityId() == RAWCODE) then
call leap.create()
endif
return false
endfunction
//===========================================================================
function Init takes nothing returns nothing
local trigger Berserk = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Berserk, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition( Berserk, Condition(function C))
call Preload(EFFECT)
set bj_lastCreatedUnit = CreateUnit(Player(15), 'h001', 0., 0., 270.)
call UnitAddAbility(bj_lastCreatedUnit, RAWCODE)
call UnitRemoveAbility(bj_lastCreatedUnit, RAWCODE)
call RemoveUnit(bj_lastCreatedUnit)
endfunction
endlibrary