-Digimon Variables:
mob
Digimon
var
hp //Hit points
hpm //Hit points
sp //Skill points
spm //Skill points
saved = 0 //Tried to use this to check if you already saved the Digimon in my save code
exp //Experience
expn //Experience
lvl //Lvl
weig //Weight
fnds //Friendship with the owner
owner // Player ckey
str //Strenght
def //Defense
dlvl // "In-Training" || "Rookie" || "Champion" || "Mega" || "Ultimate"
race // "Agumon" || "Gabumon" || "Gomamon" ...
-Save Code:
mob
proc
Save()
var/savefile/S = new("Saves/[src.ckey]/[src.ckey].sav") //Creates a new save of your last saved character
S["last_x"] << usr.x //stores last X coordinate
S["last_y"] << usr.y //stores last Y coordinate
S["last_z"] << usr.z //stores last Z coordinate
var/savefile/H = new("Saves/[src.ckey]/[src.ckey]Digimon.sav")
for(var/i=1;i<=src.digi;i++)
var/mob/Digimon/E
for(var/mob/Digimon/X in world)
if(X.owner == src.ckey && X.saved == 0)
E = X
X.saved = 1
break
H["D[i]/ICON"] << E.icon
H["D[i]/NAME"] << E.name
H["D[i]/HP"] << E.hp
H["D[i]/HPM"] << E.hpm
H["D[i]/SP"] << E.sp
H["D[i]/SPM"] << E.spm
H["D[i]/EXP"] << E.exp
H["D[i]/EXPN"] << E.expn
H["D[i]/LVL"] << E.lvl
H["D[i]/WEIG"] << E.weig
H["D[i]/FNDS"] << E.fnds
H["D[i]/STR"] << E.str
H["D[i]/DEF"] << E.def
H["D[i]/DLVL"] << E.dlvl
H["D[i]/RACE"] << E.race
H["D[i]/X"] << E.x
H["D[i]/Y"] << E.y
H["D[i]/Z"] << E.z
Write(S) // Writes the stored files into one
Write(H)
Load() //Load procedure
if(fexists("Saves/[src.ckey]/[src.ckey].sav")) // Looks for written save file and if it exists it allows acces to load
var/savefile/S = new("Saves/[src.ckey]/[src.ckey].sav")
var/savefile/H = new("Saves/[src.ckey]/[src.ckey]Digimon.sav")
Read(S)
Read(H)
usr.loc = locate(S["last_x"],S["last_y"],S["last_z"])
for(var/i=1;i<=src.digi;i++)
var/mob/Digimon/E = new()
E.loc = locate(H["D[i]/X"],H["D[i]/Y"],H["D[i]/Z"])
H["D[i]/NAME"] >> E.name
H["D[i]/ICON"] >> E.icon
H["D[i]/HP"] >> E.hp
H["D[i]/HPM"] >> E.hpm
H["D[i]/SP"] >> E.sp
H["D[i]/SPM"] >> E.spm
H["D[i]/EXP"] >> E.exp
H["D[i]/EXPN"] >> E.expn
H["D[i]/LVL"] >> E.lvl
H["D[i]/WEIG"] >> E.weig
H["D[i]/FNDS"] >> E.fnds
H["D[i]/STR"] >> E.str
H["D[i]/DEF"] >> E.def
H["D[i]/DLVL"] >> E.dlvl
H["D[i]/RACE"] >> E.race
E.owner = src.ckey
*Problem description:
I'm working in a digimon game, and the Digimon are going to be like pets, but you won't be able to get the in your inventory. So what I'm trying to do is create a savefile for each Digimon the player has, and charge them once the player loads his past savefile. I've tried EVERYTHING (seriously) but nothing works. I've created this code, but it will only charge the player, it doesn't even create the mob. I'm desperate T-T, any ideas on how to work this out? If you have a total new code, fine for me...
Store the objects you want to save in the thingstosave list. If any special processing needs to be done during saving/loading (IE: location will not be saved) put it in the object's Read() or Write() proc.