Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turns = 0
- local unitA = {
- hp = 513,
- atk = 52,
- lifesteal = .35
- }
- local unitB = {
- hp = 617,
- atk = 42,
- armor = .5,
- healing = .008
- }
- unitA.maxHp = unitA.hp
- unitB.maxHp = unitB.hp
- unitA.baseAtk = unitA.atk
- function applyDamage()
- local enrageCheck = checkForEnrage()
- local fortifyCheck = checkForFortify()
- if enrageCheck then unitA.atk = math.round(unitA.atk * 1.5) end
- if fortifyCheck then unitB.armor = .5 else unitB.armor = .75 end
- local unitADmg = math.round(unitA.atk * unitB.armor)
- unitA.hp = unitA.hp - unitB.atk
- unitB.hp = unitB.hp - unitADmg
- applyHealing(unitADmg)
- print("UNIT A DEALS "..unitADmg.." DMG")
- print("UNIT B DEALS "..unitB.atk.." DMG")
- print("UNIT A HP - "..unitA.hp)
- print("UNIT B HP - "..unitB.hp)
- unitA.atk = unitA.baseAtk
- end
- function applyHealing(unitADmg)
- unitB.hp = unitB.hp + 5
- unitA.hp = unitA.hp + math.round(unitADmg * unitA.lifesteal)
- print("UNIT B HEALS FOR 5")
- print("UNIT A HEALS FOR "..math.round(unitADmg * unitA.lifesteal))
- end
- function checkForEnrage()
- if unitA.hp <= unitA.maxHp/2 then
- print("ENRAGED")
- return true
- else
- return false
- end
- end
- function checkForFortify()
- if unitB.hp >= unitB.maxHp/2 then
- print("FORTIFIED")
- return true
- else
- return false
- end
- end
- function endCombat()
- if unitA.hp <= 0 then
- print("UNIT B WINS")
- else
- print("UNIT A WINS")
- end
- end
- function combat()
- turns = turns + 1
- print("TURN "..turns)
- applyDamage()
- if unitA.hp <=0 or unitB.hp <=0 then
- endCombat()
- else
- combat()
- end
- end
- combat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement