func_brush: Ironed out most of the behaviour, thanks Xylemon for creating

a great test map documenting how this entity should behave in Source.
This commit is contained in:
Marco Cawthorne 2021-07-12 10:15:00 +02:00
parent e13323e07d
commit 8a2820f15b

View file

@ -15,26 +15,28 @@
*/ */
/*QUAKED func_brush (0 .5 .8) ? /*QUAKED func_brush (0 .5 .8) ?
Combination of func_illusionary, func_wall, func_wall_toggle.
When triggered, it'll become invisible and lose its collision.
-------- KEYS --------
"targetname" Name "targetname" Name
"Solidity" Mode for choosing solidity: "Solidity" Mode for choosing solidity:
0 - Toggle 0 - Toggle
1 - Not solid 1 - Never solid
2 - Solid 2 - Always Solid
"StartDisabled" Only valid when Solidity is 0. Will make it spawn invisible "StartDisabled" Will make it spawn invisible and without collision.
and without collision.
"solidbsp" Type of collision model to choose "solidbsp" Type of collision model to choose
"excludednpc" Name of the NPC classname that will not collide with this "excludednpc" Name of the NPC classname that will not collide with this
entity entity
"invert_exclusion" Set to 1 if you want the 'excludednpc' key to act inverted "invert_exclusion" Set to 1 if you want the 'excludednpc' key to act inverted
Description: -------- NOTES --------
Combination of func_illusionary, func_wall, func_wall_toggle. The main thing func_brush is concerned with is appearance, if it's toggled on
Triggering it causes to become invisible if the key 'Solidity' is set to 0 as it will always become visible, when toggled off it'll always be invisible.
well as lose its collision. Collision however depends on the setting of the "Solidity" key.
-------- HISTORY --------
Trivia:
This entity was introduced in Half-Life 2 (2004). This entity was introduced in Half-Life 2 (2004).
*/ */
@ -53,20 +55,37 @@ class func_brush:CBaseTrigger
void void
func_brush::Trigger(entity act, int state) func_brush::Trigger(entity act, int state)
{ {
switch (state) { /* collision */
case TRIG_OFF: switch (m_iSolidity) {
case 1:
SetSolid(SOLID_NOT); SetSolid(SOLID_NOT);
break; break;
case TRIG_ON: case 2:
SetSolid(SOLID_BSP); SetSolid(SOLID_BSP);
break; break;
default: default:
SetSolid(solid == SOLID_BSP ? SOLID_NOT : SOLID_BSP); switch (state) {
case TRIG_OFF:
SetSolid(SOLID_NOT);
break;
case TRIG_ON:
SetSolid(SOLID_BSP);
break;
default:
SetSolid(modelindex != 0 ? SOLID_NOT : SOLID_BSP);
}
} }
/* toggle appareance */ /* visual */
if (m_iSolidity == 0) { switch (state) {
if (solid == SOLID_NOT) case TRIG_OFF:
SetModelindex(0);
break;
case TRIG_ON:
SetModel(m_oldModel);
break;
default:
if (modelindex != 0)
SetModelindex(0); SetModelindex(0);
else else
SetModel(m_oldModel); SetModel(m_oldModel);
@ -100,20 +119,11 @@ func_brush::Respawn(void)
SetModel(m_oldModel); SetModel(m_oldModel);
SetOrigin(m_oldOrigin); SetOrigin(m_oldOrigin);
switch (m_iSolidity) { /* make sure solid and so on are set */
case 1: if (m_iStartOff) {
SetSolid(SOLID_NOT); Trigger(this, TRIG_OFF);
break; } else {
case 2: Trigger(this, TRIG_ON);
SetSolid(SOLID_BSP);
break;
default:
if (m_iStartOff) {
SetSolid(SOLID_NOT);
SetModelindex(0);
} else {
SetSolid(SOLID_BSP);
}
} }
} }
@ -121,4 +131,5 @@ void
func_brush::func_brush(void) func_brush::func_brush(void)
{ {
CBaseTrigger::CBaseTrigger(); CBaseTrigger::CBaseTrigger();
Respawn();
} }