SERVER: Fix co-op tracking, update Quick Revive on connect/disconnect

This commit is contained in:
cypress 2023-11-08 08:50:34 -05:00
parent 619980e88c
commit a19658ec9e
5 changed files with 38 additions and 18 deletions

View file

@ -227,7 +227,7 @@ void() GetDown =
float players_still_alive = PollPlayersAlive();
if ((coop && !players_still_alive) || (!coop && !(self.perks & P_REVIVE))) {
if ((player_count && !players_still_alive) || (!player_count && !(self.perks & P_REVIVE))) {
EndGameSetup();
return;
} else {
@ -235,7 +235,7 @@ void() GetDown =
}
// Initiate Self-Revive on Solo
if ((self.perks & P_REVIVE) && !coop) {
if ((self.perks & P_REVIVE) && !player_count) {
self.progress_bar = 10 + time;
self.progress_bar_time = 10;
self.progress_bar_percent = 1;
@ -318,7 +318,7 @@ void() GetDown =
self.weapons[0].weapon_reserve = 0;
}
} else {
if (!coop) {
if (!player_count) {
Weapon_AssignWeapon(0, W_BIATCH, 6, 12);
} else {
Weapon_AssignWeapon(0, W_COLT, 8, 16);
@ -334,7 +334,7 @@ void() GetDown =
Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, self.weaponmodel, false, S_BOTH);
// Spawn Revive Sprite in Co-Op
if (coop) {
if (player_count) {
EnableReviveIcon(revive_index, self.origin + VEC_VIEW_OFS);
self.electro_targeted = revive_index;
revive_index++;
@ -378,7 +378,7 @@ void () GetUp =
self.teslacount = 0;
if (!coop) {
if (!player_count) {
addmoney(self, self.requirespower, false);
}

View file

@ -48,8 +48,6 @@ string string_null;
.string killtarget;
entity activator;
float framecount;
float deathmatch;
float coop;
float music_override;

View file

@ -309,7 +309,7 @@ void() touch_perk =
self = tempe; // Set self to machine
// Do Self-Revive checks
if (self.classname == "perk_revive" && !coop && !deathmatch) {
if (self.classname == "perk_revive" && !player_count) {
// Increment self-revive count
self.revivesoda++;
@ -400,14 +400,15 @@ void() Perk_Jingle =
//
void() setup_perk =
{
local entity power = find(world, classname, "power_switch");
entity power = find(world, classname, "power_switch");
// Check for Revive before Power
if (self.classname == "perk_revive" && !coop && !deathmatch) {
if (self.classname == "perk_revive" && !player_count) {
Turn_PerkLight_On(self);
self.requirespower = false;
} else {
// Check for Power
if (power != world) {
if (power != world && !isPowerOn) {
self.requirespower = true;
} else {
// There's no Power Switch, so turn the rest On.
@ -422,6 +423,24 @@ void() setup_perk =
}
}
//
// Perk_UpdateQuickRevive()
// Tallies whether to make Quick Revive
// solo or co-op accessible.
//
void() Perk_UpdateQuickRevive =
{
entity revives = find(world, classname, "perk_revive");
while(revives != world) {
Light_None(revives);
revives.think = setup_perk;
revives.nextthink = time + 0.1;
revives = find(revives, classname, "perk_revive");
}
}
//
// --------------------
// Perk Entity Spawn Functions

View file

@ -29,6 +29,7 @@
void(entity e) Light_None;
void() Spawns_Init;
void() Perk_UpdateQuickRevive;
#define PLAYER_START_HEALTH 100
@ -605,7 +606,6 @@ void() PlayerSpawn =
{
if(who)
{
coop = 1;
player_count++;
break;
}
@ -726,6 +726,7 @@ void() PutClientInServer =
#endif // FTE
Perk_UpdateQuickRevive();
};
//called when client disconnects from the server
@ -741,6 +742,8 @@ void() ClientDisconnect =
self.movetype = MOVETYPE_TOSS;
self.nextthink = -1;
setmodel(self, "models/sprites/null.spr");
Perk_UpdateQuickRevive();
};

View file

@ -43,7 +43,7 @@ float client_parse_override;
float(string params) Command_give =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue Give in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -68,7 +68,7 @@ float(string params) Command_give =
float(string params) Command_addmoney =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue Add Money in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -108,7 +108,7 @@ float(string params) Command_softrestart =
float(string params) Command_godmode =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue God Mode in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -124,7 +124,7 @@ float(string params) Command_godmode =
float(string params) Command_noclip =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue No-Clip in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -140,7 +140,7 @@ float(string params) Command_noclip =
float(string params) Command_powerup =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue spawn_pu in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}
@ -162,7 +162,7 @@ float(string params) Command_powerup =
float(string params) Command_tracedmgmultiplier =
{
// Anti-Cheat in Co-Op.
if (coop && cheats_have_been_activated == false) {
if (player_count && cheats_have_been_activated == false) {
bprint(PRINT_HIGH, "Someone tried to issue sv_tracedmgmultiplier in a Co-Op match. Nice try!\n");
return COMMAND_FAILURE;
}