forked from discordia-space/CEV-Eris
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path_upgrades.dm
More file actions
804 lines (704 loc) · 33.9 KB
/
_upgrades.dm
File metadata and controls
804 lines (704 loc) · 33.9 KB
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
/*
A tool upgrade is a little attachment for a tool that improves it in some way
Tool upgrades are generally permanant
Some upgrades have multiple bonuses. Some have drawbacks in addition to boosts
*/
/*/client/verb/debugupgrades()
for (var/t in subtypesof(/obj/item/tool_upgrade))
new t(usr.loc)
*/
/datum/component/item_upgrade
dupe_mode = COMPONENT_DUPE_UNIQUE
can_transfer = TRUE
var/prefix = "upgraded" //Added to the tool's name
var/removal_time = WORKTIME_SLOW
var/removal_difficulty = FAILCHANCE_CHALLENGING
var/destroy_on_removal = FALSE
//The upgrade can be applied to a tool that has any of these qualities
var/list/required_qualities = list()
var/removable = MOD_REMOVABLE
var/breakable = TRUE //Some mods meant to be tamper-resistant and should be removed only in a hard way
//The upgrade can not be applied to a tool that has any of these qualities
var/list/negative_qualities = list()
//If REQ_FUEL, can only be applied to tools that use fuel. If REQ_CELL, can only be applied to tools that use cell, If REQ_FUEL_OR_CELL, can be applied if it has fuel OR a cell
var/req_fuel_cell = FALSE
var/exclusive_type
//Actual effects of upgrades
var/list/tool_upgrades = list() //variable name(string) -> num
//Weapon upgrades
var/list/gun_loc_tag //Define(string). For checking if the gun already has something of this installed (No double trigger mods, for instance)
var/list/req_gun_tags = list() //Define(string). Must match all to be able to install it.
var/list/weapon_upgrades = list() //variable name(string) -> num
/datum/component/item_upgrade/RegisterWithParent()
RegisterSignal(parent, COMSIG_IATTACK, PROC_REF(attempt_install))
RegisterSignal(parent, COMSIG_EXTRA_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_REMOVE, PROC_REF(uninstall))
/datum/component/item_upgrade/proc/attempt_install(atom/A, mob/living/user, params)
//SIGNAL_HANDLER
return can_apply(A, user) && apply(A, user)
/datum/component/item_upgrade/proc/can_apply(atom/A, mob/living/user)
if(isrobot(A))
return check_robot(A, user)
if(isitem(A))
var/obj/item/T = A
//No using multiples of the same upgrade
for (var/obj/item/I in T.item_upgrades)
if(I.type == parent.type || (exclusive_type && istype(I.type, exclusive_type)))
if(user)
to_chat(user, span_warning("An upgrade of this type is already installed!"))
return FALSE
if(istool(A))
return check_tool(A, user)
if(ismodulargun(A))
return (check_modulargun(A, user) && check_gun(A, user))
if(isgun(A))
return check_gun(A, user)
return FALSE
/datum/component/item_upgrade/proc/check_robot(mob/living/silicon/robot/R, mob/living/user)
if(!R.opened)
if(user)
to_chat(user, span_warning("You need to open [R]'s panel to access its tools."))
return FALSE
var/list/robotools = list()
for(var/obj/item/tool/robotool in R.module.modules)
robotools.Add(robotool)
if(robotools.len)
var/obj/item/tool/chosen_tool = input(user,"Which tool are you trying to modify?","Tool Modification","Cancel") in robotools + "Cancel"
if(chosen_tool == "Cancel")
return FALSE
return can_apply(chosen_tool,user)
if(user)
to_chat(user, span_warning("[R] has no modifiable tools."))
return FALSE
/datum/component/item_upgrade/proc/check_tool(obj/item/tool/T, mob/living/user)
if(!tool_upgrades.len)
to_chat(user, span_warning("\The [parent] can not be attached to a tool."))
return FALSE
if(T.item_upgrades.len >= T.max_upgrades)
if(user)
to_chat(user, span_warning("This tool can't fit anymore modifications!"))
return FALSE
if(required_qualities.len)
var/qmatch = FALSE
for (var/q in required_qualities)
if(T.ever_has_quality(q))
qmatch = TRUE
break
if(!qmatch)
if(user)
to_chat(user, span_warning("This tool lacks the required qualities!"))
return FALSE
if(negative_qualities.len)
for(var/i in negative_qualities)
if(T.ever_has_quality(i))
if(user)
to_chat(user, span_warning("This tool can not accept the modification!"))
return FALSE
if((req_fuel_cell & REQ_FUEL) && !T.use_fuel_cost)
if(user)
to_chat(user, span_warning("This tool does not use fuel!"))
return FALSE
if((req_fuel_cell & REQ_CELL) && !T.use_power_cost)
if(user)
to_chat(user, span_warning("This tool does not use power!"))
return FALSE
if((req_fuel_cell & REQ_FUEL_OR_CELL) && (!T.use_power_cost && !T.use_fuel_cost))
if(user)
to_chat(user, span_warning("This tool does not use [T.use_power_cost?"fuel":"power"]!"))
return FALSE
if(tool_upgrades[UPGRADE_SANCTIFY])
if(SANCTIFIED in T.aspects)
if(user)
to_chat(user, span_warning("This tool already sanctified!"))
return FALSE
if(tool_upgrades[UPGRADE_CELLPLUS])
if(!(T.suitable_cell == /obj/item/cell/medium || T.suitable_cell == /obj/item/cell/small))
if(user)
to_chat(user, span_warning("This tool does not require a cell holding upgrade."))
return FALSE
if(T.cell)
if(user)
to_chat(user, span_warning("Remove the cell from the tool first!"))
return FALSE
return TRUE
/datum/component/item_upgrade/proc/check_gun(obj/item/gun/G, mob/living/user)
if(!weapon_upgrades.len)
if(user)
to_chat(user, span_warning("\The [parent] can not be applied to guns!"))
return FALSE //Can't be applied to a weapon
if(G.item_upgrades.len >= G.max_upgrades)
if(user)
to_chat(user, span_warning("This weapon can't fit anymore modifications!"))
return FALSE
for(var/obj/I in G.item_upgrades)
var/datum/component/item_upgrade/IU = I.GetComponent(/datum/component/item_upgrade)
if(IU && IU.gun_loc_tag == gun_loc_tag)
if(user)
to_chat(user, span_warning("There is already something attached to \the [G]'s [gun_loc_tag]!"))
return FALSE
for(var/I in req_gun_tags)
if(!G.gun_tags.Find(I))
if(user)
to_chat(user, span_warning("\The [G] lacks the following property: [I]"))
return FALSE
if((req_fuel_cell & REQ_CELL) && !istype(G, /obj/item/gun/energy))
if(user)
to_chat(user, span_warning("This weapon does not use power!"))
return FALSE
return TRUE
/datum/component/item_upgrade/proc/check_modulargun(obj/item/gun/projectile/automatic/modular/MG, mob/living/user)
if(istype(parent, /obj/item/part/gun/modular))
// Caliber check coming for barrels
if(istype(parent, /obj/item/part/gun/modular/barrel))
if(MG.good_calibers.len)
var/obj/item/part/gun/modular/barrel/B = parent
var/check = FALSE
for(var/i in MG.good_calibers)
if(B.caliber == i)
check = TRUE
if(!check)
to_chat(user, span_warning("The barrel does not fit the mechanism! The gun fits the following calibers: [english_list(MG.good_calibers, "None are suitable!", " and ", ", ", ".")]"))
return FALSE
// Caliber check for mechanism
if(istype(parent, /obj/item/part/gun/modular/mechanism))
if(MG.caliber)
var/obj/item/part/gun/modular/mechanism/M = parent
var/check = FALSE
for(var/i in M.accepted_calibers)
if(MG.caliber == i)
check = TRUE
if(!check)
to_chat(user, span_warning("The mechanism does not fit the barrel! The mechanism fits the following calibers: [english_list(M.accepted_calibers, "None are suitable!", " and ", ", ", ".")]"))
return FALSE
// Checking if part is accepted
for(var/partPath in MG.required_parts)
if(istype(parent, partPath))
return TRUE
to_chat(user, span_warning("\The [parent] doesn't fit into the [MG]."))
return FALSE
else
return TRUE //We're not even a modular part
/datum/component/item_upgrade/proc/apply(obj/item/A, mob/living/user)
if(user)
user.visible_message(span_notice("[user] starts applying [parent] to [A]"), span_notice("You start applying \the [parent] to \the [A]"))
var/obj/item/I = parent
if(!I.use_tool(user = user, target = A, base_time = WORKTIME_FAST, required_quality = null, fail_chance = FAILCHANCE_ZERO, required_stat = STAT_MEC, forced_sound = WORKSOUND_WRENCHING))
return FALSE
to_chat(user, span_notice("You have successfully installed \the [parent] in \the [A]"))
user.drop_from_inventory(parent)
//If we get here, we succeeded in the applying
var/obj/item/I = parent
I.forceMove(A)
A.item_upgrades.Add(I)
RegisterSignal(A, COMSIG_APPVAL, PROC_REF(apply_values))
RegisterSignal(A, COMSIG_ADDVAL, PROC_REF(add_values))
A.AddComponent(/datum/component/upgrade_removal)
A.refresh_upgrades()
if(user)
user.update_action_buttons()
return TRUE
/datum/component/item_upgrade/proc/rapid_apply(obj/item/A) // Faster, but no safety checks and no refresh_upgrades
var/obj/item/I = parent
I.forceMove(A)
A.item_upgrades.Add(I)
RegisterSignal(A, COMSIG_APPVAL, PROC_REF(apply_values))
RegisterSignal(A, COMSIG_ADDVAL, PROC_REF(add_values))
A.AddComponent(/datum/component/upgrade_removal)
return TRUE
/datum/component/item_upgrade/proc/uninstall(obj/item/I, mob/living/user)
//SIGNAL_HANDLER
var/obj/item/P = parent
I.item_upgrades -= P
if(destroy_on_removal)
UnregisterSignal(I, COMSIG_ADDVAL)
UnregisterSignal(I, COMSIG_APPVAL)
qdel(P)
return
P.forceMove(get_turf(I))
UnregisterSignal(I, COMSIG_ADDVAL)
UnregisterSignal(I, COMSIG_APPVAL)
reset_owner()
/datum/component/item_upgrade/proc/apply_values(atom/holder)
//SIGNAL_HANDLER
if(!holder)
return
if(istool(holder))
apply_values_tool(holder)
if(isgun(holder))
apply_values_gun(holder)
return TRUE
/datum/component/item_upgrade/proc/add_values(atom/holder)
ASSERT(holder)
if(isgun(holder))
add_values_gun(holder)
return TRUE
/datum/component/item_upgrade/proc/apply_values_tool(obj/item/tool/T)
if(tool_upgrades[UPGRADE_SANCTIFY])
T.aspects += list(SANCTIFIED)
if(tool_upgrades[UPGRADE_PRECISION])
T.precision += tool_upgrades[UPGRADE_PRECISION]
if(tool_upgrades[UPGRADE_WORKSPEED])
T.workspeed += tool_upgrades[UPGRADE_WORKSPEED]
if(tool_upgrades[UPGRADE_DEGRADATION_MULT])
T.degradation *= tool_upgrades[UPGRADE_DEGRADATION_MULT]
if(tool_upgrades[UPGRADE_FORCE_MULT])
T.force_upgrade_mults += tool_upgrades[UPGRADE_FORCE_MULT] - 1
if(tool_upgrades[UPGRADE_FORCE_MOD])
T.force_upgrade_mods += tool_upgrades[UPGRADE_FORCE_MOD]
if(tool_upgrades[UPGRADE_FUELCOST_MULT])
T.use_fuel_cost *= tool_upgrades[UPGRADE_FUELCOST_MULT]
if(tool_upgrades[UPGRADE_POWERCOST_MULT])
T.use_power_cost *= tool_upgrades[UPGRADE_POWERCOST_MULT]
if(tool_upgrades[UPGRADE_BULK])
T.extra_bulk += tool_upgrades[UPGRADE_BULK]
if(tool_upgrades[UPGRADE_HEALTH_THRESHOLD])
T.health_threshold += tool_upgrades[UPGRADE_HEALTH_THRESHOLD]
if(tool_upgrades[UPGRADE_MAXFUEL])
T.max_fuel += tool_upgrades[UPGRADE_MAXFUEL]
if(tool_upgrades[UPGRADE_MAXUPGRADES])
T.max_upgrades += tool_upgrades[UPGRADE_MAXUPGRADES]
if(tool_upgrades[UPGRADE_SHARP])
T.sharp = tool_upgrades[UPGRADE_SHARP]
if(!T.GetComponent(/datum/component/butchering))
T.AddComponent(/datum/component/butchering, FALSE, FALSE)
if(tool_upgrades[UPGRADE_COLOR])
T.color = tool_upgrades[UPGRADE_COLOR]
if(tool_upgrades[UPGRADE_ITEMFLAGPLUS])
T.item_flags |= tool_upgrades[UPGRADE_ITEMFLAGPLUS]
if(tool_upgrades[UPGRADE_CELLPLUS])
switch(T.suitable_cell)
if(/obj/item/cell/medium)
T.suitable_cell = /obj/item/cell/large
prefix = "large-cell"
if(/obj/item/cell/small)
T.suitable_cell = /obj/item/cell/medium
T.force = initial(T.force) * T.force_upgrade_mults + T.force_upgrade_mods
T.switched_on_force = initial(T.switched_on_force) * T.force_upgrade_mults + T.force_upgrade_mods
T.prefixes |= prefix
/datum/component/item_upgrade/proc/apply_values_gun(obj/item/gun/G)
if(weapon_upgrades[GUN_UPGRADE_DAMAGEMOD_PLUS])
G.damage_multiplier += weapon_upgrades[GUN_UPGRADE_DAMAGEMOD_PLUS]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_MULT])
G.damage_multiplier *= weapon_upgrades[GUN_UPGRADE_DAMAGE_MULT]
if(weapon_upgrades[GUN_UPGRADE_HALLOSS_MULT])
G.halloss_multiplier *= weapon_upgrades[GUN_UPGRADE_HALLOSS_MULT]
if(weapon_upgrades[GUN_UPGRADE_PEN_MULT])
G.penetration_multiplier += weapon_upgrades[GUN_UPGRADE_PEN_MULT]
if(weapon_upgrades[GUN_UPGRADE_PIERC_MULT])
G.pierce_multiplier += weapon_upgrades[GUN_UPGRADE_PIERC_MULT]
if(weapon_upgrades[GUN_UPGRADE_RICO_MULT])
G.ricochet_multiplier += weapon_upgrades[GUN_UPGRADE_RICO_MULT]
if(!isnull(weapon_upgrades[GUN_UPGRADE_STEPDELAY_MULT])) // so AMR barrel can 0x
G.proj_step_multiplier *= weapon_upgrades[GUN_UPGRADE_STEPDELAY_MULT]
if(weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT])
G.fire_delay *= weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT]
if(weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT])
G.move_delay *= weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT]
if(weapon_upgrades[GUN_UPGRADE_RECOIL])
G.recoil = G.recoil.modifyAllRatings(weapon_upgrades[GUN_UPGRADE_RECOIL])
if(weapon_upgrades[GUN_UPGRADE_MUZZLEFLASH])
G.muzzle_flash *= weapon_upgrades[GUN_UPGRADE_MUZZLEFLASH]
if(weapon_upgrades[GUN_UPGRADE_SILENCER])
G.silenced = weapon_upgrades[GUN_UPGRADE_SILENCER]
if(weapon_upgrades[GUN_UPGRADE_OFFSET])
G.init_offset = max(0, G.init_offset+weapon_upgrades[GUN_UPGRADE_OFFSET])
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_BRUTE])
G.proj_damage_adjust[BRUTE] += weapon_upgrades[GUN_UPGRADE_DAMAGE_BRUTE]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_BURN])
G.proj_damage_adjust[BURN] += weapon_upgrades[GUN_UPGRADE_DAMAGE_BURN]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_TOX])
G.proj_damage_adjust[TOX] += weapon_upgrades[GUN_UPGRADE_DAMAGE_TOX]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_OXY])
G.proj_damage_adjust[OXY] += weapon_upgrades[GUN_UPGRADE_DAMAGE_OXY]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_CLONE])
G.proj_damage_adjust[CLONE] += weapon_upgrades[GUN_UPGRADE_DAMAGE_CLONE]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_HALLOSS])
G.proj_damage_adjust[HALLOSS] += weapon_upgrades[GUN_UPGRADE_DAMAGE_HALLOSS]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_RADIATION])
G.proj_damage_adjust[IRRADIATE] += weapon_upgrades[GUN_UPGRADE_DAMAGE_RADIATION]
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_PSY])
G.proj_damage_adjust[PSY] += weapon_upgrades[GUN_UPGRADE_DAMAGE_PSY]
if(weapon_upgrades[GUN_UPGRADE_HONK])
G.fire_sound = 'sound/items/bikehorn.ogg'
if(weapon_upgrades[GUN_UPGRADE_RIGGED])
G.rigged = TRUE
if(weapon_upgrades[GUN_UPGRADE_FOREGRIP])
G.braceable = 0
if(weapon_upgrades[GUN_UPGRADE_BIPOD])
G.braceable += GUN_UPGRADE_BIPOD
if(weapon_upgrades[GUN_UPGRADE_EXPLODE])
G.rigged = 2
if(weapon_upgrades[GUN_UPGRADE_ZOOM])
if(G.zoom_factors.len <1)
var/newtype = weapon_upgrades[GUN_UPGRADE_ZOOM]
G.zoom_factors.Add(newtype)
G.initialize_scope()
if(ismob(G.loc))
var/mob/user = G.loc
user.update_action_buttons()
if(weapon_upgrades[GUN_UPGRADE_SCOPEVISION])
G.see_invisible_gun = max(G.see_invisible_gun, weapon_upgrades[GUN_UPGRADE_SCOPEVISION]) // scope stats should take best of class
if(weapon_upgrades[GUN_UPGRADE_SCOPECORRECTION])
G.scoped_offset_reduction = max(G.scoped_offset_reduction, weapon_upgrades[GUN_UPGRADE_SCOPECORRECTION])
if(weapon_upgrades[GUN_UPGRADE_DARKSCOPE])
G.darkness_view = max(G.darkness_view, weapon_upgrades[GUN_UPGRADE_DARKSCOPE])
if(weapon_upgrades[GUN_UPGRADE_THERMAL])
G.vision_flags = SEE_MOBS
if(weapon_upgrades[GUN_UPGRADE_GILDED])
G.gilded = TRUE
if(weapon_upgrades[GUN_UPGRADE_BAYONET])
G.attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
G.sharp = TRUE
if(weapon_upgrades[GUN_UPGRADE_MELEEDAMAGE])
G.force += weapon_upgrades[GUN_UPGRADE_MELEEDAMAGE]
if(weapon_upgrades[GUN_UPGRADE_MELEEPENETRATION])
G.armor_divisor += weapon_upgrades[GUN_UPGRADE_MELEEPENETRATION]
if(weapon_upgrades[GUN_UPGRADE_ONEHANDPENALTY])
G.recoil = G.recoil.modifyRating(_one_hand_penalty = weapon_upgrades[GUN_UPGRADE_ONEHANDPENALTY])
if(weapon_upgrades[GUN_UPGRADE_MOVEPENALTY])
G.recoil = G.recoil.modifyRating(_brace_penalty = weapon_upgrades[GUN_UPGRADE_MOVEPENALTY])
if(weapon_upgrades[GUN_UPGRADE_RECOILBUILDUP])
G.recoil = G.recoil.modifyRating(_recoil_buildup = weapon_upgrades[GUN_UPGRADE_RECOILBUILDUP])
if(weapon_upgrades[GUN_UPGRADE_DNALOCK])
G.dna_compare_samples = TRUE
if(G.dna_lock_sample == "not_set")
G.dna_lock_sample = usr.real_name
if(G.dna_compare_samples == FALSE)
G.dna_lock_sample = "not_set"
if(G.dna_lock_sample == "not_set") //that may look stupid, but without it previous two lines won't trigger on DNALOCK removal.
G.dna_compare_samples = FALSE
if(!isnull(weapon_upgrades[GUN_UPGRADE_FORCESAFETY]))
G.restrict_safety = TRUE
G.safety = weapon_upgrades[GUN_UPGRADE_FORCESAFETY]
if(istype(G, /obj/item/gun/energy))
var/obj/item/gun/energy/E = G
if(weapon_upgrades[GUN_UPGRADE_CHARGECOST])
E.charge_cost *= weapon_upgrades[GUN_UPGRADE_CHARGECOST]
if(weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX])
E.overcharge_rate *= weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX]
if(weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX])
E.overcharge_max *= weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX]
if(istype(G, /obj/item/gun/projectile))
var/obj/item/gun/projectile/P = G
if(weapon_upgrades[GUN_UPGRADE_MAGUP])
P.max_shells += weapon_upgrades[GUN_UPGRADE_MAGUP]
if(istype(G, /obj/item/gun/projectile/automatic/modular))
var/obj/item/gun/projectile/automatic/modular/M = G
if(weapon_upgrades[GUN_UPGRADE_DEFINE_MAG_WELL])
M.mag_well = weapon_upgrades[GUN_UPGRADE_DEFINE_MAG_WELL]
if(weapon_upgrades[GUN_UPGRADE_DEFINE_OK_CALIBERS])
M.good_calibers = weapon_upgrades[GUN_UPGRADE_DEFINE_OK_CALIBERS]
if(weapon_upgrades[GUN_UPGRADE_DEFINE_CALIBER])
M.caliber = weapon_upgrades[GUN_UPGRADE_DEFINE_CALIBER]
if(weapon_upgrades[GUN_UPGRADE_DEFINE_STOCK] && !(PARTMOD_FOLDING_STOCK & M.spriteTagBans))
M.spriteTags |= PARTMOD_FOLDING_STOCK // Adds the stock to the spriteTags
M.verbs += /obj/item/gun/projectile/automatic/modular/proc/quick_fold // Grant the verb for folding stocks
if(weapon_upgrades[GUN_UPGRADE_DEFINE_GRIP])
M.grip_type = weapon_upgrades[GUN_UPGRADE_DEFINE_GRIP]
if(weapon_upgrades[GUN_UPGRADE_DEFINE_LOADER])
M.load_method = weapon_upgrades[GUN_UPGRADE_DEFINE_LOADER]
if(weapon_upgrades[GUN_UPGRADE_DENY_MAG])
M.no_internal_mag = TRUE
if(weapon_upgrades[GUN_UPGRADE_DEFINE_WCLASS])
M.w_class += weapon_upgrades[GUN_UPGRADE_DEFINE_WCLASS]
if(weapon_upgrades[GUN_UPGRADE_SCOPE_POWER])
M.scope_damage_adds.Add(weapon_upgrades[GUN_UPGRADE_SCOPE_POWER])
for(var/datum/firemode/F in G.firemodes)
apply_values_firemode(F)
/datum/component/item_upgrade/proc/add_values_gun(obj/item/gun/G)
if(weapon_upgrades[GUN_UPGRADE_FULLAUTO])
G.add_firemode(FULL_AUTO_400)
if(weapon_upgrades[GUN_UPGRADE_FIREMODES])
for(var/FM in weapon_upgrades[GUN_UPGRADE_FIREMODES])
G.add_firemode(FM)
if(istype(G, /obj/item/gun/projectile/automatic/modular))
if(weapon_upgrades[GUN_UPGRADE_REPLACE_INTERACTIONS])
var/obj/item/gun/projectile/automatic/modular/interactive = G
var/datum/gunoverrides/overrided = interactive.overridedatum
if(overrided)
var/datum/guninteraction/interaction = weapon_upgrades[GUN_UPGRADE_REPLACE_INTERACTIONS]
interaction.parentgun = G
if(islist(overrided.priorities["[interaction.priority]"]))
var/list/currentpriority = overrided.priorities["[interaction.priority]"]
currentpriority.Add(interaction)
else
overrided.priorities["[interaction.priority]"] = list(interaction)
/datum/component/item_upgrade/proc/reset_owner()
if(weapon_upgrades[GUN_UPGRADE_REPLACE_INTERACTIONS])
var/datum/guninteraction/interaction = weapon_upgrades[GUN_UPGRADE_REPLACE_INTERACTIONS]
if(istype(interaction))
interaction.parentgun = null
if(weapon_upgrades[GUN_UPGRADE_DEFINE_WCLASS])
if(istype(parent, /obj/item/part/gun/modular/stock))
var/obj/item/part/gun/modular/stock/base = parent
weapon_upgrades[GUN_UPGRADE_DEFINE_WCLASS] = base.wclassmod
/datum/component/item_upgrade/proc/apply_values_firemode(datum/firemode/F)
for(var/i in F.settings)
switch(i)
if("fire_delay")
if(weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT])
F.settings[i] *= weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT]
if("move_delay")
if(weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT])
F.settings[i] *= weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT]
/datum/component/item_upgrade/proc/on_examine(mob/user, list/reference)
SIGNAL_HANDLER
if(tool_upgrades[UPGRADE_SANCTIFY])
reference.Add(span_notice("Does additional burn damage to mutants."))
if (tool_upgrades[UPGRADE_PRECISION] > 0)
reference.Add(span_notice("Enhances precision by [tool_upgrades[UPGRADE_PRECISION]]"))
else if(tool_upgrades[UPGRADE_PRECISION] < 0)
reference.Add(span_warning("Reduces precision by [abs(tool_upgrades[UPGRADE_PRECISION])]"))
if(tool_upgrades[UPGRADE_WORKSPEED])
reference.Add(span_notice("Enhances workspeed by [tool_upgrades[UPGRADE_WORKSPEED]*100]%"))
if(tool_upgrades[UPGRADE_DEGRADATION_MULT])
if(tool_upgrades[UPGRADE_DEGRADATION_MULT] < 1)
reference.Add(span_notice("Reduces tool degradation by [(1-tool_upgrades[UPGRADE_DEGRADATION_MULT])*100]%"))
else if (tool_upgrades[UPGRADE_DEGRADATION_MULT] > 1)
reference.Add(span_warning("Increases tool degradation by [(tool_upgrades[UPGRADE_DEGRADATION_MULT]-1)*100]%"))
if(tool_upgrades[UPGRADE_FORCE_MULT] >= 1)
reference.Add(span_notice("Increases tool damage by [(tool_upgrades[UPGRADE_FORCE_MULT]-1)*100]%"))
if(tool_upgrades[UPGRADE_FORCE_MOD])
reference.Add(span_notice("Increases tool damage by [tool_upgrades[UPGRADE_FORCE_MOD]]"))
if(tool_upgrades[UPGRADE_POWERCOST_MULT] >= 1)
reference.Add(span_warning("Modifies power usage by [(tool_upgrades[UPGRADE_POWERCOST_MULT]-1)*100]%"))
if(tool_upgrades[UPGRADE_FUELCOST_MULT] >= 1)
reference.Add(span_warning("Modifies fuel usage by [(tool_upgrades[UPGRADE_FUELCOST_MULT]-1)*100]%"))
if(tool_upgrades[UPGRADE_MAXFUEL])
reference.Add(span_notice("Modifies fuel storage by [tool_upgrades[UPGRADE_MAXFUEL]] units."))
if(tool_upgrades[UPGRADE_BULK])
reference.Add(span_warning("Increases tool size by [tool_upgrades[UPGRADE_BULK]]"))
if(tool_upgrades[UPGRADE_MAXUPGRADES])
reference.Add(span_notice("Adds [tool_upgrades[UPGRADE_MAXUPGRADES]] additional modification slots."))
if(required_qualities.len)
reference.Add(span_warning("Requires a tool with one of the following qualities:"))
reference.Add(english_list(required_qualities, and_text = " or "))
if(weapon_upgrades.len)
reference.Add(span_notice("Can be attached to a firearm, giving the following benefits:"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGEMOD_PLUS])
var/amount = weapon_upgrades[GUN_UPGRADE_DAMAGEMOD_PLUS]
if(amount > 0)
reference.Add(span_notice("Increases projectile damage multiplier by [amount]"))
else
reference.Add(span_warning("Decreases projectile damage by [abs(amount)]"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_DAMAGE_MULT]-1
if(amount > 0)
reference.Add(span_notice("Increases projectile damage by [amount*100]%"))
else
reference.Add(span_warning("Decreases projectile damage by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_PEN_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_PEN_MULT]
if(amount > 0)
reference.Add(span_notice("Increases projectile penetration by [amount*100]%"))
else
reference.Add(span_warning("Decreases projectile penetration by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_PIERC_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_PIERC_MULT]
if(amount > 1)
reference.Add(span_notice("Increases projectile piercing penetration by [amount] walls"))
else if(amount == 1)
reference.Add(span_notice("Increases projectile piercing penetration by [amount] wall"))
else if(amount == -1)
reference.Add(span_warning("Decreases projectile piercing penetration by [amount] wall"))
else
reference.Add(span_warning("Decreases projectile piercing penetration by [amount] walls"))
if(weapon_upgrades[GUN_UPGRADE_RICO_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_RICO_MULT]
if(amount > 0)
reference.Add(span_warning("Increases projectile ricochet by [amount*100]%"))
else
reference.Add(span_notice("Decreases projectile ricochet by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_FIRE_DELAY_MULT]-1
if(amount > 0)
reference.Add(span_warning("Increases fire delay by [amount*100]%"))
else
reference.Add(span_notice("Decreases fire delay by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_MOVE_DELAY_MULT]-1
if(amount > 0)
reference.Add(span_warning("Increases move delay by [amount*100]%"))
else
reference.Add(span_notice("Decreases move delay by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_STEPDELAY_MULT])
var/amount = weapon_upgrades[GUN_UPGRADE_STEPDELAY_MULT]-1
if(amount > 0)
reference.Add(span_warning("Slows down the weapons projectile by [amount*100]%"))
else
reference.Add(span_notice("Speeds up the weapons projectile by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_BRUTE])
reference.Add(span_notice("Modifies projectile brute damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_BRUTE]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_BURN])
reference.Add(span_notice("Modifies projectile burn damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_BURN]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_TOX])
reference.Add(span_notice("Modifies projectile toxic damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_TOX]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_OXY])
reference.Add(span_notice("Modifies projectile oxy-loss damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_OXY]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_CLONE])
reference.Add(span_notice("Modifies projectile clone damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_CLONE]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_HALLOSS])
reference.Add(span_notice("Modifies projectile pseudo damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_HALLOSS]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_RADIATION])
reference.Add(span_notice("Modifies projectile radiation damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_RADIATION]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_DAMAGE_PSY])
reference.Add(span_notice("Modifies projectile psy damage by [weapon_upgrades[GUN_UPGRADE_DAMAGE_PSY]] damage points"))
if(weapon_upgrades[GUN_UPGRADE_RECOIL])
var/amount = weapon_upgrades[GUN_UPGRADE_RECOIL]-1
if(amount > 0)
reference.Add(span_warning("Increases kickback by [amount*100]%"))
else
reference.Add(span_notice("Decreases kickback by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_MUZZLEFLASH])
var/amount = weapon_upgrades[GUN_UPGRADE_MUZZLEFLASH]-1
if(amount > 0)
reference.Add(span_warning("Increases muzzle flash by [amount*100]%"))
else
reference.Add(span_notice("Decreases muzzle flash by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_MAGUP])
var/amount = weapon_upgrades[GUN_UPGRADE_MAGUP]
if(amount > 1)
reference.Add(span_notice("Increases internal magazine size by [amount]"))
else
reference.Add(span_warning("Decreases internal magazine size by [amount]"))
if(weapon_upgrades[GUN_UPGRADE_SILENCER] == 1)
reference.Add(span_notice("Silences the weapon."))
if(weapon_upgrades[GUN_UPGRADE_FORCESAFETY] == 0)
reference.Add(span_warning("Disables the safety toggle of the weapon."))
else if(weapon_upgrades[GUN_UPGRADE_FORCESAFETY] == 1)
reference.Add(span_warning("Forces the safety toggle of the weapon to always be on."))
if(weapon_upgrades[GUN_UPGRADE_DNALOCK] == 1)
reference.Add(span_warning("Adds a biometric scanner to the weapon."))
if(weapon_upgrades[GUN_UPGRADE_CHARGECOST])
var/amount = weapon_upgrades[GUN_UPGRADE_CHARGECOST]-1
if(amount > 0)
reference.Add(span_warning("Increases cell firing cost by [amount*100]%"))
else
reference.Add(span_notice("Decreases cell firing cost by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX])
var/amount = weapon_upgrades[GUN_UPGRADE_OVERCHARGE_MAX]-1
if(amount > 0)
reference.Add(span_warning("Increases overcharge maximum by [amount*100]%"))
else
reference.Add(span_notice("Decreases overcharge maximum by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_OVERCHARGE_RATE])
var/amount = weapon_upgrades[GUN_UPGRADE_OVERCHARGE_RATE]-1
if(amount > 0)
reference.Add(span_notice("Increases overcharge rate by [amount*100]%"))
else
reference.Add(span_warning("Decreases overcharge rate by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_OFFSET])
var/amount = weapon_upgrades[GUN_UPGRADE_OFFSET]-1
if(amount > 0)
reference.Add(span_warning("Increases weapon inaccuracy by [amount*100]%"))
else
reference.Add(span_notice("Decreases weapon inaccuracy by [abs(amount*100)]%"))
if(weapon_upgrades[GUN_UPGRADE_HONK])
reference.Add(span_warning("Cheers up the firing sound of the weapon."))
if(weapon_upgrades[GUN_UPGRADE_RIGGED])
reference.Add(span_warning("Rigs the weapon to fire back on its user."))
if(weapon_upgrades[GUN_UPGRADE_EXPLODE])
reference.Add(span_warning("Rigs the weapon to explode."))
if(weapon_upgrades[GUN_UPGRADE_ZOOM])
var/amount = weapon_upgrades[GUN_UPGRADE_ZOOM]
if(amount > 0)
reference.Add(span_notice("Increases scope zoom by x[amount]"))
else
reference.Add(span_warning("Decreases scope zoom by x[amount]"))
// It is best we stick to description with some of these, at least for now
if(weapon_upgrades[GUN_UPGRADE_DEFINE_CALIBER])
var/amount = weapon_upgrades[GUN_UPGRADE_DEFINE_CALIBER]
reference.Add(span_warning("Fits [amount] caliber bullets"))
if(weapon_upgrades[GUN_UPGRADE_DEFINE_OK_CALIBERS])
var/amount = weapon_upgrades[GUN_UPGRADE_DEFINE_OK_CALIBERS]
reference.Add(span_warning("Fits the following calibers: [english_list(amount, "None are suitable!", " and ", ", ", ".")]"))
/*if(weapon_upgrades[GUN_UPGRADE_DEFINE_MAG_WELL])
var/amount = weapon_upgrades[GUN_UPGRADE_DEFINE_MAG_WELL]
to_chat(user, span_warning("Fits a variety of magazines."))*/
reference.Add(span_warning("Requires a weapon with the following properties"))
reference.Add(english_list(req_gun_tags))
/datum/component/item_upgrade/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_IATTACK)
UnregisterSignal(parent, COMSIG_EXAMINE)
UnregisterSignal(parent, COMSIG_REMOVE)
/datum/component/item_upgrade/PostTransfer()
return COMPONENT_TRANSFER
/datum/component/upgrade_removal
dupe_mode = COMPONENT_DUPE_UNIQUE
/datum/component/upgrade_removal/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATTACKBY, PROC_REF(attempt_uninstall))
/datum/component/upgrade_removal/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATTACKBY)
// FALSE return value causes attackby to be called on the item. Which means, we only want this to resolve to FALSE if we don't want to remove any parts.
/datum/component/upgrade_removal/proc/attempt_uninstall(obj/item/C, mob/living/user)
//SIGNAL_HANDLER
if(!isitem(C))
return FALSE
var/obj/item/upgrade_loc = parent
var/obj/item/tool/T //For dealing damage to the item
if(istool(upgrade_loc))
T = upgrade_loc
ASSERT(istype(upgrade_loc))
//Removing upgrades from a tool. Very difficult, but passing the check only gets you the perfect result
//You can also get a lesser success (remove the upgrade but break it in the process) if you fail
//Using a laser guided stabilised screwdriver is recommended. Precision mods will make this easier
if(upgrade_loc.item_upgrades.len && C.has_quality(QUALITY_SCREW_DRIVING))
var/list/possibles = upgrade_loc.item_upgrades.Copy()
possibles += "Cancel"
possibles += "Do something else"
var/obj/item/tool_upgrade/toremove = input("Which upgrade would you like to try to remove? The upgrade will probably be destroyed in the process","Removing Upgrades") in possibles
if(toremove == "Cancel")
return TRUE
if(toremove == "Do something else")
return FALSE // We want to use the tool for something else, eg. the bolt turning of a combi driver to disassemble a gun
var/datum/component/item_upgrade/IU = toremove.GetComponent(/datum/component/item_upgrade)
if(IU.removable == MOD_FUSED)
to_chat(user, span_danger("\the [toremove] seems to be fused with the [upgrade_loc]!"))
return TRUE
else
if(IU.removable == MOD_INTEGRAL)
if(istype(upgrade_loc, /obj/item/gun/projectile/automatic/modular))
var/obj/item/gun/projectile/automatic/modular/MG = upgrade_loc
if(MG.loaded.len || MG.ammo_magazine || MG.chambered)
to_chat(user, span_danger("You must unload the [upgrade_loc] before removing \the [toremove]!"))
return TRUE
if(C.use_tool(user = user, target = upgrade_loc, base_time = IU.removal_time, required_quality = QUALITY_SCREW_DRIVING, fail_chance = IU.removal_difficulty, required_stat = STAT_MEC))
//If you pass the check, then you manage to remove the upgrade intact
if(!IU.destroy_on_removal && user)
to_chat(user, span_notice("You successfully remove \the [toremove] while leaving it intact."))
SEND_SIGNAL_OLD(toremove, COMSIG_REMOVE, upgrade_loc)
upgrade_loc.refresh_upgrades()
return TRUE
else
//You failed the check, lets see what happens
if(IU.breakable == FALSE)
to_chat(user, span_danger("You failed to remove \the [toremove]."))
upgrade_loc.refresh_upgrades()
user.update_action_buttons()
return TRUE
else if(prob(50))
//50% chance to break the upgrade and remove it
to_chat(user, span_danger("You successfully remove \the [toremove], but destroy it in the process."))
SEND_SIGNAL_OLD(toremove, COMSIG_REMOVE, parent)
QDEL_NULL(toremove)
upgrade_loc.refresh_upgrades()
user.update_action_buttons()
return TRUE
else if(T && T.degradation) //Because robot tools are unbreakable
//otherwise, damage the host tool a bit, and give you another try
to_chat(user, span_danger("You only managed to damage \the [upgrade_loc], but you can retry."))
T.adjustToolHealth(-(5 * T.degradation), user) // inflicting 4 times use damage
upgrade_loc.refresh_upgrades()
user.update_action_buttons()
return TRUE
return FALSE
/obj/item/tool_upgrade
name = "tool upgrade"
icon = 'icons/obj/tool_upgrades.dmi'
icon_state = "placeholder" // Needed for UI
force = WEAPON_FORCE_HARMLESS
w_class = ITEM_SIZE_SMALL
spawn_tags = SPAWN_TAG_TOOL_UPGRADE
price_tag = 200
rarity_value = 15
bad_type = /obj/item/tool_upgrade