Skip to content

Commit

Permalink
TGS Test Merge (#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm13-github committed Jan 30, 2025
2 parents 93d7609 + 1c65203 commit 02bcf2d
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 11 deletions.
10 changes: 7 additions & 3 deletions code/datums/ammo/ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
return 0 //return 0 means it flies even after being near something. Return 1 means it stops

/datum/ammo/proc/knockback(mob/living/living_mob, obj/projectile/fired_projectile, max_range = 2)
for(var/list/traits in fired_projectile.bullet_traits)
if(locate(/datum/element/bullet_trait_knockback_disabled) in traits)
return
if(!living_mob || living_mob == fired_projectile.firer)
return
if(fired_projectile.distance_travelled > max_range || living_mob.body_position == LYING_DOWN)
Expand Down Expand Up @@ -226,7 +229,7 @@
else
P.play_hit_effect(M)

/datum/ammo/proc/fire_bonus_projectiles(obj/projectile/original_P)
/datum/ammo/proc/fire_bonus_projectiles(obj/projectile/original_P, gun_damage_mult = 1, projectile_max_range_add = 0)
set waitfor = 0

var/turf/curloc = get_turf(original_P.shot_from)
Expand All @@ -236,7 +239,8 @@
var/final_angle = initial_angle

var/obj/projectile/P = new /obj/projectile(curloc, original_P.weapon_cause_data)
P.generate_bullet(GLOB.ammo_list[bonus_projectiles_type]) //No bonus damage or anything.
P.generate_bullet(GLOB.ammo_list[bonus_projectiles_type])
P.damage *= gun_damage_mult
P.accuracy = floor(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!
Expand All @@ -245,7 +249,7 @@
final_angle += rand(-total_scatter_angle, total_scatter_angle)
var/turf/new_target = get_angle_target_turf(curloc, final_angle, 30)

P.fire_at(new_target, original_P.firer, original_P.shot_from, P.ammo.max_range, P.ammo.shell_speed, original_P.original, FALSE) //Fire!
P.fire_at(new_target, original_P.firer, original_P.shot_from, P.ammo.max_range + projectile_max_range_add, P.ammo.shell_speed, original_P.original, FALSE) //Fire!

/datum/ammo/proc/drop_flame(turf/turf, datum/cause_data/cause_data) // ~Art updated fire 20JAN17
if(!istype(turf))
Expand Down
4 changes: 4 additions & 0 deletions code/datums/elements/bullet_trait/knockback_disabled.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/element/bullet_trait_knockback_disabled
// General bullet trait vars
element_flags = ELEMENT_DETACH|ELEMENT_BESPOKE
id_arg_index = 2
13 changes: 13 additions & 0 deletions code/datums/supply_packs/attachments.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@
containername = "compensator attachment crate"
group = "Attachments"

/datum/supply_packs/shotgun_choke
name = "shotgun choke kit crate (x4)"
contains = list(
/obj/item/attachable/shotgun_choke,
/obj/item/attachable/shotgun_choke,
/obj/item/attachable/shotgun_choke,
/obj/item/attachable/shotgun_choke,
)
cost = 30
containertype = /obj/structure/closet/crate
containername = "shotgun choke kit crate"
group = "Attachments"

/datum/supply_packs/underbarrel_foregrip
name = "foregrip attachment crate (x8)"
contains = list(
Expand Down
1 change: 1 addition & 0 deletions code/game/machinery/vending/vendor_types/requisitions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
list("M5 Bayonet", 10.5, /obj/item/attachable/bayonet, VENDOR_ITEM_REGULAR),
list("Recoil Compensator", 6.5, /obj/item/attachable/compensator, VENDOR_ITEM_REGULAR),
list("Suppressor", 6.5, /obj/item/attachable/suppressor, VENDOR_ITEM_REGULAR),
list("Shotgun Choke Kit", 4.5, /obj/item/attachable/shotgun_choke, VENDOR_ITEM_REGULAR),

list("RAIL", -1, null, null),
list("B8 Smart-Scope", 3.5, /obj/item/attachable/scope/mini_iff, VENDOR_ITEM_REGULAR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
list("Extended Barrel", 2.5, /obj/item/attachable/extended_barrel, VENDOR_ITEM_REGULAR),
list("Recoil Compensator", 2.5, /obj/item/attachable/compensator, VENDOR_ITEM_REGULAR),
list("Suppressor", 2.5, /obj/item/attachable/suppressor, VENDOR_ITEM_REGULAR),
list("Shotgun Choke Kit", 1.5, /obj/item/attachable/shotgun_choke, VENDOR_ITEM_REGULAR),

list("RAIL", -1, null, null),
list("B8 Smart-Scope", 1.5, /obj/item/attachable/scope/mini_iff, VENDOR_ITEM_REGULAR),
Expand Down
10 changes: 8 additions & 2 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
///Multiplier. Increases or decreases how much bonus scatter is added with each bullet during burst fire (wielded only).
var/burst_scatter_mult = 4

///Modifier for how far the weapon's projectile can travel before it disappears.
var/projectile_max_range_add = 0
///What minimum range the weapon deals full damage, builds up the closer you get. 0 for no minimum.
var/effective_range_min = 0
///What maximum range the weapon deals full damage, tapers off using damage_falloff after hitting this value. 0 for no maximum.
Expand Down Expand Up @@ -333,6 +335,7 @@
//reset initial define-values
aim_slowdown = initial(aim_slowdown)
wield_delay = initial(wield_delay)
projectile_max_range_add = initial(projectile_max_range_add)

/// Populate traits_to_give in this proc
/obj/item/weapon/gun/proc/set_bullet_traits()
Expand Down Expand Up @@ -402,6 +405,7 @@
damage_buildup_mult += R.damage_buildup_mod
effective_range_min += R.range_min_mod
effective_range_max += R.range_max_mod
projectile_max_range_add += R.projectile_max_range_mod
recoil += R.recoil_mod
burst_scatter_mult += R.burst_scatter_mod
modify_burst_amount(R.burst_mod)
Expand Down Expand Up @@ -695,6 +699,8 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w
data["unwielded_accuracy"] = accuracy * accuracy_mult_unwielded
data["min_accuracy"] = min_accuracy
data["max_range"] = max_range
data["projectile_max_range_add"] = projectile_max_range_add
data["effective_range_max_mod"] = effective_range_max
data["effective_range"] = effective_range

// damage table data
Expand Down Expand Up @@ -1247,7 +1253,7 @@ and you're good to go.
//This is where the projectile leaves the barrel and deals with projectile code only.
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
in_chamber = null // It's not in the gun anymore
INVOKE_ASYNC(projectile_to_fire, TYPE_PROC_REF(/obj/projectile, fire_at), target, user, src, projectile_to_fire?.ammo?.max_range, bullet_velocity, original_target)
INVOKE_ASYNC(projectile_to_fire, TYPE_PROC_REF(/obj/projectile, fire_at), target, user, src, projectile_to_fire?.ammo?.max_range + projectile_max_range_add, bullet_velocity, original_target, null, damage_mult, projectile_max_range_add)
projectile_to_fire = null // Important: firing might have made projectile collide early and ALREADY have deleted it. We clear it too.
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -1491,7 +1497,7 @@ and you're good to go.
BP = new /obj/projectile(null, create_cause_data(initial(name), user))
BP.generate_bullet(GLOB.ammo_list[projectile_to_fire.ammo.bonus_projectiles_type], 0, NO_FLAGS)
BP.accuracy = floor(BP.accuracy * projectile_to_fire.accuracy/initial(projectile_to_fire.accuracy)) //Modifies accuracy of pellets per fire_bonus_projectiles.
BP.damage *= damage_buff
BP.damage *= damage_buff * damage_mult

BP.bonus_projectile_check = 2
projectile_to_fire.bonus_projectile_check = 1
Expand Down
39 changes: 39 additions & 0 deletions code/modules/projectiles/gun_attachables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Defined in conflicts.dm of the #defines folder.
var/damage_buildup_mod = 0 //Modifier to damage buildup, works off a multiplier.
var/range_min_mod = 0 //Modifier to minimum effective range, tile value.
var/range_max_mod = 0 //Modifier to maximum effective range, tile value.
var/projectile_max_range_mod = 0 //Modifier to how far the projectile can travel in tiles.
var/melee_mod = 0 //Changing to a flat number so this actually doesn't screw up the calculations.
var/scatter_mod = 0 //Increases or decreases scatter chance.
var/scatter_unwielded_mod = 0 //same as above but for onehanded firing.
Expand Down Expand Up @@ -444,6 +445,44 @@ Defined in conflicts.dm of the #defines folder.
accuracy_unwielded_mod = HIT_ACCURACY_MULT_TIER_4
recoil_unwielded_mod = -RECOIL_AMOUNT_TIER_4

/obj/item/attachable/shotgun_choke
name = "shotgun choke"
desc = "A modified choke for the M37A2 pump shotgun. It mildly tightens the spread, accuracy and max range of fired shells. The cyclic rate of the weapon is also increased. In exchange, projectile damage and force is greatly reduced, with the weapon also having higher recoil. Not recommended for use with slugs."
slot = "muzzle"
icon = 'icons/obj/items/weapons/guns/attachments/barrel.dmi'
icon_state = "choke"
attach_icon = "choke_a"
pixel_shift_x = 16
pixel_shift_y = 17
hud_offset_mod = -2

/obj/item/attachable/shotgun_choke/New()
..()
recoil_mod = RECOIL_AMOUNT_TIER_4
accuracy_mod = HIT_ACCURACY_MULT_TIER_5
damage_mod = -BULLET_DAMAGE_MULT_TIER_6
scatter_mod = -SCATTER_AMOUNT_TIER_9
delay_mod = -FIRE_DELAY_TIER_2
projectile_max_range_mod = 1
damage_falloff_mod = -0.3

/obj/item/attachable/shotgun_choke/Attach(obj/item/weapon/gun/shotgun/pump/attaching_gun)
if(!istype(attaching_gun, /obj/item/weapon/gun/shotgun/pump))
return ..()
attaching_gun.pump_delay -= FIRE_DELAY_TIER_5
attaching_gun.add_bullet_trait(BULLET_TRAIT_ENTRY_ID("knockback_disabled", /datum/element/bullet_trait_knockback_disabled))
attaching_gun.fire_sound = 'sound/weapons/gun_shotgun_choke.ogg'

return ..()

/obj/item/attachable/shotgun_choke/Detach(mob/user, obj/item/weapon/gun/shotgun/pump/detaching_gun)
if(!istype(detaching_gun, /obj/item/weapon/gun/shotgun/pump))
return ..()
detaching_gun.pump_delay += FIRE_DELAY_TIER_5
detaching_gun.remove_bullet_trait("knockback_disabled")
detaching_gun.fire_sound = initial(detaching_gun.fire_sound)

return ..()

/obj/item/attachable/slavicbarrel
name = "sniper barrel"
Expand Down
2 changes: 2 additions & 0 deletions code/modules/projectiles/guns/shotguns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ can cause issues with ammo types getting mixed up during the burst.
current_mag.current_rounds--
current_mag.chamber_contents[current_mag.chamber_position] = "empty"
current_mag.chamber_position--
apply_traits(in_chamber)
return in_chamber


Expand Down Expand Up @@ -1111,6 +1112,7 @@ can cause issues with ammo types getting mixed up during the burst.
/obj/item/attachable/extended_barrel,
/obj/item/attachable/heavy_barrel,
/obj/item/attachable/compensator,
/obj/item/attachable/shotgun_choke,
/obj/item/attachable/magnetic_harness,
/obj/item/attachable/attached_gun/extinguisher,
/obj/item/attachable/attached_gun/flamer,
Expand Down
4 changes: 2 additions & 2 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
return damage

// Target, firer, shot from (i.e. the gun), projectile range, projectile speed, original target (who was aimed at, not where projectile is going towards)
/obj/projectile/proc/fire_at(atom/target, atom/F, atom/S, range = 30, speed = 1, atom/original_override, randomize_speed = TRUE)
/obj/projectile/proc/fire_at(atom/target, atom/F, atom/S, range = 30, speed = 1, atom/original_override, randomize_speed = TRUE, gun_damage_mult = 1, projectile_max_range_add = 0)
SHOULD_NOT_SLEEP(TRUE)
original = original || original_override || target
if(!loc)
Expand Down Expand Up @@ -231,7 +231,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)
randomize_speed = FALSE
ammo.fire_bonus_projectiles(src)
ammo.fire_bonus_projectiles(src, gun_damage_mult, projectile_max_range_add)
bonus_projectile_check = 1 //Mark this projectile as having spawned a set of bonus projectiles.

path = get_line(starting, target_turf)
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@
#include "code\datums\elements\bullet_trait\iff.dm"
#include "code\datums\elements\bullet_trait\ignored_range.dm"
#include "code\datums\elements\bullet_trait\incendiary.dm"
#include "code\datums\elements\bullet_trait\knockback_disabled.dm"
#include "code\datums\elements\bullet_trait\penetrating\heavy.dm"
#include "code\datums\elements\bullet_trait\penetrating\penetrating.dm"
#include "code\datums\elements\bullet_trait\penetrating\weak.dm"
Expand Down
Binary file modified icons/obj/items/weapons/guns/attachments/barrel.dmi
Binary file not shown.
Binary file added sound/weapons/gun_shotgun_choke.ogg
Binary file not shown.
15 changes: 11 additions & 4 deletions tgui/packages/tgui/interfaces/WeaponStats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,30 @@ const Range = (props) => {
const { data } = useBackend();
const {
max_range,
projectile_max_range_add,
range_max,
falloff,
falloff_max,
effective_range,
effective_range_max,
effective_range_max_mod,
} = data;
return (
<>
<ProgressBar value={max_range / range_max} ranges={RedGreenRange}>
Max range: {max_range} / {range_max}
<ProgressBar
value={(max_range + projectile_max_range_add) / range_max}
ranges={RedGreenRange}
>
Max range: {max_range + projectile_max_range_add} / {range_max}
</ProgressBar>
<Box height="5px" />
<ProgressBar
value={effective_range / effective_range_max}
value={
(effective_range + effective_range_max_mod) / effective_range_max
}
ranges={RedGreenRange}
>
Effective range: {effective_range}
Effective range: {effective_range + effective_range_max_mod}
</ProgressBar>
<Box height="5px" />
<ProgressBar value={falloff / falloff_max} ranges={GreedRedRange}>
Expand Down

0 comments on commit 02bcf2d

Please sign in to comment.