File: vehicletype.h

package info (click to toggle)
asc 2.1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 59,052 kB
  • ctags: 25,676
  • sloc: cpp: 145,189; sh: 8,705; ansic: 5,564; makefile: 551; perl: 150
file content (331 lines) | stat: -rw-r--r-- 11,411 bytes parent folder | download
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
/***************************************************************************
                          vehicletype.h  -  description
                             -------------------
    begin                : Fri Sep 29 2000
    copyright            : (C) 2000 by Martin Bickel
    email                : bickel@asc-hq.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef vehicletypeH
 #define vehicletypeH

 #include "typen.h"
 #include "containerbase.h"
 #include "ascstring.h"
 #include "baseaiinterface.h"
 #include "terraintype.h"
 #include "research.h"
 #include "playercolor.h"
 
/*
//! The number of 'special' vehicle functions
extern const char*  cvehiclefunctions[];
 #define cfsonar 1
 #define cfparatrooper 2
 #define cfminenleger 4
 #define cfrepair 16
 #define cf_conquer 32
 #define cf_moveafterattack 64
 #define cfsatellitenview 128
 #define cfputbuilding 256
 #define cfmineview 512
 #define cfvehicleconstruction 1024
 #define cfspecificbuildingconstruction 2048
 #define cffuelref 4096
 #define cficebreaker 8192
 #define cfnoairrefuel 16384
 #define cfmaterialref 32768
 #define cffahrspur ( 1 << 17 )
 #define cfmanualdigger ( 1 << 18 )
 #define cfno_reactionfire ( 1 << 19 )
 #define cfautorepair ( 1 << 20 )
 #define cfgenerator ( 1 << 21 )
 #define cfautodigger ( 1 << 22 )
 #define cfkamikaze ( 1 << 23 )
 #define cfmineimmune ( 1 << 24 )
 #define cfenergyref ( 1 << 25 )
 #define cfownFieldJamming ( 1 << 26 )
 #define cfmovewithRF ( 1 << 27 )
 #define cfonlytransmove ( 1 << 28 )

 #define cfvehiclefunctionsanzeige 0xFFFFFFFF
*/

