Speed potion improvements (#87322)

## About The Pull Request
I've added a trait for when a speed potion is applied to the object.
This allows me to remove some args and variables from riding and
ridable, and allow fish past 2000 units of weight to have speed potions
applied to them without the risk of the slowdown being reset the next
time `update_size_and_weight()` is called.

Speed potions now also affect drag slowdown.

## Why It's Good For The Game
Small code improvement, leading to a possible balance change.
This fixes #38623.

## Changelog


🆑
balance: Speed potions now cancel drag slowdown too.
balance: Speed potions can be used on fish past 2000 units of weight.
fix: You can now speed up cardboard boxes with speed potions.
/🆑
This commit is contained in:
Ghom
2024-10-21 16:46:50 +03:00
committed by GitHub
parent f0c651da7b
commit 86aee083e3
11 changed files with 40 additions and 29 deletions
+2
View File
@@ -704,6 +704,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_DISABLED_BY_WOUND "disabled-by-wound"
/// This movable atom has the explosive block element
#define TRAIT_BLOCKING_EXPLOSIVES "blocking_explosives"
/// This object has been slathered with a speed potion
#define TRAIT_SPEED_POTIONED "speed_potioned"
///This mob is currently blocking a projectile.
#define TRAIT_BLOCKING_PROJECTILES "blocking_projectiles"
+1
View File
@@ -11,6 +11,7 @@
#define MAGIC_TRAIT "magic"
#define TRAUMA_TRAIT "trauma"
#define FLIGHTPOTION_TRAIT "flightpotion"
#define SLIME_POTION_TRAIT "slime_potion"
/// Trait inherited by experimental surgeries
#define EXPERIMENTAL_SURGERY_TRAIT "experimental_surgery"
#define DISEASE_TRAIT "disease"
+2 -1
View File
@@ -122,8 +122,9 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_WOUND_SCANNED" = TRAIT_WOUND_SCANNED,
),
/obj = list(
"TRAIT_WALLMOUNTED" = TRAIT_WALLMOUNTED,
"TRAIT_CONTRABAND" = TRAIT_CONTRABAND,
"TRAIT_SPEED_POTIONED" = TRAIT_SPEED_POTIONED,
"TRAIT_WALLMOUNTED" = TRAIT_WALLMOUNTED,
),
/mob = list(
"TRAIT_AI_ACCESS" = TRAIT_AI_ACCESS,
+4
View File
@@ -24,6 +24,10 @@ GLOBAL_LIST_INIT(admin_visible_traits, list(
"TRAIT_WEATHER_IMMUNE" = TRAIT_WEATHER_IMMUNE,
"TRAIT_SILENT_REACTIONS" = TRAIT_SILENT_REACTIONS,
),
/obj = list(
"TRAIT_CONTRABAND" = TRAIT_CONTRABAND,
"TRAIT_SPEED_POTIONED" = TRAIT_SPEED_POTIONED,
),
/mob = list(
"TRAIT_ABDUCTOR_SCIENTIST_TRAINING" = TRAIT_ABDUCTOR_SCIENTIST_TRAINING,
"TRAIT_ABDUCTOR_TRAINING" = TRAIT_ABDUCTOR_TRAINING,
+2 -2
View File
@@ -47,7 +47,7 @@
COOLDOWN_DECLARE(vehicle_move_cooldown)
/datum/component/riding/Initialize(mob/living/riding_mob, force = FALSE, buckle_mob_flags= NONE, potion_boost = FALSE)
/datum/component/riding/Initialize(mob/living/riding_mob, force = FALSE, buckle_mob_flags= NONE)
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
@@ -55,7 +55,7 @@
riding_mob.updating_glide_size = FALSE
ride_check_flags |= buckle_mob_flags
if(potion_boost)
if(HAS_TRAIT(parent, TRAIT_SPEED_POTIONED))
vehicle_move_delay = round(CONFIG_GET(number/movedelay/run_delay) * 0.85, 0.01)
/datum/component/riding/RegisterWithParent()
+5 -5
View File
@@ -12,7 +12,7 @@
/// abilities that are always blacklisted from sharing
var/list/blacklist_abilities = list()
/datum/component/riding/creature/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE, potion_boost = FALSE)
/datum/component/riding/creature/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
@@ -205,7 +205,7 @@
/datum/component/riding/creature/human
can_be_driven = FALSE
/datum/component/riding/creature/human/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE, potion_boost = FALSE)
/datum/component/riding/creature/human/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE)
. = ..()
var/mob/living/carbon/human/human_parent = parent
human_parent.add_movespeed_modifier(/datum/movespeed_modifier/human_carry)
@@ -446,7 +446,7 @@
/datum/component/riding/creature/goliath/deathmatch
keytype = null
/datum/component/riding/creature/goliath/Initialize(mob/living/riding_mob, force, ride_check_flags, potion_boost)
/datum/component/riding/creature/goliath/Initialize(mob/living/riding_mob, force, ride_check_flags)
. = ..()
var/mob/living/basic/mining/goliath/goliath = parent
goliath.add_movespeed_modifier(/datum/movespeed_modifier/goliath_mount)
@@ -514,7 +514,7 @@
. = ..()
set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(17, 46), TEXT_SOUTH = list(17,51), TEXT_EAST = list(27, 46), TEXT_WEST = list(6, 46)))
/datum/component/riding/creature/leaper/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE, potion_boost = FALSE)
/datum/component/riding/creature/leaper/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE)
. = ..()
RegisterSignal(riding_mob, COMSIG_MOVABLE_POINTED, PROC_REF(attack_pointed))
@@ -536,7 +536,7 @@
require_minigame = TRUE
ride_check_flags = RIDER_NEEDS_ARM | UNBUCKLE_DISABLED_RIDER
/datum/component/riding/creature/raptor/Initialize(mob/living/riding_mob, force, ride_check_flags, potion_boost)
/datum/component/riding/creature/raptor/Initialize(mob/living/riding_mob, force, ride_check_flags)
. = ..()
RegisterSignal(parent, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_bullet_hit))
RegisterSignal(parent, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_attacked))
@@ -1,6 +1,6 @@
// For any /obj/vehicle's that can be ridden
/datum/component/riding/vehicle/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = (RIDER_NEEDS_LEGS | RIDER_NEEDS_ARMS), potion_boost = FALSE)
/datum/component/riding/vehicle/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = (RIDER_NEEDS_LEGS | RIDER_NEEDS_ARMS))
if(!isvehicle(parent))
return COMPONENT_INCOMPATIBLE
return ..()
+6 -16
View File
@@ -12,10 +12,8 @@
/// The specific riding component subtype we're loading our instructions from, don't leave this as default please!
var/riding_component_type = /datum/component/riding
/// If we have a xenobio red potion applied to us, we get split off so we can pass our special status onto new riding components
var/potion_boosted = FALSE
/datum/element/ridable/Attach(atom/movable/target, component_type = /datum/component/riding, potion_boost = FALSE)
/datum/element/ridable/Attach(atom/movable/target, component_type = /datum/component/riding)
. = ..()
if(!ismovable(target))
return COMPONENT_INCOMPATIBLE
@@ -26,7 +24,6 @@
target.can_buckle = TRUE
riding_component_type = component_type
potion_boosted = potion_boost
RegisterSignal(target, COMSIG_MOVABLE_PREBUCKLE, PROC_REF(check_mounting))
if(isvehicle(target))
@@ -75,7 +72,7 @@
span_warning("You can't get a grip on [potential_rider] because your hands are full!"))
return COMPONENT_BLOCK_BUCKLE
target_living.AddComponent(riding_component_type, potential_rider, force, ride_check_flags, potion_boost = potion_boosted)
target_living.AddComponent(riding_component_type, potential_rider, force, ride_check_flags)
/// Try putting the appropriate number of [riding offhand items][/obj/item/riding_offhand] into the target's hands, return FALSE if we can't
/datum/element/ridable/proc/equip_buckle_inhands(mob/living/carbon/human/user, amount_required = 1, atom/movable/target_movable, riding_target_override = null)
@@ -117,25 +114,18 @@
/datum/element/ridable/proc/check_potion(atom/movable/ridable_atom, obj/item/slimepotion/speed/speed_potion, mob/living/user)
SIGNAL_HANDLER
if(potion_boosted)
if(HAS_TRAIT(ridable_atom, TRAIT_SPEED_POTIONED))
to_chat(user, span_warning("[ridable_atom] has already been coated with red, that's as fast as it'll go!"))
return
return SPEED_POTION_STOP
if(ridable_atom.has_buckled_mobs()) // effect won't take place til the next time someone mounts it, so just prevent that situation
to_chat(user, span_warning("It's too dangerous to smear [speed_potion] on [ridable_atom] while it's being ridden!"))
return
return SPEED_POTION_STOP
var/speed_limit = round(CONFIG_GET(number/movedelay/run_delay) * 0.85, 0.01)
var/datum/component/riding/theoretical_riding_component = riding_component_type
var/theoretical_speed = initial(theoretical_riding_component.vehicle_move_delay)
if(theoretical_speed <= speed_limit) // i say speed but this is actually move delay, so you have to be ABOVE the speed limit to pass
to_chat(user, span_warning("[ridable_atom] can't be made any faster!"))
return
Detach(ridable_atom)
ridable_atom.AddElement(/datum/element/ridable, component_type = riding_component_type, potion_boost = TRUE)
to_chat(user, span_notice("You slather the red gunk over [ridable_atom], making it faster."))
ridable_atom.remove_atom_colour(WASHABLE_COLOUR_PRIORITY)
ridable_atom.add_atom_colour(COLOR_RED, FIXED_COLOUR_PRIORITY)
qdel(speed_potion)
return SPEED_POTION_STOP
return SPEED_POTION_STOP
/// Remove all of the relevant [riding offhand items][/obj/item/riding_offhand] from the target
/datum/element/ridable/proc/unequip_buckle_inhands(mob/living/carbon/user, atom/movable/target_movable)
@@ -31,6 +31,14 @@
/// If the speed multiplier should be applied to mobs inside this box
var/move_delay = FALSE
/obj/structure/closet/cardboard/Initialize(mapload)
. = ..()
RegisterSignal(src, COMSIG_SPEED_POTION_APPLIED, PROC_REF(on_speed_potioned))
/obj/structure/closet/cardboard/proc/on_speed_potioned(datum/source)
SIGNAL_HANDLER
move_speed_multiplier *= 2
/obj/structure/closet/cardboard/relaymove(mob/living/user, direction)
if(opened || move_delay || user.incapacitated || !isturf(loc) || !has_gravity(loc))
return
+2 -2
View File
@@ -20,7 +20,7 @@
pickup_sound = SFX_FISH_PICKUP
sound_vary = TRUE
obj_flags = UNIQUE_RENAME
item_flags = IMMUTABLE_SLOW|SLOWS_WHILE_IN_HAND
item_flags = SLOWS_WHILE_IN_HAND
/// Flags for fish variables that would otherwise be TRUE/FALSE
var/fish_flags = FISH_FLAG_SHOW_IN_CATALOG|FISH_DO_FLOP_ANIM|FISH_FLAG_EXPERIMENT_SCANNABLE
@@ -520,7 +520,7 @@
if(make_edible)
make_edible()
if(weight >= FISH_WEIGHT_SLOWDOWN)
if(weight >= FISH_WEIGHT_SLOWDOWN && !HAS_TRAIT(src, TRAIT_SPEED_POTIONED))
slowdown = round(((weight/FISH_WEIGHT_SLOWDOWN_DIVISOR)**FISH_WEIGHT_SLOWDOWN_EXPONENT)-1.3, 0.1)
drag_slowdown = round(slowdown * 0.5, 1)
else
@@ -898,13 +898,16 @@
icon = 'icons/obj/medical/chemical.dmi'
icon_state = "potyellow"
/obj/item/slimepotion/speed/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
/obj/item/slimepotion/speed/interact_with_atom(obj/interacting_with, mob/living/user, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
if(!isobj(interacting_with))
to_chat(user, span_warning("The potion can only be used on objects!"))
return ITEM_INTERACT_BLOCKING
if(HAS_TRAIT(interacting_with, TRAIT_SPEED_POTIONED))
to_chat(user, span_warning("[interacting_with] can't be made any faster!"))
return ITEM_INTERACT_BLOCKING
if(SEND_SIGNAL(interacting_with, COMSIG_SPEED_POTION_APPLIED, src, user) & SPEED_POTION_STOP)
return ITEM_INTERACT_SUCCESS
if(isitem(interacting_with))
@@ -912,13 +915,15 @@
if(apply_to.slowdown <= 0 || (apply_to.item_flags & IMMUTABLE_SLOW))
if(interacting_with.atom_storage)
return NONE // lets us put the potion in the bag
to_chat(user, span_warning("The [apply_to] can't be made any faster!"))
to_chat(user, span_warning("[apply_to] can't be made any faster!"))
return ITEM_INTERACT_BLOCKING
apply_to.slowdown = 0
to_chat(user, span_notice("You slather the red gunk over the [interacting_with], making it faster."))
interacting_with.remove_atom_colour(WASHABLE_COLOUR_PRIORITY)
interacting_with.add_atom_colour(COLOR_RED, FIXED_COLOUR_PRIORITY)
interacting_with.drag_slowdown = 0
ADD_TRAIT(interacting_with, TRAIT_SPEED_POTIONED, SLIME_POTION_TRAIT)
qdel(src)
return ITEM_INTERACT_SUCCESS