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();
|
float sh = GetSpawnHealth();
|
||||||
NSRenderableEntity::Respawn();
|
NSRenderableEntity::Respawn();
|
||||||
|
|
||||||
|
/* only use spawndata's health if we aren't overriding it */
|
||||||
if (HasPropData() == TRUE && sh == -1) {
|
if (HasPropData() == TRUE && sh == -1) {
|
||||||
health = (float)GetPropData(PROPINFO_HEALTH);
|
health = (float)GetPropData(PROPINFO_HEALTH);
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,16 +214,21 @@ NSSurfacePropEntity::Pain(void)
|
||||||
void
|
void
|
||||||
NSSurfacePropEntity::Death(void)
|
NSSurfacePropEntity::Death(void)
|
||||||
{
|
{
|
||||||
Hide();
|
|
||||||
|
|
||||||
UseOutput(g_dmg_eAttacker, m_strOnBreak);
|
UseOutput(g_dmg_eAttacker, m_strOnBreak);
|
||||||
|
|
||||||
if (HasPropData() == FALSE)
|
if (HasPropData() == FALSE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string gibeffect = GetPropData(PROPINFO_BREAKMODEL);
|
if (GetPropData(PROPINFO_SKIN) != 0) {
|
||||||
int breakcount = GetPropData(PROPINFO_BREAKCOUNT);
|
SetSkin(GetPropData(PROPINFO_SKIN));
|
||||||
BreakModel_Spawn(absmin, absmax, [0,0,0], 100, breakcount, gibeffect);
|
} 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 */
|
/* handle explosions */
|
||||||
float flExplodeMag, flExplodeRad;
|
float flExplodeMag, flExplodeRad;
|
||||||
|
@ -297,7 +303,7 @@ NSSurfacePropEntity::NSSurfacePropEntity(void)
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
m_iPropData = -1;
|
m_iPropData = -1;
|
||||||
m_iMaterial = -1;
|
m_iMaterial = -1;
|
||||||
health = -1;
|
m_oldHealth = health = -1;
|
||||||
|
|
||||||
super::NSRenderableEntity();
|
super::NSRenderableEntity();
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ typedef struct
|
||||||
string breakable_particle; /* name of BreakableModels entry in PropData.txt */
|
string breakable_particle; /* name of BreakableModels entry in PropData.txt */
|
||||||
string breakable_model; /* name of BreakableModels entry in PropData.txt */
|
string breakable_model; /* name of BreakableModels entry in PropData.txt */
|
||||||
int breakable_count;
|
int breakable_count;
|
||||||
|
float breakable_skin;
|
||||||
} propdata_t;
|
} propdata_t;
|
||||||
|
|
||||||
/* entity will have to have a .propdata field pointing to a propdata id */
|
/* entity will have to have a .propdata field pointing to a propdata id */
|
||||||
|
@ -105,7 +106,8 @@ typedef enum
|
||||||
PROPINFO_EXPLOSIVE_DMG,
|
PROPINFO_EXPLOSIVE_DMG,
|
||||||
PROPINFO_EXPLOSIVE_RADIUS,
|
PROPINFO_EXPLOSIVE_RADIUS,
|
||||||
PROPINFO_BREAKMODEL,
|
PROPINFO_BREAKMODEL,
|
||||||
PROPINFO_BREAKCOUNT
|
PROPINFO_BREAKCOUNT,
|
||||||
|
PROPINFO_SKIN
|
||||||
} propinfo_t;
|
} propinfo_t;
|
||||||
__variant Prop_GetInfo(int, int);
|
__variant Prop_GetInfo(int, int);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ Prop_GetInfo(int i, int type)
|
||||||
return (__variant)g_propdata[i].breakable_model;
|
return (__variant)g_propdata[i].breakable_model;
|
||||||
case PROPINFO_BREAKCOUNT:
|
case PROPINFO_BREAKCOUNT:
|
||||||
return (__variant)g_propdata[i].breakable_count;
|
return (__variant)g_propdata[i].breakable_count;
|
||||||
|
case PROPINFO_SKIN:
|
||||||
|
return (__variant)g_propdata[i].breakable_skin;
|
||||||
default:
|
default:
|
||||||
return __NULL__;
|
return __NULL__;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +119,9 @@ PropData_ParseField(int i, int a)
|
||||||
case "breakable_count":
|
case "breakable_count":
|
||||||
g_propdata[i].breakable_count = stoi(argv(1));
|
g_propdata[i].breakable_count = stoi(argv(1));
|
||||||
break;
|
break;
|
||||||
|
case "breakable_skin":
|
||||||
|
g_propdata[i].breakable_skin = stof(argv(1));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue