I need to know how to save your level and stuff......
mob/verb
Save()
set category="S/L"
var/savefile/F = new("players/[src.ckey].sav")//define savefile
F["name"] << name//input the users name into the savefile
F["icon"] << icon
F["X"] << src.x//okay so heres where the x/y/zs come in this just saves the users current locatin..pretty simple ;)
F["Y"] << src.y
F["Z"] << src.z
for(var/V in src.verbs)
F["verbs"] << V
mob/verb
Load()
set category="S/L"
var/savefile/F = new("players/[src.ckey].sav")//this defines the F as a save file in the players directory
var/X
var/Y
var/Z
F["name"] >> name//this checks the savefiles var = name and it outputs it to the character. your going to want to add another one of these for each var
F["X"] >> X//this outputs the X var which we will put into the F later on
F["Y"] >> Y//same as X
F["Z"] >> Z//same as X/Y
F["icon"] >> icon
usr.loc = locate(X,Y,Z)//locates the user to teh saved x/y/z
^ Thats the save code....
//Begin defining procs
mob
proc
Levelup()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp to 0
src.maxexp*=2//makes your maxexp double
src<<"You gained a level!"
src.Statup()
else
..()//defaults if the if() doesn't return it's arguments
mob
proc
Statup()
src.maxhealth+=20//adds to your health
src.health=src.maxhealth
src<<"Your stats increase!"//Outputs a message telling you that you gained stats
//Call both of these procs in your attack process here's an example
/*
mob/verb/Attack(mob/M as mob in oview(1))
usr.exp+=1
usr.Levelup()//called the procs
*/
//End proc defining
//Start var defining
mob
var
health = 100//Makes a var called health and gives it the value 100
maxhealth = 100
exp = 0
maxexp = 1000
level = 1
//end var defining
//start stat process
mob
Stat()//Calls the stat proc.
..()
statpanel("Stats")//Makes a new statpanel called "Stats"
stat("Health","[health]/[maxhealth]")
stat("Experience","[exp]/[maxexp]")//Creates a new stat called "Experience" and gives it the value of "exp/maxexp"
stat("Level",level)
/*
Now, for the demo internals here. These procs and verbs are
only for the demo, you don't need them, but you can still learn from them
I'll even comment them for you :)
-Nadrew
*/
mob/proc/attack(mob/M)//This will be used to make the demo challenging
var/damage = rand(1,15)//a bit of damage never hurt..wait, yes it does!
M<<"[src] attacked you for [damage] damage!"
if(src.client)
src<<"You attacked [M] for [damage] damage!"
M.health-=damage
src.deathcheck(M)
if(src.client)//Only players can gain levels
src.exp+=rand(50,300)//adds random exp points
src.Levelup()//calls the levelup proc
else
return..()//normal action
mob/proc/deathcheck(mob/M as mob)//handles death
if(M.health<=0)//checks health
if(M.client)//if is a player
M.loc = locate(1,1,1)//restarts
M.health = M.maxhealth//resets health
M<<"[src] killed you!"//tells you, you were killed.
else//not a player
src<<"You killed [M]!"//Tells you who you killed
M.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.ma xz))
//random location after death
//Now for the NPC things.
mob/NPC//Defines a /mob/NPC
icon = 'enemy.dmi'
icon_state = "bad"
health = 200//different health than the main mob
Click()//When clicked
usr.attack(src)//attack!
proc/move()//Now, this proc handles NPC movement
for(var/mob/M in oview())//loops over all mobs in view
if(get_step_away(src,M,3))//checks distance
if(!M.client)//Not a player
continue//continues through the loop
else//Player
walk_to(src,M,1,2)//Move to the person
else//4-or-more spaces away
continue
spawn(20) move()//loops the proc after 2 seconds
proc/attackplayer()//Handles attacking
for(var/mob/M in oview(1))//Within one space this time
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.attack(M)//Calls the attack proc
else
return..()
spawn(20) attackplayer()
New()//When created
attackplayer()//Calls the procs for it
move()
^ Thats the battle code..
Thanks SO much!! ^_^
</<></<></<></<></< ></<>
ID:267707
Aug 29 2003, 5:30 pm
|
|
Aug 29 2003, 6:03 pm
|
|
nm i got it to work XD
|
mob/verb
Save() set category="S/L" var/savefile/F = new("players/[src.ckey].sav") F["[src]"] << src //Send all of his data to the file Load() set category="S/L" var/savefile/F = new("players/[src.ckey].sav") F["[src]"] >> src that will simply send everything about src to the file (src being the person) its much more efficient, it saves all the variables. (Therefore saving the persons level) OR just add the following to your code: F["level"] << src.level and for the load: F["level"] >> src.level |