00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef attackH
00029 #define attackH
00030
00031 #include "typen.h"
00032 #include "vehicletype.h"
00033 #include "vehicle.h"
00034 #include "buildings.h"
00035 #include "objects.h"
00036 #include "explosivemines.h"
00037
00038
00039
00040
00041 class AttackFormula
00042 {
00043 virtual bool checkHemming ( Vehicle* d_eht, int direc );
00044 public:
00045 float strength_experience ( int experience );
00046 float strength_damage ( int damage );
00047 float strength_attackbonus ( int abonus );
00048 float strength_hemming ( int ax, int ay, Vehicle* d_eht );
00049 float defense_experience ( int experience );
00050 float defense_defensebonus ( int defensebonus );
00051 static float getHemmingFactor ( int relDir );
00052 virtual ~AttackFormula()
00053 {}
00054 ;
00055 };
00056
00057
00058
00059 class tunitattacksobject;
00060 class tmineattacksunit;
00061 class tunitattacksbuilding;
00062 class tunitattacksunit;
00063
00064 class FightVisitor
00065 {
00066 public:
00067 virtual void visit( tunitattacksobject& battle ) = 0;
00068 virtual void visit( tmineattacksunit& battle ) = 0;
00069 virtual void visit( tunitattacksbuilding& battle ) = 0;
00070 virtual void visit( tunitattacksunit& battle ) = 0;
00071 virtual ~FightVisitor()
00072 {}
00073 ;
00074 };
00075
00076
00077 class tfight : public AttackFormula
00078 {
00079 protected:
00080 tfight ( void );
00081 int dist;
00082
00083 public:
00084 struct tavalues
00085 {
00086 tavalues() : weapontype(-1)
00087 {}
00088 ;
00089 int strength;
00090 int armor;
00091 int damage;
00092 int experience;
00093 int defensebonus;
00094 int attackbonus;
00095 float hemming;
00096 int weapnum;
00097 int weapcount;
00098 int color;
00099 int initiative;
00100 int kamikaze;
00101 int height;
00102 int weapontype;
00103 }
00104 av, dv;
00105
00107 void calc ( void ) ;
00108
00110 virtual void setresult ( void ) = 0;
00111
00112 virtual void visit ( FightVisitor& visitor ) = 0;
00113
00114 virtual int getAttackingPlayer() = 0;
00115 virtual int getDefendingPlayer() = 0;
00116
00117 };
00118
00119 class UnitAttacksSomething : public tfight
00120 {
00121 protected:
00122 Vehicle* _attackingunit;
00123 int getAttackingPlayer()
00124 {
00125 return _attackingunit->getOwner();
00126 };
00127 public:
00128 Vehicle* getAttackingUnit()
00129 {
00130 return _attackingunit;
00131 };
00132 };
00133
00134 class tunitattacksunit : public UnitAttacksSomething
00135 {
00136 Vehicle* _attackedunit;
00137
00138 Vehicle** _pattackingunit;
00139 Vehicle** _pattackedunit;
00140
00141 int _respond;
00142 bool reactionfire;
00143
00144 protected:
00145
00146 public:
00151 tunitattacksunit ( Vehicle* &attackingunit, Vehicle* &attackedunit, bool respond = true, int weapon = -1, bool reactionfire = false );
00152 void setup ( Vehicle* &attackingunit, Vehicle* &attackedunit, bool respond, int weapon );
00153 void setresult ( void );
00154
00155 void visit ( FightVisitor& visitor )
00156 {
00157 visitor.visit( *this );
00158 };
00159 Vehicle* getTarget()
00160 {
00161 return _attackedunit;
00162 };
00163
00164 int getDefendingPlayer()
00165 {
00166 return _attackedunit->getOwner();
00167 };
00168
00169 };
00170
00171 class tunitattacksbuilding : public UnitAttacksSomething
00172 {
00173 Building* _attackedbuilding;
00174 int _x, _y;
00175 public:
00176 int getAttackingPlayer()
00177 {
00178 return _attackingunit->getOwner();
00179 };
00180 int getDefendingPlayer()
00181 {
00182 return _attackedbuilding->getOwner();
00183 };
00184
00188 tunitattacksbuilding ( Vehicle* attackingunit, int x, int y, int weapon = -1);
00189 void setup ( Vehicle* attackingunit, int x, int y, int weapon );
00190 void setresult ( void );
00191
00192 void visit ( FightVisitor& visitor )
00193 {
00194 visitor.visit( *this );
00195 };
00196 Building* getTarget()
00197 {
00198 return _attackedbuilding;
00199 };
00200 };
00201
00202
00203 class tmineattacksunit : public tfight
00204 {
00205 tfield* _mineposition;
00206 Vehicle* _attackedunit;
00207 int _minenum;
00208 Vehicle** _pattackedunit;
00209
00210 public:
00211 int getAttackingPlayer()
00212 {
00213 return 8;
00214 };
00215 int getDefendingPlayer()
00216 {
00217 return _attackedunit->getOwner();
00218 };
00219
00220
00226 tmineattacksunit ( tfield* mineposition, int minenum, Vehicle* &attackedunit );
00227 void setup ( tfield* mineposition, int minenum, Vehicle* &attackedunit );
00228 void setresult ( void );
00229
00230 Mine* getFirstMine();
00231
00232 void visit ( FightVisitor& visitor )
00233 {
00234 visitor.visit( *this );
00235 };
00236
00237 Vehicle* getTarget()
00238 {
00239 return _attackedunit;
00240 };
00241 };
00242
00243 class tunitattacksobject : public UnitAttacksSomething
00244 {
00245 tfield* targetField;
00246 Object* _obji;
00247 int _x, _y;
00248
00249 public:
00250 int getAttackingPlayer()
00251 {
00252 return _attackingunit->getOwner();
00253 };
00254 int getDefendingPlayer()
00255 {
00256 return 8;
00257 };
00258
00265 tunitattacksobject ( Vehicle* attackingunit, int obj_x, int obj_y, int weapon = -1 );
00266 void setup ( Vehicle* attackingunit, int obj_x, int obj_y, int weapon );
00267 void setresult ( void );
00268 Object* getTarget()
00269 {
00270 return _obji;
00271 };
00272 void visit ( FightVisitor& visitor )
00273 {
00274 visitor.visit( *this );
00275 };
00276 };
00277
00279 class AttackWeap
00280 {
00281 public:
00282 int count;
00283 int strength[16];
00284 int num[16];
00285 int typ[16];
00286
00287 enum Target { nothing, vehicle, building, object } target;
00288 };
00289 typedef class AttackWeap* pattackweap ;
00290
00291
00292
00293
00295 extern pattackweap attackpossible( const Vehicle* attacker, int x, int y);
00296
00297
00298
00311 extern bool attackpossible2u( const Vehicle* attacker, const Vehicle* target, pattackweap attackweap = NULL, int targetheight = -1);
00312
00313
00326 extern bool attackpossible28( const Vehicle* attacker, const Vehicle* target, pattackweap attackweap = NULL, int targetHeight = -1);
00327
00328
00336 extern bool attackpossible2n( const Vehicle* attacker, const Vehicle* target, pattackweap attackweap = NULL );
00337
00339 extern bool vehicleplattfahrbar( const Vehicle* vehicle, const tfield* field );
00340
00341
00343 class WeapDist
00344 {
00345 public:
00346 static float getWeaponStrength ( const SingleWeapon* weap, int targetFieldWeather = 0, int dist =-1, int attacker_height =-1, int defender_height = -1, int reldiff = -1 );
00347 };
00348
00349
00350 #endif
00351
00352
00353