Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative IFF #4723

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
332c096
Smartgun IFF changes and buff!
Oct 17, 2023
8cd8f53
Smartgun IFF weird fixes
morrowwolf Oct 13, 2023
95764fe
test
Oct 18, 2023
7062da8
oops
Oct 18, 2023
ee43ac2
bruh
Oct 18, 2023
2fca683
ok
Oct 18, 2023
1dcf38a
almost there
Oct 19, 2023
475db0a
oops
Oct 19, 2023
7eb7131
Smartgun IFF changes and buff!
Oct 17, 2023
1ed266f
Smartgun IFF weird fixes
morrowwolf Oct 13, 2023
1ce8b40
test
Oct 18, 2023
17eca83
oops
Oct 18, 2023
e564781
bruh
Oct 18, 2023
8bc3232
ok
Oct 18, 2023
55acaaf
almost there
Oct 19, 2023
385ba5d
oops
Oct 19, 2023
a0f46d1
Merge remote-tracking branch 'origin/erm' into erm
Oct 19, 2023
ecdb4c6
eeeeh
Oct 19, 2023
1439872
rebase
Oct 19, 2023
21b0557
I don't know what to put here
Oct 19, 2023
cee59df
fix?
Oct 19, 2023
0450ad3
m46c unnerf + bugfix
Oct 19, 2023
83da250
code doc
Oct 19, 2023
4978be4
revert MD removal
Oct 19, 2023
48170a1
Update code/_onclick/hud/fullscreen.dm
ihatethisengine Oct 20, 2023
bcbe17a
hm
Oct 20, 2023
81472f0
Merge remote-tracking branch 'origin/erm' into erm
Oct 20, 2023
3fea902
more signals
Oct 20, 2023
84c17a2
uhhhh
Oct 20, 2023
5a4135e
IFF for PB
Oct 21, 2023
091b8cb
ignore scout
Oct 21, 2023
442ab6d
Merge branch 'cmss13-devs:master' into erm
ihatethisengine Oct 22, 2023
2b812cf
ultimate snowflake fix
Oct 22, 2023
ca123b2
Merge branch 'master' into erm
ihatethisengine Nov 3, 2023
0a63185
Merge branch 'master' into erm
ihatethisengine Nov 7, 2023
0301306
Merge branch 'master' into erm
ihatethisengine Nov 11, 2023
2571e99
Update colonialmarines.dme
ihatethisengine Nov 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_gun.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#define COMSIG_GUN_FIRE "gun_fire"
#define COMSIG_GUN_STOP_FIRE "gun_stop_fire"
#define COMSIG_GUN_FIRE_MODE_TOGGLE "gun_fire_mode_toggle"
#define COMSIG_GUN_AUTOFIREDELAY_MODIFIED "gun_autofiredelay_modified"
#define COMSIG_GUN_BURST_SHOTS_TO_FIRE_MODIFIED "gun_burst_shots_to_fire_modified"
#define COMSIG_GUN_BURST_SHOT_DELAY_MODIFIED "gun_burst_shot_delay_modified"

#define COMSIG_GUN_VULTURE_FIRED_ONEHAND "gun_vulture_fired_onehand"
#define COMSIG_VULTURE_SCOPE_MOVED "vulture_scope_moved"
#define COMSIG_VULTURE_SCOPE_SCOPED "vulture_scope_scoped"
#define COMSIG_VULTURE_SCOPE_UNSCOPED "vulture_scope_unscoped"

/// from /obj/item/weapon/gun/proc/recalculate_attachment_bonuses() : ()
#define COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES "gun_recalculate_attachment_bonuses"

/// from /obj/item/weapon/gun/proc/load_into_chamber() : ()
#define COMSIG_GUN_INTERRUPT_FIRE "gun_interrupt_fire"

//Signals for automatic fire at component
#define COMSIG_AUTOMATIC_SHOOTER_START_SHOOTING_AT "start_shooting_at"
#define COMSIG_AUTOMATIC_SHOOTER_STOP_SHOOTING_AT "stop_shooting_at"
#define COMSIG_AUTOMATIC_SHOOTER_SHOOT "shoot"
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved

//Signals for gun auto fire component
#define COMSIG_GET_BURST_FIRE "get_burst_fire"
#define BURST_FIRING (1<<0)

/// Called before a gun fires a projectile, note NOT point blanks, /obj/item/weapon/gun/proc/handle_fire()
#define COMSIG_GUN_BEFORE_FIRE "gun_before_fire"
#define COMPONENT_CANCEL_GUN_BEFORE_FIRE (1<<0) //continue full-auto/burst attempts
#define COMPONENT_HARD_CANCEL_GUN_BEFORE_FIRE (1<<1) //hard stop firing
27 changes: 0 additions & 27 deletions code/__DEFINES/dcs/signals/atom/signals_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,3 @@
#define COMSIG_ITEM_ZOOM "item_zoom"
/// from /obj/item/proc/unzoom() : (mob/user)
#define COMSIG_ITEM_UNZOOM "item_unzoom"

//Signals for automatic fire at component
#define COMSIG_AUTOMATIC_SHOOTER_START_SHOOTING_AT "start_shooting_at"
#define COMSIG_AUTOMATIC_SHOOTER_STOP_SHOOTING_AT "stop_shooting_at"
#define COMSIG_AUTOMATIC_SHOOTER_SHOOT "shoot"

//Signals for gun auto fire component
#define COMSIG_GET_BURST_FIRE "get_burst_fire"
#define BURST_FIRING (1<<0)

#define COMSIG_GUN_FIRE "gun_fire"
#define COMSIG_GUN_STOP_FIRE "gun_stop_fire"
#define COMSIG_GUN_FIRE_MODE_TOGGLE "gun_fire_mode_toggle"
#define COMSIG_GUN_AUTOFIREDELAY_MODIFIED "gun_autofiredelay_modified"
#define COMSIG_GUN_BURST_SHOTS_TO_FIRE_MODIFIED "gun_burst_shots_to_fire_modified"
#define COMSIG_GUN_BURST_SHOT_DELAY_MODIFIED "gun_burst_shot_delay_modified"

#define COMSIG_GUN_VULTURE_FIRED_ONEHAND "gun_vulture_fired_onehand"
#define COMSIG_VULTURE_SCOPE_MOVED "vulture_scope_moved"
#define COMSIG_VULTURE_SCOPE_SCOPED "vulture_scope_scoped"
#define COMSIG_VULTURE_SCOPE_UNSCOPED "vulture_scope_unscoped"

/// from /obj/item/weapon/gun/proc/recalculate_attachment_bonuses() : ()
#define COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES "gun_recalculate_attachment_bonuses"

/// from /obj/item/weapon/gun/proc/load_into_chamber() : ()
#define COMSIG_GUN_INTERRUPT_FIRE "gun_interrupt_fire"
7 changes: 7 additions & 0 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
else
client.remove_from_screen(screen)

//Get the distance to the farthest edge of the screen
/mob/proc/get_maximum_view_range()
if(!client)
return 7
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved

var/offset = client.pixel_x || client.pixel_y
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved
return client.view + abs(offset / 32)

/atom/movable/screen/fullscreen
icon = 'icons/mob/hud/screen1_full.dmi'
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ammo/bullet/pistol.dm
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
flags_ammo_behavior = AMMO_BALLISTIC

accuracy = HIT_ACCURACY_TIER_8
damage = 30
damage = 36
penetration = 20
shrapnel_chance = SHRAPNEL_CHANCE_TIER_2

6 changes: 3 additions & 3 deletions code/datums/ammo/bullet/special_ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

max_range = 12
accuracy = HIT_ACCURACY_TIER_4
damage = 30
damage = 36
penetration = 0

/datum/ammo/bullet/smartgun/armor_piercing
Expand All @@ -20,7 +20,7 @@

accurate_range = 12
accuracy = HIT_ACCURACY_TIER_2
damage = 20
damage = 24
penetration = ARMOR_PENETRATION_TIER_8
damage_armor_punch = 1

Expand Down Expand Up @@ -98,7 +98,7 @@
icon_state = "bullet" // Keeping it bog standard with the turret but allows it to be changed

accurate_range = 12
damage = 35
damage = 36
penetration= ARMOR_PENETRATION_TIER_10 //Bumped the penetration to serve a different role from sentries, MGs are a bit more offensive
accuracy = HIT_ACCURACY_TIER_3

Expand Down
78 changes: 78 additions & 0 deletions code/datums/components/iff_fire_prevention.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#define IFF_HALT_COOLDOWN 0.5 SECONDS

/datum/component/iff_fire_prevention
var/iff_additional_fire_delay
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved
COOLDOWN_DECLARE(iff_halt_cooldown)

/datum/component/iff_fire_prevention/Initialize(additional_fire_delay = 0)
. = ..()
iff_additional_fire_delay = additional_fire_delay


/datum/component/iff_fire_prevention/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_GUN_BEFORE_FIRE, PROC_REF(check_firing_lane))

/datum/component/iff_fire_prevention/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, COMSIG_GUN_BEFORE_FIRE)

/datum/component/iff_fire_prevention/proc/check_firing_lane(obj/firing_weapon, obj/projectile/projectile_to_fire, atom/target, mob/living/user)
SIGNAL_HANDLER

var/angle = get_angle(user, target)

var/range_to_check = user.get_maximum_view_range()

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


var/turf/starting_turf = get_turf(user)

if(!starting_turf || !extended_target_turf)
return COMPONENT_CANCEL_GUN_BEFORE_FIRE

var/list/checked_turfs = getline2(starting_turf, extended_target_turf)

checked_turfs -= starting_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(starting_turf, original_target_turf)
var/list/temp_checked_turfs = checked_turfs
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved
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(starting_turf, checked_turf))
checked_turfs += original_target_turf

checked_turfs += checked_turf

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

//Wall, should block the bullet so we're good to stop checking.
if(istype(checked_turf, /turf/closed))
return

for(var/mob/living/checked_living in checked_turf)
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)
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved
to_chat(user, SPAN_WARNING("[firing_weapon] halts firing as an IFF marked target crosses your field of fire!"))
COOLDOWN_START(src, iff_halt_cooldown, IFF_HALT_COOLDOWN)
if(iff_additional_fire_delay)
var/obj/item/weapon/gun/gun = firing_weapon
if(istype(gun))
LAZYSET(user.fire_delay_next_fire, gun, world.time + iff_additional_fire_delay)
return COMPONENT_CANCEL_GUN_BEFORE_FIRE

return //if we have a target we *can* hit and find it before any IFF targets we want to fire

#undef IFF_HALT_COOLDOWN
13 changes: 12 additions & 1 deletion code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
var/user_old_y = 0

/// How much time should pass in between full auto shots, slightly higher than burst due to click delay and similar things that slow firing down
var/fire_delay = 0.3 SECONDS
var/fire_delay = 0.25 SECONDS
/// How much time should pass in between burst fire shots
var/burst_fire_delay = 0.2 SECONDS
/// How many rounds are fired per burst
Expand Down Expand Up @@ -515,6 +515,8 @@
burst_scatter_mult = SCATTER_AMOUNT_TIER_7
update_icon()
AddComponent(/datum/component/automatedfire/autofire, fire_delay, burst_fire_delay, burst_amount, gun_firemode, autofire_slow_mult, CALLBACK(src, PROC_REF(set_burst_firing)), CALLBACK(src, PROC_REF(reset_fire)), CALLBACK(src, PROC_REF(try_fire)), CALLBACK(src, PROC_REF(display_ammo)), CALLBACK(src, PROC_REF(set_auto_firing)))
AddComponent(/datum/component/iff_fire_prevention)


/obj/structure/machinery/m56d_hmg/Destroy() //Make sure we pick up our trash.
if(operator)
Expand Down Expand Up @@ -724,6 +726,15 @@
final_angle += rand(-total_scatter_angle, total_scatter_angle)
target = get_angle_target_turf(T, final_angle, 30)

var/before_fire_cancel = SEND_SIGNAL(src, COMSIG_GUN_BEFORE_FIRE, in_chamber, target, operator)

if(before_fire_cancel)
if(before_fire_cancel & COMPONENT_CANCEL_GUN_BEFORE_FIRE)
return AUTOFIRE_CONTINUE

if(before_fire_cancel & COMPONENT_HARD_CANCEL_GUN_BEFORE_FIRE)
return

in_chamber.weapon_cause_data = create_cause_data(initial(name), operator)
in_chamber.setDir(dir)
in_chamber.def_zone = pick("chest","chest","chest","head")
Expand Down
69 changes: 44 additions & 25 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@
/// The multiplier for how much slower this should fire in automatic mode. 1 is normal, 1.2 is 20% slower, 2 is 100% slower, etc. Protected due to it never needing to be edited.
VAR_PROTECTED/autofire_slow_mult = 1


/**
* An assoc list where the keys are fire delay group string defines
* and the keys are when the guns of the group can be fired again
Expand Down Expand Up @@ -1195,6 +1194,17 @@ and you're good to go.
click_empty(user)
return NONE

var/before_fire_cancel = SEND_SIGNAL(src, COMSIG_GUN_BEFORE_FIRE, projectile_to_fire, target, user)

if(before_fire_cancel)
if(before_fire_cancel & COMPONENT_CANCEL_GUN_BEFORE_FIRE)
return TRUE

if(before_fire_cancel & COMPONENT_HARD_CANCEL_GUN_BEFORE_FIRE)
return NONE

play_firing_sounds(projectile_to_fire, user)

if(targloc != curloc)
simulate_recoil(dual_wield, user, target)

Expand Down Expand Up @@ -1414,6 +1424,8 @@ and you're good to go.
user.track_shot(initial(name))
apply_bullet_effects(projectile_to_fire, user, bullets_fired, dual_wield) //We add any damage effects that we need.

play_firing_sounds(projectile_to_fire, user)

SEND_SIGNAL(projectile_to_fire, COMSIG_BULLET_USER_EFFECTS, user)
SEND_SIGNAL(user, COMSIG_BULLET_DIRECT_HIT, attacked_mob)
simulate_recoil(1, user)
Expand Down Expand Up @@ -1614,12 +1626,6 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed

//This proc applies some bonus effects to the shot/makes the message when a bullet is actually fired.
/obj/item/weapon/gun/proc/apply_bullet_effects(obj/projectile/projectile_to_fire, mob/user, reflex = 0, dual_wield = 0)
var/actual_sound = fire_sound
if(isnull(fire_sound))
actual_sound = pick(fire_sounds)
if(projectile_to_fire.ammo && projectile_to_fire.ammo.sound_override)
actual_sound = projectile_to_fire.ammo.sound_override

var/gun_accuracy_mult = accuracy_mult_unwielded
var/gun_scatter = scatter_unwielded

Expand Down Expand Up @@ -1670,26 +1676,39 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed

projectile_to_fire.shot_from = src

if(user) //The gun only messages when fired by a user.
projectile_to_fire.firer = user
if(isliving(user)) projectile_to_fire.def_zone = user.zone_selected
//Guns with low ammo have their firing sound
var/firing_sndfreq = (current_mag && (current_mag.current_rounds / current_mag.max_rounds) > GUN_LOW_AMMO_PERCENTAGE) ? FALSE : SOUND_FREQ_HIGH
//firing from an attachment
if(active_attachable && active_attachable.flags_attach_features & ATTACH_PROJECTILE)
if(active_attachable.fire_sound) //If we're firing from an attachment, use that noise instead.
playsound(user, active_attachable.fire_sound, 50)
else
if(!(flags_gun_features & GUN_SILENCED))
if (firing_sndfreq && fire_rattle)
playsound(user, fire_rattle, firesound_volume, FALSE)//if the gun has a unique 'mag rattle' SFX play that instead of pitch shifting.
else
playsound(user, actual_sound, firesound_volume, firing_sndfreq)
else
playsound(user, actual_sound, 25, firing_sndfreq)

return 1

/obj/item/weapon/gun/proc/play_firing_sounds(obj/projectile/projectile_to_fire, mob/user)
ihatethisengine marked this conversation as resolved.
Show resolved Hide resolved
if(!user) //The gun only messages when fired by a user.
return

var/actual_sound = fire_sound
if(isnull(fire_sound))
actual_sound = pick(fire_sounds)

if(projectile_to_fire.ammo && projectile_to_fire.ammo.sound_override)
actual_sound = projectile_to_fire.ammo.sound_override

projectile_to_fire.firer = user
if(isliving(user))
projectile_to_fire.def_zone = user.zone_selected
fira marked this conversation as resolved.
Show resolved Hide resolved

//Guns with low ammo have their firing sound
var/firing_sndfreq = (current_mag && (current_mag.current_rounds / current_mag.max_rounds) > GUN_LOW_AMMO_PERCENTAGE) ? FALSE : SOUND_FREQ_HIGH

//firing from an attachment
if(active_attachable && active_attachable.flags_attach_features & ATTACH_PROJECTILE)
if(active_attachable.fire_sound) //If we're firing from an attachment, use that noise instead.
playsound(user, active_attachable.fire_sound, 50)
else
if(!(flags_gun_features & GUN_SILENCED))
if (firing_sndfreq && fire_rattle)
playsound(user, fire_rattle, firesound_volume, FALSE)//if the gun has a unique 'mag rattle' SFX play that instead of pitch shifting.
else
playsound(user, actual_sound, firesound_volume, firing_sndfreq)
else
playsound(user, actual_sound, 25, firing_sndfreq)

/obj/item/weapon/gun/proc/simulate_scatter(obj/projectile/projectile_to_fire, atom/target, turf/curloc, turf/targloc, mob/user, bullets_fired = 1)
var/fire_angle = Get_Angle(curloc, targloc)
var/total_scatter_angle = projectile_to_fire.scatter
Expand Down
Loading