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

Cleaner slimes are now far more intelligent #2350

Merged
merged 21 commits into from
Jul 11, 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
2 changes: 2 additions & 0 deletions code/__DEFINES/~monkestation/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// /obj/item
/// Whether a storage item can be compressed by the bluespace compression kit, without the usual storage limitation.
#define TRAIT_BYPASS_COMPRESS_CHECK "can_compress_anyways"
/// This item is considered "trash" (and will be eaten by cleaner slimes)
#define TRAIT_TRASH_ITEM "trash_item"

#define ABDUCTOR_GLAND_VENTCRAWLING_TRAIT "abductor_gland_ventcrawling"
#define TRAIT_BETTER_CYBERCONNECTOR "better_cyberconnector_hacking"
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/dna_injector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
to_chat(user, span_notice("It appears that [target] does not have compatible DNA."))

used = TRUE
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) // monkestation edit: trash item trait
update_appearance()

/obj/item/dnainjector/timed
Expand Down
66 changes: 66 additions & 0 deletions monkestation/code/datums/elements/trash_if_empty.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/datum/element/trash_if_empty
var/attach_type = /obj
var/static/list/update_signals = list(
COMSIG_ATOM_ENTERED,
COMSIG_ATOM_EXITED
)

/datum/element/trash_if_empty/Attach(datum/source)
. = ..()
if(!istype(source, attach_type))
return ELEMENT_INCOMPATIBLE
register_signals(source)

/datum/element/trash_if_empty/Detach(datum/source)
unregister_signals(source)
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))
return ..()

/datum/element/trash_if_empty/proc/register_signals(datum/source)
RegisterSignals(source, update_signals, PROC_REF(update_trash_trait))

/datum/element/trash_if_empty/proc/unregister_signals(datum/source)
UnregisterSignal(source, update_signals)

/datum/element/trash_if_empty/proc/update_trash_trait(obj/source)
SIGNAL_HANDLER
if(is_empty_or_trash(source))
ADD_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))
else
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))

/datum/element/trash_if_empty/proc/is_empty_or_trash(obj/source)
. = TRUE
if(!length(source.contents))
return TRUE
for(var/obj/item/stored_obj in source.contents)
if(!QDELING(stored_obj) && !HAS_TRAIT(stored_obj, TRAIT_TRASH_ITEM))
return FALSE

// Variant for reagent containers
/datum/element/trash_if_empty/reagent_container
attach_type = /obj/item/reagent_containers
var/static/list/reagent_signals = list(
COMSIG_REAGENTS_NEW_REAGENT,
COMSIG_REAGENTS_ADD_REAGENT,
COMSIG_REAGENTS_DEL_REAGENT,
COMSIG_REAGENTS_REM_REAGENT
)

/datum/element/trash_if_empty/reagent_container/register_signals(obj/item/reagent_containers/source)
RegisterSignals(source.reagents, reagent_signals, PROC_REF(update_trash_trait))

/datum/element/trash_if_empty/reagent_container/unregister_signals(obj/item/reagent_containers/source)
UnregisterSignal(source.reagents, reagent_signals)

/datum/element/trash_if_empty/reagent_container/is_empty_or_trash(datum/reagents/source)
return !source?.total_volume

/// Variant that never considers non-prefilled containers as empty
/datum/element/trash_if_empty/reagent_container/if_prefilled

/datum/element/trash_if_empty/reagent_container/if_prefilled/is_empty_or_trash(datum/reagents/source)
var/obj/item/reagent_containers/container = source?.my_atom
if(!container.list_reagents)
return FALSE
return ..()
9 changes: 9 additions & 0 deletions monkestation/code/game/objects/items/cigs_lighters.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/obj/item/cigbutt/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

/obj/item/match/matchburnout()
if(!lit)
return
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
3 changes: 3 additions & 0 deletions monkestation/code/game/objects/items/food/frozen.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/popsicle_stick/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
4 changes: 4 additions & 0 deletions monkestation/code/game/objects/items/food/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
foodtypes = FRUIT
food_flags = FOOD_FINGER_FOOD
w_class = WEIGHT_CLASS_SMALL

