updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / teeworlds-isrv / instagib-2.2.patch
blobaf6c883cc6d96cabf6a7cf2ea97be66e76b95342
1 Index: src/game/server/entities/character.cpp
2 ===================================================================
3 --- src/game/server/entities/character.cpp (revision 1937)
4 +++ src/game/server/entities/character.cpp (working copy)
5 @@ -56,6 +56,13 @@
6 last_weapon = WEAPON_HAMMER;
7 queued_weapon = -1;
9 + if(game.controller->is_instagib())
10 + {
11 + active_weapon = WEAPON_RIFLE;
12 + last_weapon = WEAPON_RIFLE;
13 + queued_weapon = -1;
14 + }
16 //clear();
17 this->player = player;
18 this->pos = pos;
19 @@ -662,6 +669,16 @@
20 dbg_msg("game", "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d",
21 killer, server_clientname(killer),
22 player->client_id, server_clientname(player->client_id), weapon, mode_special);
24 + if(on_spree())
25 + {
26 + game.create_sound(pos, SOUND_GRENADE_EXPLODE);
27 + game.create_explosion(pos, player->client_id, WEAPON_RIFLE, true);
28 + }
30 + if(game.get_player_char(killer))
31 + game.get_player_char(killer)->spree_add();
32 + spree_end(killer);
34 // send the kill message
35 NETMSG_SV_KILLMSG msg;
36 @@ -694,12 +711,56 @@
37 player->respawn_tick = server_tick()+server_tickspeed()/2;
40 +char spree_note[4][32] = { "is on a killing spree", "is on a rampage", "is dominating", "is unstoppable" };
42 +void CHARACTER::spree_add()
44 + spree++;
45 + if(spree % 5 == 0)
46 + {
47 + int p = (int)spree/5-1;
48 + if(p > 3)
49 + p = 3;
50 + char buf[256];
51 + str_format(buf, sizeof(buf), "%s %s with %d kills!", server_clientname(player->client_id), spree_note[p], spree);
52 + game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
53 + }
56 +void CHARACTER::spree_end(int killer)
58 + if(spree >= 5)
59 + {
60 + char buf[256];
61 + str_format(buf, sizeof(buf), "%s %d-kills killing spree was ended by %s", server_clientname(player->client_id), spree, server_clientname(killer));
62 + game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
63 + }
64 + spree = 0;
67 +bool CHARACTER::on_spree()
69 + if(spree >= 5)
70 + return true;
71 + return false;
74 bool CHARACTER::take_damage(vec2 force, int dmg, int from, int weapon)
76 core.vel += force;
78 if(game.controller->is_friendly_fire(player->client_id, from) && !config.sv_teamdamage)
79 return false;
81 + if(game.controller->is_instagib() && weapon == WEAPON_GAME)
82 + return false;
84 + if(game.controller->is_instagib())
85 + {
86 + game.create_sound(pos, SOUND_HIT, cmask_one(from));
87 + die(from, weapon);
88 + return true;
89 + }
91 // player only inflicts half damage on self
92 if(from == player->client_id)
93 Index: src/game/server/entities/character.hpp
94 ===================================================================
95 --- src/game/server/entities/character.hpp (revision 1937)
96 +++ src/game/server/entities/character.hpp (working copy)
97 @@ -83,6 +83,8 @@
98 //int score;
99 int team;
100 int player_state; // if the client is chatting, accessing a menu or so
102 + int spree;
104 // the player core for the physics
105 CHARACTER_CORE core;
106 @@ -113,6 +115,10 @@
107 void fire_weapon();
109 void die(int killer, int weapon);
111 + void spree_add();
112 + void spree_end(int killer);
113 + bool on_spree();
115 bool take_damage(vec2 force, int dmg, int from, int weapon);
117 Index: src/game/server/entities/laser.cpp
118 ===================================================================
119 --- src/game/server/entities/laser.cpp (revision 1937)
120 +++ src/game/server/entities/laser.cpp (working copy)
121 @@ -1,5 +1,6 @@
122 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
123 #include <engine/e_server_interface.h>
124 +#include <engine/e_config.h>
125 #include <game/generated/g_protocol.hpp>
126 #include <game/server/gamecontext.hpp>
127 #include "laser.hpp"
128 @@ -72,6 +73,9 @@
129 energy = -1;
131 game.create_sound(pos, SOUND_RIFLE_BOUNCE);
133 + if(bounces == 1 && config.sv_laserjumps)
134 + game.create_explosion(pos, owner, WEAPON_GAME, false);
137 else
138 Index: src/game/server/gamecontroller.cpp
139 ===================================================================
140 --- src/game/server/gamecontroller.cpp (revision 1937)
141 +++ src/game/server/gamecontroller.cpp (working copy)
142 @@ -29,6 +29,7 @@
144 unbalanced_tick = -1;
145 force_balanced = false;
146 + instagib = false;
148 num_spawn_points[0] = 0;
149 num_spawn_points[1] = 0;
150 @@ -145,7 +146,7 @@
151 subtype = WEAPON_NINJA;
154 - if(type != -1)
155 + if(type != -1 && !is_instagib())
157 PICKUP *pickup = new PICKUP(type, subtype);
158 pickup->pos = pos;
159 @@ -329,10 +330,18 @@
160 chr->health = 10;
162 // give default weapons
163 - chr->weapons[WEAPON_HAMMER].got = 1;
164 - chr->weapons[WEAPON_HAMMER].ammo = -1;
165 - chr->weapons[WEAPON_GUN].got = 1;
166 - chr->weapons[WEAPON_GUN].ammo = 10;
167 + if(is_instagib())
169 + chr->weapons[WEAPON_RIFLE].got = 1;
170 + chr->weapons[WEAPON_RIFLE].ammo = -1;
172 + else
174 + chr->weapons[WEAPON_HAMMER].got = 1;
175 + chr->weapons[WEAPON_HAMMER].ammo = -1;
176 + chr->weapons[WEAPON_GUN].got = 1;
177 + chr->weapons[WEAPON_GUN].ammo = 10;
181 void GAMECONTROLLER::do_warmup(int seconds)
182 @@ -471,7 +480,17 @@
183 server_setbrowseinfo(gametype, prog);
186 +void GAMECONTROLLER::make_instagib(char *new_gametype)
188 + instagib = true;
189 + gametype = new_gametype;
192 +bool GAMECONTROLLER::is_instagib() const
194 + return instagib;
197 bool GAMECONTROLLER::is_teamplay() const
199 return game_flags&GAMEFLAG_TEAMS;
200 Index: src/game/server/gamecontroller.hpp
201 ===================================================================
202 --- src/game/server/gamecontroller.hpp (revision 1937)
203 +++ src/game/server/gamecontroller.hpp (working copy)
204 @@ -50,10 +50,14 @@
205 int game_flags;
206 int unbalanced_tick;
207 bool force_balanced;
208 + bool instagib;
210 public:
211 const char *gametype;
213 + void make_instagib(char *gametype);
214 + bool is_instagib() const;
216 bool is_teamplay() const;
218 GAMECONTROLLER();
219 Index: src/game/server/hooks.cpp
220 ===================================================================
221 --- src/game/server/hooks.cpp (revision 1937)
222 +++ src/game/server/hooks.cpp (working copy)
223 @@ -531,7 +531,22 @@
224 //players = new PLAYER[MAX_CLIENTS];
226 // select gametype
227 - if(strcmp(config.sv_gametype, "mod") == 0)
228 + if(strcmp(config.sv_gametype, "ictf") == 0)
230 + game.controller = new GAMECONTROLLER_CTF;
231 + game.controller->make_instagib("iCTF");
233 + else if(strcmp(config.sv_gametype, "itdm") == 0)
235 + game.controller = new GAMECONTROLLER_TDM;
236 + game.controller->make_instagib("iTDM");
238 + else if(strcmp(config.sv_gametype, "idm") == 0)
240 + game.controller = new GAMECONTROLLER_DM;
241 + game.controller->make_instagib("iDM");
243 + else if(strcmp(config.sv_gametype, "mod") == 0)
244 game.controller = new GAMECONTROLLER_MOD;
245 else if(strcmp(config.sv_gametype, "ctf") == 0)
246 game.controller = new GAMECONTROLLER_CTF;
247 Index: src/game/variables.hpp
248 ===================================================================
249 --- src/game/variables.hpp (revision 1937)
250 +++ src/game/variables.hpp (working copy)
251 @@ -71,3 +71,6 @@
253 MACRO_CONFIG_INT(dbg_focus, 0, 0, 1, CFGFLAG_CLIENT, "")
254 MACRO_CONFIG_INT(dbg_tuning, 0, 0, 1, CFGFLAG_CLIENT, "")
256 +/* instagib */
257 +MACRO_CONFIG_INT(sv_laserjumps, 1, 0, 1, CFGFLAG_SERVER, "Enable laser jumps")