#include <deadron/characterhandling>
client
base_num_characters_allowed = 5
world
mob = /mob/creating_character
mob/base_save_location = 0
mob/creating_character
base_save_allowed = 0 // If player quits before choosing, don't want to save this mob.
Login()
// Spawn here to avoid problems with calling prompts during login.
spawn()
src.CreateCharacter()
proc/CreateCharacter()
var/prompt_title = "New Character"
var/help_text = "What do you want to name the character?"
var/default_value = key
var/char_name = input(src, help_text, prompt_title, default_value) as null|text
char_name = html_encode(char_name)
if(length(char_name)>20)
char_name = null
alert("Names must be under 21 characters long.")
if (!char_name)
client.base_ChooseCharacter()
return
// Make sure there isn't already a character named that.
// Character names are stored as ckey, so get the ckey version of the name.
var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
if (characters.Find(ckey_name))
alert("You already have a character named that! Please choose another name.")
src.CreateCharacter()
return
var/char_class
var/list/classes = list("Berserker","Demon Lord","Dragoon","Gaurd","Gladiator","Golem","Healer","Knight","Mage","Nomad","Ogre","Rogue","Warlock")
help_text = "What class?"
default_value = "Warrior"
char_class = input(src, help_text, prompt_title, default_value) in classes
var/mob/new_mob
// Okay we have enough information, so it's time to create the character and switch the player to it.
switch(char_class)
if("Berserker")
usr.hp = 20
usr.atk = 5
usr.def = 0
usr.str = 5
usr.dex = 15
usr.gold = 10
usr.icon = 'Berserker.dmi'
usr.contents += new/obj/weapons/Axe
if("Dragoon")
usr.hp = 15
usr.atk = 10
usr.def = 1
usr.str = 10
usr.dex = 5
usr.icon = 'Black Dragon.dmi'
if("Demon Lord")
usr.hp = 10
usr.atk = 4
usr.def = 0
usr.str = 4
usr.dex = 10
usr.icon = 'Demon Lord.dmi'
usr.gold = 5
usr.contents += new/obj/weapons/Longsword
usr.contents += new/obj/armour/demon_plate
if("Mage")
usr.hp = 10
usr.atk = 2
usr.def = 0
usr.gold = 40
usr.spell = 1
usr.mp = 40
usr.mmp = 40
usr.str = 3
usr.dex = 10
usr.icon = 'Mage.dmi'
usr.contents += new/obj/weapons/Quarterstaff
usr.contents += new/obj/armour/leather
if("Gaurd")
usr.hp = 15
usr.atk = 3
usr.def = 7
usr.gold = 20
usr.str = 5
usr.dex = 12
usr.icon = 'Gaurd.dmi'
usr.contents += new/obj/weapons/Hammer
usr.contents += new/obj/armour/plate
if("Gladiator")
usr.hp = 15
usr.atk = 5
usr.def = 2
usr.gold = 50
usr.str = 10
usr.dex = 13
usr.icon = 'Gladiator.dmi'
usr.contents += new/obj/weapons/Flail
usr.contents += new/obj/armour/chain_mail
if("Golem")
usr.hp = 20
usr.atk = 2
usr.def = 10
usr.str = 8
usr.dex = 1
usr.icon = 'Golem.dmi'
if("Healer")
usr.hp = 30
usr.atk = 2
usr.def = 1
usr.gold = 30
usr.spell = 1
usr.mp = 20
usr.mmp = 20
usr.str = 4
usr.dex = 14
usr.icon = 'Healer.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/leather
if("Knight")
usr.hp = 15
usr.atk = 5
usr.def = 2
usr.str = 12
usr.dex = 7
usr.icon = 'Knight.dmi'
usr.contents += new/obj/weapons/Longsword
usr.contents += new/obj/armour/plate
if("Nomad")
usr.hp = 15
usr.atk = 4
usr.def = 5
usr.gold = 10
usr.str = 10
usr.dex = 20
usr.icon = 'Nomad.dmi'
usr.contents += new/obj/weapons/Short_Sword
usr.contents += new/obj/armour/studded_leather
if("Ogre")
usr.hp = 20
usr.atk = 8
usr.def = -2
usr.gold = 5
usr.str = 15
usr.dex = 4
usr.icon = 'Ogre.dmi'
usr.contents += new/obj/weapons/Axe
usr.contents += new/obj/armour/heavy_plate
if("Ranger")
usr.hp = 20
usr.atk = 5
usr.def = 0
usr.gold = 20
usr.str = 4
usr.dex = 35
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Scimitar
usr.contents += new/obj/armour/leather
if("Rogue")
usr.hp = 10
usr.atk = 6
usr.def = 0
usr.gold = 45
usr.str = 4
usr.dex = 30
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/studded_leather
if("Samurai")
usr.hp = 15
usr.atk = 8
usr.def = 0
usr.gold = 15
usr.str = 6
usr.dex = 15
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Scimitar
usr.contents += new/obj/armour/plate
if("Skirmisher")
usr.hp = 10
usr.atk = 4
usr.def = 1
usr.gold = 10
usr.str = 3
usr.dex = 35
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/studded_leather
if("Warlock")
usr.hp = 10
usr.atk = 3
usr.def = 1
usr.gold = 50
usr.spell = 1
usr.mp = 30
usr.mmp = 30
usr.str = 5
usr.dex = 10
usr.icon = 'Sage.dmi'
usr.contents += new/obj/weapons/Quarterstaff
usr.contents += new/obj/armour/leather
// Set the attributes.
new_mob.name = char_name
// Now switch the player client over to the new mob and delete myself since I'm no longer needed.
src.client.mob = new_mob
var/turf/first_location = locate(10,3,1)
new_mob.Move(first_location)
del(src)
mob
Login()
..()
// This is just here for this sample, to make it clear which mob you've logged into.
/*switch(src.key)
if("Xerse", "ManeBass", "Mmbah")
world << "\blue <b> [usr] has joined all; bow to \his mighty power!"*/
// This is just here for this sample, to make it clear which mob you've logged into.
Write(savefile/F)
// This is sample code that keeps track of the player's last position on the map.
// Their last position is stored when the mob is saved, then reinstated when the mob
// is read in.
// First, call the default Write() behavior for mobs.
..()
// Now, if we have a map, remember their last location.
if (world.maxx)
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z
Read(savefile/F)
// Call the default Read() behavior for mobs.
..()
// Now, if we have a map, put them back on the map in their last location.
if (world.maxx)
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)
mob
Login()
..()
// This is just here for this sample, to make it clear which mob you've logged into.
sample_report()
verb
save_me()
// This demonstrates verb saving and how to manually save the mob whenever you want..
// This proc gets added and saved as a verb only if add_verb is called by the player.
src.client.base_SaveMob()
src << "\red You have been saved."
proc
sample_report()
src << "<BR><BR>"
src << "\blue You are [name]."
src << "\blue You are level [lvl]."
Problem description:
That is my entire source based off the "Rise of Heros" release.
It just doesn't work
I am only riping this because I, nor any of my coders know how to create a save code... If someone could help me, that would be great!
The code example you give looks like it was written based on stuff in that chapeter. So reading it will give them a good explanation of the code.
They should read the rest of the guide too, so they can notice some problems in the code, like where mob is indented and if it wasn't like how there are 2 Login()'s declared. Stuff like that is impossible for coders to figure out without at least learning the basics.
Good luck.