/obj/item/food/badrecipe/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
3 changes: 3 additions & 0 deletions monkestation/code/game/objects/items/food/snacks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/food/candy_trash/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
3 changes: 3 additions & 0 deletions monkestation/code/game/objects/items/storage/fancy.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/storage/fancy/cigarettes/Initialize(mapload)
. = ..()
AddElement(/datum/element/trash_if_empty)
1 change: 1 addition & 0 deletions monkestation/code/game/objects/items/superglue.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
if(uses == 0)
icon_state = "glue_used"
name = "empty bottle of super glue"
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
return
3 changes: 3 additions & 0 deletions monkestation/code/game/objects/items/trash.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/trash/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm giving things that are already in the cleaner slime target typecache the trait, just so this trait can be useful for other things in the future

4 changes: 4 additions & 0 deletions monkestation/code/modules/mob/living/basic/vermin/mouse.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/obj/item/food/deadmouse/Initialize(mapload, mob/living/basic/mouse/dead_critter)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

/obj/item/food/deadmouse/extrapolator_act(mob/user, obj/item/extrapolator/E, scan = TRUE)
if(!ratdisease.len)
return FALSE
Expand Down
7 changes: 7 additions & 0 deletions monkestation/code/modules/power/lighting/light_items.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/obj/item/light/tube/broken/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

/obj/item/light/bulb/broken/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
25 changes: 25 additions & 0 deletions monkestation/code/modules/projectiles/ammunition/_ammunition.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/obj/item/ammo_casing/Initialize(mapload)
. = ..()
update_trash_trait()

/obj/item/ammo_casing/newshot()
. = ..()
update_trash_trait()

/obj/item/ammo_casing/on_accidental_consumption(mob/living/carbon/victim, mob/living/carbon/user, obj/item/source_item, discover_after = TRUE)
. = ..()
update_trash_trait()

/obj/item/ammo_casing/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread, atom/fired_from)
. = ..()
update_trash_trait()

/obj/item/ammo_casing/refresh_shot()
. = ..()
update_trash_trait()

