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