1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5
6 This file is part of NBlood.
7
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16 See the GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 #include "actor.h"
25 #include "blood.h"
26 #include "build.h"
27 #include "common_game.h"
28 #include "compat.h"
29 #include "config.h"
30 #include "controls.h"
31 #include "db.h"
32 #include "dude.h"
33 #include "fix16.h"
34 #include "levels.h"
35 #include "qav.h"
36
37 // life modes of the player
38 enum
39 {
40 kModeHuman = 0,
41 kModeBeast = 1,
42 kModeHumanShrink = 2,
43 kModeHumanGrown = 3,
44 kModeMax = 4,
45 };
46
47 // postures
48 enum
49 {
50 kPostureStand = 0,
51 kPostureSwim = 1,
52 kPostureCrouch = 2,
53 kPostureMax = 3,
54 };
55
56 struct PACKINFO
57 {
58 bool isActive; // is active (0/1)
59 int curAmount = 0; // remaining percent
60 };
61
62 struct POSTURE
63 {
64 int frontAccel;
65 int sideAccel;
66 int backAccel;
67 int pace[2];
68 int bobV;
69 int bobH;
70 int swayV;
71 int swayH;
72 int eyeAboveZ;
73 int weaponAboveZ;
74 int xOffset;
75 int zOffset;
76 int normalJumpZ;
77 int pwupJumpZ;
78 };
79
80 extern POSTURE gPostureDefaults[kModeMax][kPostureMax];
81
82 struct PLAYER
83 {
84 spritetype* pSprite;
85 XSPRITE* pXSprite;
86 DUDEINFO* pDudeInfo;
87 GINPUT input;
88 //short input; // INPUT
89 //char moveFunc; // forward
90 //short at11; // turn
91 //char hearDist; // strafe
92 //int bobV; // buttonFlags
93 //unsigned int bobH; // keyFlags
94 //char swayV; // useFlags;
95 //char swayH; // newWeapon
96 //char at21; // mlook
97 int used1; // something related to game checksum
98 int weaponQav;
99 int qavCallback;
100 bool isRunning;
101 int posture; // stand, crouch, swim
102 int sceneQav; // by NoOne: used to keep qav id
103 int bobPhase;
104 int bobAmp;
105 int bobHeight;
106 int bobWidth;
107 int swayPhase;
108 int swayAmp;
109 int swayHeight;
110 int swayWidth;
111 int nPlayer; // Connect id
112 int nSprite;
113 int lifeMode;
114 int bloodlust; // ---> useless
115 int zView;
116 int zViewVel;
117 int zWeapon;
118 int zWeaponVel;
119 fix16_t q16look;
120 int q16horiz; // horiz
121 int q16slopehoriz; // horizoff
122 int slope;
123 bool isUnderwater;
124 bool hasKey[8];
125 char hasFlag;
126 short used2[8]; // ??
127 int damageControl[7];
128 char curWeapon;
129 char nextWeapon;
130 int weaponTimer;
131 int weaponState;
132 int weaponAmmo; //rename
133 bool hasWeapon[14];
134 int weaponMode[14];
135 int weaponOrder[2][14];
136 //int at149[14];
137 int ammoCount[12];
138 bool qavLoop;
139 int fuseTime;
140 int throwTime;
141 int throwPower;
142 Aim aim; // world
143 //int at1c6;
144 Aim relAim; // relative
145 //int relAim;
146 //int at1ce;
147 //int at1d2;
148 int aimTarget; // aim target sprite
149 int aimTargetsCount;
150 short aimTargets[16];
151 int deathTime;
152 int pwUpTime[kMaxPowerUps];
153 int fragCount;
154 int fragInfo[8];
155 int teamId;
156 int fraggerId;
157 int underwaterTime;
158 int bloodTime; // --> useless
159 int gooTime; // --> useless
160 int wetTime; // --> useless
161 int bubbleTime;
162 int at306; // --> useless
163 int restTime;
164 int kickPower;
165 int laughCount;
166 int spin; // turning around
167 bool godMode;
168 bool fallScream;
169 bool cantJump;
170 int packItemTime; // pack timer
171 int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots
172 PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots
173 int armor[3]; // armor
174 //int at342;
175 //int at346;
176 int voodooTarget;
177 int voodooTargets; // --> useless
178 int voodooVar1; // --> useless
179 int vodooVar2; // --> useless
180 int flickerEffect;
181 int tiltEffect;
182 int visibility;
183 int painEffect;
184 int blindEffect;
185 int chokeEffect;
186 int handTime;
187 bool hand; // if true, there is hand start choking the player
188 int pickupEffect;
189 bool flashEffect; // if true, reduce pPlayer->visibility counter
190 int quakeEffect;
191 fix16_t q16ang;
192 int angold;
193 int player_par;
194 int nWaterPal;
195 POSTURE pPosture[kModeMax][kPostureMax];
196 };
197
198 struct PROFILE
199 {
200 int nAutoAim;
201 int nWeaponSwitch;
202 int skill;
203 char name[MAXPLAYERNAME];
204 };
205
206 struct AMMOINFO
207 {
208 int max;
209 signed char vectorType;
210 };
211
212 struct POWERUPINFO
213 {
214 short picnum;
215 bool pickupOnce;
216 int bonusTime;
217 int maxTime;
218 };
219
220 void playerResetPosture(PLAYER* pPlayer);
221
222 extern PLAYER gPlayer[kMaxPlayers];
223 extern PLAYER *gMe, *gView;
224
225 extern bool gBlueFlagDropped;
226 extern bool gRedFlagDropped;
227
228 extern PROFILE gProfile[kMaxPlayers];
229
230 extern int dword_21EFB0[kMaxPlayers];
231 extern ClockTicks dword_21EFD0[kMaxPlayers];
232 extern AMMOINFO gAmmoInfo[];
233 extern POWERUPINFO gPowerUpInfo[kMaxPowerUps];
234
IsTargetTeammate(PLAYER * pSourcePlayer,spritetype * pTargetSprite)235 inline bool IsTargetTeammate(PLAYER *pSourcePlayer, spritetype *pTargetSprite)
236 {
237 if (pSourcePlayer == NULL)
238 return false;
239 if (!IsPlayerSprite(pTargetSprite))
240 return false;
241 if (gGameOptions.nGameType == 1 || gGameOptions.nGameType == 3)
242 {
243 PLAYER *pTargetPlayer = &gPlayer[pTargetSprite->type - kDudePlayer1];
244 if (pSourcePlayer != pTargetPlayer)
245 {
246 if (gGameOptions.nGameType == 1)
247 return true;
248 if (gGameOptions.nGameType == 3 && (pSourcePlayer->teamId & 3) == (pTargetPlayer->teamId & 3))
249 return true;
250 }
251 }
252
253 return false;
254 }
255
IsTargetTeammate(spritetype * pSourceSprite,spritetype * pTargetSprite)256 inline bool IsTargetTeammate(spritetype *pSourceSprite, spritetype *pTargetSprite)
257 {
258 if (!IsPlayerSprite(pSourceSprite))
259 return false;
260 PLAYER *pSourcePlayer = &gPlayer[pSourceSprite->type - kDudePlayer1];
261 return IsTargetTeammate(pSourcePlayer, pTargetSprite);
262 }
263
264 int powerupCheck(PLAYER *pPlayer, int nPowerUp);
265 char powerupActivate(PLAYER *pPlayer, int nPowerUp);
266 void powerupDeactivate(PLAYER *pPlayer, int nPowerUp);
267 void powerupSetState(PLAYER *pPlayer, int nPowerUp, char bState);
268 void powerupProcess(PLAYER *pPlayer);
269 void powerupClear(PLAYER *pPlayer);
270 void powerupInit(void);
271 int packItemToPowerup(int nPack);
272 int powerupToPackItem(int nPowerUp);
273 char packAddItem(PLAYER *pPlayer, unsigned int nPack);
274 int packCheckItem(PLAYER *pPlayer, int nPack);
275 char packItemActive(PLAYER *pPlayer, int nPack);
276 void packUseItem(PLAYER *pPlayer, int nPack);
277 void packPrevItem(PLAYER *pPlayer);
278 void packNextItem(PLAYER *pPlayer);
279 char playerSeqPlaying(PLAYER *pPlayer, int nSeq);
280 void playerSetRace(PLAYER *pPlayer, int nLifeMode);
281 void playerSetGodMode(PLAYER *pPlayer, char bGodMode);
282 void playerResetInertia(PLAYER *pPlayer);
283 void playerCorrectInertia(PLAYER *pPlayer, vec3_t const *oldpos);
284 void playerStart(int nPlayer, int bNewLevel = 0);
285 void playerReset(PLAYER *pPlayer);
286 void playerInit(int nPlayer, unsigned int a2);
287 char sub_3A158(PLAYER *a1, spritetype *a2);
288 char PickupItem(PLAYER *pPlayer, spritetype *pItem);
289 char PickupAmmo(PLAYER *pPlayer, spritetype *pAmmo);
290 char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon);
291 void PickUp(PLAYER *pPlayer, spritetype *pSprite);
292 void CheckPickUp(PLAYER *pPlayer);
293 int ActionScan(PLAYER *pPlayer, int *a2, int *a3);
294 void ProcessInput(PLAYER *pPlayer);
295 void playerProcess(PLAYER *pPlayer);
296 spritetype *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int a6);
297 spritetype *playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5);
298 void playerFrag(PLAYER *pKiller, PLAYER *pVictim);
299 void FragPlayer(PLAYER *pPlayer, int nSprite);
300 int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage);
301 spritetype *sub_40A94(PLAYER *pPlayer, int a2);
302 int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage);
303 int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec);
304 void sub_41250(PLAYER *pPlayer);
305 void playerLandingSound(PLAYER *pPlayer);
306 void PlayerSurvive(int, int nXSprite);
307 void PlayerKneelsOver(int, int nXSprite);
308