73
73
var /initial_eprojectile = null
74
74
// / What non-lethal mode projectile with the turret start with?
75
75
var /initial_projectile = null
76
+ // / What lens is fitted to the turret/gun?
77
+ var /obj /item/smithed_item/lens/fitted_lens
76
78
77
79
78
80
/ obj / machinery/ porta_turret/ Initialize(mapload)
@@ -381,6 +383,10 @@ GLOBAL_LIST_EMPTY(turret_icons)
381
383
if (installation)
382
384
var /obj /item/gun/energy/Gun = new installation(loc)
383
385
Gun. cell. charge = gun_charge
386
+ if (fitted_lens)
387
+ Gun. current_lens = fitted_lens
388
+ fitted_lens. forceMove(Gun)
389
+ Gun. current_lens. on_attached(Gun)
384
390
Gun. update_icon()
385
391
if (prob(50 ))
386
392
new / obj / item/ stack/ sheet/ metal(loc, rand(1 ,4 ))
@@ -390,6 +396,18 @@ GLOBAL_LIST_EMPTY(turret_icons)
390
396
to_chat (user, " <span class='notice'>You remove the turret but did not manage to salvage anything.</span>" )
391
397
qdel (src ) // qdel
392
398
399
+ / obj / machinery/ porta_turret/ screwdriver_act( mob / living/ user, obj / item/ I)
400
+ if (user. a_intent != INTENT_HELP )
401
+ return FALSE
402
+
403
+ if (! fitted_lens)
404
+ to_chat (user, " <span class='notice'>[ src ] has no attached lenses.</span>" )
405
+ return
406
+ to_chat (user, " <span class='notice'>You remove the lens from [ src ] </span>" )
407
+ user. put_in_hands(fitted_lens)
408
+ fitted_lens = null
409
+ return TRUE
410
+
393
411
/ obj / machinery/ porta_turret/ item_interaction( mob / living/ user, obj / item/ used, list / modifiers)
394
412
if ((stat & BROKEN ) && ! syndicate)
395
413
return ITEM_INTERACT_COMPLETE
@@ -406,6 +424,17 @@ GLOBAL_LIST_EMPTY(turret_icons)
406
424
407
425
return ITEM_INTERACT_COMPLETE
408
426
427
+ if (istype(used, / obj / item/ smithed_item/ lens))
428
+ if (used. flags & NODROP || ! user. drop_item() || ! used. forceMove(src ))
429
+ to_chat (user, " <span class='warning'>[ used] is stuck to your hand!</span>" )
430
+ return ITEM_INTERACT_COMPLETE
431
+ var /obj /item/smithed_item/lens/new_lens = used
432
+ if (fitted_lens)
433
+ to_chat (user, " <span class='notice'>You swap the fitted lens in [ src ] .</span>" )
434
+ user. put_in_hands(fitted_lens)
435
+ fitted_lens = new_lens
436
+ return ITEM_INTERACT_COMPLETE
437
+
409
438
if (user. a_intent == INTENT_HELP )
410
439
return .. ()
411
440
@@ -759,7 +788,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
759
788
return
760
789
761
790
if (! emagged) // if it hasn't been emagged, cooldown before shooting again
762
- if ((last_fired + shot_delay > world . time) || ! raised)
791
+ if ((last_fired + ( shot_delay / fitted_lens . fire_rate_mult) > world . time) || ! raised)
763
792
return
764
793
last_fired = world . time
765
794
@@ -779,9 +808,16 @@ GLOBAL_LIST_EMPTY(turret_icons)
779
808
A = new projectile(loc)
780
809
playsound (loc, shot_sound, 75 , 1 )
781
810
811
+ var /lens_power_mult = 1
812
+ if (fitted_lens)
813
+ A. damage = A. damage * fitted_lens. damage_mult
814
+ A. stamina = A. damage * fitted_lens. damage_mult
815
+ A. speed = A. speed / fitted_lens. laser_speed_mult
816
+ lens_power_mult = fitted_lens. power_mult
817
+
782
818
// Lethal/emagged turrets use twice the power due to higher energy beams
783
819
// Emagged turrets again use twice as much power due to higher firing rates
784
- use_power (reqpower * (2 * (emagged || lethal)) * (2 * emagged))
820
+ use_power (lens_power_mult * ( reqpower * (2 * (emagged || lethal)) * (2 * emagged) ))
785
821
786
822
if (istype(A))
787
823
A. original = target
@@ -868,6 +904,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
868
904
var /finish_name = " turret" // the name applied to the product turret
869
905
var /installation = null // the gun type installed
870
906
var /gun_charge = 0 // the gun charge of the gun type installed
907
+ // / The lens attached to the gun used
908
+ var /obj /item/smithed_item/lens/gun_lens
871
909
872
910
/ obj / machinery/ porta_turret_construct/ item_interaction( mob / living/ user, obj / item/ used, list / modifiers)
873
911
// this is a bit unwieldy but self-explanatory
@@ -925,6 +963,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
925
963
return ITEM_INTERACT_COMPLETE
926
964
installation = used. type // installation becomes used.type
927
965
gun_charge = E. cell. charge // the gun's charge is stored in gun_charge
966
+ gun_lens = E. current_lens
928
967
to_chat (user, " <span class='notice'>You add [ used] to the turret.</span>" )
929
968
930
969
if (istype(E, / obj / item/ gun/ energy/ laser/ tag/ blue))
@@ -1018,6 +1057,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
1018
1057
Turret. name = finish_name
1019
1058
Turret. installation = installation
1020
1059
Turret. gun_charge = gun_charge
1060
+ gun_lens. forceMove(Turret)
1061
+ Turret. fitted_lens = gun_lens
1021
1062
Turret. enabled = FALSE
1022
1063
Turret. setup()
1023
1064
0 commit comments