mirror of
https://github.com/nzp-team/quakec.git
synced 2025-02-20 18:52:36 +00:00
SERVER: Total weapon storage revamp
This commit is contained in:
parent
7e64e8468a
commit
1f3280a10f
13 changed files with 394 additions and 469 deletions
|
@ -595,31 +595,6 @@ float() crandom =
|
|||
return 2*(random() - 0.5);
|
||||
}
|
||||
|
||||
void WeaponSwitch(entity player) {
|
||||
float wep, cmag, cmag2, cammo;
|
||||
|
||||
wep = other.weapon;
|
||||
other.weapon = other.secondaryweapon;
|
||||
other.secondaryweapon = wep;
|
||||
|
||||
cmag = other.currentmag;
|
||||
other.currentmag = other.secondarymag;
|
||||
other.secondarymag = cmag;
|
||||
|
||||
cmag2 = other.currentmag2;
|
||||
other.currentmag2 = other.secondarymag2;
|
||||
other.secondarymag2 = cmag2;
|
||||
|
||||
cammo = other.currentammo;
|
||||
other.currentammo = other.secondaryammo;
|
||||
other.secondaryammo = cammo;
|
||||
|
||||
entity tempe = self;
|
||||
self = player;
|
||||
SwitchWeapon(other.weapon);
|
||||
self = tempe;
|
||||
}
|
||||
|
||||
void(entity person, float expamt, float doublepoint) addmoney =
|
||||
{
|
||||
if (person.classname != "player" || person.downed)
|
||||
|
|
|
@ -184,10 +184,10 @@ void() rec_downed =
|
|||
void() GetDown =
|
||||
{
|
||||
// 'Pro Gamer Move' achievement.
|
||||
if (rounds <= 1 && self.currentmag == 0 &&
|
||||
self.currentmag2 == 0 && self.currentammo == 0 &&
|
||||
self.secondarymag == 0 && self.secondarymag2 == 0 &&
|
||||
self.secondaryammo == 0) {
|
||||
if (rounds <= 1 && self.weapons[0].weapon_magazine == 0 &&
|
||||
self.weapons[0].weapon_magazine_left == 0 && self.weapons[0].weapon_reserve == 0 &&
|
||||
self.weapons[1].weapon_magazine == 0 && self.weapons[1].weapon_magazine_left == 0 &&
|
||||
self.weapons[1].weapon_reserve == 0) {
|
||||
GiveAchievement(9, self);
|
||||
}
|
||||
|
||||
|
@ -199,8 +199,17 @@ void() GetDown =
|
|||
if (self.stance == 1) self.new_ofs_z = self.view_ofs_z - 24;
|
||||
self.stance = 0;
|
||||
|
||||
// Get Rid of Mule Kick Weapon (FIXME -- this just obliterates the third slot)
|
||||
self.thirdweapon = 0;
|
||||
// Get rid of Mule Kick Weapon
|
||||
if (self.weapons[0].is_mulekick_weapon == true)
|
||||
Weapon_SwapWeapons(false);
|
||||
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
if (self.weapons[i].is_mulekick_weapon == true) {
|
||||
self.weapons[i].weapon_id = 0;
|
||||
self.weapons[i].is_mulekick_weapon = false;
|
||||
}
|
||||
}
|
||||
Weapon_FixUpList();
|
||||
|
||||
// Calculate the loss in points, take away points from downed Player.
|
||||
float point_difference;
|
||||
|
@ -237,10 +246,11 @@ void() GetDown =
|
|||
// Take away weapons and Perks
|
||||
self.perks = 0;
|
||||
SetPerk(self, self.perks);
|
||||
|
||||
self.weaponbk = self.weapon;
|
||||
self.currentammobk = self.currentammo;
|
||||
self.currentmagbk = self.currentmag;
|
||||
self.currentmagbk2 = self.currentmag2;
|
||||
self.currentammobk = self.weapons[0].weapon_reserve;
|
||||
self.currentmagbk = self.weapons[0].weapon_magazine;
|
||||
self.currentmagbk2 = self.weapons[0].weapon_magazine_left;
|
||||
|
||||
// Reset Juggernog health
|
||||
self.max_health = self.health = PLAYER_START_HEALTH;
|
||||
|
@ -258,34 +268,39 @@ void() GetDown =
|
|||
|
||||
switch(weapon_slot) {
|
||||
case 1:
|
||||
total_ammo = self.currentmag + self.currentmag2 + self.currentammo;
|
||||
total_ammo = self.weapons[0].weapon_magazine + self.weapons[0].weapon_magazine_left + self.weapons[0].weapon_reserve;
|
||||
break;
|
||||
case 2:
|
||||
total_ammo = self.secondarymag + self.secondarymag2 + self.secondaryammo;
|
||||
self.weapon = self.secondaryweapon;
|
||||
total_ammo = self.weapons[1].weapon_magazine + self.weapons[1].weapon_magazine_left + self.weapons[1].weapon_reserve;
|
||||
Weapon_SwapWeapons(false);
|
||||
break;
|
||||
}
|
||||
|
||||
self.weaponbk = self.weapon;
|
||||
self.currentammobk = self.weapons[0].weapon_reserve;
|
||||
self.currentmagbk = self.weapons[0].weapon_magazine;
|
||||
self.currentmagbk2 = self.weapons[0].weapon_magazine_left;
|
||||
|
||||
// If it's greater than the mag size, we can fill the magazine.
|
||||
if (total_ammo > getWeaponMag(self.weapon)) {
|
||||
self.currentmag = getWeaponMag(self.weapon);
|
||||
self.weapons[0].weapon_magazine = getWeaponMag(self.weapon);
|
||||
|
||||
// subtract it from the total ammo
|
||||
total_ammo -= self.currentmag;
|
||||
total_ammo -= self.weapons[0].weapon_magazine;
|
||||
} else {
|
||||
self.currentmag = total_ammo;
|
||||
self.weapons[0].weapon_magazine = 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);
|
||||
self.weapons[0].weapon_magazine_left = getWeaponMag(self.weapon);
|
||||
|
||||
// subtract it from the total ammo
|
||||
total_ammo -= self.currentmag2;
|
||||
total_ammo -= self.weapons[0].weapon_magazine_left;
|
||||
} else {
|
||||
self.currentmag2 = total_ammo;
|
||||
self.weapons[0].weapon_magazine_left = total_ammo;
|
||||
total_ammo = 0;
|
||||
}
|
||||
}
|
||||
|
@ -294,23 +309,19 @@ void() GetDown =
|
|||
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;
|
||||
self.weapons[0].weapon_reserve = getWeaponMag(self.weapon)*2;
|
||||
} else {
|
||||
// It's not so just fill it
|
||||
self.currentammo = total_ammo;
|
||||
self.weapons[0].weapon_reserve = total_ammo;
|
||||
}
|
||||
} else {
|
||||
self.currentammo = 0;
|
||||
self.weapons[0].weapon_reserve = 0;
|
||||
}
|
||||
} else {
|
||||
if (!coop) {
|
||||
self.weapon = W_BIATCH;
|
||||
self.currentammo = 12;
|
||||
self.currentmag = self.currentmag2 = 6;
|
||||
Weapon_AssignWeapon(0, W_BIATCH, 6, 12);
|
||||
} else {
|
||||
self.weapon = W_COLT;
|
||||
self.currentmag = 8;
|
||||
self.currentammo = 16;
|
||||
Weapon_AssignWeapon(0, W_COLT, 8, 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,11 +345,7 @@ void() GetDown =
|
|||
}
|
||||
|
||||
void () GetUp =
|
||||
{
|
||||
local string modelname;
|
||||
float startframe;
|
||||
float endframe;
|
||||
|
||||
{
|
||||
playgetup(); // animation
|
||||
|
||||
self.new_ofs_z = self.view_ofs_z + 42;
|
||||
|
@ -358,13 +365,13 @@ void () GetUp =
|
|||
self.currentmagbk += self.currentammobk;
|
||||
self.currentammobk = 0;
|
||||
}
|
||||
} else if (self.weapon == self.secondaryweapon) {
|
||||
self.secondaryammo -= self.teslacount;
|
||||
} else if (self.weapon == self.weapons[1].weapon_id) {
|
||||
self.weapons[1].weapon_reserve -= self.teslacount;
|
||||
|
||||
// Take from the mag if the reserve is empty now
|
||||
if (self.secondaryammo < 0) {
|
||||
self.secondarymag += self.secondaryammo;
|
||||
self.secondaryammo = 0;
|
||||
if (self.weapons[1].weapon_reserve < 0) {
|
||||
self.weapons[0].weapon_magazine += self.weapons[1].weapon_reserve;
|
||||
self.weapons[1].weapon_reserve = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,23 +382,8 @@ void () GetUp =
|
|||
addmoney(self, self.requirespower, false);
|
||||
}
|
||||
|
||||
if (self.weaponbk)
|
||||
{
|
||||
self.weapon = self.weaponbk;
|
||||
self.currentammo = self.currentammobk;
|
||||
self.currentmag = self.currentmagbk;
|
||||
self.currentmag2 = self.currentmagbk2;
|
||||
}
|
||||
modelname = GetWeaponModel(self.weapon, 0);
|
||||
self.weaponmodel = modelname;
|
||||
SwitchWeapon(self.weapon);
|
||||
self.weapon2model = GetWeapon2Model(self.weapon);
|
||||
self.movetype = MOVETYPE_WALK;
|
||||
|
||||
startframe = GetFrame(self.weapon,TAKE_OUT_START);
|
||||
endframe = GetFrame(self.weapon,TAKE_OUT_END);
|
||||
Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, modelname, false, S_BOTH);
|
||||
|
||||
Weapon_AssignWeapon(0, self.weaponbk, self.currentmagbk, self.currentammobk);
|
||||
};
|
||||
|
||||
// poll checking whether to see if our revive invoke is active
|
||||
|
|
|
@ -130,8 +130,6 @@ void(entity person, float expamt , float doublepoint) addmoney;
|
|||
float sprint_max_time = 4.0;
|
||||
.float sprinting;
|
||||
.float weaponskin;
|
||||
.float secondaryweaponskin;
|
||||
.float thirdweaponskin;
|
||||
.float stamina;
|
||||
.float sprint_timer;
|
||||
.float sprint_duration;
|
||||
|
@ -167,26 +165,33 @@ void (float shotcount, float sprd, float Damage, float side) FireTrace;
|
|||
.float currentmagbk;
|
||||
.float currentmagbk2;
|
||||
.float currentammobk;
|
||||
.float secondaryammo;
|
||||
.float thirdammo;
|
||||
.float semi;
|
||||
.float semi2;
|
||||
.float semiuse;
|
||||
.float semiswitch; // Weapon Swap Toggle
|
||||
.float seminade; // Grenade Toggle
|
||||
.float semireload;
|
||||
.float secondarymag;
|
||||
.float secondarymag2;
|
||||
.float secondaryweapon;
|
||||
.float thirdmag;
|
||||
.float thirdmag2;
|
||||
.float thirdweapon;
|
||||
.float NeedLoad;
|
||||
.string weapon2model;
|
||||
.float weapon2frame;
|
||||
.float reloadinterupted;
|
||||
.float hitcount;
|
||||
.float weaponnum; // 0 for weapon one, 1 for second weapon...we invert value for easy comparison, a third gun would need to be hardwired
|
||||
|
||||
#define MAX_PLAYER_WEAPONS 3
|
||||
#define MULEKICK_WEAPON_SLOT 3
|
||||
|
||||
var struct guninventory_struct
|
||||
{
|
||||
float weapon_id;
|
||||
float weapon_magazine;
|
||||
float weapon_magazine_left;
|
||||
float weapon_reserve;
|
||||
float weapon_skin;
|
||||
float is_mulekick_weapon;
|
||||
};
|
||||
|
||||
.guninventory_struct weapons[MAX_PLAYER_WEAPONS];
|
||||
.float weapon_count;
|
||||
|
||||
//Reviving
|
||||
.float invoke_revive;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
float backupWepSkin;
|
||||
float sound_perk_delay;
|
||||
void() W_Switch;
|
||||
void() W_TakeOut;
|
||||
|
||||
//
|
||||
|
@ -1185,18 +1184,7 @@ void PapUpgrade(entity pap, entity buyer) {
|
|||
|
||||
pap.weapon = self.weapon;
|
||||
|
||||
self.weapon = self.secondaryweapon;
|
||||
self.currentammo = self.secondaryammo;
|
||||
self.currentmag = self.secondarymag;
|
||||
self.currentmag2 = self.secondarymag2;
|
||||
self.secondaryweapon = 0;
|
||||
self.secondaryammo = 0;
|
||||
self.secondarymag = 0;
|
||||
self.secondarymag2 = 0;
|
||||
|
||||
self.isBuying = true;
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
Weapon_RemoveWeapon(0);
|
||||
Set_W_Frame (0, 39, 2.0, 0, 0, W_PlayTakeOut, "models/machines/v_pap.mdl", true, S_BOTH);
|
||||
self.weapon2model = "";
|
||||
UpdateV2model(self.weapon2model, 0);
|
||||
|
@ -1254,43 +1242,10 @@ void touch_pap() {
|
|||
useprint (other, 7, 0, EqualPapWeapon(self.weapon));
|
||||
|
||||
if (other.button7) {
|
||||
// Back-up current weapon into second slot, it's getting replaced.
|
||||
if (!other.secondaryweapon && other.weapon != EqualPapWeapon(self.weapon)) {
|
||||
other.secondaryweapon = other.weapon;
|
||||
other.secondarymag = other.currentmag;
|
||||
other.secondarymag2 = other.currentmag2;
|
||||
other.secondaryammo = other.currentammo;
|
||||
}
|
||||
|
||||
other.weapon = EqualPapWeapon(self.weapon);
|
||||
other.currentammo = getWeaponAmmo(other.weapon);
|
||||
other.currentmag = getWeaponMag(other.weapon);
|
||||
|
||||
if (IsDualWeapon(other.weapon)) {
|
||||
other.currentmag2 = other.currentmag;
|
||||
}
|
||||
|
||||
entity tempe = self;
|
||||
self = other;
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
|
||||
if (GetFrame(self.weapon, FIRST_TAKE_START) != 0)
|
||||
Weapon_PlayViewModelAnimation(ANIM_FIRST_TAKE, SUB_Null, 0);
|
||||
else
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Flash_Offset = GetWeaponFlash_Offset(self.weapon);
|
||||
self.Flash_Size = GetWeaponFlash_Size(self.weapon);
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
self.weaponskin = GetWepSkin(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
entity tempe = self;
|
||||
self = other;
|
||||
Weapon_GiveWeapon(EqualPapWeapon(tempe.weapon), 0, 0);
|
||||
self = tempe;
|
||||
|
||||
// because PaP broke itself
|
||||
self.think = reset_pap;
|
||||
self.nextthink = time + 0.1;
|
||||
|
|
|
@ -685,91 +685,11 @@ void() MBOX_Touch =
|
|||
{
|
||||
other.reload_delay = 0;
|
||||
self.owner = world;
|
||||
if (other.weapon != self.boxweapon.weapon && other.secondaryweapon != self.boxweapon.weapon && other.secondaryweapon && other.thirdweapon != self.boxweapon.weapon)
|
||||
{
|
||||
if ((other.perks & P_MULE) && !other.thirdweapon) {
|
||||
// store secondary weapon
|
||||
local float tempf = other.secondaryweapon;
|
||||
local float tempf1 = other.secondarymag;
|
||||
local float tempf2 = other.secondaryammo;
|
||||
local float tempf3 = other.secondarymag2;
|
||||
// move primary to secondary
|
||||
other.secondaryweapon = other.weapon;
|
||||
other.secondarymag = other.currentmag;
|
||||
other.secondarymag2 = other.currentmag2;
|
||||
other.secondaryammo = other.currentammo;
|
||||
// move secondary to tertiary
|
||||
other.thirdweapon = tempf;
|
||||
other.thirdmag = tempf1;
|
||||
other.thirdammo = tempf2;
|
||||
other.thirdmag2 = tempf3;
|
||||
}
|
||||
|
||||
// give boxweapon
|
||||
other.weapon = self.boxweapon.weapon;
|
||||
other.currentammo = getWeaponAmmo(self.boxweapon.weapon);
|
||||
other.currentmag = getWeaponMag(self.boxweapon.weapon);
|
||||
other.weaponskin = 0;
|
||||
|
||||
if (other.weapon != W_KAR_SCOPE && other.weapon != W_HEADCRACKER && !IsDualWeapon(other.weapon)) {
|
||||
other.weapon2model = "";
|
||||
}
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
other.Flash_Offset = GetWeaponFlash_Offset(self.boxweapon.weapon);
|
||||
other.Flash_Size = GetWeaponFlash_Size(self.boxweapon.weapon);
|
||||
other.Weapon_Name = GetWeaponName(self.boxweapon.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
}
|
||||
else if (other.weapon == self.boxweapon.weapon)
|
||||
{
|
||||
other.currentammo = getWeaponAmmo(self.boxweapon.weapon);
|
||||
other.currentmag = getWeaponMag(self.boxweapon.weapon);
|
||||
}
|
||||
else if (other.secondaryweapon == self.boxweapon.weapon)
|
||||
{
|
||||
other.secondaryammo = getWeaponAmmo(self.boxweapon.weapon);
|
||||
other.secondarymag = getWeaponMag(self.boxweapon.weapon);
|
||||
}
|
||||
else if (other.thirdweapon == self.boxweapon.weapon)
|
||||
{
|
||||
other.thirdammo = getWeaponAmmo(self.boxweapon.weapon);
|
||||
other.thirdmag = getWeaponMag(self.boxweapon.weapon);
|
||||
}
|
||||
else if (!other.secondaryweapon)
|
||||
{
|
||||
WeaponSwitch(other);
|
||||
other.weapon = self.boxweapon.weapon;
|
||||
other.currentammo = getWeaponAmmo(self.boxweapon.weapon);
|
||||
other.currentmag = getWeaponMag(self.boxweapon.weapon);
|
||||
other.weaponskin = GetWepSkin(self.boxweapon.weapon);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
other.Flash_Offset = GetWeaponFlash_Offset(self.boxweapon.weapon);
|
||||
other.Flash_Size = GetWeaponFlash_Size(self.boxweapon.weapon);
|
||||
other.Weapon_Name = GetWeaponName(self.boxweapon.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
}
|
||||
else if (!other.thirdweapon && (other.perks & P_MULE))
|
||||
{
|
||||
|
||||
}
|
||||
sound(self, 0,"sounds/misc/ching.wav", 1, 1);
|
||||
tempe = self;
|
||||
self = other;
|
||||
|
||||
if (GetFrame(self.weapon, FIRST_TAKE_START) != 0)
|
||||
Weapon_PlayViewModelAnimation(ANIM_FIRST_TAKE, SUB_Null, 0);
|
||||
else
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
Weapon_GiveWeapon(tempe.boxweapon.weapon, 0, 0);
|
||||
self = tempe;
|
||||
MBOX_FreeEnt(self.boxweapon);
|
||||
MBOX_PlayCloseAnimation();
|
||||
|
|
|
@ -435,12 +435,10 @@ void() PU_MaxAmmo =
|
|||
while(tempe) {
|
||||
|
||||
if (!tempe.downed) {
|
||||
// Fill Primary Weapon
|
||||
if (tempe.weapon) tempe.currentammo = getWeaponAmmo(tempe.weapon);
|
||||
// Fill Secondary Weapon
|
||||
if (tempe.secondaryweapon) tempe.secondaryammo = getWeaponAmmo(tempe.secondaryweapon);
|
||||
// Fill Third Weapon
|
||||
if (tempe.thirdweapon) tempe.thirdammo = getWeaponAmmo(tempe.thirdweapon);
|
||||
// Fill all weapons
|
||||
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
tempe.weapons[i].weapon_reserve = getWeaponAmmo(tempe.weapons[i].weapon_id);
|
||||
}
|
||||
// Give Grenades
|
||||
tempe.primary_grenades = 4;
|
||||
// Give Betties
|
||||
|
|
|
@ -133,7 +133,6 @@ void() weapon_wall =
|
|||
void () WallWeapon_TouchTrigger =
|
||||
{
|
||||
entity oldent;
|
||||
float tempf, tempf1, tempf2, tempf3;
|
||||
|
||||
float wcost;
|
||||
|
||||
|
@ -363,47 +362,6 @@ void () WallWeapon_TouchTrigger =
|
|||
other.semiuse = true;
|
||||
other.ach_tracker_coll++;
|
||||
|
||||
if (other.weapon && !other.secondaryweapon) {
|
||||
tempf = other.currentammo;
|
||||
other.currentammo = other.secondaryammo;
|
||||
other.secondaryammo = tempf;
|
||||
|
||||
tempf1 = other.currentmag;
|
||||
other.currentmag = other.secondarymag;
|
||||
other.secondarymag = tempf1;
|
||||
|
||||
tempf2 = other.weapon;
|
||||
other.weapon = other.secondaryweapon;
|
||||
other.secondaryweapon = tempf2;
|
||||
|
||||
tempf3 = other.currentmag2;
|
||||
other.currentmag2 = other.secondarymag2;
|
||||
other.secondarymag2 = tempf3;
|
||||
} else if (other.weapon && other.secondaryweapon) {
|
||||
if ((other.perks & P_MULE) && !other.thirdweapon) {
|
||||
// store secondary weapon
|
||||
tempf = other.secondaryweapon;
|
||||
tempf1 = other.secondarymag;
|
||||
tempf2 = other.secondaryammo;
|
||||
tempf3 = other.secondarymag2;
|
||||
// move primary to secondary
|
||||
other.secondaryweapon = other.weapon;
|
||||
other.secondarymag = other.currentmag;
|
||||
other.secondarymag2 = other.currentmag2;
|
||||
other.secondaryammo = other.currentammo;
|
||||
// move secondary to tertiary
|
||||
other.thirdweapon = tempf;
|
||||
other.thirdmag = tempf1;
|
||||
other.thirdammo = tempf2;
|
||||
other.thirdmag2 = tempf3;
|
||||
}
|
||||
|
||||
// free current slot
|
||||
other.currentammo = 0;
|
||||
other.currentmag = 0;
|
||||
other.weapon = 0;
|
||||
}
|
||||
|
||||
sound(other, 0, "sounds/misc/ching.wav", 1, 1);
|
||||
other.reload_delay = 0;
|
||||
addmoney(other, -1*self.cost, 0);
|
||||
|
@ -413,27 +371,10 @@ void () WallWeapon_TouchTrigger =
|
|||
self.use();
|
||||
self = oldent;
|
||||
}
|
||||
other.weapon = self.weapon;
|
||||
|
||||
other.currentammo = getWeaponAmmo(self.weapon);
|
||||
other.currentmag = getWeaponMag(self.weapon);
|
||||
tempe = self;
|
||||
self = other;
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
|
||||
if (GetFrame(self.weapon, FIRST_TAKE_START) != 0)
|
||||
Weapon_PlayViewModelAnimation(ANIM_FIRST_TAKE, SUB_Null, 0);
|
||||
else
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Flash_Offset = GetWeaponFlash_Offset(self.weapon);
|
||||
self.Flash_Size = GetWeaponFlash_Size(self.weapon);
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
Weapon_GiveWeapon(tempe.weapon, 0, 0);
|
||||
|
||||
self = tempe;
|
||||
}
|
||||
|
|
|
@ -302,8 +302,8 @@ void() worldspawn =
|
|||
|
||||
#ifdef FTE
|
||||
|
||||
clientstat(STAT_CURRENTMAG, EV_FLOAT, currentmag);
|
||||
clientstat(STAT_CURRENTMAG2, EV_FLOAT, currentmag2);
|
||||
clientstat(STAT_CURRENTMAG, EV_FLOAT, weapons[0].weapon_magazine);
|
||||
clientstat(STAT_CURRENTMAG2, EV_FLOAT, weapons[0].weapon_magazine_left);
|
||||
clientstat(STAT_POINTS, EV_FLOAT, points);
|
||||
clientstat(STAT_WEAPON2FRAME, EV_FLOAT, weapon2frame);
|
||||
clientstat(STAT_WEAPON2MODEL, EV_STRING, weapon2model);
|
||||
|
|
|
@ -337,6 +337,14 @@ void() PlayerPreThink =
|
|||
|
||||
self.ltime = time + 0.1;
|
||||
}
|
||||
|
||||
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
if (self.weapons[i].is_mulekick_weapon == true) {
|
||||
string third_wep = GetWeaponName(self.weapons[i].weapon_id);
|
||||
centerprint(self, strcat(third_wep, "\n"));
|
||||
}
|
||||
}
|
||||
//centerprint(self, strcat(GetWeaponName(self.weapons[0].weapon_id), "\n"));
|
||||
};
|
||||
|
||||
float player_trace_time;
|
||||
|
@ -623,10 +631,8 @@ void() PlayerSpawn =
|
|||
self.new_ofs_z = self.view_ofs_z;
|
||||
self.oldz = self.origin_z;
|
||||
|
||||
self.currentammo = G_STARTWEAPON[2];
|
||||
self.currentmag = G_STARTWEAPON[1];
|
||||
self.weapon = G_STARTWEAPON[0];
|
||||
self.grenades = self.grenades | 1; // add frag grenades to player inventory
|
||||
Weapon_GiveWeapon(G_STARTWEAPON[0], G_STARTWEAPON[1], G_STARTWEAPON[2]);
|
||||
|
||||
if (rounds)
|
||||
self.primary_grenades = 2;
|
||||
|
@ -646,7 +652,6 @@ void() PlayerSpawn =
|
|||
|
||||
self.stamina = 3;
|
||||
self.reviving = 0;
|
||||
self.weaponnum = 0;
|
||||
self.perks = G_PERKS;
|
||||
SetPerk(self, self.perks);
|
||||
|
||||
|
|
|
@ -49,27 +49,7 @@ float(string params) Command_give =
|
|||
float wep = stof(argv(1));
|
||||
|
||||
if (wep) {
|
||||
self.weapon = wep;
|
||||
self.currentammo = getWeaponAmmo(wep);
|
||||
self.currentmag = getWeaponMag(wep);
|
||||
if (IsDualWeapon(wep)) {
|
||||
self.currentmag2 = self.currentmag;
|
||||
}
|
||||
|
||||
if (GetFrame(self.weapon, FIRST_TAKE_START) != 0)
|
||||
Weapon_PlayViewModelAnimation(ANIM_FIRST_TAKE, SUB_Null, 0);
|
||||
else
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
|
||||
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = 0;
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
Weapon_GiveWeapon(wep, 0, 0);
|
||||
|
||||
return COMMAND_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -350,7 +350,10 @@ void() Soft_Restart = {
|
|||
rounds = 0;
|
||||
self.score = 0;
|
||||
self.points = 0;
|
||||
self.secondaryweapon = 0;
|
||||
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
self.weapons[i].weapon_id = 0;
|
||||
}
|
||||
|
||||
// naievil -- clear betty
|
||||
self.secondary_grenades = 0;
|
||||
|
|
|
@ -26,6 +26,15 @@
|
|||
|
||||
*/
|
||||
|
||||
// FTEQCC currently has an optimization bug with -fastarrays
|
||||
// that leads to corruption with the weapon list. Disable
|
||||
// if we're not on FTE.
|
||||
#ifndef FTE
|
||||
|
||||
#pragma flag disable fastarrays
|
||||
|
||||
#endif // FTE
|
||||
|
||||
// TODO: Actually implement some of these..
|
||||
// Frame types, generalized.
|
||||
#define ANIM_FIRE 0
|
||||
|
@ -39,6 +48,7 @@
|
|||
#define ANIM_AIM 8
|
||||
|
||||
void() W_AimOut;
|
||||
void() ReturnWeaponModel;
|
||||
|
||||
//
|
||||
// Weapon_GetPlayerAmmoInSlot(person, slot)
|
||||
|
@ -47,9 +57,9 @@ void() W_AimOut;
|
|||
float(entity person, float slot) Weapon_GetPlayerAmmoInSlot =
|
||||
{
|
||||
switch(slot) {
|
||||
case 1: return person.currentammo;
|
||||
case 2: return person.secondaryammo;
|
||||
case 3: return person.thirdammo;
|
||||
case 1: return person.weapons[0].weapon_reserve;
|
||||
case 2: return person.weapons[1].weapon_reserve;
|
||||
case 3: return person.weapons[2].weapon_reserve;
|
||||
default: return 0;
|
||||
}
|
||||
};
|
||||
|
@ -61,9 +71,9 @@ float(entity person, float slot) Weapon_GetPlayerAmmoInSlot =
|
|||
void(entity person, float slot, float ammo) Weapon_SetPlayerAmmoInSlot =
|
||||
{
|
||||
switch(slot) {
|
||||
case 1: person.currentammo = ammo; break;
|
||||
case 2: person.secondaryammo = ammo; break;
|
||||
case 3: person.thirdammo = ammo; break;
|
||||
case 1: person.weapons[0].weapon_reserve = ammo; break;
|
||||
case 2: person.weapons[1].weapon_reserve = ammo; break;
|
||||
case 3: person.weapons[2].weapon_reserve = ammo; break;
|
||||
default: return; break;
|
||||
}
|
||||
};
|
||||
|
@ -77,29 +87,22 @@ void(entity person, float slot, float ammo) Weapon_SetPlayerAmmoInSlot =
|
|||
//
|
||||
float(entity person, float comparison, float include_pap) Weapon_PlayerHasWeapon =
|
||||
{
|
||||
// Storage.
|
||||
float first, second, third;
|
||||
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
// Storage.
|
||||
float weapon_id;
|
||||
|
||||
// If we're including pap'd weapons, just convert the weapon set to the base
|
||||
// ones to save on comparison checks.
|
||||
if (include_pap == true) {
|
||||
first = EqualNonPapWeapon(person.weapon);
|
||||
second = EqualNonPapWeapon(person.secondaryweapon);
|
||||
third = EqualNonPapWeapon(person.thirdweapon);
|
||||
} else {
|
||||
first = person.weapon;
|
||||
second = person.secondaryweapon;
|
||||
third = person.thirdweapon;
|
||||
// If we're including pap'd weapons, just convert the weapon set to the base
|
||||
// ones to save on comparison checks.
|
||||
if (include_pap == true)
|
||||
weapon_id = EqualNonPapWeapon(person.weapons[i].weapon_id);
|
||||
else
|
||||
weapon_id = person.weapons[i].weapon_id;
|
||||
|
||||
// Now do the comparison
|
||||
if (weapon_id == comparison)
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
// Now do the comparisons
|
||||
if (first == comparison)
|
||||
return 1;
|
||||
if (second == comparison)
|
||||
return 2;
|
||||
if (third == comparison)
|
||||
return 3;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
@ -185,4 +188,233 @@ void (float animation_type, void(optional float t) end_function, float playback_
|
|||
|
||||
W_AimOut();
|
||||
Set_W_Frame(start_frame, end_frame, playback_duration, 0, 0, end_function, GetWeaponModel(self.weapon, 0), false, S_BOTH);
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// Weapon_SwapWeapons()
|
||||
// Performs a standard weapon swap.
|
||||
//
|
||||
void Weapon_SwapWeapons(float play_animation)
|
||||
{
|
||||
float weapon_count = 0;
|
||||
|
||||
// Un-zoom camera
|
||||
self.zoom = false;
|
||||
|
||||
// Fix fire rate exploit
|
||||
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = true;
|
||||
|
||||
// Store current weapons locally
|
||||
guninventory_struct weapons_storage[MAX_PLAYER_WEAPONS];
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
if (self.weapons[i].weapon_id != 0) {
|
||||
weapon_count++;
|
||||
weapons_storage[i].weapon_id = self.weapons[i].weapon_id;
|
||||
weapons_storage[i].weapon_magazine = self.weapons[i].weapon_magazine;
|
||||
weapons_storage[i].weapon_magazine_left = self.weapons[i].weapon_magazine_left;
|
||||
weapons_storage[i].weapon_reserve = self.weapons[i].weapon_reserve;
|
||||
weapons_storage[i].weapon_skin = self.weapons[i].weapon_skin;
|
||||
weapons_storage[i].is_mulekick_weapon = self.weapons[i].is_mulekick_weapon;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over the player inventory and shift the array around!
|
||||
for(float j = 0; j < weapon_count; j++) {
|
||||
if (j != weapon_count - 1) {
|
||||
self.weapons[j + 1].weapon_id = weapons_storage[j].weapon_id;
|
||||
self.weapons[j + 1].weapon_magazine = weapons_storage[j].weapon_magazine;
|
||||
self.weapons[j + 1].weapon_magazine_left = weapons_storage[j].weapon_magazine_left;
|
||||
self.weapons[j + 1].weapon_reserve = weapons_storage[j].weapon_reserve;
|
||||
self.weapons[j + 1].weapon_skin = weapons_storage[j].weapon_skin;
|
||||
self.weapons[j + 1].is_mulekick_weapon = weapons_storage[j].is_mulekick_weapon;
|
||||
} else {
|
||||
self.weapons[0].weapon_id = weapons_storage[j].weapon_id;
|
||||
self.weapons[0].weapon_magazine = weapons_storage[j].weapon_magazine;
|
||||
self.weapons[0].weapon_magazine_left = weapons_storage[j].weapon_magazine_left;
|
||||
self.weapons[0].weapon_reserve = weapons_storage[j].weapon_reserve;
|
||||
self.weapons[0].weapon_skin = weapons_storage[j].weapon_skin;
|
||||
self.weapons[0].is_mulekick_weapon = weapons_storage[j].is_mulekick_weapon;
|
||||
}
|
||||
}
|
||||
|
||||
if (play_animation == true) {
|
||||
// Properly update the weapon ID
|
||||
self.weapon = self.weapons[0].weapon_id;
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, ReturnWeaponModel, 0);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
self.Flash_Offset = GetWeaponFlash_Offset(self.weapon);
|
||||
self.Flash_Size = GetWeaponFlash_Size(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Weapon_SetActiveInslot(slot)
|
||||
// Iterates through the Inventory array until weapon 0
|
||||
// is what was in the requested slot.
|
||||
//
|
||||
void Weapon_SetActiveInSlot(float slot, float play_first_raise)
|
||||
{
|
||||
if (slot != 0)
|
||||
Weapon_SwapWeapons(false);
|
||||
|
||||
// Properly update the weapon ID
|
||||
self.weapon = self.weapons[0].weapon_id;
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
|
||||
if (GetFrame(self.weapon, FIRST_TAKE_START) != 0 && play_first_raise == true)
|
||||
Weapon_PlayViewModelAnimation(ANIM_FIRST_TAKE, SUB_Null, 0);
|
||||
else
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
self.Flash_Offset = GetWeaponFlash_Offset(self.weapon);
|
||||
self.Flash_Size = GetWeaponFlash_Size(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Weapon_AssignWeapon(weapon_slot, weapon_id, weapon_mag, weapon_reserve)
|
||||
// Fills in weapon data for provided slot.
|
||||
//
|
||||
void Weapon_AssignWeapon(float weapon_slot, float weapon_id, float weapon_mag, float weapon_reserve)
|
||||
{
|
||||
// Fill the stats as necessary
|
||||
self.weapons[weapon_slot].weapon_id = weapon_id;
|
||||
|
||||
if (weapon_mag > 0) {
|
||||
self.weapons[weapon_slot].weapon_magazine = weapon_mag;
|
||||
if (IsDualWeapon(self.weapons[weapon_slot].weapon_id))
|
||||
self.weapons[weapon_slot].weapon_magazine_left = weapon_mag;
|
||||
} else {
|
||||
self.weapons[weapon_slot].weapon_magazine = getWeaponMag(self.weapons[weapon_slot].weapon_id);
|
||||
if (IsDualWeapon(self.weapons[weapon_slot].weapon_id))
|
||||
self.weapons[weapon_slot].weapon_magazine_left = getWeaponMag(self.weapons[weapon_slot].weapon_id);
|
||||
else
|
||||
self.weapons[weapon_slot].weapon_magazine_left = 0;
|
||||
}
|
||||
|
||||
if (weapon_reserve > 0)
|
||||
self.weapons[weapon_slot].weapon_reserve = weapon_reserve;
|
||||
else
|
||||
self.weapons[weapon_slot].weapon_reserve = getWeaponAmmo(self.weapons[weapon_slot].weapon_id);
|
||||
|
||||
if (weapon_slot == MULEKICK_WEAPON_SLOT - 1)
|
||||
self.weapons[weapon_slot].is_mulekick_weapon = true;
|
||||
|
||||
self.weapons[weapon_slot].weapon_skin = GetWepSkin(weapon_id);
|
||||
|
||||
// Now tell the player to hold it.
|
||||
Weapon_SetActiveInSlot(weapon_slot, true);
|
||||
};
|
||||
|
||||
//
|
||||
// Weapon_GiveWeapon(weapon_id, weapon_mag, weapon_reserve)
|
||||
// Assigns a weapon to the next free slot
|
||||
// in player inventory.
|
||||
//
|
||||
void Weapon_GiveWeapon(float weapon_id, float weapon_mag, float weapon_reserve)
|
||||
{
|
||||
float should_leave = false;
|
||||
|
||||
// Find next available weapon slot
|
||||
float weapon_slots;
|
||||
|
||||
if ((self.perks & P_MULE))
|
||||
weapon_slots = MULEKICK_WEAPON_SLOT;
|
||||
else
|
||||
weapon_slots = MULEKICK_WEAPON_SLOT - 1;
|
||||
|
||||
for(float i = 0; i < weapon_slots; i++) {
|
||||
if (self.weapons[i].weapon_id == 0) {
|
||||
for(float j = 0; j < i; j++) {
|
||||
Weapon_SwapWeapons(false);
|
||||
}
|
||||
Weapon_AssignWeapon(i, weapon_id, weapon_mag, weapon_reserve);
|
||||
should_leave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (should_leave)
|
||||
return;
|
||||
|
||||
// All slots are occupied, fill in current slot
|
||||
Weapon_AssignWeapon(0, weapon_id, weapon_mag, weapon_reserve);
|
||||
};
|
||||
|
||||
//
|
||||
// Weapons_FixUpList()
|
||||
// Iterates through client weapon list and
|
||||
// re-orders to remove gaps with IDs of 0.
|
||||
//
|
||||
void Weapon_FixUpList()
|
||||
{
|
||||
// Store current weapons locally
|
||||
guninventory_struct weapons_storage[MAX_PLAYER_WEAPONS];
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
if (self.weapons[i].weapon_id != 0) {
|
||||
weapons_storage[i].weapon_id = self.weapons[i].weapon_id;
|
||||
weapons_storage[i].weapon_magazine = self.weapons[i].weapon_magazine;
|
||||
weapons_storage[i].weapon_magazine_left = self.weapons[i].weapon_magazine_left;
|
||||
weapons_storage[i].weapon_reserve = self.weapons[i].weapon_reserve;
|
||||
weapons_storage[i].weapon_skin = self.weapons[i].weapon_skin;
|
||||
weapons_storage[i].is_mulekick_weapon = self.weapons[i].is_mulekick_weapon;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset all of the player's weapons
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
self.weapons[i].weapon_id = 0;
|
||||
self.weapons[i].weapon_magazine = 0;
|
||||
self.weapons[i].weapon_magazine_left = 0;
|
||||
self.weapons[i].weapon_reserve = 0;
|
||||
self.weapons[i].weapon_skin = 0;
|
||||
self.weapons[i].is_mulekick_weapon = false;
|
||||
}
|
||||
|
||||
float weapon_index = 0;
|
||||
for(float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
|
||||
if (weapons_storage[i].weapon_id != 0) {
|
||||
self.weapons[weapon_index].weapon_id = weapons_storage[i].weapon_id;
|
||||
self.weapons[weapon_index].weapon_magazine = weapons_storage[i].weapon_magazine;
|
||||
self.weapons[weapon_index].weapon_magazine_left = weapons_storage[i].weapon_magazine_left;
|
||||
self.weapons[weapon_index].weapon_reserve = weapons_storage[i].weapon_reserve;
|
||||
self.weapons[weapon_index].weapon_skin = weapons_storage[i].weapon_skin;
|
||||
self.weapons[weapon_index].is_mulekick_weapon = weapons_storage[i].is_mulekick_weapon;
|
||||
weapon_index++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Weapon_RemoveWeapon(float slot)
|
||||
{
|
||||
if (slot == 0) {
|
||||
Weapon_SwapWeapons(false);
|
||||
slot = 1;
|
||||
}
|
||||
|
||||
self.weapons[slot].is_mulekick_weapon = false;
|
||||
self.weapons[slot].weapon_id = 0;
|
||||
Weapon_FixUpList();
|
||||
};
|
||||
|
||||
// Re-enable fast array optimization.
|
||||
#ifndef FTE
|
||||
|
||||
#pragma flag enable fastarrays
|
||||
|
||||
#endif // FTE
|
||||
|
|
|
@ -51,7 +51,7 @@ void() ReturnWeaponModel =
|
|||
UpdateV2model(self.weapon2model, GetWepSkin(self.weapon));
|
||||
|
||||
// Always try to reload after any action.
|
||||
if (self.currentmag == 0 && self.currentammo != 0)
|
||||
if (self.weapons[0].weapon_magazine == 0 && self.weapons[0].weapon_reserve != 0)
|
||||
W_Reload(S_BOTH);
|
||||
|
||||
// If the person is swapping, play the sprint anim if they're sprinting after swap. Otherwise it plays idle
|
||||
|
@ -187,96 +187,21 @@ void W_SprintStart () {
|
|||
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = 0;
|
||||
}
|
||||
|
||||
void() W_Switch =
|
||||
void() W_PutOutHack =
|
||||
{
|
||||
if (self.secondaryweapon && self.secondaryweapon != 0 && !self.new_anim_stop && !other.button7)
|
||||
{
|
||||
float tempf,tempf1,tempf2,tempf3,tempf4;
|
||||
|
||||
// un-zoom camera
|
||||
self.zoom = false;
|
||||
|
||||
// fix fire rate exploit
|
||||
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = true;
|
||||
|
||||
// just do normal weapon swapping if we don't have mule..
|
||||
if (!(self.perks & P_MULE) || !self.thirdweapon) {
|
||||
tempf = self.currentammo;
|
||||
self.currentammo = self.secondaryammo;
|
||||
self.secondaryammo = tempf;
|
||||
|
||||
tempf1 = self.currentmag;
|
||||
self.currentmag = self.secondarymag;
|
||||
self.secondarymag = tempf1;
|
||||
|
||||
tempf1 = self.currentmag2;
|
||||
self.currentmag2 = self.secondarymag2;
|
||||
self.secondarymag2 = tempf1;
|
||||
|
||||
tempf2 = self.weapon;
|
||||
self.weapon = self.secondaryweapon;
|
||||
self.secondaryweapon = tempf2;
|
||||
|
||||
tempf3 = self.weaponskin;
|
||||
self.weaponskin = self.secondaryweaponskin;
|
||||
self.secondaryweaponskin = tempf3;
|
||||
} else {
|
||||
// store primary weapon
|
||||
tempf = self.weapon;
|
||||
tempf1 = self.currentmag;
|
||||
tempf2 = self.currentmag2;
|
||||
tempf3 = self.currentammo;
|
||||
tempf4 = self.weaponskin;
|
||||
|
||||
// set primary weapon to third weapon
|
||||
self.weapon = self.thirdweapon;
|
||||
self.currentmag = self.thirdmag;
|
||||
self.currentmag2 = self.thirdmag2;
|
||||
self.currentammo = self.thirdammo;
|
||||
self.weaponskin = self.thirdweaponskin;
|
||||
|
||||
// set third weapon to secondary weapon
|
||||
self.thirdweapon = self.secondaryweapon;
|
||||
self.thirdmag = self.secondarymag;
|
||||
self.thirdmag2 = self.secondarymag2;
|
||||
self.thirdammo = self.secondaryammo;
|
||||
self.thirdweaponskin = self.secondaryweaponskin;
|
||||
|
||||
// set secondary weapon to primary weapon
|
||||
self.secondaryweapon = tempf;
|
||||
self.secondarymag = tempf1;
|
||||
self.secondarymag2 = tempf2;
|
||||
self.secondaryammo = tempf3;
|
||||
self.secondaryweaponskin = tempf4;
|
||||
}
|
||||
|
||||
SwitchWeapon(self.weapon);
|
||||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, ReturnWeaponModel, 0);
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
self.Weapon_Name = GetWeaponName(self.weapon);
|
||||
self.Flash_Offset = GetWeaponFlash_Offset(self.weapon);
|
||||
self.Flash_Size = GetWeaponFlash_Size(self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
}
|
||||
Weapon_SwapWeapons(true);
|
||||
}
|
||||
|
||||
void() W_PutOut =
|
||||
{
|
||||
if (self.downed) {
|
||||
// We don't hold more than one weapon
|
||||
if (self.weapons[1].weapon_id == 0 || self.downed)
|
||||
return;
|
||||
}
|
||||
|
||||
W_AimOut();
|
||||
self.weaponnum = !self.weaponnum;
|
||||
|
||||
if (self.secondaryweapon && !self.new_anim_stop)
|
||||
{
|
||||
Weapon_PlayViewModelAnimation(ANIM_PUT_AWAY, W_Switch, 0);
|
||||
}
|
||||
if (self.weapon_count != 1 && !self.new_anim_stop)
|
||||
Weapon_PlayViewModelAnimation(ANIM_PUT_AWAY, W_PutOutHack, 0);
|
||||
}
|
||||
|
||||
void() W_TakeOut =
|
||||
|
@ -287,14 +212,6 @@ void() W_TakeOut =
|
|||
Weapon_PlayViewModelAnimation(ANIM_TAKE_OUT, SUB_Null, 0);
|
||||
}
|
||||
|
||||
float(entity who) hasWeapon =
|
||||
{
|
||||
if (other.weapon || other.secondaryweapon || other.thirdweapon)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//RELOAD
|
||||
|
@ -306,26 +223,26 @@ void(float side) W_Give_Ammo =
|
|||
max_mag = getWeaponMag(self.weapon);
|
||||
|
||||
if (side == S_LEFT) {
|
||||
ammo_shot = max_mag - self.currentmag2;
|
||||
ammo_shot = max_mag - self.weapons[0].weapon_magazine_left;
|
||||
} else {
|
||||
ammo_shot = max_mag - self.currentmag;
|
||||
ammo_shot = max_mag - self.weapons[0].weapon_magazine;
|
||||
}
|
||||
if (ammo_shot < self.currentammo)
|
||||
if (ammo_shot < self.weapons[0].weapon_reserve)
|
||||
{
|
||||
self.currentammo = self.currentammo - ammo_shot;
|
||||
self.weapons[0].weapon_reserve = self.weapons[0].weapon_reserve - ammo_shot;
|
||||
|
||||
loadammo = max_mag;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadammo = self.currentmag + self.currentammo;
|
||||
self.currentammo = 0;
|
||||
loadammo = self.weapons[0].weapon_magazine + self.weapons[0].weapon_reserve;
|
||||
self.weapons[0].weapon_reserve = 0;
|
||||
}
|
||||
|
||||
if (side == S_LEFT) {
|
||||
self.currentmag2 = loadammo;
|
||||
self.weapons[0].weapon_magazine_left = loadammo;
|
||||
} else {
|
||||
self.currentmag = loadammo;
|
||||
self.weapons[0].weapon_magazine = loadammo;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -335,7 +252,7 @@ void() ContinueReload = //Special reloads
|
|||
if (self.new_anim_stop)
|
||||
return;
|
||||
|
||||
if (self.weapon == W_GUT && self.currentmag == 10)
|
||||
if (self.weapon == W_GUT && self.weapons[0].weapon_magazine == 10)
|
||||
return;
|
||||
|
||||
float delay = 0;
|
||||
|
@ -344,7 +261,7 @@ void() ContinueReload = //Special reloads
|
|||
float endframe = 0;
|
||||
void(optional float t) endanimfunc = SUB_Null;
|
||||
|
||||
if (self.currentmag >= getWeaponMag(self.weapon) || !self.currentammo || self.reloadinterupted) {
|
||||
if (self.weapons[0].weapon_magazine >= getWeaponMag(self.weapon) || !self.weapons[0].weapon_reserve || self.reloadinterupted) {
|
||||
if (self.weapon == W_KAR_SCOPE || self.weapon == W_HEADCRACKER)
|
||||
{
|
||||
delay = 1;
|
||||
|
@ -357,21 +274,21 @@ void() ContinueReload = //Special reloads
|
|||
endanimfunc = W_LoadAmmo;
|
||||
}
|
||||
self.reloadinterupted = FALSE;
|
||||
} else if (self.currentmag < getWeaponMag(self.weapon)) {
|
||||
} else if (self.weapons[0].weapon_magazine < getWeaponMag(self.weapon)) {
|
||||
if (self.weapon == W_KAR_SCOPE || self.weapon == W_HEADCRACKER) {
|
||||
self.currentmag++;
|
||||
self.currentammo = self.currentammo - 1;
|
||||
self.weapons[0].weapon_magazine++;
|
||||
self.weapons[0].weapon_reserve = self.weapons[0].weapon_reserve - 1;
|
||||
delay = 0.8;
|
||||
startframe = 19;
|
||||
endframe = 24;
|
||||
endanimfunc = ContinueReload;
|
||||
} else if (self.weapon == W_TRENCH || self.weapon == W_GUT) {
|
||||
if (self.weapon == W_GUT && self.currentammo >= 2 && self.currentmag < 9) {
|
||||
self.currentmag = self.currentmag + 2;
|
||||
self.currentammo = self.currentammo - 2;
|
||||
if (self.weapon == W_GUT && self.weapons[0].weapon_reserve >= 2 && self.weapons[0].weapon_magazine < 9) {
|
||||
self.weapons[0].weapon_magazine = self.weapons[0].weapon_magazine + 2;
|
||||
self.weapons[0].weapon_reserve = self.weapons[0].weapon_reserve - 2;
|
||||
} else {
|
||||
self.currentmag++;
|
||||
self.currentammo = self.currentammo - 1;
|
||||
self.weapons[0].weapon_magazine++;
|
||||
self.weapons[0].weapon_reserve = self.weapons[0].weapon_reserve - 1;
|
||||
}
|
||||
delay = 0.5;
|
||||
startframe = 18;
|
||||
|
@ -426,15 +343,15 @@ void(float side) W_Reload =
|
|||
if (side == S_RIGHT &&
|
||||
(self.reload_delay > time ||
|
||||
self.new_anim_stop ||
|
||||
!self.currentammo ||
|
||||
self.currentmag >= getWeaponMag(self.weapon))){
|
||||
!self.weapons[0].weapon_reserve ||
|
||||
self.weapons[0].weapon_magazine >= getWeaponMag(self.weapon))){
|
||||
return;
|
||||
}
|
||||
if (side == S_LEFT &&
|
||||
(self.reload_delay2 > time ||
|
||||
self.new_anim2_stop ||
|
||||
!self.currentammo ||
|
||||
self.currentmag2 >= getWeaponMag(self.weapon))) {
|
||||
!self.weapons[0].weapon_reserve ||
|
||||
self.weapons[0].weapon_magazine_left >= getWeaponMag(self.weapon))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -454,7 +371,7 @@ void(float side) W_Reload =
|
|||
}
|
||||
}
|
||||
|
||||
if (self.currentammo)
|
||||
if (self.weapons[0].weapon_reserve)
|
||||
{
|
||||
playreload();
|
||||
|
||||
|
@ -473,7 +390,7 @@ void(float side) W_Reload =
|
|||
}
|
||||
// Check for special reload type
|
||||
else if (GetFrame(self.weapon, RELOAD_EMPTY_START) != 0) {
|
||||
if (self.currentmag > 0) {
|
||||
if (self.weapons[0].weapon_magazine > 0) {
|
||||
startframe = GetFrame(self.weapon, RELOAD_PART_START);
|
||||
endframe = GetFrame(self.weapon, RELOAD_PART_END);
|
||||
delay = getWeaponDelay(self.weapon, RELOAD_PAR);
|
||||
|
@ -485,7 +402,7 @@ void(float side) W_Reload =
|
|||
endanimfunc = W_AdvanceAnim;
|
||||
}
|
||||
else if (self.weapon == W_TRENCH || self.weapon == W_GUT) {
|
||||
if (self.currentmag == 0) {
|
||||
if (self.weapons[0].weapon_magazine == 0) {
|
||||
self.NeedLoad = true;
|
||||
}
|
||||
startframe = 14;
|
||||
|
@ -522,7 +439,7 @@ void () W_LoadAmmo =
|
|||
{
|
||||
if (!self.NeedLoad)
|
||||
return;
|
||||
if (!self.currentmag)
|
||||
if (!self.weapons[0].weapon_magazine)
|
||||
{
|
||||
W_Reload(S_BOTH);
|
||||
return;
|
||||
|
@ -567,10 +484,10 @@ void () W_LoadAmmo =
|
|||
|
||||
void () CheckReload =
|
||||
{
|
||||
if (!self.currentmag2 && IsDualWeapon(self.weapon)) {
|
||||
if (!self.weapons[0].weapon_magazine_left && IsDualWeapon(self.weapon)) {
|
||||
W_Reload(S_LEFT);
|
||||
}
|
||||
if (!self.currentmag && self.currentammo) {
|
||||
if (!self.weapons[0].weapon_magazine && self.weapons[0].weapon_reserve) {
|
||||
W_Reload(S_RIGHT);
|
||||
}
|
||||
}
|
||||
|
@ -1036,7 +953,7 @@ void(float side) W_Fire =
|
|||
if (side == S_RIGHT &&
|
||||
(time < self.fire_delay ||
|
||||
self.new_anim_stop ||
|
||||
self.reload_delay > time || !self.currentmag)) {
|
||||
self.reload_delay > time || !self.weapons[0].weapon_magazine)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1067,11 +984,11 @@ void(float side) W_Fire =
|
|||
makevectors(self.v_angle);
|
||||
|
||||
//make sure magazine is loading
|
||||
if (!self.currentmag && side == S_RIGHT)
|
||||
if (!self.weapons[0].weapon_magazine && side == S_RIGHT)
|
||||
{
|
||||
W_Reload(S_RIGHT);
|
||||
return;
|
||||
} else if (!self.currentmag2 && side == S_LEFT)
|
||||
} else if (!self.weapons[0].weapon_magazine_left && side == S_LEFT)
|
||||
{
|
||||
W_Reload(S_LEFT);
|
||||
return;
|
||||
|
@ -1211,10 +1128,10 @@ void(float side) W_Fire =
|
|||
sound (self, CHAN_WEAPON, soundname, 1, ATTN_NORM);
|
||||
|
||||
if (side == S_RIGHT) {
|
||||
self.currentmag = self.currentmag - 1;
|
||||
self.weapons[0].weapon_magazine = self.weapons[0].weapon_magazine - 1;
|
||||
self.fire_delay = getWeaponDelay(self.weapon, FIRE) + time;
|
||||
} else {
|
||||
self.currentmag2 = self.currentmag2 - 1;
|
||||
self.weapons[0].weapon_magazine_left = self.weapons[0].weapon_magazine_left - 1;
|
||||
self.fire_delay2 = getWeaponDelay(self.weapon, FIRE) + time;
|
||||
}
|
||||
|
||||
|
@ -1480,10 +1397,6 @@ void() W_ThrowGrenade =
|
|||
centerprint (other, "No grenadetype defined...\n");
|
||||
}
|
||||
|
||||
//if (!(self.flags & FL_ONGROUND)) {
|
||||
// self.secondary_grenades = self.secondary_grenades + 1;
|
||||
//}
|
||||
|
||||
startframe = GetFrame(self.weapon,TAKE_OUT_START);
|
||||
endframe = GetFrame(self.weapon,TAKE_OUT_END);
|
||||
modelname = GetWeaponModel(self.weapon, 0);
|
||||
|
@ -2121,7 +2034,7 @@ void () Weapon_Logic =
|
|||
UpdateV2model(self.weapon2model, 0);
|
||||
self.viewzoom = 1;
|
||||
self.zoom = 0;
|
||||
if (self.currentmag == 0)
|
||||
if (self.weapons[0].weapon_magazine == 0)
|
||||
W_Reload(S_BOTH);
|
||||
} else {
|
||||
if (self.viewzoom == 0.75) {
|
||||
|
@ -2181,7 +2094,7 @@ void () Weapon_Logic =
|
|||
self.semiuse = false;
|
||||
}
|
||||
|
||||
if (self.button4 && !self.semiswitch && self.secondaryweapon && self.secondaryweapon !=0 && !self.zoom)
|
||||
if (self.button4 && !self.semiswitch && self.weapon_count != 1 && !self.zoom)
|
||||
{
|
||||
W_PutOut();
|
||||
self.semiswitch = true;
|
||||
|
@ -2224,4 +2137,10 @@ void () Weapon_Logic =
|
|||
|
||||
CheckImpulses();
|
||||
CheckPlayer();
|
||||
|
||||
// These are sent to clients in engine for stat
|
||||
// reference.
|
||||
self.currentammo = self.weapons[0].weapon_reserve;
|
||||
self.currentmag = self.weapons[0].weapon_magazine;
|
||||
self.currentmag2 = self.weapons[0].weapon_magazine_left;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue