Adds examine messages for helmets & guns with flashlights (and bayonets) (#40998)

cl ShizCalev
tweak: Added examine messages for helmets & guns with flashlights (and bayonets.)
fix: Fixed an issue where you were able to remove flashlights/bayonets that were supposed to be permanently attached to a gun.
fix: Fixed an issue where you were unable to remove flashlights & bayonets from certain weapons.
fix: Fixed a potential issue where adding a flashlight to your helmet would've caused you to lose other action buttons.
fix: Fixed a issue where guns with multiple action buttons would break all but one of those action buttons.
tweak: If you have both a bayonet and a flashlight attached to your gun, you'll now be given a prompt on which you'd like to remove when using a screwdriver on it.
/cl

Shouldn't need to have "pro-gamer tips" in adminpm's just to inform folks that you can remove a flashlight from a helmet with a screwdriver.

Also added some missing handle_atom_del / Destroy logic, as well as moving the clothing can_flashlight & flashlight vars down to helmet level (since they were the only things that utilize them anyway.)

also why the fuck was the helmet flashlight var just called F. hnnnngg
This commit is contained in:
ShizCalev
2018-10-26 20:10:37 -04:00
committed by oranges
parent d87ee8d293
commit fe10959af0
13 changed files with 222 additions and 134 deletions

View File

@@ -41,20 +41,21 @@
var/obj/item/firing_pin/pin = /obj/item/firing_pin //standard firing pin for most guns
var/obj/item/flashlight/gun_light
var/can_flashlight = 0
var/can_flashlight = FALSE //if a flashlight can be added or removed if it already has one.
var/obj/item/flashlight/seclite/gun_light
var/mutable_appearance/flashlight_overlay
var/datum/action/item_action/toggle_gunlight/alight
var/can_bayonet = FALSE //if a bayonet can be added or removed if it already has one.
var/obj/item/kitchen/knife/bayonet
var/mutable_appearance/knife_overlay
var/can_bayonet = FALSE
var/datum/action/item_action/toggle_gunlight/alight
var/mutable_appearance/flashlight_overlay
var/knife_x_offset = 0
var/knife_y_offset = 0
var/ammo_x_offset = 0 //used for positioning ammo count overlay on sprite
var/ammo_y_offset = 0
var/flight_x_offset = 0
var/flight_y_offset = 0
var/knife_x_offset = 0
var/knife_y_offset = 0
//Zooming
var/zoomable = FALSE //whether the gun generates a Zoom action on creation
@@ -68,9 +69,28 @@
if(pin)
pin = new pin(src)
if(gun_light)
alight = new /datum/action/item_action/toggle_gunlight(src)
alight = new(src)
build_zooming()
/obj/item/gun/Destroy()
QDEL_NULL(pin)
QDEL_NULL(gun_light)
QDEL_NULL(bayonet)
QDEL_NULL(chambered)
QDEL_NULL(azoom)
return ..()
/obj/item/gun/handle_atom_del(atom/A)
if(A == pin)
pin = null
if(A == chambered)
chambered = null
update_icon()
if(A == bayonet)
clear_bayonet()
if(A == gun_light)
clear_gunlight()
return ..()
/obj/item/gun/CheckParts(list/parts_list)
..()
@@ -86,7 +106,21 @@
if(pin)
to_chat(user, "It has \a [pin] installed.")
else
to_chat(user, "It doesn't have a firing pin installed, and won't fire.")
to_chat(user, "It doesn't have a <b>firing pin</b> installed, and won't fire.")
if(gun_light)
to_chat(user, "It has \a [gun_light] [can_flashlight ? "" : "permanently "]mounted on it.")
if(can_flashlight) //if it has a light and this is false, the light is permanent.
to_chat(user, "<span class='info'>[gun_light] looks like it can be <b>unscrewed</b> from [src].</span>")
else if(can_flashlight)
to_chat(user, "It has a mounting point for a <b>seclite</b>.")
if(bayonet)
to_chat(user, "It has \a [bayonet] [can_bayonet ? "" : "permanently "]affixed to it.")
if(can_bayonet) //if it has a bayonet and this is false, the bayonet is permanent.
to_chat(user, "<span class='info'>[bayonet] looks like it can be <b>unscrewed</b> from [src].</span>")
else if(can_bayonet)
to_chat(user, "It has a <b>bayonet</b> lug on it.")
/obj/item/gun/equipped(mob/living/user, slot)
. = ..()
@@ -104,7 +138,7 @@
/obj/item/gun/proc/shoot_with_empty_chamber(mob/living/user as mob|obj)
to_chat(user, "<span class='danger'>*click*</span>")
playsound(src, "gun_dry_fire", 30, 1)
playsound(src, "gun_dry_fire", 30, TRUE)
/obj/item/gun/proc/shoot_live_shot(mob/living/user as mob|obj, pointblank = 0, mob/pbtarget = null, message = 1)
@@ -112,9 +146,9 @@
shake_camera(user, recoil + 1, recoil)
if(suppressed)
playsound(user, fire_sound, 10, 1)
playsound(user, fire_sound, 10, TRUE)
else
playsound(user, fire_sound, 50, 1)
playsound(user, fire_sound, 50, TRUE)
if(message)
if(pointblank)
user.visible_message("<span class='danger'>[user] fires [src] point blank at [pbtarget]!</span>", null, null, COMBAT_MESSAGE_RANGE)
@@ -323,12 +357,12 @@
if(!gun_light)
if(!user.transferItemToLoc(I, src))
return
to_chat(user, "<span class='notice'>You click \the [S] into place on \the [src].</span>")
to_chat(user, "<span class='notice'>You click [S] into place on [src].</span>")
if(S.on)
set_light(0)
gun_light = S
update_gunlight(user)
alight = new /datum/action/item_action/toggle_gunlight(src)
update_gunlight()
alight = new(src)
if(loc == user)
alight.Grant(user)
else if(istype(I, /obj/item/kitchen/knife))
@@ -337,7 +371,7 @@
return ..()
if(!user.transferItemToLoc(I, src))
return
to_chat(user, "<span class='notice'>You attach \the [K] to the front of \the [src].</span>")
to_chat(user, "<span class='notice'>You attach [K] to [src]'s bayonet lug.</span>")
bayonet = K
var/state = "bayonet" //Generic state.
if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state?
@@ -347,25 +381,67 @@
knife_overlay.pixel_x = knife_x_offset
knife_overlay.pixel_y = knife_y_offset
add_overlay(knife_overlay, TRUE)
else if(I.tool_behaviour == TOOL_SCREWDRIVER)
if(gun_light)
var/obj/item/flashlight/seclite/S = gun_light
to_chat(user, "<span class='notice'>You unscrew the seclite from \the [src].</span>")
gun_light = null
S.forceMove(get_turf(user))
update_gunlight(user)
S.update_brightness(user)
QDEL_NULL(alight)
if(bayonet)
to_chat(user, "<span class='notice'>You unscrew the bayonet from \the [src].</span>")
var/obj/item/kitchen/knife/K = bayonet
K.forceMove(get_turf(user))
bayonet = null
cut_overlay(knife_overlay, TRUE)
knife_overlay = null
else
return ..()
/obj/item/gun/screwdriver_act(mob/living/user, obj/item/I)
. = ..()
if(.)
return
if(!user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
if((can_flashlight && gun_light) && (can_bayonet && bayonet)) //give them a choice instead of removing both
var/list/possible_items = list(gun_light, bayonet)
var/obj/item/item_to_remove = input(user, "Select an attachment to remove", "Attachment Removal") as null|obj in possible_items
if(!item_to_remove || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
return remove_gun_attachment(user, I, item_to_remove)
else if(gun_light && can_flashlight) //if it has a gun_light and can_flashlight is false, the flashlight is permanently attached.
return remove_gun_attachment(user, I, gun_light, "unscrewed")
else if(bayonet && can_bayonet) //if it has a bayonet, and the bayonet can be removed
return remove_gun_attachment(user, I, bayonet, "unfix")
/obj/item/gun/proc/remove_gun_attachment(mob/living/user, obj/item/tool_item, obj/item/item_to_remove, removal_verb)
if(tool_item)
tool_item.play_tool_sound(src)
to_chat(user, "<span class='notice'>You [removal_verb ? removal_verb : "remove"] [item_to_remove] from [src].</span>")
item_to_remove.forceMove(drop_location())
if(Adjacent(user) && !issilicon(user))
user.put_in_hands(item_to_remove)
if(item_to_remove == bayonet)
return clear_bayonet()
else if(item_to_remove == gun_light)
return clear_gunlight()
/obj/item/gun/proc/clear_bayonet()
if(!bayonet)
return
bayonet = null
if(knife_overlay)
cut_overlay(knife_overlay, TRUE)
knife_overlay = null
return TRUE
/obj/item/gun/proc/clear_gunlight()
if(!gun_light)
return
var/obj/item/flashlight/seclite/removed_light = gun_light
gun_light = null
update_gunlight()
removed_light.update_brightness()
QDEL_NULL(alight)
return TRUE
/obj/item/gun/ui_action_click(mob/user, actiontype)
if(istype(actiontype, alight))
toggle_gunlight()
else
..()
/obj/item/gun/proc/toggle_gunlight()
if(!gun_light)
return
@@ -374,11 +450,10 @@
gun_light.on = !gun_light.on
to_chat(user, "<span class='notice'>You toggle the gunlight [gun_light.on ? "on":"off"].</span>")
playsound(user, 'sound/weapons/empty.ogg', 100, 1)
update_gunlight(user)
return
playsound(user, 'sound/weapons/empty.ogg', 100, TRUE)
update_gunlight()
/obj/item/gun/proc/update_gunlight(mob/user = null)
/obj/item/gun/proc/update_gunlight()
if(gun_light)
if(gun_light.on)
set_light(gun_light.brightness_on)
@@ -401,21 +476,10 @@
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/gun/pickup(mob/user)
..()
if(azoom)
azoom.Grant(user)
if(alight)
alight.Grant(user)
/obj/item/gun/dropped(mob/user)
..()
. = ..()
if(zoomed)
zoom(user,FALSE)
if(azoom)
azoom.Remove(user)
if(alight)
alight.Remove(user)
/obj/item/gun/proc/handle_suicide(mob/living/carbon/human/user, mob/living/carbon/human/target, params)
if(!ishuman(user) || !ishuman(target))
@@ -522,8 +586,3 @@
if(zoomable)
azoom = new()
azoom.gun = src
/obj/item/gun/handle_atom_del(atom/A)
if(A == chambered)
chambered = null
update_icon()

View File

@@ -51,8 +51,11 @@
else
to_chat(user, "<span class='warning'>You cannot seem to get \the [src] out of your hands!</span>")
/obj/item/gun/ballistic/automatic/ui_action_click()
burst_select()
/obj/item/gun/ballistic/automatic/ui_action_click(mob/user, actiontype)
if(istype(actiontype, /datum/action/item_action/toggle_firemode))
burst_select()
else
..()
/obj/item/gun/ballistic/automatic/proc/burst_select()
var/mob/living/carbon/human/user = usr
@@ -106,7 +109,6 @@
/obj/item/gun/ballistic/automatic/c20r/afterattack()
. = ..()
empty_alarm()
return
/obj/item/gun/ballistic/automatic/c20r/update_icon()
..()
@@ -167,8 +169,8 @@
if(select == 2)
underbarrel.afterattack(target, user, flag, params)
else
. = ..()
return
return ..()
/obj/item/gun/ballistic/automatic/m90/attackby(obj/item/A, mob/user, params)
if(istype(A, /obj/item/ammo_casing))
if(istype(A, underbarrel.magazine.ammo_type))

View File

@@ -165,9 +165,6 @@
itemState += "[ratio]"
item_state = itemState
/obj/item/gun/energy/ui_action_click()
toggle_gunlight()
/obj/item/gun/energy/suicide_act(mob/living/user)
if (istype(user) && can_shoot() && can_trigger_gun(user) && user.get_bodypart(BODY_ZONE_HEAD))
user.visible_message("<span class='suicide'>[user] is putting the barrel of [src] in [user.p_their()] mouth. It looks like [user.p_theyre()] trying to commit suicide!</span>")

View File

@@ -5,7 +5,7 @@
item_state = null //so the human update icon uses the icon_state instead.
ammo_type = list(/obj/item/ammo_casing/energy/disabler, /obj/item/ammo_casing/energy/laser)
modifystate = 1
can_flashlight = 1
can_flashlight = TRUE
ammo_x_offset = 3
flight_x_offset = 15
flight_y_offset = 10
@@ -19,7 +19,7 @@
cell_type = /obj/item/stock_parts/cell{charge = 600; maxcharge = 600}
ammo_x_offset = 2
charge_sections = 3
can_flashlight = 0 // Can't attach or detach the flashlight, and override it's icon update
can_flashlight = FALSE // Can't attach or detach the flashlight, and override it's icon update
/obj/item/gun/energy/e_gun/mini/Initialize()
gun_light = new /obj/item/flashlight/seclite(src)
@@ -67,7 +67,7 @@
lefthand_file = 'icons/mob/inhands/weapons/guns_lefthand.dmi'
righthand_file = 'icons/mob/inhands/weapons/guns_righthand.dmi'
ammo_type = list(/obj/item/ammo_casing/energy/net, /obj/item/ammo_casing/energy/trap)
can_flashlight = 0
can_flashlight = FALSE
ammo_x_offset = 1
/obj/item/gun/energy/e_gun/dragnet/snare
@@ -84,7 +84,7 @@
w_class = WEIGHT_CLASS_HUGE
ammo_type = list(/obj/item/ammo_casing/energy/electrode, /obj/item/ammo_casing/energy/laser)
weapon_weight = WEAPON_HEAVY
can_flashlight = 0
can_flashlight = FALSE
trigger_guard = TRIGGER_GUARD_NONE
ammo_x_offset = 2

View File

@@ -8,7 +8,7 @@
item_flags = NONE
obj_flags = UNIQUE_RENAME
weapon_weight = WEAPON_LIGHT
can_flashlight = 1
can_flashlight = TRUE
flight_x_offset = 15
flight_y_offset = 9
automatic_charge_overlays = FALSE
@@ -22,7 +22,7 @@
var/max_mod_capacity = 100
var/list/modkits = list()
var/recharge_timerid
/obj/item/gun/energy/kinetic_accelerator/examine(mob/user)

View File

@@ -6,7 +6,7 @@
item_state = "armcannonstun4"
force = 5
selfcharge = 1
can_flashlight = 0
can_flashlight = FALSE
trigger_guard = TRIGGER_GUARD_ALLOW_ALL // Has no trigger at all, uses neural signals instead
/obj/item/gun/energy/e_gun/advtaser/mounted/dropped()//if somebody manages to drop this somehow...

View File

@@ -43,7 +43,7 @@
icon_state = "pulse_carbine"
item_state = null
cell_type = "/obj/item/stock_parts/cell/pulse/carbine"
can_flashlight = 1
can_flashlight = TRUE
flight_x_offset = 18
flight_y_offset = 12

View File

@@ -3,7 +3,7 @@
desc = "A man-portable anti-armor weapon designed to disable mechanical threats at range."
icon_state = "ionrifle"
item_state = null //so the human update icon uses the icon_state instead.
can_flashlight = 1
can_flashlight = TRUE
w_class = WEIGHT_CLASS_HUGE
flags_1 = CONDUCT_1
slot_flags = ITEM_SLOT_BACK
@@ -93,7 +93,7 @@
overheat_time = 20
holds_charge = TRUE
unique_frequency = TRUE
can_flashlight = 0
can_flashlight = FALSE
max_mod_capacity = 0
/obj/item/gun/energy/kinetic_accelerator/crossbow/halloween

View File

@@ -12,7 +12,7 @@
icon_state = "tesla"
item_state = "tesla"
ammo_type = list(/obj/item/ammo_casing/energy/tesla_revolver)
can_flashlight = 0
can_flashlight = FALSE
pin = null
shaded_charge = 1
@@ -26,7 +26,7 @@
/obj/item/gun/energy/e_gun/advtaser/cyborg
name = "cyborg taser"
desc = "An integrated hybrid taser that draws directly from a cyborg's power cell. The weapon contains a limiter to prevent the cyborg's power cell from overheating."
can_flashlight = 0
can_flashlight = FALSE
can_charge = 0
use_cyborg_cell = 1

View File

@@ -85,31 +85,33 @@
/obj/item/gun/energy/beam_rifle/equipped(mob/user)
set_user(user)
. = ..()
return ..()
/obj/item/gun/energy/beam_rifle/pickup(mob/user)
set_user(user)
. = ..()
return ..()
/obj/item/gun/energy/beam_rifle/dropped(mob/user)
set_user()
. = ..()
return ..()
/obj/item/gun/energy/beam_rifle/ui_action_click(owner, action)
if(istype(action, /datum/action/item_action/zoom_lock_action))
/obj/item/gun/energy/beam_rifle/ui_action_click(mob/user, actiontype)
if(istype(actiontype, zoom_lock_action))
zoom_lock++
if(zoom_lock > 3)
zoom_lock = 0
switch(zoom_lock)
if(ZOOM_LOCK_AUTOZOOM_FREEMOVE)
to_chat(owner, "<span class='boldnotice'>You switch [src]'s zooming processor to free directional.</span>")
to_chat(user, "<span class='boldnotice'>You switch [src]'s zooming processor to free directional.</span>")
if(ZOOM_LOCK_AUTOZOOM_ANGLELOCK)
to_chat(owner, "<span class='boldnotice'>You switch [src]'s zooming processor to locked directional.</span>")
to_chat(user, "<span class='boldnotice'>You switch [src]'s zooming processor to locked directional.</span>")
if(ZOOM_LOCK_CENTER_VIEW)
to_chat(owner, "<span class='boldnotice'>You switch [src]'s zooming processor to center mode.</span>")
to_chat(user, "<span class='boldnotice'>You switch [src]'s zooming processor to center mode.</span>")
if(ZOOM_LOCK_OFF)
to_chat(owner, "<span class='boldnotice'>You disable [src]'s zooming system.</span>")
reset_zooming()
to_chat(user, "<span class='boldnotice'>You disable [src]'s zooming system.</span>")
reset_zooming()
else
..()
/obj/item/gun/energy/beam_rifle/proc/set_autozoom_pixel_offsets_immediate(current_angle)
if(zoom_lock == ZOOM_LOCK_CENTER_VIEW || zoom_lock == ZOOM_LOCK_OFF)
@@ -518,13 +520,13 @@
return FALSE
if(!QDELETED(target))
cached = get_turf(target)
. = ..()
return ..()
/obj/item/projectile/beam/beam_rifle/on_hit(atom/target, blocked = FALSE)
if(!QDELETED(target))
cached = get_turf(target)
handle_hit(target)
. = ..()
return ..()
/obj/item/projectile/beam/beam_rifle/hitscan
icon_state = ""