Skip to content

Commit

Permalink
[MIRROR] virtual pets (#1203)
Browse files Browse the repository at this point in the history
* virtual pets

* Update emote.dm

* Update emote.dm

* We are going to modularize this correctly

---------

Co-authored-by: Ben10Omintrix <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Feb 29, 2024
1 parent 1e68b4f commit 17a297a
Show file tree
Hide file tree
Showing 31 changed files with 1,528 additions and 70 deletions.
17 changes: 17 additions & 0 deletions code/__DEFINES/ai/pets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,20 @@
/// key that holds items we arent interested in hoarding
#define BB_IGNORE_ITEMS "ignore_items"

//virtual pet keys
///the last PDA message we must relay
#define BB_LAST_RECIEVED_MESSAGE "last_recieved_message"
///our current virtual pet level
#define BB_VIRTUAL_PET_LEVEL "virtual_pet_level"
///the target we will play with
#define BB_NEARBY_PLAYMATE "nearby_playmate"
///cooldown till we search for playmates
#define BB_NEXT_PLAYDATE "next_playdate"
///our ability to trigger lights
#define BB_LIGHTS_ABILITY "lights_ability"
///our ability to capture images
#define BB_PHOTO_ABILITY "photo_ability"
///the name of our trick
#define BB_TRICK_NAME "trick_name"
///the sequence of our trick
#define BB_TRICK_SEQUENCE "trick_sequence"
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/signals_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@

/// From /datum/action/cooldown/manual_heart/Activate(): ()
#define COMSIG_HEART_MANUAL_PULSE "heart_manual_pulse"

/// From /datum/action/cooldown/mob_cooldown/capture_photo/Activate():
#define COMSIG_ACTION_PHOTO_CAPTURED "action_photo_captured"
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/signals_atom/signals_atom_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@
#define COMSIG_ATOM_GERM_UNEXPOSED "atom_germ_unexposed"
/// signal sent to puzzle pieces by activator
#define COMSIG_PUZZLE_COMPLETED "puzzle_completed"

/// From /datum/compomnent/cleaner/clean()
#define COMSIG_ATOM_PRE_CLEAN "atom_pre_clean"
///cancel clean
#define COMSIG_ATOM_CANCEL_CLEAN (1<<0)
8 changes: 8 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,11 @@
/// Sent to a mob grabbing another mob: (mob/living/grabbing)
#define COMSIG_LIVING_GRAB "living_grab"
// Return COMPONENT_CANCEL_ATTACK_CHAIN / COMPONENT_SKIP_ATTACK_CHAIN to stop the grab

/// From /datum/element/basic_eating/try_eating()
#define COMSIG_MOB_PRE_EAT "mob_pre_eat"
///cancel eating attempt
#define COMSIG_MOB_CANCEL_EAT (1<<0)

/// From /datum/element/basic_eating/finish_eating()
#define COMSIG_MOB_ATE "mob_ate"
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@
///from /datum/action/vehicle/sealed/headlights/vim/Trigger(): (headlights_on)
#define COMSIG_VIM_HEADLIGHTS_TOGGLED "vim_headlights_toggled"

///from /datum/computer_file/program/messenger/proc/receive_message
#define COMSIG_COMPUTER_RECIEVED_MESSAGE "computer_recieved_message"
///from /datum/computer_file/program/virtual_pet/proc/handle_level_up
#define COMSIG_VIRTUAL_PET_LEVEL_UP "virtual_pet_level_up"

// /obj/vehicle/sealed/mecha signals

/// sent if you attach equipment to mecha
Expand Down
3 changes: 1 addition & 2 deletions code/datums/components/cleaner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@
*/
/datum/component/cleaner/proc/clean(datum/source, atom/target, mob/living/user, clean_target = TRUE)
//make sure we don't attempt to clean something while it's already being cleaned
if(HAS_TRAIT(target, TRAIT_CURRENTLY_CLEANING))
if(HAS_TRAIT(target, TRAIT_CURRENTLY_CLEANING) || (SEND_SIGNAL(target, COMSIG_ATOM_PRE_CLEAN, user) & COMSIG_ATOM_CANCEL_CLEAN))
return

//add the trait and overlay
ADD_TRAIT(target, TRAIT_CURRENTLY_CLEANING, REF(src))
// We need to update our planes on overlay changes
Expand Down
3 changes: 3 additions & 0 deletions code/datums/elements/basic_eating.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
/datum/element/basic_eating/proc/try_eating(mob/living/eater, atom/target)
if(!is_type_in_list(target, food_types))
return FALSE
if(SEND_SIGNAL(eater, COMSIG_MOB_PRE_EAT, target) & COMSIG_MOB_CANCEL_EAT)
return FALSE
var/eat_verb
if(drinking)
eat_verb = pick("slurp","sip","guzzle","drink","quaff","suck")
Expand All @@ -79,6 +81,7 @@
return TRUE

/datum/element/basic_eating/proc/finish_eating(mob/living/eater, atom/target)
SEND_SIGNAL(eater, COMSIG_MOB_ATE)
if(drinking)
playsound(eater.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
else
Expand Down
34 changes: 19 additions & 15 deletions code/datums/elements/cleaning.dm
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
/datum/element/cleaning

/datum/element/cleaning/Attach(datum/target)
. = ..()
if(!ismovable(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(Clean))
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(clean))

/datum/element/cleaning/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)

/datum/element/cleaning/proc/Clean(datum/source)
/datum/element/cleaning/proc/clean(datum/source)
SIGNAL_HANDLER

var/atom/movable/AM = source
var/turf/tile = AM.loc
var/atom/movable/atom_movable = source
var/turf/tile = atom_movable.loc
if(!isturf(tile))
return

tile.wash(CLEAN_SCRUB)
for(var/A in tile)
for(var/atom/cleaned as anything in tile)
// Clean small items that are lying on the ground
if(isitem(A))
var/obj/item/I = A
if(I.w_class <= WEIGHT_CLASS_SMALL && !ismob(I.loc))
I.wash(CLEAN_SCRUB)
if(isitem(cleaned))
var/obj/item/cleaned_item = cleaned
if(cleaned_item.w_class <= WEIGHT_CLASS_SMALL)
cleaned_item.wash(CLEAN_SCRUB)
continue
// Clean humans that are lying down
else if(ishuman(A))
var/mob/living/carbon/human/cleaned_human = A
if(cleaned_human.body_position == LYING_DOWN)
cleaned_human.wash(CLEAN_SCRUB)
cleaned_human.regenerate_icons()
to_chat(cleaned_human, span_danger("[AM] cleans your face!"))
if(!ishuman(cleaned))
continue
var/mob/living/carbon/human/cleaned_human = cleaned
if(cleaned_human.body_position == LYING_DOWN)
cleaned_human.wash(CLEAN_SCRUB)
cleaned_human.regenerate_icons()
to_chat(cleaned_human, span_danger("[atom_movable] cleans your face!"))
21 changes: 6 additions & 15 deletions code/datums/emotes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@
var/can_message_change = FALSE
/// How long is the cooldown on the audio of the emote, if it has one?
var/audio_cooldown = 2 SECONDS
//NOVA EDIT ADDITION BEGIN - EMOTES
var/sound_volume = 25 //Emote volume
var/list/allowed_species
/// Are silicons explicitely allowed to use this emote?
var/silicon_allowed = FALSE
//NOVA EDIT ADDITION END

/datum/emote/New()
switch(mob_type_allowed_typecache)
Expand Down Expand Up @@ -299,15 +293,12 @@
return FALSE

//NOVA EDIT BEGIN
if(allowed_species)
var/check = FALSE
if(silicon_allowed && issilicon(user))
check = TRUE
if(ishuman(user))
var/mob/living/carbon/human/sender = user
if(sender.dna.species.type in allowed_species)
check = TRUE
return check
if(allowed_species && ishuman(user))
var/mob/living/carbon/human/sender = user
if(sender.dna.species.type in allowed_species)
return TRUE
else
return FALSE
//NOVA EDIT END

return TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@
name = "Gutlunch"
icon_file = 'icons/mob/simple/lavaland/lavaland_monsters.dmi'
json_config = 'code/datums/greyscale/json_configs/gutlunch.json'

9 changes: 9 additions & 0 deletions code/game/objects/items/food/sweets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
w_class = WEIGHT_CLASS_TINY
crafting_complexity = FOOD_COMPLEXITY_1

/obj/item/food/virtual_chocolate
name = "virtual chocolate bar"
desc = "Digital food only gives off the sensation of eating... without any of the nutritional benefits."
icon_state = "virtual_chocolate"
tastes = list("nothing" = 1)
foodtypes = NONE
w_class = WEIGHT_CLASS_TINY


/obj/item/food/chococoin
name = "chocolate coin"
desc = "A completely edible but non-flippable festive coin."
Expand Down
112 changes: 112 additions & 0 deletions code/modules/mob/living/basic/pets/orbie/orbie.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#define ORBIE_MAXIMUM_HEALTH 300

/mob/living/basic/orbie
name = "Orbie"
desc = "An orb shaped hologram."
icon = 'icons/mob/simple/pets.dmi'
icon_state = "orbie"
icon_living = "orbie"
speed = 0
maxHealth = 100
light_on = FALSE
light_system = OVERLAY_LIGHT
light_range = 6
light_color = "#64bee1"
health = 100
habitable_atmos = list("min_oxy" = 0, "max_oxy" = 0, "min_plas" = 0, "max_plas" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
unsuitable_atmos_damage = 0
can_buckle_to = FALSE
density = FALSE
pass_flags = PASSMOB
move_force = 0
move_resist = 0
pull_force = 0
minimum_survivable_temperature = TCMB
maximum_survivable_temperature = INFINITY
death_message = "fades out of existence!"
ai_controller = /datum/ai_controller/basic_controller/orbie
///are we happy or not?
var/happy_state = FALSE
///overlay for our neutral eyes
var/static/mutable_appearance/eyes_overlay = mutable_appearance('icons/mob/simple/pets.dmi', "orbie_eye_overlay")
///overlay for when our eyes are emitting light
var/static/mutable_appearance/orbie_light_overlay = mutable_appearance('icons/mob/simple/pets.dmi', "orbie_light_overlay")
///overlay for the flame propellar
var/static/mutable_appearance/flame_overlay = mutable_appearance('icons/mob/simple/pets.dmi', "orbie_flame_overlay")
///overlay for our happy eyes
var/static/mutable_appearance/happy_eyes_overlay = mutable_appearance('icons/mob/simple/pets.dmi', "orbie_happy_eye_overlay")
///commands we can give orbie
var/list/pet_commands = list(
/datum/pet_command/idle,
/datum/pet_command/free,
/datum/pet_command/untargeted_ability/pet_lights,
/datum/pet_command/point_targeting/use_ability/take_photo,
/datum/pet_command/follow/orbie,
/datum/pet_command/perform_trick_sequence,
)

/mob/living/basic/orbie/Initialize(mapload)
. = ..()
var/static/list/food_types = list(/obj/item/food/virtual_chocolate)
AddComponent(/datum/component/obeys_commands, pet_commands)
AddElement(/datum/element/basic_eating, food_types = food_types)
RegisterSignal(src, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(on_pulled))
RegisterSignal(src, COMSIG_VIRTUAL_PET_LEVEL_UP, PROC_REF(on_level_up))
RegisterSignal(src, COMSIG_MOB_CLICKON, PROC_REF(on_click))
RegisterSignal(src, COMSIG_ATOM_UPDATE_LIGHT_ON, PROC_REF(on_lights))
ai_controller.set_blackboard_key(BB_BASIC_FOODS, typecacheof(food_types))
update_appearance()

/mob/living/basic/orbie/proc/on_click(mob/living/basic/source, atom/target, params)
SIGNAL_HANDLER

if(!CanReach(target))
return

if(src == target || happy_state || !istype(target))
return

toggle_happy_state()
addtimer(CALLBACK(src, PROC_REF(toggle_happy_state)), 30 SECONDS)

/mob/living/basic/orbie/proc/on_lights(datum/source)
SIGNAL_HANDLER

update_appearance()

/mob/living/basic/orbie/proc/toggle_happy_state()
happy_state = !happy_state
update_appearance()

/mob/living/basic/orbie/proc/on_pulled(datum/source) //i need move resist at 0, but i also dont want him to be pulled
SIGNAL_HANDLER

return COMSIG_ATOM_CANT_PULL

/mob/living/basic/orbie/proc/on_level_up(datum/source, new_level)
SIGNAL_HANDLER

if(maxHealth >= ORBIE_MAXIMUM_HEALTH)
UnregisterSignal(src, COMSIG_VIRTUAL_PET_LEVEL_UP)
return

maxHealth += 100
heal_overall_damage(maxHealth - health)


/mob/living/basic/orbie/update_overlays()
. = ..()
if(stat == DEAD)
return
. += flame_overlay
if(happy_state)
. += happy_eyes_overlay
else if(light_on)
. += orbie_light_overlay
else
. += eyes_overlay

/mob/living/basic/orbie/gib()
death(TRUE)

#undef ORBIE_MAXIMUM_HEALTH
46 changes: 46 additions & 0 deletions code/modules/mob/living/basic/pets/orbie/orbie_abilities.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/datum/action/cooldown/mob_cooldown/lights
name = "Toggle Lights"
button_icon = 'icons/mob/simple/pets.dmi'
button_icon_state = "orbie_light_action"
background_icon_state = "bg_default"
overlay_icon_state = "bg_default_border"
click_to_activate = FALSE

/datum/action/cooldown/mob_cooldown/lights/Activate()
owner.set_light_on(!owner.light_on)
return TRUE


/datum/action/cooldown/mob_cooldown/capture_photo
name = "Camera"
button_icon = 'icons/mob/simple/pets.dmi'
button_icon_state = "orbie_light_action"
background_icon_state = "bg_default"
overlay_icon_state = "bg_default_border"
cooldown_time = 30 SECONDS
///camera we use to take photos
var/obj/item/camera/ability_camera

/datum/action/cooldown/mob_cooldown/capture_photo/Grant(mob/grant_to)
. = ..()
if(isnull(owner))
return
ability_camera = new(owner)
ability_camera.print_picture_on_snap = FALSE
RegisterSignal(ability_camera, COMSIG_PREQDELETED, PROC_REF(on_camera_delete))

/datum/action/cooldown/mob_cooldown/capture_photo/Activate(atom/target)
if(isnull(ability_camera))
return FALSE
ability_camera.captureimage(target, owner)
StartCooldown()
return TRUE

/datum/action/cooldown/mob_cooldown/capture_photo/proc/on_camera_delete(datum/source)
SIGNAL_HANDLER
UnregisterSignal(ability_camera, COMSIG_PREQDELETED)
ability_camera = null

/datum/action/cooldown/mob_cooldown/capture_photo/Destroy()
QDEL_NULL(ability_camera)
return ..()
Loading

0 comments on commit 17a297a

Please sign in to comment.