1 #pragma once 2 3 // XXX 4 #include "game/Tactical/Weapons.h" 5 6 #include "ItemModel.h" 7 8 #include <string_theory/string> 9 10 #include <map> 11 #include <stdint.h> 12 13 class JsonObject; 14 class JsonObjectReader; 15 enum SoundID; 16 struct CalibreModel; 17 struct MagazineModel; 18 19 #define NO_WEAPON_SOUND ((SoundID)-1) 20 #define NO_WEAPON_SOUND_STR ("") 21 22 #define WEAPON_TYPE_NOWEAPON ("NOWEAPON") 23 #define WEAPON_TYPE_PUNCH ("PUNCH") 24 #define WEAPON_TYPE_THROWN ("THROWN") 25 26 struct WeaponModel : ItemModel 27 { 28 WeaponModel(uint32_t itemClass, 29 uint8_t weaponType, 30 uint8_t cursor, 31 uint16_t itemIndex, 32 ST::string internalName, 33 ST::string internalType); 34 35 virtual void serializeTo(JsonObject &obj) const; 36 37 static WeaponModel* deserialize(JsonObjectReader &obj, 38 const std::map<ST::string, const CalibreModel*> &calibreMap); 39 asWeaponWeaponModel40 virtual const WeaponModel* asWeapon() const { return this; } 41 42 bool matches(const CalibreModel *calibre) const; 43 bool matches(const MagazineModel *mag) const; 44 bool isSameMagCapacity(const MagazineModel *mag) const; 45 46 bool hasSound() const; 47 bool hasBurstSound() const; 48 49 /** Check if the given attachment can be attached to the item. */ 50 virtual bool canBeAttached(uint16_t attachment) const; 51 52 /** Get standard replacement gun name. */ 53 virtual const ST::string & getStandardReplacement() const; 54 55 int getRateOfFire() const; 56 57 ST::string sound; 58 ST::string burstSound; 59 ST::string standardReplacement; 60 bool attachSilencer; 61 bool attachSniperScope; 62 bool attachLaserScope; 63 bool attachBipod; 64 bool attachDuckbill; 65 bool attachUnderGLauncher; 66 bool attachSpringAndBoltUpgrade; 67 bool attachGunBarrelExtender; 68 int m_rateOfFire; 69 70 ST::string internalType; 71 UINT8 ubWeaponClass; // handgun/shotgun/rifle/knife 72 UINT8 ubWeaponType; // exact type (for display purposes) 73 const CalibreModel *calibre; // type of ammunition needed 74 UINT8 ubReadyTime; // APs to ready/unready weapon 75 UINT8 ubShotsPer4Turns; // maximum (mechanical) firing rate 76 UINT8 ubShotsPerBurst; 77 UINT8 ubBurstPenalty; // % penalty per shot after first 78 UINT8 ubBulletSpeed; // bullet's travelling speed 79 UINT8 ubImpact; // weapon's max damage impact (size & speed) 80 UINT8 ubDeadliness; // comparative ratings of guns 81 UINT8 ubMagSize; 82 UINT16 usRange; 83 UINT16 usReloadDelay; 84 UINT8 ubAttackVolume; 85 UINT8 ubHitVolume; 86 SoundID sReloadSound; 87 SoundID sLocknLoadSound; 88 UINT16 usSmokeEffect; // item index of the smoke effect on ammo miss 89 90 protected: 91 void serializeAttachments(JsonObject &obj) const; 92 }; 93 94 struct NoWeapon : WeaponModel 95 { 96 NoWeapon(uint16_t indexIndex, const ST::string& internalName); 97 98 NoWeapon(uint16_t itemIndex, const ST::string& internalName, uint32_t itemClass, uint8_t cursor); 99 100 virtual void serializeTo(JsonObject &obj) const; 101 }; 102 103 struct Pistol : WeaponModel 104 { 105 Pistol(uint16_t indexIndex, ST::string internalName, 106 const CalibreModel *calibre, 107 uint8_t BulletSpeed, 108 uint8_t Impact, 109 uint8_t ReadyTime, 110 uint8_t ShotsPer4Turns, 111 uint8_t Deadliness, 112 uint8_t MagSize, 113 uint16_t Range, 114 uint8_t AttackVolume, 115 uint8_t HitVolume, 116 ST::string Sound); 117 118 void serializeTo(JsonObject &obj) const override; 119 }; 120 121 122 123 struct MPistol : WeaponModel 124 { 125 MPistol(uint16_t indexIndex, ST::string internalName, 126 const CalibreModel *calibre, 127 uint8_t BulletSpeed, 128 uint8_t Impact, 129 uint8_t ReadyTime, 130 uint8_t ShotsPer4Turns, 131 uint8_t ShotsPerBurst, 132 uint8_t BurstPenalty, 133 uint8_t Deadliness, 134 uint8_t MagSize, 135 uint16_t Range, 136 uint8_t AttackVolume, 137 uint8_t HitVolume, 138 ST::string Sound, 139 ST::string BurstSound); 140 141 void serializeTo(JsonObject &obj) const override; 142 }; 143 144 145 146 struct SMG : WeaponModel 147 { 148 SMG(uint16_t indexIndex, ST::string internalName, 149 const CalibreModel *calibre, 150 uint8_t BulletSpeed, 151 uint8_t Impact, 152 uint8_t ReadyTime, 153 uint8_t ShotsPer4Turns, 154 uint8_t ShotsPerBurst, 155 uint8_t BurstPenalty, 156 uint8_t Deadliness, 157 uint8_t MagSize, 158 uint16_t Range, 159 uint8_t AttackVolume, 160 uint8_t HitVolume, 161 ST::string Sound, 162 ST::string BurstSound); 163 164 void serializeTo(JsonObject &obj) const override; 165 }; 166 167 168 struct SniperRifle : WeaponModel 169 { 170 SniperRifle(uint16_t indexIndex, ST::string internalName, 171 const CalibreModel *calibre, 172 uint8_t BulletSpeed, 173 uint8_t Impact, 174 uint8_t ReadyTime, 175 uint8_t ShotsPer4Turns, 176 uint8_t Deadliness, 177 uint8_t MagSize, 178 uint16_t Range, 179 uint8_t AttackVolume, 180 uint8_t HitVolume, 181 ST::string Sound); 182 183 void serializeTo(JsonObject &obj) const override; 184 }; 185 186 187 struct Rifle : WeaponModel 188 { 189 Rifle(uint16_t indexIndex, ST::string internalName, 190 const CalibreModel *calibre, 191 uint8_t BulletSpeed, 192 uint8_t Impact, 193 uint8_t ReadyTime, 194 uint8_t ShotsPer4Turns, 195 uint8_t Deadliness, 196 uint8_t MagSize, 197 uint16_t Range, 198 uint8_t AttackVolume, 199 uint8_t HitVolume, 200 ST::string Sound); 201 202 void serializeTo(JsonObject &obj) const override; 203 }; 204 205 206 struct AssaultRifle : WeaponModel 207 { 208 AssaultRifle(uint16_t indexIndex, ST::string internalName, 209 const CalibreModel *calibre, 210 uint8_t BulletSpeed, 211 uint8_t Impact, 212 uint8_t ReadyTime, 213 uint8_t ShotsPer4Turns, 214 uint8_t ShotsPerBurst, 215 uint8_t BurstPenalty, 216 uint8_t Deadliness, 217 uint8_t MagSize, 218 uint16_t Range, 219 uint8_t AttackVolume, 220 uint8_t HitVolume, 221 ST::string Sound, 222 ST::string BurstSound); 223 224 void serializeTo(JsonObject &obj) const override; 225 }; 226 227 228 struct Shotgun : WeaponModel 229 { 230 Shotgun(uint16_t indexIndex, ST::string internalName, 231 const CalibreModel *calibre, 232 uint8_t BulletSpeed, 233 uint8_t Impact, 234 uint8_t ReadyTime, 235 uint8_t ShotsPer4Turns, 236 uint8_t ShotsPerBurst, 237 uint8_t BurstPenalty, 238 uint8_t Deadliness, 239 uint8_t MagSize, 240 uint16_t Range, 241 uint8_t AttackVolume, 242 uint8_t HitVolume, 243 ST::string Sound, 244 ST::string BurstSound); 245 246 void serializeTo(JsonObject &obj) const override; 247 }; 248 249 250 struct LMG : WeaponModel 251 { 252 LMG(uint16_t indexIndex, ST::string internalName, 253 const CalibreModel *calibre, 254 uint8_t BulletSpeed, 255 uint8_t Impact, 256 uint8_t ReadyTime, 257 uint8_t ShotsPer4Turns, 258 uint8_t ShotsPerBurst, 259 uint8_t BurstPenalty, 260 uint8_t Deadliness, 261 uint8_t MagSize, 262 uint16_t Range, 263 uint8_t AttackVolume, 264 uint8_t HitVolume, 265 ST::string Sound, 266 ST::string BurstSound); 267 268 void serializeTo(JsonObject &obj) const override; 269 }; 270 271 272 struct Blade : WeaponModel 273 { 274 Blade(uint16_t indexIndex, 275 ST::string internalName, 276 uint8_t Impact, 277 uint8_t ShotsPer4Turns, 278 uint8_t Deadliness, 279 uint16_t Range, 280 uint8_t AttackVolume, 281 ST::string Sound); 282 283 void serializeTo(JsonObject &obj) const override; 284 }; 285 286 287 struct ThrowingBlade : WeaponModel 288 { 289 ThrowingBlade(uint16_t indexIndex, ST::string internalName, 290 uint8_t Impact, 291 uint8_t ShotsPer4Turns, 292 uint8_t Deadliness, 293 uint16_t Range, 294 uint8_t AttackVolume, 295 ST::string Sound); 296 297 void serializeTo(JsonObject &obj) const override; 298 }; 299 300 301 struct PunchWeapon : WeaponModel 302 { 303 PunchWeapon(uint16_t indexIndex, ST::string internalName, 304 uint8_t Impact, 305 uint8_t ShotsPer4Turns, 306 uint8_t Deadliness, 307 uint8_t AttackVolume, 308 ST::string Sound); 309 310 void serializeTo(JsonObject &obj) const override; 311 }; 312 313 314 struct Launcher : WeaponModel 315 { 316 Launcher(uint16_t indexIndex, ST::string internalName, 317 uint8_t BulletSpeed, 318 uint8_t ReadyTime, 319 uint8_t ShotsPer4Turns, 320 uint8_t Deadliness, 321 uint16_t Range, 322 uint8_t AttackVolume, 323 uint8_t HitVolume, 324 ST::string Sound); 325 326 void serializeTo(JsonObject &obj) const override; 327 }; 328 329 330 struct LAW : WeaponModel 331 { 332 LAW(uint16_t indexIndex, ST::string internalName, 333 uint8_t BulletSpeed, 334 uint8_t ReadyTime, 335 uint8_t ShotsPer4Turns, 336 uint8_t Deadliness, 337 uint16_t Range, 338 uint8_t AttackVolume, 339 uint8_t HitVolume, 340 ST::string Sound); 341 342 void serializeTo(JsonObject &obj) const override; 343 }; 344 345 346 struct Cannon : WeaponModel 347 { 348 Cannon(uint16_t indexIndex, ST::string internalName, 349 uint8_t BulletSpeed, 350 uint8_t ReadyTime, 351 uint8_t ShotsPer4Turns, 352 uint8_t Deadliness, 353 uint16_t Range, 354 uint8_t AttackVolume, 355 uint8_t HitVolume, 356 ST::string Sound); 357 358 void serializeTo(JsonObject &obj) const override; 359 }; 360 361 362 struct MonsterSpit : WeaponModel 363 { 364 MonsterSpit(uint16_t indexIndex, ST::string internalName, 365 const CalibreModel *calibre, 366 uint8_t Impact, 367 uint8_t ShotsPer4Turns, 368 uint8_t Deadliness, 369 uint8_t MagSize, 370 uint16_t Range, 371 uint8_t AttackVolume, 372 uint8_t HitVolume, 373 ST::string Sound, 374 uint16_t smokeEffect); 375 376 void serializeTo(JsonObject &obj) const override; 377 }; 378