mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-28 07:39:13 +01:00
[MIRROR] optimizes transfer (#12211)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
co-authored by
Kashargul
Cameron Lennox
parent
9668392359
commit
61aa2b94be
@@ -1,3 +1,6 @@
|
||||
#define MAX_ENTRY_MESSAAGES 20
|
||||
#define ENTRY_MESSAGE_INTERVAL 1 SECOND
|
||||
|
||||
//
|
||||
// Belly system 2.0, now using objects instead of datums because EH at datums.
|
||||
// How many times have I rewritten bellies and vore now? -Aro
|
||||
@@ -64,9 +67,9 @@
|
||||
var/eating_privacy_local = "default" //Overrides eating_privacy_global if not "default". Determines if attempt/success messages are subtle/loud
|
||||
var/is_feedable = TRUE // If this belly shows up in belly selections for others.
|
||||
var/silicon_belly_overlay_preference = "Sleeper" //Selects between placing belly overlay in sleeper or normal vore mode. Exclusive
|
||||
var/belly_mob_mult = 1 //Multiplier for how filling mob types are in borg bellies
|
||||
var/belly_item_mult = 1 //Multiplier for how filling items are in borg borg bellies. Items are also weighted on item size
|
||||
var/belly_overall_mult = 1 //Multiplier applied ontop of any other specific multipliers
|
||||
var/belly_mob_mult = 1 //Multiplier for how filling mob types are in borg bellies
|
||||
var/belly_item_mult = 1 //Multiplier for how filling items are in borg borg bellies. Items are also weighted on item size
|
||||
var/belly_overall_mult = 1 //Multiplier applied ontop of any other specific multipliers
|
||||
var/private_struggle = FALSE // If struggles are made public or not
|
||||
var/prevent_saving = FALSE // Can this belly be saved? For special bellies that mobs and adminbus might have.
|
||||
var/absorbedrename_enabled = FALSE // If absorbed prey are renamed.
|
||||
@@ -103,14 +106,14 @@
|
||||
var/autotransferchance = 0 // % Chance of prey being autotransferred to transfer location
|
||||
var/autotransferwait = 10 // Time between trying to transfer.
|
||||
var/autotransferlocation // Place to send them
|
||||
var/autotransferextralocation = list() // List of extra places this could go
|
||||
var/list/autotransferextralocation = list() // List of extra places this could go
|
||||
var/autotransfer_whitelist = 0 // Flags for what can be transferred to the primary location
|
||||
var/autotransfer_blacklist = 2 // Flags for what can not be transferred to the primary location, defaults to Absorbed
|
||||
var/autotransfer_whitelist_items = 0 // Flags for what can be transferred to the primary location
|
||||
var/autotransfer_blacklist_items = 0 // Flags for what can not be transferred to the primary location
|
||||
var/autotransferchance_secondary = 0 // % Chance of prey being autotransferred to secondary transfer location
|
||||
var/autotransferlocation_secondary // Second place to send them
|
||||
var/autotransferextralocation_secondary = list() // List of extra places the secondary transfer could go
|
||||
var/list/autotransferextralocation_secondary = list() // List of extra places the secondary transfer could go
|
||||
var/autotransfer_secondary_whitelist = 0// Flags for what can be transferred to the secondary location
|
||||
var/autotransfer_secondary_blacklist = 2// Flags for what can not be transferred to the secondary location, defaults to Absorbed
|
||||
var/autotransfer_secondary_whitelist_items = 0// Flags for what can be transferred to the secondary location
|
||||
@@ -267,6 +270,9 @@
|
||||
var/list/belly_surrounding = list() // A list of living mobs surrounded by this belly, including inside containers, food, on mobs, etc. Exclusing inside other bellies.
|
||||
var/bellytemperature = T20C // Temperature applied to humans in the belly.
|
||||
var/temperature_damage = FALSE // Does temperature damage prey?
|
||||
var/last_transfer_log = 0 // Prevent server message spam!
|
||||
var/next_transfer_log = 0 // Prevent server message spam!
|
||||
var/entrance_log_count = 0 // Entrance count before spawm
|
||||
flags = NOREACT // We dont want bellies to start bubling nonstop due to people mixing when transfering and making different reagents
|
||||
|
||||
//For serialization, keep this updated, required for bellies to save correctly.
|
||||
@@ -516,7 +522,6 @@
|
||||
log_admin("[key_name(owner)]'s belly `[src]` moved from [old_loc] ([old_loc?.x],[old_loc?.y],[old_loc?.z]) to [loc] ([loc?.x],[loc?.y],[loc?.z]) while containing [key_name(L)].")
|
||||
break
|
||||
|
||||
|
||||
// Called whenever an atom enters this belly
|
||||
/obj/belly/Entered(atom/movable/thing, atom/OldLoc)
|
||||
. = ..()
|
||||
@@ -543,7 +548,15 @@
|
||||
//Generic entered message
|
||||
if(!owner.mute_entry && entrance_logs)
|
||||
if(!istype(thing, /mob/observer)) //Don't have ghosts announce they're reentering the belly on death
|
||||
to_chat(owner,span_vnotice("[thing] slides into your [lowertext(name)]."))
|
||||
if(world.time - last_transfer_log > ENTRY_MESSAGE_INTERVAL)
|
||||
last_transfer_log = world.time
|
||||
entrance_log_count = 0
|
||||
if(world.time >= next_transfer_log)
|
||||
to_chat(owner,span_vnotice("[thing] slides into your [lowertext(name)]."))
|
||||
entrance_log_count++
|
||||
if(entrance_log_count >= MAX_ENTRY_MESSAAGES)
|
||||
next_transfer_log = world.time + ENTRY_MESSAGE_INTERVAL
|
||||
last_transfer_log = world.time
|
||||
|
||||
//Sound w/ antispam flag setting
|
||||
if(vore_sound && !recent_sound && !istype(thing, /mob/observer))
|
||||
@@ -970,11 +983,17 @@
|
||||
// Actually perform the mechanics of devouring the tasty prey.
|
||||
// The purpose of this method is to avoid duplicate code, and ensure that all necessary
|
||||
// steps are taken.
|
||||
/obj/belly/proc/nom_mob(mob/prey, mob/user)
|
||||
if(owner.stat == DEAD)
|
||||
return
|
||||
if(prey.buckled)
|
||||
prey.buckled.unbuckle_mob()
|
||||
/obj/belly/proc/nom_atom(atom/movable/prey, mob/user)
|
||||
if(ismob(prey))
|
||||
var/mob/mob_prey = prey
|
||||
if(owner.stat == DEAD)
|
||||
return
|
||||
if(mob_prey.buckled)
|
||||
mob_prey.buckled.unbuckle_mob()
|
||||
if(mob_prey.ckey)
|
||||
GLOB.prey_eaten_roundstat++
|
||||
if(owner.mind)
|
||||
owner.mind.vore_prey_eaten++
|
||||
|
||||
prey.forceMove(src)
|
||||
owner.updateVRPanel()
|
||||
@@ -982,11 +1001,6 @@
|
||||
for(var/mob/living/M in contents)
|
||||
M.updateVRPanel()
|
||||
|
||||
if(prey.ckey)
|
||||
GLOB.prey_eaten_roundstat++
|
||||
if(owner.mind)
|
||||
owner.mind.vore_prey_eaten++
|
||||
|
||||
// new procs for handling digestion damage as a total rather than per-type
|
||||
// Returns the current total digestion damage per tick of a belly.
|
||||
/obj/belly/proc/get_total_digestion_damage()
|
||||
@@ -1506,11 +1520,15 @@
|
||||
return see
|
||||
|
||||
//Transfers contents from one belly to another
|
||||
/obj/belly/proc/transfer_contents(atom/movable/content, obj/belly/target, silent = 0)
|
||||
/obj/belly/proc/transfer_contents(atom/movable/content, obj/belly/target, silent = FALSE)
|
||||
if(!(content in src) || !istype(target))
|
||||
return
|
||||
content.belly_cycles = 0
|
||||
var/old_entrance_logs = target.entrance_logs
|
||||
if(silent)
|
||||
target.entrance_logs = FALSE
|
||||
content.forceMove(target)
|
||||
target.entrance_logs = old_entrance_logs
|
||||
if(isitem(content))
|
||||
var/obj/item/I = content
|
||||
if(istype(I,/obj/item/card/id))
|
||||
@@ -1519,38 +1537,55 @@
|
||||
I.wash(CLEAN_WASH)
|
||||
I.gurgle_contaminate(target.contents, target.contamination_flavor, target.contamination_color)
|
||||
items_preserved -= content
|
||||
if(!silent)
|
||||
handle_visual_update()
|
||||
|
||||
/obj/belly/proc/handle_visual_update()
|
||||
owner.updateVRPanel()
|
||||
for(var/mob/living/M in contents)
|
||||
M.updateVRPanel()
|
||||
owner.handle_belly_update()
|
||||
|
||||
//Autotransfer belly lookup
|
||||
/obj/belly/proc/compile_autotransfer_bellies()
|
||||
var/list/primary_bellies = list()
|
||||
var/list/secondary_bellies = list()
|
||||
|
||||
var/list/primary_locations = autotransferextralocation.Copy()
|
||||
primary_locations += autotransferlocation
|
||||
var/list/secondary_locations = autotransferextralocation_secondary.Copy()
|
||||
secondary_locations += autotransferlocation_secondary
|
||||
for(var/obj/belly/B in owner.vore_organs)
|
||||
if(B.name in primary_locations)
|
||||
primary_bellies += B
|
||||
if(B.name in secondary_locations)
|
||||
secondary_bellies += B
|
||||
|
||||
return list("primary" = primary_bellies, "secondary" = secondary_bellies)
|
||||
|
||||
//Autotransfer callback
|
||||
/obj/belly/proc/check_autotransfer(var/atom/movable/prey)
|
||||
if(!(prey in contents) || !prey.autotransferable) return
|
||||
var/dest_belly_name
|
||||
/obj/belly/proc/check_autotransfer(var/atom/movable/prey, var/list/transfer_locations)
|
||||
if(!(prey in contents) || !prey.autotransferable)
|
||||
return FALSE
|
||||
var/obj/belly/dest_belly
|
||||
if(autotransferlocation_secondary && prob(autotransferchance_secondary))
|
||||
if(ismob(prey) && autotransfer_filter(prey, autotransfer_secondary_whitelist, autotransfer_secondary_blacklist))
|
||||
dest_belly_name = pick(autotransferextralocation_secondary + autotransferlocation_secondary)
|
||||
dest_belly = pick(transfer_locations["secondary"])
|
||||
if(isitem(prey) && autotransfer_filter(prey, autotransfer_secondary_whitelist_items, autotransfer_secondary_blacklist_items))
|
||||
dest_belly_name = pick(autotransferextralocation_secondary + autotransferlocation_secondary)
|
||||
dest_belly = pick(transfer_locations["secondary"])
|
||||
if(autotransferlocation && prob(autotransferchance))
|
||||
if(ismob(prey) && autotransfer_filter(prey, autotransfer_whitelist, autotransfer_blacklist))
|
||||
dest_belly_name = pick(autotransferextralocation + autotransferlocation)
|
||||
dest_belly = pick(transfer_locations["primary"])
|
||||
if(isitem(prey) && autotransfer_filter(prey, autotransfer_whitelist_items, autotransfer_blacklist_items))
|
||||
dest_belly_name = pick(autotransferextralocation + autotransferlocation)
|
||||
if(!dest_belly_name) // Didn't transfer, so wait before retrying
|
||||
dest_belly = pick(transfer_locations["primary"])
|
||||
if(!dest_belly) // Didn't transfer, so wait before retrying
|
||||
prey.belly_cycles = 0
|
||||
return
|
||||
var/obj/belly/dest_belly
|
||||
for(var/obj/belly/B in owner.vore_organs)
|
||||
if(B.name == dest_belly_name)
|
||||
dest_belly = B
|
||||
break
|
||||
if(!dest_belly) return
|
||||
return FALSE
|
||||
if(ismob(prey))
|
||||
var/autotransfer_owner_message
|
||||
var/autotransfer_prey_message
|
||||
if(dest_belly_name == autotransferlocation)
|
||||
var/dest_belly_name = dest_belly.name
|
||||
if(dest_belly.name == autotransferlocation)
|
||||
autotransfer_owner_message = span_vwarning(belly_format_string(primary_autotransfer_messages_owner, prey, dest = dest_belly_name))
|
||||
autotransfer_prey_message = span_vwarning(belly_format_string(primary_autotransfer_messages_prey, prey, dest = dest_belly_name))
|
||||
else
|
||||
@@ -1561,7 +1596,7 @@
|
||||
if(entrance_logs)
|
||||
to_chat(owner, autotransfer_owner_message)
|
||||
|
||||
transfer_contents(prey, dest_belly)
|
||||
transfer_contents(prey, dest_belly, TRUE)
|
||||
return TRUE
|
||||
|
||||
//Autotransfer filter
|
||||
@@ -2206,3 +2241,6 @@
|
||||
|
||||
/obj/belly/proc/toggle_displayed_message_flags(flags_to_set)
|
||||
displayed_message_flags ^= flags_to_set
|
||||
|
||||
#undef MAX_ENTRY_MESSAAGES
|
||||
#undef ENTRY_MESSAGE_INTERVAL
|
||||
|
||||
@@ -27,20 +27,26 @@
|
||||
// Autotransfer count moved here.
|
||||
if(autotransfer_enabled)
|
||||
var/list/autotransferables = list()
|
||||
var/list/transfer_bellies = compile_autotransfer_bellies()
|
||||
for(var/atom/movable/M in contents)
|
||||
if(!M || !M.autotransferable) continue
|
||||
if(!M || !M.autotransferable)
|
||||
continue
|
||||
// If the prey can't pass the filter of at least one transfer location, skip it
|
||||
if(ismob(M) && !(autotransfer_filter(M, autotransfer_secondary_whitelist, autotransfer_secondary_blacklist) || autotransfer_filter(M, autotransfer_whitelist, autotransfer_blacklist))) continue
|
||||
if(isitem(M) && !(autotransfer_filter(M, autotransfer_secondary_whitelist_items, autotransfer_secondary_blacklist_items) || autotransfer_filter(M, autotransfer_whitelist_items, autotransfer_blacklist_items))) continue
|
||||
M.belly_cycles++
|
||||
if(M.belly_cycles < autotransferwait / 60) continue
|
||||
if(M.belly_cycles < autotransferwait / 60)
|
||||
continue
|
||||
autotransferables += M
|
||||
if(LAZYLEN(autotransferables) >= autotransfer_min_amount)
|
||||
var/tally = 0
|
||||
for(var/atom/movable/M in autotransferables)
|
||||
if(check_autotransfer(M))
|
||||
if(check_autotransfer(M, transfer_bellies))
|
||||
tally++
|
||||
if(autotransfer_max_amount > 0 && tally >= autotransfer_max_amount) break
|
||||
if(autotransfer_max_amount > 0 && tally >= autotransfer_max_amount)
|
||||
break
|
||||
for(var/obj/belly/transfer_belly in (transfer_bellies["primary"] + transfer_bellies["secondary"]))
|
||||
transfer_belly.handle_visual_update()
|
||||
|
||||
var/play_sound //Potential sound to play at the end to avoid code duplication.
|
||||
var/to_update = FALSE //Did anything update worthy happen?
|
||||
|
||||
@@ -829,7 +829,7 @@
|
||||
if(!I.on_trash_eaten(src)) // shows object's rejection message itself
|
||||
return
|
||||
drop_item()
|
||||
I.forceMove(vore_selected)
|
||||
vore_selected.nom_atom(I)
|
||||
updateVRPanel()
|
||||
log_admin("VORE: [src] used Eat Trash to swallow [I].")
|
||||
I.after_trash_eaten(src)
|
||||
|
||||
@@ -44,4 +44,4 @@
|
||||
target.visible_message(span_vwarning("\The [target] suddenly disappears somewhere above!"),\
|
||||
span_vdanger("You are dragged above and feel yourself slipping directly into \the [src]'s [vore_selected.get_belly_name()]!"))
|
||||
to_chat(src, span_vnotice("You successfully snatch \the [target], slipping them into your [vore_selected.get_belly_name()]."))
|
||||
target.forceMove(src.vore_selected)
|
||||
vore_selected.nom_atom(target)
|
||||
|
||||
@@ -72,13 +72,13 @@
|
||||
if(istype(prey.loc, /obj/item/holder))
|
||||
var/obj/item/holder/H = prey.loc
|
||||
for(var/mob/living/M in H.contents)
|
||||
belly.nom_mob(M, user)
|
||||
if(M.loc == H) // In case nom_mob failed somehow.
|
||||
belly.nom_atom(M, user)
|
||||
if(M.loc == H) // In case nom_atom failed somehow.
|
||||
M.forceMove(get_turf(user))
|
||||
H.held_mob = null
|
||||
qdel(H)
|
||||
else
|
||||
belly.nom_mob(prey, user)
|
||||
belly.nom_atom(prey, user)
|
||||
|
||||
user.update_icon()
|
||||
|
||||
|
||||
@@ -974,7 +974,7 @@
|
||||
if(M.absorbed)
|
||||
M.absorbed = FALSE
|
||||
OB.handle_absorb_langs(M, OB.owner)
|
||||
TB.nom_mob(M)
|
||||
TB.nom_atom(M)
|
||||
|
||||
/datum/vore_look/proc/pick_from_outside(mob/user, params)
|
||||
var/intent
|
||||
@@ -1004,7 +1004,8 @@
|
||||
to_chat(target,span_vwarning("You're squished from [host]'s [lowertext(host.vore_selected)] to their [lowertext(choice.name)]!"))
|
||||
// Send the transfer message to indirect targets as well. Slightly different message because why not.
|
||||
to_chat(host.vore_selected.get_belly_surrounding(target.contents),span_warning("You're squished along with [target] from [host]'s [lowertext(host.vore_selected)] to their [lowertext(choice.name)]!"))
|
||||
host.vore_selected.transfer_contents(target, choice, 1)
|
||||
host.vore_selected.transfer_contents(target, choice, TRUE)
|
||||
host.vore_selected.handle_visual_update()
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -1071,7 +1072,6 @@
|
||||
to_chat(host.vore_selected.get_belly_surrounding(target.contents),span_warning("You're squished along with [target] from [host]'s [lowertext(host.vore_selected)] to their [lowertext(choice.name)]!"))
|
||||
host.vore_selected.transfer_contents(target, choice)
|
||||
|
||||
|
||||
if("Transfer")
|
||||
if(host.stat)
|
||||
to_chat(user,span_warning("You can't do that in your state!"))
|
||||
@@ -1380,6 +1380,8 @@
|
||||
|
||||
switch(ability)
|
||||
if("devour_as_absorbed")
|
||||
if(!(OB.mode_flags & DM_FLAG_ABSORBEDVORE))
|
||||
return FALSE
|
||||
user.absorb_devour()
|
||||
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user