ID:159940
 
Is their a way to make it were...
kills<500 = Rank 1
kills<2000 = Rank 2
kills<9000 = Rank 3
kills<50000 = Rank 4

and so on...
Basically.

You get a kill (target has died).
It adds 1 kill to total count.
--- --- ---
Assuming you have a proper death system set up, doing it like so should allow it:
mob
var
total_kills
rank

Death(mob/killer)
//Death stuff is handled here.

killer.total_kills ++
killer.GetRank(1)

GetRank(c = 0)
if(!isnull(rank) && !c)
//If rank isn't null and c isn't on (it shouldn't
//be reevaluated), just return what's there.
return rank

//Otherwise, evaluate their rank. In this case, I'm
//going to use a simple situation, where every 500
//kills will increase their rank by one.
rank = round(total_kills / 500) + 1

return rank
Make a Death() proc that's called every time a mob's health hits 0 or below. The person who did the killing will need to be defined inside the parentheses so you can add a kill to them. As for making them a certain rank, you'll need to create another proc to handle that, unless you want a bunch of if() statements in your Death() proc.

Example
mob/verb/Attack(mob/M in get_step(usr,usr.dir))
if(!M) return
var/dmg = usr.strength
M.Health -= dmg
view(usr)<<"[M] took [dmg] from [usr]!"
M.Death_Check(usr)

mob/proc/rankUp()
if(src.Kills<500) src.Rank = "Rank 1"
else if(src.Kills>=500 && src.Kills<2000) src.Rank = "Rank 2"
//And so on...

mob/proc/Death_Check(mob/M)
if(src.Health<=0)
src.loc = locate(1,1,1)
src.Health = src.maxHealth
M.Kills += 1 //Add 1 to the killer's Kills variable
M.rankUp() //Call the rankUp() proc
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
will need to be defined inside the parentheses

This is called an argument, for reference.
In response to Alathon
I know, but maybe he doesn't. I was putting in terms that even a newbie to DM programming could understand.
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
I know, but maybe he doesn't. I was putting in terms that even a newbie to DM programming could understand.

Which is why I mentioned what its called, or how is the person ever supposed to learn?
In response to Popisfizzy
Instead of calling the proc everytime you kill a mob, it'd be better if you call the proc only if you have the requirements.
In response to Mizukouken Ketsu
You should use switch() instead, on the rankUp().
In response to Andre-g1
switch(Kills)
if(Kills>=500) src.Rank = "Rank 1"
//And so on...

Like that?
In response to Mizukouken Ketsu
Yeah.
In response to Andre-g1
Is a switch() statement faster/more efficient than an if() and else if()s?
In response to Mizukouken Ketsu
Yes, read the reference entry for switch().
In response to Mizukouken Ketsu
No offense, but you shouldn't try to help people on the forums if you don't know DM all to well, wait like a year or so and you'll be good probably.

Edit: Cause it would be bad to teach people some bad methods, so its usually best to wait till you've been programming for about 4 years.
In response to Bakasensei
Bakasensei wrote:
Edit: Cause it would be bad to teach people some bad methods, so its usually best to wait till you've been programming for about 4 years.

4 years ?! What an absurdly high amount of time...

Hell, I've only been programming for ~9 months and I wouldn't say I'm giving bad advice to people around here.
In response to Andre-g1
The proc is what determines the requirements, skip. It's a very simple proc, and it won't take any time at all to process, especially considering that killing couldn't occur, even at the best scenario, more than once every couple seconds.
In response to Andre-g1
No, you are. This, for example.
In response to Popisfizzy
What's wrong about that ? It seems I just missed the bit about the boolean vars, but meh.
In response to Andre-g1
It's because the whole bit is wrong.
In response to Bakasensei
No offense, but please don't post just to say "you suck at helping because you have no experience. Come back when you've been doing [whatever] for X years"

The snippet I originally posted was 100% functional. Andre-G1 was just giving a little improvement note. I was confirming on how to use it properly in my snippet and asked why it's better. Nothing too "newbie" about it. A simple confirmation with a question.

I did in fact read the guide about switch() statements, but reading doesn't really do it for me. I learn by example. So before you go off on you high and mighty posting spree, try thinking first. "No offense" or anything...
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
The snippet I originally posted was 100% functional.

Functionaly and quality correlate only distantly, and, to be honest, the snippet wasn't very good.
Page: 1 2