Cleanse the touch functions of the other evil
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / heal.qc
1 #ifdef SVQC
2 .float triggerhealtime;
3 void trigger_heal_touch(entity this, entity toucher)
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 (toucher.iscreature)
10         {
11                 if (toucher.takedamage)
12                 if (!IS_DEAD(toucher))
13                 if (toucher.triggerhealtime < time)
14                 {
15                         EXACTTRIGGER_TOUCH(this, toucher);
16                         toucher.triggerhealtime = time + 1;
17
18                         if (toucher.health < this.max_health)
19                         {
20                                 toucher.health = min(toucher.health + this.health, this.max_health);
21                                 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
22                                 _sound (toucher, 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