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

Updated XM43E1 for USCM Sniper Spec #5767

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions code/datums/ammo/ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
P.generate_bullet(GLOB.ammo_list[bonus_projectiles_type]) //No bonus damage or anything.
P.accuracy = round(P.accuracy * original_P.accuracy/initial(original_P.accuracy)) //if the gun changes the accuracy of the main projectile, it also affects the bonus ones.
original_P.give_bullet_traits(P)
P.bonus_projectile_check = 2 //It's a bonus projectile!

var/total_scatter_angle = P.scatter
final_angle += rand(-total_scatter_angle, total_scatter_angle)
Expand Down
9 changes: 8 additions & 1 deletion code/datums/ammo/bullet/sniper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@
if(target.mob_size >= MOB_SIZE_BIG)
size_damage_mod += 0.6
L.apply_armoured_damage(damage*size_damage_mod, ARMOR_BULLET, BRUTE, null, penetration)
// 180% damage to all targets (225), 240% (300) against non-Runner xenos, and 300% against Big xenos (375). -Kaga
// Base 180% damage to all targets (225), 240% (300) against non-Runner xenos, and 300% against Big xenos (375). -Kaga
// This applies after pen reductions. After hitting 1 other thing, it deals 180/240/300 damage, or 135/180/225 after hitting a dense wall or big xeno.
to_chat(P.firer, SPAN_WARNING("Bullseye!"))

/datum/ammo/bullet/sniper/anti_materiel/set_bullet_traits()
. = ..()
LAZYADD(traits_to_give, list(
BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_penetrating/light)
))

/datum/ammo/bullet/sniper/anti_materiel/vulture
damage = 400 // Fully intended to vaporize anything smaller than a mini cooper
accurate_range_min = 10
Expand Down
41 changes: 21 additions & 20 deletions code/datums/elements/bullet_trait/damage_boost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@ GLOBAL_LIST_INIT(damage_boost_vehicles, typecacheof(/obj/vehicle/multitile))
/// A typecache of objs or turfs that, upon being hit, boost the damage of the attached projectile
var/list/damage_boosted_atoms

//vars for dealing with interaction issues with the Penetrating trait
var/boosted_hits
var/last_damage_mult

//allows for nuance in Breaching-Resistant interactions
var/active_damage_mult
var/atom_type

//var for dealing with bonus projectiles
var/bonus_projectile_check

/**
* vars:
* * damage_mult - the damage multiplier to be applied if the bullet hits an atom whose type is in `breaching_objs`
Expand All @@ -51,11 +44,8 @@ GLOBAL_LIST_INIT(damage_boost_vehicles, typecacheof(/obj/vehicle/multitile))

src.damage_mult = damage_mult
src.damage_boosted_atoms = damage_boosted_atoms
src.boosted_hits = 0
src.last_damage_mult = 1
src.active_damage_mult = 1
src.atom_type = 0
src.bonus_projectile_check = 0

RegisterSignal(target, list(
COMSIG_BULLET_PRE_HANDLE_OBJ,
Expand All @@ -71,7 +61,9 @@ GLOBAL_LIST_INIT(damage_boost_vehicles, typecacheof(/obj/vehicle/multitile))
/datum/element/bullet_trait_damage_boost/proc/handle_bullet(obj/projectile/P, atom/A)
SIGNAL_HANDLER

atom_type = check_type(A)
to_chat(world,"STEP 0: Handling Damage Boost with bullet '[P]', target '[A]', and source '[src]'.")
to_chat(world,"STEP 1: Last Atom Hit was [P.last_atom_signaled]. Bonus Projectile Check is [P.bonus_projectile_check].")
Kaga-404 marked this conversation as resolved.
Show resolved Hide resolved
src.atom_type = check_type(A)

switch(atom_type)
if("door")
Expand All @@ -87,12 +79,21 @@ GLOBAL_LIST_INIT(damage_boost_vehicles, typecacheof(/obj/vehicle/multitile))
else
active_damage_mult = damage_mult

if(boosted_hits > 0)
if(bonus_projectile_check == P.damage)
P.damage = P.damage / last_damage_mult
boosted_hits--
if(damage_boosted_atoms[A.type])
P.damage = round(P.damage * active_damage_mult)
last_damage_mult = active_damage_mult
boosted_hits++
bonus_projectile_check = P.damage
if(P.damage_boosted && (P.last_atom_signaled != A) && (!P.bonus_projectile_check))
//If this is after a boosted hit, the last atom that procced this isn't the same as the current target, and this isn't a bonus projectile sharing the same damage_boost
if(!P.last_damage_mult) //Make sure stored mult isn't 0
P.last_damage_mult = 1

P.damage = P.damage / P.last_damage_mult //Reduce the damage back to normal
P.damage_boosted-- //Mark that damage has been returned to normal.

if(damage_boosted_atoms[A.type]) //If hitting a valid atom for damage boost
P.damage = round(P.damage * active_damage_mult) //Modify Damage by multiplier

if (active_damage_mult)
P.last_damage_mult = active_damage_mult //Save multiplier for next check
else
P.last_damage_mult = 1

P.damage_boosted++ //Mark that a boosted hit occurred.
P.last_atom_signaled = A //Save the current triggering atom to the projectile
60 changes: 60 additions & 0 deletions code/datums/elements/bullet_trait/penetrating/light.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/datum/element/bullet_trait_penetrating/light
// Generic bullet trait vars
element_flags = ELEMENT_DETACH|ELEMENT_BESPOKE
id_arg_index = 4

/// For each thing this hits, how much damage it loses normally. This can be modified by what it penetrates later.
var/damage_percent_lost_per_hit = 20
// XM43E1 AMR: First target takes full damage, each subsequent target takes at least 20% less damage (increased for large mobs and dense turfs), 25 from base 125 damage.

/// For each thing this hits, how much distance it loses normally.
distance_loss_per_hit = 4
// XM43E1 AMR: Hits 7 things at most, at point blank, with no additional modifiers. This greatly increases at actual sniping ranges.

/// How many times more effective turfs are at slowing down the projectile normally, reducing both range and damage.
var/turf_hit_slow_mult = 3
// XM43E1 AMR: Unable to hit anything through more than 2 walls, less at maximum ranges. Pens 2 walls at 8 tiles or less, 1 at 20 tiles or less, and can't wallbang through normal walls at maximum range.
// Also loses 75 damage with each normal wall pen.

/datum/element/bullet_trait_penetrating/light/Attach(datum/target, distance_loss_per_hit = 4, damage_percent_lost_per_hit = 20, turf_hit_slow_mult = 3)
. = ..()
if(. == ELEMENT_INCOMPATIBLE)
return

src.damage_percent_lost_per_hit = damage_percent_lost_per_hit
src.turf_hit_slow_mult = turf_hit_slow_mult

/datum/element/bullet_trait_penetrating/light/handle_passthrough_movables(obj/projectile/bullet, atom/movable/hit_movable, did_hit)
if(did_hit)
var/slow_mult = 1
if(ismob(hit_movable))
var/mob/mob = hit_movable
if(mob.mob_size >= MOB_SIZE_BIG) // Big Xenos (including fortified Defender) can soak hits and greatly reduce penetration.
slow_mult = 2 // 8 tiles of range lost per Big hit. At point blank, this comes out to only 3 targets. At sniping ranges, even a single one can stop the bullet dead.

bullet.distance_travelled += (distance_loss_per_hit * slow_mult)

bullet.damage -= (damage_percent_lost_per_hit * slow_mult)

return COMPONENT_BULLET_PASS_THROUGH


/datum/element/bullet_trait_penetrating/light/handle_passthrough_turf(obj/projectile/bullet, turf/closed/wall/hit_wall)
var/slow_mult = turf_hit_slow_mult

// Better penetration against Membranes to still be able to counter Boilers at most ranges. Still loses 4 tiles of range and 25 damage per.
if(istype(hit_wall, /turf/closed/wall/resin/membrane))
if(istype(hit_wall, /turf/closed/wall/resin/membrane/thick))
slow_mult = 1.5
else
slow_mult = 1

bullet.distance_travelled += (distance_loss_per_hit * slow_mult)

bullet.damage *= (1 - (damage_percent_lost_per_hit * slow_mult * 0.01))

if(!istype(hit_wall))
return COMPONENT_BULLET_PASS_THROUGH

if(!hit_wall.hull)
return COMPONENT_BULLET_PASS_THROUGH
9 changes: 4 additions & 5 deletions code/datums/supply_packs/spec_ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@
containername = "M42A Incendiary Magazine Crate"
group = "Weapons Specialist Ammo"

//XM43E1 - Disabled during testing per request.
/*
/datum/supply_packs/ammo_amr_marksman
name = "XM43E1 anti-materiel rifle marksman magazines crate (x5)"
name = "XM43E1 anti-materiel rifle marksman magazines crate (x3)"
contains = list(
/obj/item/ammo_magazine/sniper/anti_materiel,
/obj/item/ammo_magazine/sniper/anti_materiel,
Expand All @@ -123,8 +121,9 @@
cost = 30
containertype = /obj/structure/closet/crate/ammo
containername = "XM43E1 Anti-Materiel Magazine Crate"
group = "Specialist Ammo"
*/
group = "Weapons Specialist Ammo"


//M4RA

/datum/supply_packs/ammo_scout_mix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ GLOBAL_LIST_INIT(cm_vending_gear_spec, list(
list("M42A Flak Magazine (10x28mm)", 40, /obj/item/ammo_magazine/sniper/flak, null, VENDOR_ITEM_REGULAR),
list("M42A Incendiary Magazine (10x28mm)", 40, /obj/item/ammo_magazine/sniper/incendiary, null, VENDOR_ITEM_REGULAR),
list("M42A Marksman Magazine (10x28mm Caseless)", 40, /obj/item/ammo_magazine/sniper, null, VENDOR_ITEM_REGULAR),
list("XM43E1 Anti-Material (10x99mm Caseless)", 40, /obj/item/ammo_magazine/sniper/anti_materiel, null, VENDOR_ITEM_REGULAR),


list("EXTRA DEMOLITIONIST AMMUNITION", 0, null, null, null),
list("84mm Anti-Armor Rocket", 40, /obj/item/ammo_magazine/rocket/ap, null, VENDOR_ITEM_REGULAR),
Expand Down
53 changes: 44 additions & 9 deletions code/modules/cm_marines/equipment/kit_boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,38 @@

/obj/item/storage/box/spec/sniper
name = "\improper Sniper equipment case"
desc = "A large case containing your very own long-range M42A sniper rifle, M45 ghillie armor and helmet, M42 scout sight, ammunition, spotter equipment, and additional pieces of equipment.\nDrag this sprite onto yourself to open it up! NOTE: You cannot put items back inside this case."
desc = "A large case containing your very own choice of a long-range rifle, between the classic M42A and the experimental XM43E1. Additionally, the kit includes a set of M45 ghillie armor and helmet, a M42 scout sight, ammunition, spotter gear, and additional pieces of equipment.\nDrag this sprite onto yourself to open it up! NOTE: You cannot put items back inside this case."
kit_overlay = "sniper"

/obj/item/storage/box/spec/sniper/fill_preset_inventory()
// sniper
new /obj/item/spec_kit/sniper_weapon_selector(src)
new /obj/item/clothing/suit/storage/marine/ghillie(src)
new /obj/item/clothing/head/helmet/marine/ghillie(src)
new /obj/item/clothing/glasses/night/m42_night_goggles(src)
new /obj/item/weapon/gun/pistol/vp78(src)
new /obj/item/ammo_magazine/pistol/vp78(src)
new /obj/item/ammo_magazine/pistol/vp78(src)
new /obj/item/storage/backpack/marine/smock(src)
// spotter
new /obj/item/storage/box/kit/spotter(src)

/obj/item/storage/box/spec/sniper/m42a/fill_preset_inventory()
desc = "A large case containing an M42A sniper rifle, and a variety of specialized ammunition for it."
new /obj/item/ammo_magazine/sniper(src)
new /obj/item/ammo_magazine/sniper/incendiary(src)
new /obj/item/ammo_magazine/sniper/incendiary(src)
new /obj/item/ammo_magazine/sniper/flak(src)
new /obj/item/ammo_magazine/sniper/flak(src)
new /obj/item/storage/backpack/marine/smock(src)
new /obj/item/weapon/gun/pistol/vp78(src)
new /obj/item/ammo_magazine/pistol/vp78(src)
new /obj/item/ammo_magazine/pistol/vp78(src)
new /obj/item/weapon/gun/rifle/sniper/M42A(src)
new /obj/item/facepaint/sniper(src)
// spotter
new /obj/item/storage/box/kit/spotter(src)

/obj/item/storage/box/spec/sniper/anti_materiel/fill_preset_inventory()
desc = "A large case containing a XM43E1 anti-materiel rifle, and five additional magazines of 10x99mm."
new /obj/item/weapon/gun/rifle/sniper/XM43E1(src)
new /obj/item/ammo_magazine/sniper/anti_materiel(src)
new /obj/item/ammo_magazine/sniper/anti_materiel(src)
new /obj/item/ammo_magazine/sniper/anti_materiel(src)
new /obj/item/ammo_magazine/sniper/anti_materiel(src)
new /obj/item/ammo_magazine/sniper/anti_materiel(src)

/obj/item/storage/box/spec/scout
name = "\improper Scout equipment case"
Expand Down Expand Up @@ -278,6 +289,30 @@
return TRUE
return FALSE

//Sniper weapon selector snowflake
/obj/item/spec_kit/sniper_weapon_selector
name = "\improper Sniper weapon case"
desc = "A large case that might contain either a classic M42A sniper rifle, or the experimental XM43E1 anti-materiel rifle. Choose wisely."

/obj/item/spec_kit/sniper_weapon_selector/can_use(mob/living/carbon/human/user)
return TRUE

/obj/item/spec_kit/sniper_weapon_selector/select_and_spawn(mob/living/carbon/human/user)
var/sniper_selection = tgui_input_list(usr, "Select your weapon", "Weapon Selection", list("M42A sniper rifle", "XM43E1 anti-materiel rifle"))
Kaga-404 marked this conversation as resolved.
Show resolved Hide resolved
if(!sniper_selection || QDELETED(src))
return FALSE
var/turf/T = get_turf(loc)
var/obj/item/storage/box/spec/weapon_box
switch(sniper_selection)
if("M42A sniper rifle")
weapon_box = new /obj/item/storage/box/spec/sniper/m42a(T)
user.put_in_hands(weapon_box)
return TRUE
if("XM43E1 anti-materiel rifle")
weapon_box = new /obj/item/storage/box/spec/sniper/anti_materiel(T)
user.put_in_hands(weapon_box)
return TRUE
return FALSE

//******************************************PFC Kits****************************************************************/

Expand Down
4 changes: 4 additions & 0 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,10 @@ and you're good to go.
BP.generate_bullet(GLOB.ammo_list[projectile_to_fire.ammo.bonus_projectiles_type], 0, NO_FLAGS)
BP.accuracy = round(BP.accuracy * projectile_to_fire.accuracy/initial(projectile_to_fire.accuracy)) //Modifies accuracy of pellets per fire_bonus_projectiles.
BP.damage *= damage_buff

BP.bonus_projectile_check = 2
projectile_to_fire.bonus_projectile_check = 1

projectile_to_fire.give_bullet_traits(BP)
if(bullets_fired > 1)
BP.original = attacked_mob //original == the original target of the projectile. If the target is downed and this isn't set, the projectile will try to fly over it. Of course, it isn't going anywhere, but it's the principle of the thing. Very embarrassing.
Expand Down
15 changes: 9 additions & 6 deletions code/modules/projectiles/guns/specialist/sniper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
item_state = "xm43e1"
unacidable = TRUE
indestructible = 1
aimed_shot_cooldown_delay = 4 SECONDS

fire_sound = 'sound/weapons/sniper_heavy.ogg'
current_mag = /obj/item/ammo_magazine/sniper/anti_materiel //Renamed from anti-tank to align with new identity/description. Other references have been changed as well. -Kaga
Expand All @@ -354,9 +355,9 @@
attachable_allowed = list(/obj/item/attachable/bipod)
flags_gun_features = GUN_AUTO_EJECTOR|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER
starting_attachment_types = list(/obj/item/attachable/pmc_sniperbarrel)
sniper_beam_type = /obj/effect/ebeam/laser/intense
sniper_beam_icon = "laser_beam_intense"
sniper_lockon_icon = "sniper_lockon_intense"
sniper_beam_type = /obj/effect/ebeam/laser
sniper_beam_icon = "laser_beam"
sniper_lockon_icon = "sniper_lockon"

/obj/item/weapon/gun/rifle/sniper/XM43E1/handle_starting_attachment()
..()
Expand All @@ -376,6 +377,7 @@
..()
set_fire_delay(FIRE_DELAY_TIER_6 * 6 )//Big boy damage, but it takes a lot of time to fire a shot.
//Kaga: Adjusted from 56 (Tier 4, 7*8) -> 30 (Tier 6, 5*6) ticks. 95 really wasn't big-boy damage anymore, although I updated it to 125 to remain consistent with the other 10x99mm caliber weapon (M42C). Now takes only twice as long as the M42A.
//This outright deals less DPS than the normal sniper rifle, 125 vs 140 per 3s.
set_burst_amount(BURST_AMOUNT_TIER_1)
accuracy_mult = BASE_ACCURACY_MULT + 2*HIT_ACCURACY_MULT_TIER_10 //Who coded this like this, and why? It just calculates out to 1+1=2. Leaving a note here to check back later.
scatter = SCATTER_AMOUNT_TIER_10
Expand All @@ -385,17 +387,18 @@
/obj/item/weapon/gun/rifle/sniper/XM43E1/set_bullet_traits()
LAZYADD(traits_to_give, list(
BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_iff),
BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_penetrating),
BULLET_TRAIT_ENTRY_ID("turfs", /datum/element/bullet_trait_damage_boost, 11, GLOB.damage_boost_turfs),
BULLET_TRAIT_ENTRY_ID("breaching", /datum/element/bullet_trait_damage_boost, 11, GLOB.damage_boost_breaching),
//At 1375 per shot it'll take 1 shot to break resin turfs, and a full mag of 8 to break reinforced walls.
//At 1375 per shot it'll take 1 shot to break resin turfs usually (thick resin at 1350, RNG may vary), and a full mag of 8 to break reinforced walls.
//However, the second wall it hits will only take 550 damage, unable to even kill a full-health normal resin wall (900).
//Much more effective at breaking resin doors and membranes, which have less HP and slow down the projectile less.
BULLET_TRAIT_ENTRY_ID("pylons", /datum/element/bullet_trait_damage_boost, 6, GLOB.damage_boost_pylons)
//At 750 per shot it'll take 3 to break a Pylon (1800 HP). No Damage Boost vs other xeno structures yet, those will require a whole new list w/ the damage_boost trait.
))

/*
//Disabled until an identity is better defined. -Kaga
/obj/item/weapon/gun/rifle/sniper/M42B/afterattack(atom/target, mob/user, flag)
/obj/item/weapon/gun/rifle/sniper/XM43E1/afterattack(atom/target, mob/user, flag)
if(able_to_fire(user))
if(get_dist(target,user) <= 8)
to_chat(user, SPAN_WARNING("The [src.name] beeps, indicating that the target is within an unsafe proximity to the rifle, refusing to fire."))
Expand Down
6 changes: 4 additions & 2 deletions code/modules/projectiles/magazines/specialist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
//XM43E1 Magazine
/obj/item/ammo_magazine/sniper/anti_materiel
name = "\improper XM43E1 marksman magazine (10x99mm)"
desc = "A magazine of caseless 10x99mm anti-materiel rounds."
desc = "A magazine of caseless 10x99mm anti-materiel rounds, capable of penetrating through most infantry-level materiel. Depending on what you hit, it might even still have enough energy to wound anyone hiding behind it."
max_rounds = 8
caliber = "10x99mm"
default_ammo = /datum/ammo/bullet/sniper/anti_materiel
gun_type = /obj/item/weapon/gun/rifle/sniper/XM43E1

icon_state = "xm43e1"
ammo_band_icon = "+m42c_band"
ammo_band_icon_empty = "+m42c_band_e"
//M42C magazine

/obj/item/ammo_magazine/sniper/elite
Expand Down
18 changes: 18 additions & 0 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
/// How much to make the bullet fall off by accuracy-wise when closer than the ideal range
var/accuracy_range_falloff = 10

/// Is this a lone (0), original (1), or bonus (2) projectile. Used by gun.dm and fire_bonus_projectiles() currently.
var/bonus_projectile_check = 0

/// What last atom triggered a signal this projectile is registered to? Used by damage_boost.dm currently.
var/atom/last_atom_signaled = null

/// Was this projectile affected by a damage_boost trait?
var/damage_boosted = 0
/// If this projectile was affected by a damage_boost trait, what was the last modifier?
var/last_damage_mult = 1

/obj/projectile/Initialize(mapload, datum/cause_data/cause_data)
. = ..()
path = list()
Expand Down Expand Up @@ -164,6 +175,12 @@
apply_bullet_trait(L)

/obj/projectile/proc/calculate_damage()

if(damage_boosted)
damage = damage / last_damage_mult
damage_boosted--
last_damage_mult = 1

if(effective_range_min && distance_travelled < effective_range_min)
return max(0, damage - round((effective_range_min - distance_travelled) * damage_buildup))
else if(distance_travelled > effective_range_max)
Expand Down Expand Up @@ -215,6 +232,7 @@
//If we have the right kind of ammo, we can fire several projectiles at once.
if(ammo.bonus_projectiles_amount && ammo.bonus_projectiles_type)
ammo.fire_bonus_projectiles(src)
bonus_projectile_check = 1 //Mark this projectile as having spawned a set of bonus projectiles.

path = get_line(starting, target_turf)
p_x += clamp((rand()-0.5)*scatter*3, -8, 8)
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@
#include "code\datums\elements\bullet_trait\ignored_range.dm"
#include "code\datums\elements\bullet_trait\incendiary.dm"
#include "code\datums\elements\bullet_trait\penetrating\heavy.dm"
#include "code\datums\elements\bullet_trait\penetrating\light.dm"
#include "code\datums\elements\bullet_trait\penetrating\penetrating.dm"
#include "code\datums\elements\traitbound\_traitbound.dm"
#include "code\datums\elements\traitbound\crawler.dm"
Expand Down
Binary file modified icons/effects/Targeted.dmi
Binary file not shown.
Binary file modified icons/effects/beam.dmi
Binary file not shown.
Binary file modified icons/mob/humans/onmob/head_1.dmi
Binary file not shown.
Binary file modified icons/mob/humans/onmob/suit_1.dmi
Binary file not shown.
Binary file modified icons/obj/items/clothing/cm_hats.dmi
Binary file not shown.
Binary file modified icons/obj/items/clothing/cm_suits.dmi
Binary file not shown.
Loading