package ArcingLoot
import LinkedListModule
import TimerUtils
import Fx
constant real arc = 75 //modifies the arcing shape
constant real arcHeight = 350 //how high the arc reach at its peak
constant real travelTime = 0.9 //time it takes for the arc to reach destination
constant real convertArc = arc / 100.00 // do not touch
constant string sfx = "Objects\\InventoryItems\\TreasureChest\\treasurechest.mdl" //effect, the item chest in this case
constant real loopSpeed = 0.03 //how often the system runs its loop. Higher value equals better perfomance
constant location loc = Location(0,0)
function vec2.getZ() returns real
MoveLocation(loc, this.x, this.y)
return GetLocationZ(loc)
public class ArcingItem
use LinkedListModule
static timer t
integer id
Fx fx
angle angle
real distance
real maxDistance
real arc
real speed
effect e
vec2 pos
vec2 destination
construct(integer itemId, vec2 start, vec2 dest)
pos = start
fx = new Fx(pos, angle(0), sfx)
angle = pos.angleTo(dest)
distance = pos.distanceTo(dest)
maxDistance = distance
speed = distance / (travelTime / loopSpeed)
destination = dest
arc = distance * convertArc
id = itemId
e = fx.getDummy().addEffect("Abilities\\Spells\\NightElf\\Rejuvenation\\RejuvenationTarget.mdl", "origin")
if(t == null)
t = getTimer()
t.startPeriodic(loopSpeed, function ArcingItem.onLoop)
static function onLoop()
for instance in ArcingItem
instance.update()
function update()
pos.x = pos.x + speed * Cos(angle.radians)
pos.y = pos.y + speed * Sin(angle.radians)
distance = pos.distanceTo(destination)
let tarc = (4.00 * arc) / maxDistance
let dist = (maxDistance - distance) * (distance / maxDistance)
let z = pos.getZ()
let height = (tarc * dist) + z
fx.getDummy().setPosFly(vec3(pos.x, pos.y, height))
if(height <= 0)
e.destr()
createItem(id, pos)
destroy fx
destroy this
if ArcingItem.size == 0
t.destr()