Implement stance switching in 3rd person JKA

This commit is contained in:
Simon 2023-05-12 18:41:08 +01:00
parent 374e2f956c
commit 7faa7755dd
2 changed files with 54 additions and 33 deletions

View file

@ -2942,8 +2942,8 @@ void CG_ItemSelectorNext_f( void )
centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
//Only show the stance selection if using saber and in third person //Only show the stance selection if using saber and in third person and not using dual/staff saber
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) && int selectors = (cent->gent->client->ps.saberStylesKnown != SS_NONE &&
cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2; cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2;
cg.itemSelectorType = (cg.itemSelectorType+1) % selectors; cg.itemSelectorType = (cg.itemSelectorType+1) % selectors;
cg.itemSelectorTime = cg.time; cg.itemSelectorTime = cg.time;
@ -2959,8 +2959,8 @@ void CG_ItemSelectorPrev_f( void )
centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
//Only show the stance selection if using saber and in third person //Only show the stance selection if using saber and in third person and not using dual/staff saber
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) && int selectors = (cent->gent->client->ps.saberStylesKnown != SS_NONE &&
cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2; cent->currentState.weapon == WP_SABER && cg_thirdPerson.integer) ? 3 : 2;
if (--cg.itemSelectorType < 0) if (--cg.itemSelectorType < 0)
cg.itemSelectorType = selectors-1; cg.itemSelectorType = selectors-1;
@ -3114,25 +3114,25 @@ void CG_DrawItemSelector( void )
cgi_R_AddRefEntityToScene(&sprite); cgi_R_AddRefEntityToScene(&sprite);
} }
} }
/* else if (cg.itemSelectorType == 2) // fighting style else if (cg.itemSelectorType == 2) // fighting style
{ {
//For the fighting style show the active one in the middle //For the fighting style show the active one in the middle
int level = cent->gent->client->ps.saberAnimLevel; if (cent->gent->client->ps.saberStylesKnown != SS_NONE) {
if (cent->gent->client->ps.forcePowersKnown & (1 << FP_SABER_OFFENSE) &&
level > FORCE_LEVEL_0) {
refEntity_t sprite; refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite)); memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin); VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE; sprite.reType = RT_SPRITE;
switch (level) { switch (cent->gent->client->ps.saberAnimLevel) {
case FORCE_LEVEL_1: case SS_FAST:
sprite.customShader = cgs.media.HUDSaberStyleFast; sprite.customShader = otherHUDBits[OHB_SABERSTYLE_FAST].background;
break; break;
case FORCE_LEVEL_2: case SS_MEDIUM:
sprite.customShader = cgs.media.HUDSaberStyleMed; case SS_DUAL:
case SS_STAFF:
sprite.customShader = otherHUDBits[OHB_SABERSTYLE_MEDIUM].background;
break; break;
case FORCE_LEVEL_3: default:
sprite.customShader = cgs.media.HUDSaberStyleStrong; sprite.customShader = otherHUDBits[OHB_SABERSTYLE_STRONG].background;
break; break;
} }
@ -3140,7 +3140,7 @@ void CG_DrawItemSelector( void )
memset(sprite.shaderRGBA, 0xff, 4); memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite); cgi_R_AddRefEntityToScene(&sprite);
} }
}*/ }
else if (cg.itemSelectorType == ST_FORCE_POWER) // force powers else if (cg.itemSelectorType == ST_FORCE_POWER) // force powers
{ {
if (cent->gent->client->ps.forcePowersKnown != 0) { if (cent->gent->client->ps.forcePowersKnown != 0) {
@ -3204,13 +3204,8 @@ void CG_DrawItemSelector( void )
selectable = CG_InventorySelectable(itemId) && inv_icons[itemId]; selectable = CG_InventorySelectable(itemId) && inv_icons[itemId];
break; break;
case ST_FIGHTING_STYLE: //fighting style case ST_FIGHTING_STYLE: //fighting style
{ selectable = cent->gent->client->ps.saberAnimLevel <= SS_STRONG &&
if (cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) { cent->gent->client->ps.saberStylesKnown & (1<<(itemId+1));
selectable = itemId < cent->gent->client->ps.forcePowerLevel[FP_SABER_OFFENSE];
} else {
selectable = false;
}
}
break; break;
case ST_FORCE_POWER: // force powers case ST_FORCE_POWER: // force powers
selectable = ForcePower_Valid(itemId); selectable = ForcePower_Valid(itemId);
@ -3286,21 +3281,21 @@ void CG_DrawItemSelector( void )
case ST_GADGET: //gadgets case ST_GADGET: //gadgets
sprite.customShader = inv_icons[itemId]; sprite.customShader = inv_icons[itemId];
break; break;
/* case 2: //fighting style case ST_FIGHTING_STYLE: //fighting style
switch ( itemId ) switch ( itemId+1 )
{ {
case 0://FORCE_LEVEL_1: case SS_FAST:
sprite.customShader = cgs.media.HUDSaberStyleFast; sprite.customShader = otherHUDBits[OHB_SABERSTYLE_FAST].background;
break; break;
case 1://FORCE_LEVEL_2: case SS_MEDIUM:
sprite.customShader = cgs.media.HUDSaberStyleMed; sprite.customShader = otherHUDBits[OHB_SABERSTYLE_MEDIUM].background;
break; break;
case 2://FORCE_LEVEL_3: case SS_STRONG:
sprite.customShader = cgs.media.HUDSaberStyleStrong; sprite.customShader = otherHUDBits[OHB_SABERSTYLE_STRONG].background;
break; break;
} }
break; break;
*/ case ST_FORCE_POWER: // force powers case ST_FORCE_POWER: // force powers
sprite.customShader = force_icons[showPowers[itemId]]; sprite.customShader = force_icons[showPowers[itemId]];
break; break;
case ST_QUICK_SAVE: case ST_QUICK_SAVE:

View file

@ -644,6 +644,31 @@ static void Svcmd_SetForceAll_f(void)
} }
} }
void Svcmd_SaberSetLevel_f( void )
{
if ( !&g_entities[0] || !g_entities[0].client )
{
return;
}
gentity_t *self = G_GetSelfForPlayerCmd();
if ( self->s.weapon != WP_SABER )
{
return;
}
const char *newVal = gi.argv(1);
int saberAnimLevel = atoi(newVal);
if ( !self->s.number )
{
cg.saberAnimLevelPending = saberAnimLevel;
}
else
{
self->client->ps.saberAnimLevel = saberAnimLevel;
}
}
static void Svcmd_SetSaberAll_f(void) static void Svcmd_SetSaberAll_f(void)
{ {
Svcmd_ForceSetLevel_f( FP_SABERTHROW ); Svcmd_ForceSetLevel_f( FP_SABERTHROW );
@ -926,6 +951,7 @@ static svcmd_t svcmds[] = {
{ "setForceSight", Svcmd_ForceSetLevel_f<FP_SEE>, CMD_CHEAT }, { "setForceSight", Svcmd_ForceSetLevel_f<FP_SEE>, CMD_CHEAT },
{ "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT }, { "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT },
{ "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT }, { "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT },
{ "setSaberLevel", Svcmd_SaberSetLevel_f, CMD_NONE },
{ "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE }, { "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE },