Advanced Strategic Command
vehicletype.h
Go to the documentation of this file.
1 /***************************************************************************
2  vehicletype.h - description
3  -------------------
4  begin : Fri Sep 29 2000
5  copyright : (C) 2000 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef vehicletypeH
19  #define vehicletypeH
20 
21  #include "typen.h"
22  #include "containerbase.h"
23  #include "ascstring.h"
24  #include "baseaiinterface.h"
25  #include "terraintype.h"
26  #include "research.h"
27  #include "playercolor.h"
28 
29 /*
31 extern const char* cvehiclefunctions[];
32  #define cfsonar 1
33  #define cfparatrooper 2
34  #define cfminenleger 4
35  #define cfrepair 16
36  #define cf_conquer 32
37  #define cf_moveafterattack 64
38  #define cfsatellitenview 128
39  #define cfputbuilding 256
40  #define cfmineview 512
41  #define cfvehicleconstruction 1024
42  #define cfspecificbuildingconstruction 2048
43  #define cffuelref 4096
44  #define cficebreaker 8192
45  #define cfnoairrefuel 16384
46  #define cfmaterialref 32768
47  #define cffahrspur ( 1 << 17 )
48  #define cfmanualdigger ( 1 << 18 )
49  #define cfno_reactionfire ( 1 << 19 )
50  #define cfautorepair ( 1 << 20 )
51  #define cfgenerator ( 1 << 21 )
52  #define cfautodigger ( 1 << 22 )
53  #define cfkamikaze ( 1 << 23 )
54  #define cfmineimmune ( 1 << 24 )
55  #define cfenergyref ( 1 << 25 )
56  #define cfownFieldJamming ( 1 << 26 )
57  #define cfmovewithRF ( 1 << 27 )
58  #define cfonlytransmove ( 1 << 28 )
59 
60  #define cfvehiclefunctionsanzeige 0xFFFFFFFF
61 */
62 
63 #define weaponTypeNum 13
64  extern const char* cwaffentypen[weaponTypeNum] ;
65  #define cwcruisemissilen 0
66  #define cwcruisemissileb ( 1 << cwcruisemissilen )
67  #define cwminen 1
68  #define cwmineb ( 1 << cwminen )
69  #define cwbombn 2
70  #define cwbombb ( 1 << cwbombn )
71  #define cwlargemissilen 3
72  #define cwlargemissileb ( 1 << cwlargemissilen )
73  #define cwsmallmissilen 4
74  #define cwsmallmissileb ( 1 << cwsmallmissilen )
75  #define cwtorpedon 5
76  #define cwtorpedob ( 1 << cwtorpedon )
77  #define cwmachinegunn 6
78  #define cwmachinegunb ( 1 << cwmachinegunn )
79  #define cwcannonn 7
80  #define cwcannonb ( 1 << cwcannonn )
81  #define cwweapon ( cwcruisemissileb | cwbombb | cwlargemissileb | cwsmallmissileb | cwtorpedob | cwmachinegunb | cwcannonb | cwlaserb )
82  #define cwshootablen 11
83  #define cwshootableb ( 1 << cwshootablen )
84  #define cwlasern 10
85  #define cwlaserb ( 1 << cwlasern )
86  #define cwammunitionn 9
87  #define cwammunitionb ( 1 << cwammunitionn )
88  #define cwservicen 8
89  #define cwserviceb ( 1 << cwservicen )
90  #define cwobjectplacementn 12
91  #define cwobjectplacementb ( 1 << cwobjectplacementn )
92  extern const int ammoProductionCost[weaponTypeNum][3]; /* Angabe: Waffentyp; energy - Material - Sprit ; jeweils fuer 5er Pack */
93 
94 
95  extern const bool weaponAmmo[weaponTypeNum];
96 
97 
98 
100  class SingleWeapon {
101  int typ;
102  public:
103  SingleWeapon ();
105  int targ;
106 
109 
112 
115 
117  int count;
118 
121 
124 
132  int efficiency[13];
133 
138 
141 
144 
146 
148 
150 
151  int getScalarWeaponType(void) const;
152  bool requiresAmmo(void) const;
153  bool shootable( void ) const;
154  bool service( void ) const;
155  bool placeObjects() const;
156  bool canRefuel ( void ) const;
157  void set ( int type ); // will be enhanced later ...
158  int gettype ( void ) const { return typ; };
159  bool offensive( void ) const;
160  ASCString getName ( void ) const;
161  static ASCString getIconFileName( int weaponType );
162  void runTextIO ( PropertyContainer& pc );
163  bool equals( const SingleWeapon* otherWeapon ) const;
164  };
165 
167  class UnitWeapon {
168  public:
169  int count;
171  UnitWeapon ( void );
172  };
173 
174  class Player;
175 
179  Surface image;
180 
182  ASCString imageFilename;
183 
184  ASCString unitCostCalculatorName;
185 
186  public:
187  static const int legacyVehicleFunctionNum = 29;
188 
189  ASCString getName() const;
190 
191  int armor;
192 
195 
197  bool wait;
198 
201 
203  vector<int> movement;
204 
207 
210 
212  int digrange;
213 
216 
218  int weight;
219 
222 
225 
227  vector<IntRange> buildingsBuildable;
228 
230  vector<IntRange> vehiclesBuildable;
231 
233  vector<IntRange> objectsBuildable;
234 
236  vector<IntRange> objectsRemovable;
237 
239  vector<IntRange> objectGroupsBuildable;
240 
242  vector<IntRange> objectGroupsRemovable;
243 
245  vector<IntRange> objectLayedByMovement;
246 
249 
252 
255 
260 
262  vector<int> wreckageObject;
263 
265  mutable AiValue* aiparam[8];
266 
269 
271  int maxsize ( void ) const ;
272 
275 
278 
279  vector<int> guideSortHelp;
280 
283  public:
286  int moveCost;
287  bool canAttack;
288  int dist;
289 
290  void runTextIO ( PropertyContainer& pc );
291  void read ( tnstream& stream ) ;
292  void write ( tnstream& stream ) const ;
293  };
294  vector<HeightChangeMethod> heightChangeMethod;
295 
296  int maxSpeed ( ) const;
297 
298  VehicleType ( void );
299  void read ( tnstream& stream ) ;
300  void write ( tnstream& stream ) const ;
301  void runTextIO ( PropertyContainer& pc );
302  ~VehicleType ( );
304 
305  int getMoveMalusType() const {
306  return movemalustyp;
307  }
308 
309  struct JumpDrive {
312  int height;
319  } jumpDrive;
320 
321 
322 
323  void paint ( Surface& s, SPoint pos, const PlayerColor& player, int direction = 0 ) const;
324  void paint ( Surface& s, SPoint pos ) const;
325  const Surface& getImage () const { return image;};
326  Surface& getImage () { return image;};
327 
328  int getMemoryFootprint() const;
329 
330  static BitSet convertOldFunctions( int abilities, const ASCString& location );
331  private:
332  void setupRemovableObjectsFromOldFileLayout();
333  ASCString costCalculator;
334  };
335 
336 
337 extern ASCString getUnitReference ( Vehicle* veh );
338 
339 #endif
340 
341 
342 
VehicleType(void)
Definition: vehicletype.cpp:96
const bool weaponAmmo[weaponTypeNum]
Definition: vehicletype.cpp:92
The base class for buildings and vehicles.
vector< IntRange > objectsBuildable
the ids of objects this unit can construct
Definition: vehicletype.h:233
bool wait
If the unit cannot attack in the same turn after it has moved, it has to wait.
Definition: vehicletype.h:197
struct VehicleType::JumpDrive jumpDrive
vector< int > guideSortHelp
Definition: vehicletype.h:279
ASCString getName(void) const
bool service(void) const
vector< IntRange > vehiclesBuildable
the ids of units this unit can construct
Definition: vehicletype.h:230
int maxsize(void) const
returns the maximum weight of this unit without fuel and material
void set(int type)
int initiative
unused
Definition: vehicletype.h:215
#define weaponTypeNum
Definition: vehicletype.h:63
void read(tnstream &stream)
read the binary representation of this item from the given stream
double cargoMovementDivisor
if a transport moves the movement for the units inside a transport is decreased by 1/n of the tranpor...
Definition: vehicletype.h:194
UnitWeapon weapons
The weapons.
Definition: vehicletype.h:248
vector< IntRange > objectGroupsRemovable
the group-ids of objects this unit can remove
Definition: vehicletype.h:242
int sourceheight
the weapon can be shot from these levels of height (bitmapped)
Definition: vehicletype.h:108
int efficiency[13]
the targeting accuracy of the weapon over different height differences between the attacking unit and...
Definition: vehicletype.h:132
bool shootable(void) const
int targ
the weapon can attack targets at these levels of height (bitmapped)
Definition: vehicletype.h:105
bool canRefuel(void) const
vector< IntRange > buildingsBuildable
the ids of buildings this unit can construct
Definition: vehicletype.h:227
int bipicture
the image index from the GraphicSet , or -1 if no graphics from graphic sets are used.
Definition: vehicletype.h:224
const Surface & getImage() const
Definition: vehicletype.h:325
void read(tnstream &stream)
const char * cwaffentypen[weaponTypeNum]
Definition: vehicletype.cpp:71
vector< IntRange > objectsRemovable
the ids of objects this unit can remove
Definition: vehicletype.h:236
int count
amount of ammunition the unit having this weapon can carry
Definition: vehicletype.h:117
static const int legacyVehicleFunctionNum
Definition: vehicletype.h:187
int gettype(void) const
Definition: vehicletype.h:158
Resources laserRechargeCost
the resources that recharging the laser for a single shot requires
Definition: vehicletype.h:143
SingleWeapon weapon[16]
Definition: vehicletype.h:170
ASCString getName() const
The interface for all kinds of IO stream.
TerrainAccess targetterrain
Definition: vehicletype.h:314
all the weapons of a #Vehicletype
Definition: vehicletype.h:167
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void runTextIO(PropertyContainer &pc)
vector< int > movement
the distance a unit can travel each round. One value for each of the 8 levels of height ...
Definition: vehicletype.h:203
int digrange
radius of the circle in which a unit can search for mineral resolures (measured in number of fields...
Definition: vehicletype.h:212
int getScalarWeaponType(void) const
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
int unitConstructionMinDistance
the minimal distance (measured in number of fields) in which units can be externally constructed ...
Definition: vehicletype.h:257
The value of a unit for the AI.
int mindistance
the minimal distance the weapon can shoot
Definition: vehicletype.h:114
This class is used by buildings, vehicles and objects to specify which terrain it can move to / be bu...
Definition: terraintype.h:42
void write(tnstream &stream) const
write the binary representation of this item to the given stream
int minstrength
strength of the weapon when fired over the maximum distance
Definition: vehicletype.h:123
bool placeObjects() const
static BitSet convertOldFunctions(int abilities, const ASCString &location)
int getMemoryFootprint() const
Resources calcProductionCost()
int unitConstructionMaxDistance
the maximum distance (measured in number of fields) in which units can be externally constructed ...
Definition: vehicletype.h:259
int reactionFireShots
Definition: vehicletype.h:145
ASCString getUnitReference(Vehicle *veh)
Definition: vehicle.cpp:1770
int movemalustyp
The category of the unit. Original used only to distinguish only between different movement costs for...
Definition: vehicletype.h:206
const int cmovemalitypenum
The number of vehicle categories; Each category has its own move malus.
Definition: typen.h:384
int height
bitmapped: on these levels of height the jump drive can be activated
Definition: vehicletype.h:310
bool requiresAmmo(void) const
static ASCString getIconFileName(int weaponType)
int unitConstructionMoveCostPercentage
if this unit constructs another unit externally (for example a turret), it costs this much of its mov...
Definition: vehicletype.h:254
int maxdistance
the maximum distance the weapon can shoot
Definition: vehicletype.h:111
ASCString killSoundLabel
this label can select a special sound to be played when this unit is killed
Definition: vehicletype.h:277
int getMoveMalusType() const
Definition: vehicletype.h:305
A single weapon of a #Vehicletype.
Definition: vehicletype.h:100
void runTextIO(PropertyContainer &pc)
registers the properties of this item for loading/writing into asctxt files
AiParameter::Job recommendedAIJob
the recommended task for the unit, set by the unit creater
Definition: vehicletype.h:268
int targetingAccuracy[cmovemalitypenum]
the effectiveness of the weapon against different targets.
Definition: vehicletype.h:137
int autorepairrate
the damage this unit can repair itself automatically each turn.
Definition: vehicletype.h:251
SDLmm::SPoint SPoint
Definition: surface.h:27
Some AI related classes.
int weight
the weight of the unit, without fuel or other cargo
Definition: vehicletype.h:218
UnitWeapon(void)
bool equals(const SingleWeapon *otherWeapon) const
vector< HeightChangeMethod > heightChangeMethod
Definition: vehicletype.h:294
AiValue * aiparam[8]
some information the AI stores about this unit
Definition: vehicletype.h:265
int fuelConsumption
the fuel consumption to move a single field
Definition: vehicletype.h:200
int heightChangeMethodNum
Definition: vehicletype.h:281
ASCString name
Definition: vehicletype.h:149
int maxwindspeedonwater
the maximum speed of the wind that the unit can survive when on open water without sinking ...
Definition: vehicletype.h:209
vector< IntRange > objectGroupsBuildable
the group-ids of objects this unit can construct
Definition: vehicletype.h:239
bool offensive(void) const
void paint(Surface &s, SPoint pos, const PlayerColor &player, int direction=0) const
#define maxint
Definition: typen.h:462
ASCString movementSoundLabel
this label can select a special sound to be played when moving
Definition: vehicletype.h:274
vector< IntRange > objectLayedByMovement
the IDs of objects that are automatically layed by moving the movement
Definition: vehicletype.h:245
ASCString location
The filename and location on disk (including containerfiles) of the object.
Definition: typen.h:296
int maxstrength
strength of the weapon when fired over the minimal distance
Definition: vehicletype.h:120
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99
Resources are basically the currency of ASC.
Definition: typen.h:97
Surface & getImage()
Definition: vehicletype.h:326
void runTextIO(PropertyContainer &pc)
vector< int > wreckageObject
if the unit is destroyed, it can leave an wreckage object behind ( < 0 to disable ) ...
Definition: vehicletype.h:262
void write(tnstream &stream) const
std::bitset< 64 > BitSet
Definition: basictypes.h:48
Everything related to research.
int maxSpeed() const
TerrainAccess terrainaccess
the terrain this unit can move to
Definition: vehicletype.h:221
ASCString soundLabel
Definition: vehicletype.h:147
const int ammoProductionCost[weaponTypeNum][3]
Definition: vehicletype.cpp:75
int laserRechargeRate
the number of shots that the laser is recharged each turn
Definition: vehicletype.h:140