Saving is done!

This commit is contained in:
Arokha Sieyes
2016-05-08 22:48:32 -04:00
parent 801df6fd32
commit ba83c969cb
5 changed files with 132 additions and 83 deletions
+3
View File
@@ -143,8 +143,11 @@
OR.trans_to(ML,OR.total_volume / absorbed_count)
world << "check_belly [M.loc]"
var/datum/belly/B = check_belly(M.loc)
world << "check_belly returned: [B]"
if(B)
world << "RSC adding: [M] to [B]"
B.internal_contents += M
owner.visible_message("<font color='green'><b>[owner] expels [M] from their [lowertext(name)]!</b></font>")
@@ -2,10 +2,6 @@
// Called from /mob/living/Life() proc.
/datum/belly/proc/process_Life()
///////////////////////////// TIMER /////////////////////////////
if(!internal_contents.len || air_master.current_cycle%3 != 1)
return
/////////////////////////// Auto-Emotes ///////////////////////////
if((digest_mode in emote_lists) && !emotePend)
emotePend = 1
+107 -53
View File
@@ -15,17 +15,21 @@
M.verbs += /mob/living/proc/insidePanel
M.verbs += /mob/living/proc/escapeOOC
if(M.client && M.client.prefs_vr)
M.vore_organs = M.client.prefs_vr.belly_prefs
M.vore_selected = M.vore_organs[1]
M.digestable = M.client.prefs_vr.digestable
//Creates at least the typical 'stomach' on every mob.
if(!M.vore_organs.len)
//Tries to load prefs if a client is present otherwise gives freebie stomach
if(!M.vore_organs || !M.vore_organs.len)
spawn(20) //Wait a couple of seconds to make sure copy_to or whatever has gone
//In Polaris, when a character joins (not spawns), it creates some sort of 'Force' /mob/living/silicon/ai
//then immediately deletes it. I'm not sure why, but we should make sure M is still real 2 seconds later.
if(M && !M.vore_organs.len)
if(!M) return
if(M.client && M.client.prefs_vr)
if(!M.copy_from_prefs_vr())
M << "<span class='warning'>ERROR: You seem to have saved VOREStation prefs, but they couldn't be loaded.</span>"
return 0
if(M.vore_organs && M.vore_organs.len)
M.vore_selected = M.vore_organs[1]
if(!M.vore_organs || !M.vore_organs.len)
if(!M.vore_organs)
M.vore_organs = list()
var/datum/belly/B = new /datum/belly(M)
B.immutable = 1
B.name = "Stomach"
@@ -76,33 +80,40 @@
var/mob/living/attacker = user // Typecast to living
world << "[G] with [G.affecting] and [G.assailant] clicked on [src] with intent [user.a_intent] and target [user.zone_sel.selecting]"
// src is the mob clicked on
// If grab clicked on grabber
if(src == G.assailant)
if (is_vore_predator(src))
if (src.feed_grabbed_to_self(src, G.affecting))
qdel(G) //Delete grab
return 1 //Return 1 to exit upper procs
else
log_debug("[attacker] attempted to feed [G.affecting] to [user] ([user.type]) but it is not predator-capable")
if(src == G.affecting)
world << "1 is true"
if(attacker.a_intent == I_GRAB)
world << "2 is true"
if(attacker.zone_sel.selecting == BP_TORSO)
world << "3 is true"
if(is_vore_predator(G.affecting))
world << "4 is true"
// If grab clicked on grabbed
if((src == G.affecting) && (user.a_intent == I_GRAB) && (user.zone_sel.selecting == BP_TORSO))
if (is_vore_predator(G.affecting))
if (attacker.feed_self_to_grabbed(attacker, G.affecting))
qdel(G) //Delete grab
return 1 //Return 1 to exit upper procs
///// If grab clicked on grabber
if((src == G.assailant) && (is_vore_predator(src)))
if (src.feed_grabbed_to_self(src, G.affecting))
qdel(G)
return 1
else
log_debug("[attacker] attempted to feed [user] to [G.affecting] ([G.affecting.type]) but it is not predator-capable")
log_debug("[attacker] attempted to feed [G.affecting] to [user] ([user.type]) but it failed.")
// If grab clicked on anything else
else
if (is_vore_predator(src))
if (attacker.feed_grabbed_to_other(attacker, G.affecting, src))
qdel(G) //Delete grab
return 1 //Return 1 to exit upper procs
///// If grab clicked on grabbed
else if((src == G.affecting) && (attacker.a_intent == I_GRAB) && (attacker.zone_sel.selecting == BP_TORSO) && (is_vore_predator(G.affecting)))
if (attacker.feed_self_to_grabbed(attacker, G.affecting))
qdel(G)
return 1
else
log_debug("[attacker] attempted to feed [G.affecting] to [src] ([src.type]) but it is not predator-capable")
log_debug("[attacker] attempted to feed [user] to [G.affecting] ([G.affecting.type]) but it failed.")
///// If grab clicked on anyone else
else if((src != G.affecting) && (src != G.assailant) && (is_vore_predator(src)))
if (attacker.feed_grabbed_to_other(attacker, G.affecting, src))
qdel(G)
return 1
else
log_debug("[attacker] attempted to feed [G.affecting] to [src] ([src.type]) but it failed.")
//Handle case: /obj/item/weapon/holder
@@ -116,37 +127,83 @@
// Proc for updating vore organs and digestion/healing/absorbing
//
/mob/living/proc/handle_internal_contents()
for (var/bellytype in vore_organs)
var/datum/belly/B = vore_organs[bellytype]
for(var/atom/movable/M in B.internal_contents)
if(M.loc != src)
B.internal_contents -= M
log_debug("Had to remove [M] from belly [B] in [src]")
B.process_Life()
if(air_master.current_cycle%3 != 1)
return //The accursed timer
for (var/I in vore_organs)
var/datum/belly/B = vore_organs[I]
if(B.internal_contents.len)
B.process_Life() //AKA 'do bellymodes_vr.dm'
if(air_master.current_cycle%3 != 1) return //Occasionally do supercleanups.
for (var/I in vore_organs)
var/datum/belly/B = vore_organs[I]
if(B.internal_contents.len)
for(var/atom/movable/M in B.internal_contents)
if(M.loc != src)
B.internal_contents -= M
log_debug("Had to remove [M] from belly [B] in [src]")
//
// Verb for saving vore preferences to save file
//
/mob/living/proc/save_vore_prefs()
set name = "Save Vore Prefs"
set category = "Vore"
if(!(client || client.prefs_vr))
return 0
if(!copy_to_prefs_vr())
return 0
if(!client.prefs_vr.save_vore())
return 0
var/result = 0
return 1
if(client.prefs_vr)
result = client.prefs_vr.save_vore_preferences()
else
/mob/living/proc/apply_vore_prefs()
if(!(client || client.prefs_vr))
return 0
if(!client.prefs_vr.load_vore())
return 0
if(!copy_from_prefs_vr())
return 0
return 1
/mob/living/proc/copy_to_prefs_vr()
if(!client || !client.prefs_vr)
src << "<span class='warning'>You attempted to save your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>"
log_debug("[src] tried to save vore prefs but lacks a client.prefs var.")
return 0
return result
var/datum/vore_preferences/P = client.prefs_vr
P.digestable = src.digestable
P.belly_prefs = src.vore_organs
P.weight_gain = src.weight_gain
P.weight_loss = src.weight_loss
return 1
//
// Proc for applying vore preferences, given bellies
//
/mob/living/proc/apply_vore_prefs(var/list/bellies)
if(!bellies || bellies.len == 0)
log_debug("Tried to apply bellies to [src] and failed.")
/mob/living/proc/copy_from_prefs_vr(var/list/bellies)
if(!client || !client.prefs_vr)
src << "<span class='warning'>You attempted to apply your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>"
return 0
var/datum/vore_preferences/P = client.prefs_vr
src.digestable = P.digestable
src.vore_organs = P.belly_prefs
src.weight_gain = P.weight_gain
src.weight_loss = P.weight_loss
if(!src.vore_organs) //Emergency double-backup to stop runtimes from doing .len on this.
vore_organs = list()
for(var/I in vore_organs) //Set the owner at runtime since... yanno.
var/datum/belly/B = vore_organs[I]
B.owner = src
return 1
//
// OOC Escape code for pref-breaking or AFK preds
@@ -183,8 +240,6 @@
CB.release_specific_contents(src)
message_admins("[key_name(src)] used the OOC escape button to get out of [key_name(pred)] (PC) ([pred ? "<a href='?_src_=holder;adminplayerobservecoodjump=1;X=[pred.x];Y=[pred.y];Z=[pred.z]'>JMP</a>" : "null"])")
/* POLARISTODO - Depends on dogborgs
//You're in a dogborg!
else if(istype(src.loc, /obj/item/device/dogborg/sleeper))
var/mob/living/silicon/pred = src.loc.loc //Thing holding the belly!
@@ -195,7 +250,6 @@
message_admins("[key_name(src)] used the OOC escape button to get out of [key_name(pred)] (BORG) ([pred ? "<a href='?_src_=holder;adminplayerobservecoodjump=1;X=[pred.x];Y=[pred.y];Z=[pred.z]'>JMP</a>" : "null"])")
belly.go_out(src) //Just force-ejects from the borg as if they'd clicked the eject button.
*/
else
src << "<span class='alert'>You aren't inside anyone, you clod.</span>"
+14 -20
View File
@@ -58,17 +58,6 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
client_ckey = C.ckey
load_vore(C)
//
// Adding procs to types to support vore
//
/datum/vore_preferences/proc/save_vore_preferences()
save_vore()
return
/datum/vore_preferences/proc/load_vore_preferences()
load_vore()
return
//
// Check if an object is capable of eating things, based on vore_organs
//
@@ -95,24 +84,27 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
//
// Save/Load Vore Preferences
//
/datum/vore_preferences/proc/load_vore(filename="preferences_vr.sav")
/datum/vore_preferences/proc/load_vore()
if(!client || !client_ckey) return 0 //No client, how can we save?
if(!path)
path = "data/player_saves/[copytext(client_ckey,1,2)]/[client_ckey]/[filename]"
if(!path) return 0 //Path couldn't be set?
slot = client.prefs.default_slot
path = client.prefs.path
if(!path) return 0 //Path couldn't be set?
if(!fexists(path)) //Never saved before
save_vore() //Make the file first
return 1
var/savefile/S = new /savefile(path)
if(!S) return 0 //Savefile object couldn't be created?
S.cd = "/"
if(!slot)
slot = client.prefs.default_slot
slot = sanitize_integer(slot, 1, config.character_slots, initial(client.prefs.default_slot))
S.cd = "/character[slot]"
S["digestable"] >> digestable
S["belly_prefs"] >> belly_prefs
S["weight_gain"] >> weight_gain
S["weight_loss"] >> weight_loss
return 1
@@ -125,5 +117,7 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
S["digestable"] << digestable
S["belly_prefs"] << belly_prefs
S["weight_gain"] << weight_gain
S["weight_loss"] << weight_loss
return 1
+8 -6
View File
@@ -470,19 +470,21 @@
usr << "<span class='warning'>Can't delete bellies with contents!</span>"
else if(selected.immutable)
usr << "<span class='warning'>This belly is marked as undeletable.</span>"
else if(user.vore_organs.len == 1)
usr << "<span class='warning'>You must have at least one belly.</span>"
else
var/alert = alert("Are you sure you want to delete [selected]?","Confirmation","Delete","Cancel")
if(alert == "Delete" && !selected.internal_contents.len)
user.vore_organs -= selected.name
user.vore_organs.Remove(selected)
selected = null
selected = user.vore_organs[1]
user.vore_selected = user.vore_organs[1]
if(href_list["saveprefs"])
if(user.save_vore_prefs())
user << "<span class='notice'>Saved belly preferences.</span>"
if(!user.save_vore_prefs())
user << "<span class='warning'>ERROR: Virgo-specific preferences failed to save!</span>"
else
user << "<span class='warning'>ERROR: Could not save vore prefs.</span>"
log_debug("Could not save vore prefs on USER: [user].")
user << "<span class='notice'>Virgo-specific preferences saved!</span>"
if(href_list["toggledg"])
var/choice = alert(user, "This button is for those who don't like being digested. It can make you undigestable. Don't abuse this button by toggling it back and forth to extend a scene or whatever, or you'll make the admins cry. Digesting you is currently: [user.digestable ? "Allowed" : "Prevented"]", "", "Allow Digestion", "Cancel", "Prevent Digestion")
@@ -496,7 +498,7 @@
message_admins("[key_name(user)] toggled their digestability to [user.digestable] ([user ? "<a href='?_src_=holder;adminplayerobservecoodjump=1;X=[user.loc.];Y=[user.loc.y];Z=[user.loc.z]'>JMP</a>" : "null"])")
if(user.client.prefs)
if(user.client.prefs_vr)
user.client.prefs_vr.digestable = user.digestable
//Refresh when interacted with, returning 1 makes vore_look.Topic update