NSSurfacePropEntity: add SetCanBleed() and CanBleed() methods to abstract the old iBleeds field.

This commit is contained in:
Marco Cawthorne 2023-04-22 01:05:27 -07:00
parent f00d49e6ca
commit 3a755aaba7
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
9 changed files with 46 additions and 14 deletions

View File

@ -14,6 +14,17 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
string
Event_DataToMuzzleflash(string dataString)
{
float id = stof(substring(dataString, 0, 1)) - 1;
if (id)
return strcat("sprites/muzzleflash", ftos(id), ".spr");
else
return "sprites/muzzleflash.spr";
}
/*
====================
Event_ProcessModel
@ -48,23 +59,27 @@ Event_ProcessModel(float flTimeStamp, int iCode, string strData)
break;
case 5001: /* muzzle flash on attachment 0 */
pSeat->m_eMuzzleflash.alpha = 1.0f;
pSeat->m_eMuzzleflash.scale = 0.5;
pSeat->m_eMuzzleflash.scale = 0.35;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones;
setmodel(pSeat->m_eMuzzleflash, Event_DataToMuzzleflash(strData));
break;
case 5011: /* muzzle flash on attachment 1 */
pSeat->m_eMuzzleflash.alpha = 1.0f;
pSeat->m_eMuzzleflash.scale = 0.5;
pSeat->m_eMuzzleflash.scale = 0.35;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 1;
setmodel(pSeat->m_eMuzzleflash, Event_DataToMuzzleflash(strData));
break;
case 5021: /* muzzle flash on attachment 2 */
pSeat->m_eMuzzleflash.alpha = 1.0f;
pSeat->m_eMuzzleflash.scale = 0.5;
pSeat->m_eMuzzleflash.scale = 0.35;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 2;
setmodel(pSeat->m_eMuzzleflash, Event_DataToMuzzleflash(strData));
break;
case 5031: /* muzzle flash on attachment 3 */
pSeat->m_eMuzzleflash.alpha = 1.0f;
pSeat->m_eMuzzleflash.scale = 0.5;
pSeat->m_eMuzzleflash.scale = 0.35;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 3;
setmodel(pSeat->m_eMuzzleflash, Event_DataToMuzzleflash(strData));
break;
default:
print(sprintf("Unknown model event: %f %i %S\n", flTimeStamp, iCode, strData));

View File

@ -138,9 +138,9 @@ muzzleflash, dynamic lights and so on appear
void
View_DrawViewModel(void)
{
NSRenderableEntity m_eViewModel = pSeat->m_eViewModel;
NSRenderableEntity m_eViewModel = (NSRenderableEntity)pSeat->m_eViewModel;
entity m_eMuzzleflash = pSeat->m_eMuzzleflash;
NSRenderableEntity m_eViewModelL = pSeat->m_eViewModelL;
NSRenderableEntity m_eViewModelL = (NSRenderableEntity)pSeat->m_eViewModelL;
entity m_eMuzzleflashL = pSeat->m_eMuzzleflashL;
player pl = __NULL__;

View File

@ -66,6 +66,6 @@ monster_generic::Respawn(void)
if (HasSpawnFlags(MGF_NONSOLID)) {
takedamage = DAMAGE_NO;
SetSolid(SOLID_NOT);
iBleeds = FALSE;
SetCanBleed(false);
}
}

View File

@ -28,7 +28,7 @@ NSTraceAttack:NSIO
{
private:
/* multi-part damage */
entity m_eMultiTarget;
NSSurfacePropEntity m_eMultiTarget;
int m_iMultiValue;
int m_iMultiBody;

View File

@ -66,7 +66,7 @@ NSTraceAttack::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_eMultiTarget":
m_eMultiTarget = ReadEntity(strValue);
m_eMultiTarget = (NSSurfacePropEntity)ReadEntity(strValue);
break;
case "m_iMultiValue":
m_iMultiValue = ReadInt(strValue);
@ -123,7 +123,7 @@ NSTraceAttack::_ApplyDamage(void)
return;
/* the location _could_ be more accurate... */
if (m_eMultiTarget.iBleeds == 1) {
if (m_eMultiTarget.CanBleed() == true) {
FX_Blood(trace_endpos, [0.5,0,0]);
}
@ -235,7 +235,7 @@ NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, floa
if (trace_ent.takedamage == DAMAGE_YES) {
if (trace_ent != m_eMultiTarget) {
_ApplyDamage();
m_eMultiTarget = trace_ent;
m_eMultiTarget = (NSSurfacePropEntity)trace_ent;
m_iMultiValue = flDamage;
} else {
m_iMultiValue += flDamage;

View File

@ -832,7 +832,7 @@ NSClientPlayer::Death(void)
SetVelocity([0,0,0]);
SetGravity(1.0f);
customphysics = Empty;
iBleeds = FALSE;
SetCanBleed(false);
setsize(this, [0,0,0], [0,0,0]);
forceinfokey(this, "*deaths", ftos(deaths));
forceinfokey(this, "*dead", "1");
@ -867,7 +867,7 @@ NSClientPlayer::MakePlayer(void)
SetGravity(1.0f);
SendFlags = UPDATE_ALL;
customphysics = Empty;
iBleeds = TRUE;
SetCanBleed(true);
scale = 1.0f;
SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
forceinfokey(this, "*spectator", "0");

View File

@ -886,7 +886,7 @@ NSMonster::Respawn(void)
SetHealth(base_health);
m_eEnemy = __NULL__;
m_iFlags = 0x0;
iBleeds = TRUE;
SetCanBleed(true);
customphysics = Physics;
SetAngles(v_angle);

View File

@ -109,6 +109,11 @@ public:
/** Returns whether or not the entity is alive. */
virtual bool IsAlive(void);
/** Sets whether the entity can bleed. */
nonvirtual void SetCanBleed(bool);
/** Returns whether the entity can bleed. */
nonvirtual bool CanBleed(void);
/* Generic Damage */
/** Sets whether the entity can take damage */
nonvirtual void SetTakedamage(float);

View File

@ -64,6 +64,18 @@ NSSurfacePropEntity::IsAlive(void)
return (health > 0) ? true : false;
}
void
NSSurfacePropEntity::SetCanBleed(bool bleedValue)
{
iBleeds = bleedValue;
}
bool
NSSurfacePropEntity::CanBleed(void)
{
return iBleeds;
}
#if 0
typedef enum
{