This repository has been archived by the owner on Sep 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
item.h
219 lines (200 loc) · 6.45 KB
/
item.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
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/item.h $
// $Revision:: 24 $
// $Author:: Aldie $
// $Date:: 3/02/99 9:16p $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/item.h $
//
// 24 3/02/99 9:16p Aldie
// Added CTF game code
//
// 23 11/08/98 10:52p Jimdose
// amountoverride wasn't archived
// made icon_index and item_index be calculated in unarchive
//
// 22 10/14/98 1:20a Jimdose
// Got cross-level persistant info working
//
// 21 9/29/98 5:59p Markd
// Added dialog_needed stuff
//
// 20 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 19 9/01/98 7:47p Aldie
// Added itemname to inventory stuff
//
// 18 8/29/98 7:23p Aldie
// Added itemname to get around targetname problem
//
// 17 7/14/98 3:55p Markd
// Got rid of pickup_sound
//
// 16 7/11/98 8:19p Jimdose
// Drop now returns true or false depending upon whether the item can be
// dropped or not
//
// 15 6/26/98 11:29a Markd
// Changed what ItemPickup returns
//
// 14 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 13 6/24/98 1:38p Aldie
// Implementation of inventory system and picking stuff up
//
// 12 6/19/98 6:38p Aldie
// Moved icon to inventory item
//
// 11 6/18/98 9:26p Aldie
// Started inventory system
//
// 10 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 9 6/16/98 4:09p Jimdose
// Added DropToFloor
//
// 8 4/04/98 6:15p Jimdose
// Defined DROPPED_ITEM and DROPPED_PLAYER_ITEM
//
// 7 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 6 3/02/98 8:49p Jimdose
// Changed CLASS_PROTOTYPE to only take the classname
//
// 5 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 3 10/27/97 2:59p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 5:30p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class for respawnable, carryable objects.
//
#ifndef __ITEM_H__
#define __ITEM_H__
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "sentient.h"
extern Event EV_Item_Pickup;
extern Event EV_Item_DropToFloor;
extern Event EV_Item_Respawn;
extern Event EV_Item_SetAmount;
extern Event EV_Item_SetMaxAmount;
extern Event EV_Item_SetIconName;
extern Event EV_Item_RespawnSound;
extern Event EV_Item_DialogNeeded;
#define DROPPED_ITEM 0x00008000
#define DROPPED_PLAYER_ITEM 0x00010000
class EXPORT_FROM_DLL Item : public Trigger
{
protected:
SentientPtr owner;
qboolean respawnable;
qboolean playrespawn;
float respawntime;
str icon_name;
str dialog_needed;
str item_name;
int icon_index;
int item_index;
int maximum_amount;
int amount;
qboolean amount_override;
void ItemTouch( Event *ev );
public:
str itemname;
CLASS_PROTOTYPE( Item );
Item::Item();
Item::~Item();
virtual void CreateSpawnArgs( void );
virtual void PlaceItem( void );
virtual void SetOwner( Sentient *ent );
virtual void DropToFloor( Event *ev );
virtual Item *ItemPickup( Entity *other );
virtual void Respawn( Event *ev );
virtual void setRespawn( qboolean flag );
virtual qboolean Respawnable( void );
virtual void setRespawnTime( float time );
virtual float RespawnTime( void );
virtual int GetIconIndex( void ) { return icon_index; };
virtual int GetItemIndex( void ) { return item_index; };
virtual int Amount( void );
virtual int MaxAmount( void );
virtual int Icon( void );
virtual qboolean Pickupable( Entity *other );
virtual void setIcon( const char *i );
virtual void setName( const char *i );
virtual void SetAmount( Event *ev );
virtual void SetMaxAmount( Event *ev );
virtual void SetIconName( Event *ev );
virtual void SetItemName( Event *ev );
virtual void Set( int startamount );
virtual void SetMax( int maxamount );
virtual void Add( int num );
virtual void Remove( int num );
virtual qboolean Use( int amount );
virtual qboolean Removable( void );
virtual void Pickup( Event *ev );
virtual qboolean Drop( void );
virtual void RespawnSound( Event *ev );
virtual void DialogNeeded( Event *ev );
virtual str GetDialogNeeded( void );
virtual void ClearOwner( void ){ owner = NULL; }
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Item::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteSafePointer( owner );
arc.WriteBoolean( respawnable );
arc.WriteBoolean( playrespawn );
arc.WriteFloat( respawntime );
arc.WriteString( icon_name );
arc.WriteString( dialog_needed );
arc.WriteString( item_name );
arc.WriteInteger( maximum_amount );
arc.WriteInteger( amount );
arc.WriteBoolean( amount_override );
arc.WriteString( itemname );
}
inline EXPORT_FROM_DLL void Item::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadSafePointer( &owner );
arc.ReadBoolean( &respawnable );
arc.ReadBoolean( &playrespawn );
arc.ReadFloat( &respawntime );
arc.ReadString( &icon_name );
icon_index = gi.imageindex( icon_name.c_str() );
arc.ReadString( &dialog_needed );
arc.ReadString( &item_name );
item_index = gi.itemindex( item_name.c_str() );
arc.ReadInteger( &maximum_amount );
arc.ReadInteger( &amount );
arc.ReadBoolean( &amount_override );
arc.ReadString( &itemname );
}
#endif /* item.h */