Move Route_GetJumpVelocity() into shared/defs.h for now.
This commit is contained in:
parent
f8a3e227d4
commit
ff78e34c16
4 changed files with 50 additions and 47 deletions
|
@ -275,44 +275,3 @@ Route_GetNodeFlags(nodeslist_t *node)
|
||||||
else
|
else
|
||||||
return fl;
|
return fl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get's a velocity vector with which we can successfully jump from one place to another */
|
|
||||||
vector
|
|
||||||
Route_GetJumpVelocity(vector vecFrom, vector vecTo, float flGravMod)
|
|
||||||
{
|
|
||||||
#if 1
|
|
||||||
float flHeight, flGravity, flTime, flDistance, flDir;
|
|
||||||
vector vecJump = [0,0,0];
|
|
||||||
|
|
||||||
if (flGravMod <= 0.0)
|
|
||||||
flGravMod = 1.0f;
|
|
||||||
|
|
||||||
flGravity = serverkeyfloat("phy_gravity") * flGravMod;
|
|
||||||
flHeight = vecTo[2] - vecFrom[2];
|
|
||||||
|
|
||||||
if (flHeight <= 0)
|
|
||||||
flHeight = vlen(vecTo - vecFrom) / 2;
|
|
||||||
|
|
||||||
flTime = sqrt(flHeight / (flGravity * 0.5f));
|
|
||||||
if (flTime <= 0) {
|
|
||||||
return [0,0,0];
|
|
||||||
}
|
|
||||||
|
|
||||||
vecJump = vecTo - vecFrom;
|
|
||||||
vecJump[2] = 0;
|
|
||||||
flDistance = vlen(normalize(vecJump));
|
|
||||||
|
|
||||||
flDir = flDistance / flTime;
|
|
||||||
vecJump *= flDir;
|
|
||||||
vecJump[2] = bound(240, flTime * flGravity, 512);
|
|
||||||
|
|
||||||
print(sprintf("jumping from %v to %v at %v\n", vecFrom, vecTo, vecJump));
|
|
||||||
#else
|
|
||||||
vector vecJump = [0,0,0];
|
|
||||||
float flDist = vlen(vecTo - vecFrom);
|
|
||||||
makevectors(vectoangles(vecTo - vecFrom));
|
|
||||||
vecJump = v_forward * flDist;
|
|
||||||
vecJump[2] = 280;
|
|
||||||
#endif
|
|
||||||
return vecJump;
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,3 +23,4 @@ int Textmenu_IsActive(void);
|
||||||
void Textmenu_Hide(void);
|
void Textmenu_Hide(void);
|
||||||
void Textmenu_Input(int);
|
void Textmenu_Input(int);
|
||||||
void Textmenu_Draw(void);
|
void Textmenu_Draw(void);
|
||||||
|
string Titles_GetTextBody(string);
|
|
@ -172,7 +172,7 @@ EntityDef_Init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static NSEntity
|
||||||
EntityDef_PrepareEntity(entity target, int id)
|
EntityDef_PrepareEntity(entity target, int id)
|
||||||
{
|
{
|
||||||
string spawnClass;
|
string spawnClass;
|
||||||
|
@ -235,17 +235,17 @@ EntityDef_PrepareEntity(entity target, int id)
|
||||||
/* now we rename the classname for better visibility */
|
/* now we rename the classname for better visibility */
|
||||||
self.classname = g_entDefTable[id].entClass;
|
self.classname = g_entDefTable[id].entClass;
|
||||||
__fullspawndata = "";
|
__fullspawndata = "";
|
||||||
|
return targetEnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
NSEntity
|
||||||
EntityDef_SpawnClassname(string className)
|
EntityDef_SpawnClassname(string className)
|
||||||
{
|
{
|
||||||
for (int i = 0i; i < g_entDefCount; i++) {
|
for (int i = 0i; i < g_entDefCount; i++) {
|
||||||
if (className == g_entDefTable[i].entClass) {
|
if (className == g_entDefTable[i].entClass) {
|
||||||
EntityDef_PrepareEntity(self, i);
|
return EntityDef_PrepareEntity(self, i);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return __NULL__;
|
||||||
}
|
}
|
|
@ -377,3 +377,46 @@ textfile_to_string(string filename)
|
||||||
|
|
||||||
return fileContents;
|
return fileContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* moved from src/botlib/route.qc */
|
||||||
|
/* Get's a velocity vector with which we can successfully jump from one place to another */
|
||||||
|
vector
|
||||||
|
Route_GetJumpVelocity(vector vecFrom, vector vecTo, float flGravMod)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
float flHeight, flGravity, flTime, flDistance, flDir;
|
||||||
|
vector vecJump = [0,0,0];
|
||||||
|
|
||||||
|
if (flGravMod <= 0.0)
|
||||||
|
flGravMod = 1.0f;
|
||||||
|
|
||||||
|
flGravity = serverkeyfloat("phy_gravity") * flGravMod;
|
||||||
|
flHeight = vecTo[2] - vecFrom[2];
|
||||||
|
|
||||||
|
/* this may not be a much verticality to this jump, use distance instead */
|
||||||
|
if (flHeight <= 0) {
|
||||||
|
flHeight = vlen(vecTo - vecFrom);
|
||||||
|
flTime = flHeight / flGravity;
|
||||||
|
} else {
|
||||||
|
flTime = sqrt(flHeight / (flGravity * 0.5f));
|
||||||
|
if (flTime <= 0) {
|
||||||
|
return [0,0,0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vecJump = vecTo - vecFrom;
|
||||||
|
vecJump[2] = 0;
|
||||||
|
flDistance = vlen(normalize(vecJump));
|
||||||
|
|
||||||
|
flDir = flDistance / flTime;
|
||||||
|
vecJump *= flDir;
|
||||||
|
vecJump[2] = flTime * flGravity;
|
||||||
|
#else
|
||||||
|
vector vecJump = [0,0,0];
|
||||||
|
float flDist = vlen(vecTo - vecFrom);
|
||||||
|
makevectors(vectoangles(vecTo - vecFrom));
|
||||||
|
vecJump = v_forward * flDist;
|
||||||
|
vecJump[2] = 280;
|
||||||
|
#endif
|
||||||
|
return vecJump;
|
||||||
|
}
|
Loading…
Reference in a new issue