--for all of these, 1st number is x pos, 2nd number is y pos, 3rd number is health function doHitbox(X, Y, r, g, b, a) --Draw Player box agg.noFill () --Dont fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X-18, Y+3, X+18, Y-57) --Fake Hitbox end function doEtext(X, Y, Health, Id, r, g, b, a) --Draw Ennemys Infos inside the hitbox agg.lineColor(r, g, b, a) --Define text color agg.text(X-16, Y-6, "HP:"..Health.."") --HP Value agg.text(X-15, Y-47, "X:"..X.."") --X Value agg.text(X-15, Y-56, "Y:"..Y.."") --Y Value agg.text(X-15, Y-28, "#"..Id.."") --Ennemy number (from start of stage...) end function doSomeText(X, Y, Text, r, g, b, a) --dumb drawing agg.lineColor(r, g, b, a) --textcolor agg.text(X, Y, ""..Text.."") --draw text end gui.register( function () --some global setup agg.setFont("verdana12_bold") --lets draw text smaller geekNes = true --set to false to get numerical display of players HP --players addresses bimmyHP = memory.readbyte(0x1F1351); bimmyX = memory.readbyte(0x1F0043); bimmyY = memory.readbyte(0x1F0047); --HP, X, Y memory address for bimmy jimmyHP = memory.readbyte(0x1F1352); jimmyX = memory.readbyte(0x1F0045); jimmyY = memory.readbyte(0x1F0049); --HP, X, Y memory address for jimmy lifejimmy = (memory.readbyte(0x1F001F)); lifebimmy = (memory.readbyte(0x1F001E)); --lifes remaining --0x1F1208 Bimmy X related... --ennemy addresses by slots AHP = (memory.readbyte(0x1F1353)); AX = (memory.readbyte(0x1F11CF)); AY = (memory.readbyte(0x1F11BB)); --Ennemys slotA addresses BHP = (memory.readbyte(0x1F1354)); BX = (memory.readbyte(0x1F11BF)); BY = (memory.readbyte(0x1F11BD)); --Ennemys slotB addresses CHP = (memory.readbyte(0x1F1355)); CX = (memory.readbyte(0x1F11D3)); CY = (memory.readbyte(0x1F11BF)); --Ennemys slotC addresses DHP = (memory.readbyte(0x1F1356)); DX = (memory.readbyte(0x1F11D5)); DY = (memory.readbyte(0x1F020C)); --Ennemys slotD addresses EHP = (memory.readbyte(0x1F1357)); EX = (memory.readbyte(0x1F11D5)); --This is wrong X address, fix me! EY = (memory.readbyte(0x1F020C)); --This is wrong Y address, fix me! FHP = (memory.readbyte(0x1F1359)); FX = (memory.readbyte(0x1F11D5)); --This is wrong X address, fix me! FY = (memory.readbyte(0x1F020C)); --This is wrong Y address, fix me! -- BX = (memory.readbyte(0x1F16B6)); --more X slotB ? -- BX = (memory.readbyte(0x1F11D0)); --more X slotB ? --Stage by stage tables of initial ennemys HP values used to determine when they spawn, for eatch slots, assure whe realy use a correct match to tell an ennemy spawned --stage1 it1A = {32,32,35,39,41,43,47}it1B = {32,32,33,36,37,40,42,44}it1C = {34,38,45,46,132}it1D = {"no"}it1E = {48}it1F = {49} --stage2 it2A = {17,18,20,21,22,23,25,26,27,29,30,30,31,8}it2B = {17,18,19,20,28,28,31,32}it2C = {21,22,23,24,24,29,30}it2D = {19,25,26}it2E = {"no"}it2F = {27} --stage3-1 it31A = {28,28,29,32,33,36,37}it31B = {27,30,57,32,59,34,61,36}it31C = {27,29,30,31,34,35}it31D = {"no"}it31E = {"no"}it31F = {"no"} --stage3-2 it32A = {63,64,65} it32B = {"no"} it32C = {"no"} it32D = {"no"} it32E = {"no"} it32F = {"no"} --others stages need recheck for include ennemy spawing twice with same hp ammount --stage3 = pita it4A = {34,35,36,38,42,44,46,80} -- 80 = boss --stage4 slotA ennemy initial HP values it4B = {35,36,37,38,39,40,43,44,47} it4C = {34,40,41,45,46} it4D = {37,41} it4E = {"no"} --no ennemy spawn in this slot it4F = {"no"} --no ennemy spawn in this slot it51A = {"no"} --no ennemy spawn in this slot --stage5 scene1 slotA ennemy initial HP values it51B = {41,42,43,44} it51C = {41,42,43} it51D = {42,43} it51E = {"no"} --no ennemy spawn in this slot it51F = {"no"} --no ennemy spawn in this slot it52A = {"no"} --no ennemy spawn in this slot --stage5 scene2 slotA ennemy initial HP values it52B = {44,45,46} it52C = {45,46,47} it52D = {"no"} --no ennemy spawn in this slot it52E = {"no"} --no ennemy spawn in this slot it52F = {"no"} --no ennemy spawn in this slot it53A = {47,87,48,49,50} -- 87 = boss --stage5 scene3 slotA ennemy initial HP values it53B = {48,49,50} it53C = {"no"} --no ennemy spawn in this slot it53D = {"no"} --no ennemy spawn in this slot it53E = {"no"} --no ennemy spawn in this slot it53F = {"no"} --no ennemy spawn in this slot --stage5 scene4 ... no ennemy it6A = {"no"} --no ennemy spawn in this slot --stage6 slotA ennemy initial HP values it6B = {"no"} --no ennemy spawn in this slot it6C = {46,47,48,90} it6D = {47,48,90} it6E = {"no"} --no ennemy spawn in this slot it6F = {"no"} --no ennemy spawn in this slot --stage7 scene1 ... no ennemy it72A = {50} --stage7 scene2 slotA ennemy initial HP values it72B = {100} it72C = {"no"} --no ennemy spawn in this slot it72D = {"no"} --no ennemy spawn in this slot it72E = {"no"} --no ennemy spawn in this slot it72F = {"no"} --no ennemy spawn in this slot --stage7 scene3 ... no ennemy it74A = {50} --boss = 50 --stage7 scene4 slotA ennemy initial HP values it74B = {200,50} it74C = {50} it74D = {"no"} --no ennemy spawn in this slot it74E = {"no"} --no ennemy spawn in this slot it74F = {"no"} --no ennemy spawn in this slot--no ennemy spawn in this slot it8A = {55,110,200} --110 = arnold 200 = shadow --stage8 slotA ennemy initial HP values it8B = {55,128} --128 = M16 boss it8C = {"no"} --no ennemy spawn in this slot it8D = {"no"} --no ennemy spawn in this slot it8E = {"no"} --no ennemy spawn in this slot it8F = {"no"} --no ennemy spawn in this slot it91A = {255} --last boss it91B = {"no"} --no ennemy spawn in this slot it91C = {"no"} --no ennemy spawn in this slot it91D = {"no"} --no ennemy spawn in this slot it91E = {"no"} --no ennemy spawn in this slot it91F = {"no"} --no ennemy spawn in this slot it92A = {63} --last boss it92B = {"no"} --no ennemy spawn in this slot it92C = {"no"} --no ennemy spawn in this slot it92D = {"no"} --no ennemy spawn in this slot it92E = {"no"} --no ennemy spawn in this slot it92F = {"no"} --no ennemy spawn in this slot --initialize all current values for slots in case whe just started --The current position in table of ennemys HP value, this would be the per slot ennemy ID, need to be reset to 1 upon new stage if not curA then curA = 1 end if not curB then curB = 1 end if not curC then curC = 1 end if not curD then curD = 1 end if not curE then curE = 1 end if not curF then curF = 1 end --Ennemys IDs, the current logic make it a global ID, pretty much mean its the same value as totalskills, this could be set to use a per slot ID logic (not usefull for now...) if not idA then idA = 0 end if not idB then idB = 0 end if not idC then idC = 0 end if not idD then idD = 0 end if not idE then idE = 0 end if not idF then idF = 0 end --Frame counter per slot if not diefA then diefA = 0 end if not diefB then diefB = 0 end if not diefC then diefC = 0 end if not diefD then diefD = 0 end if not diefE then diefE = 0 end if not diefF then diefF = 0 end --Counter used to draw death hitbox if not tA then tA = 1 end if not tB then tB = 1 end if not tC then tC = 1 end if not tD then tD = 1 end if not tE then tE = 1 end if not tF then tF = 1 end --Colors for display -- A:0,255,0,255 B:255,255,0,255 C:255,100,0,255 D:255,0,255,255 E:0,255,255,255 F:210,150,150,255 rgbgreen = {0,255,0,255} rgbyellow = {255,255,0,255} rgborange = {255,100,0,255} rgbpink = {255,0,255,255} rgbcyan = {0,255,255,255} rgbFbox = {210,150,150,255} rgbred = {255,0,0,255} rgbblue = {0,0,255,255} rgbblack = {0,0,0,255} rgbwhite = {255,255,255,255} rgbredjimmy = {255, 0, 100, 255} rgbbluebimmy = {0,150,255,255} timerdeath = 50 --number of frames that the red hitbox will be displayed when someone die stgid = (memory.readbyte(0x1F01FE)); --the address used to determine what stage whe are in (in effect also in "mission x" screen) gametimer = (memory.readbyte(0x1F16B0)); --the gametimer... creditsleft = (memory.readbyte(0x1F0011)); --number of credits left curstg = "?"; --this will hold the stage value, for now whe dont know yet where whe are... loads = {8,28,2,60,63,66,102,129,211,7} --values while game is loading for the stage "id" if not totalkills then totalkills = 0 end --total kills counter... doh if not stagespawns then stagespawns = 0 end --stage spawns counter if not stagekills then stagekills = 0 end --total kills in this stage if not ennemyid then ennemyid = 0 end --ennemy ID if not stgmaxkill then stgmaxkill = 0 end --stage maximum ennemy spawning curFrame = emu.framecount() --the current frame curmoviemode = movie.mode() --the current movie mode moviesize = movie.length() jimmyJoy = joypad.read(2) bimmyJoy = joypad.read(1) -- Check witch stage whe are in, store in curstg, also set ammount of ennemys per stage -- stage 3 have 2 parts, stage 5 have 4 parts, stage 7 have 4 parts also find if whe are in ending, menus or loading if (stgid == 87) then curstg = 1 stgmaxkill = 22 end if (stgid == 142) then curstg = 2 stgmaxkill = 33 end if (stgid == 197) then curstg = "3-1" stgmaxkill = 21 end if (stgid == 210) then curstg = "3-2" stgmaxkill = 3 end if (stgid == 9) then curstg = 4 stgmaxkill = 40 end if (stgid == 64) then curstg = "5-1" end if (stgid == 77) then curstg = "5-2" end if (stgid == 90) then curstg = "5-3" end if (stgid == 103) then curstg = "5-4" stgmaxkill = 0 end if (stgid == 158) then curstg = 6 end if (stgid == 213) then curstg = "7-1" stgmaxkill = 0 end if (stgid == 226) then curstg = "7-2" end if (stgid == 239) then curstg = "7-3" stgmaxkill = 0 end if (stgid == 252) then curstg = "7-4" end if (stgid == 51) then curstg = 8 end if (stgid == 106) then curstg = "9-1" end if (stgid == 123) then curstg = "9-2" end if (stgid == 144) then curstg = "Ending Hard Mode" end if (stgid == 138) then curstg = "Main Menu" end if (stgid == 224) then curstg = "Options Menu" end table.maxn (loads) for i = 1,table.maxn(loads),1 do if loads[i] == stgid then --then whe are in a loading screen curstg = "Loading..." end end -- Exclude the menu loading ect... now whe want to draw a new HUD if (curstg == "Loading...") or (curstg == "Ending Hard Mode") or (curstg == "Main Menu") or (curstg == "Options Menu") or (curstg == "?") then doSomeText(180, 12, ""..curstg.."", 255,0,0,255) --then display those events else --else whe are in a mission... --Players HUD agg.fillColor (0, 0, 0, 255) agg.lineColor (0, 0, 0, 0) agg.rectangle (0, 200, 255, 230) agg.noFill() --hide bottom and put our infos doSomeText(118, 2, "Mission Clear: / |", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) --draw text : mission + clear doSomeText(156, 2, ""..curstg.."", rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) --draw mission number if stagekills < stgmaxkill then doSomeText(206, 2, ""..stagekills.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) --stage not complete, draw in red else doSomeText(206, 2, ""..stagekills.."", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) --else whe are done this stage, draw green end doSomeText(226, 2, ""..stgmaxkill.."", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) --draw stgmaxkills if stagespawns < stgmaxkill then doSomeText(243, 2, ""..stagespawns.."", rgbblue[1], rgbblue[2], rgbblue[3], rgbblue[4]) --stage not complete, draw in blue else doSomeText(243, 2, ""..stagespawns.."", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) --else whe are done this stage, draw green end doSomeText(61, 222, "KILLS: /", rgbwhite[1], rgbwhite[2], rgbwhite[3], rgbwhite[4]) --text : kills doSomeText(97, 222, ""..totalkills.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) --allkill value doSomeText(122, 222, "999", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) --text : /xxx (maxkills) doSomeText(60, 212, "TIME", 255,255,255,255) --draw text: time doSomeText(85, 212, ""..gametimer.."", rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) --draw timer value doSomeText(98, 212, "REST", rgbwhite[1], rgbwhite[2], rgbwhite[3], rgbwhite[4]) --text : credits doSomeText(124, 212, ""..creditsleft.."", rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) --credits value --bimmy's HUD if geekNes then doPlayerHP(186, 201, bimmyHP, rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4], rgbwhite[1], rgbwhite[2], rgbwhite[3], rgbwhite[4], rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) --draw bimmy infos doSomeText(140, 202, "BIMMY:"..lifebimmy.."", rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4]) --draw bimmy infos else doSomeText(140, 202, "BIMMY: "..bimmyHP.."HP Life: "..lifebimmy.."", rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4]) --draw bimmy infos end doSomeText(193, 212, "X:"..bimmyX.."-Y:"..bimmyY.."", rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4]) --draw bimmy infos doHitbox(bimmyX, bimmyY, rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4]) --draw bimmy box --jimmy's HUD if geekNes then doPlayerHP(186, 221, jimmyHP, rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4], rgbwhite[1], rgbwhite[2], rgbwhite[3], rgbwhite[4], rgbred[1], rgborange[2], rgborange[3], rgborange[4]) --draw bimmy infos doSomeText(141, 222, "JIMMY:"..lifejimmy.."", rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4]) --draw jimmy infos else doSomeText(140, 222, "JIMMY: "..jimmyHP.."HP Life: "..lifejimmy.."", rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4]) --draw jimmy infos end doSomeText(131, 212, "X:"..jimmyX.."-Y:"..jimmyY.."", rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4]) --draw jimmy infos doHitbox(jimmyX, jimmyY, rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4]) --draw jimmy box end --draw pads /movies info regardless whe are in a stage or menus doPlayerJoy(2,201, bimmyJoy, rgbbluebimmy[1], rgbbluebimmy[2], rgbbluebimmy[3], rgbbluebimmy[4]) doPlayerJoy(2,217, jimmyJoy, rgbredjimmy[1], rgbredjimmy[2], rgbredjimmy[3], rgbredjimmy[4]) doSomeText(104, 202, "/"..moviesize.."", 255,255,255,255) --draw movie size if curmoviemode == "playback" then agg.fillColor (rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) agg.lineColor (rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) agg.triangle (61, 202, 68, 205, 61, 209) agg.noFill() --play symbol doSomeText(74, 202, ""..curFrame.."", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) --draw current frame end if curmoviemode == "record" then agg.fillColor (rgbred[1], rgbred[2], rgbred[3], rgbred[4]) agg.lineColor (rgbred[1], rgbred[2], rgbred[3], rgbred[4]) agg.roundedRect (61, 202, 68, 209, 255) agg.noFill() --record symbol doSomeText(74, 202, ""..curFrame.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) --draw current frame end if curmoviemode == "inactive" then agg.fillColor (rgbblue[1], rgbblue[2], rgbblue[3], rgbblue[4]) agg.lineColor (rgbblue[1], rgbblue[2], rgbblue[3], rgbblue[4]) agg.roundedRect (61, 202, 68, 209, 1) agg.noFill() --stop symbol doSomeText(74, 202, ""..curFrame.."", rgbblue[1], rgbblue[2], rgbblue[3], rgbblue[4]) --draw current frame end --Ennemys HUD -- x seems to be absolute position in the level or something --and doesn't always look right even with taking the scroll pos (0x1F020C) into account --Some fix for the X/Y positions from pa__ , work good for slotA in most cases if curstg ~= 8 then --games of this era almost always have a 0-255 counter and a second one that --gets incremented/decremented whenever the 1st goes over/under 255/0 --this seem to be not working in stage8 AX = AX + (255*memory.readbyte(0x1f11d0)) xScroll = memory.readbyte(0x1f020C) yScroll = memory.readbyte(0x1f0210) xScroll = xScroll + (255*memory.readbyte(0x1f020D)) --account for the X scrolling AX = (AX - xScroll) --account for the Y scrolling AY = (AY - yScroll) --this trick work on some ennemys of the slotC, not all of them tought CX = CX + (255*memory.readbyte(0x1f11d0)) xScroll = memory.readbyte(0x1f020C) yScroll = memory.readbyte(0x1f0210) xScroll = xScroll + (255*memory.readbyte(0x1f020D)) CX = (CX - xScroll) CY = (CY - yScroll) end --Stage1 if curstg == 1 then --exceptions here --Tell who is the boss, also hes trown away, kill him when he reach position and 60HP (position use "fix" slotC... and seem boss is on a wrong X/Y address...) if stagespawns == 22 then idC = "Boss" if CHP == 60 and CX == 240 and CY == 152 then CHP = 0 end end --do slots for stage doSlotA(it1A) doSlotB(it1B) doSlotC(it1C) doSlotE(it1E) doSlotF(it1F) --if end of stage1, whe reach 22 kills put the flag for next stage to reset some counts if stagekills == stgmaxkill then resetstage1 = true end end --Stage2 if curstg == 2 then --first check if whe was told to reset counts, and put back flag to false if not resetstage1 and not checkloadedstate and gametimer == 99 then --whe loaded a state i guess, set good values... ennemyid = 22 totalkills = 22 checkloadedstate = true end if resetstage1 then stagespawns = 0 stagekills = 0 resetstage1 = false end --exceptions here if stagespawns == 24 and BHP == 4 then BHP = 0 end --do slots for stage doSlotA(it2A) doSlotB(it2B) doSlotC(it2C) doSlotD(it2D) doSlotF(it2F) --if end of stage2, whe reach 33 kills put the flag for next stage to reset some counts if stagekills == stgmaxkill then resetstage2 = true end end --Stage3-1 if curstg == "3-1" then if not resetstage2 and not checkloadedstate and gametimer == 99 then --whe loaded a state i guess, set good values... ennemyid = 55 totalkills = 55 checkloadedstate = true end if resetstage2 then stagespawns = 0 stagekills = 0 resetstage2 = false end --exceptions here --guys are trow out the windows, this will likely change anytime the movie change, dirty manual kill if not chk56 and BHP == 27 and BY == 161 and BX == 165 then BHP = 0 chk56 = true end if not chk57 and CHP == 3 and CY == 137 and CX == 91 then CHP = 0 chk57 = true end if not chk58 and AHP == 28 and AY == 137 and AX == 60 then AHP = 0 chk58 = true end if not chk59 and AHP == 28 and AY == 138 and AX == 96 then AHP = 0 chk59 = true end if not chk60 and AHP == 29 and AY == 136 and AX == 102 then AHP = 0 chk60 = true end if not chk61 and CHP == 5 and CY == 137 and CX == 49 then CHP = 0 chk61 = true end if not chk62 and BHP == 30 and BY == 161 and BX == 164 then BHP = 0 chk62 = true end if not chk63 and CHP == 30 and CY == 137 and CX == 94 then CHP = 0 chk63 = true end if not chk64 and BHP == 33 and BY == 160 and BX == 161 then BHP = 0 chk64 = true end if not chk65 and CHP == 31 and CY == 137 and CX == 115 then CHP = 0 chk65 = true end if not chk70 and BHP == 34 and BY == 160 and BX == 160 then BHP = 0 chk70 = true end if not chk71 and CHP == 34 and CY == 137 and CX == 113 then CHP = 0 chk71 = true end if not chk72 and CHP == 35 and CY == 136 and CX == 105 then CHP = 0 chk72 = true end if not chk73 and BHP == 37 and BY == 162 and BX == 160 then BHP = 0 chk73 = true end if not chk74 and AHP == 12 and AY == 137 and AX == 131 then AHP = 0 chk74 = true end if not chk75 and AHP == 13 and AY == 136 and AX == 150 then AHP = 0 chk75 = true end if not chk76 and BHP == 12 and BY == 161 and BX == 160 then BHP = 0 chk76 = true end --do slots for stage doSlotA(it31A) doSlotB(it31B) doSlotC(it31C) if stagekills == stgmaxkill then resetstage31 = true end end --Stage3-2 if curstg == "3-2" then if not resetstage31 and not checkloadedstate and gametimer == 89 then --whe loaded a state i guess, set good values... ennemyid = 76 totalkills = 76 checkloadedstate = true end if resetstage31 then stagespawns = 0 stagekills = 0 resetstage31 = false end --exceptions here if not chk77 and AHP == 63 and AY == 150 and AX == 25 then AHP = 0 chk77 = true end if not chk78 and AHP == 64 and AY == 141 and AX == 27 then AHP = 0 chk78 = true end --do slots for stage doSlotA(it32A) if stagekills == 3 then resetstage32 = true end end --Stage4 if curstg == 4 then if not resetstage32 and not checkloadedstate and gametimer == 99 then --whe loaded a state i guess, set good values... ennemyid = 79 totalkills = 79 checkloadedstate = true end if resetstage32 then stagespawns = 0 stagekills = 0 resetstage32 = false end --exceptions here --do slots for stage doSlotA(it4A) doSlotB(it4B) doSlotC(it4C) doSlotD(it4D) if stagekills == stgmaxkill then resetstage4 = true end end --Stage5 if curstg == "5" then if not resetstage4 and not checkloadedstate and gametimer == 99 then --whe loaded a state i guess, set good values... ennemyid = 79 totalkills = 79 checkloadedstate = true end if resetstage4 then stagespawns = 0 stagekills = 0 resetstage4 = false end --exceptions here --do slots for stage doSlotA(it5A) doSlotB(it5B) doSlotC(it5C) doSlotD(it5D) if stagekills == stgmaxkill then resetstage5 = true end end -- the end agg.setFont("verdana18_bold") --put back this font to restore pcejin default end) function doSlotA(Table) if not Achk then curmaxA = table.maxn (Table) if (Table)[curA] == AHP then Achk = true iAHP = AHP stagespawns = stagespawns+1 curA = curA+1 if curA == curmaxA+1 then --then whe just hitted the last hp value for this slot in the table, reset to 1 since whe are probly going to change stage curA = 1 end ennemyid = ennemyid+1 idA = ennemyid end end if Achk then doHitbox(AX, AY, rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) doEtext(AX, AY, AHP, ""..idA.."", rgbgreen[1], rgbgreen[2], rgbgreen[3], rgbgreen[4]) if (AHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Achk = false Adead = true end end if Adead then doHitbox(AX, AY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(AX, AY, AHP, ""..idA.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefA) and (tA < timerdeath) then diefA = emu.framecount() tA = tA+1 elseif (tA == timerdeath) then Adead = false tA = 1 end end end function doSlotB(Table) if not Bchk then curmaxB = table.maxn (Table) if (Table)[curB] == BHP then Bchk = true iBHP = BHP stagespawns = stagespawns+1 curB = curB+1 if curB == curmaxB+1 then curB = 1 end ennemyid = ennemyid+1 idB = ennemyid end end if Bchk then doHitbox(BX, BY, rgbyellow[1], rgbyellow[2], rgbyellow[3], rgbyellow[4]) doEtext(BX, BY, BHP, ""..idB.."", rgbyellow[1], rgbyellow[2], rgbyellow[3], rgbyellow[4]) if (BHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Bchk = false Bdead = true end end if Bdead then doHitbox(BX, BY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(BX, BY, BHP, ""..idB.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefB) and (tB < timerdeath) then diefB = emu.framecount() tB = tB+1 elseif (tB == timerdeath) then Bdead = false tB = 1 end end end function doSlotC(Table) if not Cchk then curmaxC = table.maxn (Table) if (Table)[curC] == CHP then Cchk = true iCHP = CHP stagespawns = stagespawns+1 curC = curC+1 if curC == curmaxC+1 then curC = 1 end ennemyid = ennemyid+1 idC = ennemyid end end if Cchk then doHitbox(CX, CY, rgborange[1], rgborange[2], rgborange[3], rgborange[4]) doEtext(CX, CY, CHP, ""..idC.."", rgborange[1], rgborange[2], rgborange[3], rgborange[4]) if (CHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Cchk = false Cdead = true end end if Cdead then doHitbox(CX, CY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(CX, CY, CHP, ""..idC.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefC) and (tC < timerdeath) then diefC = emu.framecount() tC = tC+1 elseif (tC == timerdeath) then Cdead = false tC = 1 end end end function doSlotD(Table) if not Dchk then curmaxD = table.maxn (Table) if (Table)[curD] == DHP then Dchk = true iDHP = DHP stagespawns = stagespawns+1 curD = curD+1 if curD == curmaxD+1 then curD = 1 end ennemyid = ennemyid+1 idD = ennemyid end end if Dchk then doHitbox(DX, DY, rgbpink[1], rgbpink[2], rgbpink[3], rgbpink[4]) doEtext(DX, DY, DHP, ""..idD.."", rgbpink[1], rgbpink[2], rgbpink[3], rgbpink[4]) if (DHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Dchk = false Ddead = true end end if Ddead then doHitbox(DX, DY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(DX, DY, DHP, ""..idD.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefD) and (tD < timerdeath) then diefD = emu.framecount() tD = tD+1 elseif (tD == timerdeath) then Ddead = false tD = 1 end end end function doSlotE(Table) --this slot hold only 1 ennemy for the whole game, so the check is simpler if not Echk then if (Table)[curE] == EHP then Echk = true iEHP = EHP stagespawns = stagespawns+1 ennemyid = ennemyid+1 idE = ennemyid end end if Echk then doHitbox(EX, EY, rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) doEtext(EX, EY, EHP, ""..idE.."", rgbcyan[1], rgbcyan[2], rgbcyan[3], rgbcyan[4]) if (EHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Echk = false Edead = true end end if Edead then doHitbox(EX, EY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(EX, EY, EHP, ""..idE.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefE) and (tE < timerdeath) then diefE = emu.framecount() tE = tE+1 elseif (tE == timerdeath) then Edead = false tE = 1 end end end function doSlotF(Table) --this slot hold only 2 ennemys for the whole game, so the check is simpler if not Fchk then if (Table)[curF] == FHP then Fchk = true iFHP = FHP stagespawns = stagespawns+1 ennemyid = ennemyid+1 idF = ennemyid end end if Fchk then doHitbox(FX, FY, rgbFbox[1], rgbFbox[2], rgbFbox[3], rgbFbox[4]) doEtext(FX, FY, FHP, ""..idF.."", rgbFbox[1], rgbFbox[2], rgbFbox[3], rgbFbox[4]) if (FHP == 0) then totalkills = totalkills+1 stagekills = stagekills+1 Fchk = false Fdead = true end if Fdead then doHitbox(FX, FY, rgbred[1], rgbred[2], rgbred[3], rgbred[4]) doEtext(FX, FY, FHP, ""..idF.."", rgbred[1], rgbred[2], rgbred[3], rgbred[4]) if(emu.framecount() > diefF) and (tF < timerdeath) then diefF = emu.framecount() tF = tF+1 elseif (tF == timerdeath) then Fdead = false tF = 1 end end end end --draw nes style HP squares in HUD... can be ended by using geekNes = false function doPlayerHP(X, Y, HP, r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3) --First square if HP == 0 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X, Y, X+9, Y+9, 1) --First square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+4, Y+4, X+5, Y+5, 1) --First square inside2 agg.noFill () --Stop fill the box elseif HP > 0 and HP < 12 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X, Y, X+9, Y+9, 1) --First square agg.lineColor(0, 0, 0, 255) --Outline color agg.fillColor(r, g, b, a) --Inline color agg.rectangle (X+1, Y+1, X+8, Y+8, 1) --First square inside agg.lineColor(r3, g3, b3, a3) --Outline color agg.fillColor(r3, g3, b3, a3) --Inline color agg.rectangle (X+4, Y+4, X+5, Y+5, 1) --First square inside2 elseif HP >= 12 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X, Y, X+9, Y+9, 1) --First square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+4, Y+4, X+5, Y+5, 1) --First square inside agg.noFill () --Stop fill the box end --2nd square if HP >= 12 and HP < 18 or HP < 12 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+12, Y, X+21, Y+9, 1) --2nd square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+16, Y+4, X+17, Y+5, 1) --2nd square inside2 agg.noFill () --Stop fill the box elseif HP >= 18 and HP < 24 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+12, Y, X+21, Y+9, 1) --2nd square agg.lineColor(0, 0, 0, 255) --Outline color agg.fillColor(r, g, b, a) --Inline color agg.rectangle (X+13, Y+1, X+20, Y+8, 1) --2nd square inside agg.lineColor(r3, g3, b3, a3) --Outline color agg.fillColor(r3, g3, b3, a3) --Inline color agg.rectangle (X+16, Y+4, X+17, Y+5, 1) --2nd square inside2 elseif HP >= 24 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X+12, Y, X+21, Y+9, 1) --2nd square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+16, Y+4, X+17, Y+5, 1) --2nd square inside agg.noFill () --Stop fill the box end --3rd square if HP >= 24 and HP < 30 or HP < 24 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+24, Y, X+33, Y+9, 1) --3rd square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+28, Y+4, X+29, Y+5, 1) --3rd square inside2 agg.noFill () --Stop fill the box elseif HP >= 30 and HP < 36 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+24, Y, X+33, Y+9, 1) --3rd square agg.lineColor(0, 0, 0, 255) --Outline color agg.fillColor(r, g, b, a) --Inline color agg.rectangle (X+25, Y+1, X+32, Y+8, 1) --3rd square inside agg.lineColor(r3, g3, b3, a3) --Outline color agg.fillColor(r3, g3, b3, a3) --Inline color agg.rectangle (X+28, Y+4, X+29, Y+5, 1) --3rd square inside2 elseif HP >= 36 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X+24, Y, X+33, Y+9, 1) --3rd square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+28, Y+4, X+29, Y+5, 1) --3rd square inside agg.noFill () --Stop fill the box end --4th square if HP >= 36 and HP < 42 or HP < 36 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+36, Y, X+45, Y+9, 1) --4th square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+40, Y+4, X+41, Y+5, 1) --4th square inside2 agg.noFill () --Stop fill the box elseif HP >= 42 and HP < 48 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+36, Y, X+45, Y+9, 1) --4th square agg.lineColor(0, 0, 0, 255) --Outline color agg.fillColor(r, g, b, a) --Inline color agg.rectangle (X+37, Y+1, X+44, Y+8, 1) --4th square inside agg.lineColor(r3, g3, b3, a3) --Outline color agg.fillColor(r3, g3, b3, a3) --Inline color agg.rectangle (X+40, Y+4, X+41, Y+5, 1) --4th square inside2 elseif HP >= 48 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X+36, Y, X+45, Y+9, 1) --4th square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+40, Y+4, X+41, Y+5, 1) --4th square inside agg.noFill () --Stop fill the box end --5th square if HP >= 48 and HP < 54 or HP < 48 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+48, Y, X+57, Y+9, 1) --5th square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+52, Y+4, X+53, Y+5, 1) --5th square inside2 agg.noFill () --Stop fill the box elseif HP > 54 and HP < 60 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+48, Y, X+57, Y+9, 1) --5th square agg.lineColor(0, 0, 0, 255) --Outline color agg.fillColor(r, g, b, a) --Inline color agg.rectangle (X+49, Y+1, X+56, Y+8, 1) --5th square inside agg.lineColor(r3, g3, b3, a3) --Outline color agg.fillColor(r3, g3, b3, a3) --Inline color agg.rectangle (X+52, Y+4, X+53, Y+5, 1) --5th square inside2 elseif HP >= 60 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X+48, Y, X+57, Y+9, 1) --5th square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+52, Y+4, X+53, Y+5, 1) --5th square inside agg.noFill () --Stop fill the box end --6th square if HP >= 66 and HP < 72 or HP < 66 then agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.rectangle (X+60, Y, X+69, Y+9, 1) --6th square agg.fillColor(r3, g3, b3, a3) --Inline color agg.lineColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+64, Y+4, X+65, Y+5, 1) --6th square inside2 agg.noFill () --Stop fill the box elseif HP >= 72 then agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.rectangle (X+60, Y, X+69, Y+9, 1) --6th square agg.lineColor(r3, g3, b3, a3) --Inline color agg.fillColor(r3, g3, b3, a3) --Outline color agg.rectangle (X+64, Y+4, X+65, Y+5, 1) --6th square inside agg.noFill () --Stop fill the box end --end end function doPlayerJoy(X, Y, Joy, r, g, b, a) --container box agg.noFill () --Stop fill the box agg.lineColor(r, g, b, a) --Outline color agg.roundedRect (X, Y, X+56, Y+14, 1) -- draw idle pad --left button, release doButton(X+2, Y+4, X+9, Y+9, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --right button, release doButton(X+15, Y+4, X+22, Y+9, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --up button, release doButton(X+9, Y+1, X+15, Y+7, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --down button, release doButton(X+9, Y+7, X+15, Y+13, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --select button, release doButton(X+23, Y+8, X+29, Y+12, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --run button, release doButton(X+31, Y+8, X+37, Y+12, 1, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --I button, release doButton(X+38, Y+3, X+45, Y+11, 255, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) --II button, release doButton(X+47, Y+3, X+54, Y+11, 255, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4], r, g, b, a) -- now check if something is press... for key,value in pairs(Joy) do --print(key..": "..tostring(value)) --debug if (key) == "Left" then --left button, hold doButton(X+2, Y+4, X+9, Y+9, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "Right" then --right button, hold doButton(X+15, Y+4, X+22, Y+9, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "Up" then --up button, hold doButton(X+9, Y+1, X+15, Y+7, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "Down" then --down button, hold doButton(X+9, Y+7, X+15, Y+13, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "Select" then --select button, hold doButton(X+23, Y+8, X+29, Y+12, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "Run" then --run button, hold doButton(X+31, Y+8, X+37, Y+12, 1, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "I" then --I button, hold doButton(X+38, Y+3, X+45, Y+11, 255, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) elseif (key) == "II" then --II button, hold doButton(X+47, Y+3, X+54, Y+11, 255, r, g, b, a, rgbblack[1], rgbblack[2], rgbblack[3], rgbblack[4]) end end --end end function doButton(X1, Y1, X2, Y2, Z, r, g, b, a, r2, g2, b2, a2) agg.fillColor(r, g, b, a) --Inline color agg.lineColor(r2, g2, b2, a2) --Outline color agg.roundedRect (X1, Y1, X2, Y2, Z) agg.noFill () --Stop fill the box end