4 #include "../../../lib/warpzone/util_server.qh"
5 #include "../../weapons/all.qh"
6 #include "../../../server/defs.qh"
7 #include "../../deathtypes/all.qh"
12 * Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
13 * Author tZork (Jakob MG)
18 .float swamp_interval; //Hurt players in swamp with this interval
19 .float swamp_slowdown; //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
23 spawnfunc(trigger_swamp);
26 void swampslug_think();
30 * Uses a entity calld swampslug to handle players in the swamp
31 * It works like this: When the plyer enters teh swamp the spawnfunc_trigger_swamp
32 * attaches a new "swampslug" to the player. As long as the plyer is inside
33 * the swamp the swamp gives the slug new health. But the slug slowly kills itself
34 * so when the player goes outside the swamp, it dies and releases the player from the
35 * swamps curses (dmg/slowdown)
37 * I do it this way becuz there is no "untouch" event.
39 void swampslug_think()
41 //Slowly kill the slug
42 self.health = self.health - 1;
44 //Slug dead? then remove curses.
47 self.owner.in_swamp = 0;
49 //centerprint(self.owner,"Killing slug...\n");
53 // Slug still alive, so we are still in the swamp
54 // Or we have exited it very recently.
55 // Do the damage and renew the timer.
57 Damage (self.owner, self, self, self.dmg, DEATH_SWAMP.m_id, other.origin, '0 0 0');
60 self.nextthink = time + self.swamp_interval;
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) || PHYS_DEAD(other))
72 // Chech if player alredy got a swampslug.
73 if(other.in_swamp != 1)
76 //centerprint(other,"Entering swamp!\n");
77 other.swampslug = spawn();
78 other.swampslug.health = 2;
79 other.swampslug.think = swampslug_think;
80 other.swampslug.nextthink = time;
81 other.swampslug.owner = other;
82 other.swampslug.dmg = self.dmg;
83 other.swampslug.swamp_interval = self.swamp_interval;
84 other.swamp_slowdown = self.swamp_slowdown;
91 //Revitalize players swampslug
92 other.swampslug.health = 2;
96 float swamp_send(entity to, float sf)
98 WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER); // FIXME: should this really be sent as a ladder?
100 WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
101 WriteByte(MSG_ENTITY, self.swamp_slowdown);
102 WriteByte(MSG_ENTITY, self.swamp_interval);
104 trigger_common_write(false);
111 Net_LinkEntity(self, false, 0, func_ladder_send);
114 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
115 Players gettin into the swamp will
116 get slowd down and damaged
118 spawnfunc(trigger_swamp)
122 self.touch = swamp_touch;
124 // Setup default keys, if missing
127 if(self.swamp_interval <= 0)
128 self.swamp_interval = 1;
129 if(self.swamp_slowdown <= 0)
130 self.swamp_slowdown = 0.5;
137 NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew)
139 self.dmg = ReadByte();
140 self.swamp_slowdown = ReadByte();
141 self.swamp_interval = ReadByte();
143 trigger_common_read(false);
147 self.classname = "trigger_swamp";
148 self.solid = SOLID_TRIGGER;
149 self.draw = trigger_draw_generic;
150 self.trigger_touch = swamp_touch;
151 self.drawmask = MASK_NORMAL;
152 self.move_time = time;
153 self.entremove = trigger_remove_generic;