ID:154104
 
mob/proc/Attack(mob/attacker,mob/defender)
var/damage = (attacker.precision - defender.protection)/(attacker.precision + defender.protection)
var/aim = (attacker.precision/defender.swiftness)*100
if(prob(aim))
world << "[damage] is damage!"
else
world << "[attacker] misses [defender]!"


Okay, thats the battle proc.
mob/var
toughness = 1//Damage multiplier
protection = 1//Damage divider
precision = 1//how much of a chance you have for hitting
vitality = 20// how much life points you have
max_vitality = 20//maximum life
swiftness = 1// how fast you can attack,ability to evade
recovery = 1// how fast you regen health
endurance = 1// how long you can last
max_endurance = 1//maximum endurance


Those are the stats.


Okay, now I made an enemy with a swiftness of 5. Using a "newbie" type character, it outputs this when I attack:

Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
0 is damage!
0 is damage!
0 is damage!
Sariat misses the enemy!
Sariat misses the enemy!
0 is damage!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
Sariat misses the enemy!
0 is damage!


The newbie gets in about less than 10-20% of the hits...

And they both have all the newbie stats (1 protection, 1 toughness) and it jus outputs 0 damage...how can I make my battle system more.... "uncalculated" ?

Maybe put in a few 'act of god' chances?

Like every time you attack, you have a chance of:
Falling on your face

Slipping on a rock and accidentaly dealing lots of dmg to the enemy

Stunning the enemy for a short period of time (thus negating missing or dodging.. its pretty easy to hit a stationary target unless your dealing in ranged weps)


Sure you could think of more ^_^ Combat in games is always too simplistic IMO, at least to the effect that the more time you spend you -always- get better. There's always that randomness of environment after all ^_^


El
I like to use something like this:

Attack rolls a die. 1d6.

If die = 6, roll another die. And on an on...

Here's some results of that:

4
3
3
2
3
4
2
4
5
2
1
3
5
3
4
3
3
2
5
3
1
1
2
8
2
8
4
2
4
1
4
3
4
9
2
5
5
9
2
10
4
1
3
5
1
9
4
5
2
1
5
14 <-- supposedly attacking for 1d6, yet whops an astounding 14!
5
7
5

It technically should be possible to hit 21,3987 like that, but the chances of it happening are extremely low :oP

<code>mob/verb/damage() var/die = "1d6" var/damage = 0 var/roll = roll(die) while(roll==6) damage += roll roll = roll(die) damage += roll src << damage</code>
I had the same problem with my old battle engine.

If the attacker and opponent had roughly the same stats, then they could not hit eachother. The easiest way to fix this is just by *forcing* it to be a successful hit if a rand() number if fufilled.

Mind you, the easiest way is not always the best. ;)

- Malver
In response to Foomer
I ran that proc 60,000 times and the highest number I got was 35 :oP

At 120,000 times 39 was the highest.

At 140,000 it was 41.
In response to Foomer
You need something better to do with your time... :Þ
In response to Shun Di
No, I just rigged a proc to run the same verb 100 times per tick and record the results :oP I could have been making a sandwich.
In response to Foomer
Now add a greatness check and keep the highest number. Then you can run it unlimite times.
In response to Malver
ever try just adding a rand(1,5) to the end of it? just incase htey are equal you will still do some damage?
In response to Exadv1
Then my computer starts to overheat :oP