mirror of
https://github.com/DrBeef/JKXR.git
synced 2025-02-16 08:51:50 +00:00
Force Changes...
Allow grip to pull and push NPCs away and toward player (by moving hand forward and back) Make saber still be controllable on level 1 but slower and for shorter time Always draw force crosshair, but change colour when aimed at an entity
This commit is contained in:
parent
73080a2b4b
commit
d3cd3ee71b
9 changed files with 76 additions and 33 deletions
|
@ -46,8 +46,6 @@ typedef struct {
|
|||
|
||||
int item_selector = 0; // 1 - weapons/gadgets/saber stance, 2 - Force powers
|
||||
|
||||
bool pistol; // True if the weapon is a pistol
|
||||
|
||||
//Lots of scope weapon stuff
|
||||
bool scopeengaged; // Scope has been engaged on a scoped weapon
|
||||
bool scopedweapon; // Weapon scope is available
|
||||
|
|
|
@ -238,24 +238,31 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
sendButtonAction("+attack", between(0.8f, pPrimaryJoystick->y, 1.0f));
|
||||
sendButtonAction("+altattack", between(-1.0f, pPrimaryJoystick->y, -0.8f));
|
||||
}
|
||||
} else if (vr.weaponid == WP_SABER)
|
||||
}
|
||||
else if (vr.weaponid == WP_SABER)
|
||||
{
|
||||
int mode = (int)Cvar_VariableValue("cg_thirdPerson");
|
||||
static bool switched = false;
|
||||
if (between(-0.2f, primaryJoystickX, 0.2f) &&
|
||||
(between(0.8f, pPrimaryJoystick->y, 1.0f) ||
|
||||
between(-1.0f, pPrimaryJoystick->y, -0.8f))) {
|
||||
if (!switched) {
|
||||
if (between(0.8f, pPrimaryJoystick->y, 1.0f)) {
|
||||
sendButtonActionSimple("cg_thirdPerson 1");
|
||||
} else {
|
||||
sendButtonActionSimple("cg_thirdPerson 0");
|
||||
}
|
||||
mode = 1 - mode;
|
||||
sendButtonActionSimple(va("cg_thirdPerson %i", mode));
|
||||
switched = true;
|
||||
}
|
||||
} else {
|
||||
switched = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mode = (int)Cvar_VariableValue("cg_thirdPerson");
|
||||
if (mode != 0)
|
||||
{
|
||||
sendButtonActionSimple("cg_thirdPerson 0");
|
||||
}
|
||||
}
|
||||
|
||||
//if (!vr.item_selector)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#if defined(MACOS_X) || defined(__linux__) || defined(__FreeBSD_kernel__)
|
||||
#include <unistd.h>
|
||||
#include <VrCommon.h>
|
||||
|
||||
#endif
|
||||
|
||||
static char binaryPath[ MAX_OSPATH ] = { 0 };
|
||||
|
@ -110,6 +112,7 @@ void Conbuf_AppendText( const char *pMsg )
|
|||
char msg[MAXPRINTMSG] = {0};
|
||||
Q_strncpyz(msg, pMsg, sizeof(msg));
|
||||
Q_StripColor(msg);
|
||||
ALOGV("%s", msg);
|
||||
//((void)__android_log_print(ANDROID_LOG_INFO,"JK3","%s", msg));
|
||||
//printf("%s", msg);
|
||||
}
|
||||
|
|
|
@ -842,7 +842,7 @@ static void Player_RestoreFromPrevLevel(gentity_t *ent, SavedGameJustLoaded_e eS
|
|||
}
|
||||
assert (i==NUM_FORCE_POWERS);
|
||||
|
||||
client->ps.forceGripEntityNum = client->ps.forceDrainEntityNum = ENTITYNUM_NONE;
|
||||
client->ps.forceGripEntityInitialDist = client->ps.forceGripEntityNum = client->ps.forceDrainEntityNum = ENTITYNUM_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13141,6 +13141,7 @@ void WP_ForcePowerStop( gentity_t *self, forcePowers_t forcePower )
|
|||
}
|
||||
self->s.loopSound = 0;
|
||||
self->client->ps.forceGripEntityNum = ENTITYNUM_NONE;
|
||||
self->client->ps.forceGripEntityInitialDist = ENTITYNUM_NONE;
|
||||
}
|
||||
if ( self->client->ps.torsoAnim == BOTH_FORCEGRIP_HOLD )
|
||||
{
|
||||
|
@ -14401,7 +14402,7 @@ void WP_InitForcePowers( gentity_t *ent )
|
|||
ent->client->ps.forcePower = ent->client->ps.forcePowerMax;
|
||||
ent->client->ps.forcePowerRegenDebounceTime = level.time;
|
||||
|
||||
ent->client->ps.forceGripEntityNum = ent->client->ps.forceDrainEntityNum = ent->client->ps.pullAttackEntNum = ENTITYNUM_NONE;
|
||||
ent->client->ps.forceGripEntityInitialDist = ent->client->ps.forceGripEntityNum = ent->client->ps.forceDrainEntityNum = ent->client->ps.pullAttackEntNum = ENTITYNUM_NONE;
|
||||
ent->client->ps.forceRageRecoveryTime = 0;
|
||||
ent->client->ps.forceDrainTime = 0;
|
||||
ent->client->ps.pullAttackTime = 0;
|
||||
|
|
|
@ -1851,6 +1851,7 @@ public:
|
|||
float forceJumpZStart; //So when you land, you don't get hurt as much
|
||||
float forceJumpCharge; //you're current forceJump charge-up level, increases the longer you hold the force jump button down
|
||||
int forceGripEntityNum; //what entity I'm gripping
|
||||
float forceGripEntityInitialDist; //the initial distance of the gripped entity
|
||||
vec3_t forceGripOrg; //where the gripped ent should be lifted to
|
||||
|
||||
#ifndef JK2_MODE
|
||||
|
|
|
@ -1859,11 +1859,13 @@ static void CG_DrawCrosshair3D(int type) // 0 - force, 1 - weapons
|
|||
|
||||
if (type == 0)
|
||||
{
|
||||
CG_ScanForForceCrosshairEntity();
|
||||
if (!cg_forceCrosshair)
|
||||
if (showPowers[cg.forcepowerSelect] == FP_HEAL ||
|
||||
showPowers[cg.forcepowerSelect] == FP_SPEED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CG_ScanForForceCrosshairEntity();
|
||||
}
|
||||
|
||||
w = cg_crosshairSize.value;
|
||||
|
@ -1905,7 +1907,7 @@ static void CG_DrawCrosshair3D(int type) // 0 - force, 1 - weapons
|
|||
|
||||
ent.radius = w / 640 * xmax * trace.fraction * 2048 / 64.0f;
|
||||
ent.customShader = hShader;
|
||||
ent.shaderRGBA[0] = (type == 0) ? 0 : 255;
|
||||
ent.shaderRGBA[0] = (type == 0 && !cg_forceCrosshair) ? 0 : 255;
|
||||
ent.shaderRGBA[1] = (type == 0) ? 0 : 255;
|
||||
ent.shaderRGBA[2] = 255;
|
||||
ent.shaderRGBA[3] = 255;
|
||||
|
|
|
@ -773,6 +773,7 @@ void Player_RestoreFromPrevLevel(gentity_t *ent)
|
|||
|
||||
client->ps.forcePowerMax = FORCE_POWER_MAX;
|
||||
client->ps.forceGripEntityNum = ENTITYNUM_NONE;
|
||||
client->ps.forceGripEntityInitialDist = ENTITYNUM_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
#include "wp_saber.h"
|
||||
#include "../../code/qcommon/tri_coll_test.h"
|
||||
#include "../cgame/FxScheduler.h"
|
||||
#include <JKVR/VrClientInfo.h>
|
||||
|
||||
#define MAX_SABER_VICTIMS 16
|
||||
static int victimEntityNum[MAX_SABER_VICTIMS];
|
||||
|
@ -3992,24 +3993,19 @@ void WP_RunSaber( gentity_t *self, gentity_t *saber )
|
|||
fwdangles[0] -= 5;
|
||||
}
|
||||
|
||||
if ( self->client->ps.forcePowerLevel[FP_SABERTHROW] > FORCE_LEVEL_1
|
||||
|| self->client->ps.saberEntityState == SES_RETURNING
|
||||
//For now make FORCE_LEVEL_1 saber throw do the same as FORCE_LEVEL_2, otherwise it is impossible to use
|
||||
if ( self->client->ps.forcePowerLevel[FP_SABERTHROW] >= FORCE_LEVEL_1 ||
|
||||
self->client->ps.saberEntityState == SES_RETURNING
|
||||
|| VectorCompare( saber->s.pos.trDelta, vec3_origin ) )
|
||||
{//control if it's returning or just starting
|
||||
float saberSpeed = 500;//FIXME: based on force level?
|
||||
float saberSpeed = self->client->ps.forcePowerLevel[FP_SABERTHROW] == FORCE_LEVEL_1 ? 300 : 500;
|
||||
float dist;
|
||||
gentity_t *enemy = NULL;
|
||||
|
||||
AngleVectors( fwdangles, forward, NULL, NULL );
|
||||
|
||||
if ( self->client->ps.saberEntityDist < 100 )
|
||||
{//make the saber head to my hand- the bolt it was attached to
|
||||
VectorCopy( self->client->renderInfo.handRPoint, saberHome );
|
||||
}
|
||||
else
|
||||
{//aim saber from eyes
|
||||
VectorCopy( self->client->renderInfo.eyePoint, saberHome );
|
||||
}
|
||||
//Always use right hand as saber home
|
||||
VectorCopy( self->client->renderInfo.handRPoint, saberHome );
|
||||
VectorMA( saberHome, self->client->ps.saberEntityDist, forward, saberDest );
|
||||
|
||||
if ( self->client->ps.forcePowerLevel[FP_SABERTHROW] > FORCE_LEVEL_2 && self->client->ps.saberEntityState == SES_LEAVING )
|
||||
|
@ -4025,7 +4021,6 @@ void WP_RunSaber( gentity_t *self, gentity_t *saber )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//Make the saber head there
|
||||
VectorSubtract( saberDest, saber->currentOrigin, saber->s.pos.trDelta );
|
||||
dist = VectorNormalize( saber->s.pos.trDelta );
|
||||
|
@ -8019,6 +8014,7 @@ void WP_ForcePowerStop( gentity_t *self, forcePowers_t forcePower )
|
|||
}
|
||||
self->s.loopSound = 0;
|
||||
self->client->ps.forceGripEntityNum = ENTITYNUM_NONE;
|
||||
self->client->ps.forceGripEntityInitialDist = ENTITYNUM_NONE;
|
||||
}
|
||||
if ( self->client->ps.torsoAnim == BOTH_FORCEGRIP_HOLD )
|
||||
{
|
||||
|
@ -8193,8 +8189,10 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
|
|||
{//holding it
|
||||
NPC_SetAnim( self, SETANIM_TORSO, BOTH_FORCEGRIP_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
|
||||
}
|
||||
|
||||
bool isFirstPersonPlayer = (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson);
|
||||
//get their org
|
||||
if (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson)
|
||||
if (isFirstPersonPlayer)
|
||||
{
|
||||
vec3_t origin;
|
||||
BG_CalculateVROffHandPosition(origin, angles);
|
||||
|
@ -8215,6 +8213,17 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
|
|||
VectorCopy( gripEnt->currentOrigin, gripEntOrg );
|
||||
}
|
||||
|
||||
if (isFirstPersonPlayer &&
|
||||
self->client->ps.forcePowerLevel[FP_GRIP] > FORCE_LEVEL_2 &&
|
||||
self->client->ps.forceGripEntityInitialDist == ENTITYNUM_NONE)
|
||||
{
|
||||
vec3_t diff;
|
||||
diff[2] = 0;
|
||||
VectorSubtract2(self->client->renderInfo.handLPoint,
|
||||
self->client->renderInfo.eyePoint, diff);
|
||||
self->client->ps.forceGripEntityInitialDist = VectorLength(diff);
|
||||
}
|
||||
|
||||
//how far are they
|
||||
dist = Distance( self->client->renderInfo.handLPoint, gripEntOrg );
|
||||
if ( self->client->ps.forcePowerLevel[FP_GRIP] == FORCE_LEVEL_2 &&
|
||||
|
@ -8228,16 +8237,35 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
|
|||
//check for lift or carry
|
||||
if ( self->client->ps.forcePowerLevel[FP_GRIP] > FORCE_LEVEL_2 )
|
||||
{//carry
|
||||
//cap dist
|
||||
if ( dist > 256 )
|
||||
{
|
||||
dist = 256;
|
||||
if (isFirstPersonPlayer) {
|
||||
vec3_t diff;
|
||||
diff[2] = 0;
|
||||
VectorSubtract2(self->client->renderInfo.handLPoint,
|
||||
self->client->renderInfo.eyePoint, diff);
|
||||
float length = VectorLength(diff);
|
||||
if (fabs(length - self->client->ps.forceGripEntityInitialDist) > 1.0f) {
|
||||
dist += (length - self->client->ps.forceGripEntityInitialDist) *
|
||||
5.0f;
|
||||
}
|
||||
if (dist > 384) {
|
||||
dist = 384;
|
||||
} else if (dist < 32) {
|
||||
dist = 32;
|
||||
}
|
||||
}
|
||||
else if ( dist < 128 )
|
||||
else
|
||||
{
|
||||
dist = 128;
|
||||
//cap dist
|
||||
if (dist > 256) {
|
||||
dist = 256;
|
||||
} else if (dist < 128) {
|
||||
dist = 128;
|
||||
}
|
||||
}
|
||||
VectorMA( self->client->renderInfo.handLPoint, dist, dir, gripOrg );
|
||||
|
||||
VectorMA(self->client->renderInfo.handLPoint,
|
||||
dist, dir,
|
||||
gripOrg);
|
||||
}
|
||||
else if ( self->client->ps.forcePowerLevel[FP_GRIP] > FORCE_LEVEL_1 )
|
||||
{//just lift
|
||||
|
@ -8533,6 +8561,7 @@ void WP_InitForcePowers( gentity_t *ent )
|
|||
ent->client->ps.forcePower = ent->client->ps.forcePowerMax = FORCE_POWER_MAX;
|
||||
ent->client->ps.forcePowerRegenDebounceTime = 0;
|
||||
ent->client->ps.forceGripEntityNum = ENTITYNUM_NONE;
|
||||
ent->client->ps.forceGripEntityInitialDist = ENTITYNUM_NONE;
|
||||
|
||||
if ( ent->client->NPC_class == CLASS_DESANN )
|
||||
{
|
||||
|
@ -8665,5 +8694,6 @@ void WP_InitForcePowers( gentity_t *ent )
|
|||
ent->client->ps.forcePowerLevel[FP_GRIP] = FORCE_LEVEL_2;
|
||||
}
|
||||
ent->client->ps.forceGripEntityNum = ENTITYNUM_NONE;
|
||||
ent->client->ps.forceGripEntityInitialDist = ENTITYNUM_NONE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue