]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/heal.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[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                         bool is_trigger = !boolean(!this.nottargeted && this.targetname != "");
17                         if(is_trigger)
18                                 EXACTTRIGGER_TOUCH(this, toucher);
19                         toucher.triggerhealtime = time + 1;
20
21                         if (toucher.health < this.max_health)
22                         {
23                                 toucher.health = min(toucher.health + this.health, this.max_health);
24                                 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
25                                 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
26                         }
27                 }
28         }
29 }
30
31 void trigger_heal_use(entity this, entity actor, entity trigger)
32 {
33         trigger_heal_touch(this, actor);
34 }
35
36 spawnfunc(trigger_heal)
37 {
38         this.active = ACTIVE_ACTIVE;
39
40         EXACTTRIGGER_INIT;
41         settouch(this, trigger_heal_touch);
42         if (!this.health)
43                 this.health = 10;
44         if (!this.max_health)
45                 this.max_health = 200; //Max health topoff for field
46         if(this.noise == "")
47                 this.noise = "misc/mediumhealth.wav";
48         precache_sound(this.noise);
49 }
50
51 spawnfunc(target_heal)
52 {
53         this.active = ACTIVE_ACTIVE;
54         this.use = trigger_heal_use;
55         if (!this.health)
56                 this.health = 10;
57         if (!this.max_health)
58                 this.max_health = 200; //Max health topoff for field
59         if(this.noise == "")
60                 this.noise = "misc/mediumhealth.wav";
61         precache_sound(this.noise);
62 }
63 #endif