Merge pull request #97 from AnonymousRandomPerson/master

More attack AI decomp
This commit is contained in:
Seth Barberee
2022-02-27 08:43:59 -08:00
committed by GitHub
82 changed files with 41835 additions and 42385 deletions

View File

@@ -4953,7 +4953,7 @@ sub_803F7BC:
ldrsh r0, [r5, r1]
movs r2, 0x2
ldrsh r1, [r5, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r1, [r0, 0x9]
ldr r2, _0803F808
adds r0, r4, r2

View File

@@ -232,7 +232,7 @@ _080402FC:
_08040302:
mov r0, r8
adds r1, r3, 0
bl GetMapTileAtPosition
bl GetMapTile_1
mov r9, r0
ldrh r0, [r0]
movs r5, 0x3
@@ -553,7 +553,7 @@ _0804056C:
adds r1, r3, 0
adds r1, 0x1
mov r0, r8
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -567,7 +567,7 @@ _0804058A:
adds r1, r5, 0
subs r1, 0x1
mov r0, r8
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -583,7 +583,7 @@ _080405AA:
mov r0, r8
adds r0, 0x1
ldr r1, [sp]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -598,7 +598,7 @@ _080405CA:
ble _080405E8
subs r0, 0x1
ldr r1, [sp]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -2523,8 +2523,8 @@ sub_80414C0:
cmp r0, 0x9C
bne _080414DC
adds r0, r5, 0
bl GetMapEntityForDungeonEntity
bl IsTileWater
bl GetMapTileForDungeonEntity_2
bl IsTileGround
lsls r0, 24
cmp r0, 0
bne _080414F2
@@ -2533,7 +2533,7 @@ _080414DC:
cmp r0, 0x8
bne _080414F6
adds r0, r5, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1

View File

@@ -2410,7 +2410,7 @@ _08043E6A:
_08043E6E:
adds r0, r5, 0
adds r1, r6, 0
bl GetMapEntity
bl GetMapTile_2
ldr r4, [r0, 0x14]
adds r0, r4, 0
bl EntityExists
@@ -2828,29 +2828,4 @@ _080441B4: .4byte gTeamInventory_203B460
_080441B8: .4byte gRecruitedPokemonRef
thumb_func_end sub_8044124
thumb_func_start IsBossBattle
IsBossBattle:
push {lr}
ldr r0, _080441D8
ldr r0, [r0]
ldr r1, _080441DC
adds r0, r1
movs r1, 0
ldrsh r0, [r0, r1]
cmp r0, 0
beq _080441E0
cmp r0, 0x31
bgt _080441E0
movs r0, 0x1
b _080441E2
.align 2, 0
_080441D8: .4byte gDungeonGlobalData
_080441DC: .4byte 0x00003a14
_080441E0:
movs r0, 0
_080441E2:
pop {r1}
bx r1
thumb_func_end IsBossBattle
.align 2, 0

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_8044CC8
sub_8044CC8:
push {lr}
@@ -33,7 +33,7 @@ _08044CEC:
ldrsh r0, [r2, r1]
movs r3, 0x6
ldrsh r1, [r2, r3]
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r0, [r0, 0x14]
bl GetItemData
b _08044D34

View File

@@ -792,7 +792,7 @@ sub_8045708:
ldrsh r0, [r1, r2]
movs r3, 0x2
ldrsh r1, [r1, r3]
bl GetMapEntity
bl GetMapTile_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1

View File

@@ -426,7 +426,7 @@ _08045CEE:
_08045CF6:
adds r0, r5, 0
adds r1, r6, 0
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r0, [r2]
movs r3, 0x80
@@ -542,7 +542,7 @@ sub_8045DB4:
ldrsh r0, [r1, r2]
movs r3, 0x2
ldrsh r1, [r1, r3]
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r4, [r0, 0x14]
cmp r4, 0
bne _08045DE8
@@ -958,7 +958,7 @@ _08046110:
ldrsh r0, [r5, r1]
movs r2, 0x2
ldrsh r1, [r5, r2]
bl GetMapEntity
bl GetMapTile_2
str r4, [r0, 0x14]
ldrh r1, [r0]
movs r0, 0x20
@@ -1044,7 +1044,7 @@ sub_80461C8:
ldrsh r0, [r2, r1]
movs r3, 0x2
ldrsh r1, [r2, r3]
bl GetMapEntity
bl GetMapTile_2
adds r6, r0, 0
ldr r5, [r6, 0x14]
cmp r5, 0
@@ -1187,7 +1187,7 @@ _080462E4:
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r0, [r0]
movs r1, 0x3
ands r1, r0
@@ -1492,7 +1492,7 @@ sub_804652C:
ldrsh r0, [r5, r1]
movs r2, 0x6
ldrsh r1, [r5, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r4, r0, 0
ldr r0, [r4, 0x14]
movs r3, 0
@@ -1559,7 +1559,7 @@ _080465A8:
movs r2, 0
ldrsh r0, [r0, r2]
asrs r1, 16
bl GetMapTileAtPosition
bl GetMapTile_1
adds r4, r0, 0
ldrh r1, [r4]
movs r6, 0x3
@@ -1630,7 +1630,7 @@ _08046644:
ldrsh r0, [r0, r3]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r0, [r0]
movs r1, 0x3
ands r1, r0
@@ -1999,7 +1999,7 @@ _08046904:
lsls r0, r4, 16
asrs r0, 16
asrs r1, r4, 16
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x3

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_8046CE4
sub_8046CE4:
push {r4,r5,lr}
@@ -715,7 +715,7 @@ _08047228:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
ldrh r1, [r5]
movs r0, 0x3
@@ -747,7 +747,7 @@ _0804727A:
ldrsh r1, [r1, r3]
adds r1, r2
str r2, [sp, 0x234]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -868,7 +868,7 @@ _0804737A:
ldrsh r0, [r7, r4]
movs r2, 0x6
ldrsh r1, [r7, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
ldrh r1, [r5]
movs r0, 0x3
@@ -1424,7 +1424,7 @@ _080477D0:
ldrsh r0, [r3, r1]
movs r2, 0x2
ldrsh r1, [r3, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r4, r0, 0
ldr r0, [r4, 0x10]
cmp r0, 0

3330
asm/code_80495E4.s Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2668,7 +2668,7 @@ _080538DA:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r0, [r0, 0x10]
str r0, [sp, 0x38]
bl EntityExists
@@ -7995,7 +7995,7 @@ _08056780:
movs r2, 0
ldrsh r0, [r6, r2]
asrs r1, 16
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x3
@@ -8307,7 +8307,7 @@ _08056A0E:
ldrsh r0, [r7, r2]
movs r6, 0x2
ldrsh r1, [r7, r6]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r6, r0, 0
ldrh r1, [r6]
movs r0, 0x3

View File

@@ -285,8 +285,8 @@ _08057340:
bx r1
thumb_func_end sub_8057308
thumb_func_start IsMoveUsable
IsMoveUsable:
thumb_func_start IsMoveUsable_1
IsMoveUsable_1:
push {r4-r7,lr}
mov r7, r8
push {r7}
@@ -357,7 +357,7 @@ _080573C0:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end IsMoveUsable
thumb_func_end IsMoveUsable_1
thumb_func_start IsMoveUsable_2
IsMoveUsable_2:
@@ -909,9 +909,9 @@ sub_8057788:
movs r0, 0
mov r9, r0
adds r0, r4, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
adds r5, r0, 0
bl IsTileWater
bl IsTileGround
lsls r0, 24
cmp r0, 0
beq _080577BA

File diff suppressed because it is too large Load Diff

25559
asm/code_805CEB8.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_8069E0C
sub_8069E0C:
push {r4-r7,lr}
@@ -850,7 +850,7 @@ _0806A488:
movs r2, 0x6
ldrsh r1, [r6, r2]
adds r1, r7
bl GetMapEntity
bl GetMapTile_2
adds r4, r0, 0
ldr r0, [r4, 0x10]
cmp r0, 0
@@ -1029,7 +1029,7 @@ sub_806A5B8:
b _0806A6D2
_0806A5CE:
adds r0, r6, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r0, [r0]
movs r1, 0x3
ands r1, r0
@@ -2565,7 +2565,7 @@ sub_806B168:
adds r1, r4
movs r2, 0
ldrsh r1, [r1, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r0, [r0, 0x9]
str r0, [sp, 0x2C]
movs r3, 0
@@ -2764,7 +2764,7 @@ _0806B2D2:
ldrsh r1, [r1, r4]
adds r1, r6, r1
str r3, [sp, 0x38]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
ldrb r0, [r1, 0x9]
ldr r3, [sp, 0x38]
@@ -2831,7 +2831,7 @@ _0806B366:
movs r3, 0
ldrsh r1, [r1, r3]
adds r1, r6, r1
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
mov r4, r8
movs r2, 0xE
@@ -2987,7 +2987,7 @@ _0806B4AE:
asrs r0, r5, 16
asrs r4, 16
adds r1, r4, 0
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r0, [r0, 0x9]
str r0, [sp, 0x20]
movs r2, 0
@@ -3050,7 +3050,7 @@ _0806B51C:
mov r5, r10
adds r1, r5
str r2, [sp, 0x2C]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
ldrb r0, [r1, 0x9]
ldr r2, [sp, 0x2C]
@@ -3116,7 +3116,7 @@ _0806B5A8:
mov r5, r10
adds r1, r5
str r2, [sp, 0x2C]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
movs r3, 0xE
ldrsh r0, [r6, r3]
@@ -3166,7 +3166,7 @@ _0806B606:
ldrsh r0, [r2, r1]
movs r3, 0x2
ldrsh r1, [r5, r3]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
movs r3, 0xE
ldrsh r0, [r6, r3]
@@ -3324,7 +3324,7 @@ _0806B740:
_0806B748:
adds r0, r5, 0
adds r1, r7, 0
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0, 0x4]
movs r0, 0x8
ands r0, r1
@@ -3426,7 +3426,7 @@ sub_806B7F8:
ldrsh r0, [r6, r1]
movs r2, 0xE
ldrsh r1, [r6, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
movs r3, 0
ldrsh r0, [r6, r3]
@@ -3572,7 +3572,7 @@ _0806B930:
_0806B932:
mov r0, r9
mov r1, r10
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
adds r0, r4, 0
bl sub_807034C

View File

@@ -142,7 +142,7 @@ _0806CF94: .4byte 0x000135cc
sub_806CF98:
push {r4-r7,lr}
adds r4, r0, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r0, [r0]
movs r5, 0x3
ands r5, r0
@@ -1123,7 +1123,7 @@ _0806D760:
cmp r0, 0
beq _0806D796
adds r0, r7, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
mov r8, r0
movs r0, 0x14
movs r1, 0x18

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_807034C
sub_807034C:
push {r4,lr}
@@ -67,7 +67,7 @@ sub_80703A0:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
@@ -203,7 +203,7 @@ sub_807049C:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
@@ -309,7 +309,7 @@ sub_8070564:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
@@ -387,7 +387,7 @@ sub_80705F0:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]
@@ -480,7 +480,7 @@ sub_80706A4:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r5, r0, 0
movs r1, 0
ldrsh r0, [r4, r1]

View File

@@ -1,33 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start HasQuarterHPOrLess
HasQuarterHPOrLess:
push {lr}
ldr r0, [r0, 0x70]
adds r1, r0, 0
movs r2, 0x10
ldrsh r0, [r1, r2]
cmp r0, 0
bge _08070B58
adds r0, 0x3
_08070B58:
movs r2, 0xE
ldrsh r1, [r1, r2]
asrs r0, 2
cmp r1, r0
ble _08070B66
movs r0, 0
b _08070B68
_08070B66:
movs r0, 0x1
_08070B68:
pop {r1}
bx r1
thumb_func_end HasQuarterHPOrLess
.align 2, 0

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_8070E3C
sub_8070E3C:
push {r4-r7,lr}
@@ -30,7 +30,7 @@ sub_8070E3C:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
@@ -89,7 +89,7 @@ _08070EDC:
ldrsh r0, [r6, r1]
movs r2, 0x2
ldrsh r1, [r6, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
@@ -133,7 +133,7 @@ sub_8070F14:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
@@ -147,7 +147,7 @@ sub_8070F14:
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldr r1, _08070F74
movs r0, 0x7
@@ -195,7 +195,7 @@ sub_8070F80:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
@@ -254,7 +254,7 @@ _08071020:
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
@@ -304,7 +304,7 @@ sub_8071058:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r4, r0, 0
ldrh r1, [r4]
movs r0, 0x10
@@ -368,7 +368,7 @@ _08071100:
ldrsh r0, [r5, r1]
movs r2, 0x6
ldrsh r1, [r5, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r4, r0, 0
adds r1, r4, 0
adds r1, 0xA
@@ -394,420 +394,4 @@ _08071132:
bx r1
thumb_func_end sub_8071058
thumb_func_start CanAttackInFront
CanAttackInFront:
push {r4-r6,lr}
adds r4, r0, 0
adds r6, r1, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x1
bhi _08071152
movs r5, 0x2
_08071152:
movs r2, 0x4
ldrsh r0, [r4, r2]
ldr r1, _080711B0
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _0807120C
ldr r0, [r2, 0x10]
cmp r0, 0
beq _0807118A
bl GetEntityType
cmp r0, 0x1
bne _0807120C
_0807118A:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _080711DC
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _080711AC
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _080711B4
_080711AC:
movs r5, 0x3
b _080711DC
.align 2, 0
_080711B0: .4byte gAdjacentTileOffsets
_080711B4:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _080711DA
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080711DC
movs r0, 0x1
ands r0, r6
movs r5, 0x3
cmp r0, 0
beq _080711DC
_080711DA:
movs r5, 0x2
_080711DC:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
adds r1, r5
ldr r2, _08071208
movs r0, 0x7
ands r0, r6
adds r0, r2
ldrb r1, [r1]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _0807120C
movs r0, 0x1
b _0807120E
.align 2, 0
_08071208: .4byte gDirectionBitMasks_2
_0807120C:
movs r0, 0
_0807120E:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CanAttackInFront
thumb_func_start CanMoveForward
CanMoveForward:
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r4, r0, 0
adds r7, r1, 0
mov r8, r2
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r6, r0, 24
movs r0, 0
mov r2, r8
strb r0, [r2]
movs r3, 0x4
ldrsh r0, [r4, r3]
ldr r1, _0807130C
lsls r2, r7, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
adds r5, r0, 0
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
beq _08071260
b _0807137E
_08071260:
movs r0, 0x40
ands r0, r1
cmp r0, 0
beq _08071286
ldr r0, _08071310
ldr r0, [r0]
ldr r1, _08071314
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _08071286
adds r0, r4, 0
movs r1, 0xF
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071286
b _0807137E
_08071286:
ldr r0, [r5, 0x14]
cmp r0, 0
beq _080712B8
adds r0, r4, 0
movs r1, 0xE
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080712B8
ldr r0, [r5, 0x14]
bl GetEntityType
cmp r0, 0x2
bne _080712B8
ldr r0, [r5, 0x14]
adds r0, 0x20
ldrb r0, [r0]
cmp r0, 0
bne _0807137E
ldr r0, [r4, 0x70]
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x3
beq _0807137E
_080712B8:
ldrh r1, [r5]
movs r0, 0x3
ands r0, r1
cmp r0, 0x2
bne _080712E6
ldr r1, _08071318
ldr r0, _08071310
ldr r0, [r0]
ldr r2, _0807131C
adds r0, r2
movs r3, 0
ldrsh r0, [r0, r3]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _080712E6
adds r0, r4, 0
movs r1, 0x14
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _0807137E
_080712E6:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08071348
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08071308
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08071320
_08071308:
movs r6, 0x3
b _08071348
.align 2, 0
_0807130C: .4byte gAdjacentTileOffsets
_08071310: .4byte gDungeonGlobalData
_08071314: .4byte 0x00000671
_08071318: .4byte gDungeonWaterType
_0807131C: .4byte 0x00003a0e
_08071320:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _08071346
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071348
movs r0, 0x1
ands r0, r7
movs r6, 0x3
cmp r0, 0
beq _08071348
_08071346:
movs r6, 0x2
_08071348:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r0, 0xA
adds r0, r6
ldr r2, _08071374
movs r1, 0x7
ands r1, r7
adds r1, r2
ldrb r2, [r0]
ldrb r0, [r1]
ands r0, r2
cmp r0, 0
beq _0807137E
ldr r0, [r5, 0x10]
cmp r0, 0
bne _08071378
movs r0, 0x1
b _08071380
.align 2, 0
_08071374: .4byte gDirectionBitMasks_3
_08071378:
movs r0, 0x1
mov r3, r8
strb r0, [r3]
_0807137E:
movs r0, 0
_08071380:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end CanMoveForward
thumb_func_start IsAtJunction
IsAtJunction:
push {r4,r5,lr}
adds r4, r0, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _080713E2
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _080713E0
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _080713E0
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713D2
movs r5, 0x2
b _080713E2
_080713D2:
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713E2
_080713E0:
movs r5, 0x3
_080713E2:
cmp r5, 0x3
bne _08071408
ldr r4, [r4, 0x70]
movs r0, 0x64
bl DungeonRandomCapped
movs r1, 0xFD
lsls r1, 1
adds r2, r4, r1
ldrh r1, [r2]
adds r1, r0
strh r1, [r2]
lsls r1, 16
asrs r1, 16
cmp r1, 0xC7
ble _08071458
movs r0, 0
strh r0, [r2]
b _08071468
_08071408:
ldr r1, _0807145C
ldr r0, _08071460
ldr r0, [r0]
ldr r2, _08071464
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _08071432
cmp r5, 0x1
bne _08071432
adds r0, r4, 0
movs r1, 0x14
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071432
movs r5, 0
_08071432:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
adds r0, 0xA
adds r0, r5
ldrb r0, [r0]
cmp r0, 0x54
beq _08071468
cmp r0, 0x51
beq _08071468
cmp r0, 0x45
beq _08071468
cmp r0, 0x15
beq _08071468
cmp r0, 0x55
beq _08071468
_08071458:
movs r0, 0
b _0807146A
.align 2, 0
_0807145C: .4byte gDungeonWaterType
_08071460: .4byte gDungeonGlobalData
_08071464: .4byte 0x00003a0e
_08071468:
movs r0, 0x1
_0807146A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end IsAtJunction
.align 2, 0
.align 2, 0

311
asm/code_8071214.s Normal file
View File

@@ -0,0 +1,311 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start CanMoveForward
CanMoveForward:
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r4, r0, 0
adds r7, r1, 0
mov r8, r2
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r6, r0, 24
movs r0, 0
mov r2, r8
strb r0, [r2]
movs r3, 0x4
ldrsh r0, [r4, r3]
ldr r1, _0807130C
lsls r2, r7, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
adds r5, r0, 0
ldrh r1, [r5]
movs r0, 0x10
ands r0, r1
cmp r0, 0
beq _08071260
b _0807137E
_08071260:
movs r0, 0x40
ands r0, r1
cmp r0, 0
beq _08071286
ldr r0, _08071310
ldr r0, [r0]
ldr r1, _08071314
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _08071286
adds r0, r4, 0
movs r1, 0xF
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071286
b _0807137E
_08071286:
ldr r0, [r5, 0x14]
cmp r0, 0
beq _080712B8
adds r0, r4, 0
movs r1, 0xE
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080712B8
ldr r0, [r5, 0x14]
bl GetEntityType
cmp r0, 0x2
bne _080712B8
ldr r0, [r5, 0x14]
adds r0, 0x20
ldrb r0, [r0]
cmp r0, 0
bne _0807137E
ldr r0, [r4, 0x70]
adds r0, 0xE8
ldrb r0, [r0]
cmp r0, 0x3
beq _0807137E
_080712B8:
ldrh r1, [r5]
movs r0, 0x3
ands r0, r1
cmp r0, 0x2
bne _080712E6
ldr r1, _08071318
ldr r0, _08071310
ldr r0, [r0]
ldr r2, _0807131C
adds r0, r2
movs r3, 0
ldrsh r0, [r0, r3]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _080712E6
adds r0, r4, 0
movs r1, 0x14
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _0807137E
_080712E6:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08071348
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08071308
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08071320
_08071308:
movs r6, 0x3
b _08071348
.align 2, 0
_0807130C: .4byte gAdjacentTileOffsets
_08071310: .4byte gDungeonGlobalData
_08071314: .4byte 0x00000671
_08071318: .4byte gDungeonWaterType
_0807131C: .4byte 0x00003a0e
_08071320:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _08071346
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071348
movs r0, 0x1
ands r0, r7
movs r6, 0x3
cmp r0, 0
beq _08071348
_08071346:
movs r6, 0x2
_08071348:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTile_1
adds r0, 0xA
adds r0, r6
ldr r2, _08071374
movs r1, 0x7
ands r1, r7
adds r1, r2
ldrb r2, [r0]
ldrb r0, [r1]
ands r0, r2
cmp r0, 0
beq _0807137E
ldr r0, [r5, 0x10]
cmp r0, 0
bne _08071378
movs r0, 0x1
b _08071380
.align 2, 0
_08071374: .4byte gDirectionBitMasks_3
_08071378:
movs r0, 0x1
mov r3, r8
strb r0, [r3]
_0807137E:
movs r0, 0
_08071380:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end CanMoveForward
thumb_func_start IsAtJunction
IsAtJunction:
push {r4,r5,lr}
adds r4, r0, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _080713E2
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _080713E0
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _080713E0
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713D2
movs r5, 0x2
b _080713E2
_080713D2:
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713E2
_080713E0:
movs r5, 0x3
_080713E2:
cmp r5, 0x3
bne _08071408
ldr r4, [r4, 0x70]
movs r0, 0x64
bl DungeonRandomCapped
movs r1, 0xFD
lsls r1, 1
adds r2, r4, r1
ldrh r1, [r2]
adds r1, r0
strh r1, [r2]
lsls r1, 16
asrs r1, 16
cmp r1, 0xC7
ble _08071458
movs r0, 0
strh r0, [r2]
b _08071468
_08071408:
ldr r1, _0807145C
ldr r0, _08071460
ldr r0, [r0]
ldr r2, _08071464
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _08071432
cmp r5, 0x1
bne _08071432
adds r0, r4, 0
movs r1, 0x14
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071432
movs r5, 0
_08071432:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTile_1
adds r0, 0xA
adds r0, r5
ldrb r0, [r0]
cmp r0, 0x54
beq _08071468
cmp r0, 0x51
beq _08071468
cmp r0, 0x45
beq _08071468
cmp r0, 0x15
beq _08071468
cmp r0, 0x55
beq _08071468
_08071458:
movs r0, 0
b _0807146A
.align 2, 0
_0807145C: .4byte gDungeonWaterType
_08071460: .4byte gDungeonGlobalData
_08071464: .4byte 0x00003a0e
_08071468:
movs r0, 0x1
_0807146A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end IsAtJunction
.align 2, 0

View File

@@ -189,7 +189,7 @@ _08071C08:
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r0, [r0]
movs r2, 0x80
lsls r2, 1
@@ -2247,7 +2247,7 @@ _08072C0C:
movs r3, 0x6
ldrsh r2, [r7, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
ldr r0, _08072C80
bl sub_807034C

View File

@@ -15,7 +15,7 @@ sub_8073D14:
sub sp, 0xB0
adds r6, r0, 0
ldr r4, [r6, 0x70]
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldr r5, [r0, 0x14]
cmp r5, 0
bne _08073D30
@@ -3218,7 +3218,7 @@ sub_8075708:
cmp r0, 0
beq _0807580C
adds r0, r4, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
adds r5, r0, 0
adds r0, r4, 0
movs r1, 0xD

View File

@@ -860,7 +860,7 @@ _08076292:
_08076298: .4byte gUnknown_80FCE84
_0807629C:
adds r0, r5, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -966,7 +966,7 @@ _08076362:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r4, [r0, 0x10]
adds r0, r4, 0
bl EntityExists
@@ -1198,7 +1198,7 @@ _08076544:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r4, [r0, 0x10]
adds r0, r4, 0
bl EntityExists
@@ -1421,7 +1421,7 @@ _08076714:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r4, [r0, 0x10]
adds r0, r4, 0
bl EntityExists
@@ -1542,7 +1542,7 @@ _08076814:
_0807682C: .4byte gUnknown_80FCE00
_08076830:
adds r0, r5, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -3545,7 +3545,7 @@ _08077874:
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
bl GetMapTile_1
ldr r4, [r0, 0x10]
adds r0, r4, 0
bl EntityExists
@@ -9836,7 +9836,7 @@ sub_807AB38:
_0807AB54:
adds r0, r2, 0
str r2, [sp, 0x1A4]
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
ldrh r1, [r0]
movs r0, 0x40
ands r0, r1
@@ -9898,7 +9898,7 @@ _0807ABC6:
adds r0, r4, 0
adds r1, r6, 0
str r2, [sp, 0x1A4]
bl GetMapEntity
bl GetMapTile_2
adds r1, r0, 0
ldr r0, [r1, 0x10]
ldr r2, [sp, 0x1A4]
@@ -9988,7 +9988,7 @@ _0807AC72:
adds r0, r4, 0
adds r1, r6, 0
str r2, [sp, 0x1A4]
bl GetMapEntity
bl GetMapTile_2
adds r1, r0, 0
ldr r0, [r1, 0x10]
ldr r2, [sp, 0x1A4]
@@ -10300,7 +10300,7 @@ CanTakeItem:
cmp r0, 0
bne _0807AF50
adds r0, r4, 0
bl GetMapEntityForDungeonEntity
bl GetMapTileForDungeonEntity_2
adds r6, r0, 0
ldr r4, [r6, 0x14]
cmp r4, 0
@@ -10658,7 +10658,7 @@ _0807B17C:
ldrsh r0, [r2, r3]
movs r3, 0x6
ldrsh r1, [r2, r3]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r1, [r0, 0x9]
cmp r1, 0xFF
bne _0807B1C4
@@ -10712,7 +10712,7 @@ _0807B1FA:
_0807B200:
adds r0, r4, 0
adds r1, r5, 0
bl GetMapEntity
bl GetMapTile_2
ldr r0, [r0, 0x14]
cmp r0, 0
beq _0807B216
@@ -11372,7 +11372,7 @@ _0807B6FE:
ldrsh r0, [r7, r4]
movs r2, 0x6
ldrsh r1, [r7, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x8
ands r0, r1
@@ -11400,7 +11400,7 @@ _0807B71E:
lsls r0, r5, 16
asrs r0, 16
asrs r1, r5, 16
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r0, [r0, 0x9]
cmp r0, r10
beq _0807B758
@@ -11848,7 +11848,7 @@ _0807BAA2:
ldrsh r0, [r6, r1]
movs r2, 0x6
ldrsh r1, [r6, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x8
ands r0, r1
@@ -11878,7 +11878,7 @@ _0807BAC4:
adds r5, r2, r0
mov r0, r8
adds r1, r5, 0
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r0, [r0, 0x9]
cmp r0, 0xFF
bne _0807BB04

View File

@@ -133,610 +133,4 @@ _0807C57A:
bx r1
thumb_func_end IsTargetInLineRange
thumb_func_start WeightMoveIfUsable
WeightMoveIfUsable:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
adds r6, r0, 0
adds r5, r2, 0
adds r7, r3, 0
ldr r0, [sp, 0x28]
lsls r1, 16
asrs r1, 16
mov r9, r1
lsls r0, 24
lsrs r0, 24
mov r10, r0
ldr r2, [r5, 0x70]
ldr r1, [r5, 0x4]
ldr r0, [r7, 0x4]
cmp r1, r0
beq _0807C5BC
movs r0, 0xF0
mov r1, r9
ands r0, r1
cmp r0, 0x30
beq _0807C5BC
cmp r0, 0x60
beq _0807C5BC
cmp r0, 0x70
bne _0807C5C4
_0807C5BC:
adds r0, r2, 0
adds r0, 0x46
ldrb r4, [r0]
b _0807C5CE
_0807C5C4:
adds r0, r5, 0x4
adds r1, r7, 0x4
bl CalculateFacingDir
adds r4, r0, 0
_0807C5CE:
ldr r0, _0807C638
adds r0, r4
mov r8, r0
ldrb r0, [r0]
cmp r0, 0
bne _0807C624
mov r0, r10
str r0, [sp]
mov r0, r9
adds r1, r5, 0
adds r2, r7, 0
ldr r3, [sp, 0x24]
bl CanUseStatusMove
lsls r0, 24
cmp r0, 0
beq _0807C624
movs r0, 0x1
mov r1, r8
strb r0, [r1]
ldr r0, _0807C63C
adds r0, r6, r0
strb r4, [r0]
adds r0, r5, 0
ldr r1, [sp, 0x24]
bl GetMoveTypeForPokemon
adds r3, r0, 0
lsls r3, 24
lsrs r3, 24
adds r0, r5, 0
mov r1, r9
adds r2, r7, 0
bl WeightMove
ldr r1, _0807C640
lsls r2, r6, 2
adds r1, r2, r1
str r0, [r1]
ldr r0, _0807C644
adds r2, r0
str r7, [r2]
adds r6, 0x1
_0807C624:
adds r0, r6, 0
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0807C638: .4byte gCanAttackInDirection
_0807C63C: .4byte gPotentialAttackTargetDirections
_0807C640: .4byte gPotentialTargetWeights_2
_0807C644: .4byte gPotentialTargets
thumb_func_end WeightMoveIfUsable
thumb_func_start CanUseStatusMove
CanUseStatusMove:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r5, r1, 0
adds r4, r2, 0
mov r8, r3
ldr r1, [sp, 0x1C]
lsls r0, 16
asrs r6, r0, 16
lsls r1, 24
lsrs r1, 24
mov r9, r1
movs r7, 0
movs r0, 0xF
ands r0, r6
adds r1, r0, 0
cmp r1, 0
bne _0807C686
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807C6E0
movs r7, 0x1
b _0807C6E4
_0807C686:
cmp r1, 0x1
beq _0807C6BE
cmp r1, 0x2
bne _0807C692
ldr r1, [r4, 0x70]
b _0807C69C
_0807C692:
cmp r1, 0x5
bne _0807C6B6
ldr r1, [r4, 0x70]
cmp r5, r4
beq _0807C6B2
_0807C69C:
movs r7, 0x1
ldrb r0, [r1, 0x8]
cmp r0, 0x1
beq _0807C6B2
adds r0, r1, 0
adds r0, 0xA4
ldrb r0, [r0]
cmp r0, 0x4
beq _0807C6B2
cmp r0, 0x1
bne _0807C6E0
_0807C6B2:
movs r0, 0
b _0807C7A0
_0807C6B6:
cmp r1, 0x6
bne _0807C6D4
cmp r5, r4
beq _0807C6B2
_0807C6BE:
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
lsls r0, 24
cmp r0, 0
bne _0807C6E0
movs r7, 0x1
b _0807C6E4
_0807C6D4:
subs r0, 0x3
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1
bhi _0807C6E0
movs r7, 0x1
_0807C6E0:
cmp r7, 0
beq _0807C79E
_0807C6E4:
mov r0, r9
cmp r0, 0
beq _0807C77C
adds r0, r5, 0
adds r1, r4, 0
mov r2, r8
bl CanUseWithStatusChecker_2
lsls r0, 24
cmp r0, 0
beq _0807C6B2
movs r1, 0xF0
lsls r1, 4
ands r1, r6
movs r0, 0x80
lsls r0, 1
cmp r1, r0
beq _0807C78A
movs r0, 0x80
lsls r0, 2
cmp r1, r0
beq _0807C76E
movs r0, 0xC0
lsls r0, 2
cmp r1, r0
bne _0807C720
adds r0, r4, 0
bl HasNegativeStatus
b _0807C774
_0807C720:
movs r0, 0x80
lsls r0, 3
cmp r1, r0
bne _0807C730
adds r0, r4, 0
bl IsSleeping
b _0807C774
_0807C730:
movs r0, 0xC0
lsls r0, 3
cmp r1, r0
bne _0807C75A
ldr r1, [r4, 0x70]
adds r0, r1, 0
adds r0, 0x5C
ldrb r0, [r0]
cmp r0, 0xE
beq _0807C74E
adds r0, r1, 0
adds r0, 0x5D
ldrb r0, [r0]
cmp r0, 0xE
bne _0807C6B2
_0807C74E:
adds r0, r1, 0
adds r0, 0xF5
ldrb r0, [r0]
cmp r0, 0
beq _0807C79E
b _0807C6B2
_0807C75A:
movs r0, 0xA0
lsls r0, 3
cmp r1, r0
bne _0807C79E
adds r0, r4, 0
bl HasNegativeStatus
lsls r0, 24
cmp r0, 0
bne _0807C79E
_0807C76E:
adds r0, r4, 0
bl HasQuarterHPOrLess
_0807C774:
lsls r0, 24
cmp r0, 0
bne _0807C79E
b _0807C6B2
_0807C77C:
movs r0, 0xF0
lsls r0, 4
ands r0, r6
movs r1, 0x80
lsls r1, 1
cmp r0, r1
bne _0807C79E
_0807C78A:
mov r0, r8
movs r1, 0x2
bl GetMoveAccuracy
adds r4, r0, 0
movs r0, 0x64
bl DungeonRandomCapped
cmp r0, r4
bge _0807C6B2
_0807C79E:
adds r0, r7, 0
_0807C7A0:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end CanUseStatusMove
thumb_func_start WeightMove
WeightMove:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r5, r0, 0
mov r8, r2
lsls r1, 16
asrs r1, 16
lsls r3, 24
lsrs r3, 24
mov r9, r3
movs r6, 0x1
ldr r4, [r2, 0x70]
adds r7, r4, 0
ldrb r0, [r4, 0x6]
cmp r0, 0
beq _0807C7D6
movs r0, 0xF
ands r0, r1
cmp r0, 0
beq _0807C7DA
_0807C7D6:
movs r0, 0x1
b _0807C848
_0807C7DA:
adds r0, r5, 0
movs r1, 0x9
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C804
ldr r0, _0807C7FC
ldr r0, [r0]
movs r2, 0x2
ldrsh r1, [r4, r2]
ldr r2, _0807C800
adds r0, r2
adds r0, r1
ldrb r6, [r0]
b _0807C846
.align 2, 0
_0807C7FC: .4byte gDungeonGlobalData
_0807C800: .4byte 0x0000363c
_0807C804:
adds r0, r5, 0
movs r1, 0xA
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C828
ldrb r1, [r7, 0xE]
movs r2, 0xC
negs r2, r2
adds r0, r2, 0
subs r0, r1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
bne _0807C846
movs r6, 0x1
b _0807C846
_0807C828:
adds r0, r5, 0
movs r1, 0xB
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C846
adds r0, r5, 0
mov r1, r8
mov r2, r9
bl WeightWeakTypePicker
adds r0, 0x1
lsls r0, 24
lsrs r6, r0, 24
_0807C846:
adds r0, r6, 0
_0807C848:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end WeightMove
thumb_func_start TargetRegularAttack
TargetRegularAttack:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x50
adds r7, r0, 0
str r1, [sp, 0x40]
lsls r2, 24
lsrs r2, 24
str r2, [sp, 0x44]
ldr r0, [r7, 0x70]
movs r1, 0
mov r8, r1
adds r1, r0, 0
adds r1, 0x46
ldrb r6, [r1]
adds r0, 0xE8
ldrb r0, [r0]
movs r3, 0x8
mov r10, r3
cmp r0, 0x1
bne _0807C886
movs r0, 0x1
mov r10, r0
_0807C886:
movs r4, 0
adds r0, r7, 0
movs r1, 0x9
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _0807C8A4
adds r0, r7, 0
movs r1, 0xA
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C8A6
_0807C8A4:
movs r4, 0x1
_0807C8A6:
str r4, [sp, 0x48]
adds r0, r7, 0
movs r1, 0x8
bl HasIQSkill
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x4C]
movs r1, 0
mov r9, r1
cmp r9, r10
bge _0807C952
_0807C8BE:
movs r0, 0x7
ands r6, r0
movs r3, 0x4
ldrsh r0, [r7, r3]
ldr r1, _0807C95C
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r7, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTileAtPosition
ldr r5, [r0, 0x10]
cmp r5, 0
beq _0807C948
adds r0, r5, 0
bl GetEntityType
cmp r0, 0x1
bne _0807C948
adds r0, r7, 0
adds r1, r6, 0
bl CanAttackInFront
lsls r0, 24
cmp r0, 0
beq _0807C948
adds r0, r7, 0
adds r1, r5, 0
movs r2, 0
ldr r3, [sp, 0x44]
bl CanTarget
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807C948
ldr r0, [sp, 0x4C]
cmp r0, 0
beq _0807C922
ldr r0, [r5, 0x70]
adds r0, 0xB0
ldrb r0, [r0]
cmp r0, 0x1
beq _0807C948
_0807C922:
mov r1, r8
lsls r4, r1, 2
mov r3, sp
adds r0, r3, r4
str r6, [r0]
adds r0, r7, 0
movs r1, 0
adds r2, r5, 0
movs r3, 0
bl WeightMove
add r1, sp, 0x20
adds r1, r4
str r0, [r1]
ldr r0, [sp, 0x48]
cmp r0, 0
beq _0807C960
movs r1, 0x1
add r8, r1
_0807C948:
movs r3, 0x1
add r9, r3
adds r6, 0x1
cmp r9, r10
blt _0807C8BE
_0807C952:
mov r0, r8
cmp r0, 0
bne _0807C966
movs r0, 0
b _0807C9E8
.align 2, 0
_0807C95C: .4byte gAdjacentTileOffsets
_0807C960:
ldr r1, [sp, 0x40]
str r6, [r1]
b _0807C9E6
_0807C966:
movs r4, 0
movs r3, 0
mov r0, r8
cmp r0, 0
ble _0807C984
add r1, sp, 0x20
mov r2, r8
_0807C974:
ldr r0, [r1]
cmp r3, r0
bge _0807C97C
adds r3, r0, 0
_0807C97C:
adds r1, 0x4
subs r2, 0x1
cmp r2, 0
bne _0807C974
_0807C984:
mov r1, r8
cmp r1, 0
ble _0807C9A0
movs r5, 0
add r1, sp, 0x20
mov r2, r8
_0807C990:
ldr r0, [r1]
cmp r3, r0
beq _0807C998
str r5, [r1]
_0807C998:
adds r1, 0x4
subs r2, 0x1
cmp r2, 0
bne _0807C990
_0807C9A0:
mov r3, r8
cmp r3, 0
ble _0807C9B4
add r1, sp, 0x20
mov r2, r8
_0807C9AA:
ldm r1!, {r0}
adds r4, r0
subs r2, 0x1
cmp r2, 0
bne _0807C9AA
_0807C9B4:
adds r0, r4, 0
bl DungeonRandomCapped
adds r1, r0, 0
movs r2, 0
cmp r2, r8
bge _0807C9DC
ldr r0, [sp, 0x20]
subs r1, r0
cmp r1, 0
blt _0807C9DC
add r3, sp, 0x20
_0807C9CC:
adds r3, 0x4
adds r2, 0x1
cmp r2, r8
bge _0807C9DC
ldr r0, [r3]
subs r1, r0
cmp r1, 0
bge _0807C9CC
_0807C9DC:
lsls r0, r2, 2
add r0, sp
ldr r0, [r0]
ldr r1, [sp, 0x40]
str r0, [r1]
_0807C9E6:
movs r0, 0x1
_0807C9E8:
add sp, 0x50
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end TargetRegularAttack
.align 2, 0

322
asm/code_807C7AC.s Normal file
View File

@@ -0,0 +1,322 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start WeightMove
WeightMove:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r5, r0, 0
mov r8, r2
lsls r1, 16
asrs r1, 16
lsls r3, 24
lsrs r3, 24
mov r9, r3
movs r6, 0x1
ldr r4, [r2, 0x70]
adds r7, r4, 0
ldrb r0, [r4, 0x6]
cmp r0, 0
beq _0807C7D6
movs r0, 0xF
ands r0, r1
cmp r0, 0
beq _0807C7DA
_0807C7D6:
movs r0, 0x1
b _0807C848
_0807C7DA:
adds r0, r5, 0
movs r1, 0x9
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C804
ldr r0, _0807C7FC
ldr r0, [r0]
movs r2, 0x2
ldrsh r1, [r4, r2]
ldr r2, _0807C800
adds r0, r2
adds r0, r1
ldrb r6, [r0]
b _0807C846
.align 2, 0
_0807C7FC: .4byte gDungeonGlobalData
_0807C800: .4byte 0x0000363c
_0807C804:
adds r0, r5, 0
movs r1, 0xA
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C828
ldrb r1, [r7, 0xE]
movs r2, 0xC
negs r2, r2
adds r0, r2, 0
subs r0, r1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
bne _0807C846
movs r6, 0x1
b _0807C846
_0807C828:
adds r0, r5, 0
movs r1, 0xB
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C846
adds r0, r5, 0
mov r1, r8
mov r2, r9
bl WeightWeakTypePicker
adds r0, 0x1
lsls r0, 24
lsrs r6, r0, 24
_0807C846:
adds r0, r6, 0
_0807C848:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end WeightMove
thumb_func_start TargetRegularAttack
TargetRegularAttack:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x50
adds r7, r0, 0
str r1, [sp, 0x40]
lsls r2, 24
lsrs r2, 24
str r2, [sp, 0x44]
ldr r0, [r7, 0x70]
movs r1, 0
mov r8, r1
adds r1, r0, 0
adds r1, 0x46
ldrb r6, [r1]
adds r0, 0xE8
ldrb r0, [r0]
movs r3, 0x8
mov r10, r3
cmp r0, 0x1
bne _0807C886
movs r0, 0x1
mov r10, r0
_0807C886:
movs r4, 0
adds r0, r7, 0
movs r1, 0x9
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _0807C8A4
adds r0, r7, 0
movs r1, 0xA
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _0807C8A6
_0807C8A4:
movs r4, 0x1
_0807C8A6:
str r4, [sp, 0x48]
adds r0, r7, 0
movs r1, 0x8
bl HasIQSkill
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x4C]
movs r1, 0
mov r9, r1
cmp r9, r10
bge _0807C952
_0807C8BE:
movs r0, 0x7
ands r6, r0
movs r3, 0x4
ldrsh r0, [r7, r3]
ldr r1, _0807C95C
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r7, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
ldr r5, [r0, 0x10]
cmp r5, 0
beq _0807C948
adds r0, r5, 0
bl GetEntityType
cmp r0, 0x1
bne _0807C948
adds r0, r7, 0
adds r1, r6, 0
bl CanAttackInFront
lsls r0, 24
cmp r0, 0
beq _0807C948
adds r0, r7, 0
adds r1, r5, 0
movs r2, 0
ldr r3, [sp, 0x44]
bl CanTarget
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807C948
ldr r0, [sp, 0x4C]
cmp r0, 0
beq _0807C922
ldr r0, [r5, 0x70]
adds r0, 0xB0
ldrb r0, [r0]
cmp r0, 0x1
beq _0807C948
_0807C922:
mov r1, r8
lsls r4, r1, 2
mov r3, sp
adds r0, r3, r4
str r6, [r0]
adds r0, r7, 0
movs r1, 0
adds r2, r5, 0
movs r3, 0
bl WeightMove
add r1, sp, 0x20
adds r1, r4
str r0, [r1]
ldr r0, [sp, 0x48]
cmp r0, 0
beq _0807C960
movs r1, 0x1
add r8, r1
_0807C948:
movs r3, 0x1
add r9, r3
adds r6, 0x1
cmp r9, r10
blt _0807C8BE
_0807C952:
mov r0, r8
cmp r0, 0
bne _0807C966
movs r0, 0
b _0807C9E8
.align 2, 0
_0807C95C: .4byte gAdjacentTileOffsets
_0807C960:
ldr r1, [sp, 0x40]
str r6, [r1]
b _0807C9E6
_0807C966:
movs r4, 0
movs r3, 0
mov r0, r8
cmp r0, 0
ble _0807C984
add r1, sp, 0x20
mov r2, r8
_0807C974:
ldr r0, [r1]
cmp r3, r0
bge _0807C97C
adds r3, r0, 0
_0807C97C:
adds r1, 0x4
subs r2, 0x1
cmp r2, 0
bne _0807C974
_0807C984:
mov r1, r8
cmp r1, 0
ble _0807C9A0
movs r5, 0
add r1, sp, 0x20
mov r2, r8
_0807C990:
ldr r0, [r1]
cmp r3, r0
beq _0807C998
str r5, [r1]
_0807C998:
adds r1, 0x4
subs r2, 0x1
cmp r2, 0
bne _0807C990
_0807C9A0:
mov r3, r8
cmp r3, 0
ble _0807C9B4
add r1, sp, 0x20
mov r2, r8
_0807C9AA:
ldm r1!, {r0}
adds r4, r0
subs r2, 0x1
cmp r2, 0
bne _0807C9AA
_0807C9B4:
adds r0, r4, 0
bl DungeonRandomCapped
adds r1, r0, 0
movs r2, 0
cmp r2, r8
bge _0807C9DC
ldr r0, [sp, 0x20]
subs r1, r0
cmp r1, 0
blt _0807C9DC
add r3, sp, 0x20
_0807C9CC:
adds r3, 0x4
adds r2, 0x1
cmp r2, r8
bge _0807C9DC
ldr r0, [r3]
subs r1, r0
cmp r1, 0
bge _0807C9CC
_0807C9DC:
lsls r0, r2, 2
add r0, sp
ldr r0, [r0]
ldr r1, [sp, 0x40]
str r0, [r1]
_0807C9E6:
movs r0, 0x1
_0807C9E8:
add sp, 0x50
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end TargetRegularAttack
.align 2, 0

File diff suppressed because it is too large Load Diff

2889
asm/code_807E5AC.s Normal file

File diff suppressed because it is too large Load Diff

6601
asm/code_807FCD4.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start InSameRoom_3
InSameRoom_3:
push {r4-r6,lr}
@@ -14,7 +14,7 @@ InSameRoom_3:
ldrsh r0, [r4, r1]
movs r2, 0x2
ldrsh r1, [r4, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrb r2, [r0, 0x9]
cmp r2, 0xFF
beq _08083394
@@ -107,7 +107,7 @@ sub_80833E8:
ldrsh r0, [r5, r1]
movs r2, 0x2
ldrsh r1, [r5, r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
ldr r0, _08083438
ldr r3, [r0]
@@ -253,7 +253,7 @@ _080834F8:
adds r0, r5, 0
adds r1, r4, 0
str r3, [sp]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -292,7 +292,7 @@ _0808353E:
adds r0, r5, 0
adds r1, r4, 0
str r3, [sp]
bl GetMapTileAtPosition
bl GetMapTile_1
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -618,7 +618,7 @@ _0808379C:
ldr r2, _0808380C
add r2, sp
str r3, [r2]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r2, r0, 0
ldr r0, _08083810
ldr r1, _0808380C
@@ -730,7 +730,7 @@ _0808386A:
adds r0, r5, 0
adds r1, r4, 0
str r3, [sp]
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
ldrh r2, [r1]
movs r7, 0x80

View File

@@ -218,7 +218,7 @@ _080853EE:
lsls r0, r4, 16
asrs r0, 16
asrs r1, r4, 16
bl GetMapTileAtPosition
bl GetMapTile_1
adds r1, r0, 0
mov r0, r8
bl sub_807034C

View File

@@ -157,7 +157,7 @@ _0808B6D2:
movs r2, 0
ldrsh r0, [r7, r2]
asrs r1, 16
bl GetMapEntity
bl GetMapTile_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -241,7 +241,7 @@ _0808B77E:
movs r2, 0
ldrsh r0, [r7, r2]
asrs r1, 16
bl GetMapEntity
bl GetMapTile_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -391,7 +391,7 @@ _0808B8F4:
movs r2, 0
ldrsh r0, [r7, r2]
asrs r1, 16
bl GetMapEntity
bl GetMapTile_2
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1

View File

@@ -830,52 +830,3 @@ gUnknown_80F55BC: @ 80F55BC
.global gUnknown_80F55EC
gUnknown_80F55EC: @ 80F55EC
.incbin "baserom.gba", 0xF55EC, 0x30
.global gDungeonCamouflageTypes
gDungeonCamouflageTypes: @ 80F561C
.incbin "baserom.gba", 0xF561C, 0x4C
.global gDungeonMusic
gDungeonMusic: @ 80F5668
.incbin "baserom.gba", 0xF5668, 0x98
.global gUnknown_80F5700
gUnknown_80F5700: @ 80F5700
.incbin "baserom.gba", 0xF5700, 0xCA
.global gUnknown_80F57CA
gUnknown_80F57CA: @ 80F57CA
@ replacing .incbin "baserom.gba", 0x000f57ca, 0x2
.byte 0x0a, 0x00
.global gUnknown_80F57CC
gUnknown_80F57CC: @ 80F57CC
@ replacing .incbin "baserom.gba", 0x000f57cc, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57CE
gUnknown_80F57CE: @ 80F57CE
@ replacing .incbin "baserom.gba", 0x000f57ce, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57D0
gUnknown_80F57D0: @ 80F57D0
@ replacing .incbin "baserom.gba", 0x000f57d0, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57D2
gUnknown_80F57D2: @ 80F57D2
@ replacing .incbin "baserom.gba", 0x000f57d2, 0x2
.byte 0x0a, 0x00
.global gUnknown_80F57D4
gUnknown_80F57D4: @ 80F57D4
.incbin "baserom.gba", 0xF57D4, 0x120
.global gUnknown_80F58F4
gUnknown_80F58F4: @ 80F58F4
.incbin "baserom.gba", 0xF58F4, 0x84
.global gUnknown_80F5978
gUnknown_80F5978: @ 80F5978
.incbin "baserom.gba", 0xF5978, 0x4C

46
data/data_80F5668.s Normal file
View File

@@ -0,0 +1,46 @@
.section .rodata
.global gDungeonMusic
gDungeonMusic: @ 80F5668
.incbin "baserom.gba", 0xF5668, 0x98
.global gUnknown_80F5700
gUnknown_80F5700: @ 80F5700
.incbin "baserom.gba", 0xF5700, 0xCA
.global gUnknown_80F57CA
gUnknown_80F57CA: @ 80F57CA
@ replacing .incbin "baserom.gba", 0x000f57ca, 0x2
.byte 0x0a, 0x00
.global gUnknown_80F57CC
gUnknown_80F57CC: @ 80F57CC
@ replacing .incbin "baserom.gba", 0x000f57cc, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57CE
gUnknown_80F57CE: @ 80F57CE
@ replacing .incbin "baserom.gba", 0x000f57ce, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57D0
gUnknown_80F57D0: @ 80F57D0
@ replacing .incbin "baserom.gba", 0x000f57d0, 0x2
.byte 0x14, 0x00
.global gUnknown_80F57D2
gUnknown_80F57D2: @ 80F57D2
@ replacing .incbin "baserom.gba", 0x000f57d2, 0x2
.byte 0x0a, 0x00
.global gUnknown_80F57D4
gUnknown_80F57D4: @ 80F57D4
.incbin "baserom.gba", 0xF57D4, 0x120
.global gUnknown_80F58F4
gUnknown_80F58F4: @ 80F58F4
.incbin "baserom.gba", 0xF58F4, 0x84
.global gUnknown_80F5978
gUnknown_80F5978: @ 80F5978
.incbin "baserom.gba", 0xF5978, 0x4C

View File

@@ -19,13 +19,3 @@ gUnknown_8106FC5: @ 8106FC5
gUnknown_8106FCD: @ 8106FCD
@ replacing .incbin "baserom.gba", 0x00106fcd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_2
gDirectionBitMasks_2: @ 8106FD5
@ replacing .incbin "baserom.gba", 0x00106fd5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gDirectionBitMasks_3
gDirectionBitMasks_3: @ 8106FDD
@ replacing .incbin "baserom.gba", 0x00106fdd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80

6
data/data_8106FDD.s Normal file
View File

@@ -0,0 +1,6 @@
.section .rodata
.global gDirectionBitMasks_3
gDirectionBitMasks_3: @ 8106FDD
@ replacing .incbin "baserom.gba", 0x00106fdd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80

View File

@@ -92,25 +92,3 @@ gBlastBurnIQReq: @ 810ACBC
.global gVoltTackleIQReq
gVoltTackleIQReq: @ 810ACBE
.2byte 333
.global gDungeonWaterType
gDungeonWaterType: @ 810ACC0
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x02, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x02
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x01, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x01
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x01, 0x00
.byte 0x00, 0x00, 0x00, 0x00

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,18 @@ enum MoveFlags
MOVE_FLAG_DISABLED = 1 << 5 // Disabled by an effect like Taunt.
};
enum AccuracyType
{
// Accuracy used for all moves.
ACCURACY_TYPE_GLOBAL,
// Multiplied with the global accuracy for offensive moves (i.e., not status moves).
ACCURACY_TYPE_OFFENSIVE,
// Used by the AI to determine how often to use Spikes.
// Values exist for all other moves, though they seem to be unused.
ACCURACY_TYPE_USE_CHANCE,
NUM_ACCURACY_TYPES
};
struct MoveData
{
u8 *namePointer;
@@ -22,10 +34,8 @@ struct MoveData
// The AI consider certain moves to have different range than they actually do.
/* 0xC */ u8 maxPP;
/* 0xD */ u8 weight;
/* 0xE */ u8 accuracy[2];
// Used by the AI to determine how often to use Spikes.
// Values exist for all other moves, though they seem to be unused.
/* 0x10 */ u8 useChance;
// There are multiple accuracy values. These are define with the AccuracyType enum.
/* 0xE */ u8 accuracy[NUM_ACCURACY_TYPES];
/* 0x11 */ u8 hitCount; // Maximum number of times the move will hit. Used for multi-hit moves like Fury Attack.
u8 unk12;
/* 0x13 */ u8 criticalHitChance;

View File

@@ -4,7 +4,7 @@
#define WEATHER_CLEAR 0
#define WEATHER_SUNNY 1
#define WEATHER_SANDSTORM 2
#define WEATHER_CLOUDY` 3
#define WEATHER_CLOUDY 3
#define WEATHER_RAIN 4
#define WEATHER_HAIL 5
#define WEATHER_FOG 6

View File

@@ -3,7 +3,9 @@
#include "dungeon_entity.h"
// 0x7C9F8
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange);
// 0x7C580
s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, u32 hasStatusChecker);
// 0x7C648
bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker);
#endif

View File

@@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_AI_ATTACK_2_H
#define GUARD_DUNGEON_AI_ATTACK_2_H
#include "dungeon_entity.h"
// 0x7C9F8
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange);
#endif

View File

@@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_AI_TARGETING_H
#define GUARD_DUNGEON_AI_TARGETING_H
#include "dungeon_entity.h"
// 0x71138
bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction);
#endif

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_DUNGEON_AI_H
#define GUARD_DUNGEON_AI_H
#ifndef GUARD_DUNGEON_AI_TARGETING_1_H
#define GUARD_DUNGEON_AI_TARGETING_1_H
#include "dungeon_entity.h"

View File

@@ -1,5 +1,5 @@
#ifndef GUARD_DUNGEON_AI_1_H
#define GUARD_DUNGEON_AI_1_H
#ifndef GUARD_DUNGEON_AI_TARGETING_2_H
#define GUARD_DUNGEON_AI_TARGETING_2_H
#include "dungeon_entity.h"

View File

@@ -1,6 +1,8 @@
#ifndef GUARD_DUNGEON_ENGINE_H
#define GUARD_DUNGEON_ENGINE_H
// 0x441BC
bool8 IsBossBattle();
// 0x441E8
bool8 IsFixedDungeon();

View File

@@ -6,6 +6,9 @@
#include "item.h"
#include "position.h"
#define MAX_STAT_STAGE 20
#define MAX_MOVEMENT_SPEED 4
#define MAX_STOCKPILE_COUNT 3
#define NUM_SPEED_TURN_COUNTERS 5
struct DungeonActionContainer

View File

@@ -71,7 +71,7 @@ struct DungeonGlobalData
/* 0xE277 */ u8 mudSportTurnsLeft;
/* 0xE278 */ u8 waterSportTurnsLeft;
u8 fillE279[0xE8C0 - 0xE279];
/* 0xE8C0 */ struct MapTile* mapEntityPointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
/* 0xE8C0 */ struct MapTile* mapTilePointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fill104C0[0x104C4 - 0x104C0];
/* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT];
u8 fill10764[0x10844 - 0x10764];

View File

@@ -3,7 +3,14 @@
#include "map.h"
struct unkStruct_202F190
{
struct MapTile* unk0[6];
};
// 0x4954C
struct MapTile* GetMapTileAtPosition(s32 x, s32 y);
struct MapTile* GetMapTile_1(s32 x, s32 y);
// 0x49590
struct MapTile* GetMapTile_2(s32 x, s32 y);
#endif

View File

@@ -15,6 +15,6 @@ u32 GetEntityType(struct DungeonEntity *entity);
struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity);
// 0x45108
struct ItemSlot *GetItemData(struct DungeonEntity *entity);
struct MapTile *GetMapEntityForDungeonEntity(struct DungeonEntity *entity);
struct MapTile *GetMapTileForDungeonEntity_2(struct DungeonEntity *entity);
#endif

View File

@@ -14,7 +14,7 @@ u8 GetMoveType(struct PokemonMove *move);
u8 GetMoveWeight(struct PokemonMove *move);
u8 GetMoveHitCount(struct PokemonMove *move);
s32 GetMovePower(struct PokemonMove *move);
u8 GetMoveAccuracy(struct PokemonMove *move, u32 r1);
s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType);
u32 GetMoveMaxPP(struct PokemonMove *move);
u8 GetMoveUnk12(struct PokemonMove *move);
u8 GetMoveCriticalHitChance(struct PokemonMove *move);

10
include/status_checker.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef GUARD_STATUS_CHECKER_H
#define GUARD_STATUS_CHECKER_H
#include "constants/move.h"
#include "dungeon_entity.h"
// 0x5C498
bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move);
#endif

View File

@@ -7,5 +7,7 @@
bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
// 0x70B28
bool8 IsSleeping(struct DungeonEntity *pokemon);
// 0x70B48
bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon);
#endif

View File

@@ -5,6 +5,6 @@
#include "dungeon_entity.h"
// 0x7CD64
s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, u32 isAI);
s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, bool32 isAI);
#endif

15
include/tile_types.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef GUARD_TILE_TYPES_H
#define GUARD_TILE_TYPES_H
#include "map.h"
#define DUNGEON_WATER_TYPE_NONE 0
#define DUNGEON_WATER_TYPE_LAVA 1
#define DUNGEON_WATER_TYPE_WATER 2
// 0x4AF20
bool8 IsTileGround(struct MapTile* tile);
// 0x4AF74
bool8 IsWaterTileset();
#endif

9
include/trap.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GUARD_TRAP_H
#define GUARD_TRAP_H
#include "position.h"
// 0x4AF74
bool8 CanLayTrap(struct Position *pos);
#endif

9
include/weather.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GUARD_WEATHER_H
#define GUARD_WEATHER_H
#include "dungeon_entity.h"
// 0x7E580
u8 GetWeather(struct DungeonEntity* pokemon);
#endif

View File

@@ -201,13 +201,17 @@ SECTIONS {
src/code_8048DB8.o(.text);
src/dungeon_ai_item_weight.o(.text);
src/dungeon_map_access.o(.text);
asm/code_8049590.o(.text);
asm/code_80495E4.o(.text);
src/tile_types.o(.text);
asm/code_804AFAC.o(.text);
src/code_80521D0.o(.text);
asm/code_80521D0.o(.text);
src/charge_move.o(.text);
asm/code_8057144.o(.text);
src/code_8057824.o(.text);
asm/code_8057824.o(.text);
src/status_checker.o(.text);
asm/code_805CEB8.o(.text);
src/targeting.o(.text);
asm/code_8069E0C.o(.text);
src/code_806CD90.o(.text);
@@ -217,14 +221,15 @@ SECTIONS {
src/dungeon_movement.o(.text);
asm/code_807034C.o(.text);
src/status_checks_1.o(.text);
asm/code_8070B48.o(.text);
src/dungeon_capabilities.o(.text);
asm/code_8070BC0.o(.text);
src/dungeon_capabilities_1.o(.text);
asm/code_8070E3C.o(.text);
src/dungeon_ai.o(.text);
src/dungeon_ai_targeting.o(.text);
asm/code_8071214.o(.text);
src/dungeon_ai_targeting_1.o(.text);
asm/code_8071518.o(.text);
src/dungeon_ai_1.o(.text);
src/dungeon_ai_targeting_2.o(.text);
asm/code_807167C.o(.text);
src/dungeon_pokemon_attributes.o(.text);
asm/code_80718D8.o(.text);
@@ -236,9 +241,15 @@ SECTIONS {
src/dungeon_ai_attack.o(.text);
asm/code_807C4A0.o(.text);
src/dungeon_ai_attack_1.o(.text);
asm/code_807C7AC.o(.text);
src/dungeon_ai_attack_2.o(.text);
asm/code_807CABC.o(.text);
src/targeting_flags.o(.text);
asm/code_807CD9C.o(.text);
src/weather.o(.text);
asm/code_807E5AC.o(.text);
src/trap.o(.text);
asm/code_807FCD4.o(.text);
src/code_8083288.o(.text);
src/dungeon_range.o(.text);
asm/code_808333C.o(.text);
@@ -412,16 +423,21 @@ SECTIONS {
data/data_80F4DB4.o(.rodata);
src/dungeon_ai_attack.o(.rodata);
data/data_80F4E2C.o(.rodata);
src/status_checker.o(.rodata);
data/data_80F5668.o(.rodata);
src/dungeon_pokemon_attributes.o(.rodata);
data/data_80F59C8.o(.rodata);
src/charge_move.o(.rodata);
data/data_8106A4C.o(.rodata);
src/dungeon_capabilities_1.o(.rodata);
data/data_8106FB5.o(.rodata);
src/dungeon_ai_1.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);
data/data_8106FDD.o(.rodata);
src/dungeon_ai_targeting_2.o(.rodata);
data/data_8107010.o(.rodata);
src/friend_area.o(.rodata);
data/data_810AC60.o(.rodata);
src/tile_types.o(.rodata);
src/exclusive_pokemon.o(.rodata);
src/rescue_team_info.o(.rodata);
src/text_util.o(.rodata);

View File

@@ -3,6 +3,7 @@
#include "code_80521D0.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "file_system.h"
#include "play_time.h"
@@ -26,8 +27,6 @@ extern void sub_8040A84();
extern const char *gUnknown_80FD040; // It became brighter on the floor
extern struct MapTile *GetMapEntity(u32, u32);
// Luminous Orb???
void HandleLuminousOrbAction(struct DungeonEntity *param_1)
{
@@ -41,7 +40,7 @@ void HandleLuminousOrbAction(struct DungeonEntity *param_1)
{
for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++)
{
mapTile = GetMapEntity(XCoord, YCoord);
mapTile = GetMapTile_2(XCoord, YCoord);
mapTile->unk4 = mapTile->unk4 | 1;
}
}

View File

@@ -3,6 +3,7 @@
#include "constants/friend_area.h"
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "dungeon_map_access.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "friend_area.h"
@@ -138,7 +139,6 @@ extern void sub_8049ED4();
extern void sub_8040A84();
extern void sub_8086A54(struct DungeonEntity *);
extern struct MapTile *GetMapEntity(u32, u32);
extern void sub_806BFC0(struct DungeonEntityData *, u32);
void sub_808BBA8(struct DungeonEntity *param_1)
@@ -207,7 +207,7 @@ void sub_808BCE4(void)
{
struct MapTile *puVar1;
puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1 = GetMapTile_2(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
puVar1->tileType |= TILE_TYPE_MAP_EDGE;
puVar1->tileType &= ~TILE_TYPE_STAIRS;
@@ -221,7 +221,7 @@ void sub_808BD38(void)
{
struct MapTile *puVar1;
puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1 = GetMapTile_2(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
puVar1->tileType |= TILE_TYPE_FLOOR;
puVar1->tileType &= ~TILE_TYPE_MAP_EDGE;

View File

@@ -3318,7 +3318,7 @@ void sub_808B1CC(u8 r0)
"\tldrsh r0, [r0, r2]\n"
"\tmovs r3, 0x2\n"
"\tldrsh r1, [r5, r3]\n"
"\tbl GetMapEntity\n"
"\tbl GetMapTile_2\n"
"\tldrh r2, [r0]\n"
"\tmovs r3, 0x80\n"
"\tlsls r3, 2\n"

View File

@@ -10,8 +10,10 @@
#include "constants/type.h"
#include "charge_move.h"
#include "dungeon_action.h"
#include "dungeon_ai.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_ai_targeting_1.h"
#include "dungeon_ai_attack_1.h"
#include "dungeon_ai_attack_2.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
@@ -22,6 +24,7 @@
#include "dungeon_visibility.h"
#include "moves.h"
#include "position_util.h"
#include "status_checker.h"
#include "status_checks.h"
#include "targeting.h"
#include "targeting_flags.h"
@@ -32,17 +35,13 @@ const s16 gRegularAttackWeights[] = {100, 20, 30, 40, 50};
extern bool8 gCanAttackInDirection[NUM_DIRECTIONS];
extern s32 gNumPotentialTargets;
extern s32 gPotentialTargetWeights_2[NUM_DIRECTIONS];
extern s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS];
extern u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS];
extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS];
extern bool8 IsMoveUsable(struct DungeonEntity*, s32, bool8);
extern bool8 IsMoveUsable_1(struct DungeonEntity*, s32, bool8);
extern bool8 TargetRegularAttack(struct DungeonEntity*, u32*, bool8);
extern bool8 CanUseWithStatusChecker(struct DungeonEntity*, struct PokemonMove*);
extern bool8 CanAttackInFront(struct DungeonEntity*, s32);
extern s32 WeightMoveIfUsable(s32, s32, struct DungeonEntity*, struct DungeonEntity*, struct PokemonMove*, bool8);
extern bool8 IsTargetInLineRange(struct DungeonEntity*, struct DungeonEntity*, s32);
extern bool8 CanUseStatusMove(s32, struct DungeonEntity*, struct DungeonEntity*, struct PokemonMove*, bool8);
extern s32 WeightMove(struct DungeonEntity*, s32, struct DungeonEntity*, u8);
void DecideAttack(struct DungeonEntity *pokemon)
@@ -182,7 +181,7 @@ void DecideAttack(struct DungeonEntity *pokemon)
move = &pokemonData->moves[i];
if (move->moveFlags & MOVE_FLAG_EXISTS &&
willNotUnlinkMove[i] &&
IsMoveUsable(pokemon, i, hasPPChecker) &&
IsMoveUsable_1(pokemon, i, hasPPChecker) &&
move->moveFlags & MOVE_FLAG_ENABLED)
{
moveTargetResults[i].moveUsable = TRUE;
@@ -349,7 +348,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
hasStatusChecker = HasIQSkill(pokemon, IQ_SKILL_STATUS_CHECKER);
moveTargetResults->moveUsable = FALSE;
if ((pokemonData->volatileStatus == VOLATILE_STATUS_TAUNTED && !MoveDealsDirectDamage(move)) ||
(hasStatusChecker && !CanUseWithStatusChecker(pokemon, move)))
(hasStatusChecker && !CanUseOnSelfWithStatusChecker(pokemon, move)))
{
return 1;
}
@@ -366,7 +365,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
gCanAttackInDirection[i] = TRUE;
gPotentialAttackTargetDirections[numPotentialTargets] = i;
gPotentialTargetWeights_2[numPotentialTargets] = 99;
gPotentialAttackTargetWeights[numPotentialTargets] = 99;
gPotentialTargets[numPotentialTargets] = NULL;
numPotentialTargets++;
}
@@ -377,7 +376,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
// Double assignment to fix a regswap.
s16 rangeTargetingFlags = rangeTargetingFlags2 = targetingFlags & 0xF0;
struct MapTile *adjacentTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
struct MapTile *adjacentTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y);
struct DungeonEntity *adjacentPokemon = adjacentTile->pokemon;
if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) == ENTITY_POKEMON)
@@ -411,7 +410,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
for (i = 0; i < NUM_DIRECTIONS; i++)
{
struct MapTile *targetTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
struct MapTile *targetTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y);
if (CanAttackInFront(pokemon, i))
{
@@ -425,7 +424,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
continue;
}
}
targetTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x * 2,
targetTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x * 2,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y * 2);
targetPokemon = targetTile->pokemon;
if (targetPokemon != NULL && GetEntityType(targetPokemon) == ENTITY_POKEMON)
@@ -457,7 +456,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
gCanAttackInDirection[facingDir] = TRUE;
gPotentialAttackTargetDirections[numPotentialTargets] = facingDir;
gPotentialTargetWeights_2[numPotentialTargets] = WeightMove(pokemon, targetingFlags, target, GetMoveTypeForPokemon(pokemon, move));
gPotentialAttackTargetWeights[numPotentialTargets] = WeightMove(pokemon, targetingFlags, target, GetMoveTypeForPokemon(pokemon, move));
gPotentialTargets[numPotentialTargets] = target;
numPotentialTargets++;
}
@@ -492,27 +491,27 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
s32 i;
for (i = 0; i < numPotentialTargets; i++)
{
if (maxWeight < gPotentialTargetWeights_2[i])
if (maxWeight < gPotentialAttackTargetWeights[i])
{
maxWeight = gPotentialTargetWeights_2[i];
maxWeight = gPotentialAttackTargetWeights[i];
}
}
for (i = 0; i < numPotentialTargets; i++)
{
if (maxWeight != gPotentialTargetWeights_2[i])
if (maxWeight != gPotentialAttackTargetWeights[i])
{
gPotentialTargetWeights_2[i] = 0;
gPotentialAttackTargetWeights[i] = 0;
}
}
moveWeight = maxWeight;
for (i = 0; i < numPotentialTargets; i++)
{
totalWeight += gPotentialTargetWeights_2[i];
totalWeight += gPotentialAttackTargetWeights[i];
}
weightCounter = DungeonRandomCapped(totalWeight);
for (i = 0; i < numPotentialTargets; i++)
{
weightCounter -= gPotentialTargetWeights_2[i];
weightCounter -= gPotentialAttackTargetWeights[i];
if (weightCounter < 0)
{
break;

View File

@@ -1,76 +1,175 @@
#include "global.h"
#include "dungeon_ai_attack_1.h"
#include "constants/iq_skill.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "constants/direction.h"
#include "constants/targeting.h"
#include "constants/type.h"
#include "dungeon_ai_targeting_2.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "dungeon_random.h"
#include "moves.h"
#include "position_util.h"
#include "status_checks_1.h"
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)
extern bool8 gCanAttackInDirection[NUM_DIRECTIONS];
extern s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS];
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)
{
s32 posDiffX = pokemon->posWorld.x - targetPokemon->posWorld.x;
s32 effectiveMaxRange;
if (posDiffX < 0)
s32 facingDir;
s32 targetingFlags2 = (s16) targetingFlags;
bool8 hasStatusChecker2 = hasStatusChecker;
struct DungeonEntityData *userData = user->entityData;
if ((user->posWorld.x == target->posWorld.x && user->posWorld.y == target->posWorld.y) ||
(targetingFlags2 & 0xF0) == TARGETING_FLAG_TARGET_ROOM ||
(targetingFlags2 & 0xF0) == TARGETING_FLAG_TARGET_FLOOR ||
(targetingFlags2 & 0xF0) == TARGETING_FLAG_TARGET_SELF)
{
posDiffX = -posDiffX;
}
effectiveMaxRange = pokemon->posWorld.y - targetPokemon->posWorld.y;
if (effectiveMaxRange < 0)
{
effectiveMaxRange = -effectiveMaxRange;
}
if (effectiveMaxRange < posDiffX)
{
effectiveMaxRange = posDiffX;
}
if (effectiveMaxRange > maxRange)
{
effectiveMaxRange = maxRange;
}
if (!HasIQSkill(pokemon, IQ_SKILL_COURSE_CHECKER))
{
// BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE.
// The AI also has range checks elsewhere, so this doesn't become an issue in most cases.
// If the AI has the Long Toss or Pierce statuses and Course Checker is disabled,
// this incorrect check causes the AI to throw items at targets further than 10 tiles away.
if (effectiveMaxRange <= maxRange)
{
return TRUE;
}
facingDir = userData->action.facingDir;
}
else
{
s32 currentPosX = pokemon->posWorld.x;
s32 currentPosY = pokemon->posWorld.y;
s32 adjacentTileOffsetX = gAdjacentTileOffsets[facingDir].x;
s32 adjacentTileOffsetY = gAdjacentTileOffsets[facingDir].y;
s32 i;
for (i = 0; i <= effectiveMaxRange; i++)
facingDir = CalculateFacingDir(&user->posWorld, &target->posWorld);
}
if (!gCanAttackInDirection[facingDir] &&
CanUseStatusMove(targetingFlags2, user, target, move, hasStatusChecker2))
{
gCanAttackInDirection[facingDir] = TRUE;
do { gPotentialAttackTargetDirections[numPotentialTargets] = facingDir; } while (0);
gPotentialAttackTargetWeights[numPotentialTargets] = WeightMove(user, targetingFlags2, target, GetMoveTypeForPokemon(user, move));
gPotentialTargets[numPotentialTargets] = target;
numPotentialTargets++;
}
return numPotentialTargets;
}
bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker)
{
struct DungeonEntityData *targetData;
s32 targetingFlags2 = (s16) targetingFlags;
bool8 hasStatusChecker2 = hasStatusChecker;
bool8 hasTarget = FALSE;
u32 categoryTargetingFlags = targetingFlags2 & 0xF;
u32 *categoryTargetingFlags2 = &categoryTargetingFlags; // Fixes a regswap.
if (*categoryTargetingFlags2 == TARGETING_FLAG_TARGET_OTHER)
{
if (CanTarget(user, target, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
{
struct MapTile *mapTile;
currentPosX += adjacentTileOffsetX;
currentPosY += adjacentTileOffsetY;
if (currentPosX <= 0 || currentPosY <= 0 ||
currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1)
hasTarget = TRUE;
}
}
else if (categoryTargetingFlags == TARGETING_FLAG_HEAL_TEAM)
{
goto checkCanTarget;
}
else if (categoryTargetingFlags == TARGETING_FLAG_LONG_RANGE)
{
targetData = target->entityData;
goto checkThirdParty;
}
else if (categoryTargetingFlags == TARGETING_FLAG_ATTACK_ALL)
{
targetData = target->entityData;
if (user == target)
{
goto returnFalse;
}
checkThirdParty:
hasTarget = TRUE;
if (targetData->shopkeeperMode == SHOPKEEPER_FRIENDLY ||
targetData->clientType == CLIENT_TYPE_DONT_MOVE ||
targetData->clientType == CLIENT_TYPE_CLIENT)
{
returnFalse:
return FALSE;
}
}
else if (categoryTargetingFlags == TARGETING_FLAG_BOOST_TEAM)
{
if (user == target)
{
goto returnFalse;
}
checkCanTarget:
if (CanTarget(user, target, FALSE, TRUE) == TARGET_CAPABILITY_CANNOT_ATTACK)
{
hasTarget = TRUE;
}
}
else if ((u16) (categoryTargetingFlags - 3) <= 1) // categoryTargetingFlags == TARGETING_FLAG_ITEM
{
hasTarget = TRUE;
}
if (hasTarget)
{
if (hasStatusChecker2)
{
if (!CanUseOnTargetWithStatusChecker(user, target, move))
{
break;
goto returnFalse;
}
while (0); // Extra label needed to swap branch locations in ASM.
mapTile = GetMapTileAtPosition(currentPosX, currentPosY);
if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP)
{
break;
goto rollMoveUseChance;
}
if (mapTile->pokemon == targetPokemon)
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_HP)
{
return TRUE;
if (!HasQuarterHPOrLess(target))
{
if (*categoryTargetingFlags2);
goto returnFalse;
}
}
if (mapTile->pokemon != NULL)
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_STATUS)
{
break;
if (!HasNegativeStatus(target))
{
if (*categoryTargetingFlags2); // Flips the conditional.
goto returnFalse;
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_DREAM_EATER)
{
if (!IsSleeping(target))
{
if (*categoryTargetingFlags2); // Flips the conditional.
goto returnFalse;
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_EXPOSE)
{
targetData = target->entityData;
if ((targetData->type1 != TYPE_GHOST && targetData->type2 != TYPE_GHOST) || targetData->exposedStatus)
{
if (*categoryTargetingFlags2); // Flips the conditional.
goto returnFalse;
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_ALL)
{
if (!HasNegativeStatus(target) && !HasQuarterHPOrLess(target))
{
if (*categoryTargetingFlags2); // Flips the conditional.
goto returnFalse;
}
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP)
{
s32 useChance;
rollMoveUseChance:
useChance = GetMoveAccuracy(move, ACCURACY_TYPE_USE_CHANCE);
if (DungeonRandomCapped(100) >= useChance)
{
goto returnFalse;
}
}
}
return FALSE;
return hasTarget;
}

76
src/dungeon_ai_attack_2.c Normal file
View File

@@ -0,0 +1,76 @@
#include "global.h"
#include "dungeon_ai_attack_2.h"
#include "constants/iq_skill.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)
{
s32 posDiffX = pokemon->posWorld.x - targetPokemon->posWorld.x;
s32 effectiveMaxRange;
if (posDiffX < 0)
{
posDiffX = -posDiffX;
}
effectiveMaxRange = pokemon->posWorld.y - targetPokemon->posWorld.y;
if (effectiveMaxRange < 0)
{
effectiveMaxRange = -effectiveMaxRange;
}
if (effectiveMaxRange < posDiffX)
{
effectiveMaxRange = posDiffX;
}
if (effectiveMaxRange > maxRange)
{
effectiveMaxRange = maxRange;
}
if (!HasIQSkill(pokemon, IQ_SKILL_COURSE_CHECKER))
{
// BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE.
// The AI also has range checks elsewhere, so this doesn't become an issue in most cases.
// If the AI has the Long Toss or Pierce statuses and Course Checker is disabled,
// this incorrect check causes the AI to throw items at targets further than 10 tiles away.
if (effectiveMaxRange <= maxRange)
{
return TRUE;
}
}
else
{
s32 currentPosX = pokemon->posWorld.x;
s32 currentPosY = pokemon->posWorld.y;
s32 adjacentTileOffsetX = gAdjacentTileOffsets[facingDir].x;
s32 adjacentTileOffsetY = gAdjacentTileOffsets[facingDir].y;
s32 i;
for (i = 0; i <= effectiveMaxRange; i++)
{
struct MapTile *mapTile;
currentPosX += adjacentTileOffsetX;
currentPosY += adjacentTileOffsetY;
if (currentPosX <= 0 || currentPosY <= 0 ||
currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1)
{
break;
}
while (0); // Extra label needed to swap branch locations in ASM.
mapTile = GetMapTile_1(currentPosX, currentPosY);
if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
{
break;
}
if (mapTile->pokemon == targetPokemon)
{
return TRUE;
}
if (mapTile->pokemon != NULL)
{
break;
}
}
}
return FALSE;
}

View File

@@ -3,7 +3,7 @@
#include "constants/status.h"
#include "constants/targeting.h"
#include "dungeon_ai_1.h"
#include "dungeon_ai_targeting_2.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
@@ -185,7 +185,7 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32
}
break;
case ITEM_ID_QUICK_SEED:
if (targetPokemon->entityData->movementSpeed <= 3)
if (targetPokemon->entityData->movementSpeed < MAX_MOVEMENT_SPEED)
{
if (CanTargetAdjacentPokemon(targetPokemon))
{
@@ -448,7 +448,7 @@ bool8 CanTargetAdjacentPokemon(struct DungeonEntity *pokemon)
s32 facingDir;
for (facingDir = 0; facingDir < NUM_DIRECTIONS; facingDir++)
{
struct MapTile *mapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x, pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
struct MapTile *mapTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x, pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
struct DungeonEntity *adjacentPokemon = mapTile->pokemon;
if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) != ENTITY_NONE &&
CanTarget(pokemon, adjacentPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)

View File

@@ -6,10 +6,10 @@
#include "constants/status.h"
#include "constants/targeting.h"
#include "dungeon_action.h"
#include "dungeon_ai_1.h"
#include "dungeon_ai_attack_1.h"
#include "dungeon_ai_attack_2.h"
#include "dungeon_ai_item_weight.h"
#include "dungeon_ai_items.h"
#include "dungeon_ai_targeting_2.h"
#include "dungeon_capabilities.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_entity.h"
@@ -39,7 +39,7 @@ enum ItemTargetFlag
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
extern s32 gNumPotentialTargets;
extern u32 gPotentialTargetWeights[NUM_DIRECTIONS];
extern u32 gPotentialItemTargetWeights[NUM_DIRECTIONS];
extern u32 gPotentialItemTargetDirections[NUM_DIRECTIONS];
extern bool8 gTargetAhead[NUM_DIRECTIONS];
extern struct TeamInventory *gTeamInventory_203B460;
@@ -95,7 +95,7 @@ void DecideUseItem(struct DungeonEntity *pokemon)
FindStraightThrowableTargets(pokemon, 2, item, 1);
for (targetIndex = 0; targetIndex < gNumPotentialTargets; targetIndex++)
{
if (RollPercentChance(gPotentialTargetWeights[targetIndex]))
if (RollPercentChance(gPotentialItemTargetWeights[targetIndex]))
{
SetAction(&pokemonData->action, DUNGEON_ACTION_THROW_ITEM_AI);
pokemonData->action.actionUseIndex = selectedToolboxIndex;
@@ -158,7 +158,7 @@ void DecideUseItem(struct DungeonEntity *pokemon)
else if (toolboxIndex == 0)
{
// This seems unused. toolboxIndex can never be 0.
struct MapTile *mapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
struct MapTile *mapTile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
struct DungeonEntity *mapObject = mapTile->mapObject;
if (mapObject != null)
{
@@ -229,7 +229,7 @@ void DecideUseItem(struct DungeonEntity *pokemon)
s32 thrownAIFlag;
for (thrownAIFlag = ITEM_AI_FLAG_TARGET_ALLY; thrownAIFlag <= ITEM_AI_FLAG_TARGET_ENEMY; thrownAIFlag++)
{
potentialTargetWeights = gPotentialTargetWeights;
potentialTargetWeights = gPotentialItemTargetWeights;
if (GetItemAIFlag(item->itemIndex, thrownAIFlag))
{
u8 itemType = GetItemType(item->itemIndex);
@@ -422,7 +422,7 @@ void TargetThrownItem(struct DungeonEntity *pokemon, struct DungeonEntity *targe
u32 *targetWeight;
gTargetAhead[targetDirection] = TRUE;
gPotentialItemTargetDirections[gNumPotentialTargets] = targetDirection;
targetWeight = &gPotentialTargetWeights[gNumPotentialTargets];
targetWeight = &gPotentialItemTargetWeights[gNumPotentialTargets];
itemWeight = !ignoreRollChance ? EvaluateItem(targetPokemon, item, targetingFlags) : 100;
*targetWeight = itemWeight;
gNumPotentialTargets++;

View File

@@ -49,7 +49,7 @@ u32 sub_8075818(struct DungeonEntity *entity)
entityData = entity->entityData;
if(EntityExists(entity))
{
tile = GetMapEntityForDungeonEntity(entity);
tile = GetMapTileForDungeonEntity_2(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
return 1;
@@ -136,7 +136,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(!gDungeonGlobalData->monsterHouseActive)
{
if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
if((GetMapTileForDungeonEntity_2(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);

View File

@@ -0,0 +1,62 @@
#include "global.h"
#include "dungeon_ai_targeting.h"
#include "constants/iq_skill.h"
#include "constants/item.h"
#include "constants/status.h"
#include "dungeon_engine.h"
#include "dungeon_items.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "map.h"
const u8 gDirectionBitMasks_2[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
struct MapTile *tile;
if (crossableTerrain < CROSSABLE_TERRAIN_CREVICE)
{
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
tile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[direction].x,
pokemon->posWorld.y + gAdjacentTileOffsets[direction].y);
if (!(tile->tileType & TILE_TYPE_MAP_EDGE) &&
(tile->pokemon == NULL || GetEntityType(tile->pokemon) == ENTITY_POKEMON))
{
if (!IsFixedDungeon())
{
if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE ||
HasItem(pokemon, ITEM_ID_MOBILE_SCARF))
{
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER))
{
// BUG: If the Pokémon is a Ghost type that can normally attack through walls,
// All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls.
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
{
if ((direction & 1) != 0)
{
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else
{
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
}
}
tile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (tile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks_2[direction & DIRECTION_MASK])
{
return TRUE;
}
}
return FALSE;
}

View File

@@ -1,5 +1,5 @@
#include "global.h"
#include "dungeon_ai.h"
#include "dungeon_ai_targeting_1.h"
#include "constants/ability.h"
#include "constants/tactic.h"

View File

@@ -1,5 +1,5 @@
#include "global.h"
#include "dungeon_ai_1.h"
#include "dungeon_ai_targeting_2.h"
#include "constants/status.h"
#include "constants/targeting.h"

View File

@@ -5,7 +5,7 @@
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "charge_move.h"
#include "dungeon_ai.h"
#include "dungeon_ai_targeting_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_engine.h"
#include "dungeon_items.h"
@@ -15,7 +15,7 @@
#include "dungeon_util.h"
#include "map.h"
const u8 gDirectionBitMasks[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gDirectionBitMasks_1[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
static inline bool8 JoinLocationCannotUseItems(struct DungeonEntityData *pokemonData)
{
@@ -89,7 +89,7 @@ bool8 CannotAttack(struct DungeonEntity *pokemon, bool8 skipSleep)
bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
struct MapTile *currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
struct MapTile *currentMapTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
if (currentMapTile->tileType & TILE_TYPE_MAP_EDGE || currentMapTile->pokemon != NULL)
{
@@ -118,8 +118,8 @@ bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
}
}
}
currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
if (!(currentMapTile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks[facingDir & DIRECTION_MASK]))
currentMapTile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (!(currentMapTile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks_1[facingDir & DIRECTION_MASK]))
{
return FALSE;
}

View File

@@ -3,6 +3,15 @@
#include "constants/dungeon.h"
#include "dungeon_global_data.h"
bool8 IsBossBattle()
{
if (gDungeonGlobalData->bossBattleIndex != 0 && gDungeonGlobalData->bossBattleIndex <= 0x31)
{
return TRUE;
}
return FALSE;
}
bool8 IsFixedDungeon()
{
if (gDungeonGlobalData->tileset > DUNGEON_OUT_ON_RESCUE)
@@ -10,4 +19,4 @@ bool8 IsFixedDungeon()
return TRUE;
}
return FALSE;
}
}

View File

@@ -3,13 +3,25 @@
#include "dungeon_global_data.h"
extern struct MapTile *gUnknown_203B430;
extern struct unkStruct_202F190 gUnknown_202F190;
extern struct unkStruct_202F190 *gUnknown_203B430;
struct MapTile* GetMapTileAtPosition(s32 x, s32 y)
struct MapTile* GetMapTile_1(s32 x, s32 y)
{
if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y)
{
return gDungeonGlobalData->mapEntityPointers[y][x];
return gDungeonGlobalData->mapTilePointers[y][x];
}
return gUnknown_203B430;
return (struct MapTile*) gUnknown_203B430->unk0;
}
struct MapTile* GetMapTile_2(s32 x, s32 y)
{
if (x < 0 || y < 0 || x >= DUNGEON_MAX_SIZE_X || y >= DUNGEON_MAX_SIZE_Y)
{
struct MapTile* tile = (struct MapTile*) gUnknown_202F190.unk0;
gUnknown_202F190 = *gUnknown_203B430;
return tile;
}
return gDungeonGlobalData->mapTilePointers[y][x];
}

View File

@@ -14,7 +14,7 @@ bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2)
{
visibility = 2;
}
tile1 = GetMapTileAtPosition(pos1->x, pos1->y);
tile1 = GetMapTile_1(pos1->x, pos1->y);
pos1RoomIndex = tile1->roomIndex;
if (pos1RoomIndex == CORRIDOR_ROOM_INDEX)
{

View File

@@ -14,8 +14,6 @@ const struct Position gAdjacentTileOffsets[] = {
{-1, 1}
};
extern struct MapTile* GetMapEntity(s16, s16);
bool8 EntityExists(struct DungeonEntity *entity)
{
if (!entity)
@@ -55,12 +53,12 @@ struct DungeonEntityData* sub_8045110(struct DungeonEntity *entity)
return entity->entityData;
}
struct MapTile* GetMapTileForDungeonEntity(struct DungeonEntity *entity)
struct MapTile* GetMapTileForDungeonEntity_1(struct DungeonEntity *entity)
{
return GetMapTileAtPosition(entity->posWorld.x, entity->posWorld.y);
return GetMapTile_1(entity->posWorld.x, entity->posWorld.y);
}
struct MapTile* GetMapEntityForDungeonEntity(struct DungeonEntity *entity)
struct MapTile* GetMapTileForDungeonEntity_2(struct DungeonEntity *entity)
{
return GetMapEntity(entity->posWorld.x, entity->posWorld.y);
return GetMapTile_2(entity->posWorld.x, entity->posWorld.y);
}

View File

@@ -157,7 +157,7 @@ void InitZeroedPPPokemonMove(struct PokemonMove *move, u16 moveID)
move->PP = 0;
}
s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 isAI)
s16 GetMoveTargetingFlags(struct PokemonMove *move, bool32 isAI)
{
return gMovesData[move->moveID].targetingFlags[isAI];
}
@@ -250,9 +250,9 @@ s32 GetMovePower(struct PokemonMove *move)
return gMovesData[move->moveID].power;
}
u8 GetMoveAccuracy(struct PokemonMove *move, u32 r1)
s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType)
{
return gMovesData[move->moveID].accuracy[r1];
return gMovesData[move->moveID].accuracy[accuracyType];
}
u32 GetMoveMaxPP(struct PokemonMove *move)

537
src/status_checker.c Normal file
View File

@@ -0,0 +1,537 @@
#include "global.h"
#include "status_checker.h"
#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/type.h"
#include "constants/weather.h"
#include "dungeon_engine.h"
#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "map.h"
#include "number_util.h"
#include "status_checks_1.h"
#include "tile_types.h"
#include "trap.h"
#include "weather.h"
// Array indices correspond to the current dungeon tileset.
const u8 gDungeonCamouflageTypes[76] = {
TYPE_WATER,
TYPE_GRASS,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_GRASS,
TYPE_GROUND,
TYPE_NORMAL,
TYPE_NORMAL,
TYPE_GRASS,
TYPE_ICE,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_ICE,
TYPE_ICE,
TYPE_GRASS,
TYPE_GROUND,
TYPE_ROCK,
TYPE_NORMAL,
TYPE_ICE,
TYPE_GRASS,
TYPE_GRASS,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_GRASS,
TYPE_ROCK,
TYPE_ROCK,
TYPE_GRASS,
TYPE_GRASS,
TYPE_ROCK,
TYPE_NORMAL,
TYPE_ICE,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_ROCK,
TYPE_GRASS,
TYPE_ROCK,
TYPE_ROCK,
TYPE_GROUND,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_ICE,
TYPE_ROCK,
TYPE_WATER,
TYPE_GRASS,
TYPE_GRASS,
TYPE_GROUND,
TYPE_WATER,
TYPE_ROCK,
TYPE_ROCK,
TYPE_GRASS,
TYPE_NORMAL,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_GRASS,
TYPE_ROCK,
TYPE_GRASS,
TYPE_GRASS,
TYPE_ROCK,
TYPE_GRASS,
TYPE_ROCK,
TYPE_ROCK,
TYPE_NORMAL,
TYPE_NORMAL,
TYPE_ROCK,
TYPE_NORMAL,
TYPE_ICE,
TYPE_WATER,
TYPE_WATER,
TYPE_ROCK
};
bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
switch (move->moveID)
{
case MOVE_HAIL:
if (GetWeather(pokemon) == WEATHER_HAIL)
{
return FALSE;
}
break;
case MOVE_RAGE:
if (pokemonData->chargingStatus == CHARGING_STATUS_RAGE)
{
return FALSE;
}
break;
case MOVE_COUNTER:
case MOVE_PURSUIT:
if (pokemonData->protectionStatus == PROTECTION_STATUS_COUNTER)
{
return FALSE;
}
break;
case MOVE_MIRROR_MOVE:
if (pokemonData->protectionStatus == PROTECTION_STATUS_MIRROR_MOVE)
{
return FALSE;
}
break;
case MOVE_HOWL:
case MOVE_MEDITATE:
case MOVE_SHARPEN:
if (pokemonData->attackStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_BELLY_DRUM:
if (pokemonData->attackStage >= MAX_STAT_STAGE || RoundUpFixedPoint(pokemonData->belly) <= 0)
{
return FALSE;
}
break;
case MOVE_ACID_ARMOR:
case MOVE_BARRIER:
case MOVE_DEFENSE_CURL:
case MOVE_HARDEN:
case MOVE_IRON_DEFENSE:
case MOVE_WITHDRAW:
if (pokemonData->defenseStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_BIDE:
case MOVE_REVENGE:
if (pokemonData->chargingStatus == CHARGING_STATUS_BIDE)
{
return FALSE;
}
break;
case MOVE_AGILITY:
{
u32 r1;
#ifndef NONMATCHING
asm("":"=r"(r1));
#else
r1 = 0;
#endif
if (pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED)
{
r1 = !r1;
return FALSE;
}
break;
}
case MOVE_LOCK_ON:
case MOVE_MIND_READER:
if (pokemonData->moveStatus == MOVE_STATUS_SURE_SHOT)
{
return FALSE;
}
break;
case MOVE_COSMIC_POWER:
if (pokemonData->defenseStage >= MAX_STAT_STAGE && pokemonData->specialDefenseStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_ENDURE:
if (pokemonData->protectionStatus == PROTECTION_STATUS_ENDURE)
{
return FALSE;
}
break;
case MOVE_CHARGE:
if (pokemonData->chargingStatus == CHARGING_STATUS_CHARGE)
{
return FALSE;
}
break;
case MOVE_MIST:
if (pokemonData->protectionStatus == PROTECTION_STATUS_MIST)
{
return FALSE;
}
break;
case MOVE_LIGHT_SCREEN:
if (pokemonData->protectionStatus == PROTECTION_STATUS_LIGHT_SCREEN)
{
return FALSE;
}
break;
case MOVE_MINIMIZE:
if (pokemonData->evasionStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_INGRAIN:
if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_INGRAIN || pokemonData->maxHP / 2 < pokemonData->HP)
{
return FALSE;
}
break;
case MOVE_SWALLOW:
if (pokemonData->maxHP <= pokemonData->HP || pokemonData->stockpileCount == 0)
{
return FALSE;
}
break;
case MOVE_SPIT_UP:
if (pokemonData->stockpileCount == 0)
{
return FALSE;
}
break;
case MOVE_DOOM_DESIRE:
case MOVE_FUTURE_SIGHT:
if (pokemonData->moveStatus == MOVE_STATUS_SET_DAMAGE)
{
return FALSE;
}
break;
case MOVE_BULK_UP:
if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemonData->defenseStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_CAMOUFLAGE:
if (HasType(pokemon, gDungeonCamouflageTypes[gDungeonGlobalData->tileset]))
{
return FALSE;
}
break;
case MOVE_TAIL_GLOW:
if (pokemonData->specialAttackStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_DESTINY_BOND:
if (pokemonData->linkedStatus == LINKED_STATUS_DESTINY_BOND)
{
return FALSE;
}
break;
case MOVE_MIRROR_COAT:
if (pokemonData->protectionStatus == PROTECTION_STATUS_MIRROR_COAT)
{
return FALSE;
}
break;
case MOVE_REFLECT:
if (pokemonData->protectionStatus == PROTECTION_STATUS_REFLECT)
{
return FALSE;
}
break;
case MOVE_DRAGON_DANCE:
if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED)
{
return FALSE;
}
break;
case MOVE_MAGIC_COAT:
if (pokemonData->protectionStatus == PROTECTION_STATUS_MAGIC_COAT)
{
return FALSE;
}
break;
case MOVE_DETECT:
case MOVE_PROTECT:
if (pokemonData->protectionStatus == PROTECTION_STATUS_PROTECT)
{
return FALSE;
}
break;
case MOVE_RAIN_DANCE:
if (GetWeather(pokemon) == WEATHER_RAIN)
{
return FALSE;
}
break;
case MOVE_SANDSTORM:
if (GetWeather(pokemon) == WEATHER_SANDSTORM)
{
return FALSE;
}
break;
case MOVE_SUNNY_DAY:
if (GetWeather(pokemon) == WEATHER_SUNNY)
{
return FALSE;
}
break;
case MOVE_SAFEGUARD:
if (pokemonData->protectionStatus == PROTECTION_STATUS_SAFEGUARD)
{
return FALSE;
}
break;
case MOVE_INVISIFY:
if (pokemonData->transformStatus == TRANSFORM_STATUS_INVISIBLE)
{
return FALSE;
}
break;
case MOVE_FOCUS_ENERGY:
if (pokemonData->moveStatus == MOVE_STATUS_FOCUS_ENERGY)
{
return FALSE;
}
break;
case MOVE_TAKEAWAY:
if (pokemonData->heldItem.itemFlags & ITEM_FLAG_EXISTS)
{
return FALSE;
}
break;
case MOVE_REST:
if (!HasQuarterHPOrLess(pokemon) && !HasNegativeStatus(pokemon))
{
return FALSE;
}
break;
case MOVE_DIVE:
if (IsTileGround(GetMapTileForDungeonEntity_2(pokemon)))
{
return FALSE;
}
break;
case MOVE_DIG:
{
struct MapTile *tile = GetMapTileForDungeonEntity_2(pokemon);
if (!IsTileGround(tile) || (tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_FLOOR)
{
return FALSE;
}
break;
}
case MOVE_TRAP_BUSTER:
{
struct DungeonEntity *mapObject = GetMapTileForDungeonEntity_2(pokemon)->mapObject;
if (mapObject == NULL || GetEntityType(mapObject) != ENTITY_TRAP)
{
return FALSE;
}
break;
}
case MOVE_MUD_SPORT:
if (gDungeonGlobalData->mudSportTurnsLeft > 0)
{
return FALSE;
}
break;
case MOVE_WATER_SPORT:
if (gDungeonGlobalData->waterSportTurnsLeft > 0)
{
return FALSE;
}
break;
case MOVE_GRUDGE:
if (pokemonData->grudgeStatus)
{
return FALSE;
}
break;
case MOVE_DECOY_MAKER:
case MOVE_FOLLOW_ME:
case MOVE_SUBSTITUTE:
if (gDungeonGlobalData->decoyActive)
{
return FALSE;
}
break;
case MOVE_STOCKPILE:
if (pokemonData->stockpileCount >= MAX_STOCKPILE_COUNT)
{
return FALSE;
}
break;
case MOVE_CLEANSE:
if (pokemonData->heldItem.itemFlags & ITEM_FLAG_EXISTS &&
!(pokemonData->heldItem.itemFlags & ITEM_FLAG_STICKY))
{
return FALSE;
}
break;
case MOVE_DOUBLE_TEAM:
if (pokemonData->evasionStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_GROWTH:
if (pokemonData->specialAttackStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_SWORDS_DANCE:
if (pokemonData->attackStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_WISH:
if (pokemonData->isEnemy || pokemonData->protectionStatus == PROTECTION_STATUS_WISH)
{
return FALSE;
}
break;
case MOVE_TRANSFORM:
if (pokemonData->transformStatus == TRANSFORM_STATUS_TRANSFORMED)
{
return FALSE;
}
break;
case MOVE_SPIKES:
if (!CanLayTrap(&pokemon->posWorld))
{
return FALSE;
}
break;
case MOVE_CALM_MIND:
if (pokemonData->specialAttackStage < MAX_STAT_STAGE)
{
break;
}
case MOVE_AMNESIA:
if (pokemonData->specialDefenseStage >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_SNATCH:
if (pokemonData->waitingStatus == WAITING_STATUS_SNATCH)
{
return FALSE;
}
break;
case MOVE_BEAT_UP:
case MOVE_BLOWBACK:
case MOVE_HURL:
case MOVE_MEMENTO:
case MOVE_ROAR:
case MOVE_STAY_AWAY:
case MOVE_SWITCHER:
case MOVE_TELEPORT:
case MOVE_VITAL_THROW:
case MOVE_WARP:
case MOVE_WHIRLWIND:
if (IsBossBattle())
{
return FALSE;
}
break;
case MOVE_CONVERSION_2:
if (pokemonData->protectionStatus == PROTECTION_STATUS_CONVERSION_2)
{
return FALSE;
}
break;
case MOVE_HELPING_HAND:
if (pokemonData->isEnemy)
{
s32 i;
for (i = 0; i < DUNGEON_MAX_WILD_POKEMON; i++)
{
struct DungeonEntity *target = gDungeonGlobalData->wildPokemon[i];
if (EntityExists(target) && target != pokemon && CanSee(pokemon, target))
{
if (target->entityData->attackStage >= MAX_STAT_STAGE)
{
continue;
}
if (target->entityData->specialAttackStage < MAX_STAT_STAGE)
{
break;
}
}
}
if (i == DUNGEON_MAX_WILD_POKEMON)
{
return FALSE;
}
break;
}
else
{
s32 i;
for (i = 0; i < MAX_TEAM_MEMBERS; i++)
{
struct DungeonEntity *target = gDungeonGlobalData->teamPokemon[i];
if (EntityExists(target) && target != pokemon && CanSee(pokemon, target))
{
if (target->entityData->attackStage >= MAX_STAT_STAGE)
{
continue;
}
if (target->entityData->specialAttackStage < MAX_STAT_STAGE)
{
break;
}
}
}
if (i == MAX_TEAM_MEMBERS)
{
return FALSE;
}
break;
}
}
return TRUE;
}

View File

@@ -53,3 +53,19 @@ bool8 IsSleeping(struct DungeonEntity *pokemon)
}
return TRUE;
}
bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
struct DungeonEntityData *pokemonData2 = pokemon->entityData;
s32 maxHP = pokemonData->maxHP;
if (maxHP < 0)
{
maxHP += 3;
}
if (pokemonData2->HP <= maxHP >> 2)
{
return TRUE;
}
return FALSE;
}

View File

@@ -6,7 +6,7 @@
#include "dungeon_pokemon_attributes.h"
#include "moves.h"
s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, u32 isAI)
s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, bool32 isAI)
{
if (move->moveID == MOVE_CURSE && !isAI && !HasType(pokemon, TYPE_GHOST))
{

114
src/tile_types.c Normal file
View File

@@ -0,0 +1,114 @@
#include "global.h"
#include "tile_types.h"
#include "dungeon_global_data.h"
const u8 gDungeonWaterType[] = {
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_WATER,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_WATER,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_LAVA,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_LAVA,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_LAVA,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_LAVA,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
DUNGEON_WATER_TYPE_NONE,
};
bool8 IsTileGround(struct MapTile* tile)
{
bool8 isGround = FALSE;
if (IsWaterTileset())
{
if (!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
{
isGround = TRUE;
}
}
else if ((tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_LIQUID ||
gDungeonWaterType[gDungeonGlobalData->tileset] == DUNGEON_WATER_TYPE_LAVA)
{
isGround = TRUE;
}
return isGround;
}
bool8 IsWaterTileset()
{
if (gDungeonGlobalData->tileset == 0 ||
gDungeonGlobalData->tileset == 0x31 ||
gDungeonGlobalData->tileset == 0x20 ||
gDungeonGlobalData->tileset == 0x21 ||
gDungeonGlobalData->tileset == 0x36)
{
return TRUE;
}
return FALSE;
}

27
src/trap.c Normal file
View File

@@ -0,0 +1,27 @@
#include "global.h"
#include "trap.h"
#include "dungeon_map_access.h"
#include "dungeon_util.h"
#include "map.h"
bool8 CanLayTrap(struct Position *pos)
{
struct MapTile *tile = GetMapTile_2(pos->x, pos->y);
if (tile->tileType & TILE_TYPE_STAIRS ||
tile->roomIndex == CORRIDOR_ROOM_INDEX ||
tile->tileType & TILE_TYPE_ROOM_EXIT)
{
return FALSE;
}
if (tile->tileType & TILE_TYPE_SHOP)
{
return FALSE;
}
if ((tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_FLOOR ||
(tile->mapObject != NULL && GetEntityType(tile->mapObject) != ENTITY_TRAP))
{
return FALSE;
}
return TRUE;
}

16
src/weather.c Normal file
View File

@@ -0,0 +1,16 @@
#include "global.h"
#include "weather.h"
#include "constants/item.h"
#include "constants/weather.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
u8 GetWeather(struct DungeonEntity* pokemon)
{
if (pokemon != NULL && HasItem(pokemon, ITEM_ID_WEATHER_BAND))
{
return WEATHER_CLEAR;
}
return gDungeonGlobalData->weather;
}

View File

@@ -852,7 +852,7 @@ gPotentialItemTargetDirections = .; /* 202F330 */
gTargetAhead = .; /* 202F350 */
. += 0x8;
gPotentialTargetWeights = .; /* 202F358 */
gPotentialItemTargetWeights = .; /* 202F358 */
. += 0x20;
gUnknown_202F378 = .; /* 202F378 */
@@ -864,7 +864,7 @@ gCanAttackInDirection = .; /* 202F380 */
gPotentialAttackTargetDirections = .; /* 202F388 */
. += 0x8;
gPotentialTargetWeights_2 = .; /* 202F390 */
gPotentialAttackTargetWeights = .; /* 202F390 */
. += 0x20;
gPotentialTargets = .; /* 202F3B0 */

View File

@@ -490,9 +490,9 @@ string generate_move_data_text(Json data) {
<< read_json_binary(data_entry["aiTargetingFlags"], 2)
<< read_json_int(data_entry["maxPP"], 1)
<< read_json_int(data_entry["weight"], 1)
<< read_json_int(data_entry["accuracy1"], 1)
<< read_json_int(data_entry["accuracy2"], 1)
<< read_json_int(data_entry["useChance"], 1)
<< read_json_int(data_entry["accuracyGlobal"], 1)
<< read_json_int(data_entry["accuracyOffensive"], 1)
<< read_json_int(data_entry["accuracyUseChance"], 1)
<< read_json_int(data_entry["hitCount"], 1)
<< read_json_int(data_entry["unk12"], 1)
<< read_json_int(data_entry["criticalHitChance"], 1)