From 4bcfffe44b28417da2a622eee1971dc209dae48b Mon Sep 17 00:00:00 2001 From: Cameron Lennox Date: Thu, 15 May 2025 04:09:02 -0400 Subject: [PATCH] Waddle / Animated Movement component (#17675) * Adds waddle component * waddle * moved to tgui and spans * Update waddle.dm * proc name * Waddling toggle trait! --------- Co-authored-by: ShadowLarkens --- code/datums/components/traits/waddle.dm | 104 ++++++++++++++++++ .../human/species/station/traits/neutral.dm | 15 +++ .../human/species/station/traits/trait.dm | 2 - vorestation.dme | 1 + 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 code/datums/components/traits/waddle.dm diff --git a/code/datums/components/traits/waddle.dm b/code/datums/components/traits/waddle.dm new file mode 100644 index 0000000000..75a5a1627c --- /dev/null +++ b/code/datums/components/traits/waddle.dm @@ -0,0 +1,104 @@ +/datum/component/waddle_trait + var/atom/movable/our_atom + var/mob/living/living_owner + + var/waddling = 1 + var/waddle_z = 4 + var/waddle_min = -12 + var/waddle_max = 12 + var/waddle_time = 2 + + +/datum/component/waddle_trait/Initialize() + if (!isobj(parent) && !ismob(parent)) + return COMPONENT_INCOMPATIBLE + if(isliving(parent)) + living_owner = parent + add_verb(living_owner, /mob/living/proc/waddle_adjust) + //add_verb(living_owner, /mob/living/proc/waddle_debug) + our_atom = parent + RegisterSignal(our_atom, COMSIG_MOVABLE_MOVED, PROC_REF(handle_comp)) + +/datum/component/waddle_trait/proc/handle_comp() + if (QDELETED(our_atom)) + return + //Living owner only. No waddling while downed. + if(living_owner) + if(living_owner.stat != CONSCIOUS || living_owner.resting) + return + if(waddling) + waddle_waddle(our_atom) + +/datum/component/waddle_trait/Destroy(force = FALSE) + UnregisterSignal(our_atom, COMSIG_MOVABLE_MOVED) + if(living_owner) + remove_verb(living_owner, /mob/living/proc/waddle_adjust) + //remove_verb(living_owner, /mob/living/proc/waddle_debug) + living_owner = null + our_atom = null + . = ..() + +/mob/living/verb/toggle_waddle() + set name = "Toggle Waddling" + set desc = "Allows you to toggle if you want to walk with a waddle or not!" + set category = "Preferences.Character" + var/datum/component/waddle_trait/comp = LoadComponent(/datum/component/waddle_trait) + if(comp) + comp.waddling = !comp.waddling + to_chat(src, span_warning("You will [ (comp.waddling) ? "now" : "no longer"] waddle.")) + +/mob/living/proc/waddle_debug() //Debug tool to debug waddling. + set name = "WADDLE DEBUG" + set desc = "Allows you to debug waddling!!" + set category = "Preferences.Character" + var/datum/component/waddle_trait/comp = GetComponent(/datum/component/waddle_trait) + if(comp) + var/Z = tgui_input_number(src,, "Desired Z.", "Set Z", 0.5) + comp.waddle_z = Z + var/min = tgui_input_number(src, "Desired min.", "Set min", -4) + comp.waddle_min = min + var/max = tgui_input_number(src, "Desired max.", "Set max", 4) + comp.waddle_max = max + var/time = tgui_input_number(src, "Desired time.", "Set time", 2) + comp.waddle_time = time + to_chat(src, "z = [Z] min = [min] max = [max] time = [time]") + +/mob/living/proc/waddle_adjust() + set name = "Waddle Adjust" + set desc = "Allows you to adjust your waddling." + set category = "Preferences.Character" + var/datum/component/waddle_trait/comp = GetComponent(/datum/component/waddle_trait) + if(comp) + var/Z_height = tgui_input_number(src, "Put the desired waddle height. (0.5 is default. 0 min 4 max)", "Set Height", 0.5, 4, 0) + if(Z_height > 4 || Z_height < 0 ) + to_chat(src, span_notice("Invalid height!")) + return + comp.waddle_z = Z_height + + var/min = tgui_input_number(src, "Put the desired waddle backwards lean. (4 is default. 0 min, 12 max)", "Set Back Lean", 4, 12, 0) + if(min > 12 || min < 0 ) + to_chat(src, span_notice("Invalid number!")) + return + comp.waddle_min = -min + + var/max = tgui_input_number(src, "Put the desired waddle forwards lean. (4 is default. 0 min, 12 max)", "Set Forwards Lean", 4, 12, 0) + if(max > 12 || max < 0 ) + to_chat(src, span_notice("Invalid number!")) + return + comp.waddle_max = max + + var/time = tgui_input_number(src, "Put the desired waddle animation time. (2 is default. 1 min, 2 max)", "Set Time", 2, 2, 1) + if(time > 2 || time < 1 ) + to_chat(src, span_notice("Invalid number!")) + return + comp.waddle_time = time + to_chat(src, span_notice("You have set your waddle height to [comp.waddle_z], your back lean to [comp.waddle_min], your forward lean to [comp.waddle_max] and your waddle time to [comp.waddle_time]! You will now waddle!")) + comp.waddling = 1 //Activate it! + +/datum/component/waddle_trait/proc/waddle_waddle(atom/movable/target) + var/prev_pixel_z = our_atom.pixel_z + + animate(target, pixel_z = target.pixel_z + waddle_z, time = 0) + var/prev_transform = target.transform //The person's default state. + animate(pixel_z = prev_pixel_z, transform = turn(target.transform, pick(waddle_min, 0, waddle_max)), time=waddle_time) + animate(transform = prev_transform, time = 0) diff --git a/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm b/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm index 43fdd2a0a8..85c12622f9 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits/neutral.dm @@ -1677,3 +1677,18 @@ /datum/trait/neutral/autohiss_tajaran/xenochimera, /datum/trait/neutral/autohiss_zaddat/xenochimera, /datum/trait/neutral/autohiss_vassilian/xenochimera) + +/datum/trait/neutral/waddle + name = "Waddle / Animated Movement (Adjustable)" + desc = "You move with a waddle or otherwise animated movement! Has adjustable settings with more adjustments able to be made in game!" + cost = 0 + custom_only = FALSE + is_genetrait = TRUE + hidden = FALSE + has_preferences = list("waddler" = list(TRAIT_PREF_TYPE_BOOLEAN, "Waddle on Spawn", TRAIT_NO_VAREDIT_TARGET, TRUE)) + added_component_path = /datum/component/waddle_trait + +/datum/trait/neutral/waddle/apply(var/datum/species/S,var/mob/living/carbon/human/H, var/list/trait_prefs) + ..() + var/datum/component/waddle_trait/G = H.GetComponent(added_component_path) + G.waddling = trait_prefs["waddler"] diff --git a/code/modules/mob/living/carbon/human/species/station/traits/trait.dm b/code/modules/mob/living/carbon/human/species/station/traits/trait.dm index 319ba9b420..eb01f35631 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits/trait.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits/trait.dm @@ -19,8 +19,6 @@ var/added_component_path //What component this trait applies, if any. - - // Traitgenes Traits can toggle mutations and disabilities /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/vorestation.dme b/vorestation.dme index 010f7f1855..2ea08621de 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -515,6 +515,7 @@ #include "code\datums\components\disabilities\tourettes.dm" #include "code\datums\components\traits\drippy.dm" #include "code\datums\components\traits\gargoyle.dm" +#include "code\datums\components\traits\waddle.dm" #include "code\datums\components\traits\weaver.dm" #include "code\datums\components\species\shadekin.dm" #include "code\datums\components\species\xenochimera.dm"