Skip to content

Commit

Permalink
[no gbp] some medbot fixes (tgstation#80150)
Browse files Browse the repository at this point in the history
## About The Pull Request
medbots now drop hats when tipped closes tgstation#80134 
medbots now drop their items when they explode 
player controlled bots now have their normal speed back 

## Why It's Good For The Game
they will now correctly drop their hats when tipped

## Changelog
:cl:
fix: medbots now drop hats when tipped and drop their items when they
explode
/:cl:

---------

Co-authored-by: san7890 <[email protected]>
  • Loading branch information
Ben10Omintrix and san7890 authored Dec 7, 2023
1 parent e7e290e commit a97daec
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1005,4 +1005,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/// Trait given when a mob is currently in invisimin mode
#define TRAIT_INVISIMIN "invisimin"

///Trait given when a mob has been tipped
#define TRAIT_MOB_TIPPED "mob_tipped"

// END TRAIT DEFINES
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_MIND_TEMPORARILY_GONE" = TRAIT_MIND_TEMPORARILY_GONE,
"TRAIT_MINDSHIELD" = TRAIT_MINDSHIELD,
"TRAIT_MOB_BREEDER" = TRAIT_MOB_BREEDER,
"TRAIT_MOB_TIPPED" = TRAIT_MOB_TIPPED,
"TRAIT_MORBID" = TRAIT_MORBID,
"TRAIT_MULTIZ_SUIT_SENSORS" = TRAIT_MULTIZ_SUIT_SENSORS,
"TRAIT_MUSICIAN" = TRAIT_MUSICIAN,
Expand Down
9 changes: 5 additions & 4 deletions code/datums/components/tippable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@
is_tipped = new_status
if(is_tipped)
tipped_mob.transform = turn(tipped_mob.transform, 180)
ADD_TRAIT(tipped_mob, TRAIT_IMMOBILIZED, TIPPED_OVER)
else
tipped_mob.transform = turn(tipped_mob.transform, -180)
REMOVE_TRAIT(tipped_mob, TRAIT_IMMOBILIZED, TIPPED_OVER)
tipped_mob.add_traits(list(TRAIT_MOB_TIPPED, TRAIT_IMMOBILIZED), TIPPED_OVER)
return

tipped_mob.transform = turn(tipped_mob.transform, -180)
tipped_mob.remove_traits(list(TRAIT_MOB_TIPPED, TRAIT_IMMOBILIZED), TIPPED_OVER)

/**
* Accepts "roleplay" in the form of emotes, which removes a quarter of the remaining time left to untip ourself.
Expand Down
27 changes: 26 additions & 1 deletion code/datums/elements/hat_wearer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@
argument_hash_start_idx = 2
///offsets of hats we will wear
var/list/offsets
///signals to remove the hat on
var/list/remove_hat_signals
///traits we check before adding the hat
var/traits_prevent_checks

/datum/element/hat_wearer/Attach(datum/target, offsets = list())
/datum/element/hat_wearer/Attach(datum/target, offsets = list(), remove_hat_signals = list(), traits_prevent_checks = list())
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.offsets = offsets
src.traits_prevent_checks = traits_prevent_checks
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_overlays_updated))
RegisterSignal(target, COMSIG_ATOM_EXITED, PROC_REF(exited))
RegisterSignal(target, COMSIG_ATOM_ENTERED, PROC_REF(on_entered))
RegisterSignal(target, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attack_by))
if(!length(remove_hat_signals))
return
RegisterSignals(target, remove_hat_signals, PROC_REF(remove_hat))

/datum/element/hat_wearer/Detach(datum/target)
var/obj/item/hat = (locate(/obj/item/clothing/head) in target)
Expand All @@ -27,6 +35,8 @@
COMSIG_ATOM_ENTERED,
COMSIG_ATOM_ATTACKBY,
))
if(length(remove_hat_signals))
UnregisterSignal(target, remove_hat_signals)
return ..()

/datum/element/hat_wearer/proc/on_overlays_updated(atom/source, list/overlays)
Expand Down Expand Up @@ -60,8 +70,15 @@

/datum/element/hat_wearer/proc/on_attack_by(atom/movable/source, obj/item/item, mob/living/attacker)
SIGNAL_HANDLER

if(!istype(item, /obj/item/clothing/head))
return

for(var/trait_check in traits_prevent_checks)
if(HAS_TRAIT(source, trait_check))
source.balloon_alert(attacker, "not possible right now!")
return COMPONENT_NO_AFTERATTACK

INVOKE_ASYNC(src, PROC_REF(place_hat), source, item, attacker)
return COMPONENT_NO_AFTERATTACK

Expand All @@ -70,3 +87,11 @@
source.balloon_alert(attacker, "must stay still!")
return
item.forceMove(source)

/datum/element/hat_wearer/proc/remove_hat(atom/movable/source)
SIGNAL_HANDLER

var/obj/our_hat = locate(/obj/item/clothing/head) in source
if(isnull(our_hat))
return
our_hat.forceMove(source.drop_location())
5 changes: 5 additions & 0 deletions code/modules/mob/living/basic/bots/_bots.dm
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,16 @@ GLOBAL_LIST_INIT(command_strings, list(
. = ..()
if(!. || isnull(client))
return FALSE
REMOVE_TRAIT(src, TRAIT_NO_GLIDE, INNATE_TRAIT)
speed = 2

diag_hud_set_botmode()

/mob/living/basic/bot/Logout()
. = ..()
bot_reset()
speed = initial(speed)
ADD_TRAIT(src, TRAIT_NO_GLIDE, INNATE_TRAIT)

/mob/living/basic/bot/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE)
. = ..()
Expand Down
28 changes: 21 additions & 7 deletions code/modules/mob/living/basic/bots/medbot/medbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@
pre_tipped_callback = CALLBACK(src, PROC_REF(pre_tip_over)), \
post_tipped_callback = CALLBACK(src, PROC_REF(after_tip_over)), \
post_untipped_callback = CALLBACK(src, PROC_REF(after_righted)))

var/static/list/hat_offsets = list(4,-9)
AddElement(/datum/element/hat_wearer, offsets = hat_offsets)
RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack))
var/static/list/remove_hat = list(SIGNAL_ADDTRAIT(TRAIT_MOB_TIPPED))
var/static/list/prevent_checks = list(TRAIT_MOB_TIPPED)
AddElement(/datum/element/hat_wearer,\
offsets = hat_offsets,\
remove_hat_signals = remove_hat,\
traits_prevent_checks = prevent_checks,\
)

RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack))
if(!HAS_TRAIT(SSstation, STATION_TRAIT_MEDBOT_MANIA) || !mapload || !is_station_level(z))
return
skin = "advanced"
Expand All @@ -162,10 +169,11 @@
if(HAS_TRAIT(src, TRAIT_INCAPACITATED))
icon_state = "[base_icon_state]a"
return
var/stationary_mode = !!(medical_mode_flags & MEDBOT_STATIONARY_MODE)
if(mode == BOT_HEALING)
icon_state = "[base_icon_state]s[medical_mode_flags & MEDBOT_STATIONARY_MODE]"
icon_state = "[base_icon_state]s[stationary_mode]"
return
icon_state = "[base_icon_state][medical_mode_flags & MEDBOT_STATIONARY_MODE ? 2 : 1]" //Bot has yellow light to indicate stationary mode.
icon_state = "[base_icon_state][stationary_mode ? 2 : 1]" //Bot has yellow light to indicate stationary mode.

/mob/living/basic/bot/medbot/update_overlays()
. = ..()
Expand Down Expand Up @@ -278,6 +286,12 @@
if(prob(10))
speak("PSYCH ALERT: Crewmember [user.name] recorded displaying antisocial tendencies torturing bots in [get_area(src)]. Please schedule psych evaluation.", radio_channel)

/mob/living/basic/bot/medbot/explode()
var/atom/our_loc = drop_location()
drop_part(medkit_type, our_loc)
drop_part(health_analyzer, our_loc)
return ..()

/*
* Proc used in a callback for after this medibot is righted, either by themselves or by a mob, by the tippable component.
*
Expand Down Expand Up @@ -320,7 +334,7 @@
return
var/modified_heal_amount = heal_amount
var/done_healing = FALSE
if(damage_type_healer == BRUTE && medkit_type == /obj/item/storage/medkit/brute)
if(damage_type_healer == BRUTE && medkit_type == /obj/item/storage/medkit/brute)
modified_heal_amount *= 1.1
if(bot_access_flags & BOT_COVER_EMAGGED)
patient.reagents?.add_reagent(/datum/reagent/toxin/chloralhydrate, 5)
Expand All @@ -335,12 +349,12 @@
log_combat(src, patient, "tended the wounds of", "internal tools")
if(patient.get_current_damage_of_type(damage_type_healer) <= heal_threshold)
done_healing = TRUE

patient.visible_message(span_notice("[src] tends the wounds of [patient]!"), "[span_infoplain(span_green("[src] tends your wounds!"))]")
//Go into idle only when we're done
update_bot_mode(new_mode = BOT_IDLE)
if(done_healing)
visible_message(span_infoplain("[src] places its tools back into itself."))
to_chat(src, "[patient] is now healthy!")
update_bot_mode(new_mode = BOT_IDLE)
//If player-controlled, call them to heal again here for continous player healing
else if(!isnull(client))
melee_attack(patient)
Expand Down

0 comments on commit a97daec

Please sign in to comment.