1 #include "WeaponModels.h"
2 #include "CalibreModel.h"
3 #include "Items.h"
4 #include "JsonObject.h"
5 #include "Logger.h"
6 #include "MagazineModel.h"
7 #include "Points.h"
8 #include "Sound_Control.h"
9 #include <utility>
10 
11 // exact gun types
12 // used as an index in WeaponType[] string array
13 enum
14 {
15 	NOT_GUN = 0,
16 	GUN_PISTOL,
17 	GUN_M_PISTOL,
18 	GUN_SMG,
19 	GUN_RIFLE,
20 	GUN_SN_RIFLE,
21 	GUN_AS_RIFLE,
22 	GUN_LMG,
23 	GUN_SHOTGUN
24 };
25 
WeaponModel(uint32_t itemClass,uint8_t weaponType,uint8_t cursor,uint16_t itemIndex,ST::string internalName_,ST::string internalType_)26 WeaponModel::WeaponModel(uint32_t itemClass, uint8_t weaponType, uint8_t cursor, uint16_t itemIndex, ST::string internalName_, ST::string internalType_)
27 	:ItemModel(itemIndex, std::move(internalName_), itemClass, itemIndex, (ItemCursor)cursor),
28 	sound(NO_WEAPON_SOUND_STR),
29 	burstSound(NO_WEAPON_SOUND_STR),
30 	attachSilencer(false),
31 	attachSniperScope(false),
32 	attachLaserScope(false),
33 	attachBipod(false),
34 	attachDuckbill(false),
35 	attachUnderGLauncher(false),
36 	attachSpringAndBoltUpgrade(false),
37 	attachGunBarrelExtender(false),
38 	m_rateOfFire(0)
39 {
40 	internalType         = std::move(internalType_);
41 	ubWeaponType         = weaponType;
42 	ubWeaponClass        = NOGUNCLASS;
43 	calibre              = CalibreModel::getNoCalibreObject();
44 	ubReadyTime          = 0;
45 	ubShotsPer4Turns     = 0;
46 	ubShotsPerBurst      = 0;
47 	ubBurstPenalty       = 0;
48 	ubBulletSpeed        = 0;
49 	ubImpact             = 0;
50 	ubDeadliness         = 0;
51 	ubMagSize            = 0;
52 	usRange              = 0;
53 	usReloadDelay        = 0;
54 	ubAttackVolume       = 0;
55 	ubHitVolume          = 0;
56 	sReloadSound         = NO_WEAPON_SOUND;
57 	sLocknLoadSound      = NO_WEAPON_SOUND;
58 	usSmokeEffect        = NONE;
59 }
60 
serializeTo(JsonObject & obj) const61 void WeaponModel::serializeTo(JsonObject &obj) const
62 {
63 	obj.AddMember("itemIndex",            itemIndex);
64 	obj.AddMember("internalName",         internalName);
65 	obj.AddMember("internalType",         internalType);
66 
67 	obj.AddMember("ubGraphicType", getGraphicType());
68 	obj.AddMember("ubGraphicNum", getGraphicNum());
69 	obj.AddMember("ubWeight", getWeight());
70 	obj.AddMember("ubPerPocket", getPerPocket());
71 	obj.AddMember("usPrice", getPrice());
72 	obj.AddMember("ubCoolness", getCoolness());
73 	obj.AddMember("bReliability", getReliability());
74 	obj.AddMember("bRepairEase", getRepairEase());
75 	obj.AddMember("rateOfFire", m_rateOfFire);
76 
77 	if(isInBigGunList())
78 	{
79 		obj.AddMember("standardReplacement", standardReplacement);
80 	}
81 }
82 
serializeAttachments(JsonObject & obj) const83 void WeaponModel::serializeAttachments(JsonObject &obj) const
84 {
85 	obj.addOptionalBool("attachment_Silencer",                 attachSilencer);
86 	obj.addOptionalBool("attachment_SniperScope",              attachSniperScope);
87 	obj.addOptionalBool("attachment_LaserScope",               attachLaserScope);
88 	obj.addOptionalBool("attachment_Bipod",                    attachBipod);
89 	obj.addOptionalBool("attachment_Duckbill",                 attachDuckbill);
90 	obj.addOptionalBool("attachment_UnderGLauncher",           attachUnderGLauncher);
91 	obj.addOptionalBool("attachment_SpringAndBoltUpgrade",     attachSpringAndBoltUpgrade);
92 	obj.addOptionalBool("attachment_GunBarrelExtender",        attachGunBarrelExtender);
93 }
94 
deserialize(JsonObjectReader & obj,const std::map<ST::string,const CalibreModel * > & calibreMap)95 WeaponModel* WeaponModel::deserialize(JsonObjectReader &obj,
96 					const std::map<ST::string, const CalibreModel*> &calibreMap)
97 {
98 	WeaponModel *wep = NULL;
99 	int itemIndex = obj.GetInt("itemIndex");
100 	ST::string internalName = obj.GetString("internalName");
101 	ST::string internalType = obj.GetString("internalType");
102 
103 	if (internalType == WEAPON_TYPE_NOWEAPON)
104 	{
105 		wep = new NoWeapon(itemIndex, internalName);
106 	}
107 	else if (internalType == WEAPON_TYPE_PUNCH)
108 	{
109 		wep = new NoWeapon(itemIndex, internalName, IC_PUNCH, PUNCHCURS);
110 	}
111 	else if (internalType == WEAPON_TYPE_THROWN)
112 	{
113 		wep = new NoWeapon(itemIndex, internalName, IC_THROWN, TOSSCURS);
114 	}
115 	else if (internalType == "PISTOL")
116 	{
117 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
118 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
119 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
120 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
121 		uint8_t  Impact          = obj.GetInt("ubImpact");
122 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
123 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
124 		uint16_t Range           = obj.GetInt("usRange");
125 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
126 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
127 		ST::string Sound       = obj.GetString("Sound");
128 		wep = new Pistol(itemIndex, internalName,
129 					calibre,
130 					BulletSpeed,
131 					Impact,
132 					ReadyTime,
133 					ShotsPer4Turns,
134 					Deadliness,
135 					MagSize,
136 					Range,
137 					AttackVolume,
138 					HitVolume,
139 					Sound);
140 	}
141 	else if (internalType == "M_PISTOL")
142 	{
143 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
144 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
145 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
146 		uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
147 		uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
148 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
149 		uint8_t  Impact          = obj.GetInt("ubImpact");
150 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
151 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
152 		uint16_t Range           = obj.GetInt("usRange");
153 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
154 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
155 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
156 		ST::string Sound         = obj.GetString("Sound");
157 		ST::string BurstSound    = obj.GetString("BurstSound");
158 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
159 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
160 		wep = new MPistol(itemIndex, internalName,
161 					calibre,
162 					BulletSpeed,
163 					Impact,
164 					ReadyTime,
165 					ShotsPer4Turns,
166 					ShotsPerBurst,
167 					BurstPenalty,
168 					Deadliness,
169 					MagSize,
170 					Range,
171 					AttackVolume,
172 					HitVolume,
173 					Sound,
174 					BurstSound);
175 	}
176 	else if (internalType == "SMG")
177 	{
178 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
179 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
180 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
181 		uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
182 		uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
183 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
184 		uint8_t  Impact          = obj.GetInt("ubImpact");
185 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
186 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
187 		uint16_t Range           = obj.GetInt("usRange");
188 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
189 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
190 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
191 		ST::string Sound         = obj.GetString("Sound");
192 		ST::string BurstSound    = obj.GetString("BurstSound");
193 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
194 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
195 		wep = new SMG(itemIndex, internalName,
196 				calibre,
197 				BulletSpeed,
198 				Impact,
199 				ReadyTime,
200 				ShotsPer4Turns,
201 				ShotsPerBurst,
202 				BurstPenalty,
203 				Deadliness,
204 				MagSize,
205 				Range,
206 				AttackVolume,
207 				HitVolume,
208 				Sound,
209 				BurstSound);
210 	}
211 	else if (internalType == "SN_RIFLE")
212 	{
213 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
214 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
215 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
216 		// uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
217 		// uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
218 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
219 		uint8_t  Impact          = obj.GetInt("ubImpact");
220 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
221 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
222 		uint16_t Range           = obj.GetInt("usRange");
223 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
224 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
225 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
226 		ST::string Sound       = obj.GetString("Sound");
227 		// ST::string BurstSound  = obj.GetString("BurstSound");
228 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
229 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
230 		wep = new SniperRifle(itemIndex, internalName,
231 					calibre,
232 					BulletSpeed,
233 					Impact,
234 					ReadyTime,
235 					ShotsPer4Turns,
236 					Deadliness,
237 					MagSize,
238 					Range,
239 					AttackVolume,
240 					HitVolume,
241 					Sound);
242 	}
243 	else if(internalType == "RIFLE")
244 	{
245 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
246 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
247 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
248 		// uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
249 		// uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
250 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
251 		uint8_t  Impact          = obj.GetInt("ubImpact");
252 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
253 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
254 		uint16_t Range           = obj.GetInt("usRange");
255 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
256 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
257 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
258 		ST::string Sound       = obj.GetString("Sound");
259 		// ST::string BurstSound  = obj.GetString("BurstSound");
260 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
261 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
262 		wep = new Rifle(itemIndex, internalName,
263 				calibre,
264 				BulletSpeed,
265 				Impact,
266 				ReadyTime,
267 				ShotsPer4Turns,
268 				Deadliness,
269 				MagSize,
270 				Range,
271 				AttackVolume,
272 				HitVolume,
273 				Sound);
274 	}
275 	else if (internalType == "ASRIFLE")
276 	{
277 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
278 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
279 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
280 		uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
281 		uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
282 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
283 		uint8_t  Impact          = obj.GetInt("ubImpact");
284 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
285 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
286 		uint16_t Range           = obj.GetInt("usRange");
287 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
288 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
289 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
290 		ST::string Sound       = obj.GetString("Sound");
291 		ST::string BurstSound  = obj.GetString("BurstSound");
292 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
293 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
294 		wep = new AssaultRifle(itemIndex, internalName,
295 					calibre,
296 					BulletSpeed,
297 					Impact,
298 					ReadyTime,
299 					ShotsPer4Turns,
300 					ShotsPerBurst,
301 					BurstPenalty,
302 					Deadliness,
303 					MagSize,
304 					Range,
305 					AttackVolume,
306 					HitVolume,
307 					Sound,
308 					BurstSound);
309 	}
310 	else if (internalType == "SHOTGUN")
311 	{
312 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
313 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
314 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
315 		uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
316 		uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
317 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
318 		uint8_t  Impact          = obj.GetInt("ubImpact");
319 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
320 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
321 		uint16_t Range           = obj.GetInt("usRange");
322 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
323 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
324 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
325 		ST::string Sound         = obj.GetString("Sound");
326 		ST::string BurstSound    = obj.GetString("BurstSound");
327 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
328 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
329 		wep = new Shotgun(itemIndex, internalName,
330 					calibre,
331 					BulletSpeed,
332 					Impact,
333 					ReadyTime,
334 					ShotsPer4Turns,
335 					ShotsPerBurst,
336 					BurstPenalty,
337 					Deadliness,
338 					MagSize,
339 					Range,
340 					AttackVolume,
341 					HitVolume,
342 					Sound,
343 					BurstSound);
344 	}
345 	else if (internalType == "LMG")
346 	{
347 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
348 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
349 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
350 		uint8_t  ShotsPerBurst   = obj.GetInt("ubShotsPerBurst");
351 		uint8_t  BurstPenalty    = obj.GetInt("ubBurstPenalty");
352 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
353 		uint8_t  Impact          = obj.GetInt("ubImpact");
354 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
355 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
356 		uint16_t Range           = obj.GetInt("usRange");
357 		// uint16_t ReloadDelay     = obj.GetInt("usReloadDelay");
358 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
359 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
360 		ST::string Sound       = obj.GetString("Sound");
361 		ST::string BurstSound  = obj.GetString("BurstSound");
362 		// SoundID  ReloadSound     = (SoundID) obj.GetInt("sReloadSound");
363 		// SoundID  LocknLoadSound  = (SoundID) obj.GetInt("sLocknLoadSound");
364 		wep = new LMG(itemIndex, internalName,
365 				calibre,
366 				BulletSpeed,
367 				Impact,
368 				ReadyTime,
369 				ShotsPer4Turns,
370 				ShotsPerBurst,
371 				BurstPenalty,
372 				Deadliness,
373 				MagSize,
374 				Range,
375 				AttackVolume,
376 				HitVolume,
377 				Sound,
378 				BurstSound);
379 	}
380 	else if (internalType == "BLADE")
381 	{
382 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
383 		uint8_t  Impact          = obj.GetInt("ubImpact");
384 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
385 		uint16_t Range           = obj.GetInt("usRange");
386 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
387 		ST::string Sound       = obj.GetString("Sound");
388 		wep = new Blade(itemIndex, internalName,
389 				Impact,
390 				ShotsPer4Turns,
391 				Deadliness,
392 				Range,
393 				AttackVolume,
394 				Sound);
395 	}
396 	else if (internalType == "THROWINGBLADE")
397 	{
398 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
399 		uint8_t  Impact          = obj.GetInt("ubImpact");
400 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
401 		uint16_t Range           = obj.GetInt("usRange");
402 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
403 		ST::string Sound         = obj.GetString("Sound");
404 		wep = new ThrowingBlade(itemIndex, internalName,
405 					Impact,
406 					ShotsPer4Turns,
407 					Deadliness,
408 					Range,
409 					AttackVolume,
410 					Sound);
411 	}
412 	else if (internalType == "PUNCHWEAPON")
413 	{
414 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
415 		uint8_t  Impact          = obj.GetInt("ubImpact");
416 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
417 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
418 		ST::string Sound         = obj.GetString("Sound");
419 		wep = new PunchWeapon(itemIndex, internalName,
420 					Impact,
421 					ShotsPer4Turns,
422 					Deadliness,
423 					AttackVolume,
424 					Sound);
425 	}
426 	else if (internalType == "LAUNCHER")
427 	{
428 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
429 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
430 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
431 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
432 		uint16_t Range           = obj.GetInt("usRange");
433 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
434 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
435 		ST::string Sound         = obj.GetString("Sound");
436 		wep = new Launcher(itemIndex, internalName,
437 					BulletSpeed,
438 					ReadyTime,
439 					ShotsPer4Turns,
440 					Deadliness,
441 					Range,
442 					AttackVolume,
443 					HitVolume,
444 					Sound);
445 	}
446 	else if (internalType == "LAW")
447 	{
448 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
449 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
450 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
451 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
452 		uint16_t Range           = obj.GetInt("usRange");
453 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
454 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
455 		ST::string Sound       = obj.GetString("Sound");
456 		wep = new LAW(itemIndex, internalName,
457 				BulletSpeed,
458 				ReadyTime,
459 				ShotsPer4Turns,
460 				Deadliness,
461 				Range,
462 				AttackVolume,
463 				HitVolume,
464 				Sound);
465 	}
466 	else if (internalType == "CANNON")
467 	{
468 		uint8_t  ReadyTime       = obj.GetInt("ubReadyTime");
469 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
470 		uint8_t  BulletSpeed     = obj.GetInt("ubBulletSpeed");
471 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
472 		uint16_t Range           = obj.GetInt("usRange");
473 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
474 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
475 		ST::string Sound       = obj.GetString("Sound");
476 		wep = new Cannon(itemIndex, internalName,
477 					BulletSpeed,
478 					ReadyTime,
479 					ShotsPer4Turns,
480 					Deadliness,
481 					Range,
482 					AttackVolume,
483 					HitVolume,
484 					Sound);
485 	}
486 	else if (internalType == "MONSTSPIT")
487 	{
488 		const CalibreModel *calibre = getCalibre(obj.GetString("calibre"), calibreMap);
489 		uint8_t  ShotsPer4Turns  = obj.GetInt("ubShotsPer4Turns");
490 		uint8_t  Impact          = obj.GetInt("ubImpact");
491 		uint8_t  Deadliness      = obj.GetInt("ubDeadliness");
492 		uint8_t  MagSize         = obj.GetInt("ubMagSize");
493 		uint16_t Range           = obj.GetInt("usRange");
494 		uint8_t  AttackVolume    = obj.GetInt("ubAttackVolume");
495 		uint8_t  HitVolume       = obj.GetInt("ubHitVolume");
496 		ST::string Sound         = obj.GetString("Sound");
497 		uint16_t smokeEffect     = obj.GetInt("usSmokeEffect");
498 		wep = new MonsterSpit(itemIndex, internalName,
499 					calibre,
500 					Impact,
501 					ShotsPer4Turns,
502 					Deadliness,
503 					MagSize,
504 					Range,
505 					AttackVolume,
506 					HitVolume,
507 					Sound,
508 					smokeEffect);
509 	}
510 
511 	if(!wep)
512 	{
513 		STLOGE("Weapon type '{}' is not found", internalType);
514 		return wep;
515 	}
516 
517 	wep->ubGraphicType    = obj.GetInt("ubGraphicType");
518 	wep->ubGraphicNum     = obj.GetInt("ubGraphicNum");
519 	wep->ubWeight         = obj.GetInt("ubWeight");
520 	wep->ubPerPocket      = obj.GetInt("ubPerPocket");
521 	wep->usPrice          = obj.GetInt("usPrice");
522 	wep->ubCoolness       = obj.GetInt("ubCoolness");
523 	wep->bReliability     = obj.GetInt("bReliability");
524 	wep->bRepairEase      = obj.GetInt("bRepairEase");
525 	wep->m_rateOfFire     = obj.GetInt("rateOfFire");
526 
527 	wep->attachSilencer               = obj.getOptionalBool("attachment_Silencer");
528 	wep->attachSniperScope            = obj.getOptionalBool("attachment_SniperScope");
529 	wep->attachLaserScope             = obj.getOptionalBool("attachment_LaserScope");
530 	wep->attachBipod                  = obj.getOptionalBool("attachment_Bipod");
531 	wep->attachDuckbill               = obj.getOptionalBool("attachment_Duckbill");
532 	wep->attachUnderGLauncher         = obj.getOptionalBool("attachment_UnderGLauncher");
533 	wep->attachSpringAndBoltUpgrade   = obj.getOptionalBool("attachment_SpringAndBoltUpgrade");
534 	wep->attachGunBarrelExtender      = obj.getOptionalBool("attachment_GunBarrelExtender");
535 
536 	wep->fFlags |= wep->deserializeFlags(obj);
537 
538 	ST::string replacement = obj.getOptionalString("standardReplacement");
539 	if (!replacement.empty())
540 	{
541 		wep->standardReplacement = replacement;
542 	}
543 
544 	return wep;
545 }
546 
547 
matches(const CalibreModel * calibre) const548 bool WeaponModel::matches(const CalibreModel *calibre) const
549 {
550 	return this->calibre->index == calibre->index;
551 }
552 
matches(const MagazineModel * mag) const553 bool WeaponModel::matches(const MagazineModel *mag) const
554 {
555 	return (this->calibre->index == mag->calibre->index)
556 		&& (ubMagSize == mag->capacity);
557 }
558 
isSameMagCapacity(const MagazineModel * mag) const559 bool WeaponModel::isSameMagCapacity(const MagazineModel *mag) const
560 {
561 	return ubMagSize == mag->capacity;
562 }
563 
hasSound() const564 bool WeaponModel::hasSound() const
565 {
566 	return sound.compare(NO_WEAPON_SOUND_STR) != 0;
567 }
568 
hasBurstSound() const569 bool WeaponModel::hasBurstSound() const
570 {
571 	return burstSound.compare(NO_WEAPON_SOUND_STR) != 0;
572 }
573 
574 /** Check if the given attachment can be attached to the item. */
canBeAttached(uint16_t attachment) const575 bool WeaponModel::canBeAttached(uint16_t attachment) const
576 {
577 	return (attachSilencer && (attachment == SILENCER))
578 		|| (attachSniperScope && (attachment == SNIPERSCOPE))
579 		|| (attachLaserScope && (attachment == LASERSCOPE))
580 		|| (attachBipod && (attachment == BIPOD))
581 		|| (attachDuckbill && (attachment == DUCKBILL))
582 		|| (attachUnderGLauncher && (attachment == UNDER_GLAUNCHER))
583 		|| (attachSpringAndBoltUpgrade && (attachment == SPRING_AND_BOLT_UPGRADE))
584 		|| (attachGunBarrelExtender && (attachment == GUN_BARREL_EXTENDER));
585 }
586 
587 /** Get standard replacement gun name. */
getStandardReplacement() const588 const ST::string & WeaponModel::getStandardReplacement() const
589 {
590 	return standardReplacement;
591 }
592 
getRateOfFire() const593 int WeaponModel::getRateOfFire() const
594 {
595 	return m_rateOfFire;
596 }
597 
598 ////////////////////////////////////////////////////////////
599 //
600 ////////////////////////////////////////////////////////////
601 
NoWeapon(uint16_t itemIndex,const ST::string & internalName)602 NoWeapon::NoWeapon(uint16_t itemIndex, const ST::string& internalName)
603 	:NoWeapon(itemIndex, internalName, IC_NONE, INVALIDCURS)
604 {
605 }
606 
NoWeapon(uint16_t itemIndex,const ST::string & internalName,uint32_t itemClass,uint8_t cursor)607 NoWeapon::NoWeapon(uint16_t itemIndex, const ST::string& internalName, uint32_t itemClass, uint8_t cursor)
608 	: WeaponModel(itemClass, NOT_GUN, cursor, itemIndex, internalName, WEAPON_TYPE_NOWEAPON)
609 {
610 }
611 
serializeTo(JsonObject & obj) const612 void NoWeapon::serializeTo(JsonObject &obj) const
613 {
614 	WeaponModel::serializeTo(obj);
615 	obj.AddMember("usRange", usRange);
616 	serializeAttachments(obj);
617 	serializeFlags(obj);
618 }
619 
620 
Pistol(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)621 Pistol::Pistol(uint16_t itemIndex, ST::string internalName,
622 		const CalibreModel *calibre,
623 		uint8_t BulletSpeed,
624 		uint8_t Impact,
625 		uint8_t ReadyTime,
626 		uint8_t ShotsPer4Turns,
627 		uint8_t Deadliness,
628 		uint8_t MagSize,
629 		uint16_t Range,
630 		uint8_t AttackVolume,
631 		uint8_t HitVolume,
632 		ST::string Sound)
633 	:WeaponModel(IC_GUN, GUN_PISTOL, TARGETCURS, itemIndex, internalName, "PISTOL")
634 {
635 	ubWeaponClass        = HANDGUNCLASS;
636 	this->calibre        = calibre;
637 	ubReadyTime          = ReadyTime;
638 	ubShotsPer4Turns     = ShotsPer4Turns;
639 	ubBulletSpeed        = BulletSpeed;
640 	ubImpact             = Impact;
641 	ubDeadliness         = Deadliness;
642 	ubMagSize            = MagSize;
643 	usRange              = Range;
644 	usReloadDelay        = 200;
645 	ubAttackVolume       = AttackVolume;
646 	ubHitVolume          = HitVolume;
647 	this->sound          = Sound;
648 	sReloadSound         = S_RELOAD_PISTOL;
649 	sLocknLoadSound      = S_LNL_PISTOL;
650 }
651 
serializeTo(JsonObject & obj) const652 void Pistol::serializeTo(JsonObject &obj) const
653 {
654 	WeaponModel::serializeTo(obj);
655 	obj.AddMember("calibre",              calibre->internalName);
656 	obj.AddMember("ubReadyTime",          ubReadyTime);
657 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
658 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
659 	obj.AddMember("ubImpact",             ubImpact);
660 	obj.AddMember("ubDeadliness",         ubDeadliness);
661 	obj.AddMember("ubMagSize",            ubMagSize);
662 	obj.AddMember("usRange",              usRange);
663 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
664 	obj.AddMember("ubHitVolume",          ubHitVolume);
665 	obj.AddMember("Sound",                sound);
666 	serializeAttachments(obj);
667 	serializeFlags(obj);
668 }
669 
MPistol(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t ShotsPerBurst,uint8_t BurstPenalty,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,ST::string BurstSound)670 MPistol::MPistol(uint16_t itemIndex, ST::string internalName,
671 			const CalibreModel *calibre,
672 			uint8_t BulletSpeed,
673 			uint8_t Impact,
674 			uint8_t ReadyTime,
675 			uint8_t ShotsPer4Turns,
676 			uint8_t ShotsPerBurst,
677 			uint8_t BurstPenalty,
678 			uint8_t Deadliness,
679 			uint8_t MagSize,
680 			uint16_t Range,
681 			uint8_t AttackVolume,
682 			uint8_t HitVolume,
683 			ST::string Sound,
684 			ST::string BurstSound)
685 	:WeaponModel(IC_GUN, GUN_M_PISTOL, TARGETCURS, itemIndex, internalName, "M_PISTOL")
686 {
687 	ubWeaponClass        = HANDGUNCLASS;
688 	this->calibre        = calibre;
689 	ubReadyTime          = ReadyTime;
690 	ubShotsPer4Turns     = ShotsPer4Turns;
691 	ubShotsPerBurst      = ShotsPerBurst;
692 	ubBurstPenalty       = BurstPenalty;
693 	ubBulletSpeed        = BulletSpeed;
694 	ubImpact             = Impact;
695 	ubDeadliness         = Deadliness;
696 	ubMagSize            = MagSize;
697 	usRange              = Range;
698 	usReloadDelay        = 200;
699 	ubAttackVolume       = AttackVolume;
700 	ubHitVolume          = HitVolume;
701 	this->sound          = Sound;
702 	this->burstSound     = BurstSound;
703 	sReloadSound         = S_RELOAD_PISTOL;
704 	sLocknLoadSound      = S_LNL_PISTOL;
705 }
706 
serializeTo(JsonObject & obj) const707 void MPistol::serializeTo(JsonObject &obj) const
708 {
709 	WeaponModel::serializeTo(obj);
710 	obj.AddMember("calibre",              calibre->internalName);
711 	obj.AddMember("ubReadyTime",          ubReadyTime);
712 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
713 	obj.AddMember("ubShotsPerBurst",      ubShotsPerBurst);
714 	obj.AddMember("ubBurstPenalty",       ubBurstPenalty);
715 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
716 	obj.AddMember("ubImpact",             ubImpact);
717 	obj.AddMember("ubDeadliness",         ubDeadliness);
718 	obj.AddMember("ubMagSize",            ubMagSize);
719 	obj.AddMember("usRange",              usRange);
720 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
721 	obj.AddMember("ubHitVolume",          ubHitVolume);
722 	obj.AddMember("Sound",                sound);
723 	obj.AddMember("BurstSound",           burstSound);
724 	serializeAttachments(obj);
725 	serializeFlags(obj);
726 }
727 
SMG(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t ShotsPerBurst,uint8_t BurstPenalty,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,ST::string BurstSound)728 SMG::SMG(uint16_t itemIndex, ST::string internalName,
729 		const CalibreModel *calibre,
730 		uint8_t BulletSpeed,
731 		uint8_t Impact,
732 		uint8_t ReadyTime,
733 		uint8_t ShotsPer4Turns,
734 		uint8_t ShotsPerBurst,
735 		uint8_t BurstPenalty,
736 		uint8_t Deadliness,
737 		uint8_t MagSize,
738 		uint16_t Range,
739 		uint8_t AttackVolume,
740 		uint8_t HitVolume,
741 		ST::string Sound,
742 		ST::string BurstSound)
743 	:WeaponModel(IC_GUN, GUN_SMG, TARGETCURS, itemIndex, internalName, "SMG")
744 {
745 	ubWeaponClass        = SMGCLASS;
746 	this->calibre        = calibre;
747 	ubReadyTime          = ReadyTime;
748 	ubShotsPer4Turns     = ShotsPer4Turns;
749 	ubShotsPerBurst      = ShotsPerBurst;
750 	ubBurstPenalty       = BurstPenalty;
751 	ubBulletSpeed        = BulletSpeed;
752 	ubImpact             = Impact;
753 	ubDeadliness         = Deadliness;
754 	ubMagSize            = MagSize;
755 	usRange              = Range;
756 	usReloadDelay        = 200;
757 	ubAttackVolume       = AttackVolume;
758 	ubHitVolume          = HitVolume;
759 	this->sound          = Sound;
760 	this->burstSound     = BurstSound;
761 	sReloadSound         = S_RELOAD_SMG;
762 	sLocknLoadSound      = S_LNL_SMG;
763 }
764 
serializeTo(JsonObject & obj) const765 void SMG::serializeTo(JsonObject &obj) const
766 {
767 	WeaponModel::serializeTo(obj);
768 	obj.AddMember("calibre",              calibre->internalName);
769 	obj.AddMember("ubReadyTime",          ubReadyTime);
770 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
771 	obj.AddMember("ubShotsPerBurst",      ubShotsPerBurst);
772 	obj.AddMember("ubBurstPenalty",       ubBurstPenalty);
773 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
774 	obj.AddMember("ubImpact",             ubImpact);
775 	obj.AddMember("ubDeadliness",         ubDeadliness);
776 	obj.AddMember("ubMagSize",            ubMagSize);
777 	obj.AddMember("usRange",              usRange);
778 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
779 	obj.AddMember("ubHitVolume",          ubHitVolume);
780 	obj.AddMember("Sound",                sound);
781 	obj.AddMember("BurstSound",           burstSound);
782 	serializeAttachments(obj);
783 	serializeFlags(obj);
784 }
785 
SniperRifle(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)786 SniperRifle::SniperRifle(uint16_t itemIndex, ST::string internalName,
787 				const CalibreModel *calibre,
788 				uint8_t BulletSpeed,
789 				uint8_t Impact,
790 				uint8_t ReadyTime,
791 				uint8_t ShotsPer4Turns,
792 				uint8_t Deadliness,
793 				uint8_t MagSize,
794 				uint16_t Range,
795 				uint8_t AttackVolume,
796 				uint8_t HitVolume,
797 				ST::string Sound)
798 	:WeaponModel(IC_GUN, GUN_SN_RIFLE, TARGETCURS, itemIndex, internalName, "SN_RIFLE")
799 {
800 	ubWeaponClass        = RIFLECLASS;
801 	this->calibre        = calibre;
802 	ubReadyTime          = ReadyTime;
803 	ubShotsPer4Turns     = ShotsPer4Turns;
804 	ubBulletSpeed        = BulletSpeed;
805 	ubImpact             = Impact;
806 	ubDeadliness         = Deadliness;
807 	ubMagSize            = MagSize;
808 	usRange              = Range;
809 	usReloadDelay        = 200;
810 	ubAttackVolume       = AttackVolume;
811 	ubHitVolume          = HitVolume;
812 	this->sound          = Sound;
813 	sReloadSound         = S_RELOAD_RIFLE;
814 	sLocknLoadSound      = S_LNL_RIFLE;
815 }
816 
serializeTo(JsonObject & obj) const817 void SniperRifle::serializeTo(JsonObject &obj) const
818 {
819 	WeaponModel::serializeTo(obj);
820 	obj.AddMember("calibre",              calibre->internalName);
821 	obj.AddMember("ubReadyTime",          ubReadyTime);
822 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
823 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
824 	obj.AddMember("ubImpact",             ubImpact);
825 	obj.AddMember("ubDeadliness",         ubDeadliness);
826 	obj.AddMember("ubMagSize",            ubMagSize);
827 	obj.AddMember("usRange",              usRange);
828 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
829 	obj.AddMember("ubHitVolume",          ubHitVolume);
830 	obj.AddMember("Sound",                sound);
831 	serializeAttachments(obj);
832 	serializeFlags(obj);
833 }
834 
Rifle(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)835 Rifle::Rifle(uint16_t itemIndex, ST::string internalName,
836 		const CalibreModel *calibre,
837 		uint8_t BulletSpeed,
838 		uint8_t Impact,
839 		uint8_t ReadyTime,
840 		uint8_t ShotsPer4Turns,
841 		uint8_t Deadliness,
842 		uint8_t MagSize,
843 		uint16_t Range,
844 		uint8_t AttackVolume,
845 		uint8_t HitVolume,
846 		ST::string Sound)
847 	:WeaponModel(IC_GUN, GUN_RIFLE, TARGETCURS, itemIndex, internalName, "RIFLE")
848 {
849 	ubWeaponClass        = RIFLECLASS;
850 	this->calibre        = calibre;
851 	ubReadyTime          = ReadyTime;
852 	ubShotsPer4Turns     = ShotsPer4Turns;
853 	ubBulletSpeed        = BulletSpeed;
854 	ubImpact             = Impact;
855 	ubDeadliness         = Deadliness;
856 	ubMagSize            = MagSize;
857 	usRange              = Range;
858 	usReloadDelay        = 200;
859 	ubAttackVolume       = AttackVolume;
860 	ubHitVolume          = HitVolume;
861 	this->sound          = Sound;
862 	sReloadSound         = S_RELOAD_RIFLE;
863 	sLocknLoadSound      = S_LNL_RIFLE;
864 }
865 
serializeTo(JsonObject & obj) const866 void Rifle::serializeTo(JsonObject &obj) const
867 {
868 	WeaponModel::serializeTo(obj);
869 	obj.AddMember("calibre",              calibre->internalName);
870 	obj.AddMember("ubReadyTime",          ubReadyTime);
871 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
872 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
873 	obj.AddMember("ubImpact",             ubImpact);
874 	obj.AddMember("ubDeadliness",         ubDeadliness);
875 	obj.AddMember("ubMagSize",            ubMagSize);
876 	obj.AddMember("usRange",              usRange);
877 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
878 	obj.AddMember("ubHitVolume",          ubHitVolume);
879 	obj.AddMember("Sound",                sound);
880 	serializeAttachments(obj);
881 	serializeFlags(obj);
882 }
883 
AssaultRifle(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t ShotsPerBurst,uint8_t BurstPenalty,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,ST::string BurstSound)884 AssaultRifle::AssaultRifle(uint16_t itemIndex, ST::string internalName,
885 				const CalibreModel *calibre,
886 				uint8_t BulletSpeed,
887 				uint8_t Impact,
888 				uint8_t ReadyTime,
889 				uint8_t ShotsPer4Turns,
890 				uint8_t ShotsPerBurst,
891 				uint8_t BurstPenalty,
892 				uint8_t Deadliness,
893 				uint8_t MagSize,
894 				uint16_t Range,
895 				uint8_t AttackVolume,
896 				uint8_t HitVolume,
897 				ST::string Sound,
898 				ST::string BurstSound)
899 	:WeaponModel(IC_GUN, GUN_AS_RIFLE, TARGETCURS, itemIndex, internalName, "ASRIFLE")
900 {
901 	ubWeaponClass        = RIFLECLASS;
902 	this->calibre        = calibre;
903 	ubReadyTime          = ReadyTime;
904 	ubShotsPer4Turns     = ShotsPer4Turns;
905 	ubShotsPerBurst      = ShotsPerBurst;
906 	ubBurstPenalty       = BurstPenalty;
907 	ubBulletSpeed        = BulletSpeed;
908 	ubImpact             = Impact;
909 	ubDeadliness         = Deadliness;
910 	ubMagSize            = MagSize;
911 	usRange              = Range;
912 	usReloadDelay        = 200;
913 	ubAttackVolume       = AttackVolume;
914 	ubHitVolume          = HitVolume;
915 	this->sound          = Sound;
916 	this->burstSound     = BurstSound;
917 	sReloadSound         = S_RELOAD_RIFLE;
918 	sLocknLoadSound      = S_LNL_RIFLE;
919 }
920 
serializeTo(JsonObject & obj) const921 void AssaultRifle::serializeTo(JsonObject &obj) const
922 {
923 	WeaponModel::serializeTo(obj);
924 	obj.AddMember("calibre",              calibre->internalName);
925 	obj.AddMember("ubReadyTime",          ubReadyTime);
926 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
927 	obj.AddMember("ubShotsPerBurst",      ubShotsPerBurst);
928 	obj.AddMember("ubBurstPenalty",       ubBurstPenalty);
929 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
930 	obj.AddMember("ubImpact",             ubImpact);
931 	obj.AddMember("ubDeadliness",         ubDeadliness);
932 	obj.AddMember("ubMagSize",            ubMagSize);
933 	obj.AddMember("usRange",              usRange);
934 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
935 	obj.AddMember("ubHitVolume",          ubHitVolume);
936 	obj.AddMember("Sound",                sound);
937 	obj.AddMember("BurstSound",           burstSound);
938 	serializeAttachments(obj);
939 	serializeFlags(obj);
940 }
941 
Shotgun(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t ShotsPerBurst,uint8_t BurstPenalty,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,ST::string BurstSound)942 Shotgun::Shotgun(uint16_t itemIndex, ST::string internalName,
943 			const CalibreModel *calibre,
944 			uint8_t BulletSpeed,
945 			uint8_t Impact,
946 			uint8_t ReadyTime,
947 			uint8_t ShotsPer4Turns,
948 			uint8_t ShotsPerBurst,
949 			uint8_t BurstPenalty,
950 			uint8_t Deadliness,
951 			uint8_t MagSize,
952 			uint16_t Range,
953 			uint8_t AttackVolume,
954 			uint8_t HitVolume,
955 			ST::string Sound,
956 			ST::string BurstSound)
957 	:WeaponModel(IC_GUN, GUN_SHOTGUN, TARGETCURS, itemIndex, internalName, "SHOTGUN")
958 {
959 	ubWeaponClass        = SHOTGUNCLASS;
960 	this->calibre        = calibre;
961 	ubReadyTime          = ReadyTime;
962 	ubShotsPer4Turns     = ShotsPer4Turns;
963 	ubShotsPerBurst      = ShotsPerBurst;
964 	ubBurstPenalty       = BurstPenalty;
965 	ubBulletSpeed        = BulletSpeed;
966 	ubImpact             = Impact;
967 	ubDeadliness         = Deadliness;
968 	ubMagSize            = MagSize;
969 	usRange              = Range;
970 	usReloadDelay        = 200;
971 	ubAttackVolume       = AttackVolume;
972 	ubHitVolume          = HitVolume;
973 	this->sound          = Sound;
974 	this->burstSound     = BurstSound;
975 	sReloadSound         = S_RELOAD_SHOTGUN;
976 	sLocknLoadSound      = S_LNL_SHOTGUN;
977 }
978 
serializeTo(JsonObject & obj) const979 void Shotgun::serializeTo(JsonObject &obj) const
980 {
981 	WeaponModel::serializeTo(obj);
982 	obj.AddMember("calibre",              calibre->internalName);
983 	obj.AddMember("ubReadyTime",          ubReadyTime);
984 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
985 	obj.AddMember("ubShotsPerBurst",      ubShotsPerBurst);
986 	obj.AddMember("ubBurstPenalty",       ubBurstPenalty);
987 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
988 	obj.AddMember("ubImpact",             ubImpact);
989 	obj.AddMember("ubDeadliness",         ubDeadliness);
990 	obj.AddMember("ubMagSize",            ubMagSize);
991 	obj.AddMember("usRange",              usRange);
992 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
993 	obj.AddMember("ubHitVolume",          ubHitVolume);
994 	obj.AddMember("Sound",                sound);
995 	obj.AddMember("BurstSound",           burstSound);
996 	serializeAttachments(obj);
997 	serializeFlags(obj);
998 }
999 
LMG(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t BulletSpeed,uint8_t Impact,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t ShotsPerBurst,uint8_t BurstPenalty,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,ST::string BurstSound)1000 LMG::LMG(uint16_t itemIndex, ST::string internalName,
1001 		const CalibreModel *calibre,
1002 		uint8_t BulletSpeed,
1003 		uint8_t Impact,
1004 		uint8_t ReadyTime,
1005 		uint8_t ShotsPer4Turns,
1006 		uint8_t ShotsPerBurst,
1007 		uint8_t BurstPenalty,
1008 		uint8_t Deadliness,
1009 		uint8_t MagSize,
1010 		uint16_t Range,
1011 		uint8_t AttackVolume,
1012 		uint8_t HitVolume,
1013 		ST::string Sound,
1014 		ST::string BurstSound)
1015 	:WeaponModel(IC_GUN, GUN_LMG, TARGETCURS, itemIndex, internalName, "LMG")
1016 {
1017 	ubWeaponClass        = MGCLASS;
1018 	this->calibre        = calibre;
1019 	ubReadyTime          = ReadyTime;
1020 	ubShotsPer4Turns     = ShotsPer4Turns;
1021 	ubShotsPerBurst      = ShotsPerBurst;
1022 	ubBurstPenalty       = BurstPenalty;
1023 	ubBulletSpeed        = BulletSpeed;
1024 	ubImpact             = Impact;
1025 	ubDeadliness         = Deadliness;
1026 	ubMagSize            = MagSize;
1027 	usRange              = Range;
1028 	usReloadDelay        = 200;
1029 	ubAttackVolume       = AttackVolume;
1030 	ubHitVolume          = HitVolume;
1031 	this->sound          = Sound;
1032 	this->burstSound     = BurstSound;
1033 	sReloadSound         = S_RELOAD_LMG;
1034 	sLocknLoadSound      = S_LNL_LMG;
1035 }
1036 
serializeTo(JsonObject & obj) const1037 void LMG::serializeTo(JsonObject &obj) const
1038 {
1039 	WeaponModel::serializeTo(obj);
1040 	obj.AddMember("calibre",              calibre->internalName);
1041 	obj.AddMember("ubReadyTime",          ubReadyTime);
1042 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1043 	obj.AddMember("ubShotsPerBurst",      ubShotsPerBurst);
1044 	obj.AddMember("ubBurstPenalty",       ubBurstPenalty);
1045 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
1046 	obj.AddMember("ubImpact",             ubImpact);
1047 	obj.AddMember("ubDeadliness",         ubDeadliness);
1048 	obj.AddMember("ubMagSize",            ubMagSize);
1049 	obj.AddMember("usRange",              usRange);
1050 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1051 	obj.AddMember("ubHitVolume",          ubHitVolume);
1052 	obj.AddMember("Sound",                sound);
1053 	obj.AddMember("BurstSound",           burstSound);
1054 	serializeAttachments(obj);
1055 	serializeFlags(obj);
1056 }
1057 
Blade(uint16_t itemIndex,ST::string internalName,uint8_t Impact,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint16_t Range,uint8_t AttackVolume,ST::string Sound)1058 Blade::Blade(uint16_t itemIndex, ST::string internalName,
1059 		uint8_t Impact,
1060 		uint8_t ShotsPer4Turns,
1061 		uint8_t Deadliness,
1062 		uint16_t Range,
1063 		uint8_t AttackVolume,
1064 		ST::string Sound)
1065 	:WeaponModel(IC_BLADE, NOT_GUN, KNIFECURS, itemIndex, internalName, "BLADE")
1066 {
1067 	ubWeaponClass        = KNIFECLASS;
1068 	ubReadyTime          = AP_READY_KNIFE;
1069 	ubShotsPer4Turns     = ShotsPer4Turns;
1070 	ubImpact             = Impact;
1071 	ubDeadliness         = Deadliness;
1072 	usRange              = Range;
1073 	usReloadDelay        = 200;
1074 	ubAttackVolume       = AttackVolume;
1075 	this->sound          = Sound;
1076 }
1077 
serializeTo(JsonObject & obj) const1078 void Blade::serializeTo(JsonObject &obj) const
1079 {
1080 	WeaponModel::serializeTo(obj);
1081 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1082 	obj.AddMember("ubImpact",             ubImpact);
1083 	obj.AddMember("ubDeadliness",         ubDeadliness);
1084 	obj.AddMember("usRange",              usRange);
1085 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1086 	obj.AddMember("Sound",                sound);
1087 	serializeAttachments(obj);
1088 	serializeFlags(obj);
1089 }
1090 
ThrowingBlade(uint16_t itemIndex,ST::string internalName,uint8_t Impact,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint16_t Range,uint8_t AttackVolume,ST::string Sound)1091 ThrowingBlade::ThrowingBlade(uint16_t itemIndex, ST::string internalName,
1092 				uint8_t Impact,
1093 				uint8_t ShotsPer4Turns,
1094 				uint8_t Deadliness,
1095 				uint16_t Range,
1096 				uint8_t AttackVolume,
1097 				ST::string Sound)
1098 	:WeaponModel(IC_THROWING_KNIFE, NOT_GUN, TARGETCURS, itemIndex, internalName, "THROWINGBLADE")
1099 {
1100 	ubWeaponClass        = KNIFECLASS;
1101 	ubReadyTime          = AP_READY_KNIFE;
1102 	ubShotsPer4Turns     = ShotsPer4Turns;
1103 	ubImpact             = Impact;
1104 	ubDeadliness         = Deadliness;
1105 	usRange              = Range;
1106 	usReloadDelay        = 200;
1107 	ubAttackVolume       = AttackVolume;
1108 	this->sound          = Sound;
1109 }
1110 
serializeTo(JsonObject & obj) const1111 void ThrowingBlade::serializeTo(JsonObject &obj) const
1112 {
1113 	WeaponModel::serializeTo(obj);
1114 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1115 	obj.AddMember("ubImpact",             ubImpact);
1116 	obj.AddMember("ubDeadliness",         ubDeadliness);
1117 	obj.AddMember("usRange",              usRange);
1118 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1119 	obj.AddMember("Sound",                sound);
1120 	serializeAttachments(obj);
1121 	serializeFlags(obj);
1122 }
1123 
PunchWeapon(uint16_t itemIndex,ST::string internalName,uint8_t Impact,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint8_t AttackVolume,ST::string Sound)1124 PunchWeapon::PunchWeapon(uint16_t itemIndex, ST::string internalName,
1125 				uint8_t Impact,
1126 				uint8_t ShotsPer4Turns,
1127 				uint8_t Deadliness,
1128 				uint8_t AttackVolume,
1129 				ST::string Sound)
1130 	:WeaponModel(IC_PUNCH, NOT_GUN, PUNCHCURS, itemIndex, internalName, "PUNCHWEAPON")
1131 {
1132 	ubWeaponClass        = KNIFECLASS;
1133 	ubShotsPer4Turns     = ShotsPer4Turns;
1134 	ubImpact             = Impact;
1135 	ubDeadliness         = Deadliness;
1136 	usRange              = 10;
1137 	usReloadDelay        = 200;
1138 	ubAttackVolume       = AttackVolume;
1139 	this->sound          = Sound;
1140 }
1141 
1142 
serializeTo(JsonObject & obj) const1143 void PunchWeapon::serializeTo(JsonObject &obj) const
1144 {
1145 	WeaponModel::serializeTo(obj);
1146 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1147 	obj.AddMember("ubImpact",             ubImpact);
1148 	obj.AddMember("ubDeadliness",         ubDeadliness);
1149 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1150 	obj.AddMember("Sound",                sound);
1151 	serializeAttachments(obj);
1152 	serializeFlags(obj);
1153 }
1154 
Launcher(uint16_t itemIndex,ST::string internalName,uint8_t BulletSpeed,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)1155 Launcher::Launcher(uint16_t itemIndex, ST::string internalName,
1156 			uint8_t BulletSpeed,
1157 			uint8_t ReadyTime,
1158 			uint8_t ShotsPer4Turns,
1159 			uint8_t Deadliness,
1160 			uint16_t Range,
1161 			uint8_t AttackVolume,
1162 			uint8_t HitVolume,
1163 			ST::string Sound)
1164 	:WeaponModel(IC_LAUNCHER, NOT_GUN, TRAJECTORYCURS, itemIndex, internalName, "LAUNCHER")
1165 {
1166 	ubWeaponClass        = RIFLECLASS;
1167 	ubReadyTime          = ReadyTime;
1168 	ubShotsPer4Turns     = ShotsPer4Turns;
1169 	ubBulletSpeed        = BulletSpeed;
1170 	ubImpact             = 1;
1171 	ubDeadliness         = Deadliness;
1172 	usRange              = Range;
1173 	usReloadDelay        = 200;
1174 	ubAttackVolume       = AttackVolume;
1175 	ubHitVolume          = HitVolume;
1176 	this->sound          = Sound;
1177 }
1178 
serializeTo(JsonObject & obj) const1179 void Launcher::serializeTo(JsonObject &obj) const
1180 {
1181 	WeaponModel::serializeTo(obj);
1182 	obj.AddMember("ubReadyTime",          ubReadyTime);
1183 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1184 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
1185 	obj.AddMember("ubDeadliness",         ubDeadliness);
1186 	obj.AddMember("usRange",              usRange);
1187 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1188 	obj.AddMember("ubHitVolume",          ubHitVolume);
1189 	obj.AddMember("Sound",                sound);
1190 	serializeAttachments(obj);
1191 	serializeFlags(obj);
1192 }
1193 
LAW(uint16_t itemIndex,ST::string internalName,uint8_t BulletSpeed,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)1194 LAW::LAW(uint16_t itemIndex, ST::string internalName,
1195 		uint8_t BulletSpeed,
1196 		uint8_t ReadyTime,
1197 		uint8_t ShotsPer4Turns,
1198 		uint8_t Deadliness,
1199 		uint16_t Range,
1200 		uint8_t AttackVolume,
1201 		uint8_t HitVolume,
1202 		ST::string Sound)
1203 	:WeaponModel(IC_GUN, NOT_GUN, TARGETCURS, itemIndex, internalName, "LAW")
1204 {
1205 	ubWeaponClass        = RIFLECLASS;
1206 	ubReadyTime          = ReadyTime;
1207 	ubShotsPer4Turns     = ShotsPer4Turns;
1208 	ubBulletSpeed        = BulletSpeed;
1209 	ubImpact             = 80;
1210 	ubDeadliness         = Deadliness;
1211 	ubMagSize            = 1;
1212 	usRange              = Range;
1213 	usReloadDelay        = 200;
1214 	ubAttackVolume       = AttackVolume;
1215 	ubHitVolume          = HitVolume;
1216 	this->sound          = Sound;
1217 }
1218 
serializeTo(JsonObject & obj) const1219 void LAW::serializeTo(JsonObject &obj) const
1220 {
1221 	WeaponModel::serializeTo(obj);
1222 	obj.AddMember("ubReadyTime",          ubReadyTime);
1223 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1224 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
1225 	obj.AddMember("ubDeadliness",         ubDeadliness);
1226 	obj.AddMember("usRange",              usRange);
1227 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1228 	obj.AddMember("ubHitVolume",          ubHitVolume);
1229 	obj.AddMember("Sound",                sound);
1230 	serializeAttachments(obj);
1231 	serializeFlags(obj);
1232 }
1233 
Cannon(uint16_t itemIndex,ST::string internalName,uint8_t BulletSpeed,uint8_t ReadyTime,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound)1234 Cannon::Cannon(uint16_t itemIndex, ST::string internalName,
1235 		uint8_t BulletSpeed,
1236 		uint8_t ReadyTime,
1237 		uint8_t ShotsPer4Turns,
1238 		uint8_t Deadliness,
1239 		uint16_t Range,
1240 		uint8_t AttackVolume,
1241 		uint8_t HitVolume,
1242 		ST::string Sound)
1243 	:WeaponModel(IC_GUN, NOT_GUN, TARGETCURS, itemIndex, internalName, "CANNON")
1244 {
1245 	ubWeaponClass        = RIFLECLASS;
1246 	ubReadyTime          = ReadyTime;
1247 	ubShotsPer4Turns     = ShotsPer4Turns;
1248 	ubBulletSpeed        = BulletSpeed;
1249 	ubImpact             = 80;
1250 	ubDeadliness         = Deadliness;
1251 	ubMagSize            = 1;
1252 	usRange              = Range;
1253 	usReloadDelay        = 200;
1254 	ubAttackVolume       = AttackVolume;
1255 	ubHitVolume          = HitVolume;
1256 	this->sound          = Sound;
1257 }
1258 
serializeTo(JsonObject & obj) const1259 void Cannon::serializeTo(JsonObject &obj) const
1260 {
1261 	WeaponModel::serializeTo(obj);
1262 	obj.AddMember("ubReadyTime",          ubReadyTime);
1263 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1264 	obj.AddMember("ubBulletSpeed",        ubBulletSpeed);
1265 	obj.AddMember("ubDeadliness",         ubDeadliness);
1266 	obj.AddMember("usRange",              usRange);
1267 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1268 	obj.AddMember("ubHitVolume",          ubHitVolume);
1269 	obj.AddMember("Sound",                sound);
1270 	serializeAttachments(obj);
1271 	serializeFlags(obj);
1272 }
1273 
MonsterSpit(uint16_t itemIndex,ST::string internalName,const CalibreModel * calibre,uint8_t Impact,uint8_t ShotsPer4Turns,uint8_t Deadliness,uint8_t MagSize,uint16_t Range,uint8_t AttackVolume,uint8_t HitVolume,ST::string Sound,uint16_t smokeEffect)1274 MonsterSpit::MonsterSpit(uint16_t itemIndex, ST::string internalName,
1275 				const CalibreModel *calibre,
1276 				uint8_t Impact,
1277 				uint8_t ShotsPer4Turns,
1278 				uint8_t Deadliness,
1279 				uint8_t MagSize,
1280 				uint16_t Range,
1281 				uint8_t AttackVolume,
1282 				uint8_t HitVolume,
1283 				ST::string Sound,
1284 				uint16_t smokeEffect)
1285 	:WeaponModel(IC_GUN, NOT_GUN, TARGETCURS, itemIndex, internalName, "MONSTSPIT")
1286 {
1287 	ubWeaponClass        = MONSTERCLASS;
1288 	this->calibre        = calibre;
1289 	ubReadyTime          = AP_READY_KNIFE;
1290 	ubShotsPer4Turns     = ShotsPer4Turns;
1291 	ubBulletSpeed        = 250;
1292 	ubImpact             = Impact;
1293 	ubDeadliness         = Deadliness;
1294 	ubMagSize            = MagSize;
1295 	usRange              = Range;
1296 	usReloadDelay        = 200;
1297 	ubAttackVolume       = AttackVolume;
1298 	ubHitVolume          = HitVolume;
1299 	this->sound          = Sound;
1300 	usSmokeEffect        = smokeEffect;
1301 }
1302 
serializeTo(JsonObject & obj) const1303 void MonsterSpit::serializeTo(JsonObject &obj) const
1304 {
1305 	WeaponModel::serializeTo(obj);
1306 	obj.AddMember("calibre",              calibre->internalName);
1307 	obj.AddMember("ubShotsPer4Turns",     ubShotsPer4Turns);
1308 	obj.AddMember("ubImpact",             ubImpact);
1309 	obj.AddMember("ubDeadliness",         ubDeadliness);
1310 	obj.AddMember("ubMagSize",            ubMagSize);
1311 	obj.AddMember("usRange",              usRange);
1312 	obj.AddMember("ubAttackVolume",       ubAttackVolume);
1313 	obj.AddMember("ubHitVolume",          ubHitVolume);
1314 	obj.AddMember("Sound",                sound);
1315 	obj.AddMember("ubSmokeEffect",        usSmokeEffect);
1316 	serializeAttachments(obj);
1317 	serializeFlags(obj);
1318 }
1319