Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert committed Aug 11, 2024
1 parent 3d0843b commit 7009e2b
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 9 deletions.
19 changes: 15 additions & 4 deletions code/game/turfs/closed/walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
return
leaner.start_leaning(src)

// NON-MODULE CHANGE START
/mob/living/proc/start_leaning(turf/closed/wall/wall)
var/new_y = base_pixel_y + pixel_y
var/new_x = base_pixel_x + pixel_x
Expand All @@ -65,7 +66,7 @@
new_x -= LEANING_OFFSET

animate(src, 0.2 SECONDS, pixel_x = new_x, pixel_y = new_y)
add_traits(list(TRAIT_UNDENSE, TRAIT_EXPANDED_FOV), LEANING_TRAIT)
add_traits(list(TRAIT_UNDENSE, TRAIT_EXPANDED_FOV, TRAIT_NO_LEG_AID), LEANING_TRAIT)
visible_message(
span_notice("[src] leans against [wall]."),
span_notice("You lean against [wall]."),
Expand All @@ -75,9 +76,16 @@
COMSIG_LIVING_DISARM_HIT,
COMSIG_LIVING_GET_PULLED,
COMSIG_MOVABLE_TELEPORTING,
COMSIG_ATOM_DIR_CHANGE,
COMSIG_LIVING_RESIST,
), PROC_REF(stop_leaning))
RegisterSignal(src, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(stop_leaning_dir))
update_fov()
update_limbless_locomotion()

/mob/living/proc/stop_leaning_dir(datum/source, old_dir, new_dir)
SIGNAL_HANDLER
if(new_dir != old_dir)
stop_leaning()

/mob/living/proc/stop_leaning()
SIGNAL_HANDLER
Expand All @@ -86,11 +94,14 @@
COMSIG_LIVING_DISARM_HIT,
COMSIG_LIVING_GET_PULLED,
COMSIG_MOVABLE_TELEPORTING,
COMSIG_ATOM_DIR_CHANGE,
COMSIG_ATOM_POST_DIR_CHANGE,
COMSIG_LIVING_RESIST,
))
animate(src, 0.2 SECONDS, pixel_x = base_pixel_x, pixel_y = base_pixel_y)
remove_traits(list(TRAIT_UNDENSE, TRAIT_EXPANDED_FOV), LEANING_TRAIT)
remove_traits(list(TRAIT_UNDENSE, TRAIT_EXPANDED_FOV, TRAIT_NO_LEG_AID), LEANING_TRAIT)
update_fov()
update_limbless_locomotion()
// NON-MODULE CHANGE END

/turf/closed/wall/Initialize(mapload)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6258,6 +6258,7 @@
#include "maplestation_modules\code\modules\client\preferences\loadout_preference.dm"
#include "maplestation_modules\code\modules\client\preferences\multiline_preferences.dm"
#include "maplestation_modules\code\modules\client\preferences\name_preferences.dm"
#include "maplestation_modules\code\modules\client\preferences\paraplegic_aid.dm"
#include "maplestation_modules\code\modules\client\preferences\ready_anominity.dm"
#include "maplestation_modules\code\modules\client\preferences\runechat_color.dm"
#include "maplestation_modules\code\modules\client\preferences\sound_frequency.dm"
Expand Down
62 changes: 57 additions & 5 deletions maplestation_modules/code/datums/components/limbless_aid.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// Attach to items that help mobs missing limbs move faster when held.
/datum/component/limbless_aid
/// What slot flags must the parent item have to provide the bonus?
var/required_slot = ITEM_SLOT_HANDS
var/required_slot
/// How much should the movespeed be modified?
var/movespeed_mod = 0.5
var/movespeed_mod

/datum/component/limbless_aid/Initialize(required_slot = ITEM_SLOT_HANDS, movespeed_mod = 0.5)
if(!isitem(parent))
Expand All @@ -15,37 +15,55 @@
/datum/component/limbless_aid/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(on_drop))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(examined))

var/obj/item/item_parent = parent
if(isliving(item_parent.loc))
var/mob/living/wearer = item_parent.loc
on_equip(parent, wearer, wearer.get_slot_by_item(parent))

/datum/component/limbless_aid/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED, COMSIG_ATOM_EXAMINE))

var/obj/item/item_parent = parent
if(isliving(item_parent.loc))
on_drop(item_parent, item_parent.loc)

/datum/component/limbless_aid/proc/examined(obj/item/source, mob/living/user, list/examine_list)
SIGNAL_HANDLER

examine_list += span_info("It will support your weight, allowing you to move faster with a wounded, disabled, or missing leg.")
examine_list += span_info("Holding <b>two</b> will allow you to <b>walk</b> despite having two missing or disabled legs.")
examine_list += span_info("<b>Resisting</b> will brace you, allowing you to <b>stand</b> on one support, \
despite having two missing or disabled legs. Moving will cancel this effect.")

/datum/component/limbless_aid/proc/on_equip(obj/item/source, mob/living/user, slot)
SIGNAL_HANDLER

if(!(slot & required_slot))
return

ADD_TRAIT(user, TRAIT_NO_LEG_AID, REF(src))
add_support(user)

/datum/component/limbless_aid/proc/add_support(mob/living/user)
ADD_TRAIT(user, TRAIT_NO_LEG_AID, "[REF(src)]_aid")
RegisterSignal(user, COMSIG_LIVING_LIMBLESS_MOVESPEED_UPDATE, PROC_REF(modify_movespeed), override = TRUE)
RegisterSignal(user, COMSIG_CARBON_LIMPING, PROC_REF(limp_check), override = TRUE)
RegisterSignal(user, COMSIG_LIVING_RESIST, PROC_REF(self_brace), override = TRUE)
user.update_limbless_locomotion()
user.update_limbless_movespeed_mod()

/datum/component/limbless_aid/proc/on_drop(obj/item/source, mob/living/user)
SIGNAL_HANDLER

REMOVE_TRAIT(user, TRAIT_NO_LEG_AID, REF(src))
lose_support(user)

/datum/component/limbless_aid/proc/lose_support(mob/living/user)
REMOVE_TRAIT(user, TRAIT_NO_LEG_AID, "[REF(src)]_aid")
un_self_brace(user)
UnregisterSignal(user, COMSIG_LIVING_LIMBLESS_MOVESPEED_UPDATE)
UnregisterSignal(user, COMSIG_CARBON_LIMPING)
UnregisterSignal(user, COMSIG_LIVING_RESIST)
user.update_limbless_locomotion()
user.update_limbless_movespeed_mod()

Expand Down Expand Up @@ -76,3 +94,37 @@
return null // unimplemented

#undef IS_RIGHT_ARM

/datum/component/limbless_aid/proc/self_brace(mob/living/source)
SIGNAL_HANDLER

INVOKE_ASYNC(src, PROC_REF(self_brace_async), source)

/datum/component/limbless_aid/proc/un_self_brace(mob/living/source)
REMOVE_TRAIT(source, TRAIT_NO_LEG_AID, "[REF(src)]_brace")
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)

/datum/component/limbless_aid/proc/self_brace_async(mob/living/source)
if((required_slot & ITEM_SLOT_HANDS) && parent != source.get_active_held_item())
return
if(HAS_TRAIT_FROM(source, TRAIT_NO_LEG_AID, "[REF(src)]_brace"))
return
if(DOING_INTERACTION_WITH_TARGET(source, source))
return
// lying down is a lot harder to get up from
if(!do_after(source, (source.body_position == LYING_DOWN ? 2.4 SECONDS : 0.8 SECONDS), source))
return

source.balloon_alert(source, "braced")
ADD_TRAIT(source, TRAIT_NO_LEG_AID, "[REF(src)]_brace")
RegisterSignal(source, COMSIG_MOVABLE_MOVED, PROC_REF(brace_moved))
source.update_limbless_locomotion()

/datum/component/limbless_aid/proc/brace_moved(mob/living/source, atom/old_loc)
SIGNAL_HANDLER

if(source.loc == old_loc)
return

un_self_brace(source)
source.update_limbless_locomotion()
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#define WHEELCHAIR_PREFERENCE "Wheelchair"
#define CRUTCHES_MED_PREFERENCE "Crutches (Medical)"
#define CRUTCHES_WOOD_PREFERENCE "Crutches (Wooden)"
#define NONE_PREFERENCE "None"

