3 * Adds trigger_swamp and suppoart routines for nexuiz 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 (!?)
11 .float swamp_ticker; //Used localy by the swampslug to calculate when to hurt the player and check the slug.
14 void trigger_swamp(void);
15 void swamp_touch(void);
16 void swampslug_think();
20 * Uses a entity calld swampslug to handle players in the swamp
21 * It works like this: When the plyer enters teh swamp the trigger_swamp
22 * attaches a new "swampslug" to the player. As long as the plyer is inside
23 * the swamp the swamp gives the slug new health. But the slug slowly kills itself
24 * so when the player goes outside the swamp, it dies and releases the player from the
25 * swamps curses (dmg/slowdown)
27 * I do it this way becuz there is no "untouch" event.
30 * THE ACCTUAL slowdown is done in cl_physics.c on line 57-60
33 void swampslug_think(void)
36 //Slowly kill the slug
37 self.health = self.health - 1;
39 //Slug dead? then remove curses.
40 if(self.health <= 0) {
41 self.owner.in_swamp = 0;
43 //centerprint(self.owner,"Killing slug...\n");
47 // Slug still alive, so we are still in the swamp
48 // Or we have exited it very recently.
49 // Do the damage and renew the timer.
50 Damage (self.owner, self, self, self.dmg, DEATH_SWAMP, other.origin, '0 0 0');
51 self.swamp_ticker = time + self.swamp_interval;
53 self.nextthink = time + self.swamp_interval;
57 void swamp_touch(void)
60 // If whatever thats touching the swamp is not a player
61 // or if its a dead player, just dont care abt it.
62 if((other.classname != "player")||(other.deadflag != DEAD_NO))
65 // Chech if player alredy got a swampslug.
66 if(other.in_swamp != 1) {
68 //centerprint(other,"Entering swamp!\n");
69 other.swampslug = spawn();
70 other.swampslug.health = 2;
71 other.swampslug.think = swampslug_think;
72 other.swampslug.nextthink = time;
73 other.swampslug.owner = other;
74 other.swampslug.dmg = self.dmg;
75 other.swampslug.swamp_interval = self.swamp_interval;
76 other.swamp_slowdown = self.swamp_slowdown;
83 //Revitalize players swampslug
84 other.swampslug.health = 2;
87 /*QUAKED trigger_swamp (.5 .5 .5) ?
88 Players gettin into the swamp will
89 get slowd down and damaged
91 void trigger_swamp(void)
95 self.touch = swamp_touch;
97 // Setup default keys, if missing
100 if(self.swamp_interval <= 0)
101 self.swamp_interval = 1;
102 if(self.swamp_slowdown <= 0)
103 self.swamp_slowdown = 0.5;