examine signature changed to include distance

- distance is INFINITE, 0, or a positive integer based on get_dist() between
the examiner and examinee's turfs when they are on the same Z. When the
examiner is dead or a ghost, distance is always 0.
- also updates /examine( implementations to use it!
- adds w_class_to_name proc for reusing "It is a X item." examine behavior.
This commit is contained in:
Spookerton
2024-01-31 13:49:52 +00:00
parent e3393dc87b
commit 978f4511a5
240 changed files with 524 additions and 551 deletions
+2 -3
View File
@@ -84,7 +84,7 @@
if(!BB)
icon_state = "[initial(icon_state)]-spent"
/obj/item/ammo_casing/examine(mob/user)
/obj/item/ammo_casing/examine(mob/user, distance, infix, suffix)
. = ..()
if (!BB)
. += "This one is spent."
@@ -217,7 +217,7 @@
break
icon_state = (new_state)? new_state : initial(icon_state)
/obj/item/ammo_magazine/examine(mob/user)
/obj/item/ammo_magazine/examine(mob/user, distance, infix, suffix)
. = ..()
. += "There [(stored_ammo.len == 1)? "is" : "are"] [stored_ammo.len] round\s left!"
@@ -245,4 +245,3 @@
magazine_icondata_keys["[M.type]"] = icon_keys
magazine_icondata_states["[M.type]"] = ammo_states
@@ -9,7 +9,7 @@
var/remaining = 9
preserve_item = 1
/obj/item/magnetic_ammo/examine(mob/user)
/obj/item/magnetic_ammo/examine(mob/user, distance, infix, suffix)
. = ..()
. += "There [(remaining == 1)? "is" : "are"] [remaining] flechette\s left!"
@@ -49,7 +49,7 @@
last_production_time = world.time
produce()
/obj/item/ammo_magazine/smart/examine(mob/user)
/obj/item/ammo_magazine/smart/examine(mob/user, distance, infix, suffix)
. = ..()
if(attached_cell)
@@ -223,4 +223,4 @@
ammo_type = null
production_cost = null
return
return
+2 -2
View File
@@ -22,10 +22,10 @@
if(!my_guntype && !QDELETED(src))
qdel(src)
/obj/item/broken_gun/examine(mob/user)
/obj/item/broken_gun/examine(mob/user, distance, infix, suffix)
. = ..()
spawn()
if(get_dist(get_turf(user),get_turf(src)) <= 1)
if(distance < 2)
to_chat(user, "<span class='notice'>You begin inspecting \the [src].</span>")
if(do_after(user, 5 SECONDS))
+1 -1
View File
@@ -713,7 +713,7 @@
accuracy = initial(accuracy)
recoil = initial(recoil)
/obj/item/gun/examine(mob/user)
/obj/item/gun/examine(mob/user, distance, infix, suffix)
. = ..()
if(firemodes.len > 1)
var/datum/firemode/current_mode = firemodes[sel_mode]
+1 -1
View File
@@ -182,7 +182,7 @@
return suit.cell
return null
/obj/item/gun/energy/examine(mob/user)
/obj/item/gun/energy/examine(mob/user, distance, infix, suffix)
. = ..()
if(power_supply)
if(charge_cost)
@@ -253,7 +253,7 @@
/obj/item/crossbowframe/update_icon()
icon_state = "crossbowframe[buildstate]"
/obj/item/crossbowframe/examine(mob/user)
/obj/item/crossbowframe/examine(mob/user, distance, infix, suffix)
. = ..()
switch(buildstate)
if(1)
@@ -35,9 +35,9 @@
to_chat(M, "<span class='warning'>You pump [src], but the magazine is empty.</span>")
update_icon()
/obj/item/gun/launcher/grenade/examine(mob/user)
/obj/item/gun/launcher/grenade/examine(mob/user, distance, infix, suffix)
. = ..()
if(get_dist(user, src) <= 2)
if(distance < 3)
var/grenade_count = grenades.len + (chambered? 1 : 0)
. += "Has [grenade_count] grenade\s remaining."
if(chambered)
@@ -122,4 +122,4 @@
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
chambered = null
else
to_chat(user, "<span class='warning'>[src] is empty.</span>")
to_chat(user, "<span class='warning'>[src] is empty.</span>")
@@ -98,9 +98,9 @@
item_storage.remove_from_storage(launched, src)
return launched
/obj/item/gun/launcher/pneumatic/examine(mob/user)
/obj/item/gun/launcher/pneumatic/examine(mob/user, distance, infix, suffix)
. = ..()
if(get_dist(user, src) <= 2)
if(distance < 3)
. += "The valve is dialed to [pressure_setting]%."
if(tank)
. += "The tank dial reads [tank.air_contents.return_pressure()] kPa."
@@ -150,7 +150,7 @@
/obj/item/cannonframe/update_icon()
icon_state = "pneumatic[buildstate]"
/obj/item/cannonframe/examine(mob/user)
/obj/item/cannonframe/examine(mob/user, distance, infix, suffix)
. = ..()
switch(buildstate)
if(1)
@@ -16,9 +16,9 @@
var/max_rockets = 1
var/list/rockets = new/list()
/obj/item/gun/launcher/rocket/examine(mob/user)
/obj/item/gun/launcher/rocket/examine(mob/user, distance, infix, suffix)
. = ..()
if(get_dist(user, src) <= 2)
if(distance < 3)
. += "<font color='blue'>[rockets.len] / [max_rockets] rockets.</font>"
/obj/item/gun/launcher/rocket/attackby(obj/item/I as obj, mob/user as mob)
@@ -27,7 +27,7 @@
QDEL_NULL(manipulator)
. = ..()
/obj/item/gun/magnetic/matfed/examine(mob/user)
/obj/item/gun/magnetic/matfed/examine(mob/user, distance, infix, suffix)
. = ..()
if(manipulator)
. += "<span class='notice'>The installed [manipulator.name] consumes [mat_cost] units of [ammo_material] per shot.</span>"
@@ -192,7 +192,7 @@
return new projectile_type(src, rating_modifier)
/obj/item/gun/magnetic/matfed/phoronbore/examine(mob/user)
/obj/item/gun/magnetic/matfed/phoronbore/examine(mob/user, distance, infix, suffix)
. = ..()
if(rating_modifier)
. += "<span class='notice'>A display on the side slowly scrolls the text \"BLAST EFFICIENCY [rating_modifier]\".</span>"
@@ -123,9 +123,9 @@
return ammotext
/obj/item/gun/magnetic/examine(var/mob/user)
/obj/item/gun/magnetic/examine(mob/user, distance, infix, suffix)
. = ..()
if(get_dist(user, src) <= 2)
if(distance < 3)
. += show_ammo()
if(cell)
@@ -313,4 +313,4 @@
#undef ICON_BAD
#undef ICON_CHARGE
#undef ICON_READY
#undef ICON_LOADED
#undef ICON_LOADED
@@ -87,9 +87,9 @@
construction_stage++
icon_state = "coilgun_construction_[construction_stage]"
/obj/item/coilgun_assembly/examine(var/mob/user)
/obj/item/coilgun_assembly/examine(mob/user, distance, infix, suffix)
. = ..()
if(get_dist(user, src) <= 2)
if(distance < 3)
switch(construction_stage)
if(2)
. += "<span class='notice'>It has a metal frame loosely shaped around the stock.</span>"
@@ -72,9 +72,9 @@
list(mode_name="long bursts", burst=6, fire_delay=null, move_delay=10, one_handed_penalty=30, burst_accuracy=list(0,-15,-15,-15,-30), dispersion=list(0.6, 0.6, 1.0, 1.0, 1.2)),
)
/obj/item/gun/magnetic/railgun/automatic/examine(var/mob/user)
/obj/item/gun/magnetic/railgun/automatic/examine(mob/user, distance, infix, suffix)
. = ..()
if(Adjacent(user))
if(distance < 2)
. += "<span class='notice'>Someone has scratched <i>Ultima Ratio Regum</i> onto the side of the barrel.</span>"
/obj/item/gun/magnetic/railgun/flechette
+16 -16
View File
@@ -54,9 +54,9 @@
chambered = ammo_magazine.stored_ammo[ammo_magazine.stored_ammo.len]
if(handle_casings != HOLD_CASINGS)
ammo_magazine.stored_ammo -= chambered
var/mob/living/M = loc
if(istype(M))
var/mob/living/M = loc
if(istype(M))
M?.hud_used.update_ammo_hud(M, src)
if (chambered)
@@ -102,9 +102,9 @@
if(handle_casings != HOLD_CASINGS)
chambered = null
var/mob/living/M = loc
if(istype(M))
var/mob/living/M = loc
if(istype(M))
M?.hud_used.update_ammo_hud(M, src)
@@ -140,10 +140,10 @@
loaded += C
AM.stored_ammo -= C //should probably go inside an ammo_magazine proc, but I guess less proc calls this way...
count++
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
if(count)
user.visible_message("[user] reloads [src].", "<span class='notice'>You load [count] round\s into [src].</span>")
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
AM.update_icon()
else if(istype(A, /obj/item/ammo_casing))
@@ -179,7 +179,7 @@
sleep(1 SECOND)
update_icon()
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
//attempts to unload src. If allow_dump is set to 0, the speedloader unloading method will be disabled
/obj/item/gun/projectile/proc/unload_ammo(mob/user, var/allow_dump=1)
@@ -189,7 +189,7 @@
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
ammo_magazine.update_icon()
ammo_magazine = null
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
else if(loaded.len)
//presumably, if it can be speed-loaded, it can be speed-unloaded.
if(allow_dump && (load_method & SPEEDLOADER))
@@ -208,11 +208,11 @@
user.put_in_hands(C)
user.visible_message("[user] removes \a [C] from [src].", "<span class='notice'>You remove \a [C] from [src].</span>")
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
else
to_chat(user, "<span class='warning'>[src] is empty.</span>")
update_icon()
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
/obj/item/gun/projectile/attackby(var/obj/item/A as obj, mob/user as mob)
..()
@@ -243,9 +243,9 @@
ammo_magazine.update_icon()
ammo_magazine = null
update_icon() //make sure to do this after unsetting ammo_magazine
user.hud_used.update_ammo_hud(user, src)
user.hud_used.update_ammo_hud(user, src)
/obj/item/gun/projectile/examine(mob/user)
/obj/item/gun/projectile/examine(mob/user, distance, infix, suffix)
. = ..()
if(ammo_magazine)
. += "It has \a [ammo_magazine] loaded."
@@ -320,7 +320,7 @@
for(var/obj/item/ammo_casing/bullet in ammo_magazine.stored_ammo)
if(bullet.BB)
shots_left++
if(shots_left > 0)
return shots_left
else
@@ -332,7 +332,7 @@
for(var/obj/item/ammo_casing/bullet in loaded)
if(bullet.BB) // Only increment how many shots we have left if we're loaded.
shots_left++
if(shots_left > 0)
return shots_left
else
@@ -196,7 +196,7 @@
if(!ignore_inhands) update_held_icon()
return
/obj/item/gun/projectile/automatic/z8/examine(mob/user)
/obj/item/gun/projectile/automatic/z8/examine(mob/user, distance, infix, suffix)
. = ..()
if(launcher.chambered)
. += "\The [launcher] has \a [launcher.chambered] loaded."
@@ -99,7 +99,7 @@
if(istype(dart))
fill_dart(dart)
/obj/item/gun/projectile/dartgun/examine(mob/user)
/obj/item/gun/projectile/dartgun/examine(mob/user, distance, infix, suffix)
. = ..()
if(beakers.len)
. += "<span class='notice'>[src] contains:</span>"
@@ -268,7 +268,7 @@
if(rand(1,max_shells) > loaded.len)
chamber_offset = rand(0,max_shells - loaded.len)
/obj/item/gun/projectile/revolver/lemat/examine(mob/user)
/obj/item/gun/projectile/revolver/lemat/examine(mob/user, distance, infix, suffix)
. = ..()
if(secondary_loaded)
var/to_print
+1 -1
View File
@@ -58,7 +58,7 @@
last_regen = world.time
update_icon()
/obj/item/gun/launcher/spikethrower/examine(mob/user)
/obj/item/gun/launcher/spikethrower/examine(mob/user, distance, infix, suffix)
. = ..()
. += "It has [spikes] spike\s remaining."