Adds miss chance and shield checks to thrown atoms

Also makes setting a thrown atom's throwing var the responsibility of
the handler, so that impact handling code can decide if the thrown atom
should keep on going.
This commit is contained in:
mwerezak
2014-07-14 23:53:27 -04:00
parent 177560cf4b
commit 836d2e40a8
6 changed files with 51 additions and 31 deletions

View File

@@ -107,6 +107,7 @@ var/const/MAX_ACTIVE_TIME = 400
if(stat == CONSCIOUS)
icon_state = "[initial(icon_state)]"
Attach(hit_atom)
throwing = 0
/obj/item/clothing/mask/facehugger/proc/Attach(M as mob)
if( (!iscorgi(M) && !iscarbon(M)) || isalien(M))

View File

@@ -65,6 +65,7 @@
P.on_hit(src, absorb, def_zone)
return absorb
//this proc handles being hit by a thrown atom
/mob/living/hitby(atom/movable/AM as mob|obj,var/speed = 5)//Standardization and logging -Sieve
if(istype(AM,/obj/))
var/obj/O = AM
@@ -73,14 +74,27 @@
if(istype(O,/obj/item/weapon))
var/obj/item/weapon/W = O
dtype = W.damtype
var/throw_damage = O.throwforce*(speed/5)
//run to-hit check here
//def_zone = get_zone_with_miss_chance(zone, src, 15*AM.throwing_dist_travelled)
zone = get_zone_with_miss_chance(zone, src) //TODO: store the location of the thrower and adjust miss chance with distance
if(!zone)
visible_message("\blue \The [AM] misses [src] narrowly!")
return
AM.throwing = 0 //it hit, so stop moving
if (istype(src, /mob/living/carbon/human))
var/mob/living/carbon/human/H = src
if (H.check_shields(throw_damage, "[O]"))
return
src.visible_message("\red [src] has been hit by [O].")
var/armor = run_armor_check(zone, "melee", "Your armor has protected your [zone].", "Your armor has softened hit to your [zone].")
var/armor = run_armor_check(zone, "melee", "Your armor has protected your [zone].", "Your armor has softened the hit to your [zone].")
if(armor < 2)
apply_damage(O.throwforce*(speed/5), dtype, zone, armor, is_sharp(O), has_edge(O), O)
apply_damage(throw_damage, dtype, zone, armor, is_sharp(O), has_edge(O), O)
if(!O.fingerprintslast)
return
@@ -99,7 +113,7 @@
if(speed >= 15)
var/obj/item/weapon/W = O
var/momentum = speed/2
var/dir = get_dir(M,src)
var/dir = get_dir(M,src) //TODO: store the location of the thrower and move this out of the fingerprintslast block
visible_message("\red [src] staggers under the impact!","\red You stagger under the impact!")
src.throw_at(get_edge_target_turf(src,dir),1,momentum)

View File

@@ -147,7 +147,11 @@ proc/hasorgans(A)
*/
return zone
// Returns zone with a certain probability.
// If the probability misses, returns "chest" instead.
// If "chest" was passed in as zone, then on a "miss" will return "head", "l_arm", or "r_arm"
// Do not use this if someone is intentionally trying to hit a specific body part.
// Use get_zone_with_miss_chance() for that.
/proc/ran_zone(zone, probability)
zone = check_zone(zone)
if(!probability) probability = 90