Files
Yogstation/code/datums/components/curse_of_hunger.dm
Chubbygummibear 0fda5cfc6a Icon smoothing, and Rendering overhaul, and Camera fix, and mapmerge.py fix, and Multi-z, and THE PLANE CUBE (#21221)
* why no work

angy

* weird errors

shit sucks

* fixved it

I can spell good

* fix?

POSSIBLY

* nope

wasnt this

* no more immutable

thhanks koffee

* ok

ok

* removes all the pref stuff

""removes""

* remove this

idiot

* this goes bye

 bye

* these go too

genius

* bye

bye

* better night vision

* tries to fix camera

maybe

* ok fuck it we ball

we ball

* ok lets go back

go back go back go back

* WORK

DAMNIT

* ha

fuc kyou

* this

maybe

* this doesnt work :(

* maybe fix

maybe

* fucks everything

why do i do this

* test update

test

* Revert "tries to fix camera"

This reverts commit 2d14fbae66.

* reverts everything I just did

peko pain

* bye

bitch

* oh yeah add this

I guess

* Fucks up the camera net + chunk

why

* test maybe revert

* Revert "test maybe revert"

This reverts commit 98c5ef1b93.

* Revert "Fucks up the camera net + chunk"

This reverts commit 0e421ebf5f.

* this isnt going well

uh oh

* Attempts to rework out security camera

and probably more

* Revert "this isnt going well"

This reverts commit 1d8ceac867.

* Revert "Revert "this isnt going well""

This reverts commit e26fb61415.

* ok

ok

* Revert "ok"

This reverts commit 7e7a7f8372.

* Revert "Merge remote-tracking branch 'upstream/master' into NahI'dPortit"

This reverts commit 01094731c1, reversing
changes made to c0cf69ebf1.

* this doesn't need to be redefined

I guess

* no we need this

totally

* a familiar pain

* 515 is L

* yeah

yeah

* ok god

fine

* bye bye basemap :(

doesnt work on runtime station

* Fixes AI statis not working

god im good

* remove this

oh god

* Revert "Revert "Merge remote-tracking branch 'upstream/master' into NahI'dPortit""

This reverts commit b3fb3ba0db.

* proves to god I exist

and im pissed

* yog exclusive feature (tm)

plane master

* bring this back from previous push

* updates vendor emissives

as well as firealarms

* Updates barsign

and fucks everything up

* Fixes barsigns breaks all lights and updates barsigns to be machines and not structures

We will address this in a later patch

* not sure who changed that

oh well

* yeah

this got moved

* this needs updating

yeah

* turns off the carbon monoxide alarm

duh

* FIXES IT YES

thank you biome

* turns this off too

yeah

* Can't compile yet but ports a ton of shit

* L

* the game opens ig

* extra shit

* fixes

* signals and smooth queue

* look ma im going horribly out of scope

* fixes chasms

* this fixed nothing

* ???

* more barsigns

for later

* forgive me cowboy. also fuck diagonals

* oops

we need this apparently

* fuck it we ball

* Update _lists.dm

* Update icon_smoothing.dm

* it now works kinda

* Update atom_initializing_EXPENSIVE.dm

* lighting don't work

* we have light

* sort turfs better

* big fucking reorganize

* like everything except templates

* boy i sure hope nothing bad happens to these bar templates

* we're back

* no runtimes baby

* no errors

* shuttles are almost fixed i think

* Revert "shuttles are almost fixed i think"

This reverts commit 046058827c.

* Revert "Merge remote-tracking branch 'upstream/master' into icon_smoothing"

This reverts commit 863e1b776d, reversing
changes made to 884623e600.

* Revert "no errors"

This reverts commit 884623e600.

* too far back i think

* midround smoothing runtimes fixed i think

* comment cleanup

* should fix the component runtimes

* Revert "Revert "Merge remote-tracking branch 'upstream/master' into icon_smoothing""

This reverts commit a8ff8d63aa.

* NO RUNTIMES AND ICEMETA WORKS LET'S GOOOOOO

* please stay fixed icemeta

* organizing render dms

* woops this too in the reorganizing

* cryo fixed

* nah, i'd win

* parallax isn't my problem

* pls don't break icemeta

* runtime station gets a cam console

* well it compiles

* maybe fix the map

* woops

* man i hate maps

* was that it?

* PLEASE

* missing focus tests

* maybe that was it

* maybe

* let's take the batteries out of the carbon monoxide detector

* fuck osha

* i hate vending machines

* that's not a computer

* slot machine fix

* PLEASE

* that wasn't supposed to be there

* fuck it i can't fix everything at once

* BLUESPACE LOCKER?

* literally why

* hhh

* does this fix chasms?

* that should fix bad index

* please?

* turf_flags for reservations

* haha oops

* yolo (kill me)

* fix wood walls and other walls

* fix stairs

* that might have fixed shittles

* baseturfs are good now i think

* should fix plasma windows

* decals fixed

* please fix changelog

* shuttle lighting still fucky

* lighting is stinky slow and doesn't finish updating by the time the server starts guh

* lighting seemingly works

* slipping works

* shuttle sounds, slips, and windoors fixed

* why am i here

* fuck the changelog

* of course someone touched smoothing as i'm almost done

* we good?

* updating ai_eye and rename

* z updates and more ai cam updates

* ice fixed

* weather and ice fix

* clockies can see and other clean up catches

* windows fixed

* cowbot forgive me i'm trying to update flashlights to tg because there's no light on lower multi-z z's like ice meta bottom floor

* movable lighting works on multi-z

* gps fix

* item stacking from drag works

* falsewall fix

* job panel fixed

* AI HANDLED

* woops that comment should be gone

* i hate ai i hate ai

* brass glass visible again

* vents on top of tiles now

* sigdrobe sprite back

* centcomm portals work

* portals and see openspace mapping icons fixed

* icemeta my behated

* kill

* is that it

* lighting cutoff is old hat

* angery overlay

* not super necessary

* also extra but whatever

* ticker but thicker

* job fix i hope

* this isn't needed anymore

* latejoin fix?

* laserpointer, pipecrawl, and some consoles fixed

* i hate fixing bugs as they're made

* we're not ready for that

* redef cleanup

* gps arrows, gun flashlights, shuttle console placement, multi-z pulling fixed

* goofy ah gun code

* this was a good idea and necessary

* should fix caltrop component

* does this please the linter

* linter please accept this async function

* THERE

* take the batteries out

* make it stop

* cowbot stopped me from letting ghosts dab

* recycler loc fix

* fix border firedoors not blocking movement

* should fix screen fade out and fade in on round start and end

* darker command tile trim and fixed bronze wall sprites

* fuck you linter

* railings actually stop you from leaving

* probably fixes gibtonite overlay when struck

* armaments dispenser and clockwork catwalk

* turbine fix probably

* pointing at inhand items should be fixed

* fix overwatch app

* should hopefully fix cable rotation on shuttle move

* flashlights have better directionality logic

* hopefully fixes shuttle atmos on move

* grilles fixed

* hopefully this fixes shuttle buttons, airolocks, and other machinery not working after moving

* ice meta mining area finally not freezing

* fix lightbulb icons not updating

* lava mask and lighting dots

* we actually have this

* fuck glowshrooms GC

* fix light fixture interactions and icon updates

* hopefully catches all the updates

* lava lighting good to go

* seclite was missing inhands

* smoothing in replays

* light updates accurate in replays

* biome's multi-z requests

---------

Co-authored-by: cowbot92 <75333826+cowbot92@users.noreply.github.com>
Co-authored-by: Molti <gamingjoelouis@gmail.com>
Co-authored-by: Ringalong <53777086+JohnFulpWillard@users.noreply.github.com>
2024-02-18 13:16:55 -06:00

160 lines
6.4 KiB
Plaintext

///the point where you can notice the item is hungry on examine.
#define HUNGER_THRESHOLD_WARNING 25
///the point where the item has a chance to eat something on every tick. possibly you!
#define HUNGER_THRESHOLD_TRY_EATING 50
/**
* curse of hunger component; for very hungry items.
*
* Used as a rpgloot suffix and wizard spell!
*/
/datum/component/curse_of_hunger
///whether to add dropdel to the item with curse of hunger, used for temporary curses like the wizard duffelbags
var/add_dropdel
///items given the curse of hunger will not seek out someone else to latch onto until they are dropped for the first time.
var/awakened = FALSE
///counts time passed since it ate food
var/hunger = 0
///The bag's max "health". IE, how many times you need to poison it.
var/max_health = 2
///The bag's current "health". IE, how many more times you need to poison it to stop it.
var/current_health = 2
/datum/component/curse_of_hunger/Initialize(add_dropdel = FALSE, max_health = 2)
. = ..()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
src.add_dropdel = add_dropdel
src.max_health = max_health
src.current_health = max_health
/datum/component/curse_of_hunger/RegisterWithParent()
. = ..()
var/obj/item/cursed_item = parent
RegisterSignal(cursed_item, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
RegisterSignal(cursed_item, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
/datum/component/curse_of_hunger/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(
COMSIG_ATOM_EXAMINE,
COMSIG_ITEM_EQUIPPED,
COMSIG_ITEM_DROPPED,
))
///signal called on parent being examined
/datum/component/curse_of_hunger/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
if(!awakened)
return //we should not reveal we are cursed until equipped
if(current_health < max_health)
examine_list += span_notice("[parent] looks sick from something it ate.")
if(hunger > HUNGER_THRESHOLD_WARNING)
examine_list += span_danger("[parent] hungers for something to eat...")
///signal called from equipping parent
/datum/component/curse_of_hunger/proc/on_equip(datum/source, mob/equipper, slot)
SIGNAL_HANDLER
var/obj/item/at_least_item = parent
// Items with no slot flags curse on pickup (because hand slot)
if(at_least_item.slot_flags && !(at_least_item.slot_flags & slot))
return
the_curse_begins(equipper)
///signal called from dropping parent
/datum/component/curse_of_hunger/proc/on_drop(datum/source, mob/dropper)
SIGNAL_HANDLER
INVOKE_ASYNC(src, PROC_REF(the_curse_ends), dropper)
/datum/component/curse_of_hunger/proc/the_curse_begins(mob/cursed)
var/obj/item/cursed_item = parent
awakened = TRUE
START_PROCESSING(SSobj, src)
ADD_TRAIT(cursed_item, TRAIT_NODROP, CURSED_ITEM_TRAIT(cursed_item.type))
ADD_TRAIT(cursed, TRAIT_CLUMSY, CURSED_ITEM_TRAIT(cursed_item.type))
ADD_TRAIT(cursed, TRAIT_PACIFISM, CURSED_ITEM_TRAIT(cursed_item.type))
if(add_dropdel)
cursed_item.item_flags |= DROPDEL
RegisterSignal(cursed_item, COMSIG_ITEM_DROPPED, PROC_REF(on_drop))
/datum/component/curse_of_hunger/proc/the_curse_ends(mob/uncursed)
var/obj/item/cursed_item = parent
STOP_PROCESSING(SSobj, src)
REMOVE_TRAIT(cursed_item, TRAIT_NODROP, CURSED_ITEM_TRAIT(cursed_item.type))
REMOVE_TRAIT(uncursed, TRAIT_CLUMSY, CURSED_ITEM_TRAIT(cursed_item.type))
REMOVE_TRAIT(uncursed, TRAIT_PACIFISM, CURSED_ITEM_TRAIT(cursed_item.type))
//remove either one of the signals that could have called this proc
UnregisterSignal(cursed_item, COMSIG_ITEM_DROPPED)
var/turf/vomit_turf = get_turf(cursed_item)
playsound(vomit_turf, 'sound/effects/splat.ogg', 50, TRUE)
new /obj/effect/decal/cleanable/vomit(vomit_turf)
uncursed.dropItemToGround(cursed_item, force = TRUE)
if(!QDELING(cursed_item)) //gives a head start for the person to get away from the cursed item before it begins hunting again!
addtimer(CALLBACK(src, PROC_REF(seek_new_target)), 10 SECONDS)
///proc called after a timer to awaken the AI in the cursed item if it doesn't have a target already.
/datum/component/curse_of_hunger/proc/seek_new_target()
var/obj/item/cursed_item = parent
if(iscarbon(cursed_item.loc))
return
else if(!isturf(cursed_item.loc))
cursed_item.forceMove(get_turf(cursed_item))
//only taking the most reasonable slot is fine since it unequips what is there to equip itself.
// cursed_item.AddElement(/datum/element/cursed, cursed_item.slot_equipment_priority[1])
cursed_item.visible_message(span_warning("[cursed_item] begins to move on [cursed_item.p_their()] own..."))
/datum/component/curse_of_hunger/process(delta_time)
var/obj/item/cursed_item = parent
var/mob/living/carbon/cursed = cursed_item.loc
///check hp
if(current_health <= 0)
the_curse_ends(cursed)
return
hunger += delta_time
if((hunger <= HUNGER_THRESHOLD_TRY_EATING) || prob(80))
return
playsound(cursed_item, 'sound/items/eatfood.ogg', 20, TRUE)
hunger = 0
//check hungry enough to eat something!
for(var/obj/item/food in cursed_item.contents + cursed.contents)
if(!istype(food, /obj/item/reagent_containers/food))
continue
food.forceMove(cursed.loc)
///poisoned food damages it
if(locate(/datum/reagent/toxin) in food.reagents.reagent_list)
var/sick_word = pick("queasy", "sick", "iffy", "unwell")
cursed.visible_message(
span_notice("[cursed_item] eats something from [cursed], and looks [sick_word] afterwards!"),
span_notice("[cursed_item] eats your [food.name] to sate [cursed_item.p_their()] hunger, and looks [sick_word] afterwards!"),
)
current_health--
else
cursed.visible_message(
span_warning("[cursed_item] eats something from [cursed] to sate [cursed_item.p_their()] hunger."),
span_warning("[cursed_item] eats your [food.name] to sate [cursed_item.p_their()] hunger."),
)
cursed.temporarilyRemoveItemFromInventory(food, force = TRUE)
qdel(food)
return
///no food found, but you're dead: it bites you slightly, and doesn't regain health.
if(cursed.stat == DEAD)
cursed.visible_message(span_danger("[cursed_item] nibbles on [cursed]."), span_userdanger("[cursed_item] nibbles on you!"))
cursed.apply_damage(10, BRUTE, BODY_ZONE_CHEST)
return
///no food found: it bites you and regains some health.
cursed.visible_message(span_danger("[cursed_item] bites [cursed]!"), span_userdanger("[cursed_item] bites you to sate [cursed_item.p_their()] hunger!"))
cursed.apply_damage(60, BRUTE, BODY_ZONE_CHEST, wound_bonus = -20, bare_wound_bonus = 20)
current_health = min(current_health + 1, max_health)
#undef HUNGER_THRESHOLD_WARNING
#undef HUNGER_THRESHOLD_TRY_EATING