mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-08 23:39:32 +00:00
## About The Pull Request Due to how projectile code currently operates its (almost) impossible to parry projectiles and completely impossible to projectile boost them, as they move away from you instantly after being shot. Parrying others projectiles requires them to be slow enough and to land on a tile right in front of you on their last move of their tick, as else they instantly hit you. I moved parrying component from being on user to being on projectiles themselves and added TRAIT_MINING_PARRYING which allows users to actually perform the parries. This allows me to get rid of parry code existing on all projectiles and add a "grace period" mechanic - now you can parry projectiles by clicking on any turf they moved through in the last 0.25 seconds. Parrying actually runs when projectiles hit you if you clicked on the correct turf during same grace period timer. This also acts as lag compensation, allowing players with high ping to utilize this mechanic. Projectile boosting occurs when you hit a tile the projectile moved through in first 0.25 seconds of its existence. Parry also occurs on click instead of attack_hand due to this, so you can parry projectiles while holding your accelerator/crusher/resonator(what even?) - which is also important to make projectile boosting possible as firing sets your click cooldown - making attacking the turf impossible (another roadblock on ultrakill players' path) Projectile boosting now grants x1.5 damage multiplier and +40% speed instead of x1.15 and +20% like parrying, since its significantly harder to perform. Crusher projectiles now can be parried/boosted. Crushers are ***the*** badass miner weapon, but they weren't possible to boost - probably because it'd be pointless due to their lack of damage. Now boosting a crusher blast gives it 10 damage, +3 range and makes the mark it applies always count as backstab for additional style (although doing so is very tricky due to speed/range) Crusher marks are now a STATUS_EFFECT_REFRESH effect and no longer per-user. This means that anyone can blow up anyone else's mark and applying new ones refreshes the timer. Trophy effects of the person who detonated the mark are the ones actually applied. also cleaned up pixel_move a bit ## Why It's Good For The Game Parrying refactor - parries are a very cool mechanic which is almost impossible to execute in-game (and boosting is physically impossible) and even if "fixed" would require perfect server performance and single digit ping. Making them slightly easier to execute and adding a grace period will allow more players to utilize it and also make it possible to do parrying/boosting on highpop. Boosting damage/speed buff - Boosting is harder to perform, and while with parrying damage/speed is a nice bonus to the fact that your face doesn't explode outwards from a death bolt, for boosting its the only reason why you'd do it (beyond style points) Crusher boosting - Crushers are more often used by skilled miners as they are a high risk/high reward weapon. Them not being boostable is rather disappointing as boosting is supposed to be a thing for extremely skilled miners to do, essentially turning crushers into deadweight for those who wanted to use style meters. Unified crusher marks - Mobs being able to have multiple crusher marks made fighting very confusing for rare coop crusher miners, as you weren't able to tell if you could detonate the mark or not. This should make coop fighting more viable as marks can now be comboed if you have good cooperation with your teammate. ## Changelog 🆑 refactor: Refactored parrying to be projectile-side and not user-side. add: You can now parry crusher projectiles to give them some more range, add damage and make the mark always count as a backstab. add: Projectile parrying has been significantly improved, making parrying and boosting projectiles actually possible. Includes a small grace period as lag compensation for players with higher pings. balance: Crusher marks can now be detonated by any crusher, not only the one that applied it, as to incentivise coop mining for crusher users. balance: Projectile boosting now gives a significantly bigger damage and speed increase /🆑
122 lines
5.2 KiB
Plaintext
122 lines
5.2 KiB
Plaintext
/// Add to a projectile to allow it to be parried by mobs with a certain trait (TRAIT_MINING_PARRYING by default)
|
|
/datum/component/parriable_projectile
|
|
/// List of all turfs the projectile passed on its last loop and we assigned comsigs to
|
|
var/list/turf/parry_turfs = list()
|
|
/// List of all mobs who have clicked on a parry turf in last moveloop
|
|
var/list/mob/parriers = list()
|
|
/// When the projectile was created
|
|
var/fire_time = 0
|
|
/// If this projectile has been parried
|
|
var/parried = FALSE
|
|
/// How much this projectile is sped up when parried
|
|
var/parry_speed_mult
|
|
/// How much this projectile's damage is increased when parried
|
|
var/parry_damage_mult
|
|
/// How much this projectile is sped up when boosted (parried by owner)
|
|
var/boost_speed_mult
|
|
/// How much this projectile's damage is increased when boosted (parried by owner)
|
|
var/boost_damage_mult
|
|
/// Trait required to be able to parry this projectile
|
|
var/parry_trait
|
|
/// For how long do valid tiles persist? Acts as clientside lag compensation
|
|
var/grace_period
|
|
/// Callback for special effects upon parrying
|
|
var/datum/callback/parry_callback
|
|
|
|
/datum/component/parriable_projectile/Initialize(parry_speed_mult = 0.8, parry_damage_mult = 1.15, boost_speed_mult = 0.6, boost_damage_mult = 1.5, parry_trait = TRAIT_MINING_PARRYING, grace_period = 0.25 SECONDS, datum/callback/parry_callback = null)
|
|
if(!isprojectile(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
src.parry_speed_mult = parry_speed_mult
|
|
src.parry_damage_mult = parry_damage_mult
|
|
src.boost_speed_mult = boost_speed_mult
|
|
src.boost_damage_mult = boost_damage_mult
|
|
src.parry_trait = parry_trait
|
|
src.grace_period = grace_period
|
|
src.parry_callback = parry_callback
|
|
fire_time = world.time
|
|
|
|
/datum/component/parriable_projectile/Destroy(force)
|
|
for (var/turf/parry_turf as anything in parry_turfs)
|
|
UnregisterSignal(parry_turf, COMSIG_CLICK)
|
|
. = ..()
|
|
|
|
/datum/component/parriable_projectile/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_PROJECTILE_PIXEL_STEP, PROC_REF(on_moved))
|
|
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(before_move))
|
|
RegisterSignal(parent, COMSIG_PROJECTILE_BEFORE_MOVE, PROC_REF(before_move))
|
|
RegisterSignal(parent, COMSIG_PROJECTILE_SELF_PREHIT, PROC_REF(before_hit))
|
|
|
|
/datum/component/parriable_projectile/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_PROJECTILE_PIXEL_STEP, COMSIG_MOVABLE_MOVED, COMSIG_PROJECTILE_BEFORE_MOVE, COMSIG_PROJECTILE_SELF_PREHIT))
|
|
|
|
/datum/component/parriable_projectile/proc/before_move(obj/projectile/source)
|
|
SIGNAL_HANDLER
|
|
|
|
var/list/turfs_to_remove = list()
|
|
for (var/turf/parry_turf as anything in parry_turfs)
|
|
if (parry_turfs[parry_turf] < world.time)
|
|
turfs_to_remove += parry_turf
|
|
|
|
for (var/turf/parry_turf as anything in turfs_to_remove)
|
|
parry_turfs -= parry_turf
|
|
UnregisterSignal(parry_turf, COMSIG_CLICK)
|
|
|
|
var/list/parriers_to_remove = list()
|
|
for (var/mob/parrier as anything in parriers)
|
|
if (parriers[parrier] < world.time)
|
|
parriers_to_remove += parrier
|
|
|
|
for (var/mob/parrier as anything in parriers_to_remove)
|
|
parriers_to_remove -= parrier
|
|
|
|
/datum/component/parriable_projectile/proc/on_moved(obj/projectile/source)
|
|
SIGNAL_HANDLER
|
|
if (!isturf(source.loc))
|
|
return
|
|
parry_turfs[source.loc] = world.time + grace_period
|
|
RegisterSignal(source.loc, COMSIG_CLICK, PROC_REF(on_turf_click))
|
|
|
|
/datum/component/parriable_projectile/proc/on_turf_click(turf/source, atom/location, control, list/params, mob/user)
|
|
SIGNAL_HANDLER
|
|
if (!HAS_TRAIT(user, parry_trait))
|
|
return
|
|
var/obj/projectile/proj_parent = parent
|
|
if (proj_parent.firer == user && (fire_time + grace_period > world.time) && !parried)
|
|
attempt_parry(proj_parent, user)
|
|
return
|
|
parriers[user] = world.time + grace_period
|
|
|
|
/datum/component/parriable_projectile/proc/before_hit(obj/projectile/source, list/bullet_args)
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/user = bullet_args[2]
|
|
if (!istype(user) || !parriers[user] || parried)
|
|
return
|
|
parriers -= user
|
|
attempt_parry(source, user)
|
|
|
|
/datum/component/parriable_projectile/proc/attempt_parry(obj/projectile/source, mob/user)
|
|
if (SEND_SIGNAL(user, COMSIG_LIVING_PROJECTILE_PARRIED, source) & INTERCEPT_PARRY_EFFECTS)
|
|
return
|
|
|
|
parried = TRUE
|
|
if (source.firer != user)
|
|
if (abs(source.Angle - dir2angle(user)) < 15)
|
|
source.set_angle((source.Angle + 180) % 360 + rand(-3, 3))
|
|
else
|
|
source.set_angle(dir2angle(user) + rand(-3, 3))
|
|
user.visible_message(span_warning("[user] expertly parries [source] with [user.p_their()] bare hand!"), span_warning("You parry [source] with your hand!"))
|
|
else
|
|
user.visible_message(span_warning("[user] boosts [source] with [user.p_their()] bare hand!"), span_warning("You boost [source] with your hand!"))
|
|
source.firer = user
|
|
source.speed *= (source.firer == user) ? boost_speed_mult : parry_speed_mult
|
|
source.damage *= (source.firer == user) ? boost_damage_mult : parry_damage_mult
|
|
source.add_atom_colour(COLOR_RED_LIGHT, TEMPORARY_COLOUR_PRIORITY)
|
|
if (!isnull(parry_callback))
|
|
parry_callback.Invoke(user)
|
|
|
|
user.playsound_local(source.loc, 'sound/effects/parry.ogg', 50, TRUE)
|
|
user.overlay_fullscreen("projectile_parry", /atom/movable/screen/fullscreen/crit/projectile_parry, 2)
|
|
addtimer(CALLBACK(user, TYPE_PROC_REF(/mob, clear_fullscreen), "projectile_parry"), 0.25 SECONDS)
|
|
return PROJECTILE_INTERRUPT_HIT
|