NSSurfaceProp/PropData: Add support for breakable_skin. When a prop 'dies'
it doesn't necessarily have to disappear, it can change its material to one of your choosing.
This commit is contained in:
parent
92bb821ad9
commit
2c80a9f9ff
3 changed files with 20 additions and 7 deletions
|
@ -94,6 +94,7 @@ NSSurfacePropEntity::Respawn(void)
|
|||
float sh = GetSpawnHealth();
|
||||
NSRenderableEntity::Respawn();
|
||||
|
||||
/* only use spawndata's health if we aren't overriding it */
|
||||
if (HasPropData() == TRUE && sh == -1) {
|
||||
health = (float)GetPropData(PROPINFO_HEALTH);
|
||||
} else {
|
||||
|
@ -213,16 +214,21 @@ NSSurfacePropEntity::Pain(void)
|
|||
void
|
||||
NSSurfacePropEntity::Death(void)
|
||||
{
|
||||
Hide();
|
||||
|
||||
UseOutput(g_dmg_eAttacker, m_strOnBreak);
|
||||
|
||||
if (HasPropData() == FALSE)
|
||||
return;
|
||||
|
||||
string gibeffect = GetPropData(PROPINFO_BREAKMODEL);
|
||||
int breakcount = GetPropData(PROPINFO_BREAKCOUNT);
|
||||
BreakModel_Spawn(absmin, absmax, [0,0,0], 100, breakcount, gibeffect);
|
||||
if (GetPropData(PROPINFO_SKIN) != 0) {
|
||||
SetSkin(GetPropData(PROPINFO_SKIN));
|
||||
} else if (GetPropData(PROPINFO_BREAKMODEL)) {
|
||||
string gibeffect = GetPropData(PROPINFO_BREAKMODEL);
|
||||
int breakcount = GetPropData(PROPINFO_BREAKCOUNT);
|
||||
BreakModel_Spawn(absmin, absmax, [0,0,0], 100, breakcount, gibeffect);
|
||||
Hide();
|
||||
} else {
|
||||
Hide();
|
||||
}
|
||||
|
||||
/* handle explosions */
|
||||
float flExplodeMag, flExplodeRad;
|
||||
|
@ -297,7 +303,7 @@ NSSurfacePropEntity::NSSurfacePropEntity(void)
|
|||
#ifdef SERVER
|
||||
m_iPropData = -1;
|
||||
m_iMaterial = -1;
|
||||
health = -1;
|
||||
m_oldHealth = health = -1;
|
||||
|
||||
super::NSRenderableEntity();
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct
|
|||
string breakable_particle; /* name of BreakableModels entry in PropData.txt */
|
||||
string breakable_model; /* name of BreakableModels entry in PropData.txt */
|
||||
int breakable_count;
|
||||
float breakable_skin;
|
||||
} propdata_t;
|
||||
|
||||
/* entity will have to have a .propdata field pointing to a propdata id */
|
||||
|
@ -105,7 +106,8 @@ typedef enum
|
|||
PROPINFO_EXPLOSIVE_DMG,
|
||||
PROPINFO_EXPLOSIVE_RADIUS,
|
||||
PROPINFO_BREAKMODEL,
|
||||
PROPINFO_BREAKCOUNT
|
||||
PROPINFO_BREAKCOUNT,
|
||||
PROPINFO_SKIN
|
||||
} propinfo_t;
|
||||
__variant Prop_GetInfo(int, int);
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ Prop_GetInfo(int i, int type)
|
|||
return (__variant)g_propdata[i].breakable_model;
|
||||
case PROPINFO_BREAKCOUNT:
|
||||
return (__variant)g_propdata[i].breakable_count;
|
||||
case PROPINFO_SKIN:
|
||||
return (__variant)g_propdata[i].breakable_skin;
|
||||
default:
|
||||
return __NULL__;
|
||||
}
|
||||
|
@ -117,6 +119,9 @@ PropData_ParseField(int i, int a)
|
|||
case "breakable_count":
|
||||
g_propdata[i].breakable_count = stoi(argv(1));
|
||||
break;
|
||||
case "breakable_skin":
|
||||
g_propdata[i].breakable_skin = stof(argv(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue