Skip to content

Commit

Permalink
Smartgun IFF weird fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Oct 13, 2023
1 parent d44efad commit b7f1276
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions code/modules/projectiles/guns/smartgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,30 @@

var/extended_target_turf = get_angle_target_turf(user, angle, range_to_check)

var/turf/current_turf = get_turf(user)
var/turf/user_turf = get_turf(user)

if(!current_turf || !extended_target_turf)
if(!user_turf || !extended_target_turf)
return COMPONENT_CANCEL_GUN_BEFORE_FIRE

var/list/checked_turfs = getline2(current_turf, extended_target_turf)
var/list/checked_turfs = getline2(user_turf, extended_target_turf)

checked_turfs -= current_turf
checked_turfs -= user_turf

//At some angles (scatter or otherwise) the original target is not in checked_turfs so we put it in there in order based on distance from user
//If we are literally clicking on someone with IFF then we don't want to fire, feels funny as a user otherwise
if(projectile_to_fire.original)
var/turf/original_target_turf = get_turf(projectile_to_fire.original)

if(original_target_turf && !(original_target_turf in checked_turfs))
var/user_to_target_dist = get_dist(user_turf, original_target_turf)
var/list/temp_checked_turfs = checked_turfs
checked_turfs = list()

for(var/turf/checked_turf as anything in temp_checked_turfs)
if(!(original_target_turf in checked_turfs) && user_to_target_dist < get_dist(user_turf, checked_turf))
checked_turfs += original_target_turf

checked_turfs += checked_turf

for(var/turf/checked_turf as anything in checked_turfs)

Expand All @@ -357,7 +373,10 @@
return

for(var/mob/living/checked_living in checked_turf)
if(!checked_living.lying && checked_living.get_target_lock(user.faction_group))
if(checked_living.lying && projectile_to_fire.original != checked_living)
continue

if(checked_living.get_target_lock(user.faction_group))
if(COOLDOWN_FINISHED(src, iff_halt_cooldown))
playsound_client(user.client, 'sound/weapons/smartgun_fail.ogg', src, 25)
to_chat(user, SPAN_WARNING("[src] halts firing as an IFF marked target crosses your field of fire!"))
Expand Down

0 comments on commit b7f1276

Please sign in to comment.