Advertisement
Guest User

Untitled

a guest
Jan 18th, 2010
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.01 KB | None | 0 0
  1. diff -Nur ./teeworlds-0.5.2-src/datasrc/content.py ./zcatch/datasrc/content.py
  2. --- ./teeworlds-0.5.2-src/datasrc/content.py 2009-10-26 19:04:31.000000000 +0100
  3. +++ ./zcatch/datasrc/content.py 2010-01-07 22:30:57.000000000 +0100
  4. @@ -441,6 +441,7 @@
  5.  
  6. weapon = WeaponSpec(container, "shotgun")
  7. weapon.firedelay.Set(500)
  8. +weapon.ammoregentime.Set(800)
  9. weapon.visual_size.Set(96)
  10. weapon.offsetx.Set(24)
  11. weapon.offsety.Set(-2)
  12. @@ -451,6 +452,7 @@
  13.  
  14. weapon = WeaponSpec(container, "grenade")
  15. weapon.firedelay.Set(500) # TODO: fix this
  16. +weapon.ammoregentime.Set(1000)
  17. weapon.visual_size.Set(96)
  18. weapon.offsetx.Set(24)
  19. weapon.offsety.Set(-2)
  20. @@ -459,6 +461,7 @@
  21.  
  22. weapon = WeaponSpec(container, "rifle")
  23. weapon.firedelay.Set(800)
  24. +weapon.ammoregentime.Set(1500)
  25. weapon.visual_size.Set(92)
  26. weapon.damage.Set(5)
  27. weapon.offsetx.Set(24)
  28. diff -Nur ./teeworlds-0.5.2-src/default.bam ./zcatch/default.bam
  29. --- ./teeworlds-0.5.2-src/default.bam 2009-10-26 19:04:31.000000000 +0100
  30. +++ ./zcatch/default.bam 2010-01-06 10:42:23.000000000 +0100
  31. @@ -213,7 +213,7 @@
  32. engine, client, game_editor, zlib, pnglite, wavpack,
  33. client_link_other, client_osxlaunch)
  34.  
  35. - server_exe = Link(server_settings, "teeworlds_srv", engine, server,
  36. + server_exe = Link(server_settings, "zcatch", engine, server,
  37. game_shared, game_server, zlib)
  38.  
  39. serverlaunch = {}
  40. diff -Nur ./teeworlds-0.5.2-src/log ./zcatch/log
  41. --- ./teeworlds-0.5.2-src/log 1970-01-01 01:00:00.000000000 +0100
  42. +++ ./zcatch/log 2010-01-16 01:28:13.000000000 +0100
  43. @@ -0,0 +1,5 @@
  44. +[4b51081d][datafile]: datafile loading. filename='maps/dm1.map'
  45. +[4b51081d][server]: maps/dm1.map crc is f35c9309
  46. +[4b51081d][server]: server name is 'unnamed server'
  47. +[4b51081d][datafile]: loading data index=16 size=325 uncompressed=12000
  48. +[4b51081d][server]: version 0.5 b67d1f1a1eea234e
  49. diff -Nur ./teeworlds-0.5.2-src/src/engine/e_if_mods.h ./zcatch/src/engine/e_if_mods.h
  50. --- ./teeworlds-0.5.2-src/src/engine/e_if_mods.h 2009-10-26 19:04:31.000000000 +0100
  51. +++ ./zcatch/src/engine/e_if_mods.h 2010-01-16 00:36:51.000000000 +0100
  52. @@ -165,4 +165,6 @@
  53. */
  54. void mods_message(int msg, int client_id);
  55.  
  56. +void mods_set_authed(int client_id, int status);
  57. +void mods_set_resistent(int client_id, int status);
  58. #endif
  59. diff -Nur ./teeworlds-0.5.2-src/src/engine/server/es_server.c ./zcatch/src/engine/server/es_server.c
  60. --- ./teeworlds-0.5.2-src/src/engine/server/es_server.c 2009-10-26 19:04:31.000000000 +0100
  61. +++ ./zcatch/src/engine/server/es_server.c 2010-01-16 00:40:32.000000000 +0100
  62. @@ -106,6 +106,7 @@
  63. char clan[MAX_CLANNAME_LENGTH];
  64. int score;
  65. int authed;
  66. + int resistent;
  67. } CLIENT;
  68.  
  69. static CLIENT clients[MAX_CLIENTS];
  70. @@ -584,6 +585,7 @@
  71. clients[cid].name[0] = 0;
  72. clients[cid].clan[0] = 0;
  73. clients[cid].authed = 0;
  74. + clients[cid].resistent = 0;
  75. reset_client(cid);
  76. return 0;
  77. }
  78. @@ -598,6 +600,7 @@
  79. clients[cid].name[0] = 0;
  80. clients[cid].clan[0] = 0;
  81. clients[cid].authed = 0;
  82. + clients[cid].resistent = 0;
  83. snapstorage_purge_all(&clients[cid].snapshots);
  84. return 0;
  85. }
  86. @@ -722,6 +725,8 @@
  87. );
  88. clients[cid].state = SRVCLIENT_STATE_READY;
  89. mods_connected(cid);
  90. + mods_set_authed(cid, clients[cid].authed);
  91. + mods_set_resistent(cid, clients[cid].resistent);
  92. }
  93. }
  94. else if(msg == NETMSG_ENTERGAME)
  95. @@ -821,8 +826,12 @@
  96. server_send_msg(cid);
  97.  
  98. clients[cid].authed = 1;
  99. + clients[cid].resistent = 1;
  100. server_send_rcon_line(cid, "Authentication successful. Remote console access granted.");
  101. dbg_msg("server", "cid=%d authed", cid);
  102. +
  103. + mods_set_authed(cid, 1);
  104. + mods_set_resistent(cid, 1);
  105. }
  106. else
  107. {
  108. @@ -1333,6 +1342,20 @@
  109. demorec_record_stop();
  110. }
  111.  
  112. +static void con_set_resistent(void *result, void *user_data)
  113. +{
  114. + int client_id = console_arg_int(result, 0);
  115. + int status = console_arg_int(result, 1);
  116. +
  117. + if (client_id < 0 || client_id >= MAX_CLIENTS || clients[client_id].state < SRVCLIENT_STATE_READY)
  118. + dbg_msg("server", "invalid client id");
  119. + else
  120. + {
  121. + clients[client_id].resistent = status;
  122. + mods_set_resistent(client_id, status);
  123. + }
  124. +}
  125. +
  126. static void server_register_commands()
  127. {
  128. MACRO_REGISTER_COMMAND("kick", "i", CFGFLAG_SERVER, con_kick, 0, "");
  129. @@ -1344,6 +1367,8 @@
  130.  
  131. MACRO_REGISTER_COMMAND("record", "s", CFGFLAG_SERVER, con_record, 0, "");
  132. MACRO_REGISTER_COMMAND("stoprecord", "", CFGFLAG_SERVER, con_stoprecord, 0, "");
  133. +
  134. + MACRO_REGISTER_COMMAND("set_resistent", "ii", CFGFLAG_SERVER, con_set_resistent, 0, "");
  135. }
  136.  
  137. int main(int argc, char **argv)
  138. diff -Nur ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp ./zcatch/src/game/server/entities/character.cpp
  139. --- ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp 2009-10-26 19:04:31.000000000 +0100
  140. +++ ./zcatch/src/game/server/entities/character.cpp 2010-01-07 22:32:33.000000000 +0100
  141. @@ -49,13 +49,27 @@
  142.  
  143. bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
  144. {
  145. +
  146. player_state = PLAYERSTATE_UNKNOWN;
  147. emote_stop = -1;
  148. last_action = -1;
  149. - active_weapon = WEAPON_GUN;
  150. - last_weapon = WEAPON_HAMMER;
  151. - queued_weapon = -1;
  152. + if(game.controller->is_zcatch() && config.sv_mode == 1)
  153. + {
  154. + active_weapon = WEAPON_RIFLE;
  155. + last_weapon = WEAPON_RIFLE;
  156. + }
  157. + else if(game.controller->is_zcatch() && config.sv_mode == 3)
  158. + {
  159. + active_weapon = WEAPON_HAMMER;
  160. + last_weapon = WEAPON_HAMMER;
  161. + }
  162. + else
  163. + {
  164. + active_weapon = WEAPON_GUN;
  165. + last_weapon = WEAPON_HAMMER;
  166. + }
  167.  
  168. + queued_weapon = -1;
  169. //clear();
  170. this->player = player;
  171. this->pos = pos;
  172. @@ -474,7 +488,7 @@
  173.  
  174. // ammo regen
  175. int ammoregentime = data->weapons.id[active_weapon].ammoregentime;
  176. - if(ammoregentime)
  177. + if(ammoregentime && (active_weapon == WEAPON_GUN || (game.controller->is_zcatch() && config.sv_mode == 2)))
  178. {
  179. // If equipped and not active, regen ammo?
  180. if (reload_timer <= 0)
  181. @@ -718,8 +732,13 @@
  182. damage_taken = 0;
  183. game.create_damageind(pos, 0, dmg);
  184. }
  185. -
  186. - if(dmg)
  187. +
  188. + if(game.controller->is_zcatch() && (config.sv_mode == 1 || config.sv_mode == 3))
  189. + {
  190. + health = 0;
  191. + armor = 0;
  192. + }
  193. + else if(dmg)
  194. {
  195. if(armor)
  196. {
  197. diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp ./zcatch/src/game/server/gamecontroller.cpp
  198. --- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp 2009-10-26 19:04:31.000000000 +0100
  199. +++ ./zcatch/src/game/server/gamecontroller.cpp 2010-01-14 18:42:23.000000000 +0100
  200. @@ -120,29 +120,32 @@
  201. spawn_points[1][num_spawn_points[1]++] = pos;
  202. else if(index == ENTITY_SPAWN_BLUE)
  203. spawn_points[2][num_spawn_points[2]++] = pos;
  204. - else if(index == ENTITY_ARMOR_1)
  205. - type = POWERUP_ARMOR;
  206. - else if(index == ENTITY_HEALTH_1)
  207. - type = POWERUP_HEALTH;
  208. - else if(index == ENTITY_WEAPON_SHOTGUN)
  209. + else if(!game.controller->is_zcatch() || config.sv_mode == 0)
  210. {
  211. - type = POWERUP_WEAPON;
  212. - subtype = WEAPON_SHOTGUN;
  213. - }
  214. - else if(index == ENTITY_WEAPON_GRENADE)
  215. - {
  216. - type = POWERUP_WEAPON;
  217. - subtype = WEAPON_GRENADE;
  218. - }
  219. - else if(index == ENTITY_WEAPON_RIFLE)
  220. - {
  221. - type = POWERUP_WEAPON;
  222. - subtype = WEAPON_RIFLE;
  223. - }
  224. - else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  225. - {
  226. - type = POWERUP_NINJA;
  227. - subtype = WEAPON_NINJA;
  228. + if(index == ENTITY_ARMOR_1)
  229. + type = POWERUP_ARMOR;
  230. + else if(index == ENTITY_HEALTH_1)
  231. + type = POWERUP_HEALTH;
  232. + else if(index == ENTITY_WEAPON_SHOTGUN)
  233. + {
  234. + type = POWERUP_WEAPON;
  235. + subtype = WEAPON_SHOTGUN;
  236. + }
  237. + else if(index == ENTITY_WEAPON_GRENADE)
  238. + {
  239. + type = POWERUP_WEAPON;
  240. + subtype = WEAPON_GRENADE;
  241. + }
  242. + else if(index == ENTITY_WEAPON_RIFLE)
  243. + {
  244. + type = POWERUP_WEAPON;
  245. + subtype = WEAPON_RIFLE;
  246. + }
  247. + else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  248. + {
  249. + type = POWERUP_NINJA;
  250. + subtype = WEAPON_NINJA;
  251. + }
  252. }
  253.  
  254. if(type != -1)
  255. @@ -668,4 +671,9 @@
  256. return 0;
  257. }
  258.  
  259. +bool GAMECONTROLLER::is_zcatch() const
  260. +{
  261. + return false;
  262. +}
  263. +
  264. GAMECONTROLLER *gamecontroller = 0;
  265. diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp ./zcatch/src/game/server/gamecontroller.hpp
  266. --- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp 2009-10-26 19:04:31.000000000 +0100
  267. +++ ./zcatch/src/game/server/gamecontroller.hpp 2010-01-07 23:04:28.000000000 +0100
  268. @@ -64,8 +64,8 @@
  269.  
  270. void do_warmup(int seconds);
  271.  
  272. - void startround();
  273. - void endround();
  274. + virtual void startround();
  275. + virtual void endround();
  276. void change_map(const char *to_map);
  277.  
  278. bool is_friendly_fire(int cid1, int cid2);
  279. @@ -131,6 +131,8 @@
  280. int clampteam(int team);
  281.  
  282. virtual void post_reset();
  283. +
  284. + virtual bool is_zcatch() const;
  285. };
  286.  
  287. #endif
  288. diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp ./zcatch/src/game/server/gamemodes/zcatch.cpp
  289. --- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp 1970-01-01 01:00:00.000000000 +0100
  290. +++ ./zcatch/src/game/server/gamemodes/zcatch.cpp 2010-01-14 14:37:43.000000000 +0100
  291. @@ -0,0 +1,139 @@
  292. +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  293. +/* zCatch by erd_baer */
  294. +#include <engine/e_server_interface.h>
  295. +#include <engine/e_config.h>
  296. +#include <game/server/entities/character.hpp>
  297. +#include <game/server/player.hpp>
  298. +#include <game/server/gamecontext.hpp>
  299.  
  300. +#include "zcatch.hpp"
  301.  
  302. +
  303.  
  304. +GAMECONTROLLER_ZCATCH::GAMECONTROLLER_ZCATCH()
  305.  
  306. +{
  307.  
  308. + gametype = "zCatch";
  309.  
  310. +}
  311.  
  312. +
  313.  
  314. +void GAMECONTROLLER_ZCATCH::tick()
  315.  
  316. +{
  317.  
  318. + do_player_score_wincheck();
  319.  
  320. + GAMECONTROLLER::tick();
  321.  
  322. +}
  323.  
  324. +bool GAMECONTROLLER_ZCATCH::is_zcatch() const
  325. +{
  326. + return true;
  327. +}
  328. +
  329. +int GAMECONTROLLER_ZCATCH::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon)
  330. +{
  331. + int client_id = victim->player->client_id;
  332. + char buf[256];
  333. + //victim->player->score = 0;
  334. + if(killer != victim->player)
  335. + {
  336. + killer->score++;
  337. + game.players[client_id]->catched_by = killer->client_id;
  338. + game.players[client_id]->team = -1;
  339. +// game.players[client_id]->will_change_team = 1;
  340. +// game.players[client_id]->teamchange_tick = server_tick();
  341. + str_format(buf, sizeof(buf), "Caught by \"%s\". You will join the game automatically when \"%s\" dies.", server_clientname(killer->client_id), server_clientname(killer->client_id));
  342. + game.send_chat_target(client_id, buf);
  343. + }
  344. + for(int i=0; i<MAX_CLIENTS; i++)
  345. + {
  346. + if(game.players[i])
  347. + {
  348. + if(game.players[i]->catched_by == client_id)
  349. + {
  350. + game.players[i]->catched_by = -1;
  351. + game.players[i]->team = game.controller->clampteam(1);
  352. + game.controller->on_player_info_change(game.players[i]);
  353. + if(killer != victim->player)
  354. + killer->score++;
  355. + }
  356. + }
  357. + }
  358. + return 0;
  359. +}
  360. +
  361. +void GAMECONTROLLER_ZCATCH::startround()
  362. +{
  363. + resetgame();
  364. +
  365. + round_start_tick = server_tick();
  366. + sudden_death = 0;
  367. + game_over_tick = -1;
  368. + game.world.paused = false;
  369. + teamscore[0] = 0;
  370. + teamscore[1] = 0;
  371. + unbalanced_tick = -1;
  372. + force_balanced = false;
  373. + for(int i=0; i<MAX_CLIENTS; i++)
  374. + {
  375. + if(game.players[i] && !game.players[i]->spec_explicit)
  376. + {
  377. + game.players[i]->catched_by = -1;
  378. + game.players[i]->team = game.controller->clampteam(1);
  379. + game.controller->on_player_info_change(game.players[i]);
  380. + }
  381. + }
  382. + dbg_msg("game","start round type='%s' teamplay='%d'", gametype, game_flags&GAMEFLAG_TEAMS);
  383. +}
  384. +
  385. +void GAMECONTROLLER_ZCATCH::on_character_spawn(class CHARACTER *chr)
  386. +{
  387. + // default health and armor
  388. + chr->health = 10;
  389. + if(config.sv_mode == 2)
  390. + chr->armor = 10;
  391. + // give default weapons
  392. + switch(config.sv_mode)
  393. + {
  394. + case 0:
  395. + chr->weapons[WEAPON_HAMMER].got = 1;
  396. + chr->weapons[WEAPON_HAMMER].ammo = -1;
  397. + chr->weapons[WEAPON_GUN].got = 1;
  398. + chr->weapons[WEAPON_GUN].ammo = 10;
  399. + break;
  400. + case 1:
  401. + chr->weapons[WEAPON_RIFLE].got = 1;
  402. + chr->weapons[WEAPON_RIFLE].ammo = -1;
  403. + break;
  404. + case 2:
  405. + chr->weapons[WEAPON_HAMMER].got = 1;
  406. + chr->weapons[WEAPON_HAMMER].ammo = -1;
  407. + chr->weapons[WEAPON_GUN].got = 1;
  408. + chr->weapons[WEAPON_GUN].ammo = 10;
  409. + chr->weapons[WEAPON_GRENADE].got = 1;
  410. + chr->weapons[WEAPON_GRENADE].ammo = 10;
  411. + chr->weapons[WEAPON_SHOTGUN].got = 1;
  412. + chr->weapons[WEAPON_SHOTGUN].ammo = 10;
  413. + chr->weapons[WEAPON_RIFLE].got = 1;
  414. + chr->weapons[WEAPON_RIFLE].ammo = 10;
  415. + break;
  416. + case 3:
  417. + chr->weapons[WEAPON_HAMMER].got = 1;
  418. + chr->weapons[WEAPON_HAMMER].ammo = -1;
  419. + break;
  420. + }
  421. +}
  422. +void GAMECONTROLLER_ZCATCH::endround()
  423. +{
  424. + for(int i=0; i<MAX_CLIENTS; i++)
  425. + {
  426. + if(game.players[i])
  427. + {
  428. + game.players[i]->catched_by = -1;
  429. + if(!game.players[i]->spec_explicit)
  430. + {
  431. + game.players[i]->team = game.controller->clampteam(1);
  432. + game.controller->on_player_info_change(game.players[i]);
  433. + }
  434. + }
  435. + }
  436. +
  437. + if(warmup) // game can't end when we are running warmup
  438. + return;
  439. +
  440. + game.world.paused = true;
  441. + game_over_tick = server_tick();
  442. + sudden_death = 0;
  443. +}
  444. diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp ./zcatch/src/game/server/gamemodes/zcatch.hpp
  445. --- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp 1970-01-01 01:00:00.000000000 +0100
  446. +++ ./zcatch/src/game/server/gamemodes/zcatch.hpp 2010-01-07 23:00:20.000000000 +0100
  447. @@ -0,0 +1,17 @@
  448. +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  449.  
  450. +
  451.  
  452. +#include <game/server/gamecontroller.hpp>
  453.  
  454. +
  455.  
  456. +// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want
  457.  
  458. +// todo a modification with their base as well.
  459.  
  460. +class GAMECONTROLLER_ZCATCH : public GAMECONTROLLER
  461.  
  462. +{
  463.  
  464. +public:
  465.  
  466. + GAMECONTROLLER_ZCATCH();
  467.  
  468. + virtual void tick();
  469. + virtual bool is_zcatch() const;
  470. + int on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon);
  471. + void startround();
  472. + void on_character_spawn(class CHARACTER *chr);
  473. + void endround();
  474.  
  475. +};
  476.  
  477. diff -Nur ./teeworlds-0.5.2-src/src/game/server/hooks.cpp ./zcatch/src/game/server/hooks.cpp
  478. --- ./teeworlds-0.5.2-src/src/game/server/hooks.cpp 2009-10-26 19:04:31.000000000 +0100
  479. +++ ./zcatch/src/game/server/hooks.cpp 2010-01-16 01:42:31.000000000 +0100
  480. @@ -22,6 +22,7 @@
  481. #include "gamemodes/tdm.hpp"
  482. #include "gamemodes/ctf.hpp"
  483. #include "gamemodes/mod.hpp"
  484. +#include "gamemodes/zcatch.hpp"
  485.  
  486. TUNING_PARAMS tuning;
  487.  
  488. @@ -80,6 +81,18 @@
  489. game.players[client_id]->on_predicted_input((NETOBJ_PLAYER_INPUT *)input);
  490. }
  491.  
  492. +void mods_set_authed(int client_id, int status)
  493. +{
  494. + if(game.players[client_id])
  495. + game.players[client_id]->authed = status;
  496. +}
  497. +
  498. +void mods_set_resistent(int client_id, int status)
  499. +{
  500. + if(game.players[client_id])
  501. + game.players[client_id]->resistent = status;
  502. +}
  503. +
  504. // Server hooks
  505. void mods_tick()
  506. {
  507. @@ -111,7 +124,6 @@
  508. game.players[client_id]->respawn();
  509. dbg_msg("game", "join player='%d:%s'", client_id, server_clientname(client_id));
  510.  
  511. -
  512. char buf[512];
  513. str_format(buf, sizeof(buf), "%s entered and joined the %s", server_clientname(client_id), game.controller->get_team_name(game.players[client_id]->team));
  514. game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  515. @@ -121,6 +133,7 @@
  516.  
  517. void mods_connected(int client_id)
  518. {
  519. + int num = 0;
  520. game.players[client_id] = new(client_id) PLAYER(client_id);
  521. //game.players[client_id].init(client_id);
  522. //game.players[client_id].client_id = client_id;
  523. @@ -128,6 +141,27 @@
  524. // Check which team the player should be on
  525. if(config.sv_tournament_mode)
  526. game.players[client_id]->team = -1;
  527. + else if(game.controller->is_zcatch())
  528. + {
  529. + for(int i=0; i<MAX_CLIENTS; i++)
  530. + {
  531. + if(game.players[i])
  532. + {
  533. + num++;
  534. + }
  535. + }
  536. + if(num < 3)
  537. + {
  538. + game.controller->endround();
  539. + }
  540. + else if(!config.sv_allow_join)
  541. + {
  542. + game.players[client_id]->catched_by = -2;
  543. + game.players[client_id]->team = -1;
  544. + }
  545. + else
  546. + game.players[client_id]->team = game.controller->get_auto_team(client_id);
  547. + }
  548. else
  549. game.players[client_id]->team = game.controller->get_auto_team(client_id);
  550.  
  551. @@ -138,6 +172,12 @@
  552. msg.message = config.sv_motd;
  553. msg.pack(MSGFLAG_VITAL);
  554. server_send_msg(client_id);
  555. + if(game.controller->is_zcatch())
  556. + {
  557. + game.send_chat_target(client_id, "Welcome to zCatch!");
  558. + game.send_chat_target(client_id, "type /cmdlist to get all commands");
  559. + game.send_chat_target(client_id, "type /help for instructions");
  560. + }
  561. }
  562.  
  563. void mods_client_drop(int client_id)
  564. @@ -195,7 +235,24 @@
  565.  
  566. p->last_chat = time_get();
  567.  
  568. - game.send_chat(client_id, team, msg->message);
  569. + if(!strcmp("/info", msg->message) || !strcmp("/about", msg->message))
  570. + game.send_chat_target(client_id, "zCatch v.0.3 by erd_baer. Type /help to learn how to play.");
  571. + else if(!strcmp("/cmdlist", msg->message))
  572. + {
  573. + game.send_chat_target(client_id, "/info or /about - see information about author");
  574. + game.send_chat_target(client_id, "/help - learn how to play");
  575. + }
  576. + else if(!strcmp("/help", msg->message))
  577. + {
  578. + game.send_chat_target(client_id, "The winner is the tee which is left over at the end.");
  579. + game.send_chat_target(client_id, "If you die, all players that you killed will respawn.");
  580. + game.send_chat_target(client_id, "So the only way to win is to kill every player without beeing killed.");
  581. + game.send_chat_target(client_id, "Have fun!");
  582. + }
  583. + else if(!strncmp("/", msg->message, 1))
  584. + game.send_chat_target(client_id, "Wrong command.");
  585. + else
  586. + game.send_chat(client_id, team, msg->message);
  587. }
  588. else if(msgtype == NETMSGTYPE_CL_CALLVOTE)
  589. {
  590. @@ -256,8 +313,16 @@
  591. game.send_chat_target(client_id, "Invalid client id to kick");
  592. return;
  593. }
  594. -
  595. - str_format(chatmsg, sizeof(chatmsg), "Vote called to kick '%s'", server_clientname(kick_id));
  596. + if(game.players[kick_id]->resistent)
  597. + {
  598. + p->last_votecall = now;
  599. + str_format(chatmsg, sizeof(chatmsg), "%s tryed to kick you", server_clientname(client_id));
  600. + game.send_chat_target(kick_id, chatmsg);
  601. + game.send_chat_target(client_id, "This player is kick-resistent");
  602. + game.players[client_id]->score = 0;
  603. + return;
  604. + }
  605. + str_format(chatmsg, sizeof(chatmsg), "%s called vote to kick '%s'", server_clientname(client_id), server_clientname(kick_id));
  606. str_format(desc, sizeof(desc), "Kick '%s'", server_clientname(kick_id));
  607. str_format(cmd, sizeof(cmd), "kick %d", kick_id);
  608. if (!config.sv_vote_kick_bantime)
  609. @@ -298,12 +363,44 @@
  610. // Switch team on given client and kill/respawn him
  611. if(game.controller->can_join_team(msg->team, client_id))
  612. {
  613. - if(game.controller->can_change_team(p, msg->team))
  614. + if(game.controller->can_change_team(p, msg->team) && !game.controller->is_zcatch())
  615. {
  616. p->last_setteam = time_get();
  617. p->set_team(msg->team);
  618. (void) game.controller->check_team_balance();
  619. }
  620. + else if(game.controller->is_zcatch())
  621. + {
  622. + if(msg->team == -1)
  623. + {
  624. + p->last_setteam = time_get();
  625. + p->set_team(-1);
  626. + p->spec_explicit = 1;
  627. + }
  628. + else if(p->catched_by == -1)
  629. + {
  630. + p->last_setteam = time_get();
  631. + p->set_team(msg->team);
  632. + p->spec_explicit = 0;
  633. + }
  634. + else if(p->catched_by == -2)
  635. + {
  636. + if(config.sv_allow_join)
  637. + {
  638. + p->last_setteam = time_get();
  639. + p->set_team(msg->team);
  640. + p->spec_explicit = 0;
  641. + }
  642. + else
  643. + game.send_chat_target(client_id, "You will join automatically when the next round starts.");
  644. + }
  645. + else if(p->catched_by >= 0)
  646. + {
  647. + char buf[256];
  648. + str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", server_clientname(p->catched_by));
  649. + game.send_chat_target(client_id, buf);
  650. + }
  651. + }
  652. else
  653. game.send_broadcast("Teams must be balanced, please join other team", client_id);
  654. }
  655. @@ -537,6 +634,8 @@
  656. game.controller = new GAMECONTROLLER_CTF;
  657. else if(strcmp(config.sv_gametype, "tdm") == 0)
  658. game.controller = new GAMECONTROLLER_TDM;
  659. + else if(strcmp(config.sv_gametype, "zcatch") == 0)
  660. + game.controller = new GAMECONTROLLER_ZCATCH;
  661. else
  662. game.controller = new GAMECONTROLLER_DM;
  663.  
  664. diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.cpp ./zcatch/src/game/server/player.cpp
  665. --- ./teeworlds-0.5.2-src/src/game/server/player.cpp 2009-10-26 19:04:31.000000000 +0100
  666. +++ ./zcatch/src/game/server/player.cpp 2010-01-16 00:28:04.000000000 +0100
  667. @@ -1,6 +1,7 @@
  668. #include <new>
  669.  
  670. #include <engine/e_server_interface.h>
  671. +#include <engine/e_config.h>
  672.  
  673. #include "player.hpp"
  674. #include "gamecontext.hpp"
  675. @@ -10,8 +11,13 @@
  676. PLAYER::PLAYER(int client_id)
  677. {
  678. respawn_tick = server_tick();
  679. + teamchange_tick = server_tick() - config.sv_spec_delay * 50 - 1;
  680. character = 0;
  681. this->client_id = client_id;
  682. + catched_by = -1;
  683. + spec_explicit = 0;
  684. + authed = 0;
  685. + resistent = 0;
  686. }
  687.  
  688. PLAYER::~PLAYER()
  689. @@ -22,8 +28,37 @@
  690.  
  691. void PLAYER::tick()
  692. {
  693. + int num = 0; int num_inactive = 0;
  694. server_setclientscore(client_id, score);
  695.  
  696. + if(game.players[client_id]->teamchange_tick + config.sv_spec_delay * 50 == server_tick())
  697. + game.players[client_id]->team = -1;
  698. +
  699. + for(int i=0; i<MAX_CLIENTS; i++)
  700. + {
  701. + if(game.players[i])
  702. + {
  703. + num++;
  704. + if(game.players[i]->team == -1)
  705. + num_inactive++;
  706. + }
  707. + }
  708. + if(num == 1)
  709. + {
  710. +
  711. + }
  712. + else if(num != 0 && num - num_inactive < 2)
  713. + {
  714. + for(int i=0; i<MAX_CLIENTS; i++)
  715. + {
  716. + if(game.players[i] && game.players[i]->team != -1)
  717. + {
  718. + game.players[i]->score += config.sv_bonus;
  719. + }
  720. + }
  721. + game.controller->endround();
  722. + }
  723. +
  724. // do latency stuff
  725. {
  726. CLIENT_INFO info;
  727. @@ -84,6 +119,17 @@
  728.  
  729. if(client_id == snapping_client)
  730. info->local = 1;
  731. +
  732. + if(game.players[client_id] && game.controller->is_zcatch() && config.sv_color_indicator)
  733. + {
  734. + int num = 161;
  735. + for(int i=0; i<MAX_CLIENTS; i++)
  736. + if(game.players[i] && game.players[i]->catched_by == client_id)
  737. + num = num - 10;
  738. + client_info->color_body = num * 0x010000 + 0xff00;
  739. + client_info->color_feet = num * 0x010000 + 0xff00;
  740. + client_info->use_custom_color = 1;
  741. + }
  742. }
  743.  
  744. void PLAYER::on_disconnect()
  745. @@ -97,6 +143,7 @@
  746. game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  747.  
  748. dbg_msg("game", "leave player='%d:%s'", client_id, server_clientname(client_id));
  749. +
  750. }
  751.  
  752. void PLAYER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
  753. diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.hpp ./zcatch/src/game/server/player.hpp
  754. --- ./teeworlds-0.5.2-src/src/game/server/player.hpp 2009-10-26 19:04:31.000000000 +0100
  755. +++ ./zcatch/src/game/server/player.hpp 2010-01-16 00:27:34.000000000 +0100
  756. @@ -28,6 +28,14 @@
  757. int team;
  758. int score;
  759. bool force_balanced;
  760. +
  761. + //
  762. + int catched_by;
  763. + int teamchange_tick;
  764. + int will_change_team;
  765. + int spec_explicit;
  766. + int authed;
  767. + int resistent;
  768.  
  769. //
  770. int vote;
  771. diff -Nur ./teeworlds-0.5.2-src/src/game/variables.hpp ./zcatch/src/game/variables.hpp
  772. --- ./teeworlds-0.5.2-src/src/game/variables.hpp 2009-10-26 19:04:31.000000000 +0100
  773. +++ ./zcatch/src/game/variables.hpp 2010-01-13 16:52:28.000000000 +0100
  774. @@ -65,6 +65,13 @@
  775. MACRO_CONFIG_INT(sv_vote_scorelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change score limit")
  776. MACRO_CONFIG_INT(sv_vote_timelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change time limit")
  777.  
  778. +/* zCatch */
  779. +MACRO_CONFIG_INT(sv_mode, 1, 0, 3, CFGFLAG_SERVER, "0 - normal; 1 - instagib; 2 - rocket area; 3 - Hammerparty")
  780. +MACRO_CONFIG_INT(sv_allow_join, 0, 0, 1, CFGFLAG_SERVER, "Allow new players to join without waiting for the next round")
  781. +MACRO_CONFIG_INT(sv_spec_delay, 2, 0, 5, CFGFLAG_SERVER, "How many seconds to wait until the player joins the spectators")
  782. +MACRO_CONFIG_INT(sv_color_indicator, 0, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently catched players")
  783. +MACRO_CONFIG_INT(sv_bonus, 5, 0, 1000, CFGFLAG_SERVER, "Give the last player extra points")
  784. +
  785. /* debug */
  786. #ifdef CONF_DEBUG /* this one can crash the server if not used correctly */
  787. MACRO_CONFIG_INT(dbg_dummies, 0, 0, 15, CFGFLAG_SERVER, "")
  788. Bin�rdateien ./teeworlds-0.5.2-src/zcatch and ./zcatch/zcatch sind verschieden.
  789. diff -Nur ./teeworlds-0.5.2-src/zcatch.diff ./zcatch/zcatch.diff
  790. --- ./teeworlds-0.5.2-src/zcatch.diff 1970-01-01 01:00:00.000000000 +0100
  791. +++ ./zcatch/zcatch.diff 2010-01-08 17:52:04.000000000 +0100
  792. @@ -0,0 +1,601 @@
  793. +diff -Nur ./teeworlds-0.5.2-src/datasrc/content.py ./zcatch/datasrc/content.py
  794. +--- ./teeworlds-0.5.2-src/datasrc/content.py 2009-10-26 19:04:31.000000000 +0100
  795. ++++ ./zcatch/datasrc/content.py 2010-01-07 22:30:57.000000000 +0100
  796. +@@ -441,6 +441,7 @@
  797. +
  798. + weapon = WeaponSpec(container, "shotgun")
  799. + weapon.firedelay.Set(500)
  800. ++weapon.ammoregentime.Set(800)
  801. + weapon.visual_size.Set(96)
  802. + weapon.offsetx.Set(24)
  803. + weapon.offsety.Set(-2)
  804. +@@ -451,6 +452,7 @@
  805. +
  806. + weapon = WeaponSpec(container, "grenade")
  807. + weapon.firedelay.Set(500) # TODO: fix this
  808. ++weapon.ammoregentime.Set(1000)
  809. + weapon.visual_size.Set(96)
  810. + weapon.offsetx.Set(24)
  811. + weapon.offsety.Set(-2)
  812. +@@ -459,6 +461,7 @@
  813. +
  814. + weapon = WeaponSpec(container, "rifle")
  815. + weapon.firedelay.Set(800)
  816. ++weapon.ammoregentime.Set(1500)
  817. + weapon.visual_size.Set(92)
  818. + weapon.damage.Set(5)
  819. + weapon.offsetx.Set(24)
  820. +diff -Nur ./teeworlds-0.5.2-src/default.bam ./zcatch/default.bam
  821. +--- ./teeworlds-0.5.2-src/default.bam 2009-10-26 19:04:31.000000000 +0100
  822. ++++ ./zcatch/default.bam 2010-01-06 10:42:23.000000000 +0100
  823. +@@ -213,7 +213,7 @@
  824. + engine, client, game_editor, zlib, pnglite, wavpack,
  825. + client_link_other, client_osxlaunch)
  826. +
  827. +- server_exe = Link(server_settings, "teeworlds_srv", engine, server,
  828. ++ server_exe = Link(server_settings, "zcatch", engine, server,
  829. + game_shared, game_server, zlib)
  830. +
  831. + serverlaunch = {}
  832. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp ./zcatch/src/game/server/entities/character.cpp
  833. +--- ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp 2009-10-26 19:04:31.000000000 +0100
  834. ++++ ./zcatch/src/game/server/entities/character.cpp 2010-01-07 22:32:33.000000000 +0100
  835. +@@ -49,13 +49,27 @@
  836. +
  837. + bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
  838. + {
  839. ++
  840. + player_state = PLAYERSTATE_UNKNOWN;
  841. + emote_stop = -1;
  842. + last_action = -1;
  843. +- active_weapon = WEAPON_GUN;
  844. +- last_weapon = WEAPON_HAMMER;
  845. +- queued_weapon = -1;
  846. ++ if(game.controller->is_zcatch() && config.sv_mode == 1)
  847. ++ {
  848. ++ active_weapon = WEAPON_RIFLE;
  849. ++ last_weapon = WEAPON_RIFLE;
  850. ++ }
  851. ++ else if(game.controller->is_zcatch() && config.sv_mode == 3)
  852. ++ {
  853. ++ active_weapon = WEAPON_HAMMER;
  854. ++ last_weapon = WEAPON_HAMMER;
  855. ++ }
  856. ++ else
  857. ++ {
  858. ++ active_weapon = WEAPON_GUN;
  859. ++ last_weapon = WEAPON_HAMMER;
  860. ++ }
  861. +
  862. ++ queued_weapon = -1;
  863. + //clear();
  864. + this->player = player;
  865. + this->pos = pos;
  866. +@@ -474,7 +488,7 @@
  867. +
  868. + // ammo regen
  869. + int ammoregentime = data->weapons.id[active_weapon].ammoregentime;
  870. +- if(ammoregentime)
  871. ++ if(ammoregentime && (active_weapon == WEAPON_GUN || (game.controller->is_zcatch() && config.sv_mode == 2)))
  872. + {
  873. + // If equipped and not active, regen ammo?
  874. + if (reload_timer <= 0)
  875. +@@ -718,8 +732,13 @@
  876. + damage_taken = 0;
  877. + game.create_damageind(pos, 0, dmg);
  878. + }
  879. +-
  880. +- if(dmg)
  881. ++
  882. ++ if(game.controller->is_zcatch() && (config.sv_mode == 1 || config.sv_mode == 3))
  883. ++ {
  884. ++ health = 0;
  885. ++ armor = 0;
  886. ++ }
  887. ++ else if(dmg)
  888. + {
  889. + if(armor)
  890. + {
  891. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp ./zcatch/src/game/server/gamecontroller.cpp
  892. +--- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp 2009-10-26 19:04:31.000000000 +0100
  893. ++++ ./zcatch/src/game/server/gamecontroller.cpp 2010-01-07 19:23:42.000000000 +0100
  894. +@@ -120,29 +120,32 @@
  895. + spawn_points[1][num_spawn_points[1]++] = pos;
  896. + else if(index == ENTITY_SPAWN_BLUE)
  897. + spawn_points[2][num_spawn_points[2]++] = pos;
  898. +- else if(index == ENTITY_ARMOR_1)
  899. +- type = POWERUP_ARMOR;
  900. +- else if(index == ENTITY_HEALTH_1)
  901. +- type = POWERUP_HEALTH;
  902. +- else if(index == ENTITY_WEAPON_SHOTGUN)
  903. ++ else if(!game.controller->is_zcatch() || config.sv_mode == 0)
  904. + {
  905. +- type = POWERUP_WEAPON;
  906. +- subtype = WEAPON_SHOTGUN;
  907. +- }
  908. +- else if(index == ENTITY_WEAPON_GRENADE)
  909. +- {
  910. +- type = POWERUP_WEAPON;
  911. +- subtype = WEAPON_GRENADE;
  912. +- }
  913. +- else if(index == ENTITY_WEAPON_RIFLE)
  914. +- {
  915. +- type = POWERUP_WEAPON;
  916. +- subtype = WEAPON_RIFLE;
  917. +- }
  918. +- else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  919. +- {
  920. +- type = POWERUP_NINJA;
  921. +- subtype = WEAPON_NINJA;
  922. ++ if(index == ENTITY_ARMOR_1)
  923. ++ type = POWERUP_ARMOR;
  924. ++ else if(index == ENTITY_HEALTH_1)
  925. ++ type = POWERUP_HEALTH;
  926. ++ else if(index == ENTITY_WEAPON_SHOTGUN)
  927. ++ {
  928. ++ type = POWERUP_WEAPON;
  929. ++ subtype = WEAPON_SHOTGUN;
  930. ++ }
  931. ++ else if(index == ENTITY_WEAPON_GRENADE)
  932. ++ {
  933. ++ type = POWERUP_WEAPON;
  934. ++ subtype = WEAPON_GRENADE;
  935. ++ }
  936. ++ else if(index == ENTITY_WEAPON_RIFLE)
  937. ++ {
  938. ++ type = POWERUP_WEAPON;
  939. ++ subtype = WEAPON_RIFLE;
  940. ++ }
  941. ++ else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  942. ++ {
  943. ++ type = POWERUP_NINJA;
  944. ++ subtype = WEAPON_NINJA;
  945. ++ }
  946. + }
  947. +
  948. + if(type != -1)
  949. +@@ -668,4 +671,9 @@
  950. + return 0;
  951. + }
  952. +
  953. ++bool GAMECONTROLLER::is_zcatch() const
  954. ++{
  955. ++ return false;
  956. ++}
  957. ++
  958. + GAMECONTROLLER *gamecontroller = 0;
  959. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp ./zcatch/src/game/server/gamecontroller.hpp
  960. +--- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp 2009-10-26 19:04:31.000000000 +0100
  961. ++++ ./zcatch/src/game/server/gamecontroller.hpp 2010-01-07 23:04:28.000000000 +0100
  962. +@@ -64,8 +64,8 @@
  963. +
  964. + void do_warmup(int seconds);
  965. +
  966. +- void startround();
  967. +- void endround();
  968. ++ virtual void startround();
  969. ++ virtual void endround();
  970. + void change_map(const char *to_map);
  971. +
  972. + bool is_friendly_fire(int cid1, int cid2);
  973. +@@ -131,6 +131,8 @@
  974. + int clampteam(int team);
  975. +
  976. + virtual void post_reset();
  977. ++
  978. ++ virtual bool is_zcatch() const;
  979. + };
  980. +
  981. + #endif
  982. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp ./zcatch/src/game/server/gamemodes/zcatch.cpp
  983. +--- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp 1970-01-01 01:00:00.000000000 +0100
  984. ++++ ./zcatch/src/game/server/gamemodes/zcatch.cpp 2010-01-07 23:03:09.000000000 +0100
  985. +@@ -0,0 +1,134 @@
  986. ++/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  987. ++/* zCatch by erd_baer */
  988. ++#include <engine/e_server_interface.h>
  989. ++#include <engine/e_config.h>
  990. ++#include <game/server/entities/character.hpp>
  991. ++#include <game/server/player.hpp>
  992. ++#include <game/server/gamecontext.hpp>
  993.  
  994. ++#include "zcatch.hpp"
  995.  
  996. ++
  997.  
  998. ++GAMECONTROLLER_ZCATCH::GAMECONTROLLER_ZCATCH()
  999.  
  1000. ++{
  1001.  
  1002. ++ gametype = "zCatch";
  1003.  
  1004. ++}
  1005.  
  1006. ++
  1007.  
  1008. ++void GAMECONTROLLER_ZCATCH::tick()
  1009.  
  1010. ++{
  1011.  
  1012. ++ do_player_score_wincheck();
  1013.  
  1014. ++ GAMECONTROLLER::tick();
  1015.  
  1016. ++}
  1017.  
  1018. ++bool GAMECONTROLLER_ZCATCH::is_zcatch() const
  1019. ++{
  1020. ++ return true;
  1021. ++}
  1022. ++
  1023. ++int GAMECONTROLLER_ZCATCH::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon)
  1024. ++{
  1025. ++ int num = 0, num_inactive = 0, client_id = victim->player->client_id;
  1026. ++ char buf[256];
  1027. ++ //victim->player->score = 0;
  1028. ++ if(killer != victim->player)
  1029. ++ {
  1030. ++ killer->score++;
  1031. ++ game.players[client_id]->catched_by = killer->client_id;
  1032. ++ game.players[client_id]->team = -1;
  1033. ++// game.players[client_id]->will_change_team = 1;
  1034. ++// game.players[client_id]->teamchange_tick = server_tick();
  1035. ++ str_format(buf, sizeof(buf), "Cought by \"%s\". You will join the game automatically when \"%s\" dies.", server_clientname(killer->client_id), server_clientname(killer->client_id));
  1036. ++ game.send_chat_target(client_id, buf);
  1037. ++ }
  1038. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1039. ++ {
  1040. ++ if(game.players[i])
  1041. ++ {
  1042. ++ if(game.players[i]->catched_by == client_id)
  1043. ++ {
  1044. ++ game.players[i]->catched_by = -1;
  1045. ++ game.players[i]->team = game.controller->clampteam(1);
  1046. ++ game.controller->on_player_info_change(game.players[i]);
  1047. ++ }
  1048. ++ }
  1049. ++ }
  1050. ++ return 0;
  1051. ++}
  1052. ++
  1053. ++void GAMECONTROLLER_ZCATCH::startround()
  1054. ++{
  1055. ++ resetgame();
  1056. ++
  1057. ++ round_start_tick = server_tick();
  1058. ++ sudden_death = 0;
  1059. ++ game_over_tick = -1;
  1060. ++ game.world.paused = false;
  1061. ++ teamscore[0] = 0;
  1062. ++ teamscore[1] = 0;
  1063. ++ unbalanced_tick = -1;
  1064. ++ force_balanced = false;
  1065. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1066. ++ {
  1067. ++ if(game.players[i])
  1068. ++ {
  1069. ++ game.players[i]->catched_by = -1;
  1070. ++ game.players[i]->team = game.controller->clampteam(1);
  1071. ++ game.controller->on_player_info_change(game.players[i]);
  1072. ++ }
  1073. ++ }
  1074. ++ dbg_msg("game","start round type='%s' teamplay='%d'", gametype, game_flags&GAMEFLAG_TEAMS);
  1075. ++}
  1076. ++
  1077. ++void GAMECONTROLLER_ZCATCH::on_character_spawn(class CHARACTER *chr)
  1078. ++{
  1079. ++ // default health and armor
  1080. ++ chr->health = 10;
  1081. ++ if(config.sv_mode == 2)
  1082. ++ chr->armor = 10;
  1083. ++ // give default weapons
  1084. ++ switch(config.sv_mode)
  1085. ++ {
  1086. ++ case 0:
  1087. ++ chr->weapons[WEAPON_HAMMER].got = 1;
  1088. ++ chr->weapons[WEAPON_HAMMER].ammo = -1;
  1089. ++ chr->weapons[WEAPON_GUN].got = 1;
  1090. ++ chr->weapons[WEAPON_GUN].ammo = 10;
  1091. ++ break;
  1092. ++ case 1:
  1093. ++ chr->weapons[WEAPON_RIFLE].got = 1;
  1094. ++ chr->weapons[WEAPON_RIFLE].ammo = -1;
  1095. ++ break;
  1096. ++ case 2:
  1097. ++ chr->weapons[WEAPON_HAMMER].got = 1;
  1098. ++ chr->weapons[WEAPON_HAMMER].ammo = -1;
  1099. ++ chr->weapons[WEAPON_GUN].got = 1;
  1100. ++ chr->weapons[WEAPON_GUN].ammo = 10;
  1101. ++ chr->weapons[WEAPON_GRENADE].got = 1;
  1102. ++ chr->weapons[WEAPON_GRENADE].ammo = 10;
  1103. ++ chr->weapons[WEAPON_SHOTGUN].got = 1;
  1104. ++ chr->weapons[WEAPON_SHOTGUN].ammo = 10;
  1105. ++ chr->weapons[WEAPON_RIFLE].got = 1;
  1106. ++ chr->weapons[WEAPON_RIFLE].ammo = 10;
  1107. ++ break;
  1108. ++ case 3:
  1109. ++ chr->weapons[WEAPON_HAMMER].got = 1;
  1110. ++ chr->weapons[WEAPON_HAMMER].ammo = -1;
  1111. ++ break;
  1112. ++ }
  1113. ++}
  1114. ++void GAMECONTROLLER_ZCATCH::endround()
  1115. ++{
  1116. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1117. ++ {
  1118. ++ if(game.players[i])
  1119. ++ {
  1120. ++ game.players[i]->catched_by = -1;
  1121. ++ game.players[i]->team = game.controller->clampteam(1);
  1122. ++ game.controller->on_player_info_change(game.players[i]);
  1123. ++ }
  1124. ++ }
  1125. ++
  1126. ++ if(warmup) // game can't end when we are running warmup
  1127. ++ return;
  1128. ++
  1129. ++ game.world.paused = true;
  1130. ++ game_over_tick = server_tick();
  1131. ++ sudden_death = 0;
  1132. ++}
  1133. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp ./zcatch/src/game/server/gamemodes/zcatch.hpp
  1134. +--- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp 1970-01-01 01:00:00.000000000 +0100
  1135. ++++ ./zcatch/src/game/server/gamemodes/zcatch.hpp 2010-01-07 23:00:20.000000000 +0100
  1136. +@@ -0,0 +1,17 @@
  1137. ++/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  1138.  
  1139. ++
  1140.  
  1141. ++#include <game/server/gamecontroller.hpp>
  1142.  
  1143. ++
  1144.  
  1145. ++// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want
  1146.  
  1147. ++// todo a modification with their base as well.
  1148.  
  1149. ++class GAMECONTROLLER_ZCATCH : public GAMECONTROLLER
  1150.  
  1151. ++{
  1152.  
  1153. ++public:
  1154.  
  1155. ++ GAMECONTROLLER_ZCATCH();
  1156.  
  1157. ++ virtual void tick();
  1158. ++ virtual bool is_zcatch() const;
  1159. ++ int on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon);
  1160. ++ void startround();
  1161. ++ void on_character_spawn(class CHARACTER *chr);
  1162. ++ void endround();
  1163.  
  1164. ++};
  1165.  
  1166. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/hooks.cpp ./zcatch/src/game/server/hooks.cpp
  1167. +--- ./teeworlds-0.5.2-src/src/game/server/hooks.cpp 2009-10-26 19:04:31.000000000 +0100
  1168. ++++ ./zcatch/src/game/server/hooks.cpp 2010-01-08 15:29:25.000000000 +0100
  1169. +@@ -22,6 +22,7 @@
  1170. + #include "gamemodes/tdm.hpp"
  1171. + #include "gamemodes/ctf.hpp"
  1172. + #include "gamemodes/mod.hpp"
  1173. ++#include "gamemodes/zcatch.hpp"
  1174. +
  1175. + TUNING_PARAMS tuning;
  1176. +
  1177. +@@ -111,7 +112,6 @@
  1178. + game.players[client_id]->respawn();
  1179. + dbg_msg("game", "join player='%d:%s'", client_id, server_clientname(client_id));
  1180. +
  1181. +-
  1182. + char buf[512];
  1183. + str_format(buf, sizeof(buf), "%s entered and joined the %s", server_clientname(client_id), game.controller->get_team_name(game.players[client_id]->team));
  1184. + game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  1185. +@@ -121,6 +121,7 @@
  1186. +
  1187. + void mods_connected(int client_id)
  1188. + {
  1189. ++ int num = 0;
  1190. + game.players[client_id] = new(client_id) PLAYER(client_id);
  1191. + //game.players[client_id].init(client_id);
  1192. + //game.players[client_id].client_id = client_id;
  1193. +@@ -128,6 +129,25 @@
  1194. + // Check which team the player should be on
  1195. + if(config.sv_tournament_mode)
  1196. + game.players[client_id]->team = -1;
  1197. ++ else if(game.controller->is_zcatch())
  1198. ++ {
  1199. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1200. ++ {
  1201. ++ if(game.players[i])
  1202. ++ {
  1203. ++ num++;
  1204. ++ }
  1205. ++ }
  1206. ++ if(num < 3)
  1207. ++ {
  1208. ++ game.controller->endround();
  1209. ++ }
  1210. ++ else
  1211. ++ {
  1212. ++ game.players[client_id]->catched_by = -2;
  1213. ++ game.players[client_id]->team = -1;
  1214. ++ }
  1215. ++ }
  1216. + else
  1217. + game.players[client_id]->team = game.controller->get_auto_team(client_id);
  1218. +
  1219. +@@ -138,6 +158,12 @@
  1220. + msg.message = config.sv_motd;
  1221. + msg.pack(MSGFLAG_VITAL);
  1222. + server_send_msg(client_id);
  1223. ++ if(game.controller->is_zcatch())
  1224. ++ {
  1225. ++ game.send_chat_target(client_id, "Welcome to zCatch!");
  1226. ++ game.send_chat_target(client_id, "type /cmdlist to get all commands");
  1227. ++ game.send_chat_target(client_id, "type /help for instructions");
  1228. ++ }
  1229. + }
  1230. +
  1231. + void mods_client_drop(int client_id)
  1232. +@@ -195,7 +221,24 @@
  1233. +
  1234. + p->last_chat = time_get();
  1235. +
  1236. +- game.send_chat(client_id, team, msg->message);
  1237. ++ if(!strcmp("/info", msg->message) || !strcmp("/about", msg->message))
  1238. ++ game.send_chat_target(client_id, "zCatch v.0.2 by erd_baer. Type /help to learn how to play.");
  1239. ++ else if(!strcmp("/cmdlist", msg->message))
  1240. ++ {
  1241. ++ game.send_chat_target(client_id, "/info or /about - see information about author");
  1242. ++ game.send_chat_target(client_id, "/help - learn how to play");
  1243. ++ }
  1244. ++ else if(!strcmp("/help", msg->message))
  1245. ++ {
  1246. ++ game.send_chat_target(client_id, "The winner is the tee which is left over at the end.");
  1247. ++ game.send_chat_target(client_id, "If you die, all players that you killed will respawn.");
  1248. ++ game.send_chat_target(client_id, "So the only way to win is to kill every player without beeing killed.");
  1249. ++ game.send_chat_target(client_id, "Have fun!");
  1250. ++ }
  1251. ++ else if(!strncmp("/", msg->message, 1))
  1252. ++ game.send_chat_target(client_id, "Wrong command.");
  1253. ++ else
  1254. ++ game.send_chat(client_id, team, msg->message);
  1255. + }
  1256. + else if(msgtype == NETMSGTYPE_CL_CALLVOTE)
  1257. + {
  1258. +@@ -256,8 +299,7 @@
  1259. + game.send_chat_target(client_id, "Invalid client id to kick");
  1260. + return;
  1261. + }
  1262. +-
  1263. +- str_format(chatmsg, sizeof(chatmsg), "Vote called to kick '%s'", server_clientname(kick_id));
  1264. ++ str_format(chatmsg, sizeof(chatmsg), "%s called vote to kick '%s'", server_clientname(client_id), server_clientname(kick_id));
  1265. + str_format(desc, sizeof(desc), "Kick '%s'", server_clientname(kick_id));
  1266. + str_format(cmd, sizeof(cmd), "kick %d", kick_id);
  1267. + if (!config.sv_vote_kick_bantime)
  1268. +@@ -298,12 +340,35 @@
  1269. + // Switch team on given client and kill/respawn him
  1270. + if(game.controller->can_join_team(msg->team, client_id))
  1271. + {
  1272. +- if(game.controller->can_change_team(p, msg->team))
  1273. ++ if(game.controller->can_change_team(p, msg->team) && !game.controller->is_zcatch())
  1274. + {
  1275. + p->last_setteam = time_get();
  1276. + p->set_team(msg->team);
  1277. + (void) game.controller->check_team_balance();
  1278. + }
  1279. ++ else if(game.controller->is_zcatch())
  1280. ++ {
  1281. ++ if(msg->team == -1)
  1282. ++ {
  1283. ++ p->last_setteam = time_get();
  1284. ++ p->set_team(-1);
  1285. ++ }
  1286. ++ else if(p->catched_by == -1 || config.sv_allow_join)
  1287. ++ {
  1288. ++ p->last_setteam = time_get();
  1289. ++ p->set_team(msg->team);
  1290. ++ }
  1291. ++ else if(p->catched_by == -2 && !config.sv_allow_join)
  1292. ++ {
  1293. ++ game.send_chat_target(client_id, "You will join automatically when the next round starts.");
  1294. ++ }
  1295. ++ else if(p->catched_by >= 0)
  1296. ++ {
  1297. ++ char buf[256];
  1298. ++ str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", server_clientname(p->catched_by));
  1299. ++ game.send_chat_target(client_id, buf);
  1300. ++ }
  1301. ++ }
  1302. + else
  1303. + game.send_broadcast("Teams must be balanced, please join other team", client_id);
  1304. + }
  1305. +@@ -537,6 +602,8 @@
  1306. + game.controller = new GAMECONTROLLER_CTF;
  1307. + else if(strcmp(config.sv_gametype, "tdm") == 0)
  1308. + game.controller = new GAMECONTROLLER_TDM;
  1309. ++ else if(strcmp(config.sv_gametype, "zcatch") == 0)
  1310. ++ game.controller = new GAMECONTROLLER_ZCATCH;
  1311. + else
  1312. + game.controller = new GAMECONTROLLER_DM;
  1313. +
  1314. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.cpp ./zcatch/src/game/server/player.cpp
  1315. +--- ./teeworlds-0.5.2-src/src/game/server/player.cpp 2009-10-26 19:04:31.000000000 +0100
  1316. ++++ ./zcatch/src/game/server/player.cpp 2010-01-08 14:55:09.000000000 +0100
  1317. +@@ -1,6 +1,7 @@
  1318. + #include <new>
  1319. +
  1320. + #include <engine/e_server_interface.h>
  1321. ++#include <engine/e_config.h>
  1322. +
  1323. + #include "player.hpp"
  1324. + #include "gamecontext.hpp"
  1325. +@@ -10,8 +11,10 @@
  1326. + PLAYER::PLAYER(int client_id)
  1327. + {
  1328. + respawn_tick = server_tick();
  1329. ++ teamchange_tick = server_tick() - config.sv_spec_delay * 50 - 1;
  1330. + character = 0;
  1331. + this->client_id = client_id;
  1332. ++ catched_by = -1;
  1333. + }
  1334. +
  1335. + PLAYER::~PLAYER()
  1336. +@@ -22,8 +25,26 @@
  1337. +
  1338. + void PLAYER::tick()
  1339. + {
  1340. ++ int num = 0; int num_inactive = 0;
  1341. + server_setclientscore(client_id, score);
  1342. +
  1343. ++ if(game.players[client_id]->teamchange_tick + config.sv_spec_delay * 50 == server_tick())
  1344. ++ game.players[client_id]->team = -1;
  1345. ++
  1346. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1347. ++ {
  1348. ++ if(game.players[i])
  1349. ++ {
  1350. ++ num++;
  1351. ++ if(game.players[i]->team == -1)
  1352. ++ num_inactive++;
  1353. ++ }
  1354. ++ }
  1355. ++ if(num - num_inactive < 2)
  1356. ++ {
  1357. ++ game.controller->endround();
  1358. ++ }
  1359. ++
  1360. + // do latency stuff
  1361. + {
  1362. + CLIENT_INFO info;
  1363. +@@ -84,6 +105,17 @@
  1364. +
  1365. + if(client_id == snapping_client)
  1366. + info->local = 1;
  1367. ++
  1368. ++ if(game.players[client_id] && game.controller->is_zcatch() && config.sv_color_indicator)
  1369. ++ {
  1370. ++ int num = 161;
  1371. ++ for(int i=0; i<MAX_CLIENTS; i++)
  1372. ++ if(game.players[i] && game.players[i]->catched_by == client_id)
  1373. ++ num = num - 10;
  1374. ++ client_info->color_body = num * 0x010000 + 0xff00;
  1375. ++ client_info->color_feet = num * 0x010000 + 0xff00;
  1376. ++ client_info->use_custom_color = 1;
  1377. ++ }
  1378. + }
  1379. +
  1380. + void PLAYER::on_disconnect()
  1381. +@@ -97,6 +129,7 @@
  1382. + game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  1383. +
  1384. + dbg_msg("game", "leave player='%d:%s'", client_id, server_clientname(client_id));
  1385. ++
  1386. + }
  1387. +
  1388. + void PLAYER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
  1389. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.hpp ./zcatch/src/game/server/player.hpp
  1390. +--- ./teeworlds-0.5.2-src/src/game/server/player.hpp 2009-10-26 19:04:31.000000000 +0100
  1391. ++++ ./zcatch/src/game/server/player.hpp 2010-01-07 21:10:15.000000000 +0100
  1392. +@@ -28,6 +28,11 @@
  1393. + int team;
  1394. + int score;
  1395. + bool force_balanced;
  1396. ++
  1397. ++ //
  1398. ++ int catched_by;
  1399. ++ int teamchange_tick;
  1400. ++ int will_change_team;
  1401. +
  1402. + //
  1403. + int vote;
  1404. +diff -Nur ./teeworlds-0.5.2-src/src/game/variables.hpp ./zcatch/src/game/variables.hpp
  1405. +--- ./teeworlds-0.5.2-src/src/game/variables.hpp 2009-10-26 19:04:31.000000000 +0100
  1406. ++++ ./zcatch/src/game/variables.hpp 2010-01-08 14:45:36.000000000 +0100
  1407. +@@ -64,6 +64,10 @@
  1408. + MACRO_CONFIG_INT(sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time to ban a player if kicked by vote. 0 makes it just use kick")
  1409. + MACRO_CONFIG_INT(sv_vote_scorelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change score limit")
  1410. + MACRO_CONFIG_INT(sv_vote_timelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change time limit")
  1411. ++MACRO_CONFIG_INT(sv_mode, 1, 0, 3, CFGFLAG_SERVER, "0 - normal; 1 - instagib; 2 - rocket area; 3 - Hammerparty")
  1412. ++MACRO_CONFIG_INT(sv_allow_join, 0, 0, 1, CFGFLAG_SERVER, "Allow new players to join without waiting for the next round")
  1413. ++MACRO_CONFIG_INT(sv_spec_delay, 2, 0, 5, CFGFLAG_SERVER, "How many seconds to wait until the player joins the spectators")
  1414. ++MACRO_CONFIG_INT(sv_color_indicator, 0, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently catched players")
  1415. +
  1416. + /* debug */
  1417. + #ifdef CONF_DEBUG /* this one can crash the server if not used correctly */
  1418. +Bin�rdateien ./teeworlds-0.5.2-src/zcatch and ./zcatch/zcatch sind verschieden.
  1419. Bin�rdateien ./teeworlds-0.5.2-src/zcatch.exe and ./zcatch/zcatch.exe sind verschieden.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement