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 "build.h"
25 #include "common_game.h"
26 #include "blood.h"
27 #include "db.h"
28 #include "fx.h"
29 #include "gameutil.h"
30
31 enum DAMAGE_TYPE {
32 kDamageFall = 0,
33 kDamageBurn,
34 kDamageBullet,
35 kDamageExplode,
36 kDamageDrown,
37 kDamageSpirit,
38 kDamageTesla,
39 kDamageMax = 7,
40 };
41
42 enum VECTOR_TYPE {
43 kVectorTine = 0,
44 kVectorShell,
45 kVectorBullet,
46 kVectorTommyAP,
47 kVectorShellAP,
48 kVectorTommyregular,
49 kVectorBatBite,
50 kVectorBoneelBite,
51 kVectorGillBite,
52 kVectorBeastSlash,
53 kVectorAxe,
54 kVectorCleaver,
55 kVectorGhost,
56 kVectorGargSlash,
57 kVectorCerberusHack,
58 kVectorHoundBite,
59 kVectorRatBite,
60 kVectorSpiderBite,
61 VECTOR_TYPE_18, // Unknown
62 VECTOR_TYPE_19, // Unknown
63 kVectorTchernobogBurn,
64 kVectorVoodoo10,
65 #ifdef NOONE_EXTENSIONS
66 kVectorGenDudePunch,
67 #endif
68 kVectorMax,
69 };
70
71 struct THINGINFO
72 {
73 short startHealth;
74 short mass;
75 unsigned char clipdist;
76 short flags;
77 int elastic; // elasticity
78 int dmgResist; // damage resistance
79 short cstat;
80 short picnum;
81 char shade;
82 unsigned char pal;
83 unsigned char xrepeat; // xrepeat
84 unsigned char yrepeat; // yrepeat
85 int dmgControl[kDamageMax]; // damage
86 };
87
88 struct AMMOITEMDATA
89 {
90 short cstat;
91 short picnum;
92 char shade;
93 char pal;
94 unsigned char xrepeat;
95 unsigned char yrepeat;
96 short count;
97 unsigned char type;
98 unsigned char weaponType;
99 };
100
101 struct WEAPONITEMDATA
102 {
103 short cstat;
104 short picnum;
105 char shade;
106 char pal;
107 unsigned char xrepeat;
108 unsigned char yrepeat;
109 short type;
110 short ammoType;
111 short count;
112 };
113
114 struct ITEMDATA
115 {
116 short cstat;
117 short picnum;
118 char shade;
119 char pal;
120 unsigned char xrepeat;
121 unsigned char yrepeat;
122 short packSlot;
123 };
124
125 struct MissileType
126 {
127 short picnum;
128 int velocity;
129 int angleOfs;
130 unsigned char xrepeat;
131 unsigned char yrepeat;
132 char shade;
133 unsigned char clipDist;
134 };
135
136 struct EXPLOSION
137 {
138 unsigned char repeat;
139 char dmg;
140 char dmgRng;
141 int radius;
142 int dmgType;
143 int burnTime;
144 int ticks;
145 int quakeEffect;
146 int flashEffect;
147 };
148
149 struct SURFHIT {
150 FX_ID fx1;
151 FX_ID fx2;
152 FX_ID fx3;
153 int fxSnd;
154 };
155
156 struct VECTORDATA {
157 DAMAGE_TYPE dmgType;
158 int dmg; // damage
159 int impulse;
160 int maxDist;
161 int fxChance;
162 int burnTime; // burn
163 int bloodSplats; // blood splats
164 int splatChance; // blood splat chance
165 SURFHIT surfHit[15];
166 };
167
168 extern AMMOITEMDATA gAmmoItemData[];
169 extern WEAPONITEMDATA gWeaponItemData[];
170 extern ITEMDATA gItemData[];
171 extern MissileType missileInfo[];
172 extern EXPLOSION explodeInfo[];
173 extern THINGINFO thingInfo[];
174 extern VECTORDATA gVectorData[];
175
176 extern int gDudeDrag;
177 extern short gAffectedSectors[kMaxSectors];
178 extern short gAffectedXWalls[kMaxXWalls];
179
IsPlayerSprite(T const * const pSprite)180 template<typename T> bool IsPlayerSprite(T const * const pSprite)
181 {
182 return pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8;
183 }
184
IsDudeSprite(T const * const pSprite)185 template<typename T> bool IsDudeSprite(T const * const pSprite)
186 {
187 return pSprite->type >= kDudeBase && pSprite->type < kDudeMax;
188 }
189
IsItemSprite(T const * const pSprite)190 template<typename T> bool IsItemSprite(T const * const pSprite)
191 {
192 return pSprite->type >= kItemBase && pSprite->type < kItemMax;
193 }
194
IsWeaponSprite(T const * const pSprite)195 template<typename T> bool IsWeaponSprite(T const * const pSprite)
196 {
197 return pSprite->type >= kItemWeaponBase && pSprite->type < kItemWeaponMax;
198 }
199
IsAmmoSprite(T const * const pSprite)200 template<typename T> bool IsAmmoSprite(T const * const pSprite)
201 {
202 return pSprite->type >= kItemAmmoBase && pSprite->type < kItemAmmoMax;
203 }
204
actBurnSprite(int nSource,XSPRITE * pXSprite,int nTime)205 inline void actBurnSprite(int nSource, XSPRITE *pXSprite, int nTime)
206 {
207 pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200);
208 pXSprite->burnSource = nSource;
209 }
210
211 #ifdef POLYMER
212 void actAddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio);
213 void actDoLight(int spriteNum);
214 #endif
215
216 bool IsUnderwaterSector(int nSector);
217 int actSpriteOwnerToSpriteId(spritetype *pSprite);
218 void actPropagateSpriteOwner(spritetype *pTarget, spritetype *pSource);
219 int actSpriteIdToOwnerId(int nSprite);
220 int actOwnerIdToSpriteId(int nSprite);
221 bool actTypeInSector(int nSector, int nType);
222 void actAllocateSpares(void);
223 void actInit(bool bSaveLoad);
224 void ConcussSprite(int a1, spritetype *pSprite, int x, int y, int z, int a6);
225 int actWallBounceVector(int *x, int *y, int nWall, int a4);
226 int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5);
227 void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11, int a12, int a13);
228 void sub_2AA94(spritetype *pSprite, XSPRITE *pXSprite);
229 spritetype *actSpawnFloor(spritetype *pSprite);
230 spritetype *actDropAmmo(spritetype *pSprite, int nType);
231 spritetype *actDropWeapon(spritetype *pSprite, int nType);
232 spritetype *actDropItem(spritetype *pSprite, int nType);
233 spritetype *actDropKey(spritetype *pSprite, int nType);
234 spritetype *actDropFlag(spritetype *pSprite, int nType);
235 spritetype *actDropObject(spritetype *pSprite, int nType);
236 bool actHealDude(XSPRITE *pXDude, int a2, int a3);
237 void actKillDude(int a1, spritetype *pSprite, DAMAGE_TYPE a3, int a4);
238 int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE a3, int a4);
239 void actHitcodeToData(int a1, HITINFO *pHitInfo, int *a3, spritetype **a4, XSPRITE **a5, int *a6, walltype **a7, XWALL **a8, int *a9, sectortype **a10, XSECTOR **a11);
240 void actImpactMissile(spritetype *pMissile, int hitCode);
241 void actKickObject(spritetype *pSprite1, spritetype *pSprite2);
242 void actTouchFloor(spritetype *pSprite, int nSector);
243 void ProcessTouchObjects(spritetype *pSprite, int nXSprite);
244 void actAirDrag(spritetype *pSprite, int a2);
245 int MoveThing(spritetype *pSprite);
246 void MoveDude(spritetype *pSprite);
247 int MoveMissile(spritetype *pSprite);
248 void actExplodeSprite(spritetype *pSprite);
249 void actActivateGibObject(spritetype *pSprite, XSPRITE *pXSprite);
250 bool IsUnderWater(spritetype *pSprite);
251 void actProcessSprites(void);
252 spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6);
253 spritetype *actSpawnDude(spritetype *pSource, short nType, int a3, int a4);
254 spritetype * actSpawnSprite(spritetype *pSource, int nStat);
255 spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType);
256 spritetype * actFireThing(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6);
257 spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType);
258 int actGetRespawnTime(spritetype *pSprite);
259 bool actCheckRespawn(spritetype *pSprite);
260 bool actCanSplatWall(int nWall);
261 void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, VECTOR_TYPE vectorType);
262 void actPostSprite(int nSprite, int nStatus);
263 void actPostProcess(void);
264 void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite);
265 void actBuildMissile(spritetype* pMissile, int nXSprite, int nSprite);
266
267 extern int DudeDifficulty[];
268