Moderator
M
(1 ratings)
//! zinc
library Arc
{
constant real arc = 75; //modifies the arcing shape
constant real arcHeight = 350; //how high the arc reach at its peak
constant real travelTime = 0.60; //time it takes for the arc to reach destination
constant real convertArc = arc / 100.00; // do not touch
constant integer dummy = 'h000'; //dummy unit used
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 group g = CreateGroup();
constant hashtable hash = InitHashtable();
constant timer t = CreateTimer();
function Update()
{
unit u = GetEnumUnit();
integer h = GetHandleId(u);
real angle = LoadReal(hash, h, 1);
real initDistance = LoadReal(hash, h, 2);
real currentDistance = LoadReal(hash, h, 3);
real maxHeight = LoadReal(hash, h, 4);
real time = LoadReal(hash, h, 5);
real newHeight;
real cx = GetUnitX(u);
real cy = GetUnitY(u);
real nx = cx + time * Cos(angle * bj_DEGTORAD);
real ny = cy + time * Sin(angle * bj_DEGTORAD);
integer id;
currentDistance += time;
newHeight = ((4.00 * (maxHeight / initDistance)) * ((initDistance - currentDistance) * (currentDistance / initDistance)));
SetUnitX (u, nx);
SetUnitY (u, ny);
SetUnitFlyHeight (u, newHeight, 0.00);
SaveReal (hash, h, 3, currentDistance);
if(newHeight <= 0)
{
id = LoadInteger (hash, h, 6);
CreateItem (id, nx, ny);
DestroyEffect (LoadEffectHandle(hash, h, 7));
UnitApplyTimedLife (u, 'BTLF', 0.01);
FlushChildHashtable(hash, h);
GroupRemoveUnit (g, u);
if(FirstOfGroup(g) == null)
{
PauseTimer(t);
}
}
u = null;
}
function GroupFunc()
{
ForGroup(g, function Update);
}
public function Apply(real sx, real sy, real dx, real dy, integer i)
{
unit u = CreateUnit(Player(12), dummy, sx, sy, 0);
integer h = GetHandleId(u);
real tx = dx - sx;
real ty = dy - sy;
real angle = bj_RADTODEG * Atan2(ty, tx);
real distance = SquareRoot(tx * tx + ty * ty);
real height = arcHeight; //distance * convertArc;
real time = distance / (travelTime / loopSpeed);
PauseUnit(u, true);
SaveReal (hash, h, 1, angle);
SaveReal (hash, h, 2, distance);
SaveReal (hash, h, 4, height);
SaveReal (hash, h, 5, time);
SaveInteger (hash, h, 6, i);
SaveEffectHandle (hash, h, 7, AddSpecialEffectTarget(sfx, u, "origin"));
if(FirstOfGroup(g) == null)
{
TimerStart(t, loopSpeed, true, function GroupFunc);
}
GroupAddUnit (g, u);
u = null;
}
}
//! endzinc
I was going to mention this to you when I first saw the RemoveLocation(), but I forgot xDWhy location handles over coordinates when you are using zync?
FirstOfGroup(group)
returns null
.Yus, better argue senseless about to write proper comments,
instead of just doing something useful and with even less effort.
Stubbornness at a wrong place.
- Use Vexorian, Anitarf, InfraNe model
The effect used on the dummy is never destroyed