Well, I want to add ranking officers in my game, and I want it to be automatic. Depending on how many kills and death you have, depends on your squad rank.
Example:
I have 14 kills, and 2 deaths, but someone else had 14 kills, and one death. That would make their kills and deaths record better then my own. So they would be a higher rank than me.
This is for my bleach game, and the ranking officers are for the shinigami.
Could someone show me a simple code for it so I could see how I can approach making it, so I can learn how to do it.
ID:162215
Feb 11 2008, 12:35 am
|
|
In response to Saucepan Man
|
|
Saucepan Man wrote:
Make it a ratio of kills to deaths. > mob/proc/ How would I use this to make it so Squad ranks are automatic? I want it to be so if it changes, the persons rank could possibly change. Say like I am the 4th officer of my squad, then someone in my squad dies 3 times. So his new deaths and kills is say, 12 kills, and 7 deaths. Then I have something like 12 kills and 5 deaths. He was the 3rd officer, but now since I am doing better in kills and deaths, I would take his place, and he would get knocked back a rank (Maybe 2). |
In response to DWX123
|
|
You'd need a list of people in the squad. Every time someone gets a kill or a death, sort the list using quicksort or something. Then, assign ranks based on people's positions in the list:
proc/quicksort_ratio(list/squad) //A quicksort proc, adapted for comparing a var called 'ratio' |
In response to Hazman
|
|
Arrggghh... It's so confusing. I have no idea what that code you posted does, or means. =\
|
In response to DWX123
|
|
Basically the top bit is a quicksort proc which sorts the list into three lists (bigger, smaller, equal), and then sorts those lists, and then those lists etc. until there is only 1 item in each list. It then sticks the list back together in the right order. There's a better explanation on the wiki page I linked to.
The second bit sorts the squad list you give it, then loops through each player in the squad and tells them their new rank. It does this by counting from 1 up to the number of players (for(var/r in 1 to squad.len)) and then telling the player with that rank what their rank is. [EDIT] I've put some comments in the code so hopefully it is a bit easier to understand. |
In response to Hazman
|
|
Hazman wrote:
Basically the top bit is a quicksort proc which sorts the list into three lists (bigger, smaller, equal), and then sorts those lists, and then those lists etc. until there is only 1 item in each list. It then sticks the list back together in the right order. There's a better explanation on the wiki page I linked to. So will this give everyone in the squad a rank, or just the top [insert number here]. I only want tohave 6 ranking officers in each squad, the rest of them will just be members. |
In response to DWX123
|
|
I also get errors with the code you gave me.
Squadranks.dm:10:error:m.ratio:undefined var |
In response to DWX123
|
|
That will give everyone a rank, but you can easily restrict it to the top six by changing the for() loop in the give rank proc:
//Blah blah blah |
In response to DWX123
|
|
That's because you need to actually have a 'ratio' variable for each player. You'll also need to update it every time they get a kill or death, and run the proc I gave you as well.
|
In response to DWX123
|
|
Dude, I have no idea what you wanted.
I still don't really get it. Never played a Bleach game, never seen a Bleach Episode, never read any Bleach manga. You shouldn't make posts assuming people know what youre talking about. :S Hazman wrote: That's because you need to actually have a 'ratio' variable for each player. You'll also need to update it every time they get a kill or death, and run the proc I gave you as well. At least I was of help still. |
Whenever a player is killed put this proc in: