Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds hunger to mouse #1753

Merged
merged 17 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/modules/food_and_drinks/food_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@
N.visible_message("[N] nibbles away at [src].", "")
N.adjustHealth(-2)
N.taste(reagents)
// SS220 EDIT - START
N.consume(src)
// SS220 EDIT - END
else if(iscaterpillar(M))
var/mob/living/simple_animal/nian_caterpillar/W = M
W.taste(reagents)
Expand Down
161 changes: 156 additions & 5 deletions modular_ss220/mobs/code/simple_animal/friendly/mouse.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@

// Коэфицент питательности еды, чтобы полностью не копировать сложную систему питание людей.
#define NUTRITION_COEF 20
#define MAX_FEADING_TIME 15 SECONDS
#define MIN_FEADING_TIME 3 SECONDS
// Сколько нутриентов должно быть в мыше, перед тем как мы её гибнем
#define GIB_FEED_LEVEL NUTRITION_LEVEL_FULL * 1.35

/datum/hud/simple_animal_mouse/New(mob/user)
..()

mymob.healths = new /atom/movable/screen/healths()
infodisplay += mymob.healths

mymob.nutrition_display = new /atom/movable/screen/nutrition()
mymob.nutrition_display.screen_loc = "EAST-1:26,CENTER-1:15"
// "EAST-2:32,CENTER-1:13"
mymob.nutrition_display.icon = 'modular_ss220/mobs/code/simple_animal/friendly/screen_hunger_mouse_test.dmi' // TODO Перерисовать на сыр
infodisplay += mymob.nutrition_display

var/atom/movable/screen/using
using = new /atom/movable/screen/act_intent/simple_animal()
using.icon_state = mymob.a_intent
static_inventory += using
action_intent = using

user.overlay_fullscreen("see_through_darkness", /atom/movable/screen/fullscreen/stretch/see_through_darkness)



Drsmail marked this conversation as resolved.
Show resolved Hide resolved
/mob/living/simple_animal/mouse
var/non_standard = FALSE // for no "mouse_" with mouse_color
icon = 'modular_ss220/mobs/icons/mob/animal.dmi'
Expand All @@ -7,17 +37,37 @@
blood_volume = BLOOD_VOLUME_SURVIVE
butcher_results = list(/obj/item/food/meat/mouse = 1)

Drsmail marked this conversation as resolved.
Show resolved Hide resolved
// hungry mouse
hud_type = /datum/hud/simple_animal_mouse
// Стартовый уровень голода
nutrition = NUTRITION_LEVEL_HUNGRY + 10
// Скорость с которой снижается наш голод
// Мышка тратит 1800 nutrition в час, при hunger_drain = 1. Одно блюдо восполняет где-то 100-200 nutrition
hunger_drain = HUNGER_FACTOR * 1.66

var/previous_status
var/busy = FALSE



Drsmail marked this conversation as resolved.
Show resolved Hide resolved
/mob/living/simple_animal/mouse/Initialize(mapload)
. = ..()
AddComponent(/datum/component/squeak, list("[squeak_sound]" = 1), 100, extrarange = SHORT_RANGE_SOUND_EXTRARANGE) //as quiet as a mouse or whatever

pixel_x = rand(-6, 6)
pixel_y = rand(0, 10)

mouse_color = initial(mouse_color) // сбрасываем из-за наследования чтобы своим проком переписать
color_pick()
update_appearance(UPDATE_ICON_STATE|UPDATE_DESC)

// Отслеживаем, что призрак попал в мышку.
/mob/living/simple_animal/mouse/Login()
. = ..()
// Теперь мышка будет обрабатыватся в цикле life, обычные мышки не будут обрабатывать голод.
reagents = new()
Drsmail marked this conversation as resolved.
Show resolved Hide resolved


Drsmail marked this conversation as resolved.
Show resolved Hide resolved
/mob/living/simple_animal/mouse/proc/color_pick()
if(!mouse_color)
mouse_color = pick( list("brown","gray","white") )
Expand Down Expand Up @@ -52,12 +102,107 @@
remains.pixel_x = pixel_x
remains.pixel_y = pixel_y

// Вызывается цикилически из модуля live. Отвечает за обработку голода
/mob/living/simple_animal/mouse/handle_chemicals_in_body()

Drsmail marked this conversation as resolved.
Show resolved Hide resolved
var/hunger_rate = hunger_drain
var/new_status
adjust_nutrition(-hunger_rate)

switch(nutrition)
if(GIB_FEED_LEVEL to INFINITY)
visible_message("[src] разорвало от обжорства!", "Ваши внутренности не выдерживают и лопаются.")
do_sparks(3, 1, src)
Drsmail marked this conversation as resolved.
Show resolved Hide resolved
src.gib()
if(NUTRITION_LEVEL_FULL to GIB_FEED_LEVEL)
nutrition_display.icon_state = "fat"
if(NUTRITION_LEVEL_WELL_FED to NUTRITION_LEVEL_FULL)
nutrition_display.icon_state = "full"
if(NUTRITION_LEVEL_FED to NUTRITION_LEVEL_WELL_FED)
nutrition_display.icon_state = "well_fed"
if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_FED)
nutrition_display.icon_state = "fed"
if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY)
nutrition_display.icon_state = "hungry"
if(NUTRITION_LEVEL_HYPOGLYCEMIA to NUTRITION_LEVEL_STARVING)
nutrition_display.icon_state = "starving"
adjustHealth(0.02)
else
// we are below 0 that's realy bad. Let's kill us
adjustHealth(0.05)


new_status = nutrition_display.icon_state
Drsmail marked this conversation as resolved.
Show resolved Hide resolved

if(previous_status == new_status)
return

// /mob/living/simple_animal/mouse/emote(act, m_type = 1, message = null, force)
previous_status = new_status
switch(new_status)
if("fat")
name = "жирная [initial(name)]" // Мешаем англиский с русским
desc = "[initial(desc)] Господи! Она же огромная!"
to_chat(src, "<span class='userdanger'>Ты чувствуешь, что в тебя больше не влезет и кусочка</span>")
Drsmail marked this conversation as resolved.
Show resolved Hide resolved
if("full")
name = initial(name)
desc = initial(desc)
if("well_fed")
to_chat(src, "<span class='notice'>Ты чувствуешь себя превосходно!</span>")
if("fed")
name = initial(name)
desc = initial(desc)
if("hungry")
name = "костлявая [initial(name)]"
desc = "[initial(desc)] Вы можете видеть рёбра через кожу."
to_chat(src, "<span class='warning'>Твой живот угрюмо урчит, лучше найти что-то поесть</span>")
if("starving")
to_chat(src, "<span class='userdanger'>Ты смертельно голоден!</span>")
nutrition_display.icon_state = "starving"
Drsmail marked this conversation as resolved.
Show resolved Hide resolved
else
CRASH("Неизвестный статус [new_status]")
Drsmail marked this conversation as resolved.
Show resolved Hide resolved

// if("help")
// to_chat(src, "scream, squeak")
// playsound(src, damaged_sound, 40, 1)

Drsmail marked this conversation as resolved.
Show resolved Hide resolved
//Prevents mouse from pulling things
/mob/living/simple_animal/mouse/start_pulling(atom/movable/AM, state, force = pull_force, show_message = FALSE)
if(istype(AM, /obj/item/food))
// This is stolen from mob/living/start_pulling
// because i can't call it from here ..()
// insted it will call upstream version of mouse/start_pulling
// Let me know if you know how to do it better
if(!(AM.can_be_pulled(src, state, force, show_message)))
return FALSE
if(incapacitated())
return
if(SEND_SIGNAL(src, COMSIG_LIVING_TRY_PULL, AM, force) & COMSIG_LIVING_CANCEL_PULL)
return FALSE
return
if(show_message)
to_chat(src, "<span class='warning'>You are too small to pull anything except food.</span>")
return

// Вызывается, когда мышка кликает на еду, можно кушать только одну еду за раз.
/mob/living/simple_animal/mouse/proc/consume(obj/item/food/F)

Drsmail marked this conversation as resolved.
Show resolved Hide resolved
if(busy)
to_chat(src, "<span class='warning'>You need to finish chewing first.</span>")
return

busy = TRUE
// liniar scale from (MIN_FEADING_TIME, to MAX_FEADING_TIME)
var/eat_time = MIN_FEADING_TIME + (MAX_FEADING_TIME - MIN_FEADING_TIME) * (nutrition / GIB_FEED_LEVEL)
m-dzianishchyts marked this conversation as resolved.
Show resolved Hide resolved
to_chat(src, "<span class='notice'>You're starting to chew on [F]...</span>")
if(!do_after_once(src, eat_time, target = F, needhand = FALSE))
to_chat(src, "<span class='notice'>You hurry up and stop chewing on [F]!</span>")
busy = FALSE
return
Drsmail marked this conversation as resolved.
Show resolved Hide resolved

visible_message("[src] ravenously consumes [F].", "You ravenously devour [F].")
playsound(loc, 'sound/items/eatfood.ogg', 30, FALSE, frequency = 1.5)
var/nutriment = F.reagents.get_reagent_amount("nutriment") * NUTRITION_COEF
adjust_nutrition(nutriment)
F.generate_trash(F)
busy = FALSE
qdel(F)

/mob/living/simple_animal/mouse/brown/tom
maxHealth = 10
Expand All @@ -76,3 +221,9 @@
butcher_results = list(/obj/item/stack/sheet/metal = 1)
maxHealth = 20
health = 20


Drsmail marked this conversation as resolved.
Show resolved Hide resolved
#undef NUTRITION_COEF
#undef MAX_FEADING_TIME
#undef MIN_FEADING_TIME
#undef GIB_FEED_LEVEL
Binary file not shown.
Loading