diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-02-26 13:21:40 -0500 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-03-10 22:32:17 -0500 |
commit | 17a6ab37944e3cc9fc98ee93262bd4385bf4e626 (patch) | |
tree | 45a9dd41f29f59c762b379f1845a03a52cf727e6 | |
parent | ea1aa9c0c5c3a4167912d1078fffdd5e69cbbe98 (diff) |
Decomped CanUseOnTargetWithStatusChecker()
-rw-r--r-- | asm/code_805D810.s (renamed from asm/code_805CEB8.s) | 884 | ||||
-rw-r--r-- | include/dungeon_entity.h | 33 | ||||
-rw-r--r-- | include/moves.h | 2 | ||||
-rw-r--r-- | include/status_checker.h | 2 | ||||
-rwxr-xr-x | ld_script.txt | 2 | ||||
-rw-r--r-- | src/dungeon_ai_attack_1.c | 2 | ||||
-rw-r--r-- | src/dungeon_pokemon_attributes.c | 2 | ||||
-rw-r--r-- | src/status_checker.c | 402 |
8 files changed, 413 insertions, 916 deletions
diff --git a/asm/code_805CEB8.s b/asm/code_805D810.s index d318b14..17228d2 100644 --- a/asm/code_805CEB8.s +++ b/asm/code_805D810.s @@ -4,889 +4,7 @@ .syntax unified .text - - thumb_func_start CanUseOnTargetWithStatusChecker -CanUseOnTargetWithStatusChecker: - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r0 - adds r6, r1, 0 - adds r7, r2, 0 - ldr r5, [r0, 0x70] - ldr r4, [r6, 0x70] - adds r0, r4, 0 - adds r0, 0xB0 - ldrb r0, [r0] - cmp r0, 0x1 - bne _0805CEE0 - adds r0, r7, 0 - bl MoveCannotHitFrozen - lsls r0, 24 - cmp r0, 0 - beq _0805CEE0 - b _0805D540 -_0805CEE0: - ldrh r0, [r7, 0x2] - subs r2, r0, 0x3 - ldr r0, _0805CEF8 - cmp r2, r0 - bls _0805CEEE - bl _0805D802 -_0805CEEE: - lsls r0, r2, 2 - ldr r1, _0805CEFC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0805CEF8: .4byte 0x0000017b -_0805CEFC: .4byte _0805CF00 - .align 2, 0 -_0805CF00: - .4byte _0805D4FA - .4byte _0805D4F0 - .4byte _0805D50E - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D516 - .4byte _0805D51C - .4byte _0805D802 - .4byte _0805D7F6 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D520 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D52C - .4byte _0805D532 - .4byte _0805D544 - .4byte _0805D55A - .4byte _0805D7F6 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D566 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D56A - .4byte _0805D4F0 - .4byte _0805D570 - .4byte _0805D802 - .4byte _0805D57E - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D584 - .4byte _0805D802 - .4byte _0805D7F6 - .4byte _0805D802 - .4byte _0805D596 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D59C - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5C8 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5D0 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D4F0 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5E2 - .4byte _0805D4F0 - .4byte _0805D5E8 - .4byte _0805D5F8 - .4byte _0805D802 - .4byte _0805D5FE - .4byte _0805D5F8 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D55A - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D4F0 - .4byte _0805D662 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D668 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5DC - .4byte _0805D802 - .4byte _0805D5C8 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7AC - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D704 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D704 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7F6 - .4byte _0805D70A - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7F6 - .4byte _0805D5C8 - .4byte _0805D802 - .4byte _0805D5F8 - .4byte _0805D802 - .4byte _0805D7E4 - .4byte _0805D7DC - .4byte _0805D802 - .4byte _0805D7E4 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D716 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D740 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D74A - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5DC - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D4F0 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D75C - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D734 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D782 - .4byte _0805D740 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D704 - .4byte _0805D7F6 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D5C8 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7A0 - .4byte _0805D7CA - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D78A - .4byte _0805D59C - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7BE - .4byte _0805D7AC - .4byte _0805D802 - .4byte _0805D794 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D55A - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D782 - .4byte _0805D802 - .4byte _0805D802 - .4byte _0805D7F6 -_0805D4F0: - adds r0, r6, 0 - bl IsSleeping - lsls r0, 24 - b _0805D7A6 -_0805D4FA: - adds r0, r4, 0 - adds r0, 0xA8 - ldrb r0, [r0] - cmp r0, 0x4 - beq _0805D540 - adds r0, r6, 0 - bl IsSleeping - lsls r0, 24 - b _0805D7A6 -_0805D50E: - adds r0, r4, 0 - adds r0, 0xA8 - ldrb r0, [r0] - b _0805D7F0 -_0805D516: - movs r1, 0x26 - ldrsh r0, [r4, r1] - b _0805D744 -_0805D51C: - ldr r0, [r4, 0x2C] - b _0805D58E -_0805D520: - adds r0, r4, 0 - adds r0, 0xBC - ldrb r0, [r0] - cmp r0, 0x6 - beq _0805D540 - b _0805D7AC -_0805D52C: - movs r3, 0xE - ldrsh r0, [r4, r3] - b _0805D78E -_0805D532: - movs r7, 0xE - ldrsh r1, [r4, r7] - movs r2, 0xE - ldrsh r0, [r5, r2] - cmp r1, r0 - ble _0805D540 - b _0805D802 -_0805D540: - movs r0, 0 - b _0805D804 -_0805D544: - movs r3, 0x8C - lsls r3, 1 - adds r4, r3 - adds r0, r4, 0 - bl HasDisabledMove - lsls r0, 24 - cmp r0, 0 - bne _0805D540 - adds r0, r4, 0 - b _0805D7B2 -_0805D55A: - ldr r0, [r6, 0x70] - movs r7, 0x82 - lsls r7, 1 - adds r0, r7 - ldr r0, [r0] - b _0805D744 -_0805D566: - ldr r0, [r4, 0x34] - b _0805D58E -_0805D56A: - movs r1, 0x22 - ldrsh r0, [r4, r1] - b _0805D744 -_0805D570: - movs r2, 0x8C - lsls r2, 1 - adds r0, r4, r2 - bl LastMoveOutOfPP - lsls r0, 24 - b _0805D7A6 -_0805D57E: - adds r0, r4, 0 - adds r0, 0xDC - b _0805D7FA -_0805D584: - ldr r0, [r4, 0x2C] - cmp r0, 0x3E - ble _0805D58C - b _0805D802 -_0805D58C: - ldr r0, [r4, 0x30] -_0805D58E: - cmp r0, 0x3E - ble _0805D594 - b _0805D802 -_0805D594: - b _0805D540 -_0805D596: - adds r0, r4, 0 - adds r0, 0xAC - b _0805D798 -_0805D59C: - adds r0, r4, 0 - adds r0, 0x5C - ldrb r0, [r0] - cmp r0, 0xE - beq _0805D5B0 - adds r0, r4, 0 - adds r0, 0x5D - ldrb r0, [r0] - cmp r0, 0xE - bne _0805D5BC -_0805D5B0: - adds r0, r4, 0 - adds r0, 0xF5 - ldrb r0, [r0] - cmp r0, 0 - bne _0805D5BC - b _0805D802 -_0805D5BC: - movs r3, 0x26 - ldrsh r0, [r4, r3] - cmp r0, 0xA - ble _0805D5C6 - b _0805D802 -_0805D5C6: - b _0805D540 -_0805D5C8: - adds r0, r4, 0 - adds r0, 0xAC - ldrb r0, [r0] - b _0805D7D6 -_0805D5D0: - movs r7, 0xE - ldrsh r0, [r4, r7] - movs r2, 0xE - ldrsh r1, [r5, r2] - subs r0, r1 - b _0805D744 -_0805D5DC: - movs r3, 0x20 - ldrsh r0, [r4, r3] - b _0805D744 -_0805D5E2: - movs r7, 0x22 - ldrsh r0, [r4, r7] - b _0805D744 -_0805D5E8: - movs r1, 0x1C - ldrsh r0, [r4, r1] - cmp r0, 0 - ble _0805D5F2 - b _0805D802 -_0805D5F2: - movs r2, 0x20 - ldrsh r0, [r4, r2] - b _0805D744 -_0805D5F8: - adds r0, r4, 0 - adds r0, 0xB0 - b _0805D7FA -_0805D5FE: - movs r6, 0 - adds r2, r4, 0 - adds r2, 0x1C - movs r3, 0x1C - ldrsh r0, [r4, r3] - cmp r0, 0x9 - ble _0805D6FC - adds r1, r4, 0 - adds r1, 0x20 - movs r7, 0x20 - ldrsh r0, [r4, r7] - cmp r0, 0x9 - ble _0805D6FC - adds r3, r1, 0 - movs r5, 0 -_0805D61C: - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r5 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x9 - ble _0805D6FC - lsls r1, r6, 2 - adds r0, r4, 0 - adds r0, 0x2C - adds r0, r1 - ldr r0, [r0] - cmp r0, 0xFF - ble _0805D6FC - adds r0, r4, 0 - adds r0, 0x34 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0xFF - ble _0805D6FC - adds r3, 0x2 - adds r2, 0x2 - adds r5, 0x2 - adds r6, 0x1 - cmp r6, 0x1 - bgt _0805D6FC - movs r7, 0 - ldrsh r0, [r2, r7] - cmp r0, 0x9 - ble _0805D6FC - movs r1, 0 - ldrsh r0, [r3, r1] - cmp r0, 0x9 - bgt _0805D61C - b _0805D6FC -_0805D662: - adds r0, r4, 0 - adds r0, 0xA8 - b _0805D7FA -_0805D668: - movs r6, 0 - adds r3, r5, 0 - adds r3, 0x1C - adds r2, r4, 0 - adds r2, 0x1C - movs r7, 0x1C - ldrsh r1, [r5, r7] - movs r7, 0x1C - ldrsh r0, [r4, r7] - cmp r1, r0 - blt _0805D6FC - mov r12, r2 - mov r8, r3 - movs r3, 0 -_0805D684: - adds r1, r5, 0 - adds r1, 0x20 - adds r1, r3 - adds r0, r4, 0 - adds r0, 0x20 - adds r0, r3 - movs r2, 0 - ldrsh r1, [r1, r2] - movs r7, 0 - ldrsh r0, [r0, r7] - cmp r1, r0 - blt _0805D6FC - adds r1, r5, 0 - adds r1, 0x24 - adds r1, r3 - adds r0, r4, 0 - adds r0, 0x24 - adds r0, r3 - movs r2, 0 - ldrsh r1, [r1, r2] - movs r7, 0 - ldrsh r0, [r0, r7] - cmp r1, r0 - blt _0805D6FC - lsls r2, r6, 2 - adds r1, r5, 0 - adds r1, 0x2C - adds r1, r2 - adds r0, r4, 0 - adds r0, 0x2C - adds r0, r2 - ldr r1, [r1] - ldr r0, [r0] - cmp r1, r0 - blt _0805D6FC - adds r1, r5, 0 - adds r1, 0x34 - adds r1, r2 - adds r0, r4, 0 - adds r0, 0x34 - adds r0, r2 - ldr r1, [r1] - ldr r0, [r0] - cmp r1, r0 - blt _0805D6FC - movs r0, 0x2 - add r12, r0 - add r8, r0 - adds r3, 0x2 - adds r6, 0x1 - cmp r6, 0x1 - bgt _0805D6FC - mov r2, r8 - movs r7, 0 - ldrsh r1, [r2, r7] - mov r2, r12 - movs r7, 0 - ldrsh r0, [r2, r7] - cmp r1, r0 - bge _0805D684 -_0805D6FC: - cmp r6, 0x2 - beq _0805D702 - b _0805D802 -_0805D702: - b _0805D540 -_0805D704: - movs r1, 0x24 - ldrsh r0, [r4, r1] - b _0805D744 -_0805D70A: - adds r0, r4, 0 - adds r0, 0xBC - ldrb r0, [r0] - cmp r0, 0x5 - bne _0805D802 - b _0805D540 -_0805D716: - adds r0, r5, 0 - adds r0, 0x60 - ldrb r1, [r0] - movs r2, 0x1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0805D728 - b _0805D540 -_0805D728: - adds r0, r4, 0 - adds r0, 0x60 - ldrb r1, [r0] - adds r0, r2, 0 - ands r0, r1 - b _0805D7B8 -_0805D734: - adds r0, r4, 0 - adds r0, 0x60 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - b _0805D7B8 -_0805D740: - movs r2, 0x1C - ldrsh r0, [r4, r2] -_0805D744: - cmp r0, 0 - bgt _0805D802 - b _0805D540 -_0805D74A: - adds r0, r5, 0 - adds r0, 0x5E - adds r1, r4, 0 - adds r1, 0x5E - ldrh r0, [r0] - ldrh r1, [r1] - cmp r0, r1 - bne _0805D802 - b _0805D540 -_0805D75C: - mov r0, r8 - movs r1, 0xE - bl HasType - lsls r0, 24 - cmp r0, 0 - beq _0805D770 - adds r0, r4, 0 - adds r0, 0xC8 - b _0805D798 -_0805D770: - movs r3, 0x1C - ldrsh r0, [r5, r3] - cmp r0, 0x13 - ble _0805D802 - movs r7, 0x20 - ldrsh r0, [r5, r7] - cmp r0, 0x13 - ble _0805D802 - b _0805D540 -_0805D782: - adds r0, r4, 0 - adds r0, 0xBC - ldrb r0, [r0] - b _0805D7F0 -_0805D78A: - movs r1, 0xE - ldrsh r0, [r4, r1] -_0805D78E: - cmp r0, 0x1 - bgt _0805D802 - b _0805D540 -_0805D794: - adds r0, r4, 0 - adds r0, 0xD0 -_0805D798: - ldrb r0, [r0] - cmp r0, 0x1 - bne _0805D802 - b _0805D540 -_0805D7A0: - adds r0, r4, 0 - adds r0, 0xFD - ldrb r0, [r0] -_0805D7A6: - cmp r0, 0 - beq _0805D802 - b _0805D540 -_0805D7AC: - movs r2, 0x8C - lsls r2, 1 - adds r0, r4, r2 -_0805D7B2: - bl HasLastUsedMove - lsls r0, 24 -_0805D7B8: - cmp r0, 0 - bne _0805D802 - b _0805D540 -_0805D7BE: - adds r0, r4, 0 - adds r0, 0xBC - ldrb r0, [r0] - cmp r0, 0x7 - bne _0805D802 - b _0805D540 -_0805D7CA: - adds r0, r4, 0 - adds r0, 0xB0 - ldrb r0, [r0] - cmp r0, 0x3 - bne _0805D7D6 - b _0805D540 -_0805D7D6: - cmp r0, 0x4 - bne _0805D802 - b _0805D540 -_0805D7DC: - adds r0, r4, 0 - adds r0, 0xAC - ldrb r0, [r0] - b _0805D7F0 -_0805D7E4: - adds r0, r4, 0 - adds r0, 0xAC - ldrb r0, [r0] - cmp r0, 0x2 - bne _0805D7F0 - b _0805D540 -_0805D7F0: - cmp r0, 0x3 - bne _0805D802 - b _0805D540 -_0805D7F6: - adds r0, r4, 0 - adds r0, 0xBC -_0805D7FA: - ldrb r0, [r0] - cmp r0, 0x2 - bne _0805D802 - b _0805D540 -_0805D802: - movs r0, 0x1 -_0805D804: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end CanUseOnTargetWithStatusChecker - + thumb_func_start HasDisabledMove HasDisabledMove: push {r4-r6,lr} diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h index 2567f79..8a5a032 100644 --- a/include/dungeon_entity.h +++ b/include/dungeon_entity.h @@ -7,10 +7,20 @@ #include "position.h" #define MAX_STAT_STAGE 20 +#define STAT_MULTIPLIER_THRESHOLD 63 +#define DEFAULT_STAT_STAGE 10 +#define DEFAULT_STAT_MULTIPLIER 256 #define MAX_MOVEMENT_SPEED 4 #define MAX_STOCKPILE_COUNT 3 #define NUM_SPEED_TURN_COUNTERS 5 +#define STAT_STAGE_ATTACK 0 +#define STAT_STAGE_SPECIAL_ATTACK 1 +#define STAT_STAGE_DEFENSE 0 +#define STAT_STAGE_SPECIAL_DEFENSE 1 +#define STAT_STAGE_ACCURACY 0 +#define STAT_STAGE_EVASION 1 + struct DungeonActionContainer { /* 0x0 */ u16 action; @@ -52,20 +62,20 @@ struct DungeonEntityData /* 0x18 */ u32 expPoints; // Temporary stat boosts/drops from effects like Growl or Swords Dance. // These start at 10 and are in the range [1, 19]. - /* 0x1C */ s16 attackStage; - /* 0x1E */ s16 specialAttackStage; - /* 0x20 */ s16 defenseStage; - /* 0x22 */ s16 specialDefenseStage; - /* 0x24 */ s16 accuracyStage; - /* 0x26 */ s16 evasionStage; + // Index 0 is Attack. Index 1 is Special Attack. + /* 0x1C */ s16 attackStages[2]; + // Index 0 is Defense. Index 1 is Special Defense. + /* 0x20 */ s16 defenseStages[2]; + // Index 0 is accuracy. Index 1 is evasion. + /* 0x24 */ s16 accuracyStages[2]; // // When a Fire-type move is used on a Pokémon with Flash Fire, this value increases the power of the Pokémon's Fire-type moves. /* 0x28 */ s16 flashFireBoost; u8 fill2A[0x2C - 0x2A]; // These start at 0x1000, and are halved by certain moves like Screech to lower the corresponding stat. - /* 0x2C */ s32 attackMultiplier; - /* 0x30 */ s32 specialAttackMultiplier; - /* 0x34 */ s32 defenseMultiplier; - /* 0x38 */ s32 specialDefenseMultiplier; + // Index 0 is Attack. Index 1 is Special Attack. + /* 0x2C */ s32 attackMultipliers[2]; + // Index 0 is Defense. Index 1 is Special Defense. + /* 0x34 */ s32 defenseMultipliers[2]; /* 0x3C */ s16 hiddenPowerPower; /* 0x3E */ u8 hiddenPowerType; u8 fill3F; @@ -77,8 +87,7 @@ struct DungeonEntityData /* 0x58 */ struct Position itemTargetPosition; /* 0x5C */ u8 type1; /* 0x5D */ u8 type2; - /* 0x5E */ u8 ability1; - /* 0x5F */ u8 ability2; + /* 0x5E */ u8 abilities[2]; /* 0x60 */ struct ItemSlot heldItem; u8 fill64[0x68 - 0x64]; /* 0x68 */ struct Position previousPosition1; diff --git a/include/moves.h b/include/moves.h index 44b324b..b612e69 100644 --- a/include/moves.h +++ b/include/moves.h @@ -18,7 +18,7 @@ s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType); u32 GetMoveMaxPP(struct PokemonMove *move); u8 GetMoveUnk12(struct PokemonMove *move); u8 GetMoveCriticalHitChance(struct PokemonMove *move); -u8 GetMoveCannotHitFrozen(struct PokemonMove *move); +u8 MoveCannotHitFrozen(struct PokemonMove *move); u8 MoveDealsDirectDamage(struct PokemonMove *move); u32 GetMoveRangeType(struct PokemonMove *move); void sub_8092C84(u8 *buffer, u16 moveID); diff --git a/include/status_checker.h b/include/status_checker.h index 1b65030..4538af1 100644 --- a/include/status_checker.h +++ b/include/status_checker.h @@ -6,5 +6,7 @@ // 0x5C498 bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move); +// 0x5CEB8 +bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move); #endif diff --git a/ld_script.txt b/ld_script.txt index 3af08e6..d7204b5 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -211,7 +211,7 @@ SECTIONS { src/code_8057824.o(.text); asm/code_8057824.o(.text); src/status_checker.o(.text); - asm/code_805CEB8.o(.text); + asm/code_805D810.o(.text); src/targeting.o(.text); asm/code_8069E0C.o(.text); src/code_806CD90.o(.text); diff --git a/src/dungeon_ai_attack_1.c b/src/dungeon_ai_attack_1.c index 023df14..8421cc9 100644 --- a/src/dungeon_ai_attack_1.c +++ b/src/dungeon_ai_attack_1.c @@ -9,6 +9,7 @@ #include "dungeon_random.h" #include "moves.h" #include "position_util.h" +#include "status_checker.h" #include "status_checks_1.h" extern bool8 gCanAttackInDirection[NUM_DIRECTIONS]; @@ -17,7 +18,6 @@ extern u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS]; extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS]; extern s32 WeightMove(struct DungeonEntity*, s32, struct DungeonEntity*, u8); -extern bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity*, struct DungeonEntity*, struct PokemonMove*); s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker) { diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c index bd3a1f6..671162d 100644 --- a/src/dungeon_pokemon_attributes.c +++ b/src/dungeon_pokemon_attributes.c @@ -95,7 +95,7 @@ bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability) else { struct DungeonEntityData *pokemonData = pokemon->entityData; - if (pokemonData->ability1 == ability || pokemonData->ability2 == ability) + if (pokemonData->abilities[0] == ability || pokemonData->abilities[1] == ability) { return TRUE; } diff --git a/src/status_checker.c b/src/status_checker.c index 07d6c7f..f2ea0f8 100644 --- a/src/status_checker.c +++ b/src/status_checker.c @@ -11,6 +11,7 @@ #include "dungeon_util.h" #include "dungeon_visibility.h" #include "map.h" +#include "moves.h" #include "number_util.h" #include "status_checks_1.h" #include "tile_types.h" @@ -97,6 +98,10 @@ const u8 gDungeonCamouflageTypes[76] = { TYPE_ROCK }; +extern bool8 HasLastUsedMove(struct PokemonMove *moves); +extern bool8 HasDisabledMove(struct PokemonMove *moves); +extern bool8 LastMoveOutOfPP(struct PokemonMove *moves); + bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move) { struct DungeonEntityData *pokemonData = pokemon->entityData; @@ -130,13 +135,13 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo case MOVE_HOWL: case MOVE_MEDITATE: case MOVE_SHARPEN: - if (pokemonData->attackStage >= MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_BELLY_DRUM: - if (pokemonData->attackStage >= MAX_STAT_STAGE || RoundUpFixedPoint(pokemonData->belly) <= 0) + if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE || RoundUpFixedPoint(pokemonData->belly) <= 0) { return FALSE; } @@ -147,7 +152,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo case MOVE_HARDEN: case MOVE_IRON_DEFENSE: case MOVE_WITHDRAW: - if (pokemonData->defenseStage >= MAX_STAT_STAGE) + if (pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE) { return FALSE; } @@ -182,7 +187,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_COSMIC_POWER: - if (pokemonData->defenseStage >= MAX_STAT_STAGE && pokemonData->specialDefenseStage >= MAX_STAT_STAGE) + if (pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE && pokemonData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] >= MAX_STAT_STAGE) { return FALSE; } @@ -212,7 +217,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_MINIMIZE: - if (pokemonData->evasionStage >= MAX_STAT_STAGE) + if (pokemonData->accuracyStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) { return FALSE; } @@ -243,7 +248,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_BULK_UP: - if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemonData->defenseStage >= MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE && pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE) { return FALSE; } @@ -255,7 +260,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_TAIL_GLOW: - if (pokemonData->specialAttackStage >= MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] >= MAX_STAT_STAGE) { return FALSE; } @@ -279,7 +284,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_DRAGON_DANCE: - if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED) + if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE && pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED) { return FALSE; } @@ -409,19 +414,19 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_DOUBLE_TEAM: - if (pokemonData->evasionStage >= MAX_STAT_STAGE) + if (pokemonData->accuracyStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_GROWTH: - if (pokemonData->specialAttackStage >= MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_SWORDS_DANCE: - if (pokemonData->attackStage >= MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE) { return FALSE; } @@ -445,12 +450,12 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } break; case MOVE_CALM_MIND: - if (pokemonData->specialAttackStage < MAX_STAT_STAGE) + if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE) { break; } case MOVE_AMNESIA: - if (pokemonData->specialDefenseStage >= MAX_STAT_STAGE) + if (pokemonData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] >= MAX_STAT_STAGE) { return FALSE; } @@ -492,11 +497,11 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo struct DungeonEntity *target = gDungeonGlobalData->wildPokemon[i]; if (EntityExists(target) && target != pokemon && CanSee(pokemon, target)) { - if (target->entityData->attackStage >= MAX_STAT_STAGE) + if (target->entityData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE) { continue; } - if (target->entityData->specialAttackStage < MAX_STAT_STAGE) + if (target->entityData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE) { break; } @@ -516,11 +521,11 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo struct DungeonEntity *target = gDungeonGlobalData->teamPokemon[i]; if (EntityExists(target) && target != pokemon && CanSee(pokemon, target)) { - if (target->entityData->attackStage >= MAX_STAT_STAGE) + if (target->entityData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE) { continue; } - if (target->entityData->specialAttackStage < MAX_STAT_STAGE) + if (target->entityData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE) { break; } @@ -535,3 +540,366 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo } return TRUE; } + +bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move) +{ + struct DungeonEntityData *userData = user->entityData; + struct DungeonEntityData *targetData = target->entityData; + s32 i; + if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_FROZEN && MoveCannotHitFrozen(move)) + { + return FALSE; + } + switch (move->moveID) + { + case MOVE_GRASSWHISTLE: + case MOVE_HYPNOSIS: + case MOVE_LOVELY_KISS: + case MOVE_SING: + case MOVE_SLEEP_POWDER: + case MOVE_SPORE: + if (IsSleeping(target)) + { + return FALSE; + } + break; + case MOVE_YAWN: + if (targetData->sleepStatus == SLEEP_STATUS_YAWNING) + { + return FALSE; + } + if (IsSleeping(target)) + { + return FALSE; + } + break; + case MOVE_NIGHTMARE: + if (targetData->sleepStatus == SLEEP_STATUS_NIGHTMARE) + { + return FALSE; + } + break; + case MOVE_SWEET_SCENT: + if (targetData->accuracyStages[STAT_STAGE_EVASION] <= 0) + { + return FALSE; + } + break; + case MOVE_CHARM: + if (targetData->attackMultipliers[STAT_STAGE_ATTACK] < STAT_MULTIPLIER_THRESHOLD) + { + return FALSE; + } + break; + case MOVE_ENCORE: + if (targetData->volatileStatus == VOLATILE_STATUS_ENCORE) + { + return FALSE; + } + if (!HasLastUsedMove(targetData->moves)) + { + return FALSE; + } + break; + case MOVE_SUPER_FANG: + if (targetData->HP <= 1) + { + return FALSE; + } + break; + case MOVE_PAIN_SPLIT: + if (targetData->HP <= userData->HP) + { + return FALSE; + } + break; + case MOVE_TORMENT: + if (HasDisabledMove(targetData->moves) || !HasLastUsedMove(targetData->moves)) + { + return FALSE; + } + break; + case MOVE_COTTON_SPORE: + case MOVE_SCARY_FACE: + case MOVE_STRING_SHOT: + if (target->entityData->movementSpeed <= 0) + { + return FALSE; + } + break; + case MOVE_SCREECH: + if (targetData->defenseMultipliers[STAT_STAGE_DEFENSE] < STAT_MULTIPLIER_THRESHOLD) + { + return FALSE; + } + break; + case MOVE_FAKE_TEARS: + if (targetData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] <= 0) + { + return FALSE; + } + break; + case MOVE_SPITE: + if (LastMoveOutOfPP(targetData->moves)) + { + return FALSE; + } + break; + case MOVE_SMOKESCREEN: + if (targetData->moveStatus == MOVE_STATUS_WHIFFER) + { + return FALSE; + } + break; + case MOVE_MEMENTO: + if (targetData->attackMultipliers[STAT_STAGE_ATTACK] < STAT_MULTIPLIER_THRESHOLD && + targetData->attackMultipliers[STAT_STAGE_SPECIAL_ATTACK] < STAT_MULTIPLIER_THRESHOLD) + { + return FALSE; + } + break; + case MOVE_WILL_O_WISP: + if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BURNED) + { + return FALSE; + } + break; + case MOVE_FORESIGHT: + case MOVE_ODOR_SLEUTH: + if (targetData->type1 == TYPE_GHOST || targetData->type2 == TYPE_GHOST) + { + if (!targetData->exposedStatus) + { + break; + } + } + if (targetData->accuracyStages[STAT_STAGE_EVASION] <= DEFAULT_STAT_STAGE) + { + return FALSE; + } + break; + case MOVE_DISABLE: + case MOVE_GLARE: + case MOVE_STUN_SPORE: + case MOVE_THUNDER_WAVE: + if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_PARALYZED) + { + return FALSE; + } + break; + case MOVE_ENDEAVOR: + if (targetData->HP - userData->HP <= 0) + { + return FALSE; + } + break; + case MOVE_LEER: + case MOVE_TAIL_WHIP: + if (targetData->defenseStages[STAT_STAGE_DEFENSE] <= 0) + { + return FALSE; + } + break; + case MOVE_METAL_SOUND: + if (targetData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] <= 0) + { + return FALSE; + } + break; + case MOVE_TICKLE: + if (targetData->attackStages[STAT_STAGE_ATTACK] <= 0 && + targetData->defenseStages[STAT_STAGE_DEFENSE] <= 0) + { + return FALSE; + } + break; + case MOVE_BLOCK: + case MOVE_MEAN_LOOK: + case MOVE_SPIDER_WEB: + if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_IMMOBILIZED) + { + return FALSE; + } + break; + case MOVE_HAZE: + { + for (i = 0; i < 2; i++) + { + if (targetData->attackStages[i] < DEFAULT_STAT_STAGE) break; + if (targetData->defenseStages[i] < DEFAULT_STAT_STAGE) break; + if (targetData->accuracyStages[i] < DEFAULT_STAT_STAGE || + targetData->attackMultipliers[i] < DEFAULT_STAT_MULTIPLIER || + targetData->defenseMultipliers[i] < DEFAULT_STAT_MULTIPLIER) + { + break; + } + } + if (i == 2) + { + return FALSE; + } + break; + } + case MOVE_UPROAR: + if (targetData->sleepStatus == SLEEP_STATUS_SLEEPLESS) + { + return FALSE; + } + break; + case MOVE_PSYCH_UP: + { + for (i = 0; i < 2; i++) + { + if (userData->attackStages[i] < targetData->attackStages[i]) break; + if (userData->defenseStages[i] < targetData->defenseStages[i] || + userData->accuracyStages[i] < targetData->accuracyStages[i] || + userData->attackMultipliers[i] < targetData->attackMultipliers[i] || + userData->defenseMultipliers[i] < targetData->defenseMultipliers[i]) + { + break; + } + } + if (i == 2) + { + return FALSE; + } + break; + } + case MOVE_FLASH: + case MOVE_KINESIS: + case MOVE_SAND_ATTACK: + if (targetData->accuracyStages[STAT_STAGE_ACCURACY] <= 0) + { + return FALSE; + } + break; + case MOVE_TAUNT: + if (targetData->volatileStatus == VOLATILE_STATUS_TAUNTED) + { + return FALSE; + } + break; + case MOVE_TRICK: + if (!(userData->heldItem.itemFlags & ITEM_FLAG_EXISTS) || + !(targetData->heldItem.itemFlags & ITEM_FLAG_EXISTS)) + { + return FALSE; + } + break; + case MOVE_KNOCK_OFF: + if (!(targetData->heldItem.itemFlags & ITEM_FLAG_EXISTS)) + { + return FALSE; + } + break; + case MOVE_FEATHERDANCE: + case MOVE_GROWL: + if (targetData->attackStages[STAT_STAGE_ATTACK] <= 0) + { + return FALSE; + } + break; + case MOVE_ROLE_PLAY: + if (userData->abilities[0] == targetData->abilities[0] && + userData->abilities[1] == targetData->abilities[1]) + { + return FALSE; + } + break; + case MOVE_CURSE: + if (HasType(user, TYPE_GHOST)) + { + if (targetData->waitingStatus == WAITING_STATUS_CURSED) + { + return FALSE; + } + } + else + { + if (userData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE && + userData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE) + { + return FALSE; + } + } + break; + case MOVE_IMPRISON: + case MOVE_OBSERVER: + if (targetData->volatileStatus == VOLATILE_STATUS_PAUSED) + { + return FALSE; + } + break; + case MOVE_FALSE_SWIPE: + if (targetData->HP <= 1) + { + return FALSE; + } + break; + case MOVE_LEECH_SEED: + if (targetData->linkedStatus == LINKED_STATUS_LEECH_SEED) + { + return FALSE; + } + break; + case MOVE_PERISH_SONG: + if (targetData->perishSongTimer != 0) + { + return FALSE; + } + break; + case MOVE_MIMIC: + case MOVE_SKETCH: + if (!HasLastUsedMove(targetData->moves)) + { + return FALSE; + } + break; + case MOVE_ATTRACT: + if (targetData->volatileStatus == VOLATILE_STATUS_INFATUATED) + { + return FALSE; + } + break; + case MOVE_WRAP: + if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_WRAPPED_AROUND_FOE) + { + return FALSE; + } + if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_WRAPPED_BY_FOE) + { + return FALSE; + } + break; + case MOVE_TOXIC: + if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BADLY_POISONED) + { + return FALSE; + } + break; + case MOVE_POISON_GAS: + case MOVE_POISONPOWDER: + if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_POISONED) + { + return FALSE; + } + if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BADLY_POISONED) + { + return FALSE; + } + break; + case MOVE_CONFUSE_RAY: + case MOVE_FLATTER: + case MOVE_SUPERSONIC: + case MOVE_SWAGGER: + case MOVE_SWEET_KISS: + case MOVE_TEETER_DANCE: + case MOVE_TOTTER: + if (targetData->volatileStatus == VOLATILE_STATUS_CONFUSED) + { + return FALSE; + } + break; + } + return TRUE; +} |