Weapon offset config

Implemented configurable offsets for weapons so they can be tuned without changing code
This commit is contained in:
Simon 2020-07-11 11:01:27 +01:00
parent 632ae12597
commit e8cb0d91f4
7 changed files with 155 additions and 11 deletions

View file

@ -1785,6 +1785,29 @@ extern vmCvar_t cg_waitForFire;
extern vmCvar_t cg_loadWeaponSelect;
//VR Weapon Offsets
extern vmCvar_t vr_weapon_adjustment_1;
extern vmCvar_t vr_weapon_adjustment_2;
extern vmCvar_t vr_weapon_adjustment_3;
extern vmCvar_t vr_weapon_adjustment_4;
extern vmCvar_t vr_weapon_adjustment_5;
extern vmCvar_t vr_weapon_adjustment_6;
extern vmCvar_t vr_weapon_adjustment_7;
extern vmCvar_t vr_weapon_adjustment_8;
extern vmCvar_t vr_weapon_adjustment_9;
extern vmCvar_t vr_weapon_adjustment_10;
extern vmCvar_t vr_weapon_adjustment_11;
extern vmCvar_t vr_weapon_adjustment_12;
extern vmCvar_t vr_weapon_adjustment_13;
extern vmCvar_t vr_weapon_adjustment_14;
extern vmCvar_t vr_weapon_adjustment_15;
extern vmCvar_t vr_weapon_adjustment_16;
extern vmCvar_t vr_weapon_adjustment_17;
extern vmCvar_t vr_weapon_adjustment_18;
extern vmCvar_t vr_weapon_adjustment_19;
extern vmCvar_t vr_weapon_adjustment_20;
// NERVE - SMF - Wolf multiplayer configuration cvars
extern vmCvar_t mp_playerType;
extern vmCvar_t mp_weapon;

View file

@ -272,6 +272,27 @@ vmCvar_t cg_waitForFire;
vmCvar_t cg_loadWeaponSelect;
vmCvar_t vr_weapon_adjustment_1;
vmCvar_t vr_weapon_adjustment_2;
vmCvar_t vr_weapon_adjustment_3;
vmCvar_t vr_weapon_adjustment_4;
vmCvar_t vr_weapon_adjustment_5;
vmCvar_t vr_weapon_adjustment_6;
vmCvar_t vr_weapon_adjustment_7;
vmCvar_t vr_weapon_adjustment_8;
vmCvar_t vr_weapon_adjustment_9;
vmCvar_t vr_weapon_adjustment_10;
vmCvar_t vr_weapon_adjustment_11;
vmCvar_t vr_weapon_adjustment_12;
vmCvar_t vr_weapon_adjustment_13;
vmCvar_t vr_weapon_adjustment_14;
vmCvar_t vr_weapon_adjustment_15;
vmCvar_t vr_weapon_adjustment_16;
vmCvar_t vr_weapon_adjustment_17;
vmCvar_t vr_weapon_adjustment_18;
vmCvar_t vr_weapon_adjustment_19;
vmCvar_t vr_weapon_adjustment_20;
// NERVE - SMF - Wolf multiplayer configuration cvars
vmCvar_t mp_playerType;
vmCvar_t mp_team;
@ -468,6 +489,30 @@ cvarTable_t cvarTable[] = {
{ &cg_expectedhunkusage, "com_expectedhunkusage", "0", CVAR_ROM},
//Default Weapon adjustments - these WILL be overridden
{ &vr_weapon_adjustment_1, "vr_weapon_adjustment_1", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_2, "vr_weapon_adjustment_2", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_3, "vr_weapon_adjustment_3", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_4, "vr_weapon_adjustment_4", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_5, "vr_weapon_adjustment_5", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_6, "vr_weapon_adjustment_6", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_7, "vr_weapon_adjustment_7", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_8, "vr_weapon_adjustment_8", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_9, "vr_weapon_adjustment_9", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_10, "vr_weapon_adjustment_10", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_11, "vr_weapon_adjustment_11", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_12, "vr_weapon_adjustment_12", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_13, "vr_weapon_adjustment_13", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_14, "vr_weapon_adjustment_14", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_15, "vr_weapon_adjustment_15", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_16, "vr_weapon_adjustment_16", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_17, "vr_weapon_adjustment_17", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_18, "vr_weapon_adjustment_18", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_19, "vr_weapon_adjustment_19", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
{ &vr_weapon_adjustment_20, "vr_weapon_adjustment_20", "0.62,-9.8,11.3,-16.1", CVAR_ARCHIVE},
// NERVE - SMF
{ &mp_playerType, "mp_playerType", "0", 0 },
{ &mp_team, "mp_team", "0", 0 },

View file

@ -1793,24 +1793,44 @@ static void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) {
/*
==============
CG_CalculateWeaponPosition
CG_CalculateWeaponPositionAndScale
==============
*/
static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
static float CG_CalculateWeaponPositionAndScale( vec3_t origin, vec3_t angles ) {
CG_CalculateVRWeaponPosition(origin, angles);
//Now move weapon closer to proper origin
//Now adjust weapon: scale, right, up, forward
vec3_t offset;
float scale=1.0f;
if (cg.predictedPlayerState.weapon != 0)
{
char cvar_name[64];
Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", cg.predictedPlayerState.weapon);
char weapon_adjustment[256];
trap_Cvar_VariableStringBuffer(cvar_name, weapon_adjustment, 256);
vec3_t temp_offset;
VectorClear(temp_offset);
sscanf(weapon_adjustment, "%f,%f,%f,%f", &scale, &(temp_offset[0]), &(temp_offset[1]), &(temp_offset[2]));
VectorScale(temp_offset, scale, offset);
//int lrOffset = (( r_lefthand->value != 0.0f ) ? -1 : 1);
//offset[1] *= lrOffset;
}
//Now move weapon closer to proper origin
vec3_t forward, right, up;
AngleVectors( angles, forward, right, up );
VectorMA( origin, -10, forward, origin );
VectorMA( origin, 7, up, origin );
VectorMA( origin, -6, right, origin );
return;
VectorMA( origin, offset[2], forward, origin );
VectorMA( origin, offset[1], up, origin );
VectorMA( origin, offset[0], right, origin );
return scale;
float scale;
int delta;
float fracsin, leanscale;
@ -3134,7 +3154,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
memset( &hand, 0, sizeof( hand ) );
// set up gun position
CG_CalculateWeaponPosition( hand.origin, angles );
float scale = CG_CalculateWeaponPositionAndScale( hand.origin, angles );
gunoff[0] = cg_gun_x.value;
gunoff[1] = cg_gun_y.value;
@ -3161,7 +3181,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
//scale the whole model (hand and weapon)
for ( int i = 0; i < 3; i++ ) {
VectorScale( hand.axis[i], cg_weaponScale.value, hand.axis[i] );
VectorScale( hand.axis[i], scale, hand.axis[i] );
}
// add everything onto the hand

View file

@ -220,7 +220,7 @@ void Sys_PumpEvents( void );
#elif defined __axp__
#define CPUSTRING "linux-alpha"
#elif defined ARM
#define CPUSTRING "linux-arm"
#define CPUSTRING "Oculus Quest"
#else
#define CPUSTRING "linux-other"
#endif

View file

@ -2007,6 +2007,9 @@ void Com_Init( char *commandLine ) {
Cbuf_AddText( "exec autoexec.cfg\n" );
//Execute last to overwrite wepon locations with our desired adjustments
Cbuf_AddText( "exec weapons.cfg\n" );
Cbuf_Execute();
// override anything from the config files with command line args

46
assets/weapons.cfg Normal file
View file

@ -0,0 +1,46 @@
// Weapon offsets - This is the default for the weapon models
// Values are: scale, right, up, forward
//Knife
seta vr_weapon_adjustment_1 "0.5,-8.0,8.0,-15.0"
//Luger
seta vr_weapon_adjustment_2 "0.62,-9.8,14.0,-16.1"
//Panzer Faust (Rocket Launcher)
seta vr_weapon_adjustment_7 "0.95,-2.8,10.0,-1.1"
//Flame Thrower
seta vr_weapon_adjustment_9 "0.7,-9.8,6.0,-11.0"
///////////////////////////////////////////////////////////////////
// Weapon IDs
// WP_KNIFE, // 1
// // German weapons
// WP_LUGER, // 2
// WP_MP40, // 3
// WP_MAUSER, // 4
// WP_FG42, // 5
// WP_GRENADE_LAUNCHER, // 6
// WP_PANZERFAUST, // 7
// WP_VENOM, // 8
// WP_FLAMETHROWER, // 9
// WP_TESLA, // 10
// // American equivalents
// WP_COLT, // 11 equivalent american weapon to german luger
// WP_THOMPSON, // 12 equivalent american weapon to german mp40
// WP_GARAND, // 13 equivalent american weapon to german mauser
// WP_GRENADE_PINEAPPLE, // 14
// // secondary fire weapons
// WP_SNIPERRIFLE, // 15
// WP_SNOOPERSCOPE, // 16
// WP_FG42SCOPE, // 17 fg42 alt fire
// // more weapons
// WP_STEN, // 18 silenced sten sub-machinegun
// WP_SILENCER, // 19 // used to be sp5
// WP_AKIMBO, // 20 //----(SA) added

View file

@ -167,6 +167,13 @@ import static android.system.Os.setenv;
//Configuration files
copy_asset("/sdcard/RTCWQuest", "commandline.txt");
//Make the directories
new File("/sdcard/RTCWQuest/Main").mkdirs();
//Copy the weapon adjustment config
copy_asset("/sdcard/RTCWQuest/Main", "weapons.cfg");
//Read these from a file and pass through
commandLineParams = new String("rtcw");