/// Preference for paraplegics to choose how they get around.
/datum/preference/choiced/paraplegic_aid
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "paraplegic_aid"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
should_generate_icons = TRUE

/datum/preference/choiced/paraplegic_aid/create_default_value()
return WHEELCHAIR_PREFERENCE

/datum/preference/choiced/paraplegic_aid/init_possible_values()
return list(WHEELCHAIR_PREFERENCE, CRUTCHES_MED_PREFERENCE, CRUTCHES_WOOD_PREFERENCE, NONE_PREFERENCE)

/datum/preference/choiced/paraplegic_aid/icon_for(value)
switch(value)
if(WHEELCHAIR_PREFERENCE)
return icon(/obj/item/wheelchair::icon, /obj/item/wheelchair::icon_state)
if(CRUTCHES_MED_PREFERENCE)
return icon(/obj/item/cane/crutch::icon, /obj/item/cane/crutch::icon_state)
if(CRUTCHES_WOOD_PREFERENCE)
return icon(/obj/item/cane/crutch/wood::icon, /obj/item/cane/crutch/wood::icon_state)
if(NONE_PREFERENCE)
return icon('icons/hud/screen_gen.dmi', "x")

return icon('icons/effects/random_spawners.dmi', "questionmark")

/datum/preference/choiced/paraplegic_aid/is_accessible(datum/preferences/preferences)
if(!..(preferences))
return FALSE

return /datum/quirk/paraplegic::name in preferences.all_quirks

/datum/preference/choiced/paraplegic_aid/apply_to_human(mob/living/carbon/human/target, value)
return

/datum/quirk_constant_data/paraplegic
associated_typepath = /datum/quirk/paraplegic
customization_options = list(/datum/preference/choiced/paraplegic_aid)

// Overrides paraplegic normal add unique to do our own thing
/datum/quirk/paraplegic/add_unique(client/client_source)

var/wheelchair_type = client_source?.prefs?.read_preference(/datum/preference/choiced/paraplegic_aid) || NONE_PREFERENCE

switch(wheelchair_type)
if(WHEELCHAIR_PREFERENCE)
// Handle late joins being buckled to arrival shuttle chairs.
quirk_holder.buckled?.unbuckle_mob(quirk_holder)

var/turf/holder_turf = get_turf(quirk_holder)
var/obj/structure/chair/spawn_chair = locate() in holder_turf

var/obj/vehicle/ridden/wheelchair/wheels
// More than 5k score? you unlock the gamer wheelchair.
if(client_source?.get_award_status(/datum/award/score/hardcore_random) >= 5000)
wheels = new /obj/vehicle/ridden/wheelchair/gold(holder_turf)
else
wheels = new /obj/vehicle/ridden/wheelchair(holder_turf)

// Makes spawning on the arrivals shuttle more consistent looking
if(spawn_chair)
wheels.setDir(spawn_chair.dir)

wheels.buckle_mob(quirk_holder)

// During the spawning process, they may have dropped what they were holding, due to the paralysis
// So put the things back in their hands.
for(var/obj/item/dropped_item in holder_turf)
if(dropped_item.fingerprintslast == quirk_holder.ckey)
quirk_holder.put_in_hands(dropped_item)

if(CRUTCHES_MED_PREFERENCE, CRUTCHES_WOOD_PREFERENCE)
var/crutch_type = wheelchair_type == CRUTCHES_MED_PREFERENCE ? /obj/item/cane/crutch : /obj/item/cane/crutch/wood
var/turf/holder_turf = get_turf(quirk_holder)
for(var/hand in quirk_holder.held_items)
quirk_holder.put_in_hands(new crutch_type(holder_turf))

#undef WHEELCHAIR_PREFERENCE
#undef CRUTCHES_MED_PREFERENCE
#undef CRUTCHES_WOOD_PREFERENCE
#undef NONE_PREFERENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { FeatureIconnedDropdownInput, FeatureWithIcons } from '../base';

export const paraplegic_aid: FeatureWithIcons<string> = {
name: 'Paraplegia Aid',
component: FeatureIconnedDropdownInput,
};

0 comments on commit 7009e2b

Please sign in to comment.