Skip to content

Commit 9d1cf36

Browse files
authored
Cleaner slimes are now far more intelligent (#2350)
* Cleaner slimes are now far more intelligent * fixups * bweh why no worky?? * whoopsie * wheee it all works now! * Remove unused changes * used dna mutators are now trash * glue can now be trash too * Optimize cleaner slime targeting * hmmm * bweh * bweh * byeah * fix inverted logic
1 parent 5f5206c commit 9d1cf36

File tree

22 files changed

+199
-10
lines changed

22 files changed

+199
-10
lines changed

code/__DEFINES/~monkestation/traits.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
// /obj/item
3434
/// Whether a storage item can be compressed by the bluespace compression kit, without the usual storage limitation.
3535
#define TRAIT_BYPASS_COMPRESS_CHECK "can_compress_anyways"
36+
/// This item is considered "trash" (and will be eaten by cleaner slimes)
37+
#define TRAIT_TRASH_ITEM "trash_item"
3638

3739
#define ABDUCTOR_GLAND_VENTCRAWLING_TRAIT "abductor_gland_ventcrawling"
3840
#define TRAIT_BETTER_CYBERCONNECTOR "better_cyberconnector_hacking"

code/game/objects/items/dna_injector.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
to_chat(user, span_notice("It appears that [target] does not have compatible DNA."))
9797

9898
used = TRUE
99+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) // monkestation edit: trash item trait
99100
update_appearance()
100101

101102
/obj/item/dnainjector/timed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/datum/element/trash_if_empty
2+
var/attach_type = /obj
3+
var/static/list/update_signals = list(
4+
COMSIG_ATOM_ENTERED,
5+
COMSIG_ATOM_EXITED
6+
)
7+
8+
/datum/element/trash_if_empty/Attach(datum/source)
9+
. = ..()
10+
if(!istype(source, attach_type))
11+
return ELEMENT_INCOMPATIBLE
12+
register_signals(source)
13+
14+
/datum/element/trash_if_empty/Detach(datum/source)
15+
unregister_signals(source)
16+
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))
17+
return ..()
18+
19+
/datum/element/trash_if_empty/proc/register_signals(datum/source)
20+
RegisterSignals(source, update_signals, PROC_REF(update_trash_trait))
21+
22+
/datum/element/trash_if_empty/proc/unregister_signals(datum/source)
23+
UnregisterSignal(source, update_signals)
24+
25+
/datum/element/trash_if_empty/proc/update_trash_trait(obj/source)
26+
SIGNAL_HANDLER
27+
if(is_empty_or_trash(source))
28+
ADD_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))
29+
else
30+
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type))
31+
32+
/datum/element/trash_if_empty/proc/is_empty_or_trash(obj/source)
33+
. = TRUE
34+
if(!length(source.contents))
35+
return TRUE
36+
for(var/obj/item/stored_obj in source.contents)
37+
if(!QDELING(stored_obj) && !HAS_TRAIT(stored_obj, TRAIT_TRASH_ITEM))
38+
return FALSE
39+
40+
// Variant for reagent containers
41+
/datum/element/trash_if_empty/reagent_container
42+
attach_type = /obj/item/reagent_containers
43+
var/static/list/reagent_signals = list(
44+
COMSIG_REAGENTS_NEW_REAGENT,
45+
COMSIG_REAGENTS_ADD_REAGENT,
46+
COMSIG_REAGENTS_DEL_REAGENT,
47+
COMSIG_REAGENTS_REM_REAGENT
48+
)
49+
50+
/datum/element/trash_if_empty/reagent_container/register_signals(obj/item/reagent_containers/source)
51+
RegisterSignals(source.reagents, reagent_signals, PROC_REF(update_trash_trait))
52+
53+
/datum/element/trash_if_empty/reagent_container/unregister_signals(obj/item/reagent_containers/source)
54+
UnregisterSignal(source.reagents, reagent_signals)
55+
56+
/datum/element/trash_if_empty/reagent_container/is_empty_or_trash(datum/reagents/source)
57+
return !source?.total_volume
58+
59+
/// Variant that never considers non-prefilled containers as empty
60+
/datum/element/trash_if_empty/reagent_container/if_prefilled
61+
62+
/datum/element/trash_if_empty/reagent_container/if_prefilled/is_empty_or_trash(datum/reagents/source)
63+
var/obj/item/reagent_containers/container = source?.my_atom
64+
if(!container.list_reagents)
65+
return FALSE
66+
return ..()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/obj/item/cigbutt/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
4+
5+
/obj/item/match/matchburnout()
6+
if(!lit)
7+
return
8+
. = ..()
9+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/popsicle_stick/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

