mob/proc/Attack(mob/attacker,mob/defender,effort)
attacker.endurance -= (effort/attacker.max_endurance)*100 //Take off endurance from the attacker
defender.endurance -= ((effort/4)/defender.max_endurance)*100 // Take off endurance from the defender
var/damage=rand(attacker.toughness/4,attacker.toughness/1.5)/defender.protection/1.2 // Damage Calcuations
var/aim = (attacker.precision/defender.swiftness)*100 // To see if it is able to hit
var/die = "1d6" //To add random damage later
var/roll = roll(die) // To add random damage later
// world << "aim is [aim]"
if(prob(aim)) // See if the attack is a successful hit
damage += roll
defender.vitality -= round(damage)
// world << "[defender] is hit for [round(damage)]!"
else if(prob(aim/2)) // To see if the attack can get just a small attack, if fully missed
defender.vitality -= round(damage/2)
// world << "[defender] barely dodges the attack and hit for [round(damage)]!"
else// Fully missed
..()
// world << "[attacker] misses [defender]!"
Deathcheck(attacker,defender)// Go to see if the battle is over
The code works... but... how can I improve on it?
And uh... this is for... uh..... my... uhh... well it doesn't matter which game its for ;)
-Sariat
First thing is to redo DeathCheck(). You should not be passing both the attacker and defender as arguments. The defender in a DeathCheck() proc should always be src. Just pass the attacker argument only, and call it like this:
Lummox JR