AI End of turn, in between turn, etc.

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
AI End of turn, in between turn, etc.   DUPLICATED : AI_Act_phase_handling_(in_between_turn,_end_of_turn,_etc.)
0x02b2 = 0x0eee
0019d37c: 3c02801a lui r2,0x801a
0019d380: 90420d7b lbu r2,0x0d7b(r2)			Get ability to act?
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 (Hasn't acted yet?)
0019d3a4: 3c02801a lui r2,0x801a
0019d3a8: 904202b2 lbu r2,0x02b2(r2)			Load AI Progress (0x0eee)
0019d3ac: 00000000 nop	
0019d3b0: 1040000a beq r2,r0,0x0019d3dc			Branch if Progress = 0 (Able to Act Routine ended early by Frame RNG)
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 Progress
0019d3c8: 34020001 ori r2,r0,0x0001	
0019d3cc: 10620062 beq r3,r2,0x0019d558			Branch if Progress = 1 (Routine went normally)
0019d3d0: 34020002 ori r2,r0,0x0002	
0019d3d4: 106200b7 beq r3,r2,0x0019d6b4			Branch if Progress = 2	(Unit Target Priority ended early by Frame RNG
0019d3d8: 00000000 nop
if able to act / Progress = 0 (Ending turn routine?)
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)			Set Progress to zero to resume later
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)				Clear Extended Status CTs?
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)			Clear Target Priority
0019d42c: 10600017 beq r3,r0,0x0019d48c			Branch if Targeting Flags haven't been set?
0019d430: a2420031 sb r2,0x0031(r18)			Store Base Hit%? = 255 (default value?)
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				Set Critical on Unit
0019d480: a0620188 sb r2,0x0188(r3)				Action Taken = True
0019d484: 08067538 j 0x0019d4e0
0019d488: 00000000 nop
0019d48c: 0c0676e0 jal 0x0019db80				Set Critical on unit
0019d490: 00000000 nop
0019d494: 9243001d lbu r3,0x001d(r18)			Load Skillset of Last Attack
0019d498: 00000000 nop
0019d49c: 10600011 beq r3,r0,0x0019d4e4			Skip if not a valid Skillset
0019d4a0: 34020002 ori r2,r0,0x0002
0019d4a4: 10620012 beq r3,r2,0x0019d4f0			Skip if Defend
0019d4a8: 00000000 nop
0019d4ac: 2650001c addiu r16,r18,0x001c
0019d4b0: 0c05f0f7 jal 0x0017c3dc				Call Attack Preparation (AT list preview)
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				Call AI Ability Processing (Main Action Routine)
0019d4c8: 02002021 addu r4,r16,r0
0019d4cc: 104001a1 beq r2,r0,0x0019db54			Branch if Ability cannot hit
0019d4d0: 00000000 nop
0019d4d4: 8e4317f8 lw r3,0x17f8(r18)
0019d4d8: 34020001 ori r2,r0,0x0001
0019d4dc: a0620188 sb r2,0x0188(r3)					Action Taken = True
0019d4e0: 9243001d lbu r3,0x001d(r18)				Load Skillset of Last Attack
0019d4e4: 34020002 ori r2,r0,0x0002
0019d4e8: 14620009 bne r3,r2,0x0019d510				Skip if Defend
0019d4ec: 00000000 nop
0019d4f0: 92440e2e lbu r4,0x0e2e(r18)				r4 = Caster ID
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)				Save Hit% as 100%
0019d508: 34020001 ori r2,r0,0x0001
0019d50c: a0620188 sb r2,0x0188(r3)					Action Taken = True
0019d510: 9242001d lbu r2,0x001d(r18)				Load Skillset of Last Attack
0019d514: 00000000 nop
0019d518: 14400002 bne r2,r0,0x0019d524				Skip if valid Skillset
0019d51c: 34020064 ori r2,r0,0x0064					
0019d520: a2420031 sb r2,0x0031(r18)				Save Hit% as 100%
0019d524: 92440e2e lbu r4,0x0e2e(r18)				r4 = Caster ID	
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 (Inbetween turn routine?)
0019d558: 0c0076ea jal 0x0001dba8			Get RNG from Frame Data?
0019d55c: 34040001 ori r4,r0,0x0001
0019d560: 28420139 slti r2,r2,0x0139
0019d564: 1040016c beq r2,r0,0x0019db18		Save AI Progress, then exit if Frame RNG said so
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		Not sure how this is supposed to loop 256 times...		
0019d588: 10400041 beq r2,r0,0x0019d690		<Save AI Progress -> Target Priority> if ? counter > 0x0100
0019d58c: 00000000 nop
0019d590: 0c0609fc jal 0x001827f0			In between turn control routine (Return Event Occuring + Unit ID )
0019d594: 00002021 addu r4,r0,r0
0019d598: 00408821 addu r17,r2,r0
0019d59c: 3225ff00 andi r5,r17,0xff00		r5 =  Inbetween turns Event
0019d5a0: 323100ff andi r17,r17,0x00ff		r17 = Unit ID
0019d5a4: 001110c0 sll r2,r17,0x03			Unit ID * 8
0019d5a8: 00511023 subu r2,r2,r17			Unit ID * 7
0019d5ac: 00021180 sll r2,r2,0x06			Unit ID * 1c0
0019d5b0: 3c038019 lui r3,0x8019
0019d5b4: 246308cc addiu r3,r3,0x08cc		Unit Data
0019d5b8: 00438021 addu r16,r2,r3			Get Current Unit's Data
0019d5bc: 3402ff00 ori r2,r0,0xff00
0019d5c0: 10a20033 beq r5,r2,0x0019d690		<Save AI Progress -> Target Priority> if nothing happened?
0019d5c4: 34020300 ori r2,r0,0x0300
0019d5c8: 14a20005 bne r5,r2,0x0019d5e0		Branch unless Transparent was removed?
0019d5cc: 34020200 ori r2,r0,0x0200
0019d5d0: 0c062f82 jal 0x0018be08			Main Action Routine (Simulates Damage)
0019d5d4: 02202021 addu r4,r17,r0
0019d5d8: 08067590 j 0x0019d640				<Find Charging Unit>
0019d5dc: 00008821 addu r17,r0,r0
0019d5e0: 14a2000d bne r5,r2,0x0019d618
0019d5e4: 34020100 ori r2,r0,0x0100
0019d5e8: 0c06772f jal 0x0019dcbc				Call AI Ability Processing (calls Main Action Routine)
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 Current Status
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				Status/CT based decision
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
<Find Charging Unit>
0019d640: 340400ff ori r4,r0,0x00ff
0019d644: 3c038019 lui r3,0x8019
0019d648: 246308cc addiu r3,r3,0x08cc			
0019d64c: 00608021 addu r16,r3,r0				r16 = Current Unit Data
0019d650: 92020001 lbu r2,0x0001(r16)			load unit ID
0019d654: 00000000 nop
0019d658: 10440006 beq r2,r4,0x0019d674			<Unit++> 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		Simulate Damage for all charging/performing units
0019d68c: 00000000 nop
<Save AI Progress -> Target Priority> (Update Control Variables, then go on into Unit Priorities with simulated damage)
0019d690: 8e420ee0 lw r2,0x0ee0(r18)			In between turn control variable
0019d694: 8e430ee4 lw r3,0x0ee4(r18)			Menu loading control variable
0019d698: 8e440ee8 lw r4,0x0ee8(r18)			active unit ID
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					Jump, Save AI Progress as 2 and Return -1
0019d6d4: 34020002 ori r2,r0,0x0002				
0019d6d8: 8e420cb4 lw r2,0x0cb4(r18)			Load AI Processing Order (lui 0x0100 if coming from (194314) Set AI Target Type)
0019d6dc: 00000000 nop
0019d6e0: 00431024 and r2,r2,r3
0019d6e4: 10400048 beq r2,r0,0x0019d808			Set Target Types unless already set (came from 194314)
<Set Target Type> (Then Exit)
0019d6e8: 00008821 addu r17,r0,r0				Initialize Unit Counter
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 Autobattle 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
<Dead w/o revive?>
0019d710: 92020058 lbu r2,0x0058(r16)			load Current Status 1
0019d714: 00000000 nop
0019d718: 30420020 andi r2,r2,0x0020
0019d71c: 10400007 beq r2,r0,0x0019d73c			<Petrify> if not dead
0019d720: 00000000 nop
0019d724: 9202005a lbu r2,0x005a(r16)			load Current Status 3
0019d728: 00000000 nop
0019d72c: 30420020 andi r2,r2,0x0020
0019d730: 14400002 bne r2,r0,0x0019d73c			<Petrify> if reraise
0019d734: 34620001 ori r2,r3,0x0001				add Need Revive flag
0019d738: a0820004 sb r2,0x0004(r4)				store new AI setting
<Petrify>
0019d73c: 92020059 lbu r2,0x0059(r16)			Load Current Status 2
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 Auto Battle
0019d754: 00000000 nop
0019d758: 34420002 ori r2,r2,0x0002				add Need UnPetrifed flag
0019d75c: a0820004 sb r2,0x0004(r4)				store flag
<Jump>
0019d760: 92020058 lbu r2,0x0058(r16)			Load Current Status 1
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)			Load AI Auto Battle
0019d778: 00000000 nop
0019d77c: 34420004 ori r2,r2,0x0004				Unit is Jumping Flag
0019d780: a0820004 sb r2,0x0004(r4)				store flag
<0x80 = Normal Unit?>
0019d784: 90830004 lbu r3,0x0004(r4)			Load AI Auto Battle
0019d788: 00000000 nop
0019d78c: 30620080 andi r2,r3,0x0080
0019d790: 14400016 bne r2,r0,0x0019d7ec			<Unit++> if unit is Normal?
0019d794: 00000000 nop
<If Petrify>
0019d798: 92020059 lbu r2,0x0059(r16)			Load Current Status 2
0019d79c: 00000000 nop
0019d7a0: 30420080 andi r2,r2,0x0080
0019d7a4: 14400011 bne r2,r0,0x0019d7ec			<Unit++> if petrified
0019d7a8: 00000000 nop
<If Dead>
0019d7ac: 92020058 lbu r2,0x0058(r16)			Load Current Status 1
0019d7b0: 00000000 nop
0019d7b4: 30420020 andi r2,r2,0x0020
0019d7b8: 10400006 beq r2,r0,0x0019d7d4			<Death Sentence> if not dead
0019d7bc: 00000000 nop
0019d7c0: 9202005a lbu r2,0x005a(r16)			Load Current Status 3
0019d7c4: 00000000 nop
0019d7c8: 30420020 andi r2,r2,0x0020
0019d7cc: 10400007 beq r2,r0,0x0019d7ec			<Unit++> if No Reraise
0019d7d0: 00000000 nop
<Death Sentence>
0019d7d4: 9202005c lbu r2,0x005c(r16)			Load Current Status 5
0019d7d8: 00000000 nop
0019d7dc: 30420001 andi r2,r2,0x0001
0019d7e0: 14400002 bne r2,r0,0x0019d7ec			<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
<Unit++>
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					Exit Routine
0019d804: 00000000 nop
0019d808: 0c06772b jal 0x0019dcac				Store Skillset = 0 (why not write it out if it's so small?)
0019d80c: 00000000 nop
0019d810: 3c0c8019 lui r12,0x8019
0019d814: 258c3de0 addiu r12,r12,0x3de0			r12 = Status Priority Pointer
0019d818: 3c0d801a lui r13,0x801a
0019d81c: 8dadf3c0 lw r13,-0x0c40(r13)			r13 = AI Extended Status Pointer
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
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% / 2
0019da14: 91221837 lbu r2,0x1837(r9)			MP Using Ability Mod
0019da18: 00000000 nop
0019da1c: 00c20018 mult r6,r2					(curMP% * 20) * 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)			0 = Priorites decided?
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)	Save AI Progress? (0-2, for 0x0019d37c)
0019db28: 080676d9 j 0x0019db64			jump to end, return r2=0xffff
0019db2c: 2402ffff addiu r2,r0,0xffff
<End>
0019db30: 8e420ee0 lw r2,0x0ee0(r18)	In between turn control variable
0019db34: 8e430ee4 lw r3,0x0ee4(r18)	Menu loading control variable
0019db38: 8e440ee8 lw r4,0x0ee8(r18)	active unit ID
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