4 #include "../../../dpdefs/progsdefs.qh"
5 #include "../../../warpzonelib/util_server.qh"
6 #include "../../weapons/weapons.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.warpzone_isboxy);
102 WriteByte(MSG_ENTITY, self.scale);
103 WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
104 WriteByte(MSG_ENTITY, self.swamp_slowdown);
105 WriteByte(MSG_ENTITY, self.swamp_interval);
106 WriteCoord(MSG_ENTITY, self.origin_x);
107 WriteCoord(MSG_ENTITY, self.origin_y);
108 WriteCoord(MSG_ENTITY, self.origin_z);
110 WriteCoord(MSG_ENTITY, self.mins_x);
111 WriteCoord(MSG_ENTITY, self.mins_y);
112 WriteCoord(MSG_ENTITY, self.mins_z);
113 WriteCoord(MSG_ENTITY, self.maxs_x);
114 WriteCoord(MSG_ENTITY, self.maxs_y);
115 WriteCoord(MSG_ENTITY, self.maxs_z);
117 WriteCoord(MSG_ENTITY, self.movedir_x);
118 WriteCoord(MSG_ENTITY, self.movedir_y);
119 WriteCoord(MSG_ENTITY, self.movedir_z);
121 WriteAngle(MSG_ENTITY, self.angles_x);
122 WriteAngle(MSG_ENTITY, self.angles_y);
123 WriteAngle(MSG_ENTITY, self.angles_z);
130 Net_LinkEntity(self, false, 0, func_ladder_send);
133 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
134 Players gettin into the swamp will
135 get slowd down and damaged
137 void spawnfunc_trigger_swamp(void)
141 self.touch = swamp_touch;
143 // Setup default keys, if missing
146 if(self.swamp_interval <= 0)
147 self.swamp_interval = 1;
148 if(self.swamp_slowdown <= 0)
149 self.swamp_slowdown = 0.5;
158 self.warpzone_isboxy = ReadByte();
159 self.scale = ReadByte();
160 self.dmg = ReadByte();
161 self.swamp_slowdown = ReadByte();
162 self.swamp_interval = ReadByte();
164 self.origin_x = ReadCoord();
165 self.origin_y = ReadCoord();
166 self.origin_z = ReadCoord();
167 setorigin(self, self.origin);
169 self.mins_x = ReadCoord();
170 self.mins_y = ReadCoord();
171 self.mins_z = ReadCoord();
172 self.maxs_x = ReadCoord();
173 self.maxs_y = ReadCoord();
174 self.maxs_z = ReadCoord();
175 setsize(self, self.mins, self.maxs);
177 self.movedir_x = ReadCoord();
178 self.movedir_y = ReadCoord();
179 self.movedir_z = ReadCoord();
181 self.angles_x = ReadAngle();
182 self.angles_y = ReadAngle();
183 self.angles_z = ReadAngle();
185 self.classname = "trigger_swamp";
186 self.solid = SOLID_TRIGGER;
187 self.draw = trigger_draw_generic;
188 self.trigger_touch = swamp_touch;
189 self.drawmask = MASK_NORMAL;
190 self.move_time = time;