2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "sound.h"
|
2019-11-24 09:03:19 +00:00
|
|
|
#include "ps_input.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2019-12-30 18:29:32 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "sequence.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
/*
|
|
|
|
struct Weapon
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
short nSeq;
|
|
|
|
short b[12]; // seq offsets?
|
|
|
|
short nAmmoType;
|
|
|
|
short c;
|
|
|
|
short d;
|
|
|
|
short bFireUnderwater;
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
Weapon WeaponInfo[] = {
|
2020-08-18 08:28:19 +00:00
|
|
|
{ kSeqSword, { 0, 1, 3, 7, -1, 2, 4, 5, 6, 8, 9, 10 }, 0, 0, 0, true },
|
|
|
|
{ kSeqPistol, { 0, 3, 2, 4, -1, 1, 0, 0, 0, 0, 0, 0 }, 1, 0, 1, false },
|
|
|
|
{ kSeqM60, { 0, 5, 6, 16, -1, 21, 0, 0, 0, 0, 0, 0 }, 2, 0, 1, false },
|
|
|
|
{ kSeqFlamer, { 0, 2, 5, 5, 6, 1, 0, 0, 0, 0, 0, 0 }, 3, 4, 1, false },
|
|
|
|
{ kSeqGrenade, { 0, 2, 3, 4, -1, 1, 0, 0, 0, 0, 0, 0 }, 4, 0, 1, true },
|
|
|
|
{ kSeqCobra, { 0, 1, 2, 2, -1, 4, 0, 0, 0, 0, 0, 0 }, 5, 0, 1, true },
|
|
|
|
{ kSeqRavolt, { 0, 1, 2, 3, -1, 4, 0, 0, 0, 0, 0, 0 }, 6, 0, 1, true },
|
|
|
|
{ kSeqRothands,{ 0, 1, 2, -1, -1, -1, 0, 0, 0, 0, 0, 0 }, 7, 0, 0, true },
|
|
|
|
{ kSeqDead, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 1, 0, false },
|
|
|
|
{ kSeqDeadEx, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 1, 0, false },
|
|
|
|
{ kSeqDeadBrn, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 1, 0, false }
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
short nTemperature[kMaxPlayers];
|
|
|
|
short nMinAmmo[] = { 0, 24, 51, 50, 1, 0, 0 };
|
|
|
|
short word_96E26 = 0;
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
static SavegameHelper sghgun("gun",
|
2019-12-26 21:00:04 +00:00
|
|
|
SA(nTemperature),
|
|
|
|
SV(word_96E26),
|
|
|
|
nullptr);
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
void RestoreMinAmmo(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
for (int i = 0; i < kMaxWeapons; i++)
|
|
|
|
{
|
|
|
|
if (i == kWeaponGrenade) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((1 << i) & nPlayerWeapons[nPlayer])
|
|
|
|
{
|
|
|
|
if (nMinAmmo[i] > PlayerList[nPlayer].nAmmo[i]) {
|
|
|
|
PlayerList[nPlayer].nAmmo[i] = nMinAmmo[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckClip(nPlayer);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FillWeapons(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
nPlayerWeapons[nPlayer] = 0xFFFF; // turn on all bits
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
for (int i = 0; i < kMaxWeapons; i++)
|
|
|
|
{
|
|
|
|
if (WeaponInfo[i].d) {
|
|
|
|
PlayerList[nPlayer].nAmmo[i] = 99;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
CheckClip(nPlayer);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nPlayer == nLocalPlayer)
|
|
|
|
{
|
|
|
|
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
SetCounter(PlayerList[nPlayer].nAmmo[nWeapon]);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetPlayerWeapons(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
for (int i = 0; i < kMaxWeapons; i++)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nAmmo[i] = 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
PlayerList[nPlayer].nCurrentWeapon = 0;
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
nPlayerGrenade[nPlayer] = -1;
|
|
|
|
nPlayerWeapons[nPlayer] = 0x1; // turn on bit 1 only
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitWeapons()
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
memset(nPlayerGrenade, 0, sizeof(nPlayerGrenade));
|
|
|
|
memset(nGrenadePlayer, 0, sizeof(nGrenadePlayer));
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetNewWeapon(short nPlayer, short nWeapon)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3C = PlayerList[nPlayer].nCurrentWeapon;
|
2020-08-18 08:28:19 +00:00
|
|
|
PlayerList[nPlayer].bIsFiring = false;
|
2019-11-16 12:28:07 +00:00
|
|
|
PlayerList[nPlayer].field_3A = 5;
|
2020-08-18 08:28:19 +00:00
|
|
|
SetPlayerMummified(nPlayer, true);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon < 0)
|
|
|
|
{
|
|
|
|
nPlayerOldWeapon[nPlayer] = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
}
|
|
|
|
else if (nWeapon != kWeaponGrenade || PlayerList[nPlayer].nAmmo[kWeaponGrenade] > 0)
|
|
|
|
{
|
|
|
|
short nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
if (nCurrentWeapon != kWeaponMummified)
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].bIsFiring || nWeapon == nCurrentWeapon) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_38 = nWeapon;
|
|
|
|
|
|
|
|
if (nPlayer == nLocalPlayer)
|
|
|
|
{
|
|
|
|
int nCounter;
|
|
|
|
|
|
|
|
if (nWeapon >= kWeaponSword && nWeapon <= kWeaponRing) {
|
|
|
|
nCounter = PlayerList[nPlayer].nAmmo[nWeapon];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nCounter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCounterImmediate(nCounter);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetNewWeaponImmediate(short nPlayer, short nWeapon)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
SetNewWeapon(nPlayer, nWeapon);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
|
|
|
|
PlayerList[nPlayer].field_38 = -1;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetNewWeaponIfBetter(short nPlayer, short nWeapon)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon > PlayerList[nPlayer].nCurrentWeapon) {
|
|
|
|
SetNewWeapon(nPlayer, nWeapon);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SelectNewWeapon(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
int nWeapon = kWeaponRing; // start at the highest weapon number
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
uint16_t di = nPlayerWeapons[nPlayer];
|
|
|
|
uint16_t dx = 0x40; // bit 7 turned on
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
while (dx)
|
|
|
|
{
|
|
|
|
if (di & dx)
|
|
|
|
{
|
|
|
|
// we have this weapon
|
|
|
|
if (!WeaponInfo[nWeapon].d || PlayerList[nPlayer].nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
|
|
|
break;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
nWeapon--;
|
|
|
|
dx >>= 1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon < 0)
|
|
|
|
nWeapon = kWeaponSword;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
PlayerList[nPlayer].bIsFiring = false;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
SetNewWeapon(nPlayer, nWeapon);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StopFiringWeapon(short nPlayer)
|
|
|
|
{
|
2020-08-18 08:28:19 +00:00
|
|
|
PlayerList[nPlayer].bIsFiring = false;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FireWeapon(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (!PlayerList[nPlayer].bIsFiring) {
|
2020-08-18 08:28:19 +00:00
|
|
|
PlayerList[nPlayer].bIsFiring = true;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetWeaponStatus(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nPlayer != nLocalPlayer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
if (nWeapon < 0)
|
|
|
|
{
|
|
|
|
nCounterBullet = -1;
|
|
|
|
SetCounterImmediate(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCounterBullet = WeaponInfo[nWeapon].nAmmoType;
|
|
|
|
SetCounterImmediate(PlayerList[nPlayer].nAmmo[nCounterBullet]);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
uint8_t WeaponCanFire(short nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
short nSector = nPlayerViewSect[nPlayer];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (!(SectFlag[nSector] & kSectUnderwater) || WeaponInfo[nWeapon].bFireUnderwater)
|
|
|
|
{
|
|
|
|
short nAmmoType = WeaponInfo[nWeapon].nAmmoType;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (WeaponInfo[nWeapon].d <= PlayerList[nPlayer].nAmmo[nAmmoType]) {
|
2020-08-18 08:28:19 +00:00
|
|
|
return true;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
return false;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UNUSED
|
|
|
|
void ResetSwordSeqs()
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
WeaponInfo[kWeaponSword].b[2] = 3;
|
|
|
|
WeaponInfo[kWeaponSword].b[3] = 7;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
short hitSect, hitWall, hitSprite;
|
|
|
|
int hitX, hitY, hitZ;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
short nSprite = PlayerList[nPlayer].nSprite;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
int xVect = bcos(sprite[nSprite].ang);
|
|
|
|
int yVect = bsin(sprite[nSprite].ang);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-27 06:08:18 +00:00
|
|
|
vec3_t startPos = { *x, *y, *z };
|
2019-08-31 07:47:15 +00:00
|
|
|
hitdata_t hitData;
|
2019-08-27 06:08:18 +00:00
|
|
|
hitscan(&startPos, *nSector, xVect, yVect, 0, &hitData, CLIPMASK1);
|
|
|
|
hitX = hitData.pos.x;
|
|
|
|
hitY = hitData.pos.y;
|
|
|
|
hitZ = hitData.pos.z;
|
|
|
|
hitSprite = hitData.sprite;
|
|
|
|
hitSect = hitData.sect;
|
|
|
|
hitWall = hitData.wall;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-14 09:19:28 +00:00
|
|
|
int ecx = bsin(150, -3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-06-22 10:24:21 +00:00
|
|
|
uint32_t xDiff = klabs(hitX - *x);
|
|
|
|
uint32_t yDiff = klabs(hitY - *y);
|
|
|
|
|
|
|
|
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ksqrt(sqrtNum) >= ecx)
|
2019-11-16 12:28:07 +00:00
|
|
|
return 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
*x = hitX;
|
|
|
|
*y = hitY;
|
|
|
|
*z = hitZ;
|
|
|
|
*nSector = hitSect;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (hitSprite > -1) {
|
|
|
|
return hitSprite | 0xC000;
|
|
|
|
}
|
|
|
|
if (hitWall > -1) {
|
2019-11-16 12:27:44 +00:00
|
|
|
return hitWall | 0x8000;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
return 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CheckClip(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nPlayerClip[nPlayer] <= 0)
|
|
|
|
{
|
|
|
|
nPlayerClip[nPlayer] = PlayerList[nPlayer].nAmmo[kWeaponM60];
|
|
|
|
|
|
|
|
if (nPlayerClip[nPlayer] > 99) {
|
|
|
|
nPlayerClip[nPlayer] = 99;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MoveWeapons(short nPlayer)
|
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
static int dword_96E22 = 0;
|
|
|
|
|
|
|
|
short nSectFlag = SectFlag[nPlayerViewSect[nPlayer]];
|
|
|
|
|
|
|
|
if ((nSectFlag & kSectUnderwater) && (totalmoves & 1)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nPilotLightFrame++;
|
|
|
|
|
|
|
|
if (nPilotLightFrame >= nPilotLightCount)
|
|
|
|
nPilotLightFrame = 0;
|
|
|
|
|
|
|
|
if (!PlayerList[nPlayer].bIsFiring || (nSectFlag & kSectUnderwater))
|
|
|
|
nTemperature[nPlayer] = 0;
|
|
|
|
|
|
|
|
short nPlayerSprite = PlayerList[nPlayer].nSprite;
|
|
|
|
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
if (nWeapon < -1)
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].field_38 != -1)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].field_38;
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
PlayerList[nPlayer].field_38 = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_26ACC
|
|
|
|
short eax = PlayerList[nPlayer].field_3A;
|
|
|
|
short nSeq = WeaponInfo[nWeapon].nSeq;
|
|
|
|
|
|
|
|
short var_3C = WeaponInfo[nWeapon].b[eax] + SeqOffsets[nSeq];
|
|
|
|
|
|
|
|
int var_1C = (nPlayerDouble[nPlayer] > 0) + 1;
|
|
|
|
|
|
|
|
frames = var_1C - 1;
|
|
|
|
|
|
|
|
for (frames = var_1C; frames > 0; frames--)
|
|
|
|
{
|
|
|
|
seq_MoveSequence(nPlayerSprite, var_3C, PlayerList[nPlayer].field_3FOUR);
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3FOUR++;
|
|
|
|
|
|
|
|
dword_96E22++;
|
|
|
|
if (dword_96E22 >= 15) {
|
|
|
|
dword_96E22 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PlayerList[nPlayer].field_3FOUR >= SeqSize[var_3C])
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].field_38 == -1)
|
|
|
|
{
|
|
|
|
switch (PlayerList[nPlayer].field_3A)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
SetWeaponStatus(nPlayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].bIsFiring)
|
|
|
|
{
|
|
|
|
if (!WeaponCanFire(nPlayer))
|
|
|
|
{
|
|
|
|
if (!dword_96E22) {
|
|
|
|
D3PlayFX(StaticSound[4], PlayerList[nPlayer].nSprite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponRing)
|
|
|
|
{
|
|
|
|
if (Ra[nPlayer].nTarget == -1)
|
|
|
|
break;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
Ra[nPlayer].nAction = 0;
|
|
|
|
Ra[nPlayer].nFrame = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
Ra[nPlayer].field_C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3A = 2;
|
|
|
|
|
|
|
|
if (nWeapon == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponGrenade)
|
|
|
|
{
|
|
|
|
BuildGrenade(nPlayer);
|
|
|
|
AddAmmo(nPlayer, 4, -1);
|
|
|
|
}
|
2020-03-03 09:00:23 +00:00
|
|
|
else if (nWeapon == kWeaponMummified)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
ShootStaff(nPlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponPistol && nPistolClip[nPlayer] <= 0)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 3;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
nPistolClip[nPlayer] = std::min<int>(6, PlayerList[nPlayer].nAmmo[kWeaponPistol]);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponGrenade)
|
|
|
|
{
|
|
|
|
if (!PlayerList[nPlayer].bIsFiring)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3FOUR = SeqSize[var_3C] - 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].field_3C;
|
|
|
|
|
|
|
|
nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
SetPlayerMummified(nPlayer, false);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loc_26D88:
|
|
|
|
if (PlayerList[nPlayer].bIsFiring && WeaponCanFire(nPlayer))
|
|
|
|
{
|
|
|
|
if (nWeapon != kWeaponM60 && nWeapon != kWeaponPistol) {
|
|
|
|
PlayerList[nPlayer].field_3A = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (WeaponInfo[nWeapon].b[4] == -1)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponFlamer && (nSectFlag & kSectUnderwater))
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].field_3C;
|
|
|
|
|
|
|
|
nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponRing)
|
|
|
|
{
|
|
|
|
if (!WeaponInfo[nWeapon].d || PlayerList[nPlayer].nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
|
|
|
{
|
|
|
|
if (!PlayerList[nPlayer].bIsFiring) {
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ra[nPlayer].field_C = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponM60)
|
|
|
|
{
|
|
|
|
CheckClip(nPlayer);
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponGrenade)
|
|
|
|
{
|
|
|
|
if (!WeaponInfo[nWeapon].d || PlayerList[nPlayer].nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
|
|
|
PlayerList[nPlayer].field_3A = 5;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-10-29 22:10:50 +00:00
|
|
|
PlayerList[nPlayer].field_3FOUR = SeqSize[WeaponInfo[kWeaponGrenade].b[0] + SeqOffsets[nSeq]] - 1; // CHECKME
|
2019-11-16 12:28:07 +00:00
|
|
|
goto loc_flag; // FIXME
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].bIsFiring && WeaponCanFire(nPlayer)) {
|
|
|
|
PlayerList[nPlayer].field_3A = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WeaponInfo[nWeapon].b[4] == -1)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponFlamer && (nSectFlag & kSectUnderwater))
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].field_38;
|
|
|
|
|
|
|
|
nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
PlayerList[nPlayer].field_38 = -1;
|
|
|
|
|
|
|
|
SetWeaponStatus(nPlayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_26FC5
|
|
|
|
var_3C = SeqOffsets[WeaponInfo[nWeapon].nSeq] + WeaponInfo[nWeapon].b[PlayerList[nPlayer].field_3A];
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].field_3A == 5)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].field_38;
|
|
|
|
|
|
|
|
nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_38 = -1;
|
|
|
|
PlayerList[nPlayer].field_3A = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} // end of if (PlayerList[nPlayer].field_34 >= SeqSize[var_3C])
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
loc_flag:
|
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
// loc_27001
|
|
|
|
short nFrameFlag = seq_GetFrameFlag(var_3C, PlayerList[nPlayer].field_3FOUR);
|
|
|
|
|
|
|
|
if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (nFrameFlag & 4))
|
|
|
|
{
|
|
|
|
BuildFlash(nPlayer, sprite[nPlayerSprite].sectnum, 512);
|
|
|
|
AddFlash(
|
|
|
|
sprite[nPlayerSprite].sectnum,
|
|
|
|
sprite[nPlayerSprite].x,
|
|
|
|
sprite[nPlayerSprite].y,
|
|
|
|
sprite[nPlayerSprite].z,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nFrameFlag & 0x80)
|
|
|
|
{
|
|
|
|
int nAction = PlayerList[nPlayer].nAction;
|
|
|
|
|
|
|
|
int var_38 = 1;
|
|
|
|
|
|
|
|
if (nAction < 10 || nAction > 12) {
|
|
|
|
var_38 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nPlayer == nLocalPlayer) {
|
|
|
|
obobangle = bobangle = 512;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponFlamer && (!(nSectFlag & kSectUnderwater)))
|
|
|
|
{
|
|
|
|
nTemperature[nPlayer]++;
|
|
|
|
|
|
|
|
if (nTemperature[nPlayer] > 50)
|
|
|
|
{
|
|
|
|
nTemperature[nPlayer] = 0;
|
|
|
|
PlayerList[nPlayer].field_3A = 4;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
short nAmmoType = WeaponInfo[nWeapon].nAmmoType;
|
|
|
|
short nAngle = sprite[nPlayerSprite].ang;
|
|
|
|
int theX = sprite[nPlayerSprite].x;
|
|
|
|
int theY = sprite[nPlayerSprite].y;
|
|
|
|
int theZ = sprite[nPlayerSprite].z;
|
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
int ebp = bcos(nAngle) * (sprite[nPlayerSprite].clipdist << 3);
|
|
|
|
int ebx = bsin(nAngle) * (sprite[nPlayerSprite].clipdist << 3);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (WeaponInfo[nWeapon].c)
|
|
|
|
{
|
|
|
|
int ecx;
|
|
|
|
|
|
|
|
int theVal = (totalmoves + 101) & (WeaponInfo[nWeapon].c - 1);
|
|
|
|
if (theVal & 1)
|
|
|
|
ecx = -theVal;
|
|
|
|
else
|
|
|
|
ecx = theVal;
|
|
|
|
|
|
|
|
int var_44 = (nAngle + 512) & kAngleMask;
|
2020-11-14 08:45:08 +00:00
|
|
|
ebp += bcos(var_44, -11) * ecx;
|
|
|
|
ebx += bsin(var_44, -11) * ecx;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int nHeight = (-GetSpriteHeight(nPlayerSprite)) >> 1;
|
|
|
|
|
|
|
|
if (nAction < 6)
|
|
|
|
{
|
|
|
|
nHeight -= 1792;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!var_38)
|
|
|
|
{
|
|
|
|
nHeight += 1024;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nHeight -= 2560;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
short nSectorB = sprite[nPlayerSprite].sectnum;
|
|
|
|
|
|
|
|
switch (nWeapon)
|
|
|
|
{
|
|
|
|
// loc_27266:
|
|
|
|
case kWeaponSword:
|
|
|
|
{
|
2020-10-07 06:40:59 +00:00
|
|
|
nHeight += -PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 10;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
theZ += nHeight;
|
|
|
|
|
|
|
|
int var_28;
|
|
|
|
|
|
|
|
if (PlayerList[nPlayer].field_3A == 2) {
|
|
|
|
var_28 = 6;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var_28 = 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cRange = CheckCloseRange(nPlayer, &theX, &theY, &theZ, &nSectorB);
|
|
|
|
|
|
|
|
if (cRange)
|
|
|
|
{
|
|
|
|
short nDamage = BulletInfo[kWeaponSword].nDamage;
|
|
|
|
|
|
|
|
if (nPlayerDouble[nPlayer]) {
|
|
|
|
nDamage *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cRange & 0xC000) >= 0x8000)
|
|
|
|
{
|
|
|
|
if ((cRange & 0xC000) == 0x8000) // hit wall
|
|
|
|
{
|
|
|
|
// loc_2730E:
|
|
|
|
var_28 += 2;
|
|
|
|
}
|
|
|
|
else if ((cRange & 0xC000) == 0xC000) // hit sprite
|
|
|
|
{
|
|
|
|
short nSprite2 = cRange & 0x3FFF;
|
|
|
|
|
|
|
|
if (sprite[nSprite2].cstat & 0x50)
|
|
|
|
{
|
|
|
|
var_28 += 2;
|
|
|
|
}
|
|
|
|
else if (sprite[nSprite2].statnum > 90 && sprite[nSprite2].statnum <= 199)
|
|
|
|
{
|
|
|
|
runlist_DamageEnemy(nSprite2, nPlayerSprite, nDamage);
|
|
|
|
|
|
|
|
if (sprite[nSprite2].statnum < 102) {
|
|
|
|
var_28++;
|
|
|
|
}
|
|
|
|
else if (sprite[nSprite2].statnum == 102)
|
|
|
|
{
|
|
|
|
// loc_27370:
|
|
|
|
BuildAnim(-1, 12, 0, theX, theY, theZ, nSectorB, 30, 0);
|
|
|
|
}
|
|
|
|
else if (sprite[nSprite2].statnum == kStatExplodeTrigger) {
|
|
|
|
var_28 += 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var_28++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loc_27370:
|
|
|
|
BuildAnim(-1, 12, 0, theX, theY, theZ, nSectorB, 30, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_27399:
|
|
|
|
PlayerList[nPlayer].field_3A = var_28;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponFlamer:
|
|
|
|
{
|
|
|
|
if (nSectFlag & kSectUnderwater)
|
|
|
|
{
|
|
|
|
DoBubbles(nPlayer);
|
|
|
|
PlayerList[nPlayer].field_3A = 1;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
StopSpriteSound(nPlayerSprite);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (var_38) {
|
|
|
|
nHeight += 768;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nHeight -= 2560;
|
|
|
|
}
|
|
|
|
|
|
|
|
// fall through to case 1 (kWeaponPistol)
|
2019-12-02 14:56:24 +00:00
|
|
|
fallthrough__;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWeaponM60:
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponM60) { // hack(?) to do fallthrough from kWeapon3 into kWeaponPistol without doing the nQuake[] change
|
|
|
|
nQuake[nPlayer] = 128;
|
|
|
|
}
|
|
|
|
// fall through
|
2019-12-02 14:56:24 +00:00
|
|
|
fallthrough__;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
case kWeaponPistol:
|
|
|
|
{
|
2020-10-07 06:40:59 +00:00
|
|
|
int var_50 = PlayerList[nLocalPlayer].horizon.horiz.asq16() >> 14;
|
2019-11-16 12:28:07 +00:00
|
|
|
nHeight -= var_50;
|
|
|
|
|
2020-08-25 22:22:11 +00:00
|
|
|
if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2019-11-13 22:13:11 +00:00
|
|
|
assert(sprite[sPlayerInput[nPlayer].nTarget].sectnum < kMaxSectors);
|
2019-11-16 12:28:07 +00:00
|
|
|
var_50 = sPlayerInput[nPlayer].nTarget + 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildBullet(nPlayerSprite, nAmmoType, ebp, ebx, nHeight, nAngle, var_50, var_1C);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWeaponGrenade:
|
|
|
|
{
|
2020-10-07 06:40:59 +00:00
|
|
|
ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(PlayerList[nLocalPlayer].horizon.horiz.asq16()));
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponStaff:
|
|
|
|
{
|
|
|
|
BuildSnake(nPlayer, nHeight);
|
|
|
|
nQuake[nPlayer] = 512;
|
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
nXDamage[nPlayer] -= bcos(sprite[nPlayerSprite].ang, 9);
|
|
|
|
nYDamage[nPlayer] -= bsin(sprite[nPlayerSprite].ang, 9);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponRing:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kWeaponMummified:
|
|
|
|
{
|
|
|
|
short nDamage = BulletInfo[kWeaponMummified].nDamage;
|
|
|
|
if (nPlayerDouble[nPlayer]) {
|
|
|
|
nDamage *= 2;
|
|
|
|
}
|
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
runlist_RadialDamageEnemy(nPlayerSprite, nDamage, BulletInfo[kWeaponMummified].nRadius);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of switch, loc_2753E:
|
|
|
|
if (nWeapon < kWeaponMummified)
|
|
|
|
{
|
|
|
|
if (nWeapon != kWeaponGrenade)
|
|
|
|
{
|
|
|
|
short nAmmo = -WeaponInfo[nWeapon].d; // negative
|
|
|
|
|
|
|
|
if (nAmmo) {
|
|
|
|
AddAmmo(nPlayer, nAmmoType, nAmmo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponM60) {
|
|
|
|
nPlayerClip[nPlayer] -= WeaponInfo[nWeapon].d;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponPistol) {
|
|
|
|
nPistolClip[nPlayer]--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!WeaponInfo[nWeapon].d || PlayerList[nPlayer].nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponM60 && nPlayerClip[nPlayer] <= 0)
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].field_3A = 3;
|
|
|
|
PlayerList[nPlayer].field_3FOUR = 0;
|
|
|
|
// goto loc_27609:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nWeapon != kWeaponGrenade)
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
|
|
|
// go to loc_27609:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 03:22:52 +00:00
|
|
|
void DrawWeapons(double smooth)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (bCamera) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
short nWeapon = PlayerList[nLocalPlayer].nCurrentWeapon;
|
|
|
|
if (nWeapon < -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
short var_34 = PlayerList[nLocalPlayer].field_3A;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
short var_30 = SeqOffsets[WeaponInfo[nWeapon].nSeq];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
short var_28 = var_30 + WeaponInfo[nWeapon].b[var_34];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
int8_t nShade = sector[initsect].ceilingshade;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
int nDouble = nPlayerDouble[nLocalPlayer];
|
|
|
|
int nPal = kPalNormal;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nDouble)
|
|
|
|
{
|
|
|
|
if (word_96E26) {
|
2019-10-27 13:53:20 +00:00
|
|
|
nPal = kPalRedBrite;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
word_96E26 = word_96E26 == 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-10-27 13:53:20 +00:00
|
|
|
nPal = RemapPLU(nPal);
|
|
|
|
|
2020-08-24 17:54:26 +00:00
|
|
|
double xOffset = 0, yOffset = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-24 06:02:12 +00:00
|
|
|
if (cl_weaponsway)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2020-08-24 03:22:52 +00:00
|
|
|
// CHECKME - not & 0x7FF?
|
|
|
|
double nBobAngle = obobangle + fmulscale16(((bobangle + 1024 - obobangle) & 2047) - 1024, smooth);
|
|
|
|
double nVal = (ototalvel[nLocalPlayer] + fmulscale16(totalvel[nLocalPlayer] - ototalvel[nLocalPlayer], smooth)) / 2.;
|
|
|
|
yOffset = (nVal * (calcSinTableValue(fmod(nBobAngle, 1024)) / 256.)) / 512.;
|
|
|
|
|
|
|
|
if (var_34 == 1)
|
|
|
|
{
|
2020-11-22 10:27:02 +00:00
|
|
|
xOffset = fmulscale8(bcosf(nBobAngle, -8), nVal);
|
2020-08-24 03:22:52 +00:00
|
|
|
}
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obobangle = bobangle = 512;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon == 3 && var_34 == 1) {
|
|
|
|
seq_DrawPilotLightSeq(xOffset, yOffset);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon < 0) {
|
|
|
|
nShade = sprite[PlayerList[nLocalPlayer].nSprite].shade;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-10-07 21:08:40 +00:00
|
|
|
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].angle.olook_ang.asq16(), PlayerList[nLocalPlayer].angle.look_ang.asq16(), cl_syncinput, smooth);
|
2020-09-21 10:37:09 +00:00
|
|
|
double const looking_arc = fabs(look_anghalf) / 4.5;
|
|
|
|
|
|
|
|
xOffset -= look_anghalf;
|
|
|
|
yOffset += looking_arc;
|
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].field_3FOUR, xOffset, yOffset, nShade, nPal);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon != kWeaponM60)
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
switch (var_34)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
int nClip = nPlayerClip[nLocalPlayer];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nClip <= 0)
|
|
|
|
return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
int nSeqOffset;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nClip <= 3)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 1;
|
|
|
|
}
|
|
|
|
else if (nClip <= 6)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 2;
|
|
|
|
}
|
|
|
|
else if (nClip <= 25)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 3;
|
|
|
|
}
|
2020-01-07 00:11:19 +00:00
|
|
|
else //if (nClip > 25)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(nSeqOffset, PlayerList[nLocalPlayer].field_3FOUR, xOffset, yOffset, nShade, nPal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
int nClip = nPlayerClip[nLocalPlayer];
|
|
|
|
|
|
|
|
short edx = (nClip % 3) * 4;
|
|
|
|
|
|
|
|
if (nClip <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 8, edx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 3) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 9, edx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 6) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 10, edx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 25) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 11, edx, xOffset, yOffset, nShade, nPal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
int nClip = nPlayerClip[nLocalPlayer];
|
|
|
|
|
|
|
|
short dx = PlayerList[nLocalPlayer].field_3FOUR;
|
|
|
|
|
|
|
|
if (nClip <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 8, dx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 3) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 9, dx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 6) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 10, dx, xOffset, yOffset, nShade, nPal);
|
|
|
|
|
|
|
|
if (nClip <= 25) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_DrawGunSequence(var_30 + 11, dx, xOffset, yOffset, nShade, nPal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
int nClip = nPlayerClip[nLocalPlayer];
|
|
|
|
|
|
|
|
short ax = PlayerList[nLocalPlayer].field_3FOUR;
|
|
|
|
|
|
|
|
if (nClip <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nSeqOffset;
|
|
|
|
|
|
|
|
if (nClip <= 3)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 20;
|
|
|
|
}
|
|
|
|
else if (nClip <= 6)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 19;
|
|
|
|
}
|
|
|
|
else if (nClip <= 25)
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 18;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nSeqOffset = var_30 + 17;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
seq_DrawGunSequence(nSeqOffset, ax, xOffset, yOffset, nShade, nPal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|