Warning when force power too low to use selected force

This commit is contained in:
Simon 2023-03-07 22:52:30 +00:00
parent 3f869386a3
commit 6d6b4cf3da
2 changed files with 45 additions and 3 deletions

View file

@ -10432,6 +10432,10 @@ void ForceTelepathy( gentity_t *self )
override = 50; override = 50;
if ( self->client->ps.forcePower < 50 ) if ( self->client->ps.forcePower < 50 )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
if ( traceEnt->enemy ) if ( traceEnt->enemy )
@ -10561,6 +10565,10 @@ void ForceGrip( gentity_t *self )
if ( self->client->ps.forcePower < 26 ) if ( self->client->ps.forcePower < 26 )
{//need 20 to start, 6 to hold it for any decent amount of time... {//need 20 to start, 6 to hold it for any decent amount of time...
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
@ -10931,6 +10939,10 @@ void ForceLightning( gentity_t *self )
} }
if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_LIGHTNING, 0 ) ) if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_LIGHTNING, 0 ) )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
if ( self->client->ps.forcePowerDebounce[FP_LIGHTNING] > level.time ) if ( self->client->ps.forcePowerDebounce[FP_LIGHTNING] > level.time )
@ -11414,6 +11426,10 @@ qboolean ForceDrain2( gentity_t *self )
if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_DRAIN, 0 ) ) if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_DRAIN, 0 ) )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return qtrue; return qtrue;
} }
@ -11590,6 +11606,10 @@ void ForceDrain( gentity_t *self, qboolean triedDrain2 )
if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_DRAIN, 0 ) ) if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_DRAIN, 0 ) )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
if ( self->client->ps.forcePowerDebounce[FP_DRAIN] > level.time ) if ( self->client->ps.forcePowerDebounce[FP_DRAIN] > level.time )
@ -12818,6 +12838,7 @@ void WP_ForcePowerStart( gentity_t *self, forcePowers_t forcePower, int override
} }
} }
void CG_CenterPrint( const char *str, int y );
qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int overrideAmt ) qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int overrideAmt )
{ {
if ( forcePower == FP_LEVITATION ) if ( forcePower == FP_LEVITATION )
@ -12831,7 +12852,11 @@ qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int
} }
if ( self->client->ps.forcePower < drain ) if ( self->client->ps.forcePower < drain )
{ {
//G_AddEvent( self, EV_NOAMMO, 0 ); // Only show low power warning for force powers that aren't duration based
if (drain > 1 && self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return qfalse; return qfalse;
} }
return qtrue; return qtrue;

View file

@ -6846,6 +6846,10 @@ void ForceTelepathy( gentity_t *self )
override = 50; override = 50;
if ( self->client->ps.forcePower < 50 ) if ( self->client->ps.forcePower < 50 )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
if ( traceEnt->s.weapon != WP_NONE ) if ( traceEnt->s.weapon != WP_NONE )
@ -6965,6 +6969,10 @@ void ForceGrip( gentity_t *self )
if ( self->client->ps.forcePower < 26 ) if ( self->client->ps.forcePower < 26 )
{//need 20 to start, 6 to hold it for any decent amount of time... {//need 20 to start, 6 to hold it for any decent amount of time...
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
@ -7171,6 +7179,10 @@ void ForceLightning( gentity_t *self )
} }
if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_LIGHTNING, 0 ) ) if ( self->client->ps.forcePower < 25 || !WP_ForcePowerUsable( self, FP_LIGHTNING, 0 ) )
{ {
if (self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return; return;
} }
if ( self->client->ps.forcePowerDebounce[FP_LIGHTNING] > level.time ) if ( self->client->ps.forcePowerDebounce[FP_LIGHTNING] > level.time )
@ -7781,6 +7793,7 @@ void WP_ForcePowerStart( gentity_t *self, forcePowers_t forcePower, int override
} }
} }
void CG_CenterPrint( const char *str, int y );
qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int overrideAmt ) qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int overrideAmt )
{ {
if ( forcePower == FP_LEVITATION ) if ( forcePower == FP_LEVITATION )
@ -7794,7 +7807,11 @@ qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int
} }
if ( self->client->ps.forcePower < drain ) if ( self->client->ps.forcePower < drain )
{ {
//G_AddEvent( self, EV_NOAMMO, 0 ); // Only show low power warning for force powers that aren't duration based
if (drain > 1 && self->client->ps.clientNum == 0)
{
CG_CenterPrint("Force Power Low", 440);
}
return qfalse; return qfalse;
} }
return qtrue; return qtrue;