Advertisement
Kirkq

Quest GBC Lua

Aug 23rd, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.54 KB | None | 0 0
  1. --TO DO
  2. --Experience point values.
  3.  
  4. local MaxMPAd = 0xC101
  5. local CurrMPAd = 0xC103
  6. local MaxHPAd = 0xC105
  7. local CurrHPAd = 0xC107 --not actual battle HP, that is CurrHP2Ad
  8. local AgilityAd = 0xC109 -- need to match highest enemy agility to go first
  9. -- 0-23 AG = 3 steps wide.
  10. -- 24-35 = 5 steps wide. (+11)
  11.  
  12. --25 = 2% per step
  13.  
  14. --36-47 = 7 steps wide. (+11)
  15. --48-59 = 9 steps wide. (+11)
  16. --60-?? = 11 steps wide.
  17. local DefenseAd = 0xC10B
  18. local FireLevel = 0xC10E
  19. local WindLevel = 0xC10F
  20. local WaterLevel = 0xC110
  21. local EarthLevel = 0xC111
  22. --
  23. local NumberItems = 0xC112 --Game checks this when you pick up an item I think
  24. local FirstItemSlot = 0xC113
  25. local LastItemSlot = 0xC126 -- This may or may not be only indicative?
  26. local ItemArray = {"Spirit Light","Fresh Bread", "Honey Bread","Healing Potion", "Dragon's Potion","Dew Drop","Mint Leaves","Heroes Drink","Secret Potion","Silent Flute","Celine's Bell","Replica","Giant's Shoes","Silver Amulet","Golden Amulet"} --From ID 1 to 15
  27. --
  28. local MelrodeWings = 0xC127 -- 1 if have, 0 if do not have
  29. local DondoranWings = 0xC128
  30. local LarapoolWings = 0xC129
  31. local NormoonWings = 0xC12A
  32. local LimelinWings = 0xC12B
  33. local BrannochWings = 0xC12C
  34. --
  35. local HaveEarthOrb = 0xC12D -- 0 = do not have, 1 = have
  36. local HaveWindJade = 0xC12E
  37. local HaveWaterJewel = 0xC12F
  38. local HaveFireRuby= 0xC130
  39. local HaveEletaleBook = 0xC131
  40. local HaveDarkGaolKey = 0xC132
  41. local HaveWarriorBadge = 0xC133
  42. local HaveWarriorStaff = 0xC134
  43. local HaveWarriorCape = 0xC135
  44. local HaveOrchestra = 0xC136
  45. --
  46. local LotteryInProgress = 0xC137 --0 if no, 1 if waiting for pidgeon, 3 if something in mailbox.
  47. local SpiritGemstones = 0xC138
  48. local LotteryStepCounter = 0xC139 --255 steps on overworld until pidgeon comes. If the number is even upon entering the overworld, it will decrease by one
  49. --
  50. local HPPercentAd = 0xC13A --Increments on physical attacks and either staff swings or hits.
  51. local MPPercentAd = 0xC13B -- Increments per spell that connects per enemy
  52. local AgilityPercentAd = 0xC13C
  53. --Moving in battle increments this when not running away.
  54. --It goes up by 10 per step initially, then later 2 per step.
  55. --Moving diagonally = 20 per step initially
  56. --Will stop you at 0 on rollover with no carryover.
  57. local DefensePercentAd = 0xC13D --Increments 3% at a time, rolls over after 102 damage.
  58. local ElementPercentAd = 0xC13E --Enemies seem to have an experience point value.
  59. local ExperienceHigh = 0xC13F
  60. local ExperienceLow = 0xC140
  61. local BrianLevel = 0xC141
  62. local XPosHigh = 0xC144
  63. local XPosLow = 0xC145
  64. local YPosHigh = 0xC146
  65. local YPosLow = 0xC147
  66. --1 step = 8 frames, 1 grid square = 2 steps
  67. local LotteryItemGoingFor = 0xC455 --You cannot win an item type you already have.
  68. local LotteryArray = {"Mint Leaves","Healing Potion","Heroes Drink","Spirit Light","Dragon's Potion","Secret Potion","Warrior's Cape","Warrior's Staff","Warrior's Badge","Orchestra"} --starts at index 1
  69. local BrianInTransit = 0xC45B -- 0 to 7 in movement
  70. local BrianBattleY = 0xC45C
  71. local BrianBattleX = 0xC45D
  72. local InBattle = 0xC464 -- 4 in town/overworld/dungeon, 2 in random battle
  73.  
  74. local NumEnemies1 = 0xC588
  75. local NumEnemies2 = 0xC589
  76. local MagicBarrierAd = 0xC612
  77. local NumEnemies3 = 0xCB28 --Objects on screen in battle?
  78.  
  79. local BrianAttackEligible = 0xC59B
  80. local CurrHP2Ad = 0xC5F1 -- BattleHP
  81.  
  82. local EnemyState = {}
  83. local EnemyY = {}
  84. local EnemyX = {}
  85. local EnemyType = {}
  86. local EnemyMaxHPHigh = {}
  87. local EnemyMaxHPLow = {}
  88. local EnemyCurrHPHigh = {}
  89. local EnemyCurrHPLow = {}
  90. local EnemyAgility = {}
  91. local EnemyDefense = {}
  92. local EnemyAtk = {}
  93. local EnemyElement = {}
  94. local EnemyItemDrop = {}
  95. local EnemyExp = {}
  96. local EnemyExperienceValue = {}
  97.  
  98. EnemyState[1] = 0xC615 -- 0 = dead, 1 = alive sometimes, 2 = its turn
  99. EnemyY[1] = 0xC618
  100. EnemyX[1] = 0xC619
  101. EnemyType[1] = 0xC626 --Indicative but not modifiable?
  102. EnemyMaxHPHigh[1] = 0xC62C
  103. EnemyMaxHPLow[1] = 0xC62D
  104. EnemyCurrHPHigh[1] = 0xC62E
  105. EnemyCurrHPLow[1] = 0xC62F
  106. EnemyAgility[1] = 0xC631
  107. EnemyDefense[1] = 0xC633
  108. EnemyAtk[1] = 0xC635
  109. EnemyElement[1] = 0xC636 --I think this is right? 3 earth 2 water, 1 = wind, 0 = fire
  110. EnemyExp[1] = 0xC638
  111. EnemyItemDrop[1] = 0xC639
  112. --EnemyExperienceValue
  113.  
  114. EnemyState[2] = 0xC653 -- 0 = dead, 1 = alive, 2 = its turn
  115. EnemyY[2] = 0xC656 --top of sprite, mirrored in 0xCF67
  116. EnemyX[2] = 0xC657 --left of sprite
  117. EnemyType[2] = 0xC664
  118. EnemyMaxHPHigh[2] = 0xC66A
  119. EnemyMaxHPLow[2] = 0xC66B
  120. EnemyCurrHPHigh[2] = 0xC66C
  121. EnemyCurrHPLow[2] = 0xC66D
  122. EnemyAgility[2] = 0xC66F
  123. EnemyDefense[2] = 0xC671
  124. EnemyAtk[2] = 0xC673
  125. EnemyElement[2] = 0xC674
  126. EnemyExp[2] = 0xC676
  127. EnemyItemDrop[2] = 0xC677
  128.  
  129. EnemyState[3] = 0xC691
  130. EnemyY[3] = 0xC694
  131. EnemyX[3] = 0xC695
  132. EnemyType[3] = 0xC6A2
  133. EnemyMaxHPHigh[3] = 0xC6A8
  134. EnemyMaxHPLow[3] = 0xC6A9
  135. EnemyCurrHPHigh[3] = 0xC6AA
  136. EnemyCurrHPLow[3] = 0xC6AB
  137. EnemyAgility[3] = 0xC6AD
  138. EnemyDefense[3] = 0xC6AF
  139. EnemyAtk[3] = 0xC6B1
  140. EnemyElement[3] = 0xC6B2
  141. EnemyExp[3] = 0xC6B4
  142. EnemyItemDrop[3] = 0xC6B5
  143.  
  144.  
  145.  
  146.  
  147. local LotteryRNG = 0xD522 --You win the lottery on multiples of 8, not including 0.
  148. local DefCounterSubAd = 0xD56D --0 to 2, maybe more later?
  149. local ToNextLevelHigh = 0xD5E8
  150. local ToNextLevelLow = 0xD5E9
  151. local BrianInTransit2 = 0xD837
  152. local StepCounter = 0xD82F --refreshes to 28-43 upon entering a battle.
  153. --56-86
  154.  
  155.  
  156. local RNG1Ad = 0xD82C --This does battle type and attack damages seemingly. It is part of the time based step counter determination. Changes based on Y position
  157. local RNG2Ad = 0xD5CD --This represents the amount to be subtracted every 8th frame on the overworld
  158.  
  159. --ON THE OVERWORLD OUTSIDE OF BATTLE
  160. -- 7 out of 8 frames, the RNG1 will decrease by a constant amount from 1 to 255 determined by Y CAMERA position and whether or not you last moved up or down. Up is 19 more than down.
  161. --On the 8th frame as determined by RNG2, the RNG1 will decrease by the exact value referred to by the value of RNG2 --the emulator can override lua byte setting when this 8th frame occurs.
  162. --The 8th frame values subtracted are: An example is: Starting with rollover from 0 to 1: 225, 126, 173, 92, 69, 122, 1, 160, (THESE CHANGE BETWEEN AREAS)
  163. --Moving the camera in the y direction will add 30 if it does not occur on the 8th frame. Up = 30 at start of step, Down = 30 at end of step.
  164.  
  165. --INSIDE A DUNGEON OUTSIDE OF BATTLE
  166. --the RNG1 will decrease by a constant amount from 1 to 255 determined by Y CAMERA POSITION and whether or not you last moved up or down. Up is 19 more than down.
  167. --Moving the camera in the y direction will add 200 if it does not occur on the 8th frame. Up = 200 at start of step, Down = 200 at end of step.
  168.  
  169. --INSIDE A BATTLE:
  170. --Standing still, the decrement per frame is approximately 212 to 214 depending on the amount of enemies in the battle.
  171. --If you stand in the escape zone this decrement will go between another exact value dependent on position and exactly 212-214 as the ESC text flashes.
  172. --Moving around the arena produces specific increments.
  173. --When enemies move and attack, the RNG behavior is a bit unpredictable.
  174.  
  175. local TestByte1 = 0xC126 --198->218
  176. local TestByte2 = 0xCF8C -- 210-230
  177.  
  178. --Healing = 4 water, 3 earth
  179. --Magic Barrier = 12 earth, 12 fire, 12 wind
  180.  
  181. ThisFrameRNG1 = 0
  182. LastFrameRNG1 = 0
  183.  
  184. StepCountTemp = 0
  185. PrevX = 256*memory.readbyte(XPosHigh) + memory.readbyte(XPosLow)
  186. PrevY = 256*memory.readbyte(YPosHigh) + memory.readbyte(YPosLow)
  187. ThisX = 256*memory.readbyte(XPosHigh) + memory.readbyte(XPosLow)
  188. ThisY = 256*memory.readbyte(YPosHigh) + memory.readbyte(YPosLow)
  189. BattleX = memory.readbyte(BrianBattleX)
  190. BattleY = memory.readbyte(BrianBattleY)
  191.  
  192. ScreenshotCounter = 0
  193.  
  194. --------------------------------------------------------
  195.  
  196. --require "gd"
  197.  
  198.  
  199. --snes9xImage = nil;
  200. --hugeImage = gd.create((1200), (1200));
  201.  
  202. --snes9xImage = gd.createFromGdStr(gui.gdscreenshot());
  203. --gd.copy(hugeImage, snes9xImage, ThisX - BattleX, ThisY - BattleY, 0, 0, snes9xImage:sizeX(), snes9xImage:sizeY());
  204. --gd.copy(hugeImage, snes9xImage, X, Y, 0, 0, snes9xImage:sizeX(), snes9xImage:sizeY());
  205. --hugeImage:png("map.png");
  206.  
  207.  
  208. --------------------------------------------------------
  209.  
  210.  
  211.  
  212. while true do
  213.  
  214. --if ScreenshotCounter == 100 then
  215. --snes9xImage = gd.createFromGdStr(gui.gdscreenshot());
  216. --gd.copy(hugeImage, snes9xImage, ThisX - BattleX, ThisY - BattleY, 0, 0, snes9xImage:sizeX(), snes9xImage:sizeY());
  217. ----gd.copy(hugeImage, snes9xImage, X, Y, 0, 0, snes9xImage:sizeX(), snes9xImage:sizeY());
  218. --hugeImage:png("map.png");
  219. --ScreenshotCounter = 0
  220. --end
  221.  
  222. --ScreenshotCounter = ScreenshotCounter + 1
  223.  
  224. if true then
  225. ThisX = 256*memory.readbyte(XPosHigh) + memory.readbyte(XPosLow)
  226. ThisY = 256*memory.readbyte(YPosHigh) + memory.readbyte(YPosLow)
  227. if PrevX~=ThisX then
  228. StepCountTemp = StepCountTemp+1
  229. PrevX = ThisX
  230. end
  231. if PrevY~=ThisY then
  232. StepCountTemp = StepCountTemp+1
  233. PrevY = ThisY
  234. end
  235.  
  236. gui.text(1,80, StepCountTemp/8)
  237.  
  238. end
  239.  
  240.  
  241.  
  242. if true then
  243. for i = 1,3 do
  244. -- if the enemy is not dead, if you are in battle, and there are at least that many enemies
  245. if ((memory.readbyte(EnemyState[i]) ~= 0) and (memory.readbyte(InBattle) == 2) and (memory.readbyte(NumEnemies1) + 1) > i) then --This still may be bugged.
  246. --gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) - 19, "#" .. memory.readbyte(EnemyType[i]))
  247. gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) - 19, i)
  248. gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) - 10, memory.readbyte(EnemyCurrHPHigh[i])*256 + memory.readbyte(EnemyCurrHPLow[i]))
  249. gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) - 1, "A" .. memory.readbyte(EnemyAgility[i]))
  250. --gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) + 8, "D" .. memory.readbyte(EnemyDefense[i]))
  251. gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) + 8, "E" .. 256*memory.readbyte(EnemyExp[i]-1) + memory.readbyte(EnemyExp[i]))
  252. if (memory.readbyte(EnemyItemDrop[i]) ~=0) then
  253. gui.text(memory.readbyte(EnemyX[i]) - 5, memory.readbyte(EnemyY[i]) + 17, "I" .. memory.readbyte(EnemyItemDrop[i]))
  254. end
  255. end
  256. end
  257. end
  258.  
  259. if false then
  260. --memory.writebyte(HaveEarthOrb,1)
  261. --memory.writebyte(SpiritGemstones, 10)
  262. --memory.writebyte(DefenseAd, 50)
  263. --memory.writebyte(CurrHPAd,199)
  264. --memory.writebyte(CurrHP2Ad,199)
  265. --memory.writebyte(CurrMPAd,15)
  266. --memory.writebyte(MaxHPAd,200)
  267.  
  268. --memory.writebyte(StepCounter,3)
  269. --memory.writebyte(RNG1Ad,240)
  270. --memory.writebyte(AgilityAd,24)
  271. --memory.writebyte(RNG2Ad,0)
  272. --memory.writebyte(RNG2Ad,0)
  273. end
  274.  
  275. LastFrameRNG1 = ThisFrameRNG1
  276. ThisFrameRNG1 = memory.readbyte(RNG1Ad)
  277. RNG1Diff = LastFrameRNG1 - ThisFrameRNG1
  278. if (RNG1Diff < 0) then
  279. RNG1Diff = 256 + LastFrameRNG1 - ThisFrameRNG1
  280. end
  281.  
  282.  
  283.  
  284. if false then
  285. memory.writebyte(EarthLevel,14)
  286. memory.writebyte(WaterLevel,8)
  287. memory.writebyte(FireLevel,12)
  288. memory.writebyte(WindLevel,12)
  289. end
  290.  
  291. Fire = memory.readbyte(FireLevel)
  292. Water = memory.readbyte(WaterLevel)
  293. Earth = memory.readbyte(EarthLevel)
  294. Wind = memory.readbyte(WindLevel)
  295. Step = memory.readbyte(StepCounter)
  296. MaxMP = memory.readbyte(MaxMPAd)
  297. CurrMP = memory.readbyte(CurrMPAd)
  298. MaxHP = memory.readbyte(MaxHPAd)
  299. CurrHP = memory.readbyte(CurrHPAd)
  300. Agility = memory.readbyte(AgilityAd)
  301. Defense = memory.readbyte(DefenseAd)
  302. LotteryStep = memory.readbyte(LotteryStepCounter)
  303. LotteryProgress = memory.readbyte(LotteryInProgress)
  304. HPPercent = memory.readbyte(HPPercentAd)
  305. MPPercent = memory.readbyte(MPPercentAd)
  306. AgilityPercent = memory.readbyte(AgilityPercentAd)
  307. DefensePercent = memory.readbyte(DefensePercentAd)
  308. ElementPercent = memory.readbyte(ElementPercentAd)
  309. LotteryItemGoing = memory.readbyte(LotteryItemGoingFor)
  310. DefCounterSub = memory.readbyte(DefCounterSubAd)
  311. RNG1 = memory.readbyte(RNG1Ad)
  312. RNG2 = memory.readbyte(RNG2Ad)
  313. MagicBarrier = memory.readbyte(MagicBarrierAd)
  314. BattleX = memory.readbyte(BrianBattleX)
  315. BattleY = memory.readbyte(BrianBattleY)
  316.  
  317. if true then
  318. gui.text(1,50, RNG1)
  319. gui.text(20,50,"D: " .. RNG1Diff)
  320. gui.text(1,60, RNG2)
  321. end
  322.  
  323. if MagicBarrier~=0 then
  324. gui.text(1, 100, "MB " .. (MagicBarrier))
  325. end
  326.  
  327. XPos = 256*memory.readbyte(XPosHigh) + memory.readbyte(XPosLow)
  328. YPos = 256*memory.readbyte(YPosHigh) + memory.readbyte(YPosLow)
  329. gui.text(1,0,"X " .. (XPos))
  330. gui.text(1,10,"Y " .. (YPos))
  331. gui.text(1,20,"Step " .. Step)
  332.  
  333. gui.text(28, 0, "X " .. (BattleX))
  334. gui.text(28, 10, "Y " .. (BattleY))
  335.  
  336. if (LotteryProgress ~= 0) then
  337. if (LotteryProgress == 1) then
  338. gui.text(1,30, "Lottery: " .. LotteryStep)
  339. end
  340. if (LotteryProgress == 3) then
  341. gui.text(1,30, "Item in Box")
  342. end
  343. gui.text(1,40, LotteryArray[LotteryItemGoing+1])
  344. end
  345.  
  346. if true then
  347. ElementXBase = 1--top left corner
  348. ElementYBase = 114
  349. gui.text(ElementXBase + 7, ElementYBase, Fire)
  350. gui.text(ElementXBase + 14, ElementYBase + 7, Wind)
  351. gui.text(ElementXBase, ElementYBase + 7, Earth)
  352. gui.text(ElementXBase + 7, ElementYBase + 14, Water)
  353. end
  354.  
  355. if true then
  356. StatXBase = 111
  357. StatYBase = 88
  358. gui.text(StatXBase + 33, StatYBase - 10, memory.readbyte(BrianLevel))
  359. gui.text(StatXBase,StatYBase, memory.readbyte(ExperienceHigh)*256 + memory.readbyte(ExperienceLow) .. "/" .. memory.readbyte(ToNextLevelHigh)*256 + memory.readbyte(ToNextLevelLow))
  360. gui.text(StatXBase + 33, StatYBase, ElementPercent .. "%")
  361. gui.text(StatXBase,StatYBase + 10, CurrHP .. "/" .. MaxHP)
  362. gui.text(StatXBase + 33,StatYBase + 10, HPPercent .. "%")
  363. gui.text(StatXBase,StatYBase + 20, CurrMP .. "/" .. MaxMP)
  364. gui.text(StatXBase + 33,StatYBase + 20, MPPercent .. "%")
  365. gui.text(StatXBase,StatYBase + 30, Agility)
  366. gui.text(StatXBase + 33,StatYBase + 30, AgilityPercent .. "%")
  367. gui.text(StatXBase,StatYBase + 40, Defense)
  368. gui.text(StatXBase + 33,StatYBase + 40, DefensePercent + DefCounterSub .. "%") --This is out of 102%.
  369. end
  370.  
  371. vba.frameadvance();
  372. end
  373.  
  374. --Experience Levels
  375. --1 20 exp (3 ME = 24)
  376. --2 25 exp (4 ME)
  377. --3 30 (+5) (4 ME)
  378. --4 35 (+10) (5 ME)
  379. --5 45 exp
  380. --6 55 exp
  381. --7 65 exp
  382. --8 75 (+10)
  383. --9 85 (+15)
  384. --10 100 exp
  385. --11 115 exp
  386. --12 130 exp
  387. --13 145 exp
  388. --14 150 exp
  389. --15 165 exp
  390. --16 180 exp
  391. --17 195 exp
  392. --18 210 exp
  393. --19 225 exp
  394. --20 240 exp
  395. --21 255 exp
  396. --22 270 exp
  397. --23 285 (+15)
  398. --24 300 (+20)
  399. --25 320 exp
  400. --26 340 exp
  401. --27 360 exp
  402. --28 380 exp
  403. --29 400 exp
  404. --30 420 exp
  405. --31 440 exp
  406. --32 460 exp
  407. --33 480 (+20)
  408. --34 500 (+25)
  409. --35 525
  410. --36 550
  411. --37 575
  412. --38 600
  413. --39 625
  414. --40 650
  415. --41 675 (+25)
  416. --42 700 (+30)
  417. --43 730
  418. --44 760
  419. --45 790
  420. --46 820
  421. --47 850
  422. --48 880
  423. --49 910
  424. --50 940
  425. --51 970 (+30)
  426. --52 1000 (+50)
  427. --55 1150 (+50)
  428. --60 1400 (+50)
  429. --61 1450 (+50)
  430. --62 1500 (+50)
  431. --63 1600 (+100)
  432. --64 1700 (+100)
  433. --65 1800 (+100)
  434. --70 2300 (+100)
  435. --75 2800 (+100)
  436. --80 3300 (+100)
  437. --85 3800 (+100)
  438. --86 3900 (+100)
  439. --87 4000 (+100)
  440. --88 4200 (+200)
  441. --89 4400 (+200)
  442. --90 4600 (+200)
  443. --95 5600 (+200)
  444. --100 6600 (+200)
  445.  
  446.  
  447. --Big Mouth = 2
  448. --Were Hare = 2
  449. --Parassault = 3
  450. --Bumbershoot = 3
  451. --Hell Hound = 3
  452. --Man Eater = 4
  453.  
  454. --200 frames to get an overworld spirit almost exactly.
  455.  
  456. --Tim, 3 turns with 2 earth, 4 turns with 2 water.
  457.  
  458. --Ideally level 1x off random battles before going to dondoran otherwise a level is wasted.
  459.  
  460. -- 5-6 wind for Solvaring
  461. --~12 wind or less for kiliac
  462. --~15 wind for dragon, more will cut down turns substantially.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement