SysCmds.cpp 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #pragma hdrstop
  21. #include "../../idlib/precompiled.h"
  22. #include "../Game_local.h"
  23. #include "TypeInfo.h"
  24. /*
  25. ==================
  26. Cmd_GetFloatArg
  27. ==================
  28. */
  29. float Cmd_GetFloatArg( const idCmdArgs &args, int &argNum ) {
  30. const char *value;
  31. value = args.Argv( argNum++ );
  32. return atof( value );
  33. }
  34. /*
  35. ===================
  36. Cmd_EntityList_f
  37. ===================
  38. */
  39. void Cmd_EntityList_f( const idCmdArgs &args ) {
  40. int e;
  41. idEntity *check;
  42. int count;
  43. size_t size;
  44. idStr match;
  45. if ( args.Argc() > 1 ) {
  46. match = args.Args();
  47. match.Replace( " ", "" );
  48. } else {
  49. match = "";
  50. }
  51. count = 0;
  52. size = 0;
  53. gameLocal.Printf( "%-4s %-20s %-20s %s\n", " Num", "EntityDef", "Class", "Name" );
  54. gameLocal.Printf( "--------------------------------------------------------------------\n" );
  55. for( e = 0; e < MAX_GENTITIES; e++ ) {
  56. check = gameLocal.entities[ e ];
  57. if ( !check ) {
  58. continue;
  59. }
  60. if ( !check->name.Filter( match, true ) ) {
  61. continue;
  62. }
  63. gameLocal.Printf( "%4i: %-20s %-20s %s\n", e,
  64. check->GetEntityDefName(), check->GetClassname(), check->name.c_str() );
  65. count++;
  66. size += check->spawnArgs.Allocated();
  67. }
  68. gameLocal.Printf( "...%d entities\n...%d bytes of spawnargs\n", count, size );
  69. }
  70. /*
  71. ===================
  72. Cmd_ActiveEntityList_f
  73. ===================
  74. */
  75. void Cmd_ActiveEntityList_f( const idCmdArgs &args ) {
  76. idEntity *check;
  77. int count;
  78. count = 0;
  79. gameLocal.Printf( "%-4s %-20s %-20s %s\n", " Num", "EntityDef", "Class", "Name" );
  80. gameLocal.Printf( "--------------------------------------------------------------------\n" );
  81. for( check = gameLocal.activeEntities.Next(); check != NULL; check = check->activeNode.Next() ) {
  82. char dormant = check->fl.isDormant ? '-' : ' ';
  83. gameLocal.Printf( "%4i:%c%-20s %-20s %s\n", check->entityNumber, dormant, check->GetEntityDefName(), check->GetClassname(), check->name.c_str() );
  84. count++;
  85. }
  86. gameLocal.Printf( "...%d active entities\n", count );
  87. }
  88. /*
  89. ===================
  90. Cmd_ListSpawnArgs_f
  91. ===================
  92. */
  93. void Cmd_ListSpawnArgs_f( const idCmdArgs &args ) {
  94. int i;
  95. idEntity *ent;
  96. ent = gameLocal.FindEntity( args.Argv( 1 ) );
  97. if ( !ent ) {
  98. gameLocal.Printf( "entity not found\n" );
  99. return;
  100. }
  101. for ( i = 0; i < ent->spawnArgs.GetNumKeyVals(); i++ ) {
  102. const idKeyValue *kv = ent->spawnArgs.GetKeyVal( i );
  103. gameLocal.Printf( "\"%s\" "S_COLOR_WHITE"\"%s\"\n", kv->GetKey().c_str(), kv->GetValue().c_str() );
  104. }
  105. }
  106. /*
  107. ===================
  108. Cmd_ReloadScript_f
  109. ===================
  110. */
  111. void Cmd_ReloadScript_f( const idCmdArgs &args ) {
  112. // shutdown the map because entities may point to script objects
  113. gameLocal.MapShutdown();
  114. // recompile the scripts
  115. gameLocal.program.Startup( SCRIPT_DEFAULT );
  116. if ( fileSystem->ReadFile("doom_main.script", NULL) > 0 ) {
  117. gameLocal.program.CompileFile( "doom_main.script" );
  118. gameLocal.program.FinishCompilation();
  119. }
  120. // error out so that the user can rerun the scripts
  121. gameLocal.Error( "Exiting map to reload scripts" );
  122. }
  123. CONSOLE_COMMAND( reloadScript2, "Doesn't thow an error... Use this when switching game modes", 0 ) {
  124. // shutdown the map because entities may point to script objects
  125. gameLocal.MapShutdown();
  126. // recompile the scripts
  127. gameLocal.program.Startup( SCRIPT_DEFAULT );
  128. if ( fileSystem->ReadFile("doom_main.script", NULL) > 0 ) {
  129. gameLocal.program.CompileFile( "doom_main.script" );
  130. gameLocal.program.FinishCompilation();
  131. }
  132. }
  133. /*
  134. ===================
  135. Cmd_Script_f
  136. ===================
  137. */
  138. void Cmd_Script_f( const idCmdArgs &args ) {
  139. const char * script;
  140. idStr text;
  141. idStr funcname;
  142. static int funccount = 0;
  143. idThread * thread;
  144. const function_t *func;
  145. idEntity *ent;
  146. if ( !gameLocal.CheatsOk() ) {
  147. return;
  148. }
  149. sprintf( funcname, "ConsoleFunction_%d", funccount++ );
  150. script = args.Args();
  151. sprintf( text, "void %s() {%s;}\n", funcname.c_str(), script );
  152. if ( gameLocal.program.CompileText( "console", text, true ) ) {
  153. func = gameLocal.program.FindFunction( funcname );
  154. if ( func ) {
  155. // set all the entity names in case the user named one in the script that wasn't referenced in the default script
  156. for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  157. gameLocal.program.SetEntity( ent->name, ent );
  158. }
  159. thread = new idThread( func );
  160. thread->Start();
  161. }
  162. }
  163. }
  164. /*
  165. ==================
  166. KillEntities
  167. Kills all the entities of the given class in a level.
  168. ==================
  169. */
  170. void KillEntities( const idCmdArgs &args, const idTypeInfo &superClass ) {
  171. idEntity *ent;
  172. idStrList ignore;
  173. const char *name;
  174. int i;
  175. if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  176. return;
  177. }
  178. for( i = 1; i < args.Argc(); i++ ) {
  179. name = args.Argv( i );
  180. ignore.Append( name );
  181. }
  182. for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  183. if ( ent->IsType( superClass ) ) {
  184. for( i = 0; i < ignore.Num(); i++ ) {
  185. if ( ignore[ i ] == ent->name ) {
  186. break;
  187. }
  188. }
  189. if ( i >= ignore.Num() ) {
  190. ent->PostEventMS( &EV_Remove, 0 );
  191. }
  192. }
  193. }
  194. }
  195. /*
  196. ==================
  197. Cmd_KillMonsters_f
  198. Kills all the monsters in a level.
  199. ==================
  200. */
  201. void Cmd_KillMonsters_f( const idCmdArgs &args ) {
  202. KillEntities( args, idAI::Type );
  203. // kill any projectiles as well since they have pointers to the monster that created them
  204. KillEntities( args, idProjectile::Type );
  205. }
  206. /*
  207. ==================
  208. Cmd_KillMovables_f
  209. Kills all the moveables in a level.
  210. ==================
  211. */
  212. void Cmd_KillMovables_f( const idCmdArgs &args ) {
  213. if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  214. return;
  215. }
  216. KillEntities( args, idMoveable::Type );
  217. }
  218. /*
  219. ==================
  220. Cmd_KillRagdolls_f
  221. Kills all the ragdolls in a level.
  222. ==================
  223. */
  224. void Cmd_KillRagdolls_f( const idCmdArgs &args ) {
  225. if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  226. return;
  227. }
  228. KillEntities( args, idAFEntity_Generic::Type );
  229. KillEntities( args, idAFEntity_WithAttachedHead::Type );
  230. }
  231. /*
  232. ==================
  233. Cmd_Give_f
  234. Give items to a client
  235. ==================
  236. */
  237. void Cmd_Give_f( const idCmdArgs &args ) {
  238. const char *name;
  239. int i;
  240. bool give_all;
  241. idPlayer *player;
  242. player = gameLocal.GetLocalPlayer();
  243. if ( !player || !gameLocal.CheatsOk() ) {
  244. return;
  245. }
  246. name = args.Argv( 1 );
  247. if ( idStr::Icmp( name, "all" ) == 0 ) {
  248. give_all = true;
  249. } else {
  250. give_all = false;
  251. }
  252. if ( give_all || ( idStr::Cmpn( name, "weapon", 6 ) == 0 ) ) {
  253. if ( gameLocal.world->spawnArgs.GetBool( "no_Weapons" ) ) {
  254. gameLocal.world->spawnArgs.SetBool( "no_Weapons", false );
  255. for( i = 0; i < gameLocal.numClients; i++ ) {
  256. if ( gameLocal.entities[ i ] ) {
  257. gameLocal.entities[ i ]->PostEventSec( &EV_Player_SelectWeapon, 0.5f, gameLocal.entities[ i ]->spawnArgs.GetString( "def_weapon1" ) );
  258. }
  259. }
  260. }
  261. }
  262. if ( ( idStr::Cmpn( name, "weapon_", 7 ) == 0 ) || ( idStr::Cmpn( name, "item_", 5 ) == 0 ) || ( idStr::Cmpn( name, "ammo_", 5 ) == 0 ) ) {
  263. player->GiveItem( name );
  264. return;
  265. }
  266. if ( give_all || idStr::Icmp( name, "health" ) == 0 ) {
  267. player->health = player->inventory.maxHealth;
  268. if ( !give_all ) {
  269. return;
  270. }
  271. }
  272. if ( give_all || idStr::Icmp( name, "weapons" ) == 0 ) {
  273. player->inventory.weapons = (int)( BIT( MAX_WEAPONS ) - 1 );
  274. player->CacheWeapons();
  275. if ( !give_all ) {
  276. return;
  277. }
  278. }
  279. if ( give_all || idStr::Icmp( name, "ammo" ) == 0 ) {
  280. for ( i = 0 ; i < AMMO_NUMTYPES; i++ ) {
  281. player->inventory.SetInventoryAmmoForType( i, player->inventory.MaxAmmoForAmmoClass( player, idWeapon::GetAmmoNameForNum( ( ammo_t )i ) ) );
  282. }
  283. if ( !give_all ) {
  284. return;
  285. }
  286. }
  287. if ( give_all || idStr::Icmp( name, "armor" ) == 0 ) {
  288. player->inventory.armor = player->inventory.maxarmor;
  289. if ( !give_all ) {
  290. return;
  291. }
  292. }
  293. if ( idStr::Icmp( name, "berserk" ) == 0 ) {
  294. player->GivePowerUp( BERSERK, SEC2MS( 30.0f ), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  295. return;
  296. }
  297. if ( idStr::Icmp( name, "invis" ) == 0 ) {
  298. player->GivePowerUp( INVISIBILITY, SEC2MS( 30.0f ), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  299. return;
  300. }
  301. if ( idStr::Icmp( name, "invulnerability" ) == 0 ) {
  302. if ( args.Argc() > 2 ) {
  303. player->GivePowerUp( INVULNERABILITY, atoi( args.Argv( 2 ) ), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  304. }
  305. else {
  306. player->GivePowerUp( INVULNERABILITY, 30000, ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  307. }
  308. return;
  309. }
  310. if ( idStr::Icmp( name, "helltime" ) == 0 ) {
  311. if ( args.Argc() > 2 ) {
  312. player->GivePowerUp( HELLTIME, atoi( args.Argv( 2 ) ), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  313. }
  314. else {
  315. player->GivePowerUp( HELLTIME, 30000, ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  316. }
  317. return;
  318. }
  319. if ( idStr::Icmp( name, "envirosuit" ) == 0 ) {
  320. if ( args.Argc() > 2 ) {
  321. player->GivePowerUp( ENVIROSUIT, atoi( args.Argv( 2 ) ), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  322. }
  323. else {
  324. player->GivePowerUp( ENVIROSUIT, 30000, ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE );
  325. }
  326. return;
  327. }
  328. if ( idStr::Icmp( name, "pda" ) == 0 ) {
  329. if ( args.Argc() == 2 ) {
  330. player->GivePDA( NULL, NULL );
  331. } else if ( idStr::Icmp( args.Argv(2), "all" ) == 0 ) {
  332. // Give the personal PDA first
  333. player->GivePDA( NULL, NULL );
  334. for ( int i = 0; i < declManager->GetNumDecls( DECL_PDA ); i++ ) {
  335. player->GivePDA( static_cast<const idDeclPDA *>( declManager->DeclByIndex( DECL_PDA, i ) ), NULL );
  336. }
  337. } else {
  338. const idDeclPDA * pda = static_cast<const idDeclPDA *>( declManager->FindType( DECL_PDA, args.Argv(2), false ) );
  339. if ( pda == NULL ) {
  340. gameLocal.Printf( "Unknown PDA %s\n", args.Argv(2) );
  341. } else {
  342. player->GivePDA( pda, NULL );
  343. }
  344. }
  345. return;
  346. }
  347. if ( idStr::Icmp( name, "video" ) == 0 ) {
  348. const idDeclVideo * video = static_cast<const idDeclVideo *>( declManager->FindType( DECL_VIDEO, args.Argv(2), false ) );
  349. if ( video == NULL ) {
  350. gameLocal.Printf( "Unknown video %s\n", args.Argv(2) );
  351. } else {
  352. player->GiveVideo( video, NULL );
  353. }
  354. return;
  355. }
  356. if ( !give_all && !player->Give( args.Argv(1), args.Argv(2), ITEM_GIVE_FEEDBACK | ITEM_GIVE_UPDATE_STATE ) ) {
  357. gameLocal.Printf( "unknown item\n" );
  358. }
  359. }
  360. /*
  361. ==================
  362. Cmd_CenterView_f
  363. Centers the players pitch
  364. ==================
  365. */
  366. void Cmd_CenterView_f( const idCmdArgs &args ) {
  367. idPlayer *player;
  368. idAngles ang;
  369. player = gameLocal.GetLocalPlayer();
  370. if ( !player ) {
  371. return;
  372. }
  373. ang = player->viewAngles;
  374. ang.pitch = 0.0f;
  375. player->SetViewAngles( ang );
  376. }
  377. /*
  378. ==================
  379. Cmd_God_f
  380. Sets client to godmode
  381. argv(0) god
  382. ==================
  383. */
  384. void Cmd_God_f( const idCmdArgs &args ) {
  385. char *msg;
  386. idPlayer *player;
  387. player = gameLocal.GetLocalPlayer();
  388. if ( !player || !gameLocal.CheatsOk() ) {
  389. return;
  390. }
  391. if ( player->godmode ) {
  392. player->godmode = false;
  393. msg = "godmode OFF\n";
  394. } else {
  395. player->godmode = true;
  396. msg = "godmode ON\n";
  397. }
  398. gameLocal.Printf( "%s", msg );
  399. }
  400. /*
  401. ==================
  402. Cmd_Notarget_f
  403. Sets client to notarget
  404. argv(0) notarget
  405. ==================
  406. */
  407. void Cmd_Notarget_f( const idCmdArgs &args ) {
  408. char *msg;
  409. idPlayer *player;
  410. player = gameLocal.GetLocalPlayer();
  411. if ( !player || !gameLocal.CheatsOk() ) {
  412. return;
  413. }
  414. if ( player->fl.notarget ) {
  415. player->fl.notarget = false;
  416. msg = "notarget OFF\n";
  417. } else {
  418. player->fl.notarget = true;
  419. msg = "notarget ON\n";
  420. }
  421. gameLocal.Printf( "%s", msg );
  422. }
  423. /*
  424. ==================
  425. Cmd_Noclip_f
  426. argv(0) noclip
  427. ==================
  428. */
  429. void Cmd_Noclip_f( const idCmdArgs &args ) {
  430. char *msg;
  431. idPlayer *player;
  432. player = gameLocal.GetLocalPlayer();
  433. if ( !player || !gameLocal.CheatsOk() ) {
  434. return;
  435. }
  436. if ( player->noclip ) {
  437. msg = "noclip OFF\n";
  438. } else {
  439. msg = "noclip ON\n";
  440. }
  441. player->noclip = !player->noclip;
  442. gameLocal.Printf( "%s", msg );
  443. }
  444. /*
  445. =================
  446. Cmd_PlayerModel_f
  447. =================
  448. */
  449. void Cmd_PlayerModel_f( const idCmdArgs &args ) {
  450. idPlayer *player;
  451. const char *name;
  452. idVec3 pos;
  453. idAngles ang;
  454. player = gameLocal.GetLocalPlayer();
  455. if ( !player || !gameLocal.CheatsOk() ) {
  456. return;
  457. }
  458. if ( args.Argc() < 2 ) {
  459. gameLocal.Printf( "usage: playerModel <modelname>\n" );
  460. return;
  461. }
  462. name = args.Argv( 1 );
  463. player->spawnArgs.Set( "model", name );
  464. pos = player->GetPhysics()->GetOrigin();
  465. ang = player->viewAngles;
  466. player->SpawnToPoint( pos, ang );
  467. }
  468. /*
  469. ==================
  470. Cmd_Say
  471. ==================
  472. */
  473. static void Cmd_Say( bool team, const idCmdArgs &args ) {
  474. const char *cmd = team ? "sayTeam" : "say" ;
  475. if ( !common->IsMultiplayer() ) {
  476. gameLocal.Printf( "%s can only be used in a multiplayer game\n", cmd );
  477. return;
  478. }
  479. if ( args.Argc() < 2 ) {
  480. gameLocal.Printf( "usage: %s <text>\n", cmd );
  481. return;
  482. }
  483. idStr text = args.Args();
  484. if ( text.Length() == 0 ) {
  485. return;
  486. }
  487. if ( text[ text.Length() - 1 ] == '\n' ) {
  488. text[ text.Length() - 1 ] = '\0';
  489. }
  490. const char * name = "player";
  491. // "server" will only appear on a dedicated server
  492. if ( common->IsServer() && gameLocal.GetLocalClientNum() == -1 ) {
  493. name = "server";
  494. } else {
  495. name = session->GetActingGameStateLobbyBase().GetLobbyUserName( gameLocal.lobbyUserIDs[ gameLocal.GetLocalClientNum() ] );
  496. // Append the player's location to team chat messages in CTF
  497. idPlayer * player = static_cast<idPlayer *>( gameLocal.entities[ gameLocal.GetLocalClientNum() ] );
  498. if ( gameLocal.mpGame.IsGametypeFlagBased() && team && player ) {
  499. idLocationEntity *locationEntity = gameLocal.LocationForPoint( player->GetEyePosition() );
  500. if ( locationEntity ) {
  501. idStr temp = "[";
  502. temp += locationEntity->GetLocation();
  503. temp += "] ";
  504. temp += text;
  505. text = temp;
  506. }
  507. }
  508. }
  509. if ( common->IsClient() ) {
  510. idBitMsg outMsg;
  511. byte msgBuf[ 256 ];
  512. outMsg.InitWrite( msgBuf, sizeof( msgBuf ) );
  513. outMsg.WriteString( name );
  514. outMsg.WriteString( text, -1, false );
  515. session->GetActingGameStateLobbyBase().SendReliableToHost( team ? GAME_RELIABLE_MESSAGE_TCHAT : GAME_RELIABLE_MESSAGE_CHAT, outMsg );
  516. } else {
  517. gameLocal.mpGame.ProcessChatMessage( gameLocal.GetLocalClientNum(), team, name, text, NULL );
  518. }
  519. }
  520. /*
  521. ==================
  522. Cmd_Say_f
  523. ==================
  524. */
  525. static void Cmd_Say_f( const idCmdArgs &args ) {
  526. Cmd_Say( false, args );
  527. }
  528. /*
  529. ==================
  530. Cmd_SayTeam_f
  531. ==================
  532. */
  533. static void Cmd_SayTeam_f( const idCmdArgs &args ) {
  534. Cmd_Say( true, args );
  535. }
  536. /*
  537. ==================
  538. Cmd_AddChatLine_f
  539. ==================
  540. */
  541. static void Cmd_AddChatLine_f( const idCmdArgs &args ) {
  542. gameLocal.mpGame.AddChatLine( args.Argv( 1 ) );
  543. }
  544. /*
  545. ==================
  546. Cmd_GetViewpos_f
  547. ==================
  548. */
  549. void Cmd_GetViewpos_f( const idCmdArgs &args ) {
  550. idPlayer *player;
  551. idVec3 origin;
  552. idMat3 axis;
  553. player = gameLocal.GetLocalPlayer();
  554. if ( !player ) {
  555. return;
  556. }
  557. const renderView_t *view = player->GetRenderView();
  558. if ( view ) {
  559. gameLocal.Printf( "(%s) %.1f\n", view->vieworg.ToString(), view->viewaxis[0].ToYaw() );
  560. } else {
  561. player->GetViewPos( origin, axis );
  562. gameLocal.Printf( "(%s) %.1f\n", origin.ToString(), axis[0].ToYaw() );
  563. }
  564. }
  565. /*
  566. =================
  567. Cmd_SetViewpos_f
  568. =================
  569. */
  570. void Cmd_SetViewpos_f( const idCmdArgs &args ) {
  571. idVec3 origin;
  572. idAngles angles;
  573. int i;
  574. idPlayer *player;
  575. player = gameLocal.GetLocalPlayer();
  576. if ( !player || !gameLocal.CheatsOk() ) {
  577. return;
  578. }
  579. if ( ( args.Argc() != 4 ) && ( args.Argc() != 5 ) ) {
  580. gameLocal.Printf( "usage: setviewpos <x> <y> <z> <yaw>\n" );
  581. return;
  582. }
  583. angles.Zero();
  584. if ( args.Argc() == 5 ) {
  585. angles.yaw = atof( args.Argv( 4 ) );
  586. }
  587. for ( i = 0 ; i < 3 ; i++ ) {
  588. origin[i] = atof( args.Argv( i + 1 ) );
  589. }
  590. origin.z -= pm_normalviewheight.GetFloat() - 0.25f;
  591. player->Teleport( origin, angles, NULL );
  592. }
  593. /*
  594. =================
  595. Cmd_Teleport_f
  596. =================
  597. */
  598. void Cmd_Teleport_f( const idCmdArgs &args ) {
  599. idVec3 origin;
  600. idAngles angles;
  601. idPlayer *player;
  602. idEntity *ent;
  603. player = gameLocal.GetLocalPlayer();
  604. if ( !player || !gameLocal.CheatsOk() ) {
  605. return;
  606. }
  607. if ( args.Argc() != 2 ) {
  608. gameLocal.Printf( "usage: teleport <name of entity to teleport to>\n" );
  609. return;
  610. }
  611. ent = gameLocal.FindEntity( args.Argv( 1 ) );
  612. if ( !ent ) {
  613. gameLocal.Printf( "entity not found\n" );
  614. return;
  615. }
  616. angles.Zero();
  617. angles.yaw = ent->GetPhysics()->GetAxis()[ 0 ].ToYaw();
  618. origin = ent->GetPhysics()->GetOrigin();
  619. player->Teleport( origin, angles, ent );
  620. }
  621. /*
  622. =================
  623. Cmd_Trigger_f
  624. =================
  625. */
  626. void Cmd_Trigger_f( const idCmdArgs &args ) {
  627. idVec3 origin;
  628. idAngles angles;
  629. idPlayer *player;
  630. idEntity *ent;
  631. player = gameLocal.GetLocalPlayer();
  632. if ( !player || !gameLocal.CheatsOk() ) {
  633. return;
  634. }
  635. if ( args.Argc() != 2 ) {
  636. gameLocal.Printf( "usage: trigger <name of entity to trigger>\n" );
  637. return;
  638. }
  639. ent = gameLocal.FindEntity( args.Argv( 1 ) );
  640. if ( !ent ) {
  641. gameLocal.Printf( "entity not found\n" );
  642. return;
  643. }
  644. ent->Signal( SIG_TRIGGER );
  645. ent->ProcessEvent( &EV_Activate, player );
  646. ent->TriggerGuis();
  647. }
  648. /*
  649. ===================
  650. Cmd_Spawn_f
  651. ===================
  652. */
  653. void Cmd_Spawn_f( const idCmdArgs &args ) {
  654. const char *key, *value;
  655. int i;
  656. float yaw;
  657. idVec3 org;
  658. idPlayer *player;
  659. idDict dict;
  660. player = gameLocal.GetLocalPlayer();
  661. if ( !player || !gameLocal.CheatsOk( false ) ) {
  662. return;
  663. }
  664. if ( args.Argc() & 1 ) { // must always have an even number of arguments
  665. gameLocal.Printf( "usage: spawn classname [key/value pairs]\n" );
  666. return;
  667. }
  668. yaw = player->viewAngles.yaw;
  669. value = args.Argv( 1 );
  670. dict.Set( "classname", value );
  671. dict.Set( "angle", va( "%f", yaw + 180 ) );
  672. org = player->GetPhysics()->GetOrigin() + idAngles( 0, yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 );
  673. dict.Set( "origin", org.ToString() );
  674. for( i = 2; i < args.Argc() - 1; i += 2 ) {
  675. key = args.Argv( i );
  676. value = args.Argv( i + 1 );
  677. dict.Set( key, value );
  678. }
  679. gameLocal.SpawnEntityDef( dict );
  680. }
  681. /*
  682. ==================
  683. Cmd_Damage_f
  684. Damages the specified entity
  685. ==================
  686. */
  687. void Cmd_Damage_f( const idCmdArgs &args ) {
  688. if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  689. return;
  690. }
  691. if ( args.Argc() != 3 ) {
  692. gameLocal.Printf( "usage: damage <name of entity to damage> <damage>\n" );
  693. return;
  694. }
  695. idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  696. if ( !ent ) {
  697. gameLocal.Printf( "entity not found\n" );
  698. return;
  699. }
  700. ent->Damage( gameLocal.world, gameLocal.world, idVec3( 0, 0, 1 ), "damage_moverCrush", atoi( args.Argv( 2 ) ), INVALID_JOINT );
  701. }
  702. /*
  703. ==================
  704. Cmd_Remove_f
  705. Removes the specified entity
  706. ==================
  707. */
  708. void Cmd_Remove_f( const idCmdArgs &args ) {
  709. if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  710. return;
  711. }
  712. if ( args.Argc() != 2 ) {
  713. gameLocal.Printf( "usage: remove <name of entity to remove>\n" );
  714. return;
  715. }
  716. idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  717. if ( !ent ) {
  718. gameLocal.Printf( "entity not found\n" );
  719. return;
  720. }
  721. delete ent;
  722. }
  723. /*
  724. ===================
  725. Cmd_TestLight_f
  726. ===================
  727. */
  728. void Cmd_TestLight_f( const idCmdArgs &args ) {
  729. int i;
  730. idStr filename;
  731. const char *key = NULL, *value = NULL, *name = NULL;
  732. idPlayer * player = NULL;
  733. idDict dict;
  734. player = gameLocal.GetLocalPlayer();
  735. if ( !player || !gameLocal.CheatsOk( false ) ) {
  736. return;
  737. }
  738. renderView_t *rv = player->GetRenderView();
  739. float fov = tan( idMath::M_DEG2RAD * rv->fov_x / 2 );
  740. dict.SetMatrix( "rotation", mat3_default );
  741. dict.SetVector( "origin", rv->vieworg );
  742. dict.SetVector( "light_target", rv->viewaxis[0] );
  743. dict.SetVector( "light_right", rv->viewaxis[1] * -fov );
  744. dict.SetVector( "light_up", rv->viewaxis[2] * fov );
  745. dict.SetVector( "light_start", rv->viewaxis[0] * 16 );
  746. dict.SetVector( "light_end", rv->viewaxis[0] * 1000 );
  747. if ( args.Argc() >= 2 ) {
  748. value = args.Argv( 1 );
  749. filename = args.Argv(1);
  750. filename.DefaultFileExtension( ".tga" );
  751. dict.Set( "texture", filename );
  752. }
  753. dict.Set( "classname", "light" );
  754. for( i = 2; i < args.Argc() - 1; i += 2 ) {
  755. key = args.Argv( i );
  756. value = args.Argv( i + 1 );
  757. dict.Set( key, value );
  758. }
  759. for ( i = 0; i < MAX_GENTITIES; i++ ) {
  760. name = va( "spawned_light_%d", i ); // not just light_, or it might pick up a prelight shadow
  761. if ( !gameLocal.FindEntity( name ) ) {
  762. break;
  763. }
  764. }
  765. dict.Set( "name", name );
  766. gameLocal.SpawnEntityDef( dict );
  767. gameLocal.Printf( "Created new light\n");
  768. }
  769. /*
  770. ===================
  771. Cmd_TestPointLight_f
  772. ===================
  773. */
  774. void Cmd_TestPointLight_f( const idCmdArgs &args ) {
  775. const char *key = NULL, *value = NULL, *name = NULL;
  776. int i;
  777. idPlayer *player = NULL;
  778. idDict dict;
  779. player = gameLocal.GetLocalPlayer();
  780. if ( !player || !gameLocal.CheatsOk( false ) ) {
  781. return;
  782. }
  783. dict.SetVector("origin", player->GetRenderView()->vieworg);
  784. if ( args.Argc() >= 2 ) {
  785. value = args.Argv( 1 );
  786. dict.Set("light", value);
  787. } else {
  788. dict.Set("light", "300");
  789. }
  790. dict.Set( "classname", "light" );
  791. for( i = 2; i < args.Argc() - 1; i += 2 ) {
  792. key = args.Argv( i );
  793. value = args.Argv( i + 1 );
  794. dict.Set( key, value );
  795. }
  796. for ( i = 0; i < MAX_GENTITIES; i++ ) {
  797. name = va( "light_%d", i );
  798. if ( !gameLocal.FindEntity( name ) ) {
  799. break;
  800. }
  801. }
  802. dict.Set( "name", name );
  803. gameLocal.SpawnEntityDef( dict );
  804. gameLocal.Printf( "Created new point light\n");
  805. }
  806. /*
  807. ==================
  808. Cmd_PopLight_f
  809. ==================
  810. */
  811. void Cmd_PopLight_f( const idCmdArgs &args ) {
  812. idEntity *ent;
  813. idMapEntity *mapEnt;
  814. idMapFile *mapFile = gameLocal.GetLevelMap();
  815. idLight *lastLight;
  816. int last;
  817. if ( !gameLocal.CheatsOk() ) {
  818. return;
  819. }
  820. bool removeFromMap = ( args.Argc() > 1 );
  821. lastLight = NULL;
  822. last = -1;
  823. for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  824. if ( !ent->IsType( idLight::Type ) ) {
  825. continue;
  826. }
  827. if ( gameLocal.spawnIds[ ent->entityNumber ] > last ) {
  828. last = gameLocal.spawnIds[ ent->entityNumber ];
  829. lastLight = static_cast<idLight*>( ent );
  830. }
  831. }
  832. if ( lastLight ) {
  833. // find map file entity
  834. mapEnt = mapFile->FindEntity( lastLight->name );
  835. if ( removeFromMap && mapEnt ) {
  836. mapFile->RemoveEntity( mapEnt );
  837. }
  838. gameLocal.Printf( "Removing light %i\n", lastLight->GetLightDefHandle() );
  839. delete lastLight;
  840. } else {
  841. gameLocal.Printf( "No lights to clear.\n" );
  842. }
  843. }
  844. /*
  845. ====================
  846. Cmd_ClearLights_f
  847. ====================
  848. */
  849. void Cmd_ClearLights_f( const idCmdArgs &args ) {
  850. idEntity *ent;
  851. idEntity *next;
  852. idLight *light;
  853. idMapEntity *mapEnt;
  854. idMapFile *mapFile = gameLocal.GetLevelMap();
  855. bool removeFromMap = ( args.Argc() > 1 );
  856. gameLocal.Printf( "Clearing all lights.\n" );
  857. for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = next ) {
  858. next = ent->spawnNode.Next();
  859. if ( !ent->IsType( idLight::Type ) ) {
  860. continue;
  861. }
  862. light = static_cast<idLight*>( ent );
  863. mapEnt = mapFile->FindEntity( light->name );
  864. if ( removeFromMap && mapEnt ) {
  865. mapFile->RemoveEntity( mapEnt );
  866. }
  867. delete light;
  868. }
  869. }
  870. /*
  871. ==================
  872. Cmd_TestFx_f
  873. ==================
  874. */
  875. void Cmd_TestFx_f( const idCmdArgs &args ) {
  876. idVec3 offset;
  877. const char *name;
  878. idPlayer * player;
  879. idDict dict;
  880. player = gameLocal.GetLocalPlayer();
  881. if ( !player || !gameLocal.CheatsOk() ) {
  882. return;
  883. }
  884. // delete the testModel if active
  885. if ( gameLocal.testFx ) {
  886. delete gameLocal.testFx;
  887. gameLocal.testFx = NULL;
  888. }
  889. if ( args.Argc() < 2 ) {
  890. return;
  891. }
  892. name = args.Argv( 1 );
  893. offset = player->GetPhysics()->GetOrigin() + player->viewAngles.ToForward() * 100.0f;
  894. dict.Set( "origin", offset.ToString() );
  895. dict.Set( "test", "1");
  896. dict.Set( "fx", name );
  897. gameLocal.testFx = ( idEntityFx * )gameLocal.SpawnEntityType( idEntityFx::Type, &dict );
  898. }
  899. #define MAX_DEBUGLINES 128
  900. typedef struct {
  901. bool used;
  902. idVec3 start, end;
  903. int color;
  904. bool blink;
  905. bool arrow;
  906. } gameDebugLine_t;
  907. gameDebugLine_t debugLines[MAX_DEBUGLINES];
  908. /*
  909. ==================
  910. Cmd_AddDebugLine_f
  911. ==================
  912. */
  913. static void Cmd_AddDebugLine_f( const idCmdArgs &args ) {
  914. int i, argNum;
  915. const char *value;
  916. if ( !gameLocal.CheatsOk() ) {
  917. return;
  918. }
  919. if ( args.Argc () < 7 ) {
  920. gameLocal.Printf( "usage: addline <x y z> <x y z> <color>\n" );
  921. return;
  922. }
  923. for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  924. if ( !debugLines[i].used ) {
  925. break;
  926. }
  927. }
  928. if ( i >= MAX_DEBUGLINES ) {
  929. gameLocal.Printf( "no free debug lines\n" );
  930. return;
  931. }
  932. value = args.Argv( 0 );
  933. if ( !idStr::Icmp( value, "addarrow" ) ) {
  934. debugLines[i].arrow = true;
  935. } else {
  936. debugLines[i].arrow = false;
  937. }
  938. debugLines[i].used = true;
  939. debugLines[i].blink = false;
  940. argNum = 1;
  941. debugLines[i].start.x = Cmd_GetFloatArg( args, argNum );
  942. debugLines[i].start.y = Cmd_GetFloatArg( args, argNum );
  943. debugLines[i].start.z = Cmd_GetFloatArg( args, argNum );
  944. debugLines[i].end.x = Cmd_GetFloatArg( args, argNum );
  945. debugLines[i].end.y = Cmd_GetFloatArg( args, argNum );
  946. debugLines[i].end.z = Cmd_GetFloatArg( args, argNum );
  947. debugLines[i].color = Cmd_GetFloatArg( args, argNum );
  948. }
  949. /*
  950. ==================
  951. Cmd_RemoveDebugLine_f
  952. ==================
  953. */
  954. static void Cmd_RemoveDebugLine_f( const idCmdArgs &args ) {
  955. int i, num;
  956. const char *value;
  957. if ( !gameLocal.CheatsOk() ) {
  958. return;
  959. }
  960. if ( args.Argc () < 2 ) {
  961. gameLocal.Printf( "usage: removeline <num>\n" );
  962. return;
  963. }
  964. value = args.Argv( 1 );
  965. num = atoi(value);
  966. for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  967. if ( debugLines[i].used ) {
  968. if ( --num < 0 ) {
  969. break;
  970. }
  971. }
  972. }
  973. if ( i >= MAX_DEBUGLINES ) {
  974. gameLocal.Printf( "line not found\n" );
  975. return;
  976. }
  977. debugLines[i].used = false;
  978. }
  979. /*
  980. ==================
  981. Cmd_BlinkDebugLine_f
  982. ==================
  983. */
  984. static void Cmd_BlinkDebugLine_f( const idCmdArgs &args ) {
  985. int i, num;
  986. const char *value;
  987. if ( !gameLocal.CheatsOk() ) {
  988. return;
  989. }
  990. if ( args.Argc () < 2 ) {
  991. gameLocal.Printf( "usage: blinkline <num>\n" );
  992. return;
  993. }
  994. value = args.Argv( 1 );
  995. num = atoi( value );
  996. for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  997. if ( debugLines[i].used ) {
  998. if ( --num < 0 ) {
  999. break;
  1000. }
  1001. }
  1002. }
  1003. if ( i >= MAX_DEBUGLINES ) {
  1004. gameLocal.Printf( "line not found\n" );
  1005. return;
  1006. }
  1007. debugLines[i].blink = !debugLines[i].blink;
  1008. }
  1009. /*
  1010. ==================
  1011. PrintFloat
  1012. ==================
  1013. */
  1014. static void PrintFloat( float f ) {
  1015. char buf[128], i;
  1016. for ( i = sprintf( buf, "%3.2f", f ); i < 7; i++ ) {
  1017. buf[i] = ' ';
  1018. }
  1019. buf[i] = '\0';
  1020. gameLocal.Printf( buf );
  1021. }
  1022. /*
  1023. ==================
  1024. Cmd_ListDebugLines_f
  1025. ==================
  1026. */
  1027. static void Cmd_ListDebugLines_f( const idCmdArgs &args ) {
  1028. int i, num;
  1029. if ( !gameLocal.CheatsOk() ) {
  1030. return;
  1031. }
  1032. num = 0;
  1033. gameLocal.Printf( "line num: x1 y1 z1 x2 y2 z2 c b a\n" );
  1034. for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1035. if ( debugLines[i].used ) {
  1036. gameLocal.Printf( "line %3d: ", num );
  1037. PrintFloat( debugLines[i].start.x );
  1038. PrintFloat( debugLines[i].start.y );
  1039. PrintFloat( debugLines[i].start.z );
  1040. PrintFloat( debugLines[i].end.x );
  1041. PrintFloat( debugLines[i].end.y );
  1042. PrintFloat( debugLines[i].end.z );
  1043. gameLocal.Printf( "%d %d %d\n", debugLines[i].color, debugLines[i].blink, debugLines[i].arrow );
  1044. num++;
  1045. }
  1046. }
  1047. if ( !num ) {
  1048. gameLocal.Printf( "no debug lines\n" );
  1049. }
  1050. }
  1051. /*
  1052. ==================
  1053. D_DrawDebugLines
  1054. ==================
  1055. */
  1056. void D_DrawDebugLines() {
  1057. int i;
  1058. idVec3 forward, right, up, p1, p2;
  1059. idVec4 color;
  1060. float l;
  1061. for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1062. if ( debugLines[i].used ) {
  1063. if ( !debugLines[i].blink || (gameLocal.time & (1<<9)) ) {
  1064. color = idVec4( debugLines[i].color&1, (debugLines[i].color>>1)&1, (debugLines[i].color>>2)&1, 1 );
  1065. gameRenderWorld->DebugLine( color, debugLines[i].start, debugLines[i].end );
  1066. //
  1067. if ( debugLines[i].arrow ) {
  1068. // draw a nice arrow
  1069. forward = debugLines[i].end - debugLines[i].start;
  1070. l = forward.Normalize() * 0.2f;
  1071. forward.NormalVectors( right, up);
  1072. if ( l > 3.0f ) {
  1073. l = 3.0f;
  1074. }
  1075. p1 = debugLines[i].end - l * forward + (l * 0.4f) * right;
  1076. p2 = debugLines[i].end - l * forward - (l * 0.4f) * right;
  1077. gameRenderWorld->DebugLine( color, debugLines[i].end, p1 );
  1078. gameRenderWorld->DebugLine( color, debugLines[i].end, p2 );
  1079. gameRenderWorld->DebugLine( color, p1, p2 );
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. /*
  1086. ==================
  1087. Cmd_ListCollisionModels_f
  1088. ==================
  1089. */
  1090. static void Cmd_ListCollisionModels_f( const idCmdArgs &args ) {
  1091. if ( !gameLocal.CheatsOk() ) {
  1092. return;
  1093. }
  1094. collisionModelManager->ListModels();
  1095. }
  1096. /*
  1097. ==================
  1098. Cmd_CollisionModelInfo_f
  1099. ==================
  1100. */
  1101. static void Cmd_CollisionModelInfo_f( const idCmdArgs &args ) {
  1102. const char *value;
  1103. if ( !gameLocal.CheatsOk() ) {
  1104. return;
  1105. }
  1106. if ( args.Argc () < 2 ) {
  1107. gameLocal.Printf( "usage: collisionModelInfo <modelNum>\n"
  1108. "use 'all' instead of the model number for accumulated info\n" );
  1109. return;
  1110. }
  1111. value = args.Argv( 1 );
  1112. if ( !idStr::Icmp( value, "all" ) ) {
  1113. collisionModelManager->ModelInfo( -1 );
  1114. } else {
  1115. collisionModelManager->ModelInfo( atoi(value) );
  1116. }
  1117. }
  1118. /*
  1119. ==================
  1120. Cmd_ReloadAnims_f
  1121. ==================
  1122. */
  1123. static void Cmd_ReloadAnims_f( const idCmdArgs &args ) {
  1124. // don't allow reloading anims when cheats are disabled,
  1125. // but if we're not in the game, it's ok
  1126. if ( gameLocal.GetLocalPlayer() && !gameLocal.CheatsOk( false ) ) {
  1127. return;
  1128. }
  1129. animationLib.ReloadAnims();
  1130. }
  1131. /*
  1132. ==================
  1133. Cmd_ListAnims_f
  1134. ==================
  1135. */
  1136. static void Cmd_ListAnims_f( const idCmdArgs &args ) {
  1137. idEntity * ent;
  1138. int num;
  1139. size_t size;
  1140. size_t alloced;
  1141. idAnimator * animator;
  1142. const char * classname;
  1143. const idDict * dict;
  1144. int i;
  1145. if ( args.Argc() > 1 ) {
  1146. idAnimator animator;
  1147. classname = args.Argv( 1 );
  1148. dict = gameLocal.FindEntityDefDict( classname, false );
  1149. if ( !dict ) {
  1150. gameLocal.Printf( "Entitydef '%s' not found\n", classname );
  1151. return;
  1152. }
  1153. animator.SetModel( dict->GetString( "model" ) );
  1154. gameLocal.Printf( "----------------\n" );
  1155. num = animator.NumAnims();
  1156. for( i = 0; i < num; i++ ) {
  1157. gameLocal.Printf( "%s\n", animator.AnimFullName( i ) );
  1158. }
  1159. gameLocal.Printf( "%d anims\n", num );
  1160. } else {
  1161. animationLib.ListAnims();
  1162. size = 0;
  1163. num = 0;
  1164. for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  1165. animator = ent->GetAnimator();
  1166. if ( animator ) {
  1167. alloced = animator->Allocated();
  1168. size += alloced;
  1169. num++;
  1170. }
  1171. }
  1172. gameLocal.Printf( "%d memory used in %d entity animators\n", size, num );
  1173. }
  1174. }
  1175. /*
  1176. ==================
  1177. Cmd_AASStats_f
  1178. ==================
  1179. */
  1180. static void Cmd_AASStats_f( const idCmdArgs &args ) {
  1181. int aasNum;
  1182. if ( !gameLocal.CheatsOk() ) {
  1183. return;
  1184. }
  1185. aasNum = aas_test.GetInteger();
  1186. idAAS *aas = gameLocal.GetAAS( aasNum );
  1187. if ( !aas ) {
  1188. gameLocal.Printf( "No aas #%d loaded\n", aasNum );
  1189. } else {
  1190. aas->Stats();
  1191. }
  1192. }
  1193. /*
  1194. ==================
  1195. Cmd_TestDamage_f
  1196. ==================
  1197. */
  1198. static void Cmd_TestDamage_f( const idCmdArgs &args ) {
  1199. idPlayer *player;
  1200. const char *damageDefName;
  1201. player = gameLocal.GetLocalPlayer();
  1202. if ( !player || !gameLocal.CheatsOk() ) {
  1203. return;
  1204. }
  1205. if ( args.Argc() < 2 || args.Argc() > 3 ) {
  1206. gameLocal.Printf( "usage: testDamage <damageDefName> [angle]\n" );
  1207. return;
  1208. }
  1209. damageDefName = args.Argv( 1 );
  1210. idVec3 dir;
  1211. if ( args.Argc() == 3 ) {
  1212. float angle = atof( args.Argv( 2 ) );
  1213. idMath::SinCos( DEG2RAD( angle ), dir[1], dir[0] );
  1214. dir[2] = 0;
  1215. } else {
  1216. dir.Zero();
  1217. }
  1218. // give the player full health before and after
  1219. // running the damage
  1220. player->health = player->inventory.maxHealth;
  1221. player->Damage( NULL, NULL, dir, damageDefName, 1.0f, INVALID_JOINT );
  1222. player->health = player->inventory.maxHealth;
  1223. }
  1224. /*
  1225. ==================
  1226. Cmd_TestBoneFx_f
  1227. ==================
  1228. */
  1229. static void Cmd_TestBoneFx_f( const idCmdArgs &args ) {
  1230. idPlayer *player;
  1231. const char *bone, *fx;
  1232. player = gameLocal.GetLocalPlayer();
  1233. if ( !player || !gameLocal.CheatsOk() ) {
  1234. return;
  1235. }
  1236. if ( args.Argc() < 3 || args.Argc() > 4 ) {
  1237. gameLocal.Printf( "usage: testBoneFx <fxName> <boneName>\n" );
  1238. return;
  1239. }
  1240. fx = args.Argv( 1 );
  1241. bone = args.Argv( 2 );
  1242. player->StartFxOnBone( fx, bone );
  1243. }
  1244. /*
  1245. ==================
  1246. Cmd_TestDamage_f
  1247. ==================
  1248. */
  1249. static void Cmd_TestDeath_f( const idCmdArgs &args ) {
  1250. idPlayer *player;
  1251. player = gameLocal.GetLocalPlayer();
  1252. if ( !player || !gameLocal.CheatsOk() ) {
  1253. return;
  1254. }
  1255. idVec3 dir;
  1256. idMath::SinCos( DEG2RAD( 45.0f ), dir[1], dir[0] );
  1257. dir[2] = 0;
  1258. g_testDeath.SetBool( 1 );
  1259. player->Damage( NULL, NULL, dir, "damage_triggerhurt_1000", 1.0f, INVALID_JOINT );
  1260. if ( args.Argc() >= 2) {
  1261. player->SpawnGibs( dir, "damage_triggerhurt_1000" );
  1262. }
  1263. }
  1264. /*
  1265. ==================
  1266. Cmd_WeaponSplat_f
  1267. ==================
  1268. */
  1269. static void Cmd_WeaponSplat_f( const idCmdArgs &args ) {
  1270. idPlayer *player;
  1271. player = gameLocal.GetLocalPlayer();
  1272. if ( !player || !gameLocal.CheatsOk() ) {
  1273. return;
  1274. }
  1275. player->weapon.GetEntity()->BloodSplat( 2.0f );
  1276. }
  1277. /*
  1278. ==================
  1279. Cmd_SaveSelected_f
  1280. ==================
  1281. */
  1282. static void Cmd_SaveSelected_f( const idCmdArgs &args ) {
  1283. int i;
  1284. idPlayer *player = NULL;
  1285. idEntity *s = NULL;
  1286. idMapEntity *mapEnt;
  1287. idMapFile *mapFile = gameLocal.GetLevelMap();
  1288. idDict dict;
  1289. idStr mapName;
  1290. const char *name = NULL;
  1291. player = gameLocal.GetLocalPlayer();
  1292. if ( !player || !gameLocal.CheatsOk() ) {
  1293. return;
  1294. }
  1295. s = player->dragEntity.GetSelected();
  1296. if ( !s ) {
  1297. gameLocal.Printf( "no entity selected, set g_dragShowSelection 1 to show the current selection\n" );
  1298. return;
  1299. }
  1300. if ( args.Argc() > 1 ) {
  1301. mapName = args.Argv( 1 );
  1302. mapName = "maps/" + mapName;
  1303. }
  1304. else {
  1305. mapName = mapFile->GetName();
  1306. }
  1307. // find map file entity
  1308. mapEnt = mapFile->FindEntity( s->name );
  1309. // create new map file entity if there isn't one for this articulated figure
  1310. if ( !mapEnt ) {
  1311. mapEnt = new (TAG_SYSTEM) idMapEntity();
  1312. mapFile->AddEntity( mapEnt );
  1313. for ( i = 0; i < 9999; i++ ) {
  1314. name = va( "%s_%d", s->GetEntityDefName(), i );
  1315. if ( !gameLocal.FindEntity( name ) ) {
  1316. break;
  1317. }
  1318. }
  1319. s->name = name;
  1320. mapEnt->epairs.Set( "classname", s->GetEntityDefName() );
  1321. mapEnt->epairs.Set( "name", s->name );
  1322. }
  1323. if ( s->IsType( idMoveable::Type ) ) {
  1324. // save the moveable state
  1325. mapEnt->epairs.Set( "origin", s->GetPhysics()->GetOrigin().ToString( 8 ) );
  1326. mapEnt->epairs.Set( "rotation", s->GetPhysics()->GetAxis().ToString( 8 ) );
  1327. }
  1328. else if ( s->IsType( idAFEntity_Generic::Type ) || s->IsType( idAFEntity_WithAttachedHead::Type ) ) {
  1329. // save the articulated figure state
  1330. dict.Clear();
  1331. static_cast<idAFEntity_Base *>(s)->SaveState( dict );
  1332. mapEnt->epairs.Copy( dict );
  1333. }
  1334. // write out the map file
  1335. mapFile->Write( mapName, ".map" );
  1336. }
  1337. /*
  1338. ==================
  1339. Cmd_DeleteSelected_f
  1340. ==================
  1341. */
  1342. static void Cmd_DeleteSelected_f( const idCmdArgs &args ) {
  1343. idPlayer *player;
  1344. player = gameLocal.GetLocalPlayer();
  1345. if ( !player || !gameLocal.CheatsOk() ) {
  1346. return;
  1347. }
  1348. if ( player ) {
  1349. player->dragEntity.DeleteSelected();
  1350. }
  1351. }
  1352. /*
  1353. ==================
  1354. Cmd_SaveMoveables_f
  1355. ==================
  1356. */
  1357. static void Cmd_SaveMoveables_f( const idCmdArgs &args ) {
  1358. int e, i;
  1359. idMoveable *m = NULL;
  1360. idMapEntity *mapEnt = NULL;
  1361. idMapFile *mapFile = gameLocal.GetLevelMap();
  1362. idStr mapName;
  1363. const char *name = NULL;
  1364. if ( !gameLocal.CheatsOk() ) {
  1365. return;
  1366. }
  1367. for( e = 0; e < MAX_GENTITIES; e++ ) {
  1368. m = static_cast<idMoveable *>(gameLocal.entities[ e ]);
  1369. if ( !m || !m->IsType( idMoveable::Type ) ) {
  1370. continue;
  1371. }
  1372. if ( m->IsBound() ) {
  1373. continue;
  1374. }
  1375. if ( !m->IsAtRest() ) {
  1376. break;
  1377. }
  1378. }
  1379. if ( e < MAX_GENTITIES ) {
  1380. gameLocal.Warning( "map not saved because the moveable entity %s is not at rest", gameLocal.entities[ e ]->name.c_str() );
  1381. return;
  1382. }
  1383. if ( args.Argc() > 1 ) {
  1384. mapName = args.Argv( 1 );
  1385. mapName = "maps/" + mapName;
  1386. }
  1387. else {
  1388. mapName = mapFile->GetName();
  1389. }
  1390. for( e = 0; e < MAX_GENTITIES; e++ ) {
  1391. m = static_cast<idMoveable *>(gameLocal.entities[ e ]);
  1392. if ( !m || !m->IsType( idMoveable::Type ) ) {
  1393. continue;
  1394. }
  1395. if ( m->IsBound() ) {
  1396. continue;
  1397. }
  1398. // find map file entity
  1399. mapEnt = mapFile->FindEntity( m->name );
  1400. // create new map file entity if there isn't one for this articulated figure
  1401. if ( !mapEnt ) {
  1402. mapEnt = new (TAG_SYSTEM) idMapEntity();
  1403. mapFile->AddEntity( mapEnt );
  1404. for ( i = 0; i < 9999; i++ ) {
  1405. name = va( "%s_%d", m->GetEntityDefName(), i );
  1406. if ( !gameLocal.FindEntity( name ) ) {
  1407. break;
  1408. }
  1409. }
  1410. m->name = name;
  1411. mapEnt->epairs.Set( "classname", m->GetEntityDefName() );
  1412. mapEnt->epairs.Set( "name", m->name );
  1413. }
  1414. // save the moveable state
  1415. mapEnt->epairs.Set( "origin", m->GetPhysics()->GetOrigin().ToString( 8 ) );
  1416. mapEnt->epairs.Set( "rotation", m->GetPhysics()->GetAxis().ToString( 8 ) );
  1417. }
  1418. // write out the map file
  1419. mapFile->Write( mapName, ".map" );
  1420. }
  1421. /*
  1422. ==================
  1423. Cmd_SaveRagdolls_f
  1424. ==================
  1425. */
  1426. static void Cmd_SaveRagdolls_f( const idCmdArgs &args ) {
  1427. int e, i;
  1428. idAFEntity_Base *af = NULL;
  1429. idMapEntity *mapEnt = NULL;
  1430. idMapFile *mapFile = gameLocal.GetLevelMap();
  1431. idDict dict;
  1432. idStr mapName;
  1433. const char *name = NULL;
  1434. if ( !gameLocal.CheatsOk() ) {
  1435. return;
  1436. }
  1437. if ( args.Argc() > 1 ) {
  1438. mapName = args.Argv( 1 );
  1439. mapName = "maps/" + mapName;
  1440. }
  1441. else {
  1442. mapName = mapFile->GetName();
  1443. }
  1444. for( e = 0; e < MAX_GENTITIES; e++ ) {
  1445. af = static_cast<idAFEntity_Base *>(gameLocal.entities[ e ]);
  1446. if ( !af ) {
  1447. continue;
  1448. }
  1449. if ( !af->IsType( idAFEntity_WithAttachedHead::Type ) && !af->IsType( idAFEntity_Generic::Type ) ) {
  1450. continue;
  1451. }
  1452. if ( af->IsBound() ) {
  1453. continue;
  1454. }
  1455. if ( !af->IsAtRest() ) {
  1456. gameLocal.Warning( "the articulated figure for entity %s is not at rest", gameLocal.entities[ e ]->name.c_str() );
  1457. }
  1458. dict.Clear();
  1459. af->SaveState( dict );
  1460. // find map file entity
  1461. mapEnt = mapFile->FindEntity( af->name );
  1462. // create new map file entity if there isn't one for this articulated figure
  1463. if ( !mapEnt ) {
  1464. mapEnt = new (TAG_SYSTEM) idMapEntity();
  1465. mapFile->AddEntity( mapEnt );
  1466. for ( i = 0; i < 9999; i++ ) {
  1467. name = va( "%s_%d", af->GetEntityDefName(), i );
  1468. if ( !gameLocal.FindEntity( name ) ) {
  1469. break;
  1470. }
  1471. }
  1472. af->name = name;
  1473. mapEnt->epairs.Set( "classname", af->GetEntityDefName() );
  1474. mapEnt->epairs.Set( "name", af->name );
  1475. }
  1476. // save the articulated figure state
  1477. mapEnt->epairs.Copy( dict );
  1478. }
  1479. // write out the map file
  1480. mapFile->Write( mapName, ".map" );
  1481. }
  1482. /*
  1483. ==================
  1484. Cmd_BindRagdoll_f
  1485. ==================
  1486. */
  1487. static void Cmd_BindRagdoll_f( const idCmdArgs &args ) {
  1488. idPlayer *player;
  1489. player = gameLocal.GetLocalPlayer();
  1490. if ( !player || !gameLocal.CheatsOk() ) {
  1491. return;
  1492. }
  1493. if ( player ) {
  1494. player->dragEntity.BindSelected();
  1495. }
  1496. }
  1497. /*
  1498. ==================
  1499. Cmd_UnbindRagdoll_f
  1500. ==================
  1501. */
  1502. static void Cmd_UnbindRagdoll_f( const idCmdArgs &args ) {
  1503. idPlayer *player;
  1504. player = gameLocal.GetLocalPlayer();
  1505. if ( !player || !gameLocal.CheatsOk() ) {
  1506. return;
  1507. }
  1508. if ( player ) {
  1509. player->dragEntity.UnbindSelected();
  1510. }
  1511. }
  1512. /*
  1513. ==================
  1514. Cmd_GameError_f
  1515. ==================
  1516. */
  1517. static void Cmd_GameError_f( const idCmdArgs &args ) {
  1518. gameLocal.Error( "game error" );
  1519. }
  1520. /*
  1521. ==================
  1522. Cmd_SaveLights_f
  1523. ==================
  1524. */
  1525. static void Cmd_SaveLights_f( const idCmdArgs &args ) {
  1526. int e, i;
  1527. idLight *light = NULL;
  1528. idMapEntity *mapEnt = NULL;
  1529. idMapFile *mapFile = gameLocal.GetLevelMap();
  1530. idDict dict;
  1531. idStr mapName;
  1532. const char *name = NULL;
  1533. if ( !gameLocal.CheatsOk() ) {
  1534. return;
  1535. }
  1536. if ( args.Argc() > 1 ) {
  1537. mapName = args.Argv( 1 );
  1538. mapName = "maps/" + mapName;
  1539. }
  1540. else {
  1541. mapName = mapFile->GetName();
  1542. }
  1543. for( e = 0; e < MAX_GENTITIES; e++ ) {
  1544. light = static_cast<idLight*>(gameLocal.entities[ e ]);
  1545. if ( !light || !light->IsType( idLight::Type ) ) {
  1546. continue;
  1547. }
  1548. dict.Clear();
  1549. light->SaveState( &dict );
  1550. // find map file entity
  1551. mapEnt = mapFile->FindEntity( light->name );
  1552. // create new map file entity if there isn't one for this light
  1553. if ( !mapEnt ) {
  1554. mapEnt = new (TAG_SYSTEM) idMapEntity();
  1555. mapFile->AddEntity( mapEnt );
  1556. for ( i = 0; i < 9999; i++ ) {
  1557. name = va( "%s_%d", light->GetEntityDefName(), i );
  1558. if ( !gameLocal.FindEntity( name ) ) {
  1559. break;
  1560. }
  1561. }
  1562. light->name = name;
  1563. mapEnt->epairs.Set( "classname", light->GetEntityDefName() );
  1564. mapEnt->epairs.Set( "name", light->name );
  1565. }
  1566. // save the light state
  1567. mapEnt->epairs.Copy( dict );
  1568. }
  1569. // write out the map file
  1570. mapFile->Write( mapName, ".map" );
  1571. }
  1572. /*
  1573. ==================
  1574. Cmd_SaveParticles_f
  1575. ==================
  1576. */
  1577. static void Cmd_SaveParticles_f( const idCmdArgs &args ) {
  1578. int e;
  1579. idEntity *ent;
  1580. idMapEntity *mapEnt;
  1581. idMapFile *mapFile = gameLocal.GetLevelMap();
  1582. idDict dict;
  1583. idStr mapName, strModel;
  1584. if ( !gameLocal.CheatsOk() ) {
  1585. return;
  1586. }
  1587. if ( args.Argc() > 1 ) {
  1588. mapName = args.Argv( 1 );
  1589. mapName = "maps/" + mapName;
  1590. }
  1591. else {
  1592. mapName = mapFile->GetName();
  1593. }
  1594. for( e = 0; e < MAX_GENTITIES; e++ ) {
  1595. ent = static_cast<idStaticEntity*> ( gameLocal.entities[ e ] );
  1596. if ( !ent ) {
  1597. continue;
  1598. }
  1599. strModel = ent->spawnArgs.GetString( "model" );
  1600. if ( strModel.Length() && strModel.Find( ".prt") > 0 ) {
  1601. dict.Clear();
  1602. dict.Set( "model", ent->spawnArgs.GetString( "model" ) );
  1603. dict.SetVector( "origin", ent->GetPhysics()->GetOrigin() );
  1604. // find map file entity
  1605. mapEnt = mapFile->FindEntity( ent->name );
  1606. // create new map file entity if there isn't one for this entity
  1607. if ( !mapEnt ) {
  1608. continue;
  1609. }
  1610. // save the particle state
  1611. mapEnt->epairs.Copy( dict );
  1612. }
  1613. }
  1614. // write out the map file
  1615. mapFile->Write( mapName, ".map" );
  1616. }
  1617. /*
  1618. ==================
  1619. Cmd_DisasmScript_f
  1620. ==================
  1621. */
  1622. static void Cmd_DisasmScript_f( const idCmdArgs &args ) {
  1623. gameLocal.program.Disassemble();
  1624. }
  1625. /*
  1626. ==================
  1627. Cmd_TestSave_f
  1628. ==================
  1629. */
  1630. static void Cmd_TestSave_f( const idCmdArgs &args ) {
  1631. idFile *f, *strings;
  1632. f = fileSystem->OpenFileWrite( "test.sav" );
  1633. strings = NULL;
  1634. gameLocal.SaveGame( f, strings );
  1635. fileSystem->CloseFile( f );
  1636. }
  1637. /*
  1638. ==================
  1639. Cmd_RecordViewNotes_f
  1640. ==================
  1641. */
  1642. static void Cmd_RecordViewNotes_f( const idCmdArgs &args ) {
  1643. idPlayer *player;
  1644. idVec3 origin;
  1645. idMat3 axis;
  1646. if ( args.Argc() <= 3 ) {
  1647. return;
  1648. }
  1649. player = gameLocal.GetLocalPlayer();
  1650. if ( !player ) {
  1651. return;
  1652. }
  1653. player->GetViewPos( origin, axis );
  1654. // Argv(1) = filename for map (viewnotes/mapname/person)
  1655. // Argv(2) = note number (person0001)
  1656. // Argv(3) = comments
  1657. idStr str = args.Argv(1);
  1658. str.SetFileExtension( ".txt" );
  1659. idFile *file = fileSystem->OpenFileAppend( str );
  1660. if ( file ) {
  1661. file->WriteFloatString( "\"view\"\t( %s )\t( %s )\r\n", origin.ToString(), axis.ToString() );
  1662. file->WriteFloatString( "\"comments\"\t\"%s: %s\"\r\n\r\n", args.Argv(2), args.Argv(3) );
  1663. fileSystem->CloseFile( file );
  1664. }
  1665. idStr viewComments = args.Argv(1);
  1666. viewComments.StripLeading("viewnotes/");
  1667. viewComments += " -- Loc: ";
  1668. viewComments += origin.ToString();
  1669. viewComments += "\n";
  1670. viewComments += args.Argv(3);
  1671. // TODO_SPARTY: removed old hud need to find a way of doing this with the new hud
  1672. //player->hud->SetStateString( "viewcomments", viewComments );
  1673. //player->hud->HandleNamedEvent( "showViewComments" );
  1674. }
  1675. /*
  1676. ==================
  1677. Cmd_CloseViewNotes_f
  1678. ==================
  1679. */
  1680. static void Cmd_CloseViewNotes_f( const idCmdArgs &args ) {
  1681. idPlayer *player = gameLocal.GetLocalPlayer();
  1682. if ( !player ) {
  1683. return;
  1684. }
  1685. // TODO_SPARTY: removed old hud need to find a way of doing this with the new hud
  1686. //player->hud->SetStateString( "viewcomments", "" );
  1687. //player->hud->HandleNamedEvent( "hideViewComments" );
  1688. }
  1689. /*
  1690. ==================
  1691. Cmd_ShowViewNotes_f
  1692. ==================
  1693. */
  1694. static void Cmd_ShowViewNotes_f( const idCmdArgs &args ) {
  1695. static idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS | LEXFL_NOSTRINGCONCAT | LEXFL_NOFATALERRORS );
  1696. idToken token;
  1697. idPlayer *player;
  1698. idVec3 origin;
  1699. idMat3 axis;
  1700. player = gameLocal.GetLocalPlayer();
  1701. if ( !player ) {
  1702. return;
  1703. }
  1704. if ( !parser.IsLoaded() ) {
  1705. idStr str = "viewnotes/";
  1706. str += gameLocal.GetMapName();
  1707. str.StripFileExtension();
  1708. str += "/";
  1709. if ( args.Argc() > 1 ) {
  1710. str += args.Argv( 1 );
  1711. } else {
  1712. str += "comments";
  1713. }
  1714. str.SetFileExtension( ".txt" );
  1715. if ( !parser.LoadFile( str ) ) {
  1716. gameLocal.Printf( "No view notes for %s\n", gameLocal.GetMapName() );
  1717. return;
  1718. }
  1719. }
  1720. if ( parser.ExpectTokenString( "view" ) && parser.Parse1DMatrix( 3, origin.ToFloatPtr() ) &&
  1721. parser.Parse1DMatrix( 9, axis.ToFloatPtr() ) && parser.ExpectTokenString( "comments" ) && parser.ReadToken( &token ) ) {
  1722. // TODO_SPARTY: removed old hud need to find a way of doing this with the new hud
  1723. //player->hud->SetStateString( "viewcomments", token );
  1724. //player->hud->HandleNamedEvent( "showViewComments" );
  1725. player->Teleport( origin, axis.ToAngles(), NULL );
  1726. } else {
  1727. parser.FreeSource();
  1728. // TODO_SPARTY: removed old hud need to find a way of doing this with the new hud
  1729. //player->hud->HandleNamedEvent( "hideViewComments" );
  1730. return;
  1731. }
  1732. }
  1733. /*
  1734. =================
  1735. FindEntityGUIs
  1736. helper function for Cmd_NextGUI_f. Checks the passed entity to determine if it
  1737. has any valid gui surfaces.
  1738. =================
  1739. */
  1740. bool FindEntityGUIs( idEntity *ent, const modelSurface_t ** surfaces, int maxSurfs, int &guiSurfaces ) {
  1741. renderEntity_t *renderEnt;
  1742. idRenderModel *renderModel;
  1743. const modelSurface_t *surf;
  1744. const idMaterial *shader;
  1745. int i;
  1746. assert( surfaces != NULL );
  1747. assert( ent != NULL );
  1748. memset( surfaces, 0x00, sizeof( modelSurface_t *) * maxSurfs );
  1749. guiSurfaces = 0;
  1750. renderEnt = ent->GetRenderEntity();
  1751. renderModel = renderEnt->hModel;
  1752. if ( renderModel == NULL ) {
  1753. return false;
  1754. }
  1755. for( i = 0; i < renderModel->NumSurfaces(); i++ ) {
  1756. surf = renderModel->Surface( i );
  1757. if ( surf == NULL ) {
  1758. continue;
  1759. }
  1760. shader = surf->shader;
  1761. if ( shader == NULL ) {
  1762. continue;
  1763. }
  1764. if ( shader->GetEntityGui() > 0 ) {
  1765. surfaces[ guiSurfaces++ ] = surf;
  1766. }
  1767. }
  1768. return ( guiSurfaces != 0 );
  1769. }
  1770. /*
  1771. =================
  1772. Cmd_NextGUI_f
  1773. =================
  1774. */
  1775. void Cmd_NextGUI_f( const idCmdArgs &args ) {
  1776. idVec3 origin;
  1777. idAngles angles;
  1778. idPlayer *player;
  1779. idEntity *ent;
  1780. int guiSurfaces;
  1781. bool newEnt;
  1782. renderEntity_t *renderEnt;
  1783. int surfIndex;
  1784. srfTriangles_t *geom;
  1785. idVec3 normal;
  1786. idVec3 center;
  1787. const modelSurface_t *surfaces[ MAX_RENDERENTITY_GUI ];
  1788. player = gameLocal.GetLocalPlayer();
  1789. if ( !player || !gameLocal.CheatsOk() ) {
  1790. return;
  1791. }
  1792. if ( args.Argc() != 1 ) {
  1793. gameLocal.Printf( "usage: nextgui\n" );
  1794. return;
  1795. }
  1796. // start at the last entity
  1797. ent = gameLocal.lastGUIEnt.GetEntity();
  1798. // see if we have any gui surfaces left to go to on the current entity.
  1799. guiSurfaces = 0;
  1800. newEnt = false;
  1801. if ( ent == NULL ) {
  1802. newEnt = true;
  1803. } else if ( FindEntityGUIs( ent, surfaces, MAX_RENDERENTITY_GUI, guiSurfaces ) == true ) {
  1804. if ( gameLocal.lastGUI >= guiSurfaces ) {
  1805. newEnt = true;
  1806. }
  1807. } else {
  1808. // no actual gui surfaces on this ent, so skip it
  1809. newEnt = true;
  1810. }
  1811. if ( newEnt == true ) {
  1812. // go ahead and skip to the next entity with a gui...
  1813. if ( ent == NULL ) {
  1814. ent = gameLocal.spawnedEntities.Next();
  1815. } else {
  1816. ent = ent->spawnNode.Next();
  1817. }
  1818. for ( ; ent != NULL; ent = ent->spawnNode.Next() ) {
  1819. if ( ent->spawnArgs.GetString( "gui", NULL ) != NULL ) {
  1820. break;
  1821. }
  1822. if ( ent->spawnArgs.GetString( "gui2", NULL ) != NULL ) {
  1823. break;
  1824. }
  1825. if ( ent->spawnArgs.GetString( "gui3", NULL ) != NULL ) {
  1826. break;
  1827. }
  1828. // try the next entity
  1829. gameLocal.lastGUIEnt = ent;
  1830. }
  1831. gameLocal.lastGUIEnt = ent;
  1832. gameLocal.lastGUI = 0;
  1833. if ( !ent ) {
  1834. gameLocal.Printf( "No more gui entities. Starting over...\n" );
  1835. return;
  1836. }
  1837. }
  1838. if ( FindEntityGUIs( ent, surfaces, MAX_RENDERENTITY_GUI, guiSurfaces ) == false ) {
  1839. gameLocal.Printf( "Entity \"%s\" has gui properties but no gui surfaces.\n", ent->name.c_str() );
  1840. }
  1841. if ( guiSurfaces == 0 ) {
  1842. gameLocal.Printf( "Entity \"%s\" has gui properties but no gui surfaces!\n", ent->name.c_str() );
  1843. return;
  1844. }
  1845. gameLocal.Printf( "Teleporting to gui entity \"%s\", gui #%d.\n" , ent->name.c_str (), gameLocal.lastGUI );
  1846. renderEnt = ent->GetRenderEntity();
  1847. surfIndex = gameLocal.lastGUI++;
  1848. geom = surfaces[ surfIndex ]->geometry;
  1849. if ( geom == NULL ) {
  1850. gameLocal.Printf( "Entity \"%s\" has gui surface %d without geometry!\n", ent->name.c_str(), surfIndex );
  1851. return;
  1852. }
  1853. const idVec3 & v0 = geom->verts[geom->indexes[0]].xyz;
  1854. const idVec3 & v1 = geom->verts[geom->indexes[1]].xyz;
  1855. const idVec3 & v2 = geom->verts[geom->indexes[2]].xyz;
  1856. const idPlane plane( v0, v1, v2 );
  1857. normal = plane.Normal() * renderEnt->axis;
  1858. center = geom->bounds.GetCenter() * renderEnt->axis + renderEnt->origin;
  1859. origin = center + (normal * 32.0f);
  1860. origin.z -= player->EyeHeight();
  1861. normal *= -1.0f;
  1862. angles = normal.ToAngles ();
  1863. // make sure the player is in noclip
  1864. player->noclip = true;
  1865. player->Teleport( origin, angles, NULL );
  1866. }
  1867. void Cmd_SetActorState_f( const idCmdArgs &args ) {
  1868. if ( args.Argc() != 3 ) {
  1869. common->Printf( "usage: setActorState <entity name> <state>\n" );
  1870. return;
  1871. }
  1872. idEntity* ent;
  1873. ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1874. if ( !ent ) {
  1875. gameLocal.Printf( "entity not found\n" );
  1876. return;
  1877. }
  1878. if(!ent->IsType(idActor::Type)) {
  1879. gameLocal.Printf( "entity not an actor\n" );
  1880. return;
  1881. }
  1882. idActor* actor = (idActor*)ent;
  1883. actor->PostEventMS(&AI_SetState, 0, args.Argv(2));
  1884. }
  1885. #if 0
  1886. // not used
  1887. static void ArgCompletion_DefFile( const idCmdArgs &args, void(*callback)( const char *s ) ) {
  1888. cmdSystem->ArgCompletion_FolderExtension( args, callback, "def/", true, ".def", NULL );
  1889. }
  1890. #endif
  1891. /*
  1892. ===============
  1893. Cmd_TestId_f
  1894. outputs a string from the string table for the specified id
  1895. ===============
  1896. */
  1897. void Cmd_TestId_f( const idCmdArgs &args ) {
  1898. idStr id;
  1899. int i;
  1900. if ( args.Argc() == 1 ) {
  1901. common->Printf( "usage: testid <string id>\n" );
  1902. return;
  1903. }
  1904. for ( i = 1; i < args.Argc(); i++ ) {
  1905. id += args.Argv( i );
  1906. }
  1907. if ( idStr::Cmpn( id, STRTABLE_ID, STRTABLE_ID_LENGTH ) != 0 ) {
  1908. id = STRTABLE_ID + id;
  1909. }
  1910. gameLocal.mpGame.AddChatLine( idLocalization::GetString( id ), "<nothing>", "<nothing>", "<nothing>" );
  1911. }
  1912. /*
  1913. =================
  1914. idGameLocal::InitConsoleCommands
  1915. Let the system know about all of our commands
  1916. so it can perform tab completion
  1917. =================
  1918. */
  1919. void idGameLocal::InitConsoleCommands() {
  1920. cmdSystem->AddCommand( "game_memory", idClass::DisplayInfo_f, CMD_FL_GAME, "displays game class info" );
  1921. cmdSystem->AddCommand( "listClasses", idClass::ListClasses_f, CMD_FL_GAME, "lists game classes" );
  1922. cmdSystem->AddCommand( "listThreads", idThread::ListThreads_f, CMD_FL_GAME|CMD_FL_CHEAT, "lists script threads" );
  1923. cmdSystem->AddCommand( "listEntities", Cmd_EntityList_f, CMD_FL_GAME|CMD_FL_CHEAT, "lists game entities" );
  1924. cmdSystem->AddCommand( "listActiveEntities", Cmd_ActiveEntityList_f, CMD_FL_GAME|CMD_FL_CHEAT, "lists active game entities" );
  1925. cmdSystem->AddCommand( "listMonsters", idAI::List_f, CMD_FL_GAME|CMD_FL_CHEAT, "lists monsters" );
  1926. cmdSystem->AddCommand( "listSpawnArgs", Cmd_ListSpawnArgs_f, CMD_FL_GAME|CMD_FL_CHEAT, "list the spawn args of an entity", idGameLocal::ArgCompletion_EntityName );
  1927. cmdSystem->AddCommand( "say", Cmd_Say_f, CMD_FL_GAME, "text chat" );
  1928. cmdSystem->AddCommand( "sayTeam", Cmd_SayTeam_f, CMD_FL_GAME, "team text chat" );
  1929. cmdSystem->AddCommand( "addChatLine", Cmd_AddChatLine_f, CMD_FL_GAME, "internal use - core to game chat lines" );
  1930. cmdSystem->AddCommand( "give", Cmd_Give_f, CMD_FL_GAME|CMD_FL_CHEAT, "gives one or more items" );
  1931. cmdSystem->AddCommand( "centerview", Cmd_CenterView_f, CMD_FL_GAME, "centers the view" );
  1932. cmdSystem->AddCommand( "god", Cmd_God_f, CMD_FL_GAME|CMD_FL_CHEAT, "enables god mode" );
  1933. cmdSystem->AddCommand( "notarget", Cmd_Notarget_f, CMD_FL_GAME|CMD_FL_CHEAT, "disables the player as a target" );
  1934. cmdSystem->AddCommand( "noclip", Cmd_Noclip_f, CMD_FL_GAME|CMD_FL_CHEAT, "disables collision detection for the player" );
  1935. cmdSystem->AddCommand( "where", Cmd_GetViewpos_f, CMD_FL_GAME|CMD_FL_CHEAT, "prints the current view position" );
  1936. cmdSystem->AddCommand( "getviewpos", Cmd_GetViewpos_f, CMD_FL_GAME|CMD_FL_CHEAT, "prints the current view position" );
  1937. cmdSystem->AddCommand( "setviewpos", Cmd_SetViewpos_f, CMD_FL_GAME|CMD_FL_CHEAT, "sets the current view position" );
  1938. cmdSystem->AddCommand( "teleport", Cmd_Teleport_f, CMD_FL_GAME|CMD_FL_CHEAT, "teleports the player to an entity location", idGameLocal::ArgCompletion_EntityName );
  1939. cmdSystem->AddCommand( "trigger", Cmd_Trigger_f, CMD_FL_GAME|CMD_FL_CHEAT, "triggers an entity", idGameLocal::ArgCompletion_EntityName );
  1940. cmdSystem->AddCommand( "spawn", Cmd_Spawn_f, CMD_FL_GAME|CMD_FL_CHEAT, "spawns a game entity", idCmdSystem::ArgCompletion_Decl<DECL_ENTITYDEF> );
  1941. cmdSystem->AddCommand( "damage", Cmd_Damage_f, CMD_FL_GAME|CMD_FL_CHEAT, "apply damage to an entity", idGameLocal::ArgCompletion_EntityName );
  1942. cmdSystem->AddCommand( "remove", Cmd_Remove_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes an entity", idGameLocal::ArgCompletion_EntityName );
  1943. cmdSystem->AddCommand( "killMonsters", Cmd_KillMonsters_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes all monsters" );
  1944. cmdSystem->AddCommand( "killMoveables", Cmd_KillMovables_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes all moveables" );
  1945. cmdSystem->AddCommand( "killRagdolls", Cmd_KillRagdolls_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes all ragdolls" );
  1946. cmdSystem->AddCommand( "addline", Cmd_AddDebugLine_f, CMD_FL_GAME|CMD_FL_CHEAT, "adds a debug line" );
  1947. cmdSystem->AddCommand( "addarrow", Cmd_AddDebugLine_f, CMD_FL_GAME|CMD_FL_CHEAT, "adds a debug arrow" );
  1948. cmdSystem->AddCommand( "removeline", Cmd_RemoveDebugLine_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes a debug line" );
  1949. cmdSystem->AddCommand( "blinkline", Cmd_BlinkDebugLine_f, CMD_FL_GAME|CMD_FL_CHEAT, "blinks a debug line" );
  1950. cmdSystem->AddCommand( "listLines", Cmd_ListDebugLines_f, CMD_FL_GAME|CMD_FL_CHEAT, "lists all debug lines" );
  1951. cmdSystem->AddCommand( "playerModel", Cmd_PlayerModel_f, CMD_FL_GAME|CMD_FL_CHEAT, "sets the given model on the player", idCmdSystem::ArgCompletion_Decl<DECL_MODELDEF> );
  1952. cmdSystem->AddCommand( "testFx", Cmd_TestFx_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests an FX system", idCmdSystem::ArgCompletion_Decl<DECL_FX> );
  1953. cmdSystem->AddCommand( "testBoneFx", Cmd_TestBoneFx_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests an FX system bound to a joint", idCmdSystem::ArgCompletion_Decl<DECL_FX> );
  1954. cmdSystem->AddCommand( "testLight", Cmd_TestLight_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests a light" );
  1955. cmdSystem->AddCommand( "testPointLight", Cmd_TestPointLight_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests a point light" );
  1956. cmdSystem->AddCommand( "popLight", Cmd_PopLight_f, CMD_FL_GAME|CMD_FL_CHEAT, "removes the last created light" );
  1957. cmdSystem->AddCommand( "testDeath", Cmd_TestDeath_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests death" );
  1958. cmdSystem->AddCommand( "testSave", Cmd_TestSave_f, CMD_FL_GAME|CMD_FL_CHEAT, "writes out a test savegame" );
  1959. cmdSystem->AddCommand( "testModel", idTestModel::TestModel_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests a model", idTestModel::ArgCompletion_TestModel );
  1960. cmdSystem->AddCommand( "testSkin", idTestModel::TestSkin_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests a skin on an existing testModel", idCmdSystem::ArgCompletion_Decl<DECL_SKIN> );
  1961. cmdSystem->AddCommand( "testShaderParm", idTestModel::TestShaderParm_f, CMD_FL_GAME|CMD_FL_CHEAT, "sets a shaderParm on an existing testModel" );
  1962. cmdSystem->AddCommand( "keepTestModel", idTestModel::KeepTestModel_f, CMD_FL_GAME|CMD_FL_CHEAT, "keeps the last test model in the game" );
  1963. cmdSystem->AddCommand( "testAnim", idTestModel::TestAnim_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests an animation", idTestModel::ArgCompletion_TestAnim );
  1964. cmdSystem->AddCommand( "testParticleStopTime", idTestModel::TestParticleStopTime_f,CMD_FL_GAME|CMD_FL_CHEAT, "tests particle stop time on a test model" );
  1965. cmdSystem->AddCommand( "nextAnim", idTestModel::TestModelNextAnim_f, CMD_FL_GAME|CMD_FL_CHEAT, "shows next animation on test model" );
  1966. cmdSystem->AddCommand( "prevAnim", idTestModel::TestModelPrevAnim_f, CMD_FL_GAME|CMD_FL_CHEAT, "shows previous animation on test model" );
  1967. cmdSystem->AddCommand( "nextFrame", idTestModel::TestModelNextFrame_f, CMD_FL_GAME|CMD_FL_CHEAT, "shows next animation frame on test model" );
  1968. cmdSystem->AddCommand( "prevFrame", idTestModel::TestModelPrevFrame_f, CMD_FL_GAME|CMD_FL_CHEAT, "shows previous animation frame on test model" );
  1969. cmdSystem->AddCommand( "testBlend", idTestModel::TestBlend_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests animation blending" );
  1970. cmdSystem->AddCommand( "reloadScript", Cmd_ReloadScript_f, CMD_FL_GAME|CMD_FL_CHEAT, "reloads scripts" );
  1971. cmdSystem->AddCommand( "script", Cmd_Script_f, CMD_FL_GAME|CMD_FL_CHEAT, "executes a line of script" );
  1972. cmdSystem->AddCommand( "listCollisionModels", Cmd_ListCollisionModels_f, CMD_FL_GAME, "lists collision models" );
  1973. cmdSystem->AddCommand( "collisionModelInfo", Cmd_CollisionModelInfo_f, CMD_FL_GAME, "shows collision model info" );
  1974. cmdSystem->AddCommand( "reloadanims", Cmd_ReloadAnims_f, CMD_FL_GAME|CMD_FL_CHEAT, "reloads animations" );
  1975. cmdSystem->AddCommand( "listAnims", Cmd_ListAnims_f, CMD_FL_GAME, "lists all animations" );
  1976. cmdSystem->AddCommand( "aasStats", Cmd_AASStats_f, CMD_FL_GAME, "shows AAS stats" );
  1977. cmdSystem->AddCommand( "testDamage", Cmd_TestDamage_f, CMD_FL_GAME|CMD_FL_CHEAT, "tests a damage def", idCmdSystem::ArgCompletion_Decl<DECL_ENTITYDEF> );
  1978. cmdSystem->AddCommand( "weaponSplat", Cmd_WeaponSplat_f, CMD_FL_GAME|CMD_FL_CHEAT, "projects a blood splat on the player weapon" );
  1979. cmdSystem->AddCommand( "saveSelected", Cmd_SaveSelected_f, CMD_FL_GAME|CMD_FL_CHEAT, "saves the selected entity to the .map file" );
  1980. cmdSystem->AddCommand( "deleteSelected", Cmd_DeleteSelected_f, CMD_FL_GAME|CMD_FL_CHEAT, "deletes selected entity" );
  1981. cmdSystem->AddCommand( "saveMoveables", Cmd_SaveMoveables_f, CMD_FL_GAME|CMD_FL_CHEAT, "save all moveables to the .map file" );
  1982. cmdSystem->AddCommand( "saveRagdolls", Cmd_SaveRagdolls_f, CMD_FL_GAME|CMD_FL_CHEAT, "save all ragdoll poses to the .map file" );
  1983. cmdSystem->AddCommand( "bindRagdoll", Cmd_BindRagdoll_f, CMD_FL_GAME|CMD_FL_CHEAT, "binds ragdoll at the current drag position" );
  1984. cmdSystem->AddCommand( "unbindRagdoll", Cmd_UnbindRagdoll_f, CMD_FL_GAME|CMD_FL_CHEAT, "unbinds the selected ragdoll" );
  1985. cmdSystem->AddCommand( "saveLights", Cmd_SaveLights_f, CMD_FL_GAME|CMD_FL_CHEAT, "saves all lights to the .map file" );
  1986. cmdSystem->AddCommand( "saveParticles", Cmd_SaveParticles_f, CMD_FL_GAME|CMD_FL_CHEAT, "saves all lights to the .map file" );
  1987. cmdSystem->AddCommand( "clearLights", Cmd_ClearLights_f, CMD_FL_GAME|CMD_FL_CHEAT, "clears all lights" );
  1988. cmdSystem->AddCommand( "gameError", Cmd_GameError_f, CMD_FL_GAME|CMD_FL_CHEAT, "causes a game error" );
  1989. cmdSystem->AddCommand( "disasmScript", Cmd_DisasmScript_f, CMD_FL_GAME|CMD_FL_CHEAT, "disassembles script" );
  1990. cmdSystem->AddCommand( "recordViewNotes", Cmd_RecordViewNotes_f, CMD_FL_GAME|CMD_FL_CHEAT, "record the current view position with notes" );
  1991. cmdSystem->AddCommand( "showViewNotes", Cmd_ShowViewNotes_f, CMD_FL_GAME|CMD_FL_CHEAT, "show any view notes for the current map, successive calls will cycle to the next note" );
  1992. cmdSystem->AddCommand( "closeViewNotes", Cmd_CloseViewNotes_f, CMD_FL_GAME|CMD_FL_CHEAT, "close the view showing any notes for this map" );
  1993. // multiplayer client commands ( replaces old impulses stuff )
  1994. //cmdSystem->AddCommand( "clientDropWeapon", idMultiplayerGame::DropWeapon_f, CMD_FL_GAME, "drop current weapon" );
  1995. cmdSystem->AddCommand( "clientMessageMode", idMultiplayerGame::MessageMode_f, CMD_FL_GAME, "ingame gui message mode" );
  1996. // FIXME: implement
  1997. // cmdSystem->AddCommand( "clientVote", idMultiplayerGame::Vote_f, CMD_FL_GAME, "cast your vote: clientVote yes | no" );
  1998. // cmdSystem->AddCommand( "clientCallVote", idMultiplayerGame::CallVote_f, CMD_FL_GAME, "call a vote: clientCallVote si_.. proposed_value" );
  1999. cmdSystem->AddCommand( "clientVoiceChat", idMultiplayerGame::VoiceChat_f, CMD_FL_GAME, "voice chats: clientVoiceChat <sound shader>" );
  2000. cmdSystem->AddCommand( "clientVoiceChatTeam", idMultiplayerGame::VoiceChatTeam_f, CMD_FL_GAME, "team voice chats: clientVoiceChat <sound shader>" );
  2001. // multiplayer server commands
  2002. cmdSystem->AddCommand( "serverMapRestart", idGameLocal::MapRestart_f, CMD_FL_GAME, "restart the current game" );
  2003. // localization help commands
  2004. cmdSystem->AddCommand( "nextGUI", Cmd_NextGUI_f, CMD_FL_GAME|CMD_FL_CHEAT, "teleport the player to the next func_static with a gui" );
  2005. cmdSystem->AddCommand( "testid", Cmd_TestId_f, CMD_FL_GAME|CMD_FL_CHEAT, "output the string for the specified id." );
  2006. cmdSystem->AddCommand( "setActorState", Cmd_SetActorState_f, CMD_FL_GAME|CMD_FL_CHEAT, "Manually sets an actors script state", idGameLocal::ArgCompletion_EntityName );
  2007. }
  2008. /*
  2009. =================
  2010. idGameLocal::ShutdownConsoleCommands
  2011. =================
  2012. */
  2013. void idGameLocal::ShutdownConsoleCommands() {
  2014. cmdSystem->RemoveFlaggedCommands( CMD_FL_GAME );
  2015. }