Skip to content

Commit

Permalink
buffs cades against projectiles
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoe2013 committed Jul 16, 2024
1 parent 6a7fc16 commit 2c2e809
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 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
3 changes: 1 addition & 2 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,9 @@

//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) + 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 2c2e809

Please sign in to comment.