Advertisement
SerityW

Untitled

Mar 8th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.47 KB | None | 0 0
  1. function dialog_AuctionHouseRNGHijack() -- replaces dialog 2625 in bank 1, allows forcing magicite at the auction
  2.     local text = [[Looking for something special? Today's<NL>featured auction is just about to start!]]
  3.    if (allowForceAuctionHouse) then
  4.        local ticket = (bit.band(memory.readbyte(0x7E1EBB),0x40) > 0x00)
  5.        local helmet = (bit.band(memory.readbyte(0x7E1EBB),0x80) > 0x00)
  6.        local ruin   = (bit.band(memory.readbyte(0x7E1E94),0x10) > 0x00)
  7.        local pupu   = (bit.band(memory.readbyte(0x7E1EAD),0x10) > 0x00)
  8.        local golem  = (bit.band(memory.readbyte(0x7E1EAD),0x20) > 0x00)
  9.  
  10.        local missingOptions = {}
  11.        local pupuRNG  = 0x9D
  12.        local golemRNG = 0x9E
  13.        
  14.        -- in the world of ruin, they change if you have the opera ticket but no helmet..
  15.        -- (if you don't have the ticket, the ticket is enforced over magicite)
  16.         if (ruin) then
  17.             if (ticket and not helmet) then
  18.                 if (not pupu and not golem) then
  19.                     pupuRNG  = 0x9C
  20.                     golemRNG = 0x9D
  21.                 elseif (pupu) then
  22.                     golemRNG = 0x9D
  23.                     pupuRNG = nil
  24.                 elseif (golem) then
  25.                     golemRNG = 0x9D -- is swapped with pupu below, leave this here
  26.                 end
  27.             end
  28.         end
  29.        
  30.         -- if you own golem, pupu's rng byte becomes golem's
  31.         if (golem and not pupu) then
  32.             pupuRNG = golemRNG
  33.             golemRNG = nil
  34.         end
  35.        
  36.         -- if we don't have golem..
  37.         if (golemRNG and not golem) then -- 'bought golem in jidoor' bit is 0x20 (not same as unlocked espers)
  38.             missingOptions[#missingOptions + 1] = golemRNG -- valid rng to force golem
  39.         end
  40.         -- if we don't have pupu..
  41.         if (pupuRNG and not pupu) then -- 'bought pupu in jidoor' bit is 0x10 (not same as unlocked espers)
  42.             missingOptions[#missingOptions + 1] = pupuRNG -- valid rng to force pupu
  43.         end        
  44.         if (#missingOptions > 0) then
  45.             local randByte = 0x7E1F6D
  46.             local newVal = missingOptions[math.random(1,#missingOptions+1)]
  47.             if (newVal) then
  48.                 memory.writebyte(randByte,newVal)
  49.                 if (ruin and not ticket) then
  50.                     text = text..[[<NL>Our bosses are pushing this Opera<NL>Ticket really hard right now_]]
  51.                 elseif (newVal == pupuRNG) then
  52.                     text = text..[[<NL>We've got the amazing PuPu magicite<NL>on offer right now!]]
  53.                elseif (newVal == golemRNG) then
  54.                    text = text..[[<NL>We've got the amazing Golem magicite<NL>on offer right now!]]
  55.                 end
  56.             else
  57.                 newVal = math.random(0x00,0xFF) -- randomize the item on offer if it's not magicite
  58.                 memory.writebyte(randByte,newVal) -- prevents it from being magicite anyways if selected after magicite
  59.                 if (ruin and not ticket) then
  60.                     text = text..[[<NL>Today it's just assorted goods, but we can't<NL>sell magicite as long as we have a Ticket!]]
  61.                 else
  62.                     text = text..[[<NL>There's no magicite for offer right now, but<NL>talk to me again and I could change my mind!]]
  63.                end
  64.            end
  65.        end
  66.    end
  67.    text = text..[[<EOP><c><bullet> (Join in the bidding.)<NL><c><bullet> (Maybe another time.)]]
  68.    return text
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement