Skip to content

Instantly share code, notes, and snippets.

@Nikitaw99
Created September 4, 2016 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikitaw99/b86dfed0b40c8d180459a157e2285aac to your computer and use it in GitHub Desktop.
Save Nikitaw99/b86dfed0b40c8d180459a157e2285aac to your computer and use it in GitHub Desktop.
Simple Fire Emblem battle simulator.
math.randomseed(os.time())
print("Enter attacker skill stat:")
skill = io.read('*n')
while skill > 100 or skill < 0 do
print("This number is invalid.")
print("The number must be between 0 and 100.")
print("Enter attacker skill stat:")
skill = io.read('*n')
end
print("Enter defender dodge stat:")
dodge = io.read('*n')
while dodge > 100 or dodge < 0 do
print("This number is invalid.")
print("The number must be between 0 and 100.")
print("Enter defender dodge stat:")
dodge = io.read('*n')
end
if skill > dodge then
do
local targetValue = skill - dodge
local randomValue = math.random(100)
print("Chance to hit: " .. targetValue .. "%.")
print("RNG Returned: " .. randomValue .. ".")
if targetValue >= randomValue then
print("Attacker succesfully hits!")
else
print("Attacker misses!")
end
end
else
print("Defender sucesfully dodges!")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment