g_svcmds.cpp 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. // leave this line at the top for all g_xxxx.cpp files...
  2. #include "g_headers.h"
  3. #include "Q3_Interface.h"
  4. #include "g_local.h"
  5. #include "wp_saber.h"
  6. extern void G_NextTestAxes( void );
  7. extern void G_ChangePlayerModel( gentity_t *ent, const char *newModel );
  8. extern void G_InitPlayerFromCvars( gentity_t *ent );
  9. extern void Q3_SetViewEntity(int entID, const char *name);
  10. extern qboolean G_ClearViewEntity( gentity_t *ent );
  11. extern void G_Knockdown( gentity_t *self, gentity_t *attacker, const vec3_t pushDir, float strength, qboolean breakSaberLock );
  12. extern void WP_SetSaber( gentity_t *ent, int saberNum, char *saberName );
  13. extern void WP_RemoveSaber( gentity_t *ent, int saberNum );
  14. extern saber_colors_t TranslateSaberColor( const char *name );
  15. extern void G_SetWeapon( gentity_t *self, int wp );
  16. extern stringID_table_t WPTable[];
  17. extern cvar_t *g_char_model;
  18. extern cvar_t *g_char_skin_head;
  19. extern cvar_t *g_char_skin_torso;
  20. extern cvar_t *g_char_skin_legs;
  21. extern cvar_t *g_char_color_red;
  22. extern cvar_t *g_char_color_green;
  23. extern cvar_t *g_char_color_blue;
  24. extern cvar_t *g_saber;
  25. extern cvar_t *g_saber2;
  26. extern cvar_t *g_saber_color;
  27. extern cvar_t *g_saber2_color;
  28. /*
  29. ===================
  30. Svcmd_EntityList_f
  31. ===================
  32. */
  33. void Svcmd_EntityList_f (void) {
  34. int e;
  35. gentity_t *check;
  36. check = g_entities+1;
  37. for (e = 1; e < globals.num_entities ; e++, check++) {
  38. if ( !check->inuse ) {
  39. continue;
  40. }
  41. gi.Printf("%3i:", e);
  42. switch ( check->s.eType ) {
  43. case ET_GENERAL:
  44. gi.Printf("ET_GENERAL ");
  45. break;
  46. case ET_PLAYER:
  47. gi.Printf("ET_PLAYER ");
  48. break;
  49. case ET_ITEM:
  50. gi.Printf("ET_ITEM ");
  51. break;
  52. case ET_MISSILE:
  53. gi.Printf("ET_MISSILE ");
  54. break;
  55. case ET_MOVER:
  56. gi.Printf("ET_MOVER ");
  57. break;
  58. case ET_BEAM:
  59. gi.Printf("ET_BEAM ");
  60. break;
  61. default:
  62. gi.Printf("#%i", check->s.eType);
  63. break;
  64. }
  65. if ( check->classname ) {
  66. gi.Printf("%s", check->classname);
  67. }
  68. gi.Printf("\n");
  69. }
  70. }
  71. gclient_t *ClientForString( const char *s ) {
  72. gclient_t *cl;
  73. int i;
  74. int idnum;
  75. // numeric values are just slot numbers
  76. if ( s[0] >= '0' && s[0] <= '9' ) {
  77. idnum = atoi( s );
  78. if ( idnum < 0 || idnum >= level.maxclients ) {
  79. Com_Printf( "Bad client slot: %i\n", idnum );
  80. return NULL;
  81. }
  82. cl = &level.clients[idnum];
  83. if ( cl->pers.connected == CON_DISCONNECTED ) {
  84. gi.Printf( "Client %i is not connected\n", idnum );
  85. return NULL;
  86. }
  87. return cl;
  88. }
  89. // check for a name match
  90. for ( i=0 ; i < level.maxclients ; i++ ) {
  91. cl = &level.clients[i];
  92. if ( cl->pers.connected == CON_DISCONNECTED ) {
  93. continue;
  94. }
  95. if ( !Q_stricmp( cl->pers.netname, s ) ) {
  96. return cl;
  97. }
  98. }
  99. gi.Printf( "User %s is not on the server\n", s );
  100. return NULL;
  101. }
  102. //---------------------------
  103. extern void G_StopCinematicSkip( void );
  104. extern void G_StartCinematicSkip( void );
  105. extern void ExitEmplacedWeapon( gentity_t *ent );
  106. static void Svcmd_ExitView_f( void )
  107. {
  108. extern cvar_t *g_skippingcin;
  109. static int exitViewDebounce = 0;
  110. if ( exitViewDebounce > level.time )
  111. {
  112. return;
  113. }
  114. exitViewDebounce = level.time + 500;
  115. if ( in_camera )
  116. {//see if we need to exit an in-game cinematic
  117. if ( g_skippingcin->integer ) // already doing cinematic skip?
  118. {// yes... so stop skipping...
  119. G_StopCinematicSkip();
  120. }
  121. else
  122. {// no... so start skipping...
  123. G_StartCinematicSkip();
  124. }
  125. }
  126. else if ( !G_ClearViewEntity( player ) )
  127. {//didn't exit control of a droid or turret
  128. //okay, now try exiting emplaced guns or AT-ST's
  129. if ( player->s.eFlags & EF_LOCKED_TO_WEAPON )
  130. {//get out of emplaced gun
  131. ExitEmplacedWeapon( player );
  132. }
  133. else if ( player->client && player->client->NPC_class == CLASS_ATST )
  134. {//a player trying to get out of his ATST
  135. GEntity_UseFunc( player->activator, player, player );
  136. }
  137. }
  138. }
  139. gentity_t *G_GetSelfForPlayerCmd( void )
  140. {
  141. if ( g_entities[0].client->ps.viewEntity > 0
  142. && g_entities[0].client->ps.viewEntity < ENTITYNUM_WORLD
  143. && g_entities[g_entities[0].client->ps.viewEntity].client
  144. && g_entities[g_entities[0].client->ps.viewEntity].s.weapon == WP_SABER )
  145. {//you're controlling another NPC
  146. return (&g_entities[g_entities[0].client->ps.viewEntity]);
  147. }
  148. else
  149. {
  150. return (&g_entities[0]);
  151. }
  152. }
  153. static void Svcmd_Saber_f()
  154. {
  155. char *saber = gi.argv(1);
  156. char *saber2 = gi.argv(2);
  157. if ( !g_entities[0].client || !saber || !saber[0] )
  158. {
  159. return;
  160. }
  161. gi.cvar_set( "g_saber", saber );
  162. WP_SetSaber( &g_entities[0], 0, saber );
  163. if ( saber2 && saber2[0] && !g_entities[0].client->ps.saber[0].twoHanded )
  164. {//want to use a second saber and first one is not twoHanded
  165. gi.cvar_set( "g_saber2", saber2 );
  166. WP_SetSaber( &g_entities[0], 1, saber2 );
  167. }
  168. else
  169. {
  170. gi.cvar_set( "g_saber2", "" );
  171. WP_RemoveSaber( &g_entities[0], 1 );
  172. }
  173. }
  174. static void Svcmd_SaberBlade_f()
  175. {
  176. if ( gi.argc() < 2 )
  177. {
  178. gi.Printf( "USAGE: saberblade <sabernum> <bladenum> [0 = off, 1 = on, no arg = toggle]\n" );
  179. return;
  180. }
  181. if ( &g_entities[0] == NULL || &g_entities[0].client == NULL )
  182. {
  183. return;
  184. }
  185. int sabernum = atoi(gi.argv(1)) - 1;
  186. if ( sabernum < 0 || sabernum > 1 )
  187. {
  188. return;
  189. }
  190. if ( sabernum > 0 && !g_entities[0].client->ps.dualSabers )
  191. {
  192. return;
  193. }
  194. //FIXME: what if don't even have a single saber at all?
  195. int bladenum = atoi(gi.argv(2)) - 1;
  196. if ( bladenum < 0 || bladenum >= g_entities[0].client->ps.saber[sabernum].numBlades )
  197. {
  198. return;
  199. }
  200. qboolean turnOn;
  201. if ( gi.argc() > 2 )
  202. {//explicit
  203. turnOn = (atoi(gi.argv(3))!=0);
  204. }
  205. else
  206. {//toggle
  207. turnOn = (g_entities[0].client->ps.saber[sabernum].blade[bladenum].active==qfalse);
  208. }
  209. g_entities[0].client->ps.SaberBladeActivate( sabernum, bladenum, turnOn );
  210. }
  211. static void Svcmd_SaberColor_f()
  212. {//FIXME: just list the colors, each additional listing sets that blade
  213. int saberNum = atoi(gi.argv(1));
  214. char *color[MAX_BLADES];
  215. int bladeNum;
  216. for ( bladeNum = 0; bladeNum < MAX_BLADES; bladeNum++ )
  217. {
  218. color[bladeNum] = gi.argv(2+bladeNum);
  219. }
  220. if ( !VALIDSTRING( color ) || saberNum < 1 || saberNum > 2 )
  221. {
  222. gi.Printf( "Usage: saberColor <saberNum> <blade1 color> <blade2 color> ... <blade8 color> \n" );
  223. gi.Printf( "valid saberNums: 1 or 2\n" );
  224. gi.Printf( "valid colors: red, orange, yellow, green, blue, and purple\n" );
  225. return;
  226. }
  227. saberNum--;
  228. gentity_t *self = G_GetSelfForPlayerCmd();
  229. for ( bladeNum = 0; bladeNum < MAX_BLADES; bladeNum++ )
  230. {
  231. if ( !color[bladeNum] || !color[bladeNum][0] )
  232. {
  233. break;
  234. }
  235. else
  236. {
  237. self->client->ps.saber[saberNum].blade[bladeNum].color = TranslateSaberColor( color[bladeNum] );
  238. }
  239. }
  240. if ( saberNum == 0 )
  241. {
  242. gi.cvar_set( "g_saber_color", color[0] );
  243. }
  244. else if ( saberNum == 1 )
  245. {
  246. gi.cvar_set( "g_saber2_color", color[0] );
  247. }
  248. }
  249. static void Svcmd_ForceJump_f( void )
  250. {
  251. if ( !&g_entities[0] || !g_entities[0].client )
  252. {
  253. return;
  254. }
  255. if ( !g_cheats->integer )
  256. {
  257. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  258. return;
  259. }
  260. char *newVal = gi.argv(1);
  261. if ( !VALIDSTRING( newVal ) )
  262. {
  263. gi.Printf( "Current forceJump level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] );
  264. gi.Printf( "Usage: setForceJump <level> (1 - 3)\n" );
  265. return;
  266. }
  267. int val = atoi(newVal);
  268. if ( val > FORCE_LEVEL_0 )
  269. {
  270. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_LEVITATION );
  271. }
  272. else
  273. {
  274. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_LEVITATION );
  275. }
  276. g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] = val;
  277. if ( g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] < FORCE_LEVEL_0 )
  278. {
  279. g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] = FORCE_LEVEL_0;
  280. }
  281. else if ( g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_3 )
  282. {
  283. g_entities[0].client->ps.forcePowerLevel[FP_LEVITATION] = FORCE_LEVEL_3;
  284. }
  285. }
  286. static void Svcmd_SaberThrow_f( void )
  287. {
  288. if ( !&g_entities[0] || !g_entities[0].client )
  289. {
  290. return;
  291. }
  292. if ( !g_cheats->integer )
  293. {
  294. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  295. return;
  296. }
  297. char *newVal = gi.argv(1);
  298. if ( !VALIDSTRING( newVal ) )
  299. {
  300. gi.Printf( "Current saberThrow level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] );
  301. gi.Printf( "Usage: setSaberThrow <level> (1 - 3)\n" );
  302. return;
  303. }
  304. int val = atoi(newVal);
  305. if ( val > FORCE_LEVEL_0 )
  306. {
  307. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_SABERTHROW );
  308. }
  309. else
  310. {
  311. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_SABERTHROW );
  312. }
  313. g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] = val;
  314. if ( g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] < FORCE_LEVEL_0 )
  315. {
  316. g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] = FORCE_LEVEL_0;
  317. }
  318. else if ( g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] > FORCE_LEVEL_3 )
  319. {
  320. g_entities[0].client->ps.forcePowerLevel[FP_SABERTHROW] = FORCE_LEVEL_3;
  321. }
  322. }
  323. static void Svcmd_ForceHeal_f( void )
  324. {
  325. if ( !&g_entities[0] || !g_entities[0].client )
  326. {
  327. return;
  328. }
  329. if ( !g_cheats->integer )
  330. {
  331. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  332. return;
  333. }
  334. char *newVal = gi.argv(1);
  335. if ( !VALIDSTRING( newVal ) )
  336. {
  337. gi.Printf( "Current forceHeal level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_HEAL] );
  338. gi.Printf( "Usage: forceHeal <level> (1 - 3)\n" );
  339. return;
  340. }
  341. int val = atoi(newVal);
  342. if ( val > FORCE_LEVEL_0 )
  343. {
  344. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_HEAL );
  345. }
  346. else
  347. {
  348. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_HEAL );
  349. }
  350. g_entities[0].client->ps.forcePowerLevel[FP_HEAL] = val;
  351. if ( g_entities[0].client->ps.forcePowerLevel[FP_HEAL] < FORCE_LEVEL_0 )
  352. {
  353. g_entities[0].client->ps.forcePowerLevel[FP_HEAL] = FORCE_LEVEL_0;
  354. }
  355. else if ( g_entities[0].client->ps.forcePowerLevel[FP_HEAL] > FORCE_LEVEL_3 )
  356. {
  357. g_entities[0].client->ps.forcePowerLevel[FP_HEAL] = FORCE_LEVEL_3;
  358. }
  359. }
  360. static void Svcmd_ForcePush_f( void )
  361. {
  362. if ( !&g_entities[0] || !g_entities[0].client )
  363. {
  364. return;
  365. }
  366. if ( !g_cheats->integer )
  367. {
  368. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  369. return;
  370. }
  371. char *newVal = gi.argv(1);
  372. if ( !VALIDSTRING( newVal ) )
  373. {
  374. gi.Printf( "Current forcePush level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_PUSH] );
  375. gi.Printf( "Usage: forcePush <level> (1 - 3)\n" );
  376. return;
  377. }
  378. int val = atoi(newVal);
  379. if ( val > FORCE_LEVEL_0 )
  380. {
  381. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_PUSH );
  382. }
  383. else
  384. {
  385. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_PUSH );
  386. }
  387. g_entities[0].client->ps.forcePowerLevel[FP_PUSH] = val;
  388. if ( g_entities[0].client->ps.forcePowerLevel[FP_PUSH] < FORCE_LEVEL_0 )
  389. {
  390. g_entities[0].client->ps.forcePowerLevel[FP_PUSH] = FORCE_LEVEL_0;
  391. }
  392. else if ( g_entities[0].client->ps.forcePowerLevel[FP_PUSH] > FORCE_LEVEL_3 )
  393. {
  394. g_entities[0].client->ps.forcePowerLevel[FP_PUSH] = FORCE_LEVEL_3;
  395. }
  396. }
  397. static void Svcmd_ForcePull_f( void )
  398. {
  399. if ( !&g_entities[0] || !g_entities[0].client )
  400. {
  401. return;
  402. }
  403. if ( !g_cheats->integer )
  404. {
  405. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  406. return;
  407. }
  408. char *newVal = gi.argv(1);
  409. if ( !VALIDSTRING( newVal ) )
  410. {
  411. gi.Printf( "Current forcePull level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_PULL] );
  412. gi.Printf( "Usage: forcePull <level> (1 - 3)\n" );
  413. return;
  414. }
  415. int val = atoi(newVal);
  416. if ( val > FORCE_LEVEL_0 )
  417. {
  418. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_PULL );
  419. }
  420. else
  421. {
  422. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_PULL );
  423. }
  424. g_entities[0].client->ps.forcePowerLevel[FP_PULL] = val;
  425. if ( g_entities[0].client->ps.forcePowerLevel[FP_PULL] < FORCE_LEVEL_0 )
  426. {
  427. g_entities[0].client->ps.forcePowerLevel[FP_PULL] = FORCE_LEVEL_0;
  428. }
  429. else if ( g_entities[0].client->ps.forcePowerLevel[FP_PULL] > FORCE_LEVEL_3 )
  430. {
  431. g_entities[0].client->ps.forcePowerLevel[FP_PULL] = FORCE_LEVEL_3;
  432. }
  433. }
  434. static void Svcmd_ForceSpeed_f( void )
  435. {
  436. if ( !&g_entities[0] || !g_entities[0].client )
  437. {
  438. return;
  439. }
  440. if ( !g_cheats->integer )
  441. {
  442. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  443. return;
  444. }
  445. char *newVal = gi.argv(1);
  446. if ( !VALIDSTRING( newVal ) )
  447. {
  448. gi.Printf( "Current forceSpeed level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_SPEED] );
  449. gi.Printf( "Usage: forceSpeed <level> (1 - 3)\n" );
  450. return;
  451. }
  452. int val = atoi(newVal);
  453. if ( val > FORCE_LEVEL_0 )
  454. {
  455. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_SPEED );
  456. }
  457. else
  458. {
  459. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_SPEED );
  460. }
  461. g_entities[0].client->ps.forcePowerLevel[FP_SPEED] = val;
  462. if ( g_entities[0].client->ps.forcePowerLevel[FP_SPEED] < FORCE_LEVEL_0 )
  463. {
  464. g_entities[0].client->ps.forcePowerLevel[FP_SPEED] = FORCE_LEVEL_0;
  465. }
  466. else if ( g_entities[0].client->ps.forcePowerLevel[FP_SPEED] > FORCE_LEVEL_3 )
  467. {
  468. g_entities[0].client->ps.forcePowerLevel[FP_SPEED] = FORCE_LEVEL_3;
  469. }
  470. }
  471. static void Svcmd_ForceGrip_f( void )
  472. {
  473. if ( !&g_entities[0] || !g_entities[0].client )
  474. {
  475. return;
  476. }
  477. if ( !g_cheats->integer )
  478. {
  479. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  480. return;
  481. }
  482. char *newVal = gi.argv(1);
  483. if ( !VALIDSTRING( newVal ) )
  484. {
  485. gi.Printf( "Current forceGrip level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_GRIP] );
  486. gi.Printf( "Usage: forceGrip <level> (1 - 3)\n" );
  487. return;
  488. }
  489. int val = atoi(newVal);
  490. if ( val > FORCE_LEVEL_0 )
  491. {
  492. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_GRIP );
  493. }
  494. else
  495. {
  496. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_GRIP );
  497. }
  498. g_entities[0].client->ps.forcePowerLevel[FP_GRIP] = val;
  499. if ( g_entities[0].client->ps.forcePowerLevel[FP_GRIP] < FORCE_LEVEL_0 )
  500. {
  501. g_entities[0].client->ps.forcePowerLevel[FP_GRIP] = FORCE_LEVEL_0;
  502. }
  503. else if ( g_entities[0].client->ps.forcePowerLevel[FP_GRIP] > FORCE_LEVEL_3 )
  504. {
  505. g_entities[0].client->ps.forcePowerLevel[FP_GRIP] = FORCE_LEVEL_3;
  506. }
  507. }
  508. static void Svcmd_ForceLightning_f( void )
  509. {
  510. if ( !&g_entities[0] || !g_entities[0].client )
  511. {
  512. return;
  513. }
  514. if ( !g_cheats->integer )
  515. {
  516. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  517. return;
  518. }
  519. char *newVal = gi.argv(1);
  520. if ( !VALIDSTRING( newVal ) )
  521. {
  522. gi.Printf( "Current forceLightning level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] );
  523. gi.Printf( "Usage: forceLightning <level> (1 - 3)\n" );
  524. return;
  525. }
  526. int val = atoi(newVal);
  527. if ( val > FORCE_LEVEL_0 )
  528. {
  529. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_LIGHTNING );
  530. }
  531. else
  532. {
  533. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_LIGHTNING );
  534. }
  535. g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] = val;
  536. if ( g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] < FORCE_LEVEL_0 )
  537. {
  538. g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] = FORCE_LEVEL_0;
  539. }
  540. else if ( g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_3 )
  541. {
  542. g_entities[0].client->ps.forcePowerLevel[FP_LIGHTNING] = FORCE_LEVEL_3;
  543. }
  544. }
  545. static void Svcmd_MindTrick_f( void )
  546. {
  547. if ( !&g_entities[0] || !g_entities[0].client )
  548. {
  549. return;
  550. }
  551. if ( !g_cheats->integer )
  552. {
  553. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  554. return;
  555. }
  556. char *newVal = gi.argv(1);
  557. if ( !VALIDSTRING( newVal ) )
  558. {
  559. gi.Printf( "Current mindTrick level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] );
  560. gi.Printf( "Usage: mindTrick <level> (1 - 3)\n" );
  561. return;
  562. }
  563. int val = atoi(newVal);
  564. if ( val > FORCE_LEVEL_0 )
  565. {
  566. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_TELEPATHY );
  567. }
  568. else
  569. {
  570. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_TELEPATHY );
  571. }
  572. g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] = val;
  573. if ( g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] < FORCE_LEVEL_0 )
  574. {
  575. g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] = FORCE_LEVEL_0;
  576. }
  577. else if ( g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] > FORCE_LEVEL_4 )
  578. {
  579. g_entities[0].client->ps.forcePowerLevel[FP_TELEPATHY] = FORCE_LEVEL_4;
  580. }
  581. }
  582. static void Svcmd_SaberDefense_f( void )
  583. {
  584. if ( !&g_entities[0] || !g_entities[0].client )
  585. {
  586. return;
  587. }
  588. if ( !g_cheats->integer )
  589. {
  590. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  591. return;
  592. }
  593. char *newVal = gi.argv(1);
  594. if ( !VALIDSTRING( newVal ) )
  595. {
  596. gi.Printf( "Current saberDefense level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] );
  597. gi.Printf( "Usage: saberDefense <level> (1 - 3)\n" );
  598. return;
  599. }
  600. int val = atoi(newVal);
  601. if ( val > FORCE_LEVEL_0 )
  602. {
  603. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_SABER_DEFENSE );
  604. }
  605. else
  606. {
  607. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_SABER_DEFENSE );
  608. }
  609. g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] = val;
  610. if ( g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] < FORCE_LEVEL_0 )
  611. {
  612. g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] = FORCE_LEVEL_0;
  613. }
  614. else if ( g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_3 )
  615. {
  616. g_entities[0].client->ps.forcePowerLevel[FP_SABER_DEFENSE] = FORCE_LEVEL_3;
  617. }
  618. }
  619. static void Svcmd_SaberOffense_f( void )
  620. {
  621. if ( !&g_entities[0] || !g_entities[0].client )
  622. {
  623. return;
  624. }
  625. if ( !g_cheats->integer )
  626. {
  627. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  628. return;
  629. }
  630. char *newVal = gi.argv(1);
  631. if ( !VALIDSTRING( newVal ) )
  632. {
  633. gi.Printf( "Current saberOffense level is %d\n", g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] );
  634. gi.Printf( "Usage: saberOffense <level> (1 - 3)\n" );
  635. return;
  636. }
  637. int val = atoi(newVal);
  638. if ( val > FORCE_LEVEL_0 )
  639. {
  640. g_entities[0].client->ps.forcePowersKnown |= ( 1 << FP_SABER_OFFENSE );
  641. }
  642. else
  643. {
  644. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << FP_SABER_OFFENSE );
  645. }
  646. g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] = val;
  647. if ( g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] < FORCE_LEVEL_0 )
  648. {
  649. g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] = FORCE_LEVEL_0;
  650. }
  651. else if ( g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] >= SS_NUM_SABER_STYLES )
  652. {
  653. g_entities[0].client->ps.forcePowerLevel[FP_SABER_OFFENSE] = SS_NUM_SABER_STYLES-1;
  654. }
  655. }
  656. static void Svcmd_ForceSetLevel_f( int forcePower )
  657. {
  658. if ( !&g_entities[0] || !g_entities[0].client )
  659. {
  660. return;
  661. }
  662. if ( !g_cheats->integer )
  663. {
  664. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  665. return;
  666. }
  667. char *newVal = gi.argv(1);
  668. if ( !VALIDSTRING( newVal ) )
  669. {
  670. gi.Printf( "Current force level is %d\n", g_entities[0].client->ps.forcePowerLevel[forcePower] );
  671. gi.Printf( "Usage: force <level> (1 - 3)\n" );
  672. return;
  673. }
  674. int val = atoi(newVal);
  675. if ( val > FORCE_LEVEL_0 )
  676. {
  677. g_entities[0].client->ps.forcePowersKnown |= ( 1 << forcePower );
  678. }
  679. else
  680. {
  681. g_entities[0].client->ps.forcePowersKnown &= ~( 1 << forcePower );
  682. }
  683. g_entities[0].client->ps.forcePowerLevel[forcePower] = val;
  684. if ( g_entities[0].client->ps.forcePowerLevel[forcePower] < FORCE_LEVEL_0 )
  685. {
  686. g_entities[0].client->ps.forcePowerLevel[forcePower] = FORCE_LEVEL_0;
  687. }
  688. else if ( g_entities[0].client->ps.forcePowerLevel[forcePower] > FORCE_LEVEL_3 )
  689. {
  690. g_entities[0].client->ps.forcePowerLevel[forcePower] = FORCE_LEVEL_3;
  691. }
  692. }
  693. extern qboolean PM_SaberInStart( int move );
  694. extern qboolean PM_SaberInTransition( int move );
  695. extern qboolean PM_SaberInAttack( int move );
  696. void Svcmd_SaberAttackCycle_f( void )
  697. {
  698. if ( !&g_entities[0] || !g_entities[0].client )
  699. {
  700. return;
  701. }
  702. gentity_t *self = G_GetSelfForPlayerCmd();
  703. if ( self->s.weapon != WP_SABER )
  704. {// saberAttackCycle button also switches to saber
  705. gi.SendConsoleCommand("weapon 1" );
  706. return;
  707. }
  708. if ( self->client->ps.dualSabers )
  709. {//can't cycle styles with dualSabers, so just toggle second saber on/off
  710. if ( self->client->ps.saber[1].Active() )
  711. {//turn it off
  712. self->client->ps.saber[1].Deactivate();
  713. G_SoundIndexOnEnt( self, CHAN_WEAPON, self->client->ps.saber[0].soundOff );
  714. }
  715. else if ( !self->client->ps.saber[0].Active() )
  716. {//first one is off, too, so just turn that one on
  717. if ( !self->client->ps.saberInFlight )
  718. {//but only if it's in your hand!
  719. self->client->ps.saber[0].Activate();
  720. }
  721. }
  722. else
  723. {//turn on the second one
  724. self->client->ps.saber[1].Activate();
  725. }
  726. return;
  727. }
  728. else if ( self->client->ps.saber[0].numBlades > 1 )//self->client->ps.saber[0].type == SABER_STAFF )
  729. {//can't cycle styles with saberstaff, so just toggles saber blades on/off
  730. if ( self->client->ps.saberInFlight )
  731. {//can't turn second blade back on if it's in the air, you naughty boy!
  732. return;
  733. }
  734. qboolean playedSound = qfalse;
  735. if ( !self->client->ps.saber[0].blade[0].active )
  736. {//first one is not even on
  737. //turn only it on
  738. self->client->ps.SaberBladeActivate( 0, 0, qtrue );
  739. return;
  740. }
  741. for ( int i = 1; i < self->client->ps.saber[0].numBlades; i++ )
  742. {
  743. if ( !self->client->ps.saber[0].blade[i].active )
  744. {//extra is off, turn it on
  745. self->client->ps.SaberBladeActivate( 0, i, qtrue );
  746. }
  747. else
  748. {//turn extra off
  749. self->client->ps.SaberBladeActivate( 0, i, qfalse );
  750. if ( !playedSound )
  751. {
  752. G_SoundIndexOnEnt( self, CHAN_WEAPON, self->client->ps.saber[0].soundOff );
  753. playedSound = qtrue;
  754. }
  755. }
  756. }
  757. return;
  758. }
  759. //FIXME: if dualSabers and both on, do something here, too... maybe toggle the second one on/off?
  760. if ( !self->client->ps.saberStylesKnown )
  761. {
  762. return;
  763. }
  764. int saberAnimLevel;
  765. if ( !self->s.number )
  766. {
  767. saberAnimLevel = cg.saberAnimLevelPending;
  768. }
  769. else
  770. {
  771. saberAnimLevel = self->client->ps.saberAnimLevel;
  772. }
  773. saberAnimLevel++;
  774. int sanityCheck = 0;
  775. while ( self->client->ps.saberAnimLevel != saberAnimLevel
  776. && !(self->client->ps.saberStylesKnown&(1<<saberAnimLevel))
  777. && sanityCheck < SS_NUM_SABER_STYLES+1 )
  778. {
  779. saberAnimLevel++;
  780. if ( saberAnimLevel > SS_STAFF )
  781. {
  782. saberAnimLevel = SS_FAST;
  783. }
  784. sanityCheck++;
  785. }
  786. if ( !(self->client->ps.saberStylesKnown&(1<<saberAnimLevel)) )
  787. {
  788. return;
  789. }
  790. if ( !self->s.number )
  791. {
  792. cg.saberAnimLevelPending = saberAnimLevel;
  793. }
  794. else
  795. {
  796. self->client->ps.saberAnimLevel = saberAnimLevel;
  797. }
  798. #ifndef FINAL_BUILD
  799. switch ( saberAnimLevel )
  800. {
  801. case SS_FAST:
  802. gi.Printf( S_COLOR_BLUE"Lightsaber Combat Style: Fast\n" );
  803. //LIGHTSABERCOMBATSTYLE_FAST
  804. break;
  805. case SS_MEDIUM:
  806. gi.Printf( S_COLOR_YELLOW"Lightsaber Combat Style: Medium\n" );
  807. //LIGHTSABERCOMBATSTYLE_MEDIUM
  808. break;
  809. case SS_STRONG:
  810. gi.Printf( S_COLOR_RED"Lightsaber Combat Style: Strong\n" );
  811. //LIGHTSABERCOMBATSTYLE_STRONG
  812. break;
  813. case SS_DESANN:
  814. gi.Printf( S_COLOR_CYAN"Lightsaber Combat Style: Desann\n" );
  815. //LIGHTSABERCOMBATSTYLE_DESANN
  816. break;
  817. case SS_TAVION:
  818. gi.Printf( S_COLOR_MAGENTA"Lightsaber Combat Style: Tavion\n" );
  819. //LIGHTSABERCOMBATSTYLE_TAVION
  820. break;
  821. case SS_DUAL:
  822. gi.Printf( S_COLOR_MAGENTA"Lightsaber Combat Style: Dual\n" );
  823. //LIGHTSABERCOMBATSTYLE_TAVION
  824. break;
  825. case SS_STAFF:
  826. gi.Printf( S_COLOR_MAGENTA"Lightsaber Combat Style: Staff\n" );
  827. //LIGHTSABERCOMBATSTYLE_TAVION
  828. break;
  829. }
  830. //gi.Printf("\n");
  831. #endif
  832. }
  833. qboolean G_ReleaseEntity( gentity_t *grabber )
  834. {
  835. if ( grabber && grabber->client && grabber->client->ps.heldClient < ENTITYNUM_WORLD )
  836. {
  837. gentity_t *heldClient = &g_entities[grabber->client->ps.heldClient];
  838. grabber->client->ps.heldClient = ENTITYNUM_NONE;
  839. if ( heldClient && heldClient->client )
  840. {
  841. heldClient->client->ps.heldByClient = ENTITYNUM_NONE;
  842. heldClient->owner = NULL;
  843. }
  844. return qtrue;
  845. }
  846. return qfalse;
  847. }
  848. void G_GrabEntity( gentity_t *grabber, char *target )
  849. {
  850. if ( !grabber || !grabber->client )
  851. {
  852. return;
  853. }
  854. gentity_t *heldClient = G_Find( NULL, FOFS(targetname), (char *)target );
  855. if ( heldClient && heldClient->client && heldClient != grabber )//don't grab yourself, it's not polite
  856. {//found him
  857. grabber->client->ps.heldClient = heldClient->s.number;
  858. heldClient->client->ps.heldByClient = grabber->s.number;
  859. heldClient->owner = grabber;
  860. }
  861. }
  862. /*
  863. =================
  864. ConsoleCommand
  865. // these are added in cg_main, CG_Init so they tab-complete
  866. =================
  867. */
  868. qboolean ConsoleCommand( void ) {
  869. char *cmd;
  870. cmd = gi.argv(0);
  871. if ( Q_stricmp (cmd, "entitylist") == 0 )
  872. {
  873. Svcmd_EntityList_f();
  874. return qtrue;
  875. }
  876. if (Q_stricmp (cmd, "game_memory") == 0) {
  877. Svcmd_GameMem_f();
  878. return qtrue;
  879. }
  880. // if (Q_stricmp (cmd, "addbot") == 0) {
  881. // Svcmd_AddBot_f();
  882. // return qtrue;
  883. // }
  884. if (Q_stricmp (cmd, "nav") == 0)
  885. {
  886. if ( !g_cheats->integer )
  887. {
  888. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  889. return qfalse;
  890. }
  891. Svcmd_Nav_f ();
  892. return qtrue;
  893. }
  894. if (Q_stricmp (cmd, "npc") == 0)
  895. {
  896. if ( !g_cheats->integer )
  897. {
  898. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  899. return qfalse;
  900. }
  901. Svcmd_NPC_f ();
  902. return qtrue;
  903. }
  904. if (Q_stricmp (cmd, "use") == 0)
  905. {
  906. if ( !g_cheats->integer )
  907. {
  908. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  909. return qfalse;
  910. }
  911. Svcmd_Use_f ();
  912. return qtrue;
  913. }
  914. if ( Q_stricmp( cmd, "ICARUS" ) == 0 )
  915. {
  916. if ( !g_cheats->integer )
  917. {
  918. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  919. return qfalse;
  920. }
  921. Quake3Game()->Svcmd();
  922. return qtrue;
  923. }
  924. if ( Q_stricmp( cmd, "saberColor" ) == 0 )
  925. {
  926. if ( !g_cheats->integer )
  927. {
  928. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  929. return qfalse;
  930. }
  931. Svcmd_SaberColor_f();
  932. return qtrue;
  933. }
  934. if ( Q_stricmp( cmd, "saber" ) == 0 )
  935. {
  936. if ( !g_cheats->integer )
  937. {
  938. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  939. return qfalse;
  940. }
  941. Svcmd_Saber_f();
  942. return qtrue;
  943. }
  944. if ( Q_stricmp( cmd, "saberblade" ) == 0 )
  945. {
  946. if ( !g_cheats->integer )
  947. {
  948. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  949. return qfalse;
  950. }
  951. Svcmd_SaberBlade_f();
  952. return qtrue;
  953. }
  954. if ( Q_stricmp( cmd, "setForceJump" ) == 0 )
  955. {
  956. Svcmd_ForceJump_f();
  957. return qtrue;
  958. }
  959. if ( Q_stricmp( cmd, "setSaberThrow" ) == 0 )
  960. {
  961. Svcmd_SaberThrow_f();
  962. return qtrue;
  963. }
  964. if ( Q_stricmp( cmd, "setForceHeal" ) == 0 )
  965. {
  966. Svcmd_ForceHeal_f();
  967. return qtrue;
  968. }
  969. if ( Q_stricmp( cmd, "setForcePush" ) == 0 )
  970. {
  971. Svcmd_ForcePush_f();
  972. return qtrue;
  973. }
  974. if ( Q_stricmp( cmd, "setForcePull" ) == 0 )
  975. {
  976. Svcmd_ForcePull_f();
  977. return qtrue;
  978. }
  979. if ( Q_stricmp( cmd, "setForceSpeed" ) == 0 )
  980. {
  981. Svcmd_ForceSpeed_f();
  982. return qtrue;
  983. }
  984. if ( Q_stricmp( cmd, "setForceGrip" ) == 0 )
  985. {
  986. Svcmd_ForceGrip_f();
  987. return qtrue;
  988. }
  989. if ( Q_stricmp( cmd, "setForceLightning" ) == 0 )
  990. {
  991. Svcmd_ForceLightning_f();
  992. return qtrue;
  993. }
  994. if ( Q_stricmp( cmd, "setMindTrick" ) == 0 )
  995. {
  996. Svcmd_MindTrick_f();
  997. return qtrue;
  998. }
  999. if ( Q_stricmp( cmd, "setSaberDefense" ) == 0 )
  1000. {
  1001. Svcmd_SaberDefense_f();
  1002. return qtrue;
  1003. }
  1004. if ( Q_stricmp( cmd, "setSaberOffense" ) == 0 )
  1005. {
  1006. Svcmd_SaberOffense_f();
  1007. return qtrue;
  1008. }
  1009. if ( Q_stricmp( cmd, "setForceRage" ) == 0 )
  1010. {
  1011. Svcmd_ForceSetLevel_f( FP_RAGE );
  1012. return qtrue;
  1013. }
  1014. if ( Q_stricmp( cmd, "setForceDrain" ) == 0 )
  1015. {
  1016. Svcmd_ForceSetLevel_f( FP_DRAIN );
  1017. return qtrue;
  1018. }
  1019. if ( Q_stricmp( cmd, "setForceProtect" ) == 0 )
  1020. {
  1021. Svcmd_ForceSetLevel_f( FP_PROTECT );
  1022. return qtrue;
  1023. }
  1024. if ( Q_stricmp( cmd, "setForceAbsorb" ) == 0 )
  1025. {
  1026. Svcmd_ForceSetLevel_f( FP_ABSORB );
  1027. return qtrue;
  1028. }
  1029. if ( Q_stricmp( cmd, "setForceSight" ) == 0 )
  1030. {
  1031. Svcmd_ForceSetLevel_f( FP_SEE );
  1032. return qtrue;
  1033. }
  1034. if ( Q_stricmp( cmd, "setForceAll" ) == 0 )
  1035. {
  1036. Svcmd_ForceJump_f();
  1037. Svcmd_SaberThrow_f();
  1038. Svcmd_ForceHeal_f();
  1039. Svcmd_ForcePush_f();
  1040. Svcmd_ForcePull_f();
  1041. Svcmd_ForceSpeed_f();
  1042. Svcmd_ForceGrip_f();
  1043. Svcmd_ForceLightning_f();
  1044. Svcmd_MindTrick_f();
  1045. Svcmd_SaberDefense_f();
  1046. Svcmd_SaberOffense_f();
  1047. Svcmd_ForceSetLevel_f( FP_RAGE );
  1048. Svcmd_ForceSetLevel_f( FP_DRAIN );
  1049. Svcmd_ForceSetLevel_f( FP_PROTECT );
  1050. Svcmd_ForceSetLevel_f( FP_ABSORB );
  1051. Svcmd_ForceSetLevel_f( FP_SEE );
  1052. for ( int i = SS_FAST; i < SS_NUM_SABER_STYLES; i++ )
  1053. {
  1054. g_entities[0].client->ps.saberStylesKnown |= (1<<i);
  1055. }
  1056. return qtrue;
  1057. }
  1058. if ( Q_stricmp( cmd, "saberAttackCycle" ) == 0 )
  1059. {
  1060. Svcmd_SaberAttackCycle_f();
  1061. return qtrue;
  1062. }
  1063. if ( Q_stricmp( cmd, "runscript" ) == 0 )
  1064. {
  1065. if ( !g_cheats->integer )
  1066. {
  1067. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  1068. return qfalse;
  1069. }
  1070. char *cmd2 = gi.argv(1);
  1071. if ( cmd2 && cmd2[0] )
  1072. {
  1073. char *cmd3 = gi.argv(2);
  1074. if ( cmd3 && cmd3[0] )
  1075. {
  1076. gentity_t *found = NULL;
  1077. if ( (found = G_Find(NULL, FOFS(targetname), cmd2 ) ) != NULL )
  1078. {
  1079. Quake3Game()->RunScript( found, cmd3 );
  1080. }
  1081. else
  1082. {
  1083. //can't find cmd2
  1084. gi.Printf( S_COLOR_RED"runscript: can't find targetname %s\n", cmd2 );
  1085. }
  1086. }
  1087. else
  1088. {
  1089. Quake3Game()->RunScript( &g_entities[0], cmd2 );
  1090. }
  1091. }
  1092. else
  1093. {
  1094. gi.Printf( S_COLOR_RED"usage: runscript <ent targetname> scriptname\n" );
  1095. }
  1096. //FIXME: else warning
  1097. return qtrue;
  1098. }
  1099. if ( Q_stricmp( cmd, "playerteam" ) == 0 )
  1100. {
  1101. if ( !g_cheats->integer )
  1102. {
  1103. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  1104. return qfalse;
  1105. }
  1106. char *cmd2 = gi.argv(1);
  1107. int n;
  1108. if ( !*cmd2 || !cmd2[0] )
  1109. {
  1110. gi.Printf( S_COLOR_RED"'playerteam' - change player team, requires a team name!\n" );
  1111. gi.Printf( S_COLOR_RED"Valid team names are:\n");
  1112. for ( n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
  1113. {
  1114. gi.Printf( S_COLOR_RED"%s\n", GetStringForID( TeamTable, n ) );
  1115. }
  1116. }
  1117. else
  1118. {
  1119. team_t team;
  1120. team = (team_t)GetIDForString( TeamTable, cmd2 );
  1121. if ( team == -1 )
  1122. {
  1123. gi.Printf( S_COLOR_RED"'playerteam' unrecognized team name %s!\n", cmd2 );
  1124. gi.Printf( S_COLOR_RED"Valid team names are:\n");
  1125. for ( n = TEAM_FREE; n < TEAM_NUM_TEAMS; n++ )
  1126. {
  1127. gi.Printf( S_COLOR_RED"%s\n", GetStringForID( TeamTable, n ) );
  1128. }
  1129. }
  1130. else
  1131. {
  1132. g_entities[0].client->playerTeam = team;
  1133. //FIXME: convert Imperial, Malon, Hirogen and Klingon to Scavenger?
  1134. }
  1135. }
  1136. return qtrue;
  1137. }
  1138. if ( Q_stricmp( cmd, "control" ) == 0 )
  1139. {
  1140. if ( !g_cheats->integer )
  1141. {
  1142. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  1143. return qfalse;
  1144. }
  1145. char *cmd2 = gi.argv(1);
  1146. if ( !*cmd2 || !cmd2[0] )
  1147. {
  1148. if ( !G_ClearViewEntity( &g_entities[0] ) )
  1149. {
  1150. gi.Printf( S_COLOR_RED"control <NPC_targetname>\n", cmd2 );
  1151. }
  1152. }
  1153. else
  1154. {
  1155. Q3_SetViewEntity( 0, cmd2 );
  1156. }
  1157. return qtrue;
  1158. }
  1159. if ( Q_stricmp( cmd, "grab" ) == 0 )
  1160. {
  1161. if ( !g_cheats->integer )
  1162. {
  1163. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  1164. return qfalse;
  1165. }
  1166. char *cmd2 = gi.argv(1);
  1167. if ( !*cmd2 || !cmd2[0] )
  1168. {
  1169. if ( !G_ReleaseEntity( &g_entities[0] ) )
  1170. {
  1171. gi.Printf( S_COLOR_RED"grab <NPC_targetname>\n", cmd2 );
  1172. }
  1173. }
  1174. else
  1175. {
  1176. G_GrabEntity( &g_entities[0], cmd2 );
  1177. }
  1178. return qtrue;
  1179. }
  1180. if ( Q_stricmp( cmd, "knockdown" ) == 0 )
  1181. {
  1182. if ( !g_cheats->integer )
  1183. {
  1184. gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
  1185. return qfalse;
  1186. }
  1187. G_Knockdown( &g_entities[0], &g_entities[0], vec3_origin, 300, qtrue );
  1188. return qtrue;
  1189. }
  1190. if ( Q_stricmp( cmd, "playerModel" ) == 0 )
  1191. {
  1192. if ( gi.argc() == 1 )
  1193. {
  1194. gi.Printf( S_COLOR_RED"USAGE: playerModel <NPC Name>\n playerModel <g2model> <skinhead> <skintorso> <skinlower>\n playerModel player (builds player from customized menu settings)\n" );
  1195. gi.Printf( "playerModel = %s ", va("%s %s %s %s\n", g_char_model->string, g_char_skin_head->string, g_char_skin_torso->string, g_char_skin_legs->string ) );
  1196. }
  1197. else if ( gi.argc() == 2 )
  1198. {
  1199. G_ChangePlayerModel( &g_entities[0], gi.argv(1) );
  1200. }
  1201. else if ( gi.argc() == 5 )
  1202. {
  1203. //instead of setting it directly via a command, we now store it in cvars
  1204. //G_ChangePlayerModel( &g_entities[0], va("%s|%s|%s|%s", gi.argv(1), gi.argv(2), gi.argv(3), gi.argv(4)) );
  1205. gi.cvar_set("g_char_model", gi.argv(1) );
  1206. gi.cvar_set("g_char_skin_head", gi.argv(2) );
  1207. gi.cvar_set("g_char_skin_torso", gi.argv(3) );
  1208. gi.cvar_set("g_char_skin_legs", gi.argv(4) );
  1209. G_InitPlayerFromCvars( &g_entities[0] );
  1210. }
  1211. return qtrue;
  1212. }
  1213. if ( Q_stricmp( cmd, "playerTint" ) == 0 )
  1214. {
  1215. if ( gi.argc() == 4 )
  1216. {
  1217. g_entities[0].client->renderInfo.customRGBA[0] = atoi(gi.argv(1));
  1218. g_entities[0].client->renderInfo.customRGBA[1] = atoi(gi.argv(2));
  1219. g_entities[0].client->renderInfo.customRGBA[2] = atoi(gi.argv(3));
  1220. gi.cvar_set("g_char_color_red", gi.argv(1) );
  1221. gi.cvar_set("g_char_color_green", gi.argv(2) );
  1222. gi.cvar_set("g_char_color_blue", gi.argv(3) );
  1223. }
  1224. else
  1225. {
  1226. gi.Printf( S_COLOR_RED"USAGE: playerTint <red 0 - 255> <green 0 - 255> <blue 0 - 255>\n" );
  1227. gi.Printf( "playerTint = %s\n", va("%d %d %d", g_char_color_red->integer, g_char_color_green->integer, g_char_color_blue->integer ) );
  1228. }
  1229. return qtrue;
  1230. }
  1231. if ( Q_stricmp( cmd, "nexttestaxes" ) == 0 )
  1232. {
  1233. G_NextTestAxes();
  1234. }
  1235. if ( Q_stricmp( cmd, "exitview" ) == 0 )
  1236. {
  1237. Svcmd_ExitView_f();
  1238. }
  1239. if (Q_stricmp (cmd, "iknowkungfu") == 0)
  1240. {
  1241. gi.cvar_set( "g_debugMelee", "1" );
  1242. G_SetWeapon( &g_entities[0], WP_MELEE );
  1243. /*
  1244. for ( int i = FP_FIRST; i < NUM_FORCE_POWERS; i++ )
  1245. {
  1246. g_entities[0].client->ps.forcePowersKnown |= ( 1 << i );
  1247. if ( i == FP_TELEPATHY )
  1248. {
  1249. g_entities[0].client->ps.forcePowerLevel[i] = FORCE_LEVEL_4;
  1250. }
  1251. else
  1252. {
  1253. g_entities[0].client->ps.forcePowerLevel[i] = FORCE_LEVEL_3;
  1254. }
  1255. }
  1256. */
  1257. }
  1258. return qfalse;
  1259. }