ID:142126
 
Code:
    proc
DeathCheck()
if(Hp<=0)
world<<("[src] dies")
src.loc=locate(1,1,1)
usr.Exp+=src.ExpGive
if(usr.Exp>=MaxExp)
usr.MaxExp+=100
usr.Level+=1
usr<<"You gain a level"
if(usr.Class=="Bender")
if(usr.Style=="Aggressive")
usr.Str+=3
usr.MaxHp+=2
usr.Def+=1
usr.MaxChi+=1
Bonuspoint()
else
..()


Problem description:

At first the code works fine,, i kill four times then once my Exp is greater than my MaxExp,,, i gain a level,, but after this every kill gains me a level,,
I wrote the code so i gain MaxExp each time i level,, but it doesnt seem to work,, i still level up each time i gain the slightest bit of Exp.. i know its a pretty simp-le code but i cant figure out what is wrong.
Set exp back to 0, but seriously you need to read the DM Guide that code is really bad.
In response to A.T.H.K
lol first attempt at writing codes,, and that guide is of no help to me,, just a bunch of useless information to me,, cant understand most of what it's sayin,, LOL but yeah like i said,, my first coding attempt
In response to AxlRose08
That's likely because you went through the first couple of chapters going "i know this baby crap >:(" then skipped the rest dismissing it as too hard. It's not that hard to understand, just read the whole thing through and take your time.
In response to Glarfugus
y do ppl post just to tell u "Go back to the guild its all wrong" theres reason hes posting here maybe like some ppl he doesn't get what it means I've tried reading it its just scribbles to me without a person walking me through th steps
I've figure out by my self by trial and error to where i got that guild wasn't really any help
In response to Black_Plaegue
Black_Plaegue wrote:
y do ppl post just to tell u "Go back to the guild its all wrong"

Go back to school, your English is all wrong. Well, blunt but true at least for that post. =P
Point of Duh: Anyway, people do it because it's good advice, and often they have clearly not grasped the things taught by the guide, for one reason or another.

it means I've tried reading it its just scribbles to me

Often this is because the reader has already come with an already bad attitude and dislike of the guide because of its length. But it's still an essential read, and shouldn't be all that hard to figure out, really. Read it from the beginning, in its whole, if you don't understand the later chapters.

without a person walking me through th steps

Sorry, there's only so much we can do for people*. We can't go teaching around the basics to everyone personally, one-by-one, in baby-steps, or there would be no end to it. That's the reason you have documentation and tutorials in the first place; they're much more efficient at helping the masses. Also, some [tutorials] do attempt to walk you through it somewhat - but that shouldn't even be needed; you're not a baby anymore, so you can teach yourself how to walk, like a lot of people do. You're also more independent that way, and there is info in the form of documentation, tutorials, articles [...] and old forum posts at your disposal, so it's not like you have to figure it out from guessing. Experience and experimenting helps, but you don't have to guess.

*: Of course, if you paid, more people would turn up. =P
In response to Kaioken
I dont have enough time in the day to sit down and read the entire DM guide, and learn all it has to teach me. If i was to, say... read it bit by bit each day, i'd probably forget alot of it anyway.
Basically i've taught myself how to write code by looking at Tutorials and other people's codes and adapting them to how i want them to work. Some of the coding i use i have no idea of how it works, but i know what id does and that's enough for me at the moment.
When i get a grasp of the basic elements of coding, maybe then ill give th DM guide a good read through, but for now i just want to get a feel of how to code simple things.

Some of it may be messy or novice but im still learning, just needed some advice on why this certain code wouldn't work, i know its not great and all,, just need to know why my character levels good the first time then it screws up the second time. That was all guys :)

[Edit]Oh and just tried the first bit of the DM guide, and it already isnt working for me xD,, why do my verbs that start by saying *[usr]* add the to the begining,,, example: i type *"[usr] says, [msg]" and it comes out "The bob says hi"

I havnt done it this way before and trying it now doesnt work for me at all, obviously im doing something wrong, lol
In response to Glarfugus
Glarfugus wrote:
That's likely because you went through the first couple of chapters going "i know this baby crap >:(" then skipped the rest dismissing it as too hard. It's not that hard to understand, just read the whole thing through and take your time.

actually i looked at it and thought,, "yeah this will surely teach me what i need to know,but i think i'd rather try learn for myself." So far i've had no problem with the coding. I probably will read it sometime
In response to AxlRose08
Whether or not you know it, you have plenty of problems with your code. When I read the DM guide, I did one or two chapters a day, and I coded along with the guide. When it presented me common practice, I tried to code a situation in which I could use it. It's not all that hard to do.
A big part of the problem here is usr abuse. usr is not safe in procs. Instead, in DeathCheck() you should have an argument in the proc that tells you who the killer is.

proc/DeathCheck(mob/killer)


Then anywhere you would've used usr, use killer instead. Make sure the killer is included in the call whenever you call DeathCheck():

verb/Attack()
...
victim.DeathCheck(usr)


Another issue is really that your levelup proc should be separate from the death check, for simplicity's sake. Just call killer.LevelUp() after killer.Exp is increased, and then everything in that proc should use src instead of usr:

mob/LevelUp()
while(Exp >= MaxExp)
++Level
MaxExp = MaxExp * 2 + 100 // use whatever formula you like
...


Lummox JR
In response to AxlRose08
I've personally read the entire DM guide twice and still have issues with certain things like savefiles and overlays and I've been practicing DM for over 4 years so I wouldn't say that the DM guide is the best thing I just think it's overall experience that's the biggest factor. Sure the DM guide helps in the beginning but it really doesn't solve every problem ... if any for that matter.
In response to DragonMasterGod
Surely you realize that if a certain thing doesn't magically solve all of your problems it doesn't mean it's its fault, or that there's anything wrong with it. Also, the DM Guide (and Reference as well) covers savefiles quite well, for one example.
In response to Lummox JR
Thanks thats the advice i was lookin for
In response to Glarfugus
Yeah ill give it another read sometime, i know my code has problems, but that comes with learnin somethin new. Anyway i guess i should look at it, i had a quick read through some of it lastnight and it makes alot more sense this time around, i guess because i've had a little muck around coding stuff myself.

Anywa thanks guys.....
In response to AxlRose08
While your other troubles have been addressed, I did notice this:

AxlRose08 wrote:
[Edit]Oh and just tried the first bit of the DM guide, and it already isnt working for me xD,, why do my verbs that start by saying *[usr]* add the to the begining,,, example: i type *"[usr] says, [msg]" and it comes out "The bob says hi"

This is because when you use [usr], it formats the name of use depending on if it is a proper noun or not. If you do not capitalize the name, "Bob", then it will add "The" in front of it. Let that be a lesson to you, always capitalize names.
In response to Ephemerality
There's no need to capitalize names. Replacing [usr] with [usr.name] will do.
In response to Jemai1
But it's still improper grammar, so you should actually stick to NOT using name directly but using the object reference directly embedded and properly capitalize when needed. That way, you will always get correct output: In the case of a player "Bob" eg, it will say "Bob says:", but in the case of "commoner" it will properly say "The commoner says:". Where's the wrong in it?
In response to Kaioken
Okay. I see your point.
In response to Ephemerality
Ephemerality wrote:
While your other troubles have been addressed, I did notice this:

AxlRose08 wrote:
[Edit]Oh and just tried the first bit of the DM guide, and it already isnt working for me xD,, why do my verbs that start by saying *[usr]* add the to the begining,,, example: i type *"[usr] says, [msg]" and it comes out "The bob says hi"

This is because when you use [usr], it formats the name of use depending on if it is a proper noun or not. If you do not capitalize the name, "Bob", then it will add "The" in front of it. Let that be a lesson to you, always capitalize names.


Right ok, i get it now lol, so simple xD
In response to AxlRose08
AxlRose08 wrote:
I dont have enough time in the day to sit down and read the entire DM guide, and learn all it has to teach me. If i was to, say... read it bit by bit each day, i'd probably forget alot of it anyway.

Something I did when going through, was decide a min # of pages I was going to do(usually being 5). Then if I felt I could do more that day, I would. A lot of the chapters are only 5-10 pages anyway. I also, because I didn't want to forget, made notes on everything I encountered. It took a bit longer, but for me it helped the topics stick more.