Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version = 0.34 -- 34% to Release
- matk = {}
- mdef = {}
- mhp = {}
- mexp = {}
- mname = {}
- mskilln = {}
- mskilldmg = {}
- skill1 = {}
- skill2 = {}
- skill3 = {}
- skill4 = {}
- function initmonster()
- mexp[1] = 5 -- Training Dummy
- matk[1] = 0
- mdef[1] = 0
- mhp[1] = 5
- mname[1] = "Training Dummy"
- mskilln[1] = "Fall Over"
- mskilldmg[1] = 3 -- Training Dummy
- mexp[2] = 10 -- Dark Soldier Scout
- matk[2] = 2
- mdef[2] = 1
- mhp[2] = 25
- mname[2] = "Dark Soldier Scout"
- mskilln[2] = "Dark Beam"
- mskilldmg[2] = 4 -- Dark Soldie Scout
- mexp[3] = 20
- matk[3] =4
- mdef[3] = 1
- mhp[3] = 40
- mname[3] = "Dark Scout Leader"
- mskilln[3] = "Dark Beam"
- mskilldmg[3] = 5
- end
- initmonster()
- function initchar(class)
- if class == "mage" then
- skill1[1] = "Fireball" -- name
- skill1[2] = 4 -- min damage
- skill1[3] = 7 -- max damage
- skill1[4] = 5 -- mana cost
- skill1[5] = 1 -- Skill level
- skill2[1] = "Weak heal" -- name
- skill2[2] = 5 -- min damage
- skill2[3] = 6 -- max damage
- skill2[4] = 6 -- mana cost
- skill2[5] = 1 -- Skill level
- skill3[1] = "Wall" -- name
- skill3[2] = 10 -- This is a wall, so it has a health of 10
- skill3[3] = 2 -- This is a wall, so it blocks 2 damage
- skill3[4] = 5 -- mana cost
- skill3[5] = 1 -- Skill level
- skill4[1] = "Block" -- name
- skill4[2] = 0 -- Block spell blocks the next few attacks, at level 1, 100% of 1, 0% of blocking 2 atacks
- skill4[3] = 1 -- max block length
- skill4[4] = 8 -- mana cost
- skill4[5] = 1 -- Skill level
- elseif class == "knight" then
- skill1[1] = "Strength" --Name
- skill1[2] = 2 -- Min atk bonus
- skill1[3] = 2 -- Max atk bonus
- skill1[4] = 5 -- Mana cost
- skill1[5] = 1 -- Skill lvl
- skill2[1] = "Protect" --Name
- skill2[2] = 2 -- Min def bonus
- skill2[3] = 2 -- Max atk bonus
- skill2[4] = 5 -- Mana cost
- skill2[5] = 1 -- Skill lvl
- skill3[1] = "Block" --Name
- skill3[2] = 0 --Unused
- skill3[3] = 1 -- Maximum amount of turns for block
- skill3[4] = 8 -- Mana cost
- skill3[5] = 1 -- Skill Level
- skill4[1] = "Power Slash"
- skill4[2] = 4
- skill4[3] = 7
- skill4[4] = 4
- skill4[5] = 1
- end
- if class == "knight" then
- atk = 3
- magic = 10
- elseif class == "mage" then
- atk = 2
- magic = 15
- end
- maxhp = 30
- hp = 30
- def = 1
- exp = 0
- lvl = 1
- exptolvl = 10
- lvlpoints = 0
- coins = 0
- end
- function updatehealth()
- local mshp = maxhp /10
- local mshp2 = mshp *4
- local mshp = mshp *2
- if hp <= mshp2 then
- phealth = "medium"
- if hp <= mshp then
- phealth = "low"
- end
- else
- phealth = "high"
- end
- local msehp = mhp[ma] /10
- local msehp2 = msehp *4
- local msehp = msehp *2
- if enemyhp <= msehp2 then
- ehealth = "medium"
- if enemyhp <= msehp then
- ehealth = "low"
- end
- else
- ehealth = "high"
- end
- term.setCursorPos(1,17)
- term.setBackgroundColor(colors.black)
- cWrite(" ",18)
- cWrite(" ",17)
- if phealth == "high" then
- term.setBackgroundColor(colors.green)
- elseif phealth == "medium" then
- term.setBackgroundColor(colors.orange)
- else
- term.setBackgroundColor(colors.red)
- end
- cWrite("Your Health: "..hp.."/"..maxhp)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,18)
- if ehealth == "high" then
- term.setBackgroundColor(colors.green)
- elseif ehealth == "medium" then
- term.setBackgroundColor(colors.orange)
- else
- term.setBackgroundColor(colors.red)
- end
- cWrite(enemyname .. "'s HP: " .. enemyhp .. "/" .. mhp[ma] .. " ")
- term.setBackgroundColor(colors.black)
- end
- function drawchars()
- -- I do NOT want to work on this atm
- term.setCursorPos(1,6)
- cWrite("Character art not finished")
- end
- function drawtitle()
- cWrite("You VS. " .. enemyname,3)
- end
- function win()
- hp = maxhp
- exp = exp + enemyxp
- if exp >= exptolvl then
- lvlup()
- end
- bresult = 1
- coinswon = lvl * 3
- coins = coins + coinswon
- term.clear()
- end
- function lvlup()
- lvl = lvl +1
- maxhp = maxhp +5
- atk = atk +1
- def = def +0.5
- exptolvl = exptolvl * 1.5
- lvlpoints = lvlpoints +3
- end
- function lose()
- if coins >= 0 then
- coins = coins / 2
- end
- bresult = 3
- end
- function run()
- bresult = 3
- end
- function choosemove1()
- cm1confirmed = 0
- cm1select = 0
- cm1finished = 0
- cm1lr = 1
- cm1ud = 1
- cWrite(" [Attack] Skill ",9)
- cWrite(" Item Escape ",11)
- while cm1confirmed == 0 do
- e,key = os.pullEvent("key")
- if key == 205 then
- cm1lr = 2
- elseif key == 203 then
- cm1lr = 1
- elseif key == 208 then
- cm1ud = 2
- elseif key == 200 then
- cm1ud = 1
- elseif key == 28 then
- cm1finished = 1
- end
- if cm1lr == 1 and cm1ud == 1 then
- cWrite(" [Attack] Skill ",9)
- cWrite(" Item Escape ",11)
- elseif cm1lr == 2 and cm1ud == 1 then
- cWrite(" Attack [Skill] ",9)
- cWrite(" Item Escape ",11)
- elseif cm1lr == 1 and cm1ud == 2 then
- cWrite(" Attack Skill ",9)
- cWrite(" [Item] Escape ",11)
- elseif cm1lr == 2 and cm1ud == 2 then
- cWrite(" Attack Skill ",9)
- cWrite(" Item [Escape] ",11)
- end
- if cm1finished == 1 then
- if cm1lr == 1 and cm1ud == 1 then
- cm1confirmed = 1
- return "attack"
- elseif cm1lr == 2 and cm1ud == 1 then
- cm1confirmed = 1
- return "skills"
- elseif cm1lr == 1 and cm1ud == 2 then
- cm1confirmed = 1
- return "items"
- elseif cm1lr == 2 and cm1ud == 2 then
- cm1confirmed = 1
- return "run"
- end
- end
- end
- end
- function choosemove2()
- if mv1 == "skills" then
- cm2confirmed = 0
- cm2select = 0
- cm2finished = 0
- cm2lr = 1
- cm2ud = 1
- cWrite(" ["..skill1[1].."] "..skill2[1].." ",9)
- cWrite(" "..skill3[1].." "..skill4[1].." ",11)
- while cm2confirmed == 0 do
- e,key = os.pullEvent("key")
- if key == 205 then
- cm2lr = 2
- elseif key == 203 then
- cm2lr = 1
- elseif key == 208 then
- cm2ud = 2
- elseif key == 200 then
- cm2ud = 1
- elseif key == 28 then
- cm2finished = 1
- end
- if cm2lr == 1 and cm2ud == 1 then
- cWrite(" ["..skill1[1].."] "..skill2[1].." ",9)
- cWrite(" "..skill3[1].." "..skill4[1].." ",11)
- elseif cm2lr == 2 and cm2ud == 1 then
- cWrite(" "..skill1[1].." ["..skill2[1].."] ",9)
- cWrite(" "..skill3[1].." "..skill4[1].." ",11)
- elseif cm2lr == 1 and cm2ud == 2 then
- cWrite(" "..skill1[1].." "..skill2[1].." ",9)
- cWrite(" ["..skill3[1].."] "..skill4[1].." ",11)
- elseif cm2lr == 2 and cm2ud == 2 then
- cWrite(" "..skill1[1].." "..skill2[1].." ",9)
- cWrite(" "..skill3[1].." ["..skill4[1].."] ",11)
- end
- if cm2finished == 1 then
- if cm2lr == 1 and cm2ud == 1 then
- cm2confirmed = 1
- return "skill1"
- elseif cm2lr == 2 and cm2ud == 1 then
- cm2confirmed = 1
- return "skill2"
- elseif cm2lr == 1 and cm2ud == 2 then
- cm2confirmed = 1
- return "skill3"
- elseif cm2lr == 2 and cm2ud == 2 then
- cm2confirmed = 1
- return "skill4"
- end
- end
- end
- end
- end
- function useSkill(nameOfSkill)
- if skill1[1] == nameOfSkill then
- whichSkill = 1
- elseif skill2[1] == nameOfSkill then
- whichSkill = 2
- elseif skill3[1] == nameOfSkill then
- whichSkill = 3
- else
- whichSkill = 4
- end
- if nameOfSkill == "Power Slash" then
- if whichSkill == 1 then
- dmgtodeal = math.random(skill1[2],skill1[3])
- mana = mana -skill1[4]
- elseif whichSkill == 2 then
- dmgtodeal = math.random(skill2[2],skill2[3])
- mana = mana -skill2[4]
- elseif whichSkill == 3 then
- dmgtodeal = math.random(skill3[2],skill3[3])
- mana = mana -skill3[4]
- elseif whichSkill == 4 then
- dmgtodeal = math.random(skill4[2],skill4[3])
- mana = mana -skill4[4]
- end
- dmgtodeal = math.ceil(dmgtodeal)
- enemyhp = enemyhp -dmgtodeal
- if enemyhp <= 0 then
- enemyhp = 0
- end
- end
- if nameOfSkill == "Fireball" then
- if whichSkill == 1 then
- dmgtodeal = math.random(skill1[2],skill1[3])
- mana = mana -skill1[4]
- elseif whichSkill == 2 then
- dmgtodeal = math.random(skill2[2],skill2[3])
- mana = mana -skill2[4]
- elseif whichSkill == 3 then
- dmgtodeal = math.random(skill3[2],skill3[3])
- mana = mana -skill3[4]
- elseif whichSkill == 4 then
- dmgtodeal = math.random(skill4[2],skill4[3])
- mana = mana -skill4[4]
- end
- dmgtodeal = math.ceil(dmgtodeal)
- enemyhp = enemyhp -dmgtodeal
- if enemyhp <= 0 then
- enemyhp = 0
- end
- end
- end
- function battle(mtoface)
- mana = magic
- bresult = 2
- ma = mtoface
- term.clear()
- term.setCursorPos(1,1)
- enemyhp = mhp[ma]
- enemyatk = matk[ma]
- enemydef = mdef[ma]
- enemyname = mname[ma]
- enemyxp = mexp[ma]
- enemysn = mskilln[ma]
- enemysdmg = mskilldmg[ma]
- hp = maxhp
- batk = atk
- bdef = def
- updatehealth()
- drawchars()
- drawtitle()
- battlefinish = 0
- while battlefinish == 0 do
- updatehealth()
- if hp <= 0 then
- lose()
- battlefinish = 1
- end
- if enemyhp <= 0 then
- win()
- battlefinish = 1
- end
- mv1 = choosemove1()
- if mv1 == "items" or mv1 == "skills" then
- mv2 = choosemove2()
- if mv1 == "skills" then
- useSkill(mv2)
- end
- elseif mv1 == "run" then
- rvar = math.random(1,3)
- if rvar == 1 then
- run()
- battlefinish = 1
- end
- elseif mv1 == "attack" then
- edefm = math.random(2,4)
- edef = enemydef /edefm
- dmgtodeal = batk -edef
- dmgtodeal = math.ceil(dmgtodeal)
- enemyhp = enemyhp -dmgtodeal
- if enemyhp <= 0 then
- enemyhp = 0
- end
- cWrite(" ",1)
- cWrite(" ",2)
- cWrite("You attack and do "..dmgtodeal.."dmg",1)
- cWrite("To "..enemyname,2)
- updatehealth()
- sleep(1)
- end
- --Now for the enemy.
- if enemyhp <= 0 then
- win()
- battlefinish = 1
- end
- if battlefinish == 0 then
- atktype = math.random(1,3)
- oldhp = hp
- if atktype == 1 then
- hp = hp -enemysdmg
- if hp >= oldhp then
- hp = oldhp
- end
- if hp <= 0 then
- hp = 0
- end
- cWrite(" ",1)
- cWrite(" ",2)
- cWrite(enemyname .. " Attacked you and did",1)
- cWrite(enemysdmg .. "dmg with " ..enemysn.." ",2)
- sleep(1.2)
- elseif atktype == 3 or atktype == 2 then
- aldef = def/3
- aldef = aldef +math.random(1,3)
- aldmg = enemyatk - aldef
- aldmg = math.ceil(aldmg)
- if aldmg <= 0 then
- aldmg = 0
- end
- hp = hp -aldmg
- if hp >= oldhp then
- hp = oldhp
- end
- if hp <= 0 then
- hp = 0
- end
- cWrite(" ",1)
- cWrite(" ",2)
- cWrite(enemyname .. " Attacked you and did",1)
- cWrite(aldmg .. "dmg",2)
- end
- end
- end
- end
- screenx, screeny = term.getSize()
- function cWrite(text,ytwa)
- if not ytwa then
- unusedx,ytwa = term.getCursorPos()
- end
- local len = string.len(text)
- local sxtw = screenx /2
- local len = len /2
- local sxtw = sxtw - len
- term.setCursorPos(sxtw,ytwa)
- write(text)
- end
- function Attack(Amount)
- end
- function selection() -- I use a function because I
- -- Plan to make a GUI here later
- select = 0
- term.clear()
- term.setCursorPos(1,1)
- print("Mages use mostly skills for combat")
- print("While Knights use mostly normal attacks")
- print("Knight's skills are mostly buffs")
- print("Mage's skills are mostly attacks")
- print("Arrow keys to select, Enter to confirm")
- -- ABSOLUTELY NO BALANCING
- -- I know knight is probably going to be better
- term.setCursorPos(8,6) -- Indentation FTW
- write("[Knight] Mage ")
- confirm = 0
- sover = 1
- while select == 0 do
- p1,p2 = os.pullEvent("key")
- if p2 == 205 then
- sover = 2
- elseif p2 == 203 then
- sover = 1
- elseif p2 == 28 then
- confirm = 1
- end
- if sover == 1 then
- term.setCursorPos(8,6)
- write("[Knight] Mage ")
- elseif sover == 2 then
- term.setCursorPos(8,6)
- write(" Knight [Mage]")
- end
- if confirm == 1 then
- if sover ==2 then
- class = "mage"
- elseif sover == 1 then
- class = "knight"
- end
- select = 1
- end
- end
- end
- print("Please select your class!")
- print("Class selection screen in 1 second")
- sleep(1)
- selection()
- term.clear()
- term.setCursorPos(1,1)
- print("??: So, you are a ".. class .. " , Well, Not even " .. class .. "s can destroy me!")
- sleep(1.5)
- print("??2: Teleport!")
- term.setCursorPos(1,19)
- write("Wizards Camp")
- term.setCursorPos(1,4)
- textutils.slowPrint("Master Wizard: Hello, I am the Master Wizard")
- textutils.slowPrint("I must teach you how to battle, but quickly!")
- sleep(0.5)
- textutils.slowPrint("Because a army is approaching from the Dark Crystal")
- print("[Tutorial starting in 3 seconds... ]")
- sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- print("[Note: This is not an actual battle]")
- print(" ")
- cWrite("Master Wizard Vs. Tutorial Dummy",3)
- term.setCursorPos(1,17)
- term.setBackgroundColor(colors.green)
- cWrite("Grand Wizard 900/900")
- term.setCursorPos(1,18)
- cWrite("Tutorial Dummy 5/5")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,4)
- cWrite(" o [] ",4)
- cWrite("/|\\ -|-",5)
- cWrite(" | | ",6)
- cWrite("/ \\ _=_",7)
- term.setCursorPos(1,9)
- sleep(0.5)
- cWrite("[Attack] Skill",9)
- cWrite("Item Escape",11)
- term.setCursorPos(1,2)
- textutils.slowWrite("Select the move you want to use")
- sleep(1.75)
- cWrite(" Attack [Skill]",9)
- term.setCursorPos(1,2)
- write(" ")
- term.setCursorPos(1,2)
- textutils.slowWrite("Then press the enter key")
- sleep(1.75) --100th line! (I know it's not now)
- term.setCursorPos(1,2)
- write(" ")
- cWrite(" [Explosion] Fire Ball ", 9)
- cWrite(" Shield Heal ",11)
- sleep(2)
- cWrite(" ",9)
- cWrite(" ",11)
- term.setCursorPos(1,2)
- textutils.slowWrite("Grand Wizard used Explosion, 500 dmg")
- term.setBackgroundColor(colors.red) --At one time the 200th line
- term.setCursorPos(1,18)
- cWrite("Tutorial Dummy 0/5")
- term.setBackgroundColor(colors.black)
- sleep(2)
- initchar(class)
- sleep(1.5)
- term.clear() -- At one time the 250th line
- term.setCursorPos(1,1)
- textutils.slowWrite("Now you try!")
- term.setCursorPos(1,2)
- print("[Battle starting in 3 seconds.]")
- sleep(3)
- toface = 1
- bresult = 3
- while bresult == 3 do --You ,must win this battle
- battle(toface) --At one time the 350th line
- end
- term.setCursorPos(1,1)
- cWrite("You won the battle!")
- print("Grand Wizard no time to continue this")
- print("The enemies are here, I'll let you")
- print("Battle the weaker enemies.")
- print("3-in-a-row Battle starting in 2 seconds")
- sleep(2)
- wins = 0
- while wins ~= 3 do
- battle(2)
- if bresult == 1 then
- wins = wins +1
- battle(2)
- if bresult == 1 then
- wins = wins +1
- battle(3)
- if bresult == 1 then
- wins = wins +1
- else
- wins = 0
- end
- else
- wins = 0
- end
- else
- wins = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement