Advertisement
NeonJ

ASCIIrealm RPG [Alpha 0.3]

Jan 13th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 120.82 KB | None | 0 0
  1. -- *** VARIABLES ***
  2.  
  3. -- Machine Variables - DO NOT ALTER
  4.  
  5. credits = 0
  6.  
  7. -- Main Variables - DO NOT ALTER
  8.  
  9. MGC1cost = 80
  10. MGC2cost = 120
  11. MGC3cost = 160
  12.  
  13. P1HP = 1000 -- / 1000
  14. P1MP = 1000 -- / 1000
  15. P1HPpots = 3 -- / 9
  16. P1MPpots = 3 -- / 9
  17. P1bombs = 3 -- / 9
  18. P1status = "   "
  19. P1shielded = 0
  20.  
  21. P1selected = ""
  22. P1target = ""
  23. P1ready = false
  24.  
  25. P2HP = 1000 -- / 1000
  26. P2MP = 1000 -- / 1000
  27. P2HPpots = 3 -- / 9
  28. P2MPpots = 3 -- / 9
  29. P2bombs = 3 -- / 9
  30. P2status = "   "
  31. P2shielded = 0
  32.  
  33. P2selected = ""
  34. P2target = ""
  35. P2ready = false
  36.  
  37. P3HP = 1000 -- / 1000
  38. P3MP = 1000 -- / 1000
  39. P3HPpots = 3 -- / 9
  40. P3MPpots = 3 -- / 9
  41. P3bombs = 3 -- / 9
  42. P3status = "   "
  43. P3shielded = 0
  44.  
  45. P3selected = ""
  46. P3target = ""
  47. P3ready = false
  48.  
  49. NPCHP = 1000 -- / 1000 * Enemy Tier
  50. NPCMP = 1000 -- / 1000 * Enemy Tier
  51. NPCHPpots = 3
  52. NPCMPpots = 3
  53. NPCbombs = 3
  54. NPCstatus = "   "
  55. NPCtier = 1
  56. NPCshielded = 0
  57. NPCselected = ""
  58. NPCname = "Ponky"
  59. NPCdrawA =  "      'v'      "
  60. NPCdrawB =  "      <|>      "
  61. NPCdrawC =  "      / \\      "
  62.  
  63. -- ** NPC AI VARIABLES **
  64. NPCtarget = "P1" -- All / P1 / P2 / P3, determines who the NPC bullies.
  65. NPCAggressiveness = 1 -- 1-10, determines how much the NPC will bully, and how many bombs he will use.
  66. NPCDefensiveness = 4 -- 1-10, determines how worried the NPC is over his HP.
  67. NPCAccuracy = 5 -- 1-10, determines which attack (ACCURATE / BALANCED / STRONG) he's more likely to use.
  68.  
  69. turn = "P1" -- Determines status of the game.
  70.             -- INGAME LOOP: Input > P1 > P2 > P3 > NPC > Status
  71.             -- OUT OF GAME: Coin, Lose, Win, FullWin
  72.             -- Input        - Waiting for all players to finish making their move
  73.             -- P1 / P2 / P3 - Players move in this order once moves decided
  74.             -- NPC          - NPC then moves after the players
  75.             -- Status       - Then things like poison, fire, etc happen
  76.             -- Coin         - Machine waits for insertion of coins.
  77.             -- Lose         - Machine plays the "losing" sequence, when all players have died
  78.             -- Win          - Machine plays the "winning" sequence, when any NPC is defeated
  79.             -- FullWin      - Machine plays a special "winning" sequence for beating the Final Boss.
  80.  
  81. -- Monitor, Modifiable Variables and Redstone Sides - YOU CAN ALTER THESE
  82.  
  83. monside = "front"         -- Side of the 2 x 3 Monitor. [Has to be 2x3!]
  84. detectside = "back"       -- Redstone side to detect button input.
  85. stopperside = "bottom"    -- Redstone side to stop the Filter accepting Credits.
  86.  
  87. creditspercoin = 1        -- How many credits per coin inserted?
  88.  
  89. -- Draw Designs and Strings - YOU CAN ALTER THESE
  90.  
  91. drawP1Anorm = ".'=  "
  92. drawP1Bnorm = "/|\\  "
  93. drawP1Cnorm = "/ \\  "
  94. drawP1Ahurt = "     "
  95. drawP1Bhurt = "  _'="
  96. drawP1Churt = "_/ | "
  97. drawP1Adead = "     "
  98. drawP1Bdead = "     "
  99. drawP1Cdead = "___-="
  100. drawP1Aitem = "\\'=  "
  101. drawP1Bitem = " |   "
  102. drawP1Citem = "/ \  "
  103. drawP1Aattack = ".'/ )"
  104. drawP1Battack = "/|   "
  105. drawP1Cattack = "/ \\  "
  106.  
  107. drawP2Anorm = "dOb  "
  108. drawP2Bnorm = "/|\\  "
  109. drawP2Cnorm = "/ \\  "
  110. drawP2Ahurt = "     "
  111. drawP2Bhurt = "  dOb "
  112. drawP2Churt = "_/ \\ "
  113. drawP2Adead = "     "
  114. drawP2Bdead = "     "
  115. drawP2Cdead = "__dOb"
  116. drawP2Aitem = "\Ob  "
  117. drawP2Bitem = " |    "
  118. drawP2Citem = "/ \\  "
  119. drawP2Aattack = "dO/ )"
  120. drawP2Battack = "/|   "
  121. drawP2Cattack = "/ \\  "
  122.  
  123. drawP3Anorm = "~O   "
  124. drawP3Bnorm = "/|\\  "
  125. drawP3Cnorm = "/ \\  "
  126. drawP3Ahurt = "     "
  127. drawP3Bhurt = "  ~O "
  128. drawP3Churt = "_/ | "
  129. drawP3Adead = "     "
  130. drawP3Bdead = "     "
  131. drawP3Cdead = "___~O"
  132. drawP3Aitem = "\\O/  "
  133. drawP3Bitem = " |   "
  134. drawP3Citem = "/ \  "
  135. drawP3Aattack = "~O/ )"
  136. drawP3Battack = "/|   "
  137. drawP3Cattack = "/ \\  "
  138.  
  139. drawE1A =  "      'v'      "
  140. drawE1B =  "      <|>      "
  141. drawE1C =  "      / \\      "
  142. drawE2A =  "      | Õ      "
  143. drawE2B =  "      |<K      "
  144. drawE2C =  "      | |\\     "
  145. drawE3A =  "       o       "
  146. drawE3B =  "      /Z\\      "
  147. drawE3C =  "      / \\      "
  148. drawE4A =  "  ~0    _ _ _  "
  149. drawE4B =  "  /Y\\  |_|_|_| "
  150. drawE4C =  "  / \\  |_|_|_| "
  151. drawE5A =  "  (\")          "
  152. drawE5B =  "  /|\\  =(o)__  "
  153. drawE5C =  "  / \\   (_~_/  "
  154. drawE6A =  "     s/        "
  155. drawE6B =  "    <|         "
  156. drawE6C =  "    / >        "
  157. drawE7A =  "   o/          "
  158. drawE7B =  "  /A           "
  159. drawE7C =  "  / \\          "
  160. drawE8A =  "     {'~       "
  161. drawE8B =  "     _)\\       "
  162. drawE8C =  "    /[][][]    "
  163. drawE9A =  "       @       "
  164. drawE9B =  "      /|\\      "
  165. drawE9C =  "      / \\      "
  166. drawE10A = "    ó          "
  167. drawE10B = "   /|\\    ..   "
  168. drawE10C = "   / \\    ||   "
  169.  
  170. stringE1  = "Ponky"
  171. stringE2  = "kelleroid"
  172. stringE3  = "Zeus guy"
  173. stringE4  = "theBoxMaster"
  174. stringE5  = "Cfive and his duck"
  175. stringE6  = "sepehrnoor"
  176. stringE7  = "Gameinsky"
  177. stringE8  = "Flup"
  178. stringE9  = "ddgc"
  179. stringE10 = "GeckoJSC and Pizoo"
  180.  
  181. stringBG = " * * * * * * * * * * * * * * * * * * * * "
  182.  
  183. stringHUDATK =  "ATTACK    "
  184. stringHUDMGC =  "MAGIC     "
  185. stringHUDITM =  "ITEM      "
  186. stringHUDATK1 = "ACCURATE  "       -- 80-120 damage, 90% accuracy
  187. stringHUDATK2 = "BALANCE   "       -- 100-140 damage, 75% accuracy
  188. stringHUDATK3 = "STRONG    "       -- 120-160 damage, 60% accuracy
  189. stringHUDMGC1 = "SHIELD    "       -- Halves damage taken for the turn. 80% accuracy
  190. stringHUDMGC2 = "ELEMENT   "       -- Inflicts a random debuff on the opponent. See Status Problems below. 60% accuracy
  191. stringHUDMGC3 = "CURE      "       -- Removes debuffs off teammates [Choose allied target] 80% accuracy
  192. stringHUDITM1 = "HP POT    "       -- [Max 9] Restores 60-100% HP. [Choose allied target] Always works
  193. stringHUDITM2 = "MP POT    "       -- [Max 9] Restores 50-100% MP. [Choose allied target] Always works
  194. stringHUDITM3 = "BOMB      "       -- [Max 9] Attacks for 200-400 damage. 90% accuracy
  195.  
  196. -- Additional Comments - YOU CAN ALTER THESE, but I don't see why you'd want to
  197.  
  198. --[[
  199.  
  200. When an enemy is defeated, each player replenishes:
  201.  > 20-40% HP / MP
  202.  > Item restock chance: 40% Nothing - 40% 1x - 20% 2x
  203.  > Slain players get revived at 30-50% HP
  204. When credits are inserted during battle:
  205.  > HP replenishes to full
  206.  > +2 of every item
  207. EVERYTHING in the game has chance behind it
  208. The goal is to defeat the 10th enemy!
  209.  
  210. Redstone Inputs:
  211. WHITE - Insert Coin
  212.  
  213. YELLOW    - P1 [A]
  214. ORANGE    - P1 [B]
  215. RED       - P1 [C]
  216.  
  217. LIME      - P2 [A]
  218. GREEN     - P2 [B]
  219. BROWN     - P2 [C]
  220.  
  221. LIGHTBLUE - P3 [A]
  222. BLUE      - P3 [B]
  223. CYAN      - P3 [C]
  224.  
  225. Status Problems:
  226. FRZ - Frost     - Player gets a 30% accuracy penalty. Attacks are reduced by 10-20 damage.
  227. PSN - Poison    - Player will take 20-40 damage each turn.
  228. SLP - Sleep     - Player cannot move, but restores 30-50 HP each turn.
  229. FIR - On Fire   - Player will take 30-60 damage each turn, but also damages 10-20 extra damage.
  230. PAR - Paralyzed - Player has a 40% chance to not move in a turn. Attacks gain or lose damage, from -20 - 20.
  231. --]]
  232.  
  233. -- *** THE CODE ***
  234.  
  235. -- *** Startup Code ***
  236.  
  237. mon = peripheral.wrap(monside)
  238. redstone.setOutput(stopperside,true)
  239. term.clear()
  240. print("Now playing: ASCIIrealm RPG!")
  241.  
  242. mon.setCursorPos(1,1)
  243. mon.write("      ______  ______  _____  _____  _____      ")
  244. mon.setCursorPos(1,2)
  245. mon.write("     / __  / / ____/ / ___/ /_  _/ /_  _/      ")
  246. mon.setCursorPos(1,3)
  247. mon.write("    / /_/ / / /___  / /      / /    / /        ")
  248. mon.setCursorPos(1,4)
  249. mon.write("   / __  / /___  / / /      / /    / /  ASCII  ")
  250. mon.setCursorPos(1,5)
  251. mon.write("  / / / / ____/ / / /___  _/ /_  _/ /_  Realm  ")
  252. mon.setCursorPos(1,6)
  253. mon.write(" /_/ /_/ /_____/ /_____/ /____/ /____/   RPG   ")
  254. mon.setCursorPos(1,7)
  255. mon.write("                                               ")
  256. mon.setCursorPos(1,8)
  257. mon.write(" A 3-player Battle RPG!                        ")
  258. mon.setCursorPos(1,9)
  259. mon.write("                                               ")
  260. mon.setCursorPos(1,10)
  261. mon.write("                                               ")
  262. mon.setCursorPos(1,11)
  263. mon.write(" Try to defeat               O~  dOb  ='.      ")
  264. mon.setCursorPos(1,12)
  265. mon.write("        the 10th enemy!     /|\\  /|\\  /!\\      ")
  266. mon.setCursorPos(1,13)
  267. mon.write("                            / \\  / \\  / \\      ")
  268. mon.setCursorPos(1,14)
  269. mon.write("                       ------------------------")
  270. mon.setCursorPos(1,15)
  271. mon.write("                      |^^^^^^^^^^^^^^^^^^^^^^^^")
  272. mon.setCursorPos(1,16)
  273. mon.write(" INSERT 3 MORE COINS  |                        ")
  274. mon.setCursorPos(1,17)
  275. mon.write("  TO BEGIN THE GAME   | Inspired by ASCIImator ")
  276.  
  277. turn = "Coin"
  278.  
  279. -- *** Functions ***
  280.  
  281. function startgame()
  282.   mon.setCursorPos(1,1)
  283.   mon.write(" HP["..drawBar(NPCHP, 1000 * (NPCtier/2), 20).."] ["..NPCname.."]                     ")
  284.   mon.setCursorPos(1,2)
  285.   mon.write("   ["..NPCstatus.."]                                      ")
  286.   mon.setCursorPos(1,3)
  287.   mon.write("                "..NPCdrawA.."                ")
  288.   mon.setCursorPos(1,4)
  289.   mon.write("                "..NPCdrawB.."                ")
  290.   mon.setCursorPos(1,5)
  291.   mon.write("                "..NPCdrawC.."                ")
  292.   mon.setCursorPos(1,6)
  293.   mon.write("                                               ")
  294.   mon.setCursorPos(1,7)
  295.   mon.write("  ["..stringBG.."]  ")
  296.   mon.setCursorPos(1,8)
  297.   mon.write("                                               ")
  298.   mon.setCursorPos(1,9)
  299.   mon.write("     "..drawP1Anorm.."            "..drawP2Anorm.."            "..drawP3Anorm.."     ")
  300.   mon.setCursorPos(1,10)
  301.   mon.write("     "..drawP1Bnorm.."            "..drawP2Bnorm.."            "..drawP3Bnorm.."     ")
  302.   mon.setCursorPos(1,11)
  303.   mon.write("     "..drawP1Cnorm.."            "..drawP2Cnorm.."            "..drawP3Cnorm.."     ")
  304.   mon.setCursorPos(1,12)
  305.   mon.write(" [P1]     ["..P1status.."]  [P2]     ["..P2status.."]  [P3]     ["..P3status.."] ")
  306.   mon.setCursorPos(1,13)
  307.   mon.write(" HP["..drawBar(P1HP, 1000, 10).."]  HP["..drawBar(P2HP, 1000, 10).."]  HP["..drawBar(P3HP, 1000, 10).."] ")
  308.   mon.setCursorPos(1,14)
  309.   mon.write(" MP["..drawBar(P1MP, 1000, 10).."]  MP["..drawBar(P2MP, 1000, 10).."]  MP["..drawBar(P3MP, 1000, 10).."] ")
  310.   mon.setCursorPos(1,15)
  311.   mon.write(" [A|"..stringHUDATK.."]  [A|"..stringHUDATK.."]  [A|"..stringHUDATK.."] ")
  312.   mon.setCursorPos(1,16)
  313.   mon.write(" [B|"..stringHUDMGC.."]  [B|"..stringHUDMGC.."]  [B|"..stringHUDMGC.."] ")
  314.   mon.setCursorPos(1,17)
  315.   mon.write(" [C|"..stringHUDITM.."]  [C|"..stringHUDITM.."]  [C|"..stringHUDITM.."] ")
  316.   print("The game has begun!")
  317.  
  318.   mon.setCursorPos(4,7)
  319.   mon.write(" What will P1, P2 and P3 do? ")  -- YOU CAN CHANGE THIS, but make sure to leave spaces on the side, and max 41 chars total, including the spaces.
  320. end
  321.  
  322. function round(val, decimal)     -- Round is from a library used for codes.
  323.   if (decimal) then
  324.     return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
  325.   else
  326.     return math.floor(val+0.5)
  327.   end
  328. end
  329.  
  330. function drawBar(curHP, maxHP, size)   -- Draw HP Bars function, for automatic drawing of health bars on the screen.
  331.   local str = ""                      -- The string that the HP bar will use.
  332.   local percent = curHP / maxHP       -- Will result in something that should look like: 0.786, aka 78.6%
  333.   local chips = round((size*2) * percent,0)                     -- How many chips appaear on the HP bar
  334.   if chips == 0 then
  335.     chips = 1
  336.   end
  337.   while chips > 0 do
  338.     if chips >= 2 then
  339.       str = str .. "="
  340.       chips = chips - 2
  341.       size = size - 1
  342.     else
  343.       str = str .. "-"
  344.       chips = chips - 1
  345.       size = size - 1
  346.     end
  347.   end
  348.   while size > 0 do
  349.     str = str .. " "
  350.     size = size - 1
  351.   end
  352.   return str
  353. end
  354.  
  355. function checkReady()    -- Checks if all players are ready when in the Input phase.
  356.   if P1ready == 1 and P2ready == 1 and P3ready == 1 then
  357.     turn = "Play"
  358.     turnStart()
  359.   elseif P1ready == 1 and P2ready == 1 and P3ready == 0 then
  360.     mon.setCursorPos(4,7)
  361.     mon.write(stringBG)
  362.     mon.setCursorPos(4,7)
  363.     mon.write(" What will P3 do? ")
  364.   elseif P1ready == 1 and P2ready == 0 and P3ready == 1 then
  365.     mon.setCursorPos(4,7)
  366.     mon.write(stringBG)
  367.     mon.setCursorPos(4,7)
  368.     mon.write(" What will P2 do? ")
  369.   elseif P1ready == 1 and P2ready == 0 and P3ready == 0 then
  370.     mon.setCursorPos(4,7)
  371.     mon.write(stringBG)
  372.     mon.setCursorPos(4,7)
  373.     mon.write(" What will P2 and P3 do? ")
  374.   elseif P1ready == 0 and P2ready == 1 and P3ready == 1 then
  375.     mon.setCursorPos(4,7)
  376.     mon.write(stringBG)
  377.     mon.setCursorPos(4,7)
  378.     mon.write(" What will P1 do? ")
  379.   elseif P1ready == 0 and P2ready == 1 and P3ready == 0 then
  380.     mon.setCursorPos(4,7)
  381.     mon.write(stringBG)
  382.     mon.setCursorPos(4,7)
  383.     mon.write(" What will P1 and P3 do? ")
  384.   elseif P1ready == 0 and P2ready == 0 and P3ready == 1 then
  385.     mon.setCursorPos(4,7)
  386.     mon.write(stringBG)
  387.     mon.setCursorPos(4,7)
  388.     mon.write(" What will P1 and P2 do? ")
  389.   elseif P1ready == 0 and P2ready == 0 and P3ready == 0 then
  390.     mon.setCursorPos(4,7)
  391.     mon.write(stringBG)
  392.     mon.setCursorPos(4,7)
  393.     mon.write(" What will P1, P2 and P3 do? ")
  394.   end
  395. end
  396.  
  397. function turnStart()    -- This bit probably controls most of the game.
  398.   if turn == "Play" then
  399.     local accuracy = 0
  400.     local damagemin = 0
  401.     local damagemax = 0
  402.     local damagebuff = 0
  403.     local skipturn = 0
  404.  
  405.     -- Execute PLAYER 1's attack first.
  406.     -- First figure out the "behind the scenes" stuff.
  407.  
  408.     if P1status ~= "KO " and NPCstatus ~= "KO " then
  409.       mon.setCursorPos(4,7)
  410.       mon.write(stringBG)
  411.       mon.setCursorPos(4,7)
  412.       mon.write(" PLAYER 1's turn... ")
  413.       sleep(2)
  414.     end
  415.  
  416.     if P1selected == "ATK 1" then        -- Accurate
  417.       accuracy = 90
  418.       damagemin = 80
  419.       damagemax = 120
  420.     elseif P1selected == "ATK 2" then    -- Balanced
  421.       accuracy = 75
  422.       damagemin = 100
  423.       damagemax = 140
  424.     elseif P1selected == "ATK 3" then    -- Strong
  425.       accuracy = 60
  426.       damagemin = 140
  427.       damagemax = 160
  428.     elseif P1selected == "MGC 1" then    -- Shield
  429.       accuracy = 80
  430.     elseif P1selected == "MGC 2" then    -- Element
  431.       accuracy = 60
  432.     elseif P1selected == "MGC 3" then    -- Cure
  433.       accuracy = 80
  434.     elseif P1selected == "ITM 1" then    -- HP Potion
  435.       accuracy = 100
  436.       damagemin = 600
  437.       damagemax = 1000
  438.     elseif P1selected == "ITM 2" then    -- MP Potion
  439.       accuracy = 100
  440.       damagemin = 500
  441.       damagemax = 1000
  442.     elseif P1selected == "ITM 3" then    -- Bomb
  443.       accuracy = 80
  444.       damagemin = 200
  445.       damagemax = 400
  446.     end
  447.     if P1status == "FRZ" then  -- Statuses: FRZ, PSN, SLP, FIR, PAR
  448.       accuracy = accuracy - 10
  449.       damagebuff = math.random(-20,-10)
  450.       damagemin = damagemin + damagebuff
  451.       damagemax = damagemax + damagebuff
  452.     elseif P1status == "FIR" then
  453.       damagebuff = math.random(10,20)
  454.       damagemin = damagemin + damagebuff
  455.       damagemax = damagemax + damagebuff
  456.     elseif P1status == "PAR" then
  457.       damagebuff = math.random(-20, 20)
  458.       damagemin = damagemin + damagebuff
  459.       damagemax = damagemax + damagebuff
  460.     end
  461.  
  462.     -- Then make the player execute his attack.
  463.     if P1status == "PAR" then
  464.       local freezetime = math.random(1,10)
  465.       if freezetime <= 4 then
  466.         mon.setCursorPos(4,7)
  467.         mon.write(stringBG)
  468.         mon.setCursorPos(4,7)
  469.         mon.write(" PLAYER 1 is paralyzed and cannot move! ")
  470.         sleep(2)
  471.         skipturn = 1
  472.       end
  473.     elseif P1status == "SLP" then
  474.       skipturn = 1
  475.     end
  476.     if P1HP <= 0 then
  477.       skipturn = 1
  478.       mon.setCursorPos(4,7)
  479.       mon.write(stringBG)
  480.       mon.setCursorPos(4,7)
  481.       mon.write(" PLAYER 1 is slain and cannot move! ")
  482.     end
  483.     if NPCstatus == "KO " then
  484.       skipturn = 1
  485.     end
  486.  
  487.     if skipturn == 0 then
  488.       local damage = math.random(damagemin,damagemax)
  489.       local hit = math.random(1,100)
  490.       if P1selected == "ATK 1" or P1selected == "ATK 2" or P1selected == "ATK 3" then
  491.         mon.setCursorPos(4,7)
  492.         mon.write(stringBG)
  493.         mon.setCursorPos(4,7)
  494.         mon.write(" PLAYER 1 attacks! ")
  495.         sleep(2)
  496.         if hit <= accuracy then
  497.           if NPCshielded > 0 then
  498.             damage = damage / 2
  499.           end
  500.           mon.setCursorPos(4,7)
  501.           mon.write(stringBG)
  502.           mon.setCursorPos(4,7)
  503.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  504.           NPCHP = NPCHP - damage
  505.           drawScreen()
  506.           sleep(2)
  507.           checkDeath("NPC")
  508.         else
  509.           mon.setCursorPos(4,7)
  510.           mon.write(stringBG)
  511.           mon.setCursorPos(4,7)
  512.           mon.write(" The attack missed! ")
  513.           sleep(2)
  514.         end
  515.       elseif P1selected == "MGC 1" then
  516.         mon.setCursorPos(4,7)
  517.         mon.write(stringBG)
  518.         mon.setCursorPos(4,7)
  519.         mon.write(" PLAYER 1 cast SHIELD! ")
  520.         P1MP = P1MP - MGC1cost
  521.         drawScreen()
  522.         sleep(2)
  523.         if hit <= accuracy then
  524.           if P1target == "P1" then
  525.             P1shielded = P1shielded + 2
  526.             mon.setCursorPos(4,7)
  527.             mon.write(stringBG)
  528.             mon.setCursorPos(4,7)
  529.             mon.write(" PLAYER 1 has been protected! ")
  530.             sleep(2)
  531.           elseif P1target == "P2" then
  532.             P2shielded = P2shielded + 2
  533.             mon.setCursorPos(4,7)
  534.             mon.write(stringBG)
  535.             mon.setCursorPos(4,7)
  536.             mon.write(" PLAYER 2 has been protected! ")
  537.             sleep(2)
  538.           elseif P1target == "P3" then
  539.             P3shielded = P3shielded + 2
  540.             mon.setCursorPos(4,7)
  541.             mon.write(stringBG)
  542.             mon.setCursorPos(4,7)
  543.             mon.write(" PLAYER 3 has been protected! ")
  544.             sleep(2)
  545.           else
  546.             mon.setCursorPos(4,7)
  547.             mon.write(stringBG)
  548.             mon.setCursorPos(4,7)
  549.             mon.write(" ERROR: No target specified ")
  550.             sleep(2)
  551.           end
  552.         else
  553.           mon.setCursorPos(4,7)
  554.           mon.write(stringBG)
  555.           mon.setCursorPos(4,7)
  556.           mon.write(" The spell failed! ")
  557.           sleep(2)
  558.         end
  559.       elseif P1selected == "MGC 2" then
  560.         mon.setCursorPos(4,7)
  561.         mon.write(stringBG)
  562.         mon.setCursorPos(4,7)
  563.         mon.write(" PLAYER 1 cast ELEMENT! ")
  564.         P1MP = P1MP - MGC2cost
  565.         drawScreen()
  566.         sleep(2)
  567.         if hit <= accuracy then
  568.           local element = math.random(1,10)
  569.           if element <= 3 then
  570.             NPCstatus = "PSN"
  571.             mon.setCursorPos(4,7)
  572.             mon.write(stringBG)
  573.             mon.setCursorPos(4,7)
  574.             mon.write(" "..NPCname.." got poisoned! ")
  575.             drawScreen()
  576.             sleep(2)
  577.           elseif element <= 5 then
  578.             NPCstatus = "FIR"
  579.             mon.setCursorPos(4,7)
  580.             mon.write(stringBG)
  581.             mon.setCursorPos(4,7)
  582.             mon.write(" "..NPCname.." was set aflame! ")
  583.             drawScreen()
  584.             sleep(2)
  585.           elseif element <= 7 then
  586.             NPCstatus = "PAR"
  587.             mon.setCursorPos(4,7)
  588.             mon.write(stringBG)
  589.             mon.setCursorPos(4,7)
  590.             mon.write(" "..NPCname.." got paralyzed! ")
  591.             drawScreen()
  592.             sleep(2)
  593.           elseif element <= 9 then
  594.             NPCstatus = "FRZ"
  595.             mon.setCursorPos(4,7)
  596.             mon.write(stringBG)
  597.             mon.setCursorPos(4,7)
  598.             mon.write(" "..NPCname.." got frozen! ")
  599.             drawScreen()
  600.             sleep(2)
  601.           else
  602.             NPCstatus = "SLP"
  603.             mon.setCursorPos(4,7)
  604.             mon.write(stringBG)
  605.             mon.setCursorPos(4,7)
  606.             mon.write(" "..NPCname.." fell asleep! ")
  607.             drawScreen()
  608.             sleep(2)
  609.           end
  610.         else
  611.           mon.setCursorPos(4,7)
  612.           mon.write(stringBG)
  613.           mon.setCursorPos(4,7)
  614.           mon.write(" The spell failed! ")
  615.           sleep(2)
  616.         end
  617.       elseif P1selected == "MGC 3" then
  618.         mon.setCursorPos(4,7)
  619.         mon.write(stringBG)
  620.         mon.setCursorPos(4,7)
  621.         mon.write(" PLAYER 1 cast CURE! ")
  622.         P1MP = P1MP - MGC3cost
  623.         drawScreen()
  624.         sleep(2)
  625.         if hit <= accuracy then
  626.           if P1target == "P1" then
  627.             P1status = "   "
  628.             mon.setCursorPos(4,7)
  629.             mon.write(stringBG)
  630.             mon.setCursorPos(4,7)
  631.             mon.write(" PLAYER 1 has been cured. ")
  632.             drawScreen()
  633.             sleep(2)
  634.             checkDeath("P1")
  635.           elseif P1target == "P2" then
  636.             if P2status == "KO " then
  637.               mon.setCursorPos(4,7)
  638.               mon.write(stringBG)
  639.               mon.setCursorPos(4,7)
  640.               mon.write(" PLAYER 2 has been revived! ")
  641.               P2HP = math.random(100,400)
  642.             else
  643.               mon.setCursorPos(4,7)
  644.               mon.write(stringBG)
  645.               mon.setCursorPos(4,7)
  646.               mon.write(" PLAYER 2 has been cured. ")
  647.             end
  648.             P2status = "   "
  649.             drawScreen()
  650.             sleep(2)
  651.             checkDeath("P2")
  652.           elseif P1target == "P3" then
  653.              if P3status == "KO " then
  654.               mon.setCursorPos(4,7)
  655.               mon.write(stringBG)
  656.               mon.setCursorPos(4,7)
  657.               mon.write(" PLAYER 3 has been revived! ")
  658.               P3HP = math.random(100,400)
  659.             else
  660.               mon.setCursorPos(4,7)
  661.               mon.write(stringBG)
  662.               mon.setCursorPos(4,7)
  663.               mon.write(" PLAYER 3 has been cured. ")
  664.             end
  665.             P3status = "   "
  666.             drawScreen()
  667.             sleep(2)
  668.             checkDeath("P3")
  669.           else
  670.             mon.setCursorPos(4,7)
  671.             mon.write(stringBG)
  672.             mon.setCursorPos(4,7)
  673.             mon.write(" ERROR: No target specified ")
  674.             sleep(2)
  675.           end
  676.         else
  677.           mon.setCursorPos(4,7)
  678.           mon.write(stringBG)
  679.           mon.setCursorPos(4,7)
  680.           mon.write(" The spell failed! ")
  681.           sleep(2)
  682.         end
  683.       elseif P1selected == "ITM 1" then
  684.         mon.setCursorPos(4,7)
  685.         mon.write(stringBG)
  686.         mon.setCursorPos(4,7)
  687.         mon.write(" PLAYER 1 used a HP Potion! ")
  688.         sleep(2)
  689.         P1HPpots = P1HPpots - 1
  690.         if P1target == "P1" then
  691.           if damage > (1000 - P1HP) then
  692.             damage = 1000 - P1HP
  693.           end
  694.           P1HP = P1HP + damage
  695.           mon.setCursorPos(4,7)
  696.           mon.write(stringBG)
  697.           mon.setCursorPos(4,7)
  698.           mon.write(" PLAYER 1 regained "..damage.." HP! ")
  699.           drawScreen()
  700.           sleep(2)
  701.           checkDeath("P1")
  702.         elseif P1target == "P2" then
  703.           if damage > (1000 - P2HP) then
  704.             damage = 1000 - P2HP
  705.           end
  706.           P2HP = P2HP + damage
  707.           if P2status == "KO " then
  708.             mon.setCursorPos(4,7)
  709.             mon.write(stringBG)
  710.             mon.setCursorPos(4,7)
  711.             mon.write(" PLAYER 2 has been revived! ")
  712.             P2status = "   "
  713.             drawScreen()
  714.             sleep(2)
  715.             checkDeath("P2")
  716.           end
  717.           mon.setCursorPos(4,7)
  718.           mon.write(stringBG)
  719.           mon.setCursorPos(4,7)
  720.           mon.write(" PLAYER 2 regained "..damage.." HP! ")
  721.           drawScreen()
  722.           sleep(2)
  723.           checkDeath("P2")
  724.         elseif P1target == "P3" then
  725.           if damage > (1000 - P3HP) then
  726.             damage = 1000 - P3HP
  727.           end
  728.           P3HP = P3HP + damage
  729.           if P3status == "KO " then
  730.             mon.setCursorPos(4,7)
  731.             mon.write(stringBG)
  732.             mon.setCursorPos(4,7)
  733.             mon.write(" PLAYER 3 has been revived! ")
  734.             P3status = "   "
  735.             drawScreen()
  736.             sleep(2)
  737.             checkDeath("P3")
  738.           end
  739.           mon.setCursorPos(4,7)
  740.           mon.write(stringBG)
  741.           mon.setCursorPos(4,7)
  742.           mon.write(" PLAYER 3 regained "..damage.." HP! ")
  743.           drawScreen()
  744.           sleep(2)
  745.           checkDeath("P3")
  746.         else
  747.           mon.setCursorPos(4,7)
  748.           mon.write(stringBG)
  749.           mon.setCursorPos(4,7)
  750.           mon.write(" ERROR: No target specified ")
  751.           sleep(2)
  752.         end
  753.       elseif P1selected == "ITM 2" then
  754.         mon.setCursorPos(4,7)
  755.         mon.write(stringBG)
  756.         mon.setCursorPos(4,7)
  757.         mon.write(" PLAYER 1 used an MP Potion! ")
  758.         sleep(2)
  759.         P1MPpots = P1MPpots - 1
  760.         if P1target == "P1" then
  761.           if damage > (1000 - P1MP) then
  762.             damage = 1000 - P1MP
  763.           end
  764.           P1MP = P1MP + damage
  765.           mon.setCursorPos(4,7)
  766.           mon.write(stringBG)
  767.           mon.setCursorPos(4,7)
  768.           mon.write(" PLAYER 1 regained "..damage.." MP! ")
  769.           drawScreen()
  770.           sleep(2)
  771.         elseif P1target == "P2" then
  772.           if damage > (1000 - P2MP) then
  773.             damage = 1000 - P2MP
  774.           end
  775.           P2MP = P2MP + damage
  776.           mon.setCursorPos(4,7)
  777.           mon.write(stringBG)
  778.           mon.setCursorPos(4,7)
  779.           mon.write(" PLAYER 2 regained "..damage.." MP! ")
  780.           drawScreen()
  781.           sleep(2)
  782.         elseif P1target == "P3" then
  783.           if damage > (1000 - P3MP) then
  784.             damage = 1000 - P3MP
  785.           end
  786.           P3MP = P3MP + damage
  787.           mon.setCursorPos(4,7)
  788.           mon.write(stringBG)
  789.           mon.setCursorPos(4,7)
  790.           mon.write(" PLAYER 3 regained "..damage.." MP! ")
  791.           drawScreen()
  792.           sleep(2)
  793.         else
  794.           mon.setCursorPos(4,7)
  795.           mon.write(stringBG)
  796.           mon.setCursorPos(4,7)
  797.           mon.write(" ERROR: No target specified ")
  798.           sleep(2)
  799.         end
  800.       elseif P1selected == "ITM 3" then
  801.         mon.setCursorPos(4,7)
  802.         mon.write(stringBG)
  803.         mon.setCursorPos(4,7)
  804.         mon.write(" PLAYER 1 throws a bomb! ")
  805.         P1bombs = P1bombs - 1
  806.         sleep(2)
  807.         if hit <= accuracy then
  808.           if NPCshielded > 0 then
  809.             damage = damage / 2
  810.           end
  811.           mon.setCursorPos(4,7)
  812.           mon.write(stringBG)
  813.           mon.setCursorPos(4,7)
  814.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  815.           NPCHP = NPCHP - damage
  816.           drawScreen()
  817.           sleep(2)
  818.           checkDeath("NPC")
  819.         else
  820.           mon.setCursorPos(4,7)
  821.           mon.write(stringBG)
  822.           mon.setCursorPos(4,7)
  823.           mon.write(" The bomb missed! ")
  824.           sleep(2)
  825.         end
  826.       end
  827.     end
  828.  
  829.     -- Execute PLAYER 2's attack next
  830.     -- First figure out the "behind the scenes" stuff.
  831.     skipturn = 0
  832.  
  833.     if P2status ~= "KO " and NPCstatus ~= "KO " then
  834.       mon.setCursorPos(4,7)
  835.       mon.write(stringBG)
  836.       mon.setCursorPos(4,7)
  837.       mon.write(" PLAYER 2's turn... ")
  838.       sleep(2)
  839.     end
  840.  
  841.     if P2selected == "ATK 1" then        -- Accurate
  842.       accuracy = 90
  843.       damagemin = 80
  844.       damagemax = 120
  845.     elseif P2selected == "ATK 2" then    -- Balanced
  846.       accuracy = 75
  847.       damagemin = 100
  848.       damagemax = 140
  849.     elseif P2selected == "ATK 3" then    -- Strong
  850.       accuracy = 60
  851.       damagemin = 140
  852.       damagemax = 160
  853.     elseif P2selected == "MGC 1" then    -- Shield
  854.       accuracy = 80
  855.     elseif P2selected == "MGC 2" then    -- Element
  856.       accuracy = 60
  857.     elseif P2selected == "MGC 3" then    -- Cure
  858.       accuracy = 80
  859.     elseif P2selected == "ITM 1" then    -- HP Potion
  860.       accuracy = 100
  861.       damagemin = 600
  862.       damagemax = 1000
  863.     elseif P2selected == "ITM 2" then    -- MP Potion
  864.       accuracy = 100
  865.       damagemin = 500
  866.       damagemax = 1000
  867.     elseif P2selected == "ITM 3" then    -- Bomb
  868.       accuracy = 80
  869.       damagemin = 200
  870.       damagemax = 400
  871.     end
  872.     if P2status == "FRZ" then  -- Statuses: FRZ, PSN, SLP, FIR, PAR
  873.       accuracy = accuracy - 10
  874.       damagebuff = math.random(-20,-10)
  875.       damagemin = damagemin + damagebuff
  876.       damagemax = damagemax + damagebuff
  877.     elseif P2status == "FIR" then
  878.       damagebuff = math.random(10,20)
  879.       damagemin = damagemin + damagebuff
  880.       damagemax = damagemax + damagebuff
  881.     elseif P2status == "PAR" then
  882.       damagebuff = math.random(-20, 20)
  883.       damagemin = damagemin + damagebuff
  884.       damagemax = damagemax + damagebuff
  885.     end
  886.  
  887.     -- Then make the player execute his attack.
  888.     if P2status == "PAR" then
  889.       local freezetime = math.random(1,10)
  890.       if freezetime <= 4 then
  891.         mon.setCursorPos(4,7)
  892.         mon.write(stringBG)
  893.         mon.setCursorPos(4,7)
  894.         mon.write(" PLAYER 2 is paralyzed and cannot move! ")
  895.         sleep(2)
  896.         skipturn = 1
  897.       end
  898.     elseif P2status == "SLP" then
  899.       skipturn = 1
  900.     end
  901.     if P2HP <= 0 then
  902.       skipturn = 1
  903.       mon.setCursorPos(4,7)
  904.       mon.write(stringBG)
  905.       mon.setCursorPos(4,7)
  906.       mon.write(" PLAYER 2 is slain and cannot move! ")
  907.     end
  908.     if NPCstatus == "KO " then
  909.       skipturn = 1
  910.     end
  911.  
  912.     if skipturn == 0 then
  913.       local damage = math.random(damagemin,damagemax)
  914.       local hit = math.random(1,100)
  915.       if P2selected == "ATK 1" or P2selected == "ATK 2" or P2selected == "ATK 3" then
  916.         mon.setCursorPos(4,7)
  917.         mon.write(stringBG)
  918.         mon.setCursorPos(4,7)
  919.         mon.write(" PLAYER 2 attacks! ")
  920.         sleep(2)
  921.         if hit <= accuracy then
  922.           if NPCshielded > 0 then
  923.             damage = damage / 2
  924.           end
  925.           mon.setCursorPos(4,7)
  926.           mon.write(stringBG)
  927.           mon.setCursorPos(4,7)
  928.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  929.           NPCHP = NPCHP - damage
  930.           drawScreen()
  931.           sleep(2)
  932.           checkDeath("NPC")
  933.         else
  934.           mon.setCursorPos(4,7)
  935.           mon.write(stringBG)
  936.           mon.setCursorPos(4,7)
  937.           mon.write(" The attack missed! ")
  938.           sleep(2)
  939.         end
  940.       elseif P2selected == "MGC 1" then
  941.         mon.setCursorPos(4,7)
  942.         mon.write(stringBG)
  943.         mon.setCursorPos(4,7)
  944.         mon.write(" PLAYER 2 cast SHIELD! ")
  945.         P2MP = P2MP - MGC1cost
  946.         drawScreen()
  947.         sleep(2)
  948.         if hit <= accuracy then
  949.           if P2target == "P1" then
  950.             P1shielded = P1shielded + 2
  951.             mon.setCursorPos(4,7)
  952.             mon.write(stringBG)
  953.             mon.setCursorPos(4,7)
  954.             mon.write(" PLAYER 1 has been protected! ")
  955.             sleep(2)
  956.           elseif P2target == "P2" then
  957.             P2shielded = P2shielded + 2
  958.             mon.setCursorPos(4,7)
  959.             mon.write(stringBG)
  960.             mon.setCursorPos(4,7)
  961.             mon.write(" PLAYER 2 has been protected! ")
  962.             sleep(2)
  963.           elseif P2target == "P3" then
  964.             P3shielded = P3shielded + 2
  965.             mon.setCursorPos(4,7)
  966.             mon.write(stringBG)
  967.             mon.setCursorPos(4,7)
  968.             mon.write(" PLAYER 3 has been protected! ")
  969.             sleep(2)
  970.           else
  971.             mon.setCursorPos(4,7)
  972.             mon.write(stringBG)
  973.             mon.setCursorPos(4,7)
  974.             mon.write(" ERROR: No target specified ")
  975.             sleep(2)
  976.           end
  977.         else
  978.           mon.setCursorPos(4,7)
  979.           mon.write(stringBG)
  980.           mon.setCursorPos(4,7)
  981.           mon.write(" The spell failed! ")
  982.           sleep(2)
  983.         end
  984.       elseif P2selected == "MGC 2" then
  985.         mon.setCursorPos(4,7)
  986.         mon.write(stringBG)
  987.         mon.setCursorPos(4,7)
  988.         mon.write(" PLAYER 2 cast ELEMENT! ")
  989.         P2MP = P2MP - MGC2cost
  990.         drawScreen()
  991.         sleep(2)
  992.         if hit <= accuracy then
  993.           local element = math.random(1,10)
  994.           if element <= 3 then
  995.             NPCstatus = "PSN"
  996.             mon.setCursorPos(4,7)
  997.             mon.write(stringBG)
  998.             mon.setCursorPos(4,7)
  999.             mon.write(" "..NPCname.." got poisoned! ")
  1000.             drawScreen()
  1001.             sleep(2)
  1002.           elseif element <= 5 then
  1003.             NPCstatus = "FIR"
  1004.             mon.setCursorPos(4,7)
  1005.             mon.write(stringBG)
  1006.             mon.setCursorPos(4,7)
  1007.             mon.write(" "..NPCname.." was set aflame! ")
  1008.             drawScreen()
  1009.             sleep(2)
  1010.           elseif element <= 7 then
  1011.             NPCstatus = "PAR"
  1012.             mon.setCursorPos(4,7)
  1013.             mon.write(stringBG)
  1014.             mon.setCursorPos(4,7)
  1015.             mon.write(" "..NPCname.." got paralyzed! ")
  1016.             drawScreen()
  1017.             sleep(2)
  1018.           elseif element <= 9 then
  1019.             NPCstatus = "FRZ"
  1020.             mon.setCursorPos(4,7)
  1021.             mon.write(stringBG)
  1022.             mon.setCursorPos(4,7)
  1023.             mon.write(" "..NPCname.." got frozen! ")
  1024.             drawScreen()
  1025.             sleep(2)
  1026.           else
  1027.             NPCstatus = "SLP"
  1028.             mon.setCursorPos(4,7)
  1029.             mon.write(stringBG)
  1030.             mon.setCursorPos(4,7)
  1031.             mon.write(" "..NPCname.." fell asleep! ")
  1032.             drawScreen()
  1033.             sleep(2)
  1034.           end
  1035.         else
  1036.           mon.setCursorPos(4,7)
  1037.           mon.write(stringBG)
  1038.           mon.setCursorPos(4,7)
  1039.           mon.write(" The spell failed! ")
  1040.           sleep(2)
  1041.         end
  1042.       elseif P2selected == "MGC 3" then
  1043.         mon.setCursorPos(4,7)
  1044.         mon.write(stringBG)
  1045.         mon.setCursorPos(4,7)
  1046.         mon.write(" PLAYER 2 cast CURE! ")
  1047.         P2MP = P2MP - MGC3cost
  1048.         drawScreen()
  1049.         sleep(2)
  1050.         if hit <= accuracy then
  1051.           if P2target == "P1" then
  1052.             if P1status == "KO " then
  1053.               mon.setCursorPos(4,7)
  1054.               mon.write(stringBG)
  1055.               mon.setCursorPos(4,7)
  1056.               mon.write(" PLAYER 1 has been revived! ")
  1057.               P1HP = math.random(100,400)
  1058.             else
  1059.               mon.setCursorPos(4,7)
  1060.               mon.write(stringBG)
  1061.               mon.setCursorPos(4,7)
  1062.               mon.write(" PLAYER 1 has been cured. ")
  1063.             end
  1064.             P1status = "   "
  1065.             drawScreen()
  1066.             sleep(2)
  1067.             checkDeath("P1")
  1068.           elseif P2target == "P2" then
  1069.             P2status = "   "
  1070.             mon.setCursorPos(4,7)
  1071.             mon.write(stringBG)
  1072.             mon.setCursorPos(4,7)
  1073.             mon.write(" PLAYER 2 has been cured. ")
  1074.             drawScreen()
  1075.             sleep(2)
  1076.             checkDeath("P2")
  1077.           elseif P2target == "P3" then
  1078.             if P3status == "KO " then
  1079.               mon.setCursorPos(4,7)
  1080.               mon.write(stringBG)
  1081.               mon.setCursorPos(4,7)
  1082.               mon.write(" PLAYER 3 has been revived! ")
  1083.               P3HP = math.random(100,400)
  1084.             else
  1085.               mon.setCursorPos(4,7)
  1086.               mon.write(stringBG)
  1087.               mon.setCursorPos(4,7)
  1088.               mon.write(" PLAYER 3 has been cured. ")
  1089.             end
  1090.             P3status = "   "
  1091.             drawScreen()
  1092.             sleep(2)
  1093.             checkDeath("P3")
  1094.           else
  1095.             mon.setCursorPos(4,7)
  1096.             mon.write(stringBG)
  1097.             mon.setCursorPos(4,7)
  1098.             mon.write(" ERROR: No target specified ")
  1099.             sleep(2)
  1100.           end
  1101.         else
  1102.           mon.setCursorPos(4,7)
  1103.           mon.write(stringBG)
  1104.           mon.setCursorPos(4,7)
  1105.           mon.write(" The spell failed! ")
  1106.           sleep(2)
  1107.         end
  1108.       elseif P2selected == "ITM 1" then
  1109.         mon.setCursorPos(4,7)
  1110.         mon.write(stringBG)
  1111.         mon.setCursorPos(4,7)
  1112.         mon.write(" PLAYER 2 used a HP Potion! ")
  1113.         sleep(2)
  1114.         P2HPpots = P2HPpots - 1
  1115.         if P2target == "P1" then
  1116.           if damage > (1000 - P1HP) then
  1117.             damage = 1000 - P1HP
  1118.           end
  1119.           P1HP = P1HP + damage
  1120.           if P1status == "KO " then
  1121.             mon.setCursorPos(4,7)
  1122.             mon.write(stringBG)
  1123.             mon.setCursorPos(4,7)
  1124.             mon.write(" PLAYER 1 has been revived! ")
  1125.             P1status = "   "
  1126.             drawScreen()
  1127.             sleep(2)
  1128.             checkDeath("P1")
  1129.           end
  1130.           mon.setCursorPos(4,7)
  1131.           mon.write(stringBG)
  1132.           mon.setCursorPos(4,7)
  1133.           mon.write(" PLAYER 1 regained "..damage.." HP! ")
  1134.           drawScreen()
  1135.           sleep(2)
  1136.           checkDeath("P1")
  1137.         elseif P2target == "P2" then
  1138.           if damage > (1000 - P2HP) then
  1139.             damage = 1000 - P2HP
  1140.           end
  1141.           P2HP = P2HP + damage
  1142.           mon.setCursorPos(4,7)
  1143.           mon.write(stringBG)
  1144.           mon.setCursorPos(4,7)
  1145.           mon.write(" PLAYER 2 regained "..damage.." HP! ")
  1146.           drawScreen()
  1147.           sleep(2)
  1148.           checkDeath("P2")
  1149.         elseif P2target == "P3" then
  1150.           if damage > (1000 - P3HP) then
  1151.             damage = 1000 - P3HP
  1152.           end
  1153.           P3HP = P3HP + damage
  1154.           if P3status == "KO " then
  1155.             mon.setCursorPos(4,7)
  1156.             mon.write(stringBG)
  1157.             mon.setCursorPos(4,7)
  1158.             mon.write(" PLAYER 3 has been revived! ")
  1159.             P3status = "   "
  1160.             drawScreen()
  1161.             sleep(2)
  1162.             checkDeath("P3")
  1163.           end
  1164.           mon.setCursorPos(4,7)
  1165.           mon.write(stringBG)
  1166.           mon.setCursorPos(4,7)
  1167.           mon.write(" PLAYER 3 regained "..damage.." HP! ")
  1168.           drawScreen()
  1169.           sleep(2)
  1170.           checkDeath("P3")
  1171.         else
  1172.           mon.setCursorPos(4,7)
  1173.           mon.write(stringBG)
  1174.           mon.setCursorPos(4,7)
  1175.           mon.write(" ERROR: No target specified ")
  1176.           sleep(2)
  1177.         end
  1178.       elseif P2selected == "ITM 2" then
  1179.         mon.setCursorPos(4,7)
  1180.         mon.write(stringBG)
  1181.         mon.setCursorPos(4,7)
  1182.         mon.write(" PLAYER 2 used an MP Potion! ")
  1183.         sleep(2)
  1184.         P2MPpots = P2MPpots - 1
  1185.         if P2target == "P1" then
  1186.           if damage > (1000 - P1MP) then
  1187.             damage = 1000 - P1MP
  1188.           end
  1189.           P1MP = P1MP + damage
  1190.           mon.setCursorPos(4,7)
  1191.           mon.write(stringBG)
  1192.           mon.setCursorPos(4,7)
  1193.           mon.write(" PLAYER 1 regained "..damage.." MP! ")
  1194.           drawScreen()
  1195.           sleep(2)
  1196.         elseif P2target == "P2" then
  1197.           if damage > (1000 - P2MP) then
  1198.             damage = 1000 - P2MP
  1199.           end
  1200.           P2MP = P2MP + damage
  1201.           mon.setCursorPos(4,7)
  1202.           mon.write(stringBG)
  1203.           mon.setCursorPos(4,7)
  1204.           mon.write(" PLAYER 2 regained "..damage.." MP! ")
  1205.           drawScreen()
  1206.           sleep(2)
  1207.         elseif P2target == "P3" then
  1208.           if damage > (1000 - P3MP) then
  1209.             damage = 1000 - P3MP
  1210.           end
  1211.           P3MP = P3MP + damage
  1212.           mon.setCursorPos(4,7)
  1213.           mon.write(stringBG)
  1214.           mon.setCursorPos(4,7)
  1215.           mon.write(" PLAYER 3 regained "..damage.." MP! ")
  1216.           drawScreen()
  1217.           sleep(2)
  1218.         else
  1219.           mon.setCursorPos(4,7)
  1220.           mon.write(stringBG)
  1221.           mon.setCursorPos(4,7)
  1222.           mon.write(" ERROR: No target specified ")
  1223.           sleep(2)
  1224.         end
  1225.       elseif P2selected == "ITM 3" then
  1226.         mon.setCursorPos(4,7)
  1227.         mon.write(stringBG)
  1228.         mon.setCursorPos(4,7)
  1229.         mon.write(" PLAYER 2 throws a bomb! ")
  1230.         P2bombs = P2bombs - 1
  1231.         sleep(2)
  1232.         if hit <= accuracy then
  1233.           if NPCshielded > 0 then
  1234.             damage = damage / 2
  1235.           end
  1236.           mon.setCursorPos(4,7)
  1237.           mon.write(stringBG)
  1238.           mon.setCursorPos(4,7)
  1239.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  1240.           NPCHP = NPCHP - damage
  1241.           drawScreen()
  1242.           sleep(2)
  1243.           checkDeath("NPC")
  1244.         else
  1245.           mon.setCursorPos(4,7)
  1246.           mon.write(stringBG)
  1247.           mon.setCursorPos(4,7)
  1248.           mon.write(" The bomb missed! ")
  1249.           sleep(2)
  1250.         end
  1251.       end
  1252.     end
  1253.  
  1254.     -- Execute PLAYER 3's attack last.
  1255.     -- First figure out the "behind the scenes" stuff.
  1256.     skipturn = 0
  1257.  
  1258.     if P3status ~= "KO " and NPCstatus ~= "KO " then
  1259.       mon.setCursorPos(4,7)
  1260.       mon.write(stringBG)
  1261.       mon.setCursorPos(4,7)
  1262.       mon.write(" PLAYER 3's turn... ")
  1263.       sleep(2)
  1264.     end
  1265.  
  1266.     if P3selected == "ATK 1" then        -- Accurate
  1267.       accuracy = 90
  1268.       damagemin = 80
  1269.       damagemax = 120
  1270.     elseif P3selected == "ATK 2" then    -- Balanced
  1271.       accuracy = 75
  1272.       damagemin = 100
  1273.       damagemax = 140
  1274.     elseif P3selected == "ATK 3" then    -- Strong
  1275.       accuracy = 60
  1276.       damagemin = 140
  1277.       damagemax = 160
  1278.     elseif P3selected == "MGC 1" then    -- Shield
  1279.       accuracy = 80
  1280.     elseif P3selected == "MGC 2" then    -- Element
  1281.       accuracy = 60
  1282.     elseif P3selected == "MGC 3" then    -- Cure
  1283.       accuracy = 80
  1284.     elseif P3selected == "ITM 1" then    -- HP Potion
  1285.       accuracy = 100
  1286.       damagemin = 600
  1287.       damagemax = 1000
  1288.     elseif P3selected == "ITM 2" then    -- MP Potion
  1289.       accuracy = 100
  1290.       damagemin = 500
  1291.       damagemax = 1000
  1292.     elseif P3selected == "ITM 3" then    -- Bomb
  1293.       accuracy = 80
  1294.       damagemin = 200
  1295.       damagemax = 400
  1296.     end
  1297.     if P3status == "FRZ" then  -- Statuses: FRZ, PSN, SLP, FIR, PAR
  1298.       accuracy = accuracy - 10
  1299.       damagebuff = math.random(-20,-10)
  1300.       damagemin = damagemin + damagebuff
  1301.       damagemax = damagemax + damagebuff
  1302.     elseif P3status == "FIR" then
  1303.       damagebuff = math.random(10,20)
  1304.       damagemin = damagemin + damagebuff
  1305.       damagemax = damagemax + damagebuff
  1306.     elseif P3status == "PAR" then
  1307.       damagebuff = math.random(-20, 20)
  1308.       damagemin = damagemin + damagebuff
  1309.       damagemax = damagemax + damagebuff
  1310.     end
  1311.  
  1312.     -- Then make the player execute his attack.
  1313.     if P3status == "PAR" then
  1314.       local freezetime = math.random(1,10)
  1315.       if freezetime <= 4 then
  1316.         mon.setCursorPos(4,7)
  1317.         mon.write(stringBG)
  1318.         mon.setCursorPos(4,7)
  1319.         mon.write(" PLAYER 3 is paralyzed and cannot move! ")
  1320.         sleep(2)
  1321.         skipturn = 1
  1322.       end
  1323.     elseif P3status == "SLP" then
  1324.       skipturn = 1
  1325.     end
  1326.     if P3HP <= 0 then
  1327.       skipturn = 1
  1328.       mon.setCursorPos(4,7)
  1329.       mon.write(stringBG)
  1330.       mon.setCursorPos(4,7)
  1331.       mon.write(" PLAYER 3 is slain and cannot move! ")
  1332.     end
  1333.     if NPCstatus == "KO " then
  1334.       skipturn = 1
  1335.     end
  1336.  
  1337.     if skipturn == 0 then
  1338.       local damage = math.random(damagemin,damagemax)
  1339.       local hit = math.random(1,100)
  1340.       if P3selected == "ATK 1" or P3selected == "ATK 2" or P3selected == "ATK 3" then
  1341.         mon.setCursorPos(4,7)
  1342.         mon.write(stringBG)
  1343.         mon.setCursorPos(4,7)
  1344.         mon.write(" PLAYER 3 attacks! ")
  1345.         sleep(2)
  1346.         if hit <= accuracy then
  1347.           if NPCshielded > 0 then
  1348.             damage = damage / 2
  1349.           end
  1350.           mon.setCursorPos(4,7)
  1351.           mon.write(stringBG)
  1352.           mon.setCursorPos(4,7)
  1353.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  1354.           NPCHP = NPCHP - damage
  1355.           drawScreen()
  1356.           sleep(2)
  1357.           checkDeath("NPC")
  1358.         else
  1359.           mon.setCursorPos(4,7)
  1360.           mon.write(stringBG)
  1361.           mon.setCursorPos(4,7)
  1362.           mon.write(" The attack missed! ")
  1363.           sleep(2)
  1364.         end
  1365.       elseif P3selected == "MGC 1" then
  1366.         mon.setCursorPos(4,7)
  1367.         mon.write(stringBG)
  1368.         mon.setCursorPos(4,7)
  1369.         mon.write(" PLAYER 3 cast SHIELD! ")
  1370.         P3MP = P3MP - MGC1cost
  1371.         drawScreen()
  1372.         sleep(2)
  1373.         if hit <= accuracy then
  1374.           if P3target == "P1" then
  1375.             P1shielded = P1shielded + 2
  1376.             mon.setCursorPos(4,7)
  1377.             mon.write(stringBG)
  1378.             mon.setCursorPos(4,7)
  1379.             mon.write(" PLAYER 1 has been protected! ")
  1380.             sleep(2)
  1381.           elseif P3target == "P2" then
  1382.             P2shielded = P2shielded + 2
  1383.             mon.setCursorPos(4,7)
  1384.             mon.write(stringBG)
  1385.             mon.setCursorPos(4,7)
  1386.             mon.write(" PLAYER 2 has been protected! ")
  1387.             sleep(2)
  1388.           elseif P3target == "P3" then
  1389.             P3shielded = P3shielded + 2
  1390.             mon.setCursorPos(4,7)
  1391.             mon.write(stringBG)
  1392.             mon.setCursorPos(4,7)
  1393.             mon.write(" PLAYER 3 has been protected! ")
  1394.             sleep(2)
  1395.           else
  1396.             mon.setCursorPos(4,7)
  1397.             mon.write(stringBG)
  1398.             mon.setCursorPos(4,7)
  1399.             mon.write(" ERROR: No target specified ")
  1400.             sleep(2)
  1401.           end
  1402.         else
  1403.           mon.setCursorPos(4,7)
  1404.           mon.write(stringBG)
  1405.           mon.setCursorPos(4,7)
  1406.           mon.write(" The spell failed! ")
  1407.           sleep(2)
  1408.         end
  1409.       elseif P3selected == "MGC 2" then
  1410.         mon.setCursorPos(4,7)
  1411.         mon.write(stringBG)
  1412.         mon.setCursorPos(4,7)
  1413.         mon.write(" PLAYER 3 cast ELEMENT! ")
  1414.         P3MP = P3MP - MGC2cost
  1415.         drawScreen()
  1416.         sleep(2)
  1417.         if hit <= accuracy then
  1418.           local element = math.random(1,10)
  1419.           if element <= 3 then
  1420.             NPCstatus = "PSN"
  1421.             mon.setCursorPos(4,7)
  1422.             mon.write(stringBG)
  1423.             mon.setCursorPos(4,7)
  1424.             mon.write(" "..NPCname.." got poisoned! ")
  1425.             drawScreen()
  1426.             sleep(2)
  1427.           elseif element <= 5 then
  1428.             NPCstatus = "FIR"
  1429.             mon.setCursorPos(4,7)
  1430.             mon.write(stringBG)
  1431.             mon.setCursorPos(4,7)
  1432.             mon.write(" "..NPCname.." was set aflame! ")
  1433.             drawScreen()
  1434.           sleep(2)
  1435.           elseif element <= 7 then
  1436.             NPCstatus = "PAR"
  1437.             mon.setCursorPos(4,7)
  1438.             mon.write(stringBG)
  1439.             mon.setCursorPos(4,7)
  1440.             mon.write(" "..NPCname.." got paralyzed! ")
  1441.             drawScreen()
  1442.             sleep(2)
  1443.           elseif element <= 9 then
  1444.             NPCstatus = "FRZ"
  1445.             mon.setCursorPos(4,7)
  1446.             mon.write(stringBG)
  1447.             mon.setCursorPos(4,7)
  1448.             mon.write(" "..NPCname.." got frozen! ")
  1449.             drawScreen()
  1450.             sleep(2)
  1451.           else
  1452.             NPCstatus = "SLP"
  1453.             mon.setCursorPos(4,7)
  1454.             mon.write(stringBG)
  1455.             mon.setCursorPos(4,7)
  1456.             mon.write(" "..NPCname.." fell asleep! ")
  1457.             drawScreen()
  1458.             sleep(2)
  1459.           end
  1460.         else
  1461.           mon.setCursorPos(4,7)
  1462.           mon.write(stringBG)
  1463.           mon.setCursorPos(4,7)
  1464.           mon.write(" The spell failed! ")
  1465.           sleep(2)
  1466.         end
  1467.       elseif P3selected == "MGC 3" then
  1468.         mon.setCursorPos(4,7)
  1469.         mon.write(stringBG)
  1470.         mon.setCursorPos(4,7)
  1471.         mon.write(" PLAYER 3 cast CURE! ")
  1472.         P3MP = P3MP - MGC3cost
  1473.         drawScreen()
  1474.         sleep(2)
  1475.         if hit <= accuracy then
  1476.           if P3target == "P1" then
  1477.             if P1status == "KO " then
  1478.               mon.setCursorPos(4,7)
  1479.               mon.write(stringBG)
  1480.               mon.setCursorPos(4,7)
  1481.               mon.write(" PLAYER 1 has been revived! ")
  1482.               P1HP = math.random(100,400)
  1483.               sleep(2)
  1484.             else
  1485.               mon.setCursorPos(4,7)
  1486.               mon.write(stringBG)
  1487.               mon.setCursorPos(4,7)
  1488.               mon.write(" PLAYER 1 has been cured. ")
  1489.               sleep(2)
  1490.             end
  1491.             P1status = "   "
  1492.             drawScreen()
  1493.             sleep(2)
  1494.             checkDeath("P1")
  1495.           elseif P3target == "P2" then
  1496.             if P2status == "KO " then
  1497.               mon.setCursorPos(4,7)
  1498.               mon.write(stringBG)
  1499.               mon.setCursorPos(4,7)
  1500.               mon.write(" PLAYER 2 has been revived! ")
  1501.               P2HP = math.random(100,400)
  1502.               sleep(2)
  1503.             else
  1504.               mon.setCursorPos(4,7)
  1505.               mon.write(stringBG)
  1506.               mon.setCursorPos(4,7)
  1507.               mon.write(" PLAYER 2 has been cured. ")
  1508.               sleep(2)
  1509.             end
  1510.             P2status = "   "
  1511.             drawScreen()
  1512.             sleep(2)
  1513.             checkDeath("P2")
  1514.           elseif P3target == "P3" then
  1515.             P3status = "   "
  1516.             mon.setCursorPos(4,7)
  1517.             mon.write(stringBG)
  1518.             mon.setCursorPos(4,7)
  1519.             mon.write(" PLAYER 3 has been cured. ")
  1520.             drawScreen()
  1521.             checkDeath("P3")
  1522.             sleep(2)
  1523.           else
  1524.             mon.setCursorPos(4,7)
  1525.             mon.write(stringBG)
  1526.             mon.setCursorPos(4,7)
  1527.             mon.write(" ERROR: No target specified ")
  1528.             sleep(2)
  1529.           end
  1530.         else
  1531.           mon.setCursorPos(4,7)
  1532.           mon.write(stringBG)
  1533.           mon.setCursorPos(4,7)
  1534.           mon.write(" The spell failed! ")
  1535.           sleep(2)
  1536.         end
  1537.       elseif P3selected == "ITM 1" then
  1538.         mon.setCursorPos(4,7)
  1539.         mon.write(stringBG)
  1540.         mon.setCursorPos(4,7)
  1541.         mon.write(" PLAYER 3 used a HP Potion! ")
  1542.         sleep(2)
  1543.         P3HPpots = P3HPpots - 1
  1544.         if P3target == "P1" then
  1545.           if damage > (1000 - P1HP) then
  1546.             damage = 1000 - P1HP
  1547.           end
  1548.           P1HP = P1HP + damage
  1549.           if P1status == "KO " then
  1550.             mon.setCursorPos(4,7)
  1551.             mon.write(stringBG)
  1552.             mon.setCursorPos(4,7)
  1553.             mon.write(" PLAYER 1 has been revived! ")
  1554.             P1status = "   "
  1555.             drawScreen()
  1556.             sleep(2)
  1557.             checkDeath("P1")
  1558.           end
  1559.           mon.setCursorPos(4,7)
  1560.           mon.write(stringBG)
  1561.           mon.setCursorPos(4,7)
  1562.           mon.write(" PLAYER 1 regained "..damage.." HP! ")
  1563.           drawScreen()
  1564.           sleep(2)
  1565.           checkDeath("P1")
  1566.         elseif P3target == "P2" then
  1567.           if damage > (1000 - P2HP) then
  1568.             damage = 1000 - P2HP
  1569.           end
  1570.           P2HP = P2HP + damage
  1571.           if P2status == "KO " then
  1572.             mon.setCursorPos(4,7)
  1573.             mon.write(stringBG)
  1574.             mon.setCursorPos(4,7)
  1575.             mon.write(" PLAYER 2 has been revived! ")
  1576.             P2status = "   "
  1577.             drawScreen()
  1578.             sleep(2)
  1579.             checkDeath("P2")
  1580.           end
  1581.           mon.setCursorPos(4,7)
  1582.           mon.write(stringBG)
  1583.           mon.setCursorPos(4,7)
  1584.           mon.write(" PLAYER 2 regained "..damage.." HP! ")
  1585.           drawScreen()
  1586.           sleep(2)
  1587.           checkDeath("P2")
  1588.         elseif P3target == "P3" then
  1589.           if damage > (1000 - P3HP) then
  1590.             damage = 1000 - P3HP
  1591.           end
  1592.           P3HP = P3HP + damage
  1593.           mon.setCursorPos(4,7)
  1594.           mon.write(stringBG)
  1595.           mon.setCursorPos(4,7)
  1596.           mon.write(" PLAYER 3 regained "..damage.." HP! ")
  1597.           drawScreen()
  1598.           sleep(2)
  1599.           checkDeath("P3")
  1600.         else
  1601.           mon.setCursorPos(4,7)
  1602.           mon.write(stringBG)
  1603.           mon.setCursorPos(4,7)
  1604.           mon.write(" ERROR: No target specified ")
  1605.           sleep(2)
  1606.         end
  1607.       elseif P3selected == "ITM 2" then
  1608.         mon.setCursorPos(4,7)
  1609.         mon.write(stringBG)
  1610.         mon.setCursorPos(4,7)
  1611.         mon.write(" PLAYER 3 used an MP Potion! ")
  1612.         sleep(2)
  1613.         P3MPpots = P3MPpots - 1
  1614.         if P3target == "P1" then
  1615.           if damage > (1000 - P1MP) then
  1616.             damage = 1000 - P1MP
  1617.           end
  1618.           P1MP = P1MP + damage
  1619.           mon.setCursorPos(4,7)
  1620.           mon.write(stringBG)
  1621.           mon.setCursorPos(4,7)
  1622.           mon.write(" PLAYER 1 regained "..damage.." MP! ")
  1623.           drawScreen()
  1624.           sleep(2)
  1625.         elseif P3target == "P2" then
  1626.           if damage > (1000 - P2MP) then
  1627.             damage = 1000 - P2MP
  1628.           end
  1629.           P2MP = P2MP + damage
  1630.           mon.setCursorPos(4,7)
  1631.           mon.write(stringBG)
  1632.           mon.setCursorPos(4,7)
  1633.           mon.write(" PLAYER 2 regained "..damage.." MP! ")
  1634.           drawScreen()
  1635.           sleep(2)
  1636.         elseif P3target == "P3" then
  1637.           if damage > (1000 - P3MP) then
  1638.             damage = 1000 - P3MP
  1639.           end
  1640.           P3MP = P3MP + damage
  1641.           mon.setCursorPos(4,7)
  1642.           mon.write(stringBG)
  1643.           mon.setCursorPos(4,7)
  1644.           mon.write(" PLAYER 3 regained "..damage.." MP! ")
  1645.           drawScreen()
  1646.           sleep(2)
  1647.         else
  1648.           mon.setCursorPos(4,7)
  1649.           mon.write(stringBG)
  1650.           mon.setCursorPos(4,7)
  1651.           mon.write(" ERROR: No target specified ")
  1652.           sleep(2)
  1653.         end
  1654.       elseif P3selected == "ITM 3" then
  1655.         mon.setCursorPos(4,7)
  1656.         mon.write(stringBG)
  1657.         mon.setCursorPos(4,7)
  1658.         mon.write(" PLAYER 3 throws a bomb! ")
  1659.         P3bombs = P3bombs - 1
  1660.         sleep(2)
  1661.         if hit <= accuracy then
  1662.           if NPCshielded > 0 then
  1663.             damage = damage / 2
  1664.           end
  1665.           mon.setCursorPos(4,7)
  1666.           mon.write(stringBG)
  1667.           mon.setCursorPos(4,7)
  1668.           mon.write(" "..NPCname.." took "..damage.." damage! ")
  1669.           NPCHP = NPCHP - damage
  1670.           drawScreen()
  1671.           sleep(2)
  1672.           checkDeath("NPC")
  1673.         else
  1674.           mon.setCursorPos(4,7)
  1675.           mon.write(stringBG)
  1676.           mon.setCursorPos(4,7)
  1677.           mon.write(" The bomb missed! ")
  1678.           sleep(2)
  1679.         end
  1680.       end
  1681.     end
  1682.  
  1683.     -- Finally, the NPC's attack.
  1684.     -- First figure out the "behind the scenes" stuff.
  1685.     skipturn = 0
  1686.     if NPCstatus ~= "KO " then
  1687.       mon.setCursorPos(4,7)
  1688.       mon.write(stringBG)
  1689.       mon.setCursorPos(4,7)
  1690.       mon.write(" "..NPCname.."'s turn... ")
  1691.       sleep(2)
  1692.     end
  1693.  
  1694.     NPCselected = assessTargets()
  1695.  
  1696.     if NPCselected == "ATK 1" then        -- Accurate
  1697.       accuracy = 90
  1698.       damagemin = 80
  1699.       damagemax = 120
  1700.     elseif NPCselected == "ATK 2" then    -- Balanced
  1701.       accuracy = 75
  1702.       damagemin = 100
  1703.       damagemax = 140
  1704.     elseif NPCselected == "ATK 3" then    -- Strong
  1705.       accuracy = 60
  1706.       damagemin = 140
  1707.       damagemax = 160
  1708.     elseif NPCselected == "MGC 1" then    -- Shield
  1709.       accuracy = 80
  1710.     elseif NPCselected == "MGC 2" then    -- Element
  1711.       accuracy = 60
  1712.     elseif NPCselected == "MGC 3" then    -- Cure
  1713.       accuracy = 80
  1714.     elseif NPCselected == "ITM 1" then    -- HP Potion
  1715.       accuracy = 100
  1716.       damagemin = 600
  1717.       damagemax = 1000
  1718.     elseif NPCselected == "ITM 2" then    -- MP Potion
  1719.       accuracy = 100
  1720.       damagemin = 500
  1721.       damagemax = 1000
  1722.     else                                  -- Bomb
  1723.       accuracy = 80
  1724.       damagemin = 200
  1725.       damagemax = 400
  1726.     end
  1727.  
  1728.     if NPCstatus == "FRZ" then  -- Statuses: FRZ, PSN, SLP, FIR, PAR
  1729.       accuracy = accuracy - 10
  1730.       damagebuff = math.random(-20,-10)
  1731.       damagemin = damagemin + damagebuff
  1732.       damagemax = damagemax + damagebuff
  1733.     elseif NPCstatus == "FIR" then
  1734.       damagebuff = math.random(10,20)
  1735.       damagemin = damagemin + damagebuff
  1736.       damagemax = damagemax + damagebuff
  1737.     elseif NPCstatus == "PAR" then
  1738.       damagebuff = math.random(-20, 20)
  1739.       damagemin = damagemin + damagebuff
  1740.       damagemax = damagemax + damagebuff
  1741.     end
  1742.  
  1743.     -- Then make the NPC execute his attack.
  1744.     if NPCstatus == "PAR" then
  1745.       local freezetime = math.random(1,10)
  1746.       if freezetime <= 4 then
  1747.         mon.setCursorPos(4,7)
  1748.         mon.write(stringBG)
  1749.         mon.setCursorPos(4,7)
  1750.         mon.write(" "..NPCname.." is paralyzed! ")
  1751.         sleep(2)
  1752.         skipturn = 1
  1753.       end
  1754.     elseif NPCstatus == "SLP" then
  1755.       skipturn = 1
  1756.     elseif NPCstatus == "KO " then
  1757.       skipturn = 1
  1758.     end
  1759.  
  1760.     if skipturn == 0 then
  1761.       local damage = math.random(damagemin,damagemax)
  1762.       local hit = math.random(1,100)
  1763.       if NPCselected == "ATK 1" or NPCselected == "ATK 2" or NPCselected == "ATK 3" then
  1764.         mon.setCursorPos(4,7)
  1765.         mon.write(stringBG)
  1766.         mon.setCursorPos(4,7)
  1767.         mon.write(" "..NPCname.." attacks! ")
  1768.         sleep(2)
  1769.         if hit <= accuracy then
  1770.           if NPCtarget == "P1" then
  1771.             if P1shielded > 0 then
  1772.               damage = damage / 2
  1773.             end
  1774.             mon.setCursorPos(4,7)
  1775.             mon.write(stringBG)
  1776.             mon.setCursorPos(4,7)
  1777.             mon.write(" PLAYER 1 took "..damage.." damage! ")
  1778.             P1HP = P1HP - damage
  1779.             drawScreen()
  1780.             sleep(2)
  1781.             checkDeath("P1")
  1782.           elseif NPCtarget == "P2" then
  1783.             if P2shielded > 0 then
  1784.               damage = damage / 2
  1785.             end
  1786.             mon.setCursorPos(4,7)
  1787.             mon.write(stringBG)
  1788.             mon.setCursorPos(4,7)
  1789.             mon.write(" PLAYER 2 took "..damage.." damage! ")
  1790.             P2HP = P2HP - damage
  1791.             drawScreen()
  1792.             sleep(2)
  1793.             checkDeath("P2")
  1794.           else
  1795.             if P3shielded > 0 then
  1796.               damage = damage / 2
  1797.             end
  1798.             mon.setCursorPos(4,7)
  1799.             mon.write(stringBG)
  1800.             mon.setCursorPos(4,7)
  1801.             mon.write(" PLAYER 3 took "..damage.." damage! ")
  1802.             P3HP = P3HP - damage
  1803.             drawScreen()
  1804.             sleep(2)
  1805.             checkDeath("P3")
  1806.           end
  1807.         else
  1808.           mon.setCursorPos(4,7)
  1809.           mon.write(stringBG)
  1810.           mon.setCursorPos(4,7)
  1811.           mon.write(" The attack missed! ")
  1812.           sleep(2)
  1813.         end
  1814.       elseif NPCselected == "MGC 1" then
  1815.         mon.setCursorPos(4,7)
  1816.         mon.write(stringBG)
  1817.         mon.setCursorPos(4,7)
  1818.         mon.write(" "..NPCname.." cast SHIELD! ")
  1819.         NPCMP = NPCMP - MGC1cost
  1820.         sleep(2)
  1821.         if hit <= accuracy then
  1822.           NPCshielded = NPCshielded + 3
  1823.           mon.setCursorPos(4,7)
  1824.           mon.write(stringBG)
  1825.           mon.setCursorPos(4,7)
  1826.           mon.write(" "..NPCname.." has been protected! ")
  1827.           sleep(2)
  1828.         else
  1829.           mon.setCursorPos(4,7)
  1830.           mon.write(stringBG)
  1831.           mon.setCursorPos(4,7)
  1832.           mon.write(" The spell failed! ")
  1833.           sleep(2)
  1834.         end
  1835.       elseif NPCselected == "MGC 2" then
  1836.         mon.setCursorPos(4,7)
  1837.         mon.write(stringBG)
  1838.         mon.setCursorPos(4,7)
  1839.         mon.write(" "..NPCname.." cast ELEMENT! ")
  1840.         NPCMP = NPCMP - MGC2cost
  1841.         sleep(2)
  1842.         if hit <= accuracy then
  1843.           local element = math.random(1,10)
  1844.           if NPCtarget == "P1" then
  1845.             if element <= 3 then
  1846.               P1status = "PSN"
  1847.               mon.setCursorPos(4,7)
  1848.               mon.write(stringBG)
  1849.               mon.setCursorPos(4,7)
  1850.               mon.write(" PLAYER 1 got poisoned! ")
  1851.               drawScreen()
  1852.               sleep(2)
  1853.               checkDeath("P1")
  1854.             elseif element <= 5 then
  1855.               P1status = "FIR"
  1856.               mon.setCursorPos(4,7)
  1857.               mon.write(stringBG)
  1858.               mon.setCursorPos(4,7)
  1859.               mon.write(" PLAYER 1 was set aflame! ")
  1860.               drawScreen()
  1861.               sleep(2)
  1862.               checkDeath("P1")
  1863.             elseif element <= 7 then
  1864.               P1status = "PAR"
  1865.               mon.setCursorPos(4,7)
  1866.               mon.write(stringBG)
  1867.               mon.setCursorPos(4,7)
  1868.               mon.write(" PLAYER 1 got paralyzed! ")
  1869.               drawScreen()
  1870.               sleep(2)
  1871.               checkDeath("P1")
  1872.             elseif element <= 9 then
  1873.               P1status = "FRZ"
  1874.               mon.setCursorPos(4,7)
  1875.               mon.write(stringBG)
  1876.               mon.setCursorPos(4,7)
  1877.               mon.write(" PLAYER 1 got frozen! ")
  1878.               drawScreen()
  1879.               sleep(2)
  1880.               checkDeath("P1")
  1881.             else
  1882.               P1status = "SLP"
  1883.               mon.setCursorPos(4,7)
  1884.               mon.write(stringBG)
  1885.               mon.setCursorPos(4,7)
  1886.               mon.write(" PLAYER 1 fell asleep! ")
  1887.               drawScreen()
  1888.               sleep(2)
  1889.               checkDeath("P1")
  1890.             end
  1891.           elseif NPCtarget == "P2" then
  1892.             if element <= 3 then
  1893.               P2status = "PSN"
  1894.               mon.setCursorPos(4,7)
  1895.               mon.write(stringBG)
  1896.               mon.setCursorPos(4,7)
  1897.               mon.write(" PLAYER 2 got poisoned! ")
  1898.               drawScreen()
  1899.               sleep(2)
  1900.               checkDeath("P2")
  1901.             elseif element <= 5 then
  1902.               P2status = "FIR"
  1903.               mon.setCursorPos(4,7)
  1904.               mon.write(stringBG)
  1905.               mon.setCursorPos(4,7)
  1906.               mon.write(" PLAYER 2 was set aflame! ")
  1907.               drawScreen()
  1908.               sleep(2)
  1909.               checkDeath("P2")
  1910.             elseif element <= 7 then
  1911.               P2status = "PAR"
  1912.               mon.setCursorPos(4,7)
  1913.               mon.write(stringBG)
  1914.               mon.setCursorPos(4,7)
  1915.               mon.write(" PLAYER 2 got paralyzed! ")
  1916.               drawScreen()
  1917.               sleep(2)
  1918.               checkDeath("P2")
  1919.             elseif element <= 9 then
  1920.               P2status = "FRZ"
  1921.               mon.setCursorPos(4,7)
  1922.               mon.write(stringBG)
  1923.               mon.setCursorPos(4,7)
  1924.               mon.write(" PLAYER 2 got frozen! ")
  1925.               drawScreen()
  1926.               sleep(2)
  1927.               checkDeath("P2")
  1928.             else
  1929.               P2status = "SLP"
  1930.               mon.setCursorPos(4,7)
  1931.               mon.write(stringBG)
  1932.               mon.setCursorPos(4,7)
  1933.               mon.write(" PLAYER 2 fell asleep! ")
  1934.               drawScreen()
  1935.               sleep(2)
  1936.               checkDeath("P2")
  1937.             end
  1938.           else
  1939.             if element <= 3 then
  1940.               P3status = "PSN"
  1941.               mon.setCursorPos(4,7)
  1942.               mon.write(stringBG)
  1943.               mon.setCursorPos(4,7)
  1944.               mon.write(" PLAYER 3 got poisoned! ")
  1945.               drawScreen()
  1946.               sleep(2)
  1947.               checkDeath("P3")
  1948.             elseif element <= 5 then
  1949.               P3status = "FIR"
  1950.               mon.setCursorPos(4,7)
  1951.               mon.write(stringBG)
  1952.               mon.setCursorPos(4,7)
  1953.               mon.write(" PLAYER 3 was set aflame! ")
  1954.               drawScreen()
  1955.               sleep(2)
  1956.               checkDeath("P3")
  1957.             elseif element <= 7 then
  1958.               P3status = "PAR"
  1959.               mon.setCursorPos(4,7)
  1960.               mon.write(stringBG)
  1961.               mon.setCursorPos(4,7)
  1962.               mon.write(" PLAYER 3 got paralyzed! ")
  1963.               drawScreen()
  1964.               sleep(2)
  1965.               checkDeath("P3")
  1966.             elseif element <= 9 then
  1967.               P3status = "FRZ"
  1968.               mon.setCursorPos(4,7)
  1969.               mon.write(stringBG)
  1970.               mon.setCursorPos(4,7)
  1971.               mon.write(" PLAYER 3 got frozen! ")
  1972.               drawScreen()
  1973.               sleep(2)
  1974.               checkDeath("P3")
  1975.             else
  1976.               P3status = "SLP"
  1977.               mon.setCursorPos(4,7)
  1978.               mon.write(stringBG)
  1979.               mon.setCursorPos(4,7)
  1980.               mon.write(" PLAYER 3 fell asleep! ")
  1981.               drawScreen()
  1982.               sleep(2)
  1983.               checkDeath("P3")
  1984.             end
  1985.           end
  1986.         else
  1987.           mon.setCursorPos(4,7)
  1988.           mon.write(stringBG)
  1989.           mon.setCursorPos(4,7)
  1990.           mon.write(" The spell failed! ")
  1991.           sleep(2)
  1992.         end
  1993.       elseif NPCselected == "MGC 3" then
  1994.         mon.setCursorPos(4,7)
  1995.         mon.write(stringBG)
  1996.         mon.setCursorPos(4,7)
  1997.         mon.write(" "..NPCname.." cast CURE! ")
  1998.         NPCMP = NPCMP - MGC3cost
  1999.         sleep(2)
  2000.         if hit <= accuracy then
  2001.           NPCstatus = "   "
  2002.           mon.setCursorPos(4,7)
  2003.           mon.write(stringBG)
  2004.           mon.setCursorPos(4,7)
  2005.           mon.write(" "..NPCname.." has been cured. ")
  2006.           drawScreen()
  2007.           sleep(2)
  2008.         else
  2009.           mon.setCursorPos(4,7)
  2010.           mon.write(stringBG)
  2011.           mon.setCursorPos(4,7)
  2012.           mon.write(" The spell failed! ")
  2013.           sleep(2)
  2014.         end
  2015.       elseif NPCselected == "ITM 1" then
  2016.         mon.setCursorPos(4,7)
  2017.         mon.write(stringBG)
  2018.         mon.setCursorPos(4,7)
  2019.         mon.write(" "..NPCname.." used a HP Potion! ")
  2020.         sleep(2)
  2021.         NPCHPpots = NPCHPpots - 1
  2022.         if damage > ((1000*(NPCtier/2)) - NPCHP) then
  2023.           damage = (1000*(NPCtier/2)) - NPCHP
  2024.         end
  2025.         NPCHP = NPCHP + damage
  2026.         mon.setCursorPos(4,7)
  2027.         mon.write(stringBG)
  2028.         mon.setCursorPos(4,7)
  2029.         mon.write(" "..NPCname.." regained "..damage.." HP! ")
  2030.         drawScreen()
  2031.         sleep(2)
  2032.       elseif NPCselected == "ITM 3" then
  2033.         mon.setCursorPos(4,7)
  2034.         mon.write(stringBG)
  2035.         mon.setCursorPos(4,7)
  2036.         mon.write(" "..NPCname.." throws a bomb! ")
  2037.         NPCbombs = NPCbombs - 1
  2038.         sleep(2)
  2039.         if hit <= accuracy then
  2040.          if NPCtarget == "P1" then
  2041.             if P1shielded > 0 then
  2042.               damage = damage / 2
  2043.             end
  2044.             mon.setCursorPos(4,7)
  2045.             mon.write(stringBG)
  2046.             mon.setCursorPos(4,7)
  2047.             mon.write(" PLAYER 1 took "..damage.." damage! ")
  2048.             P1HP = P1HP - damage
  2049.             drawScreen()
  2050.             sleep(2)
  2051.             checkDeath("P1")
  2052.           elseif NPCtarget == "P2" then
  2053.             if P2shielded > 0 then
  2054.               damage = damage / 2
  2055.             end
  2056.             mon.setCursorPos(4,7)
  2057.             mon.write(stringBG)
  2058.             mon.setCursorPos(4,7)
  2059.             mon.write(" PLAYER 2 took "..damage.." damage! ")
  2060.             P2HP = P2HP - damage
  2061.             drawScreen()
  2062.             sleep(2)
  2063.             checkDeath("P2")
  2064.           else
  2065.             if P3shielded > 0 then
  2066.               damage = damage / 2
  2067.             end
  2068.             mon.setCursorPos(4,7)
  2069.             mon.write(stringBG)
  2070.             mon.setCursorPos(4,7)
  2071.             mon.write(" PLAYER 3 took "..damage.." damage! ")
  2072.             P3HP = P3HP - damage
  2073.             drawScreen()
  2074.             sleep(2)
  2075.             checkDeath("P3")
  2076.           end
  2077.         else
  2078.           mon.setCursorPos(4,7)
  2079.           mon.write(stringBG)
  2080.           mon.setCursorPos(4,7)
  2081.           mon.write(" The bomb missed! ")
  2082.           sleep(2)
  2083.         end
  2084.       end
  2085.     end
  2086.  
  2087.  -- STATUS PROBLEMS
  2088.  
  2089.     if P1status == "FIR" then
  2090.       damage = math.random(30,60)
  2091.       P1HP = P1HP - damage
  2092.  
  2093.       mon.setCursorPos(4,7)
  2094.       mon.write(stringBG)
  2095.       mon.setCursorPos(4,7)
  2096.       mon.write(" PLAYER 1 is on fire! ")
  2097.       sleep(2)
  2098.       mon.setCursorPos(4,7)
  2099.       mon.write(stringBG)
  2100.       mon.setCursorPos(4,7)
  2101.       mon.write(" PLAYER 1 took "..damage.." fire damage! ")
  2102.       drawScreen()
  2103.       sleep(2)
  2104.       checkDeath("P1")
  2105.  
  2106.     elseif P1status == "PSN" then
  2107.       damage = math.random(20,40)
  2108.       P1HP = P1HP - damage
  2109.  
  2110.       mon.setCursorPos(4,7)
  2111.       mon.write(stringBG)
  2112.       mon.setCursorPos(4,7)
  2113.       mon.write(" PLAYER 1 is poisoned! ")
  2114.       sleep(2)
  2115.       mon.setCursorPos(4,7)
  2116.       mon.write(stringBG)
  2117.       mon.setCursorPos(4,7)
  2118.       mon.write(" PLAYER 1 took "..damage.." damage! ")
  2119.       drawScreen()
  2120.       sleep(2)
  2121.       checkDeath("P1")
  2122.  
  2123.     elseif P1status == "SLP" then
  2124.       damage = math.random(30,50)
  2125.       if damage > (1000 - P1HP) then
  2126.         damage = 1000 - P1HP
  2127.       end
  2128.       P1HP = P1HP + damage
  2129.  
  2130.       mon.setCursorPos(4,7)
  2131.       mon.write(stringBG)
  2132.       mon.setCursorPos(4,7)
  2133.       mon.write(" PLAYER 1 is asleep! ")
  2134.       sleep(2)
  2135.       mon.setCursorPos(4,7)
  2136.       mon.write(stringBG)
  2137.       mon.setCursorPos(4,7)
  2138.       mon.write(" PLAYER 1 healed "..damage.." health! ")
  2139.       drawScreen()
  2140.       sleep(2)
  2141.       checkDeath("P1")
  2142.     end
  2143.  
  2144.     if P1status ~= "   " and P1status ~= "KO " then
  2145.       cure = math.random(1,5)
  2146.       if cure == 5 then
  2147.         if P1status == "FIR" then
  2148.           mon.setCursorPos(4,7)
  2149.           mon.write(stringBG)
  2150.           mon.setCursorPos(4,7)
  2151.           mon.write(" PLAYER 1's fire went away. ")
  2152.         elseif P1status == "FRZ" then
  2153.           mon.setCursorPos(4,7)
  2154.           mon.write(stringBG)
  2155.           mon.setCursorPos(4,7)
  2156.           mon.write(" PLAYER 1 thawed. ")
  2157.         elseif P1status == "PSN" then
  2158.           mon.setCursorPos(4,7)
  2159.           mon.write(stringBG)
  2160.           mon.setCursorPos(4,7)
  2161.           mon.write(" PLAYER 1 is cured of poison. ")
  2162.         elseif P1status == "SLP" then
  2163.           mon.setCursorPos(4,7)
  2164.           mon.write(stringBG)
  2165.           mon.setCursorPos(4,7)
  2166.           mon.write(" PLAYER 1 woke up. ")
  2167.         elseif P1status == "PAR" then
  2168.           mon.setCursorPos(4,7)
  2169.           mon.write(stringBG)
  2170.           mon.setCursorPos(4,7)
  2171.           mon.write(" PLAYER 1 is no longer paralyzed. ")
  2172.         end
  2173.         P1status = "   "
  2174.         drawScreen()
  2175.         sleep(2)
  2176.         checkDeath("P1")
  2177.       end
  2178.     end
  2179.  
  2180.     if P2status == "FIR" then
  2181.       damage = math.random(30,60)
  2182.       P2HP = P2HP - damage
  2183.  
  2184.       mon.setCursorPos(4,7)
  2185.       mon.write(stringBG)
  2186.       mon.setCursorPos(4,7)
  2187.       mon.write(" PLAYER 2 is on fire! ")
  2188.       sleep(2)
  2189.       mon.setCursorPos(4,7)
  2190.       mon.write(stringBG)
  2191.       mon.setCursorPos(4,7)
  2192.       mon.write(" PLAYER 2 took "..damage.." damage! ")
  2193.       drawScreen()
  2194.       sleep(2)
  2195.       checkDeath("P2")
  2196.  
  2197.     elseif P2status == "PSN" then
  2198.       damage = math.random(20,40)
  2199.       P2HP = P2HP - damage
  2200.  
  2201.       mon.setCursorPos(4,7)
  2202.       mon.write(stringBG)
  2203.       mon.setCursorPos(4,7)
  2204.       mon.write(" PLAYER 2 is poisoned! ")
  2205.       sleep(2)
  2206.       mon.setCursorPos(4,7)
  2207.       mon.write(stringBG)
  2208.       mon.setCursorPos(4,7)
  2209.       mon.write(" PLAYER 2 took "..damage.." damage! ")
  2210.       drawScreen()
  2211.       sleep(2)
  2212.       checkDeath("P2")
  2213.  
  2214.     elseif P2status == "SLP" then
  2215.       damage = math.random(30,50)
  2216.       if damage > (1000 - P2HP) then
  2217.         damage = 1000 - P2HP
  2218.       end
  2219.       P2HP = P2HP + damage
  2220.  
  2221.       mon.setCursorPos(4,7)
  2222.       mon.write(stringBG)
  2223.       mon.setCursorPos(4,7)
  2224.       mon.write(" PLAYER 2 is asleep! ")
  2225.       sleep(2)
  2226.       mon.setCursorPos(4,7)
  2227.       mon.write(stringBG)
  2228.       mon.setCursorPos(4,7)
  2229.       mon.write(" PLAYER 2 healed "..damage.." health! ")
  2230.       drawScreen()
  2231.       sleep(2)
  2232.       checkDeath("P2")
  2233.     end
  2234.  
  2235.     if P2status ~= "   " and P2status ~= "KO " then
  2236.       cure = math.random(1,5)
  2237.       if cure == 5 then
  2238.         if P2status == "FIR" then
  2239.           mon.setCursorPos(4,7)
  2240.           mon.write(stringBG)
  2241.           mon.setCursorPos(4,7)
  2242.           mon.write(" PLAYER 2's fire went away. ")
  2243.         elseif P2status == "FRZ" then
  2244.           mon.setCursorPos(4,7)
  2245.           mon.write(stringBG)
  2246.           mon.setCursorPos(4,7)
  2247.           mon.write(" PLAYER 2 thawed. ")
  2248.         elseif P2status == "PSN" then
  2249.           mon.setCursorPos(4,7)
  2250.           mon.write(stringBG)
  2251.           mon.setCursorPos(4,7)
  2252.           mon.write(" PLAYER 2 is cured of poison. ")
  2253.         elseif P2status == "SLP" then
  2254.           mon.setCursorPos(4,7)
  2255.           mon.write(stringBG)
  2256.           mon.setCursorPos(4,7)
  2257.           mon.write(" PLAYER 2 woke up. ")
  2258.         elseif P2status == "PAR" then
  2259.           mon.setCursorPos(4,7)
  2260.           mon.write(stringBG)
  2261.           mon.setCursorPos(4,7)
  2262.           mon.write(" PLAYER 2 is no longer paralyzed. ")
  2263.         end
  2264.         P2status = "   "
  2265.         drawScreen()
  2266.         sleep(2)
  2267.         checkDeath("P2")
  2268.       end
  2269.     end
  2270.  
  2271.     if P3status == "FIR" then
  2272.       damage = math.random(30,60)
  2273.       P3HP = P3HP - damage
  2274.  
  2275.       mon.setCursorPos(4,7)
  2276.       mon.write(stringBG)
  2277.       mon.setCursorPos(4,7)
  2278.       mon.write(" PLAYER 3 is on fire! ")
  2279.       sleep(2)
  2280.       mon.setCursorPos(4,7)
  2281.       mon.write(stringBG)
  2282.       mon.setCursorPos(4,7)
  2283.       mon.write(" PLAYER 3 took "..damage.." damage! ")
  2284.       drawScreen()
  2285.       sleep(2)
  2286.       checkDeath("P3")
  2287.  
  2288.     elseif P3status == "PSN" then
  2289.       damage = math.random(20,40)
  2290.       P3HP = P3HP - damage
  2291.  
  2292.       mon.setCursorPos(4,7)
  2293.       mon.write(stringBG)
  2294.       mon.setCursorPos(4,7)
  2295.       mon.write(" PLAYER 3 is poisoned! ")
  2296.       sleep(2)
  2297.       mon.setCursorPos(4,7)
  2298.       mon.write(stringBG)
  2299.       mon.setCursorPos(4,7)
  2300.       mon.write(" PLAYER 3 took "..damage.." damage! ")
  2301.       drawScreen()
  2302.       sleep(2)
  2303.       checkDeath("P3")
  2304.  
  2305.     elseif P3status == "SLP" then
  2306.       damage = math.random(30,50)
  2307.       if damage > (1000 - P3HP) then
  2308.         damage = 1000 - P3HP
  2309.       end
  2310.       P3HP = P3HP + damage
  2311.  
  2312.       mon.setCursorPos(4,7)
  2313.       mon.write(stringBG)
  2314.       mon.setCursorPos(4,7)
  2315.       mon.write(" PLAYER 3 is asleep! ")
  2316.       sleep(2)
  2317.       mon.setCursorPos(4,7)
  2318.       mon.write(stringBG)
  2319.       mon.setCursorPos(4,7)
  2320.       mon.write(" PLAYER 3 healed "..damage.." health! ")
  2321.       drawScreen()
  2322.       sleep(2)
  2323.       checkDeath("P3")
  2324.     end
  2325.  
  2326.     if P3status ~= "   " and P3status ~= "KO " then
  2327.       cure = math.random(1,5)
  2328.       if cure == 5 then
  2329.         if P3status == "FIR" then
  2330.           mon.setCursorPos(4,7)
  2331.           mon.write(stringBG)
  2332.           mon.setCursorPos(4,7)
  2333.           mon.write(" PLAYER 3's fire went away. ")
  2334.         elseif P3status == "FRZ" then
  2335.           mon.setCursorPos(4,7)
  2336.           mon.write(stringBG)
  2337.           mon.setCursorPos(4,7)
  2338.           mon.write(" PLAYER 3 thawed. ")
  2339.         elseif P3status == "PSN" then
  2340.           mon.setCursorPos(4,7)
  2341.           mon.write(stringBG)
  2342.           mon.setCursorPos(4,7)
  2343.           mon.write(" PLAYER 3 is cured of poison. ")
  2344.         elseif P3status == "SLP" then
  2345.           mon.setCursorPos(4,7)
  2346.           mon.write(stringBG)
  2347.           mon.setCursorPos(4,7)
  2348.           mon.write(" PLAYER 3 woke up. ")
  2349.         elseif P3status == "PAR" then
  2350.           mon.setCursorPos(4,7)
  2351.           mon.write(stringBG)
  2352.           mon.setCursorPos(4,7)
  2353.           mon.write(" PLAYER 3 is no longer paralyzed. ")
  2354.         end
  2355.         P3status = "   "
  2356.         drawScreen()
  2357.         sleep(2)
  2358.         checkDeath("P3")
  2359.       end
  2360.     end
  2361.  
  2362.     if NPCstatus == "FIR" then
  2363.       damage = math.random(30,60)
  2364.       NPCHP = NPCHP - damage
  2365.  
  2366.       mon.setCursorPos(4,7)
  2367.       mon.write(stringBG)
  2368.       mon.setCursorPos(4,7)
  2369.       mon.write(" "..NPCname.." is on fire! ")
  2370.       sleep(2)
  2371.       mon.setCursorPos(4,7)
  2372.       mon.write(stringBG)
  2373.       mon.setCursorPos(4,7)
  2374.       mon.write(" "..NPCname.." took "..damage.." damage! ")
  2375.       drawScreen()
  2376.       sleep(2)
  2377.       checkDeath("NPC")
  2378.  
  2379.     elseif NPCstatus == "PSN" then
  2380.       damage = math.random(20,40)
  2381.       NPCHP = NPCHP - damage
  2382.  
  2383.       mon.setCursorPos(4,7)
  2384.       mon.write(stringBG)
  2385.       mon.setCursorPos(4,7)
  2386.       mon.write(" "..NPCname.." is poisoned! ")
  2387.       sleep(2)
  2388.       mon.setCursorPos(4,7)
  2389.       mon.write(stringBG)
  2390.       mon.setCursorPos(4,7)
  2391.       mon.write(" "..NPCname.." took "..damage.." damage! ")
  2392.       drawScreen()
  2393.       sleep(2)
  2394.       checkDeath("NPC")
  2395.  
  2396.     elseif NPCstatus == "SLP" then
  2397.       damage = math.random(30,50)
  2398.       if damage > ((1000 * (NPCtier/2)) - NPCHP) then
  2399.         damage = (1000 * (NPCtier/2)) - P1HP
  2400.       end
  2401.       NPCHP = NPCHP + damage
  2402.  
  2403.       mon.setCursorPos(4,7)
  2404.       mon.write(stringBG)
  2405.       mon.setCursorPos(4,7)
  2406.       mon.write(" "..NPCname.." is asleep! ")
  2407.       sleep(2)
  2408.       mon.setCursorPos(4,7)
  2409.       mon.write(stringBG)
  2410.       mon.setCursorPos(4,7)
  2411.       mon.write(" "..NPCname.." healed "..damage.." health! ")
  2412.       drawScreen()
  2413.       sleep(2)
  2414.     end
  2415.  
  2416.     if NPCstatus ~= "   " and NPCstatus ~= "KO " then
  2417.       cure = math.random(1,5)
  2418.       if cure == 5 then
  2419.         if NPCstatus == "FIR" then
  2420.           mon.setCursorPos(4,7)
  2421.           mon.write(stringBG)
  2422.           mon.setCursorPos(4,7)
  2423.           mon.write(" "..NPCname.."'s fire went away. ")
  2424.         elseif NPCstatus == "FRZ" then
  2425.           mon.setCursorPos(4,7)
  2426.           mon.write(stringBG)
  2427.           mon.setCursorPos(4,7)
  2428.           mon.write(" "..NPCname.." thawed. ")
  2429.         elseif NPCstatus == "PSN" then
  2430.           mon.setCursorPos(4,7)
  2431.           mon.write(stringBG)
  2432.           mon.setCursorPos(4,7)
  2433.           mon.write(" "..NPCname.." is cured of poison. ")
  2434.         elseif NPCstatus == "SLP" then
  2435.           mon.setCursorPos(4,7)
  2436.           mon.write(stringBG)
  2437.           mon.setCursorPos(4,7)
  2438.           mon.write(" "..NPCname.." woke up. ")
  2439.         elseif NPCstatus == "PAR" then
  2440.           mon.setCursorPos(4,7)
  2441.           mon.write(stringBG)
  2442.           mon.setCursorPos(4,7)
  2443.           mon.write(" "..NPCname.." is no longer paralyzed. ")
  2444.         end
  2445.         NPCstatus = "   "
  2446.         drawScreen()
  2447.         sleep(2)
  2448.       end
  2449.     end
  2450.     if NPCstatus == "KO " then
  2451.       NPCtier = NPCtier + 1    
  2452.       NPCHP = (NPCtier/2) * 1000
  2453.       NPCMP = (NPCtier/2) * 1000
  2454.       NPCHPpots = math.random(1,9)
  2455.       NPCMPpots = math.random(1,9)
  2456.       NPCbombs = math.random(1,9)
  2457.       NPCstatus = "   "
  2458.       NPCshielded = 0
  2459.       if NPCtier == 1 then
  2460.         NPCname = stringE1
  2461.         NPCdrawA = drawE1A
  2462.         NPCdrawB = drawE1B
  2463.         NPCdrawC = drawE1C
  2464.         NPCAggressiveness = 1
  2465.         NPCDefensiveness = 4
  2466.         NPCAccuracy = 5
  2467.       elseif NPCtier == 2 then
  2468.         NPCname = stringE2
  2469.         NPCdrawA = drawE2A
  2470.         NPCdrawB = drawE2B
  2471.         NPCdrawC = drawE2C
  2472.         NPCAggressiveness = 2
  2473.         NPCDefensiveness = 2
  2474.         NPCAccuracy = 10
  2475.       elseif NPCtier == 3 then
  2476.         NPCname = stringE3
  2477.         NPCdrawA = drawE3A
  2478.         NPCdrawB = drawE3B
  2479.         NPCdrawC = drawE3C
  2480.         NPCAggressiveness = 3
  2481.         NPCDefensiveness = 8
  2482.         NPCAccuracy = 2
  2483.       elseif NPCtier == 4 then
  2484.         NPCname = stringE4
  2485.         NPCdrawA = drawE4A
  2486.         NPCdrawB = drawE4B
  2487.         NPCdrawC = drawE4C
  2488.         NPCAggressiveness = 4
  2489.         NPCDefensiveness = 5
  2490.         NPCAccuracy = 5
  2491.       elseif NPCtier == 5 then
  2492.         NPCname = stringE5
  2493.         NPCdrawA = drawE5A
  2494.         NPCdrawB = drawE5B
  2495.         NPCdrawC = drawE5C
  2496.         NPCAggressiveness = 5
  2497.         NPCDefensiveness = 10
  2498.         NPCAccuracy = 5
  2499.       elseif NPCtier == 6 then
  2500.         NPCname = stringE6
  2501.         NPCdrawA = drawE6A
  2502.         NPCdrawB = drawE6B
  2503.         NPCdrawC = drawE6C
  2504.         NPCAggressiveness = 6
  2505.         NPCDefensiveness = 1
  2506.         NPCAccuracy = 1
  2507.       elseif NPCtier == 7 then
  2508.         NPCname = stringE7
  2509.         NPCdrawA = drawE7A
  2510.         NPCdrawB = drawE7B
  2511.         NPCdrawC = drawE7C
  2512.         NPCAggressiveness = 7
  2513.         NPCDefensiveness = 5
  2514.         NPCAccuracy = 5
  2515.       elseif NPCtier == 8 then
  2516.         NPCname = stringE8
  2517.         NPCdrawA = drawE8A
  2518.         NPCdrawB = drawE8B
  2519.         NPCdrawC = drawE8C
  2520.         NPCAggressiveness = 8
  2521.         NPCDefensiveness = 9
  2522.         NPCAccuracy = 6
  2523.       elseif NPCtier == 9 then
  2524.         NPCname = stringE9
  2525.         NPCdrawA = drawE9A
  2526.         NPCdrawB = drawE9B
  2527.         NPCdrawC = drawE9C
  2528.         NPCAggressiveness = 9
  2529.         NPCDefensiveness = 3
  2530.         NPCAccuracy = 9
  2531.       elseif NPCtier == 10 then
  2532.         NPCname = stringE10
  2533.         NPCdrawA = drawE10A
  2534.         NPCdrawB = drawE10B
  2535.         NPCdrawC = drawE10C
  2536.         NPCAggressiveness = 10
  2537.         NPCDefensiveness = 10
  2538.         NPCAccuracy = 10
  2539.       elseif NPCtier == 11 then
  2540.         -- YOU WIN
  2541.         mon.setCursorPos(4,7)
  2542.         mon.write(stringBG)
  2543.         mon.setCursorPos(4,7)
  2544.         mon.write(" All enemies defeated! YOU WIN! ")
  2545.         mon.setCursorPos(6,9)
  2546.         mon.write(drawP1Aitem)
  2547.         mon.setCursorPos(6,10)
  2548.         mon.write(drawP1Bitem)
  2549.         mon.setCursorPos(6,11)
  2550.         mon.write(drawP1Citem)
  2551.         mon.setCursorPos(23,9)
  2552.         mon.write(drawP2Aitem)
  2553.         mon.setCursorPos(23,10)
  2554.         mon.write(drawP2Bitem)
  2555.         mon.setCursorPos(23,11)
  2556.         mon.write(drawP2Citem)
  2557.         mon.setCursorPos(40,9)
  2558.         mon.write(drawP3Aitem)
  2559.         mon.setCursorPos(40,10)
  2560.         mon.write(drawP3Bitem)
  2561.         mon.setCursorPos(40,11)
  2562.         mon.write(drawP3Citem)
  2563.         sleep(2)
  2564.         os.reboot()
  2565.       end
  2566.  
  2567.       mon.setCursorPos(4,7)
  2568.       mon.write(stringBG)
  2569.       mon.setCursorPos(4,7)
  2570.       mon.write(" Enemy Defeated! Items Restocked! ")
  2571.  
  2572.       if P1status ~= "KO " then
  2573.         P1HP = P1HP + math.random(200,400)
  2574.         P1MP = P1MP + math.random(200,400)
  2575.       else
  2576.         P1HP = P1HP + math.random(300,600)
  2577.         P1MP = P1MP + math.random(300,600)
  2578.       end
  2579.       P1HPpots = P1HPpots + math.random(0,2)
  2580.       P1MPpots = P1MPpots + math.random(0,2)
  2581.       P1bombs = P1bombs + math.random(0,2)
  2582.       P1status = "   "
  2583.       if P1HP > 1000 then
  2584.         P1HP = 1000
  2585.       end
  2586.       if P1MP > 1000 then
  2587.         P1MP = 1000
  2588.       end
  2589.  
  2590.       if P2status ~= "KO " then
  2591.         P2HP = P2HP + math.random(200,400)
  2592.         P2MP = P2MP + math.random(200,400)
  2593.       else
  2594.         P2HP = P2HP + math.random(300,600)
  2595.         P2MP = P2MP + math.random(300,600)
  2596.       end
  2597.       P2HPpots = P2HPpots + math.random(0,2)
  2598.       P2MPpots = P2MPpots + math.random(0,2)
  2599.       P2bombs = P2bombs + math.random(0,2)
  2600.       P2status = "   "
  2601.       if P2HP > 1000 then
  2602.         P2HP = 1000
  2603.       end
  2604.       if P2MP > 1000 then
  2605.         P2MP = 1000
  2606.       end
  2607.  
  2608.       if P3status ~= "KO " then
  2609.         P3HP = P3HP + math.random(200,400)
  2610.         P3MP = P3MP + math.random(200,400)
  2611.       else
  2612.         P3HP = P3HP + math.random(300,600)
  2613.         P3MP = P3MP + math.random(300,600)
  2614.       end
  2615.       P3HPpots = P3HPpots + math.random(0,2)
  2616.       P3MPpots = P3MPpots + math.random(0,2)
  2617.       P3bombs = P3bombs + math.random(0,2)
  2618.       P3status = "   "
  2619.       if P3HP > 1000 then
  2620.         P3HP = 1000
  2621.       end
  2622.       if P3MP > 1000 then
  2623.         P3MP = 1000
  2624.       end
  2625.       sleep(2)
  2626.     end
  2627.   turn = "Input"
  2628.   P1selected = ""
  2629.   P2selected = ""
  2630.   P3selected = ""
  2631.   P1target = ""
  2632.   P2target = ""
  2633.   P3target = ""
  2634.   P1ready = 0
  2635.   P2ready = 0
  2636.   P3ready = 0
  2637.   P1shielded = P1shielded - 1
  2638.   P2shielded = P2shielded - 1
  2639.   P3shielded = P3shielded - 1
  2640.   NPCshielded = NPCshielded - 1
  2641.   mon.setCursorPos(1,15)
  2642.   mon.write(" [A|"..stringHUDATK.."]  [A|"..stringHUDATK.."]  [A|"..stringHUDATK.."] ")
  2643.   mon.setCursorPos(1,16)
  2644.   mon.write(" [B|"..stringHUDMGC.."]  [B|"..stringHUDMGC.."]  [B|"..stringHUDMGC.."] ")
  2645.   mon.setCursorPos(1,17)
  2646.   mon.write(" [C|"..stringHUDITM.."]  [C|"..stringHUDITM.."]  [C|"..stringHUDITM.."] ")
  2647.   drawScreen()
  2648.   end
  2649. end
  2650.  
  2651. function assessTargets()  -- NPC AI function
  2652.   -- NPCAggressiveness     [] 1-10 - determines how much the NPC will bully, and how many bombs he will use.
  2653.   -- NPCDefensiveness      [] 1-10 - determines how worried the NPC is over his HP.
  2654.   -- NPCAccuracy           [] 1-10 - determines which attack (ACCURATE / BALANCED / STRONG) he's more likely to use.
  2655.  
  2656.   -- Random weights, so that nothing takes priority. Bigger weight = better chance of it happening. No max / min.
  2657.   local ATK1weight = 0 -- Accurate
  2658.   local ATK2weight = 0 -- Balanced
  2659.   local ATK3weight = 0 -- Strong
  2660.   local MGC1weight = 0 -- Shield
  2661.   local MGC2weight = 0 -- Element
  2662.   local MGC3weight = 0 -- Cure
  2663.   local ITM1weight = 0 -- HP Potion
  2664.   local ITM2weight = 0 -- MP Potion
  2665.   local ITM3weight = 0 -- Bomb
  2666.  
  2667.   -- First, Analyze self and do defensive stuff
  2668.   if NPCHP <= (NPCDefensiveness * 75) * (NPCtier / 2) then -- Basically, each "Defensiveness" point is worth 7.5%. Determines how low NPC HP has to be before heal.
  2669.     if NPCHPpots > 0 then
  2670.       local randomize = math.random(1,12)
  2671.       ITM1weight = NPCDefensiveness * 5
  2672.     end
  2673.   end
  2674.   if NPCstatus ~= "   " then
  2675.     if NPCMP >= MGC3cost then
  2676.       local randomize = math.random(1,16)
  2677.       MGC3weight = NPCDefensiveness * 5
  2678.     end
  2679.   end
  2680.   if NPCshielded <= 0 then
  2681.     if NPCMP >= MGC1cost then
  2682.       local randomize = math.random(1,16)
  2683.       MGC1weight = NPCDefensiveness * 3
  2684.     end
  2685.   end
  2686.   if NPCMP <= 300 then
  2687.     if NPCMPpots > 0 then
  2688.       local randomize = math.random(1,16)
  2689.       ITM2weight = NPCDefensiveness * 3
  2690.     end
  2691.   end
  2692.  
  2693.   -- Then start attacking!
  2694.   local Charge1 = 1 - NPCAccuracy
  2695.   local Charge2 = 5 - NPCAccuracy
  2696.   local Charge3 = 10 - NPCAccuracy
  2697.   if Charge1 < 0 then   Charge1 = Charge1 * -1  end
  2698.   if Charge2 < 0 then   Charge2 = Charge2 * -1  end
  2699.   if Charge3 < 0 then   Charge3 = Charge3 * -1  end
  2700.   if Charge1 > 6 then   Charge1 = 6     end
  2701.   if Charge2 > 6 then   Charge2 = 6     end
  2702.   if Charge3 > 6 then   Charge3 = 6     end
  2703.   Charge1 = 6 - Charge1
  2704.   Charge2 = 6 - Charge2
  2705.   Charge3 = 6 - Charge3
  2706.   ATK1weight = Charge1 * NPCAggressiveness
  2707.   ATK2weight = Charge2 * NPCAggressiveness
  2708.   ATK3weight = Charge3 * NPCAggressiveness
  2709.  
  2710.   -- Select target, make sure target isn't dead
  2711.   local changeTarget = math.random(1,11)
  2712.   if NPCtarget == "P1" and P1status == "KO " then
  2713.     changeTarget = 11
  2714.   elseif NPCtarget == "P2" and P2status == "KO " then
  2715.     changeTarget = 11
  2716.   elseif NPCtarget == "P3" and P3status == "KO " then
  2717.     changeTarget = 11
  2718.   end
  2719.   if changeTarget > NPCAggressiveness then
  2720.     local targetSet = 0
  2721.     while targetSet ~= 0 do
  2722.       local targetSelect = math.random(1,3)
  2723.       print("Target: "..targetSelect)
  2724.       if targetSelect == 1 and P1status ~= "KO " then
  2725.         NPCtarget = "P1"
  2726.         targetSet = 1
  2727.       elseif targetSelect == 2 and P2status ~= "KO " then
  2728.         NPCtarget = "P2"
  2729.         targetSet = 1
  2730.       elseif targetSelect == 3 and P3status ~= "KO " then
  2731.         NPCtarget = "P3"
  2732.         targetSet = 1
  2733.       end
  2734.     end
  2735.   end
  2736.   -- NPC shouldn't cast Element on players already under a status problem, so it's below target selection
  2737.   -- NPC also shouldn't waste bombs on players almost dead.
  2738.  
  2739.   if NPCtarget == "P1" then
  2740.     if P1HP >= 300 then
  2741.       ITM3weight = NPCAggressiveness * 3
  2742.     end
  2743.     if P1status == "   " and NPCMP >= MGC2cost then
  2744.       MGC2weight = NPCAggressiveness * 4
  2745.     end
  2746.   elseif NPCtarget == "P2" then
  2747.     if P2HP >= 300 then
  2748.       ITM3weight = NPCAggressiveness * 3
  2749.     end
  2750.     if P2status == "   " and NPCMP >= MGC2cost then
  2751.       MGC2weight = NPCAggressiveness * 4
  2752.     end
  2753.   else
  2754.     if P3HP >= 300 then
  2755.       ITM3weight = NPCAggressiveness * 3
  2756.     end
  2757.     if P3status == "   " and NPCMP >= MGC2cost then
  2758.       MGC2weight = NPCAggressiveness * 4
  2759.     end
  2760.   end
  2761.  
  2762.   local activeAbility = math.random(1, (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight + ITM3weight + MGC1weight + MGC2weight + MGC3weight))
  2763.   if activeAbility <= (ATK1weight) then
  2764.     return "ATK 1"
  2765.   elseif activeAbility <= (ATK1weight + ATK2weight) then
  2766.     return "ATK 2"
  2767.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight) then
  2768.     return "ATK 3"
  2769.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight) then
  2770.     return "ITM 1"
  2771.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight) then
  2772.     return "ITM 2"
  2773.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight + ITM3weight) then
  2774.     return "ITM 3"
  2775.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight + ITM3weight + MGC1weight) then
  2776.     return "MGC 1"
  2777.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight + ITM3weight + MGC1weight + MGC2weight) then
  2778.     return "MGC 2"
  2779.   elseif activeAbility <= (ATK1weight + ATK2weight + ATK3weight + ITM1weight + ITM2weight + ITM3weight + MGC1weight + MGC2weight + MGC3weight) then
  2780.     return "MGC 3"
  2781.   end
  2782. end
  2783.  
  2784. function checkDeath(target)
  2785.   if target == "P1" then
  2786.     if P1HP <= 0 then -- he is dead
  2787.       P1status = "KO "
  2788.       mon.setCursorPos(4,7)
  2789.       mon.write(stringBG)
  2790.       mon.setCursorPos(4,7)
  2791.       mon.write(" PLAYER 1 was slain... ")
  2792.       mon.setCursorPos(6,9)
  2793.       mon.write(drawP1Adead)
  2794.       mon.setCursorPos(6,10)
  2795.       mon.write(drawP1Bdead)
  2796.       mon.setCursorPos(6,11)
  2797.       mon.write(drawP1Cdead)
  2798.       sleep(2)
  2799.     else
  2800.       if P1status ~= "   " and P1status ~= "KO " then
  2801.         mon.setCursorPos(6,9)
  2802.         mon.write(drawP1Ahurt)
  2803.         mon.setCursorPos(6,10)
  2804.         mon.write(drawP1Bhurt)
  2805.         mon.setCursorPos(6,11)
  2806.         mon.write(drawP1Churt)
  2807.       elseif P1HP <= 250 then
  2808.         mon.setCursorPos(6,9)
  2809.         mon.write(drawP1Ahurt)
  2810.         mon.setCursorPos(6,10)
  2811.         mon.write(drawP1Bhurt)
  2812.         mon.setCursorPos(6,11)
  2813.         mon.write(drawP1Churt)
  2814.       else
  2815.         mon.setCursorPos(6,9)
  2816.         mon.write(drawP1Anorm)
  2817.         mon.setCursorPos(6,10)
  2818.         mon.write(drawP1Bnorm)
  2819.         mon.setCursorPos(6,11)
  2820.         mon.write(drawP1Cnorm)
  2821.       end
  2822.     end
  2823.   elseif target == "P2" then
  2824.     if P2HP <= 0 then -- he is dead
  2825.       P2status = "KO "
  2826.       mon.setCursorPos(4,7)
  2827.       mon.write(stringBG)
  2828.       mon.setCursorPos(4,7)
  2829.       mon.write(" PLAYER 2 was slain... ")
  2830.       mon.setCursorPos(23,9)
  2831.       mon.write(drawP2Adead)
  2832.       mon.setCursorPos(23,10)
  2833.       mon.write(drawP2Bdead)
  2834.       mon.setCursorPos(23,11)
  2835.       mon.write(drawP2Cdead)
  2836.       sleep(2)
  2837.     else
  2838.       if P1status ~= "   " and P1status ~= "KO " then
  2839.         mon.setCursorPos(23,9)
  2840.         mon.write(drawP2Ahurt)
  2841.         mon.setCursorPos(23,10)
  2842.         mon.write(drawP2Bhurt)
  2843.         mon.setCursorPos(23,11)
  2844.         mon.write(drawP2Churt)
  2845.       elseif P1HP <= 250 then
  2846.         mon.setCursorPos(23,9)
  2847.         mon.write(drawP2Ahurt)
  2848.         mon.setCursorPos(23,10)
  2849.         mon.write(drawP2Bhurt)
  2850.         mon.setCursorPos(23,11)
  2851.         mon.write(drawP2Churt)
  2852.       else
  2853.         mon.setCursorPos(23,9)
  2854.         mon.write(drawP2Anorm)
  2855.         mon.setCursorPos(23,10)
  2856.         mon.write(drawP2Bnorm)
  2857.         mon.setCursorPos(23,11)
  2858.         mon.write(drawP2Cnorm)
  2859.       end
  2860.     end
  2861.   elseif target == "P3" then
  2862.     if P3HP <= 0 then -- he is dead
  2863.       P3status = "KO "
  2864.       mon.setCursorPos(4,7)
  2865.       mon.write(stringBG)
  2866.       mon.setCursorPos(4,7)
  2867.       mon.write(" PLAYER 3 was slain... ")
  2868.       mon.setCursorPos(40,9)
  2869.       mon.write(drawP3Adead)
  2870.       mon.setCursorPos(40,10)
  2871.       mon.write(drawP3Bdead)
  2872.       mon.setCursorPos(40,11)
  2873.       mon.write(drawP3Cdead)
  2874.       sleep(2)
  2875.     else
  2876.       if P1status ~= "   " and P1status ~= "KO " then
  2877.         mon.setCursorPos(40,9)
  2878.         mon.write(drawP3Ahurt)
  2879.         mon.setCursorPos(40,10)
  2880.         mon.write(drawP3Bhurt)
  2881.         mon.setCursorPos(40,11)
  2882.         mon.write(drawP3Churt)
  2883.       elseif P1HP <= 250 then
  2884.         mon.setCursorPos(40,9)
  2885.         mon.write(drawP3Ahurt)
  2886.         mon.setCursorPos(40,10)
  2887.         mon.write(drawP3Bhurt)
  2888.         mon.setCursorPos(40,11)
  2889.         mon.write(drawP3Churt)
  2890.       else
  2891.         mon.setCursorPos(40,9)
  2892.         mon.write(drawP3Anorm)
  2893.         mon.setCursorPos(40,10)
  2894.         mon.write(drawP3Bnorm)
  2895.         mon.setCursorPos(40,11)
  2896.         mon.write(drawP3Cnorm)
  2897.       end
  2898.     end
  2899.   else
  2900.     if NPCHP <= 0 then -- he is dead
  2901.       NPCstatus = "KO "
  2902.       mon.setCursorPos(4,7)
  2903.       mon.write(stringBG)
  2904.       mon.setCursorPos(4,7)
  2905.       mon.write(" "..NPCname.." was slain... ")
  2906.       mon.setCursorPos(1,3)
  2907.       mon.write("                                               ")
  2908.       mon.setCursorPos(1,4)
  2909.       mon.write("                                               ")
  2910.       mon.setCursorPos(1,5)
  2911.       mon.write("                                               ")
  2912.       sleep(2)
  2913.     end
  2914.   end
  2915.   if P1status == "KO " and P2status == "KO " and P3status == "KO " then
  2916.     mon.setCursorPos(4,7)
  2917.     mon.write(stringBG)
  2918.     mon.setCursorPos(4,7)
  2919.     mon.write(" All players defeated! YOU LOSE... ")
  2920.     sleep(2)
  2921.     os.reboot()
  2922.   end
  2923. end
  2924.  
  2925. function drawScreen()  -- Basically just reloads all the bars and stuff.
  2926.   mon.setCursorPos(1,1)
  2927.   mon.write(" HP["..drawBar(NPCHP, 1000 * (NPCtier/2), 20).."] ["..NPCname.."]                     ")
  2928.   mon.setCursorPos(1,2)
  2929.   mon.write("   ["..NPCstatus.."]                                      ")
  2930.   if NPCstatus ~= "KO " then
  2931.     mon.setCursorPos(1,3)
  2932.     mon.write("                "..NPCdrawA.."                ")
  2933.     mon.setCursorPos(1,4)
  2934.     mon.write("                "..NPCdrawB.."                ")
  2935.     mon.setCursorPos(1,5)
  2936.     mon.write("                "..NPCdrawC.."                ")
  2937.   end
  2938.   mon.setCursorPos(1,12)
  2939.   mon.write(" [P1]     ["..P1status.."]  [P2]     ["..P2status.."]  [P3]     ["..P3status.."] ")
  2940.   mon.setCursorPos(1,13)
  2941.   mon.write(" HP["..drawBar(P1HP, 1000, 10).."]  HP["..drawBar(P2HP, 1000, 10).."]  HP["..drawBar(P3HP, 1000, 10).."] ")
  2942.   mon.setCursorPos(1,14)
  2943.   mon.write(" MP["..drawBar(P1MP, 1000, 10).."]  MP["..drawBar(P2MP, 1000, 10).."]  MP["..drawBar(P3MP, 1000, 10).."] ")
  2944.   if turn == "Input" then
  2945.     mon.setCursorPos(4,7)
  2946.     mon.write(" What will P1, P2 and P3 do? ")  -- YOU CAN CHANGE THIS, but make sure to leave spaces on the side, and max 41 chars total, including the spaces.
  2947.   end
  2948. end
  2949.  
  2950. -- *** Redstone Input ***
  2951.  
  2952. while true do
  2953.   sleep(0.05)
  2954.   print(" - Activating Redstone Loop - "..turn)
  2955.   local rEvent, param = os.pullEvent()
  2956.   rs.setOutput(stopperside, true)
  2957.   if rEvent == "redstone" then
  2958.     if redstone.getBundledInput(detectside) then
  2959.       if redstone.testBundledInput(detectside, colors.white) then             -- Insert Coin
  2960.         credits = credits + creditspercoin
  2961.         if credits <= 3 then
  2962.           local coinage = 3 - credits
  2963.           mon.setCursorPos(1,16)
  2964.           mon.write(" INSERT "..coinage.." MORE COINS")
  2965.           mon.setCursorPos(1,17)
  2966.           mon.write("  TO BEGIN THE GAME   ")
  2967.         else
  2968.           mon.setCursorPos(1,16)
  2969.           mon.write(" PLAYER 1, PRESS [B]  ")
  2970.           mon.setCursorPos(1,17)
  2971.           mon.write("  TO BEGIN THE GAME   ")
  2972.         end
  2973.       elseif redstone.testBundledInput(detectside, colors.yellow) then        -- P1 [A]
  2974.         if turn == "Input" then
  2975.           if P1selected == "" then
  2976.             P1selected = "ATK .."
  2977.             mon.setCursorPos(5,15)
  2978.             mon.write(stringHUDATK1)
  2979.             mon.setCursorPos(5,16)
  2980.             mon.write(stringHUDATK2)
  2981.             mon.setCursorPos(5,17)
  2982.             mon.write(stringHUDATK3)
  2983.           elseif P1selected == "ATK .." then
  2984.             P1selected = "ATK 1"
  2985.             P1ready = 1
  2986.             mon.setCursorPos(5,15)
  2987.             mon.write(stringHUDATK)
  2988.             mon.setCursorPos(5,16)
  2989.             mon.write(stringHUDATK1)
  2990.             mon.setCursorPos(5,17)
  2991.             mon.write("  READY!  ")
  2992.             checkReady()
  2993.           elseif P1selected == "MGC .." then
  2994.             if P1MP >= MGC1cost then
  2995.               P1selected = "MGC 1 .."
  2996.               mon.setCursorPos(5,15)
  2997.               mon.write("PLAYER 1  ")
  2998.               mon.setCursorPos(5,16)
  2999.               mon.write("PLAYER 2  ")
  3000.               mon.setCursorPos(5,17)
  3001.               mon.write("PLAYER 3  ")
  3002.             end
  3003.           elseif P1selected == "ITM .." then
  3004.             if P1HPpots > 0 then
  3005.               P1selected = "ITM 1 .."
  3006.               mon.setCursorPos(5,15)
  3007.               mon.write("PLAYER 1  ")
  3008.               mon.setCursorPos(5,16)
  3009.               mon.write("PLAYER 2  ")
  3010.               mon.setCursorPos(5,17)
  3011.               mon.write("PLAYER 3  ")
  3012.             end
  3013.           elseif P1selected == "MGC 1 .." then
  3014.             P1selected = "MGC 1"
  3015.             P1target = "P1"
  3016.             P1ready = 1
  3017.             mon.setCursorPos(5,15)
  3018.             mon.write(stringHUDMGC)
  3019.             mon.setCursorPos(5,16)
  3020.             mon.write(stringHUDMGC1)
  3021.             mon.setCursorPos(5,17)
  3022.             mon.write("  READY!  ")
  3023.             checkReady()
  3024.           elseif P1selected == "MGC 3 .." then
  3025.             P1selected = "MGC 3"
  3026.             P1target = "P1"
  3027.             P1ready = 1
  3028.             mon.setCursorPos(5,15)
  3029.             mon.write(stringHUDMGC)
  3030.             mon.setCursorPos(5,16)
  3031.             mon.write(stringHUDMGC3)
  3032.             mon.setCursorPos(5,17)
  3033.             mon.write("  READY!  ")
  3034.             checkReady()
  3035.           elseif P1selected == "ITM 1 .." then
  3036.             P1selected = "ITM 1"
  3037.             P1target = "P1"
  3038.             P1ready = 1
  3039.             mon.setCursorPos(5,15)
  3040.             mon.write(stringHUDITM)
  3041.             mon.setCursorPos(5,16)
  3042.             mon.write(stringHUDITM1)
  3043.             mon.setCursorPos(5,17)
  3044.             mon.write("  READY!  ")
  3045.             checkReady()
  3046.           elseif P1selected == "ITM 2 .." then
  3047.             P1selected = "ITM 2"
  3048.             P1target = "P1"
  3049.             P1ready = 1
  3050.             mon.setCursorPos(5,15)
  3051.             mon.write(stringHUDITM)
  3052.             mon.setCursorPos(5,16)
  3053.             mon.write(stringHUDITM2)
  3054.             mon.setCursorPos(5,17)
  3055.             mon.write("  READY!  ")
  3056.             checkReady()
  3057.           end
  3058.         end
  3059.       elseif redstone.testBundledInput(detectside, colors.orange) then        -- P1 [B]
  3060.         if turn == "Coin" then
  3061.           if credits >= 3 then
  3062.             startgame()
  3063.             turn = "Input"
  3064.           end
  3065.         elseif turn == "Input" then
  3066.           if P1selected == "" then
  3067.             P1selected = "MGC .."
  3068.             mon.setCursorPos(5,15)
  3069.             mon.write(stringHUDMGC1)
  3070.             mon.setCursorPos(5,16)
  3071.             mon.write(stringHUDMGC2)
  3072.             mon.setCursorPos(5,17)
  3073.             mon.write(stringHUDMGC3)
  3074.           elseif P1selected == "ATK .." then
  3075.             P1selected = "ATK 2"
  3076.             P1ready = 1
  3077.             mon.setCursorPos(5,15)
  3078.             mon.write(stringHUDATK)
  3079.             mon.setCursorPos(5,16)
  3080.             mon.write(stringHUDATK2)
  3081.             mon.setCursorPos(5,17)
  3082.             mon.write("  READY!  ")
  3083.             checkReady()
  3084.           elseif P1selected == "MGC .." then
  3085.             if P1MP >= MGC2cost then
  3086.               P1selected = "MGC 2"
  3087.               P1ready = 1
  3088.               mon.setCursorPos(5,15)
  3089.               mon.write(stringHUDMGC)
  3090.               mon.setCursorPos(5,16)
  3091.               mon.write(stringHUDMGC2)
  3092.               mon.setCursorPos(5,17)
  3093.               mon.write("  READY!  ")
  3094.               checkReady()
  3095.             end
  3096.           elseif P1selected == "ITM .." then
  3097.             if P1MPpots > 0 then
  3098.               P1selected = "ITM 2 .."
  3099.               mon.setCursorPos(5,15)
  3100.               mon.write("PLAYER 1  ")
  3101.               mon.setCursorPos(5,16)
  3102.               mon.write("PLAYER 2  ")
  3103.               mon.setCursorPos(5,17)
  3104.               mon.write("PLAYER 3  ")
  3105.             end
  3106.           elseif P1selected == "MGC 1 .." then
  3107.             P1selected = "MGC 1"
  3108.             P1target = "P2"
  3109.             P1ready = 1
  3110.             mon.setCursorPos(5,15)
  3111.             mon.write(stringHUDMGC)
  3112.             mon.setCursorPos(5,16)
  3113.             mon.write(stringHUDMGC1)
  3114.             mon.setCursorPos(5,17)
  3115.             mon.write("  READY!  ")
  3116.             checkReady()
  3117.           elseif P1selected == "MGC 3 .." then
  3118.             P1selected = "MGC 3"
  3119.             P1target = "P2"
  3120.             P1ready = 1
  3121.             mon.setCursorPos(5,15)
  3122.             mon.write(stringHUDMGC)
  3123.             mon.setCursorPos(5,16)
  3124.             mon.write(stringHUDMGC3)
  3125.             mon.setCursorPos(5,17)
  3126.             mon.write("  READY!  ")
  3127.             checkReady()
  3128.           elseif P1selected == "ITM 1 .." then
  3129.             P1selected = "ITM 1"
  3130.             P1target = "P2"
  3131.             P1ready = 1
  3132.             mon.setCursorPos(5,15)
  3133.             mon.write(stringHUDITM)
  3134.             mon.setCursorPos(5,16)
  3135.             mon.write(stringHUDITM1)
  3136.             mon.setCursorPos(5,17)
  3137.             mon.write("  READY!  ")
  3138.             checkReady()
  3139.           elseif P1selected == "ITM 2 .." then
  3140.             P1selected = "ITM 2"
  3141.             P1target = "P2"
  3142.             P1ready = 1
  3143.             mon.setCursorPos(5,15)
  3144.             mon.write(stringHUDITM)
  3145.             mon.setCursorPos(5,16)
  3146.             mon.write(stringHUDITM2)
  3147.             mon.setCursorPos(5,17)
  3148.             mon.write("  READY!  ")
  3149.             checkReady()
  3150.           end
  3151.         end
  3152.       elseif redstone.testBundledInput(detectside, colors.red) then           -- P1 [C]
  3153.         if turn == "Input" then
  3154.           if P1selected == "" then
  3155.             P1selected = "ITM .."
  3156.             mon.setCursorPos(5,15)
  3157.             mon.write(stringHUDITM1)
  3158.             mon.setCursorPos(5,16)
  3159.             mon.write(stringHUDITM2)
  3160.             mon.setCursorPos(5,17)
  3161.             mon.write(stringHUDITM3)
  3162.             mon.setCursorPos(13,15)
  3163.             mon.write(P1HPpots)
  3164.             mon.setCursorPos(13,16)
  3165.             mon.write(P1MPpots)
  3166.             mon.setCursorPos(13,17)
  3167.             mon.write(P1bombs)
  3168.           elseif P1selected == "ATK .." then
  3169.             P1selected = "ATK 3"
  3170.             P1ready = 1
  3171.             mon.setCursorPos(5,15)
  3172.             mon.write(stringHUDATK)
  3173.             mon.setCursorPos(5,16)
  3174.             mon.write(stringHUDATK3)
  3175.             mon.setCursorPos(5,17)
  3176.             mon.write("  READY!  ")
  3177.             checkReady()
  3178.           elseif P1selected == "MGC .." then
  3179.             if P1MP >= MGC3cost then
  3180.               P1selected = "MGC 3 .."
  3181.               mon.setCursorPos(5,15)
  3182.               mon.write("PLAYER 1  ")
  3183.               mon.setCursorPos(5,16)
  3184.               mon.write("PLAYER 2  ")
  3185.               mon.setCursorPos(5,17)
  3186.               mon.write("PLAYER 3  ")
  3187.             end
  3188.           elseif P1selected == "ITM .." then
  3189.             if P1bombs > 0 then
  3190.               P1selected = "ITM 3"
  3191.               P1ready = 1
  3192.               mon.setCursorPos(5,15)
  3193.               mon.write(stringHUDITM)
  3194.               mon.setCursorPos(5,16)
  3195.               mon.write(stringHUDITM3)
  3196.               mon.setCursorPos(5,17)
  3197.               mon.write("  READY!  ")
  3198.               checkReady()
  3199.             end
  3200.           elseif P1selected == "MGC 1 .." then
  3201.             P1selected = "MGC 1"
  3202.             P1target = "P3"
  3203.             P1ready = 1
  3204.             mon.setCursorPos(5,15)
  3205.             mon.write(stringHUDMGC)
  3206.             mon.setCursorPos(5,16)
  3207.             mon.write(stringHUDMGC1)
  3208.             mon.setCursorPos(5,17)
  3209.             mon.write("  READY!  ")
  3210.             checkReady()
  3211.           elseif P1selected == "MGC 3 .." then
  3212.             P1selected = "MGC 3"
  3213.             P1target = "P3"
  3214.             P1ready = 1
  3215.             mon.setCursorPos(5,15)
  3216.             mon.write(stringHUDMGC)
  3217.             mon.setCursorPos(5,16)
  3218.             mon.write(stringHUDMGC3)
  3219.             mon.setCursorPos(5,17)
  3220.             mon.write("  READY!  ")
  3221.             checkReady()
  3222.           elseif P1selected == "ITM 1 .." then
  3223.             P1selected = "ITM 1"
  3224.             P1target = "P3"
  3225.             P1ready = 1
  3226.             mon.setCursorPos(5,15)
  3227.             mon.write(stringHUDITM)
  3228.             mon.setCursorPos(5,16)
  3229.             mon.write(stringHUDITM1)
  3230.             mon.setCursorPos(5,17)
  3231.             mon.write("  READY!  ")
  3232.             checkReady()
  3233.           elseif P1selected == "ITM 2 .." then
  3234.             P1selected = "ITM 2"
  3235.             P1target = "P3"
  3236.             P1ready = 1
  3237.             mon.setCursorPos(5,15)
  3238.             mon.write(stringHUDITM)
  3239.             mon.setCursorPos(5,16)
  3240.             mon.write(stringHUDITM2)
  3241.             mon.setCursorPos(5,17)
  3242.             mon.write("  READY!  ")
  3243.             checkReady()
  3244.           end
  3245.         end
  3246.       elseif redstone.testBundledInput(detectside, colors.lime) then          -- P2 [A]
  3247.         if turn == "Input" then
  3248.           if P2selected == "" then
  3249.             P2selected = "ATK .."
  3250.             mon.setCursorPos(21,15)
  3251.             mon.write(stringHUDATK1)
  3252.             mon.setCursorPos(21,16)
  3253.             mon.write(stringHUDATK2)
  3254.             mon.setCursorPos(21,17)
  3255.             mon.write(stringHUDATK3)
  3256.           elseif P2selected == "ATK .." then
  3257.             P2selected = "ATK 1"
  3258.             P2ready = 1
  3259.             mon.setCursorPos(21,15)
  3260.             mon.write(stringHUDATK)
  3261.             mon.setCursorPos(21,16)
  3262.             mon.write(stringHUDATK1)
  3263.             mon.setCursorPos(21,17)
  3264.             mon.write("  READY!  ")
  3265.             checkReady()
  3266.           elseif P2selected == "MGC .." then
  3267.             if P2MP >= MGC1cost then
  3268.               P2selected = "MGC 1 .."
  3269.               mon.setCursorPos(21,15)
  3270.               mon.write("PLAYER 1  ")
  3271.               mon.setCursorPos(21,16)
  3272.               mon.write("PLAYER 2  ")
  3273.               mon.setCursorPos(21,17)
  3274.               mon.write("PLAYER 3  ")
  3275.             end
  3276.           elseif P2selected == "ITM .." then
  3277.             if P2HPpots > 0 then
  3278.               P2selected = "ITM 1 .."
  3279.               mon.setCursorPos(21,15)
  3280.               mon.write("PLAYER 1  ")
  3281.               mon.setCursorPos(21,16)
  3282.               mon.write("PLAYER 2  ")
  3283.               mon.setCursorPos(21,17)
  3284.               mon.write("PLAYER 3  ")
  3285.             end
  3286.           elseif P2selected == "MGC 1 .." then
  3287.             P2selected = "MGC 1"
  3288.             P2target = "P1"
  3289.             P2ready = 1
  3290.             mon.setCursorPos(21,15)
  3291.             mon.write(stringHUDMGC)
  3292.             mon.setCursorPos(21,16)
  3293.             mon.write(stringHUDMGC1)
  3294.             mon.setCursorPos(21,17)
  3295.             mon.write("  READY!  ")
  3296.             checkReady()
  3297.           elseif P2selected == "MGC 3 .." then
  3298.             P2selected = "MGC 3"
  3299.             P2target = "P1"
  3300.             P2ready = 1
  3301.             mon.setCursorPos(21,15)
  3302.             mon.write(stringHUDMGC)
  3303.             mon.setCursorPos(21,16)
  3304.             mon.write(stringHUDMGC3)
  3305.             mon.setCursorPos(21,17)
  3306.             mon.write("  READY!  ")
  3307.             checkReady()
  3308.           elseif P2selected == "ITM 1 .." then
  3309.             P2selected = "ITM 1"
  3310.             P2target = "P1"
  3311.             P2ready = 1
  3312.             mon.setCursorPos(21,15)
  3313.             mon.write(stringHUDITM)
  3314.             mon.setCursorPos(21,16)
  3315.             mon.write(stringHUDITM1)
  3316.             mon.setCursorPos(21,17)
  3317.             mon.write("  READY!  ")
  3318.             checkReady()
  3319.           elseif P2selected == "ITM 2 .." then
  3320.             P2selected = "ITM 2"
  3321.             P2target = "P1"
  3322.             P2ready = 1
  3323.             mon.setCursorPos(21,15)
  3324.             mon.write(stringHUDITM)
  3325.             mon.setCursorPos(21,16)
  3326.             mon.write(stringHUDITM2)
  3327.             mon.setCursorPos(21,17)
  3328.             mon.write("  READY!  ")
  3329.             checkReady()
  3330.           end
  3331.         end
  3332.       elseif redstone.testBundledInput(detectside, colors.green) then         -- P2 [B]
  3333.         if turn == "Input" then
  3334.           if P2selected == "" then
  3335.             P2selected = "MGC .."
  3336.             mon.setCursorPos(21,15)
  3337.             mon.write(stringHUDMGC1)
  3338.             mon.setCursorPos(21,16)
  3339.             mon.write(stringHUDMGC2)
  3340.             mon.setCursorPos(21,17)
  3341.             mon.write(stringHUDMGC3)
  3342.           elseif P2selected == "ATK .." then
  3343.             P2selected = "ATK 2"
  3344.             P2ready = 1
  3345.             mon.setCursorPos(21,15)
  3346.             mon.write(stringHUDATK)
  3347.             mon.setCursorPos(21,16)
  3348.             mon.write(stringHUDATK2)
  3349.             mon.setCursorPos(21,17)
  3350.             mon.write("  READY!  ")
  3351.             checkReady()
  3352.           elseif P2selected == "MGC .." then
  3353.             if P2MP >= MGC2cost then
  3354.               P2selected = "MGC 2"
  3355.               P2ready = 1
  3356.               mon.setCursorPos(21,15)
  3357.               mon.write(stringHUDMGC)
  3358.               mon.setCursorPos(21,16)
  3359.               mon.write(stringHUDMGC2)
  3360.               mon.setCursorPos(21,17)
  3361.               mon.write("  READY!  ")
  3362.               checkReady()
  3363.             end
  3364.           elseif P2selected == "ITM .." then
  3365.             if P2MPpots > 0 then
  3366.               P2selected = "ITM 2 .."
  3367.               mon.setCursorPos(21,15)
  3368.               mon.write("PLAYER 1  ")
  3369.               mon.setCursorPos(21,16)
  3370.               mon.write("PLAYER 2  ")
  3371.               mon.setCursorPos(21,17)
  3372.               mon.write("PLAYER 3  ")
  3373.             end
  3374.           elseif P2selected == "MGC 1 .." then
  3375.             P2selected = "MGC 1"
  3376.             P2target = "P2"
  3377.             P2ready = 1
  3378.             mon.setCursorPos(21,15)
  3379.             mon.write(stringHUDMGC)
  3380.             mon.setCursorPos(21,16)
  3381.             mon.write(stringHUDMGC1)
  3382.             mon.setCursorPos(21,17)
  3383.             mon.write("  READY!  ")
  3384.             checkReady()
  3385.           elseif P2selected == "MGC 3 .." then
  3386.             P2selected = "MGC 3"
  3387.             P2target = "P2"
  3388.             P2ready = 1
  3389.             mon.setCursorPos(21,15)
  3390.             mon.write(stringHUDMGC)
  3391.             mon.setCursorPos(21,16)
  3392.             mon.write(stringHUDMGC3)
  3393.             mon.setCursorPos(21,17)
  3394.             mon.write("  READY!  ")
  3395.             checkReady()
  3396.           elseif P2selected == "ITM 1 .." then
  3397.             P2selected = "ITM 1"
  3398.             P2target = "P2"
  3399.             P2ready = 1
  3400.             mon.setCursorPos(21,15)
  3401.             mon.write(stringHUDITM)
  3402.             mon.setCursorPos(21,16)
  3403.             mon.write(stringHUDITM1)
  3404.             mon.setCursorPos(21,17)
  3405.             mon.write("  READY!  ")
  3406.             checkReady()
  3407.           elseif P2selected == "ITM 2 .." then
  3408.             P2selected = "ITM 2"
  3409.             P2target = "P2"
  3410.             P2ready = 1
  3411.             mon.setCursorPos(21,15)
  3412.             mon.write(stringHUDITM)
  3413.             mon.setCursorPos(21,16)
  3414.             mon.write(stringHUDITM2)
  3415.             mon.setCursorPos(21,17)
  3416.             mon.write("  READY!  ")
  3417.             checkReady()
  3418.           end
  3419.         end
  3420.       elseif redstone.testBundledInput(detectside, colors.brown) then         -- P2 [C]
  3421.         if turn == "Input" then
  3422.           if P2selected == "" then
  3423.             P2selected = "ITM .."
  3424.             mon.setCursorPos(21,15)
  3425.             mon.write(stringHUDITM1)
  3426.             mon.setCursorPos(21,16)
  3427.             mon.write(stringHUDITM2)
  3428.             mon.setCursorPos(21,17)
  3429.             mon.write(stringHUDITM3)
  3430.             mon.setCursorPos(29,15)
  3431.             mon.write(P2HPpots)
  3432.             mon.setCursorPos(29,16)
  3433.             mon.write(P2MPpots)
  3434.             mon.setCursorPos(29,17)
  3435.             mon.write(P2bombs)
  3436.           elseif P2selected == "ATK .." then
  3437.             P2selected = "ATK 3"
  3438.             P2ready = 1
  3439.             mon.setCursorPos(21,15)
  3440.             mon.write(stringHUDATK)
  3441.             mon.setCursorPos(21,16)
  3442.             mon.write(stringHUDATK3)
  3443.             mon.setCursorPos(21,17)
  3444.             mon.write("  READY!  ")
  3445.             checkReady()
  3446.           elseif P2selected == "MGC .." then
  3447.             if P2MP >= MGC3cost then
  3448.               P2selected = "MGC 3 .."
  3449.               mon.setCursorPos(21,15)
  3450.               mon.write("PLAYER 1  ")
  3451.               mon.setCursorPos(21,16)
  3452.               mon.write("PLAYER 2  ")
  3453.               mon.setCursorPos(21,17)
  3454.               mon.write("PLAYER 3  ")
  3455.             end
  3456.           elseif P2selected == "ITM .." then
  3457.             if P2bombs > 0 then
  3458.               P2selected = "ITM 3"
  3459.               P2ready = 1
  3460.               mon.setCursorPos(21,15)
  3461.               mon.write(stringHUDITM)
  3462.               mon.setCursorPos(21,16)
  3463.               mon.write(stringHUDITM3)
  3464.               mon.setCursorPos(21,17)
  3465.               mon.write("  READY!  ")
  3466.               checkReady()
  3467.             end
  3468.           elseif P2selected == "MGC 1 .." then
  3469.             P2selected = "MGC 1"
  3470.             P2target = "P3"
  3471.             P2ready = 1
  3472.             mon.setCursorPos(21,15)
  3473.             mon.write(stringHUDMGC)
  3474.             mon.setCursorPos(21,16)
  3475.             mon.write(stringHUDMGC1)
  3476.             mon.setCursorPos(21,17)
  3477.             mon.write("  READY!  ")
  3478.             checkReady()
  3479.           elseif P2selected == "MGC 3 .." then
  3480.             P2selected = "MGC 3"
  3481.             P2target = "P3"
  3482.             P2ready = 1
  3483.             mon.setCursorPos(21,15)
  3484.             mon.write(stringHUDMGC)
  3485.             mon.setCursorPos(21,16)
  3486.             mon.write(stringHUDMGC3)
  3487.             mon.setCursorPos(21,17)
  3488.             mon.write("  READY!  ")
  3489.             checkReady()
  3490.           elseif P2selected == "ITM 1 .." then
  3491.             P2selected = "ITM 1"
  3492.             P2target = "P3"
  3493.             P2ready = 1
  3494.             mon.setCursorPos(21,15)
  3495.             mon.write(stringHUDITM)
  3496.             mon.setCursorPos(21,16)
  3497.             mon.write(stringHUDITM1)
  3498.             mon.setCursorPos(21,17)
  3499.             mon.write("  READY!  ")
  3500.             checkReady()
  3501.           elseif P2selected == "ITM 2 .." then
  3502.             P2selected = "ITM 2"
  3503.             P2target = "P3"
  3504.             P2ready = 1
  3505.             mon.setCursorPos(21,15)
  3506.             mon.write(stringHUDITM)
  3507.             mon.setCursorPos(21,16)
  3508.             mon.write(stringHUDITM2)
  3509.             mon.setCursorPos(21,17)
  3510.             mon.write("  READY!  ")
  3511.             checkReady()
  3512.           end
  3513.         end
  3514.       elseif redstone.testBundledInput(detectside, colors.lightBlue) then     -- P3 [A]
  3515.         if turn == "Input" then
  3516.           if P3selected == "" then
  3517.             P3selected = "ATK .."
  3518.             mon.setCursorPos(37,15)
  3519.             mon.write(stringHUDATK1)
  3520.             mon.setCursorPos(37,16)
  3521.             mon.write(stringHUDATK2)
  3522.             mon.setCursorPos(37,17)
  3523.             mon.write(stringHUDATK3)
  3524.           elseif P3selected == "ATK .." then
  3525.             P3selected = "ATK 1"
  3526.             P3ready = 1
  3527.             mon.setCursorPos(37,15)
  3528.             mon.write(stringHUDATK)
  3529.             mon.setCursorPos(37,16)
  3530.             mon.write(stringHUDATK1)
  3531.             mon.setCursorPos(37,17)
  3532.             mon.write("  READY!  ")
  3533.             checkReady()
  3534.           elseif P3selected == "MGC .." then
  3535.             if P3MP >= MGC1cost then
  3536.               P3selected = "MGC 1 .."
  3537.               mon.setCursorPos(37,15)
  3538.               mon.write("PLAYER 1  ")
  3539.               mon.setCursorPos(37,16)
  3540.               mon.write("PLAYER 2  ")
  3541.               mon.setCursorPos(37,17)
  3542.               mon.write("PLAYER 3  ")
  3543.             end
  3544.           elseif P3selected == "ITM .." then
  3545.             if P3HPpots > 0 then
  3546.               P3selected = "ITM 1 .."
  3547.               mon.setCursorPos(37,15)
  3548.               mon.write("PLAYER 1  ")
  3549.               mon.setCursorPos(37,16)
  3550.               mon.write("PLAYER 2  ")
  3551.               mon.setCursorPos(37,17)
  3552.               mon.write("PLAYER 3  ")
  3553.             end
  3554.           elseif P3selected == "MGC 1 .." then
  3555.             P3selected = "MGC 1"
  3556.             P3target = "P1"
  3557.             P3ready = 1
  3558.             mon.setCursorPos(37,15)
  3559.             mon.write(stringHUDMGC)
  3560.             mon.setCursorPos(37,16)
  3561.             mon.write(stringHUDMGC1)
  3562.             mon.setCursorPos(37,17)
  3563.             mon.write("  READY!  ")
  3564.             checkReady()
  3565.           elseif P3selected == "MGC 3 .." then
  3566.             P3selected = "MGC 3"
  3567.             P3target = "P1"
  3568.             P3ready = 1
  3569.             mon.setCursorPos(37,15)
  3570.             mon.write(stringHUDMGC)
  3571.             mon.setCursorPos(37,16)
  3572.             mon.write(stringHUDMGC3)
  3573.             mon.setCursorPos(37,17)
  3574.             mon.write("  READY!  ")
  3575.             checkReady()
  3576.           elseif P3selected == "ITM 1 .." then
  3577.             P3selected = "ITM 1"
  3578.             P3target = "P1"
  3579.             P3ready = 1
  3580.             mon.setCursorPos(37,15)
  3581.             mon.write(stringHUDITM)
  3582.             mon.setCursorPos(37,16)
  3583.             mon.write(stringHUDITM1)
  3584.             mon.setCursorPos(37,17)
  3585.             mon.write("  READY!  ")
  3586.             checkReady()
  3587.           elseif P3selected == "ITM 2 .." then
  3588.             P3selected = "ITM 2"
  3589.             P3target = "P1"
  3590.             P3ready = 1
  3591.             mon.setCursorPos(37,15)
  3592.             mon.write(stringHUDITM)
  3593.             mon.setCursorPos(37,16)
  3594.             mon.write(stringHUDITM2)
  3595.             mon.setCursorPos(37,17)
  3596.             mon.write("  READY!  ")
  3597.             checkReady()
  3598.           end
  3599.         end
  3600.       elseif redstone.testBundledInput(detectside, colors.blue) then          -- P3 [B]
  3601.         if turn == "Input" then
  3602.           if P3selected == "" then
  3603.             P3selected = "MGC .."
  3604.             mon.setCursorPos(37,15)
  3605.             mon.write(stringHUDMGC1)
  3606.             mon.setCursorPos(37,16)
  3607.             mon.write(stringHUDMGC2)
  3608.             mon.setCursorPos(37,17)
  3609.             mon.write(stringHUDMGC3)
  3610.           elseif P3selected == "ATK .." then
  3611.             P3selected = "ATK 2"
  3612.             P3ready = 1
  3613.             mon.setCursorPos(37,15)
  3614.             mon.write(stringHUDATK)
  3615.             mon.setCursorPos(37,16)
  3616.             mon.write(stringHUDATK2)
  3617.             mon.setCursorPos(37,17)
  3618.             mon.write("  READY!  ")
  3619.             checkReady()
  3620.           elseif P3selected == "MGC .." then
  3621.             if P3MP >= MGC2cost then
  3622.               P3selected = "MGC 2"
  3623.               P3ready = 1
  3624.               mon.setCursorPos(37,15)
  3625.               mon.write(stringHUDMGC)
  3626.               mon.setCursorPos(37,16)
  3627.               mon.write(stringHUDMGC2)
  3628.               mon.setCursorPos(37,17)
  3629.               mon.write("  READY!  ")
  3630.               checkReady()
  3631.             end
  3632.           elseif P3selected == "ITM .." then
  3633.             if P3MPpots > 0 then
  3634.               P3selected = "ITM 2 .."
  3635.               mon.setCursorPos(37,15)
  3636.               mon.write("PLAYER 1  ")
  3637.               mon.setCursorPos(37,16)
  3638.               mon.write("PLAYER 2  ")
  3639.               mon.setCursorPos(37,17)
  3640.               mon.write("PLAYER 3  ")
  3641.             end
  3642.           elseif P3selected == "MGC 1 .." then
  3643.             P3selected = "MGC 1"
  3644.             P3target = "P2"
  3645.             P3ready = 1
  3646.             mon.setCursorPos(37,15)
  3647.             mon.write(stringHUDMGC)
  3648.             mon.setCursorPos(37,16)
  3649.             mon.write(stringHUDMGC1)
  3650.             mon.setCursorPos(37,17)
  3651.             mon.write("  READY!  ")
  3652.             checkReady()
  3653.           elseif P3selected == "MGC 3 .." then
  3654.             P3selected = "MGC 3"
  3655.             P3target = "P2"
  3656.             P3ready = 1
  3657.             mon.setCursorPos(37,15)
  3658.             mon.write(stringHUDMGC)
  3659.             mon.setCursorPos(37,16)
  3660.             mon.write(stringHUDMGC3)
  3661.             mon.setCursorPos(37,17)
  3662.             mon.write("  READY!  ")
  3663.             checkReady()
  3664.           elseif P3selected == "ITM 1 .." then
  3665.             P3selected = "ITM 1"
  3666.             P3target = "P2"
  3667.             P3ready = 1
  3668.             mon.setCursorPos(37,15)
  3669.             mon.write(stringHUDITM)
  3670.             mon.setCursorPos(37,16)
  3671.             mon.write(stringHUDITM1)
  3672.             mon.setCursorPos(37,17)
  3673.             mon.write("  READY!  ")
  3674.             checkReady()
  3675.           elseif P3selected == "ITM 2 .." then
  3676.             P3selected = "ITM 2"
  3677.             P3target = "P2"
  3678.             P3ready = 1
  3679.             mon.setCursorPos(37,15)
  3680.             mon.write(stringHUDITM)
  3681.             mon.setCursorPos(37,16)
  3682.             mon.write(stringHUDITM2)
  3683.             mon.setCursorPos(37,17)
  3684.             mon.write("  READY!  ")
  3685.             checkReady()
  3686.           end
  3687.         end
  3688.       elseif redstone.testBundledInput(detectside, colors.cyan) then          -- P3 [C]
  3689.         if turn == "Input" then
  3690.           if P3selected == "" then
  3691.             P3selected = "ITM .."
  3692.             mon.setCursorPos(37,15)
  3693.             mon.write(stringHUDITM1)
  3694.             mon.setCursorPos(37,16)
  3695.             mon.write(stringHUDITM2)
  3696.             mon.setCursorPos(37,17)
  3697.             mon.write(stringHUDITM3)
  3698.             mon.setCursorPos(45,15)
  3699.             mon.write(P3HPpots)
  3700.             mon.setCursorPos(45,16)
  3701.             mon.write(P3MPpots)
  3702.             mon.setCursorPos(45,17)
  3703.             mon.write(P3bombs)
  3704.           elseif P3selected == "ATK .." then
  3705.             P3selected = "ATK 3"
  3706.             P3ready = 1
  3707.             mon.setCursorPos(37,15)
  3708.             mon.write(stringHUDATK)
  3709.             mon.setCursorPos(37,16)
  3710.             mon.write(stringHUDATK3)
  3711.             mon.setCursorPos(37,17)
  3712.             mon.write("  READY!  ")
  3713.             checkReady()
  3714.           elseif P3selected == "MGC .." then
  3715.             if P3MP >= MGC3cost then
  3716.               P3selected = "MGC 3 .."
  3717.               mon.setCursorPos(37,15)
  3718.               mon.write("PLAYER 1  ")
  3719.               mon.setCursorPos(37,16)
  3720.               mon.write("PLAYER 2  ")
  3721.               mon.setCursorPos(37,17)
  3722.               mon.write("PLAYER 3  ")
  3723.             end
  3724.           elseif P3selected == "ITM .." then
  3725.             if P3bombs > 0 then
  3726.               P3selected = "ITM 3"
  3727.               P3ready = 1
  3728.               mon.setCursorPos(37,15)
  3729.               mon.write(stringHUDITM)
  3730.               mon.setCursorPos(37,16)
  3731.               mon.write(stringHUDITM3)
  3732.               mon.setCursorPos(37,17)
  3733.               mon.write("  READY!  ")
  3734.               checkReady()
  3735.             end
  3736.           elseif P3selected == "MGC 1 .." then
  3737.             P3selected = "MGC 1"
  3738.             P3target = "P3"
  3739.             P3ready = 1
  3740.             mon.setCursorPos(37,15)
  3741.             mon.write(stringHUDMGC)
  3742.             mon.setCursorPos(37,16)
  3743.             mon.write(stringHUDMGC1)
  3744.             mon.setCursorPos(37,17)
  3745.             mon.write("  READY!  ")
  3746.             checkReady()
  3747.           elseif P3selected == "MGC 3 .." then
  3748.             P3selected = "MGC 3"
  3749.             P3target = "P3"
  3750.             P3ready = 1
  3751.             mon.setCursorPos(37,15)
  3752.             mon.write(stringHUDMGC)
  3753.             mon.setCursorPos(37,16)
  3754.             mon.write(stringHUDMGC3)
  3755.             mon.setCursorPos(37,17)
  3756.             mon.write("  READY!  ")
  3757.             checkReady()
  3758.           elseif P3selected == "ITM 1 .." then
  3759.             P3selected = "ITM 1"
  3760.             P3target = "P3"
  3761.             P3ready = 1
  3762.             mon.setCursorPos(37,15)
  3763.             mon.write(stringHUDITM)
  3764.             mon.setCursorPos(37,16)
  3765.             mon.write(stringHUDITM1)
  3766.             mon.setCursorPos(37,17)
  3767.             mon.write("  READY!  ")
  3768.             checkReady()
  3769.           elseif P3selected == "ITM 2 .." then
  3770.             P3selected = "ITM 2"
  3771.             P3target = "P3"
  3772.             P3ready = 1
  3773.             mon.setCursorPos(37,15)
  3774.             mon.write(stringHUDITM)
  3775.             mon.setCursorPos(37,16)
  3776.             mon.write(stringHUDITM2)
  3777.             mon.setCursorPos(37,17)
  3778.             mon.write("  READY!  ")
  3779.             checkReady()
  3780.           end
  3781.         end
  3782.       end
  3783.     end
  3784.   end
  3785. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement