Skip to content

Commit

Permalink
* New events system.
Browse files Browse the repository at this point in the history
* Fix a bunch of AI.
  • Loading branch information
uq1 committed Aug 15, 2019
1 parent b3e7403 commit 32e4f1a
Show file tree
Hide file tree
Showing 38 changed files with 1,622 additions and 2,528 deletions.
3 changes: 3 additions & 0 deletions codemp/cgame/cg_consolecmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ void Clcmd_EntityList_f (void) {
case ET_TRIGGER_HURT:
trap->Print("ET_TRIGGER_HURT ");
break;
case ET_SERVERMODEL:
trap->Print("ET_SERVERMODEL ");
break;
default:
trap->Print("%-3i ", check->currentState.eType);
break;
Expand Down
2 changes: 1 addition & 1 deletion codemp/cgame/cg_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ qboolean ShouldCull ( vec3_t org, qboolean check_angles )
{
float dist = Distance(cg.refdef.vieworg, org);

if (dist > 3072.0) return qtrue; // TOO FAR! CULLED!
if (dist > DEFAULT_ENTITY_CULL_RANGE/*3072.0*/) return qtrue; // TOO FAR! CULLED!
if (check_angles && dist > 256 && !CG_InFOV( org, cg.refdef.vieworg, cg.refdef.viewangles, cg.refdef.fov_x*1.2, cg.refdef.fov_y*1.2)) return qtrue; // NOT ON SCREEN! CULLED!
//if (/*dist > 256 &&*/ !CullVisible(cg.refdef.vieworg, org, cg.clientNum)) return qtrue; // NOT VISIBLE TO US! CULLED!
}
Expand Down
113 changes: 113 additions & 0 deletions codemp/cgame/cg_ents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,116 @@ Ghoul2 Insert End
*/
}

/*
==================
CG_General
==================
*/
void CG_G2ServerBoneAngles(centity_t *cent);

extern qboolean BG_GetRootSurfNameWithVariant(void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize);

static void CG_ServerModel(centity_t *cent) {
refEntity_t ent;
entityState_t *s1;

if (cent->currentState.eFlags & EF_RADAROBJECT)
{
CG_AddRadarEnt(cent);
}

if (cent->currentState.eFlags & EF_CLIENTSMOOTH)
{
if (cent->currentState.groundEntityNum >= ENTITYNUM_WORLD)
{
float smoothFactor = 0.5f*timescale.value;
int k = 0;
vec3_t posDif;

//Use origin smoothing since dismembered limbs use ExPhys
if (DistanceSquared(cent->turAngles, cent->lerpOrigin)>18000.0f)
{
VectorCopy(cent->lerpOrigin, cent->turAngles);
}

VectorSubtract(cent->lerpOrigin, cent->turAngles, posDif);

for (k = 0; k<3; k++)
{
cent->turAngles[k] = (cent->turAngles[k] + posDif[k] * smoothFactor);
cent->lerpOrigin[k] = cent->turAngles[k];
}
}
else
{ //if we're sitting on an entity like a moving plat then we don't want to smooth either
VectorCopy(cent->lerpOrigin, cent->turAngles);
}
}

memset(&ent, 0, sizeof(ent));

ent.shaderRGBA[0] = cent->currentState.customRGBA[0];
ent.shaderRGBA[1] = cent->currentState.customRGBA[1];
ent.shaderRGBA[2] = cent->currentState.customRGBA[2];
ent.shaderRGBA[3] = cent->currentState.customRGBA[3];

s1 = &cent->currentState;

if ((s1->eFlags & EF_NODRAW))
{
return;
}

// set frame
if (s1->eFlags & EF_SHADER_ANIM)
{
// Deliberately setting it up so that shader anim will completely override any kind of model animation frame setting.
ent.renderfx |= RF_SETANIMINDEX;
ent.skinNum = s1->frame;
}
else
{
ent.frame = s1->frame;

}
ent.oldframe = ent.frame;
ent.backlerp = 0;

// event ships bob up and down continuously while hoverring...
if (s1->generic1 == 1)
{
float scale = 0.005 + cent->currentState.number * 0.00001;
int bobSpeed = 256; // 4
float bobScale = scale * 0.1;
cent->lerpOrigin[2] += bobSpeed + cos((cg.time + 1000) * bobScale) * bobSpeed;
}

VectorCopy(cent->lerpOrigin, ent.origin);
VectorCopy(cent->lerpOrigin, ent.oldorigin);

ent.hModel = cgs.gameModels[s1->modelindex];

// convert angles to axis
AnglesToAxis(cent->lerpAngles, ent.axis);

if (cent->currentState.iModelScale)
{ //if the server says we have a custom scale then set it now.
cent->modelScale[0] = cent->modelScale[1] = cent->modelScale[2] = cent->currentState.iModelScale;// / 100.0f;
VectorCopy(cent->modelScale, ent.modelScale);
ScaleModelAxis(&ent);
}
else
{
VectorClear(cent->modelScale);
}

// Event ship spawns never get culled...
ent.ignoreCull = qtrue;

// add to refresh list
AddRefEntityToScene(&ent);
}

/*
==================
CG_Speaker
Expand Down Expand Up @@ -3499,6 +3609,9 @@ Ghoul2 Insert End
case ET_BODY:
CG_General( cent );
break;
case ET_SERVERMODEL:
CG_ServerModel(cent);
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions codemp/cgame/cg_nav_autowaypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8705,6 +8705,7 @@ typedef enum {
ET_MOVER_MARKER,
ET_SPAWNPOINT,
ET_TRIGGER_HURT,
ET_SERVERMODEL,

ET_FREED, // UQ1: Added to mark freed entities...

Expand Down
2 changes: 1 addition & 1 deletion codemp/client/snd_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ qboolean S_ShouldCull ( vec3_t org, qboolean check_angles, int entityNum )

float dist = Distance(cl.snap.ps.origin, checkOrg);

if (dist > 3072.0) return qtrue; // TOO FAR! CULLED!
if (dist > DEFAULT_ENTITY_CULL_RANGE/*3072.0*/) return qtrue; // TOO FAR! CULLED!
if (s_realism->integer >= 2 && check_angles && !S_InFOV(checkOrg, cl.snap.ps.origin, cl.snap.ps.viewangles, 180.0, 180.0)) return qtrue; // NOT ON SCREEN! CULLED!
//if (s_realism->integer >= 3 && !CullVisible(cl.snap.ps.origin, checkOrg, cl.snap.ps.clientNum)) return qtrue; // NOT VISIBLE TO US! CULLED!

Expand Down
1 change: 1 addition & 0 deletions codemp/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set(MPGameGameFiles
"${MPDir}/game/g_cmds.cpp"
"${MPDir}/game/g_combat.cpp"
"${MPDir}/game/g_cvar.cpp"
"${MPDir}/game/g_eventsystem.cpp"
"${MPDir}/game/g_exphysics.cpp"
"${MPDir}/game/g_foliage.cpp"
"${MPDir}/game/g_ICARUScb.cpp"
Expand Down
59 changes: 58 additions & 1 deletion codemp/game/NPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ qboolean UQ_MoveDirClear( gentity_t *aiEnt, int forwardmove, int rightmove, qboo
extern qboolean NPC_IsJetpacking ( gentity_t *self );
extern void ST_Speech( gentity_t *self, int speechType, float failChance );
extern void BubbleShield_Update(gentity_t *aiEnt);
extern qboolean NPC_IsCombatPathing(gentity_t *aiEnt);

// Conversations...
extern void NPC_NPCConversation(gentity_t *aiEnt);
Expand Down Expand Up @@ -3440,9 +3441,29 @@ qboolean UQ1_UcmdMoveForDir ( gentity_t *self, usercmd_t *cmd, vec3_t dir, qbool
}
*/

int waterPlane = 0;

if (self && self->client)
{
waterPlane = IsBelowWaterPlane(self->client->ps.origin, self->client->ps.viewheight);
}

if (self->waterlevel > 0 && self->enemy && self->enemy->client && NPC_IsAlive(self, self->enemy))
{// When we have a valid enemy, always check water level so we don't drown while attacking them...

}
else if (waterPlane)
{
if (self->client->ps.eFlags & EF_JETPACK)
{// Fly over :)
pm->waterlevel = 2;
pm->watertype = CONTENTS_WATER;
}
else
{
pm->waterlevel = waterPlane;
pm->watertype = CONTENTS_WATER;
}
}
else if (gWPNum > 0 && self->wpCurrent >= 0 && self->wpCurrent < gWPNum)
{
Expand All @@ -3467,6 +3488,10 @@ qboolean UQ1_UcmdMoveForDir ( gentity_t *self, usercmd_t *cmd, vec3_t dir, qbool
{// Jedi always walk when in combat with saber...
walk = qtrue;
}
else if (self->NPC && self->NPC->forceWalkTime > level.time)
{// Retreating NPCs walk backwards, don't run... Because thats annoying as hell to saber users...
walk = qtrue;
}

if (walk)
{
Expand Down Expand Up @@ -3641,9 +3666,29 @@ qboolean UQ1_UcmdMoveForDir_NoAvoidance ( gentity_t *self, usercmd_t *cmd, vec3_
}
*/

int waterPlane = 0;

if (self && self->client)
{
waterPlane = IsBelowWaterPlane(self->client->ps.origin, self->client->ps.viewheight);
}

if (self->waterlevel > 0 && self->enemy && self->enemy->client && NPC_IsAlive(self, self->enemy))
{// When we have a valid enemy, always check water level so we don't drown while attacking them...

}
else if (waterPlane)
{
if (self->client->ps.eFlags & EF_JETPACK)
{// Fly over :)
pm->waterlevel = 2;
pm->watertype = CONTENTS_WATER;
}
else
{
pm->waterlevel = waterPlane;
pm->watertype = CONTENTS_WATER;
}
}
else if (gWPNum > 0 && self->wpCurrent >= 0 && self->wpCurrent < gWPNum)
{
Expand All @@ -3668,6 +3713,10 @@ qboolean UQ1_UcmdMoveForDir_NoAvoidance ( gentity_t *self, usercmd_t *cmd, vec3_
{// Jedi always walk when in combat with saber...
walk = qtrue;
}
else if (self->NPC && self->NPC->forceWalkTime > level.time)
{// Retreating NPCs walk backwards, don't run... Because thats annoying as hell to saber users...
walk = qtrue;
}

if (walk)
{
Expand Down Expand Up @@ -4017,7 +4066,7 @@ qboolean NPC_CheckNearbyPlayers(gentity_t *NPC)
continue;
}

if (Distance(NPC->r.currentOrigin, cl->ps.origin) > 4096.0)
if (Distance(NPC->r.currentOrigin, cl->ps.origin) > 8192.0)
{
continue;
}
Expand Down Expand Up @@ -4246,6 +4295,7 @@ void NPC_Think ( gentity_t *self )//, int msec )
//
// Escaping water...
//
#if 0
if (((self->waterlevel && self->watertype == CONTENTS_WATER) || self->water_escape_time > level.time) && NPC_EscapeWater(self))
{
// UQ1: Check any jetpack stuff...
Expand Down Expand Up @@ -4286,6 +4336,7 @@ void NPC_Think ( gentity_t *self )//, int msec )
NPC_CheckAllClear(aiEnt);
return;
}
#endif

//nextthink is set before this so something in here can override it
if (self->s.NPC_class != CLASS_VEHICLE && !self->m_pVehicle)
Expand Down Expand Up @@ -4724,6 +4775,12 @@ void NPC_Think ( gentity_t *self )//, int msec )
{
//trap->Print("NPCBOT DEBUG: NPC is attacking.\n");

// If we have combat pathing, use it while we do the other stuff...
if (NPC_IsCombatPathing(aiEnt))
{
NPC_FollowRoutes(aiEnt);
}

NPC_ExecuteBState( self );

#if 0 // UQ1: Should be handled in behavior now...
Expand Down
Loading

0 comments on commit 32e4f1a

Please sign in to comment.