SysCmds.cpp 64 KB

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