]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/heal.qc
Merge branch 'master' into terencehill/infomessages_panel_update
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / heal.qc
1 #ifdef SVQC
2 .float triggerhealtime;
3 void trigger_heal_touch(entity this)
4 {
5         if (this.active != ACTIVE_ACTIVE)
6                 return;
7
8         // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
9         if (other.iscreature)
10         {
11                 if (other.takedamage)
12                 if (!IS_DEAD(other))
13                 if (other.triggerhealtime < time)
14                 {
15                         EXACTTRIGGER_TOUCH;
16                         other.triggerhealtime = time + 1;
17
18                         if (other.health < this.max_health)
19                         {
20                                 other.health = min(other.health + this.health, this.max_health);
21                                 other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
22                                 _sound (other, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
23                         }
24                 }
25         }
26 }
27
28 spawnfunc(trigger_heal)
29 {
30         this.active = ACTIVE_ACTIVE;
31
32         EXACTTRIGGER_INIT;
33         settouch(this, trigger_heal_touch);
34         if (!this.health)
35                 this.health = 10;
36         if (!this.max_health)
37                 this.max_health = 200; //Max health topoff for field
38         if(this.noise == "")
39                 this.noise = "misc/mediumhealth.wav";
40         precache_sound(this.noise);
41 }
42 #endif