]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/t_swamp.qc
fix useless reference to fireball_impact.wav
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_swamp.qc
1 /*
2 *               t_swamp.c
3 *               Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
4 *               Author tZork (Jakob MG) 
5 *               jakob@games43.se
6 *               2005 11 29
7 */
8
9 .float swamp_interval;  //Hurt players in swamp with this interval
10 .float swamp_slowdown;  //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
11 .entity swampslug;
12
13 void spawnfunc_trigger_swamp(void);
14 void swamp_touch(void);
15 void swampslug_think();
16
17
18 /*
19 * Uses a entity calld swampslug to handle players in the swamp
20 * It works like this: When the plyer enters teh swamp the spawnfunc_trigger_swamp
21 * attaches a new "swampslug" to the player. As long as the plyer is inside
22 * the swamp the swamp gives the slug new health. But the slug slowly kills itself
23 * so when the player goes outside the swamp, it dies and releases the player from the 
24 * swamps curses (dmg/slowdown) 
25
26 * I do it this way becuz there is no "untouch" event.
27 *
28 * --NOTE-- 
29 * THE ACCTUAL slowdown is done in cl_physics.c on line 57-60
30 * --NOTE--
31 */
32 void swampslug_think(void) 
33 {
34         //Slowly kill the slug
35         self.health = self.health - 1;
36
37         //Slug dead? then remove curses.
38         if(self.health <= 0) {
39                 self.owner.in_swamp = 0;
40                 remove(self);
41                 //centerprint(self.owner,"Killing slug...\n");
42                 return;
43         }
44         
45         // Slug still alive, so we are still in the swamp
46         // Or we have exited it very recently.
47         // Do the damage and renew the timer.
48         Damage (self.owner, self, self, self.dmg, DEATH_SWAMP, other.origin, '0 0 0');
49
50         self.nextthink = time + self.swamp_interval;
51 }
52
53 void swamp_touch(void) 
54 {
55         // If whatever thats touching the swamp is not a player
56         // or if its a dead player, just dont care abt it.
57         if((other.classname != "player")||(other.deadflag != DEAD_NO))
58                 return;
59
60         EXACTTRIGGER_TOUCH;
61
62         // Chech if player alredy got a swampslug.
63         if(other.in_swamp != 1) {
64                 // If not attach one.
65                 //centerprint(other,"Entering swamp!\n");
66                 other.swampslug = spawn();
67                 other.swampslug.health = 2;
68                 other.swampslug.think = swampslug_think;
69                 other.swampslug.nextthink = time;
70                 other.swampslug.owner = other;
71                 other.swampslug.dmg = self.dmg;
72                 other.swampslug.swamp_interval = self.swamp_interval;
73                 other.swamp_slowdown = self.swamp_slowdown;
74                 other.in_swamp = 1;
75                 return;
76         }
77
78         //other.in_swamp = 1;
79
80         //Revitalize players swampslug
81         other.swampslug.health = 2;
82 }
83
84 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
85 Players gettin into the swamp will 
86 get slowd down and damaged
87 */
88 void spawnfunc_trigger_swamp(void)
89 {
90         // Init stuff
91         EXACTTRIGGER_INIT;
92         self.touch = swamp_touch;       
93
94         // Setup default keys, if missing
95         if(self.dmg <= 0) 
96                 self.dmg = 5;
97         if(self.swamp_interval <= 0) 
98                 self.swamp_interval = 1;
99         if(self.swamp_slowdown <= 0) 
100                 self.swamp_slowdown = 0.5;
101 };