Files
kiwistation/code/datums/components/mood.dm
T
Qustinnus 5140cff38c [reviewpls] Adds moodlets to the game - [Please give suggestions for trait additions in comments] (#35475)
Floyd / Qustinnus (Sprites by Ausops, Some moodlets by Ike709)

add: Adds mood, which can be found by clicking on the face icon on your screen.
add: Adds various moodlets which affect your mood. Try eating your favourite food, playing an arcade game, reading a book, or petting a doggo to increase your moo. Also be sure to take care of your hunger on a regular basis, like always.
add: Adds config option to disable/enable mood.
add: Indoor area's now have a beauty var defined by the amount of cleanables in them, (We can later expand this to something like rimworld, where structures could make rooms more beautiful). These also affect mood. (Janitor now has gameplay purpose besides slipping and removing useless decals)
remove: Removes hunger slowdown, replacing it with slowdown by being depressed
imageadd: Icons for mood states and depression states


What this PR is

This PR adds a system that allows player to gain and lose moodlets based on events occuring to, and around them. These events then give the player a mood value based on what it is. For example a hug could give you +1 mood, while being stabbed in the eye with a screwdriver can give -5 mood. All these moodlets together determine the mood of your character which currently affects the following things:

    Movement speed - If you are very sad you move slower. Replacing movement slow from hunger. (hunger now instead affects mood)
    Screen blur - If you are sad you gain an overlay that slightly blurs the screen, increasing in severity as you get sadder.
    Interaction / do after speed - If you are sad or happy your interaction speed with things such as handcuffs is changed. with a 25% longer time if you are sad, or 10% shorter time if you are extremely happy.
    Hunger rate - You gain hunger slower if you are very happy.
2018-03-08 14:15:57 +13:00

123 lines
4.0 KiB
Plaintext

/datum/component/mood
var/mood //Real happiness
var/shown_mood //Shown happiness, this is what others can see when they try to examine you, prevents antag checking by noticing traitors are always very happy.
var/mood_level //To track what stage of moodies they're on
var/mood_modifier = 1 //Modifier to allow certain mobs to be less affected by moodlets
var/datum/mood_event/list/mood_events = list()
var/mob/living/owner
/datum/component/mood/Initialize()
if(!isliving(parent))
. = COMPONENT_INCOMPATIBLE
CRASH("Some good for nothing loser put a mood component on something that isn't even a living mob.")
START_PROCESSING(SSmood, src)
owner = parent
/datum/component/mood/Destroy()
STOP_PROCESSING(SSmood, src)
return ..()
/datum/component/mood/proc/print_mood()
var/msg = "<span class='info'>*---------*\n<EM>Your current mood</EM>\n"
for(var/i in mood_events)
var/datum/mood_event/event = mood_events[i]
msg += event.description
to_chat(owner, msg)
/datum/component/mood/proc/update_mood() //Called whenever a mood event is added or removed
mood = 0
shown_mood = 0
for(var/i in mood_events)
var/datum/mood_event/event = mood_events[i]
mood += event.mood_change
if(!event.hidden)
shown_mood += event.mood_change
mood *= mood_modifier
shown_mood *= mood_modifier
switch(mood)
if(-INFINITY to MOOD_LEVEL_SAD4)
mood_level = 1
if(MOOD_LEVEL_SAD4 to MOOD_LEVEL_SAD3)
mood_level = 2
if(MOOD_LEVEL_SAD3 to MOOD_LEVEL_SAD2)
mood_level = 3
if(MOOD_LEVEL_SAD2 to MOOD_LEVEL_SAD1)
mood_level = 4
if(MOOD_LEVEL_SAD1 to MOOD_LEVEL_HAPPY1)
mood_level = 5
if(MOOD_LEVEL_HAPPY1 to MOOD_LEVEL_HAPPY2)
mood_level = 6
if(MOOD_LEVEL_HAPPY2 to MOOD_LEVEL_HAPPY3)
mood_level = 7
if(MOOD_LEVEL_HAPPY3 to MOOD_LEVEL_HAPPY4)
mood_level = 8
if(MOOD_LEVEL_HAPPY4 to INFINITY)
mood_level = 9
if(owner.client && owner.hud_used)
owner.hud_used.mood.icon_state = "mood[mood_level]"
/datum/component/mood/process() //Called on SSmood process
switch(mood)
if(-INFINITY to MOOD_LEVEL_SAD4)
owner.overlay_fullscreen("depression", /obj/screen/fullscreen/depression, 3)
if(MOOD_LEVEL_SAD4 to MOOD_LEVEL_SAD3)
owner.overlay_fullscreen("depression", /obj/screen/fullscreen/depression, 2)
if(MOOD_LEVEL_SAD3 to MOOD_LEVEL_SAD2)
owner.overlay_fullscreen("depression", /obj/screen/fullscreen/depression, 1)
if(MOOD_LEVEL_SAD2 to INFINITY)
owner.clear_fullscreen("depression")
if(owner.has_trait(TRAIT_DEPRESSION))
if(prob(0.1))
add_event("depression", /datum/mood_event/depression)
clear_event("jolly")
if(owner.has_trait(TRAIT_JOLLY))
if(prob(0.1))
add_event("jolly", /datum/mood_event/jolly)
clear_event("depression")
/datum/component/mood/proc/add_event(category, type, param) //Category will override any events in the same category, should be unique unless the event is based on the same thing like hunger.
var/datum/mood_event/the_event
if(mood_events[category])
the_event = mood_events[category]
if(the_event.type != type)
clear_event(category)
return .()
else
return 0 //Don't have to update the event.
else
the_event = new type(src, param)
mood_events[category] = the_event
update_mood()
if(the_event.timeout)
addtimer(CALLBACK(src, .proc/clear_event, category), the_event.timeout)
/datum/component/mood/proc/clear_event(category)
var/datum/mood_event/event = mood_events[category]
if(!event)
return 0
mood_events -= category
qdel(event)
update_mood()
/datum/component/mood/proc/update_beauty(var/area/A)
if(A.outdoors) //if we're outside, we don't care.
clear_event("area_beauty")
return FALSE
switch(A.beauty)
if(-INFINITY to BEAUTY_LEVEL_HORRID)
add_event("area_beauty", /datum/mood_event/disgustingroom)
if(BEAUTY_LEVEL_HORRID to BEAUTY_LEVEL_BAD)
add_event("area_beauty", /datum/mood_event/grossroom)
if(BEAUTY_LEVEL_BAD to BEAUTY_LEVEL_GOOD)
clear_event("area_beauty")
if(BEAUTY_LEVEL_GOOD to BEAUTY_LEVEL_GREAT)
add_event("area_beauty", /datum/mood_event/niceroom)
if(BEAUTY_LEVEL_GREAT to INFINITY)
add_event("area_beauty", /datum/mood_event/greatroom)