monkestation/code/game/objects/items/food/misc.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
foodtypes = FRUIT
1212
food_flags = FOOD_FINGER_FOOD
1313
w_class = WEIGHT_CLASS_SMALL
14+
15+
/obj/item/food/badrecipe/Initialize(mapload)
16+
. = ..()
17+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/food/candy_trash/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/storage/fancy/cigarettes/Initialize(mapload)
2+
. = ..()
3+
AddElement(/datum/element/trash_if_empty)

monkestation/code/game/objects/items/superglue.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929
if(uses == 0)
3030
icon_state = "glue_used"
3131
name = "empty bottle of super glue"
32+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
3233
return
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/trash/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

monkestation/code/modules/mob/living/basic/vermin/mouse.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/obj/item/food/deadmouse/Initialize(mapload, mob/living/basic/mouse/dead_critter)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
4+
15
/obj/item/food/deadmouse/extrapolator_act(mob/user, obj/item/extrapolator/E, scan = TRUE)
26
if(!ratdisease.len)
37
return FALSE
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/obj/item/light/tube/broken/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
4+
5+
/obj/item/light/bulb/broken/Initialize(mapload)
6+
. = ..()
7+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/obj/item/ammo_casing/Initialize(mapload)
2+
. = ..()
3+
update_trash_trait()
4+
5+
/obj/item/ammo_casing/newshot()
6+
. = ..()
7+
update_trash_trait()
8+
9+
/obj/item/ammo_casing/on_accidental_consumption(mob/living/carbon/victim, mob/living/carbon/user, obj/item/source_item, discover_after = TRUE)
10+
. = ..()
11+
update_trash_trait()
12+
13+
/obj/item/ammo_casing/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread, atom/fired_from)
14+
. = ..()
15+
update_trash_trait()
16+
17+
/obj/item/ammo_casing/refresh_shot()
18+
. = ..()
19+
update_trash_trait()
20+
21+
/obj/item/ammo_casing/proc/update_trash_trait()
22+
if(QDELETED(loaded_projectile))
23+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC)
24+
else
25+
REMOVE_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/reagent_containers/condiment/pack/Initialize(mapload, vol)
2+
. = ..()
3+
AddElement(/datum/element/trash_if_empty/reagent_container)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/reagent_containers/cup/Initialize(mapload, vol)
2+
. = ..()
3+
AddElement(/datum/element/trash_if_empty/reagent_container/if_prefilled)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/obj/item/broken_bottle/Initialize(mapload)
2+
. = ..()
3+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)

monkestation/code/modules/skyrat_snipes/vending_machines/vending_packages.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
///What kind of condiment pack should we give the package
1313
var/condiment_pack = /obj/item/reagent_containers/condiment/pack/ketchup
1414

15+
/obj/item/storage/box/foodpack/Initialize(mapload)
16+
. = ..()
17+
AddElement(/datum/element/trash_if_empty)
18+
1519
/obj/item/storage/box/foodpack/PopulateContents()
1620
. = ..()
1721
new main_course(src)

monkestation/code/modules/slimecore/items/mutation_syringe.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
user.balloon_alert_to_viewers("injected mutator")
3939
to_chat(user, span_notice("You inject [target] with [src]."))
4040
on_inject(slime)
41+
if(uses <= 0)
42+
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT)
4143

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

monkestation/code/modules/slimecore/mobs/_base_slime.dm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
///our list of slime traits
5858
var/list/slime_traits = list()
5959
///used to help our name changes so we don't rename named slimes
60-
var/static/regex/slime_name_regex = new("\\w+ (baby|adult) slime \\(\\d+\\)")
60+
var/static/regex/slime_name_regex = new("\\w+ (baby|adult) (cleaner )?(cat)?slime \\(\\d+\\)")
6161
///our number
6262
var/number
6363

@@ -308,6 +308,7 @@
308308
var/datum/slime_trait/new_trait = new added_trait
309309
new_trait.on_add(src)
310310
slime_traits += new_trait
311+
update_name()
311312
return TRUE
312313

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

322324
///unlike add trait this uses a type and is checked against the list don't pass the created one pass the type
@@ -331,10 +333,16 @@
331333
if(slime_name_regex.Find(name))
332334
if(!number)
333335
number = rand(1, 1000)
336+
var/slime_variant = "slime"
337+
if(has_slime_trait(/datum/slime_trait/visual/cat))
338+
slime_variant = "catslime"
339+
if(slime_flags & CLEANER_SLIME)
340+
slime_variant = "cleaner [slime_variant]"
341+
334342
if(overriding_name_prefix)
335-
name = "[overriding_name_prefix] [current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] slime ([number])"
343+
name = "[overriding_name_prefix] [current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] [slime_variant] ([number])"
336344
else
337-
name = "[current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] slime ([number])"
345+
name = "[current_color.name] [(slime_flags & ADULT_SLIME) ? "adult" : "baby"] [slime_variant] ([number])"
338346
real_name = name
339347
update_name_tag()
340348
return ..()

monkestation/code/modules/slimecore/mobs/ai_controller/behaviours/clean_target.dm

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
finish_action(controller, FALSE, target_key)
1818
return
1919

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

3536
/datum/ai_behavior/find_and_set/in_list/clean_targets_slime
36-
action_cooldown = 2 SECONDS
37+
action_cooldown = 1.2 SECONDS
3738

3839
/datum/ai_behavior/find_and_set/in_list/clean_targets_slime/search_tactic(datum/ai_controller/controller, locate_paths, search_range)
39-
var/list/found = typecache_filter_list(oview(search_range, controller.pawn), locate_paths)
40-
if(length(found))
41-
return pick(found)
42-
40+
var/obj/closest
41+
var/closest_dist
42+
var/closest_path
43+
for(var/obj/trash as anything in view(search_range, controller.pawn))
44+
if(QDELETED(trash))
45+
continue
46+
if(!is_type_in_typecache(trash, locate_paths) && !HAS_TRAIT(trash, TRAIT_TRASH_ITEM))
47+
continue
48+
if(trash.loc == controller.pawn.loc)
49+
return trash
50+
var/dist = get_dist(get_turf(controller.pawn), get_turf(trash))
51+
var/path_length
52+
if(!QDELETED(closest))
53+
if(dist > (closest_dist + 2)) // leeway to try to avoid "shorter dist but longer path" targets
54+
continue
55+
path_length = length(get_path_to(controller.pawn, trash))
56+
if(closest_path <= path_length)
57+
continue
58+
else
59+
path_length = length(get_path_to(controller.pawn, trash))
60+
closest = trash
61+
closest_dist = dist
62+
closest_path = path_length
63+
return closest

