g_spawn.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "g_local.h"
  16. typedef struct
  17. {
  18. char *name;
  19. void (*spawn)(edict_t *ent);
  20. } spawn_t;
  21. void SP_item_health (edict_t *self);
  22. void SP_item_health_small (edict_t *self);
  23. void SP_item_health_large (edict_t *self);
  24. void SP_item_health_mega (edict_t *self);
  25. void SP_info_player_start (edict_t *ent);
  26. void SP_info_player_deathmatch (edict_t *ent);
  27. void SP_info_player_coop (edict_t *ent);
  28. void SP_info_player_intermission (edict_t *ent);
  29. void SP_func_plat (edict_t *ent);
  30. void SP_func_rotating (edict_t *ent);
  31. void SP_func_button (edict_t *ent);
  32. void SP_func_door (edict_t *ent);
  33. void SP_func_door_secret (edict_t *ent);
  34. void SP_func_door_rotating (edict_t *ent);
  35. void SP_func_water (edict_t *ent);
  36. void SP_func_train (edict_t *ent);
  37. void SP_func_conveyor (edict_t *self);
  38. void SP_func_wall (edict_t *self);
  39. void SP_func_object (edict_t *self);
  40. void SP_func_explosive (edict_t *self);
  41. void SP_func_timer (edict_t *self);
  42. void SP_func_areaportal (edict_t *ent);
  43. void SP_func_clock (edict_t *ent);
  44. void SP_func_killbox (edict_t *ent);
  45. void SP_trigger_always (edict_t *ent);
  46. void SP_trigger_once (edict_t *ent);
  47. void SP_trigger_multiple (edict_t *ent);
  48. void SP_trigger_relay (edict_t *ent);
  49. void SP_trigger_push (edict_t *ent);
  50. void SP_trigger_hurt (edict_t *ent);
  51. void SP_trigger_key (edict_t *ent);
  52. void SP_trigger_counter (edict_t *ent);
  53. void SP_trigger_elevator (edict_t *ent);
  54. void SP_trigger_gravity (edict_t *ent);
  55. void SP_trigger_monsterjump (edict_t *ent);
  56. void SP_target_temp_entity (edict_t *ent);
  57. void SP_target_speaker (edict_t *ent);
  58. void SP_target_explosion (edict_t *ent);
  59. void SP_target_changelevel (edict_t *ent);
  60. void SP_target_secret (edict_t *ent);
  61. void SP_target_goal (edict_t *ent);
  62. void SP_target_splash (edict_t *ent);
  63. void SP_target_spawner (edict_t *ent);
  64. void SP_target_blaster (edict_t *ent);
  65. void SP_target_crosslevel_trigger (edict_t *ent);
  66. void SP_target_crosslevel_target (edict_t *ent);
  67. void SP_target_laser (edict_t *self);
  68. void SP_target_help (edict_t *ent);
  69. void SP_target_actor (edict_t *ent);
  70. void SP_target_lightramp (edict_t *self);
  71. void SP_target_earthquake (edict_t *ent);
  72. void SP_target_character (edict_t *ent);
  73. void SP_target_string (edict_t *ent);
  74. void SP_worldspawn (edict_t *ent);
  75. void SP_viewthing (edict_t *ent);
  76. void SP_light (edict_t *self);
  77. void SP_light_mine1 (edict_t *ent);
  78. void SP_light_mine2 (edict_t *ent);
  79. void SP_info_null (edict_t *self);
  80. void SP_info_notnull (edict_t *self);
  81. void SP_path_corner (edict_t *self);
  82. void SP_point_combat (edict_t *self);
  83. void SP_misc_explobox (edict_t *self);
  84. void SP_misc_banner (edict_t *self);
  85. void SP_misc_satellite_dish (edict_t *self);
  86. void SP_misc_actor (edict_t *self);
  87. void SP_misc_gib_arm (edict_t *self);
  88. void SP_misc_gib_leg (edict_t *self);
  89. void SP_misc_gib_head (edict_t *self);
  90. void SP_misc_insane (edict_t *self);
  91. void SP_misc_deadsoldier (edict_t *self);
  92. void SP_misc_viper (edict_t *self);
  93. void SP_misc_viper_bomb (edict_t *self);
  94. void SP_misc_bigviper (edict_t *self);
  95. void SP_misc_strogg_ship (edict_t *self);
  96. void SP_misc_teleporter (edict_t *self);
  97. void SP_misc_teleporter_dest (edict_t *self);
  98. void SP_misc_blackhole (edict_t *self);
  99. void SP_misc_eastertank (edict_t *self);
  100. void SP_misc_easterchick (edict_t *self);
  101. void SP_misc_easterchick2 (edict_t *self);
  102. void SP_monster_berserk (edict_t *self);
  103. void SP_monster_gladiator (edict_t *self);
  104. void SP_monster_gunner (edict_t *self);
  105. void SP_monster_infantry (edict_t *self);
  106. void SP_monster_soldier_light (edict_t *self);
  107. void SP_monster_soldier (edict_t *self);
  108. void SP_monster_soldier_ss (edict_t *self);
  109. void SP_monster_tank (edict_t *self);
  110. void SP_monster_medic (edict_t *self);
  111. void SP_monster_flipper (edict_t *self);
  112. void SP_monster_chick (edict_t *self);
  113. void SP_monster_parasite (edict_t *self);
  114. void SP_monster_flyer (edict_t *self);
  115. void SP_monster_brain (edict_t *self);
  116. void SP_monster_floater (edict_t *self);
  117. void SP_monster_hover (edict_t *self);
  118. void SP_monster_mutant (edict_t *self);
  119. void SP_monster_supertank (edict_t *self);
  120. void SP_monster_boss2 (edict_t *self);
  121. void SP_monster_jorg (edict_t *self);
  122. void SP_monster_boss3_stand (edict_t *self);
  123. void SP_monster_commander_body (edict_t *self);
  124. void SP_turret_breach (edict_t *self);
  125. void SP_turret_base (edict_t *self);
  126. void SP_turret_driver (edict_t *self);
  127. spawn_t spawns[] = {
  128. {"item_health", SP_item_health},
  129. {"item_health_small", SP_item_health_small},
  130. {"item_health_large", SP_item_health_large},
  131. {"item_health_mega", SP_item_health_mega},
  132. {"info_player_start", SP_info_player_start},
  133. {"info_player_deathmatch", SP_info_player_deathmatch},
  134. {"info_player_coop", SP_info_player_coop},
  135. {"info_player_intermission", SP_info_player_intermission},
  136. //ZOID
  137. {"info_player_team1", SP_info_player_team1},
  138. {"info_player_team2", SP_info_player_team2},
  139. //ZOID
  140. {"func_plat", SP_func_plat},
  141. {"func_button", SP_func_button},
  142. {"func_door", SP_func_door},
  143. {"func_door_secret", SP_func_door_secret},
  144. {"func_door_rotating", SP_func_door_rotating},
  145. {"func_rotating", SP_func_rotating},
  146. {"func_train", SP_func_train},
  147. {"func_water", SP_func_water},
  148. {"func_conveyor", SP_func_conveyor},
  149. {"func_areaportal", SP_func_areaportal},
  150. {"func_clock", SP_func_clock},
  151. {"func_wall", SP_func_wall},
  152. {"func_object", SP_func_object},
  153. {"func_timer", SP_func_timer},
  154. {"func_explosive", SP_func_explosive},
  155. {"func_killbox", SP_func_killbox},
  156. {"trigger_always", SP_trigger_always},
  157. {"trigger_once", SP_trigger_once},
  158. {"trigger_multiple", SP_trigger_multiple},
  159. {"trigger_relay", SP_trigger_relay},
  160. {"trigger_push", SP_trigger_push},
  161. {"trigger_hurt", SP_trigger_hurt},
  162. {"trigger_key", SP_trigger_key},
  163. {"trigger_counter", SP_trigger_counter},
  164. {"trigger_elevator", SP_trigger_elevator},
  165. {"trigger_gravity", SP_trigger_gravity},
  166. {"trigger_monsterjump", SP_trigger_monsterjump},
  167. {"target_temp_entity", SP_target_temp_entity},
  168. {"target_speaker", SP_target_speaker},
  169. {"target_explosion", SP_target_explosion},
  170. {"target_changelevel", SP_target_changelevel},
  171. {"target_secret", SP_target_secret},
  172. {"target_goal", SP_target_goal},
  173. {"target_splash", SP_target_splash},
  174. {"target_spawner", SP_target_spawner},
  175. {"target_blaster", SP_target_blaster},
  176. {"target_crosslevel_trigger", SP_target_crosslevel_trigger},
  177. {"target_crosslevel_target", SP_target_crosslevel_target},
  178. {"target_laser", SP_target_laser},
  179. {"target_help", SP_target_help},
  180. #if 0 // remove monster code
  181. {"target_actor", SP_target_actor},
  182. #endif
  183. {"target_lightramp", SP_target_lightramp},
  184. {"target_earthquake", SP_target_earthquake},
  185. {"target_character", SP_target_character},
  186. {"target_string", SP_target_string},
  187. {"worldspawn", SP_worldspawn},
  188. {"viewthing", SP_viewthing},
  189. {"light", SP_light},
  190. {"light_mine1", SP_light_mine1},
  191. {"light_mine2", SP_light_mine2},
  192. {"info_null", SP_info_null},
  193. {"func_group", SP_info_null},
  194. {"info_notnull", SP_info_notnull},
  195. {"path_corner", SP_path_corner},
  196. {"point_combat", SP_point_combat},
  197. {"misc_explobox", SP_misc_explobox},
  198. {"misc_banner", SP_misc_banner},
  199. //ZOID
  200. {"misc_ctf_banner", SP_misc_ctf_banner},
  201. {"misc_ctf_small_banner", SP_misc_ctf_small_banner},
  202. //ZOID
  203. {"misc_satellite_dish", SP_misc_satellite_dish},
  204. #if 0 // remove monster code
  205. {"misc_actor", SP_misc_actor},
  206. #endif
  207. {"misc_gib_arm", SP_misc_gib_arm},
  208. {"misc_gib_leg", SP_misc_gib_leg},
  209. {"misc_gib_head", SP_misc_gib_head},
  210. #if 0 // remove monster code
  211. {"misc_insane", SP_misc_insane},
  212. #endif
  213. {"misc_deadsoldier", SP_misc_deadsoldier},
  214. {"misc_viper", SP_misc_viper},
  215. {"misc_viper_bomb", SP_misc_viper_bomb},
  216. {"misc_bigviper", SP_misc_bigviper},
  217. {"misc_strogg_ship", SP_misc_strogg_ship},
  218. {"misc_teleporter", SP_misc_teleporter},
  219. {"misc_teleporter_dest", SP_misc_teleporter_dest},
  220. //ZOID
  221. {"trigger_teleport", SP_trigger_teleport},
  222. {"info_teleport_destination", SP_info_teleport_destination},
  223. //ZOID
  224. {"misc_blackhole", SP_misc_blackhole},
  225. {"misc_eastertank", SP_misc_eastertank},
  226. {"misc_easterchick", SP_misc_easterchick},
  227. {"misc_easterchick2", SP_misc_easterchick2},
  228. #if 0 // remove monster code
  229. {"monster_berserk", SP_monster_berserk},
  230. {"monster_gladiator", SP_monster_gladiator},
  231. {"monster_gunner", SP_monster_gunner},
  232. {"monster_infantry", SP_monster_infantry},
  233. {"monster_soldier_light", SP_monster_soldier_light},
  234. {"monster_soldier", SP_monster_soldier},
  235. {"monster_soldier_ss", SP_monster_soldier_ss},
  236. {"monster_tank", SP_monster_tank},
  237. {"monster_tank_commander", SP_monster_tank},
  238. {"monster_medic", SP_monster_medic},
  239. {"monster_flipper", SP_monster_flipper},
  240. {"monster_chick", SP_monster_chick},
  241. {"monster_parasite", SP_monster_parasite},
  242. {"monster_flyer", SP_monster_flyer},
  243. {"monster_brain", SP_monster_brain},
  244. {"monster_floater", SP_monster_floater},
  245. {"monster_hover", SP_monster_hover},
  246. {"monster_mutant", SP_monster_mutant},
  247. {"monster_supertank", SP_monster_supertank},
  248. {"monster_boss2", SP_monster_boss2},
  249. {"monster_boss3_stand", SP_monster_boss3_stand},
  250. {"monster_jorg", SP_monster_jorg},
  251. {"monster_commander_body", SP_monster_commander_body},
  252. {"turret_breach", SP_turret_breach},
  253. {"turret_base", SP_turret_base},
  254. {"turret_driver", SP_turret_driver},
  255. #endif
  256. {NULL, NULL}
  257. };
  258. /*
  259. ===============
  260. ED_CallSpawn
  261. Finds the spawn function for the entity and calls it
  262. ===============
  263. */
  264. void ED_CallSpawn (edict_t *ent)
  265. {
  266. spawn_t *s;
  267. gitem_t *item;
  268. int i;
  269. if (!ent->classname)
  270. {
  271. gi.dprintf ("ED_CallSpawn: NULL classname\n");
  272. return;
  273. }
  274. // check item spawn functions
  275. for (i=0,item=itemlist ; i<game.num_items ; i++,item++)
  276. {
  277. if (!item->classname)
  278. continue;
  279. if (!strcmp(item->classname, ent->classname))
  280. { // found it
  281. SpawnItem (ent, item);
  282. return;
  283. }
  284. }
  285. // check normal spawn functions
  286. for (s=spawns ; s->name ; s++)
  287. {
  288. if (!strcmp(s->name, ent->classname))
  289. { // found it
  290. s->spawn (ent);
  291. return;
  292. }
  293. }
  294. gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
  295. }
  296. /*
  297. =============
  298. ED_NewString
  299. =============
  300. */
  301. char *ED_NewString (char *string)
  302. {
  303. char *newb, *new_p;
  304. int i,l;
  305. l = strlen(string) + 1;
  306. newb = gi.TagMalloc (l, TAG_LEVEL);
  307. new_p = newb;
  308. for (i=0 ; i< l ; i++)
  309. {
  310. if (string[i] == '\\' && i < l-1)
  311. {
  312. i++;
  313. if (string[i] == 'n')
  314. *new_p++ = '\n';
  315. else
  316. *new_p++ = '\\';
  317. }
  318. else
  319. *new_p++ = string[i];
  320. }
  321. return newb;
  322. }
  323. /*
  324. ===============
  325. ED_ParseField
  326. Takes a key/value pair and sets the binary values
  327. in an edict
  328. ===============
  329. */
  330. void ED_ParseField (char *key, char *value, edict_t *ent)
  331. {
  332. field_t *f;
  333. byte *b;
  334. float v;
  335. vec3_t vec;
  336. for (f=fields ; f->name ; f++)
  337. {
  338. if (!Q_stricmp(f->name, key))
  339. { // found it
  340. if (f->flags & FFL_SPAWNTEMP)
  341. b = (byte *)&st;
  342. else
  343. b = (byte *)ent;
  344. switch (f->type)
  345. {
  346. case F_LSTRING:
  347. *(char **)(b+f->ofs) = ED_NewString (value);
  348. break;
  349. case F_VECTOR:
  350. sscanf (value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
  351. ((float *)(b+f->ofs))[0] = vec[0];
  352. ((float *)(b+f->ofs))[1] = vec[1];
  353. ((float *)(b+f->ofs))[2] = vec[2];
  354. break;
  355. case F_INT:
  356. *(int *)(b+f->ofs) = atoi(value);
  357. break;
  358. case F_FLOAT:
  359. *(float *)(b+f->ofs) = atof(value);
  360. break;
  361. case F_ANGLEHACK:
  362. v = atof(value);
  363. ((float *)(b+f->ofs))[0] = 0;
  364. ((float *)(b+f->ofs))[1] = v;
  365. ((float *)(b+f->ofs))[2] = 0;
  366. break;
  367. case F_IGNORE:
  368. break;
  369. }
  370. return;
  371. }
  372. }
  373. gi.dprintf ("%s is not a field\n", key);
  374. }
  375. /*
  376. ====================
  377. ED_ParseEdict
  378. Parses an edict out of the given string, returning the new position
  379. ed should be a properly initialized empty edict.
  380. ====================
  381. */
  382. char *ED_ParseEdict (char *data, edict_t *ent)
  383. {
  384. qboolean init;
  385. char keyname[256];
  386. char *com_token;
  387. init = false;
  388. memset (&st, 0, sizeof(st));
  389. // go through all the dictionary pairs
  390. while (1)
  391. {
  392. // parse key
  393. com_token = COM_Parse (&data);
  394. if (com_token[0] == '}')
  395. break;
  396. if (!data)
  397. gi.error ("ED_ParseEntity: EOF without closing brace");
  398. strncpy (keyname, com_token, sizeof(keyname)-1);
  399. // parse value
  400. com_token = COM_Parse (&data);
  401. if (!data)
  402. gi.error ("ED_ParseEntity: EOF without closing brace");
  403. if (com_token[0] == '}')
  404. gi.error ("ED_ParseEntity: closing brace without data");
  405. init = true;
  406. // keynames with a leading underscore are used for utility comments,
  407. // and are immediately discarded by quake
  408. if (keyname[0] == '_')
  409. continue;
  410. ED_ParseField (keyname, com_token, ent);
  411. }
  412. if (!init)
  413. memset (ent, 0, sizeof(*ent));
  414. return data;
  415. }
  416. /*
  417. ================
  418. G_FindTeams
  419. Chain together all entities with a matching team field.
  420. All but the first will have the FL_TEAMSLAVE flag set.
  421. All but the last will have the teamchain field set to the next one
  422. ================
  423. */
  424. void G_FindTeams (void)
  425. {
  426. edict_t *e, *e2, *chain;
  427. int i, j;
  428. int c, c2;
  429. c = 0;
  430. c2 = 0;
  431. for (i=1, e=g_edicts+i ; i < globals.num_edicts ; i++,e++)
  432. {
  433. if (!e->inuse)
  434. continue;
  435. if (!e->team)
  436. continue;
  437. if (e->flags & FL_TEAMSLAVE)
  438. continue;
  439. chain = e;
  440. e->teammaster = e;
  441. c++;
  442. c2++;
  443. for (j=i+1, e2=e+1 ; j < globals.num_edicts ; j++,e2++)
  444. {
  445. if (!e2->inuse)
  446. continue;
  447. if (!e2->team)
  448. continue;
  449. if (e2->flags & FL_TEAMSLAVE)
  450. continue;
  451. if (!strcmp(e->team, e2->team))
  452. {
  453. c2++;
  454. chain->teamchain = e2;
  455. e2->teammaster = e;
  456. chain = e2;
  457. e2->flags |= FL_TEAMSLAVE;
  458. }
  459. }
  460. }
  461. gi.dprintf ("%i teams with %i entities\n", c, c2);
  462. }
  463. /*
  464. ==============
  465. SpawnEntities
  466. Creates a server's entity / program execution context by
  467. parsing textual entity definitions out of an ent file.
  468. ==============
  469. */
  470. void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
  471. {
  472. edict_t *ent;
  473. int inhibit;
  474. char *com_token;
  475. int i;
  476. float skill_level;
  477. skill_level = floor (skill->value);
  478. if (skill_level < 0)
  479. skill_level = 0;
  480. if (skill_level > 3)
  481. skill_level = 3;
  482. if (skill->value != skill_level)
  483. gi.cvar_forceset("skill", va("%f", skill_level));
  484. SaveClientData ();
  485. gi.FreeTags (TAG_LEVEL);
  486. memset (&level, 0, sizeof(level));
  487. memset (g_edicts, 0, game.maxentities * sizeof (g_edicts[0]));
  488. strncpy (level.mapname, mapname, sizeof(level.mapname)-1);
  489. strncpy (game.spawnpoint, spawnpoint, sizeof(game.spawnpoint)-1);
  490. // set client fields on player ents
  491. for (i=0 ; i<game.maxclients ; i++)
  492. g_edicts[i+1].client = game.clients + i;
  493. ent = NULL;
  494. inhibit = 0;
  495. // parse ents
  496. while (1)
  497. {
  498. // parse the opening brace
  499. com_token = COM_Parse (&entities);
  500. if (!entities)
  501. break;
  502. if (com_token[0] != '{')
  503. gi.error ("ED_LoadFromFile: found %s when expecting {",com_token);
  504. if (!ent)
  505. ent = g_edicts;
  506. else
  507. ent = G_Spawn ();
  508. entities = ED_ParseEdict (entities, ent);
  509. // yet another map hack
  510. if (!stricmp(level.mapname, "command") && !stricmp(ent->classname, "trigger_once") && !stricmp(ent->model, "*27"))
  511. ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
  512. // remove things (except the world) from different skill levels or deathmatch
  513. if (ent != g_edicts)
  514. {
  515. if (deathmatch->value)
  516. {
  517. if ( ent->spawnflags & SPAWNFLAG_NOT_DEATHMATCH )
  518. {
  519. G_FreeEdict (ent);
  520. inhibit++;
  521. continue;
  522. }
  523. }
  524. else
  525. {
  526. if ( /* ((coop->value) && (ent->spawnflags & SPAWNFLAG_NOT_COOP)) || */
  527. ((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
  528. ((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
  529. (((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD))
  530. )
  531. {
  532. G_FreeEdict (ent);
  533. inhibit++;
  534. continue;
  535. }
  536. }
  537. ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH);
  538. }
  539. ED_CallSpawn (ent);
  540. }
  541. gi.dprintf ("%i entities inhibited\n", inhibit);
  542. G_FindTeams ();
  543. PlayerTrail_Init ();
  544. //ZOID
  545. CTFSpawn();
  546. //ZOID
  547. }
  548. //===================================================================
  549. #if 0
  550. // cursor positioning
  551. xl <value>
  552. xr <value>
  553. yb <value>
  554. yt <value>
  555. xv <value>
  556. yv <value>
  557. // drawing
  558. statpic <name>
  559. pic <stat>
  560. num <fieldwidth> <stat>
  561. string <stat>
  562. // control
  563. if <stat>
  564. ifeq <stat> <value>
  565. ifbit <stat> <value>
  566. endif
  567. #endif
  568. char *single_statusbar =
  569. "yb -24 "
  570. // health
  571. "xv 0 "
  572. "hnum "
  573. "xv 50 "
  574. "pic 0 "
  575. // ammo
  576. "if 2 "
  577. " xv 100 "
  578. " anum "
  579. " xv 150 "
  580. " pic 2 "
  581. "endif "
  582. // armor
  583. "if 4 "
  584. " xv 200 "
  585. " rnum "
  586. " xv 250 "
  587. " pic 4 "
  588. "endif "
  589. // selected item
  590. "if 6 "
  591. " xv 296 "
  592. " pic 6 "
  593. "endif "
  594. "yb -50 "
  595. // picked up item
  596. "if 7 "
  597. " xv 0 "
  598. " pic 7 "
  599. " xv 26 "
  600. " yb -42 "
  601. " stat_string 8 "
  602. " yb -50 "
  603. "endif "
  604. // timer
  605. "if 9 "
  606. " xv 262 "
  607. " num 2 10 "
  608. " xv 296 "
  609. " pic 9 "
  610. "endif "
  611. // help / weapon icon
  612. "if 11 "
  613. " xv 148 "
  614. " pic 11 "
  615. "endif "
  616. ;
  617. char *dm_statusbar =
  618. "yb -24 "
  619. // health
  620. "xv 0 "
  621. "hnum "
  622. "xv 50 "
  623. "pic 0 "
  624. // ammo
  625. "if 2 "
  626. " xv 100 "
  627. " anum "
  628. " xv 150 "
  629. " pic 2 "
  630. "endif "
  631. // armor
  632. "if 4 "
  633. " xv 200 "
  634. " rnum "
  635. " xv 250 "
  636. " pic 4 "
  637. "endif "
  638. // selected item
  639. "if 6 "
  640. " xv 296 "
  641. " pic 6 "
  642. "endif "
  643. "yb -50 "
  644. // picked up item
  645. "if 7 "
  646. " xv 0 "
  647. " pic 7 "
  648. " xv 26 "
  649. " yb -42 "
  650. " stat_string 8 "
  651. " yb -50 "
  652. "endif "
  653. // timer
  654. "if 9 "
  655. " xv 246 "
  656. " num 2 10 "
  657. " xv 296 "
  658. " pic 9 "
  659. "endif "
  660. // help / weapon icon
  661. "if 11 "
  662. " xv 148 "
  663. " pic 11 "
  664. "endif "
  665. // frags
  666. "xr -50 "
  667. "yt 2 "
  668. "num 3 14"
  669. ;
  670. /*QUAKED worldspawn (0 0 0) ?
  671. Only used for the world.
  672. "sky" environment map name
  673. "skyaxis" vector axis for rotating sky
  674. "skyrotate" speed of rotation in degrees/second
  675. "sounds" music cd track number
  676. "gravity" 800 is default gravity
  677. "message" text to print at user logon
  678. */
  679. void SP_worldspawn (edict_t *ent)
  680. {
  681. ent->movetype = MOVETYPE_PUSH;
  682. ent->solid = SOLID_BSP;
  683. ent->inuse = true; // since the world doesn't use G_Spawn()
  684. ent->s.modelindex = 1; // world model is always index 1
  685. //---------------
  686. // reserve some spots for dead player bodies for coop / deathmatch
  687. InitBodyQue ();
  688. // set configstrings for items
  689. SetItemNames ();
  690. if (st.nextmap)
  691. strcpy (level.nextmap, st.nextmap);
  692. // make some data visible to the server
  693. if (ent->message && ent->message[0])
  694. {
  695. gi.configstring (CS_NAME, ent->message);
  696. strncpy (level.level_name, ent->message, sizeof(level.level_name));
  697. }
  698. else
  699. strncpy (level.level_name, level.mapname, sizeof(level.level_name));
  700. if (st.sky && st.sky[0])
  701. gi.configstring (CS_SKY, st.sky);
  702. else
  703. gi.configstring (CS_SKY, "unit1_");
  704. gi.configstring (CS_SKYROTATE, va("%f", st.skyrotate) );
  705. gi.configstring (CS_SKYAXIS, va("%f %f %f",
  706. st.skyaxis[0], st.skyaxis[1], st.skyaxis[2]) );
  707. gi.configstring (CS_CDTRACK, va("%i", ent->sounds) );
  708. gi.configstring (CS_MAXCLIENTS, va("%i", (int)(maxclients->value) ) );
  709. // status bar program
  710. if (deathmatch->value)
  711. //ZOID
  712. if (ctf->value) {
  713. gi.configstring (CS_STATUSBAR, ctf_statusbar);
  714. //precaches
  715. gi.imageindex("i_ctf1");
  716. gi.imageindex("i_ctf2");
  717. gi.imageindex("i_ctf1d");
  718. gi.imageindex("i_ctf2d");
  719. gi.imageindex("i_ctf1t");
  720. gi.imageindex("i_ctf2t");
  721. gi.imageindex("i_ctfj");
  722. } else
  723. //ZOID
  724. gi.configstring (CS_STATUSBAR, dm_statusbar);
  725. else
  726. gi.configstring (CS_STATUSBAR, single_statusbar);
  727. //---------------
  728. // help icon for statusbar
  729. gi.imageindex ("i_help");
  730. level.pic_health = gi.imageindex ("i_health");
  731. gi.imageindex ("help");
  732. gi.imageindex ("field_3");
  733. if (!st.gravity)
  734. gi.cvar_set("sv_gravity", "800");
  735. else
  736. gi.cvar_set("sv_gravity", st.gravity);
  737. snd_fry = gi.soundindex ("player/fry.wav"); // standing in lava / slime
  738. PrecacheItem (FindItem ("Blaster"));
  739. gi.soundindex ("player/lava1.wav");
  740. gi.soundindex ("player/lava2.wav");
  741. gi.soundindex ("misc/pc_up.wav");
  742. gi.soundindex ("misc/talk1.wav");
  743. gi.soundindex ("misc/udeath.wav");
  744. // gibs
  745. gi.soundindex ("items/respawn1.wav");
  746. // sexed sounds
  747. gi.soundindex ("*death1.wav");
  748. gi.soundindex ("*death2.wav");
  749. gi.soundindex ("*death3.wav");
  750. gi.soundindex ("*death4.wav");
  751. gi.soundindex ("*fall1.wav");
  752. gi.soundindex ("*fall2.wav");
  753. gi.soundindex ("*gurp1.wav"); // drowning damage
  754. gi.soundindex ("*gurp2.wav");
  755. gi.soundindex ("*jump1.wav"); // player jump
  756. gi.soundindex ("*pain25_1.wav");
  757. gi.soundindex ("*pain25_2.wav");
  758. gi.soundindex ("*pain50_1.wav");
  759. gi.soundindex ("*pain50_2.wav");
  760. gi.soundindex ("*pain75_1.wav");
  761. gi.soundindex ("*pain75_2.wav");
  762. gi.soundindex ("*pain100_1.wav");
  763. gi.soundindex ("*pain100_2.wav");
  764. #if 0 //DISABLED
  765. // sexed models
  766. // THIS ORDER MUST MATCH THE DEFINES IN g_local.h
  767. // you can add more, max 15
  768. gi.modelindex ("#w_blaster.md2");
  769. gi.modelindex ("#w_shotgun.md2");
  770. gi.modelindex ("#w_sshotgun.md2");
  771. gi.modelindex ("#w_machinegun.md2");
  772. gi.modelindex ("#w_chaingun.md2");
  773. gi.modelindex ("#a_grenades.md2");
  774. gi.modelindex ("#w_glauncher.md2");
  775. gi.modelindex ("#w_rlauncher.md2");
  776. gi.modelindex ("#w_hyperblaster.md2");
  777. gi.modelindex ("#w_railgun.md2");
  778. gi.modelindex ("#w_bfg.md2");
  779. gi.modelindex ("#w_grapple.md2");
  780. #endif
  781. //-------------------
  782. gi.soundindex ("player/gasp1.wav"); // gasping for air
  783. gi.soundindex ("player/gasp2.wav"); // head breaking surface, not gasping
  784. gi.soundindex ("player/watr_in.wav"); // feet hitting water
  785. gi.soundindex ("player/watr_out.wav"); // feet leaving water
  786. gi.soundindex ("player/watr_un.wav"); // head going underwater
  787. gi.soundindex ("player/u_breath1.wav");
  788. gi.soundindex ("player/u_breath2.wav");
  789. gi.soundindex ("items/pkup.wav"); // bonus item pickup
  790. gi.soundindex ("world/land.wav"); // landing thud
  791. gi.soundindex ("misc/h2ohit1.wav"); // landing splash
  792. gi.soundindex ("items/damage.wav");
  793. gi.soundindex ("items/protect.wav");
  794. gi.soundindex ("items/protect4.wav");
  795. gi.soundindex ("weapons/noammo.wav");
  796. gi.soundindex ("infantry/inflies1.wav");
  797. sm_meat_index = gi.modelindex ("models/objects/gibs/sm_meat/tris.md2");
  798. gi.modelindex ("models/objects/gibs/arm/tris.md2");
  799. gi.modelindex ("models/objects/gibs/bone/tris.md2");
  800. gi.modelindex ("models/objects/gibs/bone2/tris.md2");
  801. gi.modelindex ("models/objects/gibs/chest/tris.md2");
  802. gi.modelindex ("models/objects/gibs/skull/tris.md2");
  803. gi.modelindex ("models/objects/gibs/head2/tris.md2");
  804. //
  805. // Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
  806. //
  807. // 0 normal
  808. gi.configstring(CS_LIGHTS+0, "m");
  809. // 1 FLICKER (first variety)
  810. gi.configstring(CS_LIGHTS+1, "mmnmmommommnonmmonqnmmo");
  811. // 2 SLOW STRONG PULSE
  812. gi.configstring(CS_LIGHTS+2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
  813. // 3 CANDLE (first variety)
  814. gi.configstring(CS_LIGHTS+3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
  815. // 4 FAST STROBE
  816. gi.configstring(CS_LIGHTS+4, "mamamamamama");
  817. // 5 GENTLE PULSE 1
  818. gi.configstring(CS_LIGHTS+5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
  819. // 6 FLICKER (second variety)
  820. gi.configstring(CS_LIGHTS+6, "nmonqnmomnmomomno");
  821. // 7 CANDLE (second variety)
  822. gi.configstring(CS_LIGHTS+7, "mmmaaaabcdefgmmmmaaaammmaamm");
  823. // 8 CANDLE (third variety)
  824. gi.configstring(CS_LIGHTS+8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
  825. // 9 SLOW STROBE (fourth variety)
  826. gi.configstring(CS_LIGHTS+9, "aaaaaaaazzzzzzzz");
  827. // 10 FLUORESCENT FLICKER
  828. gi.configstring(CS_LIGHTS+10, "mmamammmmammamamaaamammma");
  829. // 11 SLOW PULSE NOT FADE TO BLACK
  830. gi.configstring(CS_LIGHTS+11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
  831. // styles 32-62 are assigned by the light program for switchable lights
  832. // 63 testing
  833. gi.configstring(CS_LIGHTS+63, "a");
  834. }