ID:145251
 
Code:
mob/player

Login()
sleep(20)
world << " \blue [usr] logs on!"
alert("welcome to my first game!","Welcome","Ok")
src.name = input("What is your name?","Name",src.key)
var/a = input("What class do you want?") in list ("Bowser")
if(a=="Bowser")
usr.icon='characters.dmi'
usr.icon_state="bowser"
usr.HP=25
usr.MAXHP=25
usr.FP=5
usr.MAXFP=5
usr.def=15
usr.str=10
usr.class="Bowser"
usr.Exp=0
usr.NExp=30
usr.Mexp=0
usr.NeedMexp=40
usr.Fexp=0
usr.NeedFexp=50
usr.loc = locate(7,5,1)
Logout()
world << " \blue [usr] logs out!"
sleep(5)
del(src)

mob/player

HP=0
MAXHP=0
FP
MAXFP
def=0
str=0
Exp //Level experiance
NExp // Need experiance to raise Level
Level=1
MiningLvl=1
Mexp //mining experiance
NeedMexp //needed mining experiance
FishingLvl=1
Fexp//fishing experiance
NeedFexp //needed fishing experiance
Click()
usr<< " \green Name: [name] HP:[HP] MaxHP: [MAXHP] Class: [class]"

mob/var
HP
MAXHP
FP
MAXFP
def
str
Level
class=""
Exp=0
NExp=0
Gold=0
MiningLvl
FishingLvl
Mexp=0 //mining experiance
NeedMexp=0 //needed mining experiance
Fexp=0 //fishing experiance
NeedFexp=0 //needed fishing experiance


mob/verb
Say(msg as text)
view() << "[usr] says [msg]"

World_Say(msg as text)
world << "[usr] says [msg]"

Build_Wall()
set category= "Build"
view() << "[usr] builds a wall"
new/turf/wall2(locate(usr.x,usr.y,usr.z))

mob/player
Stat()
statpanel("Stats")
stat("Name",usr.name)
stat("level",usr.Level)
stat("HP","[usr.HP] / [usr.MAXHP]")
stat("FP","[usr.FP] / [usr.MAXFP]")
stat("Exp","[usr.Exp] / [usr.NExp]")
stat("Strength",usr.str)
stat("Defense",usr.def)
statpanel("Skills")
stat("Mining Level", usr.MiningLvl)
stat("Mining Exp" , "[usr.Mexp] / [usr.NeedMexp]")
stat("Fishing Level", usr.FishingLvl)
stat("Fishing Exp" , "[usr.Fexp] / [usr.NeedFexp]")




turf
grass
icon='tiles.dmi'
icon_state="grass"

dirt
icon='tiles.dmi'
icon_state="dirt"

water
icon='tiles.dmi'
icon_state="water"
density=1

wall
icon='tiles.dmi'
icon_state="stone"
density=1
opacity = 1
floor
icon='tiles.dmi'
icon_state="wood"

tree
icon='tiles.dmi'
icon_state="tree"
density=1
opacity = 1
rock
icon='tiles.dmi'
icon_state="miningrock"
density=1
opacity = 1
verb
Mine()
set src in oview(1)
var/obj/Pickaxe = locate(/obj/Pickaxe) in usr.contents
if(Pickaxe)
usr<<"You start mining the rock"
sleep(10)
if(prob(100))
usr<<"You mined some ore!"
usr.contents+=new/obj/ore
usr.Mexp += 10
else
usr<<"You didn't find anything"
else
usr<< "You need a pickaxe!"


fishingwater
icon='tiles.dmi'
icon_state="fishing"
density=1
verb
Fish()
set src in oview(1)
var/obj/Fishing_Rod = locate(/obj/Fishing_Rod) in usr.contents
if(Fishing_Rod)
usr<<"You start fishing."
sleep(30)
if (prob(20))
usr<<"You catch a fish!"
usr.contents+=new/obj/Fish
usr.Fexp += 10
else
usr<<"You don't catch anything."
else
usr<<"You need a Fishing rod."

wall2
icon='tiles.dmi'
icon_state="stone"
density=1
opacity = 1

verb
Remove_Wall()
set category="Build"
set src in oview(1)
del (src)

obj
Fishing_Rod
icon='items.dmi'
icon_state="fishingpole"
verb
Get()
set src in oview(1)
usr.contents+=new/obj/Fishing_Rod
del src
Drop()
src.Move(usr.loc)

Fish
icon = 'items.dmi'
icon_state = "fish"

Pickaxe
icon='items.dmi'
icon_state="pickaxe"
verb
Get()
set src in oview(1)
usr.contents+=new/obj/Pickaxe
del src

Drop()
src.Move(usr.loc)
ore
icon='items.dmi'
icon_state="ore"
world
mob= /mob/player
turf= /turf/grass



mob/proc
Death(mob/M)
if(src.type == /mob/player)
PlayerDie()
else
if(src.HP <= 0)
range() << "[src] has been killed by [usr]!"
src.overlays -= 'characters.dmi'
del(src)
PlayerDie(mob/M)
if (src.HP <= 0)
view() << "[src] killed by [M]"
src.loc = locate(7,5,1)
src.HP = src.MAXHP
src.FP = src.MAXHP


mob/proc

LevelUp(mob/player)
if(usr.class=="Bowser")
if(usr.Exp>=usr.NExp)
usr.Level += 1
usr.MAXHP += rand(3,10) * usr.Level
usr.MAXFP += rand (2,3) * usr.Level
usr.str += rand (2,5) * usr.Level
usr.def += rand (2,5) * usr.Level
usr.NExp += src.Level * 30
usr.HP = usr.MAXHP

MiningUp(mob/player)
if (usr.Mexp>=usr.NeedMexp)
usr << "You leveled to Mining Level [MiningLvl]"
usr.MiningLvl += 1
usr.NeedMexp += usr.MiningLvl * 200 / 5

FishingUp(mob/player)
if(usr.Fexp>=usr.NeedFexp)
usr.FishingLvl += 1
usr.NeedFexp += usr.FishingLvl * 400 / 8


Problem description:
I spent 2-3 hours trying to fix it. Below is my entire code in case i missed something somewhere. I'm a noob and just looked at a tutorial to see how to make a skill like this. When the player mines and gets enough experiance, the mining level does not increase, and the experiance just keeps going over the experiance max. I am also getting no errors.Please some one help!

No put usr in proc. Ungh.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
No put usr in proc. Ungh.

Lummox JR


so you mean like

mob/usr/proc
???
or
do not put usr in code? replace with src?

Remember I'm NEW to this, including programming
In response to FriesOfDoom
FriesOfDoom wrote:
do not put usr in code? replace with src?

Close. Don't put usr in a proc. You can put it in verbs safely, but usr doesn't always work in procs.

Don't simply replace usr with src: replace it with whatever variable is what you mean(which is only sometimes src). Sometimes, you need to pass another variable to a proc so that it knows what object it's supposed to deal with(ex: mob/proc/Attack(mob/targetmob))
In response to Jon88
Jon88 wrote:
FriesOfDoom wrote:
do not put usr in code? replace with src?

Close. Don't put usr in a proc. You can put it in verbs safely, but usr doesn't always work in procs.

Don't simply replace usr with src: replace it with whatever variable is what you mean(which is only sometimes src). Sometimes, you need to pass another variable to a proc so that it knows what object it's supposed to deal with(ex: mob/proc/Attack(mob/targetmob))

I replaced usr with src,and it didnt work. I tried many diffrent combinations. I don't know what you mean in your last sentence but here is the redone code:

mob/proc
Death(mob/M)
if(src.type == /mob/player)
PlayerDie()
else
if(src.HP <= 0)
range() << "[src] has been killed by [usr]!"
src.overlays -= 'characters.dmi'
del(src)
PlayerDie(mob/M)
if (src.HP <= 0)
view() << "[src] killed by [M]"
src.loc = locate(7,5,1)
src.HP = src.MAXHP
src.FP = src.MAXHP

MskillCheck(mob/player/M)
if(usr.Mexp>= usr.NeedMexp)
usr.MiningUp()


mob/proc

LevelUp(mob/Player/M)
if(usr.class=="Bowser")
if(usr.Exp>=usr.NExp)
usr.Level += 1
usr.MAXHP += rand(3,10) * usr.Level
usr.MAXFP += rand (2,3) * usr.Level
usr.str += rand (2,5) * usr.Level
usr.def += rand (2,5) * usr.Level
usr.NExp += src.Level * 30
usr.HP = usr.MAXHP

MiningUp(mob/Player/M)
if (usr.Mexp >= usr.NeedMexp)
src << "You leveled to Mining Level [MiningLvl]"
src.MiningLvl += 1
src.NeedMexp += usr.MiningLvl * 200 / 5

FishingUp(mob/Player/M)
if(src.Fexp>= src.NeedFexp)
src.FishingLvl += 1
src.NeedFexp += usr.FishingLvl * 400 / 8
You didn't call the MiningUp proc.

mob/player

Login()
sleep(20)
world << " \blue [usr] logs on!"
alert("welcome to my first game!","Welcome","Ok")
src.name = input("What is your name?","Name",src.key)
var/a = input("What class do you want?") in list ("Bowser")
if(a=="Bowser")
usr.icon='characters.dmi'
usr.icon_state="bowser"
usr.HP=25
usr.MAXHP=25
usr.FP=5
usr.MAXFP=5
usr.def=15
usr.str=10
usr.class="Bowser"
usr.Exp=0
usr.NExp=30
usr.Mexp=0
usr.NeedMexp=40
usr.Fexp=0
usr.NeedFexp=50
usr.loc = locate(7,5,1)
Logout()
world << " \blue [usr] logs out!"
sleep(5)
del(src)

mob/player

HP=0
MAXHP=0
FP
MAXFP
def=0
str=0
Exp //Level experiance
NExp // Need experiance to raise Level
Level=1
MiningLvl=1
Mexp //mining experiance
NeedMexp //needed mining experiance
FishingLvl=1
Fexp//fishing experiance
NeedFexp //needed fishing experiance
Click()
usr<< " \green Name: [name] HP:[HP] MaxHP: [MAXHP] Class: [class]"

mob/var
HP
MAXHP
FP
MAXFP
def
str
Level
class=""
Exp=0
NExp=0
Gold=0
MiningLvl
FishingLvl
Mexp=0 //mining experiance
NeedMexp=0 //needed mining experiance
Fexp=0 //fishing experiance
NeedFexp=0 //needed fishing experiance


mob/verb
Say(msg as text)
view() << "[usr] says [msg]"

World_Say(msg as text)
world << "[usr] says [msg]"

Build_Wall()
set category= "Build"
view() << "[usr] builds a wall"
new/turf/wall2(locate(usr.x,usr.y,usr.z))

mob/player
Stat()
statpanel("Stats")
stat("Name",usr.name)
stat("level",usr.Level)
stat("HP","[usr.HP] / [usr.MAXHP]")
stat("FP","[usr.FP] / [usr.MAXFP]")
stat("Exp","[usr.Exp] / [usr.NExp]")
stat("Strength",usr.str)
stat("Defense",usr.def)
statpanel("Skills")
stat("Mining Level", usr.MiningLvl)
stat("Mining Exp" , "[usr.Mexp] / [usr.NeedMexp]")
stat("Fishing Level", usr.FishingLvl)
stat("Fishing Exp" , "[usr.Fexp] / [usr.NeedFexp]")




turf
grass
icon='tiles.dmi'
icon_state="grass"

dirt
icon='tiles.dmi'
icon_state="dirt"

water
icon='tiles.dmi'
icon_state="water"
density=1

wall
icon='tiles.dmi'
icon_state="stone"
density=1
opacity = 1
floor
icon='tiles.dmi'
icon_state="wood"

tree
icon='tiles.dmi'
icon_state="tree"
density=1
opacity = 1
rock
icon='tiles.dmi'
icon_state="miningrock"
density=1
opacity = 1
verb
Mine()
set src in oview(1)
var/obj/Pickaxe = locate(/obj/Pickaxe) in usr.contents
if(Pickaxe)
usr<<"You start mining the rock"
sleep(10)
if(prob(100))
usr<<"You mined some ore!"
usr.contents+=new/obj/ore
usr.Mexp += 10
usr.MiningUp()
else
usr<<"You didn't find anything"
else
usr<< "You need a pickaxe!"


fishingwater
icon='tiles.dmi'
icon_state="fishing"
density=1
verb
Fish()
set src in oview(1)
var/obj/Fishing_Rod = locate(/obj/Fishing_Rod) in usr.contents
if(Fishing_Rod)
usr<<"You start fishing."
sleep(30)
if (prob(20))
usr<<"You catch a fish!"
usr.contents+=new/obj/Fish
usr.Fexp += 10
else
usr<<"You don't catch anything."
else
usr<<"You need a Fishing rod."

wall2
icon='tiles.dmi'
icon_state="stone"
density=1
opacity = 1

verb
Remove_Wall()
set category="Build"
set src in oview(1)
del (src)

obj
Fishing_Rod
icon='items.dmi'
icon_state="fishingpole"
verb
Get()
set src in oview(1)
usr.contents+=new/obj/Fishing_Rod
del src
Drop()
src.Move(usr.loc)

Fish
icon = 'items.dmi'
icon_state = "fish"

Pickaxe
icon='items.dmi'
icon_state="pickaxe"
verb
Get()
set src in oview(1)
usr.contents+=new/obj/Pickaxe
del src

Drop()
src.Move(usr.loc)
ore
icon='items.dmi'
icon_state="ore"
world
mob= /mob/player
turf= /turf/grass



mob/proc
Death(mob/M)
if(src.type == /mob/player)
PlayerDie()
else
if(src.HP <= 0)
range() << "[src] has been killed by [usr]!"
src.overlays -= 'characters.dmi'
del(src)
PlayerDie(mob/M)
if (src.HP <= 0)
view() << "[src] killed by [M]"
src.loc = locate(7,5,1)
src.HP = src.MAXHP
src.FP = src.MAXHP


mob/proc

LevelUp()
if(usr.class=="Bowser")
if(src.Exp>=src.NExp)
src.Level += 1
src.MAXHP += rand(3,10) * src.Level
src.MAXFP += rand (2,3) * src.Level
src.str += rand (2,5) * src.Level
src.def += rand (2,5) * src.Level
src.NExp += src.Level * 30
src.HP = src.MAXHP

MiningUp()
if(src.Mexp>=src.NeedMexp)
src << "You leveled to Mining Level [MiningLvl]"
src.MiningLvl += 1
src.NeedMexp += src.MiningLvl * 200 / 5

FishingUp()
if(src.Fexp>=src.NeedFexp)
src.FishingLvl += 1
src.NeedFexp += src.FishingLvl * 400 / 8