+#include "heal.qh"
#ifdef SVQC
.float triggerhealtime;
-void trigger_heal_touch(entity this)
+void trigger_heal_touch(entity this, entity toucher)
{
if (this.active != ACTIVE_ACTIVE)
return;
// only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
- if (other.iscreature)
+ if (toucher.iscreature)
{
- if (other.takedamage)
- if (!IS_DEAD(other))
- if (other.triggerhealtime < time)
+ if (toucher.takedamage)
+ if (!IS_DEAD(toucher))
+ if (toucher.triggerhealtime < time)
{
- EXACTTRIGGER_TOUCH;
- other.triggerhealtime = time + 1;
+ bool is_trigger = !boolean(!this.nottargeted && this.targetname != "");
+ if(is_trigger)
+ EXACTTRIGGER_TOUCH(this, toucher);
+ if(this.delay > 0)
+ toucher.triggerhealtime = time + this.delay;
- if (other.health < this.max_health)
+ bool playthesound = (this.spawnflags & 4);
+ if (toucher.health < this.max_health)
{
- other.health = min(other.health + this.health, this.max_health);
- other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
- _sound (other, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
+ playthesound = true;
+ toucher.health = min(toucher.health + this.health, this.max_health);
+ toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
}
+
+ if(playthesound)
+ _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
}
}
}
-spawnfunc(trigger_heal)
+void trigger_heal_use(entity this, entity actor, entity trigger)
{
- this.active = ACTIVE_ACTIVE;
+ trigger_heal_touch(this, actor);
+}
- EXACTTRIGGER_INIT;
- settouch(this, trigger_heal_touch);
- if (!this.health)
+void trigger_heal_init(entity this)
+{
+ this.active = ACTIVE_ACTIVE;
+ if(!this.delay)
+ this.delay = 1;
+ if(!this.health)
this.health = 10;
- if (!this.max_health)
- this.max_health = 200; //Max health topoff for field
+ if(!this.max_health)
+ this.max_health = 200; // max health topoff for field
if(this.noise == "")
this.noise = "misc/mediumhealth.wav";
precache_sound(this.noise);
}
+
+spawnfunc(trigger_heal)
+{
+ EXACTTRIGGER_INIT;
+ settouch(this, trigger_heal_touch);
+ trigger_heal_init(this);
+}
+
+spawnfunc(target_heal)
+{
+ this.use = trigger_heal_use;
+ trigger_heal_init(this);
+}
#endif