From 8aae42687d29723527218753a634f380feba5a60 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:05:26 -0400 Subject: [PATCH] 1029204smallbugs (#1109) * Fix people marked by the flock seeing the marker * Cleanup directional block code and fix a bug --- code/__DEFINES/maths.dm | 3 +++ code/__HELPERS/combat_helpers.dm | 18 ++++++++++++------ code/game/objects/items.dm | 7 ++++++- .../flock_controller/_flock_controller.dm | 2 +- .../flockmind/flock_structure/flock_turret.dm | 3 ++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index e22a0dffe1cd..984dbbabc719 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -123,6 +123,9 @@ /// Gets shift x that would be required the bitflag (1< 225, 0 -> 180, etc +#define REVERSE_ANGLE(angle) (floor((angle) + 180) % 360) + // Will filter out extra rotations and negative rotations // E.g: 540 becomes 180. -180 becomes 180. #define SIMPLIFY_DEGREES(degrees) (MODULUS((degrees), 360)) diff --git a/code/__HELPERS/combat_helpers.dm b/code/__HELPERS/combat_helpers.dm index 4ea817b573b3..4a80d4109dd6 100644 --- a/code/__HELPERS/combat_helpers.dm +++ b/code/__HELPERS/combat_helpers.dm @@ -1,23 +1,29 @@ /// Returns an angle between 0 and 180, where 0 is the attacker is directly infront of the defender, 180 for directly behind. /proc/get_relative_attack_angle(mob/living/carbon/human/defender, atom/movable/hitby) - var/attack_dir = defender.dir // Default to the defender's dir so that the attack angle is 0 by default + /// Null is the value that will consider angles to match the defender's dir + var/attack_angle = null + var/turf/defender_turf = get_turf(defender) + var/turf/attack_turf = get_turf(hitby) + var/attack_dir = get_dir(defender_turf, attack_turf) if(isprojectile(hitby)) var/obj/projectile/P = hitby if(P.starting != defender_turf) - attack_dir = REVERSE_DIR(angle2dir(P.Angle)) + attack_angle = REVERSE_ANGLE(P.Angle) else if(isitem(hitby)) if(ismob(hitby.loc)) - attack_dir = get_dir(defender, hitby.loc) + attack_angle = dir2angle(get_dir(defender, get_turf(hitby.loc))) else - attack_dir = get_dir(defender, hitby) + attack_angle = dir2angle(attack_dir) else - attack_dir = get_dir(defender, hitby) + attack_angle = dir2angle(attack_dir) + + if(attack_angle == null) + return 0 - var/attack_angle = dir2angle(attack_dir) || 0 // If attack_dir == 0, dir2angle returns null var/facing_angle = dir2angle(defender.dir) || 0 var/delta = abs(attack_angle - facing_angle) if(delta > 180) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index d2fab841345a..b008ca56a454 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -706,8 +706,13 @@ DEFINE_INTERACTABLE(/obj/item) var/sig_return = SEND_SIGNAL(src, COMSIG_ITEM_CHECK_BLOCK) var/block_result = sig_return & COMPONENT_CHECK_BLOCK_BLOCKED + var/attack_armor_pen = 0 + if(isitem(hitby)) + var/obj/item/hitby_item = hitby + attack_armor_pen = hitby_item.armor_penetration + if(!block_result && can_block_attack(wielder, hitby, attack_type)) - block_result = prob(get_block_chance(wielder, hitby, damage, attack_type, armor_penetration)) + block_result = prob(get_block_chance(wielder, hitby, damage, attack_type, attack_armor_pen)) var/list/reaction_args = args.Copy() if(block_result) diff --git a/code/modules/flockmind/flock_controller/_flock_controller.dm b/code/modules/flockmind/flock_controller/_flock_controller.dm index 8fea8132533a..f839f07f17af 100644 --- a/code/modules/flockmind/flock_controller/_flock_controller.dm +++ b/code/modules/flockmind/flock_controller/_flock_controller.dm @@ -320,7 +320,7 @@ /datum/flock/proc/add_notice(atom/target, notice_type) var/image/I = image(notice_images[notice_type], loc = target) - return target.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/flock, notice_type, I, null, src) + return target.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/flock, notice_type, I, NONE, src) /datum/flock/proc/remove_notice(atom/target, notice_type) target.remove_alt_appearance(notice_type) diff --git a/code/modules/flockmind/flock_structure/flock_turret.dm b/code/modules/flockmind/flock_structure/flock_turret.dm index a1a8a95dc007..99037087e3fb 100644 --- a/code/modules/flockmind/flock_structure/flock_turret.dm +++ b/code/modules/flockmind/flock_structure/flock_turret.dm @@ -11,6 +11,7 @@ active_compute_cost = 50 var/range = 8 + var/projectile_count = 4 var/projectile_type = /obj/projectile/bullet/dart/piercing/gnesis var/mob/current_target @@ -54,7 +55,7 @@ fire() -/obj/structure/flock/gnesis_turret/proc/fire(bullets = 4) +/obj/structure/flock/gnesis_turret/proc/fire(bullets = src.projectile_count) if(isnull(current_target)) return