Server: Re-Write GetDown

Now properly checks the weapons the player has to modify the last down
weapon. Also doesn't spawn the revive entity on solo.
This commit is contained in:
Steam Deck User 2022-12-27 16:23:17 -05:00
parent 4b62411685
commit a1f07c75f0
3 changed files with 146 additions and 71 deletions

View file

@ -194,97 +194,156 @@ void() rec_downed =
void() GetDown = void() GetDown =
{ {
float startframe; // 'Pro Gamer Move' achievement.
float endframe; if (rounds <= 1 && self.currentmag == 0 &&
local string modelname; self.currentmag2 == 0 && self.currentammo == 0 &&
self.secondarymag == 0 && self.secondarymag2 == 0 &&
if (rounds <= 1 && self.currentmag == 0 && self.currentmag2 == 0 && self.currentammo == 0 && self.secondarymag == 0 && self.secondaryammo == 0) {
self.secondarymag2 == 0 && self.secondaryammo == 0) {
GiveAchievement(9, self); GiveAchievement(9, self);
} }
playdown(); // Play Last Stand Animation
PAnim_GetDown1();
switch(self.stance) { // Force the player to prone.
case 2: if (self.stance == 2) self.new_ofs_z = self.view_ofs_z - 42;
self.new_ofs_z = self.view_ofs_z - 42; if (self.stance == 1) self.new_ofs_z = self.view_ofs_z - 24;
self.stance = 0; self.stance = 0;
break;
case 1:
self.new_ofs_z = self.view_ofs_z - 24;
self.stance = 0;
break;
default: break;
}
// remove third weapon // Get Rid of Mule Kick Weapon (FIXME -- this just obliterates the third slot)
self.thirdweapon = 0; self.thirdweapon = 0;
self.velocity = '-80 0 -80'; // Stop any old movement // Reset state
self.zoom = 0; self.velocity = self.zoom = 0;
self.downed = true; self.downed = true;
self.dive_delay = 0; self.dive_delay = 0;
self.movetype = MOVETYPE_NONE; self.movetype = MOVETYPE_NONE;
float gotalive = PollPlayersAlive(); float players_still_alive = PollPlayersAlive();
if ((coop && !gotalive) || (!coop && !(self.perks & P_REVIVE))) { if ((coop && !players_still_alive) || (!coop && !(self.perks & P_REVIVE))) {
EndGameSetup(); EndGameSetup();
return; return;
} else { } else {
self.health = 19; self.health = 19;
} }
// Initiate Self-Revive on Solo
if ((self.perks & P_REVIVE) && !coop) { if ((self.perks & P_REVIVE) && !coop) {
self.progress_bar = 10 + time; self.progress_bar = 10 + time;
self.progress_bar_time = 10; self.progress_bar_time = 10;
self.progress_bar_percent = 1; self.progress_bar_percent = 1;
self.downed = true;
} }
self.points = 10*rint((self.points*0.95)/10); // Calculate the loss in points, take away points from downed Player.
addmoney(self, 0, true); // used to call a broadcast float point_difference;
point_difference = self.points;
point_difference -= 10*rint((self.points*0.95)/10);
addmoney(self, point_difference * -1, false);
self.requirespower = point_difference;
// Broadcast that the player has downed.
BroadcastMessage(time + 3, 2); BroadcastMessage(time + 3, 2);
// Take away weapons and Perks
self.perks = 0; self.perks = 0;
SetPerk(self, self.perks);
self.weaponbk = self.weapon; self.weaponbk = self.weapon;
self.currentammobk = self.currentammo; self.currentammobk = self.currentammo;
self.currentmagbk = self.currentmag; self.currentmagbk = self.currentmag;
self.currentmagbk2 = self.currentmag2; self.currentmagbk2 = self.currentmag2;
if (self.weapon == W_BIATCH || self.secondaryweapon == W_BIATCH || self.progress_bar_percent > 0) { if(Util_PlayerHasWeapon(self, W_BIATCH, false) ||
self.weapon = W_BIATCH; Util_PlayerHasWeapon(self, W_RAY, true) ||
self.currentammo = 12; Util_PlayerHasWeapon(self, W_357, true)) {
self.currentmag = 6; float weapon_slot;
self.currentmag2 = 6; float total_ammo;
} else {
self.weapon = W_COLT; weapon_slot = Util_PlayerHasWeapon(self, W_RAY, true);
self.currentammo = 16; if (weapon_slot == 0) weapon_slot = Util_PlayerHasWeapon(self, W_BIATCH, false);
self.currentmag = 8; if (weapon_slot == 0) weapon_slot = Util_PlayerHasWeapon(self, W_357, true);
switch(weapon_slot) {
case 1:
total_ammo = self.currentmag + self.currentmag2 + self.currentammo;
break;
case 2:
total_ammo = self.secondarymag + self.secondarymag2 + self.secondaryammo;
self.weapon = self.secondaryweapon;
break;
} }
modelname = GetWeaponModel(self.weapon, 0); // If it's greater than the mag size, we can fill the magazine.
self.weaponmodel = modelname; if (total_ammo > getWeaponMag(self.weapon)) {
self.currentmag = getWeaponMag(self.weapon);
// subtract it from the total ammo
total_ammo -= self.currentmag;
} else {
self.currentmag = total_ammo;
total_ammo = 0;
}
// Check for dual wield mag too
if (IsDualWeapon(self.weapon)) {
if (total_ammo > getWeaponMag(self.weapon)) {
self.currentmag2 = getWeaponMag(self.weapon);
// subtract it from the total ammo
total_ammo -= self.currentmag2;
} else {
self.currentmag2 = total_ammo;
total_ammo = 0;
}
}
// Ray Gun has a special case where we DON'T fill its reserve
if (self.weapon != W_RAY && self.weapon != W_PORTER) {
// Now see if the reserve ammo is more than max downed capacity
if (total_ammo > getWeaponMag(self.weapon)*2) {
self.currentammo = getWeaponMag(self.weapon)*2;
} else {
// It's not so just fill it
self.currentammo = total_ammo;
}
} else {
self.currentammo = 0;
}
} else {
if (!coop) {
self.weapon = W_BIATCH;
self.currentammo = 12;
self.currentmag = self.currentmag2 = 6;
} else {
self.weapon = W_COLT;
self.currentmag = 8;
self.currentammo = 16;
}
}
// Play Switch Animation
self.weaponmodel = GetWeaponModel(self.weapon, 0);
SwitchWeapon(self.weapon); SwitchWeapon(self.weapon);
startframe = GetFrame(self.weapon,TAKE_OUT_START); float startframe = GetFrame(self.weapon,TAKE_OUT_START);
endframe = GetFrame(self.weapon,TAKE_OUT_END); float endframe = GetFrame(self.weapon,TAKE_OUT_END);
Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, modelname, false, S_BOTH); Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, self.weaponmodel, false, S_BOTH);
local entity revive; // Spawn Revive Sprite in Co-Op
if (coop) {
entity revive_sprite;
revive = spawn (); revive_sprite = spawn();
revive.owner = self; revive_sprite.owner = self;
revive.movetype = MOVETYPE_NONE; revive_sprite.movetype = MOVETYPE_NONE;
revive.solid = SOLID_NOT; revive_sprite.solid = SOLID_NOT;
revive.think = remove_revive; revive_sprite.think = remove_revive;
revive.nextthink = time + 0.1; revive_sprite.nextthink = time + 0.1;
setmodel (revive, "models/sprites/revive.spr"); setmodel(revive_sprite, "models/sprites/revive.spr");
revive.origin = self.origin + VEC_VIEW_OFS; revive_sprite.origin = self.origin + VEC_VIEW_OFS;
setorigin (revive, revive.origin); setorigin(revive_sprite, revive_sprite.origin);
}
SetPerk(self, 0);
self.think = rec_downed; self.think = rec_downed;
self.nextthink = time + 0.1; self.nextthink = time + 0.1;
@ -304,6 +363,15 @@ void () GetUp =
self.downedloop = 0; // used for death timing vs endgame self.downedloop = 0; // used for death timing vs endgame
self.downed = 0; self.downed = 0;
self.classname = "player"; self.classname = "player";
// Take away the ammo that was fired while in last stand.
if (self.weapon == self.weaponbk) {
self.currentammobk -= self.teslacount;
} else if (self.weapon == self.secondaryweapon) {
self.secondaryammo -= self.teslacount;
}
self.teslacount = 0;
if (self.weaponbk) if (self.weaponbk)
{ {
self.weapon = self.weaponbk; self.weapon = self.weaponbk;

View file

@ -29,14 +29,18 @@
void(entity e) Light_None; void(entity e) Light_None;
// player animations //
// Player 3rd Person Animations
//
// Enter Last Stand
void() PAnim_GetDown1 =[ 1, PAnim_GetDown2 ] {self.frame = 32;};
void() PAnim_GetDown2 =[ 1, PAnim_GetDown3 ] {self.frame = 33;};
void() PAnim_GetDown3 =[ 1, PAnim_GetDown4 ] {self.frame = 34;};
void() PAnim_GetDown4 =[ 1, PAnim_GetDown5 ] {self.frame = 35;};
void() PAnim_GetDown5 =[ 1, PAnim_GetDown6 ] {self.frame = 36;};
void() PAnim_GetDown6 =[ 1, PAnim_GetDown6 ] {self.frame = 37;};
void() playdown =[ 1, playdown1 ] {self.frame = 32;}
void() playdown1 =[ 2, playdown2 ] {self.frame = 33;}
void() playdown2 =[ 2, playdown3 ] {self.frame = 34;}
void() playdown3 =[ 2, playdown4 ] {self.frame = 35;}
void() playdown4 =[ 2, playdown5 ] {self.frame = 36;}
void() playdown5 =[ 2, playdown5 ] {self.frame = 37;}
// //
void() playreload =[ 1, playreload1 ] {self.frame = 11;} void() playreload =[ 1, playreload1 ] {self.frame = 11;}
void() playreload1 =[ 2, playreload2 ] {self.frame = 12;} void() playreload1 =[ 2, playreload2 ] {self.frame = 12;}

View file

@ -1563,6 +1563,9 @@ void(float side) W_Fire =
startframe = GetFrame(self.weapon,FIRE_START); startframe = GetFrame(self.weapon,FIRE_START);
endframe = GetFrame(self.weapon,FIRE_END); endframe = GetFrame(self.weapon,FIRE_END);
// Increment the amount of shots fired while downed
if (self.downed == true)
self.teslacount++;
if (self.perks & P_DOUBLE) { if (self.perks & P_DOUBLE) {
delay *= 0.66; delay *= 0.66;