forked from Oniryck/POSTAL-1-Open-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerUp.h
278 lines (236 loc) · 9.74 KB
/
PowerUp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 RWS Inc, All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of version 2 of the GNU General Public License 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
//
// PowerUp.H
// Project: Nostril (aka Postal)
//
// History:
// 05/08/97 JMI Started.
//
// 05/09/97 JMI Added m_smash and Init().
//
// 05/14/97 JMI Added Grab() and Drop().
// Also, made m_sprite public.
//
// 06/06/97 JMI Got rid of the whole type thing. Now uses a CStockPile
// and can contain any combination of powerups w/i one
// instance. Types are still used for loading old powerup
// files.
// Also, added GetDescription().
//
// 06/12/97 JMI Added support for new weapon members of CStockPile.
//
// 06/12/97 JMI Added sHitPointMax parameter to GetDescription().
//
// 06/14/97 JMI Changed to a descendant of CItem3d instead of CThing.
//
// 06/14/97 JMI Added KevlarVest (CStockPile::m_sArmorLayers).
//
// 06/15/97 JMI Added Backpack (CStockPile::m_sBackpack).
//
// 06/16/97 JMI Added a user (audible) feedback function, PickUpFeedback().
//
// 07/15/97 JMI Made GetDescription() and TypeToStockPile() static and
// added stockpiles as parms so they can be used more
// generically.
// Also, added RepaginateNow().
// Also, added IsEmpty().
//
// 07/15/97 JMI Added some message handling functions.
// Transferred powerup index enums into CStockPile.
//
// 07/16/97 JMI Moved IsEmpty() from powerup to stockpile.
//
// 07/23/97 JMI Added separate launcher for napalm.
//
// 08/17/97 JMI Got rid of m_szMessages and all message related functions
// and variables from CDude since we are now using the toolbar
// for dude status feedback to the user. This includes:
// MsgTypeInfo, m_lNextStatusUpdateTime, m_lMsgUpdateDoneTime,
// m_print, m_bClearedStatus, m_szMessages[], m_sDeadMsgNum,
// ms_amtfMessages[], ms_u8FontForeIndex, ms_u8FontBackIndex,
// ms_u8FontShadowIndex, DrawStatus(), StatusChange(),
// MessageChange(), Message(), UpdateFontColors(),
// CPowerUp::ms_apszPowerUpTypeNames[],
// CPowerUp::GetDescription(), and some strings and a string
// array in localize.*.
//
//////////////////////////////////////////////////////////////////////////////
//
// This CItem3d-derived class will represent power ups that the player can
// pick up.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef POWERUP_H
#define POWERUP_H
#include "RSPiX.h"
#include "realm.h"
#include "item3d.h"
#include "StockPile.h"
class CPowerUp : public CItem3d
{
//---------------------------------------------------------------------------
// Types, enums, etc.
//---------------------------------------------------------------------------
public:
//---------------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------------
public:
protected:
//---------------------------------------------------------------------------
// Static Variables
//---------------------------------------------------------------------------
public:
// Powerup anim names.
static char* ms_apszPowerUpResNames[CStockPile::NumStockPileItems + 2];
//---------------------------------------------------------------------------
// Constructor(s) / destructor
//---------------------------------------------------------------------------
public:
// Constructor
CPowerUp(CRealm* pRealm)
: CItem3d(pRealm, CPowerUpID)
{
m_panimCur = &m_anim;
m_stockpile.m_sHitPoints = 0;
m_sprite.m_pthing = this;
m_smash.m_pThing = this;
}
public:
// Destructor
~CPowerUp()
{
// Remove sprite from scene (this is safe even if it was already removed!)
m_pRealm->m_scene.RemoveSprite(&m_sprite);
// Free resources
FreeResources();
// Remove collision thinger.
m_pRealm->m_smashatorium.Remove(&m_smash);
}
//---------------------------------------------------------------------------
// Required static functions
//---------------------------------------------------------------------------
public:
// Construct object
static short Construct( // Returns 0 if successfull, non-zero otherwise
CRealm* pRealm, // In: Pointer to realm this object belongs to
CThing** ppNew) // Out: Pointer to new object
{
short sResult = 0;
*ppNew = new CPowerUp(pRealm);
if (*ppNew == 0)
{
sResult = -1;
TRACE("CPowerUp::Construct(): Couldn't construct CPowerUp (that's a bad thing)\n");
}
return sResult;
}
//---------------------------------------------------------------------------
// Optional static functions
//---------------------------------------------------------------------------
// Preload assets needed during the game
static short Preload(CRealm* prealm);
//---------------------------------------------------------------------------
// Required virtual functions (implementing them as inlines doesn't pay!)
//---------------------------------------------------------------------------
public:
// Load object (should call base class version!)
short Load( // Returns 0 if successfull, non-zero otherwise
RFile* pFile, // In: File to load from
bool bEditMode, // In: True for edit mode, false otherwise
short sFileCount, // In: File count (unique per file, never 0)
ULONG ulFileVersion); // In: Version of file format to load.
// Save object (should call base class version!)
short Save( // Returns 0 if successfull, non-zero otherwise
RFile* pFile, // In: File to save to
short sFileCount); // In: File count (unique per file, never 0)
// Update object
void Update(void);
// Render object
void Render(void);
// Called by editor to init new object at specified position
short EditNew( // Returns 0 if successfull, non-zero otherwise
short sX, // In: New x coord
short sY, // In: New y coord
short sZ); // In: New z coord
// Called by editor to modify object
short EditModify(void); // Returns 0 if successfull, non-zero otherwise
//---------------------------------------------------------------------------
// Handy external functions
//---------------------------------------------------------------------------
public:
short Setup( // Returns 0 on success.
short sX, // In: New x coord
short sY, // In: New y coord
short sZ); // In: New z coord
// Call to grab this item.
short Grab( // Returns 0 on success.
CSprite* psprParent); // In: Parent's sprite.
// Call to release this item.
void Drop( // Returns nothing.
short sX, // In: Position from which to release.
short sY, // In: Position from which to release.
short sZ); // In: Position from which to release.
// Determine if this powerup's stockpile is empty.
bool IsEmpty(void) // Returns true, if the stockpile is
// empty.
{
return m_stockpile.IsEmpty();
}
// Plays a sample corresponding to the type of powerup indicating it
// was picked up.
void PickUpFeedback(void); // Returns nothing.
// If this powerup has nothing left, destroys itself. Otherwise, chooses
// a new resource to represent its current contents.
// NOTE: This function can cause this item to be destroyed. Don't use
// a ptr to this object after calling this function.
void RepaginateNow(void);
// Message handling functions ////////////////////////////////////////////
// Handles a Shot_Message.
virtual // Override to implement additional functionality.
// Call base class to get default functionality.
void OnShotMsg( // Returns nothing.
Shot_Message* pshotmsg); // In: Message to handle.
// Handles an Explosion_Message.
virtual // Override to implement additional functionality.
// Call base class to get default functionality.
void OnExplosionMsg( // Returns nothing.
Explosion_Message* pexplosionmsg); // In: Message to handle.
// Handles a Burn_Message.
virtual // Override to implement additional functionality.
// Call base class to get default functionality.
void OnBurnMsg( // Returns nothing.
Burn_Message* pburnmsg); // In: Message to handle.
//---------------------------------------------------------------------------
// Internal functions
//---------------------------------------------------------------------------
protected:
// Get all required resources
short GetResources(void); // Returns 0 if successfull, non-zero otherwise
// Free all resources
short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
// Initialize object.
short Init(void); // Returns 0 on success.
// Get resource name for this item.
void GetResName( // Returns nothing.
char* pszResName); // Out: Resource base name.
};
#endif // POWERUP_H
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////