]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/heal.qc
Fix bots waiting for a teamed item to spawn again once they got it (e.g. megas and...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / heal.qc
1 #include "heal.qh"
2 #ifdef SVQC
3 .float triggerhealtime;
4 void trigger_heal_touch(entity this, entity toucher)
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)
13                 if (!IS_DEAD(toucher))
14                 if (toucher.triggerhealtime < time)
15                 {
16                         EXACTTRIGGER_TOUCH(this, toucher);
17                         toucher.triggerhealtime = time + 1;
18
19                         if (toucher.health < this.max_health)
20                         {
21                                 toucher.health = min(toucher.health + this.health, this.max_health);
22                                 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
23                                 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
24                         }
25                 }
26         }
27 }
28
29 spawnfunc(trigger_heal)
30 {
31         this.active = ACTIVE_ACTIVE;
32
33         EXACTTRIGGER_INIT;
34         settouch(this, trigger_heal_touch);
35         if (!this.health)
36                 this.health = 10;
37         if (!this.max_health)
38                 this.max_health = 200; //Max health topoff for field
39         if(this.noise == "")
40                 this.noise = "misc/mediumhealth.wav";
41         precache_sound(this.noise);
42 }
43 #endif