4 #include "../../../server/_all.qh"
5 #include "../../../dpdefs/progsdefs.qh"
6 #include "../../../warpzonelib/util_server.qh"
7 #include "../../weapons/all.qh"
8 #include "../../../server/defs.qh"
9 #include "../../deathtypes.qh"
14 * Adds spawnfunc_trigger_swamp and suppoart routines for xonotic 1.2.1+
15 * Author tZork (Jakob MG)
20 .float swamp_interval; //Hurt players in swamp with this interval
21 .float swamp_slowdown; //Players in swamp get slowd down by this mutch 0-1 is slowdown 1-~ is speedup (!?)
25 void spawnfunc_trigger_swamp(void);
27 void swamp_touch(void);
28 void swampslug_think();
32 * Uses a entity calld swampslug to handle players in the swamp
33 * It works like this: When the plyer enters teh swamp the spawnfunc_trigger_swamp
34 * attaches a new "swampslug" to the player. As long as the plyer is inside
35 * the swamp the swamp gives the slug new health. But the slug slowly kills itself
36 * so when the player goes outside the swamp, it dies and releases the player from the
37 * swamps curses (dmg/slowdown)
39 * I do it this way becuz there is no "untouch" event.
41 void swampslug_think(void)
43 //Slowly kill the slug
44 self.health = self.health - 1;
46 //Slug dead? then remove curses.
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.
59 Damage (self.owner, self, self, self.dmg, DEATH_SWAMP, other.origin, '0 0 0');
62 self.nextthink = time + self.swamp_interval;
65 void swamp_touch(void)
67 // If whatever thats touching the swamp is not a player
68 // or if its a dead player, just dont care abt it.
69 if(!IS_PLAYER(other) || PHYS_DEAD(other))
74 // Chech if player alredy got a swampslug.
75 if(other.in_swamp != 1)
78 //centerprint(other,"Entering swamp!\n");
79 other.swampslug = spawn();
80 other.swampslug.health = 2;
81 other.swampslug.think = swampslug_think;
82 other.swampslug.nextthink = time;
83 other.swampslug.owner = other;
84 other.swampslug.dmg = self.dmg;
85 other.swampslug.swamp_interval = self.swamp_interval;
86 other.swamp_slowdown = self.swamp_slowdown;
93 //Revitalize players swampslug
94 other.swampslug.health = 2;
98 float swamp_send(entity to, float sf)
100 WriteByte(MSG_ENTITY, ENT_CLIENT_LADDER);
102 WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
103 WriteByte(MSG_ENTITY, self.swamp_slowdown);
104 WriteByte(MSG_ENTITY, self.swamp_interval);
106 trigger_common_write(false);
113 Net_LinkEntity(self, false, 0, func_ladder_send);
116 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
117 Players gettin into the swamp will
118 get slowd down and damaged
120 void spawnfunc_trigger_swamp(void)
124 self.touch = swamp_touch;
126 // Setup default keys, if missing
129 if(self.swamp_interval <= 0)
130 self.swamp_interval = 1;
131 if(self.swamp_slowdown <= 0)
132 self.swamp_slowdown = 0.5;
141 self.dmg = ReadByte();
142 self.swamp_slowdown = ReadByte();
143 self.swamp_interval = ReadByte();
145 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;