Fix for saber not affecting dark jedi

This commit is contained in:
Simon 2022-10-10 21:56:08 +01:00
parent daafcc6ba4
commit a00281d038
6 changed files with 42 additions and 26 deletions

View file

@ -8,7 +8,7 @@
#define SCOPE_ENGAGE_DISTANCE 0.25 #define SCOPE_ENGAGE_DISTANCE 0.25
#define VSTOCK_ENGAGE_DISTANCE 0.25 #define VSTOCK_ENGAGE_DISTANCE 0.25
#define BINOCULAR_ENGAGE_DISTANCE 0.25 #define BINOCULAR_ENGAGE_DISTANCE 0.25
#define VELOCITY_TRIGGER 1.6 #define VELOCITY_TRIGGER 1.0
extern ovrInputStateTrackedRemote leftTrackedRemoteState_old; extern ovrInputStateTrackedRemote leftTrackedRemoteState_old;
extern ovrInputStateTrackedRemote leftTrackedRemoteState_new; extern ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -22,10 +22,9 @@ Authors : Simon Brown
#include <qcommon/qcommon.h> #include <qcommon/qcommon.h>
#include <client/client.h> #include <client/client.h>
#include "android/sys_local.h" #include "android/sys_local.h"
#include "weapons.h"
#define WP_SABER 1
void SV_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule ); void SV_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule );
void JKVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight ); void JKVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight );
@ -231,13 +230,14 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
powf(pOff->HeadPose.LinearVelocity.z, 2)); powf(pOff->HeadPose.LinearVelocity.z, 2));
//We don't allow the saber to be velocity triggered //For melee right hand is alt attack and left hand is attack
if (vr.weaponid != WP_SABER) { static bool primaryVelocityTriggeredAttack = false;
static bool secondaryVelocityTriggeredAttack = false;
if (vr.weaponid == WP_MELEE) {
//Does weapon velocity trigger attack (melee) and is it fast enough //Does weapon velocity trigger attack (melee) and is it fast enough
static bool primaryVelocityTriggeredAttack = false; if (vr.velocitytriggered) {
if (vr.velocitytriggered) {
static bool fired = qfalse; static bool fired = qfalse;
primaryVelocityTriggeredAttack = (vr.primaryswingvelocity > VELOCITY_TRIGGER); primaryVelocityTriggeredAttack = (vr.primaryswingvelocity > WEAPON_VELOCITY_TRIGGER);
if (fired != primaryVelocityTriggeredAttack) { if (fired != primaryVelocityTriggeredAttack) {
ALOGV("**WEAPON EVENT** veocity triggered %s", ALOGV("**WEAPON EVENT** veocity triggered %s",
@ -253,11 +253,10 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
sendButtonAction("+altattack", primaryVelocityTriggeredAttack); sendButtonAction("+altattack", primaryVelocityTriggeredAttack);
} }
static bool secondaryVelocityTriggeredAttack = false;
if (vr.velocitytriggered) { if (vr.velocitytriggered) {
static bool fired = qfalse; static bool fired = qfalse;
secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity > secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity >
VELOCITY_TRIGGER); WEAPON_VELOCITY_TRIGGER);
if (fired != secondaryVelocityTriggeredAttack) { if (fired != secondaryVelocityTriggeredAttack) {
ALOGV("**WEAPON EVENT** veocity triggered %s", ALOGV("**WEAPON EVENT** veocity triggered %s",
@ -273,6 +272,26 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
sendButtonAction("+attack", secondaryVelocityTriggeredAttack); sendButtonAction("+attack", secondaryVelocityTriggeredAttack);
} }
} }
else if (vr.weaponid == WP_SABER) {
//Does weapon velocity trigger attack
if (vr.velocitytriggered) {
static bool fired = qfalse;
primaryVelocityTriggeredAttack = (vr.primaryswingvelocity > WEAPON_VELOCITY_TRIGGER);
if (fired != primaryVelocityTriggeredAttack) {
ALOGV("**WEAPON EVENT** veocity triggered %s",
primaryVelocityTriggeredAttack ? "+attack" : "-attack");
//normal attack is a punch with the left hand
sendButtonAction("+attack", primaryVelocityTriggeredAttack);
fired = primaryVelocityTriggeredAttack;
}
} else if (primaryVelocityTriggeredAttack) {
//send a stop attack as we have an unfinished velocity attack
primaryVelocityTriggeredAttack = qfalse;
ALOGV("**WEAPON EVENT** veocity triggered -attack");
sendButtonAction("+attack", primaryVelocityTriggeredAttack);
}
}
if (vr.weapon_stabilised) if (vr.weapon_stabilised)
{ {

View file

@ -37,9 +37,6 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define LOOK_SWING_SCALE 0.5f #define LOOK_SWING_SCALE 0.5f
#define CG_SWINGSPEED 0.3f #define CG_SWINGSPEED 0.3f
//How fast the saber needs to be physically swung in order to trigger sounds and trails
#define SABER_ACTIVATE_VELOCITY 0.6f
#include "animtable.h" #include "animtable.h"
extern qboolean WP_SaberBladeUseSecondBladeStyle( saberInfo_t *saber, int bladeNum ); extern qboolean WP_SaberBladeUseSecondBladeStyle( saberInfo_t *saber, int bladeNum );
@ -6579,9 +6576,7 @@ Ghoul2 Insert End
{//okay to draw the trail {//okay to draw the trail
saberTrail_t *saberTrail = &client->ps.saber[saberNum].blade[bladeNum].trail; saberTrail_t *saberTrail = &client->ps.saber[saberNum].blade[bladeNum].trail;
#define SABER_TRAIL_TIME 40.0f #define SABER_TRAIL_TIME 60.0f
bool saberInAction = (saberTrail->inAction || (vr->primaryswingvelocity > SABER_ACTIVATE_VELOCITY));
// if we happen to be timescaled or running in a high framerate situation, we don't want to flood // if we happen to be timescaled or running in a high framerate situation, we don't want to flood
// the system with very small trail slices...but perhaps doing it by distance would yield better results? // the system with very small trail slices...but perhaps doing it by distance would yield better results?
@ -6592,9 +6587,9 @@ Ghoul2 Insert End
//cap it to cg.time here //cap it to cg.time here
saberTrail->lastTime = cg.time; saberTrail->lastTime = cg.time;
} }
if ( cg.time > saberTrail->lastTime + 2 && saberInAction ) // 2ms if ( cg.time > saberTrail->lastTime + 2 && saberTrail->inAction ) // 2ms
{ {
if ( saberInAction && cg.time < saberTrail->lastTime + 300 ) // if we have a stale segment, don't draw until we have a fresh one if ( saberTrail->inAction && cg.time < saberTrail->lastTime + 300 ) // if we have a stale segment, don't draw until we have a fresh one
{ {
vec3_t rgb1={255,255,255}; vec3_t rgb1={255,255,255};

View file

@ -31,6 +31,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "../qcommon/q_shared.h" #include "../qcommon/q_shared.h"
//How fast the saber/melee needs to be physically swung in order to trigger sounds and trails etc
#define WEAPON_VELOCITY_TRIGGER 0.6f
typedef enum //# weapon_e typedef enum //# weapon_e
{ {
WP_NONE, WP_NONE,

View file

@ -35,9 +35,6 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define LOOK_SWING_SCALE 0.5 #define LOOK_SWING_SCALE 0.5
//How fast the saber needs to be physically swung in order to trigger sounds and trails
#define SABER_ACTIVATE_VELOCITY 0.6f
#include "animtable.h" #include "animtable.h"
@ -3461,8 +3458,9 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
VectorCopy(axis[1], hiltEnt.axis[1]); VectorCopy(axis[1], hiltEnt.axis[1]);
VectorCopy(axis[0], hiltEnt.axis[2]); VectorCopy(axis[0], hiltEnt.axis[2]);
cgi_R_AddRefEntityToScene(&hiltEnt); cgi_R_AddRefEntityToScene(&hiltEnt);
static int playingSaberSwingSound = 0; static int playingSaberSwingSound = 0;
if (vr->primaryswingvelocity > SABER_ACTIVATE_VELOCITY && (cg.time - playingSaberSwingSound) > 750) if (vr->primaryswingvelocity > WEAPON_VELOCITY_TRIGGER && (cg.time - playingSaberSwingSound) > 750)
{ {
cgi_S_StartSound ( hiltEnt.origin, cent->gent->s.number, CHAN_AUTO, cgi_S_RegisterSound( va( "sound/weapons/saber/saberhup%d.wav", Q_irand( 0, 2 ) * 3 + 1 ) ) ); cgi_S_StartSound ( hiltEnt.origin, cent->gent->s.number, CHAN_AUTO, cgi_S_RegisterSound( va( "sound/weapons/saber/saberhup%d.wav", Q_irand( 0, 2 ) * 3 + 1 ) ) );
playingSaberSwingSound = cg.time; playingSaberSwingSound = cg.time;
@ -4676,8 +4674,6 @@ Ghoul2 Insert End
#define SABER_TRAIL_TIME 60.0f #define SABER_TRAIL_TIME 60.0f
bool saberInAction = (saberTrail->inAction || (vr->primaryswingvelocity > SABER_ACTIVATE_VELOCITY));
// if we happen to be timescaled or running in a high framerate situation, we don't want to flood // if we happen to be timescaled or running in a high framerate situation, we don't want to flood
// the system with very small trail slices...but perhaps doing it by distance would yield better results? // the system with very small trail slices...but perhaps doing it by distance would yield better results?
if ( saberTrail->lastTime > cg.time ) if ( saberTrail->lastTime > cg.time )
@ -4687,10 +4683,10 @@ Ghoul2 Insert End
//cap it to cg.time here //cap it to cg.time here
saberTrail->lastTime = cg.time; saberTrail->lastTime = cg.time;
} }
if ( cg.time > saberTrail->lastTime + 2 && saberInAction) // 2ms if ( cg.time > saberTrail->lastTime + 2 && saberTrail->inAction) // 2ms
{ {
//Swinging the saber quick enough to trigger a sound should also invoke trails //Swinging the saber quick enough to trigger a sound should also invoke trails
if ( saberInAction && cg.time < saberTrail->lastTime + 300 ) // if we have a stale segment, don't draw until we have a fresh one if ( saberTrail->inAction && cg.time < saberTrail->lastTime + 300 ) // if we have a stale segment, don't draw until we have a fresh one
{ {
vec3_t rgb1={255,255,255}; vec3_t rgb1={255,255,255};

View file

@ -31,6 +31,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "../../code/qcommon/q_shared.h" #include "../../code/qcommon/q_shared.h"
//How fast the saber/melee needs to be physically swung in order to trigger sounds and trails
#define WEAPON_VELOCITY_TRIGGER 0.6f
typedef enum //# weapon_e typedef enum //# weapon_e
{ {
WP_NONE, WP_NONE,