BVB Source Codes

CRYENGINE Show VehicleCVars.cpp Source code

Return Download CRYENGINE: download VehicleCVars.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: VehicleSystem CVars
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - 02:01:2007  12:47 : Created by MichaelR
  11.  
  12. *************************************************************************/
  13.  
  14. #include "StdAfx.h"
  15. #include "VehicleCVars.h"
  16. #include "VehicleSystem.h"
  17. #include "Vehicle.h"
  18.  
  19. CVehicleCVars* CVehicleCVars::s_pThis = 0;
  20.  
  21. #if ENABLE_VEHICLE_DEBUG
  22. void OnDebugDrawVarChanged(ICVar* pVar);
  23. #endif
  24.  
  25. void OnDriverControlledGunsChanged(ICVar* pVar);
  26. void CmdExitPlayer(IConsoleCmdArgs* pArgs);
  27.  
  28. //------------------------------------------------------------------------
  29. CVehicleCVars::CVehicleCVars()
  30. {
  31.         assert(s_pThis == 0);
  32.         s_pThis = this;
  33.  
  34.         IConsole* pConsole = gEnv->pConsole;
  35.         assert(pConsole);
  36.  
  37. #if ENABLE_VEHICLE_DEBUG
  38.         // debug draw
  39.         REGISTER_STRING("v_debugVehicle", "", 0, "Vehicle entity name to use for debugging output");
  40.         REGISTER_CVAR_CB(v_draw_components, 0, VF_DUMPTODISK, "Enables/disables display of components and their damage count", OnDebugDrawVarChanged);
  41.         REGISTER_CVAR_CB(v_draw_helpers, 0, 0, "Enables/disables display of vehicle helpers", OnDebugDrawVarChanged);
  42.         REGISTER_CVAR_CB(v_draw_seats, 0, 0, "Enables/disables display of seat positions", OnDebugDrawVarChanged);
  43.         REGISTER_CVAR(v_draw_tm, 0, 0, "Enables/disables drawing of local part matrices");
  44.         REGISTER_CVAR(v_draw_passengers, 0, VF_CHEAT, "draw passenger TMs set by VehicleSeat");
  45.         REGISTER_CVAR(v_debugdraw, 0, VF_DUMPTODISK,
  46.                       "Displays vehicle status info on HUD\n"
  47.                       "Values:\n"
  48.                       "1:  common stuff\n"
  49.                       "2:  vehicle particles\n"
  50.                       "3:  parts\n"
  51.                       "4:  views\n"
  52.                       "6:  parts + partIds\n"
  53.                       "7:  parts + transformations and bboxes\n"
  54.                       "8:  component damage\n"
  55.                       "10: vehicle editor");
  56.         REGISTER_CVAR(v_debug_mem, 0, 0, "display memory statistic for vehicles");
  57.  
  58.         REGISTER_CVAR(v_debugViewDetach, 0, VF_CHEAT | VF_DUMPTODISK, "Freeze vehicle camera position, (1) fixed rotation, (2) track the vehicle");
  59.         REGISTER_CVAR(v_debugViewAbove, 0, VF_CHEAT | VF_DUMPTODISK, "Debug camera, looking down on vehicle");
  60.         REGISTER_CVAR(v_debugViewAboveH, 10.f, VF_CHEAT | VF_DUMPTODISK, "Debug camera, looking down on vehicle, height ");
  61.         REGISTER_CVAR(v_debugCollisionDamage, 0, VF_CHEAT, "Enable debug output for vehicle collisions");
  62.  
  63.         REGISTER_CVAR(v_debug_flip_over, 0, VF_CHEAT, "flip over the current vehicle that the player is driving");
  64.         REGISTER_CVAR(v_debug_reorient, 0, VF_CHEAT, "reset the orientation of the vehicle that the player is driving so that it is upright again");
  65.  
  66.         REGISTER_COMMAND("v_dump_classes", CVehicleSystem::DumpClasses, 0, "Outputs a list of vehicle classes in use");
  67. #endif
  68.  
  69.         // dev vars
  70.         REGISTER_CVAR(v_lights, 2, 0, "Controls vehicle lights.\n"
  71.                                       "0: disable all lights\n"
  72.                                       "1: enable lights only for local player\n"
  73.                                       "2: enable all lights");
  74.         REGISTER_CVAR(v_lights_enable_always, 0, VF_CHEAT, "Vehicle lights are always on (debugging)");
  75.         REGISTER_CVAR(v_autoDisable, 1, VF_CHEAT, "Enables/disables vehicle autodisabling");
  76.         REGISTER_CVAR(v_set_passenger_tm, 1, VF_CHEAT, "enable/disable passenger entity tm update");
  77.         REGISTER_CVAR(v_disable_hull, 0, 0, "Disable hull proxies");
  78.         REGISTER_CVAR(v_staticTreadDeform, 1, 0, "enables physics-based deforming of threads even for *non-moving* vehicles");
  79.         REGISTER_CVAR(v_show_all, 0, VF_CHEAT, "");
  80.         REGISTER_CVAR(v_transitionAnimations, 1, VF_CHEAT, "Enables enter/exit transition animations for vehicles");
  81.         REGISTER_CVAR(v_playerTransitions, 1, VF_CHEAT, "Enables enter/exit transition animations for vehicles");
  82.         REGISTER_CVAR(v_ragdollPassengers, 0, VF_CHEAT, "Forces vehicle passenger to detach and ragdoll when they die inside of a vehicle");
  83.         REGISTER_CVAR(v_goliathMode, 0, VF_CHEAT, "Makes all vehicles invincible");
  84.         REGISTER_CVAR(v_enableMannequin, 1, VF_CHEAT, "Enables enter/exit transition animations for vehicles");
  85.         REGISTER_CVAR(v_serverControlled, 0, VF_CHEAT | VF_REQUIRE_LEVEL_RELOAD, "Makes the vehicles server authoritative, clients only send inputs to the server who then drives the vehicles");
  86.         REGISTER_CVAR(v_clientPredict, 1, VF_CHEAT, "Enable client-side prediction on vehicle movement");
  87.         REGISTER_CVAR(v_clientPredictSmoothing, 1, VF_CHEAT, "Enable client-side prediction smoothing on vehicle movement");
  88.         REGISTER_CVAR(v_testClientPredict, 0, VF_CHEAT, "Test client-side prediction on a listen server with no clients, the value represents the number of frames to rewind and replay");
  89.         REGISTER_CVAR(v_clientPredictSmoothingConst, 8.0f, VF_CHEAT, "The amount of smoothing to use, lower values result in smoothing looking movement but more lag behind the true position");
  90.         REGISTER_CVAR(v_clientPredictAdditionalTime, 0.033f, VF_CHEAT, "Additional time offset to calibrate client prediction, will be added to ping and p_net_interp cvar");
  91.         REGISTER_CVAR(v_clientPredictMaxTime, 0.5f, VF_CHEAT, "The maximum time the client can predict ahead of the server position (should be roughly equal to the maximum ping we expect in the real world)");
  92.  
  93.         // for tweaking
  94.         REGISTER_CVAR(v_slipSlopeFront, 0.f, VF_CHEAT, "coefficient for slip friction slope calculation (front wheels)");
  95.         REGISTER_CVAR(v_slipSlopeRear, 0.f, VF_CHEAT, "coefficient for slip friction slope calculation (rear wheels)");
  96.         REGISTER_CVAR(v_slipFrictionModFront, 0.f, VF_CHEAT, "if non-zero, used as slip friction modifier (front wheels)");
  97.         REGISTER_CVAR(v_slipFrictionModRear, 0.f, VF_CHEAT, "if non-zero, used as slip friction modifier (rear wheels)");
  98.  
  99.         REGISTER_CVAR(v_FlippedExplosionTimeToExplode, 20.f, VF_CHEAT, "The number of seconds to wait after a vehicle is flipped to attempt exploding");
  100.         REGISTER_CVAR(v_FlippedExplosionPlayerMinDistance, 25.f, VF_CHEAT, "If a player is within this distance then don't explode yet");
  101.         REGISTER_CVAR(v_FlippedExplosionRetryTimeMS, 10000, VF_CHEAT, "If a nearby player blocked explosion then try again after this time period");
  102.  
  103.         REGISTER_COMMAND("v_reload_system", "VehicleSystem.ReloadVehicleSystem()", 0, "Reloads VehicleSystem script");
  104.         REGISTER_COMMAND("v_exit_player", CmdExitPlayer, VF_CHEAT, "Makes the local player exit his current vehicle.");
  105.  
  106.         REGISTER_CVAR(v_disableEntry, 0, 0, "Don't allow players to enter vehicles");
  107.  
  108.         REGISTER_CVAR(v_vehicle_quality, 4, 0, "Geometry/Physics quality (1-lowspec, 4-highspec)");
  109.         REGISTER_CVAR_CB(v_driverControlledMountedGuns, 1, VF_CHEAT, "Specifies if the driver can control the vehicles mounted gun when driving without gunner.", OnDriverControlledGunsChanged);
  110.         REGISTER_CVAR(v_independentMountedGuns, 1, 0, "Whether mounted gunners operate their turret independently from the parent vehicle");
  111.  
  112.         REGISTER_CVAR(v_debugSuspensionIK, 0, 0, "Debug draw the suspension ik");
  113. }
  114.  
  115. //------------------------------------------------------------------------
  116. CVehicleCVars::~CVehicleCVars()
  117. {
  118.         assert(s_pThis != 0);
  119.         s_pThis = 0;
  120.  
  121.         IConsole* pConsole = gEnv->pConsole;
  122.  
  123.         pConsole->RemoveCommand("v_tpvDist");
  124.         pConsole->RemoveCommand("v_tpvHeight");
  125.         pConsole->RemoveCommand("v_reload_system");
  126.         pConsole->RemoveCommand("v_exit_player");
  127.  
  128. #if ENABLE_VEHICLE_DEBUG
  129.         pConsole->UnregisterVariable("v_debugVehicle", true);
  130.         pConsole->UnregisterVariable("v_draw_components", true);
  131.         pConsole->UnregisterVariable("v_draw_helpers", true);
  132.         pConsole->UnregisterVariable("v_draw_seats", true);
  133.         pConsole->UnregisterVariable("v_draw_tm", true);
  134.         pConsole->UnregisterVariable("v_draw_passengers", true);
  135.         pConsole->UnregisterVariable("v_debugdraw", true);
  136.         pConsole->UnregisterVariable("v_debug_mem", true);
  137. #endif
  138.  
  139.         pConsole->UnregisterVariable("v_lights", true);
  140.         pConsole->UnregisterVariable("v_lights_enable_always", true);
  141.         pConsole->UnregisterVariable("v_autoDisable", true);
  142.         pConsole->UnregisterVariable("v_set_passenger_tm", true);
  143.         pConsole->UnregisterVariable("v_disable_hull", true);
  144.         pConsole->UnregisterVariable("v_staticTreadDeform", true);
  145.         pConsole->UnregisterVariable("v_transitionAnimations", true);
  146.         pConsole->UnregisterVariable("v_ragdollPassengers", true);
  147.         pConsole->UnregisterVariable("v_goliathMode", true);
  148.  
  149.         pConsole->UnregisterVariable("v_slipSlopeFront", true);
  150.         pConsole->UnregisterVariable("v_slipSlopeRear", true);
  151.         pConsole->UnregisterVariable("v_slipFrictionModFront", true);
  152.         pConsole->UnregisterVariable("v_slipFrictionModRear", true);
  153.  
  154.         pConsole->UnregisterVariable("v_vehicle_quality", true);
  155.         pConsole->UnregisterVariable("v_driverControlledMountedGuns", true);
  156.  
  157.         pConsole->UnregisterVariable("v_debugSuspensionIK", true);
  158. }
  159.  
  160. #if ENABLE_VEHICLE_DEBUG
  161. //------------------------------------------------------------------------
  162. void OnDebugDrawVarChanged(ICVar* pVar)
  163. {
  164.         if (pVar->GetIVal())
  165.         {
  166.                 IVehicleSystem* pVehicleSystem = gEnv->pGameFramework->GetIVehicleSystem();
  167.  
  168.                 IVehicleIteratorPtr pIter = pVehicleSystem->CreateVehicleIterator();
  169.                 while (IVehicle* pVehicle = pIter->Next())
  170.                 {
  171.                         pVehicle->NeedsUpdate();
  172.                 }
  173.         }
  174. }
  175. #endif
  176.  
  177. //------------------------------------------------------------------------
  178. void OnDriverControlledGunsChanged(ICVar* pVar)
  179. {
  180.         if (gEnv->bMultiplayer)
  181.                 return;
  182.  
  183.         if (IActor* pActor = CCryAction::GetCryAction()->GetClientActor())
  184.         {
  185.                 if (IVehicle* pVehicle = pActor->GetLinkedVehicle())
  186.                 {
  187.                         SVehicleEventParams params;
  188.                         params.bParam = (pVar->GetIVal() != 0);
  189.  
  190.                         pVehicle->BroadcastVehicleEvent(eVE_ToggleDriverControlledGuns, params);
  191.                 }
  192.         }
  193. }
  194.  
  195. //------------------------------------------------------------------------
  196. void CmdExitPlayer(IConsoleCmdArgs* pArgs)
  197. {
  198.         if (IActor* pActor = CCryAction::GetCryAction()->GetClientActor())
  199.         {
  200.                 if (IVehicle* pVehicle = pActor->GetLinkedVehicle())
  201.                         pVehicle->ExitVehicleAtPosition(pActor->GetEntityId(), ZERO);
  202.         }
  203. }
  204.  
downloadVehicleCVars.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top