ID:155051
 
Ok so i have the basics of leveling up and death checking down.

What i'm trying to do is award exp based on the players level relative to the target it has killed.

Example

if(M.Level>=src.Level)
//whatever happens
if(M.Level<=src.Level)
//whatever happens


But problem is when i go about setting this up, I tried just adding it into my level check, but it doesnt work, I tired adding it to the attack code, but it doesnt work.

Advise? and/or and example?
Put it into the deatcheck procedure.
I give you examples but I am on the phone now :P
In response to Dj dovis
and i seriously need examples
In response to Komuroto
if(usr.level <= 5)//these would only work if you have 1 type of monster
usr.exp+=4
else if(usr.level >=5)
usr.exp+=2


Now here is something to check for another mob

if(istype(src,/mob/monster/whatever))
//give them stuff or stats here

I would personnally have this and check a whole different proc to see how much a person would gain from that kill instead of stacking all of it into a deatcheck proc

//heres now how everything could be
if(istype(src,/mob/monster/stickman)&&usr.level <= 15)//&& means and.istype checks if the monster is stickman
usr.Exp += 5
else if(istype(src,/mob/monster/stickman)&&usr.level >= 15)
usr.Exp += 2


You could also just check the mobs level and reward the person based on their level.But this depends on your attack and deathcheck procs.

Hope this helps

In response to Dj dovis
Thanks I'll take that all into consideration as i work on this.
In response to Dj dovis
Dj dovis wrote:
> if(usr.level <= 5)//these would only work if you have 1 type of monster
> usr.exp+=4
> else if(usr.level >=5)
> usr.exp+=2
>

Now here is something to check for another mob

> if(istype(src,/mob/monster/whatever))
> //give them stuff or stats here
>

I would personnally have this and check a whole different proc to see how much a person would gain from that kill instead of stacking all of it into a deatcheck proc

> //heres now how everything could be
> if(istype(src,/mob/monster/stickman)&&usr.level <= 15)//&& means and.istype checks if the monster is stickman
> usr.Exp += 5
> else if(istype(src,/mob/monster/stickman)&&usr.level >= 15)
> usr.Exp += 2
>

You could also just check the mobs level and reward the person based on their level.But this depends on your attack and deathcheck procs.

Hope this helps



I might need a bit more elabaration, as what i'm trying to do is have it so when a player attacks any mob(key or !key) they will gain levels accordingly. I know this needs to be figured out through the death proc, but when i try to set things up I never get any exp.

Unless i Just do the standard basic level up system...
In response to Komuroto
proc/Attack()
src.exp++
In response to ANiChowy
For the love of christ.
Use arguements to set that mob = M
and do M.exp +=5
In response to ANiChowy
ANiChowy wrote:
> proc/Attack()
> src.exp++
>


If you want to help, at least give information with the code snippet contained in your post; the post is very uninformative.

if(usr.level <= 5)//these would only work if you have 1 type of monster
usr.exp+=4
else if(usr.level >=5)
usr.exp+=2


The 5 in the second <code>if</code> statement should be either 6 or remove the <code>=</code> sign.

proc

reward_experience( mob/player , mob/enemy )

if( player.level <= enemy.level ) player.experience += 10

else /* second if statement is redundant, if the player's level is greater than the enemy's, add 5 experience. */ player.experience += 5


This can be called in your <code>death_check()</code> proc, along the lines of: <code>reward_experience( src , mob )</code> or whatever you are passing the killer for mob.
In response to Neimo
fine

some_kinda_stat_thing
var/exp
var/mexp=100
var/level=1
var/max_level = 100
var/mob/human/owner
New(P, mob/human/o)
if(P) mexp = P
if(o) owner = o

proc/calc_new_max()
mexp = max(round(mexp * sqrt(level), 10), 100) // or something like that
proc/Add(n)
exp = min(max(exp + n, 0), mexp)
if(exp == mexp)
lvlup()
proc/lvlup()
exp = 0
level = min(level+1, 100)
calc_new_max()
proc/expToText()
return "[exp]/[mexp]"
proc/expToPercent()
return "[round(100 * exp / mexp)]%"
proc/lvlToText()
return "[level]/[max_level]"
proc/lvlToPercent()
return "[round(100 * level / max_level)]%"


okay did I give enough example yet?
In response to ANiChowy
This is quite irrelevant as I was not talking about that kind of "information". I was merely referring to your simple post with 2 lines of code that had no explanations included within it. Oh and, you do not have to get all defensive.
In response to Neimo
"as what i'm trying to do is have it so when a player attacks any mob(key or !key) they will gain levels accordingly."

