6 #include "../warpzonelib/util_server.qh"
7 #include "../common/weapons/all.qh"
8 #include "../common/deathtypes.qh"
13 * Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
14 * Author tZork (Jakob MG)
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 (!?)
23 void spawnfunc_trigger_swamp(void);
24 void swamp_touch(void);
25 void swampslug_think();
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)
36 * I do it this way becuz there is no "untouch" event.
39 * THE ACCTUAL slowdown is done in cl_physics.c on line 57-60
42 void swampslug_think(void)
44 //Slowly kill the slug
45 self.health = self.health - 1;
47 //Slug dead? then remove curses.
48 if(self.health <= 0) {
49 self.owner.in_swamp = 0;
51 //centerprint(self.owner,"Killing slug...\n");
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');
60 self.nextthink = time + self.swamp_interval;
63 void swamp_touch(void)
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)
72 // Chech if player alredy got a swampslug.
73 if(other.in_swamp != 1) {
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;
90 //Revitalize players swampslug
91 other.swampslug.health = 2;
94 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
95 Players gettin into the swamp will
96 get slowd down and damaged
98 void spawnfunc_trigger_swamp(void)
102 self.touch = swamp_touch;
104 // Setup default keys, if missing
107 if(self.swamp_interval <= 0)
108 self.swamp_interval = 1;
109 if(self.swamp_slowdown <= 0)
110 self.swamp_slowdown = 0.5;