Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. local turns = 0
  2.  
  3. local unitA = {
  4. hp = 513,
  5. atk = 52,
  6. lifesteal = .35
  7. }
  8.  
  9. local unitB = {
  10. hp = 617,
  11. atk = 42,
  12. armor = .5,
  13. healing = .008
  14. }
  15.  
  16. unitA.maxHp = unitA.hp
  17. unitB.maxHp = unitB.hp
  18. unitA.baseAtk = unitA.atk
  19.  
  20. function applyDamage()
  21.  
  22. local enrageCheck = checkForEnrage()
  23. local fortifyCheck = checkForFortify()
  24.  
  25. if enrageCheck then unitA.atk = math.round(unitA.atk * 1.5) end
  26. if fortifyCheck then unitB.armor = .5 else unitB.armor = .75 end
  27.  
  28. local unitADmg = math.round(unitA.atk * unitB.armor)
  29.  
  30. unitA.hp = unitA.hp - unitB.atk
  31. unitB.hp = unitB.hp - unitADmg
  32.  
  33. applyHealing(unitADmg)
  34.  
  35. print("UNIT A DEALS "..unitADmg.." DMG")
  36. print("UNIT B DEALS "..unitB.atk.." DMG")
  37.  
  38. print("UNIT A HP - "..unitA.hp)
  39. print("UNIT B HP - "..unitB.hp)
  40.  
  41. unitA.atk = unitA.baseAtk
  42. end
  43.  
  44. function applyHealing(unitADmg)
  45.  
  46. unitB.hp = unitB.hp + 5
  47. unitA.hp = unitA.hp + math.round(unitADmg * unitA.lifesteal)
  48.  
  49. print("UNIT B HEALS FOR 5")
  50. print("UNIT A HEALS FOR "..math.round(unitADmg * unitA.lifesteal))
  51.  
  52. end
  53.  
  54. function checkForEnrage()
  55.  
  56. if unitA.hp <= unitA.maxHp/2 then
  57. print("ENRAGED")
  58. return true
  59. else
  60. return false
  61. end
  62.  
  63. end
  64.  
  65. function checkForFortify()
  66. if unitB.hp >= unitB.maxHp/2 then
  67. print("FORTIFIED")
  68. return true
  69. else
  70. return false
  71. end
  72. end
  73.  
  74. function endCombat()
  75. if unitA.hp <= 0 then
  76. print("UNIT B WINS")
  77. else
  78. print("UNIT A WINS")
  79. end
  80. end
  81.  
  82. function combat()
  83.  
  84. turns = turns + 1
  85. print("TURN "..turns)
  86.  
  87. applyDamage()
  88.  
  89. if unitA.hp <=0 or unitB.hp <=0 then
  90. endCombat()
  91. else
  92. combat()
  93. end
  94. end
  95.  
  96. combat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement