Advertisement
Guest User

Devil Island level 16 exp grind bot v0.0 by ThunderAxe31

a guest
Nov 15th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.24 KB | None | 0 0
  1. --Devil Island level 16 exp grind bot v0.0 by ThunderAxe31
  2. --This is an alpha version, so there is a lot of unfinished stuff scattered around, but it's already usable.
  3.  
  4. local cycle = 0
  5. local cycle_sub = 0
  6.  
  7. local addr_objects = 0xC200
  8.  
  9. local level_x    = memory.read_u16_le(0xC122)
  10. local experience = memory.read_u16_be(0xCFF8)
  11. local player_hp  = 0
  12.  
  13. local experience_old = -1
  14. local player_hp_old  = -1
  15.  
  16. local timing_whip_1 = -1
  17. local timing_whip_2 = -1
  18. local timing_stop   = -1
  19. local timing_resume = -1
  20. local timing_jump   = -1
  21.  
  22. local timing_hurt_1 = -1
  23. local timing_hurt_2 = -1
  24. local timing_hurt_3 = -1
  25. local timing_hurt_4 = -1
  26.  
  27. local whip_wait_start = 21 --constant confirmed
  28. local exp_wait = 15
  29. local move_wait_start = 40 --constant TO CONFIRM
  30.  
  31. local wait_hurt = 20 --constant
  32.  
  33. local function wait_disappear()
  34.     savestate.save(".\\Devil Island level 16 exp grind bot\\" .. cycle .. "subtest.state")
  35.     while true do
  36.         for y = 0, 3 do --yes, there are just 4 object slots
  37.             local addr = addr_objects+y*0x20 --data chunks for objects are 32 bytes long
  38.             if memory.read_u8(addr)==0 or memory.read_u8(addr+0x4)==1 or memory.read_u8(addr+0x4)==2 then --check if any disappeared
  39.                 console.log("cycle_sub " .. cycle_sub .. " at frame " .. emu.framecount())
  40.                 savestate.load(".\\Devil Island level 16 exp grind bot\\" .. cycle .. "subtest.state")
  41.                 savestate.save(".\\Devil Island level 16 exp grind bot\\" .. cycle .. "_" .. cycle_sub .. ".state")
  42.                 return
  43.             end
  44.         end
  45.         emu.frameadvance()
  46.     end
  47. end
  48.  
  49. local function check_hurt_1()
  50.     while true do
  51.         joypad.set({["Right"]=true})
  52.         player_hp  = memory.read_u8(0xCFF5)
  53.         if player_hp_old > player_hp then
  54.             timing_hurt_1 = emu.framecount()
  55.             return
  56.         end
  57.         player_hp_old = player_hp
  58.         emu.frameadvance()
  59.     end
  60. end
  61.  
  62. local function do_whipping()
  63.         cycle_sub = 0
  64.         experience = memory.read_u16_be(0xCFF8)
  65.         experience_old = experience
  66.         for i = 0 , whip_wait_start do
  67.             for j = 0 , whip_wait_start do
  68.                 savestate.load(".\\Devil Island level 16 exp grind bot\\" .. cycle .. ".state")
  69.                 player_hp_old = player_hp
  70.                 while player_hp_old <= player_hp do
  71.                     player_hp_old = player_hp
  72.                     local framecount = emu.framecount()
  73.                     if framecount == (timing_hurt_1 - whip_wait_start + i) or
  74.                        framecount == (timing_hurt_1 - whip_wait_start + i + 1) or
  75.                        framecount == (timing_hurt_1 + i + j) or
  76.                        framecount == (timing_hurt_1 + i + j + 1) then
  77.                         joypad.set({["B"]=true})
  78.                     end
  79.                     joypad.set({["Right"]=true})
  80.                     emu.frameadvance()
  81.                     player_hp = memory.read_u8(0xCFF5)
  82.                     if framecount > timing_hurt_1 + exp_wait then
  83.                         experience = memory.read_u16_be(0xCFF8)
  84.                         if (experience_old + 24) <= experience then--if all enemies have been killed
  85.                             wait_disappear()
  86.                             cycle_sub = cycle_sub + 1
  87.                             break
  88.                         end
  89.                     end
  90.                 end
  91.                 if emu.framecount() <= (timing_hurt_1 + i + j) then break end --if we get hit before being able to hit 2, increase hit 1 delay
  92.             end
  93.         end
  94.        
  95.         console.log("the end")
  96. end
  97.  
  98. savestate.save(".\\Devil Island level 16 exp grind bot\\" .. cycle .. ".state")
  99.  
  100. --while true do
  101.    
  102.     check_hurt_1() --check for timing_hurt_1
  103.     do_whipping()
  104.    
  105. --  cycle = cycle + 1
  106. --  emu.frameadvance()
  107. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement