Catching is no longer guaranteed, accuracy code is more general

This commit is contained in:
Anewbe
2018-08-27 22:37:06 -05:00
parent 532012c5bf
commit b5e9000e11
5 changed files with 47 additions and 35 deletions

View File

@@ -71,13 +71,7 @@
if(!istype(P))
return
// Certain statuses make it harder to aim, blindness especially. Same chances as melee, however guns accuracy uses multiples of 15.
if(user.eye_blind)
P.accuracy -= 75
if(user.eye_blurry)
P.accuracy -= 30
if(user.confused)
P.accuracy -= 45
P.accuracy -= user.get_accuracy_penalty()
// Some modifiers make it harder or easier to hit things.
for(var/datum/modifier/M in user.modifiers)

View File

@@ -24,8 +24,8 @@
// Should this all be in Touch()?
if(istype(H))
if(get_accuracy_penalty(H) && H != src) //Should only trigger if they're not aiming well
var/hit_zone = get_zone_with_miss_chance(H.zone_sel.selecting, src, get_accuracy_penalty(H))
if(H.get_accuracy_penalty() && H != src) //Should only trigger if they're not aiming well
var/hit_zone = get_zone_with_miss_chance(H.zone_sel.selecting, src, H.get_accuracy_penalty())
if(!hit_zone)
H.do_attack_animation(src)
playsound(loc, 'sound/weapons/punchmiss.ogg', 25, 1, -1)
@@ -235,7 +235,7 @@
H.visible_message("<span class='danger'>[attack_message]</span>")
playsound(loc, ((miss_type) ? (miss_type == 1 ? attack.miss_sound : 'sound/weapons/thudswoosh.ogg') : attack.attack_sound), 25, 1, -1)
add_attack_logs(H,src,"Melee attacked with fists (miss/block)")
if(miss_type)

View File

@@ -187,18 +187,6 @@ emp_act
if(.) return
return 0
/mob/living/carbon/human/proc/get_accuracy_penalty(mob/living/user)
// Certain statuses make it harder to score a hit. These are the same as gun accuracy, however melee doesn't use multiples of 15.
var/accuracy_penalty = 0
if(user.eye_blind)
accuracy_penalty += 75
if(user.eye_blurry)
accuracy_penalty += 30
if(user.confused)
accuracy_penalty += 45
return accuracy_penalty
/mob/living/carbon/human/resolve_item_attack(obj/item/I, mob/living/user, var/target_zone)
if(check_neckgrab_attack(I, user, target_zone))
return null
@@ -206,7 +194,7 @@ emp_act
if(user == src) // Attacking yourself can't miss
return target_zone
var/hit_zone = get_zone_with_miss_chance(target_zone, src, get_accuracy_penalty(user))
var/hit_zone = get_zone_with_miss_chance(target_zone, src, user.get_accuracy_penalty())
if(!hit_zone)
user.do_attack_animation(src)
@@ -349,13 +337,14 @@ emp_act
if(istype(AM,/obj/))
var/obj/O = AM
if(in_throw_mode && !get_active_hand() && speed <= THROWFORCE_SPEED_DIVISOR) //empty active hand and we're in throw mode
if(in_throw_mode && speed <= THROWFORCE_SPEED_DIVISOR) //empty active hand and we're in throw mode
if(canmove && !restrained())
if(isturf(O.loc))
put_in_active_hand(O)
visible_message("<span class='warning'>[src] catches [O]!</span>")
throw_mode_off()
return
if(can_catch(O))
put_in_active_hand(O)
visible_message("<span class='warning'>[src] catches [O]!</span>")
throw_mode_off()
return
var/dtype = O.damtype
var/throw_damage = O.throwforce*(speed/THROWFORCE_SPEED_DIVISOR)
@@ -450,6 +439,29 @@ emp_act
src.anchored = 1
src.pinned += O
// This does a prob check to catch the thing flying at you, with a minimum of 1%
/mob/living/carbon/human/proc/can_catch(var/obj/O)
if(!get_active_hand()) // If active hand is empty
var/obj/item/organ/external/temp = organs_by_name["r_hand"]
if (hand)
temp = organs_by_name["l_hand"]
if(temp && !temp.is_usable())
return FALSE // The hand isn't working in the first place
// Alright, our hand works? Time to try the catching.
var/catch_chance = 90 // Default 90% catch rate
if(O.sharp)
catch_chance -= 50 // Catching knives is hard
catch_chance -= get_accuracy_penalty() // Same issues with shooting a gun, or swinging a weapon
catch_chance = between(1, catch_chance, 100)
if(prob(catch_chance))
return TRUE
return FALSE
/mob/living/carbon/human/embed(var/obj/O, var/def_zone=null)
if(!def_zone) ..()

View File

@@ -507,3 +507,15 @@
if(!isnull(M.evasion))
result += M.evasion
return result
/mob/living/proc/get_accuracy_penalty()
// Certain statuses make it harder to score a hit.
var/accuracy_penalty = 0
if(eye_blind)
accuracy_penalty += 75
if(eye_blurry)
accuracy_penalty += 30
if(confused)
accuracy_penalty += 45
return accuracy_penalty

View File

@@ -590,13 +590,7 @@
P.accuracy = accuracy + acc_mod
P.dispersion = disp_mod
// Certain statuses make it harder to aim, blindness especially. Same chances as melee, however guns accuracy uses multiples of 15.
if(user.eye_blind)
P.accuracy -= 75
if(user.eye_blurry)
P.accuracy -= 30
if(user.confused)
P.accuracy -= 45
P.accuracy -= user.get_accuracy_penalty()
//accuracy bonus from aiming
if (aim_targets && (target in aim_targets))