Make unnatural resizing even better and more efficient with the power of DCS™️

This commit is contained in:
Chompstation Bot
2021-04-08 15:15:21 +00:00
parent 23af41589b
commit 6ce0b7ee4e
9 changed files with 169 additions and 5 deletions

View File

@@ -80,6 +80,8 @@
#define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon"
///from base of atom/Entered(): (atom/movable/entering, /atom)
#define COMSIG_ATOM_ENTERED "atom_entered"
/// Sent from the atom that just Entered src. From base of atom/Entered(): (/atom/entered_atom, /atom/oldLoc)
#define COMSIG_ATOM_ENTERING "atom_entering"
///from base of atom/Exit(): (/atom/movable/exiting, /atom/newloc)
#define COMSIG_ATOM_EXIT "atom_exit"
#define COMPONENT_ATOM_BLOCK_EXIT (1<<0)

View File

@@ -0,0 +1,19 @@
/datum/component/resize_guard
/datum/component/resize_guard/Initialize()
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/resize_guard/RegisterWithParent()
// When our parent mob enters any atom, we check resize
RegisterSignal(parent, COMSIG_ATOM_ENTERING, .proc/check_resize)
/datum/component/resize_guard/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATOM_ENTERING)
/datum/component/resize_guard/proc/check_resize()
var/area/A = get_area(parent)
if(A?.limit_mob_size)
var/mob/living/L = parent
L.resize(L.size_multiplier)
qdel(src)

View File

@@ -638,6 +638,7 @@
. = ..()
GLOB.moved_event.raise_event(AM, old_loc, AM.loc)
SEND_SIGNAL(src, COMSIG_ATOM_ENTERED, AM, old_loc)
SEND_SIGNAL(AM, COMSIG_ATOM_ENTERING, src, old_loc)
/atom/Exit(atom/movable/AM, atom/new_loc)
. = ..()

View File

@@ -5,12 +5,48 @@
if(!check_rights(R_ADMIN, R_FUN))
return
<<<<<<< HEAD
var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1)
L.resize(size_multiplier, TRUE, TRUE)
if(size_multiplier >= RESIZE_TINY && size_multiplier <= RESIZE_HUGE)
L.size_uncapped = FALSE
else
L.size_uncapped = TRUE
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1) as num|null
if(!size_multiplier)
return //cancelled
size_multiplier = clamp(size_multiplier, 0.01, 1000)
var/can_be_big = L.has_large_resize_bounds()
var/very_big = is_extreme_size(size_multiplier)
if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse
to_chat(src,"<span class='warning'>[L] will lose this size upon moving into an area where this size is not allowed.</span>")
else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse
to_chat(src,"<span class='warning'>[L] will retain this normally unallowed size outside this area.</span>")
L.size_uncapped = TRUE
else if(L.size_uncapped) // made a normal size after having been an extreme adminbuse size
to_chat(src,"<span class='warning'>[L] now returned to normal area-based size limitations.</span>")
L.size_uncapped = FALSE
L.resize(size_multiplier, animate = TRUE, uncapped = TRUE, ignore_prefs = TRUE)
=======
var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1) as num|null
if(!size_multiplier)
return //cancelled
size_multiplier = clamp(size_multiplier, 0.01, 1000)
var/can_be_big = L.has_large_resize_bounds()
var/very_big = is_extreme_size(size_multiplier)
if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse
to_chat(src,"<span class='warning'>[L] will lose this size upon moving into an area where this size is not allowed.</span>")
else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse
to_chat(src,"<span class='warning'>[L] will retain this normally unallowed size outside this area.</span>")
L.resize(size_multiplier, animate = TRUE, uncapped = TRUE, ignore_prefs = TRUE)
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
log_and_message_admins("has changed [key_name(L)]'s size multiplier to [size_multiplier].")
feedback_add_details("admin_verb","RESIZE")

View File

@@ -6,8 +6,6 @@
appearance_flags = TILE_BOUND|PIXEL_SCALE|KEEP_TOGETHER
var/hunger_rate = DEFAULT_HUNGER_FACTOR
var/resizable = TRUE
var/size_uncapped = FALSE //Determines if a mob's size obedies the resize cap, used for adminbus resize.
//custom say verbs
var/custom_say = null
var/custom_ask = null

View File

@@ -134,7 +134,13 @@
to_chat(nif.human,"<span class='notice'>The safety features of the NIF Program prevent you from choosing this size.</span>")
return
else
<<<<<<< HEAD
if(nif.human.resize(new_size/100))
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
if(nif.human.resize(new_size/100, ignore_prefs = TRUE))
=======
if(nif.human.resize(new_size/100, uncapped=nif.human.has_large_resize_bounds(), ignore_prefs = TRUE))
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
to_chat(nif.human,"<span class='notice'>You set the size to [new_size]%</span>")
nif.human.visible_message("<span class='warning'>Swirling grey mist envelops [nif.human] as they change size!</span>","<span class='notice'>Swirling streams of nanites wrap around you as you change size!</span>")
spawn(0)

View File

