you have to make this up yourself.
search this online i’m sure you’ll find something.
there are virtually infinite ways to do this.
my suggestion would be:
have a function called
GetGrade() that returns a float (yes a float). normalized 0 to 1. 1 being the best.
then on the ui you call that, and depending on the range you show a letter.
how to implement
on the ui you can do
GradeNorm = GetGrade()
then have an array lets say of 5 letters ABCDE. EDCBA in order.
you do
index = frac(GradeNorm*Array.Length)
letter = Array[index]
as for GetGrade you have to come up with that yourself.
i know nothing about your game except it’s related to RE.
i imagine it will be something like this:
- have different checks for different aspects of your game (kills, deaths, damage taken, bullets spent, etc) just about anything you can track.
-
- obviously you’ll have to have a way to track those values. i recommend to use something like my “flags” system (aka facts) you can use it it’s free and open source. (hint, is just a subsystem/singleton with a map of names:floats) Making sure you're not a bot!
- have a normalized value based on min/max of each of those. one norm value per aspect.
- have a way to combine those values together. average can do, it’s not “amazing”, but enough to start with.
here’s a pseudo code of GetGrade in python like (because reasons)
GetGrade():
g_deaths = Clamp(Facts.Get("Deaths")/DEATHS_MAX, 0, 1) # dividing makes it from 0 to 1. clamping cuts it at 0 and 1.
g_shots = 1 - Clamp(Facts.Get("Shots")/SHOTS_MAX, 0, 1) # 1- because you want to give MORE grade the LESS shots you shot
# same for the rest lol im not going to bother
# some values might start from a base number. (like 0 is anything below 500 for example. in that case you can use remap instead of a simple division
g_time = 1 - Clamp(Remap(Facts.Get("Time"), TIME_MIN, TIME_MAX, 0, 1))
g_average = (g_deaths + g_shots + g_kills + g_dmg + g_time) /5.0
return g_average
the way you “weight” each grade will give a lot of personality. so you’ll have to play with that. at some point you can also do something like this:
GetGrade():
# same as before
weights = [.1, .3, .1, .2, .3] # just random numbers i came up with, it will be a factor for each one of the grades. they need to at least add up to 1, and they could add to more, this will make it easier to reach A, otherwise you'll have to do everything about perfect.
grades = [g_deaths, g_shots, g_kills, g_dmg, g_time]
res = 0
for i in range(len(grades)): # i could have used zip but this way is more akin to cpp/bp
res = res + grades[i] * weights[i]
return Clamp(res, 0, 1) # important to avoid the weights going overboard
you can also play by having weights that are negative. so they will lower your grade instead of just “not adding”.