Guest User

Boxer

a guest
Dec 9th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.73 KB | None | 0 0
  1. --Boxer
  2. --Made By Hellkid98
  3.  
  4. --General
  5. local var = 0
  6. local hp = 100 --Player Health
  7. local tHP = 100 --Total Health
  8. local sta = 50 -- Stamina
  9. local totalXp = 100
  10. local xp = 0
  11. local myScore = 0
  12. local money = 0
  13. local wins = 0
  14. local loss = 0
  15. local day = 1
  16. local regainHP = math.random(25,50)
  17. local regainSTA = math.random(25,50)
  18. local lvl = 1
  19. enemyLvl = 1
  20. enemySta = 50
  21. enemyHP = 100
  22. d = damage1
  23. a = agility1
  24. s = speed1
  25. dfc = defence1
  26. eAtk = enemyDMG1
  27.  
  28. --Skills
  29. local damage1 = math.random(5,10)
  30. local damage2 = math.random(5,20)
  31. local damage3 = math.random(5,30)
  32. local damage4 = math.random(5,40)
  33. local damage5 = math.random(5,50)
  34. local agility1 = math.random(5,10)
  35. local agility2 = math.random(10,20)
  36. local agility3 = math.random(20,30)
  37. local agility4 = math.random(30,40)
  38. local agility5 = math.random(40,50)
  39.  
  40.  
  41.  
  42. --Enemies
  43. local enemyHP1 = 100 -- Enemies Health
  44. local enemyHP2 = 125
  45. local enemyHP3 = 150
  46. local enemyHP4 = 175
  47. local enemyHP5 = 200
  48.  
  49. local enemyDMG1 = math.random(2,8) --Enemies Damage. NOTE:If they are Higher Level they get better damage
  50. local enemyDMG2 = math.random(10,15) --For example: if enemy level = 2 then eAtk = enemyDMG2
  51. local enemyDMG3 = math.random(20,30)
  52. local enemyDMG4 = math.random(30,45)
  53. local enemyDMG5 = math.random(50,60)
  54.  
  55. --Randomly Selects An Enemy PS. This Is For Solo Play
  56. function randomChallenger()
  57. var = math.random(1,20)
  58. if var ==1 then
  59. enemy = "Rock Hardwood"
  60. elseif var ==2 then
  61. enemy = "Olov Reynkon"
  62. elseif var ==3 then
  63. enemy = "Usumo Binlayden"
  64. elseif var ==4 then
  65. enemy = "Duke Parker"
  66. elseif var ==5 then
  67. enemy = "Peter Pestrami"
  68. elseif var ==6 then
  69. enemy = "Lucky Mook"
  70. elseif var ==7 then
  71. enemy = "Gouda Croissant"
  72. elseif var ==8 then
  73. enemy = "John Dorkian"
  74. elseif var ==9 then
  75. enemy = "Rochy Ballboda"
  76. elseif var ==10 then
  77. enemy = "Felix Mjellberg"
  78. elseif var ==11 then
  79. enemy = "Turk Turkleton"
  80. elseif var ==12 then
  81. enemy = "Rock Hardwood"
  82. elseif var ==13 then
  83. enemy = "Rock Hardwood"
  84. elseif var ==14 then
  85. enemy = "Rock Hardwood"
  86. elseif var ==15 then
  87. enemy = "Rock Hardwood"
  88. elseif var ==16 then
  89. enemy = "Rock Hardwood"
  90. elseif var ==17 then
  91. enemy = "Rock Hardwood"
  92. elseif var ==18 then
  93. enemy = "Rock Hardwood"
  94. elseif var ==19 then
  95. enemy = "Rock Hardwood"
  96. elseif var ==20 then
  97. enemy = "Rock Hardwood"
  98. print(enemy)
  99. cleanScreen()
  100. end
  101. end
  102.  
  103.  
  104.  
  105.  
  106.  
  107. os.pullEvent = os.pullEventRaw
  108.  
  109. function drawAt(x,y,text)
  110. term.setCursorPos(x,y)
  111. term.write(text)
  112. end
  113.  
  114. function cleanScreen()
  115. term.clear()
  116. term.setCursorPos(1,1)
  117. end
  118.  
  119. --Draw Cursor
  120. function drawCursor(x1,x2,y)
  121.   drawAt(x1,y,"[")
  122.   drawAt(x2,y,"]")
  123. end
  124.  
  125. --Resets Everything
  126. function resetStats()
  127. hp = 100
  128. sta = 50
  129. myScore = 0
  130. money = 0
  131. wins = 0
  132. loss = 0
  133. day = 1
  134. end
  135.  
  136.  
  137. --Credits
  138. function credits()
  139. cleanScreen()  
  140. drawAt(1,1,"+----------------------------------------+")
  141. drawAt(1,2,"|              CREDITS                   |")
  142. drawAt(1,3,"|----------------------------------------|")
  143. drawAt(1,4,"|                                          |")
  144. drawAt(1,5,"|  CODED BY: Hellkid98                   |")
  145. drawAt(1,6,"|  BETA TESTERS:                         |")
  146. drawAt(1,7,"|                                          |")
  147. drawAt(1,8,"|                                          |")
  148. drawAt(1,9,"|                                        |")
  149. drawAt(1,10,"|                                         |") 
  150. drawAt(1,11,"|                                         |")
  151. drawAt(1,12,"+----------------------------------------+")
  152. drawAt(1,13,"")
  153. drawAt(1,14," PRESS [ENTER] TO EXIT")  
  154. event, p1 = os.pullEvent()
  155.         if event == "key" then
  156.           if p1 == 28 then
  157.           return
  158.  
  159. end
  160. end
  161. end      
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. local warningOptions = {
  169.  "Yes", "No"
  170. }
  171.  
  172. local menuOptions =
  173. {
  174.   "Solo",  "Multiplayer",  "Settings",  "Highscore",  "Help",  "Credits",  "Exit"
  175. }
  176.  
  177.  
  178. local hMenuOptions =
  179. {
  180.  "Tournament", "Quick Match", "Relax", "Open Map", "Exit To Main Menu"
  181. }
  182.  
  183.  
  184.  
  185.  
  186. --Draws the Gameplay
  187. function drawMatchArt()
  188. drawAt(11,9,"ACTION:")
  189. end
  190.  
  191. --Draw The players and The Enemies Grid PS. This Is for solo Play
  192. function drawGrids()
  193. drawAt(1,1,"|======| "..myName.."   ")
  194. drawAt(1,2,"| O ..O| HP:"..hp.."    ")
  195. drawAt(1,3,"|  _   | STA:"..sta.."  ")
  196. drawAt(1,4,"|      | LVL:"..lvl.."  ")
  197. drawAt(1,5,"|------+                ")
  198. drawAt(28,1,"|======| "..enemy.."   ")
  199. drawAt(28,2,"|O ..O | HP:"..enemyHP.."    ")
  200. drawAt(28,3,"|   _  | STA:"..enemySta.."  ")
  201. drawAt(28,4,"|      | LVL:"..enemyLvl.."  ")
  202. drawAt(28,5,"|------+                ")
  203. end
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. --Draws The Main Menu
  213. function drawMenu()
  214.   cleanScreen()
  215.   drawAt(1,1,"+------------------------------------------------+")
  216.   drawAt(1,2,"|            Boxer Tournament V 0.1              |")
  217.   drawAt(1,3,"+------------------------------------------------+")
  218.   drawAt(1,4,"|                                                |")
  219.   drawAt(1,5,"|                                                |")
  220.   drawAt(1,6,"|                                                |")
  221.   drawAt(1,7,"|                                                |")
  222.   drawAt(1,8,"|                                                |")
  223.   drawAt(1,9,"|                                                |")
  224.   drawAt(1,10,"|                                                |")
  225.   drawAt(1,11,"|                                                |")
  226.   drawAt(1,12,"|                                                |")
  227.   drawAt(1,13,"|                                                |")
  228.   drawAt(1,14,"|                                                |")
  229.   drawAt(1,15,"|                                                |")
  230.   drawAt(1,16,"|                                                |")
  231.   drawAt(1,17,"|                                                |")
  232.   drawAt(1,18,"+------------------------------------------------+")
  233.   for i = 1, #menuOptions do
  234.         drawAt(3,i + 3,"*")
  235.         drawAt(5,i + 3,menuOptions[i])
  236.   end
  237.   drawCursor(2,4,2 + menuStat)
  238. end
  239.  
  240.  
  241.  
  242.  
  243. --Highscore        
  244. function highScore()
  245. cleanScreen()      
  246. print("+------------------------------------------------+")
  247. print("|              +--Highscore--+                   |")
  248. print("|------------------------------------------------|")        
  249. print("|    1. James Bond  Score: 1337                  |")                                
  250. print("|    1. James Bond  Score: 1337                  |")    
  251. print("|    1. James Bond  Score: 1337                  |")        
  252. print("|    1. James Bond  Score: 1337                  |")        
  253. print("|    1. James Bond  Score: 1337                  |")        
  254. print("|    1. James Bond  Score: 1337                  |")        
  255. print("|    1. James Bond  Score: 1337                  |")        
  256. print("|    1. James Bond  Score: 1337                  |")
  257. print("|    1. James Bond  Score: 1337                  |")
  258. print("|    1. James Bond  Score: 1337                  |")
  259. print("+------------------------------------------------+")
  260. print("")
  261. print(" PRESS [ENTER] TO EXIT")
  262. event, p1 = os.pullEvent()
  263.         if event == "key" then
  264.           if p1 == 28 then
  265. return
  266. end
  267. end
  268. end
  269.  
  270.  
  271. --Main Menu Events
  272. function menuEvents()
  273. event, p1 = os.pullEvent()
  274. if event == "key" then
  275. if p1 == 200
  276. then
  277. menuStat = menuStat - 1
  278. if menuStat < 2 then
  279. menuStat = 8
  280. end
  281. elseif p1 == 208 then
  282.          menuStat = menuStat + 1
  283.          if menuStat > 8 then
  284.            menuStat = 2
  285.            end
  286.            elseif p1 == 28 then
  287.            if menuStat == 2 then
  288.            enterName()
  289.            solo()
  290.            elseif menuStat == 3 then
  291.            cleanScreen()
  292.            print("Multiplayer Not Available Yet")
  293.            sleep(2)
  294.            menu()
  295.            elseif menuStat == 4 then
  296.            cleanScreen()
  297.            print("Settings Not Available Yet")
  298.            sleep(2)
  299.            menu()
  300.            elseif menuStat == 5 then
  301.            highScore()
  302.            elseif menuStat == 6 then
  303.            cleanScreen()
  304.            print("Help Not Available Yet")
  305.            sleep(2)
  306.            menu()
  307.            elseif menuStat == 7 then
  308.            credits()
  309.            elseif menuStat == 8 then
  310.            os.reboot()
  311.            menu()
  312.            end
  313.            end
  314.            end
  315.            end
  316.            
  317.            
  318. -----------------------------------------
  319. --HomeMenu Events
  320. function hMenuEvents()
  321. event, p1 = os.pullEvent()
  322. if event == "key" then
  323. if p1 == 200
  324. then
  325. menuStat = menuStat - 1
  326. if menuStat < 2 then
  327. menuStat = 6
  328. end
  329. elseif p1 == 208 then
  330.          menuStat = menuStat + 1
  331.          if menuStat > 6 then
  332.            menuStat = 2
  333.            end
  334.            elseif p1 == 28 then
  335.            if menuStat == 2 then
  336.            startTournament()
  337.            elseif menuStat == 3 then
  338.            randomChallenger()
  339.            matchPlaying = true
  340.            fight()
  341.            elseif menuStat == 4 then
  342.            relax()
  343.            elseif menuStat == 5 then
  344.            openMap()
  345.            elseif menuStat == 6 then
  346.            warningMenu()
  347.            end
  348.            end
  349.            end
  350.            end
  351.            
  352.            
  353. --------------------------------
  354. --Tournament
  355. function startTournament()
  356. cleanScreen()
  357. print("Nothing Available YET")
  358. sleep(1)
  359. return
  360. end
  361.  
  362. --Quick Match
  363. function fight()
  364. checkAvail()
  365. matchPlaying = true
  366. repeat
  367. cleanScreen()
  368. checkStatus()
  369. checkMatch()
  370. drawGrids()
  371. drawMatchArt()
  372. if matchPlaying == false
  373. then
  374. solo()
  375. end
  376. fight = string.lower(read())
  377. if fight == "Punch" or fight == "punch"
  378. then
  379. drawGrids()
  380. drawMatchArt()
  381. print("")
  382. print(myName.." did "..d.." damage")
  383. print(enemy.." did "..eAtk.." damage")
  384. enemyHP = enemyHP - d
  385. hp = hp - eAtk
  386. sleep(2)
  387. cleanScreen()
  388. if hp < 1 then hp = 0
  389. if enemyHP < 1 then enemyHP = 0
  390. sleep(2)
  391. end
  392. end
  393. elseif fight == "Block" or fight == "block" then
  394. block = math.random(1,2)
  395. if block == 1
  396. then
  397. print(enemy.." Blocked Successfully")
  398. sleep(2)
  399. cleanScreen()
  400. elseif block == 2 then
  401. print(enemy.." Blocked Unsuccessfully")
  402. hp = hp - eAtk
  403. sleep(2)
  404. cleanScreen()
  405. elseif fight == "Punch Myself" or fight == "punch myself"
  406. then
  407. drawGrids()
  408. drawMatchArt()
  409. print("")
  410. print(myName.." punches himself/herself in the head.")
  411. print(enemy.." just stands and stares.")
  412. hp = hp - d
  413. sleep(2)
  414. cleanScreen()
  415. elseif fight == "Leave" or fight == "leave" then
  416. matchPlaying = false
  417. else
  418. term.setCursorPos(10,9)
  419. print("Unknown Action")
  420. cleanScreen()
  421. end
  422. end
  423. until matchPlaying == false
  424. end
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435. --Checks If someone Has Won
  436. function checkMatch()
  437. myName = myName
  438. d = damage1
  439. enemy = enemy
  440. eAtk = enemyDMG1
  441. if hp == 0 then
  442. cleanScreen()
  443. drawAt(10,9,enemy.." Won")
  444. loss = loss + 1
  445. sleep(2)
  446. matchPlaying = false
  447. elseif enemyHP == 0
  448. then
  449. cleanScreen()
  450. xp = xp + 50
  451. drawAt(10,9,myName.." Won")
  452. drawAt(11,10,xp.." Xp Earned")
  453. wins = wins + 1
  454. sleep(2)
  455. matchPlaying = false
  456. if sta == 0 then
  457. drawAt(10,9,enemy.." Won")
  458. loss = loss + 1
  459. sleep(2)
  460. matchPlaying = false
  461. elseif enemySta == 0
  462. then
  463. drawAt(10,9,myName.." Won")
  464. wins = wins + 1
  465. sleep(2)
  466. matchPlaying = false
  467. end
  468. end
  469. end
  470.  
  471.  
  472. --Checks If you Can start the match
  473. function checkAvail()
  474. if hp == 0 then
  475. cleanScreen()
  476. term.setCursorPos(6,6)
  477. print("Need to rest first!")
  478. return
  479. end
  480. if sta == 0 then
  481. cleanScreen()
  482. term.setCursorPos(6,6)
  483. print("Need to rest first!")
  484. return
  485. end
  486. end
  487.  
  488. --Checks Status of HP/STA
  489. function checkStatus()
  490. if hp < 1 then hp = 0
  491. end
  492. if enemyHP < 1 then enemyHP = 0
  493. end
  494. end
  495.  
  496.  
  497.  
  498. function checkXp()
  499. if xp == totalXp then
  500. lvl = lvl + 1
  501. d = d + 1
  502. totalXp = totalXp + 50
  503. tHP = tHP + 10
  504. end
  505. end
  506.  
  507.  
  508. --Checks if Hp are a larger value than the total Healt
  509. function checkHP()
  510. if hp > tHP then
  511. hp = tHP
  512. end
  513. end
  514.  
  515.  
  516. --Relax
  517. function relax()
  518. checkHP()
  519. sta = sta + regainSTA
  520. hp = hp + regainHP         
  521. day = day + 1          
  522. cleanScreen()
  523. drawAt(6,6,"Played "..day.." days")
  524. sleep(2)
  525. checkHP()
  526. solo()
  527. end
  528.  
  529. --Opens the Map
  530. function openMap()
  531. cleanScreen()
  532. print("Nothing Available YET")
  533. sleep(1)
  534. return
  535. end    
  536.            
  537.            --Draws the Home Menu
  538. function drawHomeMenu()
  539.   cleanScreen()
  540.   drawAt(1,1,"+-------------------------+----------------------+")
  541.   drawAt(1,2,"|         HOME            |======+ "..myName.."   ")
  542.   drawAt(1,3,"|-------------------------| O ..O| HP:"..hp.."/"..tHP)
  543.   drawAt(1,4,"|                         |  _   | STA:"..sta.."  ")
  544.   drawAt(1,5,"|                         |      | LVL:"..lvl.."  ")
  545.   drawAt(1,6,"|                         |------+ XP:"..xp.."/"..totalXp)
  546.   drawAt(1,7,"|                         | MONEY:"..money.."$    ")
  547.   drawAt(1,8,"|                         | WINS:"..wins.."       ")
  548.   drawAt(1,9,"|                         | LOSSES:"..loss.."      ")
  549.   drawAt(1,10,"|                         | SCORE:"..myScore.."   ")
  550.   drawAt(1,11,"+-------------------------+----------------------+")
  551.  
  552.  
  553.   for i = 1, #hMenuOptions do
  554.         drawAt(4,i + 3,"*")
  555.         drawAt(6,i + 3,hMenuOptions[i])
  556.   end
  557.   drawCursor(3,5,2 + menuStat)
  558. end
  559.            
  560.            
  561.            
  562. ----------------------------------------------
  563. --Draws Warning Menu
  564. function drawWarningMenu()
  565. cleanScreen()
  566. drawAt(1,1,"+------------------------------------------------+")
  567. drawAt(1,2,"|          #####---!WARNING!---#####             |")
  568. drawAt(1,3,"+------------------------------------------------+")
  569. drawAt(1,4,"|     If you quit to the main menu you will      |")
  570. drawAt(1,5,"|   lose all unsaved progress made in the game.  |")
  571. drawAt(1,6,"|       ARE YOU SURE YOU WANT TO QUIT?           |")
  572. drawAt(1,7,"|                                                |")
  573. drawAt(1,8,"|                                                |")
  574. drawAt(1,9,"|                                                |")
  575. drawAt(1,10,"+------------------------------------------------+")
  576.  
  577. for i = 1, #warningOptions do
  578.         drawAt(20,i + 6,"*")
  579.         drawAt(22,i + 6,warningOptions[i])
  580.   end
  581.   drawCursor(19,21,2 + menuStat)
  582. end
  583.  
  584.  
  585. ----------------------------------------------
  586. --Warning Menu events
  587. function wMenuEvents()
  588. event, p1 = os.pullEvent()
  589. if event == "key" then
  590. if p1 == 200
  591. then
  592. menuStat = menuStat - 1
  593. if menuStat < 5 then
  594. menuStat = 6
  595. end
  596. elseif p1 == 208 then
  597.          menuStat = menuStat + 1
  598.          if menuStat > 6 then
  599.            menuStat = 5
  600.            end
  601.            elseif p1 == 28 then
  602.            if menuStat == 5 then
  603.            resetStats()
  604.            menu()
  605.            elseif menuStat == 6 then
  606.            solo()
  607.            end
  608.            end
  609.            end
  610.            end
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618. --Enter Your Name
  619. function enterName()
  620. while true do
  621. drawNameMenu()
  622. term.setCursorPos(1,3)
  623. write("|ENTER NAME:")
  624. myName = read()
  625. solo()  
  626. end          
  627. end
  628.  
  629. --Draws the Name menu
  630. function drawNameMenu()
  631. cleanScreen()
  632. drawAt(1,2,"+-------------------------+")
  633. drawAt(27,3,"|")
  634. drawAt(1,4,"+-------------------------+")
  635. end
  636.  
  637.  
  638. --Warning Menu
  639. function warningMenu()
  640. menuStat = 5
  641. while true do
  642. drawWarningMenu()
  643. wMenuEvents()
  644. end
  645. end
  646.  
  647. --Solo Menu
  648. function solo()
  649. menuStat = 2
  650. while true do
  651. checkXp()
  652. drawHomeMenu()
  653. hMenuEvents()
  654. end
  655. end
  656.  
  657.  
  658. --Main Menu
  659. function menu()
  660.   menuStat = 2
  661.   while true do
  662.   checkXp()
  663.         drawMenu()
  664.         menuEvents()
  665.   end
  666. end
  667.  
  668. --Main Function
  669. function main()
  670. menu()
  671. end
  672.  
  673. --Starts
  674. main()
Advertisement
Add Comment
Please, Sign In to add comment