Skip to content

Commit 342aeca

Browse files
authored
Kapmood (#1113)
* framework * initial bits * features 1 * chance perspective in text * minor fix * destroy
1 parent dd0ad4e commit 342aeca

File tree

15 files changed

+538
-7
lines changed

15 files changed

+538
-7
lines changed

code/__DEFINES/hud.dm

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
#define ui_blob_health "EAST-1:28,CENTER+1:21"
9999
#define ui_spacesuit "EAST-1:28,CENTER-3:14"
100100
#define ui_stamina "EAST-1:28,CENTER-2:17"
101+
#define ui_mood "EAST-1:28,CENTER:21"
101102

102103
//Pop-up inventory
103104
#define ui_shoes "WEST+1:8,SOUTH:5"

code/__DEFINES/mobs.dm

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
#define BLOOD_CIRC_BAD 60
3232
#define BLOOD_CIRC_SURVIVE 30
3333

34+
// Mood levels
35+
#define MOOD_LEVEL_HAPPY4 20
36+
#define MOOD_LEVEL_HAPPY3 15
37+
#define MOOD_LEVEL_HAPPY2 10
38+
#define MOOD_LEVEL_HAPPY1 5
39+
#define MOOD_LEVEL_NEUTRAL 0
40+
#define MOOD_LEVEL_SAD1 -5
41+
#define MOOD_LEVEL_SAD2 -10
42+
#define MOOD_LEVEL_SAD3 -15
43+
#define MOOD_LEVEL_SAD4 -20
44+
3445
// Values for flash_pain()
3546
#define PAIN_SMALL "weakest_pain"
3647
#define PAIN_MEDIUM "weak_pain"

code/_onclick/hud/screen_objects.dm

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
SEND_SIGNAL(src, COMSIG_CLICK, location, control, params, usr)
5959

60-
6160
/atom/movable/screen/examine(mob/user)
6261
return list()
6362

@@ -1050,3 +1049,9 @@
10501049
/atom/movable/screen/vis_holder
10511050
icon = ""
10521051
invisibility = INVISIBILITY_MAXIMUM
1052+
1053+
/atom/movable/screen/mood
1054+
name = "mood"
1055+
icon_state = "mood5"
1056+
screen_loc = ui_mood
1057+
color = "#4b96c4"

code/modules/grab/grab_datum.dm

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ GLOBAL_LIST_EMPTY(all_grabstates)
181181
*/
182182

183183
// What happens when you upgrade from one grab state to the next.
184-
/datum/grab/proc/upgrade_effect(obj/item/hand_item/grab/G, datum/grab/old_grab)
184+
/datum/grab/proc/upgrade_effect(obj/item/hand_item/grab/G)
185185
SHOULD_CALL_PARENT(TRUE)
186186

187187
G.remove_competing_grabs()
@@ -210,7 +210,7 @@ GLOBAL_LIST_EMPTY(all_grabstates)
210210
return TRUE
211211

212212
// What happens when you downgrade from one grab state to the next.
213-
/datum/grab/proc/downgrade_effect(obj/item/hand_item/grab/G, datum/grab/old_grab)
213+
/datum/grab/proc/downgrade_effect(obj/item/hand_item/grab/G)
214214
return
215215

216216
// Conditions to see if downgrading is possible

code/modules/mob/living/carbon/pain.dm

+14
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@
180180
shock_stage = max(shock_stage + 1, SHOCK_TIER_4 + 1)
181181

182182
var/pain = getPain()
183+
184+
// Pain mood adjustment
185+
if(pain == 0)
186+
mob_mood?.clear_mood_event("pain")
187+
else
188+
if(pain >= PAIN_AMT_AGONIZING)
189+
mob_mood.add_mood_event("pain", /datum/mood_event/pain_four)
190+
else if(pain >= PAIN_AMT_MEDIUM)
191+
mob_mood.add_mood_event("pain", /datum/mood_event/pain_three)
192+
else if(pain >= PAIN_AMT_LOW)
193+
mob_mood.add_mood_event("pain", /datum/mood_event/pain_two)
194+
else
195+
mob_mood.add_mood_event("pain", /datum/mood_event/pain_one)
196+
183197
if(pain >= max(SHOCK_MIN_PAIN_TO_BEGIN, shock_stage * 0.8))
184198
// A chance to fight through the pain.
185199
if((shock_stage >= SHOCK_TIER_3) && stat == CONSCIOUS && !heart_attack_gaming && stats.cooldown_finished("shrug_off_pain"))

code/modules/mob/living/living.dm

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
register_init_signals()
77
if(unique_name)
88
give_unique_name()
9+
910
var/datum/atom_hud/data/human/medical/advanced/medhud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
1011
medhud.add_atom_to_hud(src)
12+
1113
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
1214
diag_hud.add_atom_to_hud(src)
15+
1316
faction += "[REF(src)]"
1417
GLOB.mob_living_list += src
1518
SSpoints_of_interest.make_point_of_interest(src)
1619
voice_type = pick(voice_type2sound)
20+
mob_mood = new(src)
21+
1722
AddElement(/datum/element/movetype_handler)
1823
gravity_setup()
1924

@@ -28,6 +33,7 @@
2833
QDEL_NULL(z_eye)
2934
QDEL_NULL(stamina)
3035
QDEL_NULL(stats)
36+
QDEL_NULL(mob_mood)
3137

3238
for(var/datum/status_effect/effect as anything in status_effects)
3339
// The status effect calls on_remove when its mob is deleted
@@ -680,6 +686,7 @@
680686

681687
if(.)
682688
qdel(GetComponent(/datum/component/spook_factor))
689+
mob_mood?.add_mood_event("revival", /datum/mood_event/revival)
683690

684691
// The signal is called after everything else so components can properly check the updated values
685692
SEND_SIGNAL(src, COMSIG_LIVING_REVIVE, full_heal, admin_revive)
@@ -1770,6 +1777,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
17701777
ADD_TRAIT(src, TRAIT_HANDS_BLOCKED, STAT_TRAIT)
17711778
ADD_TRAIT(src, TRAIT_INCAPACITATED, STAT_TRAIT)
17721779
ADD_TRAIT(src, TRAIT_FLOORED, STAT_TRAIT)
1780+
mob_mood?.update_mood_icon()
17731781

17741782
if(UNCONSCIOUS)
17751783
cure_blind(UNCONSCIOUS_TRAIT)
@@ -1784,6 +1792,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
17841792
if(CONSCIOUS)
17851793
if(. >= UNCONSCIOUS)
17861794
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT)
1795+
mob_mood?.update_mood()
17871796
REMOVE_TRAIT(src, TRAIT_HANDS_BLOCKED, STAT_TRAIT)
17881797
REMOVE_TRAIT(src, TRAIT_INCAPACITATED, STAT_TRAIT)
17891798
REMOVE_TRAIT(src, TRAIT_FLOORED, STAT_TRAIT)
@@ -1919,7 +1928,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
19191928
/// Sets the mob's hunger levels to a safe overall level. Useful for TRAIT_NOHUNGER species changes.
19201929
/mob/living/proc/set_safe_hunger_level()
19211930
// Nutrition reset and alert clearing.
1922-
nutrition = NUTRITION_LEVEL_FED
1931+
set_nutrition(NUTRITION_LEVEL_FED)
19231932
clear_alert(ALERT_NUTRITION)
19241933
satiety = 0
19251934

@@ -2259,3 +2268,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
22592268

22602269
SEND_SIGNAL(src, COMSIG_LIVING_UNFRIENDED, old_friend)
22612270
return TRUE
2271+
2272+
/mob/living/set_nutrition(change)
2273+
. = ..()
2274+
mob_mood?.update_nutrition_moodlets()

code/modules/mob/living/living_defines.dm

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ DEFINE_INTERACTABLE(/mob/living)
2525
var/datum/stats/stats
2626
///The holder for stamina handling
2727
var/datum/stamina_container/stamina
28+
/// Mood datum, can be null.
29+
var/datum/mood/mob_mood
2830

2931
//Damage related vars, NOTE: THESE SHOULD ONLY BE MODIFIED BY PROCS
3032
VAR_PROTECTED/bruteloss = 0 //!Brutal damage caused by brute force (punching, being clubbed by a toolbox ect... this also accounts for pressure damage)

code/modules/mob/mob.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@
14581458

14591459
///Adjust the nutrition of a mob
14601460
/mob/proc/adjust_nutrition(change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks
1461-
nutrition = max(0, nutrition + change)
1461+
set_nutrition(max(0, nutrition + change))
14621462

14631463
///Force set the mob nutrition
14641464
/mob/proc/set_nutrition(change) //Seriously fuck you oldcoders.

0 commit comments

Comments
 (0)