Skip to content

Commit

Permalink
Replacing zone_sel.selecting with a helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 authored and comma committed Jun 17, 2023
1 parent 2c33867 commit 028eb48
Show file tree
Hide file tree
Showing 62 changed files with 143 additions and 136 deletions.
4 changes: 2 additions & 2 deletions code/_helpers/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/proc/random_name(gender, species)
if(species)
var/decl/species/current_species = get_species_by_key(species)
if(current_species)
if(current_species)
var/decl/cultural_info/current_culture = GET_DECL(current_species.default_cultural_info[TAG_CULTURE])
if(current_culture)
return current_culture.get_random_name(null, gender)
Expand Down Expand Up @@ -116,7 +116,7 @@
. = 0
break

if(target_zone && user.zone_sel.selecting != target_zone)
if(target_zone && user.get_target_zone() != target_zone)
. = 0
break

Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define ui_construct_health "RIGHT:00,CENTER:15" //same height as humans, hugging the right border
#define ui_construct_purge "RIGHT:00,CENTER-1:15"
#define ui_construct_fire "RIGHT-1:16,CENTER+1:13" //above health, slightly to the left
#define ui_construct_pull "RIGHT-1:28,BOTTOM+1:10" //above the zone_sel icon
#define ui_construct_pull "RIGHT-1:28,BOTTOM+1:10" //above the zone selector icon

//Lower right, persistant menu
#define ui_dropbutton "RIGHT-4:22,BOTTOM:5"
Expand Down
5 changes: 2 additions & 3 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,11 @@
mymob.pain = new /obj/screen/fullscreen/pain( null )
hud_elements |= mymob.pain

mymob.zone_sel = new /obj/screen/zone_sel( null )
mymob.zone_sel = new
mymob.zone_sel.icon = ui_style
mymob.zone_sel.color = ui_color
mymob.zone_sel.alpha = ui_alpha
mymob.zone_sel.overlays.Cut()
mymob.zone_sel.overlays += image('icons/mob/zone_sel.dmi', "[mymob.zone_sel.selecting]")
mymob.zone_sel.update_icon()
hud_elements |= mymob.zone_sel

target.attack_selector = new
Expand Down
5 changes: 2 additions & 3 deletions code/_onclick/hud/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
mymob.healths.SetName("health")
mymob.healths.screen_loc = ui_construct_health

mymob.zone_sel = new /obj/screen/zone_sel()
mymob.zone_sel = new
mymob.zone_sel.icon = 'icons/mob/screen1_construct.dmi'
mymob.zone_sel.overlays.len = 0
mymob.zone_sel.overlays += image('icons/mob/zone_sel.dmi', "[mymob.zone_sel.selecting]")
mymob.zone_sel.update_icon()

mymob.purged = new /obj/screen()
mymob.purged.icon = 'icons/mob/screen1_construct.dmi'
Expand Down
5 changes: 2 additions & 3 deletions code/_onclick/hud/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ var/global/obj/screen/robot_inventory
R.up_hint.SetName("up hint")
R.up_hint.screen_loc = ui_up_hint

R.zone_sel = new /obj/screen/zone_sel()
R.zone_sel = new
R.zone_sel.icon = 'icons/mob/screen1_robot.dmi'
R.zone_sel.overlays.Cut()
R.zone_sel.overlays += image('icons/mob/zone_sel.dmi', "[R.zone_sel.selecting]")
R.zone_sel.update_icon()

//Handle the gun settings buttons
R.gun_setting_icon = new /obj/screen/gun/mode(null)
Expand Down
15 changes: 9 additions & 6 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@
usr.ClickOn(master)
return 1

/obj/screen/zone_sel
/obj/screen/zone_selector
name = "damage zone"
icon_state = "zone_sel"
screen_loc = ui_zonesel
var/selecting = BP_CHEST

/obj/screen/zone_sel/Click(location, control,params)
/obj/screen/zone_selector/Click(location, control,params)
var/list/PL = params2list(params)
var/icon_x = text2num(PL["icon-x"])
var/icon_y = text2num(PL["icon-y"])
Expand Down Expand Up @@ -198,16 +198,19 @@
set_selected_zone(new_selecting)
return 1

/obj/screen/zone_sel/proc/set_selected_zone(bodypart)
/obj/screen/zone_selector/Initialize(mapload)
. = ..()
update_icon()

/obj/screen/zone_selector/proc/set_selected_zone(bodypart)
var/old_selecting = selecting
selecting = bodypart
if(old_selecting != selecting)
update_icon()
return TRUE

/obj/screen/zone_sel/on_update_icon()
overlays.Cut()
overlays += image('icons/mob/zone_sel.dmi', "[selecting]")
/obj/screen/zone_selector/on_update_icon()
set_overlays(image('icons/mob/zone_sel.dmi', "[selecting]"))

/obj/screen/intent
name = "intent"
Expand Down
7 changes: 4 additions & 3 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ avoid code duplication. This includes items that may sometimes act as a standard
user.visible_message(SPAN_NOTICE("\The [user] puts \the [I] on \the [src]."))
return TRUE

return I.attack(src, user, user.zone_sel ? user.zone_sel.selecting : ran_zone())
return I.attack(src, user, user.get_target_zone() || ran_zone())

/mob/living/carbon/human/attackby(obj/item/I, mob/user)
if(user == src && user.zone_sel.selecting == BP_MOUTH && can_devour(I, silent = TRUE))
var/user_zone_sel = user.get_target_zone()
if(user == src && user_zone_sel == BP_MOUTH && can_devour(I, silent = TRUE))
var/obj/item/blocked = src.check_mouth_coverage()
if(blocked)
to_chat(user, SPAN_WARNING("\The [blocked] is in the way!"))
return TRUE
if(devour(I))
return TRUE
if(user.a_intent == I_HELP)
var/obj/item/organ/external/E = GET_EXTERNAL_ORGAN(src, user.zone_sel.selecting)
var/obj/item/organ/external/E = GET_EXTERNAL_ORGAN(src, user_zone_sel)
if(E)
for(var/datum/ailment/ailment in E.ailments)
if(ailment.treated_by_item(I))
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystems/throwing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SUBSYSTEM_DEF(throwing)
src.thrower = thrower
src.callback = callback
if(!QDELETED(thrower))
src.target_zone = thrower.zone_sel ? thrower.zone_sel.selecting : null
src.target_zone = thrower.get_target_zone()

dist_x = abs(target.x - thrownthing.x)
dist_y = abs(target.y - thrownthing.y)
Expand Down
10 changes: 5 additions & 5 deletions code/datums/observation/zone_selected.dm
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Observer Pattern Implementation: Zone Selected
// Registration type: /obj/screen/zone_sel
// Registration type: /obj/screen/zone_selector
//
// Raised when: A /obj/screen/zone_sel had its selected zone modified.
// Raised when: A /obj/screen/zone_selector had its selected zone modified.
//
// Arguments that the called proc should expect:
// /obj/screen/zone_sel: the
// /obj/screen/zone_selector: the
// old_zone: the previously selected zone
// new_zone: the newly selected zone
//

/decl/observ/zone_selected
name = "Zone Selected"
expected_type = /obj/screen/zone_sel
expected_type = /obj/screen/zone_selector

/*******************
* Zone Selected Handling *
*******************/

/obj/screen/zone_sel/set_selected_zone(bodypart)
/obj/screen/zone_selector/set_selected_zone(bodypart)
var/old_selecting = selecting
if((. = ..()))
RAISE_EVENT(/decl/observ/zone_selected, src, old_selecting, selecting)
4 changes: 2 additions & 2 deletions code/datums/repositories/attack_logs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var/global/repository/attack_logs/attack_log_repository = new()
/datum/attack_log
var/station_time
var/intent
var/zone_sel
var/target_zone
var/datum/mob_lite/attacker // We don't store the proper mob in case it gets deleted
var/datum/mob_lite/victim
var/turf/location // Turfs are forever
Expand All @@ -34,7 +34,7 @@ var/global/repository/attack_logs/attack_log_repository = new()
message = "[victim.name] [action_message]"

intent = mob_attacker ? uppertext(mob_attacker.a_intent) : "N/A"
zone_sel = mob_attacker?.zone_sel?.selecting ? uppertext(mob_attacker.zone_sel.selecting) : "N/A"
target_zone = uppertext(mob_attacker?.get_target_zone() || "N/A")

if(mob_attacker)
location = get_turf(mob_attacker)
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/changeling/changeling_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var/global/list/possible_changeling_IDs = list("Alpha","Beta","Gamma","Delta","E
to_chat(src, SPAN_WARNING("We are already absorbing!"))
return

var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(T, src.zone_sel.selecting)
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(T, get_target_zone())
if(!affecting)
to_chat(src, SPAN_WARNING("They are missing that body part!"))

Expand Down Expand Up @@ -708,7 +708,7 @@ var/global/list/datum/absorbed_dna/hivemind_bank = list()
if(!(T in view(changeling.sting_range))) return
if(!sting_can_reach(T, changeling.sting_range)) return
if(!changeling_power(required_chems)) return
var/obj/item/organ/external/target_limb = GET_EXTERNAL_ORGAN(T, src.zone_sel.selecting)
var/obj/item/organ/external/target_limb = GET_EXTERNAL_ORGAN(T, get_target_zone())
if (!target_limb)
to_chat(src, SPAN_WARNING("\The [T] is missing that limb."))
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/kitchen/cooking_machines/fryer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
icon_state = off_icon
return

var/target_zone = user.zone_sel.selecting
var/target_zone = user.get_target_zone()
if(ishuman(victim) && !(target_zone in list(BP_GROIN, BP_CHEST)))
var/mob/living/carbon/human/H = victim
var/obj/item/organ/external/E = GET_EXTERNAL_ORGAN(H, target_zone)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/spiders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var/mob/living/carbon/human/H = user
var/decl/natural_attack/attack = H.get_unarmed_attack(src)
if(istype(attack))
attack.show_attack(H, src, H.zone_sel.selecting, 1)
attack.show_attack(H, src, H.get_target_zone(), 1)
showed_msg = TRUE
if(!showed_msg)
visible_message(SPAN_DANGER("\The [user] squashes \the [src] flat!"))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/books/_book.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
..()

/obj/item/book/attack(mob/living/carbon/M, mob/living/carbon/user)
if(user.zone_sel.selecting == BP_EYES)
if(user.get_target_zone() == BP_EYES)
user.visible_message("<span class='notice'>You open up the book and show it to [M]. </span>", \
"<span class='notice'> [user] opens up a book and shows it to [M]. </span>")
user.setClickCooldown(DEFAULT_QUICK_COOLDOWN) //to prevent spam
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

/obj/item/flashlight/attack(mob/living/M, mob/living/user)
add_fingerprint(user)
if(on && user.zone_sel.selecting == BP_EYES)
if(on && user.get_target_zone() == BP_EYES)

if((MUTATION_CLUMSY in user.mutations) && prob(50)) //too dumb to use flashlight properly
return ..() //just hit them in the head
Expand Down
14 changes: 7 additions & 7 deletions code/game/objects/items/stacks/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting)
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone())

if(!affecting)
to_chat(user, SPAN_WARNING("\The [M] is missing that body part!"))
Expand Down Expand Up @@ -83,7 +83,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting) //nullchecked by ..()
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone()) //nullchecked by ..()

if(affecting.is_bandaged())
to_chat(user, SPAN_WARNING("The wounds on [M]'s [affecting.name] have already been bandaged."))
Expand Down Expand Up @@ -140,7 +140,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting) //nullchecked by ..()
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone()) //nullchecked by ..()

if(affecting.is_salved())
to_chat(user, SPAN_WARNING("The wounds on [M]'s [affecting.name] have already been salved."))
Expand Down Expand Up @@ -175,7 +175,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting) //nullchecked by ..()
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone()) //nullchecked by ..()
if(affecting.is_bandaged() && affecting.is_disinfected())
to_chat(user, SPAN_WARNING("The wounds on [M]'s [affecting.name] have already been treated."))
return 1
Expand Down Expand Up @@ -231,7 +231,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting) //nullchecked by ..()
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone()) //nullchecked by ..()

if(affecting.is_salved())
to_chat(user, SPAN_WARNING("The wounds on [M]'s [affecting.name] have already been salved."))
Expand Down Expand Up @@ -272,7 +272,7 @@

if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting) //nullchecked by ..()
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone()) //nullchecked by ..()
var/limb = affecting.name
if(!(affecting.organ_tag in splintable_organs))
to_chat(user, SPAN_WARNING("You can't use \the [src] to apply a splint there!"))
Expand Down Expand Up @@ -344,7 +344,7 @@
. = ..()
if(!. && ishuman(M))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting)
var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(H, user.get_target_zone())
if((affecting.brute_dam + affecting.burn_dam) <= 0)
to_chat(user, SPAN_WARNING("\The [M]'s [affecting.name] is undamaged."))
return 1
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/stacks/nanopaste.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

if (istype(M,/mob/living/carbon/human)) //Repairing robolimbs
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/S = GET_EXTERNAL_ORGAN(H, user.zone_sel.selecting)
var/obj/item/organ/external/S = GET_EXTERNAL_ORGAN(H, user.get_target_zone())

if(!S)
to_chat(user, "<span class='warning'>\The [M] is missing that body part.</span>")
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/weapons/autopsy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var/mob/living/carbon/human/M = A
set_target(M, user)
timeofdeath = M.timeofdeath
var/obj/item/organ/external/S = GET_EXTERNAL_ORGAN(M, user.zone_sel.selecting)
var/obj/item/organ/external/S = GET_EXTERNAL_ORGAN(M, user.get_target_zone())
if(!S)
visible_message(SPAN_WARNING("[src] states, 'The targeted bodypart is missing.'"))
return
Expand All @@ -42,8 +42,8 @@
else if(istype(A, /obj/item/organ/external))
set_target(A, user)
add_data(A)
scan_title = "Autopsy Report ([target_name])"

scan_title = "Autopsy Report ([target_name])"
scan_data = get_formatted_data()
playsound(src, 'sound/effects/fastbeep.ogg', 10)

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/handcuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var/global/last_chew = 0 //#FIXME: Its funny how only one person in the world ca
var/mob/living/carbon/human/H = A
if (!H.get_equipped_item(slot_handcuffed_str)) return
if (H.a_intent != I_HURT) return
if (H.zone_sel.selecting != BP_MOUTH) return
if (H.get_target_zone() != BP_MOUTH) return
if (H.get_equipped_item(slot_wear_mask_str)) return
if (istype(H.get_equipped_item(slot_wear_suit_str), /obj/item/clothing/suit/straight_jacket)) return

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/implants/implanter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
user.setClickCooldown(DEFAULT_QUICK_COOLDOWN)
user.do_attack_animation(M)

var/target_zone = user.zone_sel.selecting
var/target_zone = user.get_target_zone()
if(src.imp.can_implant(M, user, target_zone))
var/imp_name = imp.name

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/lighter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
M.IgniteMob()

var/obj/item/clothing/mask/smokable/cigarette/cig = M.get_equipped_item(slot_wear_mask_str)
if(istype(cig) && user.zone_sel.selecting == BP_MOUTH)
if(istype(cig) && user.get_target_zone() == BP_MOUTH)
if(M == user)
cig.attackby(src, user)
else
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/material/kitchen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
return ..()

if(user.a_intent != I_HELP)
if(user.zone_sel.selecting == BP_HEAD || user.zone_sel.selecting == BP_EYES)
if(user.get_target_zone() == BP_HEAD || user.get_target_zone() == BP_EYES)
if((MUTATION_CLUMSY in user.mutations) && prob(50))
M = user
return eyestab(M,user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/material/knives.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
return ..()

if(user.a_intent != I_HELP)
if(user.zone_sel.selecting == BP_EYES)
if(user.get_target_zone() == BP_EYES)
if((MUTATION_CLUMSY in user.mutations) && prob(50))
M = user
return eyestab(M, user)
Expand Down
Loading

0 comments on commit 028eb48

Please sign in to comment.