• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 27, 2024, 11:29:22 am

News:

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


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Dokurider

41
Hey guys, I'm going to spend some time looking into the AI's code. I don't know exactly how far I'll get, but I already have some great results.

Unit Target Priority

Located in: AI End of turn, in between turn, etc. (0019d37c)


AI End of turn, in between turn, etc.


0019d37c: 3c02801a lui r2,0x801a
0019d380: 90420d7b lbu r2,0x0d7b(r2)
0019d384: 27bdffe0 addiu r29,r29,0xffe0
0019d388: afb20018 sw r18,0x0018(r29)
0019d38c: 3c12801a lui r18,0x801a
0019d390: 2652f3c4 addiu r18,r18,0xf3c4
0019d394: afbf001c sw r31,0x001c(r29)
0019d398: afb10014 sw r17,0x0014(r29)
0019d39c: 1040000f beq r2,r0,0x0019d3dc branch if able to act
0019d3a0: afb00010 sw r16,0x0010(r29)

if unable to act

0019d3a4: 3c02801a lui r2,0x801a
0019d3a8: 904202b2 lbu r2,0x02b2(r2) Load ?
0019d3ac: 00000000 nop
0019d3b0: 1040000a beq r2,r0,0x0019d3dc Branch if ? = 0
0019d3b4: 00000000 nop
0019d3b8: 0c0678de jal 0x0019e378 Transfer AI Data to Unit Data
0019d3bc: 34040001 ori r4,r0,0x0001 r4 = 1 (extended transfer)
0019d3c0: 3c03801a lui r3,0x801a
0019d3c4: 906302b2 lbu r3,0x02b2(r3) Load ?
0019d3c8: 34020001 ori r2,r0,0x0001
0019d3cc: 10620062 beq r3,r2,0x0019d558 Branch if ? = 1
0019d3d0: 34020002 ori r2,r0,0x0002
0019d3d4: 106200b7 beq r3,r2,0x0019d6b4 Branch if ? = 2
0019d3d8: 00000000 nop

if able to act

0019d3dc: 0c0076ea jal 0x0001dba8 (Calculate Cycles Passed?)
0019d3e0: 34040001 ori r4,r0,0x0001 r4 = 1
0019d3e4: 284201b9 slti r2,r2,0x01b9
0019d3e8: 14400004 bne r2,r0,0x0019d3fc Branch if Cycles Passed? < 0x1b9
0019d3ec: 00000000 nop
0019d3f0: a2400eee sb r0,0x0eee(r18) Store ? = 0
0019d3f4: 080676d9 j 0x0019db64
0019d3f8: 2402ffff addiu r2,r0,0xffff r2 = -1 (fail)
0019d3fc: 0c067858 jal 0x0019e160 Transfer Unit Data to AI Data
0019d400: 00002021 addu r4,r0,r0 r4 = 0 (Extended transfer)
0019d404: a24019bc sb r0,0x19bc(r18) Store ? = 0
0019d408: 34110014 ori r17,r0,0x0014 Counter = 0x14
0019d40c: 26420014 addiu r2,r18,0x0014 r2 = AI Data Pointer + 0x14
0019d410: a0400e18 sb r0,0x0e18(r2) Store ? = 0
0019d414: 2631ffff addiu r17,r17,0xffff Counter --
0019d418: 0621fffd bgez r17,0x0019d410 Branch if Counter >= 0
0019d41c: 2442ffff addiu r2,r2,0xffff Pointer --
0019d420: 92430014 lbu r3,0x0014(r18) Load ?
0019d424: 340200ff ori r2,r0,0x00ff r2 = FF
0019d428: a6400032 sh r0,0x0032(r18) Store ? = 0
0019d42c: 10600017 beq r3,r0,0x0019d48c Branch if Targeting Flags haven't been set?
0019d430: a2420031 sb r2,0x0031(r18) Store Base Hit%? = 255
0019d434: 9243001d lbu r3,0x001d(r18) Load Skillset
0019d438: 00000000 nop
0019d43c: 10600029 beq r3,r0,0x0019d4e4 Branch if Skillset = 0
0019d440: 34020002 ori r2,r0,0x0002 r2 = 2
0019d444: 1062002a beq r3,r2,0x0019d4f0 Branch if Skillset = Defend
0019d448: 00000000 nop
0019d44c: 2650001c addiu r16,r18,0x001c r16 = Acting Unit's ID Pointer
0019d450: 0c05f0f7 jal 0x0017c3dc Attack Preparation Setup
0019d454: 02002021 addu r4,r16,r0 r4 = Acting Unit's ID Pointer
0019d458: 34030001 ori r3,r0,0x0001
0019d45c: 14430005 bne r2,r3,0x0019d474 Branch if CT = 0
0019d460: 00000000 nop
0019d464: 0c06772f jal 0x0019dcbc              Call AI Ability Processing
0019d468: 02002021 addu r4,r16,r0 r4 = Acting Unit's ID Pointer
0019d46c: 104001b9 beq r2,r0,0x0019db54
0019d470: 00000000 nop
0019d474: 8e4317f8 lw r3,0x17f8(r18) load acting units data
0019d478: 34020001 ori r2,r0,0x0001
0019d47c: 0c0676e0 jal 0x0019db80 0019db80 - 0019dca8
0019d480: a0620188 sb r2,0x0188(r3)
0019d484: 08067538 j 0x0019d4e0
0019d488: 00000000 nop
0019d48c: 0c0676e0 jal 0x0019db80 0019db80 - 0019dca8
0019d490: 00000000 nop
0019d494: 9243001d lbu r3,0x001d(r18)
0019d498: 00000000 nop
0019d49c: 10600011 beq r3,r0,0x0019d4e4
0019d4a0: 34020002 ori r2,r0,0x0002
0019d4a4: 10620012 beq r3,r2,0x0019d4f0
0019d4a8: 00000000 nop
0019d4ac: 2650001c addiu r16,r18,0x001c
0019d4b0: 0c05f0f7 jal 0x0017c3dc
0019d4b4: 02002021 addu r4,r16,r0
0019d4b8: 34030001 ori r3,r0,0x0001
0019d4bc: 14430005 bne r2,r3,0x0019d4d4
0019d4c0: 00000000 nop
0019d4c4: 0c06772f jal 0x0019dcbc 0019dcbc - 0019dd88
0019d4c8: 02002021 addu r4,r16,r0
0019d4cc: 104001a1 beq r2,r0,0x0019db54
0019d4d0: 00000000 nop
0019d4d4: 8e4317f8 lw r3,0x17f8(r18)
0019d4d8: 34020001 ori r2,r0,0x0001
0019d4dc: a0620188 sb r2,0x0188(r3)
0019d4e0: 9243001d lbu r3,0x001d(r18)
0019d4e4: 34020002 ori r2,r0,0x0002
0019d4e8: 14620009 bne r3,r2,0x0019d510
0019d4ec: 00000000 nop
0019d4f0: 92440e2e lbu r4,0x0e2e(r18)
0019d4f4: 0c060f80 jal 0x00183e00                 Another intermediate routine
0019d4f8: 00000000 nop
0019d4fc: 8e4317f8 lw r3,0x17f8(r18)
0019d500: 34020064 ori r2,r0,0x0064
0019d504: a2420031 sb r2,0x0031(r18)
0019d508: 34020001 ori r2,r0,0x0001
0019d50c: a0620188 sb r2,0x0188(r3)
0019d510: 9242001d lbu r2,0x001d(r18)
0019d514: 00000000 nop
0019d518: 14400002 bne r2,r0,0x0019d524
0019d51c: 34020064 ori r2,r0,0x0064
0019d520: a2420031 sb r2,0x0031(r18)
0019d524: 92440e2e lbu r4,0x0e2e(r18)
0019d528: 0c060f1b jal 0x00183c6c                 End of Turn
0019d52c: 00000000 nop
0019d530: 3c028019 lui r2,0x8019
0019d534: 8c42f518 lw r2,-0x0ae8(r2) load in between turn control variable
0019d538: 3c038019 lui r3,0x8019
0019d53c: 8c63f51c lw r3,-0x0ae4(r3) load menu control variable?
0019d540: 3c048019 lui r4,0x8019
0019d544: 8c84f520 lw r4,-0x0ae0(r4) load active units ID?
0019d548: a6400eec sh r0,0x0eec(r18)
0019d54c: ae420ee0 sw r2,0x0ee0(r18)
0019d550: ae430ee4 sw r3,0x0ee4(r18)
0019d554: ae440ee8 sw r4,0x0ee8(r18)

? = 1

0019d558: 0c0076ea jal 0x0001dba8 0001dba8 - 0001dcec
0019d55c: 34040001 ori r4,r0,0x0001
0019d560: 28420139 slti r2,r2,0x0139
0019d564: 1040016c beq r2,r0,0x0019db18 Exit if
0019d568: 00000000 nop
0019d56c: 96420eec lhu r2,0x0eec(r18)
0019d570: 00000000 nop
0019d574: 24420001 addiu r2,r2,0x0001
0019d578: a6420eec sh r2,0x0eec(r18)
0019d57c: 96420eec lhu r2,0x0eec(r18)
0019d580: 00000000 nop
0019d584: 2c420100 sltiu r2,r2,0x0100
0019d588: 10400041 beq r2,r0,0x0019d690
0019d58c: 00000000 nop
0019d590: 0c0609fc jal 0x001827f0
0019d594: 00002021 addu r4,r0,r0
0019d598: 00408821 addu r17,r2,r0
0019d59c: 3225ff00 andi r5,r17,0xff00
0019d5a0: 323100ff andi r17,r17,0x00ff
0019d5a4: 001110c0 sll r2,r17,0x03
0019d5a8: 00511023 subu r2,r2,r17
0019d5ac: 00021180 sll r2,r2,0x06
0019d5b0: 3c038019 lui r3,0x8019
0019d5b4: 246308cc addiu r3,r3,0x08cc
0019d5b8: 00438021 addu r16,r2,r3
0019d5bc: 3402ff00 ori r2,r0,0xff00
0019d5c0: 10a20033 beq r5,r2,0x0019d690
0019d5c4: 34020300 ori r2,r0,0x0300
0019d5c8: 14a20005 bne r5,r2,0x0019d5e0
0019d5cc: 34020200 ori r2,r0,0x0200
0019d5d0: 0c062f82 jal 0x0018be08
0019d5d4: 02202021 addu r4,r17,r0
0019d5d8: 08067590 j 0x0019d640
0019d5dc: 00008821 addu r17,r0,r0
0019d5e0: 14a2000d bne r5,r2,0x0019d618
0019d5e4: 34020100 ori r2,r0,0x0100
0019d5e8: 0c06772f jal 0x0019dcbc 0019dcbc - 0019dd88
0019d5ec: 2604016e addiu r4,r16,0x016e
0019d5f0: 1040014f beq r2,r0,0x0019db30
0019d5f4: 340200ff ori r2,r0,0x00ff
0019d5f8: a202015d sb r2,0x015d(r16) store no ability CT
0019d5fc: 92020058 lbu r2,0x0058(r16) load statii
0019d600: 920301bb lbu r3,0x01bb(r16) load status infliction
0019d604: 304200f6 andi r2,r2,0x00f6 remove performing/charging
0019d608: 306300f6 andi r3,r3,0x00f6 remove performing/charging
0019d60c: a2020058 sb r2,0x0058(r16) store new status
0019d610: 0806758f j 0x0019d63c
0019d614: a20301bb sb r3,0x01bb(r16) store new status infliction
0019d618: 14a20008 bne r5,r2,0x0019d63c
0019d61c: 00002021 addu r4,r0,r0
0019d620: 0c067c57 jal 0x0019f15c 0019f15c - 0019f254
0019d624: 02202821 addu r5,r17,r0
0019d628: 10400003 beq r2,r0,0x0019d638
0019d62c: 02511821 addu r3,r18,r17
0019d630: 34020001 ori r2,r0,0x0001
0019d634: a0620e18 sb r2,0x0e18(r3)
0019d638: a2000186 sb r0,0x0186(r16) store turn over
0019d63c: 00008821 addu r17,r0,r0
0019d640: 340400ff ori r4,r0,0x00ff
0019d644: 3c038019 lui r3,0x8019
0019d648: 246308cc addiu r3,r3,0x08cc
0019d64c: 00608021 addu r16,r3,r0
0019d650: 92020001 lbu r2,0x0001(r16) load unit ID
0019d654: 00000000 nop
0019d658: 10440006 beq r2,r4,0x0019d674 branch if doesn't exist
0019d65c: 00000000 nop
0019d660: 92020058 lbu r2,0x0058(r16) load status
0019d664: 00000000 nop
0019d668: 30420009 andi r2,r2,0x0009
0019d66c: 14400006 bne r2,r0,0x0019d688 branch if charging/performing
0019d670: 34020015 ori r2,r0,0x0015
0019d674: 26310001 addiu r17,r17,0x0001
0019d678: 2a220015 slti r2,r17,0x0015
0019d67c: 1440fff3 bne r2,r0,0x0019d64c branch if counter < 0x15
0019d680: 260301c0 addiu r3,r16,0x01c0 next unit
0019d684: 34020015 ori r2,r0,0x0015
0019d688: 1622ffb3 bne r17,r2,0x0019d558 branch if counter != 0x15
0019d68c: 00000000 nop
0019d690: 8e420ee0 lw r2,0x0ee0(r18)
0019d694: 8e430ee4 lw r3,0x0ee4(r18)
0019d698: 8e440ee8 lw r4,0x0ee8(r18)
0019d69c: 3c018019 lui r1,0x8019
0019d6a0: ac22f518 sw r2,-0x0ae8(r1)
0019d6a4: 3c018019 lui r1,0x8019
0019d6a8: ac23f51c sw r3,-0x0ae4(r1)
0019d6ac: 3c018019 lui r1,0x8019
0019d6b0: ac24f520 sw r4,-0x0ae0(r1)

? = 2 (Starting turn?) Unit Priority Routine (The lower, the better)

0019d6b4: 0c0076ea jal 0x0001dba8 Derive RNG from Frame Data?
0019d6b8: 34040001 ori r4,r0,0x0001
0019d6bc: 284201b9 slti r2,r2,0x01b9 (I assume 0x01ff is the highest value?)
0019d6c0: 14400005 bne r2,r0,0x0019d6d8 Branch if you pleased the Frame RNG gods today
0019d6c4: 3c030100 lui r3,0x0100
0019d6c8: 0c067858 jal 0x0019e160 Transfer Unit Data to AI Data
0019d6cc: 34040001 ori r4,r0,0x0001
0019d6d0: 080676c9 j 0x0019db24 Basically Exit Routine (Is this why sometimes units will just skip turns?)
0019d6d4: 34020002 ori r2,r0,0x0002 (A 70/511(13.7%) chance of being screwed by the RNG in Arena lol)
0019d6d8: 8e420cb4 lw r2,0x0cb4(r18)
0019d6dc: 00000000 nop
0019d6e0: 00431024 and r2,r2,r3
0019d6e4: 10400048 beq r2,r0,0x0019d808 Skip Loop if r2 =/= 0x01000000
0019d6e8: 00008821 addu r17,r0,r0
0019d6ec: 00003021 addu r6,r0,r0
0019d6f0: 3405182c ori r5,r0,0x182c
0019d6f4: 02452021 addu r4,r18,r5 r4 = AI decision data
0019d6f8: 3c028019 lui r2,0x8019
0019d6fc: 244208cc addiu r2,r2,0x08cc
0019d700: 90830004 lbu r3,0x0004(r4) load AI settings?
0019d704: 00c28021 addu r16,r6,r2
0019d708: 306300f8 andi r3,r3,0x00f8 remove Unit needs Reviving/Unstoning, Unit is Jumping
0019d70c: a0830004 sb r3,0x0004(r4) store new flags
0019d710: 92020058 lbu r2,0x0058(r16) load status
0019d714: 00000000 nop
0019d718: 30420020 andi r2,r2,0x0020
0019d71c: 10400007 beq r2,r0,0x0019d73c branch if if not dead
0019d720: 00000000 nop
0019d724: 9202005a lbu r2,0x005a(r16) load status
0019d728: 00000000 nop
0019d72c: 30420020 andi r2,r2,0x0020
0019d730: 14400002 bne r2,r0,0x0019d73c branch if reraise
0019d734: 34620001 ori r2,r3,0x0001 add Need Revive flag
0019d738: a0820004 sb r2,0x0004(r4) store new AI setting
0019d73c: 92020059 lbu r2,0x0059(r16)
0019d740: 00000000 nop
0019d744: 30420080 andi r2,r2,0x0080
0019d748: 10400005 beq r2,r0,0x0019d760 branch if not petrified
0019d74c: 00000000 nop
0019d750: 90820004 lbu r2,0x0004(r4) load AI settings
0019d754: 00000000 nop
0019d758: 34420002 ori r2,r2,0x0002 add Need UnPetrifed flag
0019d75c: a0820004 sb r2,0x0004(r4) store flag
0019d760: 92020058 lbu r2,0x0058(r16)
0019d764: 00000000 nop
0019d768: 30420004 andi r2,r2,0x0004
0019d76c: 10400005 beq r2,r0,0x0019d784 branch if not jumping
0019d770: 00000000 nop
0019d774: 90820004 lbu r2,0x0004(r4)
0019d778: 00000000 nop
0019d77c: 34420004 ori r2,r2,0x0004 Unit is Jumping Flag
0019d780: a0820004 sb r2,0x0004(r4) store flag
0019d784: 90830004 lbu r3,0x0004(r4)
0019d788: 00000000 nop
0019d78c: 30620080 andi r2,r3,0x0080
0019d790: 14400016 bne r2,r0,0x0019d7ec Next Unit if unit is Charging/Performing?
0019d794: 00000000 nop
0019d798: 92020059 lbu r2,0x0059(r16)
0019d79c: 00000000 nop
0019d7a0: 30420080 andi r2,r2,0x0080
0019d7a4: 14400011 bne r2,r0,0x0019d7ec Next Unit if petrified
0019d7a8: 00000000 nop
0019d7ac: 92020058 lbu r2,0x0058(r16)
0019d7b0: 00000000 nop
0019d7b4: 30420020 andi r2,r2,0x0020
0019d7b8: 10400006 beq r2,r0,0x0019d7d4 branch if not dead
0019d7bc: 00000000 nop
0019d7c0: 9202005a lbu r2,0x005a(r16)
0019d7c4: 00000000 nop
0019d7c8: 30420020 andi r2,r2,0x0020
0019d7cc: 10400007 beq r2,r0,0x0019d7ec Next Unit if No Reraise
0019d7d0: 00000000 nop
0019d7d4: 9202005c lbu r2,0x005c(r16)
0019d7d8: 00000000 nop
0019d7dc: 30420001 andi r2,r2,0x0001
0019d7e0: 14400002 bne r2,r0,0x0019d7ec Next Unit if death-sentenced
0019d7e4: 34620080 ori r2,r3,0x0080 Unit needs to be dealt with flag
0019d7e8: a0820004 sb r2,0x0004(r4) store new flags
0019d7ec: 24c601c0 addiu r6,r6,0x01c0 Unit Data Pointer++
0019d7f0: 26310001 addiu r17,r17,0x0001 Unit Counter++
0019d7f4: 2a220015 slti r2,r17,0x0015
0019d7f8: 1440ffbe bne r2,r0,0x0019d6f4 perform for all units
0019d7fc: 24a50010 addiu r5,r5,0x0010 Unit AI Data++
0019d800: 080676d5 j 0x0019db54
0019d804: 00000000 nop
0019d808: 0c06772b jal 0x0019dcac 0019dcac - 0019dcb8
0019d80c: 00000000 nop
0019d810: 3c0c8019 lui r12,0x8019
0019d814: 258c3de0 addiu r12,r12,0x3de0
0019d818: 3c0d801a lui r13,0x801a
0019d81c: 8dadf3c0 lw r13,-0x0c40(r13)
0019d820: 02404821 addu r9,r18,r0 r9 = Unit AI
0019d824: 02405021 addu r10,r18,r0 r10 = Unit AI
0019d828: 00005821 addu r11,r0,r0

<Unit Priority Loop>
0019d82c: 9145198c lbu r5,0x198c(r10) load units battle ID?
0019d830: 340200ff ori r2,r0,0x00ff
0019d834: 10a2009c beq r5,r2,0x0019daa8 branch if doesn't exist
0019d838: 00002821 addu r5,r0,r0 r5 = Current Status Loop Counter
0019d83c: 3c028019 lui r2,0x8019
0019d840: 244208cc addiu r2,r2,0x08cc
0019d844: 01628021 addu r16,r11,r2 r16 = unit data
0019d848: 01204021 addu r8,r9,r0 r8 = Unit AI
0019d84c: 00003021 addu r6,r0,r0

0019d850: 96070028 lhu r7,0x0028(r16) load current HP
0019d854: 9602002a lhu r2,0x002a(r16) load max HP
0019d858: 000739c0 sll r7,r7,0x07 current HP * 80
0019d85c: 00e2001a div r7,r2 current HP * 80 / maxHP
0019d860: 00003812 mflo r7 r7 = Unit Target Priority Value (curHP% of 0x80)

0019d864: 04a10002 bgez r5,0x0019d870 Branch if this isn't first status loop (the Blank Status)
0019d868: 00a01021 addu r2,r5,r0 r2 = Current Status Loop Counter
0019d86c: 24a20007 addiu r2,r5,0x0007 r2 = 7 (To counteract negative loops??)
0019d870: 000210c3 sra r2,r2,0x03 Status ID / 8
0019d874: 02021821 addu r3,r16,r2 Get Unit Current Status
0019d878: 90630058 lbu r3,0x0058(r3) load Current Status 1, 2, 3, 4, or 5
0019d87c: 000210c0 sll r2,r2,0x03 {0,1,2,3,4} * 8
0019d880: 00a21023 subu r2,r5,r2 r2 = Status ID - {0,10,18,20,28}
0019d884: 00431804 sllv r3,r3,r2 Will always equal 0x80 if Status in question is present
0019d888: 30630080 andi r3,r3,0x0080
0019d88c: 1060003b beq r3,r0,0x0019d97c Next Status if Current Status not present
0019d890: 00000000 nop
0019d894: 92020059 lbu r2,0x0059(r16) load Current Status 2
0019d898: 3c01801a lui r1,0x801a
0019d89c: 00260821 addu r1,r1,r6
0019d8a0: 8424f308 lh r4,-0x0cf8(r1) load Status Modifers for Target Priority Value
0019d8a4: 30420014 andi r2,r2,0x0014
0019d8a8: 14400006 bne r2,r0,0x0019d8c4 Branch if Confuse/Blood Suck
0019d8ac: 00000000 nop
0019d8b0: 9202005c lbu r2,0x005c(r16) load Current Status 5
0019d8b4: 00000000 nop
0019d8b8: 30420020 andi r2,r2,0x0020
0019d8bc: 10400003 beq r2,r0,0x0019d8cc branch if not Charmed
0019d8c0: 24a3fff6 addiu r3,r5,0xfff6 Exclude Blank to Invite statuses
0019d8c4: 0481002d bgez r4,0x0019d97c Branch if Status Target Priority is not negative (Blood Suck/Confuse is zero)
0019d8c8: 24a3fff6 addiu r3,r5,0xfff6 Exclude Blank to Invite statuses
0019d8cc: 2c62001c sltiu r2,r3,0x001c
0019d8d0: 10400029 beq r2,r0,0x0019d978 Branch and add zero to the Target Priority if Blank to Invite (Reflect/DS as well)
0019d8d4: 00031080 sll r2,r3,0x02 (Status ID - 9) * 4
0019d8d8: 004c1021 addu r2,r2,r12
0019d8dc: 8c420000 lw r2,0x0000(r2) Get Jump Address (only 0x1c addresses...)
0019d8e0: 00000000 nop
0019d8e4: 00400008 jr r2
0019d8e8: 00000000 nop

