Merge pull request #141 from GremlingSS/master

Tidies up the calorite door code & refactors a lot of it
This commit is contained in:
evilew
2023-12-31 19:54:43 +01:00
committed by GitHub
5 changed files with 118 additions and 69 deletions
@@ -0,0 +1,44 @@
/datum/component/fattening_door
var/fatten = FALSE // whether player will be fattened
var/fat_to_add = 2 // fatness per tick stunned
/datum/component/fattening_door/Initialize()
if(!istype(parent, /obj/structure/mineral_door)) // if the attached object isn't a door, return incompatible!
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, list(COMSIG_MOVABLE_CROSSED), .proc/Fatten)
/datum/component/fattening_door/proc/Fatten() //GS13
var/stuck_delay = 0
var/turf/T = get_turf(parent)
for(var/mob/living/carbon/M in T)
var/vis_message_self = ""
var/vis_message_others = ""
// determine if mob should get stuck and be fattened
if(M.fatness >= FATNESS_LEVEL_FAT)
if(!M.AmountFatStunned())
fatten = TRUE
stuck_delay = 5
vis_message_self = "You feel your sides briefly brush against the doorway!"
vis_message_others = "[M]'s sides briefly brush against the doorway."
// Scales depending on this switch.
switch(M.fatness)
if(FATNESS_LEVEL_BARELYMOBILE to INFINITY)
stuck_delay = 120
vis_message_self = "You feel yourself get stuck in the doorway!"
vis_message_others = "[M] gets stuck in the doorway!"
if((FATNESS_LEVEL_FATTER+1) to FATNESS_LEVEL_MORBIDLY_OBESE)
stuck_delay = 50
vis_message_self ="You feel your sides barely squeeze through the doorway!"
vis_message_others = "[M] barely squeezes through the doorway!"
if((FATNESS_LEVEL_FAT+1) to FATNESS_LEVEL_FATTER)
stuck_delay = 15
vis_message_self = "You feel your sides smush against the doorway!."
vis_message_others = "[M]'s sides briefly smush against the doorway."
// Apply the fatstun
if(fatten)
M.visible_message("<span class='boldnotice'>[vis_message_others]</span>", "<span class='boldwarning'>[vis_message_self]</span>")
M.FatStun(stuck_delay, fatAmount = fat_to_add) // DOOR STUCK
@@ -0,0 +1,64 @@
// Cba making a define file just for status effects so all the helper stuff goes here!~
#define STATUS_EFFECT_FATSTUN /datum/status_effect/incapacitating/stun/fat //the affected is knocked down
////
// Makes it so player is stunned and while stunned, fatness level grows.
////
/datum/status_effect/incapacitating/stun/fat
var/fatAmount = 1
/datum/status_effect/incapacitating/stun/fat/on_creation(mob/living/new_owner, set_duration, updating_canmove, fatnessAmount)
fatAmount = fatnessAmount
..()
/datum/status_effect/incapacitating/stun/fat/tick()
var/mob/living/carbon/C = owner
if(C)
C.adjust_fatness(fatAmount, FATTENING_TYPE_ITEM) // simply adds/removes the fat overtime.
// to_chat(owner, "You feel larger...") // debugging to see if the stun works.
////
// Helpers so it applies to the mob. (I cannot be bothered making a new file for this AUGH)
////
/mob/proc/IsFatStunned() //non-living mobs shouldn't be stunned
return FALSE
/mob/living/IsFatStunned() //If we're knocked down
return has_status_effect(STATUS_EFFECT_FATSTUN)
/mob/living/proc/AmountFatStunned() //How many deciseconds remain in our knockdown
var/datum/status_effect/incapacitating/stun/fat/F = IsFatStunned()
if(F)
return F.duration - world.time
return 0
/mob/living/proc/FatStun(amount, updating = TRUE, ignore_canstun = FALSE, fatAmount)
if(((status_flags & CANSTUN) && !HAS_TRAIT(src, TRAIT_STUNIMMUNE)) || ignore_canstun)
var/datum/status_effect/incapacitating/stun/fat/F = IsFatStunned()
if(F)
F.duration = max(world.time + amount, F.duration)
else if(amount > 0)
F = apply_status_effect(STATUS_EFFECT_FATSTUN, amount, updating, fatAmount)
return F
/mob/living/proc/SetFatStun(amount, updating = TRUE, ignore_canstun = FALSE) //Sets remaining duration
if(((status_flags & CANSTUN) && !HAS_TRAIT(src, TRAIT_STUNIMMUNE)) || ignore_canstun)
var/datum/status_effect/incapacitating/stun/fat/F = IsFatStunned()
if(amount <= 0)
if(F)
qdel(F)
else
if(F)
F.duration = world.time + amount
else
F = apply_status_effect(STATUS_EFFECT_FATSTUN, amount, updating)
return F
/mob/living/proc/AdjustFatStun(amount, updating = TRUE, ignore_canstun = FALSE) //Adds to remaining duration
if(((status_flags & CANSTUN) && !HAS_TRAIT(src, TRAIT_STUNIMMUNE)) || ignore_canstun)
var/datum/status_effect/incapacitating/stun/fat/F = IsFatStunned()
if(F)
F.duration += amount
else if(amount > 0)
F = apply_status_effect(STATUS_EFFECT_FATSTUN, amount, updating)
return F
@@ -5,75 +5,14 @@
sheetType = /obj/item/stack/sheet/mineral/calorite
max_integrity = 200
light_range = 1
var/fatten = FALSE // whether player will be fattened
var/fatten_delay = 1 // ticks per periodic loop
var/fat_to_add = 2 // fatness per tick stunned
var/stuck = FALSE // whether player is stuck
var/stuck_delay = 0 // set in proc/Fatten
var/blocked = FALSE // whether door is blocked
// Sets it open by default
state = TRUE
density = FALSE
// override /obj/structure/mineral_door/proc/Open()
/obj/structure/mineral_door/calorite/Open() //GS13
..()
// If you ever want to make any door like this, just simply add the component like this :3
/obj/structure/mineral_door/calorite/Initialize()
. = ..()
AddComponent(/datum/component/fattening_door)
// start periodic loop
stuck = FALSE
START_PROCESSING(SSprocessing, src)
update_icon() // Updates the sprite when spawned in cause it's closed by default.
/obj/structure/mineral_door/calorite/process()
if(!state) // Door be closed!!!
STOP_PROCESSING(SSprocessing, src)
Fatten()
/obj/structure/mineral_door/calorite/proc/Fatten() //GS13
var/turf/T = get_turf(src)
blocked = FALSE
for(var/mob/living/carbon/M in T)
blocked = TRUE
// determine if mob should get stuck and be fattened
if(M.fatness >= FATNESS_LEVEL_BARELYMOBILE)
fatten = TRUE
if (!stuck)
stuck_delay = 120
M.visible_message(
"<span class='boldnotice'>[M] gets stuck in the doorway!</span>",
"<span class='boldwarning'>You feel yourself get stuck in the doorway!</span>")
else if(M.fatness >= FATNESS_LEVEL_MORBIDLY_OBESE)
fatten = TRUE
if (!stuck)
stuck_delay = 50
M.visible_message(
"<span class='boldnotice'>[M] barely squeezes through the doorway!</span>",
"<span class='boldwarning'>You feel your sides barely squeeze through the doorway!</span>")
else if(M.fatness >= FATNESS_LEVEL_FATTER)
fatten = TRUE
if (!stuck)
stuck_delay = 15
M.visible_message(
"<span class='boldnotice'>[M]'s sides briefly smush against the doorway.</span>",
"<span class='boldwarning'>You feel your sides smush against the doorway!.</span>")
else if(M.fatness >= FATNESS_LEVEL_FAT)
fatten = TRUE
if (!stuck)
stuck_delay = 5
M.visible_message(
"<span class='boldnotice'>[M]'s sides briefly brush against the doorway.</span>",
"<span class='boldwarning'>You feel your sides briefly brush against the doorway!</span>")
else
fatten = FALSE
stuck = FALSE
stuck_delay = 0
if (fatten) // get stuck
if (!stuck)
M.Stun(stuck_delay/2) // give player time to escape
stuck = TRUE
if (stuck_delay > 0) // wait for stun to end
stuck_delay = stuck_delay - fatten_delay
if (stuck_delay <= 0)
stuck_delay = 0
// gain weight while stuck
M.adjust_fatness(fat_to_add, FATTENING_TYPE_ITEM)
if (!blocked)
stuck = FALSE // ready to go again
Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 116 KiB

+2
View File
@@ -3074,6 +3074,8 @@
#include "code\modules\zombie\organs.dm"
#include "GainStation13\code\clothing\accessory.dm"
#include "GainStation13\code\clothing\calorite_collar.dm"
#include "GainStation13\code\datums\components\fattening_door.dm"
#include "GainStation13\code\datums\status_effects\fatstun.dm"
#include "GainStation13\code\game\lore_papers.dm"
#include "GainStation13\code\game\sound.dm"
#include "GainStation13\code\game\area\ruins.dm"