IzNoGoD
18th May 2013, 09:51
jump(start, end)
{
height = end[2] - start[2];
v0 = 275;
t0 = v0 / getcvarint("g_gravity");
s0 = 0.5 * getcvarint("g_gravity") * t0 * t0;
height -= s0;
if(height > 0)
return false; //no jumping possible. Target too high.
t1sq = -2 * height / getcvarint("g_gravity");
time = int((sqrt(t1sq) + t0) * 20) / 20;
xdist = end[0] - start[0];
ydist = end[1] - start[1];
xspeed = xdist / time;
yspeed = ydist / time;
self movegravity((xspeed, yspeed, v0), time);
wait time;
self.origin = end;
return true;
}
Just some math...
To change this function into fall(), just set v0 to 0, t0 to 0 or s0 to 0. (or remove all associated stuff)
{
height = end[2] - start[2];
v0 = 275;
t0 = v0 / getcvarint("g_gravity");
s0 = 0.5 * getcvarint("g_gravity") * t0 * t0;
height -= s0;
if(height > 0)
return false; //no jumping possible. Target too high.
t1sq = -2 * height / getcvarint("g_gravity");
time = int((sqrt(t1sq) + t0) * 20) / 20;
xdist = end[0] - start[0];
ydist = end[1] - start[1];
xspeed = xdist / time;
yspeed = ydist / time;
self movegravity((xspeed, yspeed, v0), time);
wait time;
self.origin = end;
return true;
}
Just some math...
To change this function into fall(), just set v0 to 0, t0 to 0 or s0 to 0. (or remove all associated stuff)