Blind             
0019d8ec: 91021839 lbu r2,0x1839(r8) Evade Mod (# evadeable (physical?) abilities ")
0019d8f0: 08067641 j 0x0019d904
0019d8f4: 00820018 mult r4,r2 Status Target Value * Evade Mod

Silence
0019d8f8: 91021838 lbu r2,0x1838(r8) Load Silence Blocking Mod
0019d8fc: 00000000 nop
0019d900: 00820018 mult r4,r2 Status Target Value * Silence Mod
0019d904: 00001012 mflo r2
0019d908: 0441001b bgez r2,0x0019d978 Increase Unit Target Priority Value and go to next status
0019d90c: 00022083 sra r4,r2,0x02 Status Target Value / 4
0019d910: 24420003 addiu r2,r2,0x0003 Status Target Value + 3
0019d914: 0806765e j 0x0019d978 Subtract from Target Value and Next Status
0019d918: 00022083 sra r4,r2,0x02 Status Target Value / 4

Confusion/Charm/Blood Suck
0019d91c: 9202005b lbu r2,0x005b(r16) load Current Status 4
0019d920: 00000000 nop
0019d924: 30420006 andi r2,r2,0x0006
0019d928: 14400006 bne r2,r0,0x0019d944 branch if slow/stop
0019d92c: 000417c2 srl r2,r4,0x1f Status Target Value / 0x1f
0019d930: 9202005c lbu r2,0x005c(r16) load Current Status 5
0019d934: 00000000 nop
0019d938: 3042001c andi r2,r2,0x001c
0019d93c: 1040000e beq r2,r0,0x0019d978 Modify Target Value and next status if not sleep/don't move/act
0019d940: 000417c2 srl r2,r4,0x1f Status Target Value / 0x1f
0019d944: 00821021 addu r2,r4,r2 Status Target Value + {0 if positive, 1 if negative}
0019d948: 0806765e j 0x0019d978
0019d94c: 00022043 sra r4,r2,0x01 Status Target Value + {0,1} / 4

Slow/Stop/Sleep/Don't Move/Don't Act
0019d950: 92020059 lbu r2,0x0059(r16) load Current Status 2
0019d954: 00000000 nop
0019d958: 30420014 andi r2,r2,0x0014
0019d95c: 14400007 bne r2,r0,0x0019d97c Add nothing to Target Priority; next status if confuse/blood suck
0019d960: 00000000 nop
0019d964: 9202005c lbu r2,0x005c(r16) load Current Status 5
0019d968: 00000000 nop
0019d96c: 30420020 andi r2,r2,0x0020
0019d970: 14400002 bne r2,r0,0x0019d97c Add nothing to Target Priority; next status if charm
0019d974: 00000000 nop

Everything Else:
0019d978: 00e43821 addu r7,r7,r4 Add Status Target Value to Unit Target Priority
0019d97c: 24a50001 addiu r5,r5,0x0001 Next Status
0019d980: 28a20028 slti r2,r5,0x0028
0019d984: 1440ffb7 bne r2,r0,0x0019d864 loop until all statuses are looked for
0019d988: 24c60002 addiu r6,r6,0x0002 Next Status Target Value (Halfword)

0019d98c: 92020006 lbu r2,0x0006(r16) load gender
0019d990: 00000000 nop
0019d994: 30420020 andi r2,r2,0x0020
0019d998: 14400010 bne r2,r0,0x0019d9dc branch if monster
0019d99c: 00000000 nop

0019d9a0: 9142198c lbu r2,0x198c(r10) load unit battle ID?
0019d9a4: 00002821 addu r5,r0,r0
0019d9a8: 00021180 sll r2,r2,0x06
0019d9ac: 004d3021 addu r6,r2,r13 r6 = unit AI extended status data
0019d9b0: 02051021 addu r2,r16,r5 r2 = unit data
0019d9b4: 00c51821 addu r3,r6,r5 r3 = unit AI extended status data
0019d9b8: 9044001a lbu r4,0x001a(r2) load Head slot equipment
0019d9bc: 90620036 lbu r2,0x0036(r3) load helmet
0019d9c0: 00000000 nop
0019d9c4: 14820002 bne r4,r2,0x0019d9d0 branch if items are missing (Broken/Stolen)
0019d9c8: 24a50001 addiu r5,r5,0x0001
0019d9cc: 24e70033 addiu r7,r7,0x0033 Unit Target Priority Value + 0x33 if information matches (Target is not as desirable to target)
0019d9d0: 28a20007 slti r2,r5,0x0007
0019d9d4: 1440fff7 bne r2,r0,0x0019d9b4 Look for missing Helmet, Armor, Acc., R Weapon, R Shield, L Weapon and L Shield
0019d9d8: 02051021 addu r2,r16,r5 r2 = next unit data

0019d9dc: 9604002e lhu r4,0x002e(r16) load max MP
0019d9e0: 00000000 nop
0019d9e4: 10800014 beq r4,r0,0x0019da38 branch if unit has no MP
0019d9e8: 00000000 nop
0019d9ec: 9606002c lhu r6,0x002c(r16) load current MP
0019d9f0: 91231836 lbu r3,0x1836(r9) Load Lowest MP Cost
0019d9f4: 00c01021 addu r2,r6,r0
0019d9f8: 00063180 sll r6,r6,0x06 CurMP * 40
0019d9fc: 0043102b sltu r2,r2,r3 r2 = curMP < Lowest MP Cost
0019da00: 00c4001a div r6,r4 (CurMP * 40) / Max MP
0019da04: 00003012 mflo r6
0019da08: 10400002 beq r2,r0,0x0019da14 Branch if unit doesn't have enough MP to cast spells.
0019da0c: 00000000 nop
0019da10: 00063042 srl r6,r6,0x01 curMP% / 4
0019da14: 91221837 lbu r2,0x1837(r9) MP Using Ability Mod
0019da18: 00000000 nop
0019da1c: 00c20018 mult r6,r2 (curMP% / 10) * MP Mod
0019da20: 00001012 mflo r2 Caster Hate
0019da24: 04410003 bgez r2,0x0019da34 Branch if no spell unit has uses MP
0019da28: 00023083 sra r6,r2,0x02 Caster Hate / 4
0019da2c: 24420003 addiu r2,r2,0x0003 Caster Hate + 3
0019da30: 00023083 sra r6,r2,0x02 Caster Hate + 3 / 4
0019da34: 00e63821 addu r7,r7,r6 Add Caster Hate to Target Priority Value

0019da38: 92020005 lbu r2,0x0005(r16) load ENTD flags
0019da3c: 00000000 nop
0019da40: 000210c2 srl r2,r2,0x03 flags / 8
0019da44: 30420006 andi r2,r2,0x0006 Get Team
0019da48: 3c018019 lui r1,0x8019
0019da4c: 00220821 addu r1,r1,r2
0019da50: 9426f5f4 lhu r6,-0x0a0c(r1) Load Current? Team Golem Amount
0019da54: 92430e17 lbu r3,0x0e17(r18) Load average max hp of team
0019da58: 00c02821 addu r5,r6,r0
0019da5c: 000631c0 sll r6,r6,0x07 CurGolem * 80
0019da60: 00c3001a div r6,r3 CurGolem * 80 / Average Team HP
0019da64: 00001812 mflo r3 Golem Fear
0019da68: 00521021 addu r2,r2,r18
0019da6c: 94420e3c lhu r2,0x0e3c(r2) load Max? Team Golem Amount
0019da70: 00000000 nop
0019da74: 00a2282b sltu r5,r5,r2 CurGolem <  MaxGolem?
0019da78: 10a00002 beq r5,r0,0x0019da84 -1 to Priority if Golem is undamaged
0019da7c: 00e33821 addu r7,r7,r3 Add Golem Hate to Target Priority Value (Big mistake, has no real value when it's added to everyone)
0019da80: 24e7ffff addiu r7,r7,0xffff Target Priority - 1

0019da84: 91221834 lbu r2,0x1834(r9) Load Enemy Flag
0019da88: 00000000 nop
0019da8c: 10400002 beq r2,r0,0x0019da98 Branch if not Enemy
0019da90: 00000000 nop
0019da94: 00073823 subu r7,r0,r7 Invert Target Priority

0019da98: 96420032 lhu r2,0x0032(r18) Load Current Unit Target Priority Value
0019da9c: 00000000 nop
0019daa0: 00471021 addu r2,r2,r7 Add/Subtract from current Target Priority
0019daa4: a6420032 sh r2,0x0032(r18) Save New Unit Target Priority Value

0019daa8: 25290010 addiu r9,r9,0x0010 Unit AI Data++
0019daac: 254a0001 addiu r10,r10,0x0001 Unit AI++
0019dab0: 26310001 addiu r17,r17,0x0001 Unit++
0019dab4: 2a220015 slti r2,r17,0x0015
0019dab8: 1440ff5c bne r2,r0,0x0019d82c Loop for all units
0019dabc: 256b01c0 addiu r11,r11,0x01c0 Unit Data++
</Unit Priority loop>

0019dac0: 92420000 lbu r2,0x0000(r18) Load Skillset
0019dac4: 3c018006 lui r1,0x8006
0019dac8: 00220821 addu r1,r1,r2
0019dacc: 90235cb4 lbu r3,0x5cb4(r1) load action menu byte
0019dad0: 34020002 ori r2,r0,0x0002
0019dad4: 1462000b bne r3,r2,0x0019db04 branch if not weapon inventory
0019dad8: 3402017e ori r2,r0,0x017e
0019dadc: 86430002 lh r3,0x0002(r18) load ability ID
0019dae0: 00000000 nop
0019dae4: 10620007 beq r3,r2,0x0019db04 branch if ability = throw shuriken
0019dae8: 34020189 ori r2,r0,0x0189
0019daec: 10620005 beq r3,r2,0x0019db04 branch if ability = throw ball (So both will be spammed?)
0019daf0: 00000000 nop
0019daf4: 92420031 lbu r2,0x0031(r18) load base hit%
0019daf8: 00000000 nop
0019dafc: 00021042 srl r2,r2,0x01 base hit/2
0019db00: a2420031 sb r2,0x0031(r18) store new base hit%
0019db04: 0c0678de jal 0x0019e378 Transfer AI Data to Unit Data
0019db08: 00002021 addu r4,r0,r0
0019db0c: a24019b7 sb r0,0x19b7(r18)
0019db10: 080676d9 j 0x0019db64 jump to end, return r2 = 0x01
0019db14: 34020001 ori r2,r0,0x0001
</2 >

0019db18: 0c067858 jal 0x0019e160
0019db1c: 34040001 ori r4,r0,0x0001
0019db20: 34020001 ori r2,r0,0x0001
0019db24: a2420eee sb r2,0x0eee(r18)
0019db28: 080676d9 j 0x0019db64 jump to end, return r2=0xffff
0019db2c: 2402ffff addiu r2,r0,0xffff

<End>
0019db30: 8e420ee0 lw r2,0x0ee0(r18)
0019db34: 8e430ee4 lw r3,0x0ee4(r18)
0019db38: 8e440ee8 lw r4,0x0ee8(r18)
0019db3c: 3c018019 lui r1,0x8019
0019db40: ac22f518 sw r2,-0x0ae8(r1)
0019db44: 3c018019 lui r1,0x8019
0019db48: ac23f51c sw r3,-0x0ae4(r1)
0019db4c: 3c018019 lui r1,0x8019
0019db50: ac24f520 sw r4,-0x0ae0(r1)
0019db54: 0c0678de jal 0x0019e378                 Transfer AI Data to Unit Data
0019db58: 00002021 addu r4,r0,r0
0019db5c: a24019b7 sb r0,0x19b7(r18)
0019db60: 00001021 addu r2,r0,r0 return r2 = 0x00
0019db64: 8fbf001c lw r31,0x001c(r29)
0019db68: 8fb20018 lw r18,0x0018(r29)
0019db6c: 8fb10014 lw r17,0x0014(r29)
0019db70: 8fb00010 lw r16,0x0010(r29)
0019db74: 27bd0020 addiu r29,r29,0x0020
0019db78: 03e00008 jr r31
0019db7c: 00000000 nop

*Note: The entire routine isn't done yet, but the subroutine I'm about to talk about will prove very interesting and is documented.

Summary:
Target Value Formula

(HP Value[curHP * 128 / maxHP] + Total Status Values + (51 * # of items broken up to 7) + Caster Hate [(curMP% / 16) * # MP using Abilities, 0 if not enough MP] + Golem Fear [CurGolem * 128 / Average Team HP (- 1 if Golem not damaged)]) * (-1 if unit is Enemy, 1 if ally)




HP Value goes from 0% to 128%. Multiply by 25/32 to get 0% - 100%.

This is the formula that the AI uses the determine how much priority an individual unit gets.

The more negative the value, the higher on the enemy target priority that unit becomes. The lower the target's HP, the more of a target that unit becomes, which makes sense. However there most likely is a threshold and the unit will be ignored if it gets too negative.

I assume that the Priority Value is interpreted as effective curHP%. So if a unit has -50% effective curHP%, the AI assumes that unit is pretty incapacitated and will ignore them for a unit that has 5% effective curHP%. However, units in critical are flagged and singled out, so the AI doesn't ignore units with no HP left but a ton of non-fatal statuses.

Units that are Petrified, Dead with no Reraise, Death Sentenced, and Charging/Performing skip giving a Target Value at all. Charging and Performing do not need to contribute to Priority because they already have their own routines to processes them. Same goes for Dead and Petrify.

Now, what exactly, does the AI do with this Target Value next, I've yet to determine.


Observations:

You didn't make a sacrifice to the RNG gods today, I'm just gonna sit and spin my wheels instead
0019d6b4: 0c0076ea jal 0x0001dba8 Derive RNG from Frame Data?
0019d6b8: 34040001 ori r4,r0,0x0001
0019d6bc: 284201b9 slti r2,r2,0x01b9 (I assume 0x01ff is the highest value?)
0019d6c0: 14400005 bne r2,r0,0x0019d6d8 Branch if you pleased the Frame RNG gods today
0019d6c4: 3c030100 lui r3,0x0100
0019d6c8: 0c067858 jal 0x0019e160 Transfer Unit Data to AI Data
0019d6cc: 34040001 ori r4,r0,0x0001
0019d6d0: 080676c9 j 0x0019db24 Basically Exit Routine (Is this why sometimes units will just skip turns?)
0019d6d4: 34020002 ori r2,r0,0x0002 (A 70/511(13.7%) chance of being screwed by the RNG in Arena lol)


This confuses me a bit, but no matter how you slice it, it does seem that the AI will occasionally skip assigning units a Target Value at all or basically decide not to do anything at all this turn. The odds of that happening is pretty small because while this might be a 13.7% of that happening every time you come here, the AI comes to this routine several times. So it's more like a .13X% very tiny chance of that happening. Still, giving the amount of decisions the AI makes just per battle, it can and has been observed to happen.


Blind and Silence gain more value to the AI the more abilities you have that are Evadable/Silenceable
Blind             
0019d8ec: 91021839 lbu r2,0x1839(r8) Evade Mod (# evadeable (physical?) abilities ")
0019d8f0: 08067641 j 0x0019d904
0019d8f4: 00820018 mult r4,r2 Status Target Value * Evade Mod {0-4}

Silence
0019d8f8: 91021838 lbu r2,0x1838(r8) Load Silence Blocking Mod
0019d8fc: 00000000 nop
0019d900: 00820018 mult r4,r2 Status Target Value * Silence Mod {0-4}
0019d904: 00001012 mflo r2
0019d908: 0441001b bgez r2,0x0019d978 Increase Unit Target Priority Value and go to next status
0019d90c: 00022083 sra r4,r2,0x02 Status Target Value / 4
0019d910: 24420003 addiu r2,r2,0x0003 Status Target Value + 3
0019d914: 0806765e j 0x0019d978 Subtract from Target Value and Next Status
0019d918: 00022083 sra r4,r2,0x02 Status Target Value / 4


This is probably why the AI doesn't seem to like adding Blind a lot in Arena, or even at all. The AI doesn't take into an account just how much damage a unit can actually do. Attack, even if they deal a truck load of damage, is only one skill to the AI. It cannot tell the immediate difference between a White Mage with Healing Staff and a Berserk Cursed Ring Two Handed Main Gauche killer. Since there aren't too many physically evadable skills in the game, the AI just tends to not want to use Blind all that much it seems, only ever adding -12.5% priority at one time. So simply having no abilities at all is apparently just as good as Blind Immunity. The AI looks at the percentage of units with P-Ev, not the total.

It should be a different story for Silence, but I only ever seen the AI cast Silence as an interrupt, not ever by itself to debuff, even though it's desire to should be much higher, right?


Units become bigger targets the more equips they lose
0019d9a0: 9142198c lbu r2,0x198c(r10) load unit battle ID?
0019d9a4: 00002821 addu r5,r0,r0
0019d9a8: 00021180 sll r2,r2,0x06
0019d9ac: 004d3021 addu r6,r2,r13 r6 = unit AI extended status data
0019d9b0: 02051021 addu r2,r16,r5 r2 = unit data
0019d9b4: 00c51821 addu r3,r6,r5 r3 = unit AI extended status data
0019d9b8: 9044001a lbu r4,0x001a(r2) load Head slot equipment
0019d9bc: 90620036 lbu r2,0x0036(r3) load helmet
0019d9c0: 00000000 nop
0019d9c4: 14820002 bne r4,r2,0x0019d9d0 branch if items are missing (Broken/Stolen)
0019d9c8: 24a50001 addiu r5,r5,0x0001
0019d9cc: 24e70033 addiu r7,r7,0x0033 Unit Target Priority Value + 0x33 if information matches (Target is not as desirable to target)
0019d9d0: 28a20007 slti r2,r5,0x0007
0019d9d4: 1440fff7 bne r2,r0,0x0019d9b4 Look for missing Helmet, Armor, Acc., R Weapon, R Shield, L Weapon and L Shield
0019d9d8: 02051021 addu r2,r16,r5 r2 = next unit data

Seems pretty straight forward. The more stuff you lose, the bigger of a target you become. What is a bit surprising is that all items lost are treated equal. In practice however, you also lose Max HP for losing Armor anyways, so you become an even bigger target than normal.


The AI really fucking hates Mages
0019d9dc: 9604002e lhu r4,0x002e(r16) load max MP
0019d9e0: 00000000 nop
0019d9e4: 10800014 beq r4,r0,0x0019da38 branch if unit has no MP
0019d9e8: 00000000 nop
0019d9ec: 9606002c lhu r6,0x002c(r16) load current MP
0019d9f0: 91231836 lbu r3,0x1836(r9) Load Lowest MP Cost
0019d9f4: 00c01021 addu r2,r6,r0
0019d9f8: 00063180 sll r6,r6,0x06 CurMP * 40
0019d9fc: 0043102b sltu r2,r2,r3 r2 = curMP < Lowest MP Cost
0019da00: 00c4001a div r6,r4 (CurMP * 40) / Max MP
0019da04: 00003012 mflo r6
0019da08: 10400002 beq r2,r0,0x0019da14 Branch if unit doesn't have enough MP to cast spells.
0019da0c: 00000000 nop
0019da10: 00063042 srl r6,r6,0x01 curMP% / 2
0019da14: 91221837 lbu r2,0x1837(r9) MP Using Ability Mod
0019da18: 00000000 nop
0019da1c: 00c20018 mult r6,r2 (curMP% / 20) * MP Mod {0-4}
0019da20: 00001012 mflo r2 Caster Hate
0019da24: 04410003 bgez r2,0x0019da34 Branch if no spell this unit has uses MP
0019da28: 00023083 sra r6,r2,0x02 Caster Hate / 4
0019da2c: 24420003 addiu r2,r2,0x0003 Caster Hate + 3
0019da30: 00023083 sra r6,r2,0x02 Caster Hate + 3 / 4
0019da34: 00e63821 addu r7,r7,r6 Add Caster Hate to Target Priority Value


The AI puts priority on units that have lots of mana and can cast a variety of spells. So if you ever wondered why they gun after your weak little mages all the time, this is why. The price these guys can gain can get stupid high at time, just take your MP, divide by 16, and multiply it by your number of spells to get a grasp on just how much the AI hates spellcasters.
Robe of Lords might as well be a giant Kick Me sign.
The AI takes into account the percentage of spells with MP costs.


Golem is complete cancer
0019da38: 92020005 lbu r2,0x0005(r16) load ENTD flags
0019da3c: 00000000 nop
0019da40: 000210c2 srl r2,r2,0x03 flags / 8
0019da44: 30420006 andi r2,r2,0x0006 Get Team
0019da48: 3c018019 lui r1,0x8019
0019da4c: 00220821 addu r1,r1,r2
0019da50: 9426f5f4 lhu r6,-0x0a0c(r1) Load Current? Team Golem Amount
0019da54: 92430e17 lbu r3,0x0e17(r18) Load average max hp of team
0019da58: 00c02821 addu r5,r6,r0
0019da5c: 000631c0 sll r6,r6,0x07 CurGolem * 80
0019da60: 00c3001a div r6,r3 CurGolem * 80 / Average Team HP
0019da64: 00001812 mflo r3 Golem Fear
0019da68: 00521021 addu r2,r2,r18
0019da6c: 94420e3c lhu r2,0x0e3c(r2) load Max? Team Golem Amount
0019da70: 00000000 nop
0019da74: 00a2282b sltu r5,r5,r2 CurGolem <  MaxGolem?
0019da78: 10a00002 beq r5,r0,0x0019da84 -1 to Priority if Golem is undamaged
0019da7c: 00e33821 addu r7,r7,r3 Add Golem Hate to Target Priority Value (Big mistake, has no real value when it's added to everyone)
0019da80: 24e7ffff addiu r7,r7,0xffff Target Priority - 1

To clarify, this is not exactly why the AI drops everything it's doing to break Golem and makes the AI retarded. However, this is not really helping at all. You can clearly see the fault in adding the same amount of priority value to all units in a team. it's useless at best. Nuke this section please.



Finally, here are the Status Target Priority Values.

Status Priority Values (19f308)
Values, I assume, are interpreted as curHP%, thus, each status is +/- effective curHP.
0x0058: Current Statuses 1
0x80 - 0% (0000)
0x40 - Crystal -150% -c0(ff40)
0x20 - Dead -150% -c0(ff40)
0x10 - Undead -30.5% -27(ffd9)
0x08 - Charging 0% (0000)
0x04 - Jump 0% (0000)
0x02 - Defending 0% (0000)
0x01 - Performing 0% (0000)
0x0059: Current Statuses 2
0x80 - Petrify -90.6% -74(ff8c)
0x40 - Invite -180.4% -e7(ff19)
0x20 - Darkness -50% [-40(ffc0) * Evadable abilities] + 3 / 4
0x10 - Confusion -50% -40(ffc0) (+1 / 4 if slow/stop/sleep/don't move/act/)
0x08 - Silence -70.3% [-5a(ffa6) * Silence abilities] + 3 / 4
0x04 - Blood Suck -90.6% -74(ff8c) (+1 / 4 if slow/stop/sleep/don't move/act/)
0x02 - Cursed 0%(0000)
0x01 - Treasure -150% -c0(ff40)
0x005a: Current Statuses 3
0x80 - Oil -5.5% -7(fff9)
0x40 - Float 9.4% c(000c)
0x20 - Reraise 39.8% 33(0033)
0x10 - Transparent 29.7% 26(0026)
0x08 - Berserk -30.5% -27(ffd9)
0x04 - Chicken -20.3% -1a(ffe6)
0x02 - Frog -40.6% -34(ffcc)
0x01 - Critical -25% -20(ffe0)
0x005b: Current Statuses 4
0x80 - Poison -20.3% -1a(ffe6)
0x40 - Regen 19.5% 19(0019)
0x20 - Protect 19.5% 19(0019)
0x10 - Shell 19.5% 19(0019)
0x08 - Haste 14.8% 13(0013)
0x04 - Slow -30.5% -27(ffd9) 0 if Confusion/Charm/Blood Suck
0x02 - Stop -70.3% -5a(ffa6) 0 if Confusion/Charm/Blood Suck
0x01 - Wall 50% 40(0040)
0x005c: Current Statuses 5
0x80 - Faith 4.7% 6(0006)
0x40 - Innocent -5.5% -7(fff9)
0x20 - Charm -50% -40(ffc0) (+1 / 4 if slow/stop/sleep/don't move/act/)
0x10 - Sleep -30.5% -27(ffd9) 0 if Confusion/Charm/Blood Suck
0x08 - Don't Move -30.5% -27(ffd9) 0 if Confusion/Charm/Blood Suck
0x04 - Don't Act -50% -40(ffc0) 0 if Confusion/Charm/Blood Suck
0x02 - Reflect 19.5% 19(0019)
0x01 - Death Sentence -80.5% -67(ff99)
42
PSX FFT Hacking / Re: ASM Requests
December 24, 2016, 09:20:08 pm
Hey guys, can any of you do me a quick little favor? It's super easy.


Crack open FFTPatcher
Go to Attack (0000) under Abilities
Go to the AI Behavior and select "Stop at Obstacle"
Give yourself a reliable way of Berserking yourself
Give yourself a ranged weapon
Patch it
See if the AI acts retarded anymore

...It can't have been that easy, right? Right?
43
PSX FFT Hacking / Re: Dokurider's Custom AoEs
December 21, 2016, 11:32:59 pm
I just confirmed that the AI will hit itself with it's own weapon, (if it's allowed to) if it heals them.
44
PSX FFT Hacking / Re: Dokurider's Custom AoEs
December 21, 2016, 05:33:38 pm
k, I'm back

I'll add pictures later on.



Cone AoE (v2)
Version 1.09
Creates Cone AoE. Enable this on any skill by flagging both Linear and Tri Direction AoE flags. Uses Kanji Space. Uses lines 0x1557fc - 0x155b04. 194 Lines. Does not work with Direct/Stop at Obstacle or Weapon Range, as neither does Linear/Tri AoE. Does not work with Auto Target, so give it a non-zero range. Don't even think about targeting yourselves, you derps. Designed to emulate Linear/Tri's behaviors including being dependent on the caster panel to be generated.
0017bb24: Targeting Routine (0x0017b874)

0017bb24: 06000234 ori r2,r0,0x0006
0017bb28: FF55050C jal 0x001557fc
0017bb2c: 00000000 nop
0017bb30: 02004014 bne r2,r0,0x0017bb3c
0017bb34: 1000A427 addiu r4,r29,0x0010 Needed for Ally/Enemy Targeting Routine
0017bb38: 0C56050C jal 0x00155830 Cone Generation Routine
0017bb3c: 00000000 nop
0017bb40: 0300A010 beq r5,r0,0x0017bb50 Branch if not flagged as Linear/Tri
0017bb44: C0003032 andi r16,r17,0x00c0
0017bb48: 9AEF050C jal 0x0017be68 Linear/Tri Generation Routine
0017bb4c: 00000000 nop

========================================================

Morbol Virus Depth Check (0x00179204)

00179214: 00004126 addiu r1,r18,0x0000 Saves Target Tile Vertical

========================================================

001557fc: Parse Linear AoE Flags Routine

001557fc: 06002632 andi r6,r17,0x0006 False if flagged as Cone (Linear + Tri)
00155800: 09004610 beq r2,r6,0x00155828 Branch if Cone AoE
00155804: 00000234 ori r2,r0,0x0000 r2 = Cone AoE
00155808: 02000234 ori r2,r0,0x0002
0015580c: 0600C210 beq r6,r2,0x00155828 Branch if Tri Linear AoE
00155810: 03000534 ori r5,r0,0x0003 r5 = 3 (Tri Linear Value)
00155814: 04000234 ori r2,r0,0x0004
00155818: 0300C210 beq r6,r2,0x00155828 Branch if Linear AoE
0015581c: 01000534 ori r5,r0,0x0001 r5 = 1 (Linear Value)
00155820: FF000234 ori r2,r0,0x00ff r2 = -1 (No Value)
00155824: 00000534 ori r5,r0,0x0000
00155828: 0800E003 jr r31
0015582c: 00002F24 addiu r15,r1,0x0000 r15 = Target Tile Vertical

========================================================================

00155830: AoE Flagging Routine

r5 = IsLinear/Tri? (1,3,0)
r15 = Target Tile Vertical
r16 = Unit Y
r17 = Unit X
r18 = Target X
r19 = Direction
r20 = Target Y
r21 = Vertical


00155830: C0FFBD27 addiu r29,r29,-0x0040 Pointer Memory - 40
00155834: 1000A527 addiu r5,r29,0x0010
00155838: 3C00BFAF sw r31,0x003c(r29)
0015583c: 3800B4AF sw r20,0x0038(r29)
00155840: 3400B3AF sw r19,0x0034(r29)
00155844: 3000B2AF sw r18,0x0030(r29)
00155848: 2C00B1AF sw r17,0x002c(r29)
0015584c: 8B78010C jal 0x0005e22c Transfer Attacker/Self ID Routine
00155850: 2800B0AF sw r16,0x0028(r29)
00155854: 1000A393 lbu r3,0x0010(r29) Load Attacker/Self ID
00155858: 1C00B287 lh r18,0x001c(r29) Load Target X
0015585c: 2000B487 lh r20,0x0020(r29) Load Target Y
00155860: 01000234 ori r2,r0,0x0001 r2 = 1
00155864: 1980013C lui r1,0x8019
00155868: F8F422AC sw r2,-0x0b08(r1) Linear Attack = True
0015586c: C0100300 sll r2,r3,0x03
00155870: 23104300 subu r2,r2,r3
00155874: 80110200 sll r2,r2,0x06
00155878: 1980033C lui r3,0x8019
0015587c: CC086324 addiu r3,r3,0x08cc Load Unit Data
00155880: 21104300 addu r2,r2,r3
00155884: 47005190 lbu r17,0x0047(r2) Load Unit's X
00155888: 48005090 lbu r16,0x0048(r2) Load Unit's Y

0015588c: 2A103202 slt r2,r17,r18
00155890: 04004010 beq r2,r0,0x001558a4 Branch if Unit X >= Target X is not true
00155894: 01001334 ori r19,r0,0x0001 Direction = +X
00155898: 5856050C jal 0x00155960 Cone Generation Routine
0015589c: 00000000 nop
001558a0: 3A560508 j 0x001558e8
001558a4: 2A105102 slt r2,r18,r17
001558a8: 04004010 beq r2,r0,0x001558bc Branch if Target X >= Unit X is not true
001558ac: FF001334 ori r19,r0,0x00ff Direction = -X
001558b0: 5856050C jal 0x00155960 Cone Generation Routine
001558b4: 00000000 nop
001558b8: 3A560508 j 0x001558e8
001558bc: 2A101402 slt r2,r16,r20
001558c0: 04004010 beq r2,r0,0x001558d4 Branch if Unit Y >= Target Y is not true
001558c4: 00011334 ori r19,r0,0x0100 Direction = +Y
001558c8: 5856050C jal 0x00155960 Cone Generation Routine
001558cc: 00000000 nop
001558d0: 3A560508 j 0x001558e8
001558d4: 2A109002 slt r2,r20,r16
001558d8: 18004010 beq r2,r0,0x0015593c End if Target Y >= Unit Y is not true
001558dc: 00FF1334 ori r19,r0,0xff00 Direction = -Y
001558e0: 5856050C jal 0x00155960 Cone Generation Routine
001558e4: 00000000 nop

001558e8: 21200000 addu r4,r0,r0 Tile Counter = 0
001558ec: 1980033C lui r3,0x8019
001558f0: D82D6324 addiu r3,r3,0x2dd8
001558f4: 01006290 lbu r2,0x0001(r3) Load Tile Targeted? Flag
001558f8: 00000000 nop
001558fc: 03004014 bne r2,r0,0x0015590c Branch if Tile is Targeted?
00155900: 00000000 nop
00155904: 44560508 j 0x00155910
00155908: 000060A0 sb r0,0x0000(r3) AoE = 0
0015590c: 010060A0 sb r0,0x0001(r3) Tile Targeted? = False
00155910: 01008424 addiu r4,r4,0x0001 Counter ++
00155914: 00028228 slti r2,r4,0x0200
00155918: F6FF4014 bne r2,r0,0x001558f4 Branch if Counter < 0x200
0015591c: 05006324 addiu r3,r3,0x0005 Pointer += 5

00155920: 00000000 nop [deleted line]
00155924: 2C00B18F lw r17,0x002c(r29)
00155928: FF00E431 andi r4,r15,0x00ff
0015592c: 2128A002 addu r5,r21,r0
00155930: 42311100 srl r6,r17,0x05
00155934: A9E4050C jal 0x001792a4 check vertical tolerance + if tiles can be chosen
00155938: 0100C630 andi r6,r6,0x0001 Top Down Targeting Flag

0015593c: 3C00BF8F lw r31,0x003c(r29)
00155940: 3800B48F lw r20,0x0038(r29)
00155944: 3400B38F lw r19,0x0034(r29)
00155948: 3000B28F lw r18,0x0030(r29)
0015594c: 2C00B18F lw r17,0x002c(r29)
00155950: 2800B08F lw r16,0x0028(r29)
00155954: 4000BD27 addiu r29,r29,0x0040 Pointer + 40
00155958: 0800E003 jr r31
0015595c: 25280000 or r5,r0,r0 Is Linear/Tri? = False

====================================================================



00155960: Cone Attack Tile Calculation

r4 = Tile Coordinate
r5 = Secondary Tile Coordinate
r6 = AoE
r7 = Row Counter
r8 = 0xffffffff (Also used as Temporary High Tile Coordinate)
r9 = Row Width Counter
r10 = 0x0001 (True)
r16 = Unit Y (Treated as Current Y)
r17 = Unit X (Treated as Current X)
r18 = Target X
r20 = Target Y
r19 = Direction


00155960: 21380000 addu r7,r0,r0 Initialize Row Counter
00155964: 19800B3C lui r11,0x8019
00155968: D82D6B25 addiu r11,r11,0x2dd8 r11 = Tile Data Pointer
0015596c: 01000A34 ori r10,r0,0x0001 r10 = True
00155970: 3400A68F lw r6,0x0034(r29) r6 = AoE
00155974: 62004006 bltz r18,0x00155af0 Branch if X is negative
00155978: 0E80033C lui r3,0x800e
0015597c: 9C4E6390 lbu r3,0x4e9c(r3) Load Map Max X
00155980: 00000000 nop
00155984: 2A104302 slt r2,r18,r3
00155988: 5D004010 beq r2,r0,0x00155af0 Branch if X >= Max X
0015598c: 00000000 nop
00155990: 5B008006 bltz r20,0x00155af0 Branch if Y is negative
00155994: 0E80023C lui r2,0x800e
00155998: A04E4290 lbu r2,0x4ea0(r2) Load Map Max Y
0015599c: 00000000 nop
001559a0: 2A108202 slt r2,r20,r2
001559a4: 56004010 beq r2,r0,0x00155af0 Branch if Y >= Max Y

001559a8: 18000302 mult r16,r3 Y * Max X
001559ac: 12100000 mflo r2
001559b0: 21205100 addu r4,r2,r17 Tile ID = Y * Max X + X

<-Row Length Main Loop Starts Here->
========================
X Direction Sub Routine
========================

001559b4: 0E80083C lui r3,0x800e
001559b8: FF000834 ori r8,r0,0x00ff r8 = -1
001559bc: 24106802 and r2,r19,r8 Get X Direction from Direction Variable
001559c0: 0F004010 beq r2,r0,0x001559f0 Branch to Y if no X Direction obtained
001559c4: 00000000 nop

-X Direction

001559c8: 05000215 bne r8,r2,0x001559d0 Branch if r2 =/= -X Direction
001559cc: FFFF2126 addiu r1,r17,0xffff Current X - 1
001559d0: 48002004 bltz r1,0x00155ae4 Proceed to Next Row if the current Target X = -1
001559d4: 00000000 nop
001559d8: 7D560508 j 0x001559f4 Go To Tile Coordinates Modify Function
001559dc: FFFF0224 addiu r2,r0,0xffff r2 = -1


+X Direction

001559e0: 9C4E6390 lbu r3,0x4e9c(r3) Load Map Max X
001559e4: 01002126 addiu r1,r17,0x0001 Current X + 1
001559e8: 42006110 beq r3,r1,0x00155ae4 End if current Target X is Max X
001559ec: 00000000 nop
001559f0: 01000220 addi r2,r0,0x0001 r2 = 1

001559f4: 20882202 add r17,r17,r2 Current Target X++
001559f8: 93560508 j 0x00155a4c Go to Row Generation Subroutine
001559fc: 20208200 add r4,r4,r2 Tile Coordinates is modified(+/-)

========================
Y Direction Sub Routine
========================

00155a00: 02121300 srl r2,r19,0x0008 Get Y Direction from Direction Variable
00155a04: 3E004010 beq r2,r0,0x00155af0 End if no Y Direction obtained
00155a08: FFFF0126 addiu r1,r16,0xffff Current Y - 1

-Y Direction

00155a0c: 06000215 bne r8,r2,0x00155a18 Branch if r2 =/= 0x00ff
00155a10: 00000000 nop

00155a14: 37002004 bltz r1,0x00155ae4 End Routine if the current Target Y = -1
00155a18: FFFF0224 addiu r2,r0,0xffff
00155a1c: 9C4E6390 lbu r3,0x4e9c(r3) Get Max X
00155a20: 91560508 j 0x00155a44 Jump to Modify Tile Coordinate Function
00155a24: 22180300 sub r3,r0,r3 r3 = -Max X (-Y)

+Y Direction

00155a28: A04E6390 lbu r3,0x4ea0(r3) Load Max Y
00155a2c: 01000126 addiu r1,r16,0x0001 Current Y + 1
00155a30: 30007010 beq r3,r16,0x00155ae4 Branch if current Target Y is greater than Max Y
00155a34: 00000000 nop
00155a38: 0E80033C lui r3,0x800e
00155a3c: 9C4E6390 lbu r3,0x4e9c(r3) Get Max X
00155a40: 01000234 ori r2,r0,0x0001

00155a44: 20800202 add r16,r16,r2 Current Target Y++
00155a48: 20208300 add r4,r4,r3 Tile Coordinates++

========================
Row Generation Subroutine
========================

What direction are we going?
If X direction, then make Y rows, and vice versa

r7 = Row Counter
r9 = Row Size Counter
r6 = AoE
r9 = r0 - r7
r9++ until r9 = r7
r7++ until r7 = r6

r20 = Target Y
r18 = Target X
r5 = Secondary Tile Coordinate

========================================================================================

00155a4c: 22480700 sub r9,r0,r7 Initialize Row Size Counter
00155a50: 25288000 or r5,r4,r0 Initialize Secondary Tile Coordinate
<-Row Size Subloop Begins Here->
00155a54: FF000334 ori r3,r0,0x00ff
00155a58: 24106302 and r2,r19,r3 Get X Direction from Direction Variable
00155a5c: 0E004010 beq r2,r0,0x00155a88 Branch if X Direction was not obtained
00155a60: 0E80033C lui r3,0x800e

Y Row

00155a64: 20100902 add r2,r16,r9
00155a68: 20004004 bltz r2,0x00155adc Branch if Y Size is negative
00155a6c: A04E6390 lbu r3,0x4ea0(r3) Load Max Y
00155a70: 00000000 nop
00155a74: 1F006210 beq r3,r2,0x00155ae4 Branch if Y Size = Max Y
00155a78: 00000000 nop
00155a7c: 0E80033C lui r3,0x800e
00155a80: 9C4E6390 lbu r3,0x4e9c(r3) Load Map Max X
00155a84: 00000000 nop
00155a88: 18006900 mult r3,r9 Max X * Row Size Counter
00155a8c: 12180000 mflo r3
00155a90: B0560508 j 0x00155ac0 Jump to Save Tile
00155a94: 20288300 add r5,r4,r3 Modify Secondary Tile Coordinate

X Row

00155a98: 02121300 srl r2,r19,0x0008 Get X Direction from Direction Variable
00155a9c: 18004010 beq r2,r0,0x00155af0 End if no X Direction obtained
00155aa0: 00000000 nop
00155aa4: 20102902 add r2,r17,r9
00155aa8: 10004004 bltz r2,0x00155adc Branch if X Size is negative
00155aac: 9C4E6390 lbu r3,0x4e9c(r3) Load Map Max X
00155ab0: 00000000 nop
00155ab4: 0F006210 beq r3,r2,0x00155ae4 Branch if X Size = Max X
00155ab8: 00000000 nop
00155abc: 20288900 add r5,r4,r9 Modify Secondary Tile Coordinate

Save Tile

00155ac0: 80100500 sll r2,r5,0x02 ID * 4
00155ac4: 21104500 addu r2,r2,r5 ID * 5
00155ac8: 21184B00 addu r3,r2,r11
00155acc: 00006AA0 sb r10,0x0000(r3) Store Low Tile's AoE = True
00155ad0: 01006AA0 sb r10,0x0001(r3) Store Low Tile Targeted? = True
00155ad4: 0001A824 addiu r8,r5,0x0100 Tile ID + 0x100
00155ad8: 80100800 sll r2,r8,0x02 ID * 4
00155adc: 21104800 addu r2,r2,r8 ID * 5
00155ae0: 21184B00 addu r3,r2,r11
00155ae4: 00006AA0 sb r10,0x0000(r3) Store High Tile's AoE = True
00155ae8: 01006AA0 sb r10,0x0001(r3) Store High Tile Targeted? = True
00155aec: D9FF2715 bne r9,r7,0x00155a44 Branch if Size Counter = Row Counter else loop
00155af0: 01002921 addi r9,r9,0x0001 Size Counter++
00155af4: 2210C700 sub r2,r6,r7
00155af8: AEFF401C bgtz r2,0x001559a4 Finish if Row Counter has exceeded AoE else loop
00155afc: 0100E724 addiu r7,r7,0x0001 Row Counter++
00155b00: 0800E003 jr r31
00155b04: 00000000 nop



"Arcing" AoE and Range
Version 1.1
Feeds AoE/Range generation through the Arc Range Routine (001798b0), creating an AoE/Range that gains size from height/2
Uses Ability Flags 1 Unknown Flags 0x80 and 0x40.
Removes and overwrites the coding otherwise attached to the Unknown Ability Flags (0017a6dc) known so far. Does not use Kanji Space.
0x80 - Arcing AoE
0x40 - Arcing Range
Old:

0017bac8: 00002821 addu r5,r0,r0
0017bacc: 26620001 addiu r2,r19,0x0001
0017bad0: a1020000 sb r2,0x0000(r8) store aoe + 1
0017bad4: 0c05e546 jal 0x00179518 Store surrounding panels AoE value
0017bad8: a0e20000 sb r2,0x0000(r7) store aoe + 1

New:
0017bac8: 0680053C lui r5,0x8006
0017bacc: 01006226 addiu r2,r19,0x0001
0017bad0: 000002A1 sb r2,0x0000(r8)
0017bad4: B7E9050C jal 0x0017a6dc Arc Range/AoE Routine


Old:

0017a43c: 0c05e546 jal 0x00179518 Calculate Tiles Hit by Ability
0017a440: 00002821 addu r5,r0,r0 r5 = 0

New:

0017a43c: B7E9050C jal 0x0017a6dc Arc Range/AoE Routine
0017a440: 0680053C lui r5,0x8006

Old:

0017a4a0: 324200c0 andi r2,r18,0x00c0 If Unknown Flags 0x80/0x40 (!!!)
0017a4a4: 0c05e497 jal 0x0017925c Clear Some stuff for Untargetable Terrain
0017a4a8: 00000000 nop
0017a4ac: 324200c0 andi r2,r18,0x00c0 If Unknown Flags 0x80/0x40 (!!!)
0017a4b0: 10400003 beq r2,r0,0x0017a4c0 Branch if False
0017a4b4: 02802021 addu r4,r20,r0 r4 = Caster Data
0017a4b8: 0c05e9b7 jal 0x0017a6dc Target Ally/Enemy with Range Routine
0017a4bc: 02402821 addu r5,r18,r0 r5 = Ability Flags 1
0017a4c0: 324200d0 andi r2,r18,0x00d0 If Unknown Flags 0x80/0x40 or Vertical Fixed
0017a4c4: 14400005 bne r2,r0,0x0017a4dc Branch if True

New:

0017a4a0: 00000000 nop
0017a4a4: 97E4050C jal 0x0017925c Clear Some stuff for Untargetable Terrain
0017a4a8: 00000000 nop [Deleted]
0017a4ac: 00000000 nop
0017a4b0: 00000000 nop
0017a4b4: 00000000 nop
0017a4b8: 00000000 nop
0017a4bc: 21208002 addu r4,r20,r0
0017a4c0: 10004232 andi r2,r18,0x0010
0017a4c4: 05004014 bne r2,r0,0x0017a4dc Branch if Vertical Fixed


Arc Range/AoE Routine

0017a6dc: F0FBA524 addiu r5,r5,0xfbf0
0017a6e0: 1200A287 lh r2,0x0012(r29)           r2 = Used Ability ID
0017a6e4: C0180200 sll r3,r2,0x03
0017a6e8: 23186200 subu r3,r3,r2
0017a6ec: 40180300 sll r3,r3,0x01
0017a6f0: 2128A300 addu r5,r5,r3
0017a6f4: 1880063C lui r6,0x8018
0017a6f8: A8A7DFAC sw r31,0xa7a8(r6) Save return address
0017a6fc: A8A7C280 lb r2,0xa7a8(r6) Load last two bytes of Return Address' instructions
0017a700: FF004230 andi r2,r2,0x00ff
0017a704: DC000334 ori r3,r0,0x00dc
0017a708: 0300A580 lb r5,0x0003(r5) Load Ability Flags 1
0017a70c: 14004314 bne r2,r3,0x0017a760 Branch if not from Targeting Routine (From AoE routine)
0017a710: 8000A230 andi r2,r5,0x0080
0017a714: 1D004010 beq r2,r0,0x0017a78c Branch if not Arc AoE
0017a718: 4CA7C324 addiu r3,r6,0xa74c
0017a71c: 2000AD93 lbu r13,0x0020(r29) r13 = Target Y
0017a720: 1C00AC93 lbu r12,0x001c(r29) r12 = Target X
0017a724: 0E80023C lui r2,0x800e
0017a728: D0FFBD27 addiu r29,r29,-0x0030
0017a72c: 2000B0AF sw r16,0x0020(r29)
0017a730: 2400B1AF sw r17,0x0024(r29)
0017a734: 2800A3AF sw r3,0x0028(r29) Save Return Address
0017a738: 3899C0AC sw r0,0x9938(r6) Remove Close Range Branch from Arc routine
0017a73c: 21184002 addu r3,r18,r0 r3 = Target Height
0017a740: 21886002 addu r17,r19,r0 r17 = AoE
0017a744: 39E6050C jal 0x001798e4 Calculate Arc AoE Routine (Jump to later on in the routine)
0017a748: A04E4290 lbu r2,0x4ea0(r2) r2 = Max Map Y
0017a74c: 1880023C lui r2,0x8018
0017a750: 4014033C lui r3,0x1440
0017a754: 27006324 addiu r3,r3,0x0027 Load instructions (14400027)
0017a758: 389943AC sw r3,0x9938(r2) Restore Close Range Branch from Arc Routine
0017a75c: E5E90508 j 0x0017a794 Exit Routine
0017a760: 4000A230 andi r2,r5,0x0040
0017a764: 09004010 beq r2,r0,0x0017a78c Branch if not Arc Range
0017a768: 25288000 or r5,r4,r0 r5 = Ability Range
0017a76c: 3899C0AC sw r0,0x9938(r6)
0017a770: 2CE6050C jal 0x001798b0 Calculate Arc Range Routine
0017a774: 25208002 or r4,r20,r0 r4 = Caster Unit Data
0017a778: 1880023C lui r2,0x8018
0017a77c: 4014033C lui r3,0x1440
0017a780: 27006324 addiu r3,r3,0x0027 Load instructions (14400027)
0017a784: E5E90508 j 0x0017a794
0017a788: 389943AC sw r3,0x9938(r2) Restore Close Range Branch from Arc Routine
0017a78c: 46E5050C jal 0x00179518 Store surrounding panels AoE value (Normal function)
0017a790: 21280000 addu r5,r0,r0
0017a794: 1880023C lui r2,0x8018
0017a798: A8A75F8C lw r31,0xa7a8(r2) Load old return address
0017a79c: 00000000 nop
0017a7a0: 0800E003 jr r31
0017a7a4: 00000000 nop
0017a7a8: 00000000 nop Return Address here



Reenables Unknown Flags 1 and 2
Speaking of the Unknown Ability Flags, this hack restores their functionality that was deliberately disabled by Square. Enables you to target any ally or any enemy on the map.
No notes because there really isn't much to it. It's literally a single line.


Weapon Range now accepts AoE
Version -1.0
I'm releasing this against my better judgement. Enables the use of Weapon Ranged AoE. It might also enable Direct/Stop at Obstacle AoE as well. Won't crash your game, but it's interactions with AoE might cause your brain to crash if I'm reading the Weapon Strike/Direct routines correctly. Still current doing research on the matter, but feel free to be a guinea pig.
0017af40: 0c05ed28 jal 0x0017b4a0 Invalidate AoE panels routine (In the Weapon Targeting Routine [0017ac90])
to
0017af40: 00000000 nop [deleted]

0017babc: 31220020 andi r2,r9,0x0020 Weapon Ranged check
0017bac0: 1440000e bne r2,r0,0x 0017bafc branch if so
to
0017bac0: 00000000 nop [deleted]



Clear Yellow Panels not occupied by a unit.
Version 2.0
Overwrites Morbol AoE Depth Routine. Takes the 255 AoE check and modifies it to target only tiles with units in them. Good for Random Fire Skills. Saves Ability ID to unused lines for future Ability ID hardcoding. Enable this on an ability by flagging it as a Math Skill.

Don't Target Empty Space Routine

====================================================================================================================================
Targeting/AoE Main Routine(0x0017b874)
====================================================================================================================================

Original Code:
0017b8d0: 90690003 lbu r9,0x0003(r3) Load ability flags 1
0017b8d4: 90710004 lbu r17,0x0004(r3) Load ability flags 2
0017b8d8: 90640006 lbu r4,0x0006(r3) Load ability flags 4

New Code
0017b8d4: lhu r17,0x0004(r3) Load Ability Flags 2 and 3

====================================================================================================================================

Original Code
0017bae4: 00113142 srl r6,r17,0x05 Parse down Ability Flag 2 to Top Down Targeting Flag

New Code
0017bae4: andi r6,r17,0x00e0 Parse Ability Flag 2 to Hit Ally/Enemy

====================================================================================================================================

Original Code
0017baec: 30c60001 andi r6,r6,0x0001 Keep Top Down Targeting Flag

New Code
0017baec: andi r6,r6,0x0020 Keep Top Down Targeting Flag

====================================================================================================================================

Original Code
0017baf4: 0c05e481 jal 0x00179204 moldball virus depth check
0017baf8: 00000000 nop

New Code
0017baf4: jal 0x00179204 moldball virus depth check
0017baf8: lui r2,0x8018

====================================================================================================================================

Original Code
0017b9fc: 326300ff andi r3,r19,0x00ff r3 = ability AoE
0017ba00: 340200ff ori r2,r0,0x00ff
0017ba04: 1462000c bne r3,r2,0x 0017ba38 Branch if ability AoE isn't 0xff
0017ba08: 00002021 addu r4,r0,r0
0017ba0c: 34050001 ori r5,r0,0x0001
0017ba10: 3c038019 lui r3,0x8019
0017ba14: 24632dd8 addiu r3,r3,0x2dd8
0017ba18: a0650000 sb r5,0x0000(r3) store highlight panel for targeting
0017ba1c: a0600001 sb r0,0x0001(r3) store panel not targeted
0017ba20: 24840001 addiu r4,r4,0x0001 Counter++
0017ba24: 28820200 slti r2,r4,0x0200 Do for all tiles
0017ba28: 1440fffb bne r2,r0,0x 0017ba18
0017ba2c: 24630005 addiu r3,r3,0x0005 tile counter++
0017ba30: 0805eebf j 0x 0017bafc skip following routine
0017ba34: 00000000 nop

New Code
0017b9fc: addu r4,r0,r0 Clear r4
0017ba00: andi r2,r17,0x4000 Get Math Skill Flag
0017ba04: lui r3,0x8018
0017ba08: addiu r3,r3,0xba28
0017ba0c: sh r0,0x0000(r3) Clear space
0017ba10: beq r2,r0,0x0017ba38 Branch if no Math Flag
0017ba14: nop
0017ba18: xori r17,r17,0x00c0 Add Ignore Ally/Enemy Flag if Math Skill (Reverses the effects of a later routine)
0017ba1c: sh r2,0x0000(r3) Jump to Tile Initialization
0017ba20: j 0x0017ba38 Save Math Skill Flag for later
0017ba24: nop
0017ba28: nop                           [save Math Flag here]
0017ba2c: nop [save Ability ID here]
0017ba30: nop
0017ba34: nop                             

====================================================================================================================================

Original Code
0017bb40: 323000c0 andi r16,r17,0x00c0 Keep Hit Ally/Enemy Flags

New Code
0017bb40: andi r16,r17,0x40c0 Keep Hit Ally/Enemy and Math Skill Flag

====================================================================================================================================

Original Code
0017bb60: 3a6700ff xori r7,r19,0x00ff
0017bb64: 0c05ef1e jal 0x0017bc78 Hit ally/enemy routine
0017bb68: 2ce70001 sltiu r7,r7,0x0001

New Code
0017bb60: lui r7,0x8018
0017bb64: jal 0x0017bc78 Hit ally/enemy routine
0017bb68: addiu r7,r7,0xba28 Load Math Skill Flag

====================================================================================================================================
Check if Ally/Enemy can be targeted Routine(0x0017bc78)
====================================================================================================================================

Original Code
0017bc90: 00e0b821 addu r23,r7,r0 r23 = 255 AoE check

New Code
0017bc90: lhu r23,0x0000(r7) r23 = Math Flag

====================================================================================================================================

Original Code
0017bd68: 32e200ff andi r2,r23,0x00ff
0017bd6c: 1440000c bne r2,r0,0x 0017bda0 Branch if AoE = 255
0017bd70: 00008021 addu r16,r0,r0 Tile Counter = 0
0017bd74: 34040001 ori r4,r0,0x0001 Tile Targeted? = True
0017bd78: 3c038019 lui r3,0x8019
0017bd7c: 24632dd8 addiu r3,r3,0x2dd8

New Code
0017bd68: addu r16,r0,r0 Tile Counter = 0
0017bd6c: ori r4,r0,0x0001 Tile Targeted? = True
0017bd70: jal 0x0017921c
0017bd74: nop
0017bd78: bne r23,r2,0x0017bda0
0017bd7c: nop

====================================================================================================================================
Morbol Virus Depth Check (0x00179204)
====================================================================================================================================

Original Code
00179204: 00042400 sll r4,r4,0x10
00179208: 00042403 sra r4,r4,0x10
0017920c: 34020149 ori r2,r0,0x0149 r2 = Moldball Virus
00179210: 14820010 bne r4,r2,0x 00179254 Branch if ID != Moldball Virus
00179214: 00000000 nop
00179218: 00002821 addu r5,r0,r0 Counter = 0
0017921c: 3c048019 lui r4,0x8019
00179220: 24842dd8 addiu r4,r4,0x2dd8 r4 = ? Tile Data Pointer
00179224: 3c038019 lui r3,0x8019
00179228: 2463f8cc addiu r3,r3,0xf8cc r3 = Tile Data Pointer
0017922c: 90620003 lbu r2,0x0003(r3) Load Tile's Halves + Depth
00179230: 00000000 nop
00179234: 304200e0 andi r2,r2,0x00e0
00179238: 10400002 beq r2,r0,0x 00179244 Branch if Depth > 1
0017923c: 24630008 addiu r3,r3,0x0008 Tile Data Pointer += 8
00179240: a0800000 sb r0,0x0000(r4) Store AoE = 0
00179244: 24a50001 addiu r5,r5,0x0001 Counter ++
00179248: 28a20200 slti r2,r5,0x0200
0017924c: 1440fff7 bne r2,r0,0x 0017922c Branch if Counter < 0x200
00179250: 24840005 addiu r4,r4,0x0005 ? Tile Data Pointer += 5
00179254: 03e00008 jr r31
00179258: 00000000 nop

New Code
r3 = Tile Data (0x80192dd8)
r4 = True
r23 = Math Skill

00179204: addiu r2,r2,0xba2c
00179208: sll r4,r4,0x10 Code still needs a parsed Ability ID
0017920c: sra r4,r4,0x10
00179210: sh r4,0x0000(r2) Save Ability ID to (0x0017ba28)(For some future code)
00179214: nop Must be empty for another routine I made
00179218: jr r31
0017921c: lui r3,0x8019
00179220: beq r23,r0,0x00179254 Exit if no Math Skill
00179224: addiu r3,r3,0x2dd8
00179228: lbu r2,0x0000(r3) Load AoE saved on Tile
0017922c: lbu r20,0x0002(r3) Load Unit ID
00179230: sltiu r2,r2,0x0001 True if No AoE
00179234: sltiu r20,r20,0x0001 True if No Unit ID
00179238: addu r2,r2,r20
0017923c: bne r2,r0,0x179248 Do not Target Panel if panel does not have a unit on it and isn't apart of AoE
00179240: addiu r16,r16,0x0001 Tile Counter++
00179244: sb r4,0x0001(r3) Target Tile Panel
00179248: slti r2,r16,0x0200
0017924c: bne r2,r0,0x00179228 Loop for all 0x200 panels
00179250: addiu r3,r3,0x0005 Tile ID++
00179254: jr r31
00179258: ori r2,r0,0x4000

====================================================================================================================================



Enable Attacks on Yourself (Strike/Lunge Weapon)
Version 0.0
Allows units to target themselves with Attack. Only works with Strike/Lunge flagged Weapons.
Attack Self with Weapon Description

Original Code:

0017a598: a0800000 sb r0,0x0000(r4) Remove Caster Panel from targeting


New Code:

0017a598: 00000000 nop Code is deleted




Original Code:

0017a5a0: a0600000 sb r0,0x0000(r3) Remove High Caster Panel from targeting


New Code:

0017a5a0: 00000000 nop Code is deleted


Current Issues:

*This hack only applies to Strike/Lunge Weapons. Ranged units currently cannot attack themselves.


Notes:

Healing weapons do indeed heal on self attack.

HP Drain weapons also absorbs on self dealt damage.



Caster is always apart of AoE
Version -1.0
Removes the code from Unknown Flag 1 and 2 (0x80 and 0x40) of Ability Flags 1. This hack makes it so an ability will always target (make a yellow square under) the caster in addition to the targeted panel or panels. Enable this property with Unknown Flag 1. Unknown Flag 2 is non-functional. I can also upload an alternate version that checks for Ability IDs instead if requested.
0017bb04: 00021880 sll r3,r2,0x02
0017bb08: 00621821 addu r3,r3,r2
0017bb0c: 3c128019 lui r18,0x8019
0017bb10: 26522dd8 addiu r18,r18,0x2dd8
0017bb14: 32220001 andi r2,r17,0x0001

to

0017bb0c: andi r4,r9,0x0080 Look for Flag 1
0017bb10: jal 0x0017a6dc Always Target Caster Routine
0017bb14: lui r18,0x8019


0017a6dc: beq r4,r0,0x0017 Branch if Target Caster
0017a6e0: addiu r18,r18,0x2dd8 Load Map Data
0017a6e4: ori r2,r0,0x0001 Target Caster = True
0017a6e8: addu r3,r3,r18 r3 = Caster Tile
0017a6ec: sb r2,0x0000(r3) Target Caster Tile
0017a6f0: j 0x0017a6fc Exit Subroutine
0017a6f4: andi r2,r17,0x0001 Check Ability Flag 1 for Ignore Caster
0017a6f8: ori r2,r0,0x0000 Ignore Caster Tile = False
0017a6fc: jr r31
0017a700: nop
0017a704:
0017a708:
0017a70c:
0017a710:
0017a6dc:
0017a6dc:



F_MA Damage formula accepts Weapon Elemental (for one ability)
Version -1.2
Faith Magical Damage Formula accepts Weapon Elemental when ability ID = 165(Currently Maelstrom in Arena).
00185ffc: 3c028019 lui r2,0x8019
00186000: 8c422d94 lw r2,0x2d94(r2) Load Attacker's Data
00186004: 3c038019 lui r3,0x8019
00186008: 906338f7 lbu r3,0x38f7(r3) Load Abilities Element
0018600c: 90420071 lbu r2,0x0071(r2) Load Attacker's Elemental Strenghtened
00186010: 00000000 nop
00186014: 00431024 and r2,r2,r3
00186018: 1040000c beq r2,r0,0x0018604c Branch if Abilities Element isn't being powered
0018601c: 00000000 nop
00186020: 3c038019 lui r3,0x8019
00186024: 846338ce lh r3,0x38ce(r3) Load XA
00186028: 00000000 nop
0018602c: 00031080 sll r2,r3,0x02 XA * 4
00186030: 00431021 addu r2,r2,r3 XA * 5
00186034: 04410002 bgez r2,0x00186040 Branch if XA > 0
00186038: 00000000 nop
0018603c: 24420003 addiu r2,r2,0x0003 XA + 3
00186040: 00021083 sra r2,r2,0x02 XA * 5 / 4 (increase XA by 25%)
00186044: 3c018019 lui r1,0x8019
00186048: a42238ce sh r2,0x38ce(r1) Store new XA
0018604c: 03e00008 jr r31
00186050: 00000000 nop

========================================================================================================

00185ffc: 3c028019 lui r2,0x8019
00186000: 8c422d94 lw r2,0x2d94(r2) Load Attacker's Data
00186004: 3c038019 lui r3,0x8019
00186008: 906338f7 lbu r3,0x38f7(r3) Load Abilities Element
0018600c: 90420071 lbu r2,0x0071(r2) Load Attacker's Elemental Strenghtened
00186010: 00000000 nop
00186014: 00431024 and r2,r2,r3

to

11EFFC(+67000):
1580013C lui r1,0x8015
FC573FAC sw r31,0x57fc(r1)
0056050C jal 0x00155800
00000000 nop
25802000 or r16,r1,r0
1580013C lui r1,0x8015
24108300 and r2,r4,r3
1040000c beq r2,r0,0x0018604c Branch if Abilities Element isn't being powered
FC573F8C lw r31,0x57fc(r1)

...

00187010: 3c108019 lui r16,0x8019
00187014: 921038f7 lbu r16,0x38f7(r16)

to

120010(+67000):
0056050C jal 0x00155800
00000000 nop

...

Weapon Ele for F_MA damage Routine (0x1557fc)
EE7FC(+67000)
00000000 nop
1980013C lui r1,0x8019
D6382394 lhu r3,0x38d6(r1) Load Ability ID
942D248C lw r4,0x2d94(r1) Load Attacker's Data
65010134 ori r1,r0,0x0165
03006114 bne r3,r1,0x00155820 Branch if not the correct Ability ID
1980013C lui r1,0x8019
09560508 j 0x155824
04392390 lbu r3,0x3904(r1) Load Weapon's Element
F7382390 lbu r3,0x38f7(r1) Load Abilities Element
71008490 lbu r4,0x0071(r4) Load Attacker's Elemental Strengthened
25080002 or r1,r16,r0
25806000 or r16,r3,r0
0800E003 jr r31
00000000 nop





As always, the XMLs are attached to this post and notes are provided in spoilers above. Make sure you are using the latest version of FFTPatcher, or at least 489 or later. Let me know if you find any bugs, contacting me through this site or finding me on Steam.

EDIT: Thanks Firefox for crashing and wiping out my message, I'm switching back to Opera after this.
45
FFT Arena / Re: Dancer Skill Set Rework?
September 08, 2016, 09:14:19 pm
I'm going to reproposition this Wiznaibus idea I had and FDC refined:

Wiznaibus deals 10% curHP (that's current HP for the easily alarmed) damage. What this does is make Wiznaibus effective by itself but ineffective when stacked. Have some math:

1st: 100% HP * 90% = 90%
2nd: 90% HP * 90% =  81%
3rd: 72.9%
4th: 65.61%
5th: 59.049%
6th: 53.1441%
7th: 47.82969%
8th: 43.046721%

As you can see, it rapidly takes off HP initially, but falls off hard. This creates pressure on teams and has an effect without being directly lethal. It would also take ages for a Wiznaibus spam team to actually bring a team down, and most importantly, it is equally effective to all units, squishy or tough. So to summarize:

Wiznaibus: 0 Range, 255 AoE and Vertical, 6 CT, 5 MP, 100% Hit, 10% curHP + PA damage, Enemy Only
46
Hmm, I seem to have made a typo on Bizen Missile II. She was supposed to have a Murasame. Well in any case, Gatebuster does have a point, lower range = better berserk usage, with 1 Range being the least threatening to your team. This is why Melee Berserkers have been the most practical build in Arena's history.

It's rather infuriating that an otherwise decent team loses because of deliberately coded stupidity. Given all of our recent advances in ASM and documentation of FFT's code, it's more and more of a reality that we can even fix this idiocy. It's not quite there yet, because the AI routines are even still relatively undocumented because they are scary, possibly running on magic, and most of all, are very confusing.

In any case, good luck on your next matches, Andante. Hopefully, your Gunner will do something besides shoot his own teammates and the wall.
47
Well that's too bad Skip, I was looking forward to it.
48
FFT Arena / Re: FFT Arena Season 5 Registration
August 21, 2016, 01:20:59 pm
Submitted.
49
FFT Arena / Re: FFT Arena Season 5 Registration
August 16, 2016, 11:56:07 pm
Creating a team, will try to have it submitted by Friday.
50
FFT Arena / Re: Official names for MP poison and regen
August 02, 2016, 12:32:00 pm
MP Regen could be Mist. Sorta ties into FFXII lore. But Refresh is good, is okay, I like.

Hex though... My association is different: I keep thinking about the polymorph spell in DOTA 2. Leak could be a good name.
51
I support a pairing tourney with swiss rules because swiss would allow said newcomers to learn more, as opposed to being chewed up and spit out by the veterans.
52
Don't we usually do SCC tournies in the winter? Of course I say that with only 2 SCCs done so far.
53
FFT Arena / Re: Arena battle videos and discussion
July 28, 2016, 08:17:03 am
Ugh, Leg Aim is so disgusting now. Also I might have to increase the team speed to 9. Or maybe just my Item Dancers.
54
FFT Arena / Re: Arena battle videos and discussion
July 26, 2016, 07:30:04 pm
Well shoot, it looks like I took the Nameless Dance bait. All I wanted was some Oil.
55
Looks good guys. Keep up the good work.
56
The Lounge / Re: How to save money
December 16, 2014, 02:04:39 pm
Sorry Ryqo, but I'll just stick to canned soup.
Speaking of:

  • Buy Canned Soup. It's cheap, comes in wide, wide varieties (so you're not eating the same thing over and over again, see Ramen Noodles) and savory. All you need is a container and a microwave to cook it in. Oh and a can opener (some come with an easy open top, though). You can buy the basic for under a dollar, or for 1.50-ish, you can buy the Campbell's Chunky varieties or Progressive cans.

  • You'd be surprised what you can fix on your own with a little bit of google searching and the right tools. A screwdriver set, wrench, and duct tape are minimal requirements. Note that you might have to torrent some manuals to do so.

  • In that vein, car repair manuals (known as Haynes Manuals) are surprising cheap and easy to understand if you're mechanically inclined, and you probably are given the nature of this site. Combined with some tools (socket wrenches are a must, some bolts can be insanely difficult or impossible without them) and some willingness to get down and dirty, you can troubleshoot and replace some parts yourself. Hell, some manuals are online on Haynes' own website or you can torrent them.

57
FFT Arena / Re: Arena Team Battle
November 20, 2014, 09:59:40 pm
Hurricane
Male
Serpentarius
70
45
Monk
Steal
HP Restore
Martial Arts
Move +1
FS Bag

Chakra Band
Power Sleeve
Germinas Boots

Spin Fist, Repeating Fist, Wave Fist, Stigma Magic, Chakra, Revive
Heretic
58
FFT Arena / Re: Arena battle videos and discussion
November 08, 2014, 06:53:10 pm
Guys, please stop giving Mimes magic secondaries. They interrupt their own charge spells. You're just shooting yourselves in the foot.
59
FFT Arena / Re: Arena battle videos and discussion
October 28, 2014, 03:45:59 am
This is a very good team, Andante49. I don't feel bad losing to you at all, even if this was my team's debut match. Excellent use of Spellbreaker and PA Save+Lorestribute combo. Feel kinda bad that Slow 2 didn't get CM'd like it was supposed to, but eh, them's the breaks.
60
FFT Arena / Re: FFT Arena: Balance Discussion Thread
October 26, 2014, 04:12:05 pm
Quote2. When a critical unit is the last unit standing OR when all units on the team are in critical or dead, the AI switches into attack mode despite its critical status. At least that is my experience with it.


IF it's the last unit standing. Otherwise, you have the perfect AI bait loop, all with just one weapon, and you know that the AI prioritizes units in critical. It doesn't need to do anything else, just turn burning itself is good enough. Balance just took it to a whole new level. And there is nothing one can do about it except hope he's the last unit your team focuses on or breaking the Phoenix Blade.

You already can make yourself Poison Immune with Platina Helmet and Diamond Armlet and in fact, you have to if you don't want to get shut down by Hawk's Eye and Kiyomori and the like. Making Phoenix Blade Immune: Poison would have been even more broken by making even safer to abuse.