Skip to content

Commit

Permalink
Ports even more projectile changes. (#340)
Browse files Browse the repository at this point in the history
* More projectile fixes/improvements (#15305)

* Update abilities_praetorian.dm

* Airburst IFF fix (#15447)

* Projectile fixes (#15340)

* Xeno turret fix (#15633)

* Fix infinite reflect (#15558)

* Decreases ping sound range (#15794)

Co-authored-by: TiviPlus <[email protected]>

* stagger gun code adjustment (#15875)

* Tank Desant projectile fix (#15918)

* Hit scan fix (#16021)

* Automatic changelog for PR #15338 [ci skip]

* Fix bemo throw (#15338)

* Revert "Automatic changelog for PR #15338 [ci skip]"

This reverts commit 3a5efdc.

* Tank desant targeting (#16520)

* Sentry density fix (#16475)

* Update xeno.dm

* Fixes tank aiming at darkness trying to shoot across zlevels (#16145)

Co-authored-by: TiviPlus <[email protected]>

* Tank fixes for mines and sentry (#16112)

* Sentry tank fix (#16472)

* bruh

* skill isue

---------

Signed-off-by: Helg2 <[email protected]>
Co-authored-by: Lumipharon <[email protected]>
Co-authored-by: TiviPlus <[email protected]>
Co-authored-by: TiviPlus <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 23, 2024
1 parent 7f988f9 commit 81e9183
Show file tree
Hide file tree
Showing 29 changed files with 214 additions and 166 deletions.
17 changes: 17 additions & 0 deletions code/__HELPERS/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@
if(get_dist(source, nearby_illusion) > distance)
continue
. += nearby_illusion
///Returns a list of vehicles via get_dist and same z level method, very cheap compared to range()
/proc/cheap_get_tanks_near(atom/movable/source, distance)
. = list()
var/turf/source_turf = get_turf(source)
if(!source_turf)
return
for(var/obj/vehicle/sealed/armored/nearby_tank AS in GLOB.tank_list)
if(isnull(nearby_tank))
continue
if(source_turf.z != nearby_tank.z)
continue
var/bound_max = 1
if(nearby_tank.hitbox)
bound_max = max(nearby_tank.hitbox.bound_height, nearby_tank.hitbox.bound_width) / 32
if(get_dist(source_turf, nearby_tank) > distance + bound_max - 1)
continue
. += nearby_tank

///Returns the nearest target that has the right target flag
/proc/get_nearest_target(atom/source, distance, target_flags, attacker_faction, attacker_hive)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/autofire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ SUBSYSTEM_DEF(automatedfire)
SIGNAL_HANDLER
var/obj/projectile/newshot = new(loc)
newshot.generate_bullet(ammo)
newshot.fire_at(target, src, null, ammo.max_range, ammo.shell_speed)
newshot.fire_at(target, null, src, ammo.max_range, ammo.shell_speed)

/datum/component/automatedfire/xeno_turret_autofire
///Delay between two shots
Expand Down
2 changes: 1 addition & 1 deletion code/datums/elements/debris.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
var/pitch = 0
if(P.ammo.flags_ammo_behavior & AMMO_SOUND_PITCH)
pitch = 55000
playsound(source, P.ammo.sound_bounce, 50, 1, frequency = pitch)
playsound(source, P.ammo.sound_bounce, 50, TRUE, 4, 5, pitch)
addtimer(CALLBACK(src, PROC_REF(remove_ping), src, smoke_visuals, debris_visuals), 0.7 SECONDS)

/datum/element/debris/proc/remove_ping(hit, obj/effect/abstract/particle_holder/smoke_visuals, obj/effect/abstract/particle_holder/debris_visuals)
Expand Down
12 changes: 5 additions & 7 deletions code/datums/personal_statistics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,15 @@ The alternative is scattering them everywhere under their respective objects whi
return ..()

///Tally to personal_statistics that a successful shot was made and record the damage dealt
/mob/living/proc/record_projectile_damage(mob/shooter, damage)
/mob/living/proc/record_projectile_damage(damage, mob/living/victim)
//Check if a ckey exists; the check for victim aliveness is handled before the proc call
if(!shooter.ckey)
if(!ckey)
return FALSE
var/datum/personal_statistics/personal_statistics = GLOB.personal_statistics_list[shooter.ckey]
var/datum/personal_statistics/personal_statistics = GLOB.personal_statistics_list[ckey]
personal_statistics.projectiles_hit++
personal_statistics.projectile_damage += damage
if(faction && isliving(shooter)) //See if any friendly fire was made
var/mob/living/L = shooter
if(faction == L.faction)
personal_statistics.friendly_fire_damage += damage //FF multiplier already included by the way
if(faction == victim.faction)
personal_statistics.friendly_fire_damage += damage //FF multiplier already included by the way
return TRUE

///Record what reagents and how much of them were transferred to a mob into their ckey's /datum/personal_statistics
Expand Down
15 changes: 10 additions & 5 deletions code/game/objects/items/explosives/mine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,16 @@ Stepping directly on the mine will also blow it up
var/mob/living/living_victim
if((target_mode & MINE_LIVING_ONLY) && isliving(victim))
living_victim = victim
else if((target_mode & MINE_VEHICLE_ONLY) && isvehicle(victim))
var/obj/vehicle/vehicle_victim = victim
if(!length(vehicle_victim.occupants))
return FALSE
living_victim = vehicle_victim.occupants[1]
else if(target_mode & MINE_VEHICLE_ONLY)
if(ishitbox(victim))
var/obj/hitbox/hitbox = victim
victim = hitbox.root
if(isvehicle(victim))
var/obj/vehicle/vehicle_victim = victim
var/list/driver_list = vehicle_victim.return_drivers()
if(!length(driver_list))
return FALSE
living_victim = driver_list[1]

if(!living_victim)
return FALSE
Expand Down
3 changes: 1 addition & 2 deletions code/game/objects/machinery/mortar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@
var/datum/ammo/ammo = GLOB.ammo_list[arty_shell.ammo_type]
shell.generate_bullet(ammo)
var/shell_range = min(get_dist_euclidean(src, target), ammo.max_range)
// shell.fire_at(target, null, src, shell_range, ammo.shell_speed) // FUTURE ORIGINAL, WE DON'T HAVE NEEDED CHANGES YET
shell.fire_at(target, src, src, shell_range, ammo.shell_speed) // RUTGMC OLD VERSION
shell.fire_at(target, null, src, shell_range, ammo.shell_speed)

perform_firing_visuals()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@
ability_cost = X.ammo.spit_cost
newspit.generate_bullet(X.ammo, X.ammo.damage * SPIT_UPGRADE_BONUS(X))
newspit.def_zone = X.get_limbzone_target()
newspit.fire_at(current_target, X, null, X.ammo.max_range, X.ammo.shell_speed)
newspit.fire_at(current_target, X, X, X.ammo.max_range, X.ammo.shell_speed)

if(can_use_ability(current_target) && X.client) //X.client to make sure autospit doesn't continue for non player mobs.
succeed_activate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ RU TGMC EDIT */
var/datum/ammo/xeno/earth_pillar/projectile = landslide? GLOB.ammo_list[/datum/ammo/xeno/earth_pillar/landslide] : GLOB.ammo_list[/datum/ammo/xeno/earth_pillar]
var/obj/projectile/new_projectile = new /obj/projectile(source_turf)
new_projectile.generate_bullet(projectile)
new_projectile.fire_at(get_turf(target_atom), usr, null, new_projectile.ammo.max_range, loc_override = source_turf)
new_projectile.fire_at(get_turf(target_atom), usr, source_turf, new_projectile.ammo.max_range)

/// Seismic Fracture (as in the ability) has a special interaction with any Earth Pillars caught in its attack range.
/// Those Earth Pillars will reflect the same attack in a similar range around it, destroying itself afterwards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ GLOBAL_LIST_INIT(boiler_glob_image_list, list(

var/obj/projectile/P = new /obj/projectile(boiler_owner.loc)
P.generate_bullet(boiler_owner.ammo)
P.fire_at(target, boiler_owner, null, boiler_owner.ammo.max_range, boiler_owner.ammo.shell_speed)
P.fire_at(target, boiler_owner, boiler_owner, boiler_owner.ammo.max_range, boiler_owner.ammo.shell_speed)
playsound(boiler_owner, 'sound/effects/blobattack.ogg', 25, 1)
if(istype(boiler_owner.ammo, /datum/ammo/xeno/boiler_gas/corrosive))
GLOB.round_statistics.boiler_acid_smokes++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
newspit.generate_bullet(scatter_spit, scatter_spit.damage * SPIT_UPGRADE_BONUS(X))
newspit.def_zone = X.get_limbzone_target()

newspit.fire_at(target, X, null, newspit.ammo.max_range)
newspit.fire_at(target, X, X, newspit.ammo.max_range)

succeed_activate()
add_cooldown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
newspit.generate_bullet(scatter_spit, scatter_spit.damage * SPIT_UPGRADE_BONUS(X))
newspit.def_zone = X.get_limbzone_target()

newspit.fire_at(target, X, null, newspit.ammo.max_range)
newspit.fire_at(target, X, X, newspit.ammo.max_range)

succeed_activate()
add_cooldown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@
new_angle += 360
else if(new_angle > 360)
new_angle -= 360
proj.firer = src
proj.fire_at(shooter = src, source = src, angle = new_angle, recursivity = TRUE)
proj.fire_at(source = src, angle = new_angle, recursivity = TRUE)

//Record those sick rocket shots
//Is not part of record_projectiles_frozen() because it is probably bad to be running that for every bullet!
Expand Down Expand Up @@ -565,7 +564,7 @@
var/obj/projectile/hitscan/projectile = new /obj/projectile/hitscan(xeno_owner.loc)
projectile.effect_icon = initial(ammo_type.hitscan_effect_icon)
projectile.generate_bullet(ammo_type)
projectile.fire_at(A, xeno_owner, null, projectile.ammo.max_range, projectile.ammo.shell_speed)
projectile.fire_at(A, xeno_owner, xeno_owner, projectile.ammo.max_range, projectile.ammo.shell_speed)
playsound(xeno_owner, 'sound/weapons/guns/fire/volkite_4.ogg', 40)

if(istype(xeno_owner.ammo, /datum/ammo/energy/xeno/psy_blast))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/hostile/hostile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
var/obj/projectile/P = new(startloc)
playsound(src, projectilesound, 100, 1)
P.generate_bullet(GLOB.ammo_list[ammotype])
P.fire_at(targeted_atom, src)
P.fire_at(targeted_atom, src, src)


/mob/living/simple_animal/hostile/proc/CanSmashTurfs(turf/T)
Expand Down
21 changes: 13 additions & 8 deletions code/modules/projectiles/ammo_datums/_ammo_datums.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
return

///Special effects for leaving a turf. Only called if the projectile has AMMO_LEAVE_TURF enabled
/datum/ammo/proc/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/proc/on_leave_turf(turf/T, obj/projectile/proj)
return

///Handles CC application on the victim
Expand Down Expand Up @@ -189,7 +189,7 @@
continue
victim.visible_message(span_danger("[victim] is hit by backlash from \a [proj.name]!"),
isxeno(victim) ? span_xenodanger("We are hit by backlash from \a </b>[proj.name]</b>!") : span_highdanger("You are hit by backlash from \a </b>[proj.name]</b>!"))
victim.apply_damage(proj.damage * proj.airburst_multiplier, proj.ammo.damage_type, blocked = armor_type, updating_health = TRUE)
victim.apply_damage(proj.damage * airburst_multiplier, proj.ammo.damage_type, blocked = armor_type, updating_health = TRUE)

///handles the probability of a projectile hit to trigger fire_burst, based off actual damage done
/datum/ammo/proc/deflagrate(atom/target, obj/projectile/proj)
Expand Down Expand Up @@ -222,7 +222,12 @@
victim.adjust_fire_stacks(5)
victim.IgniteMob()

/datum/ammo/proc/fire_bonus_projectiles(obj/projectile/main_proj, atom/shooter, atom/source, range, speed, angle, target, origin_override)
/**
* Fires additional projectiles, generally considered to still be originating from a gun
* Such a buckshot
* origin_override used to have the new projectile(s) originate from a different source than the main projectile
*/
/datum/ammo/proc/fire_bonus_projectiles(obj/projectile/main_proj, mob/living/shooter, atom/source, range, speed, angle, target, origin_override) //todo: Combine these procs with extra args or something, as they are quite similar
var/effect_icon = ""
var/proj_type = /obj/projectile
if(istype(main_proj, /obj/projectile/hitscan))
Expand All @@ -249,7 +254,7 @@
new_proj.fire_at(target, shooter, source, range, speed, new_angle, TRUE, loc_override = origin_override)

///A variant of Fire_bonus_projectiles without fixed scatter and no link between gun and bonus_projectile accuracy
/datum/ammo/proc/fire_directionalburst(obj/projectile/main_proj, atom/shooter, atom/source, projectile_amount, range, speed, angle, target)
/datum/ammo/proc/fire_directionalburst(obj/projectile/main_proj, mob/living/shooter, atom/source, projectile_amount, range, speed, angle, target)
var/effect_icon = ""
var/proj_type = /obj/projectile
if(istype(main_proj, /obj/projectile/hitscan))
Expand All @@ -265,7 +270,7 @@

if(isgun(source))
var/obj/item/weapon/gun/gun = source
gun.apply_gun_modifiers(new_proj, target, shooter)
gun.apply_gun_modifiers(new_proj, target)

//Scatter here is how many degrees extra stuff deviate from the main projectile's firing angle. Fully randomised with no 45 degree cap like normal bullets
var/f = (i-1)
Expand All @@ -274,7 +279,7 @@
new_angle += 360
if(new_angle > 360)
new_angle -= 360
new_proj.fire_at(target, main_proj.loc, source, range, speed, new_angle, TRUE)
new_proj.fire_at(target, shooter, main_proj.loc, range, speed, new_angle, TRUE)

/datum/ammo/proc/drop_flame(turf/T)
if(!istype(T))
Expand All @@ -293,7 +298,7 @@

///bounces the projectile by creating a new projectile and calculating an angle of reflection
/datum/ammo/proc/reflect(turf/T, obj/projectile/proj, scatter_variance)
if(!bonus_projectiles_type)
if(!bonus_projectiles_type) //while fire_bonus_projectiles does not require this var, it can cause infinite recursion in some cases, leading to death tiles
return

var/new_range = proj.proj_max_range - proj.distance_travelled
Expand All @@ -320,5 +325,5 @@
new_angle -= 360

bonus_projectiles_amount = 1
fire_bonus_projectiles(proj, T, proj.shot_from, new_range, proj.projectile_speed, new_angle, null, get_step(T, dir_to_proj))
fire_bonus_projectiles(proj, null, proj.shot_from, new_range, proj.projectile_speed, new_angle, null, get_step(T, dir_to_proj))
bonus_projectiles_amount = 0
2 changes: 1 addition & 1 deletion code/modules/projectiles/ammo_datums/artillery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
return
T.ignite(5, 10)

/datum/ammo/bullet/atgun_spread/incendiary/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/bullet/atgun_spread/incendiary/on_leave_turf(turf/T, obj/projectile/proj)
drop_flame(T)

/datum/ammo/ags_shrapnel
Expand Down
10 changes: 5 additions & 5 deletions code/modules/projectiles/ammo_datums/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
return
T.ignite(5, 10)

/datum/ammo/bullet/tx54_spread/incendiary/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/bullet/tx54_spread/incendiary/on_leave_turf(turf/T, obj/projectile/proj)
drop_flame(T)

/datum/ammo/bullet/tx54_spread/smoke
Expand All @@ -241,7 +241,7 @@
/datum/ammo/bullet/tx54_spread/smoke/on_hit_mob(mob/M, obj/projectile/proj)
return

/datum/ammo/bullet/tx54_spread/smoke/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/bullet/tx54_spread/smoke/on_leave_turf(turf/T, obj/projectile/proj)
trail_spread_system.set_up(0, T)
trail_spread_system.start()

Expand Down Expand Up @@ -279,7 +279,7 @@
/datum/ammo/bullet/tx54_spread/razor/on_hit_mob(mob/M, obj/projectile/proj)
return

/datum/ammo/bullet/tx54_spread/razor/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/bullet/tx54_spread/razor/on_leave_turf(turf/T, obj/projectile/proj)
chemical_payload.set_up(0, T, reagent_list, RAZOR_FOAM)
chemical_payload.start()

Expand Down Expand Up @@ -374,7 +374,7 @@
return
T.ignite(5, 10)

/datum/ammo/bullet/micro_rail_spread/incendiary/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/bullet/micro_rail_spread/incendiary/on_leave_turf(turf/T, obj/projectile/proj)
if(prob(40))
drop_flame(T)

Expand Down Expand Up @@ -423,7 +423,7 @@
var/obj/obj_victim = target
obj_victim.take_damage(explosion_damage, BRUTE, BOMB)

/datum/ammo/micro_rail_cluster/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
/datum/ammo/micro_rail_cluster/on_leave_turf(turf/T, obj/projectile/proj)
///chance to detonate early, scales with distance and capped, to avoid lots of immediate detonations, and nothing reach max range respectively.
var/detonate_probability = min(proj.distance_travelled * 4, 16)
if(prob(detonate_probability))
Expand Down
11 changes: 6 additions & 5 deletions code/modules/projectiles/ammo_datums/xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ GLOBAL_LIST_INIT(no_sticky_resin, typecacheof(list(/obj/item/clothing/mask/faceh
ping = "ping_x"
damage_type = TOX
flags_ammo_behavior = AMMO_XENO
var/added_spit_delay = 0 //used to make cooldown of the different spits vary.
var/spit_cost = 5
armor_type = BIO
shell_speed = 1
accuracy = 40
Expand All @@ -15,6 +13,9 @@ GLOBAL_LIST_INIT(no_sticky_resin, typecacheof(list(/obj/item/clothing/mask/faceh
accuracy_var_low = 3
accuracy_var_high = 3
bullet_color = COLOR_LIME
///used to make cooldown of the different spits vary.
var/added_spit_delay = 0
var/spit_cost = 5
///List of reagents transferred upon spit impact if any
var/list/datum/reagent/spit_reagents
///Amount of reagents transferred upon spit impact if any
Expand Down Expand Up @@ -399,9 +400,9 @@ GLOBAL_LIST_INIT(no_sticky_resin, typecacheof(list(/obj/item/clothing/mask/faceh
///We're going to reuse one smoke spread system repeatedly to cut down on processing.
var/datum/effect_system/smoke_spread/xeno/trail_spread_system

/datum/ammo/xeno/boiler_gas/on_leave_turf(turf/T, atom/firer, obj/projectile/proj)
if(isxeno(firer))
var/mob/living/carbon/xenomorph/X = firer
/datum/ammo/xeno/boiler_gas/on_leave_turf(turf/T, obj/projectile/proj)
if(isxeno(proj.firer))
var/mob/living/carbon/xenomorph/X = proj.firer
trail_spread_system.strength = X.xeno_caste.bomb_strength
trail_spread_system.set_up(0, T)
trail_spread_system.start()
Expand Down
15 changes: 0 additions & 15 deletions code/modules/projectiles/attachables/rail.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,6 @@
. = ..()
ENABLE_BITFIELD(master_gun.flags_item, IS_DEPLOYABLE)
master_gun.deployable_item = /obj/machinery/deployable/mounted/sentry/buildasentry
master_gun.ignored_terrains = list(
/obj/machinery/deployable/mounted,
/obj/machinery/miner,
)
if(master_gun.ammo_datum_type && CHECK_BITFIELD(initial(master_gun.ammo_datum_type.flags_ammo_behavior), AMMO_ENERGY) || istype(master_gun, /obj/item/weapon/gun/energy)) //If the guns ammo is energy, the sentry will shoot at things past windows.
master_gun.ignored_terrains += list(
/obj/structure/window,
/obj/structure/window/reinforced,
/obj/machinery/door/window,
/obj/structure/window/framed,
/obj/structure/window/framed/colony,
/obj/structure/window/framed/mainship,
/obj/structure/window/framed/prison,
)
master_gun.turret_flags |= TURRET_HAS_CAMERA|TURRET_SAFETY|TURRET_ALERTS
master_gun.AddComponent(/datum/component/deployable_item, master_gun.deployable_item, deploy_time, undeploy_time)
update_icon()
Expand All @@ -171,7 +157,6 @@
var/obj/item/weapon/gun/detaching_gun = detaching_item
DISABLE_BITFIELD(detaching_gun.flags_item, IS_DEPLOYABLE)
qdel(detaching_gun.GetComponent(/datum/component/deployable_item))
detaching_gun.ignored_terrains = null
detaching_gun.deployable_item = null
detaching_gun.turret_flags &= ~(TURRET_HAS_CAMERA|TURRET_SAFETY|TURRET_ALERTS)

Expand Down
3 changes: 2 additions & 1 deletion code/modules/projectiles/gun_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w
return target
if(!istype(target, /atom/movable/screen/click_catcher))
return null
return params2turf(modifiers["screen-loc"], get_turf(user), user.client)
var/loctoget = user.client?.eye ? user.client.eye : user
return params2turf(modifiers["screen-loc"], get_turf(loctoget), user.client)

//----------------------------------------------------------
// \\
Expand Down
Loading

0 comments on commit 81e9183

Please sign in to comment.