Skip to content

Commit

Permalink
1029204smallbugs (#1109)
Browse files Browse the repository at this point in the history
* Fix people marked by the flock seeing the marker

* Cleanup directional block code and fix a bug
  • Loading branch information
Kapu1178 authored Oct 30, 2024
1 parent a94c4c5 commit 8aae426
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
/// Gets shift x that would be required the bitflag (1<<x)
#define TOBITSHIFT(bit) (round(log(2, bit), 1))

/// Reverse an angle. 45 -> 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))
Expand Down
18 changes: 12 additions & 6 deletions code/__HELPERS/combat_helpers.dm
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 6 additions & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/flockmind/flock_structure/flock_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8aae426

Please sign in to comment.