Skip to content

Commit

Permalink
game: Add 'block' alternative command and apply block stats time as p…
Browse files Browse the repository at this point in the history
…ml.msec, so that depends of pmove time
  • Loading branch information
LegendaryGuard committed Apr 15, 2024
1 parent 9f3c681 commit 8962300
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
20 changes: 20 additions & 0 deletions source/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,23 @@ static void PM_HitStun( void ) { // BFP - Hit stun
pm->cmd.upmove = 0;
}

/*
================
PM_BlockTime
Handle block status (treated as block time)
================
*/
static void PM_BlockTime( void ) { // BFP - Block
if ( pm->ps->stats[STAT_BLOCK] >= 0 ) {
pm->ps->stats[STAT_BLOCK] -= pml.msec;
// Print block length duration debug
#if 0
Com_Printf( "BLOCK LENGTH: %d\n", pm->ps->stats[STAT_BLOCK] );
#endif
}
}

/*
================
PmoveSingle
Expand Down Expand Up @@ -2402,6 +2419,9 @@ void PmoveSingle (pmove_t *pmove) {
PM_DeadMove ();
}

// BFP - Block
PM_BlockTime();

PM_DropTimers();

// BFP - Flight
Expand Down
24 changes: 6 additions & 18 deletions source/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,24 +758,12 @@ void ClientThink_real( gentity_t *ent ) {
client->ps.powerups[PW_HASTE] = 0;
client->ps.eFlags &= ~EF_AURA;
ucmd->buttons &= ~BUTTON_KI_USE;
client->ps.stats[STAT_BLOCK] = (g_blockLength.integer * 100);
}

// Handle block status (it's like block time)
if ( client->ps.stats[STAT_BLOCK] >= 0 ) {
client->ps.stats[STAT_BLOCK]--;
// Print debug
#if 0
if ( ( client->ps.pm_flags & PMF_BLOCK ) && client->ps.stats[STAT_BLOCK] <= (g_blockLength.integer * 100) )
Com_Printf( "BLOCK LENGTH: %d\n", client->ps.stats[STAT_BLOCK] );
else if ( !( client->ps.pm_flags & PMF_BLOCK ) && client->ps.stats[STAT_BLOCK] <= (g_blockDelay.integer * 100) )
Com_Printf( "BLOCK DELAY: %d\n", client->ps.stats[STAT_BLOCK] );
#endif
client->ps.stats[STAT_BLOCK] = (g_blockLength.integer * 1000);
}

// BFP - Blocking status. Ki energy is being consumed and ki boost can't be used
if ( ( client->ps.pm_flags & PMF_BLOCK )
&& client->ps.stats[STAT_BLOCK] <= (g_blockLength.integer * 100)
&& client->ps.stats[STAT_BLOCK] <= (g_blockLength.integer * 1000)
&& client->ps.stats[STAT_BLOCK] >= 0 ) {

// BFP - NOTE: Approximate calculation of ki consumption while blocking
Expand All @@ -801,10 +789,10 @@ void ClientThink_real( gentity_t *ent ) {

// When the block length duration has been expired, then start the delay to avoid user
if ( ( client->ps.pm_flags & PMF_BLOCK )
&& client->ps.stats[STAT_BLOCK] <= (g_blockLength.integer * 100)
&& client->ps.stats[STAT_BLOCK] <= (g_blockLength.integer * 1000)
&& client->ps.stats[STAT_BLOCK] <= 0 ) {
client->ps.pm_flags &= ~PMF_BLOCK;
client->ps.stats[STAT_BLOCK] = (g_blockDelay.integer * 100);
client->ps.stats[STAT_BLOCK] = (g_blockDelay.integer * 1000);
}

// If the block length duration hasn't been expired yet and
Expand All @@ -814,12 +802,12 @@ void ClientThink_real( gentity_t *ent ) {
|| ( ucmd->buttons & BUTTON_ATTACK )
|| ( client->ps.eFlags & EF_AURA ) ) ) {
client->ps.pm_flags &= ~PMF_BLOCK;
client->ps.stats[STAT_BLOCK] = (g_blockDelay.integer * 100);
client->ps.stats[STAT_BLOCK] = (g_blockDelay.integer * 1000);
}

// Handle the delay and don't leave the user get away with it
if ( !( client->ps.pm_flags & PMF_BLOCK )
&& client->ps.stats[STAT_BLOCK] <= (g_blockDelay.integer * 100)
&& client->ps.stats[STAT_BLOCK] <= (g_blockDelay.integer * 1000)
&& client->ps.stats[STAT_BLOCK] >= 0 ) {
client->ps.pm_flags &= ~PMF_BLOCK;
ucmd->buttons &= ~BUTTON_BLOCK; // If the user holds the key, when that ends, then immediately enters to this status again
Expand Down
21 changes: 12 additions & 9 deletions source/game/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,12 +1690,17 @@ void Cmd_BFP_SelectCharacter_f( gentity_t* ent ) { // BFP - Select character
G_Printf( "Character: %s\n", characterselected );
}

void Cmd_BFP_StartBlock_f( gentity_t* ent ) { // BFP - TODO: Start block
Com_Printf( "Cmd_BFP_StartBlock_f\n" );
}
/*
=================
Cmd_BFP_Block_f
=================
*/
void Cmd_BFP_Block_f( gentity_t* ent ) { // BFP - Block

void Cmd_BFP_StopBlock_f( gentity_t* ent ) { // BFP - TODO: Stop block
Com_Printf( "Cmd_BFP_StopBlock_f\n" );
if ( ent->client->ps.pm_type != PM_DEAD ) {
ent->client->ps.pm_flags |= PMF_BLOCK;
ent->client->ps.stats[STAT_BLOCK] = (g_blockLength.integer * 1000);
}
}

void Cmd_BFP_StartMelee_f( gentity_t* ent ) { // BFP - TODO: Start melee
Expand Down Expand Up @@ -1826,10 +1831,8 @@ void ClientCommand( int clientNum ) {
Cmd_BFP_SetKiIdle_f( ent );
else if (Q_stricmp (cmd, "selectcharacter") == 0) // BFP - Select character
Cmd_BFP_SelectCharacter_f( ent );
else if (Q_stricmp (cmd, "start_block") == 0) // BFP - TODO: Start Block
Cmd_BFP_StartBlock_f( ent );
else if (Q_stricmp (cmd, "stop_block") == 0) // BFP - TODO: Stop block
Cmd_BFP_StopBlock_f( ent );
else if (Q_stricmp (cmd, "block") == 0) // BFP - Block
Cmd_BFP_Block_f( ent );
else if (Q_stricmp (cmd, "start_melee") == 0) // BFP - TODO: Start melee
Cmd_BFP_StartMelee_f( ent );
else if (Q_stricmp (cmd, "stop_melee") == 0) // BFP - TODO: Stop melee
Expand Down

0 comments on commit 8962300

Please sign in to comment.