3 * Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
4 * Author tZork (Jakob MG)
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 (!?)
13 void spawnfunc_trigger_swamp(void);
14 void swamp_touch(void);
15 void swampslug_think();
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)
26 * I do it this way becuz there is no "untouch" event.
29 * THE ACCTUAL slowdown is done in cl_physics.c on line 57-60
32 void swampslug_think(void)
34 //Slowly kill the slug
35 self.health = self.health - 1;
37 //Slug dead? then remove curses.
38 if(self.health <= 0) {
39 self.owner.in_swamp = 0;
41 //centerprint(self.owner,"Killing slug...\n");
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');
50 self.nextthink = time + self.swamp_interval;
53 void swamp_touch(void)
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))
62 // Chech if player alredy got a swampslug.
63 if(other.in_swamp != 1) {
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;
80 //Revitalize players swampslug
81 other.swampslug.health = 2;
84 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
85 Players gettin into the swamp will
86 get slowd down and damaged
88 void spawnfunc_trigger_swamp(void)
92 self.touch = swamp_touch;
94 // Setup default keys, if missing
97 if(self.swamp_interval <= 0)
98 self.swamp_interval = 1;
99 if(self.swamp_slowdown <= 0)
100 self.swamp_slowdown = 0.5;