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"
|
|
|
|
#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
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
static const uint8_t nMinAmmo[] = { 0, 24, 51, 50, 1, 0, 0 };
|
2021-11-21 19:34:15 +00:00
|
|
|
int isRed = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-12-26 21:00:04 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-30 00:07:14 +00:00
|
|
|
void SerializeGun(FSerializer& arc)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject("gun"))
|
|
|
|
{
|
2023-03-25 09:00:53 +00:00
|
|
|
arc("isred", isRed).EndObject();
|
2020-11-30 00:07:14 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void RestoreMinAmmo(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
for (int i = 0; i < kMaxWeapons; i++)
|
|
|
|
{
|
|
|
|
if (i == kWeaponGrenade) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-10-21 10:51:16 +00:00
|
|
|
if ((1 << i) & PlayerList[nPlayer].nPlayerWeapons)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
if (nMinAmmo[i] > PlayerList[nPlayer].nAmmo[i]) {
|
|
|
|
PlayerList[nPlayer].nAmmo[i] = nMinAmmo[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckClip(nPlayer);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void FillWeapons(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
PlayerList[nPlayer].nPlayerWeapons = 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) {
|
2021-07-17 04:54:36 +00:00
|
|
|
PlayerList[nPlayer].nAmmo[i] = 300;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void ResetPlayerWeapons(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
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;
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nState = 0;
|
|
|
|
PlayerList[nPlayer].nSeqSize2 = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 17:44:53 +00:00
|
|
|
PlayerList[nPlayer].pPlayerGrenade = nullptr;
|
2021-10-21 10:51:16 +00:00
|
|
|
PlayerList[nPlayer].nPlayerWeapons = 0x1; // turn on bit 1 only
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitWeapons()
|
|
|
|
{
|
2021-10-21 17:44:53 +00:00
|
|
|
for (auto& p : PlayerList) p.pPlayerGrenade = nullptr;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-21 18:24:46 +00:00
|
|
|
void SetNewWeapon(int nPlayer, int nWeapon)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nLastWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
2020-08-18 08:28:19 +00:00
|
|
|
PlayerList[nPlayer].bIsFiring = false;
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nState = 5;
|
2020-08-18 08:28:19 +00:00
|
|
|
SetPlayerMummified(nPlayer, true);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon < 0)
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
PlayerList[nPlayer].nPlayerOldWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else if (nWeapon != kWeaponGrenade || PlayerList[nPlayer].nAmmo[kWeaponGrenade] > 0)
|
|
|
|
{
|
2021-11-21 19:34:15 +00:00
|
|
|
int nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nCurrentWeapon != kWeaponMummified)
|
|
|
|
{
|
|
|
|
if (PlayerList[nPlayer].bIsFiring || nWeapon == nCurrentWeapon) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nNextWeapon = nWeapon;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-21 18:24:46 +00:00
|
|
|
void SetNewWeaponImmediate(int nPlayer, int nWeapon)
|
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
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
|
2021-11-21 18:33:51 +00:00
|
|
|
PlayerList[nPlayer].nNextWeapon = -1;
|
|
|
|
PlayerList[nPlayer].nSeqSize2 = 0;
|
|
|
|
PlayerList[nPlayer].nState = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-21 18:24:46 +00:00
|
|
|
void SetNewWeaponIfBetter(int nPlayer, int nWeapon)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon > PlayerList[nPlayer].nCurrentWeapon) {
|
|
|
|
SetNewWeapon(nPlayer, nWeapon);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void SelectNewWeapon(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
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
|
|
|
|
2021-10-21 10:51:16 +00:00
|
|
|
uint16_t di = PlayerList[nPlayer].nPlayerWeapons;
|
2019-11-16 12:28:07 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void SetWeaponStatus(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
uint8_t WeaponCanFire(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-11-21 18:24:46 +00:00
|
|
|
int nWeapon = PlayerList[nPlayer].nCurrentWeapon;
|
2021-11-22 23:20:15 +00:00
|
|
|
auto pSector =PlayerList[nPlayer].pPlayerViewSect;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 23:20:15 +00:00
|
|
|
if (!(pSector->Flag & kSectUnderwater) || WeaponInfo[nWeapon].bFireUnderwater)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2021-11-21 18:24:46 +00:00
|
|
|
int 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
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-08-20 13:46:52 +00:00
|
|
|
Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-12-26 07:47:54 +00:00
|
|
|
auto pActor = PlayerList[nPlayer].pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-12-06 11:24:22 +00:00
|
|
|
HitInfo hit{};
|
2022-11-25 12:13:50 +00:00
|
|
|
hitscan(pos, *ppSector, DVector3(pActor->spr.Angles.Yaw.ToVector() * 1024, 0 ), hit, CLIPMASK1);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-08-20 13:46:52 +00:00
|
|
|
const double ecx = 56.84; // bsin(150, -3)
|
|
|
|
double sqrtNum = (hit.hitpos.XY() - pos.XY()).LengthSquared();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-26 13:26:03 +00:00
|
|
|
Collision c;
|
|
|
|
c.setNone();
|
2020-06-22 10:24:21 +00:00
|
|
|
|
2022-08-20 13:46:52 +00:00
|
|
|
if (sqrtNum >= ecx * ecx)
|
2021-10-21 22:08:40 +00:00
|
|
|
return c;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-08-20 13:46:52 +00:00
|
|
|
pos = hit.hitpos;
|
2021-11-25 23:25:28 +00:00
|
|
|
*ppSector = hit.hitSector;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-25 23:25:28 +00:00
|
|
|
if (hit.actor()) {
|
|
|
|
c.setSprite(hit.actor());
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2021-11-25 23:25:28 +00:00
|
|
|
if (hit.hitWall) {
|
2022-11-15 11:03:44 +00:00
|
|
|
c.setWall(wallindex(hit.hitWall));
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 22:08:40 +00:00
|
|
|
return c;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void CheckClip(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2023-03-27 11:05:25 +00:00
|
|
|
const auto pPlayer = &PlayerList[nPlayer];
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-27 11:05:25 +00:00
|
|
|
if (pPlayer->nPlayerClip <= 0)
|
|
|
|
pPlayer->nPlayerClip = min(pPlayer->nAmmo[kWeaponM60], (int16_t)100);
|
2021-07-17 04:57:00 +00:00
|
|
|
|
2023-03-27 11:05:25 +00:00
|
|
|
if (pPlayer->nPistolClip <= 0)
|
|
|
|
pPlayer->nPistolClip = min(pPlayer->nAmmo[kWeaponPistol], (int16_t)6);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:50:02 +00:00
|
|
|
void MoveWeapons(int nPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
const auto pPlayer = &PlayerList[nPlayer];
|
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
static int dword_96E22 = 0;
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
int nSectFlag = pPlayer->pPlayerViewSect->Flag;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if ((nSectFlag & kSectUnderwater) && (totalmoves & 1)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nPilotLightFrame++;
|
|
|
|
|
|
|
|
if (nPilotLightFrame >= nPilotLightCount)
|
|
|
|
nPilotLightFrame = 0;
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!pPlayer->bIsFiring || (nSectFlag & kSectUnderwater))
|
|
|
|
pPlayer->nTemperature = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
auto pPlayerActor = pPlayer->pActor;
|
|
|
|
int nWeapon = pPlayer->nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nWeapon < -1)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nNextWeapon != -1)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nCurrentWeapon = pPlayer->nNextWeapon;
|
|
|
|
pPlayer->nState = 0;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
|
|
|
pPlayer->nNextWeapon = -1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_26ACC
|
2023-03-25 09:32:11 +00:00
|
|
|
int eax = pPlayer->nState;
|
2021-11-21 19:34:15 +00:00
|
|
|
int nSeq = WeaponInfo[nWeapon].nSeq;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-04-06 09:19:23 +00:00
|
|
|
int var_3C = getSeqFromId(nSeq, WeaponInfo[nWeapon].b[eax]);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
int var_1C = (pPlayer->nDouble > 0) + 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
frames = var_1C - 1;
|
|
|
|
|
|
|
|
for (frames = var_1C; frames > 0; frames--)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
seq_MoveSequence(pPlayerActor, var_3C, pPlayer->nSeqSize2);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nSeqSize2++;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
dword_96E22++;
|
|
|
|
if (dword_96E22 >= 15) {
|
|
|
|
dword_96E22 = 0;
|
|
|
|
}
|
|
|
|
|
2023-04-06 08:51:39 +00:00
|
|
|
if (pPlayer->nSeqSize2 >= getSeqFrameCount(var_3C))
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nNextWeapon == -1)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
switch (pPlayer->nState)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
SetWeaponStatus(nPlayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->bIsFiring)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
if (!WeaponCanFire(nPlayer))
|
|
|
|
{
|
|
|
|
if (!dword_96E22) {
|
2023-03-25 09:32:11 +00:00
|
|
|
D3PlayFX(StaticSound[4], pPlayer->pActor);
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponRing)
|
|
|
|
{
|
2021-10-19 13:06:46 +00:00
|
|
|
if (Ra[nPlayer].pTarget == nullptr)
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
Ra[nPlayer].nAction = 0;
|
|
|
|
Ra[nPlayer].nFrame = 0;
|
2021-11-21 19:13:19 +00:00
|
|
|
Ra[nPlayer].nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 2;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
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:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (nWeapon == kWeaponPistol && pPlayer->nPistolClip <= 0)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 3;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nPistolClip = min<int>(6, pPlayer->nAmmo[kWeaponPistol]);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponGrenade)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!pPlayer->bIsFiring)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 3;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-04-06 08:51:39 +00:00
|
|
|
pPlayer->nSeqSize2 = getSeqFrameCount(var_3C) - 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 0;
|
|
|
|
pPlayer->nCurrentWeapon = pPlayer->nLastWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
nWeapon = pPlayer->nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
SetPlayerMummified(nPlayer, false);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loc_26D88:
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->bIsFiring && WeaponCanFire(nPlayer))
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
if (nWeapon != kWeaponM60 && nWeapon != kWeaponPistol) {
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 3;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (WeaponInfo[nWeapon].b[4] == -1)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponFlamer && (nSectFlag & kSectUnderwater))
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 4;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
{
|
|
|
|
if (nWeapon == kWeaponMummified)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nCurrentWeapon = pPlayer->nLastWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
nWeapon = pPlayer->nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponRing)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!WeaponInfo[nWeapon].d || pPlayer->nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!pPlayer->bIsFiring) {
|
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
|
|
|
}
|
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
Ra[nPlayer].nState = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponM60)
|
|
|
|
{
|
|
|
|
CheckClip(nPlayer);
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponGrenade)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!WeaponInfo[nWeapon].d || pPlayer->nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 5;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-04-06 08:51:39 +00:00
|
|
|
pPlayer->nSeqSize2 = getSeqFrameCount(getSeqFromId(nSeq, WeaponInfo[kWeaponGrenade].b[0])) - 1; // CHECKME
|
2019-11-16 12:28:07 +00:00
|
|
|
goto loc_flag; // FIXME
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->bIsFiring && WeaponCanFire(nPlayer)) {
|
|
|
|
pPlayer->nState = 2;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WeaponInfo[nWeapon].b[4] == -1)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponFlamer && (nSectFlag & kSectUnderwater))
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 4;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nCurrentWeapon = pPlayer->nNextWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
nWeapon = pPlayer->nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 0;
|
|
|
|
pPlayer->nNextWeapon = -1;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
SetWeaponStatus(nPlayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_26FC5
|
2023-04-06 09:19:23 +00:00
|
|
|
var_3C = getSeqFromId(WeaponInfo[nWeapon].nSeq, WeaponInfo[nWeapon].b[pPlayer->nState]);
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nState == 5)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nCurrentWeapon = pPlayer->nNextWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
nWeapon = pPlayer->nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nNextWeapon = -1;
|
|
|
|
pPlayer->nState = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 5;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
2023-04-06 08:51:39 +00:00
|
|
|
} // end of if (pPlayer->field_34 >= getSeqFrameCount(var_3C))
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
loc_flag:
|
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
// loc_27001
|
2023-04-06 09:08:39 +00:00
|
|
|
int nFrameFlag = getSeqFrameFlags(getSeqFrame(var_3C, pPlayer->nSeqSize2));
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (((!(nSectFlag & kSectUnderwater)) || nWeapon == kWeaponRing) && (nFrameFlag & 4))
|
|
|
|
{
|
2021-11-09 16:27:54 +00:00
|
|
|
BuildFlash(nPlayer, 512);
|
2019-11-16 12:28:07 +00:00
|
|
|
AddFlash(
|
2021-12-30 15:51:56 +00:00
|
|
|
pPlayerActor->sector(),
|
2022-08-20 14:19:07 +00:00
|
|
|
pPlayerActor->spr.pos,
|
2019-11-16 12:28:07 +00:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nFrameFlag & 0x80)
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
int nAction = pPlayer->nAction;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
int var_38 = 1;
|
|
|
|
|
|
|
|
if (nAction < 10 || nAction > 12) {
|
|
|
|
var_38 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nPlayer == nLocalPlayer) {
|
|
|
|
obobangle = bobangle = 512;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponFlamer && (!(nSectFlag & kSectUnderwater)))
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nTemperature++;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nTemperature > 50)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nTemperature = 0;
|
|
|
|
pPlayer->nState = 4;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 18:24:46 +00:00
|
|
|
int nAmmoType = WeaponInfo[nWeapon].nAmmoType;
|
2022-11-25 12:13:50 +00:00
|
|
|
DAngle nAngle = pPlayerActor->spr.Angles.Yaw;
|
2022-08-20 13:46:52 +00:00
|
|
|
auto thePos = pPlayerActor->spr.pos;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2022-09-10 19:24:40 +00:00
|
|
|
double nHeight = GetActorHeight(pPlayerActor) * -0.5;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nAction < 6)
|
|
|
|
{
|
2022-09-10 19:16:25 +00:00
|
|
|
nHeight -= 7;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!var_38)
|
|
|
|
{
|
2022-09-10 19:16:25 +00:00
|
|
|
nHeight += 4;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-09-10 19:16:25 +00:00
|
|
|
nHeight -= 10;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSectorB = pPlayerActor->sector();
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
switch (nWeapon)
|
|
|
|
{
|
|
|
|
// loc_27266:
|
|
|
|
case kWeaponSword:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
nHeight += pPlayerActor->spr.Angles.Pitch.Tan() * 32.;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2022-09-10 19:16:25 +00:00
|
|
|
thePos.Z += nHeight;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
int var_28;
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nState == 2) {
|
2019-11-16 12:28:07 +00:00
|
|
|
var_28 = 6;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var_28 = 9;
|
|
|
|
}
|
|
|
|
|
2022-08-20 13:46:52 +00:00
|
|
|
auto cRange = CheckCloseRange(nPlayer, thePos, &pSectorB);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-10-21 22:08:40 +00:00
|
|
|
if (cRange.type != kHitNone)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2021-11-21 19:34:15 +00:00
|
|
|
int nDamage = BulletInfo[kWeaponSword].nDamage;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nDouble) {
|
2019-11-16 12:28:07 +00:00
|
|
|
nDamage *= 2;
|
|
|
|
}
|
|
|
|
|
2021-10-21 22:08:40 +00:00
|
|
|
//if (cRange.type != kHitNone)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2021-10-21 22:08:40 +00:00
|
|
|
if (cRange.type == kHitWall)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
// loc_2730E:
|
|
|
|
var_28 += 2;
|
|
|
|
}
|
2021-10-21 22:08:40 +00:00
|
|
|
else if (cRange.type == kHitSprite)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
auto pActor2 = cRange.actor();
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-12-23 17:11:53 +00:00
|
|
|
if (pActor2->spr.cstat & (CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ONE_SIDE))
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
var_28 += 2;
|
|
|
|
}
|
2021-12-23 17:11:53 +00:00
|
|
|
else if (pActor2->spr.statnum > 90 && pActor2->spr.statnum <= 199)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2021-10-21 07:46:24 +00:00
|
|
|
runlist_DamageEnemy(pActor2, pPlayerActor, nDamage);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-12-23 17:11:53 +00:00
|
|
|
if (pActor2->spr.statnum < 102) {
|
2019-11-16 12:28:07 +00:00
|
|
|
var_28++;
|
|
|
|
}
|
2021-12-23 17:11:53 +00:00
|
|
|
else if (pActor2->spr.statnum == 102)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
|
|
|
// loc_27370:
|
2022-10-07 17:40:27 +00:00
|
|
|
BuildAnim(nullptr, 12, 0, thePos, pSectorB, 0.46875, 0);
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2021-12-23 17:11:53 +00:00
|
|
|
else if (pActor2->spr.statnum == kStatExplodeTrigger) {
|
2019-11-16 12:28:07 +00:00
|
|
|
var_28 += 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var_28++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loc_27370:
|
2022-10-07 17:40:27 +00:00
|
|
|
BuildAnim(nullptr, 12, 0, thePos, pSectorB, 0.46875, 0);
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_27399:
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = var_28;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponFlamer:
|
|
|
|
{
|
|
|
|
if (nSectFlag & kSectUnderwater)
|
|
|
|
{
|
|
|
|
DoBubbles(nPlayer);
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 1;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
2021-10-21 07:46:24 +00:00
|
|
|
StopActorSound(pPlayerActor);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (var_38) {
|
2022-09-10 19:16:25 +00:00
|
|
|
nHeight += 3;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-09-10 19:16:25 +00:00
|
|
|
nHeight -= 10;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// fall through to case 1 (kWeaponPistol)
|
2021-10-21 07:46: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
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nQuake = 0.5;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
// fall through
|
2021-12-14 11:05:24 +00:00
|
|
|
[[fallthrough]];
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
case kWeaponPistol:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
double h = pPlayerActor->spr.Angles.Pitch.Tan() * 2.;
|
2022-10-11 06:46:56 +00:00
|
|
|
nHeight += h;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-10-21 20:18:29 +00:00
|
|
|
DExhumedActor* target = nullptr;
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->pTarget != nullptr && Autoaim(nPlayer))
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
DExhumedActor* t = pPlayer->pTarget;
|
2021-10-21 20:18:29 +00:00
|
|
|
// only autoaim if target is in front of the player.
|
2021-12-30 15:51:56 +00:00
|
|
|
assert(t->sector());
|
2022-09-30 11:51:37 +00:00
|
|
|
DAngle angletotarget = (t->spr.pos - pPlayerActor->spr.pos).Angle();
|
2022-11-25 12:13:50 +00:00
|
|
|
DAngle anglediff = absangle(pPlayerActor->spr.Angles.Yaw, angletotarget);
|
2022-09-09 15:58:11 +00:00
|
|
|
if (anglediff < DAngle90)
|
2021-05-16 17:20:36 +00:00
|
|
|
{
|
2021-10-21 20:18:29 +00:00
|
|
|
target = t;
|
2022-08-20 15:44:55 +00:00
|
|
|
h = 0;
|
2021-05-16 17:20:36 +00:00
|
|
|
}
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 10:53:29 +00:00
|
|
|
BuildBullet(pPlayerActor, nAmmoType, nHeight, nAngle, target, var_1C, -int(h * zworldtoint));
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWeaponGrenade:
|
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
ThrowGrenade(nPlayer, nHeight - 10, pPlayerActor->spr.Angles.Pitch.Tan());
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponStaff:
|
|
|
|
{
|
2022-09-10 20:16:37 +00:00
|
|
|
BuildSnake(nPlayer, nHeight);
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nQuake = 2.;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nThrust -= pPlayerActor->spr.Angles.Yaw.ToVector() * 2;
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kWeaponRing:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kWeaponMummified:
|
|
|
|
{
|
2021-11-21 19:34:15 +00:00
|
|
|
int nDamage = BulletInfo[kWeaponMummified].nDamage;
|
2023-03-25 09:32:11 +00:00
|
|
|
if (pPlayer->nDouble) {
|
2019-11-16 12:28:07 +00:00
|
|
|
nDamage *= 2;
|
|
|
|
}
|
|
|
|
|
2021-10-21 07:46:24 +00:00
|
|
|
runlist_RadialDamageEnemy(pPlayerActor, nDamage, BulletInfo[kWeaponMummified].nRadius);
|
2019-11-16 12:28:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of switch, loc_2753E:
|
|
|
|
if (nWeapon < kWeaponMummified)
|
|
|
|
{
|
|
|
|
if (nWeapon != kWeaponGrenade)
|
2021-01-19 08:44:16 +00:00
|
|
|
{
|
|
|
|
if (WeaponInfo[nWeapon].d) {
|
|
|
|
AddAmmo(nPlayer, nAmmoType, -1);
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nWeapon == kWeaponM60) {
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nPlayerClip--;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
else if (nWeapon == kWeaponPistol) {
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nPistolClip--;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-25 09:32:11 +00:00
|
|
|
if (!WeaponInfo[nWeapon].d || pPlayer->nAmmo[WeaponInfo[nWeapon].nAmmoType])
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
if (nWeapon == kWeaponM60 && pPlayer->nPlayerClip <= 0)
|
2019-11-16 12:28:07 +00:00
|
|
|
{
|
2023-03-25 09:32:11 +00:00
|
|
|
pPlayer->nState = 3;
|
|
|
|
pPlayer->nSeqSize2 = 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
// goto loc_27609:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nWeapon != kWeaponGrenade)
|
|
|
|
{
|
|
|
|
SelectNewWeapon(nPlayer);
|
|
|
|
// go to loc_27609:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-07 05:34:55 +00:00
|
|
|
void DrawWeapons(double interpfrac)
|
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
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int nWeapon = PlayerList[nLocalPlayer].nCurrentWeapon;
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon < -1) {
|
|
|
|
return;
|
|
|
|
}
|
2021-11-21 19:34:15 +00:00
|
|
|
int var_34 = PlayerList[nLocalPlayer].nState;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-04-06 09:19:23 +00:00
|
|
|
int var_30 = getSeqFromId(WeaponInfo[nWeapon].nSeq);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int var_28 = var_30 + WeaponInfo[nWeapon].b[var_34];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-03-18 01:52:54 +00:00
|
|
|
int8_t nShade = PlayerList[nLocalPlayer].pActor->sector()->ceilingshade;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-05-13 17:15:53 +00:00
|
|
|
int nDouble = PlayerList[nLocalPlayer].nDouble;
|
2019-11-16 12:28:07 +00:00
|
|
|
int nPal = kPalNormal;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nDouble)
|
|
|
|
{
|
2020-11-30 00:07:14 +00:00
|
|
|
if (isRed) {
|
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
|
|
|
|
2020-11-30 00:07:14 +00:00
|
|
|
isRed = isRed == 0;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
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;
|
2022-05-05 22:03:54 +00:00
|
|
|
bool screenalign = false;
|
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
|
|
|
{
|
2021-04-15 03:35:42 +00:00
|
|
|
double nBobAngle, nVal;
|
|
|
|
|
|
|
|
if (cl_hudinterpolation)
|
|
|
|
{
|
2022-12-11 01:09:19 +00:00
|
|
|
nBobAngle = interpolatedvalue<double>(obobangle, bobangle, interpfrac);
|
2022-09-07 08:50:01 +00:00
|
|
|
nVal = interpolatedvalue<double>(PlayerList[nLocalPlayer].ototalvel, PlayerList[nLocalPlayer].totalvel, interpfrac);
|
2021-04-15 03:35:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nBobAngle = bobangle;
|
2021-10-21 10:51:16 +00:00
|
|
|
nVal = PlayerList[nLocalPlayer].totalvel;
|
2021-04-15 03:35:42 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 01:09:19 +00:00
|
|
|
yOffset = nVal * fabs(BobVal(nBobAngle)) * (1. / 16.);
|
2020-08-24 03:22:52 +00:00
|
|
|
|
|
|
|
if (var_34 == 1)
|
|
|
|
{
|
2022-12-11 01:09:19 +00:00
|
|
|
xOffset = nVal * BobVal(nBobAngle + 512) * (1. / 8.);
|
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);
|
|
|
|
}
|
2022-05-05 22:03:54 +00:00
|
|
|
else if (nWeapon == 8 || nWeapon == 9)
|
|
|
|
{
|
|
|
|
screenalign = true;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-16 12:28:07 +00:00
|
|
|
if (nWeapon < 0) {
|
2021-12-26 07:47:54 +00:00
|
|
|
nShade = PlayerList[nLocalPlayer].pActor->spr.shade;
|
2019-11-16 12:28:07 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
const auto weaponOffsets = PlayerList[nLocalPlayer].Angles.getWeaponOffsets(interpfrac);
|
2022-12-11 01:42:54 +00:00
|
|
|
const auto angle = weaponOffsets.second;
|
2022-12-11 00:54:00 +00:00
|
|
|
xOffset += weaponOffsets.first.X;
|
|
|
|
yOffset += weaponOffsets.first.Y;
|
2020-09-21 10:37:09 +00:00
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal, angle, screenalign);
|
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:
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
int nClip = PlayerList[nLocalPlayer].nPlayerClip;
|
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;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(nSeqOffset, PlayerList[nLocalPlayer].nSeqSize2, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
int nClip = PlayerList[nLocalPlayer].nPlayerClip;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int edx = (nClip % 3) * 4;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 8, edx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 3) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 9, edx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 6) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 10, edx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 25) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 11, edx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
int nClip = PlayerList[nLocalPlayer].nPlayerClip;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int dx = PlayerList[nLocalPlayer].nSeqSize2;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 8, dx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 3) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 9, dx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 6) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 10, dx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
if (nClip <= 25) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(var_30 + 11, dx, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
int nClip = PlayerList[nLocalPlayer].nPlayerClip;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int ax = PlayerList[nLocalPlayer].nSeqSize2;
|
2019-11-16 12:28:07 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-12-11 00:54:00 +00:00
|
|
|
seq_DrawGunSequence(nSeqOffset, ax, xOffset, yOffset, nShade, nPal, angle);
|
2019-11-16 12:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|