Offset(x00186000) //Map: 74 Arena //Music: Fighting LoadConditionals(x00C2) PlayTrack(x51) Draw(x90,x00) Draw(x91,x00) Draw(x92,x00) Draw(x93,x00) Draw(x94,x00) Draw(x95,x00) Draw(x96,x00) Draw(x97,x00) Draw(x98,x00) Draw(x99,x00) Draw(x9A,x00) Draw(x9B,x00) ColorField(x01,+000,+000,+000,000) //Set the number of Chests Left. We'll go with all 12 - 0C in hex. SET(x0054,x000C) //Set up the initial Rare Chest odds. Let's say 10% - 0A in hex. Note: this won't affect the starting Press Triangle to Upgrade odds. This variable will be reset to 5% for that later on. SET(x0028,x000A) //Set up the Bonus Reward odds for whether a chest can reward rare items or bonus JP upon opening one. Let's say 5%. SET(x002A,x0005) //Set Var x83 to a value of 1. This will run a separate rare proc check on every single chest at the start, rather than only checking once and assigning the rare status to a random chest. //If you don't want to potentially get multiple randomly selected rare chests, comment out this command, or set the value to zero. SET(x0083,x0001) //Set Var x84 to a value of 1. This will allow players to throw gil at chests until they Upgrade to Rare or Mystery chests. SET(x0084,x0001) //Also, set the upgrade cost. We'll go with 25,000, which is 61A8 in hex. SET(x0022,x61A8) //Figure out the chest types by checking units' Faith. //SaveAddress Pointer (Unit Stats) LUI(x007F,x8019) ADD(x007F,x08CC) //The 12th ENTD unit's stats. LUI(x007E,x8019) ADD(x007E,x1C0C) BackTarget(x05) //Get the unit's Faith LoadAddress(x01,x0026,x7F,001) //Is it greater than x20? SET(x0000,x0020) LT() If() //Yes, it is. Get a random value from 0-6, then. Random(x01,00007) //Is this value 0? If so, it's going to be a weapon later, and needs a +1. SETVar(x0000,x0001) If() Else() //Add +1 to make it a weapon. ADD(x0001,x0001) EndIf() //Add +1 to get the value to be 2-7 rather than 1-6. ADD(x0001,x0001) EndIf() //Kick this value over to Var x18 for a little while so we can run a Random check if needed. SETVar(x0018,x0001) //Is var x83 set? SETVar(x0000,x0083) //It is. Run a rare check. If() Random(x01,00100) SETVar(x0000,x0028) GT() If() //We procced a rare chest. But is this chest already rare? SETVar(x0001,x0018) SET(x0000,x0007) LT() If() //It isn't already rare. Add 6 to its value. Else() ADD(x0018,x0006) EndIf() EndIf() EndIf() //Save the value to the unit's Faith. Also, zero x18 just in case. SaveAddress(x18,x0026,x7F,001) ZERO(x0018) //Chest type is established. Check if we've run out of units yet. SETVar(x0000,x007F) SETVar(x0001,x007E) LT() If() //Not out of units yet. Add to the value of x7E and jump back. ADD(x007F,x01C0) JumpBack(x05) EndIf() //Now we're out of units. //Check if var x83 is set. If not, the rare check is a one-off. SETVar(x0000,x0083) If() //It's not set. Run a rare check now. Else() Random(x01,00100) SETVar(x0000,x0028) GT() If() //We procced a rare chest. Figure out which chest it'll be. Random(x00,00012) MULT(x0000,x01C0) LUI(x007F,x8019) ADD(x007F,x08CC) ADDVar(x007F,x0000) //Unit address is set. Get that unit's Faith. LoadAddress(x01,x0026,x7F,001) //Is this already a rare chest? SET(x0000,x0007) LT() If() //It isn't already rare. Add 6 to its value and save it to the unit. Else() ADD(x0001,x0006) SaveAddress(x01,x0026,x7F,001) EndIf() EndIf() EndIf() //Reset x7F to the first unit's address. LUI(x007F,x8019) ADD(x007F,x08CC) //Set x7E to the eighth unit's address. LUI(x007E,x8019) ADD(x007E,x150C) //Figure out each set of common loot. Weapons, Shields, Helmets, Armor, Accessories, Consumables (and then Number of Consumables). //Then Rare Weapons, Rare Shields, Rare Helmets, Rare Armor, Rare Accessories. //Load every set of loot one by one into Vars x70-x77. Var x78 will be a backup if any unit is missing something in a slot. Var x79 will keep track of which variable we're on right now. Var x7A will be a tally of how many times a slot is empty; if it hits 8, the entire category will be scrapped and set as a Consumable (any empty Consumable will be set to Phoenix Downs). //Var x7B will be used to determine what category we're checking right now: x1D weapons, x20 Shields, x1A Helmets, x1B Armor, x1C Accessories, x163 War Trophies, xE1D rare weapons, xE20 rare shields, xE1A Rare Helmets, xE1B Rare Armor, xE1C Rare Accessories. //x7C will keep track of the current loot category. //x7D will be used to determine what battle stat the LOOT is saved to. This will be to Auto-Status for common loot and Status Immunity for rare loot. Consumables are fine as is. //Weapons //Zero x78. ZERO(x0078) //Set x79 to a value of x70. SET(x0079,x0070) //Zero x7A. ZERO(x007A) //Set x7B to a value of x1D. SET(x007B,x001D) //Set x7C to x02, for the Weapon loot category. SET(x007C,x0002) //Set x7D to x4E SET(x007D,x004E) BackTarget(x06) //Load the stat and see if there's any value there. (It might be set to zero if it's a War Trophy check.) AlterParameter(x41,x7B) LoadAddress(x00,xFFFF,x7F,001) If() //There is a value. But does that value equal xFF, meaning an empty equipment slot? SETVar(x0001,x0000) SET(x0000,x00FF) NEQ() If() //It doesn't. Save this value to the next item list variable, as well as the backup option. AlterParameter(x40,x79) SETVar(xFFFF,x0001) SETVar(x0078,x0001) //But was this a consumable? If so, get their Bonus Money amount as well. Multiply it by 1000 and add it to the variable. Switch(x7B) Case(x0163) LoadAddress(x18,x0164,x7F,001) MULT(x0018,x1000) AlterParameter(x40,x79) ADDVar(xFFFF,x0018) Break() EndSwitch() //Advance the item list variable and move on. ADD(x0079,x0001) //It does. Add 1 to the empty slot tally and move on. Else() ADD(x007A,x0001) EndIf() //The value was set to zero, meaning this should have been an empty consumable. Set x01 to xFD, save the stat, and jump back. Else() SET(x0001,x00FD) AlterParameter(x41,x7B) SaveAddress(x01,xFFFF,x7F,001) JumpBack(x06) EndIf() //Check if the unit address matches the final unit address. SETVar(x0000,x007F) SETVar(x0001,x007E) EQ() If() //They match. Now, did we end up with a backup option? SETVar(x0000,x0078) If() //We did end up with a backup option... not that we're going to use it. Instead, we're going to subtract the number of Random outcomes by the number of empty slots. SET(x0078,x0008) SUBVar(x0078,x007A) //Reset the Unit Address to go to the first unit. LUI(x007F,x8019) ADD(x007F,x08CC) BackTarget(x09) //Run the Random command, and then add x70. AlterParameter(x41,x78) Random(x01,00222) ADD(x0001,x0070) //Set this variable's value to the appropriate stat. AlterParameter(x00,x01) AlterParameter(x41,x7D) SaveAddress(xFF,xFFFF,x7F,001) //Now, check if these were Consumables. If so, divide the value by x1000, and save the result to Bonus Money. Switch(x7B) Case(x0163) AlterParameter(x42,x01) SETVar(x0018,xFFFF) DIV(x0018,x1000) SaveAddress(x18,x0164,x7F,001) Break() EndSwitch() //Check if we're on the eighth unit. If not, jump back. LUI(x0001,x8019) ADD(x0001,x1C0C) SETVar(x0000,x007F) LT() If() ADD(x007F,x01C0) JumpBack(x09) EndIf() //We didn't end up with a backup option. Are we in Rare loot? Else() SETVar(x0000,x007C) SET(x0001,x0007) GT() If() //We are in rare loot. Set the backup option to a value of x0D for the Mystery chest. SET(x0078,x000D) //We aren't in rare loot. Set the backup option to a value of 7 for Consumables. Else() SET(x0078,x0007) EndIf() //Consumables/Mystery have been determined. Go through all 12 chests' Faith and reset it to this if it matches this loot category. LUI(x007F,x8019) ADD(x007F,x08CC) BackTarget(x08) LoadAddress(x00,x0026,x7F,001) SETVar(x0001,x007C) EQ() If() SaveAddress(x78,x0026,x7F,001) EndIf() LUI(x0001,x8019) ADD(x0001,x1C0C) SETVar(x0000,x007F) LT() If() ADD(x007F,x01C0) JumpBack(x08) EndIf() //Now zero the backup option again. ZERO(x0078) EndIf() //Run a switch on the item category to determine what to do next. Switch(x7B) //x1D weapons. Set x7B to shields Case(x001D) SET(x007B,x0020) SET(x007C,x0003) SET(x007D,x004F) Break() //x20 Shields. Set x7B to helmets Case(x0020) SET(x007B,x001A) SET(x007C,x0004) SET(x007D,x0050) Break() //x1A Helmets. Set x7B to armor Case(x001A) SET(x007B,x001B) SET(x007C,x0005) SET(x007D,x0051) Break() //x1B Armor. Set x7B to accessories Case(x001B) SET(x007B,x001C) SET(x007C,x0006) SET(x007D,x0052) Break() //1C Accessories. Set x7B to War Trophies. Case(x001C) SET(x007B,x0163) SET(x007C,x0007) SET(x007D,x0163) Break() //x163 War Trophies. Set x7B to Rare Weapons. Case(x0163) SET(x007B,x0E1D) SET(x007C,x0008) SET(x007D,x0053) Break() //xE1D rare weapons. Set x7B to Rare Shields. Case(x0E1D) SET(x007B,x0E20) SET(x007C,x0009) SET(x007D,x0054) Break() //xE20 rare shields. Set x7B to Rare Helmets. Case(x0E20) SET(x007B,x0E1A) SET(x007C,x000A) SET(x007D,x0055) Break() //xE1A Rare Helmets. Set x7B to Rare Armor. Case(x0E1A) SET(x007B,x0E1B) SET(x007C,x000B) SET(x007D,x0056) Break() //xE1B Rare Armor. Set x7B to Rare Accessories. Case(x0E1B) SET(x007B,x0E1C) SET(x007C,x000C) SET(x007D,x0057) Break() //xE1C Rare Accessories. Jump out of this loop. Case(x0E1C) JumpForward(x07) Break() EndSwitch() //Next loot type has been determined. Return the Unit Address to match the first unit's. Reset the variable pointer to a value of x70. Reset the empty slot tally. Zero the loot table variables. Reset the backup variable. LUI(x007F,x8019) ADD(x007F,x08CC) SET(x0079,x0070) ZERO(x007A) ZERO(x0070) ZERO(x0071) ZERO(x0072) ZERO(x0073) ZERO(x0074) ZERO(x0075) ZERO(x0076) ZERO(x0077) ZERO(x0078) //This wasn't the eighth unit. Add x1C0 to the Unit Address. Else() ADD(x007F,x01C0) EndIf() JumpBack(x06) ForwardTarget(x07) //Set all chests' status using variables 70-7B. 0 empty, 2 Weapon, 3 Shield, 4 Helmet, 5 Armor, 6 Accessory, 7 Consumable, then 7-C repeating 2-6 but Rare. At the moment, nothing will be triggered Rare or Empty. Mystery also isn't triggered here by default. Camera(+00590,-00000,+00350,+01200,-00000,+00000,+02048,+00000) LoadEVTCHR(x00,x6F,x00) WaitForInstruction(x34,x00) SaveEVTCHR(x00) //LoadAddress Pointer (Button Presses) LUI(x0025,x8004) ADD(x0025,x5944) //Check if Chests Left has been set. SETVar(x0000,x0054) If() Else() //Set Chests Left to 3. SET(x0054,x0003) EndIf() //Set Current Chest to x90. SET(x0023,x0090) //Set x0000 to 12 (C). SET(x0000,x000C) //Set the chests' warp locations, initial sprite location, palette, and unitaddresses. BackTarget(x01) JumpForwardIfZero(x02) ADD(x0000,x008F) AlterParameter(x00,x00) WarpUnit(x90,x00,005,005,x00,x00) AlterParameter(x00,x00) EVTCHRPalette(x90,x00,x00,x01) Wait(00001) SUB(x0000,x0090) JumpBack(x01) ForwardTarget(x02) SpriteMove(x97,x00,-00010,+00000,-00116,x00,x02,+00000) SpriteMove(x98,x00,+00036,-00000,-00092,x00,x02,+00000) SpriteMove(x99,x00,+00074,-00000,-00059,x00,x02,+00000) SpriteMove(x9a,x00,+00095,-00000,-00000,x00,x02,+00000) SpriteMove(x9b,x00,+00074,-00000,+00054,x00,x02,+00000) SpriteMove(x90,x00,+00036,-00000,+00088,x00,x02,+00000) SpriteMove(x91,x00,-00010,-00000,+00108,x00,x02,+00000) SpriteMove(x92,x00,-00056,-00000,+00088,x00,x02,+00000) SpriteMove(x93,x00,-00090,-00000,+00054,x00,x02,+00000) SpriteMove(x94,x00,-00112,-00000,-00000,x00,x02,+00000) SpriteMove(x95,x00,-00090,-00000,-00059,x00,x02,+00000) SpriteMove(x96,x00,-00056,-00000,-00092,x00,x02,+00000) Reveal(080) UnitAnim(x90,x02,x0202,x00) Camera(+00590,-00050,+00350,+00400,+00000,+00000,+04096,+00180) Wait(00050) SoundEffect(x001e) //Spin inward. SpriteMove(x98,x00,-00010,-00000,-00116,x00,x02,+00008) SpriteMove(x99,x00,+00036,-00000,-00092,x00,x02,+00008) SpriteMove(x9a,x00,+00074,-00000,-00059,x00,x02,+00008) SpriteMove(x9b,x00,+00095,-00000,-00000,x00,x02,+00008) SpriteMove(x90,x00,+00074,-00000,+00054,x00,x02,+00008) SpriteMove(x91,x00,+00036,-00000,+00088,x00,x02,+00008) SpriteMove(x92,x00,-00010,-00000,+00108,x00,x02,+00008) SpriteMove(x93,x00,-00056,-00000,+00088,x00,x02,+00008) SpriteMove(x94,x00,-00090,-00000,+00054,x00,x02,+00008) SpriteMove(x95,x00,-00112,-00000,-00000,x00,x02,+00008) SpriteMove(x96,x00,-00090,-00000,-00059,x00,x02,+00008) SpriteMove(x97,x00,-00056,-00000,-00092,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x99,x00,-00009,-00000,-00090,x00,x02,+00008) SpriteMove(x9a,x00,+00026,-00000,-00072,x00,x02,+00008) SpriteMove(x9b,x00,+00060,-00000,-00045,x00,x02,+00008) SpriteMove(x90,x00,+00072,-00000,-00000,x00,x02,+00008) SpriteMove(x91,x00,+00060,-00000,+00033,x00,x02,+00008) SpriteMove(x92,x00,+00026,-00000,+00062,x00,x02,+00008) SpriteMove(x93,x00,-00014,-00000,+00085,x00,x02,+00008) SpriteMove(x94,x00,-00063,-00000,+00062,x00,x02,+00008) SpriteMove(x95,x00,-00078,-00000,+00040,x00,x02,+00008) SpriteMove(x96,x00,-00097,-00000,-00000,x00,x02,+00008) SpriteMove(x97,x00,-00078,-00000,-00040,x00,x02,+00008) SpriteMove(x98,x00,-00045,-00000,-00065,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x9a,x00,-00007,-00000,-00070,x00,x02,+00008) SpriteMove(x9b,x00,+00022,-00000,-00060,x00,x02,+00008) SpriteMove(x90,x00,+00047,-00000,-00034,x00,x02,+00008) SpriteMove(x91,x00,+00060,-00000,-00000,x00,x02,+00008) SpriteMove(x92,x00,+00044,-00000,+00030,x00,x02,+00008) SpriteMove(x93,x00,+00021,-00000,+00051,x00,x02,+00008) SpriteMove(x94,x00,-00010,-00000,+00070,x00,x02,+00008) SpriteMove(x95,x00,-00050,-00000,+00051,x00,x02,+00008) SpriteMove(x96,x00,-00062,-00000,+00033,x00,x02,+00008) SpriteMove(x97,x00,-00074,-00000,-00000,x00,x02,+00008) SpriteMove(x98,x00,-00060,-00000,-00033,x00,x02,+00008) SpriteMove(x99,x00,-00039,-00000,-00054,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x9b,x00,-00006,-00000,-00058,x00,x02,+00008) SpriteMove(x90,x00,+00018,-00000,-00046,x00,x02,+00008) SpriteMove(x91,x00,+00037,-00000,-00029,x00,x02,+00008) SpriteMove(x92,x00,+00047,-00000,-00000,x00,x02,+00008) SpriteMove(x93,x00,+00037,-00000,+00027,x00,x02,+00008) SpriteMove(x94,x00,+00018,-00000,+00044,x00,x02,+00008) SpriteMove(x95,x00,-00006,-00000,+00054,x00,x02,+00008) SpriteMove(x96,x00,-00021,-00000,+00044,x00,x02,+00008) SpriteMove(x97,x00,-00041,-00000,+00027,x00,x02,+00008) SpriteMove(x98,x00,-00057,-00000,-00000,x00,x02,+00008) SpriteMove(x99,x00,-00049,-00000,-00029,x00,x02,+00008) SpriteMove(x9a,x00,-00031,-00000,-00046,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x90,x00,-00004,-00000,-00044,x00,x02,+00008) SpriteMove(x91,x00,+00014,-00000,-00029,x00,x02,+00008) SpriteMove(x92,x00,+00029,-00000,-00014,x00,x02,+00008) SpriteMove(x93,x00,+00036,-00000,-00000,x00,x02,+00008) SpriteMove(x94,x00,+00029,-00000,+00019,x00,x02,+00008) SpriteMove(x95,x00,+00014,-00000,+00030,x00,x02,+00008) SpriteMove(x96,x00,-00004,-00000,+00040,x00,x02,+00008) SpriteMove(x97,x00,-00015,-00000,+00030,x00,x02,+00008) SpriteMove(x98,x00,-00035,-00000,+00008,x00,x02,+00008) SpriteMove(x99,x00,-00047,-00000,-00000,x00,x02,+00008) SpriteMove(x9a,x00,-00040,-00000,-00019,x00,x02,+00008) SpriteMove(x9b,x00,-00024,-00000,-00030,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x91,x00,-00003,-00000,-00025,x00,x02,+00008) SpriteMove(x92,x00,+00009,-00000,-00019,x00,x02,+00008) SpriteMove(x93,x00,+00019,-00000,-00009,x00,x02,+00008) SpriteMove(x94,x00,+00022,-00000,-00000,x00,x02,+00008) SpriteMove(x95,x00,+00019,-00000,+00009,x00,x02,+00008) SpriteMove(x96,x00,+00009,-00000,+00019,x00,x02,+00008) SpriteMove(x97,x00,-00003,-00000,+00025,x00,x02,+00008) SpriteMove(x98,x00,-00011,-00000,+00019,x00,x02,+00008) SpriteMove(x99,x00,-00022,-00000,+00009,x00,x02,+00008) SpriteMove(x9a,x00,-00025,-00000,-00000,x00,x02,+00008) SpriteMove(x9b,x00,-00022,-00000,-00009,x00,x02,+00008) SpriteMove(x90,x00,-00011,-00000,-00019,x00,x02,+00008) WaitSpriteMove(x90,x00) SET(x0070,x0092) SET(x0071,x0093) SET(x0072,x0094) SET(x0073,x0095) SET(x0074,x0096) SET(x0075,x0097) SET(x0076,x0098) SET(x0077,x0099) SET(x0078,x009a) SET(x0079,x009b) SET(x007a,x0090) SET(x007b,x0091) SET(x007C,x000b) SET(x007D,x0004) BackTarget(x14) //adAddress(x00,x0006,x7E,002) //adAddress(x01,x000E,x7E,002) AlterParameter(x00,x70) SpriteMove(x90,x00,-00002,-00000,-00015,x00,x02,+00008) AlterParameter(x00,x71) SpriteMove(x91,x00,+00006,-00000,-00012,x00,x02,+00008) AlterParameter(x00,x72) SpriteMove(x92,x00,+00011,-00000,-00005,x00,x02,+00008) AlterParameter(x00,x73) SpriteMove(x93,x00,+00015,-00000,-00000,x00,x02,+00008) AlterParameter(x00,x74) SpriteMove(x94,x00,+00011,-00000,+00005,x00,x02,+00008) AlterParameter(x00,x75) SpriteMove(x95,x00,+00006,-00000,+00013,x00,x02,+00008) AlterParameter(x00,x76) SpriteMove(x96,x00,-00002,-00000,+00017,x00,x02,+00008) AlterParameter(x00,x77) SpriteMove(x97,x00,-00010,-00000,+00018,x00,x02,+00008) AlterParameter(x00,x78) SpriteMove(x98,x00,-00015,-00000,+00005,x00,x02,+00008) AlterParameter(x00,x79) SpriteMove(x99,x00,-00019,-00000,-00000,x00,x02,+00008) AlterParameter(x00,x7A) SpriteMove(x9a,x00,-00015,-00000,-00005,x00,x02,+00008) AlterParameter(x00,x7B) SpriteMove(x9b,x00,-00010,-00000,-00018,x00,x02,+00008) WaitSpriteMove(x90,x00) SETVar(x0000,x007D) SUB(x007D,x0001) ADD(x0070,x0001) ADD(x0071,x0001) ADD(x0072,x0001) ADD(x0073,x0001) ADD(x0074,x0001) ADD(x0075,x0001) ADD(x0076,x0001) ADD(x0077,x0001) ADD(x0078,x0001) ADD(x0079,x0001) ADD(x007a,x0001) ADD(x007b,x0001) SET(x0001,x009B) SETVar(x0000,x0070) GT() If() SUB(x0070,x000C) EndIf() SETVar(x0000,x0071) GT() If() SUB(x0071,x000C) EndIf() SETVar(x0000,x0072) GT() If() SUB(x0072,x000C) EndIf() SETVar(x0000,x0073) GT() If() SUB(x0073,x000C) EndIf() SETVar(x0000,x0074) GT() If() SUB(x0074,x000C) EndIf() SETVar(x0000,x0075) GT() If() SUB(x0075,x000C) EndIf() SETVar(x0000,x0076) GT() If() SUB(x0076,x000C) EndIf() SETVar(x0000,x0077) GT() If() SUB(x0077,x000C) EndIf() SETVar(x0000,x0078) GT() If() SUB(x0078,x000C) EndIf() SETVar(x0000,x0079) GT() If() SUB(x0079,x000C) EndIf() SETVar(x0000,x007A) GT() If() SUB(x007A,x000C) EndIf() SETVar(x0000,x007B) GT() If() SUB(x007b,x000C) EndIf() SETVar(x0000,x007D) If() JumpBack(x14) EndIf() ForwardTarget(x1A) //Spin outward. SpriteMove(x97,x00,-00003,-00000,-00033,x00,x02,+00008) SpriteMove(x98,x00,+00009,-00000,-00019,x00,x02,+00008) SpriteMove(x99,x00,+00019,-00000,-00009,x00,x02,+00008) SpriteMove(x9a,x00,+00022,-00000,-00000,x00,x02,+00008) SpriteMove(x9b,x00,+00019,-00000,+00009,x00,x02,+00008) SpriteMove(x90,x00,+00009,-00000,+00019,x00,x02,+00008) SpriteMove(x91,x00,-00003,-00000,+00033,x00,x02,+00008) SpriteMove(x92,x00,-00011,-00000,+00019,x00,x02,+00008) SpriteMove(x93,x00,-00022,-00000,+00009,x00,x02,+00008) SpriteMove(x94,x00,-00025,-00000,-00000,x00,x02,+00008) SpriteMove(x95,x00,-00022,-00000,-00009,x00,x02,+00008) SpriteMove(x96,x00,-00011,-00000,-00019,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x98,x00,-00004,-00000,-00044,x00,x02,+00008) SpriteMove(x99,x00,+00014,-00000,-00029,x00,x02,+00008) SpriteMove(x9a,x00,+00029,-00000,-00014,x00,x02,+00008) SpriteMove(x9b,x00,+00036,-00000,-00000,x00,x02,+00008) SpriteMove(x90,x00,+00029,-00000,+00019,x00,x02,+00008) SpriteMove(x91,x00,+00014,-00000,+00030,x00,x02,+00008) SpriteMove(x92,x00,-00004,-00000,+00040,x00,x02,+00008) SpriteMove(x93,x00,-00015,-00000,+00030,x00,x02,+00008) SpriteMove(x94,x00,-00035,-00000,+00008,x00,x02,+00008) SpriteMove(x95,x00,-00047,-00000,-00000,x00,x02,+00008) SpriteMove(x96,x00,-00040,-00000,-00019,x00,x02,+00008) SpriteMove(x97,x00,-00024,-00000,-00030,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x99,x00,-00006,-00000,-00058,x00,x02,+00008) SpriteMove(x9a,x00,+00018,-00000,-00046,x00,x02,+00008) SpriteMove(x9b,x00,+00037,-00000,-00029,x00,x02,+00008) SpriteMove(x90,x00,+00047,-00000,-00000,x00,x02,+00008) SpriteMove(x91,x00,+00037,-00000,+00027,x00,x02,+00008) SpriteMove(x92,x00,+00018,-00000,+00044,x00,x02,+00008) SpriteMove(x93,x00,-00006,-00000,+00054,x00,x02,+00008) SpriteMove(x94,x00,-00021,-00000,+00044,x00,x02,+00008) SpriteMove(x95,x00,-00041,-00000,+00027,x00,x02,+00008) SpriteMove(x96,x00,-00057,-00000,-00000,x00,x02,+00008) SpriteMove(x97,x00,-00049,-00000,-00029,x00,x02,+00008) SpriteMove(x98,x00,-00031,-00000,-00046,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x9a,x00,-00007,-00000,-00070,x00,x02,+00008) SpriteMove(x9b,x00,+00022,-00000,-00060,x00,x02,+00008) SpriteMove(x90,x00,+00047,-00000,-00034,x00,x02,+00008) SpriteMove(x91,x00,+00060,-00000,-00000,x00,x02,+00008) SpriteMove(x92,x00,+00044,-00000,+00030,x00,x02,+00008) SpriteMove(x93,x00,+00021,-00000,+00051,x00,x02,+00008) SpriteMove(x94,x00,-00010,-00000,+00070,x00,x02,+00008) SpriteMove(x95,x00,-00050,-00000,+00051,x00,x02,+00008) SpriteMove(x96,x00,-00062,-00000,+00033,x00,x02,+00008) SpriteMove(x97,x00,-00074,-00000,-00000,x00,x02,+00008) SpriteMove(x98,x00,-00060,-00000,-00033,x00,x02,+00008) SpriteMove(x99,x00,-00039,-00000,-00054,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x9b,x00,-00009,-00000,-00090,x00,x02,+00008) SpriteMove(x90,x00,+00026,-00000,-00072,x00,x02,+00008) SpriteMove(x91,x00,+00060,-00000,-00045,x00,x02,+00008) SpriteMove(x92,x00,+00072,-00000,-00000,x00,x02,+00008) SpriteMove(x93,x00,+00060,-00000,+00033,x00,x02,+00008) SpriteMove(x94,x00,+00026,-00000,+00062,x00,x02,+00008) SpriteMove(x95,x00,-00014,-00000,+00085,x00,x02,+00008) SpriteMove(x96,x00,-00063,-00000,+00062,x00,x02,+00008) SpriteMove(x97,x00,-00078,-00000,+00040,x00,x02,+00008) SpriteMove(x98,x00,-00097,-00000,-00000,x00,x02,+00008) SpriteMove(x99,x00,-00078,-00000,-00040,x00,x02,+00008) SpriteMove(x9a,x00,-00045,-00000,-00065,x00,x02,+00008) WaitSpriteMove(x90,x00) SpriteMove(x90,x00,-00010,-00000,-00116,x00,x02,+00008) SpriteMove(x91,x00,+00036,-00000,-00092,x00,x02,+00008) SpriteMove(x92,x00,+00074,-00000,-00059,x00,x02,+00008) SpriteMove(x93,x00,+00095,-00000,-00000,x00,x02,+00008) SpriteMove(x94,x00,+00074,-00000,+00054,x00,x02,+00008) SpriteMove(x95,x00,+00036,-00000,+00088,x00,x02,+00008) SpriteMove(x96,x00,-00010,-00000,+00108,x00,x02,+00008) SpriteMove(x97,x00,-00056,-00000,+00088,x00,x02,+00008) SpriteMove(x98,x00,-00090,-00000,+00054,x00,x02,+00008) SpriteMove(x99,x00,-00112,-00000,-00000,x00,x02,+00008) SpriteMove(x9a,x00,-00090,-00000,-00059,x00,x02,+00008) SpriteMove(x9b,x00,-00056,-00000,-00092,x00,x02,+00008) WaitSpriteMove(x90,x00) //Save the value for Chests Left to text. SetTextVar(x00,x54) SETVar(x0000,x0084) If() SetTextVal(x01,x001A) Else() SetTextVal(x01,x0001) EndIf() DisplayMessage(x10,x81,x000F,x90,x00,x00,-00000,-00022,+00000,x00) SoundEffect(x0047) UnitAnim(x02,x02,x0201,x00) Wait(00003) UnitAnim(x02,x02,x0200,x00) Wait(00003) //Extract the units' chest types from their Faith. Save them to their Max HP while we're at it. Then, if the value is higher than 7, set the palettes accordingly (Mystery 8, Silver 9) and set var x81 to play the rare sound instead. LUI(x007F,x8019) ADD(x007F,x08CC) SET(x007C,x0070) SET(x007D,x007B) BackTarget(x03) AlterParameter(x00,x7C) LoadAddress(xFF,x0026,x7F,001) AlterParameter(x00,x7C) SaveAddress(xFF,x002A,x7F,001) AlterParameter(x42,x7C) SETVar(x0001,xFFFF) SET(x0000,x000C) LT() //Mystery box. Set the palette to 8 and set var x81. If() AlterParameter(x40,x7C) SET(xFFFF,x0008) SET(x0081,x0001) Else() //Find out if it's rare equipment. SET(x0000,x0007) LT() If() //Rare equipment. Set the palette to 9 and set var x81. AlterParameter(x40,x7C) SET(xFFFF,x0009) SET(x0081,x0001) EndIf() EndIf() SETVar(x0000,x007C) SETVar(x0001,x007D) LT() If() ADD(x007F,x01C0) ADD(x007C,x0001) JumpBack(x03) EndIf() AlterParameter(x03,x70) EVTCHRPalette(x90,x00,x00,x02) AlterParameter(x03,x71) EVTCHRPalette(x91,x00,x00,x02) AlterParameter(x03,x72) EVTCHRPalette(x92,x00,x00,x02) AlterParameter(x03,x73) EVTCHRPalette(x93,x00,x00,x03) AlterParameter(x03,x74) EVTCHRPalette(x94,x00,x00,x03) AlterParameter(x03,x75) EVTCHRPalette(x95,x00,x00,x03) AlterParameter(x03,x76) EVTCHRPalette(x96,x00,x00,x04) AlterParameter(x03,x77) EVTCHRPalette(x97,x00,x00,x04) AlterParameter(x03,x78) EVTCHRPalette(x98,x00,x00,x04) AlterParameter(x03,x79) EVTCHRPalette(x99,x00,x00,x05) AlterParameter(x03,x7A) EVTCHRPalette(x9a,x00,x00,x05) AlterParameter(x03,x7B) EVTCHRPalette(x9b,x00,x00,x05) BlockStart() UnitAnim(x02,x02,x0201,x00) Wait(00003) UnitAnim(x02,x02,x0202,x00) Wait(00015) BlockEnd() //If there was a rare, play a sound and display a message. SETVar(x0000,x0081) If() WaitForInstruction(x01,x00) SoundEffect(x0097) DisplayMessage(x10,x63,x0019,x90,x00,x00,+00000,+00000,+00000,x03) EndIf() WaitForInstruction(x01,x00) WaitForInstruction(x08,x00) //Reset the Rare Chest odds to 5% for the Upgrade option. SET(x0028,x0005) //The backtarget for what goes on after setting the chests to move. BackTarget(x10) //Set x0001 to match the Current Chest #. SETVar(x0001,x0023) //Check if the Current Chest # is higher than 9B. If so that means it's time to loop it back around to 90. SET(x0000,x009C) LTE() If() SET(x0023,x0090) EndIf() //Check if it's less than 90. If so, that means it's time to loop it back around to x0B SET(x0000,x0090) GT() If() SET(x0023,x009B) EndIf() //Set the parameters. SETVar(x0000,x0023) SETVar(x0070,x0000) ADD(x0000,x0001) SETVar(x0071,x0000) ADD(x0000,x0001) SETVar(x0072,x0000) ADD(x0000,x0001) SETVar(x0073,x0000) ADD(x0000,x0001) SETVar(x0074,x0000) ADD(x0000,x0001) SETVar(x0075,x0000) ADD(x0000,x0001) SETVar(x0076,x0000) ADD(x0000,x0001) SETVar(x0077,x0000) ADD(x0000,x0001) SETVar(x0078,x0000) ADD(x0000,x0001) SETVar(x0079,x0000) ADD(x0000,x0001) SETVar(x007A,x0000) ADD(x0000,x0001) SETVar(x007b,x0000) ADD(x0000,x0001) SETVar(x0000,x0023) SUB(x0000,x0090) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x007B,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x007A,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0079,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0078,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0077,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0076,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0075,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0074,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0073,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0072,x000C) JumpForwardIfZero(x13) SUB(x0000,x0001) SUB(x0071,x000C) ForwardTarget(x13) AlterParameter(x00,x70) SpriteMove(x90,x00,-00010,+00000,-00116,x00,x02,+00010) AlterParameter(x00,x71) SpriteMove(x91,x00,+00036,-00000,-00092,x00,x02,+00010) AlterParameter(x00,x72) SpriteMove(x92,x00,+00074,-00000,-00059,x00,x02,+00010) AlterParameter(x00,x73) SpriteMove(x93,x00,+00095,-00000,-00000,x00,x02,+00010) AlterParameter(x00,x74) SpriteMove(x94,x00,+00074,-00000,+00054,x00,x02,+00010) AlterParameter(x00,x75) SpriteMove(x95,x00,+00036,-00000,+00088,x00,x02,+00010) AlterParameter(x00,x76) SpriteMove(x96,x00,-00010,-00000,+00108,x00,x02,+00010) AlterParameter(x00,x77) SpriteMove(x97,x00,-00056,-00000,+00088,x00,x02,+00010) AlterParameter(x00,x78) SpriteMove(x98,x00,-00090,-00000,+00054,x00,x02,+00010) AlterParameter(x00,x79) SpriteMove(x99,x00,-00112,-00000,-00000,x00,x02,+00010) AlterParameter(x00,x7A) SpriteMove(x9a,x00,-00090,-00000,-00059,x00,x02,+00010) AlterParameter(x00,x7b) SpriteMove(x9b,x00,-00056,-00000,-00092,x00,x02,+00010) WaitSpriteMove(x90,x00) //Check if the player is holding Left or Right. If so, skip this. LoadAddress(x01,x0000,x25,004) SET(x0000,x2000) NEQ() JumpForwardIfZero(x14) SET(x0000,x8000) NEQ() JumpForwardIfZero(x14) //Save the words to set up the current Chest Type. BackTarget(x17) //Extract the Current Chest Type from the current chest's max HP AlterParameter(x00,x23) UnitAddress(x00,x7F) LoadAddress(x34,x002A,x7F,002) SetTextVar(x00,x34) WaitForInstruction(x01,x00) DisplayMessage(x10,x82,x0010,x90,x00,x00,-00000,+00092,+00000,x00) WaitForInstruction(x01,x00) ForwardTarget(x14) //===================================== //BUTTON PRESSES (x20s) //===================================== // 0x8000 Left // 0x4000 Down // 0x2000 Right // 0x1000 Up // 0x0800 Start // 0x0400 R3 // 0x0200 L3 // 0x0100 Select // 0x0080 Square // 0x0040 Cross (X) // 0x0020 Circle // 0x0010 Triangle // 0x0008 R1 // 0x0004 L1 // 0x0002 R2 // 0x0001 L2 BackTarget(x20) LoadAddress(x01,x0000,x25,004) Switch(x01) //Check if Left. Case(x8000) SUB(x0023,x0001) //Jump into the Right section to continue. JumpForward(x22) Break() //Right? Case(x2000) ADD(x0023,x0001) //Jump from the Left section. ForwardTarget(x22) SoundEffect(x0003) //Close Current Chest text. ChangeDialog(x02,xFFFF,x00,x00) JumpBack(x10) Break() //Cross or Circle (Open)? Case(x0040) Case(x0020) //Make sure the chest isn't empty already. SET(x0001,x0100) SETVar(x0000,x0034) If() LT() JumpForwardIfZero(x28) //The chest isn't empty. Let's open it up! JumpForward(x2A) EndIf() JumpForward(x28) Break() //Triangle? Case(x0010) //Is this chest empty? SETVar(x0000,x0034) JumpForwardIfZero(x2C) //Check if this chest is rare. SET(x0001,x0008) LT() JumpForwardIfZero(x2C) //This chest is common. Are upgrades allowed? SETVar(x0000,x0084) JumpForwardIfZero(x2C) //Offer the player the option to pay gil to upgrade. SetTextVar(x00,x28) SetTextVar(x01,x2C) SetTextVar(x02,x22) DisplayMessage(x10,x63,x001A,x90,x00,x00,+00000,+00000,+00000,x03) WaitForInstruction(x01,x00) SETVar(x0000,x0018) JumpForwardIfZero(x2C) //Does the player have enough gil? SETVar(x0000,x0022) SETVar(x0001,x002C) LTE() JumpForwardIfZero(x2C) //The player has enough gil. Let's see if it succeeds. SoundEffect(x0004) Wait(00020) SUBVar(x002C,x0022) MULT(x0028,x0002) Random(x01,00100) SETVar(x0000,x0028) GT() JumpForwardIfZero(x2C) SoundEffect(x0097) //Now we need to see if there's a valid rare option. Get the chest type's value and see if it's 2-7. SETVar(x0001,x0034) SUB(x0001,x0002) Switch(x01) Case(x0000) Case(x0001) Case(x0002) Case(x0003) Case(x0004) //It's a piece of equipment. Check that it's got a valid option, and add 6 to the value if so. If not, add +10. //Add a value of x53 to var x01 to get the current Battle Stat to check. ADD(x0001,x0053) AlterParameter(x41,x01) LoadAddress(x00,xFFFF,x7F,001) If() ADD(x0034,x0006) AlterParameter(x00,x23) EVTCHRPalette(xFF,x00,x00,x09) Else() ADD(x0034,x0010) //Set the palette of the chest. AlterParameter(x00,x23) EVTCHRPalette(xFF,x00,x00,x08) EndIf() Break() //It's a consumable. Add x10. Case(x0005) ADD(x0034,x0010) //Set the palette of the chest. AlterParameter(x00,x23) EVTCHRPalette(xFF,x00,x00,x08) Break() EndSwitch() //Upgrade generated. //Erase current chest dialogue. ChangeDialog(x02,xFFFF,x00,x00) SoundEffect(x000A) //Reset Gold Chest odds to 5%. SET(x0028,x0005) //Save the loot type to the current chest's max HP SaveAddress(x34,x002A,x7F,002) //Make the chest animate. AlterParameter(x00,x23) UnitAnim(xFF,x00,x0201,x00) Wait(00003) AlterParameter(x00,x23) UnitAnim(xFF,x00,x0200,x00) Wait(00006) AlterParameter(x00,x23) UnitAnim(xFF,x00,x0201,x00) Wait(00003) AlterParameter(x00,x23) UnitAnim(xFF,x00,x0202,x00) JumpBack(x17) //Upgrade failed. ForwardTarget(x2C) SoundEffect(x0005) AlterParameter(x00,x23) ColorUnit(x90,x00,x00,+060,-060,-060,002) Wait(00010) AlterParameter(x00,x23) ColorUnit(x90,x00,x04,+000,+000,+000,002) Wait(00010) Break() //Checks failed Default() Break() EndSwitch() Wait(00001) JumpBack(x20) //================================= //END BUTTON PRESSES //================================= //==================================== //DETERMINING LOOT SUBSET (x30s,xA0s) //==================================== //Player is opening a chest. ForwardTarget(x2A) //Set Number Of Items to a default of 01. SET(x0029,x0001) ChangeDialog(x01,xFFFF,x00,x00) ChangeDialog(x02,xFFFF,x00,x00) //Subtract 1 from Chests Left. SUB(x0054,x0001) //Zero vars x80 and x82. Then generate a random number and check if we'll proc a rare. ZERO(x0080) ZERO(x0082) Random(x00,00100) SETVar(x0001,x002A) LT() If() //We did proc one. But now we need to see if there's a valid rare option. Get the chest type's value and see if it's 2-7. SETVar(x0001,x0034) SUB(x0001,x0002) Switch(x01) Case(x0000) Case(x0001) Case(x0002) Case(x0003) Case(x0004) //It's a piece of equipment. Check that it's got a valid option, and add 6 to the value if so. If not, enable var x80 instead, allowing the chest to become a Mystery chest after rewarding its loot. //Add a value of x53 to var x01 to get the current Battle Stat to check. ADD(x0001,x0053) AlterParameter(x41,x01) LoadAddress(x00,xFFFF,x7F,001) If() ADD(x0034,x0006) AlterParameter(x00,x23) EVTCHRPalette(xFF,x00,x00,x09) Else() SET(x0080,x0001) EndIf() Break() //It's a consumable. Enable var x80. Case(x0005) SET(x0080,x0001) Break() EndSwitch() EndIf() //Now, check if this is (or has been turned into) a rare chest. Switch(x34) Case(x0008) Case(x0009) Case(x000A) Case(x000B) Case(x000C) SET(x0082,x0001) Break() EndSwitch() SETVar(x0000,x0082) If() //We got a rare. play the rare item sound SoundEffect(x00A7) Else() //Loot is common loot. Play regular opening sound. SoundEffect(x004C) EndIf() //Do a switch on var x34. Depending on the type, pull the item from the unit's stats. //Note: For Cases 12, 13, 14, 15,& 16, they're common items + JP. They can share the same cases as the common items, but also need to enable var x80. Switch(x34) //Weapon Case(x0012) SET(x0080,x0001) Case(x0002) LoadAddress(x36,x004e,x7F,001) Break() //Shield Case(x0013) SET(x0080,x0001) Case(x0003) LoadAddress(x36,x004F,x7F,001) Break() //Helm Case(x0014) SET(x0080,x0001) Case(x0004) LoadAddress(x36,x0050,x7F,001) Break() //Armor Case(x0015) SET(x0080,x0001) Case(x0005) LoadAddress(x36,x0051,x7F,001) Break() //Accessory Case(x0016) SET(x0080,x0001) Case(x0006) LoadAddress(x36,x0052,x7F,001) Break() //Consumable Case(x0017) SET(x0080,x0001) Case(x0007) LoadAddress(x36,x0163,x7F,001) //Also, load the number of items. LoadAddress(x29,x0164,x7F,001) //Check the number of items. If it's zero, set it to be randomly 1-9. SETVar(x0000,x0029) If() Else() Random(x29,00009) ADD(x0029,x0001) EndIf() Break() //Rare Weapon Case(x0008) LoadAddress(x36,x0053,x7F,001) Break() //Rare Shield Case(x0009) LoadAddress(x36,x0054,x7F,001) Break() //Rare Helm Case(x000A) LoadAddress(x36,x0055,x7F,001) Break() //Rare Armor Case(x000B) LoadAddress(x36,x0056,x7F,001) Break() //Rare Accessory Case(x000C) LoadAddress(x36,x0057,x7F,001) Break() //Mystery: Set x80 to mark a Bonus JP reward in a moment. Default() SET(x0080,x0001) //Do a random check, and reward a random piece of loot. Random(x01,00005) Switch(x01) Case(x0000) LoadAddress(x36,x004e,x7F,001) Break() Case(x0001) LoadAddress(x36,x004F,x7F,001) Break() Case(x0002) LoadAddress(x36,x0050,x7F,001) Break() Case(x0003) LoadAddress(x36,x0051,x7F,001) Break() Case(x0004) LoadAddress(x36,x0052,x7F,001) Break() EndSwitch() //Check if x36 is zeroed out. If so, force this to be a consumable. SETVar(x0000,x0036) If() Else() LoadAddress(x36,x0163,x7F,001) //Also, load the number of items. LoadAddress(x29,x0164,x7F,001) //Check the number of items. If it's zero, set it to be randomly 1-9. SETVar(x0000,x0029) If() Else() Random(x29,00009) ADD(x0029,x0001) EndIf() EndIf() Break() EndSwitch() //Add 3800 to that value to get the text information SET(x0035,x3800) ADDVar(x0035,x0036) WaitForInstruction(x01,x00) SetTextVar(x00,x35) SetTextVar(x01,x29) //SaveAddress(x35,x0000,x2B,004) //SaveAddress(x29,x0004,x2B,004) //LoadAddress(x01,x0000,x37,001) //ADDVar(x0001,x0029) AlterParameter(x01,x36) Inventory(x2A,x00,x29) AlterParameter(x01,x36) Inventory(x28,x00,x01) //SET(x0000,x003C) //LTE() //JumpForwardIfZero(x2B) //SET(x0001,x003B) //ForwardTarget(x2B) //SaveAddress(x01,x0000,x37,001) SetTextVar(x02,x01) //SaveAddress(x01,x0008,x2B,004) DisplayMessage(x10,x63,x0011,x90,x00,x00,+00000,+00000,+00000,x03) //Check which chest this is and set the animations accordingly. Also, set its type to Empty. SETVar(x0001,x0023) AlterParameter(x00,x01) UnitAnim(x90,x00,x0203,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0204,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0205,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0206,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0207,x00) Wait(00001) //If there was also Bonus JP, pay it out now. SETVar(x0000,x0080) If() WaitForInstruction(x01,x00) Random(x18,00025) ADD(x0018,x0019) AlterParameter(x00,x23) EVTCHRPalette(xFF,x00,x00,x08) SoundEffect(x0098) SetTextVar(x00,x18) DisplayMessage(x10,x63,x0012,x90,x00,x00,+00000,+00000,+00000,x03) //Also, open the chest again. SETVar(x0001,x0023) AlterParameter(x00,x01) UnitAnim(x90,x00,x0203,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0204,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0205,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0206,x00) Wait(00003) AlterParameter(x00,x01) UnitAnim(x90,x00,x0207,x00) Wait(00001) CallSub(x01) ZERO(x0080) EndIf() //Save Chests Left to text and display the message. SetTextVar(x00,x54) SET(x0000,x0084) If() SetTextVal(x01,x001A) Else() SetTextVal(x01,x0001) EndIf() DisplayMessage(x10,x81,x000F,x90,x00,x00,-00000,-00022,+00000,x00) ZERO(x0034) //Save the item's name to the unit's Max HP. SaveAddress(x35,x002A,x7F,002) SETVar(x0000,x0054) JumpForwardIfZero(xFF) //Display looted item name at the bottom. LoadAddress(x01,x002A,x7F,002) WaitForInstruction(x01,x00) SetTextVar(x00,x01) //SaveAddress(x00,x0000,x2B,004) //SaveAddress(x01,x0004,x2B,004) DisplayMessage(x10,x82,x0010,x90,x00,x00,-00000,+00092,+00000,x00) WaitForInstruction(x01,x00) JumpBack(x20) //Chest was empty, play a sound and bow out. ForwardTarget(x28) SoundEffect(x0005) AlterParameter(x00,x23) ColorUnit(x90,x00,x00,+127,-127,-127,002) AlterParameter(x00,x23) UnitAnim(x90,x00,x0206,x00) Wait(00002) AlterParameter(x00,x23) UnitAnim(x90,x00,x0205,x00) Wait(00002) AlterParameter(x00,x23) ColorUnit(x90,x00,x04,+000,+000,+000,002) AlterParameter(x00,x23) UnitAnim(x90,x00,x0206,x00) Wait(00002) AlterParameter(x00,x23) UnitAnim(x90,x00,x0207,x00) Wait(00020) JumpBack(x20) //============================ //START BONUS JP DefineSub(x01) //============================= //Setting Variable x0070 to point at the first unit in the Formation. LUI(x0070,x8005) ADD(x0070,x7F74) //Setting Variable x0072 to point at the last guest slot in the Formation. LUI(x0072,x8005) ADD(x0072,x9274) //The BackTarget used for every jump back after one unit's JP has been altered. BackTarget(x90) //Checking if the unit is a Monster, and skipping them if so. LoadAddress(x00,x0004,x70,001) //The Monster bit in the Gender Byte is x20. We'll do an AND check. If it succeeds, the result will be a value of 20. If it fails - the unit is not a monster - the result will be 0. AND(x0000,x0020) //Does the final result have a value? If so, it's a monster. Apply EXP instead of JP. If() LoadAddress(x01,x0015,x70,001) ADDVar(x0001,x0018) //Check if the value for EXP is now greater than 99. If so, cap it. SET(x0000,x0064) LTE() If() SET(x0001,x0063) EndIf() SaveAddress(x01,x0015,x70,001) JumpForward(x9A) EndIf() //This LoadAddress checks the unit's Job ID to determine which job the JP would go to. LoadAddress(x01,x0002,x70,001) //We're going to default to aim JP at the Base Job. This is Squire for a generic unit, but for a special unit, this is their special job. However, the Job ID does NOT just share the Squire ID the same way the JP does. Which means the simplest thing to do is to rule out whether or not the unit has a non-generic, non-base job, using the base job if they do, and doing a little extra if they don't. //Anyway, here's the base job current JP location in World Stats: SET(x0071,x006E) //First, let's just see if there even IS a job. I'm not mucking about with that data if there's no unit there. So for comparison, I'll zero out x0000 and see if x0001 does NOT equal it. If it doesn't not equal it - meaning, if it equals it - meaning, if its value is zero - we'll jump this whole thing. ZERO(x0000) NEQ() JumpForwardIfZero(x9A) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //DK Hack Jobs (slots 37 & 38) //~~~~~~~~~~~~~~~~~~~~~~~~~~~ //With the DK hack in TLW, jobs 37 and 38 are used for the Female and Male Dark Knights, respectively. We'll check for them specifically by setting x0000 to a value of 37/38, jumping to the next check if they are not equal. If they are equal, we'll set x0071 to a value of 90 or 92, respectively (Bard/Dancer job JP), then jump over the rest of the checks. SET(x0000,x0037) EQ() If() //This is a female DK. Set x0071 to point at Bard JP. SET(x0071,x0090) JumpForward(x91) EndIf() //This was not a female DK. Is it a male DK? SET(x0000,x0038) EQ() If() //This is a male DK. Set x0071 to point at Dancer JP. SET(x0071,x0092) JumpForward(x91) EndIf() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //This was neither DK. Continue on with the rest. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Check to see if the job is in the range for a non-Squire generic job. This starts with Chemist at 4B and goes to Mime at 5D. //So x0000 will be set to 4A, then we'll check if x0000 is Less Than x0001's value. If it isn't, that means the unit's current job is something between 00-4A - so this will be for Base Job JP, and we'll jump forward to that target. SET(x0000,x004A) LT() JumpForwardIfZero(x91) //x0000's value was less than x0001's. Now we need to check if the unit has a job AFTER the generic jobs. Mime was 5D, so we'll use 5E, and see if it's Greater Than. SET(x0000,x005E) GT() JumpForwardIfZero(x91) //x0000's new value was higher than x0001's. This means the unit is in a non-base job. However, each individual job's JP takes TWO bytes, meaning that instead of something like x70 Chemist and x71 Knight, it's x70 Chemist and x72 Knight. So we need to double the numbers to aim it correctly at the proper job's JP. But in order to do that, we need to first set Chemist as the base 0, then double the value. //So. If Chemist is to be zero, and Chemist is 4B - then subtract 4B. SUB(x0001,x004B) //Now we have a range of 00 Chemist, 01 Knight, 02 Archer, 03 Monk, etc. We need that to be doubled. MULT(x0001,x0002) //00 Chemist, 02 Knight, 04 Archer, 06 Monk, etc. //Now, these non-base jobs' Current JP starts at x70. So add x70. ADD(x0001,x0070) //That will do it. Now we set x0071's value to x0001's. SETVar(x0071,x0001) //And if it was a base job, this is the jump point that would have skipped all that process and just gone with the default Base Job JP location. ForwardTarget(x91) BackTarget(x91) //Now we need to load the value of this JP. AlterParameter will be used to make sure we get the correct job's JP. AlterParameter(x41,x71) LoadAddress(x01,x0000,x70,002) //Adding JP according to the value stored in Variable x0018. ADDVar(x0001,x0018) AlterParameter(x41,x71) SaveAddress(x01,x0000,x70,002) //And that's current JP. Now for total JP. Base job total JP is at x96, and base job current JP was at x6E. That's a hex value of 28. So add 28. ADD(x0071,x0028) //But, if we already did this, let's get out now. Mime Total JP is at BC, so check if this value is now BD or higher. SET(x0000,x00BD) SETVar(x0001,x0071) GT() If() JumpBack(x91) EndIf() ForwardTarget(x9A) //So now we check which unit we were on. If the current unit and final unit variables don't not match (i.e., they do match), we're done here. If they DO not match, we add 100 to the value and jump back. SETVar(x0000,x0070) SETVar(x0001,x0072) NEQ() If() ADD(x0070,x0100) JumpBack(x90) EndIf() //==================================== //END BONUS JP EndSub() //==================================== //END OF EVENT ForwardTarget(xFF) WaitForInstruction(x01,x00) ChangeDialog(x01,xFFFF,x00,x00) ChangeDialog(x02,xFFFF,x00,x00) WaitForInstruction(x01,x00) Camera(+00590,-00600,+00350,+00100,+00000,+00000,+02048,+00100) FadeSound(x00,180) ColorScreen(x02,000,000,000,255,255,255,+00110) WaitForInstruction(x04,x00) PostEvent(x80,x0000) EventEnd() //INSTRUCTION SECTION END - TEXT START //01 MESSAGE 01{end} //x02 {end} //03 Weapon{end} //04 Shield{end} //05 Helmet{end} //06 Armor{end} //07 Accessory{end} //08 Consumable{end} //09 Rare Weapon{end} //0A Rare Shield{end} //0B Rare Helmet{end} //0C Rare Armor{end} //x0D Rare Accessory{end} //x0E Mystery{end} //0F {delay:00}{E4} left.{EB}{end} //x10 {delay:00}{EB}{end} //x11 Received '{EB}' x{E4}!{br} Total: {E4}.{end} //x12 All units received{br} {E4} JP!{end} //x13 Weapon+{end} //x14 Armor+{end} //x15 Helmet+{end} //x16 Armor+{end} //x17 Accessory+{end} //x18 Consumable+{end} //x19 A rare find!{end} //x1A Rare Chest odds: {E4}%{br} Gil: {E4}{br} Pay {E4} gil to double{br} odds and try again?{br} {FB}No{br} Yes{FC}{close} //x1B {br}{D9C7}: Upgrade{end}