Skip to content

Commit

Permalink
Removed redundant var overrides, added balloon text to all SG toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
BasilHerb committed Nov 17, 2024
1 parent fe6a2f1 commit 4c5ad33
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 37 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#define COMSIG_KB_HUMAN_WEAPON_ATTACHMENT "keybinding_human_weapon_attachment"
#define COMSIG_KB_HUMAN_WEAPON_ATTACHMENT_RAIL "keybinding_human_weapon_attachment_rail"
#define COMSIG_KB_HUMAN_WEAPON_SHOTGUN_TUBE "keybinding_human_weapon_shotgun_tube"

#define COMSIG_KB_HUMAN_WEAPON_TOGGLE_FRONTLINE_MODE "keybinding_human_weapon_toggle_frontline_mode"
#define COMSIG_KB_HUMAN_WEAPON_TOGGLE_IFF "keybinding_human_weapon_toggle_iff"

//Living
Expand Down
33 changes: 21 additions & 12 deletions code/datums/ammo/bullet/special_ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@
effective_range_max = 5

/datum/ammo/bullet/smartgun/alt
name = "smartgun bullet"
icon_state = "redbullet"
flags_ammo_behavior = AMMO_BALLISTIC

damage_falloff = DAMAGE_FALLOFF_TIER_7
max_range = 14
accuracy = HIT_ACCURACY_TIER_4
damage = 36
penetration = 0
effective_range_max = 7

/datum/ammo/bullet/smartgun/armor_piercing
Expand All @@ -41,16 +36,9 @@
damage_armor_punch = 1

/datum/ammo/bullet/smartgun/armor_piercing/alt
name = "armor-piercing smartgun bullet"
icon_state = "bullet"

damage_falloff = DAMAGE_FALLOFF_TIER_7
accurate_range = 14
accuracy = HIT_ACCURACY_TIER_2
damage = 25
effective_range_max = 7
penetration = ARMOR_PENETRATION_TIER_8
damage_armor_punch = 1

/datum/ammo/bullet/smartgun/dirty
name = "irradiated smartgun bullet"
Expand All @@ -63,7 +51,13 @@
damage = 40
penetration = 0

/datum/ammo/bullet/smartgun/dirty/alt
damage_falloff = DAMAGE_FALLOFF_TIER_7
effective_range_max = 7
damage = 48

/datum/ammo/bullet/smartgun/dirty/armor_piercing
icon_state = "bullet"
debilitate = list(0,0,0,3,0,0,0,1)

accurate_range = 22
Expand All @@ -72,6 +66,11 @@
penetration = ARMOR_PENETRATION_TIER_7
damage_armor_punch = 3

/datum/ammo/bullet/smartgun/dirty/armor_piercing/alt
damage = 36
damage_falloff = DAMAGE_FALLOFF_TIER_7
effective_range_max = 7

/datum/ammo/bullet/smartgun/holo_target //Royal marines smartgun bullet has only diff between regular ammo is this one does holostacks
name = "holo-targeting smartgun bullet"
damage = 30
Expand All @@ -82,6 +81,11 @@
/// multiplies the default drain of 5 holo stacks per second by this amount
var/stack_loss_multiplier = 1

/datum/ammo/bullet/smartgun/holo_target/alt
damage = 36
effective_range_max = 7
damage_falloff = DAMAGE_FALLOFF_TIER_7

/datum/ammo/bullet/smartgun/holo_target/on_hit_mob(mob/hit_mob, obj/projectile/bullet)
. = ..()
hit_mob.AddComponent(/datum/component/bonus_damage_stack, holo_stacks, world.time, bonus_damage_cap_increase, stack_loss_multiplier)
Expand All @@ -96,6 +100,11 @@
penetration = ARMOR_PENETRATION_TIER_8
damage_armor_punch = 1

/datum/ammo/bullet/smartgun/holo_target/ap/alt
damage = 25
effective_range_max = 7
damage_falloff = DAMAGE_FALLOFF_TIER_7

/datum/ammo/bullet/smartgun/m56_fpw
name = "\improper M56 FPW bullet"
icon_state = "redbullet"
Expand Down
1 change: 0 additions & 1 deletion code/datums/components/iff_fire_prevention.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

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

/datum/component/iff_fire_prevention/UnregisterFromParent()
Expand Down
18 changes: 18 additions & 0 deletions code/datums/keybinding/human_combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@
held_item.activate_rail_attachment_verb()
return TRUE

/datum/keybinding/human/combat/toggle_frontline_mode
hotkey_keys = list("Unbound")
classic_keys = list("Unbound")
name = "toggle_frontline_mode"
full_name = "Toggle Smartgun Frontline Mode"
keybind_signal = COMSIG_KB_HUMAN_WEAPON_TOGGLE_FRONTLINE_MODE

/datum/keybinding/human/combat/toggle_frontline_mode/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/human/human = user.mob
var/obj/item/weapon/gun/held_item = human.get_held_item()
if(istype(held_item, /obj/item/weapon/gun/smartgun))
var/obj/item/weapon/gun/smartgun/clevergun = held_item
clevergun.toggle_frontline_mode(human)
return TRUE

/datum/keybinding/human/combat/toggle_iff
hotkey_keys = list("Unbound")
classic_keys = list("Unbound")
Expand Down
64 changes: 41 additions & 23 deletions code/modules/projectiles/guns/smartgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
/datum/action/item_action/smartgun/toggle_motion_detector,
/datum/action/item_action/smartgun/toggle_recoil_compensation,
)
var/datum/ammo/ammo_primary = /datum/ammo/bullet/smartgun //Toggled ammo type
var/datum/ammo/ammo_secondary = /datum/ammo/bullet/smartgun/armor_piercing //Toggled ammo type
var/datum/ammo/ammo_primary //Toggled ammo type
var/datum/ammo/ammo_secondary //Toggled ammo type
var/datum/ammo/ammo_primary_def = /datum/ammo/bullet/smartgun
var/datum/ammo/ammo_secondary_def = /datum/ammo/bullet/smartgun/armor_piercing
var/datum/ammo/ammo_primary_alt = /datum/ammo/bullet/smartgun/alt
var/datum/ammo/ammo_secondary_alt = /datum/ammo/bullet/smartgun/armor_piercing/alt
var/iff_enabled = TRUE //Begin with the safety on.
var/frontline_enabled = FALSE //Begins with 'normal IFF' enabled (shoots through friendly marines, instead of Alt-IFF)
var/secondary_toggled = 0 //which ammo we use
Expand Down Expand Up @@ -70,8 +74,12 @@


/obj/item/weapon/gun/smartgun/Initialize(mapload, ...)
ammo_primary = GLOB.ammo_list[ammo_primary] //Gun initialize calls replace_ammo() so we need to set these first.
ammo_secondary = GLOB.ammo_list[ammo_secondary]
ammo_primary_def = GLOB.ammo_list[ammo_primary_def] //Gun initialize calls replace_ammo() so we need to set these first.
ammo_secondary_def = GLOB.ammo_list[ammo_secondary_def]
ammo_primary_alt = GLOB.ammo_list[ammo_primary_alt]
ammo_secondary_alt = GLOB.ammo_list[ammo_secondary_alt]
ammo_primary = ammo_primary_def
ammo_secondary = ammo_secondary_def
MD = new(src)
battery = new /obj/item/smartgun_battery(src)
. = ..()
Expand Down Expand Up @@ -104,6 +112,13 @@
scatter = SCATTER_AMOUNT_TIER_6
recoil = RECOIL_AMOUNT_TIER_3
damage_mult = BASE_BULLET_DAMAGE_MULT
if(!iff_enabled || frontline_enabled)
ammo_primary = ammo_primary_alt
ammo_secondary = ammo_secondary_alt
else
ammo_primary = ammo_primary_def
ammo_secondary = ammo_secondary_def
ammo = secondary_toggled ? ammo_secondary : ammo_primary

/obj/item/weapon/gun/smartgun/set_bullet_traits()
LAZYADD(traits_to_give, list(
Expand Down Expand Up @@ -338,14 +353,11 @@

/obj/item/weapon/gun/smartgun/proc/toggle_frontline_mode(mob/user)
to_chat(user, "[icon2html(src, usr)] You [frontline_enabled? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s frontline mode. You will now [frontline_enabled ? "be able to shoot through friendlies" : "deal increased damage but be unable to shoot through friendlies"].")
balloon_alert(user, "frontline mode [frontline_enabled ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
frontline_enabled = !frontline_enabled
ammo = ammo_primary
secondary_toggled = FALSE
if(frontline_enabled)
SEND_SIGNAL(src, COMSIG_GUN_ALT_IFF_TOGGLED, frontline_enabled)
if(!frontline_enabled)
AddComponent(/datum/component/iff_fire_prevention)
SEND_SIGNAL(src, COMSIG_GUN_ALT_IFF_TOGGLED, frontline_enabled)
recalculate_attachment_bonuses()

/obj/item/weapon/gun/smartgun/able_to_fire(mob/living/user)
. = ..()
Expand All @@ -372,15 +384,9 @@

/obj/item/weapon/gun/smartgun/proc/toggle_ammo_type(mob/user)
secondary_toggled = !secondary_toggled
to_chat(user, "[icon2html(src, usr)] You changed \the [src]'s ammo preparation procedures. You now fire [secondary_toggled ? "armor shredding rounds" : "highly precise rounds"].")
balloon_alert(user, "firing [secondary_toggled ? "armor shredding" : "highly precise"]")
to_chat(user, "[icon2html(src, usr)] You changed \the [src]'s ammo preparation procedures. You now fire [secondary_toggled ? "armor piercing rounds" : "highly precise rounds"].")
balloon_alert(user, "firing [secondary_toggled ? "armor piercing" : "highly precise"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
if(!iff_enabled || !frontline_enabled)
ammo_primary = /datum/ammo/bullet/smartgun/alt
ammo_secondary = /datum/ammo/bullet/smartgun/armor_piercing/alt
else
ammo_primary = /datum/ammo/bullet/smartgun
ammo_secondary = /datum/ammo/bullet/smartgun/armor_piercing
ammo = secondary_toggled ? ammo_secondary : ammo_primary
var/datum/action/item_action/smartgun/toggle_ammo_type/TAT = locate(/datum/action/item_action/smartgun/toggle_ammo_type) in actions
TAT.update_icon()
Expand All @@ -391,6 +397,7 @@

/obj/item/weapon/gun/smartgun/proc/toggle_lethal_mode(mob/user)
to_chat(user, "[icon2html(src, usr)] You [iff_enabled? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s fire restriction. You will [iff_enabled ? "harm anyone in your way" : "target through IFF"].")
balloon_alert(user, "IFF [iff_enabled ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
iff_enabled = !iff_enabled
ammo = ammo_primary
Expand Down Expand Up @@ -439,6 +446,7 @@

/obj/item/weapon/gun/smartgun/proc/toggle_recoil_compensation(mob/user)
to_chat(user, "[icon2html(src, usr)] You [recoil_compensation? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s recoil compensation.")
balloon_alert(user, "recoil compensation [recoil_compensation ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
recoil_compensation = !recoil_compensation
if(recoil_compensation)
Expand All @@ -449,6 +457,7 @@

/obj/item/weapon/gun/smartgun/proc/toggle_accuracy_improvement(mob/user)
to_chat(user, "[icon2html(src, usr)] You [accuracy_improvement? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s accuracy improvement.")
balloon_alert(user, "accuracy improvement [accuracy_improvement ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
accuracy_improvement = !accuracy_improvement
if(accuracy_improvement)
Expand All @@ -462,6 +471,7 @@
to_chat(user, "[icon2html(src, usr)] You need to wield \the [src] to enable autofire.")
return //Have to be actually be wielded.
to_chat(user, "[icon2html(src, usr)] You [auto_fire? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s auto fire mode.")
balloon_alert(user, "autofire [auto_fire ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
auto_fire = !auto_fire
var/datum/action/item_action/smartgun/toggle_auto_fire/TAF = locate(/datum/action/item_action/smartgun/toggle_auto_fire) in actions
Expand Down Expand Up @@ -595,6 +605,7 @@

/obj/item/weapon/gun/smartgun/proc/toggle_motion_detector(mob/user)
to_chat(user, "[icon2html(src, usr)] You [motion_detector? "<B>disable</b>" : "<B>enable</b>"] \the [src]'s motion detector.")
balloon_alert(user, "motion detector [motion_detector ? "disabled" : "enabled"]")
playsound(loc,'sound/machines/click.ogg', 25, 1)
motion_detector = !motion_detector
var/datum/action/item_action/smartgun/toggle_motion_detector/TMD = locate(/datum/action/item_action/smartgun/toggle_motion_detector) in actions
Expand Down Expand Up @@ -714,15 +725,18 @@
desc = "The actual firearm in the 4-piece M56D Smartgun System. If you have this, you're about to bring some serious pain to anyone in your way.\nYou may toggle firing restrictions by using a special action.\nAlt-click it to open the feed cover and allow for reloading."
current_mag = /obj/item/ammo_magazine/smartgun/dirty
ammo = /obj/item/ammo_magazine/smartgun/dirty
ammo_primary = /datum/ammo/bullet/smartgun/dirty//Toggled ammo type
ammo_secondary = /datum/ammo/bullet/smartgun/dirty/armor_piercing///Toggled ammo type
ammo_primary //Toggled ammo type
ammo_secondary //Toggled ammo type
ammo_primary_def = /datum/ammo/bullet/smartgun/dirty
ammo_secondary_def = /datum/ammo/bullet/smartgun/dirty/armor_piercing
ammo_primary_alt = /datum/ammo/bullet/smartgun/dirty/alt
ammo_secondary_alt = /datum/ammo/bullet/smartgun/dirty/armor_piercing/alt
flags_gun_features = GUN_WY_RESTRICTED|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY

/obj/item/weapon/gun/smartgun/dirty/Initialize(mapload, ...)
. = ..()
MD.iff_signal = FACTION_PMC


//TERMINATOR SMARTGUN
/obj/item/weapon/gun/smartgun/dirty/elite
name = "\improper M56T 'Terminator' smartgun"
Expand Down Expand Up @@ -789,8 +803,12 @@
desc = "The actual firearm in the 2-piece L56A2 Smartgun System. This Variant is used by the Three World Empires Royal Marines Commando units.\nYou may toggle firing restrictions by using a special action.\nAlt-click it to open the feed cover and allow for reloading."
current_mag = /obj/item/ammo_magazine/smartgun/holo_targetting
ammo = /obj/item/ammo_magazine/smartgun/holo_targetting
ammo_primary = /datum/ammo/bullet/smartgun/holo_target //Toggled ammo type
ammo_secondary = /datum/ammo/bullet/smartgun/holo_target/ap ///Toggled ammo type
ammo_primary //Toggled ammo type
ammo_secondary //Toggled ammo type
ammo_primary_def = /datum/ammo/bullet/smartgun/holo_target
ammo_secondary_def = /datum/ammo/bullet/smartgun/holo_target/ap
ammo_primary_alt = /datum/ammo/bullet/smartgun/holo_target/alt
ammo_secondary_alt = /datum/ammo/bullet/smartgun/holo_target/ap/alt
flags_gun_features = GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY
icon = 'icons/obj/items/weapons/guns/guns_by_faction/twe_guns.dmi'
icon_state = "magsg"
Expand Down

0 comments on commit 4c5ad33

Please sign in to comment.