Dunno how much explanation you really need for that..

proc
Attack() // This is a procedure named Attack, it doesn't take any arguments
src.lvl++ // They increase in level when they attack any mob!
// What you need to do is call it when they attack a mob!
In response to ANiChowy
ANiChowy wrote:
"as what i'm trying to do is have it so when a player attacks any mob(key or !key) they will gain levels accordingly."

Dunno how much explanation you really need for that..

> proc
> Attack() // This is a procedure named Attack, it doesn't take any arguments
> src.lvl++ // They increase in level when they attack any mob!
> // What you need to do is call it when they attack a mob!
>



AS this doesnt even answer my question in the first place...

Its irrelevant...

Edit: I may not know how to do this exact function directly, but you can't assume everyone who doesnt know something is a complete idiot.... Your example is something that ANYONE should already know.
In response to Neimo
if(usr.level <= 5)//these would only work if you have 1 type of monster
> usr.exp+=4
> else if(usr.level >=5)
> usr.exp+=2

The 5 in the second <code>if</code> statement should be either 6 or remove the <code>=</code> sign.

> proc
>
> reward_experience( mob/player , mob/enemy )
>
> if( player.level <= enemy.level ) player.experience += 10
>
> else /* second if statement is redundant, if the player's level is greater than the enemy's, add 5 experience. */ player.experience += 5
>

This can be called in your <code>death_check()</code> proc, along the lines of: <code>reward_experience( src , mob )</code> or whatever you are passing the killer for mob.



mob
proc
LevelCheck()
while(Exp>=MaxExp)
Exp=0
MaxExp+=16
src << "You have gained a level!"
Level+=1
SP+=1
DeathCheck()
if(src.health<=0)
if(!key)
reward_experience()
sleep(10)
del(src)
return
else
dead=1
src << "You have died"
src.loc=locate(1,1,1) //change later
src.health=Maxhealth
src.Exp-=src.Exp*0.15
src.dead=0

return
reward_experience( mob/player , mob/enemy )
if( player.Level <= enemy.Level )
player.Exp += 25*player.Level
else
player.Exp += 15*player.Level


So THIS is what I understood from what you said.

Correct?

EDIT: Dont know why my Del is all the way out there like that xD

2nd:edit: I know this isnt a snippet, it needs to be worked with. But really everyone seems to be avoiding my actual question.

So let me readd it.

How do I APPLY this?

I know where it goes, I know how to stick it in there, what I don't know how to do is make it assign EXP properly...

In response to Dj dovis
Dj dovis wrote:
For the love of christ.
Use arguements to set that mob = M
and do M.exp +=5

you mean
aproc(mob/m)
M.var+=5


How on earth does that answer my question in the LEAST?

I already know this, thats not what i was asking.
In response to Komuroto
I do not understand what you cannot.

var/damage = 10 ; mob.stamina -= damage ; mob.death_check()


Suspecting your attack verb finds a mob, generates damage, subtracts it and then calls the death check like above you would continue like so.

if( stamina < 1 )

if( enemy.client /* this would be checking if the killer is a client. */ )

enemy.experience += enemy.return_experience( src )


<code>return_experience( mob/target )</code> would return the amount of experience to add to the killer. This would be the <code>death_check()</code>.

return_experience( mob/target )

if( level <= 5 ) /* add lower(?) experience if the target's level is lower. */ return 15 * target.level

else /* add more(?) experience if the target's level is higher. */ return 25 * target.level


In this scenario, the <code>target</code> is the one being killed, in the <code>death_check()</code> the enemy is the one who is killing the <code>target</code>.
In response to Komuroto
Komuroto wrote:
ANiChowy wrote:
"as what i'm trying to do is have it so when a player attacks any mob(key or !key) they will gain levels accordingly."

Dunno how much explanation you really need for that..

> > proc
> > Attack() // This is a procedure named Attack, it doesn't take any arguments
> > src.lvl++ // They increase in level when they attack any mob!
> > // What you need to do is call it when they attack a mob!
> >

AS this doesnt even answer my question in the first place...

Its irrelevant...

Edit: I may not know how to do this exact function directly, but you can't assume everyone who doesnt know something is a complete idiot.... Your example is something that ANYONE should already know.

I did not assume that. My example is not something that anyone should already know but...anyone posting here should definitely understand the example I posted.