• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 16, 2024, 03:38:08 pm

News:

Please use .png instead of .bmp when uploading unfinished sprites to the forum!


How to change random clan battle rewards in FFTA?

Started by rrs_kai, August 08, 2015, 03:46:14 pm

rrs_kai

August 08, 2015, 03:46:14 pm Last Edit: August 20, 2015, 11:33:44 am by rrs_kai
I want to make random clan battles give two pieces of equipment as rewards . Any kind of help on this would be appreciated.

I have been able to change the AP rewards and equipment rewards for missions using the mission-data.nmm nightmare module, but I could not find the missions which are linked to the random clan battles.
There are a few unknown missions in there but I don't think that they are the clan battles because they give 20AP and no equipment whereas random clans give 50AP and 1 equipment.
  • Modding version: Other/Unknown

bcrobert

Huh. I would assume it's in that structure somewhere and just not labeled. I know that the clan battles draw from their own random reward list that contains the mythril items though, so be on the lookout for that. If it's not in that structure then...idk. It shouldn't be hard-coded though, since random battles are essentially treated like the missions in most respects. :(
My FFTA hacking tools: http://ffhacktics.com/smf/index.php?topic=9559.0

Believe it or not, I'm still working on this game.

Darthatron

August 17, 2015, 07:07:46 am #2 Last Edit: August 17, 2015, 07:30:20 am by Darthatron
So the way it currently works is that it randomly picks an item and then checks it can be dropped from the "Shop" byte (0xC) in the Item Data. Depending on where you are up to in the game it will drop an item that is either currently available in the shop OR has the up-most bit set (0x80). That's the last "Unknown" byte in the AIO Item Editor which all the Mythril items and generic healing items have set.

So it goes through all the items and works out how many can potentional drops there could be, then it randomly selects one of those items (Rand[1, X]) and that is the dropped item.

As for AP given, it is hard coded to 50AP by the looks of it.

Codez below for reference.
ROM:080D2114 ; =============== S U B R O U T I N E =======================================
ROM:080D2114
ROM:080D2114
ROM:080D2114 GetRandomLoot                           ; CODE XREF: sub_8046A4C+10FAp
ROM:080D2114                 PUSH    {R4,R5,LR}
ROM:080D2116                 LDR     R0, =WRAM_Base
ROM:080D2118                 LDR     R1, =0x1F6C
ROM:080D211A                 ADDS    R0, R0, R1
ROM:080D211C                 LDRH    R0, [R0]
ROM:080D211E                 MOVS    R5, #0b10010000
ROM:080D2120                 CMP     R0, #10
ROM:080D2122                 BLS     GetItemDatabase
ROM:080D2124                 MOVS    R5, #0b11000000
ROM:080D2126                 CMP     R0, #20
ROM:080D2128                 BHI     GetItemDatabase
ROM:080D212A                 MOVS    R5, #0b10100000
ROM:080D212C
ROM:080D212C GetItemDatabase                         ; CODE XREF: GetRandomLoot+Ej
ROM:080D212C                                         ; GetRandomLoot+14j
ROM:080D212C                 MOVS    R4, #0
ROM:080D212E                 LDR     R0, =ItemDataBase
ROM:080D2130                 MOVS    R1, R0
ROM:080D2132                 ADDS    R1, #0x20 ; ' '
ROM:080D2134                 LDR     R2, =0x177
ROM:080D2136
ROM:080D2136 loc_80D2136                             ; CODE XREF: GetRandomLoot+32j
ROM:080D2136                 LDRB    R0, [R1,#0xC]
ROM:080D2138                 ANDS    R0, R5
ROM:080D213A                 CMP     R0, #0
ROM:080D213C                 BEQ     loc_80D2140
ROM:080D213E                 ADDS    R4, #1
ROM:080D2140
ROM:080D2140 loc_80D2140                             ; CODE XREF: GetRandomLoot+28j
ROM:080D2140                 ADDS    R1, #0x20 ; ' '
ROM:080D2142                 SUBS    R2, #1
ROM:080D2144                 CMP     R2, #0
ROM:080D2146                 BNE     loc_80D2136
ROM:080D2148                 CMP     R4, #0
ROM:080D214A                 BNE     loc_80D2166
ROM:080D214C                 B       loc_80D2196
ROM:080D214C ; ---------------------------------------------------------------------------
ROM:080D214E                 DCB    0
ROM:080D214F                 DCB    0
ROM:080D2150 off_80D2150     DCD WRAM_Base           ; DATA XREF: GetRandomLoot+2r
ROM:080D2154 off_80D2154     DCD 0x1F6C              ; DATA XREF: GetRandomLoot+4r
ROM:080D2158 off_80D2158     DCD ItemDataBase        ; DATA XREF: GetRandomLoot+1Ar
ROM:080D215C off_80D215C     DCD 0x177               ; DATA XREF: GetRandomLoot+20r
ROM:080D2160 ; ---------------------------------------------------------------------------
ROM:080D2160
ROM:080D2160 FixAndReturn                            ; CODE XREF: GetRandomLoot+76j
ROM:080D2160                 LSLS    R0, R2, #0x10
ROM:080D2162                 LSRS    R0, R0, #0x10
ROM:080D2164                 B       Return
ROM:080D2166 ; ---------------------------------------------------------------------------
ROM:080D2166
ROM:080D2166 loc_80D2166                             ; CODE XREF: GetRandomLoot+36j
ROM:080D2166                 BL      Rand            ; r0 = random val between 0 and 32767 (0x7FFF)
ROM:080D216A                 LSLS    R0, R0, #0x10
ROM:080D216C                 ASRS    R0, R0, #0x10
ROM:080D216E                 MOVS    R1, R4
ROM:080D2170                 BL      Mod_r0_by_r1    ; r0 = r0 % r1
ROM:080D2174                 MOVS    R1, R0
ROM:080D2176                 MOVS    R2, #1
ROM:080D2178                 LDR     R0, =ItemDataBase
ROM:080D217A                 LDR     R4, =0x177
ROM:080D217C                 MOVS    R3, R0
ROM:080D217E                 ADDS    R3, #0x20 ; ' '
ROM:080D2180
ROM:080D2180 loc_80D2180                             ; CODE XREF: GetRandomLoot+80j
ROM:080D2180                 LDRB    R0, [R3,#0xC]
ROM:080D2182                 ANDS    R0, R5
ROM:080D2184                 CMP     R0, #0
ROM:080D2186                 BEQ     loc_80D218E
ROM:080D2188                 CMP     R1, #0
ROM:080D218A                 BEQ     FixAndReturn
ROM:080D218C                 SUBS    R1, #1
ROM:080D218E
ROM:080D218E loc_80D218E                             ; CODE XREF: GetRandomLoot+72j
ROM:080D218E                 ADDS    R3, #0x20 ; ' '
ROM:080D2190                 ADDS    R2, #1
ROM:080D2192                 CMP     R2, R4
ROM:080D2194                 BLE     loc_80D2180
ROM:080D2196
ROM:080D2196 loc_80D2196                             ; CODE XREF: GetRandomLoot+38j
ROM:080D2196                 MOVS    R0, #0
ROM:080D2198
ROM:080D2198 Return                                  ; CODE XREF: GetRandomLoot+50j
ROM:080D2198                 POP     {R4,R5}
ROM:080D219A                 POP     {R1}
ROM:080D219C                 BX      R1
ROM:080D219C ; End of function GetRandomLoot
ROM:080D219C
ROM:080D219C ; ---------------------------------------------------------------------------
  • Modding version: Other/Unknown
  • Discord username: Darthatron

Darthatron

Law Cards work in a similar fashion to items.
ROM:080D21A8 ; =============== S U B R O U T I N E =======================================
ROM:080D21A8
ROM:080D21A8
ROM:080D21A8 GetRandomBattle_Card                    ; CODE XREF: sub_8045DF4+354p
ROM:080D21A8                                         ; sub_8045DF4+3A0p ...
ROM:080D21A8                 PUSH    {R4-R7,LR}
ROM:080D21AA                 MOV     R7, R9
ROM:080D21AC                 MOV     R6, R8
ROM:080D21AE                 PUSH    {R6,R7}
ROM:080D21B0                 LDR     R0, =0x206      ; flag
ROM:080D21B2                 BL      Flags.Get
ROM:080D21B6                 LSLS    R0, R0, #0x18
ROM:080D21B8                 LSRS    R0, R0, #0x18
ROM:080D21BA                 NEGS    R1, R0
ROM:080D21BC                 ORRS    R1, R0
ROM:080D21BE                 LSRS    R5, R1, #0x1F
ROM:080D21C0                 LDR     R0, =0x209      ; flag
ROM:080D21C2                 BL      Flags.Get
ROM:080D21C6                 LSLS    R0, R0, #0x18
ROM:080D21C8                 CMP     R0, #0
ROM:080D21CA                 BEQ     loc_80D21CE
ROM:080D21CC                 MOVS    R5, #2
ROM:080D21CE
ROM:080D21CE loc_80D21CE                             ; CODE XREF: GetRandomBattle_Card+22j
ROM:080D21CE                 MOVS    R0, 0x20C       ; flag
ROM:080D21D2                 BL      Flags.Get
ROM:080D21D6                 LSLS    R0, R0, #0x18
ROM:080D21D8                 CMP     R0, #0
ROM:080D21DA                 BEQ     loc_80D21DE
ROM:080D21DC                 MOVS    R5, #3
ROM:080D21DE
ROM:080D21DE loc_80D21DE                             ; CODE XREF: GetRandomBattle_Card+32j
ROM:080D21DE                 LDR     R0, =0x211      ; flag
ROM:080D21E0                 BL      Flags.Get
ROM:080D21E4                 LSLS    R0, R0, #0x18
ROM:080D21E6                 CMP     R0, #0
ROM:080D21E8                 BEQ     loc_80D21EC
ROM:080D21EA                 MOVS    R5, #4
ROM:080D21EC
ROM:080D21EC loc_80D21EC                             ; CODE XREF: GetRandomBattle_Card+40j
ROM:080D21EC                 LDR     R0, =0x215      ; flag
ROM:080D21EE                 BL      Flags.Get
ROM:080D21F2                 LSLS    R0, R0, #0x18
ROM:080D21F4                 CMP     R0, #0
ROM:080D21F6                 BEQ     loc_80D21FA
ROM:080D21F8                 MOVS    R5, #5
ROM:080D21FA
ROM:080D21FA loc_80D21FA                             ; CODE XREF: GetRandomBattle_Card+4Ej
ROM:080D21FA                 LDR     R0, =0x21D      ; flag
ROM:080D21FC                 BL      Flags.Get
ROM:080D2200                 LSLS    R0, R0, #0x18
ROM:080D2202                 CMP     R0, #0
ROM:080D2204                 BEQ     loc_80D2208
ROM:080D2206                 MOVS    R5, #6
ROM:080D2208
ROM:080D2208 loc_80D2208                             ; CODE XREF: GetRandomBattle_Card+5Cj
ROM:080D2208                 MOVS    R4, #0
ROM:080D220A                 MOVS    R6, #0
ROM:080D220C                 ADDS    R5, #1
ROM:080D220E                 MOV     R8, R5
ROM:080D2210                 CMP     R6, R8
ROM:080D2212                 BGE     loc_80D2256
ROM:080D2214                 LDR     R0, =LawTable1
ROM:080D2216                 MOV     R9, R0
ROM:080D2218                 LDR     R1, =LawBreakChecksMaybe
ROM:080D221A                 MOV     R12, R1
ROM:080D221C
ROM:080D221C loc_80D221C                             ; CODE XREF: GetRandomBattle_Card+ACj
ROM:080D221C                 ADDS    R4, #1
ROM:080D221E                 LSLS    R0, R6, #2
ROM:080D2220                 ADDS    R7, R6, #1
ROM:080D2222                 ADDS    R0, R0, R6
ROM:080D2224                 LSLS    R0, R0, #3
ROM:080D2226                 MOV     R1, R9
ROM:080D2228                 ADDS    R3, R0, R1
ROM:080D222A                 MOVS    R5, #19
ROM:080D222C
ROM:080D222C loc_80D222C                             ; CODE XREF: GetRandomBattle_Card+A6j
ROM:080D222C                 LDRH    R2, [R3]
ROM:080D222E                 LSLS    R0, R2, #4
ROM:080D2230                 ADD     R0, R12
ROM:080D2232                 LDRH    R1, [R0,#LawData.Flags]
ROM:080D2234                 MOVS    R0, #0x80 ; 'Ç'
ROM:080D2236                 ANDS    R0, R1
ROM:080D2238                 CMP     R0, #0
ROM:080D223A                 BEQ     loc_80D223E
ROM:080D223C                 ADDS    R4, #1
ROM:080D223E
ROM:080D223E loc_80D223E                             ; CODE XREF: GetRandomBattle_Card+92j
ROM:080D223E                 MOVS    R0, #0x40 ; '@'
ROM:080D2240                 ANDS    R0, R1
ROM:080D2242                 CMP     R0, #0
ROM:080D2244                 BEQ     loc_80D2248
ROM:080D2246                 ADDS    R4, #1
ROM:080D2248
ROM:080D2248 loc_80D2248                             ; CODE XREF: GetRandomBattle_Card+9Cj
ROM:080D2248                 ADDS    R3, #2
ROM:080D224A                 SUBS    R5, #1
ROM:080D224C                 CMP     R5, #0
ROM:080D224E                 BGE     loc_80D222C
ROM:080D2250                 MOVS    R6, R7
ROM:080D2252                 CMP     R6, R8
ROM:080D2254                 BLT     loc_80D221C
ROM:080D2256
ROM:080D2256 loc_80D2256                             ; CODE XREF: GetRandomBattle_Card+6Aj
ROM:080D2256                 BL      Rand            ; r0 = random val between 0 and 32767 (0x7FFF)
ROM:080D225A                 LSLS    R0, R0, #0x10
ROM:080D225C                 ASRS    R0, R0, #0x10
ROM:080D225E                 MOVS    R1, R4
ROM:080D2260                 BL      Mod_r0_by_r1    ; r0 = r0 % r1
ROM:080D2264                 MOVS    R3, R0
ROM:080D2266                 MOVS    R6, #0
ROM:080D2268                 CMP     R6, R8
ROM:080D226A                 BGE     loc_80D22F2
ROM:080D226C                 MOV     R12, R6
ROM:080D226E                 LDR     R0, =LawTable1
ROM:080D2270                 MOV     R9, R0
ROM:080D2272
ROM:080D2272 loc_80D2272                             ; CODE XREF: GetRandomBattle_Card+148j
ROM:080D2272                 CMP     R3, #0
ROM:080D2274                 BNE     loc_80D2298
ROM:080D2276                 MOVS    R0, R6
ROM:080D2278                 ADDS    R0, #0xAB ; '½'
ROM:080D227A                 B       loc_80D22D8
ROM:080D227A ; ---------------------------------------------------------------------------
ROM:080D227C ; __int8 off_80D227C
ROM:080D227C off_80D227C     DCD 0x206               ; DATA XREF: GetRandomBattle_Card+8r
ROM:080D2280 ; __int8 off_80D2280
ROM:080D2280 off_80D2280     DCD 0x209               ; DATA XREF: GetRandomBattle_Card+18r
ROM:080D2284 ; __int8 off_80D2284
ROM:080D2284 off_80D2284     DCD 0x211               ; DATA XREF: GetRandomBattle_Card:loc_80D21DEr
ROM:080D2288 ; __int8 off_80D2288
ROM:080D2288 off_80D2288     DCD 0x215               ; DATA XREF: GetRandomBattle_Card:loc_80D21ECr
ROM:080D228C ; __int8 off_80D228C
ROM:080D228C off_80D228C     DCD 0x21D               ; DATA XREF: GetRandomBattle_Card:loc_80D21FAr
ROM:080D2290 off_80D2290     DCD LawTable1           ; DATA XREF: GetRandomBattle_Card+6Cr
ROM:080D2290                                         ; GetRandomBattle_Card+C6r
ROM:080D2294 off_80D2294     DCD LawBreakChecksMaybe ; DATA XREF: GetRandomBattle_Card+70r
ROM:080D2298 ; ---------------------------------------------------------------------------
ROM:080D2298
ROM:080D2298 loc_80D2298                             ; CODE XREF: GetRandomBattle_Card+CCj
ROM:080D2298                 SUBS    R3, #1
ROM:080D229A                 MOVS    R5, #0
ROM:080D229C                 LDR     R7, =LawBreakChecksMaybe
ROM:080D229E                 MOV     R4, R12
ROM:080D22A0                 ADD     R4, R9
ROM:080D22A2
ROM:080D22A2 loc_80D22A2                             ; CODE XREF: GetRandomBattle_Card+13Ej
ROM:080D22A2                 LDRH    R2, [R4]
ROM:080D22A4                 LSLS    R0, R2, #4
ROM:080D22A6                 ADDS    R0, R0, R7
ROM:080D22A8                 LDRH    R1, [R0,#LawData.Flags]
ROM:080D22AA                 MOVS    R0, #0x80 ; 'Ç'
ROM:080D22AC                 ANDS    R0, R1
ROM:080D22AE                 CMP     R0, #0
ROM:080D22B0                 BEQ     loc_80D22C2
ROM:080D22B2                 CMP     R3, #0
ROM:080D22B4                 BNE     loc_80D22C0
ROM:080D22B6                 MOVS    R0, R2
ROM:080D22B8                 B       loc_80D22F4
ROM:080D22B8 ; ---------------------------------------------------------------------------
ROM:080D22BA                 DCB    0
ROM:080D22BB                 DCB    0
ROM:080D22BC off_80D22BC     DCD LawBreakChecksMaybe ; DATA XREF: GetRandomBattle_Card+F4r
ROM:080D22C0 ; ---------------------------------------------------------------------------
ROM:080D22C0
ROM:080D22C0 loc_80D22C0                             ; CODE XREF: GetRandomBattle_Card+10Cj
ROM:080D22C0                 SUBS    R3, #1
ROM:080D22C2
ROM:080D22C2 loc_80D22C2                             ; CODE XREF: GetRandomBattle_Card+108j
ROM:080D22C2                 LSLS    R0, R2, #4
ROM:080D22C4                 ADDS    R0, R0, R7
ROM:080D22C6                 LDRH    R1, [R0,#2]
ROM:080D22C8                 MOVS    R0, #0x40 ; '@'
ROM:080D22CA                 ANDS    R0, R1
ROM:080D22CC                 CMP     R0, #0
ROM:080D22CE                 BEQ     loc_80D22E0
ROM:080D22D0                 CMP     R3, #0
ROM:080D22D2                 BNE     loc_80D22DE
ROM:080D22D4                 MOVS    R0, R2
ROM:080D22D6                 ADDS    R0, #0x55 ; 'U'
ROM:080D22D8
ROM:080D22D8 loc_80D22D8                             ; CODE XREF: GetRandomBattle_Card+D2j
ROM:080D22D8                 LSLS    R0, R0, #0x10
ROM:080D22DA                 LSRS    R0, R0, #0x10
ROM:080D22DC                 B       loc_80D22F4
ROM:080D22DE ; ---------------------------------------------------------------------------
ROM:080D22DE
ROM:080D22DE loc_80D22DE                             ; CODE XREF: GetRandomBattle_Card+12Aj
ROM:080D22DE                 SUBS    R3, #1
ROM:080D22E0
ROM:080D22E0 loc_80D22E0                             ; CODE XREF: GetRandomBattle_Card+126j
ROM:080D22E0                 ADDS    R4, #2
ROM:080D22E2                 ADDS    R5, #1
ROM:080D22E4                 CMP     R5, #0x13
ROM:080D22E6                 BLE     loc_80D22A2
ROM:080D22E8                 MOVS    R1, #0x28 ; '('
ROM:080D22EA                 ADD     R12, R1
ROM:080D22EC                 ADDS    R6, #1
ROM:080D22EE                 CMP     R6, R8
ROM:080D22F0                 BLT     loc_80D2272
ROM:080D22F2
ROM:080D22F2 loc_80D22F2                             ; CODE XREF: GetRandomBattle_Card+C2j
ROM:080D22F2                 MOVS    R0, #0
ROM:080D22F4
ROM:080D22F4 loc_80D22F4                             ; CODE XREF: GetRandomBattle_Card+110j
ROM:080D22F4                                         ; GetRandomBattle_Card+134j
ROM:080D22F4                 POP     {R3,R4}
ROM:080D22F6                 MOV     R8, R3
ROM:080D22F8                 MOV     R9, R4
ROM:080D22FA                 POP     {R4-R7}
ROM:080D22FC                 POP     {R1}
ROM:080D22FE                 BX      R1
ROM:080D22FE ; End of function GetRandomBattle_Card


Gold is a random value between 1000 and 2999.
ROM:080D2EE8 ; =============== S U B R O U T I N E =======================================
ROM:080D2EE8
ROM:080D2EE8
ROM:080D2EE8 GetRandomBattle_Gold                    ; CODE XREF: sub_8046A4C+1108p
ROM:080D2EE8                 PUSH    {LR}
ROM:080D2EEA                 BL      Rand            ; r0 = random val between 0 and 32767 (0x7FFF)
ROM:080D2EEE                 LSLS    R0, R0, #0x10
ROM:080D2EF0                 ASRS    R0, R0, #0x10
ROM:080D2EF2                 MOVS    R1, 2000
ROM:080D2EF6                 BL      Mod_r0_by_r1    ; r0 = r0 % r1
ROM:080D2EFA                 MOVS    R1, 1000
ROM:080D2EFE                 ADDS    R0, R0, R1
ROM:080D2F00                 LSLS    R0, R0, #0x10
ROM:080D2F02                 LSRS    R0, R0, #0x10
ROM:080D2F04                 POP     {R1}
ROM:080D2F06                 BX      R1
ROM:080D2F06 ; End of function GetRandomBattle_Gold


AP is 50 (shown as 50 in game. Actual value is 5.)
ROM:080D2F08 ; =============== S U B R O U T I N E =======================================
ROM:080D2F08
ROM:080D2F08
ROM:080D2F08 GetRandomBattle_AP                      ; CODE XREF: sub_8046A4C+1112p
ROM:080D2F08                 MOVS    R0, #5
ROM:080D2F0A                 BX      LR
ROM:080D2F0A ; End of function GetRandomBattle_AP
  • Modding version: Other/Unknown
  • Discord username: Darthatron

rrs_kai

Quote from: Darthatron on August 17, 2015, 07:07:46 am
As for AP given, it is hard coded to 50AP by the looks of it.

hmm...ok, thanks.

Also, I made help!!Area missions give two rewards and higher AP using the nightmare module but only the AP reward changed in-game, no item rewards appeared.
  • Modding version: Other/Unknown

bcrobert

So basically it uses flags to select from items available in stores plus the mythril and consumables? That's...actually a pretty damned clever system. I've gotta give props to SquareEnix on this one.

Thanks for the timely clarification Darth. I always assumed the clan battles went strictly off of a combination of random reward lists so I flunk out on this one. :P
My FFTA hacking tools: http://ffhacktics.com/smf/index.php?topic=9559.0

Believe it or not, I'm still working on this game.

trukxlig123

So, I wanted to make Random clan battles drop only myhtril and healing items or anything that has the last unknown byte checked in the AIO item editor.

Quote from: Darthatron on August 17, 2015, 07:07:46 am
So the way it currently works is that it randomly picks an item and then checks it can be dropped from the "Shop" byte (0xC) in the Item Data. Depending on where you are up to in the game it will drop an item that is either currently available in the shop OR has the up-most bit set (0x80). That's the last "Unknown" byte in the AIO Item Editor which all the Mythril items and generic healing items have set.

So it goes through all the items and works out how many can potentional drops there could be, then it randomly selects one of those items (Rand[1, X]) and that is the dropped item.


If the game checks the items with the "shop" byte (0xC) set to make it "potetional" drops, is there a way to skip this check so that it only drops the mythril and healing items or any item that has the last unknown byte checked in the AIO item editor? 

Also, I tried changing the gold reward to a fixed number so I changed 4 bytes at 0x08D2EE8 to FF 20 70 47 (copied how the AP reward is hardcoded) but I can't get past 255 :( .
  • Modding version: Other/Unknown