refactoring this whole thing again

This commit is contained in:
kevinz000
2020-03-16 04:56:32 -07:00
parent c35ffacf50
commit a77be038b8
15 changed files with 64 additions and 43 deletions

View File

@@ -228,21 +228,27 @@ GLOBAL_LIST_INIT(shove_disarming_types, typecacheof(list(
/// Attack outright missed because the target dodged. Should usually be combined with redirection passthrough or something (see martial arts)
#define BLOCK_TARGET_DODGED (1<<7)
/// Meta-flag for run_block/do_run_block : By default, BLOCK_SUCCESS tells do_run_block() to assume the attack is completely blocked and not continue the block chain. If this is present, it will continue to check other items in the chain rather than stopping.
#define BLOCK_cONTINUE_CHAIN (1<<8)
#define BLOCK_CONTINUE_CHAIN (1<<8)
/// For keys in associative list/block_return as we don't want to saturate our (somewhat) limited flags.
#define BLOCK_RETURN_REDIRECT_METHOD "REDIRECT_METHOD"
/// Pass through victim
#define REDIRECT_METHOD_PASSTHROUGH "passthrough"
/// Reflect using normal angular/mirrorlike reflection
#define REDIRECT_METHOD_REFLECT "reflect"
/// Deflect at randomish angle
#define REDIRECT_METHOD_DEFLECT "deflect"
/// do not taser the bad man with the desword
/// reverse 180 angle, basically (as opposed to "realistic" wall reflections)
#define REDIRECT_METHOD_REFLECT "reflect"
/// "do not taser the bad man with the desword" - actually aims at the firer/attacker rather than just reversing
#define REDIRECT_METHOD_RETURN_TO_SENDER "no_you"
/// These keys are generally only applied to the list if real_attack is FALSE. Used incase we want to make "smarter" mob AI in the future or something.
/// Tells the caller how likely from 0 (none) to 100 (always) we are to reflect energy projectiles
#define BLOCK_RETURN_REFLECT_PROJECTILE_CHANCE
/// Tells the caller how likely we are to block attacks from 0 to 100 in general
#define BLOCK_RETURN_NORMAL_BLOCK_CHANCE
/// Default if the above isn't set in the list.
#define DEFAULT_REDIRECT_METHOD_PROJECTILE REDIRECT_METHOD_REFLECT
#define DEFAULT_REDIRECT_METHOD_PROJECTILE REDIRECT_METHOD_DEFLECT
/// Block priorities
#define BLOCK_PRIORITY_HELD_ITEM 100

View File

@@ -121,7 +121,7 @@
if(damage && !P.nodamage && (P.damage_type != STAMINA) && prob(15))
owner.visible_message("<span class='danger'>[attack_text] hits [owner]'s [src], setting it off! What a shot!</span>")
prime()
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL | BLOCK_INTERRUPT_CHAIN
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return ..()
/obj/item/proc/grenade_prime_react(obj/item/grenade/nade)

View File

@@ -755,7 +755,7 @@
if(real_attack && (attack_type & ATTACK_TYPE_PROJECTILE))
owner.visible_message("<span class='danger'>Ranged attacks just make [owner] angrier!</span>")
playsound(src, pick('sound/weapons/bulletflyby.ogg', 'sound/weapons/bulletflyby2.ogg', 'sound/weapons/bulletflyby3.ogg'), 75, 1)
return BLOCK_SUCCESS | BLOCK_INTERRUPT_CHAIN | BLOCK_PHYSICAL_EXTERNAL
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return ..()
//GREY TIDE
@@ -908,7 +908,7 @@
return BLOCK_SUCCESS | BLOCK_REDIRECTED | BLOCK_SHOULD_REDIRECT | BLOCK_PHYSICAL_EXTERNAL
else
owner.visible_message("<span class='danger'>[owner] parries [attack_text] with [src]!</span>")
return BLOCK_SUCCESS | BLOCK_PARRY
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return NONE
/obj/item/twohanded/vibro_weapon/update_icon_state()

View File

@@ -157,7 +157,7 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301
/obj/item/claymore/highlander/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
if((attack_type & ATTACK_TYPE_PROJECTILE) && is_energy_reflectable_projectile(object))
return BLOCK_SUCCESS | BLOCK_SHOULD_REDIRECT | BLOCK_PHYSICAL_EXTERNAL | BLOCK_REDIRECT
return BLOCK_SUCCESS | BLOCK_SHOULD_REDIRECT | BLOCK_PHYSICAL_EXTERNAL | BLOCK_REDIRECTED
return ..()
/obj/item/claymore/highlander/proc/add_notch(mob/living/user) //DYNAMIC CLAYMORE PROGRESSION SYSTEM - THIS IS THE FUTURE
@@ -583,14 +583,13 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301
force = 12
throwforce = 15
/obj/item/melee/baseball_bat/ablative/IsReflect()//some day this will reflect thrown items instead of lasers
var/picksound = rand(1,2)
var/turf = get_turf(src)
if(picksound == 1)
playsound(turf, 'sound/weapons/effects/batreflect1.ogg', 50, 1)
if(picksound == 2)
playsound(turf, 'sound/weapons/effects/batreflect2.ogg', 50, 1)
return 1
/obj/item/melee/baseball_bat/ablative/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
//some day this will reflect thrown items instead of lasers
if(is_energy_reflectable_projectile(object) && (attack_type == ATTACK_TYPE_PROJECTILE))
var/turf = get_turf(src)
playsound(turf, pick('sound/weapons/effects/batreflect1.ogg', 'sound/weapons/effects/batreflect2.ogg'), 50, 1)
return BLOCK_SUCESS | BLOCK_SHOULD_REDIRECT | BLOCK_PHYSICAL_EXTERNAL | BLOCK_REDIRECTED
return ..()
/obj/item/melee/baseball_bat/ablative/syndi
name = "syndicate major league bat"

View File

@@ -725,19 +725,19 @@
playsound(T, 'sound/effects/glassbr3.ogg', 100)
qdel(src)
/obj/item/twohanded/cult_spear/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/twohanded/cult_spear/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
if(wielded)
final_block_chance *= 2
if(prob(final_block_chance))
if(attack_type & PROJECTILE_ATTACK)
if(attack_type & ATTACK_TYPE_PROJECTILE)
owner.visible_message("<span class='danger'>[owner] deflects [attack_text] with [src]!</span>")
playsound(src, pick('sound/weapons/effects/ric1.ogg', 'sound/weapons/effects/ric2.ogg', 'sound/weapons/effects/ric3.ogg', 'sound/weapons/effects/ric4.ogg', 'sound/weapons/effects/ric5.ogg'), 100, 1)
return TRUE
return BLOCK_SUCCESS | BLOCK_SHOULD_REDIRECT | BLOCK_REDIRECTED | BLOCK_PHYSICAL_EXTERNAL
else
playsound(src, 'sound/weapons/parry.ogg', 100, 1)
owner.visible_message("<span class='danger'>[owner] parries [attack_text] with [src]!</span>")
return TRUE
return FALSE
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return BLOCK_NONE
/datum/action/innate/cult/spear
name = "Bloody Bond"
@@ -936,10 +936,13 @@
hitsound = 'sound/weapons/smash.ogg'
var/illusions = 2
/obj/item/shield/mirror/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/shield/mirror/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
if(!real_attack)
block_return[BLOCK_RETURN_REFLECT_PROJECTILE_CHANCE] = final_block_chance
return ..()
if(iscultist(owner))
if(istype(hitby, /obj/item/projectile))
var/obj/item/projectile/P = hitby
if(istype(object, /obj/item/projectile) && (attack_type == ATTACK_TYPE_PROJECTILE))
var/obj/item/projectile/P = object
if(P.damage >= 30)
var/turf/T = get_turf(owner)
T.visible_message("<span class='warning'>The sheer force from [P] shatters the mirror shield!</span>")
@@ -947,11 +950,13 @@
playsound(T, 'sound/effects/glassbr3.ogg', 100)
owner.DefaultCombatKnockdown(25)
qdel(src)
return FALSE
return BLOCK_NONE
if(P.is_reflectable)
return FALSE //To avoid reflection chance double-dipping with block chance
if(prob(final_block_chance))
return BLOCK_SUCCESS | BLOCK_SHOULD_REDIRECT | BLOCK_PHYSICAL_EXTERNAL | BLOCK_REDIRECTED
return BLOCK_NONE //To avoid reflection chance double-dipping with block chance
. = ..()
if(.)
if(. & BLOCK_SUCCESS)
playsound(src, 'sound/weapons/parry.ogg', 100, 1)
if(illusions > 0)
illusions--
@@ -966,7 +971,7 @@
E.Copy_Parent(owner, 70, 10)
E.GiveTarget(owner)
E.Goto(owner, owner.movement_delay(), E.minimum_distance)
return TRUE
return
else
if(prob(50))
var/mob/living/simple_animal/hostile/illusion/H = new(owner.loc)
@@ -975,7 +980,7 @@
H.GiveTarget(owner)
H.move_to_delay = owner.movement_delay()
to_chat(owner, "<span class='danger'><b>[src] betrays you!</b></span>")
return FALSE
return BLOCK_NONE
/obj/item/shield/mirror/proc/readd()
illusions++

View File

@@ -757,7 +757,11 @@
if(!allowed)
allowed = GLOB.advanced_hardsuit_allowed
/obj/item/clothing/suit/space/hardsuit/shielded/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/clothing/suit/space/hardsuit/shielded/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
if(!real_attack)
if(current_charges > 0)
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return BLOCK_NONE
recharge_cooldown = world.time + recharge_delay
if(current_charges > 0)
var/datum/effect_system/spark_spread/s = new
@@ -771,8 +775,8 @@
owner.visible_message("[owner]'s shield overloads!")
shield_state = "broken"
owner.update_inv_wear_suit()
return 1
return 0
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return BLOCK_NONE
/obj/item/clothing/suit/space/hardsuit/shielded/Destroy()
STOP_PROCESSING(SSobj, src)

View File

@@ -4,7 +4,6 @@
icon_state = "reactiveoff"
icon = 'icons/obj/clothing/suits.dmi'
w_class = WEIGHT_CLASS_BULKY
var/hit_reaction_chance = 50
/obj/item/reactive_armour_shell/attackby(obj/item/I, mob/user, params)
..()
@@ -39,6 +38,7 @@
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
hit_reaction_chance = 50 // Only on the chest yet blocks all attacks?
rad_flags = RAD_PROTECT_CONTENTS | RAD_NO_CONTAMINATE
var/hit_reaction_chance = 50
/obj/item/clothing/suit/armor/reactive/attack_self(mob/user)
active = !(active)

View File

@@ -81,8 +81,9 @@
/obj/item/clothing/under/color/grey/glorf/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
. = ..()
if(real_attack)
owner.forcesay(GLOB.hit_appends)
if(real_attack && ishuman(owner))
var/mob/living/human/H = owner
H.forcesay(GLOB.hit_appends)
/obj/item/clothing/under/color/blue
name = "blue jumpsuit"

View File

@@ -835,9 +835,9 @@
force = CLAMP((ghost_counter * 4), 0, 75)
user.visible_message("<span class='danger'>[user] strikes with the force of [ghost_counter] vengeful spirits!</span>")
..()
return ..()
/obj/item/melee/ghost_sword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/melee/ghost_sword/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
var/ghost_counter = ghost_check()
final_block_chance += CLAMP((ghost_counter * 5), 0, 75)
owner.visible_message("<span class='danger'>[owner] is protected by a ring of [ghost_counter] ghosts!</span>")

View File

@@ -63,7 +63,7 @@
if(hit_atom)
if(isliving(hit_atom))
var/mob/living/L = hit_atom
if(L.run_block(src, 0, "the [name]", attack_type = LEAP_ATTACK, 0, src) & BLOCK_SUCCESS)
if(L.run_block(src, 0, "the [name]", attack_type = ATTACK_TYPE_TACKLE, 0, src) & BLOCK_SUCCESS)
DefaultCombatKnockdown(40, 1, 1)
else
L.visible_message("<span class ='danger'>[src] pounces on [L]!</span>", "<span class ='userdanger'>[src] pounces on you!</span>")

View File

@@ -76,9 +76,15 @@
/// Block priority, higher means we check this higher in the "chain".
var/block_priority = BLOCK_PRIORITY_DEFAULT
/// Runs block and returns flag for do_run_block to process.
/obj/item/proc/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
SEND_SIGNAL(src, COMSIG_ITEM_RUN_BLOCK, args)
if(prob(final_block_chance))
owner.visible_message("<span class='danger'>[owner] blocks [attack_text] with [src]!</span>")
return BLOCK_SUCCESS | BLOCK_PHYSICAL_EXTERNAL
return BLOCK_NONE
/// Returns block information using list/block_return. Used for check_block() on mobs.
/obj/item/proc/check_block(mob/living/owner, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
SEND_SIGNAL(src, COMSIG_ITEM_CHECK_BLOCK, args)
block_return[BLOCK_RETURN_NORMAL_BLOCK_CHANCE] = final_block_chance

View File

@@ -115,7 +115,7 @@
if(reflect_bullet_check(P, def_zone))
return -1 // complete projectile permutation
#warn implement blocktypes
if(run_block(P, P.damage, "the [P.name]", PROJECTILE_ATTACK, P.armour_penetration) & BLOCK_SUCCESS)
if(run_block(P, P.damage, "the [P.name]", ATTACK_TYPE_PROJECTILE, P.armour_penetration) & BLOCK_SUCCESS)
P.on_hit(src, 100, def_zone)
return BULLET_ACT_BLOCK
if((P.damage_type == BRUTE || P.damage_type == BURN))

View File

@@ -54,7 +54,7 @@
var/blocked = FALSE
if(hasmatchingsummoner(hit_atom)) //if the summoner matches don't hurt them
blocked = TRUE
if(L.run_block(src, 90, "[name]", attack_type = ATTACK_TYPE_LEAP, 0, src) & BLOCK_SUCCESS)
if(L.run_block(src, 90, "[name]", attack_type = ATTACK_TYPE_TACKLE, 0, src) & BLOCK_SUCCESS)
blocked = TRUE
if(!blocked)
L.drop_all_held_items()

View File

@@ -92,7 +92,7 @@
/obj/item/gun/magic/staff/spellblade/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
// Do not block projectiles.
if(attack_type & PROJECTILE_ATTACK)
if(attack_type & ATTACK_TYPE_PROJECTILE)
return BLOCK_NONE
return ..()