forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdroiddef.h
188 lines (150 loc) · 7.57 KB
/
droiddef.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
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2012 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** \file
* Definitions for droids.
*/
#ifndef __INCLUDED_DROIDDEF_H__
#define __INCLUDED_DROIDDEF_H__
#include <vector>
#include "lib/gamelib/animobj.h"
#include "stringdef.h"
#include "actiondef.h"
#include "basedef.h"
#include "movedef.h"
#include "orderdef.h"
#include "statsdef.h"
#include "weapondef.h"
#include "orderdef.h"
#include "actiondef.h"
/*!
* The number of components in the asParts / asBits arrays.
* Weapons are stored seperately, thus the maximum index into the array
* is 1 smaller than the number of components.
*/
#define DROID_MAXCOMP (COMP_NUMCOMPONENTS - 1)
/* The maximum number of droid weapons */
#define DROID_MAXWEAPS 3
#define DROID_DAMAGE_SCALING 400
// This should really be logarithmic
#define CALC_DROID_SMOKE_INTERVAL(x) ((((100-x)+10)/10) * DROID_DAMAGE_SCALING)
//defines how many times to perform the iteration on looking for a blank location
#define LOOK_FOR_EMPTY_TILE 20
//used to get a location next to a droid - withinh one tile
#define LOOK_NEXT_TO_DROID 8
struct COMPONENT
{
UBYTE nStat; ///< Allowing a maximum of 255 stats per file
};
typedef std::vector<DROID_ORDER_DATA> OrderList;
struct DROID_TEMPLATE : public BASE_STATS
{
DROID_TEMPLATE();
DROID_TEMPLATE(LineView line);
// On the PC the pName entry in STATS_BASE is redundant and can be assumed to be NULL,
/// on the PC this contains the full editable UTF-8 encoded name of the template
char aName[MAX_STR_LENGTH];
/*!
* The droid components.
*
* This array is indexed by COMPONENT_TYPE so the ECM would be accessed
* using asParts[COMP_ECM].
* COMP_BRAIN is an index into the asCommandDroids array NOT asBrainStats
*
* Weapons are stored in asWeaps, _not_ here at index COMP_WEAPON! (Which is the reason we do not have a COMP_NUMCOMPONENTS sized array here.)
*/
SDWORD asParts[DROID_MAXCOMP];
UDWORD buildPoints; ///< total build points required to manufacture the droid
UDWORD powerPoints; ///< total power points required to build/maintain the droid
UDWORD storeCount; ///< used to load in weaps and progs
/* The weapon systems */
UDWORD numWeaps; ///< Number of weapons
UDWORD asWeaps[DROID_MAXWEAPS]; ///< weapon indices
DROID_TYPE droidType; ///< The type of droid
UDWORD multiPlayerID; ///< multiplayer unique descriptor(cant use id's for templates). Used for save games as well now - AB 29/10/98
DROID_TEMPLATE* psNext; ///< Pointer to next template
bool prefab; ///< Not player designed, not saved, never delete or change
bool stored; ///< Stored template
bool enabled; ///< Has been enabled
};
class DROID_GROUP;
struct STRUCTURE;
struct DROID : public BASE_OBJECT
{
DROID(uint32_t id, unsigned player);
~DROID();
/// UTF-8 name of the droid. This is generated from the droid template
/// WARNING: This *can* be changed by the game player after creation & can be translated, do NOT rely on this being the same for everyone!
char aName[MAX_STR_LENGTH];
DROID_TYPE droidType; ///< The type of droid
/** Holds the specifics for the component parts - allows damage
* per part to be calculated. Indexed by COMPONENT_TYPE.
* Weapons need to be dealt with separately.
* COMP_BRAIN is an index into the asCommandDroids array NOT asBrainStats
*/
COMPONENT asBits[DROID_MAXCOMP];
/* The other droid data. These are all derived from the components
* but stored here for easy access
*/
UDWORD weight;
UDWORD baseSpeed; ///< the base speed dependant on propulsion type
UDWORD originalBody; ///< the original body points
uint32_t experience;
int lastFrustratedTime; ///< Set when eg being stuck; used for eg firing indiscriminately at map features to clear the way (note: signed, so wrap arounds after 24.9 days)
SWORD resistance; ///< used in Electronic Warfare
UDWORD numWeaps; ///< Watermelon:Re-enabled this,I need this one in droid.c
WEAPON asWeaps[DROID_MAXWEAPS];
// The group the droid belongs to
DROID_GROUP * psGroup;
DROID * psGrpNext;
STRUCTURE * psBaseStruct; ///< a structure that this droid might be associated with. For VTOLs this is the rearming pad
// queued orders
SDWORD listSize; ///< Gives the number of synchronised orders. Orders from listSize to the real end of the list may not affect game state.
OrderList asOrderList; ///< The range [0; listSize - 1] corresponds to synchronised orders, and the range [listPendingBegin; listPendingEnd - 1] corresponds to the orders that will remain, once all orders are synchronised.
unsigned listPendingBegin; ///< Index of first order which will not be erased by a pending order. After all messages are processed, the orders in the range [listPendingBegin; listPendingEnd - 1] will remain.
/* Order data */
DROID_ORDER_DATA order;
#ifdef DEBUG
// these are to help tracking down dangling pointers
char targetFunc[MAX_EVENT_NAME_LEN];
int targetLine;
char actionTargetFunc[DROID_MAXWEAPS][MAX_EVENT_NAME_LEN];
int actionTargetLine[DROID_MAXWEAPS];
char baseFunc[MAX_EVENT_NAME_LEN];
int baseLine;
#endif
// secondary order data
UDWORD secondaryOrder;
uint32_t secondaryOrderPending; ///< What the secondary order will be, after synchronisation.
int secondaryOrderPendingCount; ///< Number of pending secondary order changes.
/* Action data */
DROID_ACTION action;
Vector2i actionPos;
BASE_OBJECT* psActionTarget[DROID_MAXWEAPS]; ///< Action target object
UDWORD actionStarted; ///< Game time action started
UDWORD actionPoints; ///< number of points done by action since start
UDWORD expectedDamage; ///< Expected damage to be caused by all currently incoming projectiles. This info is shared between all players,
///< but shouldn't make a difference unless 3 mutual enemies happen to be fighting each other at the same time.
UBYTE illumination;
/* Movement control data */
MOVE_CONTROL sMove;
Spacetime prevSpacetime; ///< Location of droid in previous tick.
uint8_t blockedBits; ///< Bit set telling which tiles block this type of droid (TODO)
/* anim data */
ANIM_OBJECT *psCurAnim;
SDWORD iAudioID;
};
#endif // __INCLUDED_DROIDDEF_H__