basic vibebot (and small rework) (#84143)

## About The Pull Request
this refactors vibebots and reworks them to be a little more useful.
vibebots can now play a range of MIDI songs. they will seek out
depressed players and play an upbeat tune for them and celebrate with
them to cheer them up and increase their mood a little bit. if its ur
birthday, it will play a happy birthday tune for u. emagged vibebots are
ruthless, they will look for sad people and go play grim music for them
to ruin their day even more and decrease their moods.

## Why It's Good For The Game
refactors vibebots into basic bots and gives them a bit more character

## Changelog
🆑
refactor: vibebots are not basic bots
add: vibebots will now seek out the depressed and cheer them up
/🆑
This commit is contained in:
Ben10Omintrix
2024-06-24 22:28:52 -04:00
committed by GitHub
parent 5e6abcdedc
commit abbd040526
15 changed files with 207 additions and 102 deletions
@@ -0,0 +1,30 @@
/mob/living/basic/bot/vibebot
name = "\improper Vibebot"
desc = "A little robot. It's just vibing, doing its thing."
icon = 'icons/mob/silicon/aibots.dmi'
icon_state = "vibebot1"
base_icon_state = "vibebot"
pass_flags = PASSMOB | PASSFLAPS
light_system = OVERLAY_LIGHT
light_range = 6
ai_controller = /datum/ai_controller/basic_controller/bot/vibebot
light_power = 2
hackables = "vibing scanners"
radio_key = /obj/item/encryptionkey/headset_service
radio_channel = RADIO_CHANNEL_SERVICE
bot_type = VIBE_BOT
data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC
path_image_color = "#2cac12"
possessed_message = "You are a vibebot! Maintain the station's vibes to the best of your ability!"
/mob/living/basic/bot/vibebot/Initialize(mapload)
. = ..()
var/static/list/innate_actions = list(
/datum/action/cooldown/mob_cooldown/bot/vibe = BB_VIBEBOT_PARTY_ABILITY,
)
grant_actions_by_list(innate_actions)
var/obj/item/instrument/piano_synth/piano = new(src)
ai_controller.set_blackboard_key(BB_SONG_INSTRUMENT, piano)
update_appearance(UPDATE_ICON)
@@ -0,0 +1,59 @@
/**
* Vibebot's vibe ability
*
* Given to vibebots so sentient ones can change/reset thier colors at will.
*/
#define VIBE_MOOD_TIMER 30 SECONDS
/datum/action/cooldown/mob_cooldown/bot/vibe
name = "Vibe"
desc = "Use on yourself to remove color!"
click_to_activate = TRUE
button_icon = 'icons/mob/actions/actions_minor_antag.dmi'
button_icon_state = "funk"
///cooldown to apply a new mood
COOLDOWN_DECLARE(change_mood)
/datum/action/cooldown/mob_cooldown/bot/vibe/Grant(mob/granted_to)
. = ..()
if(isnull(granted_to))
return
RegisterSignal(granted_to, COMSIG_BOT_RESET, PROC_REF(remove_colors))
/datum/action/cooldown/mob_cooldown/bot/vibe/Activate(atom/target)
if(target == owner)
remove_colors()
return TRUE
vibe()
StartCooldown()
return TRUE
///Gives a random color
/datum/action/cooldown/mob_cooldown/bot/vibe/proc/vibe()
var/mob/living/basic/bot/bot_owner = owner
var/final_color = (bot_owner.bot_access_flags & BOT_COVER_EMAGGED) ? COLOR_GRAY : "#[random_color()]"
owner.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
owner.add_atom_colour(final_color, TEMPORARY_COLOUR_PRIORITY)
owner.set_light_color(owner.color)
if(!COOLDOWN_FINISHED(src, change_mood))
return
var/mood_to_add = bot_owner.bot_access_flags & BOT_COVER_EMAGGED ? /datum/mood_event/depressing_party : /datum/mood_event/festive_party
for(var/mob/living/carbon/human/human_target in oview(1, owner))
human_target.add_mood_event("vibebot_party", mood_to_add)
COOLDOWN_START(src, change_mood, VIBE_MOOD_TIMER)
///Removes all colors
/datum/action/cooldown/mob_cooldown/bot/vibe/proc/remove_colors()
owner.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
owner.set_light_color(null)
/datum/mood_event/depressing_party
description = "That was a really grim party..."
mood_change = -1
timeout = 30 SECONDS
/datum/mood_event/festive_party
description = "That was a really fantastic party!"
mood_change = 2
timeout = 30 SECONDS
#undef VIBE_MOOD_TIMER
@@ -0,0 +1,88 @@
/datum/ai_controller/basic_controller/bot/vibebot
blackboard = list(
BB_UNREACHABLE_LIST_COOLDOWN = 2 MINUTES,
BB_VIBEBOT_HAPPY_SONG = VIBEBOT_CHEER_SONG,
BB_VIBEBOT_GRIM_SONG = VIBEBOT_GRIM_MUSIC,
BB_VIBEBOT_BIRTHDAY_SONG = VIBEBOT_HAPPY_BIRTHDAY,
)
planning_subtrees = list(
/datum/ai_planning_subtree/respond_to_summon,
/datum/ai_planning_subtree/manage_unreachable_list,
/datum/ai_planning_subtree/find_party_friends,
/datum/ai_planning_subtree/find_patrol_beacon,
)
reset_keys = list(
BB_BEACON_TARGET,
BB_PREVIOUS_BEACON_TARGET,
BB_VIBEBOT_PARTY_TARGET,
BB_BOT_SUMMON_TARGET,
)
ai_traits = PAUSE_DURING_DO_AFTER
/datum/ai_controller/basic_controller/bot/vibebot/TryPossessPawn(atom/new_pawn)
. = ..()
if(. & AI_CONTROLLER_INCOMPATIBLE)
return
RegisterSignal(new_pawn, COMSIG_AI_BLACKBOARD_KEY_SET(BB_VIBEBOT_PARTY_TARGET), PROC_REF(play_music))
/datum/ai_controller/basic_controller/bot/vibebot/proc/play_music(datum/source, blackboard_key)
SIGNAL_HANDLER
var/mob/living/basic/bot/living_bot = pawn
var/obj/item/instrument/instrument = blackboard[BB_SONG_INSTRUMENT]
if(isnull(instrument))
return
var/atom/target = blackboard[blackboard_key]
var/datum/song/song = instrument.song
song.stop_playing()
var/song_lines
if(living_bot.bot_access_flags & BOT_COVER_EMAGGED)
song_lines = blackboard[BB_VIBEBOT_GRIM_SONG]
else
song_lines = HAS_TRAIT(target, TRAIT_BIRTHDAY_BOY) ? blackboard[BB_VIBEBOT_BIRTHDAY_SONG] : blackboard[BB_VIBEBOT_HAPPY_SONG]
if(isnull(song_lines))
return
song.ParseSong(new_song = song_lines)
song.start_playing(pawn)
addtimer(CALLBACK(song, TYPE_PROC_REF(/datum/song, stop_playing)), 10 SECONDS) //in 10 seconds, stop playing music
///subtree we use to find party friends in general
/datum/ai_planning_subtree/find_party_friends
/datum/ai_planning_subtree/find_party_friends/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
var/static/list/type_to_search = typecacheof(list(/mob/living/carbon/human))
if(!controller.blackboard_key_exists(BB_VIBEBOT_PARTY_TARGET))
controller.queue_behavior(/datum/ai_behavior/bot_search/party_friends, BB_VIBEBOT_PARTY_TARGET, type_to_search)
return
controller.queue_behavior(/datum/ai_behavior/targeted_mob_ability/and_clear_target/vibebot_party, BB_VIBEBOT_PARTY_ABILITY, BB_VIBEBOT_PARTY_TARGET)
return SUBTREE_RETURN_FINISH_PLANNING
///behavior we use to party with people
/datum/ai_behavior/targeted_mob_ability/and_clear_target/vibebot_party
behavior_flags = AI_BEHAVIOR_REQUIRE_REACH | AI_BEHAVIOR_REQUIRE_MOVEMENT
/datum/ai_behavior/targeted_mob_ability/and_clear_target/vibebot_party/setup(datum/ai_controller/controller, ability_key, target_key)
. = ..()
var/atom/target = controller.blackboard[target_key]
if(QDELETED(target))
return FALSE
set_movement_target(controller, target)
/datum/ai_behavior/targeted_mob_ability/and_clear_target/vibebot_party/finish_action(datum/ai_controller/controller, succeeded, ability_key, target_key)
var/atom/target = controller.blackboard[target_key]
controller.set_blackboard_key_assoc_lazylist(BB_TEMPORARY_IGNORE_LIST, target, TRUE)
if(succeeded)
var/mob/living/living_pawn = controller.pawn
living_pawn.manual_emote("celebrates with [target]!")
living_pawn.emote("flip")
return ..()
///behavior that searches for party friends
/datum/ai_behavior/bot_search/party_friends
action_cooldown = 5 SECONDS
/datum/ai_behavior/bot_search/party_friends/valid_target(datum/ai_controller/basic_controller/bot/controller, mob/living/carbon/human/my_target)
if(my_target.stat != CONSCIOUS || isnull(my_target.mind))
return FALSE
return (my_target.mob_mood.mood_level < MOOD_LEVEL_NEUTRAL || HAS_TRAIT(my_target, TRAIT_BIRTHDAY_BOY))