// sys_preycmds.cpp // #include "precompiled.h" #pragma hdrstop #include "prey_local.h" #if INGAME_PROFILER_ENABLED void Profiler_ZoomOut_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TRAVERSEOUT); } void Profiler_Mode_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TOGGLEMODE); } void Profiler_MSMode_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TOGGLEMS); } void Profiler_Smooth_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TOGGLESMOOTHING); } void Profiler_ToggleCapture_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TOGGLECAPTURE); } void Profiler_Toggle_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_TOGGLE); } void Profiler_Release_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_RELEASE); } void Profiler_In0_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN0); } void Profiler_In1_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN1); } void Profiler_In2_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN2); } void Profiler_In3_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN3); } void Profiler_In4_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN4); } void Profiler_In5_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN5); } void Profiler_In6_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN6); } void Profiler_In7_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN7); } void Profiler_In8_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN8); } void Profiler_In9_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN9); } void Profiler_In10_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN10); } void Profiler_In11_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN11); } void Profiler_In12_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN12); } void Profiler_In13_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN13); } void Profiler_In14_f( const idCmdArgs &args ) { profiler->SubmitFrameCommand(PROFCOMMAND_IN14); } #endif void Cmd_GetMapName_f( const idCmdArgs &args ) { gameLocal.Printf( "%s\n", gameLocal.GetMapName() ); } void Cmd_TestText_f( const idCmdArgs &args ) { #if 0 // jmarshall char translated[1024]; if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: testtext \n"); return; } common->FixupKeyTranslations(args.Argv(1), translated, 1024); // No passing idStr between game and engine gameLocal.Printf("%s\n", translated); #endif } void Cmd_GetBinds_f( const idCmdArgs &args ) { const char *entityname; if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: getbinds \n"); return; } if ( !gameLocal.CheatsOk() ) { return; } // get name of entity entityname = args.Argv( 1 ); // find entity by name or classname idEntity *master = gameLocal.FindEntity(entityname); if (master) { int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if ( ent && ent->GetBindMaster() == master ) { gameLocal.Printf(" %s bound (%s)\n", ent->GetName(), ent->GetClassname()); count++; } } gameLocal.Printf("%d entities bound to %s\n", count, entityname); } } void Cmd_SpiritWalkMode_f( const idCmdArgs &args ) { if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: envirosuit <1|0>\n"); return; } bool on = atoi(args.Argv( 1 )) != 0; gameLocal.SpiritWalkSoundMode( on ); } void Cmd_DialogMode_f( const idCmdArgs &args ) { if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: dialogmode <1|0>\n"); return; } bool on = atoi(args.Argv( 1 )) != 0; idPlayer *player = gameLocal.GetLocalPlayer(); if (player && player->IsType(hhPlayer::Type)) { if (on) { static_cast(player)->DialogStart(0, 1, 1); } else { static_cast(player)->DialogStop(); } } } void Cmd_EntitySize_f( const idCmdArgs &args ) { //TEMP: For memory optimization gameLocal.Printf("Sizeof(idDict): %d\n", (int)sizeof(idDict)); gameLocal.Printf("Sizeof(idList): %d\n", 16); gameLocal.Printf("Sizeof(idMat3): %d\n", (int)sizeof(idMat3)); gameLocal.Printf("Sizeof(idVec3): %d\n", (int)sizeof(idVec3)); gameLocal.Printf("Sizeof(renderEntity_t): %d\n", (int)sizeof(renderEntity_t)); gameLocal.Printf("Sizeof(refSound_t): %d\n", (int)sizeof(refSound_t)); gameLocal.Printf("Sizeof(idAnimator): %d\n", (int)sizeof(idAnimator)); gameLocal.Printf("Sizeof(idClass): %d\n", (int)sizeof(idClass)); gameLocal.Printf("sizeof(idEntity): %d\n", (int)sizeof(idEntity)); gameLocal.Printf("Sizeof(idAI): %d\n", (int)sizeof(idAI)); gameLocal.Printf("Sizeof(hhPlayer): %d\n", (int)sizeof(hhPlayer)); gameLocal.Printf("Number entities: %d\n", gameLocal.num_entities); gameLocal.Printf("sizeof(idEntity): %d\n", (int)sizeof(idEntity)); gameLocal.Printf("Total mem cost: %d\n", gameLocal.num_entities * (int)sizeof(idEntity)); } void Cmd_Assert_f( const idCmdArgs &args ) { assert(0); } void Cmd_Dormant_f( const idCmdArgs &args ) { const char *classname; if ( !gameLocal.CheatsOk() ) { return; } if ( args.Argc() != 2 ) { gameLocal.Printf("Usage: dormant \n"); return; } classname = args.Argv( 1 ); const idTypeInfo *searchType = idClass::GetClass(classname); if (searchType) { // make all entities of this class: neverdormant int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if (ent && ent->IsType(*searchType)) { ent->fl.neverDormant = false; count++; } } gameLocal.Printf("%d %s entities unmarked neverdormant\n", count, classname); } else { gameLocal.Printf("class not found, make sure capitalization is correct\n"); } } void Cmd_UnDormant_f( const idCmdArgs &args ) { const char *classname; if ( !gameLocal.CheatsOk() ) { return; } if ( args.Argc() != 2 ) { gameLocal.Printf("Usage: undormant \n"); return; } classname = args.Argv( 1 ); const idTypeInfo *searchType = idClass::GetClass(classname); if (searchType) { // make all entities of this class: neverdormant int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; // if (ent && !idStr::Icmp(ent->GetClassname(), classname)) { if (ent && ent->IsType(*searchType)) { ent->fl.neverDormant = true; count++; } } gameLocal.Printf("%d %s entities marked neverdormant\n", count, classname); } else { gameLocal.Printf("class not found, make sure capitalization is correct\n"); } } void Cmd_TestHealthPulse_f( const idCmdArgs &args ) { idPlayer *player = gameLocal.GetLocalPlayer(); if (player && player->hud) { player->healthPulse = true; } } void Cmd_TestSpiritPulse_f( const idCmdArgs &args ) { idPlayer *player = gameLocal.GetLocalPlayer(); if (player && player->hud) { player->spiritPulse = true; } } void Cmd_SpawnABunch_f( const idCmdArgs &args ) { const char *key, *value; float yaw; idVec3 org; idPlayer *player; idDict dict; int i; const char *classname; player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk( false ) ) { return; } if ( args.Argc() < 2 || !args.Argc() & 1 ) { // must always have an even number of arguments gameLocal.Printf( "usage: spawn classname []\n" ); return; } int numberToSpawn = atoi(args.Argv(2)); classname = args.Argv( 1 ); dict.Set( "classname", classname ); for (int ix=0; ixviewAngles.yaw + gameLocal.random.CRandomFloat()*10; dict.Set( "angle", va( "%f", yaw + 180 ) ); org = player->GetPhysics()->GetOrigin() + idAngles( 0, yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 )*(10+gameLocal.random.RandomFloat()*50); dict.Set( "origin", org.ToString() ); for( i = 3; i < args.Argc() - 1; i += 2 ) { key = args.Argv( i ); value = args.Argv( i + 1 ); dict.Set( key, value ); } //HACK if (!idStr::Icmpn(classname, "movable_", 8)) { idVec3 vel = idAngles(0,yaw,0).ToForward() * gameLocal.random.RandomFloat()*150; dict.SetVector("init_velocity", vel); } gameLocal.SpawnEntityDef( dict ); } } void Cmd_ListDictionary_f( const idCmdArgs &args ) { const idDict *dict=NULL; idEntity *ent=NULL; const char *classname=NULL; idStr key; const idKeyValue *kv=NULL; if ( !gameLocal.CheatsOk() ) { return; } if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: Dict [key]\n"); return; } // get classname classname = args.Argv( 1 ); dict = gameLocal.FindEntityDefDict( classname ); if (!dict) { gameLocal.Printf("Unknown entity definition: %s\n", classname); return; } // handle specific key if (args.Argc()==3) { key = args.Argv( 2 ); kv = dict->FindKey(key); if (kv) { gameLocal.Printf(" %30s %s\n", kv->GetKey().c_str(), kv->GetValue().c_str()); } } else { int num = dict->GetNumKeyVals(); for (int ix=0; ixGetKeyVal(ix); if (kv) { gameLocal.Printf(" %30s %s\n", kv->GetKey().c_str(), kv->GetValue().c_str()); } } } } // id has a version of this as well, but ours is better // Trigger all entities matching given name or class void Cmd_HHTrigger_f( const idCmdArgs &args ) { idVec3 origin; idAngles angles; idPlayer *player; const char *classname; player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk() ) { return; } if ( args.Argc() != 2 ) { gameLocal.Printf( "usage: trigger \n" ); return; } // get name/class of entity classname = args.Argv( 1 ); // find entity by name or classname int count=0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if ( ent && (!idStr::Icmp(ent->name, classname) || !idStr::Icmp(ent->GetClassname(), classname)) ) { ent->Signal( SIG_TRIGGER ); ent->ProcessEvent( &EV_Activate, player ); ent->TriggerGuis(); count++; } } // failed by name. try by entity number if ( count == 0 ) { int entityNumber = atoi(args.Argv( 1 )); if ( entityNumber < gameLocal.num_entities ) { idEntity *ent = gameLocal.entities[entityNumber]; if ( ent ) { ent->Signal( SIG_TRIGGER ); ent->ProcessEvent( &EV_Activate, player ); ent->TriggerGuis(); } } } gameLocal.Printf( "Triggered %d entities\n", count ); } // CJRPERSISTENTMERGE: id has a version of this as well, but ours is better // Remove all of a specified class from the level void Cmd_HHRemove_f( const idCmdArgs &args ) { idPlayer *player; const char *classname; if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: remove \n"); return; } player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk() ) { return; } // get name/class of entity classname = args.Argv( 1 ); // find entity by name or classname int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if ( ent && (!idStr::Icmp(ent->name, classname) || !idStr::Icmp(ent->GetClassname(), classname)) ) { ent->PostEventMS( &EV_Remove, 0 ); count++; } } gameLocal.Printf("%d %s entities removed\n", count, classname); } // Hide all of a specified class or a specific name void Cmd_Hide_f( const idCmdArgs &args ) { idPlayer *player; idEntity *ent = NULL; const char *classname; if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: hide \n"); return; } player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk() ) { return; } // get name/class of entity classname = args.Argv( 1 ); // find entity by name or classname int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if ( ent && (!idStr::Icmp(ent->name, classname) || !idStr::Icmp(ent->GetClassname(), classname)) ) { ent->Hide(); count++; } } gameLocal.Printf("%d %s entities hidden\n", count, classname); } // Show all of a specified class or a specific name void Cmd_Show_f( const idCmdArgs &args ) { idPlayer *player; idEntity *ent = NULL; const char *classname; if ( args.Argc() < 2 ) { gameLocal.Printf("Usage: show \n"); return; } player = gameLocal.GetLocalPlayer(); if ( !player || !gameLocal.CheatsOk() ) { return; } // get name/class of entity classname = args.Argv( 1 ); // find entity by name or classname int count = 0; for (int i = 0; i < gameLocal.num_entities; i++) { idEntity *ent = gameLocal.entities[i]; if ( ent && (!idStr::Icmp(ent->name, classname) || !idStr::Icmp(ent->GetClassname(), classname)) ) { ent->Show(); count++; } } gameLocal.Printf("%d %s entities shown\n", count, classname); } /* ============ Cmd_SpawnDebrisMass_f ============ */ void Cmd_SpawnDebrisMass_f(const idCmdArgs &args) { const char *temp; if ( !gameLocal.CheatsOk() ) { return; } if ( args.Argc() < 2 ) { gameLocal.Printf( "Usage: SpawnDebrisMass entityDef\n" ); return; } temp = args.Argv( 1 ); hhUtils::SpawnDebrisMass( temp, vec3_origin ); } void Cmd_SetPlayerGravity_f( const idCmdArgs &args ) { idVec3 gravDirection; idStr temp; hhPlayer *player; int argIndex = 0; if ( args.Argc() < 3 ) { gameLocal.Printf("Usage: SetPlayerGravity \n"); return; } player = static_cast( gameLocal.GetLocalPlayer() ); if ( !player || !gameLocal.CheatsOk() ) { return; } for( int ix = 0; ix < 3; ++ix ) { temp = args.Argv( ++argIndex ); if( temp.Icmp("-") == 0 ) { temp = args.Argv( ++argIndex ); gravDirection[ix] = -1 * atof( temp.c_str() ); } else { gravDirection[ix] = atof( temp.c_str() ); } } if( player->GetPhysics() ) { player->OrientToGravity( true ); player->GetPhysics()->SetGravity( gravDirection ); } } //========================================================================= // Cmd_ClosePortal_f // // Closes a portal if it intersects my current bounds (for testing) //========================================================================= void Cmd_ClosePortal_f(const idCmdArgs &args) { if (!gameLocal.CheatsOk()) { return; } idPlayer *player = gameLocal.GetLocalPlayer(); qhandle_t areaPortal = gameRenderWorld->FindPortal( player->GetPhysics()->GetAbsBounds() ); if ( areaPortal ) { gameLocal.SetPortalState( areaPortal, PS_BLOCK_ALL ); gameLocal.Printf("Portal closed\n"); } } //========================================================================= // Cmd_OpenPortal_f // // Opens a portal if it intersects my current bounds (for testing) //========================================================================= void Cmd_OpenPortal_f(const idCmdArgs &args) { if (!gameLocal.CheatsOk()) { return; } idPlayer *player = gameLocal.GetLocalPlayer(); qhandle_t areaPortal = gameRenderWorld->FindPortal( player->GetPhysics()->GetAbsBounds() ); if ( areaPortal ) { gameLocal.SetPortalState( areaPortal, PS_BLOCK_NONE ); gameLocal.Printf("Portal opened\n"); } } //========================================================================= // // Cmd_CallScriptFunc_f // //========================================================================= void Cmd_CallScriptFunc_f( const idCmdArgs &args ) { if( !gameLocal.CheatsOk() ) { return; } if( args.Argc() <= 1 ) { gameLocal.Printf( "Usage: call