Fatness Hiding Rework

Fatness hiding has been reworked to allow multiple items that add or reduce a character's fatness value. A thing that wishes to use this system needs to add and remove itself to a character's hiding list (hider_add(), hider_remove()) based on that thing's conditions. Then it needs to have a /proc/fat_hide() that will return the value by which to shift fatness
This commit is contained in:
Alphas00
2024-06-06 12:49:33 +02:00
parent 682c355510
commit adc5923034
6 changed files with 83 additions and 56 deletions
@@ -57,7 +57,7 @@
affected_mob.reagents.remove_reagent(/datum/reagent/berry_juice_infection, volume)
return
picked_color = pick(random_color_list)
affected_mob.fat_hide(affected_mob.fatness_real + ((3 * (volume * volume))/50), src)
affected_mob.hider_add(src)
else
L.reagents.remove_reagent(/datum/reagent/berry_juice_infection, volume)
..()
@@ -68,7 +68,6 @@
return
if(!no_mob_color)
M.add_atom_colour(picked_color, WASHABLE_COLOUR_PRIORITY)
M.fat_hide(M.fatness_real + ((3 * (volume * volume))/50), src)
M.adjust_fatness(1, FATTENING_TYPE_CHEM)
..()
@@ -76,7 +75,7 @@
if(!iscarbon(L))
return
var/mob/living/carbon/C = L
C.fat_show()
C.hider_remove(src)
/obj/item/reagent_containers/glass/attack(mob/M, mob/user, obj/target)
if(M.reagents.get_reagent_amount(/datum/reagent/berry_juice_infection) > 0 && (reagents.total_volume + min(amount_per_transfer_from_this, 10)) <= volume)
@@ -89,3 +88,6 @@
to_chat(user, "<span class='warning'>You get some juice out of you...</span>")
return
..()
/datum/reagent/berry_juice_infection/proc/fat_hide()
return (3 * (volume * volume))/50
+22 -18
View File
@@ -5,12 +5,10 @@
// -fatness_real is the value a mob is actually at, even if it's being hidden. For permanent changes, use this one
//What level of fatness is the parent mob currently at?
var/fatness = 0
//Is something hiding the actual fatness value of a character?
var/fat_hider = FALSE
//The list of items/effects that are being added/subtracted from our real fatness
var/fat_hiders = list()
//The actual value a mob is at. Is equal to fatness if fat_hider is FALSE.
var/fatness_real = 0
//The value a mob's fatness is being overwritten with if fat_hider has something in it.
var/fatness_over = 0
///At what rate does the parent mob gain weight? 1 = 100%
var/weight_gain_rate = 1
//At what rate does the parent mob lose weight? 1 = 100%
@@ -44,11 +42,12 @@
if(client?.prefs?.max_weight) // GS13
fatness_real = min(fatness_real, (client?.prefs?.max_weight - 1))
if(fat_hider) //If a character's real fatness is being hidden
if(fat_hiders) //If a character's real fatness is being hidden
var/fatness_over = hiders_calc() //calculate the sum of all hiders
if(client?.prefs?.max_weight) //Check their prefs
fatness_over = min(fatness_over, (client?.prefs?.max_weight - 1)) //And make sure it's not above their preferred max
fatness = fatness_over //Then, make that value their current fatness
fatness = fatness_real + fatness_over //Then, make their current fatness the sum of their real plus/minus the calculated amount
else //If it's not being hidden
fatness = fatness_real //Make their current fatness their real fatness
@@ -102,23 +101,28 @@
return TRUE
/mob/living/carbon/proc/fat_hide(hide_amount, hide_source) //If something wants to hide fatness_real, it'll call this method and give it an amount to cover it with
fat_hider = hide_source
fatness_over = hide_amount
fatness = fatness_over //To update a mob's fatness with the new amount to be shown immediately
if(client?.prefs?.weight_gain_extreme)
xwg_resize()
/mob/living/carbon/proc/hider_add(hide_source)
if(!(hide_source in fat_hiders))
fat_hiders += hide_source
return TRUE
/mob/living/carbon/proc/fat_show() //If something that hides fatness is removed or expires, it'll call this method
fat_hider = FALSE
fatness = fatness_real //To update a mob's fatness with their real one immediately
if(client?.prefs?.weight_gain_extreme)
xwg_resize()
/mob/living/carbon/proc/hider_remove(hide_source)
if(hide_source in fat_hiders)
fat_hiders -= hide_source
return TRUE
/mob/living/carbon/proc/hiders_calc()
var/hiders_value = 0
for(var/hider in fat_hiders)
var/hide_values = hider:fat_hide(src)
if(!islist(hide_values))
hiders_value += hide_values
else
for(var/hide_value in hide_values)
hiders_value += hide_value
return hiders_value
/mob/living/carbon/proc/xwg_resize()
var/xwg_size = sqrt(fatness/FATNESS_LEVEL_BLOB)
xwg_size = min(xwg_size, RESIZE_HUGE)
+11 -4
View File
@@ -8,20 +8,27 @@
equip_sound = 'sound/items/equip/toolbelt_equip.ogg'
drop_sound = 'sound/items/handling/toolbelt_drop.ogg'
pickup_sound = 'sound/items/handling/toolbelt_pickup.ogg'
var/hide_value = 0
/obj/item/bluespace_belt/equipped(mob/user, slot)
..()
if(!iscarbon(user))
return
var/mob/living/carbon/U = user
if(slot == SLOT_BELT)
to_chat(user, "<span class='notice'>You put the belt around your waist and your mass begins to shrink...</span>")
U.fat_hide(hide_value, src)
U.hider_add(src)
else
to_chat(user, "<span class='notice'>The belt is opened, letting your mass flow out!</span>")
U.fat_show()
U.hider_remove(src)
/obj/item/bluespace_belt/dropped(mob/user)
..()
if(!iscarbon(user))
return
to_chat(user, "<span class='warning'>The belt is opened, letting your mass flow out!</span>")
var/mob/living/carbon/U = user
U.fat_show()
U.hider_remove(src)
/obj/item/bluespace_belt/proc/fat_hide(var/mob/living/carbon/user)
return -(user.fatness_real - 1)
+9 -9
View File
@@ -2,9 +2,9 @@
. = ..()
if(iscarbon(target))
var/mob/living/carbon/T = target
if(T.fat_hider)
if(isitem(T.fat_hider))
var/obj/item/O = T.fat_hider
for(var/hider in T.fat_hiders)
if(isitem(hider))
var/obj/item/O = hider
T.dropItemToGround(O)
if(T.cursed_fat == 1)
T.cursed_fat = 0
@@ -14,9 +14,9 @@
. = ..()
if(iscarbon(M))
var/mob/living/carbon/T = M
if(T.fat_hider)
if(isitem(T.fat_hider))
var/obj/item/O = T.fat_hider
for(var/hider in T.fat_hiders)
if(isitem(hider))
var/obj/item/O = hider
T.dropItemToGround(O)
if(T.cursed_fat == 1)
T.cursed_fat = 0
@@ -24,9 +24,9 @@
/datum/reagent/water/holywater/on_mob_life(mob/living/carbon/M)
. = ..()
if(M.fat_hider)
if(isitem(M.fat_hider))
var/obj/item/O = M.fat_hider
for(var/hider in M.fat_hiders)
if(isitem(hider))
var/obj/item/O = hider
M.dropItemToGround(O)
if(M.cursed_fat == 1)
M.cursed_fat = 0
@@ -227,10 +227,9 @@
items_preserved.Cut()
owner.update_icons()
var/mob/living/carbon/predator = owner
if(iscarbon(predator))
if(digest_mode == DM_FATTEN && predator.fat_hider == src)
predator.fat_show()
if(iscarbon(owner))
var/mob/living/carbon/predator = owner
predator.hider_remove(src)
return count
@@ -279,16 +278,17 @@
owner.visible_message("<font color='green'><b>[owner] expels [M] from their [lowertext(name)]!</b></font>")
owner.update_icons()
var/mob/living/carbon/predator = owner
if(iscarbon(predator))
if(digest_mode == DM_FATTEN && predator.fat_hider == src)
var/preys_fatness = 0
for(var/mob/living/carbon/prey in contents)
preys_fatness += prey.fatness
if(preys_fatness > predator.fatness)
predator.fat_hide(preys_fatness, src)
else
predator.fat_show()
if(iscarbon(owner))
var/mob/living/carbon/predator = owner
var/found = FALSE
for(var/prey in contents)
if(istype(prey, /mob/living/carbon))
found = TRUE
if(found)
predator.hider_add(src)
else
predator.hider_remove(src)
return TRUE
// Actually perform the mechanics of devouring the tasty prey.
@@ -695,3 +695,11 @@
for(var/I in emote_lists[K])
dupe.emote_lists[K] += I
return dupe
/obj/belly/proc/fat_hide(var/mob/living/carbon/user)
var/preys_fatness = 0
for(var/prey in contents)
if(iscarbon(prey))
var/mob/living/carbon/cprey = prey
preys_fatness += cprey.fatness
return preys_fatness
@@ -58,6 +58,18 @@
var/sound/pred_death = sound(get_sfx("death_pred"))
var/turf/source = get_turf(owner)
////////////////////////// Vore Fatness /////////////////////////////
if(iscarbon(owner))
var/mob/living/carbon/predator = owner
var/found = FALSE
for(var/prey in contents)
if(istype(prey, /mob/living/carbon))
found = TRUE
if(found)
predator.hider_add(src)
else
predator.hider_remove(src)
///////////////////////////// DM_HOLD /////////////////////////////
if(digest_mode == DM_HOLD)
return SSBELLIES_PROCESSED
@@ -65,8 +77,8 @@
///////////////////////////// DM_FATTEN /////////////////////////////
if(digest_mode == DM_FATTEN)
var/preys_fatness = 0
var/mob/living/carbon/predator = owner
if(iscarbon(predator))
if(iscarbon(owner))
var/mob/living/carbon/predator = owner
for(var/mob/living/M in contents)
var/mob/living/carbon/prey = M
if(iscarbon(prey) && predator.fatness_real)
@@ -77,12 +89,6 @@
predator.nutrition -= 3
preys_fatness += prey.fatness
if(!predator.fat_hider || predator.fat_hider == src)
if(preys_fatness > predator.fatness)
predator.fat_hide(preys_fatness, src)
if(predator.fat_hider != src)
predator.fat_show()
//////////////////////////// DM_DIGEST ////////////////////////////
else if(digest_mode == DM_DIGEST)
if(HAS_TRAIT(owner, TRAIT_PACIFISM)) //obvious.