/obj/item/ammo_casing/proc/update_trash_trait()
if(QDELETED(loaded_projectile))
ADD_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC)
else
REMOVE_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/reagent_containers/condiment/pack/Initialize(mapload, vol)
. = ..()
AddElement(/datum/element/trash_if_empty/reagent_container)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/reagent_containers/cup/Initialize(mapload, vol)
. = ..()
AddElement(/datum/element/trash_if_empty/reagent_container/if_prefilled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/item/broken_bottle/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
///What kind of condiment pack should we give the package
var/condiment_pack = /obj/item/reagent_containers/condiment/pack/ketchup

/obj/item/storage/box/foodpack/Initialize(mapload)
. = ..()
AddElement(/datum/element/trash_if_empty)

/obj/item/storage/box/foodpack/PopulateContents()
. = ..()
new main_course(src)
Expand Down
2 changes: 2 additions & 0 deletions monkestation/code/modules/slimecore/items/mutation_syringe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
user.balloon_alert_to_viewers("injected mutator")
to_chat(user, span_notice("You inject [target] with [src]."))
on_inject(slime)
if(uses <= 0)
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

/obj/item/slime_mutation_syringe/proc/on_inject(mob/living/basic/slime/target)

Expand Down
14 changes: 11 additions & 3 deletions monkestation/code/modules/slimecore/mobs/_base_slime.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
///our list of slime traits
var/list/slime_traits = list()
///used to help our name changes so we don't rename named slimes
var/static/regex/slime_name_regex = new("\\w+ (baby|adult) slime \\(\\d+\\)")
var/static/regex/slime_name_regex = new("\\w+ (baby|adult) (cleaner )?(cat)?slime \\(\\d+\\)")
///our number
var/number

Expand Down Expand Up @@ -308,6 +308,7 @@
var/datum/slime_trait/new_trait = new added_trait
new_trait.on_add(src)
slime_traits += new_trait
update_name()
return TRUE

///unlike add trait this uses a type and is checked against the list don't pass the created one pass the type
Expand All @@ -317,6 +318,7 @@
continue
slime_traits -= trait
qdel(trait)
update_name()
return

///unlike add trait this uses a type and is checked against the list don't pass the created one pass the type
Expand All @@ -331,10 +333,16 @@
if(slime_name_regex.Find(name))
if(!number)
number = rand(1, 1000)
var/slime_variant = "slime"
if(has_slime_trait(/datum/slime_trait/visual/cat))
slime_variant = "catslime"
if(slime_flags & CLEANER_SLIME)
slime_variant = "cleaner [slime_variant]"

if(overriding_name_prefix)
name = "[overriding_name_prefix] [current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] slime ([number])"
name = "[overriding_name_prefix] [current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] [slime_variant] ([number])"
else
name = "[current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] slime ([number])"
name = "[current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] [slime_variant] ([number])"
real_name = name
update_name_tag()
return ..()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
finish_action(controller, FALSE, target_key)
return

living_pawn.visible_message(span_notice("[living_pawn] dissolves the [target]."))
living_pawn.balloon_alert_to_viewers("cleaned")
living_pawn.visible_message(span_notice("[living_pawn] dissolves \the [target]."))
SEND_SIGNAL(living_pawn, COMSIG_MOB_FEED, target, 20)
qdel(target) // Sent to the shadow realm to never be seen again
finish_action(controller, TRUE, target_key)
Expand All @@ -33,10 +34,30 @@
controller.clear_blackboard_key(target_key)

/datum/ai_behavior/find_and_set/in_list/clean_targets_slime
action_cooldown = 2 SECONDS
action_cooldown = 1.2 SECONDS

/datum/ai_behavior/find_and_set/in_list/clean_targets_slime/search_tactic(datum/ai_controller/controller, locate_paths, search_range)
var/list/found = typecache_filter_list(oview(search_range, controller.pawn), locate_paths)
if(length(found))
return pick(found)

var/obj/closest
var/closest_dist
var/closest_path
for(var/obj/trash as anything in view(search_range, controller.pawn))
if(QDELETED(trash))
continue
if(!is_type_in_typecache(trash, locate_paths) && !HAS_TRAIT(trash, TRAIT_TRASH_ITEM))
continue
if(trash.loc == controller.pawn.loc)
return trash
var/dist = get_dist(get_turf(controller.pawn), get_turf(trash))
var/path_length
if(!QDELETED(closest))
if(dist > (closest_dist + 2)) // leeway to try to avoid "shorter dist but longer path" targets
continue
path_length = length(get_path_to(controller.pawn, trash))
if(closest_path <= path_length)
continue
else
path_length = length(get_path_to(controller.pawn, trash))
closest = trash
closest_dist = dist
closest_path = path_length
return closest
5 changes: 4 additions & 1 deletion monkestation/code/modules/slimecore/slime_traits/cleaner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
///decals we can clean
var/static/list/cleanable_decals = typecacheof(list(
/obj/effect/decal/cleanable/ants,
/obj/effect/decal/cleanable/ash,
/obj/effect/decal/cleanable/confetti,
/obj/effect/decal/cleanable/ash,
/obj/effect/decal/cleanable/dirt,
/obj/effect/decal/cleanable/fuel_pool,
/obj/effect/decal/cleanable/generic,
Expand Down Expand Up @@ -45,6 +45,9 @@
/obj/item/food/candy_trash,
/obj/item/cigbutt,
/obj/item/food/breadslice/moldy,
/obj/item/food/pizzaslice/moldy,
/obj/item/food/badrecipe,
/obj/item/food/egg/rotten,
/obj/item/light/tube/broken,
/obj/item/light/bulb/broken,
/obj/item/popsicle_stick,
Expand Down
11 changes: 11 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5779,6 +5779,7 @@
#include "monkestation\code\datums\components\wound_converter.dm"
#include "monkestation\code\datums\diseases\advance\symptoms\clockwork.dm"
#include "monkestation\code\datums\elements\area_locked.dm"
#include "monkestation\code\datums\elements\trash_if_empty.dm"
#include "monkestation\code\datums\elements\uncompressed_storage.dm"
#include "monkestation\code\datums\ert\moff_inspectors.dm"
#include "monkestation\code\datums\id_trim\jobs.dm"
Expand Down Expand Up @@ -5825,6 +5826,7 @@
#include "monkestation\code\game\objects\effects\spawners\random\fishing.dm"
#include "monkestation\code\game\objects\items\caneswords.dm"
#include "monkestation\code\game\objects\items\choice_beacon.dm"
#include "monkestation\code\game\objects\items\cigs_lighters.dm"
#include "monkestation\code\game\objects\items\cirno_plush.dm"
#include "monkestation\code\game\objects\items\gravity_gun.dm"
#include "monkestation\code\game\objects\items\jukebox_beacon.dm"
Expand All @@ -5836,6 +5838,7 @@
#include "monkestation\code\game\objects\items\spraycan_gun.dm"
#include "monkestation\code\game\objects\items\stickers.dm"
#include "monkestation\code\game\objects\items\superglue.dm"
#include "monkestation\code\game\objects\items\trash.dm"
#include "monkestation\code\game\objects\items\turf_demolisher.dm"
#include "monkestation\code\game\objects\items\venom_knife.dm"
#include "monkestation\code\game\objects\items\AI_modules\monke_lawsets.dm"
Expand All @@ -5856,7 +5859,9 @@
#include "monkestation\code\game\objects\items\effects\nugget.dm"
#include "monkestation\code\game\objects\items\effects\washing_machine.dm"
#include "monkestation\code\game\objects\items\food\corndog.dm"
#include "monkestation\code\game\objects\items\food\frozen.dm"
#include "monkestation\code\game\objects\items\food\misc.dm"
#include "monkestation\code\game\objects\items\food\snacks.dm"
#include "monkestation\code\game\objects\items\food\spaghetti.dm"
#include "monkestation\code\game\objects\items\granters\elance.dm"
#include "monkestation\code\game\objects\items\grenades\monkey_barrel.dm"
Expand All @@ -5870,6 +5875,7 @@
#include "monkestation\code\game\objects\items\storage\book.dm"
#include "monkestation\code\game\objects\items\storage\boxes.dm"
#include "monkestation\code\game\objects\items\storage\crate.dm"
#include "monkestation\code\game\objects\items\storage\fancy.dm"
#include "monkestation\code\game\objects\items\storage\garment.dm"
#include "monkestation\code\game\objects\items\storage\uplink_kits.dm"
#include "monkestation\code\game\objects\structures\tables_racks.dm"
Expand Down Expand Up @@ -7129,6 +7135,7 @@
#include "monkestation\code\modules\possession\possessed_hud.dm"
#include "monkestation\code\modules\power\cables.dm"
#include "monkestation\code\modules\power\lighting\floor_light.dm"
#include "monkestation\code\modules\power\lighting\light_items.dm"
#include "monkestation\code\modules\power\lighting\neon_lining.dm"
#include "monkestation\code\modules\power\power_transmission_laser\code\announcement.dm"
#include "monkestation\code\modules\power\power_transmission_laser\code\beam.dm"
Expand All @@ -7139,6 +7146,7 @@
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_accelerator.dm"
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_controller.dm"
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_emitter.dm"
#include "monkestation\code\modules\projectiles\ammunition\_ammunition.dm"
#include "monkestation\code\modules\projectiles\guns\ballistic\revolver.dm"
#include "monkestation\code\modules\projectiles\guns\ballistic\ryanecorp_whispering_jester.dm"
#include "monkestation\code\modules\projectiles\guns\special\meat_hook.dm"
Expand Down Expand Up @@ -7231,9 +7239,12 @@
#include "monkestation\code\modules\reagents\fun\liquid_justice.dm"
#include "monkestation\code\modules\reagents\fun\shakeium.dm"
#include "monkestation\code\modules\reagents\reagent_containers\blood_pack.dm"
#include "monkestation\code\modules\reagents\reagent_containers\condiment.dm"
#include "monkestation\code\modules\reagents\reagent_containers\drinks.dm"
#include "monkestation\code\modules\reagents\reagent_containers\sunsetglass.dm"
#include "monkestation\code\modules\reagents\reagent_containers\cups\_cup.dm"
#include "monkestation\code\modules\reagents\reagent_containers\cups\bottle.dm"
#include "monkestation\code\modules\reagents\reagent_containers\cups\glassbottle.dm"
#include "monkestation\code\modules\reagents\recipes\fun.dm"
#include "monkestation\code\modules\reagents\recipes\medical.dm"
#include "monkestation\code\modules\replays\hooks\generic_hooks.dm"
Expand Down
Loading