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