This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-06-08 13:01:03

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Please critique my battle system equation :)

Battle System


Let me just say, I absolutely HATE the concept of Random Numbers affecting an outcome. I understand that it is a necessary evil that must be incorporated to assume some measure of chance, but how on Earth does anyone know what BEST random number range should be used???

In my algorithm I use a random range of -3 to 3, because I want a slight variation to allow for random chance. But by using a negative possibility, a player could miss completely for no real reason (which just seems wrong?). Anyways...

To test out the battle system I just started with basic variables;

Givens:
playerArmor ranges from 8 to 12
playerDefense ranges from 8 to 12
playerHealth ranges from 80 to 120
playerStrength ranges from 8 to 12
playerWeapon ranges from 8 to 12
(opponent variables are the same)

Oh, I almost forgot, this is for a TURN-BASED combat system.

Here's the actual equation:
__________________________

combatCalculation = rnd(-3 to 3) * [playerWeapon * (playerStrength + playerHealth)] - [opponentArmor * (opponentHealth + opponentDefense)]
__________________________



(in shorthand)
cCalc = rnd(-3 to 3) * [pWeap * (pStr + pHth)] - [opArmor * (opHth + opDef)]

The weapon and armor have the biggest influence on outcome (being multipliers). Is that a good idea???

To increase the variablity, on each turn, the attacker's weapon score is reduced by rnd(1 to 3), and if it is a hit, the defender's armor score is reduced by rnd(1 to 3)

So, on the player's attack turn;

playerWeapon = playerWeapon - rnd(1 to 3)
If combatCalculation > 0
Then opponentArmor = opponentArmor - rnd(1 to 3)



So as you can see this works (and is kinda fun), but I just picked the number three (3) as my variable modifier, with no real reason for choosing 3. I could just as easily have picked 789787367835.


I guess my real question is; "How do you choose the range for 'random' variation?
Battle System

Offline

 

Board footer