//TESH.scrollpos=0
//TESH.alwaysfold=0
//Spell Name: Force Arrow
//Made by: Mckill2009
library ForceArrow needs MapBounds
globals
private constant hashtable HASH = InitHashtable() //Dont touch!
private constant integer SPELL_ID = 'A000' //roar
private constant integer MISSILE_ID = 'h001' //just change this model
private constant real AOE = 250
private constant real PERIODIC = 0.03125
private constant real SPEED = 15
private constant attacktype ATK = ATTACK_TYPE_CHAOS
private constant damagetype DMG = DAMAGE_TYPE_NORMAL
private constant string SFX = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
private constant group FA_GROUP = CreateGroup()
private integer CHECK = 0
endglobals
private function GetDamage takes integer i returns real
return 50 + i * 50.
endfunction
private function GetDistance takes integer i returns real
return 500 + i * 100.
endfunction
private module Init
private static method onInit takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t1, Condition(function thistype.go))
call TriggerRegisterTimerEvent(t2, PERIODIC, true)
call TriggerAddCondition(t2, Condition(function thistype.runloop))
set t1 = null
set t2 = null
endmethod
endmodule
private struct FA
unit caster
unit missile
integer level
real x
real y
real damage
real angle
real distance
real height
real distx
static thistype DATA
static method damagethem takes nothing returns boolean
local thistype this = DATA
local unit u = GetFilterUnit()
if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(.missile)) then
call UnitDamageTarget(.missile, u, .damage, false, false, ATK, DMG, null)
endif
set u = null
return false
endmethod
static method looper takes nothing returns nothing
local unit u = GetEnumUnit()
local thistype this = LoadInteger(HASH, GetHandleId(u), 1)
local integer i = 0
local real x
local real y
local real x1
local real y1
if .distance > .distx then
set .distx = .distx + SPEED
set x = .x + .distx * Cos(.angle*bj_DEGTORAD)
set y = .y + .distx * Sin(.angle*bj_DEGTORAD)
call SetUnitX(.missile, x)
call SetUnitY(.missile, y)
else
set x1 = GetUnitX(.missile)
set y1 = GetUnitY(.missile)
call KillUnit(.missile)
call DestroyEffect(AddSpecialEffect(SFX, x1, y1))
set DATA = this
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x1, y1, AOE, Filter(function thistype.damagethem))
call GroupRemoveUnit(FA_GROUP, .missile)
set CHECK = CHECK - 1
call .destroy(this)
call FlushChildHashtable(HASH, GetHandleId(.missile))
endif
set u = null
endmethod
static method create takes unit u, integer level, real x, real y returns thistype
local thistype this = thistype.allocate()
set .distx = 0
set .angle = GetUnitFacing(u)
set .distance = GetDistance(level)
set .missile = CreateUnit(GetTriggerPlayer(), MISSILE_ID, x, y, 0)
set .damage = GetDamage(level)
set .x = x
set .y = y
set CHECK = CHECK + 1
call GroupAddUnit(FA_GROUP, .missile)
call SaveInteger(HASH, GetHandleId(.missile), 1, this)
return this
endmethod
static method go takes nothing returns boolean
local unit u
local integer level
if GetSpellAbilityId()==SPELL_ID then
set u = GetTriggerUnit()
set level = GetUnitAbilityLevel(u, SPELL_ID)
call FA.create(u, level, GetUnitX(u), GetUnitY(u))
endif
set u = null
return false
endmethod
static method runloop takes nothing returns boolean
if CHECK > 0 then
call ForGroup(FA_GROUP, function thistype.looper)
endif
return false
endmethod
implement Init
endstruct
endlibrary