Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
heal.qc
Go to the documentation of this file.
1#include "heal.qh"
2#ifdef SVQC
5{
6 if (this.active != ACTIVE_ACTIVE)
7 return;
8
9 // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
10 if (toucher.iscreature)
11 {
12 if (toucher.takedamage && !IS_DEAD(toucher) && toucher.triggerhealtime < time)
13 {
14 bool is_trigger = this.targetname == "";
15 if(is_trigger)
17 if(this.delay > 0)
18 toucher.triggerhealtime = time + this.delay;
19
20 bool playthesound = (this.spawnflags & HEAL_SOUND_ALWAYS);
21 bool healed = Heal(toucher, this, this.health, this.max_health);
22
23 if(playthesound || healed)
25 }
26 }
27}
28
29void trigger_heal_use(entity this, entity actor, entity trigger)
30{
31 trigger_heal_touch(this, actor);
32}
33
35{
36 this.active = ACTIVE_ACTIVE;
37 if(!this.delay)
38 this.delay = 1;
39 if(!this.health)
40 this.health = 10;
41 if(!this.max_health)
42 this.max_health = 200; // max health topoff for field
43 if(this.noise == "")
44 this.noise = "misc/mediumhealth.wav";
46}
47
48spawnfunc(trigger_heal)
49{
53}
54
55spawnfunc(target_heal)
56{
57 this.use = trigger_heal_use;
59}
60#endif
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float max_health
float delay
Definition items.qc:17
int spawnflags
Definition ammo.qh:15
#define IS_DEAD(s)
Definition player.qh:245
float time
#define use
bool Heal(entity targ, entity inflictor, float amount, float limit)
Definition damage.qc:987
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
#define EXACTTRIGGER_INIT
Definition common.qh:116
void trigger_heal_touch(entity this, entity toucher)
Definition heal.qc:4
float triggerhealtime
Definition heal.qc:3
void trigger_heal_init(entity this)
Definition heal.qc:34
void trigger_heal_use(entity this, entity actor, entity trigger)
Definition heal.qc:29
const int HEAL_SOUND_ALWAYS
Definition heal.qh:4
string precache_sound(string sample)
float health
Legacy fields for the resources. To be removed.
Definition resources.qh:9
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
const int CH_TRIGGER
Definition sound.qh:12
const float VOL_BASE
Definition sound.qh:36
#define _sound(e, c, s, v, a)
Definition sound.qh:43
const float ATTEN_NORM
Definition sound.qh:30
#define spawnfunc(id)
Definition spawnfunc.qh:96
string noise
Definition subs.qh:83
string targetname
Definition triggers.qh:56