2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood 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-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-09-06 11:39:57 +00:00
|
|
|
#include "automap.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "blood.h"
|
2019-12-09 01:01:30 +00:00
|
|
|
#include "gstrings.h"
|
2020-09-04 20:23:38 +00:00
|
|
|
#include "gamestate.h"
|
2020-09-06 10:44:58 +00:00
|
|
|
#include "automap.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
PLAYER gPlayer[kMaxPlayers];
|
|
|
|
|
2019-09-15 11:59:27 +00:00
|
|
|
bool gBlueFlagDropped = false;
|
|
|
|
bool gRedFlagDropped = false;
|
|
|
|
|
2019-10-19 19:11:39 +00:00
|
|
|
// V = has effect in game, X = no effect in game
|
2019-09-19 22:42:45 +00:00
|
|
|
POWERUPINFO gPowerUpInfo[kMaxPowerUps] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ -1, 1, 1, 1 }, // 00: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 01: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 02: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 03: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 04: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 05: V keys
|
|
|
|
{ -1, 1, 1, 1 }, // 06: V keys
|
|
|
|
{ -1, 0, 100, 100 }, // 07: V doctor's bag
|
|
|
|
{ -1, 0, 50, 100 }, // 08: V medicine pouch
|
|
|
|
{ -1, 0, 20, 100 }, // 09: V life essense
|
|
|
|
{ -1, 0, 100, 200 }, // 10: V life seed
|
|
|
|
{ -1, 0, 2, 200 }, // 11: V red potion
|
|
|
|
{ 783, 0, 3600, 432000 }, // 12: V feather fall
|
|
|
|
{ 896, 0, 3600, 432000 }, // 13: V cloak of invisibility
|
|
|
|
{ 825, 1, 3600, 432000 }, // 14: V death mask (invulnerability)
|
|
|
|
{ 827, 0, 3600, 432000 }, // 15: V jump boots
|
|
|
|
{ 828, 0, 3600, 432000 }, // 16: X raven flight
|
|
|
|
{ 829, 0, 3600, 1728000 }, // 17: V guns akimbo
|
|
|
|
{ 830, 0, 3600, 432000 }, // 18: V diving suit
|
|
|
|
{ 831, 0, 3600, 432000 }, // 19: V gas mask
|
|
|
|
{ -1, 0, 3600, 432000 }, // 20: X clone
|
|
|
|
{ 2566, 0, 3600, 432000 }, // 21: V crystal ball
|
|
|
|
{ 836, 0, 3600, 432000 }, // 22: X decoy
|
|
|
|
{ 853, 0, 3600, 432000 }, // 23: V doppleganger
|
|
|
|
{ 2428, 0, 3600, 432000 }, // 24: V reflective shots
|
|
|
|
{ 839, 0, 3600, 432000 }, // 25: V beast vision
|
|
|
|
{ 768, 0, 3600, 432000 }, // 26: X cloak of shadow (useless)
|
|
|
|
{ 840, 0, 3600, 432000 }, // 27: X rage shroom
|
|
|
|
{ 841, 0, 900, 432000 }, // 28: V delirium shroom
|
|
|
|
{ 842, 0, 3600, 432000 }, // 29: V grow shroom (gModernMap only)
|
|
|
|
{ 843, 0, 3600, 432000 }, // 30: V shrink shroom (gModernMap only)
|
|
|
|
{ -1, 0, 3600, 432000 }, // 31: X death mask (useless)
|
|
|
|
{ -1, 0, 3600, 432000 }, // 32: X wine goblet
|
|
|
|
{ -1, 0, 3600, 432000 }, // 33: X wine bottle
|
|
|
|
{ -1, 0, 3600, 432000 }, // 34: X skull grail
|
|
|
|
{ -1, 0, 3600, 432000 }, // 35: X silver grail
|
|
|
|
{ -1, 0, 3600, 432000 }, // 36: X tome
|
|
|
|
{ -1, 0, 3600, 432000 }, // 37: X black chest
|
|
|
|
{ -1, 0, 3600, 432000 }, // 38: X wooden chest
|
|
|
|
{ 837, 1, 3600, 432000 }, // 39: V asbestos armor
|
|
|
|
{ -1, 0, 1, 432000 }, // 40: V basic armor
|
|
|
|
{ -1, 0, 1, 432000 }, // 41: V body armor
|
|
|
|
{ -1, 0, 1, 432000 }, // 42: V fire armor
|
|
|
|
{ -1, 0, 1, 432000 }, // 43: V spirit armor
|
|
|
|
{ -1, 0, 1, 432000 }, // 44: V super armor
|
|
|
|
{ 0, 0, 0, 0 }, // 45: ? unknown
|
|
|
|
{ 0, 0, 0, 0 }, // 46: ? unknown
|
|
|
|
{ 0, 0, 0, 0 }, // 47: ? unknown
|
|
|
|
{ 0, 0, 0, 0 }, // 48: ? unknown
|
|
|
|
{ 0, 0, 0, 0 }, // 49: X dummy
|
|
|
|
{ 833, 1, 1, 1 } // 50: V kModernItemLevelMap (gModernMap only)
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int Handicap[] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
144, 208, 256, 304, 368
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
2020-01-01 20:53:29 +00:00
|
|
|
POSTURE gPostureDefaults[kModeMax][kPostureMax] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
|
|
|
|
// normal human
|
|
|
|
{
|
2022-09-12 11:16:31 +00:00
|
|
|
{ 0x4000, 0x4000, 0x4000, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 },
|
|
|
|
{ 0x1200, 0x1200, 0x1200, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -0x600, 0xb0, 0x5b05, 0 },
|
|
|
|
{ 0x2000, 0x2000, 0x2000, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -0x600, 0xb0, 0, 0 },
|
2021-12-29 21:56:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// normal beast
|
|
|
|
{
|
2022-09-12 11:16:31 +00:00
|
|
|
{ 0x4000, 0x4000, 0x4000, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 0xc00, 0x90, -0xbaaaa, -0x175555 },
|
|
|
|
{ 0x1200, 0x1200, 0x1200, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -0x600, 0xb0, 0x5b05, 0 },
|
|
|
|
{ 0x2000, 0x2000, 0x2000, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -0x600, 0xb0, 0, 0 },
|
2021-12-29 21:56:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// shrink human
|
|
|
|
{
|
2022-09-12 11:16:31 +00:00
|
|
|
{ 10384, 10384, 10384, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 3072, 144, -564586, -1329173 },
|
|
|
|
{ 2108, 2108, 2108, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -1536, 176, 0x5b05, 0 },
|
|
|
|
{ 2192, 2192, 2192, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -1536, 176, 0, 0 },
|
2021-12-29 21:56:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// grown human
|
|
|
|
{
|
2022-09-12 11:16:31 +00:00
|
|
|
{ 19384, 19384, 19384, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 22, 18, 3072, 144, -1014586, -1779173 },
|
|
|
|
{ 5608, 5608, 5608, 14, 17, 0.09375, 0.0625, 0.125, 0.3125, 20, 16, -1536, 176, 0x5b05, 0 },
|
|
|
|
{ 11192, 11192, 11192, 22, 28, 0.09375, 0.0625, 0.0625, 0.15625, 8, 6, -1536, 176, 0, 0 },
|
2021-12-29 21:56:21 +00:00
|
|
|
},
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AMMOINFO gAmmoInfo[] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ 0, -1 },
|
|
|
|
{ 100, -1 },
|
|
|
|
{ 100, 4 },
|
|
|
|
{ 500, 5 },
|
|
|
|
{ 100, -1 },
|
|
|
|
{ 50, -1 },
|
|
|
|
{ 2880, -1 },
|
|
|
|
{ 250, -1 },
|
|
|
|
{ 100, -1 },
|
|
|
|
{ 100, -1 },
|
|
|
|
{ 50, -1 },
|
|
|
|
{ 50, -1 },
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ARMORDATA {
|
2021-12-29 21:56:21 +00:00
|
|
|
int armor0;
|
|
|
|
int armor0max;
|
|
|
|
int armor1;
|
|
|
|
int armor1max;
|
|
|
|
int armor2;
|
|
|
|
int armor2max;
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
ARMORDATA armorData[5] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ 0x320, 0x640, 0x320, 0x640, 0x320, 0x640 },
|
|
|
|
{ 0x640, 0x640, 0, 0x640, 0, 0x640 },
|
|
|
|
{ 0, 0x640, 0x640, 0x640, 0, 0x640 },
|
|
|
|
{ 0, 0x640, 0, 0x640, 0x640, 0x640 },
|
|
|
|
{ 0xc80, 0xc80, 0xc80, 0xc80, 0xc80, 0xc80 }
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct VICTORY {
|
2021-12-29 21:56:21 +00:00
|
|
|
const char* message;
|
|
|
|
int Kills;
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
VICTORY gVictory[] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ "%s boned %s like a fish", 4100 },
|
|
|
|
{ "%s castrated %s", 4101 },
|
|
|
|
{ "%s creamed %s", 4102 },
|
|
|
|
{ "%s destroyed %s", 4103 },
|
|
|
|
{ "%s diced %s", 4104 },
|
|
|
|
{ "%s disemboweled %s", 4105 },
|
|
|
|
{ "%s flattened %s", 4106 },
|
|
|
|
{ "%s gave %s Anal Justice", 4107 },
|
|
|
|
{ "%s gave AnAl MaDnEsS to %s", 4108 },
|
|
|
|
{ "%s hurt %s real bad", 4109 },
|
|
|
|
{ "%s killed %s", 4110 },
|
|
|
|
{ "%s made mincemeat out of %s", 4111 },
|
|
|
|
{ "%s massacred %s", 4112 },
|
|
|
|
{ "%s mutilated %s", 4113 },
|
|
|
|
{ "%s reamed %s", 4114 },
|
|
|
|
{ "%s ripped %s a new orifice", 4115 },
|
|
|
|
{ "%s slaughtered %s", 4116 },
|
|
|
|
{ "%s sliced %s", 4117 },
|
|
|
|
{ "%s smashed %s", 4118 },
|
|
|
|
{ "%s sodomized %s", 4119 },
|
|
|
|
{ "%s splattered %s", 4120 },
|
|
|
|
{ "%s squashed %s", 4121 },
|
|
|
|
{ "%s throttled %s", 4122 },
|
|
|
|
{ "%s wasted %s", 4123 },
|
|
|
|
{ "%s body bagged %s", 4124 },
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SUICIDE {
|
2021-12-29 21:56:21 +00:00
|
|
|
const char* message;
|
|
|
|
int Kills;
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SUICIDE gSuicide[] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ "%s is excrement", 4202 },
|
|
|
|
{ "%s is hamburger", 4203 },
|
|
|
|
{ "%s suffered scrotum separation", 4204 },
|
|
|
|
{ "%s volunteered for population control", 4206 },
|
|
|
|
{ "%s has suicided", 4207 },
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DAMAGEINFO {
|
2021-12-29 21:56:21 +00:00
|
|
|
int armorType;
|
|
|
|
int Kills[3];
|
|
|
|
int at10[3];
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DAMAGEINFO damageInfo[7] = {
|
2021-12-29 21:56:21 +00:00
|
|
|
{ -1, 731, 732, 733, 710, 710, 710 },
|
|
|
|
{ 1, 742, 743, 744, 711, 711, 711 },
|
|
|
|
{ 0, 731, 732, 733, 712, 712, 712 },
|
|
|
|
{ 1, 731, 732, 733, 713, 713, 713 },
|
|
|
|
{ -1, 724, 724, 724, 714, 714, 714 },
|
|
|
|
{ 2, 731, 732, 733, 715, 715, 715 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0 }
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-23 12:15:19 +00:00
|
|
|
inline bool IsTargetTeammate(PLAYER* pSourcePlayer, DBloodActor* target)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pSourcePlayer == nullptr)
|
|
|
|
return false;
|
|
|
|
if (!target->IsPlayerActor())
|
|
|
|
return false;
|
|
|
|
if (gGameOptions.nGameType == 1 || gGameOptions.nGameType == 3)
|
|
|
|
{
|
|
|
|
PLAYER* pTargetPlayer = &gPlayer[target->spr.type - kDudePlayer1];
|
|
|
|
if (pSourcePlayer != pTargetPlayer)
|
|
|
|
{
|
|
|
|
if (gGameOptions.nGameType == 1)
|
|
|
|
return true;
|
|
|
|
if (gGameOptions.nGameType == 3 && (pSourcePlayer->teamId & 3) == (pTargetPlayer->teamId & 3))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-12-23 12:15:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int powerupCheck(PLAYER* pPlayer, int nPowerUp)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(pPlayer != NULL);
|
|
|
|
assert(nPowerUp >= 0 && nPowerUp < kMaxPowerUps);
|
|
|
|
int nPack = powerupToPackItem(nPowerUp);
|
|
|
|
if (nPack >= 0 && !packItemActive(pPlayer, nPack))
|
|
|
|
return 0;
|
|
|
|
return pPlayer->pwUpTime[nPowerUp];
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
|
2019-10-19 19:11:39 +00:00
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool powerupActivate(PLAYER* pPlayer, int nPowerUp)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (powerupCheck(pPlayer, nPowerUp) > 0 && gPowerUpInfo[nPowerUp].pickupOnce)
|
|
|
|
return 0;
|
|
|
|
if (!pPlayer->pwUpTime[nPowerUp])
|
|
|
|
pPlayer->pwUpTime[nPowerUp] = gPowerUpInfo[nPowerUp].bonusTime;
|
|
|
|
int nPack = powerupToPackItem(nPowerUp);
|
|
|
|
if (nPack >= 0)
|
|
|
|
pPlayer->packSlots[nPack].isActive = 1;
|
|
|
|
|
|
|
|
switch (nPowerUp + kItemBase) {
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kItemModernMapLevel:
|
|
|
|
if (gModernMap) gFullMap = true;
|
|
|
|
break;
|
|
|
|
case kItemShroomShrink:
|
|
|
|
if (!gModernMap) break;
|
|
|
|
else if (isGrown(pPlayer->actor)) playerDeactivateShrooms(pPlayer);
|
|
|
|
else playerSizeShrink(pPlayer, 2);
|
|
|
|
break;
|
|
|
|
case kItemShroomGrow:
|
|
|
|
if (!gModernMap) break;
|
|
|
|
else if (isShrinked(pPlayer->actor)) playerDeactivateShrooms(pPlayer);
|
|
|
|
else {
|
|
|
|
playerSizeGrow(pPlayer, 2);
|
|
|
|
if (powerupCheck(&gPlayer[pPlayer->actor->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0) {
|
|
|
|
powerupDeactivate(pPlayer, kPwUpShadowCloak);
|
|
|
|
pPlayer->pwUpTime[kPwUpShadowCloak] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ceilIsTooLow(pPlayer->actor))
|
|
|
|
actDamageSprite(pPlayer->actor, pPlayer->actor, kDamageExplode, 65535);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case kItemFeatherFall:
|
|
|
|
case kItemJumpBoots:
|
|
|
|
pPlayer->damageControl[0]++;
|
|
|
|
break;
|
|
|
|
case kItemReflectShots: // reflective shots
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pPlayer->nPlayer == myconnectindex && gGameOptions.nGameType == 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
sfxSetReverb2(1);
|
|
|
|
break;
|
|
|
|
case kItemDeathMask:
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
pPlayer->damageControl[i]++;
|
|
|
|
break;
|
|
|
|
case kItemDivingSuit: // diving suit
|
|
|
|
pPlayer->damageControl[4]++;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pPlayer->nPlayer == myconnectindex && gGameOptions.nGameType == 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
sfxSetReverb(1);
|
|
|
|
break;
|
|
|
|
case kItemGasMask:
|
|
|
|
pPlayer->damageControl[4]++;
|
|
|
|
break;
|
|
|
|
case kItemArmorAsbest:
|
|
|
|
pPlayer->damageControl[1]++;
|
|
|
|
break;
|
|
|
|
case kItemTwoGuns:
|
|
|
|
pPlayer->newWeapon = pPlayer->curWeapon;
|
|
|
|
WeaponRaise(pPlayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 776, -1, 0);
|
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void powerupDeactivate(PLAYER* pPlayer, int nPowerUp)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
int nPack = powerupToPackItem(nPowerUp);
|
|
|
|
if (nPack >= 0)
|
|
|
|
pPlayer->packSlots[nPack].isActive = 0;
|
|
|
|
|
|
|
|
switch (nPowerUp + kItemBase) {
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kItemShroomShrink:
|
|
|
|
if (gModernMap) {
|
|
|
|
playerSizeReset(pPlayer);
|
|
|
|
if (ceilIsTooLow(pPlayer->actor))
|
|
|
|
actDamageSprite(pPlayer->actor, pPlayer->actor, kDamageExplode, 65535);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kItemShroomGrow:
|
|
|
|
if (gModernMap) playerSizeReset(pPlayer);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case kItemFeatherFall:
|
|
|
|
case kItemJumpBoots:
|
|
|
|
pPlayer->damageControl[0]--;
|
|
|
|
break;
|
|
|
|
case kItemDeathMask:
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
pPlayer->damageControl[i]--;
|
|
|
|
break;
|
|
|
|
case kItemDivingSuit:
|
|
|
|
pPlayer->damageControl[4]--;
|
2022-09-24 10:26:18 +00:00
|
|
|
if (pPlayer && pPlayer->nPlayer == myconnectindex && VanillaMode() ? true : pPlayer->pwUpTime[24] == 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
sfxSetReverb(0);
|
|
|
|
break;
|
|
|
|
case kItemReflectShots:
|
2022-09-24 10:26:18 +00:00
|
|
|
if (pPlayer && pPlayer->nPlayer == myconnectindex && VanillaMode() ? true : pPlayer->packSlots[1].isActive == 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
sfxSetReverb(0);
|
|
|
|
break;
|
|
|
|
case kItemGasMask:
|
|
|
|
pPlayer->damageControl[4]--;
|
|
|
|
break;
|
|
|
|
case kItemArmorAsbest:
|
|
|
|
pPlayer->damageControl[1]--;
|
|
|
|
break;
|
|
|
|
case kItemTwoGuns:
|
|
|
|
pPlayer->newWeapon = pPlayer->curWeapon;
|
|
|
|
WeaponRaise(pPlayer);
|
|
|
|
break;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void powerupSetState(PLAYER* pPlayer, int nPowerUp, bool bState)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (!bState)
|
|
|
|
powerupActivate(pPlayer, nPowerUp);
|
|
|
|
else
|
|
|
|
powerupDeactivate(pPlayer, nPowerUp);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void powerupProcess(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->packItemTime = ClipLow(pPlayer->packItemTime - 4, 0);
|
|
|
|
for (int i = kMaxPowerUps - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
int nPack = powerupToPackItem(i);
|
|
|
|
if (nPack >= 0)
|
|
|
|
{
|
|
|
|
if (pPlayer->packSlots[nPack].isActive)
|
|
|
|
{
|
|
|
|
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i] - 4, 0);
|
|
|
|
if (pPlayer->pwUpTime[i])
|
|
|
|
pPlayer->packSlots[nPack].curAmount = (100 * pPlayer->pwUpTime[i]) / gPowerUpInfo[i].bonusTime;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
powerupDeactivate(pPlayer, i);
|
|
|
|
if (pPlayer->packItemId == nPack)
|
|
|
|
pPlayer->packItemId = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pPlayer->pwUpTime[i] > 0)
|
|
|
|
{
|
|
|
|
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i] - 4, 0);
|
|
|
|
if (!pPlayer->pwUpTime[i])
|
|
|
|
powerupDeactivate(pPlayer, i);
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void powerupClear(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
for (int i = kMaxPowerUps - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
pPlayer->pwUpTime[i] = 0;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
int packItemToPowerup(int nPack)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
int nPowerUp = -1;
|
|
|
|
switch (nPack) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
nPowerUp = kPwUpDivingSuit;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
nPowerUp = kPwUpCrystalBall;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
nPowerUp = kPwUpBeastVision;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
nPowerUp = kPwUpJumpBoots;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
I_Error("Unhandled pack item %d", nPack);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nPowerUp;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
int powerupToPackItem(int nPowerUp)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
switch (nPowerUp) {
|
|
|
|
case kPwUpDivingSuit:
|
|
|
|
return 1;
|
|
|
|
case kPwUpCrystalBall:
|
|
|
|
return 2;
|
|
|
|
case kPwUpBeastVision:
|
|
|
|
return 3;
|
|
|
|
case kPwUpJumpBoots:
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
return -1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool packAddItem(PLAYER* pPlayer, unsigned int nPack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (nPack <= 4)
|
|
|
|
{
|
|
|
|
if (pPlayer->packSlots[nPack].curAmount >= 100)
|
|
|
|
return 0;
|
|
|
|
pPlayer->packSlots[nPack].curAmount = 100;
|
|
|
|
int nPowerUp = packItemToPowerup(nPack);
|
|
|
|
if (nPowerUp >= 0)
|
|
|
|
pPlayer->pwUpTime[nPowerUp] = gPowerUpInfo[nPowerUp].bonusTime;
|
|
|
|
if (pPlayer->packItemId == -1)
|
|
|
|
pPlayer->packItemId = nPack;
|
|
|
|
if (!pPlayer->packSlots[pPlayer->packItemId].curAmount)
|
|
|
|
pPlayer->packItemId = nPack;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
I_Error("Unhandled pack item %d", nPack);
|
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int packCheckItem(PLAYER* pPlayer, int nPack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
return pPlayer->packSlots[nPack].curAmount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
bool packItemActive(PLAYER* pPlayer, int nPack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
return pPlayer->packSlots[nPack].isActive;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void packUseItem(PLAYER* pPlayer, int nPack)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
bool v4 = 0;
|
|
|
|
int nPowerUp = -1;
|
|
|
|
if (pPlayer->packSlots[nPack].curAmount > 0)
|
|
|
|
{
|
2020-09-11 17:58:16 +00:00
|
|
|
pPlayer->packItemId = nPack;
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
switch (nPack)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
unsigned int health = pPlayer->actor->xspr.health >> 4;
|
|
|
|
if (health < 100)
|
|
|
|
{
|
|
|
|
int heal = ClipHigh(100 - health, pPlayer->packSlots[0].curAmount);
|
|
|
|
actHealDude(pPlayer->actor, heal, 100);
|
|
|
|
pPlayer->packSlots[0].curAmount -= heal;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
v4 = 1;
|
|
|
|
nPowerUp = kPwUpDivingSuit;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
v4 = 1;
|
|
|
|
nPowerUp = kPwUpCrystalBall;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
v4 = 1;
|
|
|
|
nPowerUp = kPwUpBeastVision;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
v4 = 1;
|
|
|
|
nPowerUp = kPwUpJumpBoots;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
I_Error("Unhandled pack item %d", nPack);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPlayer->packItemTime = 0;
|
|
|
|
if (v4)
|
|
|
|
powerupSetState(pPlayer, nPowerUp, pPlayer->packSlots[nPack].isActive);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void packPrevItem(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pPlayer->packItemTime > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
for (int nPrev = pPlayer->packItemId - 1; nPrev >= 0; nPrev--)
|
|
|
|
{
|
|
|
|
if (pPlayer->packSlots[nPrev].curAmount)
|
|
|
|
{
|
|
|
|
pPlayer->packItemId = nPrev;
|
|
|
|
pPlayer->packItemTime = 600;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPlayer->packItemId = 4;
|
|
|
|
if (pPlayer->packSlots[4].curAmount) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pPlayer->packItemTime = 600;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-08-27 20:29:45 +00:00
|
|
|
void packNextItem(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pPlayer->packItemTime > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
for (int nNext = pPlayer->packItemId + 1; nNext < 5; nNext++)
|
|
|
|
{
|
|
|
|
if (pPlayer->packSlots[nNext].curAmount)
|
|
|
|
{
|
|
|
|
pPlayer->packItemId = nNext;
|
|
|
|
pPlayer->packItemTime = 600;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPlayer->packItemId = 0;
|
|
|
|
if (pPlayer->packSlots[0].curAmount) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPlayer->packItemTime = 600;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool playerSeqPlaying(PLAYER* pPlayer, int nSeq)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
int nCurSeq = seqGetID(pPlayer->actor);
|
|
|
|
if (pPlayer->pDudeInfo->seqStartID + nSeq == nCurSeq && seqGetStatus(pPlayer->actor) >= 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void playerSetRace(PLAYER* pPlayer, int nLifeMode)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(nLifeMode >= kModeHuman && nLifeMode <= kModeHumanGrown);
|
|
|
|
DUDEINFO* pDudeInfo = pPlayer->pDudeInfo;
|
|
|
|
*pDudeInfo = gPlayerTemplate[nLifeMode];
|
|
|
|
pPlayer->lifeMode = nLifeMode;
|
|
|
|
|
|
|
|
// By NoOne: don't forget to change clipdist for grow and shrink modes
|
2022-09-09 16:32:42 +00:00
|
|
|
pPlayer->actor->set_native_clipdist(pDudeInfo->clipdist);
|
2021-12-29 21:56:21 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
pDudeInfo->damageVal[i] = MulScale(Handicap[gSkill], pDudeInfo->startDamage[i], 8);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void playerSetGodMode(PLAYER* pPlayer, bool bGodMode)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->godMode = bGodMode;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
void playerResetInertia(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
|
2022-09-11 13:33:14 +00:00
|
|
|
pPlayer->zView = pPlayer->actor->spr.pos.Z - pPosture->eyeAboveZ;
|
|
|
|
pPlayer->zWeapon = pPlayer->actor->spr.pos.Z - pPosture->weaponAboveZ;
|
2021-12-29 21:56:21 +00:00
|
|
|
viewBackupView(pPlayer->nPlayer);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2022-09-10 10:27:14 +00:00
|
|
|
void playerCorrectInertia(PLAYER* pPlayer, const DVector3& oldpos)
|
2019-09-07 16:39:26 +00:00
|
|
|
{
|
2022-09-11 12:09:19 +00:00
|
|
|
auto zAdj = pPlayer->actor->spr.pos.Z - oldpos.Z;
|
2022-09-10 10:27:14 +00:00
|
|
|
pPlayer->zView += zAdj;
|
2022-09-11 13:19:19 +00:00
|
|
|
pPlayer->zWeapon += zAdj;
|
2022-09-10 12:15:33 +00:00
|
|
|
pPlayer->actor->opos.XY() += pPlayer->actor->spr.pos.XY() - oldpos.XY();
|
2022-09-11 12:09:19 +00:00
|
|
|
pPlayer->ozView += zAdj;
|
2019-09-07 16:39:26 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
void playerResetPowerUps(PLAYER* pPlayer)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
for (int i = 0; i < kMaxPowerUps; i++) {
|
|
|
|
if (!VanillaMode() && (i == kPwUpJumpBoots || i == kPwUpDivingSuit || i == kPwUpCrystalBall || i == kPwUpBeastVision))
|
|
|
|
continue;
|
|
|
|
pPlayer->pwUpTime[i] = 0;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void playerResetPosture(PLAYER* pPlayer) {
|
2021-12-29 21:56:21 +00:00
|
|
|
memcpy(pPlayer->pPosture, gPostureDefaults, sizeof(gPostureDefaults));
|
2022-05-05 22:59:53 +00:00
|
|
|
if (!VanillaMode()) {
|
|
|
|
pPlayer->bobPhase = 0;
|
|
|
|
pPlayer->bobAmp = 0;
|
|
|
|
pPlayer->swayAmp = 0;
|
|
|
|
pPlayer->bobHeight = 0;
|
|
|
|
pPlayer->bobWidth = 0;
|
|
|
|
pPlayer->swayHeight = 0;
|
|
|
|
pPlayer->swayWidth = 0;
|
|
|
|
}
|
2020-02-07 19:47:43 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-02-10 05:23:49 +00:00
|
|
|
void playerStart(int nPlayer, int bNewLevel)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
PLAYER* pPlayer = &gPlayer[nPlayer];
|
|
|
|
InputPacket* pInput = &pPlayer->input;
|
|
|
|
ZONE* pStartZone = NULL;
|
|
|
|
|
|
|
|
// normal start position
|
|
|
|
if (gGameOptions.nGameType <= 1)
|
|
|
|
pStartZone = &gStartZone[nPlayer];
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// let's check if there is positions of teams is specified
|
|
|
|
// if no, pick position randomly, just like it works in vanilla.
|
|
|
|
else if (gModernMap && gGameOptions.nGameType == 3 && gTeamsSpawnUsed == true) {
|
|
|
|
int maxRetries = 5;
|
|
|
|
while (maxRetries-- > 0) {
|
|
|
|
if (pPlayer->teamId == 0) pStartZone = &gStartZoneTeam1[Random(3)];
|
|
|
|
else pStartZone = &gStartZoneTeam2[Random(3)];
|
|
|
|
|
|
|
|
if (maxRetries != 0) {
|
|
|
|
// check if there is no spawned player in selected zone
|
|
|
|
BloodSectIterator it(pStartZone->sector);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
2022-08-22 16:25:40 +00:00
|
|
|
if (pStartZone->pos.XY() == act->spr.pos.XY() && act->IsPlayerActor()) {
|
2021-12-29 21:56:21 +00:00
|
|
|
pStartZone = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pStartZone != NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else {
|
|
|
|
pStartZone = &gStartZone[Random(8)];
|
|
|
|
}
|
|
|
|
|
2022-08-22 16:25:40 +00:00
|
|
|
auto actor = actSpawnSprite(pStartZone->sector, pStartZone->pos, 6, 1);
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(actor->hasX());
|
|
|
|
pPlayer->actor = actor;
|
|
|
|
DUDEINFO* pDudeInfo = &dudeInfo[kDudePlayer1 + nPlayer - kDudeBase];
|
|
|
|
pPlayer->pDudeInfo = pDudeInfo;
|
|
|
|
playerSetRace(pPlayer, kModeHuman);
|
|
|
|
playerResetPosture(pPlayer);
|
|
|
|
seqSpawn(pDudeInfo->seqStartID, actor, -1);
|
2022-09-10 13:15:58 +00:00
|
|
|
if (nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
|
|
|
|
int top, bottom;
|
|
|
|
GetActorExtents(actor, &top, &bottom);
|
2022-01-30 17:09:26 +00:00
|
|
|
actor->add_int_z(-(bottom - actor->int_pos().Z));
|
2021-12-29 21:56:21 +00:00
|
|
|
actor->spr.pal = 11 + (pPlayer->teamId & 3);
|
2022-08-16 21:20:03 +00:00
|
|
|
actor->set_int_ang(pStartZone->ang);
|
2022-08-28 03:15:31 +00:00
|
|
|
pPlayer->angle.ang = actor->spr.angle;
|
2021-12-29 21:56:21 +00:00
|
|
|
actor->spr.type = kDudePlayer1 + nPlayer;
|
2022-09-09 16:32:42 +00:00
|
|
|
actor->set_native_clipdist(pDudeInfo->clipdist);
|
2021-12-29 21:56:21 +00:00
|
|
|
actor->spr.flags = 15;
|
|
|
|
actor->xspr.burnTime = 0;
|
|
|
|
actor->SetBurnSource(nullptr);
|
|
|
|
pPlayer->actor->xspr.health = pDudeInfo->startHealth << 4;
|
|
|
|
pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
|
|
|
pPlayer->bloodlust = 0;
|
|
|
|
pPlayer->horizon.horiz = pPlayer->horizon.horizoff = q16horiz(0);
|
|
|
|
pPlayer->slope = 0;
|
|
|
|
pPlayer->fragger = nullptr;
|
|
|
|
pPlayer->underwaterTime = 1200;
|
|
|
|
pPlayer->bubbleTime = 0;
|
|
|
|
pPlayer->restTime = 0;
|
|
|
|
pPlayer->kickPower = 0;
|
|
|
|
pPlayer->laughCount = 0;
|
2022-08-28 02:09:44 +00:00
|
|
|
pPlayer->angle.spin = nullAngle;
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->posture = 0;
|
|
|
|
pPlayer->voodooTarget = nullptr;
|
|
|
|
pPlayer->voodooTargets = 0;
|
|
|
|
pPlayer->voodooVar1 = 0;
|
|
|
|
pPlayer->vodooVar2 = 0;
|
|
|
|
playerResetInertia(pPlayer);
|
|
|
|
pPlayer->zWeaponVel = 0;
|
|
|
|
pPlayer->relAim.dx = 0x4000;
|
|
|
|
pPlayer->relAim.dy = 0;
|
|
|
|
pPlayer->relAim.dz = 0;
|
|
|
|
pPlayer->aimTarget = nullptr;
|
2022-09-11 13:19:19 +00:00
|
|
|
pPlayer->zViewVel = pPlayer->zWeaponVel;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (!(gGameOptions.nGameType == 1 && gGameOptions.bKeepKeysOnRespawn && !bNewLevel))
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
pPlayer->hasKey[i] = gGameOptions.nGameType >= 2;
|
|
|
|
pPlayer->hasFlag = 0;
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
pPlayer->ctfFlagState[i] = nullptr;
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
pPlayer->damageControl[i] = 0;
|
|
|
|
if (pPlayer->godMode)
|
|
|
|
playerSetGodMode(pPlayer, 1);
|
|
|
|
gInfiniteAmmo = 0;
|
|
|
|
gFullMap = 0;
|
|
|
|
pPlayer->throwPower = 0;
|
|
|
|
pPlayer->deathTime = 0;
|
|
|
|
pPlayer->nextWeapon = kWeapNone;
|
2022-08-23 19:25:05 +00:00
|
|
|
actor->ZeroVelocity();
|
2021-12-29 21:56:21 +00:00
|
|
|
pInput->avel = 0;
|
|
|
|
pInput->actions = 0;
|
|
|
|
pInput->fvel = 0;
|
|
|
|
pInput->svel = 0;
|
|
|
|
pInput->horz = 0;
|
|
|
|
pPlayer->flickerEffect = 0;
|
|
|
|
pPlayer->quakeEffect = 0;
|
|
|
|
pPlayer->tiltEffect = 0;
|
|
|
|
pPlayer->visibility = 0;
|
|
|
|
pPlayer->painEffect = 0;
|
|
|
|
pPlayer->blindEffect = 0;
|
|
|
|
pPlayer->chokeEffect = 0;
|
|
|
|
pPlayer->handTime = 0;
|
|
|
|
pPlayer->weaponTimer = 0;
|
|
|
|
pPlayer->weaponState = 0;
|
|
|
|
pPlayer->weaponQav = kQAVNone;
|
|
|
|
pPlayer->qavLastTick = 0;
|
|
|
|
pPlayer->qavTimer = 0;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
playerQavSceneReset(pPlayer); // reset qav scene
|
|
|
|
|
|
|
|
// assign or update player's sprite index for conditions
|
|
|
|
if (gModernMap) {
|
|
|
|
|
|
|
|
BloodStatIterator it(kStatModernPlayerLinker);
|
|
|
|
while (auto iactor = it.Next())
|
|
|
|
{
|
|
|
|
if (iactor->xspr.data1 == pPlayer->nPlayer + 1)
|
|
|
|
{
|
|
|
|
DBloodActor* SpriteOld = iactor->prevmarker;
|
|
|
|
trPlayerCtrlLink(iactor, pPlayer, (SpriteOld == nullptr)); // this modifies iactor's prevmarker field!
|
|
|
|
if (SpriteOld)
|
|
|
|
condUpdateObjectIndex(SpriteOld, iactor->prevmarker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
pPlayer->hand = 0;
|
|
|
|
pPlayer->nWaterPal = 0;
|
|
|
|
playerResetPowerUps(pPlayer);
|
|
|
|
|
2022-09-10 13:15:58 +00:00
|
|
|
if (nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewInitializePrediction();
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
if (IsUnderwaterSector(actor->sector()))
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
pPlayer->posture = 1;
|
|
|
|
pPlayer->actor->xspr.medium = kMediumWater;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void playerReset(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
static int dword_136400[] = {
|
|
|
|
3, 4, 2, 8, 9, 10, 7, 1, 1, 1, 1, 1, 1, 1
|
|
|
|
};
|
|
|
|
static int dword_136438[] = {
|
|
|
|
3, 4, 2, 8, 9, 10, 7, 1, 1, 1, 1, 1, 1, 1
|
|
|
|
};
|
|
|
|
assert(pPlayer != NULL);
|
|
|
|
for (int i = 0; i < 14; i++)
|
|
|
|
{
|
|
|
|
pPlayer->hasWeapon[i] = gInfiniteAmmo;
|
|
|
|
pPlayer->weaponMode[i] = 0;
|
|
|
|
}
|
2022-01-12 11:22:48 +00:00
|
|
|
pPlayer->hasWeapon[kWeapPitchFork] = 1;
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->curWeapon = kWeapNone;
|
|
|
|
pPlayer->qavCallback = -1;
|
|
|
|
pPlayer->newWeapon = kWeapPitchFork;
|
|
|
|
for (int i = 0; i < 14; i++)
|
|
|
|
{
|
|
|
|
pPlayer->weaponOrder[0][i] = dword_136400[i];
|
|
|
|
pPlayer->weaponOrder[1][i] = dword_136438[i];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
if (gInfiniteAmmo)
|
|
|
|
pPlayer->ammoCount[i] = gAmmoInfo[i].max;
|
|
|
|
else
|
|
|
|
pPlayer->ammoCount[i] = 0;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
pPlayer->armor[i] = 0;
|
|
|
|
pPlayer->weaponTimer = 0;
|
|
|
|
pPlayer->weaponState = 0;
|
|
|
|
pPlayer->weaponQav = kQAVNone;
|
|
|
|
pPlayer->qavLoop = 0;
|
|
|
|
pPlayer->qavLastTick = 0;
|
|
|
|
pPlayer->qavTimer = 0;
|
|
|
|
pPlayer->packItemId = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
pPlayer->packSlots[i].isActive = 0;
|
|
|
|
pPlayer->packSlots[i].curAmount = 0;
|
|
|
|
}
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
playerQavSceneReset(pPlayer);
|
|
|
|
#endif
|
|
|
|
// reset posture (mainly required for resetting movement speed and jump height)
|
|
|
|
playerResetPosture(pPlayer);
|
2020-01-26 11:19:01 +00:00
|
|
|
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 12:16:58 +00:00
|
|
|
int team_score[8];
|
|
|
|
int team_ticker[8];
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
void playerInit(int nPlayer, unsigned int a2)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (!(a2 & 1))
|
|
|
|
gPlayer[nPlayer] = {};
|
|
|
|
|
|
|
|
PLAYER* pPlayer = &gPlayer[nPlayer];
|
|
|
|
pPlayer->nPlayer = nPlayer;
|
|
|
|
pPlayer->teamId = nPlayer;
|
|
|
|
if (gGameOptions.nGameType == 3)
|
|
|
|
pPlayer->teamId = nPlayer & 1;
|
|
|
|
pPlayer->fragCount = 0;
|
|
|
|
memset(team_score, 0, sizeof(team_score));
|
|
|
|
memset(team_ticker, 0, sizeof(team_ticker));
|
|
|
|
memset(pPlayer->fragInfo, 0, sizeof(pPlayer->fragInfo));
|
|
|
|
|
|
|
|
if (!(a2 & 1))
|
|
|
|
playerReset(pPlayer);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool findDroppedLeech(PLAYER* a1, DBloodActor* a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
BloodStatIterator it(kStatThing);
|
|
|
|
while (auto actor = it.Next())
|
|
|
|
{
|
|
|
|
if (a2 == actor)
|
|
|
|
continue;
|
|
|
|
if (actor->spr.type == kThingDroppedLifeLeech && actor->GetOwner() == a1->actor)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool PickupItem(PLAYER* pPlayer, DBloodActor* itemactor)
|
2021-09-04 19:55:26 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
char buffer[80];
|
2021-11-16 17:36:34 +00:00
|
|
|
int pickupSnd = 775;
|
2021-12-23 09:17:18 +00:00
|
|
|
int nType = itemactor->spr.type - kItemBase;
|
2021-12-29 21:56:21 +00:00
|
|
|
auto plActor = pPlayer->actor;
|
|
|
|
|
|
|
|
switch (itemactor->spr.type) {
|
|
|
|
case kItemShadowCloak:
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (isGrown(pPlayer->actor) || !powerupActivate(pPlayer, nType)) return false;
|
|
|
|
#else
|
|
|
|
if (!powerupActivate(pPlayer, nType)) return false;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kItemShroomShrink:
|
|
|
|
case kItemShroomGrow:
|
|
|
|
|
|
|
|
if (gModernMap) {
|
|
|
|
switch (itemactor->spr.type) {
|
|
|
|
case kItemShroomShrink:
|
|
|
|
if (isShrinked(pPlayer->actor)) return false;
|
|
|
|
break;
|
|
|
|
case kItemShroomGrow:
|
|
|
|
if (isGrown(pPlayer->actor)) return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
powerupActivate(pPlayer, nType);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case kItemFlagABase:
|
|
|
|
case kItemFlagBBase: {
|
|
|
|
if (gGameOptions.nGameType != 3 || !itemactor->hasX()) return 0;
|
|
|
|
if (itemactor->spr.type == kItemFlagABase) {
|
|
|
|
if (pPlayer->teamId == 1) {
|
|
|
|
if ((pPlayer->hasFlag & 1) == 0 && itemactor->xspr.state) {
|
|
|
|
pPlayer->hasFlag |= 1;
|
|
|
|
pPlayer->ctfFlagState[0] = itemactor;
|
|
|
|
trTriggerSprite(itemactor, kCmdOff);
|
|
|
|
sprintf(buffer, "%s stole Blue Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8007, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->teamId == 0) {
|
|
|
|
|
|
|
|
if ((pPlayer->hasFlag & 1) != 0 && !itemactor->xspr.state) {
|
|
|
|
pPlayer->hasFlag &= ~1;
|
|
|
|
pPlayer->ctfFlagState[0] = nullptr;
|
|
|
|
trTriggerSprite(itemactor, kCmdOn);
|
|
|
|
sprintf(buffer, "%s returned Blue Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8003, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pPlayer->hasFlag & 2) != 0 && itemactor->xspr.state) {
|
|
|
|
pPlayer->hasFlag &= ~2;
|
|
|
|
pPlayer->ctfFlagState[1] = nullptr;
|
|
|
|
team_score[pPlayer->teamId] += 10;
|
|
|
|
team_ticker[pPlayer->teamId] += 240;
|
|
|
|
evSendGame(81, kCmdOn);
|
|
|
|
sprintf(buffer, "%s captured Red Flag!", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8001, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (itemactor->spr.type == kItemFlagBBase) {
|
|
|
|
|
|
|
|
if (pPlayer->teamId == 0) {
|
|
|
|
if ((pPlayer->hasFlag & 2) == 0 && itemactor->xspr.state) {
|
|
|
|
pPlayer->hasFlag |= 2;
|
|
|
|
pPlayer->ctfFlagState[1] = itemactor;
|
|
|
|
trTriggerSprite(itemactor, kCmdOff);
|
|
|
|
sprintf(buffer, "%s stole Red Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8006, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->teamId == 1) {
|
|
|
|
if ((pPlayer->hasFlag & 2) != 0 && !itemactor->xspr.state)
|
|
|
|
{
|
|
|
|
pPlayer->hasFlag &= ~2;
|
|
|
|
pPlayer->ctfFlagState[1] = nullptr;
|
|
|
|
trTriggerSprite(itemactor, kCmdOn);
|
|
|
|
sprintf(buffer, "%s returned Red Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8002, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
if ((pPlayer->hasFlag & 1) != 0 && itemactor->xspr.state)
|
|
|
|
{
|
|
|
|
pPlayer->hasFlag &= ~1;
|
|
|
|
pPlayer->ctfFlagState[0] = nullptr;
|
|
|
|
team_score[pPlayer->teamId] += 10;
|
|
|
|
team_ticker[pPlayer->teamId] += 240;
|
|
|
|
evSendGame(80, kCmdOn);
|
|
|
|
sprintf(buffer, "%s captured Blue Flag!", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8000, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case kItemFlagA: {
|
|
|
|
if (gGameOptions.nGameType != 3) return 0;
|
|
|
|
gBlueFlagDropped = false;
|
|
|
|
const bool enemyTeam = (pPlayer->teamId & 1) == 1;
|
|
|
|
if (!enemyTeam && itemactor->GetOwner())
|
|
|
|
{
|
|
|
|
pPlayer->hasFlag &= ~1;
|
|
|
|
pPlayer->ctfFlagState[0] = nullptr;
|
|
|
|
trTriggerSprite(itemactor->GetOwner(), kCmdOn);
|
|
|
|
sprintf(buffer, "%s returned Blue Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8003, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pPlayer->hasFlag |= 1;
|
|
|
|
pPlayer->ctfFlagState[0] = itemactor->GetOwner();
|
|
|
|
if (enemyTeam)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%s stole Blue Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8007, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kItemFlagB: {
|
|
|
|
if (gGameOptions.nGameType != 3) return 0;
|
|
|
|
gRedFlagDropped = false;
|
|
|
|
const bool enemyTeam = (pPlayer->teamId & 1) == 0;
|
|
|
|
if (!enemyTeam && itemactor->GetOwner())
|
|
|
|
{
|
|
|
|
pPlayer->hasFlag &= ~2;
|
|
|
|
pPlayer->ctfFlagState[1] = nullptr;
|
|
|
|
trTriggerSprite(itemactor->GetOwner(), kCmdOn);
|
|
|
|
sprintf(buffer, "%s returned Red Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8002, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pPlayer->hasFlag |= 2;
|
|
|
|
pPlayer->ctfFlagState[1] = itemactor->GetOwner();
|
|
|
|
if (enemyTeam)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%s stole Red Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8006, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kItemArmorBasic:
|
|
|
|
case kItemArmorBody:
|
|
|
|
case kItemArmorFire:
|
|
|
|
case kItemArmorSpirit:
|
|
|
|
case kItemArmorSuper: {
|
|
|
|
ARMORDATA* pArmorData = &armorData[itemactor->spr.type - kItemArmorBasic]; bool pickedUp = false;
|
|
|
|
if (pPlayer->armor[1] < pArmorData->armor1max) {
|
|
|
|
pPlayer->armor[1] = ClipHigh(pPlayer->armor[1] + pArmorData->armor1, pArmorData->armor1max);
|
|
|
|
pickedUp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->armor[0] < pArmorData->armor0max) {
|
|
|
|
pPlayer->armor[0] = ClipHigh(pPlayer->armor[0] + pArmorData->armor0, pArmorData->armor0max);
|
|
|
|
pickedUp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPlayer->armor[2] < pArmorData->armor2max) {
|
|
|
|
pPlayer->armor[2] = ClipHigh(pPlayer->armor[2] + pArmorData->armor2, pArmorData->armor2max);
|
|
|
|
pickedUp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pickedUp) return 0;
|
|
|
|
pickupSnd = 779;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kItemCrystalBall:
|
|
|
|
if (gGameOptions.nGameType == 0 || !packAddItem(pPlayer, gItemData[nType].packSlot)) return 0;
|
|
|
|
break;
|
|
|
|
case kItemKeySkull:
|
|
|
|
case kItemKeyEye:
|
|
|
|
case kItemKeyFire:
|
|
|
|
case kItemKeyDagger:
|
|
|
|
case kItemKeySpider:
|
|
|
|
case kItemKeyMoon:
|
|
|
|
case kItemKeyKey7:
|
|
|
|
if (pPlayer->hasKey[itemactor->spr.type - 99]) return 0;
|
|
|
|
pPlayer->hasKey[itemactor->spr.type - 99] = 1;
|
|
|
|
pickupSnd = 781;
|
|
|
|
break;
|
|
|
|
case kItemHealthMedPouch:
|
|
|
|
case kItemHealthLifeEssense:
|
|
|
|
case kItemHealthLifeSeed:
|
|
|
|
case kItemHealthRedPotion: {
|
|
|
|
int addPower = gPowerUpInfo[nType].bonusTime;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// allow custom amount for item
|
|
|
|
if (gModernMap && itemactor->hasX() && itemactor->xspr.data1 > 0)
|
|
|
|
addPower = itemactor->xspr.data1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!actHealDude(pPlayer->actor, addPower, gPowerUpInfo[nType].maxTime)) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case kItemHealthDoctorBag:
|
|
|
|
case kItemJumpBoots:
|
|
|
|
case kItemDivingSuit:
|
|
|
|
case kItemBeastVision:
|
|
|
|
if (!packAddItem(pPlayer, gItemData[nType].packSlot)) return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!powerupActivate(pPlayer, nType)) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-01-30 17:09:26 +00:00
|
|
|
sfxPlay3DSound(plActor->int_pos().X, plActor->int_pos().Y, plActor->int_pos().Z, pickupSnd, plActor->sector());
|
2021-12-29 21:56:21 +00:00
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-16 17:36:34 +00:00
|
|
|
bool PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor)
|
2021-09-04 19:55:26 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
const AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[ammoactor->spr.type - kItemAmmoBase];
|
|
|
|
int nAmmoType = pAmmoItemData->type;
|
|
|
|
|
|
|
|
if (pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
else if (gModernMap && ammoactor->hasX() && ammoactor->xspr.data1 > 0) // allow custom amount for item
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + ammoactor->xspr.data1, gAmmoInfo[nAmmoType].max);
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + pAmmoItemData->count, gAmmoInfo[nAmmoType].max);
|
|
|
|
|
|
|
|
if (pAmmoItemData->weaponType) pPlayer->hasWeapon[pAmmoItemData->weaponType] = 1;
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 782, -1, 0);
|
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool PickupWeapon(PLAYER* pPlayer, DBloodActor* weaponactor)
|
2021-08-30 18:21:49 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
const WEAPONITEMDATA* pWeaponItemData = &gWeaponItemData[weaponactor->spr.type - kItemWeaponBase];
|
|
|
|
int nWeaponType = pWeaponItemData->type;
|
|
|
|
int nAmmoType = pWeaponItemData->ammoType;
|
|
|
|
if (!pPlayer->hasWeapon[nWeaponType] || gGameOptions.nWeaponSettings == 2 || gGameOptions.nWeaponSettings == 3) {
|
|
|
|
if (weaponactor->spr.type == kItemWeaponLifeLeech && gGameOptions.nGameType > 1 && findDroppedLeech(pPlayer, NULL))
|
|
|
|
return 0;
|
|
|
|
pPlayer->hasWeapon[nWeaponType] = 1;
|
|
|
|
if (nAmmoType == -1) return 0;
|
|
|
|
// allow to set custom ammo count for weapon pickups
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
else if (gModernMap && weaponactor->hasX() && weaponactor->xspr.data1 > 0)
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + weaponactor->xspr.data1, gAmmoInfo[nAmmoType].max);
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + pWeaponItemData->count, gAmmoInfo[nAmmoType].max);
|
|
|
|
|
|
|
|
int nNewWeapon = WeaponUpgrade(pPlayer, nWeaponType);
|
|
|
|
if (nNewWeapon != pPlayer->curWeapon) {
|
|
|
|
pPlayer->weaponState = 0;
|
|
|
|
pPlayer->nextWeapon = nNewWeapon;
|
|
|
|
}
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 777, -1, 0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!actGetRespawnTime(weaponactor) || nAmmoType == -1 || pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
else if (gModernMap && weaponactor->hasX() && weaponactor->xspr.data1 > 0)
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + weaponactor->xspr.data1, gAmmoInfo[nAmmoType].max);
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + pWeaponItemData->count, gAmmoInfo[nAmmoType].max);
|
|
|
|
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 777, -1, 0);
|
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PickUp(PLAYER* pPlayer, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
const char* msg = nullptr;
|
|
|
|
int nType = actor->spr.type;
|
|
|
|
bool pickedUp = 0;
|
|
|
|
int customMsg = -1;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (gModernMap && actor->hasX()) { // allow custom INI message instead "Picked up"
|
|
|
|
if (actor->xspr.txID != 3 && actor->xspr.lockMsg > 0)
|
|
|
|
customMsg = actor->xspr.lockMsg;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (nType >= kItemBase && nType <= kItemMax) {
|
|
|
|
pickedUp = PickupItem(pPlayer, actor);
|
|
|
|
if (pickedUp && customMsg == -1) msg = GStrings(FStringf("TXTB_ITEM%02d", int(nType - kItemBase + 1)));
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) {
|
|
|
|
pickedUp = PickupAmmo(pPlayer, actor);
|
|
|
|
if (pickedUp && customMsg == -1) msg = GStrings(FStringf("TXTB_AMMO%02d", int(nType - kItemAmmoBase + 1)));
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) {
|
|
|
|
pickedUp = PickupWeapon(pPlayer, actor);
|
|
|
|
if (pickedUp && customMsg == -1) msg = GStrings(FStringf("TXTB_WPN%02d", int(nType - kItemWeaponBase + 1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pickedUp) return;
|
|
|
|
else if (actor->hasX())
|
|
|
|
{
|
|
|
|
if (actor->xspr.Pickup)
|
|
|
|
trTriggerSprite(actor, kCmdSpritePickup);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!actCheckRespawn(actor))
|
|
|
|
actPostSprite(actor, kStatFree);
|
|
|
|
|
|
|
|
pPlayer->pickupEffect = 30;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pPlayer->nPlayer == myconnectindex) {
|
2021-12-29 21:56:21 +00:00
|
|
|
if (customMsg > 0) trTextOver(customMsg - 1);
|
2022-01-22 08:38:01 +00:00
|
|
|
else if (msg) viewSetMessage(msg, nullptr, MESSAGE_PRIORITY_PICKUP);
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckPickUp(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
auto plActor = pPlayer->actor;
|
2022-08-22 16:39:02 +00:00
|
|
|
auto ppos = plActor->spr.pos;
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector = plActor->sector();
|
2021-12-29 21:56:21 +00:00
|
|
|
BloodStatIterator it(kStatItem);
|
|
|
|
while (auto itemactor = it.Next())
|
|
|
|
{
|
|
|
|
if (itemactor->spr.flags & 32)
|
|
|
|
continue;
|
2022-08-22 16:39:02 +00:00
|
|
|
double dx = abs(ppos.X - itemactor->spr.pos.X);
|
2021-12-29 21:56:21 +00:00
|
|
|
if (dx > 48)
|
|
|
|
continue;
|
2022-08-22 16:39:02 +00:00
|
|
|
double dy = abs(ppos.Y - itemactor->spr.pos.Y);
|
2021-12-29 21:56:21 +00:00
|
|
|
if (dy > 48)
|
|
|
|
continue;
|
2022-08-22 16:39:02 +00:00
|
|
|
double top, bottom;
|
2021-12-29 21:56:21 +00:00
|
|
|
GetActorExtents(plActor, &top, &bottom);
|
2022-08-22 16:39:02 +00:00
|
|
|
double vb = 0;
|
|
|
|
if (itemactor->spr.pos.Z < top)
|
|
|
|
vb = (top - itemactor->spr.pos.Z);
|
|
|
|
else if (itemactor->spr.pos.Z > bottom)
|
|
|
|
vb = (itemactor->spr.pos.Z - bottom);
|
2021-12-29 21:56:21 +00:00
|
|
|
if (vb > 32)
|
|
|
|
continue;
|
2022-08-22 16:39:02 +00:00
|
|
|
if (DVector2(dx, dy).LengthSquared() > 48*48)
|
2021-12-29 21:56:21 +00:00
|
|
|
continue;
|
|
|
|
GetActorExtents(itemactor, &top, &bottom);
|
2022-08-22 16:39:02 +00:00
|
|
|
if (cansee(ppos, pSector, itemactor->spr.pos, itemactor->sector())
|
|
|
|
|| cansee(ppos, pSector, DVector3(itemactor->spr.pos.XY(), top), itemactor->sector())
|
|
|
|
|| cansee(ppos, pSector, DVector3(itemactor->spr.pos.XY(), bottom), itemactor->sector()))
|
2021-12-29 21:56:21 +00:00
|
|
|
PickUp(pPlayer, itemactor);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int ActionScan(PLAYER* pPlayer, HitInfo* out)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
auto plActor = pPlayer->actor;
|
|
|
|
*out = {};
|
2022-08-16 21:15:49 +00:00
|
|
|
int x = bcos(plActor->int_ang());
|
|
|
|
int y = bsin(plActor->int_ang());
|
2021-12-29 21:56:21 +00:00
|
|
|
int z = pPlayer->slope;
|
|
|
|
int hit = HitScan(pPlayer->actor, pPlayer->zView, x, y, z, 0x10000040, 128);
|
2022-08-23 20:32:14 +00:00
|
|
|
int hitDist = (int)(plActor->spr.pos.XY() - gHitInfo.hitpos.XY()).Length();
|
2021-12-29 21:56:21 +00:00
|
|
|
if (hitDist < 64)
|
|
|
|
{
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
auto hitactor = gHitInfo.actor();
|
|
|
|
if (!hitactor || !hitactor->hasX()) return -1;
|
|
|
|
out->hitActor = hitactor;
|
|
|
|
if (hitactor->spr.statnum == kStatThing)
|
|
|
|
{
|
|
|
|
if (hitactor->spr.type == kThingDroppedLifeLeech)
|
|
|
|
{
|
|
|
|
if (gGameOptions.nGameType > 1 && findDroppedLeech(pPlayer, hitactor))
|
|
|
|
return -1;
|
|
|
|
hitactor->xspr.data4 = pPlayer->nPlayer;
|
|
|
|
hitactor->xspr.isTriggered = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hitactor->xspr.Push)
|
|
|
|
return 3;
|
|
|
|
if (hitactor->spr.statnum == kStatDude)
|
|
|
|
{
|
|
|
|
int nMass = getDudeInfo(hitactor->spr.type)->mass;
|
|
|
|
if (nMass)
|
|
|
|
{
|
|
|
|
int t2 = DivScale(0xccccc, nMass, 8);
|
2022-09-01 19:02:20 +00:00
|
|
|
hitactor->add_int_bvel_x(MulScale(x, t2, 16));
|
2022-09-01 19:05:25 +00:00
|
|
|
hitactor->add_int_bvel_y(MulScale(y, t2, 16));
|
2022-09-01 19:08:05 +00:00
|
|
|
hitactor->add_int_bvel_z(MulScale(z, t2, 16));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
if (hitactor->xspr.Push && !hitactor->xspr.state && !hitactor->xspr.isTriggered)
|
|
|
|
trTriggerSprite(hitactor, kCmdSpritePush);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
auto pWall = gHitInfo.hitWall;
|
|
|
|
out->hitWall = gHitInfo.hitWall;
|
|
|
|
if (pWall->hasX() && pWall->xw().triggerPush)
|
|
|
|
return 0;
|
|
|
|
if (pWall->twoSided())
|
|
|
|
{
|
|
|
|
auto sect = pWall->nextSector();
|
|
|
|
out->hitWall = nullptr;
|
|
|
|
out->hitSector = sect;
|
|
|
|
if (sect->hasX() && sect->xs().Wallpush)
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
auto pSector = gHitInfo.hitSector;
|
|
|
|
out->hitSector = gHitInfo.hitSector;
|
|
|
|
if (pSector->hasX() && pSector->xs().Push)
|
|
|
|
return 6;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
out->hitSector = plActor->sector();
|
|
|
|
if (plActor->sector()->hasX() && plActor->sector()->xs().Push)
|
2021-12-29 21:56:21 +00:00
|
|
|
return 6;
|
|
|
|
return -1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-09-16 11:59:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-09-21 07:00:07 +00:00
|
|
|
// Player's sprite angle function, called in ProcessInput() or from gi->GetInput() as required.
|
2020-09-16 11:59:19 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
void UpdatePlayerSpriteAngle(PLAYER* pPlayer)
|
2020-09-16 08:22:01 +00:00
|
|
|
{
|
2022-08-27 13:09:22 +00:00
|
|
|
pPlayer->actor->set_int_ang(pPlayer->angle.ang.Buildang());
|
2020-09-16 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 03:40:35 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Player's slope tilting wrapper function function, called in ProcessInput() or from gi->GetInput() as required.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
auto plActor = pPlayer->actor;
|
|
|
|
int const florhit = pPlayer->actor->hit.florhit.type;
|
|
|
|
bool const va = plActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0;
|
2022-09-05 15:23:10 +00:00
|
|
|
pPlayer->horizon.calcviewpitch(plActor->spr.pos.XY(), plActor->spr.angle, va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector(), scaleAdjust);
|
2021-01-02 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ProcessInput(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
Item_MedKit = 0,
|
|
|
|
Item_CrystalBall = 1,
|
|
|
|
Item_BeastVision = 2,
|
|
|
|
Item_JumpBoots = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
pPlayer->horizon.resetadjustment();
|
|
|
|
pPlayer->angle.resetadjustment();
|
|
|
|
|
|
|
|
DBloodActor* actor = pPlayer->actor;
|
|
|
|
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
|
|
|
|
InputPacket* pInput = &pPlayer->input;
|
|
|
|
|
|
|
|
// Originally, this was never able to be true due to sloppy input code in the original game.
|
|
|
|
// Allow it to become true behind a CVAR to offer an alternate playing experience if desired.
|
|
|
|
pPlayer->isRunning = !!(pInput->actions & SB_RUN) && !cl_bloodvanillarun;
|
|
|
|
|
|
|
|
if ((pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->avel)
|
|
|
|
pPlayer->restTime = 0;
|
|
|
|
else if (pPlayer->restTime >= 0)
|
|
|
|
pPlayer->restTime += 4;
|
|
|
|
WeaponProcess(pPlayer);
|
|
|
|
if (actor->xspr.health == 0)
|
|
|
|
{
|
|
|
|
bool bSeqStat = playerSeqPlaying(pPlayer, 16);
|
|
|
|
DBloodActor* fragger = pPlayer->fragger;
|
|
|
|
if (fragger)
|
|
|
|
{
|
2022-09-11 17:12:47 +00:00
|
|
|
pPlayer->angle.addadjustment(deltaangle(pPlayer->angle.ang, VecToAngle(fragger->spr.pos.XY() - actor->spr.pos.XY())));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
pPlayer->deathTime += 4;
|
|
|
|
if (!bSeqStat)
|
|
|
|
pPlayer->horizon.addadjustment(q16horiz(MulScale(0x8000 - (Cos(ClipHigh(pPlayer->deathTime << 3, 1024)) >> 15), gi->playerHorizMax(), 16) - pPlayer->horizon.horiz.asq16()));
|
|
|
|
if (pPlayer->curWeapon)
|
|
|
|
pInput->setNewWeapon(pPlayer->curWeapon);
|
|
|
|
if (pInput->actions & SB_OPEN)
|
|
|
|
{
|
|
|
|
if (bSeqStat)
|
|
|
|
{
|
|
|
|
if (pPlayer->deathTime > 360)
|
|
|
|
seqSpawn(pPlayer->pDudeInfo->seqStartID + 14, pPlayer->actor, nPlayerSurviveClient);
|
|
|
|
}
|
|
|
|
else if (seqGetStatus(pPlayer->actor) < 0)
|
|
|
|
{
|
|
|
|
if (pPlayer->actor)
|
|
|
|
pPlayer->actor->spr.type = kThingBloodChunks;
|
|
|
|
actPostSprite(pPlayer->actor, kStatThing);
|
|
|
|
seqSpawn(pPlayer->pDudeInfo->seqStartID + 15, pPlayer->actor, -1);
|
|
|
|
playerReset(pPlayer);
|
|
|
|
if (gGameOptions.nGameType == 0 && numplayers == 1)
|
|
|
|
{
|
|
|
|
gameaction = ga_autoloadgame;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
playerStart(pPlayer->nPlayer);
|
|
|
|
}
|
|
|
|
pInput->actions &= ~SB_OPEN;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pPlayer->posture == 1)
|
|
|
|
{
|
2022-08-16 21:15:49 +00:00
|
|
|
int x = Cos(actor->int_ang());
|
|
|
|
int y = Sin(actor->int_ang());
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pInput->fvel)
|
|
|
|
{
|
|
|
|
int forward = pInput->fvel;
|
|
|
|
if (forward > 0)
|
|
|
|
forward = MulScale(pPosture->frontAccel, forward, 8);
|
|
|
|
else
|
|
|
|
forward = MulScale(pPosture->backAccel, forward, 8);
|
2022-09-01 19:02:20 +00:00
|
|
|
actor->add_int_bvel_x(MulScale(forward, x, 30));
|
2022-09-01 19:05:25 +00:00
|
|
|
actor->add_int_bvel_y(MulScale(forward, y, 30));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
if (pInput->svel)
|
|
|
|
{
|
|
|
|
int strafe = pInput->svel;
|
|
|
|
strafe = MulScale(pPosture->sideAccel, strafe, 8);
|
2022-09-01 19:02:20 +00:00
|
|
|
actor->add_int_bvel_x(MulScale(strafe, y, 30));
|
2022-09-01 19:10:35 +00:00
|
|
|
actor->add_int_bvel_y(-MulScale(strafe, x, 30));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (actor->xspr.height < 256)
|
|
|
|
{
|
|
|
|
int speed = 0x10000;
|
|
|
|
if (actor->xspr.height > 0)
|
|
|
|
speed -= DivScale(actor->xspr.height, 256, 16);
|
2022-08-16 21:15:49 +00:00
|
|
|
int x = Cos(actor->int_ang());
|
|
|
|
int y = Sin(actor->int_ang());
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pInput->fvel)
|
|
|
|
{
|
|
|
|
int forward = pInput->fvel;
|
|
|
|
if (forward > 0)
|
|
|
|
forward = MulScale(pPosture->frontAccel, forward, 8);
|
|
|
|
else
|
|
|
|
forward = MulScale(pPosture->backAccel, forward, 8);
|
|
|
|
if (actor->xspr.height)
|
|
|
|
forward = MulScale(forward, speed, 16);
|
2022-09-01 19:02:20 +00:00
|
|
|
actor->add_int_bvel_x(MulScale(forward, x, 30));
|
2022-09-01 19:05:25 +00:00
|
|
|
actor->add_int_bvel_y(MulScale(forward, y, 30));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
if (pInput->svel)
|
|
|
|
{
|
|
|
|
int strafe = pInput->svel;
|
|
|
|
strafe = MulScale(pPosture->sideAccel, strafe, 8);
|
|
|
|
if (actor->xspr.height)
|
|
|
|
strafe = MulScale(strafe, speed, 16);
|
2022-09-01 19:02:20 +00:00
|
|
|
actor->add_int_bvel_x(MulScale(strafe, y, 30));
|
2022-09-01 19:10:35 +00:00
|
|
|
actor->add_int_bvel_y(-MulScale(strafe, x, 30));
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SyncInput())
|
|
|
|
{
|
|
|
|
pPlayer->angle.applyinput(pInput->avel, &pInput->actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
// unconditionally update the player's sprite angle
|
|
|
|
// in case game is forcing synchronised input.
|
|
|
|
UpdatePlayerSpriteAngle(pPlayer);
|
|
|
|
|
|
|
|
if (!(pInput->actions & SB_JUMP))
|
|
|
|
pPlayer->cantJump = 0;
|
|
|
|
|
|
|
|
switch (pPlayer->posture) {
|
|
|
|
case 1:
|
|
|
|
if (pInput->actions & SB_JUMP)
|
2022-09-01 19:10:35 +00:00
|
|
|
actor->add_int_bvel_z(-pPosture->normalJumpZ);//0x5b05;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (pInput->actions & SB_CROUCH)
|
2022-09-01 19:08:05 +00:00
|
|
|
actor->add_int_bvel_z(pPosture->normalJumpZ);//0x5b05;
|
2021-12-29 21:56:21 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!(pInput->actions & SB_CROUCH))
|
|
|
|
pPlayer->posture = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!pPlayer->cantJump && (pInput->actions & SB_JUMP) && actor->xspr.height == 0) {
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0)
|
|
|
|
#endif
|
|
|
|
sfxPlay3DSound(actor, 700, 0, 0);
|
|
|
|
|
2022-09-01 19:40:03 +00:00
|
|
|
if (packItemActive(pPlayer, 4)) actor->set_int_bvel_z(pPosture->pwupJumpZ); //-0x175555;
|
|
|
|
else actor->set_int_bvel_z(pPosture->normalJumpZ); //-0xbaaaa;
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->cantJump = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pInput->actions & SB_CROUCH)
|
|
|
|
pPlayer->posture = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pInput->actions & SB_OPEN)
|
|
|
|
{
|
|
|
|
HitInfo result;
|
|
|
|
|
|
|
|
int hit = ActionScan(pPlayer, &result);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
auto pSector = result.hitSector;
|
|
|
|
auto pXSector = &pSector->xs();
|
|
|
|
int key = pXSector->Key;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pXSector->locked && pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewSetMessage(GStrings("TXTB_LOCKED"));
|
|
|
|
auto snd = 3062;
|
|
|
|
if (sndCheckPlaying(snd))
|
|
|
|
sndStopSample(snd);
|
|
|
|
sndStartSample(snd, 255, 2, 0);
|
|
|
|
}
|
|
|
|
if (!key || pPlayer->hasKey[key])
|
|
|
|
trTriggerSector(pSector, kCmdSpritePush);
|
2022-09-10 13:15:58 +00:00
|
|
|
else if (pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewSetMessage(GStrings("TXTB_KEY"));
|
|
|
|
auto snd = 3063;
|
|
|
|
if (sndCheckPlaying(snd))
|
|
|
|
sndStopSample(snd);
|
|
|
|
sndStartSample(snd, 255, 2, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
auto pWall = result.hitWall;
|
|
|
|
auto pXWall = &pWall->xw();
|
|
|
|
int key = pXWall->key;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pXWall->locked && pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewSetMessage(GStrings("TXTB_LOCKED"));
|
|
|
|
auto snd = 3062;
|
|
|
|
if (sndCheckPlaying(snd))
|
|
|
|
sndStopSample(snd);
|
|
|
|
sndStartSample(snd, 255, 2, 0);
|
|
|
|
}
|
|
|
|
if (!key || pPlayer->hasKey[key])
|
|
|
|
trTriggerWall(pWall, kCmdWallPush);
|
2022-09-10 13:15:58 +00:00
|
|
|
else if (pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewSetMessage(GStrings("TXTB_KEY"));
|
|
|
|
auto snd = 3063;
|
|
|
|
if (sndCheckPlaying(snd))
|
|
|
|
sndStopSample(snd);
|
|
|
|
sndStartSample(snd, 255, 2, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
auto act = result.actor();
|
2021-12-31 23:56:23 +00:00
|
|
|
int key = act->xspr.key;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (actor->xspr.locked && pPlayer->nPlayer == myconnectindex && act->xspr.lockMsg)
|
2021-12-31 23:56:23 +00:00
|
|
|
trTextOver(act->xspr.lockMsg);
|
2021-12-29 21:56:21 +00:00
|
|
|
if (!key || pPlayer->hasKey[key])
|
|
|
|
trTriggerSprite(act, kCmdSpritePush);
|
2022-09-10 13:15:58 +00:00
|
|
|
else if (pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
viewSetMessage(GStrings("TXTB_KEY"));
|
|
|
|
sndStartSample(3063, 255, 2, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pPlayer->handTime > 0)
|
|
|
|
pPlayer->handTime = ClipLow(pPlayer->handTime - 4 * (6 - gGameOptions.nDifficulty), 0);
|
|
|
|
if (pPlayer->handTime <= 0 && pPlayer->hand)
|
|
|
|
{
|
|
|
|
DBloodActor* pactor = pPlayer->actor;
|
2022-09-09 16:32:42 +00:00
|
|
|
auto spawned = actSpawnDude(pactor, kDudeHand, pPlayer->actor->native_clipdist() << 1, 0);
|
2021-12-29 21:56:21 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
2022-08-16 21:20:03 +00:00
|
|
|
spawned->set_int_ang((pPlayer->actor->int_ang() + 1024) & 2047);
|
2022-08-16 21:15:49 +00:00
|
|
|
int x = bcos(pPlayer->actor->int_ang());
|
|
|
|
int y = bsin(pPlayer->actor->int_ang());
|
2022-09-01 19:18:16 +00:00
|
|
|
spawned->set_int_bvel_x(pPlayer->actor->int_vel().X + MulScale(0x155555, x, 14));
|
2022-09-01 19:24:29 +00:00
|
|
|
spawned->set_int_bvel_y(pPlayer->actor->int_vel().Y + MulScale(0x155555, y, 14));
|
2022-09-01 19:40:03 +00:00
|
|
|
spawned->set_int_bvel_z(pPlayer->actor->int_vel().Z);
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
pPlayer->hand = 0;
|
|
|
|
}
|
|
|
|
pInput->actions &= ~SB_OPEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SyncInput())
|
|
|
|
{
|
|
|
|
pPlayer->horizon.applyinput(pInput->horz, &pInput->actions);
|
|
|
|
doslopetilting(pPlayer);
|
|
|
|
}
|
|
|
|
|
2022-06-06 08:41:45 +00:00
|
|
|
pPlayer->angle.unlockinput();
|
|
|
|
pPlayer->horizon.unlockinput();
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
|
|
|
|
if (pInput->actions & SB_INVPREV)
|
|
|
|
{
|
|
|
|
pInput->actions &= ~SB_INVPREV;
|
|
|
|
packPrevItem(pPlayer);
|
|
|
|
}
|
|
|
|
if (pInput->actions & SB_INVNEXT)
|
|
|
|
{
|
|
|
|
pInput->actions &= ~SB_INVNEXT;
|
|
|
|
packNextItem(pPlayer);
|
|
|
|
}
|
|
|
|
if (pInput->actions & SB_INVUSE)
|
|
|
|
{
|
|
|
|
pInput->actions &= ~SB_INVUSE;
|
|
|
|
if (pPlayer->packSlots[pPlayer->packItemId].curAmount > 0)
|
|
|
|
packUseItem(pPlayer, pPlayer->packItemId);
|
|
|
|
}
|
|
|
|
if (pInput->isItemUsed(Item_BeastVision))
|
|
|
|
{
|
|
|
|
pInput->clearItemUsed(Item_BeastVision);
|
|
|
|
if (pPlayer->packSlots[3].curAmount > 0)
|
|
|
|
packUseItem(pPlayer, 3);
|
|
|
|
}
|
|
|
|
if (pInput->isItemUsed(Item_CrystalBall))
|
|
|
|
{
|
|
|
|
pInput->clearItemUsed(Item_CrystalBall);
|
|
|
|
if (pPlayer->packSlots[2].curAmount > 0)
|
|
|
|
packUseItem(pPlayer, 2);
|
|
|
|
}
|
|
|
|
if (pInput->isItemUsed(Item_JumpBoots))
|
|
|
|
{
|
|
|
|
pInput->clearItemUsed(Item_JumpBoots);
|
|
|
|
if (pPlayer->packSlots[4].curAmount > 0)
|
|
|
|
packUseItem(pPlayer, 4);
|
|
|
|
}
|
|
|
|
if (pInput->isItemUsed(Item_MedKit))
|
|
|
|
{
|
|
|
|
pInput->clearItemUsed(Item_MedKit);
|
|
|
|
if (pPlayer->packSlots[0].curAmount > 0)
|
|
|
|
packUseItem(pPlayer, 0);
|
|
|
|
}
|
|
|
|
if (pInput->actions & SB_HOLSTER)
|
|
|
|
{
|
|
|
|
pInput->actions &= ~SB_HOLSTER;
|
|
|
|
if (pPlayer->curWeapon)
|
|
|
|
{
|
|
|
|
WeaponLower(pPlayer);
|
|
|
|
viewSetMessage("Holstering weapon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckPickUp(pPlayer);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
void playerProcess(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
DBloodActor* actor = pPlayer->actor;
|
|
|
|
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
|
|
|
|
powerupProcess(pPlayer);
|
|
|
|
int top, bottom;
|
|
|
|
GetActorExtents(actor, &top, &bottom);
|
2022-01-30 17:09:26 +00:00
|
|
|
int dzb = (bottom - actor->int_pos().Z) / 4;
|
|
|
|
int dzt = (actor->int_pos().Z - top) / 4;
|
2022-09-09 16:07:44 +00:00
|
|
|
int dw = actor->int_clipdist();
|
2021-12-29 21:56:21 +00:00
|
|
|
if (!gNoClip)
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector = actor->sector();
|
2022-01-30 16:56:38 +00:00
|
|
|
if (pushmove(actor, &pSector, dw, dzt, dzb, CLIPMASK0) == -1)
|
2021-12-29 21:56:21 +00:00
|
|
|
actDamageSprite(actor, actor, kDamageFall, 500 << 4);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector() != pSector)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
|
|
|
if (pSector == nullptr)
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
pSector = actor->sector();
|
2021-12-29 21:56:21 +00:00
|
|
|
actDamageSprite(actor, actor, kDamageFall, 500 << 4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ChangeActorSect(actor, pSector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcessInput(pPlayer);
|
2022-09-01 18:49:35 +00:00
|
|
|
int nSpeed = approxDist(actor->int_vel().X, actor->int_vel().Y);
|
2022-09-11 12:39:38 +00:00
|
|
|
pPlayer->zViewVel = interpolatedvalue(pPlayer->zViewVel, actor->vel.Z, FixedToFloat(0x7000));
|
2022-09-11 13:33:14 +00:00
|
|
|
double dz = pPlayer->actor->spr.pos.Z - pPosture->eyeAboveZ - pPlayer->zView;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (dz > 0)
|
2022-09-11 13:33:14 +00:00
|
|
|
pPlayer->zViewVel += dz * FixedToFloat(0xa000);
|
2021-12-29 21:56:21 +00:00
|
|
|
else
|
2022-09-11 13:33:14 +00:00
|
|
|
pPlayer->zViewVel += dz * FixedToFloat(0x1800);
|
2022-09-11 12:39:38 +00:00
|
|
|
pPlayer->zView += pPlayer->zViewVel;
|
2022-09-11 13:21:36 +00:00
|
|
|
pPlayer->zWeaponVel = interpolatedvalue(pPlayer->zWeaponVel, actor->vel.Z, FixedToFloat(0x5000));
|
2022-09-11 13:33:14 +00:00
|
|
|
dz = pPlayer->actor->spr.pos.Z - pPosture->weaponAboveZ - pPlayer->zWeapon;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (dz > 0)
|
2022-09-11 13:33:14 +00:00
|
|
|
pPlayer->zWeaponVel += dz * FixedToFloat(0x8000);
|
2021-12-29 21:56:21 +00:00
|
|
|
else
|
2022-09-11 13:33:14 +00:00
|
|
|
pPlayer->zWeaponVel += dz * FixedToFloat(0xc00);
|
2022-09-11 13:21:36 +00:00
|
|
|
pPlayer->zWeapon += pPlayer->zWeaponVel;
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->bobPhase = ClipLow(pPlayer->bobPhase - 4, 0);
|
|
|
|
nSpeed >>= FRACBITS;
|
|
|
|
if (pPlayer->posture == 1)
|
|
|
|
{
|
|
|
|
pPlayer->bobAmp = (pPlayer->bobAmp + 17) & 2047;
|
|
|
|
pPlayer->swayAmp = (pPlayer->swayAmp + 17) & 2047;
|
2022-09-12 11:16:31 +00:00
|
|
|
pPlayer->bobHeight = pPosture->bobV * 10 * BobVal(pPlayer->bobAmp * 2);
|
|
|
|
pPlayer->bobWidth = pPosture->bobH * pPlayer->bobPhase * BobVal(pPlayer->bobAmp - 256);
|
|
|
|
pPlayer->swayHeight = pPosture->swayV * pPlayer->bobPhase * BobVal(pPlayer->swayAmp * 2);
|
|
|
|
pPlayer->swayWidth = pPosture->swayH * pPlayer->bobPhase * BobVal(pPlayer->swayAmp - 0x155);
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (actor->xspr.height < 256)
|
|
|
|
{
|
|
|
|
bool running = pPlayer->isRunning && !cl_bloodvanillabobbing;
|
|
|
|
pPlayer->bobAmp = (pPlayer->bobAmp + pPosture->pace[running] * 4) & 2047;
|
|
|
|
pPlayer->swayAmp = (pPlayer->swayAmp + (pPosture->pace[running] * 4) / 2) & 2047;
|
|
|
|
if (running)
|
|
|
|
{
|
|
|
|
if (pPlayer->bobPhase < 60)
|
|
|
|
pPlayer->bobPhase = ClipHigh(pPlayer->bobPhase + nSpeed, 60);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pPlayer->bobPhase < 30)
|
|
|
|
pPlayer->bobPhase = ClipHigh(pPlayer->bobPhase + nSpeed, 30);
|
|
|
|
}
|
|
|
|
}
|
2022-09-12 11:16:31 +00:00
|
|
|
pPlayer->bobHeight = pPosture->bobV * pPlayer->bobPhase * BobVal(pPlayer->bobAmp * 2);
|
|
|
|
pPlayer->bobWidth = pPosture->bobH * pPlayer->bobPhase * BobVal(pPlayer->bobAmp - 256);
|
|
|
|
pPlayer->swayHeight = pPosture->swayV * pPlayer->bobPhase * BobVal(pPlayer->swayAmp * 2);
|
|
|
|
pPlayer->swayWidth = pPosture->swayH * pPlayer->bobPhase * BobVal(pPlayer->swayAmp - 0x155);
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
pPlayer->flickerEffect = 0;
|
|
|
|
pPlayer->quakeEffect = ClipLow(pPlayer->quakeEffect - 4, 0);
|
|
|
|
pPlayer->tiltEffect = ClipLow(pPlayer->tiltEffect - 4, 0);
|
|
|
|
pPlayer->visibility = ClipLow(pPlayer->visibility - 4, 0);
|
|
|
|
pPlayer->painEffect = ClipLow(pPlayer->painEffect - 4, 0);
|
|
|
|
pPlayer->blindEffect = ClipLow(pPlayer->blindEffect - 4, 0);
|
|
|
|
pPlayer->pickupEffect = ClipLow(pPlayer->pickupEffect - 4, 0);
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pPlayer->nPlayer == myconnectindex && pPlayer->actor->xspr.health == 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->hand = 0;
|
|
|
|
if (!actor->xspr.health)
|
|
|
|
return;
|
|
|
|
pPlayer->isUnderwater = 0;
|
|
|
|
if (pPlayer->posture == 1)
|
|
|
|
{
|
|
|
|
pPlayer->isUnderwater = 1;
|
2021-12-30 15:51:56 +00:00
|
|
|
auto link = actor->sector()->lowerLink;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (link && (link->spr.type == kMarkerLowGoo || link->spr.type == kMarkerLowWater))
|
|
|
|
{
|
2022-09-11 12:09:19 +00:00
|
|
|
if (getceilzofslopeptrf(actor->sector(), actor->spr.pos) > pPlayer->zView)
|
2021-12-29 21:56:21 +00:00
|
|
|
pPlayer->isUnderwater = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pPlayer->isUnderwater)
|
|
|
|
{
|
|
|
|
pPlayer->underwaterTime = 1200;
|
|
|
|
pPlayer->chokeEffect = 0;
|
|
|
|
if (packItemActive(pPlayer, 1))
|
|
|
|
packUseItem(pPlayer, 1);
|
|
|
|
}
|
|
|
|
int nType = kDudePlayer1 - kDudeBase;
|
|
|
|
switch (pPlayer->posture)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
seqSpawn(dudeInfo[nType].seqStartID + 9, actor, -1);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
seqSpawn(dudeInfo[nType].seqStartID + 10, actor, -1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!nSpeed)
|
|
|
|
seqSpawn(dudeInfo[nType].seqStartID, actor, -1);
|
|
|
|
else
|
|
|
|
seqSpawn(dudeInfo[nType].seqStartID + 8, actor, -1);
|
|
|
|
break;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DBloodActor* playerFireMissile(PLAYER* pPlayer, int a2, int a3, int a4, int a5, int a6)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2022-09-11 13:19:19 +00:00
|
|
|
return actFireMissile(pPlayer->actor, a2, pPlayer->zWeapon * zworldtoint - pPlayer->actor->int_pos().Z, a3, a4, a5, a6);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
DBloodActor* playerFireThing(PLAYER* pPlayer, int a2, int a3, int thingType, int a5)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(thingType >= kThingBase && thingType < kThingMax);
|
2022-09-11 13:19:19 +00:00
|
|
|
return actFireThing(pPlayer->actor, a2, pPlayer->zWeapon * zworldtoint - pPlayer->actor->int_pos().Z, pPlayer->slope + a3, thingType, a5);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void playerFrag(PLAYER* pKiller, PLAYER* pVictim)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(pKiller != NULL);
|
|
|
|
assert(pVictim != NULL);
|
|
|
|
|
|
|
|
char buffer[128] = "";
|
|
|
|
int nKiller = pKiller->actor->spr.type - kDudePlayer1;
|
|
|
|
assert(nKiller >= 0 && nKiller < kMaxPlayers);
|
|
|
|
int nVictim = pVictim->actor->spr.type - kDudePlayer1;
|
|
|
|
assert(nVictim >= 0 && nVictim < kMaxPlayers);
|
|
|
|
if (nKiller == nVictim)
|
|
|
|
{
|
|
|
|
pVictim->fragger = nullptr;
|
|
|
|
if (VanillaMode() || gGameOptions.nGameType != 1)
|
|
|
|
{
|
|
|
|
pVictim->fragCount--;
|
|
|
|
pVictim->fragInfo[nVictim]--;
|
|
|
|
}
|
|
|
|
if (gGameOptions.nGameType == 3)
|
|
|
|
team_score[pVictim->teamId]--;
|
|
|
|
int nMessage = Random(5);
|
|
|
|
int nSound = gSuicide[nMessage].Kills;
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pVictim->nPlayer == myconnectindex && pVictim->handTime <= 0)
|
2021-12-29 21:56:21 +00:00
|
|
|
{
|
2020-01-07 00:11:19 +00:00
|
|
|
strcpy(buffer, GStrings("TXTB_KILLSELF"));
|
2021-12-29 21:56:21 +00:00
|
|
|
if (gGameOptions.nGameType > 0 && nSound >= 0)
|
|
|
|
sndStartSample(nSound, 255, 2, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(buffer, gSuicide[nMessage].message, PlayerName(nVictim));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (VanillaMode() || gGameOptions.nGameType != 1)
|
|
|
|
{
|
|
|
|
pKiller->fragCount++;
|
|
|
|
pKiller->fragInfo[nKiller]++;
|
|
|
|
}
|
|
|
|
if (gGameOptions.nGameType == 3)
|
|
|
|
{
|
|
|
|
if (pKiller->teamId == pVictim->teamId)
|
|
|
|
team_score[pKiller->teamId]--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
team_score[pKiller->teamId]++;
|
|
|
|
team_ticker[pKiller->teamId] += 120;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int nMessage = Random(25);
|
|
|
|
int nSound = gVictory[nMessage].Kills;
|
|
|
|
const char* pzMessage = gVictory[nMessage].message;
|
|
|
|
sprintf(buffer, pzMessage, PlayerName(nKiller), PlayerName(nVictim));
|
2022-09-10 13:15:58 +00:00
|
|
|
if (gGameOptions.nGameType > 0 && nSound >= 0 && pKiller->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
sndStartSample(nSound, 255, 2, 0);
|
|
|
|
}
|
|
|
|
viewSetMessage(buffer);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FragPlayer(PLAYER* pPlayer, DBloodActor* killer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (killer && killer->IsPlayerActor())
|
|
|
|
{
|
|
|
|
PLAYER* pKiller = &gPlayer[killer->spr.type - kDudePlayer1];
|
|
|
|
playerFrag(pKiller, pPlayer);
|
|
|
|
int nTeam1 = pKiller->teamId & 1;
|
|
|
|
int nTeam2 = pPlayer->teamId & 1;
|
|
|
|
if (nTeam1 == 0)
|
|
|
|
{
|
|
|
|
if (nTeam1 != nTeam2)
|
|
|
|
evSendGame(15, kCmdToggle);
|
|
|
|
else
|
|
|
|
evSendGame(16, kCmdToggle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nTeam1 == nTeam2)
|
|
|
|
evSendGame(16, kCmdToggle);
|
|
|
|
else
|
|
|
|
evSendGame(15, kCmdToggle);
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int playerDamageArmor(PLAYER* pPlayer, DAMAGE_TYPE nType, int nDamage)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
DAMAGEINFO* pDamageInfo = &damageInfo[nType];
|
|
|
|
int nArmorType = pDamageInfo->armorType;
|
|
|
|
if (nArmorType >= 0 && pPlayer->armor[nArmorType])
|
|
|
|
{
|
2019-09-19 22:42:45 +00:00
|
|
|
#if 0
|
2021-12-29 21:56:21 +00:00
|
|
|
int vbp = (nDamage * 7) / 8 - nDamage / 4;
|
|
|
|
int v8 = pPlayer->at33e[nArmorType];
|
|
|
|
int t = nDamage / 4 + vbp * v8 / 3200;
|
|
|
|
v8 -= t;
|
2019-09-19 22:42:45 +00:00
|
|
|
#endif
|
2021-12-29 21:56:21 +00:00
|
|
|
int v8 = pPlayer->armor[nArmorType];
|
|
|
|
int t = scale(v8, 0, 3200, nDamage / 4, (nDamage * 7) / 8);
|
|
|
|
v8 -= t;
|
|
|
|
nDamage -= t;
|
|
|
|
pPlayer->armor[nArmorType] = ClipLow(v8, 0);
|
|
|
|
}
|
|
|
|
return nDamage;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void flagDropped(PLAYER* pPlayer, int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
DBloodActor* playeractor = pPlayer->actor;
|
|
|
|
DBloodActor* actor;
|
|
|
|
char buffer[80];
|
|
|
|
switch (a2)
|
|
|
|
{
|
|
|
|
case kItemFlagA:
|
|
|
|
pPlayer->hasFlag &= ~1;
|
|
|
|
actor = actDropObject(playeractor, kItemFlagA);
|
|
|
|
if (actor) actor->SetOwner(pPlayer->ctfFlagState[0]);
|
|
|
|
gBlueFlagDropped = true;
|
|
|
|
sprintf(buffer, "%s dropped Blue Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8005, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
break;
|
|
|
|
case kItemFlagB:
|
|
|
|
pPlayer->hasFlag &= ~2;
|
|
|
|
actor = actDropObject(playeractor, kItemFlagB);
|
|
|
|
if (actor) actor->SetOwner(pPlayer->ctfFlagState[1]);
|
|
|
|
gRedFlagDropped = true;
|
|
|
|
sprintf(buffer, "%s dropped Red Flag", PlayerName(pPlayer->nPlayer));
|
|
|
|
sndStartSample(8004, 255, 2, 0);
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
break;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int playerDamageSprite(DBloodActor* source, PLAYER* pPlayer, DAMAGE_TYPE nDamageType, int nDamage)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
assert(pPlayer != NULL);
|
|
|
|
if (pPlayer->damageControl[nDamageType] || pPlayer->godMode)
|
|
|
|
return 0;
|
|
|
|
nDamage = playerDamageArmor(pPlayer, nDamageType, nDamage);
|
|
|
|
pPlayer->painEffect = ClipHigh(pPlayer->painEffect + (nDamage >> 3), 600);
|
|
|
|
|
|
|
|
DBloodActor* pActor = pPlayer->actor;
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(pActor->spr.type);
|
|
|
|
int nDeathSeqID = -1;
|
|
|
|
int nKneelingPlayer = -1;
|
|
|
|
bool va = playerSeqPlaying(pPlayer, 16);
|
|
|
|
if (!pActor->xspr.health)
|
|
|
|
{
|
|
|
|
if (va)
|
|
|
|
{
|
|
|
|
switch (nDamageType)
|
|
|
|
{
|
|
|
|
case kDamageSpirit:
|
|
|
|
nDeathSeqID = 18;
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 716, 0, 0);
|
|
|
|
break;
|
|
|
|
case kDamageExplode:
|
|
|
|
GibSprite(pActor, GIBTYPE_7, NULL, NULL);
|
|
|
|
GibSprite(pActor, GIBTYPE_15, NULL, NULL);
|
|
|
|
pPlayer->actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
nDeathSeqID = 17;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
2022-08-23 20:43:06 +00:00
|
|
|
double top, bottom;
|
2021-12-29 21:56:21 +00:00
|
|
|
GetActorExtents(pActor, &top, &bottom);
|
2022-08-23 20:43:06 +00:00
|
|
|
DVector3 gibPos(pActor->spr.pos.XY(), top);
|
2022-09-01 18:43:35 +00:00
|
|
|
CGibVelocity gibVel(pActor->int_vel().X >> 1, pActor->int_vel().Y >> 1, -0xccccc);
|
2021-12-29 21:56:21 +00:00
|
|
|
GibSprite(pActor, GIBTYPE_27, &gibPos, &gibVel);
|
|
|
|
GibSprite(pActor, GIBTYPE_7, NULL, NULL);
|
|
|
|
fxSpawnBlood(pActor, nDamage << 4);
|
|
|
|
fxSpawnBlood(pActor, nDamage << 4);
|
|
|
|
nDeathSeqID = 17;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int nHealth = pActor->xspr.health - nDamage;
|
|
|
|
pActor->xspr.health = ClipLow(nHealth, 0);
|
|
|
|
if (pActor->xspr.health > 0 && pActor->xspr.health < 16)
|
|
|
|
{
|
|
|
|
nDamageType = kDamageBullet;
|
|
|
|
pActor->xspr.health = 0;
|
|
|
|
nHealth = -25;
|
|
|
|
}
|
|
|
|
if (pActor->xspr.health > 0)
|
|
|
|
{
|
|
|
|
DAMAGEINFO* pDamageInfo = &damageInfo[nDamageType];
|
|
|
|
int nSound;
|
|
|
|
if (nDamage >= (10 << 4))
|
|
|
|
nSound = pDamageInfo->Kills[0];
|
|
|
|
else
|
|
|
|
nSound = pDamageInfo->Kills[Random(3)];
|
|
|
|
if (nDamageType == kDamageDrown && pActor->xspr.medium == kMediumWater && !pPlayer->hand)
|
|
|
|
nSound = 714;
|
|
|
|
sfxPlay3DSound(pPlayer->actor, nSound, 0, 6);
|
|
|
|
return nDamage;
|
|
|
|
}
|
|
|
|
sfxKill3DSound(pPlayer->actor, -1, 441);
|
|
|
|
if (gGameOptions.nGameType == 3 && pPlayer->hasFlag) {
|
|
|
|
if (pPlayer->hasFlag & 1) flagDropped(pPlayer, kItemFlagA);
|
|
|
|
if (pPlayer->hasFlag & 2) flagDropped(pPlayer, kItemFlagB);
|
|
|
|
}
|
|
|
|
pPlayer->deathTime = 0;
|
|
|
|
pPlayer->qavLoop = 0;
|
|
|
|
pPlayer->curWeapon = kWeapNone;
|
|
|
|
pPlayer->fragger = source;
|
|
|
|
pPlayer->voodooTargets = 0;
|
|
|
|
if (nDamageType == kDamageExplode && nDamage < (9 << 4))
|
|
|
|
nDamageType = kDamageFall;
|
|
|
|
switch (nDamageType)
|
|
|
|
{
|
|
|
|
case kDamageExplode:
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 717, 0, 0);
|
|
|
|
GibSprite(pActor, GIBTYPE_7, NULL, NULL);
|
|
|
|
GibSprite(pActor, GIBTYPE_15, NULL, NULL);
|
|
|
|
pPlayer->actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
nDeathSeqID = 2;
|
|
|
|
break;
|
|
|
|
case kDamageBurn:
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 718, 0, 0);
|
|
|
|
nDeathSeqID = 3;
|
|
|
|
break;
|
|
|
|
case kDamageDrown:
|
|
|
|
nDeathSeqID = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (nHealth < -20 && gGameOptions.nGameType >= 2 && Chance(0x4000))
|
|
|
|
{
|
|
|
|
DAMAGEINFO* pDamageInfo = &damageInfo[nDamageType];
|
|
|
|
sfxPlay3DSound(pPlayer->actor, pDamageInfo->at10[0], 0, 2);
|
|
|
|
nDeathSeqID = 16;
|
|
|
|
nKneelingPlayer = nPlayerKneelClient;
|
|
|
|
powerupActivate(pPlayer, kPwUpDeliriumShroom);
|
|
|
|
pActor->SetTarget(source);
|
|
|
|
evPostActor(pPlayer->actor, 15, kCallbackFinishHim);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sfxPlay3DSound(pPlayer->actor, 716, 0, 0);
|
|
|
|
nDeathSeqID = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nDeathSeqID < 0)
|
|
|
|
return nDamage;
|
|
|
|
if (nDeathSeqID != 16)
|
|
|
|
{
|
|
|
|
powerupClear(pPlayer);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (pActor->sector()->hasX() && pActor->sector()->xs().Exit)
|
|
|
|
trTriggerSector(pActor->sector(), kCmdSectorExit);
|
2021-12-29 21:56:21 +00:00
|
|
|
pActor->spr.flags |= 7;
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
|
|
|
if (gPlayer[p].fragger == pPlayer->actor && gPlayer[p].deathTime > 0)
|
|
|
|
gPlayer[p].fragger = nullptr;
|
|
|
|
}
|
|
|
|
FragPlayer(pPlayer, source);
|
|
|
|
trTriggerSprite(pActor, kCmdOff);
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// allow drop items and keys in multiplayer
|
|
|
|
if (gModernMap && gGameOptions.nGameType != 0 && pPlayer->actor->xspr.health <= 0) {
|
|
|
|
|
|
|
|
DBloodActor* pItem = nullptr;
|
|
|
|
if (pPlayer->actor->xspr.dropMsg && (pItem = actDropItem(pActor, pPlayer->actor->xspr.dropMsg)) != NULL)
|
|
|
|
evPostActor(pItem, 500, kCallbackRemove);
|
|
|
|
|
|
|
|
if (pPlayer->actor->xspr.key) {
|
|
|
|
|
|
|
|
int i; // if all players have this key, don't drop it
|
|
|
|
for (i = connecthead; i >= 0; i = connectpoint2[i]) {
|
|
|
|
if (!gPlayer[i].hasKey[pPlayer->actor->xspr.key])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0 && (pItem = actDropKey(pActor, (pPlayer->actor->xspr.key + kItemKeyBase) - 1)) != NULL)
|
|
|
|
evPostActor(pItem, 500, kCallbackRemove);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
assert(getSequence(pDudeInfo->seqStartID + nDeathSeqID) != NULL);
|
|
|
|
seqSpawn(pDudeInfo->seqStartID + nDeathSeqID, pPlayer->actor, nKneelingPlayer);
|
|
|
|
return nDamage;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int UseAmmo(PLAYER* pPlayer, int nAmmoType, int nDec)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (gInfiniteAmmo)
|
|
|
|
return 9999;
|
|
|
|
if (nAmmoType == -1)
|
|
|
|
return 9999;
|
|
|
|
pPlayer->ammoCount[nAmmoType] = ClipLow(pPlayer->ammoCount[nAmmoType] - nDec, 0);
|
|
|
|
return pPlayer->ammoCount[nAmmoType];
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void voodooTarget(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
DBloodActor* actor = pPlayer->actor;
|
|
|
|
int v4 = pPlayer->aim.dz;
|
2022-09-11 13:19:19 +00:00
|
|
|
double dz = pPlayer->zWeapon - pPlayer->actor->spr.pos.Z;
|
2021-12-29 21:56:21 +00:00
|
|
|
if (UseAmmo(pPlayer, 9, 0) < 8)
|
|
|
|
{
|
|
|
|
pPlayer->voodooTargets = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
int ang1 = (pPlayer->voodooVar1 + pPlayer->vodooVar2) & 2047;
|
2022-09-11 13:19:19 +00:00
|
|
|
actFireVectorf(actor, 0, dz, bcos(ang1), bsin(ang1), v4, kVectorVoodoo10);
|
2021-12-29 21:56:21 +00:00
|
|
|
int ang2 = (pPlayer->voodooVar1 + 2048 - pPlayer->vodooVar2) & 2047;
|
2022-09-11 13:19:19 +00:00
|
|
|
actFireVectorf(actor, 0, dz, bcos(ang2), bsin(ang2), v4, kVectorVoodoo10);
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
pPlayer->voodooTargets = ClipLow(pPlayer->voodooTargets - 1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void playerLandingSound(PLAYER* pPlayer)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
static int surfaceSound[] = {
|
|
|
|
-1,
|
|
|
|
600,
|
|
|
|
601,
|
|
|
|
602,
|
|
|
|
603,
|
|
|
|
604,
|
|
|
|
605,
|
|
|
|
605,
|
|
|
|
605,
|
|
|
|
600,
|
|
|
|
605,
|
|
|
|
605,
|
|
|
|
605,
|
|
|
|
604,
|
|
|
|
603
|
|
|
|
};
|
|
|
|
SPRITEHIT* pHit = &pPlayer->actor->hit;
|
|
|
|
if (pHit->florhit.type != kHitNone)
|
|
|
|
{
|
|
|
|
if (!gGameOptions.bFriendlyFire && pHit->florhit.type == kHitSprite && IsTargetTeammate(pPlayer, pHit->florhit.actor()))
|
|
|
|
return;
|
|
|
|
int nSurf = tileGetSurfType(pHit->florhit);
|
|
|
|
if (nSurf)
|
|
|
|
sfxPlay3DSound(pPlayer->actor, surfaceSound[nSurf], -1, 0);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void PlayerSurvive(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
char buffer[80];
|
|
|
|
actHealDude(actor, 1, 2);
|
|
|
|
if (gGameOptions.nGameType > 0 && numplayers > 1)
|
|
|
|
{
|
|
|
|
sfxPlay3DSound(actor, 3009, 0, 6);
|
|
|
|
if (actor->IsPlayerActor())
|
|
|
|
{
|
|
|
|
PLAYER* pPlayer = &gPlayer[actor->spr.type - kDudePlayer1];
|
2022-09-10 13:15:58 +00:00
|
|
|
if (pPlayer->nPlayer == myconnectindex)
|
2021-12-29 21:56:21 +00:00
|
|
|
viewSetMessage(GStrings("TXT_LIVEAGAIM"));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%s lives again!", PlayerName(pPlayer->nPlayer));
|
|
|
|
viewSetMessage(buffer);
|
|
|
|
}
|
|
|
|
pPlayer->newWeapon = kWeapPitchFork;
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void PlayerKneelsOver(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
|
|
|
if (gPlayer[p].actor == actor)
|
|
|
|
{
|
|
|
|
PLAYER* pPlayer = &gPlayer[p];
|
|
|
|
playerDamageSprite(pPlayer->fragger, pPlayer, kDamageSpirit, 500 << 4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 13:24:55 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Aim& w, Aim* def)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("x", w.dx)
|
|
|
|
("y", w.dx)
|
|
|
|
("z", w.dx)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2020-11-22 13:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PACKINFO& w, PACKINFO* def)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("isactive", w.isActive)
|
|
|
|
("curamount", w.curAmount)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2020-11-22 13:24:55 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-22 13:24:55 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, POSTURE& w, POSTURE* def)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("frontaccel", w.frontAccel, def->frontAccel)
|
|
|
|
("sideaccel", w.sideAccel, def->sideAccel)
|
|
|
|
("backaccel", w.backAccel, def->backAccel)
|
|
|
|
("pace0", w.pace[0], def->pace[0])
|
|
|
|
("pace1", w.pace[1], def->pace[1])
|
|
|
|
("bobv", w.bobV, def->bobV)
|
|
|
|
("bobh", w.bobH, def->bobH)
|
|
|
|
("swayv", w.swayV, def->swayV)
|
|
|
|
("swayh", w.swayH, def->swayH)
|
|
|
|
("eyeabovez", w.eyeAboveZ, def->eyeAboveZ)
|
|
|
|
("weaponabovez", w.weaponAboveZ, def->weaponAboveZ)
|
|
|
|
("xoffset", w.xOffset, def->xOffset)
|
|
|
|
("zoffset", w.zOffset, def->zOffset)
|
|
|
|
("normaljumpz", w.normalJumpZ, def->normalJumpZ)
|
|
|
|
("pwupjumpz", w.pwupJumpZ, def->pwupJumpZ)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2020-11-22 13:24:55 +00:00
|
|
|
}
|
2020-02-07 19:47:43 +00:00
|
|
|
|
2020-11-22 13:24:55 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER* def)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.isReading()) playerResetPosture(&w);
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("spritenum", w.actor)
|
|
|
|
("horizon", w.horizon)
|
|
|
|
("angle", w.angle)
|
|
|
|
("newweapon", w.newWeapon)
|
|
|
|
("used1", w.used1)
|
|
|
|
("weaponqav", w.weaponQav)
|
|
|
|
("qavcallback", w.qavCallback)
|
|
|
|
("isrunning", w.isRunning)
|
|
|
|
("posture", w.posture)
|
|
|
|
("sceneqav", w.sceneQav)
|
|
|
|
("bobphase", w.bobPhase)
|
|
|
|
("bobamp", w.bobAmp)
|
|
|
|
("bobheight", w.bobHeight)
|
|
|
|
("bobwidth", w.bobWidth)
|
|
|
|
("swayphase", w.swayPhase)
|
|
|
|
("swayamp", w.swayAmp)
|
|
|
|
("swayheight", w.swayHeight)
|
|
|
|
("swaywidth", w.swayWidth)
|
|
|
|
("nplayer", w.nPlayer)
|
|
|
|
("lifemode", w.lifeMode)
|
|
|
|
("bloodlust", w.bloodlust)
|
|
|
|
("zview", w.zView)
|
|
|
|
("zviewvel", w.zViewVel)
|
|
|
|
("zweapon", w.zWeapon)
|
|
|
|
("zweaponvel", w.zWeaponVel)
|
|
|
|
("slope", w.slope)
|
|
|
|
("underwater", w.isUnderwater)
|
|
|
|
.Array("haskey", w.hasKey, 8)
|
|
|
|
("hasflag", w.hasFlag)
|
|
|
|
.Array("ctfflagstate", w.ctfFlagState, 2)
|
|
|
|
.Array("dmgcontrol", w.damageControl, 7)
|
|
|
|
("curweapon", w.curWeapon)
|
|
|
|
("nextweapon", w.nextWeapon)
|
|
|
|
("weapontimer", w.weaponTimer)
|
|
|
|
("weaponstate", w.weaponState)
|
|
|
|
("weaponammo", w.weaponAmmo)
|
|
|
|
.Array("hasweapon", w.hasWeapon, countof(w.hasWeapon))
|
|
|
|
.Array("weaponmode", w.weaponMode, countof(w.weaponMode))
|
2022-01-12 11:22:48 +00:00
|
|
|
.Array("weaponorder", &w.weaponOrder[0][kWeapNone], +kWeapMax * 2)
|
2021-12-29 21:56:21 +00:00
|
|
|
.Array("ammocount", w.ammoCount, countof(w.ammoCount))
|
|
|
|
("qavloop", w.qavLoop)
|
|
|
|
("qavlastTick", w.qavLastTick)
|
|
|
|
("qavtimer", w.qavTimer)
|
|
|
|
("fusetime", w.fuseTime)
|
|
|
|
("throwtime", w.throwTime)
|
|
|
|
("throwpower", w.throwPower)
|
|
|
|
("aim", w.aim)
|
|
|
|
("relaim", w.relAim)
|
|
|
|
("aimtarget", w.aimTarget)
|
|
|
|
("aimtargetscount", w.aimTargetsCount)
|
|
|
|
.Array("aimtargets", w.aimTargets, countof(w.aimTargets))
|
|
|
|
("deathtime", w.deathTime)
|
|
|
|
.Array("pwuptime", w.pwUpTime, countof(w.pwUpTime))
|
|
|
|
("fragcount", w.fragCount)
|
|
|
|
.Array("fraginfo", w.fragInfo, countof(w.fragInfo))
|
|
|
|
("teamid", w.teamId)
|
|
|
|
("fraggerid", w.fragger)
|
|
|
|
("undserwatertime", w.underwaterTime)
|
|
|
|
("bubbletime", w.bubbleTime)
|
|
|
|
("resttime", w.restTime)
|
|
|
|
("kickpower", w.kickPower)
|
|
|
|
("laughcount", w.laughCount)
|
|
|
|
("godmode", w.godMode)
|
|
|
|
("fallscream", w.fallScream)
|
|
|
|
("cantjump", w.cantJump)
|
|
|
|
("packitemtime", w.packItemTime)
|
|
|
|
("packitemid", w.packItemId)
|
|
|
|
.Array("packslots", w.packSlots, countof(w.packSlots))
|
|
|
|
.Array("armor", w.armor, countof(w.armor))
|
|
|
|
("voodootarget", w.voodooTarget)
|
|
|
|
("voodootargets", w.voodooTargets)
|
|
|
|
("voodoovar1", w.voodooVar1)
|
|
|
|
("voodoovar2", w.vodooVar2)
|
|
|
|
("flickereffect", w.flickerEffect)
|
|
|
|
("tilteffect", w.tiltEffect)
|
|
|
|
("visibility", w.visibility)
|
|
|
|
("paineffect", w.painEffect)
|
|
|
|
("blindeffect", w.blindEffect)
|
|
|
|
("chokeeffect", w.chokeEffect)
|
|
|
|
("handtime", w.handTime)
|
|
|
|
("hand", w.hand)
|
|
|
|
("pickupeffect", w.pickupEffect)
|
|
|
|
("flasheffect", w.flashEffect)
|
|
|
|
("quakeeffect", w.quakeEffect)
|
|
|
|
("player_par", w.player_par)
|
|
|
|
("waterpal", w.nWaterPal)
|
|
|
|
.Array("posturedata", &w.pPosture[0][0], &gPostureDefaults[0][0], kModeMax * kPostureMax) // only save actual changes in this.
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2020-11-22 13:24:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-22 13:24:55 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRPLAYERCTRL& w, TRPLAYERCTRL* def)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("index", w.qavScene.initiator)
|
|
|
|
("dummy", w.qavScene.dummy)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
if (arc.isReading()) w.qavScene.qavResrc = nullptr;
|
|
|
|
return arc;
|
2020-11-22 13:24:55 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-22 13:24:55 +00:00
|
|
|
void SerializePlayers(FSerializer& arc)
|
|
|
|
{
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.BeginObject("players"))
|
|
|
|
{
|
|
|
|
arc("numplayers", gNetPlayers)
|
|
|
|
.Array("teamscore", team_score, gNetPlayers)
|
|
|
|
.Array("players", gPlayer, gNetPlayers)
|
2020-11-22 13:24:55 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2021-12-29 21:56:21 +00:00
|
|
|
.Array("playerctrl", gPlayerCtrl, gNetPlayers)
|
2020-11-22 13:24:55 +00:00
|
|
|
#endif
|
2021-12-29 21:56:21 +00:00
|
|
|
.EndObject();
|
|
|
|
}
|
2020-11-22 13:24:55 +00:00
|
|
|
|
2021-12-29 21:56:21 +00:00
|
|
|
if (arc.isReading())
|
|
|
|
{
|
|
|
|
for (int i = 0; i < gNetPlayers; i++)
|
|
|
|
{
|
|
|
|
gPlayer[i].pDudeInfo = &dudeInfo[gPlayer[i].actor->spr.type - kDudeBase];
|
2020-11-22 13:24:55 +00:00
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
2021-12-29 21:56:21 +00:00
|
|
|
// load qav scene
|
|
|
|
if (gPlayer[i].sceneQav != -1)
|
|
|
|
{
|
|
|
|
QAV* pQav = playerQavSceneLoad(gPlayer[i].sceneQav);
|
|
|
|
if (pQav)
|
|
|
|
{
|
|
|
|
gPlayerCtrl[i].qavScene.qavResrc = pQav;
|
|
|
|
//gPlayerCtrl[i].qavScene.qavResrc->Preload();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gPlayer[i].sceneQav = -1;
|
|
|
|
}
|
|
|
|
}
|
2020-11-22 13:24:55 +00:00
|
|
|
#endif
|
2021-12-29 21:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
|
2021-05-11 16:04:17 +00:00
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, newWeapon)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponQav)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, qavCallback)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, isRunning)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, posture) // stand, crouch, swim
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, sceneQav) // by NoOne: used to keep qav id
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, bobPhase)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, bobAmp)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, bobHeight)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, bobWidth)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, swayPhase)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, swayAmp)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, swayHeight)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, swayWidth)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, nPlayer) // Connect id
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, lifeMode)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, zView)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, zViewVel)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, zWeapon)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, zWeaponVel)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, slope)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, isUnderwater)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, hasKey)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, hasFlag)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, damageControl)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, curWeapon)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, nextWeapon)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponTimer)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponState)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponAmmo) //rename
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, hasWeapon)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponMode)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponOrder)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, ammoCount)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, qavLoop)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, fuseTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, throwTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, throwPower)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, aim) // world
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargetsCount)
|
2021-09-05 06:41:44 +00:00
|
|
|
//DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargets)
|
2021-05-11 16:04:17 +00:00
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, deathTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, pwUpTime)
|
2021-05-13 07:31:08 +00:00
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, teamId)
|
2021-05-11 16:04:17 +00:00
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, fragCount)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, fragInfo)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, underwaterTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, bubbleTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, restTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, kickPower)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, laughCount)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, godMode)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, fallScream)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, cantJump)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemTime) // pack timer
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemId) // pack id 1: diving suit, 2: crystal ball, 3:
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, packSlots) // at325 1]: diving suit, [2]: crystal ball,
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, armor) // armor
|
2021-08-29 16:13:15 +00:00
|
|
|
//DEFINE_FIELD_X(BloodPlayer, PLAYER, voodooTarget)
|
2021-05-11 16:04:17 +00:00
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, flickerEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, tiltEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, visibility)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, painEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, blindEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, chokeEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, handTime)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, hand) // if true, there is hand start choking the player
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, pickupEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, flashEffect) // if true, reduce pPlayer->visibility counter
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, quakeEffect)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, player_par)
|
|
|
|
DEFINE_FIELD_X(BloodPlayer, PLAYER, nWaterPal)
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|