monkestation/code/modules/slimecore/slime_traits/cleaner.dm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
///decals we can clean
88
var/static/list/cleanable_decals = typecacheof(list(
99
/obj/effect/decal/cleanable/ants,
10-
/obj/effect/decal/cleanable/ash,
1110
/obj/effect/decal/cleanable/confetti,
11+
/obj/effect/decal/cleanable/ash,
1212
/obj/effect/decal/cleanable/dirt,
1313
/obj/effect/decal/cleanable/fuel_pool,
1414
/obj/effect/decal/cleanable/generic,
@@ -45,6 +45,9 @@
4545
/obj/item/food/candy_trash,
4646
/obj/item/cigbutt,
4747
/obj/item/food/breadslice/moldy,
48+
/obj/item/food/pizzaslice/moldy,
49+
/obj/item/food/badrecipe,
50+
/obj/item/food/egg/rotten,
4851
/obj/item/light/tube/broken,
4952
/obj/item/light/bulb/broken,
5053
/obj/item/popsicle_stick,

tgstation.dme

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5779,6 +5779,7 @@
57795779
#include "monkestation\code\datums\components\wound_converter.dm"
57805780
#include "monkestation\code\datums\diseases\advance\symptoms\clockwork.dm"
57815781
#include "monkestation\code\datums\elements\area_locked.dm"
5782+
#include "monkestation\code\datums\elements\trash_if_empty.dm"
57825783
#include "monkestation\code\datums\elements\uncompressed_storage.dm"
57835784
#include "monkestation\code\datums\ert\moff_inspectors.dm"
57845785
#include "monkestation\code\datums\id_trim\jobs.dm"
@@ -5825,6 +5826,7 @@
58255826
#include "monkestation\code\game\objects\effects\spawners\random\fishing.dm"
58265827
#include "monkestation\code\game\objects\items\caneswords.dm"
58275828
#include "monkestation\code\game\objects\items\choice_beacon.dm"
5829+
#include "monkestation\code\game\objects\items\cigs_lighters.dm"
58285830
#include "monkestation\code\game\objects\items\cirno_plush.dm"
58295831
#include "monkestation\code\game\objects\items\gravity_gun.dm"
58305832
#include "monkestation\code\game\objects\items\jukebox_beacon.dm"
@@ -5836,6 +5838,7 @@
58365838
#include "monkestation\code\game\objects\items\spraycan_gun.dm"
58375839
#include "monkestation\code\game\objects\items\stickers.dm"
58385840
#include "monkestation\code\game\objects\items\superglue.dm"
5841+
#include "monkestation\code\game\objects\items\trash.dm"
58395842
#include "monkestation\code\game\objects\items\turf_demolisher.dm"
58405843
#include "monkestation\code\game\objects\items\venom_knife.dm"
58415844
#include "monkestation\code\game\objects\items\AI_modules\monke_lawsets.dm"
@@ -5856,7 +5859,9 @@
58565859
#include "monkestation\code\game\objects\items\effects\nugget.dm"
58575860
#include "monkestation\code\game\objects\items\effects\washing_machine.dm"
58585861
#include "monkestation\code\game\objects\items\food\corndog.dm"
5862+
#include "monkestation\code\game\objects\items\food\frozen.dm"
58595863
#include "monkestation\code\game\objects\items\food\misc.dm"
5864+
#include "monkestation\code\game\objects\items\food\snacks.dm"
58605865
#include "monkestation\code\game\objects\items\food\spaghetti.dm"
58615866
#include "monkestation\code\game\objects\items\granters\elance.dm"
58625867
#include "monkestation\code\game\objects\items\grenades\monkey_barrel.dm"
@@ -5870,6 +5875,7 @@
58705875
#include "monkestation\code\game\objects\items\storage\book.dm"
58715876
#include "monkestation\code\game\objects\items\storage\boxes.dm"
58725877
#include "monkestation\code\game\objects\items\storage\crate.dm"
5878+
#include "monkestation\code\game\objects\items\storage\fancy.dm"
58735879
#include "monkestation\code\game\objects\items\storage\garment.dm"
58745880
#include "monkestation\code\game\objects\items\storage\uplink_kits.dm"
58755881
#include "monkestation\code\game\objects\structures\tables_racks.dm"
@@ -7129,6 +7135,7 @@
71297135
#include "monkestation\code\modules\possession\possessed_hud.dm"
71307136
#include "monkestation\code\modules\power\cables.dm"
71317137
#include "monkestation\code\modules\power\lighting\floor_light.dm"
7138+
#include "monkestation\code\modules\power\lighting\light_items.dm"
71327139
#include "monkestation\code\modules\power\lighting\neon_lining.dm"
71337140
#include "monkestation\code\modules\power\power_transmission_laser\code\announcement.dm"
71347141
#include "monkestation\code\modules\power\power_transmission_laser\code\beam.dm"
@@ -7139,6 +7146,7 @@
71397146
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_accelerator.dm"
71407147
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_controller.dm"
71417148
#include "monkestation\code\modules\power\singularity\particle_accelerator\particle_emitter.dm"
7149+
#include "monkestation\code\modules\projectiles\ammunition\_ammunition.dm"
71427150
#include "monkestation\code\modules\projectiles\guns\ballistic\revolver.dm"
71437151
#include "monkestation\code\modules\projectiles\guns\ballistic\ryanecorp_whispering_jester.dm"
71447152
#include "monkestation\code\modules\projectiles\guns\special\meat_hook.dm"
@@ -7231,9 +7239,12 @@
72317239
#include "monkestation\code\modules\reagents\fun\liquid_justice.dm"
72327240
#include "monkestation\code\modules\reagents\fun\shakeium.dm"
72337241
#include "monkestation\code\modules\reagents\reagent_containers\blood_pack.dm"
7242+
#include "monkestation\code\modules\reagents\reagent_containers\condiment.dm"
72347243
#include "monkestation\code\modules\reagents\reagent_containers\drinks.dm"
72357244
#include "monkestation\code\modules\reagents\reagent_containers\sunsetglass.dm"
7245+
#include "monkestation\code\modules\reagents\reagent_containers\cups\_cup.dm"
72367246
#include "monkestation\code\modules\reagents\reagent_containers\cups\bottle.dm"
7247+
#include "monkestation\code\modules\reagents\reagent_containers\cups\glassbottle.dm"
72377248
#include "monkestation\code\modules\reagents\recipes\fun.dm"
72387249
#include "monkestation\code\modules\reagents\recipes\medical.dm"
72397250
#include "monkestation\code\modules\replays\hooks\generic_hooks.dm"

0 commit comments

Comments
 (0)