#define cwaffentypennum 13
 extern const char*  cwaffentypen[cwaffentypennum] ;
 #define cwcruisemissile 0
 #define cwcruisemissileb ( 1 << cwcruisemissile )
 #define cwminen 1
 #define cwmineb ( 1 << cwminen   )
 #define cwbombn 2
 #define cwbombb ( 1 << cwbombn  )
 #define cwlargemissilen 3
 #define cwlargemissileb ( 1 << cwlargemissilen  )
 #define cwsmallmissilen 4
 #define cwsmallmissileb ( 1 << cwsmallmissilen  )
 #define cwtorpedon 5
 #define cwtorpedob ( 1 << cwtorpedon  )
 #define cwmachinegunn 6
 #define cwmachinegunb ( 1 << cwmachinegunn )
 #define cwcannonn 7
 #define cwcannonb ( 1 << cwcannonn )
 #define cwweapon ( cwcruisemissileb | cwbombb | cwlargemissileb | cwsmallmissileb | cwtorpedob | cwmachinegunb | cwcannonb | cwlaserb )
 #define cwshootablen 11
 #define cwshootableb ( 1 << cwshootablen  )
 #define cwlasern 10
 #define cwlaserb ( 1 << cwlasern  )
 #define cwammunitionn 9
 #define cwammunitionb ( 1 << cwammunitionn )
 #define cwservicen 8
 #define cwserviceb ( 1 << cwservicen )
 #define cwobjectplacementn 12
 #define cwobjectplacementb ( 1 << cwobjectplacementn )
 extern const int cwaffenproduktionskosten[cwaffentypennum][3];  /*  Angabe: Waffentyp; energy - Material - Sprit ; jeweils fuer 5er Pack */


 extern const bool weaponAmmo[cwaffentypennum];



 //! A single weapon of a #Vehicletype
 class SingleWeapon {
     int          typ;
    public:
     SingleWeapon ();
     //! the weapon can attack targets at these levels of height (bitmapped)
     int          targ;

     //! the weapon can be shot from these levels of height (bitmapped)
     int          sourceheight;

     //! the maximum distance the weapon can shoot
     int          maxdistance;

     //! the minimal distance the weapon can shoot
     int          mindistance;

     //! amount of ammunition the unit having this weapon can carry
     int          count;

     //! strength of the weapon when fired over the minimal distance
     int          maxstrength;

     //! strength of the weapon when fired over the maximum distance
     int          minstrength;

     /** the targeting accuracy of the weapon over different height differences between the attacking unit and the target.
         The levels "ground" and "floating" are assumed to be the same.
         All values are in percent.
         The index for this array is the height difference+6
         Example: low flying airplane attacking a submerged submarine:
                  height difference is -2 ; index here is 4
     */
     int          efficiency[13];

     /** the effectiveness of the weapon against different targets.
         All values are in percent. \see cmovemalitypes
     */
     int          targetingAccuracy[cmovemalitypenum];

     //! the number of shots that the laser is recharged each turn
     int          laserRechargeRate;

     //! the resources that recharging the laser for a single shot requires
     Resources    laserRechargeCost;

     int          reactionFireShots;

     ASCString    soundLabel;

     ASCString    name;

     int          getScalarWeaponType(void) const;
     bool         requiresAmmo(void) const;
     bool         shootable( void ) const;
     bool         service( void ) const;
     bool         placeObjects() const;
     bool         canRefuel ( void ) const;
     void         set ( int type );  // will be enhanced later ...
     int          gettype ( void ) const { return typ; };
     bool         offensive( void ) const;
     ASCString    getName ( void ) const;
     static ASCString   getIconFileName( int weaponType );
     void         runTextIO ( PropertyContainer& pc );
     bool         equals( const SingleWeapon* otherWeapon ) const;
 };

 //! all the weapons of a #Vehicletype
 class  UnitWeapon {
   public:
     int count;
     SingleWeapon weapon[16];
     UnitWeapon ( void );
 };

 class Player;

 //! The class describing properties that are common to all vehicles of a certain kind. \sa Vehicle
 class Vehicletype : public ContainerBaseType {
        //! the image of the unit.
        Surface  image;
    public:
        static const int legacyVehicleFunctionNum = 29;
        
        //! short description of the units role, for example "strategic bomber"
        ASCString    description;

        ASCString    getName() const;

        int armor;

        
        //! the levels of height which this unit can enter
        int          height;

        //! if a transport moves the movement for the units inside a transport is decreased by 1/n of the tranport's distance
        double     cargoMovementDivisor;

        //! If the unit cannot attack in the same turn after it has moved, it has to wait
        bool         wait;

        //! the fuel consumption to move a single field
        int          fuelConsumption;

        //! the distance a unit can travel each round. One value for each of the 8 levels of height
        vector<int>  movement;

        //! The category of the unit. Original used only to distinguish only between different movement costs for a field, this categorization is now used for many more things. \see cmovemalitypes
        int          movemalustyp;

        //! the maximum speed of the wind that the unit can survive when on open water without sinking
        int          maxwindspeedonwater;

        //! radius of the circle in which a unit can search for mineral resolures (measured in number of fields, not distance !)
        int          digrange;

        //! unused
        int          initiative;

        //! the weight of the unit, without fuel or other cargo
        int           weight;

        //! the terrain this unit can move to
        TerrainAccess terrainaccess;

        //! the image index from the GraphicSet , or -1 if no graphics from graphic sets are used.
        int           bipicture;

        //! the ids of buildings this unit can construct
        vector<IntRange> buildingsBuildable;

        //! the ids of units this unit can construct
        vector<IntRange> vehiclesBuildable;

        //! the ids of objects this unit can construct
        vector<IntRange> objectsBuildable;

        //! the ids of objects this unit can remove
        vector<IntRange> objectsRemovable;

        //! the group-ids of objects this unit can construct
        vector<IntRange> objectGroupsBuildable;

        //! the group-ids of objects this unit can remove
        vector<IntRange> objectGroupsRemovable;

        //! the IDs of objects that are automatically layed by moving the movement
        vector<IntRange> objectLayedByMovement;

        //! The weapons
        UnitWeapon   weapons;

        //! the damage this unit can repair itself automatically each turn.
        int          autorepairrate;

        //! if the unit is destroyed, it can leave an wreckage object behind ( < 0 to disable )
        vector<int> wreckageObject;

        //! some information the AI stores about this unit
        mutable AiValue* aiparam[8];

        //! the recommended task for the unit, set by the unit creater
        AiParameter::Job recommendedAIJob;

        //! returns the maximum weight of this unit without fuel and material
        int maxsize   ( void ) const ;

        //! this label can select a special sound to be played when moving
        ASCString    movementSoundLabel;

        //! this label can select a special sound to be played when this unit is killed
        ASCString    killSoundLabel;

        vector<int> guideSortHelp;

        int heightChangeMethodNum;
        class HeightChangeMethod{
            public:
              int startHeight;
              int heightDelta;
              int moveCost;
              bool canAttack;
              int dist;

              void runTextIO ( PropertyContainer& pc );
              void read ( tnstream& stream ) ;
              void write ( tnstream& stream ) const ;
        };
        vector<HeightChangeMethod> heightChangeMethod;

        int maxSpeed ( ) const;

        Vehicletype ( void );
        void read ( tnstream& stream ) ;
        void write ( tnstream& stream ) const ;
        void runTextIO ( PropertyContainer& pc );
        ~Vehicletype ( );
        Resources calcProductionsCost();

        int getMoveMalusType() const {
           return movemalustyp;
        }

        struct JumpDrive {
           JumpDrive() : height(0), maxDistance(maxint) {};
           //! bitmapped: on these levels of height the jump drive can be activated
           int height; 
           Resources consumption;
           TerrainAccess targetterrain;
           int maxDistance;
        } jumpDrive;
           
        
        
        void  paint ( Surface& s, SPoint pos, const PlayerColor& player, int direction = 0 ) const;
        void  paint ( Surface& s, SPoint pos ) const;
        const Surface&  getImage () const { return image;};
        Surface&  getImage () { return image;};
        
        int getMemoryFootprint() const;

        static BitSet convertOldFunctions( int abilities, const ASCString& location );
    private:
        void setupRemovableObjectsFromOldFileLayout();
 };


extern ASCString getUnitReference ( Vehicle* veh );

#endif