mirror of
https://github.com/DrBeef/Doom3Quest.git
synced 2025-02-21 11:31:34 +00:00
Visible flashlight in holster
This commit is contained in:
parent
6cfe71c10b
commit
c6d666aba0
8 changed files with 166 additions and 44 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.drbeef.doom3quest"
|
||||
android:versionCode="3"
|
||||
android:versionName="0.0.9" android:installLocation="auto" >
|
||||
android:versionCode="4"
|
||||
android:versionName="0.0.10" android:installLocation="auto" >
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t weaponangles_delta;
|
||||
|
||||
vec3_t flashlightHolsterOrigin; // Where the flashlight can be picked up from
|
||||
vec3_t flashlightHolsterOffset; // Where the flashlight can be picked up from
|
||||
|
||||
|
||||
vec3_t current_weaponoffset;
|
||||
|
|
|
@ -274,18 +274,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
}
|
||||
}
|
||||
|
||||
if (pVRClientInfo->weaponid != -1 &&
|
||||
pVRClientInfo->weaponid != 11)
|
||||
{
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(pVRClientInfo->right_handed ? 0.25f : -0.25f, 0.0f,
|
||||
rotateAboutOrigin(pVRClientInfo->right_handed ? -0.2f : 0.2f, 0.0f,
|
||||
-pVRClientInfo->hmdorientation[YAW], v);
|
||||
pVRClientInfo->flashlightHolsterOrigin[0] = pVRClientInfo->hmdposition[0] + v[0];
|
||||
pVRClientInfo->flashlightHolsterOrigin[1] = pVRClientInfo->hmdposition[1] / 2.0f; // half way down body "waist"
|
||||
pVRClientInfo->flashlightHolsterOrigin[2] = (pVRClientInfo->hmdposition[2] + v[1]);
|
||||
pVRClientInfo->flashlightHolsterOffset[0] = -v[0];
|
||||
pVRClientInfo->flashlightHolsterOffset[1] = -pVRClientInfo->hmdposition[1] * 0.45f; // almost half way down body "waist"
|
||||
pVRClientInfo->flashlightHolsterOffset[2] = -v[1];
|
||||
|
||||
float distance = sqrtf(
|
||||
powf(pVRClientInfo->flashlightHolsterOrigin[0] - pWeapon->HeadPose.Pose.Position.x, 2) +
|
||||
powf(pVRClientInfo->flashlightHolsterOrigin[1] - pWeapon->HeadPose.Pose.Position.y, 2) +
|
||||
powf(pVRClientInfo->flashlightHolsterOrigin[2] - pWeapon->HeadPose.Pose.Position.z, 2));
|
||||
powf((pVRClientInfo->hmdposition[0] + pVRClientInfo->flashlightHolsterOffset[0]) - pWeapon->HeadPose.Pose.Position.x, 2) +
|
||||
powf((pVRClientInfo->hmdposition[1] + pVRClientInfo->flashlightHolsterOffset[1]) - pWeapon->HeadPose.Pose.Position.y, 2) +
|
||||
powf((pVRClientInfo->hmdposition[2] + pVRClientInfo->flashlightHolsterOffset[2]) - pWeapon->HeadPose.Pose.Position.z, 2));
|
||||
|
||||
if (distance > FLASHLIGHT_HOLSTER_DISTANCE) {
|
||||
canGrabFlashlight = false;
|
||||
|
|
|
@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "framework/async/NetworkSystem.h"
|
||||
#include "framework/DeclEntityDef.h"
|
||||
#include "renderer/RenderSystem.h"
|
||||
#include "renderer/ModelManager.h"
|
||||
|
||||
#include "gamesys/SysCvar.h"
|
||||
#include "script/Script_Thread.h"
|
||||
|
@ -44,6 +45,16 @@ If you have questions concerning this license or the applicable additional terms
|
|||
const int ASYNC_PLAYER_INV_AMMO_BITS = idMath::BitsForInteger( 999 ); // 9 bits to cover the range [0, 999]
|
||||
const int ASYNC_PLAYER_INV_CLIP_BITS = -7; // -7 bits to cover the range [-1, 60]
|
||||
|
||||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, float out[2])
|
||||
{
|
||||
out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y;
|
||||
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -1037,9 +1048,12 @@ idPlayer::idPlayer() {
|
|||
weapon_soulcube = -1;
|
||||
weapon_pda = -1;
|
||||
weapon_fists = -1;
|
||||
weapon_flashlight = -1;
|
||||
showWeaponViewModel = true;
|
||||
|
||||
skin = NULL;
|
||||
flashlightModelDefHandle = -1;
|
||||
|
||||
skin = NULL;
|
||||
powerUpSkin = NULL;
|
||||
baseSkinName = "";
|
||||
|
||||
|
@ -1214,6 +1228,7 @@ void idPlayer::Init( void ) {
|
|||
weapon_soulcube = SlotForWeapon( "weapon_soulcube" );
|
||||
weapon_pda = SlotForWeapon( "weapon_pda" );
|
||||
weapon_fists = SlotForWeapon( "weapon_fists" );
|
||||
weapon_flashlight = SlotForWeapon( "weapon_flashlight" );
|
||||
showWeaponViewModel = GetUserInfo()->GetBool( "ui_showGun" );
|
||||
|
||||
|
||||
|
@ -1411,6 +1426,8 @@ void idPlayer::Init( void ) {
|
|||
}
|
||||
|
||||
cvarSystem->SetCVarBool( "ui_chat", false );
|
||||
|
||||
SetupFlashlightHolster();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2086,6 +2103,10 @@ void idPlayer::Restore( idRestoreGame *savefile ) {
|
|||
if ( hud ) {
|
||||
hud->SetStateString( "message", "" );
|
||||
}
|
||||
|
||||
//Have to do this for loaded games
|
||||
weapon_flashlight = SlotForWeapon( "weapon_flashlight" );
|
||||
SetupFlashlightHolster();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -6211,6 +6232,81 @@ void idPlayer::StartFxOnBone( const char *fx, const char *bone ) {
|
|||
idEntityFx::StartFx( fx, &offset, &axis, this, true );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
idPlayer::SetupFlashlightSlot
|
||||
==============
|
||||
*/
|
||||
void idPlayer::SetupFlashlightHolster()
|
||||
{
|
||||
memset( &flashlightRenderEntity, 0, sizeof( flashlightRenderEntity ) );
|
||||
flashlightRenderEntity.hModel = renderModelManager->FindModel( "models/items/flashlight/flashlight2_world.lwo" );
|
||||
if( flashlightRenderEntity.hModel )
|
||||
{
|
||||
flashlightRenderEntity.hModel->Reset();
|
||||
flashlightRenderEntity.bounds = flashlightRenderEntity.hModel->Bounds( &flashlightRenderEntity );
|
||||
}
|
||||
flashlightRenderEntity.shaderParms[ SHADERPARM_RED ] = 1.0f;
|
||||
flashlightRenderEntity.shaderParms[ SHADERPARM_GREEN ] = 1.0f;
|
||||
flashlightRenderEntity.shaderParms[ SHADERPARM_BLUE ] = 1.0f;
|
||||
flashlightRenderEntity.shaderParms[ SHADERPARM_ALPHA ] = 0.75f;
|
||||
flashlightRenderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = 0.0f;
|
||||
flashlightRenderEntity.shaderParms[5] = 0.0f;
|
||||
flashlightRenderEntity.shaderParms[6] = 0.0f;
|
||||
flashlightRenderEntity.shaderParms[7] = 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
idPlayer::UpdateFlashlightHolster
|
||||
==============
|
||||
*/
|
||||
void idPlayer::UpdateFlashlightHolster()
|
||||
{
|
||||
bool hasFlashlight = !( ( weapon_flashlight < 0 ) || ( inventory.weapons & ( 1 << weapon_flashlight ) ) == 0 );
|
||||
if( hasFlashlight &&
|
||||
currentWeapon != weapon_flashlight &&
|
||||
flashlightRenderEntity.hModel &&
|
||||
pVRClientInfo != nullptr)
|
||||
{
|
||||
idVec3 holsterOffset( pVRClientInfo->flashlightHolsterOffset[2],
|
||||
pVRClientInfo->flashlightHolsterOffset[0],
|
||||
pVRClientInfo->flashlightHolsterOffset[1]);
|
||||
|
||||
float r[2];
|
||||
rotateAboutOrigin(holsterOffset.x, holsterOffset.y, viewAngles.yaw - pVRClientInfo->hmdorientation[YAW], r);
|
||||
holsterOffset.x = -r[0];
|
||||
holsterOffset.y = -r[1];
|
||||
holsterOffset *= cvarSystem->GetCVarFloat( "vr_worldscale" );
|
||||
flashlightRenderEntity.origin = firstPersonViewOrigin + holsterOffset;
|
||||
|
||||
flashlightRenderEntity.entityNum = ENTITYNUM_NONE;
|
||||
|
||||
flashlightRenderEntity.axis = idAngles(-60, 90, 0).ToMat3() * firstPersonViewAxis;
|
||||
|
||||
flashlightRenderEntity.allowSurfaceInViewID = entityNumber + 1;
|
||||
flashlightRenderEntity.weaponDepthHack = true;
|
||||
|
||||
if( flashlightModelDefHandle == -1 )
|
||||
{
|
||||
flashlightModelDefHandle = gameRenderWorld->AddEntityDef( &flashlightRenderEntity );
|
||||
}
|
||||
else
|
||||
{
|
||||
gameRenderWorld->UpdateEntityDef( flashlightModelDefHandle, &flashlightRenderEntity );
|
||||
}
|
||||
}
|
||||
else if (!hasFlashlight || // User hasn't got flashlight yet
|
||||
currentWeapon == weapon_flashlight)
|
||||
{
|
||||
if( flashlightModelDefHandle != -1 )
|
||||
{
|
||||
gameRenderWorld->FreeEntityDef( flashlightModelDefHandle );
|
||||
flashlightModelDefHandle = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
idPlayer::Think
|
||||
|
@ -6238,7 +6334,12 @@ void idPlayer::Think( void ) {
|
|||
|
||||
if (pVRClientInfo != nullptr)
|
||||
{
|
||||
pVRClientInfo->weaponid = currentWeapon;
|
||||
if (inventory.weapons > 1) {
|
||||
pVRClientInfo->weaponid = currentWeapon;
|
||||
}
|
||||
else {
|
||||
pVRClientInfo->weaponid = -1;
|
||||
}
|
||||
cvarSystem->SetCVarBool("vr_weapon_stabilised", pVRClientInfo->weapon_stabilised);
|
||||
pVRClientInfo->velocitytriggered = (currentWeapon == 11 || // 11 is flashlight
|
||||
currentWeapon == 10); // 10 is chainsaw
|
||||
|
@ -6377,6 +6478,8 @@ void idPlayer::Think( void ) {
|
|||
|
||||
UpdatePowerUps();
|
||||
|
||||
UpdateFlashlightHolster();
|
||||
|
||||
UpdateDeathSkin( false );
|
||||
|
||||
if ( gameLocal.isMultiplayer ) {
|
||||
|
@ -6794,24 +6897,28 @@ void idPlayer::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di
|
|||
|
||||
CalcDamagePoints( inflictor, attacker, &damageDef->dict, damageScale, location, &damage, &armorSave );
|
||||
|
||||
// determine knockback
|
||||
damageDef->dict.GetInt( "knockback", "20", knockback );
|
||||
// determine knockback
|
||||
if ( vr_knockBack.GetBool() )
|
||||
{
|
||||
// determine knockback
|
||||
damageDef->dict.GetInt("knockback", "20", knockback);
|
||||
|
||||
if ( knockback != 0 && !fl.noknockback ) {
|
||||
if ( attacker == this ) {
|
||||
damageDef->dict.GetFloat( "attackerPushScale", "0", attackerPushScale );
|
||||
} else {
|
||||
attackerPushScale = 1.0f;
|
||||
}
|
||||
if (knockback != 0 && !fl.noknockback) {
|
||||
if (attacker == this) {
|
||||
damageDef->dict.GetFloat("attackerPushScale", "0", attackerPushScale);
|
||||
} else {
|
||||
attackerPushScale = 1.0f;
|
||||
}
|
||||
|
||||
kick = dir;
|
||||
kick.Normalize();
|
||||
kick *= g_knockback.GetFloat() * knockback * attackerPushScale / 200.0f;
|
||||
physicsObj.SetLinearVelocity( physicsObj.GetLinearVelocity() + kick );
|
||||
kick = dir;
|
||||
kick.Normalize();
|
||||
kick *= g_knockback.GetFloat() * knockback * attackerPushScale / 200.0f;
|
||||
physicsObj.SetLinearVelocity(physicsObj.GetLinearVelocity() + kick);
|
||||
|
||||
// set the timer so that the player can't cancel out the movement immediately
|
||||
physicsObj.SetKnockBack( idMath::ClampInt( 50, 200, knockback * 2 ) );
|
||||
}
|
||||
// set the timer so that the player can't cancel out the movement immediately
|
||||
physicsObj.SetKnockBack(idMath::ClampInt(50, 200, knockback * 2));
|
||||
}
|
||||
}
|
||||
|
||||
// give feedback on the player view and audibly when armor is helping
|
||||
if ( armorSave ) {
|
||||
|
@ -7130,12 +7237,6 @@ Calculate the bobbing position of the view weapon
|
|||
==============
|
||||
*/
|
||||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, float out[2])
|
||||
{
|
||||
out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y;
|
||||
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
||||
}
|
||||
|
||||
void idPlayer::CalculateViewWeaponPos( bool adjusted, idVec3 &origin, idMat3 &axis, idAngles &angles ) {
|
||||
float scale;
|
||||
float fracsin;
|
||||
|
@ -7173,8 +7274,16 @@ void idPlayer::CalculateViewWeaponPos( bool adjusted, idVec3 &origin, idMat3 &ax
|
|||
|
||||
gunpos *= cvarSystem->GetCVarFloat( "vr_worldscale" );
|
||||
|
||||
idVec3 gunOfs( g_gun_x.GetFloat(), g_gun_y.GetFloat(), g_gun_z.GetFloat() );
|
||||
origin = viewOrigin + gunpos + (gunOfs * axis);
|
||||
if (currentWeapon == 11) // Flashlight adjustment
|
||||
{
|
||||
idVec3 gunOfs( -14, 9, 20 );
|
||||
origin = viewOrigin + gunpos + (gunOfs * axis);
|
||||
}
|
||||
else
|
||||
{
|
||||
idVec3 gunOfs( g_gun_x.GetFloat(), g_gun_y.GetFloat(), g_gun_z.GetFloat() );
|
||||
origin = viewOrigin + gunpos + (gunOfs * axis);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -221,6 +221,9 @@ public:
|
|||
|
||||
class idPlayerView playerView; // handles damage kicks and effects
|
||||
|
||||
renderEntity_t flashlightRenderEntity; // used to present a model to the renderer
|
||||
qhandle_t flashlightModelDefHandle; // handle to static renderer model
|
||||
|
||||
bool noclip;
|
||||
bool godmode;
|
||||
|
||||
|
@ -270,6 +273,7 @@ public:
|
|||
int weapon_soulcube;
|
||||
int weapon_pda;
|
||||
int weapon_fists;
|
||||
int weapon_flashlight;
|
||||
|
||||
int heartRate;
|
||||
idInterpolate<float> heartInfo;
|
||||
|
@ -391,7 +395,11 @@ public:
|
|||
// use exitEntityNum to specify a teleport with private camera view and delayed exit
|
||||
virtual void Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
|
||||
|
||||
void Kill( bool delayRespawn, bool nodamage );
|
||||
virtual void SetupFlashlightHolster();
|
||||
virtual void UpdateFlashlightHolster();
|
||||
|
||||
|
||||
void Kill( bool delayRespawn, bool nodamage );
|
||||
virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
|
||||
void StartFxOnBone(const char *fx, const char *bone);
|
||||
|
||||
|
|
|
@ -395,20 +395,21 @@ void idPlayerView::CalculateShake() {
|
|||
idVec3 origin, matrix;
|
||||
|
||||
float shakeVolume = gameSoundWorld->CurrentShakeAmplitudeForPosition( gameLocal.time, player->firstPersonViewOrigin );
|
||||
|
||||
//
|
||||
// shakeVolume should somehow be molded into an angle here
|
||||
// it should be thought of as being in the range 0.0 -> 1.0, although
|
||||
// since CurrentShakeAmplitudeForPosition() returns all the shake sounds
|
||||
// the player can hear, it can go over 1.0 too.
|
||||
//
|
||||
shakeAng[0] = gameLocal.random.CRandomFloat() * shakeVolume;
|
||||
shakeAng[1] = gameLocal.random.CRandomFloat() * shakeVolume;
|
||||
shakeAng[2] = gameLocal.random.CRandomFloat() * shakeVolume;
|
||||
shakeAng[0] = gameLocal.random.CRandomFloat() * shakeVolume * vr_shakeAmplitude.GetFloat();
|
||||
shakeAng[1] = gameLocal.random.CRandomFloat() * shakeVolume * vr_shakeAmplitude.GetFloat();
|
||||
shakeAng[2] = gameLocal.random.CRandomFloat() * shakeVolume * vr_shakeAmplitude.GetFloat();
|
||||
|
||||
if (shakeVolume > 0.05) {
|
||||
if (shakeVolume > 0.1) {
|
||||
//Shake controllers!
|
||||
common->Vibrate(50, 0, idMath::ClampFloat(0.3, 1.0, (shakeVolume*2.0f + 0.1f)));
|
||||
common->Vibrate(50, 1, idMath::ClampFloat(0.3, 1.0, (shakeVolume*2.0f + 0.1f)));
|
||||
common->Vibrate(50, 0, idMath::ClampFloat(0.1, 1.0, shakeVolume*2.0f + 0.1f));
|
||||
common->Vibrate(50, 1, idMath::ClampFloat(0.1, 1.0, shakeVolume*2.0f + 0.1f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,5 +343,5 @@ idCVar vr_worldscale( "vr_worldscale", "45.0", CVAR_GAME | CVAR_FLOAT | C
|
|||
idCVar vr_heightoffset( "vr_heightoffset", "0.0", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "VR Height Offset" );
|
||||
idCVar vr_eye( "vr_eye", "0", CVAR_GAME | CVAR_INTEGER, "VR Eye currently being drawn" );
|
||||
idCVar vr_control_scheme( "vr_control_scheme", "0", CVAR_GAME | CVAR_INTEGER, "VR Control Scheme: 0 = right handed, 10 = left handed" );
|
||||
|
||||
|
||||
idCVar vr_shakeAmplitude( "vr_shakeAmplitude", "0.8", CVAR_FLOAT | CVAR_ARCHIVE, "Screen shake amplitude 0.0 = disabled to 1.0 = full\n", 0.0f, 1.0f );
|
||||
idCVar vr_knockBack( "vr_knockBack", "0", CVAR_BOOL | CVAR_ARCHIVE | CVAR_GAME, "Enable damage knockback in VR. 0 = Disabled, 1 = Enabled" );
|
||||
|
|
|
@ -257,6 +257,8 @@ extern idCVar vr_worldscale;
|
|||
extern idCVar vr_eye;
|
||||
extern idCVar vr_heightoffset;
|
||||
extern idCVar vr_control_scheme;
|
||||
extern idCVar vr_shakeAmplitude;
|
||||
extern idCVar vr_knockBack;
|
||||
|
||||
extern const char *si_gameTypeArgs[];
|
||||
|
||||
|
|
Loading…
Reference in a new issue