Refactors Zone Selection (#12523)

This commit is contained in:
Fox McCloud
2019-10-08 21:11:09 -04:00
committed by variableundefined
parent a39127a1ca
commit 5194094d3a
57 changed files with 116 additions and 126 deletions
+1 -1
View File
@@ -241,7 +241,7 @@
// BEGIN HUGCODE - N3X
else
playsound(get_turf(src), 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
if(M.zone_sel.selecting == "head")
if(M.zone_selected == "head")
M.visible_message(\
"<span class='notice'>[M] pats [src] on the head.</span>",\
"<span class='notice'>You pat [src] on the head.</span>",\
@@ -1013,7 +1013,7 @@
if(!user)
target_zone = pick("chest","chest","chest","left leg","right leg","left arm", "right arm", "head")
else
target_zone = user.zone_sel.selecting
target_zone = user.zone_selected
if(PIERCEIMMUNE in dna.species.species_traits)
@@ -355,7 +355,7 @@ emp_act
qdel(src)
var/obj/item/organ/external/affecting = get_organ(ran_zone(user.zone_sel.selecting))
var/obj/item/organ/external/affecting = get_organ(ran_zone(user.zone_selected))
if(!affecting)
to_chat(user, "<span class='danger'>They are missing that limb!</span>")
return 1
@@ -382,7 +382,7 @@ emp_act
var/armor = run_armor_check(affecting, "melee", "<span class='warning'>Your armour has protected your [hit_area].</span>", "<span class='warning'>Your armour has softened hit to your [hit_area].</span>", armour_penetration = I.armour_penetration)
var/weapon_sharp = is_sharp(I)
if(weapon_sharp && prob(getarmor(user.zone_sel.selecting, "melee")))
if(weapon_sharp && prob(getarmor(user.zone_selected, "melee")))
weapon_sharp = 0
if(armor >= 100)
return 0
@@ -532,7 +532,7 @@ emp_act
var/damage = rand(1, 3)
if(stat != DEAD)
L.amount_grown = min(L.amount_grown + damage, L.max_grown)
var/obj/item/organ/external/affecting = get_organ(ran_zone(L.zone_sel.selecting))
var/obj/item/organ/external/affecting = get_organ(ran_zone(L.zone_selected))
var/armor_block = run_armor_check(affecting, "melee")
apply_damage(damage, BRUTE, affecting, armor_block)
updatehealth("larva attack")
@@ -551,7 +551,7 @@ emp_act
playsound(loc, 'sound/weapons/slashmiss.ogg', 50, 1, -1)
visible_message("<span class='danger'>[M] has lunged at [src]!</span>")
return 0
var/obj/item/organ/external/affecting = get_organ(ran_zone(M.zone_sel.selecting))
var/obj/item/organ/external/affecting = get_organ(ran_zone(M.zone_selected))
var/armor_block = run_armor_check(affecting, "melee")
playsound(loc, 'sound/weapons/slice.ogg', 25, 1, -1)
@@ -568,7 +568,7 @@ emp_act
if(M.a_intent == INTENT_DISARM)
if(prob(80))
var/obj/item/organ/external/affecting = get_organ(ran_zone(M.zone_sel.selecting))
var/obj/item/organ/external/affecting = get_organ(ran_zone(M.zone_selected))
playsound(loc, 'sound/weapons/pierce.ogg', 25, 1, -1)
apply_effect(5, WEAKEN, run_armor_check(affecting, "melee"))
add_attack_logs(M, src, "Alien tackled")
@@ -395,7 +395,7 @@
/datum/species/proc/harm(mob/living/carbon/human/user, mob/living/carbon/human/target, datum/martial_art/attacker_style)
//Vampire code
if(user.mind && user.mind.vampire && (user.mind in SSticker.mode.vampires) && !user.mind.vampire.draining && user.zone_sel && user.zone_sel.selecting == "head" && target != user)
if(user.mind && user.mind.vampire && (user.mind in SSticker.mode.vampires) && !user.mind.vampire.draining && user.zone_selected == "head" && target != user)
if((NO_BLOOD in target.dna.species.species_traits) || target.dna.species.exotic_blood || !target.blood_volume)
to_chat(user, "<span class='warning'>They have no blood!</span>")
return
@@ -438,7 +438,7 @@
return FALSE
var/obj/item/organ/external/affecting = target.get_organ(ran_zone(user.zone_sel.selecting))
var/obj/item/organ/external/affecting = target.get_organ(ran_zone(user.zone_selected))
var/armor_block = target.run_armor_check(affecting, "melee")
playsound(target.loc, attack.attack_sound, 25, 1, -1)
@@ -465,7 +465,7 @@
user.do_attack_animation(target, ATTACK_EFFECT_DISARM)
if(target.w_uniform)
target.w_uniform.add_fingerprint(user)
var/obj/item/organ/external/affecting = target.get_organ(ran_zone(user.zone_sel.selecting))
var/obj/item/organ/external/affecting = target.get_organ(ran_zone(user.zone_selected))
var/randn = rand(1, 100)
if(randn <= 25)
target.apply_effect(2, WEAKEN, target.run_armor_check(affecting, "melee"))
-9
View File
@@ -376,15 +376,6 @@
/mob/living/is_drawable(mob/user, allowmobs = TRUE)
return (allowmobs && reagents && can_inject(user))
/mob/living/proc/get_organ_target()
var/mob/shooter = src
var/t = shooter:zone_sel.selecting
if((t in list( "eyes", "mouth" )))
t = "head"
var/obj/item/organ/external/def_zone = ran_zone(t)
return def_zone
/mob/living/proc/restore_all_organs()
return
@@ -67,9 +67,6 @@ Difficulty: Medium
. = ..()
miner_saw = new(src)
// Add a zone selection UI; otherwise the mob can't melee attack properly.
zone_sel = new /obj/screen/zone_sel()
/datum/action/innate/megafauna_attack/dash
name = "Dash To Target"
icon_icon = 'icons/mob/actions/actions.dmi'
@@ -95,8 +95,6 @@
forceMove( possessed_loc )
possessed_item.forceMove(src) // We'll keep the actual item inside of us until we die.
zone_sel = new /obj/screen/zone_sel(src) // Create a new zone selection item so the human attacks have something to reference. Horrifying and ugly hack, do not look directly at this.
update_icon(1)
visible_message("<span class='shadowling'>[src] rises into the air and begins to float!</span>") // Inform those around us that shit's gettin' spooky.
+3 -1
View File
@@ -8,6 +8,9 @@
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
/// The zone this mob is currently targeting
var/zone_selected = null
var/obj/screen/hands = null
var/obj/screen/pullin = null
var/obj/screen/i_select = null
@@ -21,7 +24,6 @@
I'll make some notes on where certain variable defines should probably go.
Changing this around would probably require a good look-over the pre-existing code.
*/
var/obj/screen/zone_sel/zone_sel = null
var/obj/screen/leap_icon = null
var/obj/screen/healthdoll/healthdoll = null
+1 -1
View File
@@ -106,7 +106,7 @@
assailant.client.screen -= hud
assailant.client.screen += hud
var/hit_zone = assailant.zone_sel.selecting
var/hit_zone = assailant.zone_selected
last_hit_zone = hit_zone
if(assailant.pulling == affecting)
+13 -13
View File
@@ -388,7 +388,7 @@
/mob/proc/update_gravity()
return
/client/proc/check_has_body_select()
return mob && mob.hud_used && mob.zone_sel && istype(mob.zone_sel, /obj/screen/zone_sel)
return mob && mob.hud_used && mob.hud_used.zone_select && istype(mob.hud_used.zone_select, /obj/screen/zone_sel)
/client/verb/body_toggle_head()
set name = "body-toggle-head"
@@ -398,7 +398,7 @@
return
var/next_in_line
switch(mob.zone_sel.selecting)
switch(mob.zone_selected)
if(BODY_ZONE_HEAD)
next_in_line = BODY_ZONE_PRECISE_EYES
if(BODY_ZONE_PRECISE_EYES)
@@ -406,7 +406,7 @@
else
next_in_line = BODY_ZONE_HEAD
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(next_in_line, mob)
/client/verb/body_r_arm()
@@ -416,12 +416,12 @@
return
var/next_in_line
if(mob.zone_sel.selecting == BODY_ZONE_R_ARM)
if(mob.zone_selected == BODY_ZONE_R_ARM)
next_in_line = BODY_ZONE_PRECISE_R_HAND
else
next_in_line = BODY_ZONE_R_ARM
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(next_in_line, mob)
/client/verb/body_chest()
@@ -431,7 +431,7 @@
if(!check_has_body_select())
return
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(BODY_ZONE_CHEST, mob)
/client/verb/body_l_arm()
@@ -442,12 +442,12 @@
return
var/next_in_line
if(mob.zone_sel.selecting == BODY_ZONE_L_ARM)
if(mob.zone_selected == BODY_ZONE_L_ARM)
next_in_line = BODY_ZONE_PRECISE_L_HAND
else
next_in_line = BODY_ZONE_L_ARM
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(next_in_line, mob)
/client/verb/body_r_leg()
@@ -458,12 +458,12 @@
return
var/next_in_line
if(mob.zone_sel.selecting == BODY_ZONE_R_LEG)
if(mob.zone_selected == BODY_ZONE_R_LEG)
next_in_line = BODY_ZONE_PRECISE_R_FOOT
else
next_in_line = BODY_ZONE_R_LEG
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(next_in_line, mob)
/client/verb/body_groin()
@@ -473,7 +473,7 @@
if(!check_has_body_select())
return
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(BODY_ZONE_PRECISE_GROIN, mob)
/client/verb/body_l_leg()
@@ -484,12 +484,12 @@
return
var/next_in_line
if(mob.zone_sel.selecting == BODY_ZONE_L_LEG)
if(mob.zone_selected == BODY_ZONE_L_LEG)
next_in_line = BODY_ZONE_PRECISE_L_FOOT
else
next_in_line = BODY_ZONE_L_LEG
var/obj/screen/zone_sel/selector = mob.zone_sel
var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
selector.set_selected_zone(next_in_line, mob)
/client/verb/toggle_walk_run()