Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cse1()
- term.setCursorPos(1, 3)
- write("[Attack] Defend")
- end
- function cse2()
- term.setCursorPos(1, 3)
- write("Attack [Defend]")
- end
- c1t = 0
- c2t = 0
- c3t = 0
- c4t = 0
- c5t = 0
- c6t = 0
- c7t = 0
- c8t = 0
- c9t = 0
- c10t = 0
- c11t = 0
- c12t = 0
- c13t = 0
- exp = 1
- hp = 25
- dmg = 5
- while true do
- randenemy = math.random(1, 4)
- if randenemy == 4 then
- enemy = "skeleton"
- elseif randenemy == 3 then
- enemy = "enemy.name(nil)"
- elseif randenemy == 2 then
- enemy = "Ninja"
- else
- if xp <= 10 then
- enemy = "Knight"
- elseif xp > 10 and xp < 25 then
- enemy = "Lion"
- elseif xp > 24 and xp < 50 then
- enemy = "King"
- elseif xp > 49 then
- enemy = "Ultimate Boss"
- else
- print("Error: battle:21 xp value unexpected")
- end
- end
- function takeaction()
- tkactdone = 0
- while not tkactdone == 1 do
- selectaction = 1
- event, p1, p2 = os.pullEvent()
- if event == "key" then
- if p1 == 28 then
- action = selectaction
- tkactdone = 1
- end
- if p1 == 203 then
- if selectaction == 2 then
- selectaction = 1
- elseif selectaction == 1 then
- selectaction = 2
- end
- if p1 == 205 then
- if selectaction == 2 then
- selectaction = 1
- elseif selectaction == 1 then
- selectaction = 2
- end
- end
- if selectaction == 1 then
- cse1()
- elseif selectaction == 2 then
- cse2()
- else
- print("Error:battle:71 selected Action Unknown")
- end
- end
- end
- end
- if enemy == "skeleton" then
- enemyhp = 50
- enemyatt = 5
- enemyxp = 1
- elseif enemy == "enemy.name(nil)" then
- enemyhp = 80
- enemyatt = 15
- enemyxp = 5
- elseif enemy == "Ninja" then
- enemyhp = 60
- enemyatt = 15
- enemyxp = 3
- elseif enemy == "Knight" then
- enemyhp = 50
- enemyatt = 7
- enemyxp = 2
- elseif enemy == "Lion" then
- enemyhp = 65
- enemyatt = 10
- enemyxp = 4
- elseif enemy == "King" then
- enemyhp = 90
- enemyatt = 20
- enemyxp = 5
- elseif enemy == "Ultimate Boss" then
- enemyhp = 125
- enemyatt = 25
- enemyxp = 10
- else
- print("Error:battle:105 Enemy Name Does not exist")
- os.reboot()
- end
- while not enemyhp == 0 do
- takeaction()
- attack()
- enemyturn()
- if hp == 0 then
- break
- end
- end
- if enemyhp == 0 then
- exp = exp + enemyxp
- if xp == 5 then
- if c13t == 0 then
- maxhp = maxhp +5
- dmg = dmg +3
- c13t = 1
- end
- end
- if xp >= 10 then
- if c12t == 0 then
- maxhp = maxhp +5
- dmg = dmg +4
- c12t = 1
- end
- end
- if xp >= 15 then
- if c11t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c11t = 1
- end
- end
- if xp >= 20 then
- if c10t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c10t = 1
- end
- end
- if xp >= 30 then
- if c9t == 0 then
- maxhp = maxhp +15
- dmg = dmg +13
- c9t = 1
- end
- end
- if xp >= 40 then
- if c8t == 0 then
- maxhp = maxhp +20
- dmg = dmg +15
- c8t = 1
- end
- end
- if xp >= 50 then
- if c7t == 0 then
- maxhp = maxhp +20
- dmg = dmg +15
- c7t = 1
- end
- end
- if xp >= 60 then
- if c6t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c6t = 1
- end
- end
- if xp >= 70 then
- if c5t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c5t = 1
- end
- end
- if xp >= 80 then
- if c4t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c4t = 1
- end
- end
- if xp >= 90 then
- if c3t == 0 then
- maxhp = maxhp +5
- dmg = dmg +5
- c3t = 1
- end
- end
- if xp >= 100 then
- if c2t == 0 then
- maxhp = maxhp +10
- dmg = dmg +10
- c2t = 1
- end
- end
- if xp >= 150 then
- if c1t == 0 then
- maxhp = maxhp +75
- dmg = dmg +30
- c1t = 1
- end
- end
- if xp >= 150 then
- print("error:battle:210 XP unexpected value")
- os.reboot()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement