Move base classes out of gs-entbase. This evolution only happened because classes such as CBaseMonster that once existed were replaced and it grew from there.

Tweak g_developer prints for scripted_sequences.
This commit is contained in:
Marco Cawthorne 2022-07-19 15:22:15 -07:00
parent 6ff42e4176
commit 2a220fb331
Signed by: eukara
GPG key ID: CE2032F0A2882A22
41 changed files with 111 additions and 80 deletions

View file

@ -1,4 +1,5 @@
#includelist #includelist
NSInteractiveSurface.qc
fog.qc fog.qc
font.qc font.qc
sky.qc sky.qc

View file

@ -6,7 +6,6 @@
baseentity.h baseentity.h
decals.h decals.h
client/defs.h client/defs.h
shared/NSVehicle.h
client/env_cubemap.qc client/env_cubemap.qc
client/env_glow.qc client/env_glow.qc
client/env_sun.qc client/env_sun.qc

View file

@ -5,8 +5,6 @@
#includelist #includelist
baseentity.h baseentity.h
decals.h decals.h
server/NSOutput.qc
shared/NSVehicle.h
server/info_null.qc server/info_null.qc
server/info_notnull.qc server/info_notnull.qc
server/info_intermission.qc server/info_intermission.qc

View file

@ -15,7 +15,6 @@
*/ */
#include "../shared/baseentity.h" #include "../shared/baseentity.h"
#include "NSOutput.h"
void FX_Spark(vector, vector); void FX_Spark(vector, vector);
void FX_BreakModel(int, vector, vector, vector, float); void FX_BreakModel(int, vector, vector, vector, float);

View file

@ -206,22 +206,22 @@ scripted_sequence::RunOnEntity(entity targ)
f.m_iSequenceFlags = spawnflags; f.m_iSequenceFlags = spawnflags;
if (m_iMove == SS_NO) { if (m_iMove == SS_NO) {
dprint("\tType: SS_NO\n"); NSLog("\tType: SS_NO (%i)", m_iMove);
} else if (m_iMove == SS_WALK) { } else if (m_iMove == SS_WALK) {
f.NewRoute(origin); f.NewRoute(origin);
f.m_flSequenceSpeed = f.GetWalkSpeed(); f.m_flSequenceSpeed = f.GetWalkSpeed();
dprint("\tType: SS_WALK\n"); NSLog("\tType: SS_WALK (%i)", m_iMove);
return; return;
} else if (m_iMove == SS_RUN) { } else if (m_iMove == SS_RUN) {
f.NewRoute(origin); f.NewRoute(origin);
f.m_flSequenceSpeed = f.GetRunSpeed(); f.m_flSequenceSpeed = f.GetRunSpeed();
dprint("\tType: SS_RUN\n"); NSLog("\tType: SS_RUN (%i)", m_iMove);
return; return;
} else if (m_iMove == SS_INSTANTANEOUS) { } else if (m_iMove == SS_INSTANTANEOUS) {
setorigin(f, this.origin); setorigin(f, this.origin);
dprint("\tType: SS_INSTANTANEOUS\n"); NSLog("\tType: SS_INSTANTANEOUS (%i)", m_iMove);
} else if (m_iMove == SS_TURNTOFACE) { } else if (m_iMove == SS_TURNTOFACE) {
dprint("\tType: SS_TURNTOFACE\n"); NSLog("\tType: SS_TURNTOFACE (%i)", m_iMove);
} }
/* all the non-moving targets will do this at least */ /* all the non-moving targets will do this at least */
@ -229,7 +229,7 @@ scripted_sequence::RunOnEntity(entity targ)
duration = frameduration(f.modelindex, f.m_flSequenceEnd); duration = frameduration(f.modelindex, f.m_flSequenceEnd);
f.nextthink = time + duration; f.nextthink = time + duration;
NSLog( NSLog(
"\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)\n", "\tAnimation: %s Duration: %f seconds (modelindex %d, frame %d)",
m_strActionAnim, m_strActionAnim,
duration, duration,
f.modelindex, f.modelindex,
@ -238,7 +238,7 @@ scripted_sequence::RunOnEntity(entity targ)
} else { } else {
f.nextthink = time; f.nextthink = time;
NSLog( NSLog(
"\t^1WARNING: %s skipping animation on script type %i\n", "\t^1WARNING: %s skipping animation on script type %i",
f.targetname, f.targetname,
m_iMove m_iMove
); );

View file

@ -3,20 +3,6 @@
#endif #endif
#includelist #includelist
shared/NSIO.qc
shared/NSTrigger.qc
shared/NSEntity.qc
shared/NSRenderableEntity.qc
shared/NSSurfacePropEntity.qc
shared/NSPhysicsEntity.qc
shared/NSBrushTrigger.qc
shared/NSPointTrigger.qc
shared/NSVehicle.qc
shared/NSNavAI.qc
shared/NSMonster.qc
shared/NSTalkMonster.qc
shared/NSProjectile.qc
shared/NSInteractiveSurface.qc
shared/ambient_generic.qc shared/ambient_generic.qc
shared/decals.qc shared/decals.qc
shared/spraylogo.qc shared/spraylogo.qc

View file

@ -17,17 +17,5 @@
#ifndef BASEENTITY #ifndef BASEENTITY
#define BASEENTITY #define BASEENTITY
#include "NSIO.h"
#include "NSTrigger.h"
#include "NSEntity.h"
#include "NSRenderableEntity.h"
#include "NSSurfacePropEntity.h"
#include "NSPhysicsEntity.h"
#include "NSBrushTrigger.h"
#include "NSPointTrigger.h"
#include "NSNavAI.h"
#include "NSMonster.h"
#include "NSTalkMonster.h"
#include "NSProjectile.h"
#include "env_sprite.h" #include "env_sprite.h"
#endif #endif

View file

@ -14,6 +14,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "NSOutput.h"
#include "gamerules.h" #include "gamerules.h"
#include "sentences.h" #include "sentences.h"
#include "skill.h" #include "skill.h"

View file

@ -1,4 +1,5 @@
#includelist #includelist
NSOutput.qc
plugins.qc plugins.qc
logging.qc logging.qc
nodes.qc nodes.qc

View file

@ -36,6 +36,8 @@ enumflags
/* NSEntity is the lowest, user accessible class. /* NSEntity is the lowest, user accessible class.
It's responsible for handling practically every entity in Nuclide. It's responsible for handling practically every entity in Nuclide.
Try to avoid using the built-in 'entity' type unless you know exactly
what you are doing.
*/ */
class NSEntity:NSTrigger class NSEntity:NSTrigger
{ {

View file

@ -21,7 +21,6 @@
This is a very low-level class. You're never meant to use this. This is a very low-level class. You're never meant to use this.
Use NSEntity as a basis for your classes. Use NSEntity as a basis for your classes.
*/ */
class NSIO class NSIO
{ {
void(void) NSIO; void(void) NSIO;

View file

@ -20,10 +20,6 @@ NSIO::Respawn(void)
// Respawn code goes here... // Respawn code goes here...
} }
#ifdef CLIENT
string __fullspawndata;
#endif
void void
NSIO::Init(void) NSIO::Init(void)
{ {

View file

@ -294,6 +294,7 @@ class NSMonster:NSNavAI
#ifdef CLIENT #ifdef CLIENT
string Sentences_GetSamples(string); string Sentences_GetSamples(string);
string Sentences_ProcessSample(string); string Sentences_ProcessSample(string);
void NSMonster_ReadEntity(bool);
#else #else
void NSMonster_AlertEnemyAlliance(vector pos, float radius, int alliance); void NSMonster_AlertEnemyAlliance(vector pos, float radius, int alliance);
entity NSMonster_FindClosestPlayer(entity); entity NSMonster_FindClosestPlayer(entity);

View file

@ -280,7 +280,7 @@ NSMonster::GetRunSpeed(void)
void void
NSMonster::AttackThink(void) NSMonster::AttackThink(void)
{ {
if (m_iSequenceState != SEQUENCESTATE_NONE) if (InSequence())
return; return;
if (m_flAttackThink > time) if (m_flAttackThink > time)
@ -391,17 +391,17 @@ NSMonster::FreeState(void)
if (m_iSequenceRemove) { if (m_iSequenceRemove) {
Hide(); Hide();
} }
dprint("NSMonster::FreeState\n"); NSLog("^2%s::^3FreeState^7: (%i, %S)", classname, m_iSequenceRemove, to_trigger);
} }
void void
NSMonster::FreeStateMoved(void) NSMonster::FreeStateMoved(void)
{ {
vector new_origin; vector new_origin;
dprint("NSMonster::FreeStateMoved\n");
new_origin = gettaginfo(this, 1); new_origin = gettaginfo(this, 1);
NSLog("^2%s::^3FreeStateMoved^7: moved to %v", classname, new_origin);
SetOrigin(new_origin); SetOrigin(new_origin);
droptofloor(); DropToFloor();
FreeState(); FreeState();
} }
@ -410,21 +410,24 @@ NSMonster::RouteEnded(void)
{ {
super::RouteEnded(); super::RouteEnded();
if (GetSequenceState() != SEQUENCESTATE_ACTIVE)
return;
/* mark that we've ended a sequence, if we're in one and que anim */ /* mark that we've ended a sequence, if we're in one and que anim */
if (m_iSequenceState == SEQUENCESTATE_ACTIVE) { if (m_flSequenceEnd) {
if (m_flSequenceEnd) { float duration = frameduration(modelindex, m_flSequenceEnd);
float duration = frameduration(modelindex, m_flSequenceEnd); m_iSequenceState = SEQUENCESTATE_ENDING;
m_iSequenceState = SEQUENCESTATE_ENDING; think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved;
think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved; nextthink = time + duration;
nextthink = time + duration; NSLog("^2%s::^3CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)", \
NSLog("^2NSNavAI::^3CheckRoute^7: %s overriding anim for %f seconds (modelindex %d, frame %d)", this.targetname, duration, modelindex, m_flSequenceEnd); classname, this.targetname, duration, modelindex, m_flSequenceEnd);
} else { } else {
/* we still need to trigger targets */ /* we still need to trigger targets */
think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved; think = (m_iSequenceFlags & SSFL_NOSCRIPTMOVE) ? FreeState : FreeStateMoved;
nextthink = time; nextthink = time;
NSLog("^2NSNavAI::^3CheckRoute^7: %s has no anim, finished sequence.", this.targetname); NSLog("^2%s::^3CheckRoute^7: %s has no anim, finished sequence", \
} classname, this.targetname);
} }
} }
void void
@ -535,7 +538,8 @@ NSMonster::IsAlive(void)
void void
NSMonster::StateChanged(monsterState_e oldState, monsterState_e newState) NSMonster::StateChanged(monsterState_e oldState, monsterState_e newState)
{ {
print(sprintf("%s state changed from %d to %d\n", classname, oldState, newState)); NSLog("^2%s::^3StateChanged^7: state changed from %d to %d", \
classname, oldState, newState);
} }
void void

View file

@ -14,6 +14,9 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* NSNavAI is a moving/pathfinding object. It knows how to deal
with waypoint based nodes.
*/
class class
NSNavAI:NSSurfacePropEntity NSNavAI:NSSurfacePropEntity
{ {

View file

@ -48,8 +48,8 @@ NSNavAI::CheckRoute(void)
flDist = floor(vlen(evenpos - origin)); flDist = floor(vlen(evenpos - origin));
if (flDist < 8) { if (flDist < 8) {
NSLog("^2NSNavAI::^3CheckRoute^7: " \ NSLog("^2%s::^3CheckRoute^7: " \
"%s reached node\n", this.targetname); "%s reached node", classname, targetname);
m_iCurNode--; m_iCurNode--;
velocity = [0,0,0]; /* clamp friction */ velocity = [0,0,0]; /* clamp friction */
@ -60,8 +60,8 @@ NSNavAI::CheckRoute(void)
/* can we walk directly to our target destination? */ /* can we walk directly to our target destination? */
if (trace_fraction == 1.0) { if (trace_fraction == 1.0) {
dprint("^2NSNavAI::^3CheckRoute^7: " \ NSLog("^2%s::^3CheckRoute^7: Walking directly to last node at '%v'", \
"Walking directly to last node\n"); classname, m_vecLastNode);
m_iCurNode = -1; m_iCurNode = -1;
} }
} }
@ -78,6 +78,8 @@ NSNavAI::CheckRoute(void)
if (trace_fraction == 1.0f) { if (trace_fraction == 1.0f) {
evenpos = vecNextNode; evenpos = vecNextNode;
m_iCurNode = iNextNode; m_iCurNode = iNextNode;
NSLog("^2%s::^3CheckRoute^7: skipping to next node %i at '%v'", \
classname, iNextNode, vecNextNode);
} }
} }
@ -85,7 +87,7 @@ NSNavAI::CheckRoute(void)
if (m_iCurNode < -1) { if (m_iCurNode < -1) {
ClearRoute(); ClearRoute();
RouteEnded(); RouteEnded();
NSLog("^2NSNavAI::^3CheckRoute^7: %s reached end", this.targetname); NSLog("^2%s::^3CheckRoute^7: %s reached end", classname, targetname);
} }
/* crouch attempt */ /* crouch attempt */
@ -173,12 +175,12 @@ NSNavAI::NewRoute(vector destination)
/* can we walk directly to our target destination? */ /* can we walk directly to our target destination? */
if (trace_fraction == 1.0) { if (trace_fraction == 1.0) {
dprint("^2NSNavAI::^3NewRoute^7: " \ NSLog("^2%s::^3NewRoute^7: " \
"Walking directly to last node\n"); "Walking directly to last node", classname);
p.m_iCurNode = -1; p.m_iCurNode = -1;
} else { } else {
dprint("^2NSNavAI::^3NewRoute^7: " \ NSLog("^2%s::^3NewRoute^7: " \
"Path obstructed, calculating route\n"); "Path obstructed, calculating route", classname);
/* run through all nodes, mark the closest direct path possible */ /* run through all nodes, mark the closest direct path possible */
for (int i = 0; i < p.m_iNodes; i++) { for (int i = 0; i < p.m_iNodes; i++) {

View file

@ -94,3 +94,7 @@ class NSPhysicsEntity:NSSurfacePropEntity
virtual void(vector) ApplyTorqueCenter; virtual void(vector) ApplyTorqueCenter;
virtual float(int, int) CalculateImpactDamage; virtual float(int, int) CalculateImpactDamage;
}; };
#ifdef CLIENT
void NSPhysicsEntity_ReadEntity(bool);
#endif

View file

@ -111,3 +111,7 @@ class NSRenderableEntity:NSEntity
vector m_oldvecRenderColor; vector m_oldvecRenderColor;
#endif #endif
}; };
#ifdef CLIENT
void NSRenderableEntity_ReadEntity(bool)
#endif

View file

@ -104,5 +104,8 @@ class NSSurfacePropEntity:NSRenderableEntity
nonvirtual void(void) SurfaceDataFinish; nonvirtual void(void) SurfaceDataFinish;
nonvirtual void(void) PropDataFinish; nonvirtual void(void) PropDataFinish;
#endif #endif
}; };
#ifdef CLIENT
void NSSurfacePropEntity_ReadEntity(bool);
#endif

View file

@ -127,3 +127,8 @@ class NSTalkMonster:NSMonster
virtual void(float,float) ReceiveEntity; virtual void(float,float) ReceiveEntity;
#endif #endif
}; };
#ifdef CLIENT
void NSTalkMonster_ParseSentence(void);
void NSTalkMonster_ReadEntity(bool);
#endif

View file

@ -20,7 +20,7 @@ void
NSTrigger::Trigger(entity act, int state) NSTrigger::Trigger(entity act, int state)
{ {
NSLog("^2%s::^3Input^7: Triggerd by %s with no consequence", NSLog("^2%s::^3Input^7: Triggerd by %s with no consequence",
this.classname, act.classname); classname, act.classname);
} }
void void
@ -36,7 +36,7 @@ NSTrigger::UseTargets(entity act, int state, float fDelay)
if (fDelay > 0.0f) { if (fDelay > 0.0f) {
NSLog("^2%s::^3UseTargets^7: Triggering `%s`", NSLog("^2%s::^3UseTargets^7: Triggering `%s`",
this.classname, target); classname, target);
NSTrigger eTimer = spawn(NSTrigger); NSTrigger eTimer = spawn(NSTrigger);
eTimer.owner = act; eTimer.owner = act;
@ -53,8 +53,8 @@ NSTrigger::UseTargets(entity act, int state, float fDelay)
NSTrigger trigger = (NSTrigger)f; NSTrigger trigger = (NSTrigger)f;
NSLog("^2%s::^3UseTargets^7:" \ NSLog("^2%s::^3UseTargets^7:" \
"Triggering %s `%s` from %s\n", \ "Triggering %s `%s` from %s", \
this.classname, f.classname, \ classname, f.classname, \
trigger.targetname, act.classname); trigger.targetname, act.classname);
if (trigger.Trigger != __NULL__) { if (trigger.Trigger != __NULL__) {
@ -96,7 +96,7 @@ NSTrigger::GetMaster(void)
/* default to success */ /* default to success */
if (!m_strMaster) { if (!m_strMaster) {
/*NSLog("^2%s::^3GetMaster^7: No master, return success", /*NSLog("^2%s::^3GetMaster^7: No master, return success",
this.classname));*/ classname));*/
return (1); return (1);
} }
@ -105,16 +105,16 @@ NSTrigger::GetMaster(void)
/* we couldn't find it, so let's not even bother going further */ /* we couldn't find it, so let's not even bother going further */
if (!t) { if (!t) {
NSLog("^2%s::^3GetMaster^7: Invalid master (%s), return success", NSLog("^2%s::^3GetMaster^7: Invalid master (%s), return success",
this.classname, m_strMaster); classname, m_strMaster);
return (1); return (1);
} }
if (t.GetValue() == 1) if (t.GetValue() == 1)
NSLog("^2%s::^3GetMaster^7: %s learns %s ^2POSITIVE", NSLog("^2%s::^3GetMaster^7: %s learns %s ^2POSITIVE",
this.classname, targetname, m_strMaster); classname, targetname, m_strMaster);
else else
NSLog("^2%s::^3GetMaster^7: %s learns %s ^1NEGATIVE", NSLog("^2%s::^3GetMaster^7: %s learns %s ^1NEGATIVE",
this.classname, targetname, m_strMaster); classname, targetname, m_strMaster);
return t.GetValue(); return t.GetValue();
} }

View file

@ -32,6 +32,9 @@
#define ATTR_CHANGED(x) (x ##_net != x) #define ATTR_CHANGED(x) (x ##_net != x)
#define VEC_CHANGED(x,y) (x ##_net[y] != x[y]) #define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
#ifdef CLIENT
string __fullspawndata;
#endif
#include "global.h" #include "global.h"
#include "sound.h" #include "sound.h"
@ -43,10 +46,27 @@
#endif #endif
#include "../gs-entbase/shared/baseentity.h" #include "../gs-entbase/shared/baseentity.h"
#include "NSIO.h"
#include "NSTrigger.h"
#include "NSEntity.h"
#include "NSRenderableEntity.h"
#include "NSSurfacePropEntity.h"
#include "NSPhysicsEntity.h"
#include "NSBrushTrigger.h"
#include "NSPointTrigger.h"
#include "NSNavAI.h"
#include "NSMonster.h"
#include "NSTalkMonster.h"
#include "NSProjectile.h"
#include "../xr/defs.h" #include "../xr/defs.h"
#include "NSClient.h" #include "NSClient.h"
#include "NSClientSpectator.h" #include "NSClientSpectator.h"
#include "NSClientPlayer.h" #include "NSClientPlayer.h"
#include "NSVehicle.h"
#include "NSMaterial.h" #include "NSMaterial.h"
#include "damage.h" #include "damage.h"
#include "flags.h" #include "flags.h"

View file

@ -1,4 +1,19 @@
#includelist #includelist
NSIO.qc
NSTrigger.qc
NSEntity.qc
NSRenderableEntity.qc
NSSurfacePropEntity.qc
NSPhysicsEntity.qc
NSBrushTrigger.qc
NSPointTrigger.qc
NSVehicle.qc
NSNavAI.qc
NSMonster.qc
NSTalkMonster.qc
NSProjectile.qc
NSClient.qc NSClient.qc
NSClientSpectator.qc NSClientSpectator.qc
pmove.qc pmove.qc

View file

@ -482,7 +482,7 @@ PMoveCustom_Move(void)
if (trace_startsolid) { if (trace_startsolid) {
if (!PMoveCustom_Fix_Origin()) { if (!PMoveCustom_Fix_Origin()) {
dprint("PHYSICS ERROR: We are stuck!\n"); dprint(sprintf("%s PHYSICS ERROR: We are stuck!\n", self.classname));
return; return;
} }
continue; continue;