nuclide/Source/gs-entbase/server/trigger_hurt.cpp
Marco Hladik 9ce909e291 - Added Rewolf decore_* entities from the demo
- Added early Rewolf Health/Armor HUD variants
- Added original scoreboard from the early Half-Life versions for valve/scihunt/rewolf
- Fixed some skybox behaviour to only apply to BSP30
- Changed the env_message and game_text display to use "creditsfont" instead of the conchars
- Tweaked damage radius and prediction for some entities and weapons
- Added world_items
- Added item_healthkit
- Added item_battery
- Fixed level transition logic
- impulse 101 now fills up health and armor/suit in mod valve
- Some tweaks to Damage_Apply so that healing can be performed without funky visuals
- Added stub monsters for valve/rewolf that'll soon support scripted sequences
- Tweaked chat system to get rid of quotation marks around messages
- Added support for changing the window caption to reflect the mod you're playing
- Lots of small little things in terms of cleanup
2019-03-19 20:01:24 +01:00

118 lines
2.3 KiB
C++

/***
*
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
*
* See the file LICENSE attached with the sources for usage details.
*
****/
#define SF_HURT_ONCE 1 // Turn off once it fired the first time
#define SF_HURT_OFF 2 // Needs to be triggered in order to work again
#define SF_HURT_NOPLAYERS 8 // Don't hurt players
#define SF_HURT_FIREONPLAYER 16 // Only call UseTarget functions when it's a player
#define SF_HURT_TOUCHPLAYER 32 // Only hurt players
class trigger_hurt:CBaseTrigger
{
float m_flNextTrigger;
int m_iDamage;
float m_flDelay;
void() trigger_hurt;
virtual void() Trigger;
virtual void() Touch;
virtual void() Respawn;
};
void trigger_hurt::Trigger(void)
{
if (solid != SOLID_NOT) {
#ifdef GS_DEVELOPER
print("trigger_hurt: de-activated.\n");
#endif
solid = SOLID_NOT;
touch = __NULL__;
} else {
#ifdef GS_DEVELOPER
print("trigger_hurt: activated.\n");
#endif
solid = SOLID_TRIGGER;
touch = Touch;
}
}
void trigger_hurt::Touch(void)
{
if (m_flNextTrigger > time) {
return;
} else if (other.takedamage == DAMAGE_NO) {
return;
} else if ((spawnflags & SF_HURT_TOUCHPLAYER) && !(other.flags & FL_CLIENT)) {
return;
} else if ((spawnflags & SF_HURT_NOPLAYERS) && (other.flags & FL_CLIENT)) {
return;
}
if (spawnflags & SF_HURT_FIREONPLAYER) {
if (other.flags & FL_CLIENT) {
if (m_flDelay > 0) {
CBaseTrigger::UseTargets_Delay(m_flDelay);
} else {
CBaseTrigger::UseTargets();
}
}
} else {
if (m_flDelay > 0) {
CBaseTrigger::UseTargets_Delay(m_flDelay);
} else {
CBaseTrigger::UseTargets();
}
}
Damage_Apply(other, this, m_iDamage, other.origin, FALSE);
// Shut it down if used once
if (spawnflags & SF_HURT_ONCE) {
Trigger();
}
m_flNextTrigger = time + 0.5;
}
void trigger_hurt::Respawn(void)
{
#ifdef GS_DEVELOPER
alpha = 0.5f;
#endif
m_flNextTrigger = 0;
if (spawnflags & SF_HURT_OFF) {
solid = SOLID_NOT;
touch = __NULL__;
} else {
solid = SOLID_TRIGGER;
touch = Touch;
}
}
void trigger_hurt::trigger_hurt(void)
{
for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
switch (argv(i)) {
case "dmg":
m_iDamage = stoi(argv(i+1));
break;
case "wait":
case "delay":
m_flDelay = stof(argv(i+1));
break;
default:
break;
}
}
CBaseEntity::CBaseEntity();
CBaseTrigger::InitBrushTrigger();
trigger_hurt::Respawn();
}