Hey, I am making a RPG action game with lots of attacks. So I would like to know how do developers make it so that the attack damages are so random, meaning they are not straightforward numbers like 100, 200, 500, 30000, etc. more like 156, 964, 338, etc. these numbers are not random everytime they are fixed values somehow and dont change with every attack like a randomized range number.
You can just utilise
math.random(), to generate a number from a given range.
local minimumDamage, maximumDamage = MINIMUMDAMAGEHERE, MAXIMUMDAMAGEHERE -- Sets a double variable for the minimum damage and the maximum damage local atkMulti = Stats.Attack.Value or 1 -- If you want to have an attack multiplier, youll be able to multiply it by the player's stats, if they have no value or something goes wrong (e.g it isnt loaded) it'll default to whatever is after "or" local damage = math.ceil(Random.new():NextNumber(minimumDamage, maximumDamage) * atkMulti) -- math.ceil() will round it to the nearest highest number, since Random.new():NextNumber(min, max) will return decimals. -- If you're making a system where it displays damage numbers, you might want to keep the decimals BUT math.ceil() it when displaying the numbers, that way the decimals will still be hidden but apply to health anyway
Use this as a baseline to your damage system.
Thanks a lot for the explaination but I need a way to get the attack multiplier because I am using a point stat system WITH a level system. so both values are getting added but I dont know how much value would 1 stat point of attack represent.
Yeah, whats your attack in the point stat system, and how much do you want 1 stat point to represent?
Well thats exactly what I dont want… I need the values to be fixed and not change randomly. What I meant by randomized is how the numbers formed. in generally any action game the damages are a ridiculous number than plain numbers with 0s and 5s.
what are you talking about??? to set a fixed value:
oh, then remove the math.ceil() in the damage baseline i gave you and you should get your crazy numbers like 134.238956092 or some random decimal.
to get your point simply refrence it | then multiply it depending on how much you want each point to be worth
plr.Stats.Attack.Value (the base atk, 5 points = 5 multi.)
plr.Stats.Attack.Value * .5 (cuts it in half, so 5 points would be 2.5 multi)
plr.Stats.Attack.Value * .1 (shifts the decimal point back once, 5 points would become .5 multi)
plr.Stats.Attack.Value * .01 (shifts the decimal back twice, 5 points would become 0.05)
Ok I will try this. Thanks for the idea