Move Route_GetJumpVelocity() into shared/defs.h for now.

This commit is contained in:
Marco Cawthorne 2023-05-10 15:52:17 -07:00
parent f8a3e227d4
commit ff78e34c16
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
4 changed files with 50 additions and 47 deletions

View File

@ -275,44 +275,3 @@ Route_GetNodeFlags(nodeslist_t *node)
else
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;
}

View File

@ -23,3 +23,4 @@ int Textmenu_IsActive(void);
void Textmenu_Hide(void);
void Textmenu_Input(int);
void Textmenu_Draw(void);
string Titles_GetTextBody(string);

View File

@ -172,7 +172,7 @@ EntityDef_Init(void)
#endif
}
static void
static NSEntity
EntityDef_PrepareEntity(entity target, int id)
{
string spawnClass;
@ -235,17 +235,17 @@ EntityDef_PrepareEntity(entity target, int id)
/* now we rename the classname for better visibility */
self.classname = g_entDefTable[id].entClass;
__fullspawndata = "";
return targetEnt;
}
bool
NSEntity
EntityDef_SpawnClassname(string className)
{
for (int i = 0i; i < g_entDefCount; i++) {
if (className == g_entDefTable[i].entClass) {
EntityDef_PrepareEntity(self, i);
return true;
return EntityDef_PrepareEntity(self, i);
}
}
return false;
}
return __NULL__;
}

View File

@ -377,3 +377,46 @@ textfile_to_string(string filename)
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;
}