Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craig fixups and QoL #3426

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/modules/mob/living/basic/jungle/seedling/seedling_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@

if(isnull(can))
return
if(locate(/datum/reagent/water) in can.reagents.reagent_list)
if(can.reagents?.has_reagent(/datum/reagent/water)) // monkestation edit: just use has_reagent instead of locate()
return

return ..()

/datum/ai_behavior/find_hunt_target/suitable_dispenser

/datum/ai_behavior/find_hunt_target/suitable_dispenser/valid_dinner(mob/living/source, obj/structure/water_source, radius)
if(!(locate(/datum/reagent/water) in water_source.reagents.reagent_list))
if(!water_source.reagents?.has_reagent(/datum/reagent/water)) // monkestation edit: just use has_reagent instead of locate()
return FALSE

return can_see(source, water_source, radius)
Expand Down
15 changes: 15 additions & 0 deletions monkestation/code/datums/components/basic_inhands.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/datum/component/basic_inhands/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))

/datum/component/basic_inhands/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, COMSIG_ATOM_EXAMINE)

/datum/component/basic_inhands/proc/on_examine(datum/source, mob/user, list/examine_info)
SIGNAL_HANDLER
var/mob/living/parent = src.parent
for(var/obj/item/held_thing in parent.held_items)
if(held_thing.item_flags & (ABSTRACT | EXAMINE_SKIP | HAND_ITEM))
continue
examine_info += span_info("[parent.p_They()] [parent.p_are()] holding [held_thing.get_examine_string(user)] in [parent.p_their()] [parent.get_held_index_name(parent.get_held_index_of_item(held_thing))].")
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
managed_seeds["[i]"] = null

///we create reagents using max_reagents, then make it visible and an open container
movable_parent.create_reagents(max_reagents, (OPENCONTAINER | AMOUNT_VISIBLE))
movable_parent.create_reagents(max_reagents, (REFILLABLE | DRAINABLE)) // We don't use OPENCONTAINER, as there's no need for it to be transparent, we have our own examine info handler

RegisterSignals(parent, list(COMSIG_TRY_PLANT_SEED, COMSIG_ATOM_ATTACKBY), PROC_REF(try_plant_seed))
RegisterSignal(parent, COMSIG_TRY_POLLINATE, PROC_REF(try_pollinate))
Expand Down
82 changes: 71 additions & 11 deletions monkestation/code/modules/botany/potty.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/mob/living/basic/pet/potty
name = "craig the potted plant"
name = "\proper craig the potted plant"
desc = "A potted plant."

icon = 'monkestation/code/modules/botany/icons/potty.dmi'
Expand All @@ -25,17 +25,32 @@
)

/mob/living/basic/pet/potty/Initialize(mapload)
. = ..()

..()
AddComponent(/datum/component/plant_tray_overlay, icon, null, null, null, null, null, null, 3, 8)
AddComponent(/datum/component/plant_growing)
AddComponent(/datum/component/obeys_commands, pet_commands)
AddComponent(/datum/component/emotion_buffer)
AddComponent(/datum/component/friendship_container, list(FRIENDSHIP_HATED = -100, FRIENDSHIP_DISLIKED = -50, FRIENDSHIP_STRANGER = 0, FRIENDSHIP_NEUTRAL = 1, FRIENDSHIP_ACQUAINTANCES = 3, FRIENDSHIP_FRIEND = 5, FRIENDSHIP_BESTFRIEND = 10), FRIENDSHIP_FRIEND)
AddComponent(/datum/component/basic_inhands)
AddElement(/datum/element/waddling)

SEND_SIGNAL(src, COMSIG_TOGGLE_BIOBOOST)

return INITIALIZE_HINT_LATELOAD

/mob/living/basic/pet/potty/LateInitialize()
for(var/obj/item/reagent_containers/cup/watering_can/can in range(1, src))
if(pick_up_watering_can(can))
break

/mob/living/basic/pet/potty/Destroy()
drop_all_held_items()
return ..()

/mob/living/basic/pet/potty/death(gibbed)
drop_all_held_items()
return ..()

/mob/living/basic/pet/potty/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE)
face_atom(target)
if (!ignore_cooldown)
Expand All @@ -52,17 +67,62 @@
SEND_SIGNAL(src, COMSIG_HOSTILE_POST_ATTACKINGTARGET, target, result)
return result

/*
/mob/living/basic/pet/potty/attackby(obj/item/thing, mob/user, params)
// no forcing it into the hands of a sentient craig
if(QDELETED(client) && istype(thing, /obj/item/reagent_containers/cup/watering_can))
if(user.temporarilyRemoveItemFromInventory(thing) && !pick_up_watering_can(thing, user))
user.put_in_hands(thing)
return TRUE
return ..()
*/

/mob/living/basic/pet/potty/proc/pick_up_watering_can(obj/item/reagent_containers/cup/watering_can/can, mob/living/feedback)
// make sure it's actually a watering can, and that its not deleted
if(!istype(can) || QDELING(can) || stat == DEAD)
return FALSE
// check if we're already holding a watering can
var/obj/item/held_can = is_holding_item_of_type(/obj/item/reagent_containers/cup/watering_can)
if(held_can)
var/holding_advanced = istype(held_can, /obj/item/reagent_containers/cup/watering_can/advanced)
var/giving_advanced = istype(can, /obj/item/reagent_containers/cup/watering_can/advanced)
if(holding_advanced || !giving_advanced)
if(feedback)
balloon_alert(feedback, "already has watering can!")
return FALSE
else
// we can hand craig an advanced can and they'll switch it out if their current can isn't advanced
dropItemToGround(held_can)
// make sure our hands aren't full
if(!length(get_empty_held_indexes()))
if(feedback)
balloon_alert(feedback, "hands full!")
return FALSE
can.forceMove(src)
// just make SURE we pick up the can - drop it back to the floor if we somehow fail
if(!put_in_hands(can))
if(feedback)
balloon_alert(feedback, "couldn't pick up!")
can.forceMove(drop_location())
return FALSE
// remove all non-water reagents from the can
for(var/datum/reagent/reagent in can.reagents.reagent_list)
if(reagent.type == /datum/reagent/water)
continue
can.reagents.remove_reagent(reagent.type, reagent.volume)
if(feedback)
balloon_alert(feedback, "took watering can")
return TRUE

/mob/living/basic/pet/potty/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)
. = ..()
if(. && proximity_flag)
pick_up_watering_can(attack_target)

if(!. || !proximity_flag || (locate(/obj/item/reagent_containers/cup/watering_can) in contents))
return

if(!istype(attack_target, /obj/item/reagent_containers/cup/watering_can))
return

var/obj/item/can_target = attack_target
can_target.pickup(src)
// craig's living icons are movement states, so we gotta ensure icon2html handles that properly
/mob/living/basic/pet/potty/get_examine_string(mob/user, thats = FALSE)
var/is_icon_moving = (icon_state == initial(icon_state) || icon_state == initial(icon_living))
return "[icon2html(src, user, moving = is_icon_moving)] [thats ? "That's " : ""][get_examine_name(user)]"

/datum/pet_command/craig_harvest
command_name = "Shake"
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,7 @@
#include "monkestation\code\datums\brain_damage\magic.dm"
#include "monkestation\code\datums\brain_damage\phobia.dm"
#include "monkestation\code\datums\changelog\changelog.dm"
#include "monkestation\code\datums\components\basic_inhands.dm"
#include "monkestation\code\datums\components\carbon_sprint.dm"
#include "monkestation\code\datums\components\charge_adjuster.dm"
#include "monkestation\code\datums\components\crafting.dm"
Expand Down
Loading