@@ -1,6 +1,3 @@
GLOBAL_LIST_EMPTY(size_uncapped_mobs)
GLOBAL_VAR(size_uncapped_mobs_timer)
// Adding needed defines to /mob/living
// Note: Polaris had this on /mob/living/carbon/human We need it higher up for animals and stuff.
/mob/living
@@ -60,6 +57,7 @@ GLOBAL_VAR(size_uncapped_mobs_timer)
return FALSE
return TRUE
<<<<<<< HEAD
/proc/add_to_uncapped_list(var/mob/living/L)
if(L.size_uncapped)
return
@@ -92,14 +90,87 @@ GLOBAL_VAR(size_uncapped_mobs_timer)
if(!GLOB.size_uncapped_mobs.len)
deltimer(GLOB.size_uncapped_mobs_timer)
GLOB.size_uncapped_mobs_timer = null
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
/atom/movable/proc/has_large_resize_bounds()
var/area/A = get_area(src) //Get the atom's area to check for size limit.
return !A.limit_mob_size
/proc/is_extreme_size(size)
return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM)
/proc/add_to_uncapped_list(var/mob/living/L)
if(L.size_uncapped)
return
if(!GLOB.size_uncapped_mobs.len)
//Could be a subsystem but arguably a giant waste of time to make into a subsystem. A subsystem that is paused on and off all the time? Eh.
//If you're that worried, make metrics for how often this even runs and then decide.
GLOB.size_uncapped_mobs_timer = addtimer(CALLBACK(GLOBAL_PROC, .check_uncapped_list), 2 SECONDS, TIMER_LOOP | TIMER_UNIQUE | TIMER_STOPPABLE)
GLOB.size_uncapped_mobs |= weakref(L)
/proc/remove_from_uncapped_list(var/mob/living/L)
if(!GLOB.size_uncapped_mobs.len)
return
GLOB.size_uncapped_mobs -= weakref(L)
if(!GLOB.size_uncapped_mobs.len)
deltimer(GLOB.size_uncapped_mobs_timer)
GLOB.size_uncapped_mobs_timer = null
/proc/check_uncapped_list()
for(var/weakref/wr in GLOB.size_uncapped_mobs)
var/mob/living/L = wr.resolve()
if(!istype(L) || L.size_uncapped)
GLOB.size_uncapped_mobs -= wr
continue
// If we get here, you're a mob, and you don't have admin exclusion (size_uncapped) to being big, and you're very likely big.
// If you're not abnormally big, the below will do nothing, so it's fine to run anyway.
if(!L.has_large_resize_bounds())
L.resize(L.size_multiplier, ignore_prefs = TRUE) //Calling this will have resize() clamp it
GLOB.size_uncapped_mobs -= wr
if(!GLOB.size_uncapped_mobs.len)
deltimer(GLOB.size_uncapped_mobs_timer)
GLOB.size_uncapped_mobs_timer = null
=======
/atom/movable/proc/has_large_resize_bounds()
var/area/A = get_area(src) //Get the atom's area to check for size limit.
return !A.limit_mob_size
/proc/is_extreme_size(size)
return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM)
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
/mob/living/proc/resize(var/new_size, var/animate = TRUE, var/uncapped = FALSE)
if(!uncapped)
<<<<<<< HEAD
new_size = clamp(new_size, RESIZE_TINY, RESIZE_HUGE)
src.size_uncapped = FALSE
remove_from_uncapped_list(src)
else
add_to_uncapped_list(src)
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
remove_from_uncapped_list(src)
else if(is_extreme_size(new_size))
add_to_uncapped_list(src)
=======
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard)
if(guard)
qdel(guard)
else if(has_large_resize_bounds())
if(is_extreme_size(new_size))
AddComponent(/datum/component/resize_guard)
else
var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard)
if(guard)
qdel(guard)
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
if(size_multiplier == new_size)
return 1

View File

@@ -98,10 +98,40 @@
/obj/item/projectile/beam/sizelaser/admin/on_hit(var/atom/target)
var/mob/living/M = target
if(istype(M))
<<<<<<< HEAD
M.resize(set_size, TRUE, TRUE)
if(set_size >= RESIZE_TINY && set_size <= RESIZE_HUGE)
M.size_uncapped = FALSE
M.size_uncapped = TRUE
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
var/can_be_big = M.has_large_resize_bounds()
var/very_big = is_extreme_size(set_size)
if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse
to_chat(firer, "<span class='warning'>[M] will lose this size upon moving into an area where this size is not allowed.</span>")
else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse
to_chat(firer, "<span class='warning'>[M] will retain this normally unallowed size outside this area.</span>")
M.size_uncapped = TRUE
else if(M.size_uncapped) // made a normal size after having been an extreme adminbuse size
to_chat(firer, "<span class='warning'>[M] now returned to normal area-based size limitations.</span>")
M.size_uncapped = FALSE
M.resize(set_size, uncapped = TRUE, ignoring_prefs = TRUE) // Always ignores prefs, caution is advisable
=======
var/can_be_big = M.has_large_resize_bounds()
var/very_big = is_extreme_size(set_size)
if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse
to_chat(firer, "<span class='warning'>[M] will lose this size upon moving into an area where this size is not allowed.</span>")
else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse
to_chat(firer, "<span class='warning'>[M] will retain this normally unallowed size outside this area.</span>")
M.resize(set_size, uncapped = TRUE, ignore_prefs = TRUE) // Always ignores prefs, caution is advisable
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
to_chat(M, "<font color='blue'>The beam fires into your body, changing your size!</font>")
M.updateicon()
return

View File

@@ -353,6 +353,7 @@
#include "code\datums\autolathe\tools.dm"
#include "code\datums\autolathe\tools_vr.dm"
#include "code\datums\components\_component.dm"
#include "code\datums\components\resize_guard.dm"
#include "code\datums\elements\_element.dm"
#include "code\datums\game_masters\_common.dm"
#include "code\datums\helper_datums\construction_datum.dm"