Set chosen ability/target for AI status

From Final Fantasy Hacktics Wiki
Revision as of 22:56, 6 March 2013 by Choto (talk | contribs) (Created page with " Pick ability/target for berserk/confuse/chicken/bloodsuck 001971b8: 3c02801a lui r2,0x801a 001971bc: 90420d7b lbu r2,0x0d7b(r2) 001971c0: 27bdffd8 addiu r29,r29,0xffd8 00...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Pick ability/target for berserk/confuse/chicken/bloodsuck
001971b8: 3c02801a lui r2,0x801a
001971bc: 90420d7b lbu r2,0x0d7b(r2)
001971c0: 27bdffd8 addiu r29,r29,0xffd8
001971c4: afb3001c sw r19,0x001c(r29)
001971c8: 3c13801a lui r19,0x801a
001971cc: 2673f3c4 addiu r19,r19,0xf3c4
001971d0: afbf0020 sw r31,0x0020(r29)
001971d4: afb20018 sw r18,0x0018(r29)
001971d8: afb10014 sw r17,0x0014(r29)
001971dc: 10400008 beq r2,r0,0x 00197200		branch if 0x801a0d7b = 0
001971e0: afb00010 sw r16,0x0010(r29)
if not:
001971e4: 3c02801a lui r2,0x801a
001971e8: 90420032 lbu r2,0x0032(r2)		load byte
001971ec: 00000000 nop
001971f0: 1040000c beq r2,r0,0x 00197224		branch to chicken if = 00
001971f4: 00000000 nop
001971f8: 08065cb9 j 0x 001972e4				else, branch to movement calculation
001971fc: 00000000 nop
00197200: 3c03801a lui r3,0x801a
00197204: 8c630bbc lw r3,0x0bbc(r3)			load acting units data
00197208: 3c01801a lui r1,0x801a
0019720c: a02001f1 sb r0,0x01f1(r1)
00197210: 9064005a lbu r4,0x005a(r3)		load status
00197214: 00000000 nop
00197218: 30820004 andi r2,r4,0x0004
0019721c: 10400011 beq r2,r0,0x 00197264		branch if not chicken
<Chicken>
00197220: 00000000 nop
00197224: 0c066672 jal 0x 001999c8
00197228: 00000000 nop
0019722c: 2403ffff addiu r3,r0,0xffff
00197230: 14430004 bne r2,r3,0x 00197244
00197234: 266403b4 addiu r4,r19,0x03b4
00197238: a2600c6e sb r0,0x0c6e(r19)
0019723c: 08065d46 j 0x 00197518
00197240: 2402ffff addiu r2,r0,0xffff
00197244: 0c066ade jal 0x 0019ab78
00197248: 34050240 ori r5,r0,0x0240
0019724c: 340400ff ori r4,r0,0x00ff
00197250: 0c065a4f jal 0x 0019693c			some map stuff
00197254: 34050001 ori r5,r0,0x0001
00197258: 8e620cc4 lw r2,0x0cc4(r19)
0019725c: 08065ccb j 0x 0019732c
00197260: a26017fc sb r0,0x17fc(r19)
	</Chicken>
00197264: 90630059 lbu r3,0x0059(r3)
00197268: 00000000 nop
0019726c: 30620004 andi r2,r3,0x0004
00197270: 10400031 beq r2,r0,0x 00197338		branch if not blood suck
	<Blood Suck>
00197274: 00000000 nop
00197278: 0c066449 jal 0x 00199124			calculate physical target
0019727c: 00002021 addu r4,r0,r0
00197280: 00409021 addu r18,r2,r0
00197284: 26711770 addiu r17,r19,0x1770
00197288: 3c02801a lui r2,0x801a
0019728c: 904201f2 lbu r2,0x01f2(r2)		load acting unit ID?
00197290: 96631770 lhu r3,0x1770(r19)
00197294: 00021280 sll r2,r2,0x0a 
00197298: 00621825 or r3,r3,r2
0019729c: a6631770 sh r3,0x1770(r19)		store shifted acting unit ID?
Berserk jumps here too
	<Clear targetable unit list>
001972a0: 0c06561e jal 0x 00195878			AI ability setting
001972a4: 02202021 addu r4,r17,r0
001972a8: 34100014 ori r16,r0,0x0014		CLEAR TARGETABLE LIST
001972ac: 26620014 addiu r2,r19,0x0014		r2 = AI data + 0x14
001972b0: a0400c8d sb r0,0x0c8d(r2)			clear byte
001972b4: 2610ffff addiu r16,r16,0xffff		counter--
001972b8: 0601fffd bgez r16,0x 001972b0
001972bc: 2442ffff addiu r2,r2,0xffff		address--
	</Clear targetable unit list>
001972c0: 02721821 addu r3,r19,r18			8019f3c4 + chosen targets ID
001972c4: 34020001 ori r2,r0,0x0001
001972c8: 0c065d4e jal 0x 00197538			AI ability setting
001972cc: a0620c8d sb r2,0x0c8d(r3)			set unit targetable
001972d0: 14400091 bne r2,r0,0x 00197518		branch to end if return != 0
001972d4: 34020001 ori r2,r0,0x0001
Validation
001972d8: 02402021 addu r4,r18,r0
001972dc: 0c067ca9 jal 0x 0019f2a4			transfer unit coordinates to AI
001972e0: 26650c74 addiu r5,r19,0x0c74		
001972e4: 0c06653e jal 0x 001994f8			Movement calculations?
001972e8: 26640c74 addiu r4,r19,0x0c74
001972ec: 2403ffff addiu r3,r0,0xffff
001972f0: 14430005 bne r2,r3,0x 00197308		branch if can't move to target?
001972f4: 3c047fff lui r4,0x7fff
001972f8: 34020001 ori r2,r0,0x0001
001972fc: a2620c6e sb r2,0x0c6e(r19)		set able to move to target?
00197300: 08065d46 j 0x 00197518				branch to end
00197304: 2402ffff addiu r2,r0,0xffff		return 0xffff (success?)
????
00197308: 3484ffff ori r4,r4,0xffff
0019730c: 0c065a4f jal 0x 0019693c			some map checks
00197310: 34050001 ori r5,r0,0x0001
00197314: 92620e2d lbu r2,0x0e2d(r19)		load ??
00197318: 00000000 nop
0019731c: 00021080 sll r2,r2,0x02			??*4
00197320: 00531021 addu r2,r2,r19			AI data + ??*4
00197324: 8c420cc4 lw r2,0x0cc4(r2)			load ??
00197328: a26017fc sb r0,0x17fc(r19)
0019732c: a2601805 sb r0,0x1805(r19)
00197330: 08065d45 j 0x 00197514
00197334: ae621800 sw r2,0x1800(r19)		store ??
00197338: 30620010 andi r2,r3,0x0010
0019733c: 10400054 beq r2,r0,0x 00197490		branch if not Confusion
00197340: 30820008 andi r2,r4,0x0008
<Confusion>
00197344: 00002021 addu r4,r0,r0
00197348: 0c065f43 jal 0x 00197d0c			Set valid targets for turn consideration
0019734c: 340500ff ori r5,r0,0x00ff
00197350: 1040004b beq r2,r0,0x 00197480		branch if no targets found?
00197354: 00000000 nop
00197358: 00008021 addu r16,r0,r0
0019735c: 02708821 addu r17,r19,r16
00197360: a2200c8d sb r0,0x0c8d(r17)		clear targetable unit list byte
00197364: 0c065b23 jal 0x 00196c8c			check target type
00197368: 02002021 addu r4,r16,r0
0019736c: 14400004 bne r2,r0,0x 00197380		branch if not targetable
00197370: 26100001 addiu r16,r16,0x0001
00197374: 92220c78 lbu r2,0x0c78(r17)		load active unit list
00197378: 00000000 nop
0019737c: a2220c8d sb r2,0x0c8d(r17)		store targetable/nontargetable
00197380: 2a020015 slti r2,r16,0x0015
00197384: 1440fff6 bne r2,r0,0x 00197360		do for all units
00197388: 02708821 addu r17,r19,r16
0019738c: 00009021 addu r18,r0,r0
00197390: 00008021 addu r16,r0,r0
00197394: 92630e2f lbu r3,0x0e2f(r19)		load battle ID?
00197398: 340400ff ori r4,r0,0x00ff
0019739c: 00031100 sll r2,r3,0x04			byte*16
001973a0: 00431021 addu r2,r2,r3			byte*17
001973a4: 000210c0 sll r2,r2,0x03			byte*136 (0x88)
001973a8: 24420ef0 addiu r2,r2,0x0ef0		r2 = units move pointer
001973ac: 02621821 addu r3,r19,r2			r3 = units move list
001973b0: 00101080 sll r2,r16,0x02			move counter prep
<Count usable moves>
001973b4: 00628821 addu r17,r3,r2			r17 = units move list address
001973b8: 92220002 lbu r2,0x0002(r17)		load skillset
001973bc: 00000000 nop
001973c0: 1044000a beq r2,r4,0x 001973ec		branch if none
001973c4: 00000000 nop	
001973c8: 96220002 lhu r2,0x0002(r17)		load usage type
001973cc: 00000000 nop
001973d0: 30428000 andi r2,r2,0x8000			
001973d4: 10400002 beq r2,r0,0x 001973e0		branch if not usable
001973d8: 26100001 addiu r16,r16,0x0001		move counter++
001973dc: 26520001 addiu r18,r18,0x0001		usable move counter++
001973e0: 2a020022 slti r2,r16,0x0022		do for all moves
001973e4: 1440fff3 bne r2,r0,0x 001973b4
001973e8: 00101080 sll r2,r16,0x02			move address prep
</Count usable moves>
001973ec: 12400024 beq r18,r0,0x 00197480	branch if no moves found?
001973f0: 00000000 nop
001973f4: 0c0088c3 jal 0x0002230c			random routine
001973f8: 00000000 nop
001973fc: 00002021 addu r4,r0,r0
00197400: 92630e2f lbu r3,0x0e2f(r19)		load units ID
00197404: 0052001a div r2,r18				random / move list
00197408: 00008010 mfhi r16					r16 = remainder
0019740c: 00031100 sll r2,r3,0x04
00197410: 00431021 addu r2,r2,r3
00197414: 000210c0 sll r2,r2,0x03
00197418: 24420ef0 addiu r2,r2,0x0ef0
0019741c: 02621821 addu r3,r19,r2	
<Pick move?>		
00197420: 00608821 addu r17,r3,r0				r3, r17 = move list
00197424: 94620002 lhu r2,0x0002(r3)			load usage
00197428: 00000000 nop
0019742c: 30428000 andi r2,r2,0x8000	
00197430: 10400004 beq r2,r0,0x 00197444			branch if unusable
00197434: 26230004 addiu r3,r17,0x0004			move list++
00197438: 12000006 beq r16,r0,0x 00197454		branch if remainder of random / move list = 0
0019743c: 00000000 nop
00197440: 2610ffff addiu r16,r16,0xffff			remainder--
00197444: 24840001 addiu r4,r4,0x0001			move counter++
00197448: 28820022 slti r2,r4,0x0022
0019744c: 1440fff4 bne r2,r0,0x 00197420			do for all moves
00197450: 00000000 nop
</Pick move?>
00197454: 0c06561e jal 0x 00195878				AI ability setup
00197458: 02202021 addu r4,r17,r0				r4 = address of chosen move in list?
0019745c: 0c065d4e jal 0x 00197538				Store ability/skillset data, set AI settings for ability?
00197460: 00000000 nop
00197464: 1440002b bne r2,r0,0x 00197514			branch to end if return != 0
00197468: 2652ffff addiu r18,r18,0xffff			move counter--
0019746c: 96220002 lhu r2,0x0002(r17)			load usage flags
00197470: 00000000 nop
00197474: 30427fff andi r2,r2,0x7fff			remove usable flag
00197478: 1640ffde bne r18,r0,0x 001973f4		branch if not finished?
0019747c: a6220002 sh r2,0x0002(r17)			store new flags
00197480: 0c066449 jal 0x 00199124				calculate target
00197484: 34040003 ori r4,r0,0x0003				#Choose closest unit
00197488: 08065cb6 j 0x 001972d8					branch to targeting/movement validation
0019748c: 00409021 addu r18,r2,r0
</Confusion>
00197490: 10400021 beq r2,r0,0x 00197518				branch if not Berserk
00197494: 00001021 addu r2,r0,r0
<Berserk>
00197498: 0c066449 jal 0x 00199124					Calculate Physical target choose unit to attack
0019749c: 34040002 ori r4,r0,0x0002					#target enemy
001974a0: 3c04801a lui r4,0x801a
001974a4: 8c840bbc lw r4,0x0bbc(r4)					load acting units data
001974a8: 00000000 nop
001974ac: 90830012 lbu r3,0x0012(r4)				load primary skillset
001974b0: 00000000 nop
001974b4: 2c6300b0 sltiu r3,r3,0x00b0				set if not monster
001974b8: 1060000f beq r3,r0,0x 001974f8				branch if monster skillset
001974bc: 00409021 addu r18,r2,r0
001974c0: 9082005a lbu r2,0x005a(r4)				
001974c4: 00000000 nop
001974c8: 30420002 andi r2,r2,0x0002
001974cc: 1440000b bne r2,r0,0x 001974fc				branch if frog
001974d0: 26711774 addiu r17,r19,0x1774
001974d4: 3c03801a lui r3,0x801a
001974d8: 906301f3 lbu r3,0x01f3(r3)				load acting units battle ID
001974dc: 00000000 nop
001974e0: 00031100 sll r2,r3,0x04					ID * 16
001974e4: 00431021 addu r2,r2,r3					ID*17
001974e8: 000210c0 sll r2,r2,0x03					ID*104 (0x88)
001974ec: 24420ef0 addiu r2,r2,0x0ef0				
001974f0: 08065ca8 j 0x 001972a0						jump to
001974f4: 00538821 addu r17,r2,r19					r17 = units move list (default to 1st ability?)
</Berserk>
??
001974f8: 26711774 addiu r17,r19,0x1774				r17 = AI + 0x1774
001974fc: 92620e2e lbu r2,0x0e2e(r19)				load acting unit ID
00197500: 96631774 lhu r3,0x1774(r19)				
00197504: 00021280 sll r2,r2,0x0a					
00197508: 00621825 or r3,r3,r2
0019750c: 08065ca8 j 0x 001972a0						jump to 
00197510: a6631774 sh r3,0x1774(r19)				store shifted acting unit ID
End
00197514: 34020001 ori r2,r0,0x0001
00197518: 8fbf0020 lw r31,0x0020(r29)
0019751c: 8fb3001c lw r19,0x001c(r29)
00197520: 8fb20018 lw r18,0x0018(r29)
00197524: 8fb10014 lw r17,0x0014(r29)
00197528: 8fb00010 lw r16,0x0010(r29)
0019752c: 27bd0028 addiu r29,r29,0x0028
00197530: 03e00008 jr r31
00197534: 00000000 nop