Skip to content

Commit

Permalink
Removes various helpers that can be simplified in a single variable c…
Browse files Browse the repository at this point in the history
…heck (ParadiseSS13#24551)

* Removes the first weird helper

* Removes get_turf_or_move

* Slightly alters the sharp weapon proc

* Adds nullcheck to adjustBruteLossByPart

* Changes `is_dead`

* Adds `hasorgans` to the replaced list

* Update code/__HELPERS/unsorted.dm

Co-authored-by: Deniz <[email protected]>

* Contra review

---------

Co-authored-by: Deniz <[email protected]>
  • Loading branch information
DGamerL and Oyu07 authored Mar 25, 2024
1 parent 19c0b70 commit de1229b
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 61 deletions.
1 change: 0 additions & 1 deletion code/__DEFINES/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@
#define is_external_organ(A) (istype((A), /obj/item/organ/external))
#define is_internal_organ(A) (istype((A), /obj/item/organ/internal))
#define is_organ(A) (istype((A), /obj/item/organ))
#define hasorgans(A) (iscarbon(A))

#define is_admin(user) (check_rights(R_ADMIN, 0, (user)) != 0)

Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
var/turf/T = get_turf(vent)
var/mobs_nearby = FALSE
for(var/mob/living/M in orange(7, T))
if(M.is_dead()) //we don't care about dead mobs
if(M.stat == DEAD) //we don't care about dead mobs
continue
if(!M.client && !istype(get_area(T), /area/station/science/xenobiology)) //we add an exception here for clientless mobs (apart from ones near xenobiology vents because it's usually filled with gold slime mobs who attack hostile mobs)
continue
Expand Down
22 changes: 5 additions & 17 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1124,32 +1124,20 @@ Returns 1 if the chain up to the area contains the given typepath
loc = loc.loc
return null

/proc/get_turf_or_move(turf/location)
return get_turf(location)


//For objects that should embed, but make no sense being is_sharp or is_pointed()
//For objects that should embed, but make no sense being sharp or is_pointed()
//e.g: rods
GLOBAL_LIST_INIT(can_embed_types, typecacheof(list(
/obj/item/stack/rods,
/obj/item/pipe)))

/proc/can_embed(obj/item/W)
if(is_sharp(W))
return 1
if(W.sharp)
return TRUE
if(is_pointed(W))
return 1
return TRUE

if(is_type_in_typecache(W, GLOB.can_embed_types))
return 1

//Whether or not the given item counts as sharp in terms of dealing damage
/proc/is_sharp(obj/O)
if(!O)
return 0
if(O.sharp)
return 1
return 0
return TRUE

/proc/reverse_direction(dir)
switch(dir)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@
var/list/cached_healthdoll_overlays = list() // List of icon states (strings) for overlays

/atom/movable/screen/healthdoll/Click()
if(ishuman(usr) && !usr.is_dead())
if(ishuman(usr) && usr.stat != DEAD)
var/mob/living/carbon/H = usr
H.check_self_for_injuries()

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/obj/machinery/sleeper/examine(mob/user)
. = ..()
if(occupant)
if(occupant.is_dead())
if(occupant.stat == DEAD)
. += "<span class='warning'>You see [occupant.name] inside. [occupant.p_they(TRUE)] [occupant.p_are()] dead!</span>"
else
. += "<span class='notice'>You see [occupant.name] inside.</span>"
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/adv_med.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/obj/machinery/bodyscanner/examine(mob/user)
. = ..()
if(occupant)
if(occupant.is_dead())
if(occupant.stat == DEAD)
. += "<span class='warning'>You see [occupant.name] inside. [occupant.p_they(TRUE)] [occupant.p_are()] dead!</span>"
else
. += "<span class='notice'>You see [occupant.name] inside.</span>"
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/paicard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
current_emotion = emotion

/obj/item/paicard/proc/alertUpdate()
var/turf/T = get_turf_or_move(loc)
var/turf/T = get_turf(loc)
for(var/mob/M in viewers(T))
M.show_message("<span class='notice'>[src] flashes a message across its screen, \"Additional personalities available for download.\"</span>", 3, "<span class='notice'>[src] bleeps electronically.</span>", 2)

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/latexballoon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
var/obj/item/tank/T = W
blow(T, user)
return
if(is_sharp(W) || W.get_heat() || is_pointed(W))
if(W.sharp || W.get_heat() || is_pointed(W))
burst()
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/storage/boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@
design = switchDesign
update_appearance(UPDATE_DESC|UPDATE_ICON_STATE)
return
else if(is_sharp(W))
else if(W.sharp)
if(!contents.len)
if(item_state == "paperbag_None")
to_chat(user, "<span class='notice'>You cut eyeholes into [src].</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/simulated/walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
dismantle_wall()

/turf/simulated/wall/proc/try_rot(obj/item/I, mob/user, params)
if((!is_sharp(I) && I.force >= 10) || I.force >= 20)
if((!I.sharp && I.force >= 10) || I.force >= 20)
to_chat(user, "<span class='notice'>[src] crumbles away under the force of your [I.name].</span>")
dismantle_wall(1)
return TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/obj/machinery/atmospherics/unary/cryo_cell/examine(mob/user)
. = ..()
if(occupant)
if(occupant.is_dead())
if(occupant.stat == DEAD)
. += "<span class='warning'>You see [occupant.name] inside. [occupant.p_they(TRUE)] [occupant.p_are()] dead!</span>"
else
. += "<span class='notice'>You see [occupant.name] inside.</span>"
Expand Down
4 changes: 2 additions & 2 deletions code/modules/events/spacevine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
holder.obj_integrity = holder.max_integrity

/datum/spacevine_mutation/woodening/on_hit(obj/structure/spacevine/holder, mob/living/hitter, obj/item/I, expected_damage)
if(!is_sharp(I))
if(!I.sharp)
. = expected_damage * 0.5
else
. = expected_damage
Expand Down Expand Up @@ -488,7 +488,7 @@
else
B.wither()
return
if(is_sharp(I))
if(I.sharp)
damage_dealt *= 4
if(I.damtype == BURN)
damage_dealt *= 4
Expand Down
6 changes: 3 additions & 3 deletions code/modules/fish/fish_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
icon_state = "catfish"

/obj/item/fish/catfish/attackby(obj/item/O, mob/user as mob)
if(is_sharp(O))
if(O.sharp)
to_chat(user, "You carefully clean and gut \the [src.name].")
new /obj/item/food/snacks/catfishmeat(get_turf(src))
new /obj/item/food/snacks/catfishmeat(get_turf(src))
Expand All @@ -187,7 +187,7 @@
icon_state = "salmon"

/obj/item/fish/salmon/attackby(obj/item/O, mob/user as mob)
if(is_sharp(O))
if(O.sharp)
to_chat(user, "You carefully clean and gut \the [src.name].")
new /obj/item/food/snacks/salmonmeat(get_turf(src))
new /obj/item/food/snacks/salmonmeat(get_turf(src))
Expand All @@ -203,7 +203,7 @@
force = 3

/obj/item/fish/babycarp/attackby(obj/item/O, mob/user as mob)
if(is_sharp(O))
if(O.sharp)
to_chat(user, "You carefully clean and gut \the [src.name].")
new /obj/item/food/snacks/carpmeat(get_turf(src)) //just one fillet; this is a baby, afterall.
qdel(src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/corn.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
throw_range = 7

/obj/item/grown/corncob/attackby(obj/item/grown/W, mob/user, params)
if(is_sharp(W))
if(W.sharp)
to_chat(user, "<span class='notice'>You use [W] to fashion a pipe out of the corn cob!</span>")
new /obj/item/clothing/mask/cigarette/pipe/cobpipe (user.loc)
user.unEquip(src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/potato.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


/obj/item/food/snacks/grown/potato/attackby(obj/item/W, mob/user, params)
if(is_sharp(W))
if(W.sharp)
to_chat(user, "<span class='notice'>You cut the potato into wedges with [W].</span>")
var/obj/item/food/snacks/grown/potato/wedges/Wedges = new /obj/item/food/snacks/grown/potato/wedges
if(!remove_item_from_storage(user))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/pumpkin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
var/carved_type = /obj/item/clothing/head/hardhat/pumpkinhead

/obj/item/food/snacks/grown/pumpkin/attackby(obj/item/W as obj, mob/user as mob, params)
if(is_sharp(W))
if(W.sharp)
user.show_message("<span class='notice'>You carve a face into [src]!</span>", 1)
new carved_type(user.loc)
qdel(src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/root.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
bitesize_mod = 2

/obj/item/food/snacks/grown/carrot/attackby(obj/item/I, mob/user, params)
if(is_sharp(I))
if(I.sharp)
to_chat(user, "<span class='notice'>You sharpen the carrot into a shiv with [I].</span>")
var/obj/item/kitchen/knife/shiv/carrot/Shiv = new ()
if(!remove_item_from_storage(user))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown/towercap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/obj/item/food/snacks/grown/wheat))

/obj/item/grown/log/attackby(obj/item/W, mob/user, params)
if(is_sharp(W))
if(W.sharp)
if(in_inventory)
to_chat(user, "<span class='warning'>You need to place [src] on a flat surface to make [plank_name].</span>")
return
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
var/obj/item/organ/external/O = get_organ(organ_name)

if(amount > 0)
O.receive_damage(amount, 0, sharp=is_sharp(damage_source), used_weapon=damage_source, forbidden_limbs = list(), ignore_resists=FALSE, updating_health=updating_health)
O.receive_damage(amount, 0, sharp = (damage_source ? damage_source.sharp : null), used_weapon = damage_source, forbidden_limbs = list(), ignore_resists = FALSE, updating_health = updating_health)
else
//if you don't want to heal robot organs, they you will have to check that yourself before using this proc.
O.heal_damage(-amount, 0, internal = 0, robo_repair = O.is_robotic(), updating_health = updating_health)
Expand All @@ -124,7 +124,7 @@
var/obj/item/organ/external/O = get_organ(organ_name)

if(amount > 0)
O.receive_damage(0, amount, sharp=is_sharp(damage_source), used_weapon=damage_source, forbidden_limbs = list(), ignore_resists = FALSE, updating_health = updating_health)
O.receive_damage(0, amount, sharp = damage_source.sharp, used_weapon = damage_source, forbidden_limbs = list(), ignore_resists = FALSE, updating_health = updating_health)
else
//if you don't want to heal robot organs, they you will have to check that yourself before using this proc.
O.heal_damage(0, -amount, internal = 0, robo_repair = O.is_robotic(), updating_health = updating_health)
Expand Down
14 changes: 6 additions & 8 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -959,14 +959,12 @@
return 0

/mob/living/proc/attempt_harvest(obj/item/I, mob/user)
if(user.a_intent == INTENT_HARM && stat == DEAD && butcher_results) //can we butcher it?
var/sharpness = is_sharp(I)
if(sharpness)
to_chat(user, "<span class='notice'>You begin to butcher [src]...</span>")
playsound(loc, 'sound/weapons/slice.ogg', 50, 1, -1)
if(do_mob(user, src, 80 / sharpness) && Adjacent(I))
harvest(user)
return 1
if(user.a_intent == INTENT_HARM && stat == DEAD && butcher_results && I.sharp) //can we butcher it?
to_chat(user, "<span class='notice'>You begin to butcher [src]...</span>")
playsound(loc, 'sound/weapons/slice.ogg', 50, TRUE, -1)
if(do_mob(user, src, 8 SECONDS) && Adjacent(I))
harvest(user)
return TRUE

/mob/living/proc/harvest(mob/living/user)
if(QDELETED(src))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
if(!thrown_item.throwforce)
return
var/armor = run_armor_check(zone, MELEE, "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].", thrown_item.armour_penetration_flat, armour_penetration_percentage = thrown_item.armour_penetration_percentage)
apply_damage(thrown_item.throwforce, thrown_item.damtype, zone, armor, is_sharp(thrown_item), thrown_item)
apply_damage(thrown_item.throwforce, thrown_item.damtype, zone, armor, thrown_item.sharp, thrown_item)
if(QDELETED(src)) //Damage can delete the mob.
return
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/pai/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
silence_time = world.timeofday + 120 * 10 // Silence for 2 minutes
to_chat(src, "<font color=green><b>Communication circuit overload. Shutting down and reloading communication circuits - speech and messaging functionality will be unavailable until the reboot is complete.</b></font>")
if(prob(20))
var/turf/T = get_turf_or_move(loc)
var/turf/T = get_turf(loc)
for(var/mob/M in viewers(T))
M.show_message("<span class='warning'>A shower of sparks spray from [src]'s inner workings.</span>", 3, "<span class='warning'>You hear and smell the ozone hiss of electrical sparks being expelled violently.</span>", 2)
return death(0)
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,6 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \
else
return "<span class='notice'>[copytext_preserve_html(msg, 1, 37)]... <a href='byond://?src=[UID()];flavor_more=1'>More...</a></span>"

/mob/proc/is_dead()
return stat == DEAD

// Nobody in their right mind will have this enabled on the production server, uncomment if you want this for some reason
/*
/mob/verb/abandon_mob()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/pda/core_apps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if(1) // Configure pAI device
pda.pai.attack_self(usr)
if(2) // Eject pAI device
var/turf/T = get_turf_or_move(pda.loc)
var/turf/T = get_turf(pda.loc)
if(T)
pda.pai.forceMove(T)
pda.pai = null
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/reagents/alcohol.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@
if(prob(50))
var/list/mob/living/targets = list()
for(var/mob/living/L in orange(14, M))
if(L.is_dead() || !L.client) //we don't care about dead mobs
if(L.stat == DEAD || !L.client) //we don't care about dead mobs
continue
targets += L
if(length(targets))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/organs/organ_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ Note that amputating the affected organ does in fact remove the infection from t

var/mob/living/carbon/C = owner

if(!hasorgans(C))
if(!iscarbon(C))
return

var/organ_spilled = FALSE
Expand Down
8 changes: 4 additions & 4 deletions code/modules/surgery/organs_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
var/tool_name = get_tool_name(tool)
var/obj/item/organ/external/affected = target.get_organ(target_zone)

if(!hasorgans(target))
if(!iscarbon(target))
to_chat(user, "They do not have organs to mend!")
// note that we want to return skip here so we can go "back" to the proxy step
return SURGERY_BEGINSTEP_SKIP
Expand Down Expand Up @@ -232,7 +232,7 @@
/datum/surgery_step/internal/manipulate_organs/mend/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/tool_name = get_tool_name(tool)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
if(!hasorgans(target))
if(!iscarbon(target))
return SURGERY_STEP_INCOMPLETE

var/list/organs = get_organ_list(target_zone, target, affected)
Expand All @@ -256,7 +256,7 @@
return SURGERY_STEP_CONTINUE

/datum/surgery_step/internal/manipulate_organs/mend/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(!hasorgans(target))
if(!iscarbon(target))
return SURGERY_STEP_INCOMPLETE

var/obj/item/organ/external/affected = target.get_organ(target_zone)
Expand Down Expand Up @@ -505,7 +505,7 @@
return ..()

/datum/surgery_step/internal/manipulate_organs/clean/end_step(mob/living/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(!hasorgans(target))
if(!iscarbon(target))
return SURGERY_STEP_INCOMPLETE
if(!istype(tool, /obj/item/reagent_containers))
return SURGERY_STEP_INCOMPLETE
Expand Down
4 changes: 2 additions & 2 deletions code/modules/surgery/robotics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
)

/datum/surgery_step/robotics/manipulate_robotic_organs/mend/begin_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(!hasorgans(target))
if(!iscarbon(target))
return
var/obj/item/organ/external/affected = target.get_organ(target_zone)

Expand All @@ -368,7 +368,7 @@


/datum/surgery_step/robotics/manipulate_robotic_organs/mend/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(!hasorgans(target))
if(!iscarbon(target))
return
var/obj/item/organ/external/affected = target.get_organ(target_zone)
for(var/obj/item/organ/internal/I in affected.internal_organs)
Expand Down

0 comments on commit de1229b

Please sign in to comment.