4 #include "../../../server/_all.qh"
5 #include "../../../warpzonelib/util_server.qh"
6 #include "../../weapons/all.qh"
7 #include "../../../server/defs.qh"
8 #include "../../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 (!?)
24 void spawnfunc_trigger_swamp(void);
26 void swamp_touch(void);
27 void swampslug_think();
31 * Uses a entity calld swampslug to handle players in the swamp
32 * It works like this: When the plyer enters teh swamp the spawnfunc_trigger_swamp
33 * attaches a new "swampslug" to the player. As long as the plyer is inside
34 * the swamp the swamp gives the slug new health. But the slug slowly kills itself
35 * so when the player goes outside the swamp, it dies and releases the player from the
36 * swamps curses (dmg/slowdown)
38 * I do it this way becuz there is no "untouch" event.
40 void swampslug_think(void)
42 //Slowly kill the slug
43 self.health = self.health - 1;
45 //Slug dead? then remove curses.
48 self.owner.in_swamp = 0;
50 //centerprint(self.owner,"Killing slug...\n");
54 // Slug still alive, so we are still in the swamp
55 // Or we have exited it very recently.
56 // Do the damage and renew the timer.
58 Damage (self.owner, self, self, self.dmg, DEATH_SWAMP, other.origin, '0 0 0');
61 self.nextthink = time + self.swamp_interval;
64 void swamp_touch(void)
66 // If whatever thats touching the swamp is not a player
67 // or if its a dead player, just dont care abt it.
68 if(!IS_PLAYER(other) || PHYS_DEAD(other))
73 // Chech if player alredy got a swampslug.
74 if(other.in_swamp != 1)
77 //centerprint(other,"Entering swamp!\n");
78 other.swampslug = spawn();
79 other.swampslug.health = 2;
80 other.swampslug.think = swampslug_think;
81 other.swampslug.nextthink = time;
82 other.swampslug.owner = other;
83 other.swampslug.dmg = self.dmg;
84 other.swampslug.swamp_interval = self.swamp_interval;
85 other.swamp_slowdown = self.swamp_slowdown;
92 //Revitalize players swampslug
93 other.swampslug.health = 2;
97 float swamp_send(entity to, float sf)
99 WriteByte(MSG_ENTITY, ENT_CLIENT_LADDER);
101 WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
102 WriteByte(MSG_ENTITY, self.swamp_slowdown);
103 WriteByte(MSG_ENTITY, self.swamp_interval);
105 trigger_common_write(false);
112 Net_LinkEntity(self, false, 0, func_ladder_send);
115 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
116 Players gettin into the swamp will
117 get slowd down and damaged
119 void spawnfunc_trigger_swamp(void)
123 self.touch = swamp_touch;
125 // Setup default keys, if missing
128 if(self.swamp_interval <= 0)
129 self.swamp_interval = 1;
130 if(self.swamp_slowdown <= 0)
131 self.swamp_slowdown = 0.5;
140 self.dmg = ReadByte();
141 self.swamp_slowdown = ReadByte();
142 self.swamp_interval = ReadByte();
144 trigger_common_read(false);
146 self.classname = "trigger_swamp";
147 self.solid = SOLID_TRIGGER;
148 self.draw = trigger_draw_generic;
149 self.trigger_touch = swamp_touch;
150 self.drawmask = MASK_NORMAL;
151 self.move_time = time;
152 self.entremove = trigger_remove_generic;