mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
Fixing Energy Gun Weapon Description Runtimes + Miscellaneous Weapon Description Fixes, Take 2 (#59778)
Fixes a runtime issue cause by the possibility of loaded_projectile being null by changing how projectile stats are obtained on energy weapons, and adds a separate line for energy ammo types that deal stamina damage and regular damage to incorporate both damage types
This commit is contained in:
@@ -65,20 +65,20 @@
|
||||
*
|
||||
*/
|
||||
/obj/item/ammo_casing/proc/add_notes_ammo()
|
||||
// Make sure there is actually something IN the casing
|
||||
if(loaded_projectile)
|
||||
var/list/readout = list("")
|
||||
// No dividing by 0
|
||||
if(loaded_projectile.damage > 0)
|
||||
readout += "Most monkeys our legal team subjected to these rounds succumbed to their wounds after [span_warning("[round(100 / (loaded_projectile.damage * pellets), 0.1)]")] discharge\s at point-blank, taking [span_warning("[pellets]")] shot\s per round"
|
||||
if(loaded_projectile.stamina > 0)
|
||||
readout += "[loaded_projectile.damage == 0 ? "Most Monkeys" : "More Fortunate Monkeys" ] collapsed from exhaustion after [span_warning("[round(100 / ((loaded_projectile.damage + loaded_projectile.stamina) * pellets), 0.1)]")] of these rounds"
|
||||
if(loaded_projectile.damage == 0 && loaded_projectile.stamina == 0)
|
||||
return "Our legal team has determined the offensive nature of these rounds to be esoteric"
|
||||
return readout.Join("\n") // Sending over a single string, rather than the whole list
|
||||
else
|
||||
// Labels don't do well with extreme forces
|
||||
return "The warning label was blown away..."
|
||||
// Try to get a projectile to derive stats from
|
||||
var/obj/projectile/exam_proj = GLOB.proj_by_path_key[projectile_type]
|
||||
if(!istype(exam_proj) || pellets == 0)
|
||||
return
|
||||
|
||||
var/list/readout = list()
|
||||
// No dividing by 0
|
||||
if(exam_proj.damage > 0)
|
||||
readout += "Most monkeys our legal team subjected to these [span_warning(caliber)] rounds succumbed to their wounds after [span_warning("[HITS_TO_CRIT(exam_proj.damage * pellets)] shot\s")] at point-blank, taking [span_warning("[pellets] shot\s")] per round"
|
||||
if(exam_proj.stamina > 0)
|
||||
readout += "[!readout.len ? "Most monkeys" : "More fortunate monkeys"] collapsed from exhaustion after [span_warning("[HITS_TO_CRIT(exam_proj.stamina * pellets)] impact\s")] of these [span_warning("[caliber]")] rounds"
|
||||
if(!readout.len) // Everything else failed, give generic text
|
||||
return "Our legal team has determined the offensive nature of these [span_warning(caliber)] rounds to be esoteric"
|
||||
return readout.Join("\n") // Sending over a single string, rather than the whole list
|
||||
|
||||
/obj/item/ammo_casing/update_icon_state()
|
||||
icon_state = "[initial(icon_state)][loaded_projectile ? "-live" : null]"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
throw_speed = 3
|
||||
throw_range = 7
|
||||
override_notes = TRUE
|
||||
///list containing the actual ammo within the magazine
|
||||
var/list/stored_ammo = list()
|
||||
///type that the magazine will be searching for, rejects if not a subtype of
|
||||
@@ -41,6 +42,23 @@
|
||||
if(!start_empty)
|
||||
top_off(starting=TRUE)
|
||||
|
||||
/obj/item/ammo_box/add_weapon_description()
|
||||
AddElement(/datum/element/weapon_description, attached_proc = .proc/add_notes_box)
|
||||
|
||||
/obj/item/ammo_box/proc/add_notes_box()
|
||||
var/list/readout = list()
|
||||
|
||||
if(caliber && max_ammo) // Text references a 'magazine' as only magazines generally have the caliber variable initialized
|
||||
readout += "Up to [span_warning("[max_ammo] [caliber] rounds")] can be found within this magazine. \
|
||||
\nAccidentally discharging any of these projectiles may void your insurance contract."
|
||||
|
||||
var/obj/item/ammo_casing/mag_ammo = get_round(TRUE)
|
||||
|
||||
if(istype(mag_ammo))
|
||||
readout += "\n[mag_ammo.add_notes_ammo()]"
|
||||
|
||||
return readout.Join("\n")
|
||||
|
||||
/**
|
||||
* top_off is used to refill the magazine to max, in case you want to increase the size of a magazine with VV then refill it at once
|
||||
*
|
||||
|
||||
@@ -141,8 +141,8 @@
|
||||
*
|
||||
*/
|
||||
/obj/item/gun/ballistic/proc/add_notes_ballistic()
|
||||
if(magazine) // Make sure you have a magazine, thats where the warning is!
|
||||
return "\nBe especially careful around this device, as it can be loaded with [span_warning("[magazine.caliber]")] rounds, which you can inspect for more information."
|
||||
if(magazine) // Make sure you have a magazine, to get the notes from
|
||||
return "\n[magazine.add_notes_box()]"
|
||||
else
|
||||
return "\nThe warning attached to the magazine is missing..."
|
||||
|
||||
|
||||
@@ -59,19 +59,25 @@
|
||||
*
|
||||
*/
|
||||
/obj/item/gun/energy/proc/add_notes_energy()
|
||||
var/list/readout = list("")
|
||||
var/list/readout = list()
|
||||
// Make sure there is something to actually retrieve
|
||||
if(!ammo_type)
|
||||
if(!ammo_type.len)
|
||||
return
|
||||
var/obj/projectile/exam_proj
|
||||
readout += "Standard models of this projectile weapon have [span_warning("[ammo_type.len]")] mode\s"
|
||||
readout += "\nStandard models of this projectile weapon have [span_warning("[ammo_type.len] mode\s")]"
|
||||
readout += "Our heroic interns have shown that one can theoretically stay standing after..."
|
||||
for(var/obj/item/ammo_casing/energy/for_ammo in ammo_type)
|
||||
exam_proj = for_ammo.loaded_projectile
|
||||
for(var/obj/item/ammo_casing/energy/for_ammo as anything in ammo_type)
|
||||
exam_proj = GLOB.proj_by_path_key[for_ammo?.projectile_type]
|
||||
if(!istype(exam_proj))
|
||||
continue
|
||||
|
||||
if(exam_proj.damage > 0) // Don't divide by 0!!!!!
|
||||
readout += "[span_warning("[round(100 / exam_proj.damage, 0.1)]")] shot\s on [span_warning("[for_ammo.select_name]")] mode before collapsing from [exam_proj.damage_type == STAMINA ? "immense pain" : "their wounds"]."
|
||||
readout += "[span_warning("[HITS_TO_CRIT(exam_proj.damage)] shot\s")] on [span_warning("[for_ammo.select_name]")] mode before collapsing from [exam_proj.damage_type == STAMINA ? "immense pain" : "their wounds"]."
|
||||
if(exam_proj.stamina > 0) // In case a projectile does damage AND stamina damage (Energy Crossbow)
|
||||
readout += "[span_warning("[HITS_TO_CRIT(exam_proj.stamina)] shot\s")] on [span_warning("[for_ammo.select_name]")] mode before collapsing from immense pain."
|
||||
else
|
||||
readout += "an infinite number of shots on [span_warning("[for_ammo.select_name] mode")]."
|
||||
readout += "a theoretically infinite number of shots on [span_warning("[for_ammo.select_name]")] mode."
|
||||
|
||||
return readout.Join("\n") // Sending over the singular string, rather than the whole list
|
||||
|
||||
/obj/item/gun/energy/ComponentInitialize()
|
||||
|
||||
Reference in New Issue
Block a user