Advertisement
exodus122

Turn received item into blue rupee

Dec 12th, 2019
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.81 KB | None | 0 0
  1. // This function takes an item value as input, then returns FF if the item doesn't use a slot. If it does use a slot, then it can return FF or some other value. Basically, this function is used to determine if an item has already been obtained (the slot is filled), which is used to convert items into blue rupees.
  2.  
  3. uint FUN_801143cc(uint ItemValue) // not get item value, but the actual value of the item to be received
  4.  
  5. {
  6.   int loopCounter;
  7.   uint ItemSlot;
  8.   uint ItemSlotCopy;
  9.   undefined *puVar4;
  10.  
  11.   ItemValue = ItemValue & 0xff;
  12.   ItemSlot = (uint)(byte)(&DAT_801c2078)[ItemValue]; // Loads the slot from the slot table
  13.   ItemSlotCopy = ItemSlot;
  14.   if (0x8a < ItemValue) { // Refill ammo or glitched item
  15.     ItemSlotCopy = (uint)(byte)(&DAT_801c2078)[*(short *)(&DAT_801bf79e + ItemValue * 2)]; // gets slot value from the "Item Refill Slot Table"
  16.   }
  17.   if (ItemValue == 0x6e) { // (unused Gold Skulltula Spirit marker on quest status screen?)
  18.     return 0xff;
  19.   }
  20.   if (ItemValue == 0x31) { // Tingle's map
  21.     return 0xff;
  22.   }
  23.   if (ItemValue == 0x6d) { // Bomber's Notebook
  24.     return 0xff;
  25.   }
  26.   if ((0x4c < ItemValue) && (ItemValue < 0x50)) { // Kokiri/Razor/Gilded Sword
  27.     return 0xff;
  28.   }
  29.   if ((0x50 < ItemValue) && (ItemValue < 0x53)) { // Hero's/Mirror Shield
  30.     return 0xff;
  31.   }
  32.   if (((ItemValue == 0x74) || (ItemValue == 0x75)) || (ItemValue == 0x76)) { // Boss Key/Compass/Map
  33.     if ((*(uint *)(&DAT_801c1b60 + ItemValue * 4) & (uint)(byte)(&DAT_801ef730)[_DAT_801f35a6]) !=0)
  34.     {
  35.       return ItemValue;
  36.     }
  37.     return 0xff;
  38.   }
  39.   if (ItemValue == 0x78) { // Small Key
  40.     return 0xff;
  41.   }
  42.   if ((((ItemValue == 0) || (ItemValue == 7)) || // Ocarina/Bombchus(10)/Hookshot/Lens/Great Fairy Sword/Pictograph Box
  43.       ((ItemValue == 0xf || ((ItemValue == 0xe || (ItemValue == 0x10)))))) || (ItemValue == 0xd)) {
  44.     if ((&DAT_801ef6e0)[ItemSlot] != 0xff) {
  45.       return (uint)(byte)(&DAT_801ef6e0)[ItemSlot];
  46.     }
  47.     return 0xff;
  48.   }
  49.   if ((0x8e < ItemValue) && (ItemValue == 0x92)) { // Bombs(30). This should have been all bomb refills, but the dev made a typo
  50.     if ((_DAT_801ef728 & DAT_801c1dc4) >> ((uint)DAT_801c1e05 & 0x1f) != 0) {
  51.       return 0;
  52.     }
  53.     return 0xff;
  54.   }
  55.   if ((0x96 < ItemValue) && (ItemValue < 0x9b)) { // Bombchu refill
  56.     if ((_DAT_801ef728 & DAT_801c1dc4) >> ((uint)DAT_801c1e05 & 0x1f) != 0) {
  57.       return 0;
  58.     }
  59.     return 0xff;
  60.   }
  61.   if ((ItemValue == 0x53) || (ItemValue == 1)) { // Hero's Bow/Quiver 30
  62.     if ((_DAT_801ef728 & DAT_801c1dc0) >> ((uint)DAT_801c1e04 & 0x1f) != 0) {
  63.       return 0;
  64.     }
  65.     return 0xff;
  66.   }
  67.   if ((ItemValue == 0x54) || (ItemValue == 0x55)) { // Quiver 40/50
  68.     return 0xff;
  69.   }
  70.   if ((ItemValue == 0x56) || (ItemValue == 6)) { // Bombs (20)/Bomb Bag 20
  71.     if ((_DAT_801ef728 & DAT_801c1dc4) >> ((uint)DAT_801c1e05 & 0x1f) != 0) {
  72.       return 0;
  73.     }
  74.     return 0xff;
  75.   }
  76.   if ((0x9a < ItemValue) && (ItemValue < 0x9f)) { // Stick or Nut Capacity upgrade
  77.     return 0xff;
  78.   }
  79.   if ((0x56 < ItemValue) && (ItemValue < 0x5c)) { // Bomb bag 30/40 or any of 3 wallets
  80.     return 0xff;
  81.   }
  82.   if (ItemValue == 10) { // Magic Beans
  83.     return 0xff;
  84.   }
  85.   if (ItemValue != 0xc) { // not powder keg
  86.     if ((ItemValue == 0x7b) || (ItemValue == 0x70)) { // Piece of Heart or Piece of Heart
  87.       return 0xff;
  88.     }
  89.     if (ItemValue == 0x6f) { // Heart Container
  90.       return 0xff;
  91.     }
  92.     if (ItemValue == 0x83) { // Recovery Heart/Blue Rupee
  93.       return 0x83;
  94.     }
  95.     if ((ItemValue == 0x79) || (ItemValue == 0x7a)) { // Blue Rupee/Magic Jar
  96.       if ((DAT_801f0574 & 0x80) != 0) {
  97.         return ItemValue;
  98.       }
  99.       return 0xff;
  100.     }
  101.     if ((0x83 < ItemValue) && (ItemValue < 0x8b)) { // Rupees
  102.       return 0xff;
  103.     }
  104.     if ((0x5c < ItemValue) && (ItemValue < 0x61)) { // Remains
  105.       return 0xff;
  106.     }
  107.     if (ItemValue == 0x11) { // Bottle of Red Potion/OoT Hookshot
  108.       return 0xff;
  109.     }
  110.     if (ItemValue != 0x12) { // not empty bottle
  111.       if ((((ItemValue != 0x18) && (ItemValue != 0x1d)) && (ItemValue != 0x22)) &&
  112.          ((ItemValue != 0x25 && (ItemValue != 0x26)))) { // not // Milk, Poe, Gold Dust, Chateau Romani, Hylian Loach
  113.         if ((((ItemValue < 0x13) || (0x27 < ItemValue)) &&
  114.             ((ItemValue != 0x9f && (((ItemValue != 0xa0 && (ItemValue != 0xa1)) && (ItemValue != 0xa2))))))
  115.            && (ItemValue != 0xa3)) {
  116.           if ((0x27 < ItemValue) && (ItemValue < 0x4a)) { // Trade Item or Mask
  117.             return 0xff;
  118.           }
  119.         }
  120.         else {
  121.           if ((ItemValue == 0x18) || (ItemValue == 0x19)) { // Milk or Halfmilk
  122.             loopCounter = 0;
  123.             puVar4 = &DAT_801ef670 + ItemSlot;
  124.             while( true ) { // loop 6 times for bottle slots
  125.               loopCounter = (loopCounter + 1) * 0x10000 >> 0x10;
  126.               if (puVar4[0x70] == -1) {
  127.                 return 0xff;
  128.               }
  129.               if (5 < loopCounter)
  130.                   break;
  131.               puVar4 = &DAT_801ef670 + ItemSlot + loopCounter;
  132.             }
  133.           }
  134.           else {
  135.             if (ItemValue == 0x9f) { // Chateau Romani
  136.               ItemSlot = (uint)DAT_801c209d;
  137.             }
  138.             else {
  139.               if (ItemValue == 0xa0) { // Milk
  140.                 ItemSlot = (uint)DAT_801c2090;
  141.               }
  142.               else {
  143.                 if (ItemValue == 0xa1) { // Gold Dust
  144.                   ItemSlot = (uint)DAT_801c209a;
  145.                 }
  146.                 else {
  147.                   if (ItemValue == 0xa2) { // Hylian Loach
  148.                     ItemSlot = (uint)DAT_801c209e;
  149.                   }
  150.                   else {
  151.                     if (ItemValue == 0xa3) { // Seahorse
  152.                       ItemSlot = (uint)DAT_801c209c;
  153.                     }
  154.                   }
  155.                 }
  156.               }
  157.             }
  158.             loopCounter = 0;
  159.             puVar4 = &DAT_801ef670 + ItemSlot;
  160.             while( true ) { // loop 6 times
  161.               loopCounter = (loopCounter + 1) * 0x10000 >> 0x10;
  162.               if (puVar4[0x70] == '\x12') {
  163.                 return 0xff;
  164.               }
  165.               if (5 < loopCounter)
  166.                   break;
  167.               puVar4 = &DAT_801ef670 + ItemSlot + loopCounter;
  168.             }
  169.           }
  170.         }
  171.         return (uint)(byte)(&DAT_801ef6e0)[ItemSlotCopy]; // item in the inventory slot
  172.       }
  173.       return 0xff; // Milk, Poe, Gold Dust, Chateau Romani, Hylian Loach
  174.     }
  175.     return 0xff; // empty bottle
  176.   }
  177.   return 0xff; // powder keg (1)
  178. }
  179.  
  180.  
  181.  
  182.  
  183. /* The full logic for determining if an item is converted into a blue rupee is the following:
  184. itemInSlot = FUN_801143cc(ItemValue)
  185.  
  186. if (flag & 0x40 == 1) && (itemInSlot == 0xFF)
  187.     get blue rupee
  188. else if (itemInSlot == 0xFF) || (flag & 0x20 == 0)
  189.     get item from chest content table
  190. else
  191.     get blue rupee
  192. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement