Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rns = { 256, 512, 512, 0, 768, 256, 512, 512, 512, 0, 512, 0, 0, 768, 256, 0, 768, 256, 768, 768, 0, 512, 768, 0, 768, 256, 0, 768, 256, 256, 256, 512 }
- enHealth = { }
- display = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }
- dropsX = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 00
- 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, -- 10
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -- 20
- 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, -- 30
- 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 40
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, -- 50
- 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, -- 60
- 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, -- 70
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, -- 80
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 90
- 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, -- A0
- 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, -- B0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -- C0
- function DrawArrow(x, y) -- displays an arrow
- gui.text(7+x, y, "<-")
- end
- function DrawDrop(x, y, label)
- if label == "Y" then
- gui.text(x, y, label, "#F0F000")
- elseif label == "G" then
- gui.text(x, y, label, "#00F000")
- else
- gui.text(x, y, label, "#F00000")
- end
- end
- while true do
- -- get these values every frame
- local cameraX, cameraY = memory.readword(0x3001228), memory.readword(0x300122A)
- local frame1 = memory.readbyte(0x3000BE5)
- local frame2 = memory.readword(0x3000002)
- local fullHealth = (memory.readword(0x3001310) == memory.readword(0x3001312))
- local fullMissiles = (memory.readbyte(0x3001314) == memory.readbyte(0x3001316))
- -- display frame counter for convenience
- gui.text(28, 3, 255 - (frame1 + 45) % 256)
- -- for each enemy
- for i=0,23 do
- local status = memory.readword(0x3000140 + i*0x38)
- local prop = memory.readbyte(0x3000174 + i*0x38)
- local id = memory.readbyte(0x300015D + i*0x38)
- -- if enemy exists and can drop x
- if status > 0 and prop < 0x80 and dropsX[id + 1] == 1 then
- -- get enemy position
- local enemyX, enemyY = memory.readword(0x3000144 + i*0x38), memory.readword(0x3000142 + i*0x38)
- local posX, posY = bit.rshift(enemyX - cameraX, 2), bit.rshift(enemyY - cameraY, 2)
- -- update enemy's past/current health
- local pastHealth = enHealth[i+1]
- local enemyHealth = memory.readword(0x3000154 + i*56)
- enHealth[i+1] = enemyHealth
- -- if enemy recently died, show drop
- if pastHealth == 0 then
- DrawDrop(posX, posY, display[i+1])
- DrawArrow(posX, posY)
- -- otherwise, determine which x will be dropped
- else
- local healthX = memory.readword(0x82E4D54+ id*0xE)
- local missileX = memory.readword(0x82E4D56 + id*0xE)
- local redX = memory.readword(0x82E4D58 + id*0xE)
- local temp1 = (frame1 + 45) % 256
- local temp2 = bit.rshift(frame2 + 45, 4)
- local rn = rns[((i + temp1 + temp2 + enemyX + enemyY) % 32) + 1]
- local cmpVal = rn + temp1
- local cmpRed = 1024 - redX
- local dropLabel
- if cmpVal >= cmpRed then
- dropLabel = "R"
- elseif cmpVal >= cmpRed - missileX then
- if (fullMissiles and not fullHealth) then
- dropLabel = "Y"
- else
- dropLabel = "G"
- end
- else
- if (fullHealth and not fullMissiles) then
- dropLabel = "G"
- else
- dropLabel = "Y"
- end
- end
- DrawDrop(posX, posY, dropLabel)
- -- if enemy just died, save drop and draw arrow
- if enemyHealth == 0 then
- display[i+1] = dropLabel
- DrawArrow(posX, posY)
- end
- -- determine when red x will appear
- if redX > 0 then
- local wait = 0
- while temp1 ~= 0 do
- rn = rns[((i + temp1 + temp2 + enemyX + enemyY) % 32) + 1]
- if rn + temp1 >= cmpRed then
- gui.text(posX, posY + 7, wait)
- break
- end
- wait = wait + 1
- temp1 = (temp1 + 1) % 256
- if (temp1 % 16 == 0) then
- temp2 = temp2 + 1
- end
- end
- end
- end
- end
- end
- vba.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement