diff --git a/design doc.docx b/design doc.docx index d231638..31fb0e0 100644 Binary files a/design doc.docx and b/design doc.docx differ diff --git a/misc/combat damage.lua b/misc/combat damage.lua new file mode 100644 index 0000000..aabc313 --- /dev/null +++ b/misc/combat damage.lua @@ -0,0 +1,70 @@ +--enumeration +hitType = { MISS = 1, HIT = 2, CRITICAL = 3 } +attackType = { PHYSICAL = 1, MAGICAL = 2 } + +function MakeChar() + local t = {} + t.MaxHP = 100 + t.HP = t.MaxHP + t.MaxMP = 100 + t.MP = t.MaxMP + t.attack = 10 + t.defence = 10 + t.intelligence = 10 + t.resistance = 10 + t.accuracy = 0.1 + t.evasion = 0.1 + t.luck = 0.1 + t.level = 1 + return t +end + +function CheckHit(A, D) + local RNG = math.random(100) + local hitRate = A.accuracy - A.accuracy * D.evasion + + if RNG <= hitRate * A.luck then + return hitType.CRITICAL + end + if RNG <= hitRate then + return hitType.HIT + end + return hitType.MISS +end + +function CalcDamage(A, D, t) +-- if t == attackType.PHYSICAL then + return math.max(1, ( A.attack*3 + A.attack*(math.random(A.luck*100)/10) ) - (D.defence + D.defence*D.evasion)) +-- end +-- if t == attackType.MAGICAL then +-- --?? +-- end +-- --wtf? +end + +A = MakeChar() +D = MakeChar() + +dump = io.open("dump.txt", "w") + +--top +dump:write("\t\t") +for i = 10, 100, 10 do + dump:write(i, "\t") +end +dump:write("\n\n") + +--lines +for j = 10, 100, 10 do + dump:write(j, "\t\t") + for i = 10, 100, 10 do + A.attack = i + D.defence = j + dump:write(CalcDamage(A, D, 0), "\t") + end + dump:write("\n") +end + +--bottom +dump:write("\n") +dump:close() \ No newline at end of file