NSProjectile: don't spawn debris on monsters.

NSIO: change EntWarning to EntLog for unknown spawn data keys.
This commit is contained in:
Marco Cawthorne 2024-07-30 20:20:07 -07:00
parent 4a636693bc
commit caac73bec9
Signed by: eukara
GPG key ID: CE2032F0A2882A22
17 changed files with 273 additions and 228 deletions

View file

@ -67,17 +67,6 @@ of type NSClientSpectator.
class
NSClientSpectator:NSClient
{
private:
PREDICTED_FLOAT(spec_ent)
PREDICTED_FLOAT(spec_flags)
NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net;
float m_flDeathCam;
float m_flLastSpecTargetChange;
vector spec_org;
int sequence;
public:
void NSClientSpectator(void);
@ -120,6 +109,15 @@ public:
nonvirtual void SpectatorDeathcam(NSRenderableEntity, NSEntity, float);
#endif
private:
PREDICTED_FLOAT(spec_ent)
PREDICTED_FLOAT(spec_flags)
NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net;
float m_flDeathCam;
float m_flLastSpecTargetChange;
vector spec_org;
int sequence;
};
#ifdef CLIENT

View file

@ -1,3 +1,19 @@
/*
* Copyright (c) 2023-2024 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef CLIENT
class
NSDebris:NSPhysicsEntity
@ -11,4 +27,4 @@ public:
private:
string m_strImpactDecal;
};
#endif
#endif

View file

@ -24,9 +24,7 @@
class
NSDecal
{
string m_strShader;
string m_strTexture;
public:
void NSDecal(void);
#ifdef SERVER
@ -39,6 +37,10 @@ NSDecal
/** Paint the given decal at the specified position. */
virtual void Place(vector, string);
private:
string m_strShader;
string m_strTexture;
};
typedef struct

View file

@ -52,42 +52,6 @@ what you are doing. Otherwise, you will deal with loss of savegames and much mor
*/
class NSEntity:NSTrigger
{
private:
float m_flSpawnTime;
bool m_bHidden; /**< decides whether the entity is visible or not, without affecting collision */
vector m_vecMins; /**< REAL min bounding box value, without .scale affecting it */
vector m_vecMaxs; /**< REAL max bounding box value, without .scale affecting it */
bool m_bIsBrush;
vector m_vecEditorColor;
PREDICTED_FLOAT(entityDefID)
PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(angles)
PREDICTED_FLOAT_N(modelindex)
PREDICTED_VECTOR_N(size)
PREDICTED_VECTOR_N(mins)
PREDICTED_VECTOR_N(maxs)
PREDICTED_FLOAT_N(solid)
PREDICTED_FLOAT_N(movetype)
PREDICTED_FLOAT_N(scale)
PREDICTED_FLOAT_N(flags)
PREDICTED_FLOAT_N(vv_flags)
PREDICTED_VECTOR_N(velocity)
PREDICTED_VECTOR_N(avelocity)
#ifdef SERVER
string m_parent;
string m_parent_old;
string m_parent_attachment;
PREDICTED_FLOAT_N(frame)
PREDICTED_FLOAT_N(skin)
PREDICTED_FLOAT_N(effects)
#endif
/** Will read from the named def to perform a projectile attack. */
nonvirtual bool _ProjectileAttack(string, bool);
public:
/** The constructor.
Not much may be known of what the entity will be just yet. */
@ -424,6 +388,42 @@ public:
/** Sets the @ref bot_info tag on this entity to the desired botInfo_t tag. */
nonvirtual void SetBotTag(botInfo_t);
private:
float m_flSpawnTime;
bool m_bHidden; /**< decides whether the entity is visible or not, without affecting collision */
vector m_vecMins; /**< REAL min bounding box value, without .scale affecting it */
vector m_vecMaxs; /**< REAL max bounding box value, without .scale affecting it */
bool m_bIsBrush;
vector m_vecEditorColor;
PREDICTED_FLOAT(entityDefID)
PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(angles)
PREDICTED_FLOAT_N(modelindex)
PREDICTED_VECTOR_N(size)
PREDICTED_VECTOR_N(mins)
PREDICTED_VECTOR_N(maxs)
PREDICTED_FLOAT_N(solid)
PREDICTED_FLOAT_N(movetype)
PREDICTED_FLOAT_N(scale)
PREDICTED_FLOAT_N(flags)
PREDICTED_FLOAT_N(vv_flags)
PREDICTED_VECTOR_N(velocity)
PREDICTED_VECTOR_N(avelocity)
#ifdef SERVER
string m_parent;
string m_parent_old;
string m_parent_attachment;
PREDICTED_FLOAT_N(frame)
PREDICTED_FLOAT_N(skin)
PREDICTED_FLOAT_N(effects)
#endif
/** Will read from the named def to perform a projectile attack. */
nonvirtual bool _ProjectileAttack(string, bool);
};
/** Returns a new entity. Guaranteed to be something. Never __NULL__

View file

@ -120,12 +120,12 @@ NSEntity::Visible(entity ent)
traceline(origin, ent.origin, MOVE_NORMAL, this);
if (trace_fraction == 1.0f || trace_ent == ent) {
print(sprintf("%s can see %s\n", classname, ent.classname));
/*print(sprintf("%s can see %s\n", classname, ent.classname));*/
return (true);
}
}
print(sprintf("%s can not see %s\n", classname, ent.classname));
/*print(sprintf("%s can not see %s\n", classname, ent.classname));*/
return (false);
}

View file

@ -25,24 +25,9 @@ Use NSEntity as a basis for your classes.
*/
class NSIO
{
private:
public:
void NSIO(void);
string m_strSpawnData;
#ifdef SERVER
string m_strOnTrigger;
string m_strOnUser1;
string m_strOnUser2;
string m_strOnUser3;
string m_strOnUser4;
/* entityDef powered modelevent callbacks */
string m_strModelEventCB;
#endif
public:
/** Called when the entity is fulled initialized.
Any spawn key/value info pairs have already been
dealt with. So now we can make full decisions on the entity.
@ -194,6 +179,19 @@ public:
nonvirtual void DebugBool(string,bool);
/** Debug print for a given entity. */
nonvirtual void DebugEntity(string,entity);
private:
string m_strSpawnData;
#ifdef SERVER
string m_strOnTrigger;
string m_strOnUser1;
string m_strOnUser2;
string m_strOnUser3;
string m_strOnUser4;
/* entityDef powered modelevent callbacks */
string m_strModelEventCB;
#endif
};
.bool _mapspawned;

View file

@ -874,7 +874,7 @@ NSIO::SpawnKey(string strKey, string strValue)
#endif
default:
#ifdef SERVER
EntWarning("%s has unknown key %S with value %S",
EntLog("%s has unknown key %S with value %S",
classname, strKey, strValue);
#endif
break;

View file

@ -37,7 +37,6 @@ NSPhysicsConstraint:NSEntity
public:
void NSPhysicsConstraint(void);
virtual void SpawnKey(string, string);
#ifdef SERVER

View file

@ -87,30 +87,6 @@ You will find the API to be mostly compatible of that offered by Garry's Mod.
*/
class NSPhysicsEntity:NSSurfacePropEntity
{
private:
int m_iEnabled;
int m_iShape;
int m_iMaterial;
int m_iFlags;
float m_flInertiaScale;
float m_flBuoyancyRatio;
bool m_bInvincible;
float m_flVolume;
/* performance sanity checks */
vector m_vecPrevOrigin;
vector m_vecPrevAngles;
float m_flCheckTime;
PREDICTED_FLOAT(m_flMass)
virtual void _TouchThink(void);
#ifdef SERVER
PREDICTED_VECTOR(m_vecNetAngles)
string m_strOnDamaged;
#endif
public:
void NSPhysicsEntity(void);
@ -216,6 +192,30 @@ public:
nonvirtual void Wake(void);
/** Call to freeze physics simulation on this entity. */
nonvirtual void Sleep(void);
private:
int m_iEnabled;
int m_iShape;
int m_iMaterial;
int m_iFlags;
float m_flInertiaScale;
float m_flBuoyancyRatio;
bool m_bInvincible;
float m_flVolume;
/* performance sanity checks */
vector m_vecPrevOrigin;
vector m_vecPrevAngles;
float m_flCheckTime;
PREDICTED_FLOAT(m_flMass)
virtual void _TouchThink(void);
#ifdef SERVER
PREDICTED_VECTOR(m_vecNetAngles)
string m_strOnDamaged;
#endif
};
noref .bool isPhysics;

View file

@ -46,6 +46,57 @@ Objects such as rockets, grenades, bolts etc. should ideally be this.
*/
class NSProjectile:NSSurfacePropEntity
{
public:
void NSProjectile(void);
#ifdef CLIENT
virtual void ReceiveEntity(float, float);
virtual float predraw(void);
#endif
#ifdef SERVER
/** Sets the function that'll be called upon impact of the projectile onto a surface. */
nonvirtual void SetImpact(void(entity, entity));
/** When called, will animated between two frame positions at a specified framerate on loop. */
nonvirtual void Animate(int, int, float);
/** When called, will animated between two frame positions at a specified framerate and remove itself when it has finished playing the sequence. */
nonvirtual void AnimateOnce(int, int, float);
/** Called upon the projectile touching another object. */
virtual void Touch(entity);
virtual void Spawned(void);
virtual void Pain(entity, entity, int, vector, int);
virtual void Death(entity, entity, int, vector, int);
virtual void SpawnKey(string, string);
virtual void EvaluateEntity(void);
virtual float SendEntity(entity, float);
virtual void Save(float);
virtual void Restore(string, string);
virtual void Trigger(entity, triggermode_t);
nonvirtual void _FuseEnded(void);
nonvirtual void _Explode(entity);
virtual void _LaunchHitscan(vector, vector, float);
/* launch the projectile into the world */
virtual void Launch(vector, vector, float, float, float);
nonvirtual void SetLightColor(vector);
nonvirtual void SetLightRadius(float);
nonvirtual void EnableDetonateOnFuse(bool);
nonvirtual void EnableDetonateOnDeath(bool);
nonvirtual void EnableDetonateOnWorld(bool);
nonvirtual void EnableDetonateOnActor(bool);
nonvirtual void EnableStickToWorld(bool);
nonvirtual void EnableStickToActor(bool);
nonvirtual void EnableThrustHoming(bool);
nonvirtual void EnableInheritVelocity(bool);
#endif
private:
NETWORKED_FLOAT_N(traileffectnum)
NETWORKED_VECTOR(m_vecLightColor)
@ -132,57 +183,6 @@ private:
virtual void OnRemoveEntity(void);
#endif
public:
void NSProjectile(void);
#ifdef CLIENT
virtual void ReceiveEntity(float, float);
virtual float predraw(void);
#endif
#ifdef SERVER
/** Sets the function that'll be called upon impact of the projectile onto a surface. */
nonvirtual void SetImpact(void(entity, entity));
/** When called, will animated between two frame positions at a specified framerate on loop. */
nonvirtual void Animate(int, int, float);
/** When called, will animated between two frame positions at a specified framerate and remove itself when it has finished playing the sequence. */
nonvirtual void AnimateOnce(int, int, float);
/** Called upon the projectile touching another object. */
virtual void Touch(entity);
virtual void Spawned(void);
virtual void Pain(entity, entity, int, vector, int);
virtual void Death(entity, entity, int, vector, int);
virtual void SpawnKey(string, string);
virtual void EvaluateEntity(void);
virtual float SendEntity(entity, float);
virtual void Save(float);
virtual void Restore(string, string);
virtual void Trigger(entity, triggermode_t);
nonvirtual void _FuseEnded(void);
nonvirtual void _Explode(void);
virtual void _LaunchHitscan(vector, vector, float);
/* launch the projectile into the world */
virtual void Launch(vector, vector, float, float, float);
nonvirtual void SetLightColor(vector);
nonvirtual void SetLightRadius(float);
nonvirtual void EnableDetonateOnFuse(bool);
nonvirtual void EnableDetonateOnDeath(bool);
nonvirtual void EnableDetonateOnWorld(bool);
nonvirtual void EnableDetonateOnActor(bool);
nonvirtual void EnableStickToWorld(bool);
nonvirtual void EnableStickToActor(bool);
nonvirtual void EnableThrustHoming(bool);
nonvirtual void EnableInheritVelocity(bool);
#endif
};
#ifdef SERVER

View file

@ -486,7 +486,7 @@ NSProjectile::Restore(string strKey, string strValue)
void
NSProjectile::Trigger(entity theActivator, triggermode_t theMode)
{
_Explode();
_Explode(this);
}
void
@ -514,13 +514,13 @@ NSProjectile::Touch(entity eToucher)
if (m_bDetonateOnWorld) {
if (eToucher == world || eToucher.takedamage == DAMAGE_NO) {
_Explode();
_Explode(eToucher);
return;
}
}
if (m_bDetonateOnActor) {
if (eToucher.takedamage != DAMAGE_NO) {
_Explode();
_Explode(eToucher);
return;
}
}
@ -547,7 +547,7 @@ void
NSProjectile::Death(entity inflictor, entity attacker, int damage, vector dir, int location)
{
if (m_bDetonateOnDeath) {
_Explode();
_Explode(this);
return;
}
@ -674,7 +674,7 @@ void
NSProjectile::_FuseEnded(void)
{
if (m_bDetonateOnFuse) {
_Explode();
_Explode(this);
return;
}
@ -687,7 +687,7 @@ NSProjectile::_FuseEnded(void)
}
void
NSProjectile::_Explode(void)
NSProjectile::_Explode(entity explodedOn)
{
vector newAngles, aimFwd, aimRgt, aimUp;
vector debrisPos;
@ -733,7 +733,7 @@ NSProjectile::_Explode(void)
}
/* another def that'll be spawned when this one detonates */
if (m_defProjectileDebris) {
if (m_defProjectileDebris && !explodedOn && explodedOn != this) {
float movementAmount = 360.0f / (float)m_iDebrisCount;
for (int i = 0; i < m_iDebrisCount; i++) {

View file

@ -92,39 +92,6 @@ and bone control settings.
*/
class NSRenderableEntity:NSEntity
{
private:
/* new */
PREDICTED_FLOAT(m_flBoneControl1)
PREDICTED_FLOAT(m_flBoneControl2)
PREDICTED_FLOAT(m_flBoneControl3)
PREDICTED_FLOAT(m_flBoneControl4)
PREDICTED_FLOAT(m_flBoneControl5)
PREDICTED_FLOAT_N(modelflags)
PREDICTED_INT(m_iBody)
PREDICTED_FLOAT_N(colormap)
PREDICTED_VECTOR_N(glowmod)
PREDICTED_FLOAT_N(frame1time)
PREDICTED_FLOAT(m_iRenderFX)
PREDICTED_FLOAT(m_iRenderMode)
PREDICTED_FLOAT(m_flRenderAmt)
PREDICTED_VECTOR(m_vecRenderColor)
PREDICTED_VECTOR(m_vecAxialScale)
/* either a sprite model or a particle */
PREDICTED_INT(m_iMuzzleModel)
PREDICTED_INT(m_iMuzzlePart)
PREDICTED_FLOAT(m_flMuzzleScale)
/* model events */
float m_flBaseTime;
#ifdef CLIENT
float m_iNumBones;
nonvirtual void _UpdateGeomset();
nonvirtual void _UpdateBoneCount();
#endif
public:
void NSRenderableEntity(void);
@ -204,10 +171,43 @@ public:
/** Returns the axial/anisotropic scale of the entity, same as input format (forward, right, up) */
nonvirtual vector GetAxialScale(void);
#ifdef CLIENT
#ifdef CLIENT
/** Called by predraw(); and will set the appropriate rendering specific fields. */
nonvirtual void RenderFXPass(void);
nonvirtual void RenderAxialScale(void);
nonvirtual void RenderGLQuakeShadow(void);
#endif
};
#endif
private:
/* new */
PREDICTED_FLOAT(m_flBoneControl1)
PREDICTED_FLOAT(m_flBoneControl2)
PREDICTED_FLOAT(m_flBoneControl3)
PREDICTED_FLOAT(m_flBoneControl4)
PREDICTED_FLOAT(m_flBoneControl5)
PREDICTED_FLOAT_N(modelflags)
PREDICTED_INT(m_iBody)
PREDICTED_FLOAT_N(colormap)
PREDICTED_VECTOR_N(glowmod)
PREDICTED_FLOAT_N(frame1time)
PREDICTED_FLOAT(m_iRenderFX)
PREDICTED_FLOAT(m_iRenderMode)
PREDICTED_FLOAT(m_flRenderAmt)
PREDICTED_VECTOR(m_vecRenderColor)
PREDICTED_VECTOR(m_vecAxialScale)
/* either a sprite model or a particle */
PREDICTED_INT(m_iMuzzleModel)
PREDICTED_INT(m_iMuzzlePart)
PREDICTED_FLOAT(m_flMuzzleScale)
/* model events */
float m_flBaseTime;
#ifdef CLIENT
float m_iNumBones;
nonvirtual void _UpdateGeomset();
nonvirtual void _UpdateBoneCount();
#endif
};

View file

@ -1,11 +1,21 @@
/*
* Copyright (c) 2024 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class NSSound:NSPointTrigger {
float m_radius;
float m_volume;
string m_sample;
bool m_omniDirectional;
float m_offset;
public:
void NSSound( void );
nonvirtual void SetSample( string );
@ -17,6 +27,13 @@ class NSSound:NSPointTrigger {
nonvirtual void EnableReverb( void );
nonvirtual void DisableReverb( void );
nonvirtual virtual void Play( void );
private:
float m_radius;
float m_volume;
string m_sample;
bool m_omniDirectional;
float m_offset;
};
void NSSound::NSSound( void ) {

View file

@ -1,3 +1,18 @@
/*
* Copyright (c) 2024 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
enumflags
{

View file

@ -21,6 +21,12 @@
*/
class NSSpraylogo:NSEntity
{
public:
void NSSpraylogo(void);
virtual float predraw(void);
virtual void RendererRestarted(void);
private:
vector m_vecColor;
vector m_vecPosition;
@ -30,12 +36,6 @@ private:
string m_m_strPath;
bool m_bInitialized;
bool m_bMonochrome;
public:
void NSSpraylogo(void);
virtual float predraw(void);
virtual void RendererRestarted(void);
};
void Spray_Parse(void);

View file

@ -24,14 +24,6 @@ It has the ability to clean itself up afterwards, too.
class
NSTimer:NSEntity
{
private:
entity m_eReceiver;
float m_flTime;
bool m_bRepeats;
virtual void _TimerThink(void);
virtual void _TempTimerThink(void);
public:
void NSTimer(void);
@ -56,4 +48,12 @@ public:
virtual void Save(float);
virtual void Restore(string, string);
#endif
private:
entity m_eReceiver;
float m_flTime;
bool m_bRepeats;
virtual void _TimerThink(void);
virtual void _TempTimerThink(void);
};

View file

@ -31,25 +31,6 @@ _NSVehicle_Log(string className, string functionName, float edictNum, string war
*/
class NSVehicle:NSSurfacePropEntity
{
private:
int m_iVehicleFlags;
int m_iMoveButtons;
vector m_vecMoveValues;
NSEntity m_eDriver;
NSEntity m_eDriver_net;
NSEntity m_eDriverLast;
vector m_vecPlayerPos;
vector m_vecExitPos;
/* FIXME: Aren't those already defined in parent classes? */
PREDICTED_VECTOR_N(angles)
PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(velocity)
#ifdef CLIENT
PREDICTED_FLOAT(driver_entnum)
#endif
public:
void NSVehicle(void);
@ -84,6 +65,25 @@ public:
virtual bool CanDriverCrouch(void);
virtual bool PreventPlayerMovement(void);
virtual bool PreventPlayerFire(void);
private:
int m_iVehicleFlags;
int m_iMoveButtons;
vector m_vecMoveValues;
NSEntity m_eDriver;
NSEntity m_eDriver_net;
NSEntity m_eDriverLast;
vector m_vecPlayerPos;
vector m_vecExitPos;
/* FIXME: Aren't those already defined in parent classes? */
PREDICTED_VECTOR_N(angles)
PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(velocity)
#ifdef CLIENT
PREDICTED_FLOAT(driver_entnum)
#endif
};
enumflags