env_sprite: Hack to accept materials instead of models

func_breakable: Some minor fixes
prop_physics/func_physbox: Add PHYSICS_STATIC ifdef for when a game does not want fakephysics either
NSSurfacePropEntity: max_health will now be set along with health in SpawnKey()
This commit is contained in:
Marco Cawthorne 2022-04-16 18:42:38 -07:00
parent 274686a0df
commit a34c9a8059
Signed by: eukara
GPG key ID: C196CD8BA993248A
6 changed files with 117 additions and 5 deletions

View file

@ -19,13 +19,50 @@ class env_sprite:NSRenderableEntity
float framerate;
int loops;
int maxframe;
string m_strMaterial;
virtual float(void) predraw;
virtual void(void) Init;
virtual void(void) Initialized;
virtual void(float,float) ReceiveEntity;
virtual void(void) think;
};
float
env_sprite::predraw(void)
{
if (!m_strMaterial)
return (PREDRAW_NEXT);
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
vector vecPlayer = pSeat->m_vecPredictedOrigin;
makevectors(view_angles);
makevectors(vectoangles(origin - vecPlayer));
vector forg = origin + (v_forward * -16);
vector fsize = [64,64];
traceline(origin, vecPlayer, MOVE_WORLDONLY, this);
if (trace_fraction < 1.0)
return;
R_BeginPolygon(m_strMaterial, 1, 0);
R_PolygonVertex(forg + v_right * fsize[0] - v_up * fsize[1],
[1,1], m_vecRenderColor, 1.0);
R_PolygonVertex(forg - v_right * fsize[0] - v_up * fsize[1],
[0,1], m_vecRenderColor, 1.0);
R_PolygonVertex(forg - v_right * fsize[0] + v_up * fsize[1],
[0,0], m_vecRenderColor, 1.0);
R_PolygonVertex(forg + v_right * fsize[0] + v_up * fsize[1],
[1,0], m_vecRenderColor, 1.0);
R_EndPolygon();
addentity(this);
return (PREDRAW_NEXT);
}
void
env_sprite::think(void)
{
@ -51,6 +88,7 @@ env_sprite::ReceiveEntity(float flNew, float flChanged)
modelindex = readfloat();
framerate = readfloat();
scale = readfloat();
m_strMaterial = readstring();
#ifdef GS_RENDERFX
m_iRenderFX = readbyte();
@ -92,6 +130,7 @@ EnvSprite_ParseEvent(void)
spr.modelindex = readfloat();
spr.framerate = readfloat();
spr.scale = readfloat();
spr.m_strMaterial = readstring();
#ifdef GS_RENDERFX
spr.m_iRenderFX = readbyte();

View file

@ -48,17 +48,33 @@ enumflags
class env_sprite:NSRenderableEntity
{
bool m_iIsShader;
int m_iToggled;
float m_flFramerate;
float m_flScale;
float m_flEffects;
string m_strMaterial;
void(void) env_sprite;
virtual void(entity, int) Trigger;
virtual float(entity, float) SendEntity;
virtual void(string, string) SpawnKey;
virtual void(entity, string, string) Input;
};
void
env_sprite::Input(entity eAct, string strInput, string strData)
{
switch (strInput) {
case "Color":
m_vecRenderColor = stov(strData) / 255;
SendFlags |= 1;
break;
default:
super::Input(eAct, strInput, strData);
}
}
float
env_sprite::SendEntity(entity ePEnt, float flags)
{
@ -80,6 +96,7 @@ env_sprite::SendEntity(entity ePEnt, float flags)
WriteFloat(MSG_ENTITY, modelindex);
WriteFloat(MSG_ENTITY, m_flFramerate);
WriteFloat(MSG_ENTITY, m_flScale);
WriteString(MSG_ENTITY, m_strMaterial);
#ifdef GS_RENDERFX
WriteByte(MSG_ENTITY, m_iRenderFX);
@ -109,6 +126,7 @@ env_sprite::NetworkOnce(void)
WriteFloat(MSG_MULTICAST, modelindex);
WriteFloat(MSG_MULTICAST, m_flFramerate);
WriteFloat(MSG_MULTICAST, m_flScale);
WriteString(MSG_MULTICAST, m_strMaterial);
#ifdef GS_RENDERFX
WriteByte(MSG_MULTICAST, m_iRenderFX);
@ -144,6 +162,10 @@ void
env_sprite::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "shader":
case "material":
m_strMaterial = strValue;
break;
case "framerate":
m_flFramerate = stof(strValue);
break;
@ -158,6 +180,7 @@ env_sprite::SpawnKey(string strKey, string strValue)
void
env_sprite::env_sprite(void)
{
m_iIsShader = false;
m_flFramerate = 10;
m_flScale = 1.0f;

View file

@ -218,7 +218,6 @@ func_breakable::Death(void)
return;
}
health = 0;
eActivator = g_dmg_eAttacker;
if (m_strBreakSpawn != "" && isfunction(m_strBreakSpawn)) {
@ -241,9 +240,8 @@ func_breakable::Death(void)
nextthink = time + random(0.0,0.5);
} else {
FX_BreakModel(vlen(size) / 10, absmin, absmax, [0,0,0], GetSurfaceData(SURFDATA_MATERIAL));
/* TODO: ability to have whoever destroyed the crate be the activator */
UseTargets(this, TRIG_TOGGLE, 0.0f);
Hide();
UseTargets(eActivator, TRIG_TOGGLE, 0.0f);
}
}

View file

@ -24,6 +24,7 @@ Physics brush.
This entity was introduced in Half-Life 2 (2004).
*/
#ifndef PHYSICS_STATIC
#define FNCPHYBX_ASLEEP 4096
class func_physbox:NSPhysicsEntity
@ -57,3 +58,33 @@ func_physbox::func_physbox(void)
{
super::NSPhysicsEntity();
}
#else
class func_physbox:NSSurfacePropEntity
{
void(void) func_physbox;
virtual void(void) Respawn;
virtual void(void) Death;
};
void
func_physbox::Death(void)
{
Hide();
}
void
func_physbox::Respawn(void)
{
NSSurfacePropEntity::Respawn();
health = GetSpawnHealth();
SetTakedamage(DAMAGE_YES);
SetSolid(SOLID_BBOX);
}
void
func_physbox::func_physbox(void)
{
super::NSSurfacePropEntity();
}
#endif

View file

@ -24,6 +24,7 @@ Physics model
This entity was introduced in Half-Life 2 (2004).
*/
#ifndef PHYSICS_STATIC
#define PRPPHYS_ASLEEP 1
class prop_physics:NSPhysicsEntity
@ -56,4 +57,24 @@ void
prop_physics::prop_physics(void)
{
super::NSPhysicsEntity();
}
}
#else
class prop_physics:NSRenderableEntity
{
void(void) prop_physics;
virtual void(void) Respawn;
};
void
prop_physics::Respawn(void)
{
super::Respawn();
SetSolid(SOLID_BBOX);
}
void
prop_physics::prop_physics(void)
{
super::NSRenderableEntity();
}
#endif

View file

@ -215,7 +215,7 @@ NSSurfacePropEntity::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
health = stof(strValue);
max_health = health = stof(strValue);
m_oldHealth = health;
break;
case "propdata":