Process Learn on Hit
Jump to navigation
Jump to search
Duplicated here : Learn_on_hit_1 # ROUTINE: Process Learn on Hit # Parameters: # r4 = (actingUnitIndex) Battle unit index of acting unit # r5 = (learnedAbilityStorePtr) Pointer for storing learned ability ID # Returns: # r2 = { # (Unit index) of unit that learned the ability # -1, if no used ability or used ability is not flagged as Learn on Hit, or no unit learned the ability # } 8018e6b8: 3c028019 lui r2,0x8019 8018e6bc: 8c4238bc lw r2,0x38bc(r2) # isHamedo 8018e6c0: 27bdffc0 addiu r29,r29,-0x0040 8018e6c4: afb60030 sw r22,0x0030(r29) 8018e6c8: 0080b021 addu r22,r4,r0 # actingUnitIndex 8018e6cc: afb70034 sw r23,0x0034(r29) 8018e6d0: 00a0b821 addu r23,r5,r0 # learnedAbilityStorePtr 8018e6d4: afbf0038 sw r31,0x0038(r29) 8018e6d8: afb5002c sw r21,0x002c(r29) 8018e6dc: afb40028 sw r20,0x0028(r29) 8018e6e0: afb30024 sw r19,0x0024(r29) 8018e6e4: afb20020 sw r18,0x0020(r29) 8018e6e8: afb1001c sw r17,0x001c(r29) 8018e6ec: 14400062 bne r2,r0,0x8018e878 8018e6f0: afb00018 sw r16,0x0018(r29) 8018e6f4: 3c038019 lui r3,0x8019 8018e6f8: 84633d44 lh r3,0x3d44(r3) # usedAbilityID 8018e6fc: 00000000 nop 8018e700: 1060005d beq r3,r0,0x8018e878 # if (usedAbilityID == 0) return -1; 8018e704: 000318c0 sll r3,r3,0x03 8018e708: 3c028006 lui r2,0x8006 8018e70c: 2442ebf0 addiu r2,r2,-0x1410 8018e710: 0062a821 addu r21,r3,r2 # abilities[usedAbilityID] 8018e714: 92a20003 lbu r2,0x0003(r21) # abilities[usedAbilityID].TypeFlags 8018e718: 00000000 nop 8018e71c: 30420020 andi r2,r2,0x0020 8018e720: 14400007 bne r2,r0,0x8018e740 8018e724: 00008821 addu r17,r0,r0 # unitIndex = 0 # if ((abilities[usedAbilityID].TypeFlags & FLAGS_LEARN_ON_HIT) == 0) { 8018e728: 08063a1f j 0x8018e87c # return -1; 8018e72c: 2402ffff addiu r2,r0,-0x0001 # } 8018e730: 3c038019 lui r3,0x8019 8018e734: 94633d44 lhu r3,0x3d44(r3) 8018e738: 08063a1f j 0x8018e87c 8018e73c: a6e30000 sh r3,0x0000(r23) 8018e740: 27b20010 addiu r18,r29,0x0010 # localLearnedAbilityFlags 8018e744: 0000a021 addu r20,r0,r0 # for (; unitIndex < 21; unitIndex++) { 8018e748: 12d10047 beq r22,r17,0x8018e868 # if (unitIndex == actingUnitIndex) continue; 8018e74c: 00000000 nop 8018e750: 3c028019 lui r2,0x8019 8018e754: 244208cc addiu r2,r2,0x08cc 8018e758: 02828021 addu r16,r20,r2 # unit = units[unitIndex] 8018e75c: 92020189 lbu r2,0x0189(r16) # unit.Flags0x189 8018e760: 00000000 nop 8018e764: 30420002 andi r2,r2,0x0002 8018e768: 1040003f beq r2,r0,0x8018e868 # if ((unit.Flags0x189 & FLAGS_HIT_BY_ABILITY) == 0) continue; 8018e76c: 34020004 ori r2,r0,0x0004 8018e770: 92030006 lbu r3,0x0006(r16) # unit.Flags 8018e774: 00000000 nop 8018e778: 30630020 andi r3,r3,0x0020 8018e77c: 1460003a bne r3,r0,0x8018e868 # if (unit.Flags & FLAGS_MONSTER) continue; 8018e780: a2020189 sb r2,0x0189(r16) # unit.Flags0x189 = FLAGS_LEARNING_ABILITY 8018e784: 02002021 addu r4,r16,r0 8018e788: 0c01786c jal 0x8005e1b0 # hasStatus = Does Unit Have Status In Set (unit, 4); 8018e78c: 34050004 ori r5,r0,0x0004 8018e790: 14400035 bne r2,r0,0x8018e868 # if (hasStatus) continue; 8018e794: 00000000 nop 8018e798: 92030003 lbu r3,0x0003(r16) # unit.JobID 8018e79c: 92130012 lbu r19,0x0012(r16) # unit.PrimarySkillset 8018e7a0: 2862004a slti r2,r3,0x004a 8018e7a4: 10400003 beq r2,r0,0x8018e7b4 # if (unit.JobID < 0x4A) { // Special character 8018e7a8: 00000000 nop 8018e7ac: 080639ee j 0x8018e7b8 8018e7b0: 00001821 addu r3,r0,r0 # jobWheelIndex = 0 # } else { 8018e7b4: 2463ffb6 addiu r3,r3,-0x004a # jobWheelIndex = unit.JobID - 0x4A # } 8018e7b8: 02402021 addu r4,r18,r0 # localLearnedAbilityFlagsPtr = localLearnedAbilityFlags 8018e7bc: 00031040 sll r2,r3,0x01 # jobWheelIndex * 2 8018e7c0: 00431021 addu r2,r2,r3 # jobWheelIndex * 3 8018e7c4: 00501021 addu r2,r2,r16 # (jobWheelIndex * 3) + unit 8018e7c8: 24430099 addiu r3,r2,0x0099 # learnedAbilityPtr = unit + (jobWheelIndex * 3) + 0x99 8018e7cc: 26450003 addiu r5,r18,0x0003 # sentinelPtr = localLearnedAbilityFlagsPtr + 3 # do { 8018e7d0: 90620000 lbu r2,0x0000(r3) # *learnedAbilityPtr 8018e7d4: 00000000 nop 8018e7d8: a0820000 sb r2,0x0000(r4) # *localLearnedAbilityFlagsPtr = *learnedAbilityPtr 8018e7dc: 24840001 addiu r4,r4,0x0001 # localLearnedAbilityFlagsPtr = localLearnedAbilityFlagsPtr + 1 8018e7e0: 0085102a slt r2,r4,r5 8018e7e4: 1440fffa bne r2,r0,0x8018e7d0 8018e7e8: 24630001 addiu r3,r3,0x0001 # learnedAbilityPtr = learnedAbilityPtr + 1 # } while (localLearnedAbilityFlagsPtr < sentinelPtr); 8018e7ec: 00008021 addu r16,r0,r0 # abilityIndex = 0 # for (; abilityIndex < 25; abilityIndex++) { 8018e7f0: 06010002 bgez r16,0x8018e7fc 8018e7f4: 02001021 addu r2,r16,r0 8018e7f8: 26020007 addiu r2,r16,0x0007 8018e7fc: 000210c3 sra r2,r2,0x03 # abilityIndex / 8 8018e800: 000220c0 sll r4,r2,0x03 8018e804: 02042023 subu r4,r16,r4 # abilityIndex % 8 8018e808: 34030080 ori r3,r0,0x0080 # 0x80 8018e80c: 02421021 addu r2,r18,r2 # localLearnedAbilityFlagsPtr + (abilityIndex / 8) 8018e810: 90420000 lbu r2,0x0000(r2) # currentLearnedAbilityFlags = *(localLearnedAbilityFlagsPtr + (abilityIndex / 8)) 8018e814: 00831807 srav r3,r3,r4 # 0x80 >> (abilityIndex % 8) 8018e818: 00431024 and r2,r2,r3 # currentLearnedAbilityFlag = currentLearnedAbilityFlags & (0x80 >> (abilityIndex % 8)) 8018e81c: 1440000e bne r2,r0,0x8018e858 # if (currentLearnedAbilityFlag != 0) continue; // Ability already learned 8018e820: 00000000 nop 8018e824: 326400ff andi r4,r19,0x00ff 8018e828: 0c01695a jal 0x8005a568 # abilityID = Load Ability From Skillset (unit.PrimarySkillset, abilityIndex); 8018e82c: 02002821 addu r5,r16,r0 8018e830: 3c038019 lui r3,0x8019 8018e834: 84633d44 lh r3,0x3d44(r3) # usedAbilityID 8018e838: 3042ffff andi r2,r2,0xffff 8018e83c: 14430006 bne r2,r3,0x8018e858 # if (abilityID != usedAbilityID) continue; 8018e840: 00000000 nop 8018e844: 92a50002 lbu r5,0x0002(r21) 8018e848: 0c017833 jal 0x8005e0cc # rollResult = Pass/Fail Roll (100, abilities[usedAbilityID].ChanceToLearn); 8018e84c: 34040064 ori r4,r0,0x0064 8018e850: 1040ffb7 beq r2,r0,0x8018e730 # if (rollResult == 0) { *learnedAbilityStorePtr = usedAbilityID; return unitIndex; } 8018e854: 02201021 addu r2,r17,r0 8018e858: 26100001 addiu r16,r16,0x0001 8018e85c: 2a020018 slti r2,r16,0x0018 8018e860: 1440ffe3 bne r2,r0,0x8018e7f0 8018e864: 00000000 nop # } 8018e868: 26310001 addiu r17,r17,0x0001 8018e86c: 2a220015 slti r2,r17,0x0015 8018e870: 1440ffb5 bne r2,r0,0x8018e748 8018e874: 269401c0 addiu r20,r20,0x01c0 # } 8018e878: 2402ffff addiu r2,r0,-0x0001 # return -1; 8018e87c: 8fbf0038 lw r31,0x0038(r29) 8018e880: 8fb70034 lw r23,0x0034(r29) 8018e884: 8fb60030 lw r22,0x0030(r29) 8018e888: 8fb5002c lw r21,0x002c(r29) 8018e88c: 8fb40028 lw r20,0x0028(r29) 8018e890: 8fb30024 lw r19,0x0024(r29) 8018e894: 8fb20020 lw r18,0x0020(r29) 8018e898: 8fb1001c lw r17,0x001c(r29) 8018e89c: 8fb00018 lw r16,0x0018(r29) 8018e8a0: 27bd0040 addiu r29,r29,0x0040 8018e8a4: 03e00008 jr r31 8018e8a8: 00000000 nop
Return Locations
80073598: Some_post_action_(including_learn_on_hit_setup)