Skip to content

Commit

Permalink
Buffs cades against projectiles (#6727)
Browse files Browse the repository at this point in the history
# About the pull request

Barricades and tables are now better against projectiles.
Assuming a standard rifleman with an unmodified m41a vs. a barricade,
the probabilities of hitting are:

| Dist | Old | New | New (Xeno)
|---|---|---|---|
|  1 |  0 | 0   | 0|
|  2 |  -0.1833 |  0.0045 |0|
|  3 | -0.0466  |  0.52 |0|
|  4 |  0.0550 |  0.85 |0|
|  5 |  0.2367  |  0.85 |0.0045|
|  [6, ∞) | 0.3383  | 0.85  |0.52|

# Explain why it's good for the game

Cades are completely worthless in hvh situations, because they fail to
block the overwhelming majority of bullets (especially in cqc, where
most gunfights happen). This makes them better while still allowing
people who get within 2 tiles to attack easier.

# Changelog
:cl:
balance: Barricades are now far better at blocking bullets from the
front. They will not block most bullets if the shooter is within 2
tiles, however.
/:cl:

---------

Co-authored-by: John Doe <[email protected]>
  • Loading branch information
Zonespace27 and johndoe2013 authored Aug 3, 2024
1 parent 6041179 commit bf3226e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

/// an object's "projectile_coverage" var indicates the maximum probability of blocking a projectile, assuming density and throwpass. Used by barricades, tables and window frames
var/projectile_coverage = 0
/// How many tiles away from this object that a shooter needs to be to maximize this barricade's projectile coverage
var/projectile_coverage_distance_limit = 6
/// set to true if the item is garbage and should be deleted after awhile
var/garbage = FALSE

Expand Down
1 change: 1 addition & 0 deletions code/game/objects/structures/barricade/barricade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
var/is_wired = FALSE
flags_barrier = HANDLE_BARRIER_CHANCE
projectile_coverage = PROJECTILE_COVERAGE_HIGH
projectile_coverage_distance_limit = 2
var/upgraded
var/brute_multiplier = 1
var/burn_multiplier = 1
Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/structures/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
var/flip_cooldown = 0 //If flip cooldown exists, don't allow flipping or putting back. This carries a WORLD.TIME value
health = 100
projectile_coverage = 20 //maximum chance of blocking a projectile
var/flipped_projectile_coverage_distance_limit = 2
var/flipped_projectile_coverage = PROJECTILE_COVERAGE_HIGH
var/upright_projectile_coverage = PROJECTILE_COVERAGE_LOW
surgery_duration_multiplier = SURGERY_SURFACE_MULT_UNSUITED
Expand All @@ -42,6 +43,7 @@
qdel(T)
if(flipped)
projectile_coverage = flipped_projectile_coverage
projectile_coverage_distance_limit = flipped_projectile_coverage_distance_limit
else
projectile_coverage = upright_projectile_coverage

Expand Down Expand Up @@ -446,6 +448,7 @@
INVOKE_ASYNC(movable_on_table, TYPE_PROC_REF(/atom/movable, throw_atom), pick(targets), 1, SPEED_FAST)

projectile_coverage = flipped_projectile_coverage
projectile_coverage_distance_limit = flipped_projectile_coverage_distance_limit

setDir(direction)
if(dir != NORTH)
Expand Down Expand Up @@ -473,6 +476,7 @@
verbs += /obj/structure/surface/table/verb/do_flip

projectile_coverage = upright_projectile_coverage
projectile_coverage_distance_limit = src::projectile_coverage_distance_limit

layer = initial(layer)
flipped = FALSE
Expand Down
5 changes: 2 additions & 3 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,17 @@

//Used by machines and structures to calculate shooting past cover
/obj/proc/calculate_cover_hit_boolean(obj/projectile/P, distance = 0, cade_direction_correct = FALSE)
if(istype(P.shot_from, /obj/item/hardpoint)) //anything shot from a tank gets a bonus to bypassing cover
if(istype(P.shot_from, /obj/item/hardpoint) || istype(P.ammo, /datum/ammo/xeno)) //anything shot from a tank or a xeno gets a bonus to bypassing cover
distance -= 3

if(distance < 1 || (distance > 3 && cade_direction_correct))
return FALSE

//an object's "projectile_coverage" var indicates the maximum probability of blocking a projectile
var/effective_accuracy = P.get_effective_accuracy()
var/distance_limit = 6 //number of tiles needed to max out block probability
var/accuracy_factor = 50 //degree to which accuracy affects probability (if accuracy is 100, probability is unaffected. Lower accuracies will increase block chance)

var/hitchance = min(projectile_coverage, (projectile_coverage * distance/distance_limit) + accuracy_factor * (1 - effective_accuracy/100))
var/hitchance = min(projectile_coverage, (projectile_coverage * distance / (projectile_coverage_distance_limit * (cade_direction_correct ? 3 : 1))) + accuracy_factor * (1 - effective_accuracy/100))

#if DEBUG_HIT_CHANCE
to_world(SPAN_DEBUG("([name] as cover) Distance travelled: [P.distance_travelled] | Effective accuracy: [effective_accuracy] | Hit chance: [hitchance]"))
Expand Down

0 comments on commit bf3226e

Please sign in to comment.