Merge pull request #98 from AnonymousRandomPerson/master

Finished attack AI decomp
This commit is contained in:
Seth Barberee
2022-03-11 10:10:49 -08:00
committed by GitHub
101 changed files with 14148 additions and 15227 deletions

View File

@@ -8704,7 +8704,7 @@ _08011406:
ldr r1, _0801147C
ldr r2, [r6]
add r0, sp, 0x4
bl ExpandPlaceholdersBuffer
bl sprintf_2
movs r0, 0
str r0, [sp]
movs r0, 0xC

View File

@@ -510,7 +510,7 @@ _08012F62:
_08012F64:
mov r0, r8
ldr r1, _08012FBC
bl ExpandPlaceholdersBuffer
bl sprintf_2
adds r0, r5, 0
adds r0, 0x14
mov r1, r9
@@ -4504,7 +4504,7 @@ _08014E60:
adds r5, 0x1
ldr r2, [r0]
mov r0, sp
bl ExpandPlaceholdersBuffer
bl sprintf_2
_08014E78:
mov r4, sp
b _08014F0E
@@ -4525,7 +4525,7 @@ _08014E84:
subs r2, 0x30
adds r5, 0x1
mov r0, sp
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r0, sp
ldrb r1, [r0]
cmp r1, 0
@@ -4558,7 +4558,7 @@ _08014EC4:
subs r2, 0x30
adds r5, 0x1
mov r0, sp
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r0, sp
ldrb r1, [r0]
cmp r1, 0
@@ -6139,7 +6139,7 @@ _08015B04:
add r0, sp, 0x4
ldr r1, _08015B30
adds r2, r5, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r1, r8
ldr r0, [r1]
ldrb r0, [r0, 0x19]
@@ -6169,7 +6169,7 @@ _08015B34:
mov r0, r10
ldr r1, _08015B78
adds r2, r5, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r3, r8
ldr r0, [r3]
ldrb r0, [r0, 0x19]
@@ -6477,7 +6477,7 @@ _08015DD0:
adds r0, 0xF8
ldr r2, [r0]
add r0, sp, 0x4
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _08015DEE
.align 2, 0
_08015DDC: .4byte gUnknown_80DB65C
@@ -6487,7 +6487,7 @@ _08015DE0:
adds r0, 0xF8
ldr r2, [r0]
add r0, sp, 0x4
bl ExpandPlaceholdersBuffer
bl sprintf_2
_08015DEE:
movs r0, 0
str r0, [sp]

View File

@@ -1160,7 +1160,7 @@ sub_801F700:
movs r7, 0
ldrsh r3, [r0, r7]
adds r0, r5, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r6]
adds r0, r4
ldr r3, [r0]
@@ -4920,7 +4920,7 @@ _08021574:
mov r0, r10
ldr r1, _08021598
add r2, sp, 0x8
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r3, r8
ldr r0, [r3]
adds r0, 0x40
@@ -4968,7 +4968,7 @@ _080215D8:
adds r2, r0, 0
mov r0, r10
ldr r1, _08021608
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r2, r8
ldr r0, [r2]
adds r0, 0x40
@@ -5519,7 +5519,7 @@ _08021A16:
add r0, sp, 0x4
ldr r1, _08021A58
adds r2, r7, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r1, r8
ldr r0, [r1]
ldr r3, [r0, 0x74]
@@ -9021,7 +9021,7 @@ _08023628:
ldr r1, _080236A0
adds r2, r7, 0
adds r3, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r6, _0802368C
ldr r0, [r6]
movs r1, 0xE4
@@ -10170,7 +10170,7 @@ _08023F02:
ldr r1, _08023F80
adds r2, r6, 0
mov r3, r9
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r1, r8
ldr r0, [r1]
movs r2, 0xD6
@@ -10874,7 +10874,7 @@ sub_80243E8:
ldr r1, _08024454
mov r0, sp
adds r2, r5, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
adds r0, r4, 0
add sp, 0x3C
pop {r4,r5}

View File

@@ -3,7 +3,7 @@
.syntax unified
.text
.text
thumb_func_start sub_803B050
sub_803B050:
@@ -1059,7 +1059,7 @@ _0803B818:
add r0, sp, 0x4
adds r2, r6, 0
_0803B84C:
bl ExpandPlaceholdersBuffer
bl sprintf_2
_0803B850:
ldr r1, [r7, 0x48]
ldr r3, [r7]
@@ -1096,7 +1096,7 @@ _0803B86C:
ldr r1, [r0]
add r0, sp, 0x4
adds r2, r6, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r1, [r7, 0x48]
ldr r3, [r7]
movs r0, 0
@@ -1160,7 +1160,7 @@ _0803B916:
ldr r1, _0803B938
add r0, sp, 0x4
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _0803B944
.align 2, 0
_0803B938: .4byte gUnknown_80E8884
@@ -1299,7 +1299,7 @@ _0803BA4C:
ldr r1, _0803BA68
add r0, sp, 0x4
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _0803BACC
.align 2, 0
_0803BA64: .4byte gUnknown_202DE58
@@ -1313,7 +1313,7 @@ _0803BA6C:
ldr r1, _0803BA88
add r0, sp, 0x4
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _0803BACC
.align 2, 0
_0803BA84: .4byte gUnknown_202DE58
@@ -1347,7 +1347,7 @@ _0803BAA0:
add r0, sp, 0x4
adds r2, r4, 0
adds r3, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
_0803BACC:
ldr r3, [r7]
movs r0, 0
@@ -1408,7 +1408,7 @@ _0803BB10:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r6, 0
str r6, [sp]
@@ -1454,7 +1454,7 @@ _0803BB74:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r4, 0
str r4, [sp]
@@ -1472,7 +1472,7 @@ _0803BB74:
ldr r1, [r5]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
str r4, [sp]
b _0803BD32
@@ -1508,7 +1508,7 @@ _0803BBF0:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r6, 0
str r6, [sp]
@@ -1554,7 +1554,7 @@ _0803BC58:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r6, 0
str r6, [sp]
@@ -1600,7 +1600,7 @@ _0803BCC0:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r6, 0
str r6, [sp]
@@ -1621,7 +1621,7 @@ _0803BD1A:
ldr r1, [r0]
add r0, sp, 0x4
mov r2, r8
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
str r6, [sp]
_0803BD32:
@@ -1677,7 +1677,7 @@ _0803BD88:
adds r0, r5, 0
adds r2, r6, 0
adds r3, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
mov r1, r8
str r1, [sp]
@@ -1783,7 +1783,7 @@ _0803BE80:
_0803BE94:
add r0, sp, 0x4
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r0, 0
str r0, [sp]
@@ -1823,7 +1823,7 @@ _0803BEC8:
ldr r1, _0803BF00
add r0, sp, 0x4
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _0803BF0C
.align 2, 0
_0803BEF8: .4byte gSpecialMissionText
@@ -1940,7 +1940,7 @@ _0803BFD0:
add r0, sp, 0x4
adds r2, r4, 0
_0803BFEE:
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r3, [r7]
movs r0, 0
str r0, [sp]

View File

@@ -1388,7 +1388,7 @@ _0803DB54:
adds r1, r5, 0
adds r2, r6, 0
adds r3, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _0803DBCA
.align 2, 0
_0803DB84: .4byte gUnknown_80F60F8
@@ -1411,7 +1411,7 @@ _0803DBBC:
adds r3, 0x30
add r0, sp, 0x4
adds r2, r6, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
_0803DBCA:
add r0, sp, 0x4
bl CalcStringWidth

View File

@@ -1316,14 +1316,4 @@ sub_8044C50:
_08044C84: .4byte 0x0000ffff
thumb_func_end sub_8044C50
thumb_func_start ResetAction
ResetAction:
movs r2, 0
movs r1, 0
strh r1, [r0]
strb r2, [r0, 0x4]
strb r2, [r0, 0xC]
bx lr
thumb_func_end ResetAction
.align 2, 0
.align 2, 0

View File

@@ -785,7 +785,7 @@ _080529D4:
ldr r0, _080529E4
ldr r1, _080529E8
ldr r2, _080529EC
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _08052A28
.align 2, 0
_080529E4: .4byte gUnknown_202E5D8
@@ -795,7 +795,7 @@ _080529F0:
ldr r0, _080529FC
ldr r1, _08052A00
ldr r2, _08052A04
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _08052A28
.align 2, 0
_080529FC: .4byte gUnknown_202E5D8
@@ -2451,7 +2451,7 @@ _08053734:
ldrb r1, [r1]
strb r1, [r0]
ldr r0, [sp, 0x18]
bl GetMoveTargetsUser
bl MoveTargetsUser
lsls r0, 24
cmp r0, 0
beq _080537B4
@@ -2856,7 +2856,7 @@ _08053A86:
cmp r0, 0x5
bne _08053AE8
ldr r0, [sp, 0x18]
bl GetMoveAffectedByMagicCoat
bl MoveAffectedByMagicCoat
lsls r0, 24
cmp r0, 0
beq _08053B5C
@@ -7204,7 +7204,7 @@ _08056136:
adds r0, r5, 0
adds r1, r7, 0
movs r2, 0x1
bl IsMoveUsable_2
bl IsMoveUsable
_08056142:
lsls r0, 24
lsrs r4, r0, 24
@@ -7222,7 +7222,7 @@ _08056156:
cmp r0, 0x1
bne _080561A0
ldrh r0, [r7, 0x2]
bl GetMoveAffectedByMuzzled
bl MoveAffectedByMuzzled
lsls r0, 24
cmp r0, 0
beq _080561A0

View File

@@ -285,693 +285,4 @@ _08057340:
bx r1
thumb_func_end sub_8057308
thumb_func_start IsMoveUsable_1
IsMoveUsable_1:
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r7, r0, 0
lsls r2, 24
lsrs r2, 24
mov r8, r2
ldr r6, [r7, 0x70]
lsls r1, 3
movs r0, 0x8C
lsls r0, 1
adds r1, r0
adds r4, r6, r1
ldrb r1, [r4]
movs r2, 0x1
adds r0, r2, 0
ands r0, r1
cmp r0, 0
beq _080573BE
movs r0, 0x2
ands r0, r1
cmp r0, 0
bne _080573BE
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _080573BE
ldrb r1, [r4, 0x1]
adds r0, r2, 0
ands r0, r1
cmp r0, 0
beq _0805738E
b _080573BE
_0805738A:
movs r0, 0x1
b _080573C0
_0805738E:
movs r5, 0
b _08057394
_08057392:
adds r5, 0x1
_08057394:
cmp r5, 0x3
bgt _080573BE
adds r0, r7, 0
adds r1, r4, 0
mov r2, r8
bl IsMoveUsable_2
lsls r0, 24
cmp r0, 0
bne _0805738A
adds r4, 0x8
movs r1, 0x9C
lsls r1, 1
adds r0, r6, r1
cmp r4, r0
bcs _080573BE
ldrb r1, [r4]
movs r0, 0x2
ands r0, r1
cmp r0, 0
bne _08057392
_080573BE:
movs r0, 0
_080573C0:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end IsMoveUsable_1
thumb_func_start IsMoveUsable_2
IsMoveUsable_2:
push {r4-r6,lr}
adds r4, r1, 0
lsls r2, 24
lsrs r2, 24
ldr r6, [r0, 0x70]
ldrh r1, [r4, 0x2]
ldr r0, _08057430
cmp r1, r0
beq _08057442
ldrb r1, [r4]
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _0805743E
ldrb r1, [r4, 0x1]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _0805743E
cmp r2, 0
beq _08057442
ldrb r0, [r4, 0x4]
cmp r0, 0
beq _0805743E
adds r0, r6, 0
adds r0, 0xBC
ldrb r1, [r0]
adds r5, r0, 0
cmp r1, 0x5
bne _08057414
adds r0, r4, 0
bl MoveDealsDirectDamage
lsls r0, 24
cmp r0, 0
beq _0805743E
_08057414:
ldrb r0, [r5]
cmp r0, 0x6
bne _08057442
ldrh r1, [r4, 0x2]
movs r0, 0xB0
lsls r0, 1
cmp r1, r0
bne _08057434
movs r1, 0x9C
lsls r1, 1
adds r0, r6, r1
ldrb r1, [r0]
b _08057436
.align 2, 0
_08057430: .4byte 0x00000163
_08057434:
ldrb r1, [r4]
_08057436:
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08057442
_0805743E:
movs r0, 0
b _08057444
_08057442:
movs r0, 0x1
_08057444:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end IsMoveUsable_2
thumb_func_start sub_805744C
sub_805744C:
push {r4-r6,lr}
adds r4, r1, 0
lsls r2, 24
lsrs r2, 24
ldr r6, [r0, 0x70]
ldrh r1, [r4, 0x2]
ldr r0, _080574A8
cmp r1, r0
beq _080574BA
ldrb r1, [r4]
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _080574B6
ldrb r1, [r4, 0x1]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _080574B6
cmp r2, 0
beq _080574BA
adds r0, r6, 0
adds r0, 0xBC
ldrb r1, [r0]
adds r5, r0, 0
cmp r1, 0x5
bne _0805748E
adds r0, r4, 0
bl MoveDealsDirectDamage
lsls r0, 24
cmp r0, 0
beq _080574B6
_0805748E:
ldrb r0, [r5]
cmp r0, 0x6
bne _080574BA
ldrh r1, [r4, 0x2]
movs r0, 0xB0
lsls r0, 1
cmp r1, r0
bne _080574AC
movs r1, 0x9C
lsls r1, 1
adds r0, r6, r1
ldrb r1, [r0]
b _080574AE
.align 2, 0
_080574A8: .4byte 0x00000163
_080574AC:
ldrb r1, [r4]
_080574AE:
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _080574BA
_080574B6:
movs r0, 0
b _080574BC
_080574BA:
movs r0, 0x1
_080574BC:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_805744C
thumb_func_start sub_80574C4
sub_80574C4:
push {r4-r6,lr}
sub sp, 0x104
adds r4, r0, 0
adds r5, r1, 0
movs r3, 0
movs r2, 0
ldr r0, [r4]
cmp r0, 0
beq _08057502
cmp r0, r5
beq _080574EA
_080574DA:
lsls r0, r3, 2
mov r6, sp
adds r1, r6, r0
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
str r0, [r1]
adds r3, 0x1
_080574EA:
adds r2, 0x1
cmp r2, 0x40
bgt _08057502
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
cmp r0, 0
beq _08057502
cmp r0, r5
beq _080574EA
cmp r3, 0x3F
ble _080574DA
_08057502:
movs r2, 0
ldr r0, [r4]
b _08057524
_08057508:
lsls r0, r3, 2
mov r6, sp
adds r1, r6, r0
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
str r0, [r1]
adds r3, 0x1
_08057518:
adds r2, 0x1
cmp r2, 0x40
bgt _08057530
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
_08057524:
cmp r0, 0
beq _08057530
cmp r0, r5
bne _08057518
cmp r3, 0x3F
ble _08057508
_08057530:
cmp r3, 0x40
bgt _08057542
movs r1, 0
lsls r0, r3, 2
add r0, sp
_0805753A:
stm r0!, {r1}
adds r3, 0x1
cmp r3, 0x40
ble _0805753A
_08057542:
mov r3, sp
adds r1, r4, 0
movs r2, 0x40
_08057548:
ldm r3!, {r0}
stm r1!, {r0}
subs r2, 0x1
cmp r2, 0
bge _08057548
add sp, 0x104
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_80574C4
thumb_func_start sub_805755C
sub_805755C:
push {r4,lr}
lsls r1, 16
lsrs r4, r1, 16
cmp r4, 0x97
bne _08057576
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08057576
movs r0, 0
b _08057580
_08057576:
adds r0, r4, 0
bl DoesMoveCharge
lsls r0, 24
lsrs r0, 24
_08057580:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_805755C
thumb_func_start sub_8057588
sub_8057588:
push {r4-r6,lr}
adds r4, r0, 0
lsls r1, 24
lsrs r6, r1, 24
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080575F8
ldr r5, [r4, 0x70]
movs r3, 0
_0805759E:
lsls r0, r3, 3
movs r1, 0x8C
lsls r1, 1
adds r0, r1
adds r2, r5, r0
ldrb r1, [r2]
movs r0, 0x1
ands r0, r1
adds r4, r3, 0x1
cmp r0, 0
beq _080575F2
movs r3, 0x1
ldrb r1, [r2, 0x1]
movs r0, 0x10
ands r0, r1
cmp r0, 0
beq _080575C8
movs r0, 0xEF
ands r0, r1
strb r0, [r2, 0x1]
movs r3, 0x2
_080575C8:
ldrb r1, [r2, 0x1]
movs r0, 0x8
ands r0, r1
cmp r0, 0
beq _080575F2
movs r0, 0xF7
ands r0, r1
strb r0, [r2, 0x1]
cmp r6, 0
beq _080575F2
cmp r3, 0
beq _080575F2
adds r1, r3, 0
_080575E2:
ldrb r0, [r2, 0x4]
cmp r0, 0
beq _080575EC
subs r0, 0x1
strb r0, [r2, 0x4]
_080575EC:
subs r1, 0x1
cmp r1, 0
bne _080575E2
_080575F2:
adds r3, r4, 0
cmp r3, 0x3
ble _0805759E
_080575F8:
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_8057588
thumb_func_start sub_8057600
sub_8057600:
push {r4,lr}
ldrh r4, [r0, 0x2]
adds r0, r1, 0
bl sub_8057620
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl sub_8094828
lsls r0, 16
asrs r0, 16
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8057600
thumb_func_start sub_8057620
sub_8057620:
push {lr}
cmp r0, 0
beq _0805762C
lsls r0, 24
lsrs r0, 24
b _0805762E
_0805762C:
movs r0, 0
_0805762E:
pop {r1}
bx r1
thumb_func_end sub_8057620
thumb_func_start sub_8057634
sub_8057634:
push {r4-r7,lr}
sub sp, 0x8
adds r5, r0, 0
adds r6, r1, 0
movs r7, 0
movs r4, 0x80
lsls r4, 1
str r3, [sp]
adds r3, r4, 0
bl sub_8055640
cmp r0, 0
beq _08057678
movs r7, 0x1
ldr r0, _08057684
movs r1, 0
ldrsh r2, [r0, r1]
adds r0, r5, 0
adds r1, r6, 0
bl sub_805727C
lsls r0, 24
cmp r0, 0
beq _08057678
ldr r0, _08057688
ldr r2, [r0]
str r7, [sp]
movs r0, 0
str r0, [sp, 0x4]
adds r0, r5, 0
adds r1, r6, 0
movs r3, 0x1
bl sub_8076F80
_08057678:
adds r0, r7, 0
add sp, 0x8
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_08057684: .4byte gUnknown_80F4DB4
_08057688: .4byte gUnknown_8106A4C
thumb_func_end sub_8057634
thumb_func_start sub_805768C
sub_805768C:
push {r4-r6,lr}
sub sp, 0x4
adds r5, r3, 0
movs r6, 0
ldr r4, _080576B8
ldr r3, [r4]
adds r3, 0x1
str r3, [r4]
ldr r4, _080576BC
lsls r3, 2
adds r3, r4
ldr r3, [r3]
str r5, [sp]
bl sub_8055640
cmp r0, 0
bne _080576C4
ldr r1, _080576C0
movs r0, 0x1
strb r0, [r1]
b _080576C6
.align 2, 0
_080576B8: .4byte gUnknown_202F21C
_080576BC: .4byte gUnknown_8106A54
_080576C0: .4byte gUnknown_202F220
_080576C4:
movs r6, 0x1
_080576C6:
adds r0, r6, 0
add sp, 0x4
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_805768C
thumb_func_start sub_80576D0
sub_80576D0:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _080576F4
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r2, 0x1
adds r0, r5, 0
adds r1, r4, 0
bl sub_8075F34
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_080576F4: .4byte gUnknown_80F4F28
thumb_func_end sub_80576D0
thumb_func_start sub_80576F8
sub_80576F8:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _0805771C
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r0, r5, 0
adds r1, r4, 0
movs r3, 0x1
bl sub_8075C58
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_0805771C: .4byte gUnknown_80F4E74
thumb_func_end sub_80576F8
thumb_func_start sub_8057720
sub_8057720:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _08057744
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r0, r5, 0
adds r1, r4, 0
bl sub_8075DBC
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_08057744: .4byte gUnknown_80F4E78
thumb_func_end sub_8057720
thumb_func_start sub_8057748
sub_8057748:
push {r4-r6,lr}
sub sp, 0x4
adds r5, r0, 0
adds r6, r1, 0
ldr r4, _08057778
bl GetWeather
lsls r0, 24
lsrs r0, 23
adds r0, r4
movs r1, 0
ldrsh r2, [r0, r1]
movs r0, 0x1
str r0, [sp]
adds r0, r5, 0
adds r1, r6, 0
movs r3, 0
bl HealTargetHP
movs r0, 0x1
add sp, 0x4
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_08057778: .4byte gUnknown_80F502A
thumb_func_end sub_8057748
thumb_func_start sub_805777C
sub_805777C:
push {lr}
bl sub_8079DB8
movs r0, 0x1
pop {r1}
bx r1
thumb_func_end sub_805777C
thumb_func_start sub_8057788
sub_8057788:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x4
adds r4, r0, 0
adds r7, r1, 0
adds r6, r2, 0
mov r8, r3
movs r0, 0
mov r9, r0
adds r0, r4, 0
bl GetMapTileForDungeonEntity_2
adds r5, r0, 0
bl IsTileGround
lsls r0, 24
cmp r0, 0
beq _080577BA
ldrh r1, [r5]
movs r0, 0x3
ands r0, r1
cmp r0, 0x1
beq _080577CC
_080577BA:
ldr r0, _080577C8
ldr r2, [r0]
adds r0, r4, 0
adds r1, r7, 0
bl sub_80522F4
b _0805780E
.align 2, 0
_080577C8: .4byte gUnknown_80FD14C
_080577CC:
adds r0, r4, 0
adds r1, r6, 0
bl MoveMatchesChargingStatus
lsls r0, 24
cmp r0, 0
beq _080577F8
ldr r0, _080577F4
ldr r3, [r0]
mov r0, r8
str r0, [sp]
adds r0, r4, 0
adds r1, r7, 0
adds r2, r6, 0
bl sub_8055640
adds r0, r4, 0
bl sub_8079764
b _0805780A
.align 2, 0
_080577F4: .4byte gUnknown_80F4F68
_080577F8:
ldr r0, _08057820
ldr r0, [r0]
str r0, [sp]
adds r0, r4, 0
adds r1, r4, 0
movs r2, 0xA
adds r3, r6, 0
bl sub_8079618
_0805780A:
movs r0, 0x1
mov r9, r0
_0805780E:
mov r0, r9
add sp, 0x4
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_08057820: .4byte gUnknown_80FAD4C
thumb_func_end sub_8057788
.align 2,0 @ Don't pad with nop
.align 2, 0

552
asm/code_805744C.s Normal file
View File

@@ -0,0 +1,552 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_805744C
sub_805744C:
push {r4-r6,lr}
adds r4, r1, 0
lsls r2, 24
lsrs r2, 24
ldr r6, [r0, 0x70]
ldrh r1, [r4, 0x2]
ldr r0, _080574A8
cmp r1, r0
beq _080574BA
ldrb r1, [r4]
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _080574B6
ldrb r1, [r4, 0x1]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _080574B6
cmp r2, 0
beq _080574BA
adds r0, r6, 0
adds r0, 0xBC
ldrb r1, [r0]
adds r5, r0, 0
cmp r1, 0x5
bne _0805748E
adds r0, r4, 0
bl MoveDealsDirectDamage
lsls r0, 24
cmp r0, 0
beq _080574B6
_0805748E:
ldrb r0, [r5]
cmp r0, 0x6
bne _080574BA
ldrh r1, [r4, 0x2]
movs r0, 0xB0
lsls r0, 1
cmp r1, r0
bne _080574AC
movs r1, 0x9C
lsls r1, 1
adds r0, r6, r1
ldrb r1, [r0]
b _080574AE
.align 2, 0
_080574A8: .4byte 0x00000163
_080574AC:
ldrb r1, [r4]
_080574AE:
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _080574BA
_080574B6:
movs r0, 0
b _080574BC
_080574BA:
movs r0, 0x1
_080574BC:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_805744C
thumb_func_start sub_80574C4
sub_80574C4:
push {r4-r6,lr}
sub sp, 0x104
adds r4, r0, 0
adds r5, r1, 0
movs r3, 0
movs r2, 0
ldr r0, [r4]
cmp r0, 0
beq _08057502
cmp r0, r5
beq _080574EA
_080574DA:
lsls r0, r3, 2
mov r6, sp
adds r1, r6, r0
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
str r0, [r1]
adds r3, 0x1
_080574EA:
adds r2, 0x1
cmp r2, 0x40
bgt _08057502
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
cmp r0, 0
beq _08057502
cmp r0, r5
beq _080574EA
cmp r3, 0x3F
ble _080574DA
_08057502:
movs r2, 0
ldr r0, [r4]
b _08057524
_08057508:
lsls r0, r3, 2
mov r6, sp
adds r1, r6, r0
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
str r0, [r1]
adds r3, 0x1
_08057518:
adds r2, 0x1
cmp r2, 0x40
bgt _08057530
lsls r0, r2, 2
adds r0, r4
ldr r0, [r0]
_08057524:
cmp r0, 0
beq _08057530
cmp r0, r5
bne _08057518
cmp r3, 0x3F
ble _08057508
_08057530:
cmp r3, 0x40
bgt _08057542
movs r1, 0
lsls r0, r3, 2
add r0, sp
_0805753A:
stm r0!, {r1}
adds r3, 0x1
cmp r3, 0x40
ble _0805753A
_08057542:
mov r3, sp
adds r1, r4, 0
movs r2, 0x40
_08057548:
ldm r3!, {r0}
stm r1!, {r0}
subs r2, 0x1
cmp r2, 0
bge _08057548
add sp, 0x104
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_80574C4
thumb_func_start sub_805755C
sub_805755C:
push {r4,lr}
lsls r1, 16
lsrs r4, r1, 16
cmp r4, 0x97
bne _08057576
bl GetWeather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08057576
movs r0, 0
b _08057580
_08057576:
adds r0, r4, 0
bl DoesMoveCharge
lsls r0, 24
lsrs r0, 24
_08057580:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_805755C
thumb_func_start sub_8057588
sub_8057588:
push {r4-r6,lr}
adds r4, r0, 0
lsls r1, 24
lsrs r6, r1, 24
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080575F8
ldr r5, [r4, 0x70]
movs r3, 0
_0805759E:
lsls r0, r3, 3
movs r1, 0x8C
lsls r1, 1
adds r0, r1
adds r2, r5, r0
ldrb r1, [r2]
movs r0, 0x1
ands r0, r1
adds r4, r3, 0x1
cmp r0, 0
beq _080575F2
movs r3, 0x1
ldrb r1, [r2, 0x1]
movs r0, 0x10
ands r0, r1
cmp r0, 0
beq _080575C8
movs r0, 0xEF
ands r0, r1
strb r0, [r2, 0x1]
movs r3, 0x2
_080575C8:
ldrb r1, [r2, 0x1]
movs r0, 0x8
ands r0, r1
cmp r0, 0
beq _080575F2
movs r0, 0xF7
ands r0, r1
strb r0, [r2, 0x1]
cmp r6, 0
beq _080575F2
cmp r3, 0
beq _080575F2
adds r1, r3, 0
_080575E2:
ldrb r0, [r2, 0x4]
cmp r0, 0
beq _080575EC
subs r0, 0x1
strb r0, [r2, 0x4]
_080575EC:
subs r1, 0x1
cmp r1, 0
bne _080575E2
_080575F2:
adds r3, r4, 0
cmp r3, 0x3
ble _0805759E
_080575F8:
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_8057588
thumb_func_start sub_8057600
sub_8057600:
push {r4,lr}
ldrh r4, [r0, 0x2]
adds r0, r1, 0
bl sub_8057620
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl sub_8094828
lsls r0, 16
asrs r0, 16
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8057600
thumb_func_start sub_8057620
sub_8057620:
push {lr}
cmp r0, 0
beq _0805762C
lsls r0, 24
lsrs r0, 24
b _0805762E
_0805762C:
movs r0, 0
_0805762E:
pop {r1}
bx r1
thumb_func_end sub_8057620
thumb_func_start sub_8057634
sub_8057634:
push {r4-r7,lr}
sub sp, 0x8
adds r5, r0, 0
adds r6, r1, 0
movs r7, 0
movs r4, 0x80
lsls r4, 1
str r3, [sp]
adds r3, r4, 0
bl sub_8055640
cmp r0, 0
beq _08057678
movs r7, 0x1
ldr r0, _08057684
movs r1, 0
ldrsh r2, [r0, r1]
adds r0, r5, 0
adds r1, r6, 0
bl sub_805727C
lsls r0, 24
cmp r0, 0
beq _08057678
ldr r0, _08057688
ldr r2, [r0]
str r7, [sp]
movs r0, 0
str r0, [sp, 0x4]
adds r0, r5, 0
adds r1, r6, 0
movs r3, 0x1
bl sub_8076F80
_08057678:
adds r0, r7, 0
add sp, 0x8
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_08057684: .4byte gUnknown_80F4DB4
_08057688: .4byte gUnknown_8106A4C
thumb_func_end sub_8057634
thumb_func_start sub_805768C
sub_805768C:
push {r4-r6,lr}
sub sp, 0x4
adds r5, r3, 0
movs r6, 0
ldr r4, _080576B8
ldr r3, [r4]
adds r3, 0x1
str r3, [r4]
ldr r4, _080576BC
lsls r3, 2
adds r3, r4
ldr r3, [r3]
str r5, [sp]
bl sub_8055640
cmp r0, 0
bne _080576C4
ldr r1, _080576C0
movs r0, 0x1
strb r0, [r1]
b _080576C6
.align 2, 0
_080576B8: .4byte gUnknown_202F21C
_080576BC: .4byte gUnknown_8106A54
_080576C0: .4byte gUnknown_202F220
_080576C4:
movs r6, 0x1
_080576C6:
adds r0, r6, 0
add sp, 0x4
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_805768C
thumb_func_start sub_80576D0
sub_80576D0:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _080576F4
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r2, 0x1
adds r0, r5, 0
adds r1, r4, 0
bl sub_8075F34
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_080576F4: .4byte gUnknown_80F4F28
thumb_func_end sub_80576D0
thumb_func_start sub_80576F8
sub_80576F8:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _0805771C
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r0, r5, 0
adds r1, r4, 0
movs r3, 0x1
bl sub_8075C58
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_0805771C: .4byte gUnknown_80F4E74
thumb_func_end sub_80576F8
thumb_func_start sub_8057720
sub_8057720:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
ldr r1, _08057744
adds r0, r4, 0
movs r2, 0x1
bl sub_808417C
adds r2, r0, 0
adds r0, r5, 0
adds r1, r4, 0
bl sub_8075DBC
movs r0, 0x1
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_08057744: .4byte gUnknown_80F4E78
thumb_func_end sub_8057720
thumb_func_start sub_8057748
sub_8057748:
push {r4-r6,lr}
sub sp, 0x4
adds r5, r0, 0
adds r6, r1, 0
ldr r4, _08057778
bl GetWeather
lsls r0, 24
lsrs r0, 23
adds r0, r4
movs r1, 0
ldrsh r2, [r0, r1]
movs r0, 0x1
str r0, [sp]
adds r0, r5, 0
adds r1, r6, 0
movs r3, 0
bl HealTargetHP
movs r0, 0x1
add sp, 0x4
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_08057778: .4byte gUnknown_80F502A
thumb_func_end sub_8057748
thumb_func_start sub_805777C
sub_805777C:
push {lr}
bl sub_8079DB8
movs r0, 0x1
pop {r1}
bx r1
thumb_func_end sub_805777C
thumb_func_start sub_8057788
sub_8057788:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x4
adds r4, r0, 0
adds r7, r1, 0
adds r6, r2, 0
mov r8, r3
movs r0, 0
mov r9, r0
adds r0, r4, 0
bl GetMapTileForDungeonEntity_2
adds r5, r0, 0
bl IsTileGround
lsls r0, 24
cmp r0, 0
beq _080577BA
ldrh r1, [r5]
movs r0, 0x3
ands r0, r1
cmp r0, 0x1
beq _080577CC
_080577BA:
ldr r0, _080577C8
ldr r2, [r0]
adds r0, r4, 0
adds r1, r7, 0
bl sub_80522F4
b _0805780E
.align 2, 0
_080577C8: .4byte gUnknown_80FD14C
_080577CC:
adds r0, r4, 0
adds r1, r6, 0
bl MoveMatchesChargingStatus
lsls r0, 24
cmp r0, 0
beq _080577F8
ldr r0, _080577F4
ldr r3, [r0]
mov r0, r8
str r0, [sp]
adds r0, r4, 0
adds r1, r7, 0
adds r2, r6, 0
bl sub_8055640
adds r0, r4, 0
bl sub_8079764
b _0805780A
.align 2, 0
_080577F4: .4byte gUnknown_80F4F68
_080577F8:
ldr r0, _08057820
ldr r0, [r0]
str r0, [sp]
adds r0, r4, 0
adds r1, r4, 0
movs r2, 0xA
adds r3, r6, 0
bl sub_8079618
_0805780A:
movs r0, 0x1
mov r9, r0
_0805780E:
mov r0, r9
add sp, 0x4
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_08057820: .4byte gUnknown_80FAD4C
thumb_func_end sub_8057788
.align 2,0 @ Don't pad with nop

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2951
asm/code_806E8B0.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -858,7 +858,7 @@ sub_8070968:
ldr r0, _0807098C
ldr r3, [r0]
adds r0, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
b _080709BA
.align 2, 0
_08070988: .4byte gUnknown_8106FA4

View File

@@ -3173,7 +3173,7 @@ _080733DE:
mov r0, r8
adds r1, r5, 0
movs r2, 0x1
bl IsMoveUsable_2
bl IsMoveUsable
lsls r0, 24
cmp r0, 0
bne _08073440
@@ -3384,7 +3384,7 @@ _0807357A:
adds r1, r5, 0
movs r2, 0x1
str r3, [sp, 0x14]
bl IsMoveUsable_2
bl IsMoveUsable
lsls r0, 24
ldr r3, [sp, 0x14]
cmp r0, 0

File diff suppressed because it is too large Load Diff

9186
asm/code_8077274.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,136 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start IsTargetInLineRange
IsTargetInLineRange:
push {r4-r7,lr}
adds r4, r0, 0
adds r5, r1, 0
movs r0, 0x4
ldrsh r1, [r4, r0]
movs r3, 0x4
ldrsh r0, [r5, r3]
subs r3, r1, r0
cmp r3, 0
bge _0807C4B6
negs r3, r3
_0807C4B6:
movs r6, 0x6
ldrsh r1, [r4, r6]
movs r7, 0x6
ldrsh r0, [r5, r7]
subs r1, r0
cmp r1, 0
bge _0807C4C6
negs r1, r1
_0807C4C6:
adds r0, r1, 0
cmp r1, r3
bge _0807C4CE
adds r0, r3, 0
_0807C4CE:
cmp r0, 0xA
bgt _0807C578
cmp r0, r2
bgt _0807C578
movs r6, 0x1
negs r6, r6
cmp r3, r1
bne _0807C516
movs r0, 0x4
ldrsh r1, [r4, r0]
movs r2, 0x4
ldrsh r0, [r5, r2]
ldrh r2, [r4, 0x4]
ldrh r3, [r5, 0x4]
cmp r1, r0
bge _0807C4FE
movs r6, 0x6
ldrsh r1, [r4, r6]
movs r7, 0x6
ldrsh r0, [r5, r7]
cmp r1, r0
blt _0807C574
cmp r1, r0
bgt _0807C574
_0807C4FE:
lsls r1, r2, 16
lsls r0, r3, 16
movs r6, 0x7
cmp r1, r0
ble _0807C570
movs r0, 0x6
ldrsh r1, [r4, r0]
movs r2, 0x6
ldrsh r0, [r5, r2]
cmp r1, r0
ble _0807C570
b _0807C574
_0807C516:
movs r3, 0x4
ldrsh r1, [r4, r3]
movs r7, 0x4
ldrsh r0, [r5, r7]
ldrh r2, [r4, 0x4]
ldrh r3, [r5, 0x4]
cmp r1, r0
bne _0807C532
movs r0, 0x6
ldrsh r1, [r4, r0]
movs r7, 0x6
ldrsh r0, [r5, r7]
cmp r1, r0
blt _0807C574
_0807C532:
lsls r1, r2, 16
lsls r0, r3, 16
cmp r1, r0
bge _0807C546
movs r0, 0x6
ldrsh r1, [r4, r0]
movs r7, 0x6
ldrsh r0, [r5, r7]
cmp r1, r0
beq _0807C574
_0807C546:
lsls r1, r2, 16
lsls r0, r3, 16
cmp r1, r0
bne _0807C55A
movs r0, 0x6
ldrsh r1, [r4, r0]
movs r7, 0x6
ldrsh r0, [r5, r7]
cmp r1, r0
bgt _0807C574
_0807C55A:
lsls r1, r2, 16
lsls r0, r3, 16
cmp r1, r0
ble _0807C570
movs r0, 0x6
ldrsh r1, [r4, r0]
movs r2, 0x6
ldrsh r0, [r5, r2]
cmp r1, r0
bne _0807C570
movs r6, 0x6
_0807C570:
cmp r6, 0
blt _0807C578
_0807C574:
movs r0, 0x1
b _0807C57A
_0807C578:
movs r0, 0
_0807C57A:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end IsTargetInLineRange
.align 2, 0

View File

@@ -1,322 +0,0 @@
#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

View File

@@ -676,7 +676,7 @@ _080907DA:
bne _0809080C
ldr r1, _08090808
adds r0, r7, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
movs r0, 0
b _0809080E
.align 2, 0

View File

@@ -3,7 +3,7 @@
.syntax unified
.text
.text
thumb_func_start sub_8098FCC
sub_8098FCC:
@@ -4305,7 +4305,7 @@ _0809B0E4:
lsls r2, 4
ldr r3, _0809B13C
adds r2, r3
bl ExpandPlaceholdersBuffer
bl sprintf_2
_0809B0F6:
adds r0, r4, 0
bl sub_809AE3C
@@ -4602,7 +4602,7 @@ _0809B318:
lsls r2, 4
ldr r3, _0809B3D8
adds r2, r3
bl ExpandPlaceholdersBuffer
bl sprintf_2
_0809B32A:
ldr r0, _0809B3DC
mov r8, r0
@@ -4614,7 +4614,7 @@ _0809B32A:
ldr r1, _0809B3E0
adds r0, r4, 0
adds r2, r7, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
adds r7, r4, 0
_0809B344:
adds r0, r6, 0
@@ -7670,7 +7670,7 @@ sub_809CBBC:
adds r0, r3
ldr r3, [r0]
mov r0, sp
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, _0809CC14
ldr r0, [r0]
movs r1, 0x98

View File

@@ -1542,7 +1542,7 @@ _080335C0:
adds r0, r4
ldr r1, _080335F0
add r2, sp, 0x14
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r5]
adds r0, r4
b _0803388E

View File

@@ -241,7 +241,7 @@ _0801AB90:
ldr r1, _0801AC08
adds r0, r5, 0
add r2, sp, 0x4
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r4, _0801AC0C
ldr r0, [r4]
adds r0, 0x54

View File

@@ -829,7 +829,7 @@ _08030608:
add r0, sp, 0x8
ldr r1, _08030664
adds r2, r5, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
mov r5, r8
ldr r0, [r5]
ldr r3, [r0, 0x64]

View File

@@ -139,7 +139,7 @@ _0802BFE8:
adds r1, r0, 0
mov r0, r8
mov r2, r9
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x38]
movs r0, 0

View File

@@ -865,7 +865,7 @@ _08030EE8:
ldr r1, _08030F54
adds r0, r6, 0
adds r2, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r5]
ldr r3, [r0, 0x10]
mov r0, r8

View File

@@ -56,7 +56,7 @@ _08031B2C:
ldr r1, _08031B8C
ldrb r2, [r5, 0x5]
add r0, sp, 0x4
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
str r6, [sp]
@@ -71,7 +71,7 @@ _08031B2C:
adds r2, r0, 0
add r0, sp, 0x4
adds r1, r4, 0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
str r6, [sp]
@@ -136,7 +136,7 @@ _08031BC2:
ldrb r2, [r4, 0x5]
ldr r0, [sp, 0xD8]
ldr r1, _08031C2C
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
mov r0, r8
@@ -167,7 +167,7 @@ _08031C30:
adds r0, r5, 0
ldr r1, _08031C54
mov r2, r9
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
mov r1, r8
@@ -194,7 +194,7 @@ _08031C70:
adds r0, r5, 0
ldr r1, _08031C98
_08031C7E:
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
mov r2, r8
@@ -214,7 +214,7 @@ _08031C9C:
adds r2, r0, 0
adds r0, r5, 0
ldr r1, _08031CD0
bl ExpandPlaceholdersBuffer
bl sprintf_2
ldr r0, [r7]
ldr r3, [r0, 0x10]
mov r2, r8

View File

@@ -805,28 +805,3 @@ gUnknown_80F51EC: @ 80F51EC
.global gUnknown_80F520C
gUnknown_80F520C: @ 80F520C
.incbin "baserom.gba", 0xF520C, 0x20
.global gTypeEffectivenessChart
gTypeEffectivenessChart: @ 80F522C
.incbin "baserom.gba", 0xF522C, 0x288
.global gUnknown_80F54B4
gUnknown_80F54B4: @ 80F54B4
.incbin "baserom.gba", 0xF54B4, 0x40
.global gUnknown_80F54F4
gUnknown_80F54F4: @ 80F54F4
.incbin "baserom.gba", 0xF54F4, 0xA0
.global gWarpScarfActivationChances
gWarpScarfActivationChances: @ 80F5594
@ replacing .incbin "baserom.gba", 0xF5594, 0x28
.2byte 0, 6, 12, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 999, 0
.global gUnknown_80F55BC
gUnknown_80F55BC: @ 80F55BC
.incbin "baserom.gba", 0xF55BC, 0x30
.global gUnknown_80F55EC
gUnknown_80F55EC: @ 80F55EC
.incbin "baserom.gba", 0xF55EC, 0x30

22
data/data_80F54B4.s Normal file
View File

@@ -0,0 +1,22 @@
.section .rodata
.global gUnknown_80F54B4
gUnknown_80F54B4: @ 80F54B4
.incbin "baserom.gba", 0xF54B4, 0x40
.global gUnknown_80F54F4
gUnknown_80F54F4: @ 80F54F4
.incbin "baserom.gba", 0xF54F4, 0xA0
.global gWarpScarfActivationChances
gWarpScarfActivationChances: @ 80F5594
@ replacing .incbin "baserom.gba", 0xF5594, 0x28
.2byte 0, 6, 12, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 999, 0
.global gUnknown_80F55BC
gUnknown_80F55BC: @ 80F55BC
.incbin "baserom.gba", 0xF55BC, 0x30
.global gUnknown_80F55EC
gUnknown_80F55EC: @ 80F55EC
.incbin "baserom.gba", 0xF55EC, 0x30

View File

@@ -347,18 +347,3 @@ gUnknown_8106F54: @ 8106F54
gUnknown_8106F64: @ 8106F64
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0xC0, 0x00, 0x00
.global gTypeEffectivenessMultipliers
gTypeEffectivenessMultipliers: @ 8106F6C
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.global gUnknown_8106F7C
gUnknown_8106F7C: @ 8106F7C
.incbin "baserom.gba", 0x106F7C, 0x28
.global gUnknown_8106FA4
gUnknown_8106FA4: @ 8106FA4
.string "{COLOR_2}%c%s{END_COLOR_TEXT_2}\0"

9
data/data_8106F7C.s Normal file
View File

@@ -0,0 +1,9 @@
.section .rodata
.global gUnknown_8106F7C
gUnknown_8106F7C: @ 8106F7C
.incbin "baserom.gba", 0x106F7C, 0x28
.global gUnknown_8106FA4
gUnknown_8106FA4: @ 8106FA4
.string "{COLOR_2}%c%s{END_COLOR_TEXT_2}\0"

View File

@@ -3,9 +3,7 @@
#include "dungeon_entity.h"
// 0x570AC
bool8 MoveMatchesChargingStatus(struct DungeonEntity *pokemon, struct PokemonMove *move);
// 0x570F4
// checkCharge = Check for the move named Charge.
bool8 IsCharging(struct DungeonEntity *pokemon, bool8 checkCharge);

6
include/code_800D090.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GUARD_CODE_800D090_H
#define GUARD_CODE_800D090_H
void sprintf_2(char *buffer, const char *text, ...);
#endif

View File

@@ -1,7 +1,9 @@
#ifndef GUARD_CONSTANTS_MOVE_H
#define GUARD_CONSTANTS_MOVE_H
enum MoveFlags
#define STRUGGLE_MOVE_INDEX 4
enum MoveFlag
{
MOVE_FLAG_EXISTS = 1 << 0,
MOVE_FLAG_LINKED = 1 << 1, // This move is linked with the previous move in the Pokémon's moveset.
@@ -11,6 +13,13 @@ enum MoveFlags
MOVE_FLAG_DISABLED = 1 << 5 // Disabled by an effect like Taunt.
};
enum MoveFlag2
{
MOVE_FLAG_SEALED = 1 << 0,
MOVE_FLAG_TEMPORARY = 1 << 3, // Used for moves copied by Mimic.
MOVE_FLAG_REPLACE = 1 << 5 // Used for moves copied by Sketch.
};
enum AccuracyType
{
// Accuracy used for all moves.
@@ -28,7 +37,6 @@ struct MoveData
u8 *namePointer;
/* 0x4 */ s16 power;
u8 type;
u8 fill7;
// Determines the range of moves.
/* 0x8 */ u16 targetingFlags[2]; // 0 for player and 1 for AI
// The AI consider certain moves to have different range than they actually do.
@@ -52,7 +60,7 @@ struct MoveData
struct PokemonMove
{
u8 moveFlags;
bool8 sealed;
u8 moveFlags2;
u16 moveID;
u8 PP;
u8 powerBoost; // How much the move is boosted by Ginsengs.

View File

@@ -1,6 +1,8 @@
#ifndef GUARD_CONSTANTS_TYPE_H
#define GUARD_CONSTANTS_TYPE_H
#define NUM_TYPES 18
#define TYPE_NONE 0x0
#define TYPE_NORMAL 0x1
#define TYPE_FIRE 0x2

View File

@@ -3,9 +3,8 @@
#include "dungeon_entity.h"
// 0x44C94
void ResetAction(struct DungeonActionContainer *actionPointer);
void SetAction(struct DungeonActionContainer *actionPointer, u16 action);
// 0x44CA0
void SetWalkAction(struct DungeonActionContainer *actionPointer, s16 species);
#endif

View File

@@ -3,6 +3,8 @@
#include "dungeon_entity.h"
#define RANGED_ATTACK_RANGE 10
struct MoveTargetResults
{
bool8 moveUsable;
@@ -10,9 +12,13 @@ struct MoveTargetResults
s32 moveWeight;
};
// 0x7BB94
void DecideAttack(struct DungeonEntity *pokemon);
// 0x7C04C
s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEntity *pokemon, struct PokemonMove *move);
bool8 IsTargetInLineRange(struct DungeonEntity *user, struct DungeonEntity *target, s32 range);
s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, u32 hasStatusChecker);
bool8 CanUseStatusMove(s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker);
s32 WeightMove(struct DungeonEntity *user, s32 targetingFlags, struct DungeonEntity *target, u32 moveType);
bool8 TargetRegularAttack(struct DungeonEntity *pokemon, u32 *targetDir, bool8 checkPetrified);
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange);
#endif

View File

@@ -1,11 +0,0 @@
#ifndef GUARD_DUNGEON_AI_ATTACK_1_H
#define GUARD_DUNGEON_AI_ATTACK_1_H
#include "dungeon_entity.h"
// 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

@@ -1,9 +0,0 @@
#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

@@ -3,9 +3,7 @@
#include "dungeon_entity.h"
// 0x48F28
u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags);
// 0x494EC
bool8 CanTargetAdjacentPokemon(struct DungeonEntity *pokemon);
#endif

View File

@@ -4,13 +4,9 @@
#include "dungeon_entity.h"
#include "position.h"
// 0x73658
void DecideUseItem(struct DungeonEntity *pokemon);
// 0x739DC
void FindStraightThrowableTargets(struct DungeonEntity *pokemon, s32 thrownAIFlag, struct ItemSlot *item, bool8 ignoreRollChance);
// 0x73AA0
void FindRockItemTargets(struct DungeonEntity *pokemon, struct ItemSlot *item, struct Position potentialTargets[], bool8 ignoreRollChance);
// 0x73B78
void TargetThrownItem(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, struct ItemSlot *item, s32 targetingFlags, bool8 ignoreRollChance);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x75990
void DecideAction(struct DungeonEntity *pokemon);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x71138
bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction);
#endif

View File

@@ -3,9 +3,7 @@
#include "dungeon_entity.h"
// 0x71494
bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon);
// 0x71518
bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x71598
u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x70B6C
bool8 CannotMove(struct DungeonEntity *pokemon, bool8 checkBlinker);
#endif

View File

@@ -3,13 +3,9 @@
#include "dungeon_entity.h"
// 0x70C60
bool8 CannotUseItems(struct DungeonEntity *pokemon);
// 0x70CD0
bool8 CannotAct(struct DungeonEntity *pokemon);
// 0x70d04
bool8 CannotAttack(struct DungeonEntity *pokemon, bool8 skipSleep);
// 0x70D6C
bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir);
#endif

View File

@@ -1,9 +1,7 @@
#ifndef GUARD_DUNGEON_ENGINE_H
#define GUARD_DUNGEON_ENGINE_H
// 0x441BC
bool8 IsBossBattle();
// 0x441E8
bool8 IsFixedDungeon();
#endif

View File

@@ -7,10 +7,20 @@
#include "position.h"
#define MAX_STAT_STAGE 20
#define STAT_MULTIPLIER_THRESHOLD 63
#define DEFAULT_STAT_STAGE 10
#define DEFAULT_STAT_MULTIPLIER 256
#define MAX_MOVEMENT_SPEED 4
#define MAX_STOCKPILE_COUNT 3
#define NUM_SPEED_TURN_COUNTERS 5
#define STAT_STAGE_ATTACK 0
#define STAT_STAGE_SPECIAL_ATTACK 1
#define STAT_STAGE_DEFENSE 0
#define STAT_STAGE_SPECIAL_DEFENSE 1
#define STAT_STAGE_ACCURACY 0
#define STAT_STAGE_EVASION 1
struct DungeonActionContainer
{
/* 0x0 */ u16 action;
@@ -18,7 +28,6 @@ struct DungeonActionContainer
u8 fill3;
// Additional parameter alongside actionIndex. Used for things like indicating which move a Pokémon should use from its moveset.
/* 0x4 */ u8 actionUseIndex;
u8 fill5[0x8 - 0x5];
// Position of the Pokémon the last time it threw an item.
/* 0x8 */ struct Position lastItemThrowPosition;
u8 unkC;
@@ -39,7 +48,6 @@ struct DungeonEntityData
/* 0x8 */ u8 shopkeeperMode;
/* 0x9 */ u8 level;
/* 0xA */ u8 partyIndex; // Leader is 0, partner is 1, etc.
u8 fillB;
/* 0xC */ s16 IQ;
/* 0xE */ s16 HP;
/* 0x10 */ s16 maxHP;
@@ -52,33 +60,29 @@ struct DungeonEntityData
/* 0x18 */ u32 expPoints;
// Temporary stat boosts/drops from effects like Growl or Swords Dance.
// These start at 10 and are in the range [1, 19].
/* 0x1C */ s16 attackStage;
/* 0x1E */ s16 specialAttackStage;
/* 0x20 */ s16 defenseStage;
/* 0x22 */ s16 specialDefenseStage;
/* 0x24 */ s16 accuracyStage;
/* 0x26 */ s16 evasionStage;
// Index 0 is Attack. Index 1 is Special Attack.
/* 0x1C */ s16 attackStages[2];
// Index 0 is Defense. Index 1 is Special Defense.
/* 0x20 */ s16 defenseStages[2];
// Index 0 is accuracy. Index 1 is evasion.
/* 0x24 */ s16 accuracyStages[2];
// // When a Fire-type move is used on a Pokémon with Flash Fire, this value increases the power of the Pokémon's Fire-type moves.
/* 0x28 */ s16 flashFireBoost;
u8 fill2A[0x2C - 0x2A];
// These start at 0x1000, and are halved by certain moves like Screech to lower the corresponding stat.
/* 0x2C */ s32 attackMultiplier;
/* 0x30 */ s32 specialAttackMultiplier;
/* 0x34 */ s32 defenseMultiplier;
/* 0x38 */ s32 specialDefenseMultiplier;
// Index 0 is Attack. Index 1 is Special Attack.
/* 0x2C */ s32 attackMultipliers[2];
// Index 0 is Defense. Index 1 is Special Defense.
/* 0x34 */ s32 defenseMultipliers[2];
/* 0x3C */ s16 hiddenPowerPower;
/* 0x3E */ u8 hiddenPowerType;
u8 fill3F;
/* 0x40 */ u8 joinLocation; // Uses the dungeon index in dungeon.h.
u8 fill41[0x44 - 0x41];
/* 0x44 */ struct DungeonActionContainer action;
u8 fill55[0x58 - 0x55];
// Position of the target that the Pokémon wants throw an item at.
/* 0x58 */ struct Position itemTargetPosition;
/* 0x5C */ u8 type1;
/* 0x5D */ u8 type2;
/* 0x5E */ u8 ability1;
/* 0x5F */ u8 ability2;
/* 0x5C */ u8 types[2];
/* 0x5E */ u8 abilities[2];
/* 0x60 */ struct ItemSlot heldItem;
u8 fill64[0x68 - 0x64];
/* 0x68 */ struct Position previousPosition1;
@@ -90,7 +94,6 @@ struct DungeonEntityData
/* 0x7A */ bool8 hasTarget;
/* 0x7B */ bool8 turnAround;
/* 0x7C */ u16 targetPokemonSpawnIndex;
u8 fill7E[0x80 - 0x7E];
/* 0x80 */ u32 targetPokemon;
u8 fill84[0x88 - 0x84];
/* 0x88 */ struct Position targetMovePosition;
@@ -168,7 +171,6 @@ struct DungeonEntityData
/* 0xFD */ u8 perishSongTimer; // When this reaches 0, the Pokémon faints from Perish Song. Doubles as a bool for whether the Pokémon is afflicted by Perish Song.
u8 fillFE[0x100 - 0xFE];
/* 0x100 */ u8 targetingDecoy; // If the Pokémon is targeting a decoy, this indicates whether the decoy target is a team or wild Pokémon.
u8 fill101[0x104 - 0x101];
/* 0x104 */ s32 movementSpeed;
// The turn counter for movement speed up/down is split into five timers each. Multiple timers are used if the Pokémon is affected by multiple
// speed-up/slow effects at once, like using Agility twice.
@@ -179,10 +181,8 @@ struct DungeonEntityData
// When true, an AI Pokémon will move in a random direction every turn.
// Unclear where this is set in-game; it is not set by statuses (e.g., confusion) or mission clients.
/* 0x114 */ bool8 moveRandomly;
u8 fill115[0x118 - 0x115];
/* 0x118 */ struct PokemonMove moves[MAX_MON_MOVES];
/* 0x138 */ u8 struggleMoveFlags;
u8 fill139[0x13C - 0x139];
/* 0x13C */ u32 belly;
/* 0x140 */ u32 maxBelly;
/* 0x144 */ bool8 movingIntoTarget; // True if an AI Pokémon is following another Pokémon and is already adjacent to them.
@@ -201,7 +201,6 @@ struct DungeonEntityData
u8 unk15F;
u8 fill160[0x169 - 0x160];
u8 turnsSinceWarpScarfActivation;
u8 fill16A[0x16C - 0x16A];
/* 0x16C */ struct Position targetPosition;
/* 0x170 */ struct Position posPixel;
u32 unk174;
@@ -210,7 +209,6 @@ struct DungeonEntityData
/* 0x184 */ struct Position previousTargetMovePosition1;
/* 0x188 */ struct Position32 previousTargetMovePosition2;
/* 0x190 */ u8 lastMoveDirection; // The last direction that the Pokémon moved in.
u8 fill191[0x194 - 0x191];
// Number of tiles that the Pokémon moved last, multiplied by 0x100.
/* 0x194 */ struct Position32 lastMoveIncrement;
/* 0x19C */ u8 walkAnimationCounter; // Set when the Pokémon starts moving, and counts down until the Pokémon's walk animation stops.
@@ -220,9 +218,7 @@ struct DungeonEntityData
/* 0x1F6 */ bool8 notMoving;
u8 fill1F7[0x1FA - 0x1F7];
/* 0x1FA */ u8 mobileTurnTimer; // When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
u8 fill1FB;
/* 0x1FC */ u16 expGainedInTurn; // Used to accumulate experience when multiple enemies are defeated in one turn.
u8 fill1FE[0x200 - 0x1FE];
/* 0x200 */ u32 statusSprites;
u32 unk204;
};
@@ -273,7 +269,6 @@ struct DungeonEntity
/* 0x6A */ u8 unk6B;
/* 0x6C */ u8 facingDir;
/* 0x6D */ u8 facingDir2; // Duplicate of 0x6C?
u8 fill6D[0x70 - 0x6E];
/* 0x70 */ struct DungeonEntityData *entityData;
};

View File

@@ -53,7 +53,6 @@ struct DungeonGlobalData
/* 0x3A0E */ s16 tileset;
u8 fill3A10[0x3A14 - 0x3A10];
/* 0x3A14 */ s16 bossBattleIndex;
u8 fill3A16[0x3A18 - 0x3A16];
/* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fillE218[0xE23C - 0xE218];
s16 unkE23C;

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x46CB0
bool8 HasItem(struct DungeonEntity *pokemon, u8 itemIndex);
#endif

View File

@@ -8,9 +8,7 @@ struct unkStruct_202F190
struct MapTile* unk0[6];
};
// 0x4954C
struct MapTile* GetMapTile_1(s32 x, s32 y);
// 0x49590
struct MapTile* GetMapTile_2(s32 x, s32 y);
#endif

View File

@@ -1,7 +1,6 @@
#ifndef GUARD_DUNGEON_MOVEMENT_H
#define GUARD_DUNGEON_MOVEMENT_H
// 0x70328
u8 GetCrossableTerrain(s16 species);
#endif

View File

@@ -3,22 +3,14 @@
#include "dungeon_entity.h"
// 0x71824
bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability);
// 0x71858
bool8 HasType(struct DungeonEntity *pokemon, u8 type);
// 0x71884
bool8 CanSeeInvisible(struct DungeonEntity *pokemon);
// 0x718AC
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic);
// 0x718D8
bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill);
void LoadIQSkills(struct DungeonEntity *pokemon);
bool8 CanSeeTeammate(struct DungeonEntity * pokemon);
u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
// 0x71A44
s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
bool8 ToolboxEnabled(struct DungeonEntityData *pokemon);

View File

@@ -1,9 +1,7 @@
#ifndef GUARD_DUNGEON_RANDOM_H
#define GUARD_DUNGEON_RANDOM_H
// 0x840E8
s32 DungeonRandom(void);
// 0x84100
s32 DungeonRandomCapped(s32 cap);
#endif

View File

@@ -1,7 +1,6 @@
#ifndef GUARD_DUNGEON_RANDOM_1_H
#define GUARD_DUNGEON_RANDOM_1_H
// 0x84144
bool8 RollPercentChance(s32 percentChance);
#endif

View File

@@ -3,7 +3,6 @@
#include "position.h"
// 0x83294
bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2);
#endif

View File

@@ -7,13 +7,9 @@
extern const struct Position gAdjacentTileOffsets[NUM_DIRECTIONS];
// 0x450E0
bool8 EntityExists(struct DungeonEntity *pokemon);
// 0x450F8
u32 GetEntityType(struct DungeonEntity *entity);
// 0x45104
struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity);
// 0x45108
struct ItemSlot *GetItemData(struct DungeonEntity *entity);
struct MapTile *GetMapTileForDungeonEntity_2(struct DungeonEntity *entity);

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x85A50
bool8 IsMovingClient(struct DungeonEntity *entity);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x45990
bool8 CanSee(struct DungeonEntity *entity, struct DungeonEntity *targetEntity);
#endif

9
include/move_util.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef GUARD_MOVE_UTIL_H
#define GUARD_MOVE_UTIL_H
#include "dungeon_entity.h"
bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasPPChecker);
bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker);
#endif

View File

@@ -18,14 +18,14 @@ s32 GetMoveAccuracy(struct PokemonMove *move, u32 accuracyType);
u32 GetMoveMaxPP(struct PokemonMove *move);
u8 GetMoveUnk12(struct PokemonMove *move);
u8 GetMoveCriticalHitChance(struct PokemonMove *move);
u8 GetMoveCannotHitFrozen(struct PokemonMove *move);
u8 MoveDealsDirectDamage(struct PokemonMove *move);
bool8 MoveCannotHitFrozen(struct PokemonMove *move);
bool8 MoveDealsDirectDamage(struct PokemonMove *move);
u32 GetMoveRangeType(struct PokemonMove *move);
void sub_8092C84(u8 *buffer, u16 moveID);
u8 *GetMoveUseText(u16 moveID);
u8 GetMoveAffectedByMagicCoat(u16 moveID);
u8 GetMoveTargetsUser(u16 moveID);
u8 GetMoveAffectedByMuzzled(u16 moveID);
bool8 MoveAffectedByMagicCoat(u16 moveID);
bool8 MoveTargetsUser(u16 moveID);
bool8 MoveAffectedByMuzzled(u16 moveID);
bool8 IsBlockedBySoundproof(struct PokemonMove *move);
bool8 DoesMoveCharge(u16 move);

View File

@@ -1,7 +1,6 @@
#ifndef GUARD_NUMBER_UTIL_H
#define GUARD_NUMBER_UTIL_H
// 0x94450
s32 RoundUpFixedPoint(s32 fixedPointNumber);
#endif

View File

@@ -3,7 +3,6 @@
#include "position.h"
// 0x983D8
s32 CalculateFacingDir(struct Position *originPos, struct Position *targetPos);
#endif

12
include/status.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef GUARD_STATUS_H
#define GUARD_STATUS_H
#include "dungeon_entity.h"
#define FLASH_FIRE_STATUS_NONE 0
#define FLASH_FIRE_STATUS_MAXED 1
#define FLASH_FIRE_STATUS_NOT_MAXED 2
u8 GetFlashFireStatus(struct DungeonEntity *pokemon);
#endif

View File

@@ -4,7 +4,10 @@
#include "constants/move.h"
#include "dungeon_entity.h"
// 0x5C498
bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move);
bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move);
bool8 HasDisabledMove(struct PokemonMove *moves);
bool8 LastUsedMoveOutOfPP(struct PokemonMove *moves);
bool8 HasLastUsedMove(struct PokemonMove *moves);
#endif

View File

@@ -5,7 +5,6 @@
extern const s16 gConfusedAttackChance;
// 0x7001C
bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon);
#endif

View File

@@ -3,11 +3,8 @@
#include "dungeon_entity.h"
// 0x70A58
bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
// 0x70B28
bool8 IsSleeping(struct DungeonEntity *pokemon);
// 0x70B48
bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x69DCC
void TargetTileInFront(struct DungeonEntity *pokemon);
#endif

View File

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

View File

@@ -7,9 +7,7 @@
#define DUNGEON_WATER_TYPE_LAVA 1
#define DUNGEON_WATER_TYPE_WATER 2
// 0x4AF20
bool8 IsTileGround(struct MapTile* tile);
// 0x4AF74
bool8 IsWaterTileset();
#endif

View File

@@ -3,7 +3,6 @@
#include "position.h"
// 0x4AF74
bool8 CanLayTrap(struct Position *pos);
#endif

17
include/type_chart.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef GUARD_TYPE_CHART_H
#define GUARD_TYPE_CHART_H
#include "global.h"
#include "constants/type.h"
#define NUM_EFFECTIVENESS 4
#define EFFECTIVENESS_IMMUNE 0
#define EFFECTIVENESS_RESIST 1
#define EFFECTIVENESS_NEUTRAL 2
#define EFFECTIVENESS_SUPER 3
// [Attacking type][Defending type]
extern const s16 gTypeEffectivenessChart[NUM_TYPES][NUM_TYPES];
#endif

View File

@@ -0,0 +1,8 @@
#ifndef GUARD_TYPE_EFFECTIVENESS_H
#define GUARD_TYPE_EFFECTIVENESS_H
#include "dungeon_entity.h"
s32 WeightWeakTypePicker(struct DungeonEntity *user, struct DungeonEntity *target, u8 moveType);
#endif

View File

@@ -3,7 +3,6 @@
#include "dungeon_entity.h"
// 0x7E580
u8 GetWeather(struct DungeonEntity* pokemon);
#endif

View File

@@ -208,14 +208,18 @@ SECTIONS {
asm/code_80521D0.o(.text);
src/charge_move.o(.text);
asm/code_8057144.o(.text);
src/move_util.o(.text);
asm/code_805744C.o(.text);
src/code_8057824.o(.text);
asm/code_8057824.o(.text);
src/status_checker.o(.text);
asm/code_805CEB8.o(.text);
asm/code_805D8C8.o(.text);
src/targeting.o(.text);
asm/code_8069E0C.o(.text);
src/code_806CD90.o(.text);
asm/code_806CD90.o(.text);
src/type_effectiveness.o(.text);
asm/code_806E8B0.o(.text);
src/status_checks.o(.text);
asm/code_80701A4.o(.text);
src/dungeon_movement.o(.text);
@@ -238,11 +242,9 @@ SECTIONS {
asm/code_8073CF0.o(.text);
src/dungeon_ai_movement.o(.text);
asm/code_8075BA4.o(.text);
src/status.o(.text);
asm/code_8077274.o(.text);
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);
@@ -423,12 +425,16 @@ SECTIONS {
data/data_80F4DB4.o(.rodata);
src/dungeon_ai_attack.o(.rodata);
data/data_80F4E2C.o(.rodata);
src/type_chart.o(.rodata);
data/data_80F54B4.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/type_effectiveness.o(.data);
data/data_8106F7C.o(.rodata);
src/dungeon_capabilities_1.o(.rodata);
data/data_8106FB5.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);

View File

@@ -4,7 +4,6 @@
#include "config.h"
#include "global.h"
extern void SoundBiasReset(void);
extern void SoundBiasSet(void);
@@ -70,7 +69,7 @@ void sub_800D098(void)
while(REG_KEYINPUT != KEYS_MASK){} // All buttons
}
void ExpandPlaceholdersBuffer(u8 *buffer, const char *text, ...)
void sprintf_2(char *buffer, const char *text, ...)
{
va_list vArgv;
va_start(vArgv, text);

View File

@@ -8,6 +8,7 @@
#include "input.h"
#include "text.h"
#include "rescue_team_info.h"
#include "code_800D090.h"
struct unkStruct_203B258
{
@@ -64,15 +65,14 @@ extern void sub_8008C54(u32);
extern void sub_80073B8(u32);
extern void sub_80073E0(u32);
void LoadTeamRankBadge(u32, u32, u32);
extern void ExpandPlaceholdersBuffer(u8 *, u32 *, ...);
extern void SetBGPaletteBufferColorArray(s32 index, u8 *colorArray);
extern void sub_8007E20(u32, u32, u32, u32, u32, u8 *, u32);
extern struct FileArchive gTitleMenuFileArchive;
extern const char gTeamRankBadgeFileName;
extern u32 gUnknown_80DBF3C;
extern u32 gUnknown_80DBF4C;
extern char gUnknown_80DBF3C[];
extern char gUnknown_80DBF4C[];
struct TeamBadgeData
{
@@ -305,8 +305,8 @@ void sub_801D894(void)
// Stored on stack
u32 *preload_string;
u32 *r5; // R5
u8 buffer [96]; // sp +4
char *r5; // R5
char buffer [96]; // sp +4
if (gUnknown_203B250->currFriendAreaLocation == NONE) {
location = sub_8098FB4();
@@ -327,11 +327,11 @@ void sub_801D894(void)
LoadTeamRankBadge(2, 8, 6);
// Have to load before TeamRank funcs
r5 = &gUnknown_80DBF3C; // %s {COLOR_1 CYAN}%d{END_COLOR_TEXT_1} Pts.
r5 = gUnknown_80DBF3C; // %s {COLOR_1 CYAN}%d{END_COLOR_TEXT_1} Pts.
rank = GetRescueTeamRank();
ExpandPlaceholdersBuffer(buffer, r5, GetTeamRankString(rank), GetTeamRankPts());
sprintf_2(buffer, r5, GetTeamRankString(rank), GetTeamRankPts());
xxx_call_draw_string(32, 4, buffer, 2, 0);
ExpandPlaceholdersBuffer(buffer, &gUnknown_80DBF4C, gTeamInventory_203B460->teamMoney);
sprintf_2(buffer, gUnknown_80DBF4C, gTeamInventory_203B460->teamMoney);
xxx_call_draw_string(32, 18, buffer, 2, 0);
sub_80073E0(2);
}

View File

@@ -1,13 +1,11 @@
#include "global.h"
#include "dungeon.h"
#include "code_800D090.h"
extern const char gUnknown_8108F10[];
extern const char gUnknown_8108F18[];
extern const char gUnknown_8108F2C[];
void ExpandPlaceholdersBuffer(u8 *buffer, const char *text, ...);
struct unkDungeonStruct
{
u8 index;
@@ -16,17 +14,17 @@ struct unkDungeonStruct
void sub_8090208(u8 *buffer, struct unkDungeonStruct *dungeonLocation)
{
ExpandPlaceholdersBuffer(buffer, gUnknown_8108F10, gDungeonNames[dungeonLocation->index].name1); // {COLOR_2 YELLOW_4}%s{END_COLOR_TEXT_2} (normal floor print (no B)
sprintf_2(buffer, gUnknown_8108F10, gDungeonNames[dungeonLocation->index].name1); // {COLOR_2 YELLOW_4}%s{END_COLOR_TEXT_2} (normal floor print (no B)
}
void PrintDungeonLocationtoBuffer(u8 *buffer, struct unkDungeonStruct *dungeonLocation)
{
if(gDungeons[dungeonLocation->index].stairDirection != 0){
ExpandPlaceholdersBuffer(buffer, gUnknown_8108F18, gDungeonNames[dungeonLocation->index].name1, dungeonLocation->floor); //_F
sprintf_2(buffer, gUnknown_8108F18, gDungeonNames[dungeonLocation->index].name1, dungeonLocation->floor); //_F
}
else
{
ExpandPlaceholdersBuffer(buffer, gUnknown_8108F2C, gDungeonNames[dungeonLocation->index].name1, dungeonLocation->floor); // B _F
sprintf_2(buffer, gUnknown_8108F2C, gDungeonNames[dungeonLocation->index].name1, dungeonLocation->floor); // B _F
}
}

View File

@@ -5,6 +5,13 @@
#include "dungeon_entity.h"
#include "pokemon.h"
void ResetAction(struct DungeonActionContainer *actionPointer)
{
actionPointer->action = DUNGEON_ACTION_NONE;
actionPointer->actionUseIndex = 0;
actionPointer->unkC = 0;
}
void SetAction(struct DungeonActionContainer *actionPointer, u16 action)
{
actionPointer->action = action;

View File

@@ -7,13 +7,13 @@
#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/tactic.h"
#include "constants/targeting.h"
#include "constants/type.h"
#include "charge_move.h"
#include "dungeon_action.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_ai_targeting_2.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
@@ -22,12 +22,15 @@
#include "dungeon_random_1.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "move_util.h"
#include "moves.h"
#include "position_util.h"
#include "status_checker.h"
#include "status_checks.h"
#include "status_checks_1.h"
#include "targeting.h"
#include "targeting_flags.h"
#include "type_effectiveness.h"
#define REGULAR_ATTACK_INDEX 4
@@ -39,11 +42,6 @@ extern s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS];
extern u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS];
extern struct DungeonEntity *gPotentialTargets[NUM_DIRECTIONS];
extern bool8 IsMoveUsable_1(struct DungeonEntity*, s32, bool8);
extern bool8 TargetRegularAttack(struct DungeonEntity*, u32*, bool8);
extern bool8 IsTargetInLineRange(struct DungeonEntity*, struct DungeonEntity*, s32);
extern s32 WeightMove(struct DungeonEntity*, s32, struct DungeonEntity*, u8);
void DecideAttack(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
@@ -181,7 +179,7 @@ void DecideAttack(struct DungeonEntity *pokemon)
move = &pokemonData->moves[i];
if (move->moveFlags & MOVE_FLAG_EXISTS &&
willNotUnlinkMove[i] &&
IsMoveUsable_1(pokemon, i, hasPPChecker) &&
IsMoveIndexUsable(pokemon, i, hasPPChecker) &&
move->moveFlags & MOVE_FLAG_ENABLED)
{
moveTargetResults[i].moveUsable = TRUE;
@@ -522,4 +520,405 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
moveTargetResults->moveWeight = 8;
}
return moveWeight;
}
}
bool8 IsTargetInLineRange(struct DungeonEntity *user, struct DungeonEntity *target, s32 range)
{
s32 posDiffX = user->posWorld.x - target->posWorld.x;
s32 posDiffY, maxPosDiff;
s32 direction;
if (posDiffX < 0)
{
posDiffX = -posDiffX;
}
posDiffY = user->posWorld.y - target->posWorld.y;
if (posDiffY < 0)
{
posDiffY = -posDiffY;
}
maxPosDiff = posDiffY;
if (posDiffY < posDiffX)
{
maxPosDiff = posDiffX;
}
if (maxPosDiff > RANGED_ATTACK_RANGE || maxPosDiff > range)
{
return FALSE;
}
direction = -1;
if (posDiffX == posDiffY)
{
if (user->posWorld.x < target->posWorld.x &&
(user->posWorld.y < target->posWorld.y || user->posWorld.y > target->posWorld.y))
{
returnTrue:
return TRUE;
}
if (user->posWorld.x > target->posWorld.x); // Fixes register loading order.
direction = DIRECTION_SOUTHWEST;
if (user->posWorld.x <= target->posWorld.x || user->posWorld.y <= target->posWorld.y)
{
goto checkDirectionSet;
}
goto returnTrue;
}
else if (user->posWorld.x == target->posWorld.x && user->posWorld.y < target->posWorld.y)
{
return TRUE;
}
else if (user->posWorld.x < target->posWorld.x && user->posWorld.y == target->posWorld.y)
{
return TRUE;
}
else if (user->posWorld.x == target->posWorld.x && user->posWorld.y > target->posWorld.y)
{
return TRUE;
}
else if (user->posWorld.x > target->posWorld.x && user->posWorld.y == target->posWorld.y)
{
direction = DIRECTION_WEST;
}
checkDirectionSet:
if (direction < 0)
{
return FALSE;
}
return TRUE;
}
s32 WeightMoveIfUsable(s32 numPotentialTargets, s32 targetingFlags, struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move, bool32 hasStatusChecker)
{
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)
{
facingDir = userData->action.facingDir;
}
else
{
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)
{
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))
{
goto returnFalse;
}
if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP)
{
goto rollMoveUseChance;
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_HP)
{
if (!HasQuarterHPOrLess(target))
{
if (*categoryTargetingFlags2);
goto returnFalse;
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_STATUS)
{
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->types[0] != TYPE_GHOST && targetData->types[1] != 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 hasTarget;
}
s32 WeightMove(struct DungeonEntity *user, s32 targetingFlags, struct DungeonEntity *target, u32 moveType)
{
#ifndef NONMATCHING
register struct DungeonEntityData *targetData asm("r4");
#else
struct DungeonEntityData *targetData;
#endif
s32 targetingFlags2 = (s16) targetingFlags;
u8 moveType2 = moveType;
u8 weight = 1;
struct DungeonEntityData *targetData2;
targetData2 = targetData = target->entityData;
if (!targetData->isEnemy || (targetingFlags2 & 0xF) != TARGETING_FLAG_TARGET_OTHER)
{
return 1;
}
else if (HasIQSkill(user, IQ_SKILL_EXP_GO_GETTER))
{
// BUG: expYieldRankings has lower values as the Pokémon's experience yield increases.
// This causes Exp. Go-Getter to prioritize Pokémon worth less experience
// instead of Pokémon worth more experience.
weight = gDungeonGlobalData->expYieldRankings[targetData->entityID];
}
else if (HasIQSkill(user, IQ_SKILL_EFFICIENCY_EXPERT))
{
weight = -12 - targetData2->HP;
if (weight == 0)
{
weight = 1;
}
}
else if (HasIQSkill(user, IQ_SKILL_WEAK_TYPE_PICKER))
{
weight = WeightWeakTypePicker(user, target, moveType2) + 1;
}
return weight;
}
bool8 TargetRegularAttack(struct DungeonEntity *pokemon, u32 *targetDir, bool8 checkPetrified)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
s32 numPotentialTargets = 0;
s32 facingDir = pokemonData->action.facingDir;
s32 faceTurnLimit = pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER ? 1 : 8;
s32 i;
s32 potentialAttackTargetDirections[NUM_DIRECTIONS];
s32 potentialAttackTargetWeights[NUM_DIRECTIONS];
bool8 hasTargetingIQ = HasIQSkill(pokemon, IQ_SKILL_EXP_GO_GETTER) || HasIQSkill(pokemon, IQ_SKILL_EFFICIENCY_EXPERT);
bool8 hasStatusChecker = HasIQSkill(pokemon, IQ_SKILL_STATUS_CHECKER);
for (i = 0; i < faceTurnLimit; i++, facingDir++)
{
struct DungeonEntity *target;
facingDir &= DIRECTION_MASK;
target = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y)->pokemon;
if (target != NULL &&
GetEntityType(target) == ENTITY_POKEMON &&
CanAttackInFront(pokemon, facingDir) &&
CanTarget(pokemon, target, FALSE, checkPetrified) == TARGET_CAPABILITY_CAN_TARGET &&
(!hasStatusChecker || target->entityData->immobilizeStatus != IMMOBILIZE_STATUS_FROZEN))
{
potentialAttackTargetDirections[numPotentialTargets] = facingDir;
potentialAttackTargetWeights[numPotentialTargets] = WeightMove(pokemon, TARGETING_FLAG_TARGET_OTHER, target, TYPE_NONE);
if (!hasTargetingIQ)
{
*targetDir = facingDir;
return TRUE;
}
numPotentialTargets++;
}
}
if (numPotentialTargets == 0)
{
return FALSE;
}
else
{
s32 totalWeight = 0;
s32 maxWeight = 0;
s32 weightCounter;
s32 i;
for (i = 0; i < numPotentialTargets; i++)
{
if (maxWeight < potentialAttackTargetWeights[i])
{
maxWeight = potentialAttackTargetWeights[i];
}
}
for (i = 0; i < numPotentialTargets; i++)
{
if (maxWeight != potentialAttackTargetWeights[i])
{
potentialAttackTargetWeights[i] = 0;
}
}
for (i = 0; i < numPotentialTargets; i++)
{
totalWeight += potentialAttackTargetWeights[i];
}
weightCounter = DungeonRandomCapped(totalWeight);
for (i = 0; i < numPotentialTargets; i++)
{
weightCounter -= potentialAttackTargetWeights[i];
if (weightCounter < 0)
{
break;
}
}
*targetDir = potentialAttackTargetDirections[i];
return TRUE;
}
}
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

@@ -1,175 +0,0 @@
#include "global.h"
#include "dungeon_ai_attack_1.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_random.h"
#include "moves.h"
#include "position_util.h"
#include "status_checks_1.h"
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 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)
{
facingDir = userData->action.facingDir;
}
else
{
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)
{
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))
{
goto returnFalse;
}
if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP)
{
goto rollMoveUseChance;
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_HP)
{
if (!HasQuarterHPOrLess(target))
{
if (*categoryTargetingFlags2);
goto returnFalse;
}
}
else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_STATUS)
{
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 hasTarget;
}

View File

@@ -1,76 +0,0 @@
#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

@@ -6,7 +6,7 @@
#include "constants/status.h"
#include "constants/targeting.h"
#include "dungeon_action.h"
#include "dungeon_ai_attack_2.h"
#include "dungeon_ai_attack.h"
#include "dungeon_ai_item_weight.h"
#include "dungeon_ai_items.h"
#include "dungeon_ai_targeting_2.h"
@@ -28,7 +28,6 @@
#define NUM_POTENTIAL_ROCK_TARGETS 20
#define GROUND_ITEM_TOOLBOX_INDEX 0x80
#define HELD_ITEM_TOOLBOX_INDEX 0x81
#define RANGED_ATTACK_RANGE 10
enum ItemTargetFlag
{

View File

@@ -28,7 +28,6 @@ extern char *gPtrItsaMonsterHouseMessage;
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void ResetAction(u16*);
extern void MoveIfPossible(struct DungeonEntity*, bool8);
extern u8 sub_8044B28(void);
extern void sub_807AB38(struct DungeonEntity *, u32);
@@ -206,7 +205,7 @@ void DecideAction(struct DungeonEntity *pokemon)
}
}
}
ResetAction(&pokemonData->action.action);
ResetAction(&pokemonData->action);
if (pokemonData->clientType == CLIENT_TYPE_CLIENT)
{
SetWalkAction(&pokemonData->action, pokemonData->entityID);

View File

@@ -95,7 +95,7 @@ bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability)
else
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->ability1 == ability || pokemonData->ability2 == ability)
if (pokemonData->abilities[0] == ability || pokemonData->abilities[1] == ability)
{
return TRUE;
}
@@ -110,11 +110,11 @@ bool8 HasType(struct DungeonEntity *pokemon, u8 type)
{
return FALSE;
}
if (pokemonData->type1 == type)
if (pokemonData->types[0] == type)
{
return TRUE;
}
if (pokemonData->type2 == type)
if (pokemonData->types[1] == type)
{
return TRUE;
}

View File

@@ -2,6 +2,7 @@
#include "constants/friend_area.h"
#include "friend_area.h"
#include "pokemon.h"
#include "code_800D090.h"
bool8 gBoughtFriendAreas[NUM_FRIEND_AREAS];
EWRAM_DATA bool8 *gFriendAreas;
@@ -14,7 +15,6 @@ extern const char *gFriendAreaNames[];
extern const char gUnknown_81098A4;
extern const char gUnknown_81098AC;
extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...);
extern void sub_8090FEC(u32, u8 *r1, u32);
const struct FriendAreaSettings gFriendAreaSettings[NUM_FRIEND_AREAS] =
@@ -599,7 +599,7 @@ u32 GetFriendAreaPrice(u8 index)
void sub_8092558(u8 *buffer, u8 index)
{
// colors the friend area name green and prints to buffer?
ExpandPlaceholdersBuffer(buffer, &gUnknown_81098A4, gFriendAreaNames[index]);
sprintf_2(buffer, &gUnknown_81098A4, gFriendAreaNames[index]);
}
void sub_8092578(u8 *buffer, u8 index, u8 r2)
@@ -609,7 +609,7 @@ void sub_8092578(u8 *buffer, u8 index, u8 r2)
if(r2)
{
sub_8090FEC(gFriendAreaSettings[index].price, priceBuffer, 1);
ExpandPlaceholdersBuffer(buffer, &gUnknown_81098AC, gFriendAreaNames[index], 96, priceBuffer);
sprintf_2(buffer, &gUnknown_81098AC, gFriendAreaNames[index], 96, priceBuffer);
}
else
{

View File

@@ -4,6 +4,7 @@
#include "text.h"
#include "team_inventory.h"
#include "constants/move.h"
#include "code_800D090.h"
struct unkStruct_203B2B8
{
@@ -52,7 +53,6 @@ extern void sub_8008C54(u32);
extern void sub_80073B8(u32);
extern void sub_80073E0(u32);
extern void sub_80922B4(u8 *, const u8 *, u32);
extern void ExpandPlaceholdersBuffer(u8 *buffer, const u8 *text, ...);
extern void sub_808D930(u8 *, s16);
extern s32 sub_8008ED0(u8 *);
extern void xxx_call_draw_string(s32 x, s32 y, u8 *, u32, u32);
@@ -333,7 +333,7 @@ void sub_8026E08(u32 r0)
sub_80073B8(r0);
sub_80922B4(gAvailablePokemonNames, gUnknown_203B2B8->unk18->name, POKEMON_NAME_LENGTH);
sub_808D930(buffer, gUnknown_203B2B8->unk18->speciesNum);
ExpandPlaceholdersBuffer(buffer1, gUnknown_80DD6E0, gAvailablePokemonNames);
sprintf_2(buffer1, gUnknown_80DD6E0, gAvailablePokemonNames);
x = sub_8008ED0(buffer1);
xxx_call_draw_string(((gUnknown_80DD370.unk0c << 3) - x) / 2, 3, buffer1, r0, 0);
sub_80073E0(r0);

View File

@@ -8,6 +8,7 @@
#include "random.h"
#include "subStruct_203B240.h"
#include "team_inventory.h"
#include "code_800D090.h"
#include <stddef.h>
@@ -37,7 +38,6 @@ EWRAM_DATA struct Item *gItemParametersData;
extern u8 GetItemType(u8);
extern u32 GetItemUnkThrow(u8, u32);
extern void ExpandPlaceholdersBuffer(u8 *, const u8 *, ...);
extern s32 sub_8090FEC(s32 a1, u8* a2, u8 a3);
extern void sub_80073B8(u32);
extern u32 sub_8097DF0(char *, struct subStruct_203B240 **);
@@ -326,35 +326,35 @@ void sub_8090E14(u8* ext_buffer, struct ItemSlot* slot, struct unkStruct_8090F58
if (GetItemType(slot->itemIndex) == ITEM_TYPE_THROWABLE) {
// I feel like these labels might actually be there...
if (unk8) {
ExpandPlaceholdersBuffer(buffer, gUnknown_8109770, gItemParametersData[slot->itemIndex].namePointer, slot->numItems);
sprintf_2(buffer, gUnknown_8109770, gItemParametersData[slot->itemIndex].namePointer, slot->numItems);
}
else {
ExpandPlaceholdersBuffer(buffer, gUnknown_8109778, gItemParametersData[slot->itemIndex].namePointer);
sprintf_2(buffer, gUnknown_8109778, gItemParametersData[slot->itemIndex].namePointer);
}
}
else if (GetItemType(slot->itemIndex) == ITEM_TYPE_ROCK) {
if (unk8) {
ExpandPlaceholdersBuffer(buffer, gUnknown_8109770, gItemParametersData[slot->itemIndex].namePointer, slot->numItems);
sprintf_2(buffer, gUnknown_8109770, gItemParametersData[slot->itemIndex].namePointer, slot->numItems);
}
else {
ExpandPlaceholdersBuffer(buffer, gUnknown_8109778, gItemParametersData[slot->itemIndex].namePointer);
sprintf_2(buffer, gUnknown_8109778, gItemParametersData[slot->itemIndex].namePointer);
}
}
else if (slot->itemIndex == ITEM_ID_POKE) {
ExpandPlaceholdersBuffer(buffer, gUnknown_810977C, GetMoneyValue(slot));
sprintf_2(buffer, gUnknown_810977C, GetMoneyValue(slot));
}
else {
strncpy(buffer, gItemParametersData[slot->itemIndex].namePointer, 80);
}
if (slot->itemFlags & ITEM_FLAG_STICKY) {
ExpandPlaceholdersBuffer(ext_buffer, gUnknown_8109784, buffer);
sprintf_2(ext_buffer, gUnknown_8109784, buffer);
strncpy(buffer, ext_buffer, 80);
}
if (a3) {
if (a3->unk4 && (slot->itemFlags & ITEM_FLAG_SET)) {
ExpandPlaceholdersBuffer(ext_buffer, gUnknown_810978C, buffer);
sprintf_2(ext_buffer, gUnknown_810978C, buffer);
strncpy(buffer, ext_buffer, 80);
}
if ((*(u32*)a3 == 1) || (*(u32*)a3 == 3)) {
@@ -408,11 +408,11 @@ void sub_8090F58(void* a1, u8 *a2, struct ItemSlot *slot, struct unkStruct_8090F
if (a4->unk6) {
sub_8090FEC(value, buffer, 1);
ExpandPlaceholdersBuffer(a1, gUnknown_8109794, a2, a4->unk6, buffer);
sprintf_2(a1, gUnknown_8109794, a2, a4->unk6, buffer);
}
else {
sub_8090FEC(value, buffer, 0);
ExpandPlaceholdersBuffer(a1, gUnknown_81097A4, a2, buffer);
sprintf_2(a1, gUnknown_81097A4, a2, buffer);
}
}

View File

@@ -6,6 +6,7 @@
#include "item.h"
#include "kecleon_items.h"
#include "team_inventory.h"
#include "code_800D090.h"
extern struct unkStruct_203B210 *gUnknown_203B210;
extern u8 gUnknown_80DB8E4[];
@@ -31,7 +32,6 @@ extern void sub_8008C54(u32);
extern void sub_80073B8(u32);
extern void sub_80073E0(u32);
extern s32 sub_8013800(void *, u32);
extern void ExpandPlaceholdersBuffer(u8 *, u8 *, ...);
extern void xxx_call_draw_string(s32 x, s32, u8 *, u32, u32);
extern void sub_801AE84(void);
extern void sub_8012D08(void *, u32);
@@ -475,7 +475,7 @@ void sub_801A0D8(void)
// Needed for the shifts..
u32 index_shift;
u32 numItems_shift;
sub_8008C54(gUnknown_203B214->unk34);
sub_80073B8(gUnknown_203B214->unk34);
xxx_call_draw_string(gUnknown_203B214->unk1E * 8 + 10,0,gUnknown_80DB8E4,
@@ -505,7 +505,7 @@ void sub_801A0D8(void)
xxx_call_draw_string(8,y,auStack204,gUnknown_203B214->unk34,0);
}
else {
ExpandPlaceholdersBuffer(auStack112,gUnknown_80DB8EC,auStack204);
sprintf_2(auStack112,gUnknown_80DB8EC,auStack204);
y = sub_8013800(gUnknown_203B214,iVar4);
xxx_call_draw_string(8,y,auStack112,gUnknown_203B214->unk34,0);
}
@@ -701,7 +701,7 @@ void sub_801A4A4(void)
// Needed for the shifts..
u32 index_shift;
u32 numItems_shift;
sub_8008C54(gUnknown_203B21C->unk34);
sub_80073B8(gUnknown_203B21C->unk34);
xxx_call_draw_string(gUnknown_203B21C->unk1E * 8 + 10,0,gUnknown_80DB92C,
@@ -731,7 +731,7 @@ void sub_801A4A4(void)
xxx_call_draw_string(8,y,auStack204,gUnknown_203B21C->unk34,0);
}
else {
ExpandPlaceholdersBuffer(auStack112,gUnknown_80DB934,auStack204);
sprintf_2(auStack112,gUnknown_80DB934,auStack204);
y = sub_8013800(gUnknown_203B21C,iVar4);
xxx_call_draw_string(8,y,auStack112,gUnknown_203B21C->unk34,0);
}
@@ -741,7 +741,7 @@ void sub_801A4A4(void)
u32 sub_801A5D8(u32 param_1,int param_2,struct UnkTextStruct2_sub *param_3,u32 param_4)
{
if (GetNumberOfFilledInventorySlots() == 0) {
return 0;
}
@@ -781,7 +781,7 @@ u32 sub_801A6E8(u8 param_1)
{
s32 iVar5;
struct ItemSlot local_10;
if (param_1 == '\0') {
sub_8013660(&gUnknown_203B224->unk54);
return 0;

View File

@@ -8,6 +8,7 @@
#include "text.h"
#include "pokemon.h"
#include "save.h"
#include "code_800D090.h"
extern const struct FileArchive gTitleMenuFileArchive;
@@ -59,7 +60,6 @@ extern void sub_80920D8(u8 *);
extern struct PokemonStruct *GetPlayerPokemonStruct(void);
extern u8 sub_80023E4(u32);
extern u8 *sub_8098FB4();
extern void ExpandPlaceholdersBuffer(u8 *buffer, const u8 *text, ...);
extern u8 *GetDungeonLocationInfo(void);
extern u32 GetNumAdventures(void);
extern void xxx_call_draw_string(u32 x, u32 y, const u8 *, u32, u32);
@@ -179,7 +179,7 @@ ALIGNED(4) const char load_screen_fill[] = "pksdir0";
void CreateLoadScreen(u32 currMenu)
{
int iVar8;
if (gLoadScreen == NULL) {
gLoadScreen = MemoryAlloc(sizeof(struct LoadScreen),8);
MemoryFill8((u8 *)gLoadScreen,0,sizeof(struct LoadScreen));
@@ -230,7 +230,7 @@ u32 UpdateLoadScreenMenu(void)
{
u32 nextMenu;
u32 menuAction;
nextMenu = MENU_NO_SCREEN_CHANGE;
menuAction = 4;
sub_8012FD8(&gLoadScreen->unk54);
@@ -311,7 +311,7 @@ void DrawLoadScreenText(void)
r2 = DrawLoadScreenTextSub(teamNameBuffer);
}
ExpandPlaceholdersBuffer(gLoadScreen->formattedTeamName,gUnknown_80E7804,r2);
sprintf_2(gLoadScreen->formattedTeamName,gUnknown_80E7804,r2);
xxx_call_draw_string(64,0,gLoadScreen->formattedTeamName,0,0);
// Draw Player Name
@@ -320,7 +320,7 @@ void DrawLoadScreenText(void)
sub_80922B4(playerName, gNoNamePlaceholder, POKEMON_NAME_LENGTH);
else
sub_80922B4(playerName, playerInfo->name, POKEMON_NAME_LENGTH);
ExpandPlaceholdersBuffer(gLoadScreen->formattedPlayerName,gUnknown_80E7804,playerName);
sprintf_2(gLoadScreen->formattedPlayerName,gUnknown_80E7804,playerName);
xxx_call_draw_string(64,12,gLoadScreen->formattedPlayerName,0,0);
// Draw Location Info
@@ -328,7 +328,7 @@ void DrawLoadScreenText(void)
if (iVar2 == 0xf1207)
PrintDungeonLocationtoBuffer(gLoadScreen->formattedLocation,GetDungeonLocationInfo());
else
ExpandPlaceholdersBuffer(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
}
else {
switch(sub_8011C1C())
@@ -337,12 +337,12 @@ void DrawLoadScreenText(void)
switch(sub_8001658(0,24))
{
default:
ExpandPlaceholdersBuffer(auStack356,gUnknown_80E7804,sub_8098FB4());
sprintf_2(auStack356,gUnknown_80E7804,sub_8098FB4());
xxx_format_string(auStack356,gLoadScreen->formattedLocation,gLoadScreen->formattedPlayTime,0);
break;
case 0x7:
case 0xB:
ExpandPlaceholdersBuffer(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
break;
}
break;
@@ -350,10 +350,10 @@ void DrawLoadScreenText(void)
if (iVar2 == 0xf1207)
PrintDungeonLocationtoBuffer(gLoadScreen->formattedLocation,GetDungeonLocationInfo());
else
ExpandPlaceholdersBuffer(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
break;
default:
ExpandPlaceholdersBuffer(gLoadScreen->formattedLocation,gLocationUnknownText); // Location unknown
sprintf_2(gLoadScreen->formattedLocation,gLocationUnknownText); // Location unknown
break;
}
}
@@ -361,12 +361,12 @@ void DrawLoadScreenText(void)
// Draw Play Time
DeconstructPlayTime(gPlayTimeRef,&hours,&minutes,&seconds);
ExpandPlaceholdersBuffer(gLoadScreen->formattedPlayTime,gPlayTimePlaceholder,hours,minutes,seconds);
sprintf_2(gLoadScreen->formattedPlayTime,gPlayTimePlaceholder,hours,minutes,seconds);
xxx_call_draw_string(64,36,gLoadScreen->formattedPlayTime,0,0);
// Draw Adventures Info
// Draw Adventures Info
numAdventures = GetNumAdventures();
ExpandPlaceholdersBuffer(gLoadScreen->formattedAdventures,gNumAdventurePlaceholder,numAdventures); // %d
sprintf_2(gLoadScreen->formattedAdventures,gNumAdventurePlaceholder,numAdventures); // %d
xxx_call_draw_string(64,48,gLoadScreen->formattedAdventures,0,0);
// Draw Helper Info
@@ -376,14 +376,14 @@ void DrawLoadScreenText(void)
if(temp2->speciesIndex != SPECIES_NONE) {
sub_808D930(speciesHelper,temp2->speciesIndex);
sub_80922B4(nameHelper,temp2->helperName,POKEMON_NAME_LENGTH);
ExpandPlaceholdersBuffer(gLoadScreen->formattedHelperInfo,gHelperInfoPlaceholder,nameHelper,speciesHelper); // %s (%s)
sprintf_2(gLoadScreen->formattedHelperInfo,gHelperInfoPlaceholder,nameHelper,speciesHelper); // %s (%s)
}
else
goto print_helper_placeholder;
}
else {
print_helper_placeholder:
ExpandPlaceholdersBuffer(gLoadScreen->formattedHelperInfo,gNoHelperText); // -----
sprintf_2(gLoadScreen->formattedHelperInfo,gNoHelperText); // -----
}
xxx_call_draw_string(64,60,gLoadScreen->formattedHelperInfo,0,0);
@@ -399,7 +399,7 @@ void sub_80397B4(void)
int iVar3;
int iVar4;
s32 other_arg;
clmkFile = OpenFileAndGetFileDataPtr(gClmkpatFileName,&gTitleMenuFileArchive); // clmkpat
for(iVar3 = 0; iVar3 < 64; iVar3++)
@@ -426,7 +426,7 @@ bool8 IsQuickSave(void)
{
int iVar1;
bool8 isQuicksave;
iVar1 = sub_8011FA8();
isQuicksave = FALSE;
if (sub_8095324(1) != 0 || sub_8095324(7) != 0)

88
src/move_util.c Normal file
View File

@@ -0,0 +1,88 @@
#include "global.h"
#include "move_util.h"
#include "constants/move_id.h"
#include "constants/status.h"
#include "moves.h"
bool8 IsMoveIndexUsable(struct DungeonEntity *pokemon, s32 moveIndex, bool8 hasPPChecker)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
struct PokemonMove *move = &pokemonData->moves[moveIndex];
s32 i;
if (!(move->moveFlags & MOVE_FLAG_EXISTS))
{
return FALSE;
}
if (move->moveFlags & MOVE_FLAG_LINKED)
{
return FALSE;
}
if (move->moveFlags & MOVE_FLAG_DISABLED ||
move->moveFlags2 & MOVE_FLAG_SEALED)
{
return FALSE;
}
goto initMoveIndex;
returnTrue:
return TRUE;
initMoveIndex:
i = 0;
goto checkMoveUsable;
incMoveIndex:
i++;
checkMoveUsable:
if (i >= MAX_MON_MOVES)
{
return FALSE;
}
if (IsMoveUsable(pokemon, move, hasPPChecker))
{
goto returnTrue;
}
move++;
if ((u32) move >= (u32) &pokemonData->struggleMoveFlags || !(move->moveFlags & MOVE_FLAG_LINKED))
{
return FALSE;
}
goto incMoveIndex;
}
bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool8 hasPPChecker)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (move->moveID == MOVE_REGULAR_ATTACK)
{
return TRUE;
}
if (move->moveFlags & MOVE_FLAG_DISABLED || move->moveFlags2 & MOVE_FLAG_SEALED)
{
return FALSE;
}
if (hasPPChecker)
{
if (move->PP == 0)
{
return FALSE;
}
if (pokemonData->volatileStatus == VOLATILE_STATUS_TAUNTED && !MoveDealsDirectDamage(move))
{
return FALSE;
}
if (pokemonData->volatileStatus == VOLATILE_STATUS_ENCORE)
{
if (move->moveID == MOVE_STRUGGLE)
{
if (!(pokemonData->struggleMoveFlags & MOVE_FLAG_LAST_USED))
{
return FALSE;
}
}
else if (!(move->moveFlags & MOVE_FLAG_LAST_USED))
{
return FALSE;
}
}
}
return TRUE;
}

View File

@@ -3,6 +3,7 @@
#include "file_system.h"
#include "moves.h"
#include "code_800D090.h"
struct MoveDataFile
{
@@ -37,7 +38,6 @@ extern u8 gUnknown_810992C[];
extern void sub_8093F10(struct PokemonMove *, struct PokemonMove *);
extern void sub_80928C0(u8 *, struct PokemonMove *, struct unkStruct_80928C0 *);
extern void ExpandPlaceholdersBuffer(u8 *, u8 *, ...);
void LoadWazaParameters(void)
{
@@ -51,7 +51,7 @@ u8 sub_809287C(struct PokemonMove *move)
{
if((move->moveFlags & MOVE_FLAG_DISABLED) != 0)
return 0x32;
else if((move->sealed & 1) == 0)
else if((move->moveFlags2 & MOVE_FLAG_SEALED) == 0)
return 0x34;
else
return 0x32;
@@ -76,7 +76,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
}
if (move->powerBoost != 0)
ExpandPlaceholdersBuffer(localBuffer,gUnknown_81098DC,move->powerBoost); // %+d
sprintf_2(localBuffer,gUnknown_81098DC,move->powerBoost); // %+d
else
localBuffer[0] = '\0';
@@ -88,14 +88,14 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
}
switch(param_3->unk0) {
case 0:
ExpandPlaceholdersBuffer
sprintf_2
(buffer,gUnknown_81098E0,uVar2,
gMovesData[move->moveID].namePointer,localBuffer);
break;
case 1:
maxPP = GetMoveMaxPP(move);
ExpandPlaceholdersBuffer
sprintf_2
(buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
move->PP,maxPP);
@@ -103,7 +103,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
case 2:
maxPP = GetMoveMaxPP(move);
ExpandPlaceholdersBuffer
sprintf_2
(buffer,gUnknown_8109910,uVar2,move->moveFlags & MOVE_FLAG_SET ? gUnknown_8109908 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
move->PP,maxPP);
@@ -111,7 +111,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
case 3:
maxPP = GetMoveMaxPP(move);
ExpandPlaceholdersBuffer
sprintf_2
(buffer,gUnknown_81098EC,uVar2,move->moveFlags & MOVE_FLAG_ENABLED ? gUnknown_8109928 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
move->PP,maxPP);
@@ -119,7 +119,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
case 4:
maxPP = GetMoveMaxPP(move);
ExpandPlaceholdersBuffer
sprintf_2
(buffer,gUnknown_8109910,uVar2, move->moveFlags & MOVE_FLAG_ENABLED ? gUnknown_8109928 : gUnknown_810990C,
gMovesData[move->moveID].namePointer,localBuffer,param_3->unk4,
move->PP,maxPP);
@@ -130,7 +130,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0
void InitPokemonMove(struct PokemonMove *move, u16 moveID)
{
move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS;
move->sealed = FALSE;
move->moveFlags2 = 0;
move->moveID = moveID;
move->PP = GetMoveMaxPP(move);
move->powerBoost = 0;
@@ -143,7 +143,7 @@ void sub_8092AA8(struct PokemonMove *move, u16 moveID)
else
{
move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS;
move->sealed = FALSE;
move->moveFlags2 = 0;
move->moveID = moveID;
move->PP = GetMoveMaxPP(move);
move->powerBoost = 0;
@@ -297,17 +297,17 @@ u8 *GetMoveUseText(u16 moveID)
return gMovesData[moveID].useText;
}
u8 GetMoveAffectedByMagicCoat(u16 moveID)
bool8 MoveAffectedByMagicCoat(u16 moveID)
{
return gMovesData[moveID].affectedByMagicCoat;
}
u8 GetMoveTargetsUser(u16 moveID)
bool8 MoveTargetsUser(u16 moveID)
{
return gMovesData[moveID].targetsUser;
}
u8 GetMoveAffectedByMuzzled(u16 moveID)
bool8 MoveAffectedByMuzzled(u16 moveID)
{
return gMovesData[moveID].affectedByMuzzled;
}
@@ -331,5 +331,5 @@ bool8 IsBlockedBySoundproof(struct PokemonMove *move)
void sub_8092D54(u8 *buffer, struct PokemonMove *move)
{
ExpandPlaceholdersBuffer(buffer, gUnknown_810992C, gRangeNames[GetMoveRangeType(move)]);
sprintf_2(buffer, gUnknown_810992C, gRangeNames[GetMoveRangeType(move)]);
}

View File

@@ -38,7 +38,7 @@ void RestorePokemonMoves(struct unkStruct_8094924 *r0, struct PokemonMove *moveS
void sub_8094148(struct unkStruct_8094924 *r0, struct PokemonMove *move)
{
SaveIntegerBits(r0, &move->moveFlags, 4);
SaveIntegerBits(r0, &move->sealed, 1);
SaveIntegerBits(r0, &move->moveFlags2, 1);
SaveIntegerBits(r0, &move->moveID, 9);
SaveIntegerBits(r0, &move->PP, 7);
SaveIntegerBits(r0, &move->powerBoost, 7);
@@ -59,7 +59,7 @@ void sub_80941B0(struct unkStruct_8094924 *r0, struct PokemonMove *move)
{
memset(move, 0, sizeof(struct PokemonMove));
RestoreIntegerBits(r0, &move->moveFlags, 4);
RestoreIntegerBits(r0, &move->sealed, 1);
RestoreIntegerBits(r0, &move->moveFlags2, 1);
RestoreIntegerBits(r0, &move->moveID, 9);
RestoreIntegerBits(r0, &move->PP, 7);
RestoreIntegerBits(r0, &move->powerBoost, 7);

View File

@@ -6,6 +6,7 @@
#include "subStruct_203B240.h"
#include "constants/colors.h"
#include "constants/move_id.h"
#include "code_800D090.h"
extern struct gPokemon *gMonsterParameters;
extern const char gUnknown_8107600[];
@@ -27,7 +28,6 @@ extern u16 gLevelCurrentPokeId;
extern struct LevelData gLevelCurrentData[];
extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...);
extern s16 GetBaseSpecies(s16);
extern void sub_80922B4(u8 *, u8 *, s32);
extern int sprintf(char *, const char *, ...);
@@ -239,13 +239,13 @@ void CopySpeciesNametoBuffer(u8 * buffer, s16 index)
void CopyYellowSpeciesNametoBuffer(u8 *buffer, s16 index)
{
s32 new_index = index;
ExpandPlaceholdersBuffer(buffer, gUnknown_8107600, gMonsterParameters[new_index].species); // {COLOR_2 YELLOW}%s{END_COLOR_TEXT_2}
sprintf_2(buffer, gUnknown_8107600, gMonsterParameters[new_index].species); // {COLOR_2 YELLOW}%s{END_COLOR_TEXT_2}
}
void CopyCyanSpeciesNametoBuffer(u8 *buffer, s16 index)
{
s32 new_index = index;
ExpandPlaceholdersBuffer(buffer, gUnknown_8107608, gMonsterParameters[new_index].species); // {COLOR_2 CYAN}%s{END_COLOR_TEXT_2}
sprintf_2(buffer, gUnknown_8107608, gMonsterParameters[new_index].species); // {COLOR_2 CYAN}%s{END_COLOR_TEXT_2}
}
void sub_808D930(u8 *buffer, s16 index)
@@ -258,10 +258,10 @@ void sub_808D930(u8 *buffer, s16 index)
preload = gUnknown_8107630; // %s%c
unownString = GetMonSpecies(SPECIES_UNOWN);
unownIndex = GetUnownIndex(index);
ExpandPlaceholdersBuffer(buffer,preload,unownString,gUnownLetters[unownIndex]); // ABCDEFGHIJKLMNOPQRSTUVWXYZ!?
sprintf_2(buffer,preload,unownString,gUnownLetters[unownIndex]); // ABCDEFGHIJKLMNOPQRSTUVWXYZ!?
}
else {
ExpandPlaceholdersBuffer(buffer,gUnknown_8107638, gMonsterParameters[index].species); // %s
sprintf_2(buffer,gUnknown_8107638, gMonsterParameters[index].species); // %s
}
}
@@ -278,7 +278,7 @@ void PrintColoredPokeNameToBuffer(u8 *buffer, struct PokemonStruct *pokemon, s32
if (colorNum == COLOR_WHITE) {
colorNum = COLOR_CYAN;
}
ExpandPlaceholdersBuffer(buffer,gUnknown_810763C,colorNum,nameBuffer); // {COLOR_2}%c%s{END_COLOR_TEXT_2}
sprintf_2(buffer,gUnknown_810763C,colorNum,nameBuffer); // {COLOR_2}%c%s{END_COLOR_TEXT_2}
}
void sub_808D9DC(u8 *buffer, u8 *param_2, s32 colorNum)
@@ -289,7 +289,7 @@ void sub_808D9DC(u8 *buffer, u8 *param_2, s32 colorNum)
if (colorNum == COLOR_WHITE) {
colorNum = COLOR_YELLOW;
}
ExpandPlaceholdersBuffer(buffer,gUnknown_810763C,colorNum,nameBuffer); // {COLOR_2}%c%s{END_COLOR_TEXT_2}
sprintf_2(buffer,gUnknown_810763C,colorNum,nameBuffer); // {COLOR_2}%c%s{END_COLOR_TEXT_2}
}
void sub_808DA0C(u8 *buffer, u8 *param_2)
@@ -297,7 +297,7 @@ void sub_808DA0C(u8 *buffer, u8 *param_2)
u8 nameBuffer [20];
sub_80922B4(nameBuffer, param_2 + 0x58, POKEMON_NAME_LENGTH);
ExpandPlaceholdersBuffer(buffer,gUnknown_8107638,nameBuffer); // %s
sprintf_2(buffer,gUnknown_8107638,nameBuffer); // %s
}
void PrintPokeNameToBuffer(u8 *buffer, struct PokemonStruct *pokemon)

19
src/status.c Normal file
View File

@@ -0,0 +1,19 @@
#include "global.h"
#include "status.h"
#include "constants/ability.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
u8 GetFlashFireStatus(struct DungeonEntity *pokemon)
{
if (!EntityExists(pokemon) || !HasAbility(pokemon, ABILITY_FLASH_FIRE))
{
return FLASH_FIRE_STATUS_NONE;
}
if (pokemon->entityData->flashFireBoost > 1)
{
return FLASH_FIRE_STATUS_MAXED;
}
return FLASH_FIRE_STATUS_NOT_MAXED;
}

View File

@@ -11,6 +11,7 @@
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "map.h"
#include "moves.h"
#include "number_util.h"
#include "status_checks_1.h"
#include "tile_types.h"
@@ -130,13 +131,13 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
case MOVE_HOWL:
case MOVE_MEDITATE:
case MOVE_SHARPEN:
if (pokemonData->attackStage >= MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_BELLY_DRUM:
if (pokemonData->attackStage >= MAX_STAT_STAGE || RoundUpFixedPoint(pokemonData->belly) <= 0)
if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE || RoundUpFixedPoint(pokemonData->belly) <= 0)
{
return FALSE;
}
@@ -147,7 +148,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
case MOVE_HARDEN:
case MOVE_IRON_DEFENSE:
case MOVE_WITHDRAW:
if (pokemonData->defenseStage >= MAX_STAT_STAGE)
if (pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -182,7 +183,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_COSMIC_POWER:
if (pokemonData->defenseStage >= MAX_STAT_STAGE && pokemonData->specialDefenseStage >= MAX_STAT_STAGE)
if (pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE && pokemonData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -212,7 +213,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_MINIMIZE:
if (pokemonData->evasionStage >= MAX_STAT_STAGE)
if (pokemonData->accuracyStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -243,7 +244,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_BULK_UP:
if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemonData->defenseStage >= MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE && pokemonData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -255,7 +256,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_TAIL_GLOW:
if (pokemonData->specialAttackStage >= MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -279,7 +280,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_DRAGON_DANCE:
if (pokemonData->attackStage >= MAX_STAT_STAGE && pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED)
if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE && pokemon->entityData->movementSpeed >= MAX_MOVEMENT_SPEED)
{
return FALSE;
}
@@ -409,19 +410,19 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_DOUBLE_TEAM:
if (pokemonData->evasionStage >= MAX_STAT_STAGE)
if (pokemonData->accuracyStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_GROWTH:
if (pokemonData->specialAttackStage >= MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] >= MAX_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_SWORDS_DANCE:
if (pokemonData->attackStage >= MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -445,12 +446,12 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_CALM_MIND:
if (pokemonData->specialAttackStage < MAX_STAT_STAGE)
if (pokemonData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE)
{
break;
}
case MOVE_AMNESIA:
if (pokemonData->specialDefenseStage >= MAX_STAT_STAGE)
if (pokemonData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] >= MAX_STAT_STAGE)
{
return FALSE;
}
@@ -492,11 +493,11 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
struct DungeonEntity *target = gDungeonGlobalData->wildPokemon[i];
if (EntityExists(target) && target != pokemon && CanSee(pokemon, target))
{
if (target->entityData->attackStage >= MAX_STAT_STAGE)
if (target->entityData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE)
{
continue;
}
if (target->entityData->specialAttackStage < MAX_STAT_STAGE)
if (target->entityData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE)
{
break;
}
@@ -516,11 +517,11 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
struct DungeonEntity *target = gDungeonGlobalData->teamPokemon[i];
if (EntityExists(target) && target != pokemon && CanSee(pokemon, target))
{
if (target->entityData->attackStage >= MAX_STAT_STAGE)
if (target->entityData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE)
{
continue;
}
if (target->entityData->specialAttackStage < MAX_STAT_STAGE)
if (target->entityData->attackStages[STAT_STAGE_SPECIAL_ATTACK] < MAX_STAT_STAGE)
{
break;
}
@@ -535,3 +536,415 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
return TRUE;
}
bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move)
{
struct DungeonEntityData *userData = user->entityData;
struct DungeonEntityData *targetData = target->entityData;
s32 i;
if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_FROZEN && MoveCannotHitFrozen(move))
{
return FALSE;
}
switch (move->moveID)
{
case MOVE_GRASSWHISTLE:
case MOVE_HYPNOSIS:
case MOVE_LOVELY_KISS:
case MOVE_SING:
case MOVE_SLEEP_POWDER:
case MOVE_SPORE:
if (IsSleeping(target))
{
return FALSE;
}
break;
case MOVE_YAWN:
if (targetData->sleepStatus == SLEEP_STATUS_YAWNING)
{
return FALSE;
}
if (IsSleeping(target))
{
return FALSE;
}
break;
case MOVE_NIGHTMARE:
if (targetData->sleepStatus == SLEEP_STATUS_NIGHTMARE)
{
return FALSE;
}
break;
case MOVE_SWEET_SCENT:
if (targetData->accuracyStages[STAT_STAGE_EVASION] <= 0)
{
return FALSE;
}
break;
case MOVE_CHARM:
if (targetData->attackMultipliers[STAT_STAGE_ATTACK] < STAT_MULTIPLIER_THRESHOLD)
{
return FALSE;
}
break;
case MOVE_ENCORE:
if (targetData->volatileStatus == VOLATILE_STATUS_ENCORE)
{
return FALSE;
}
if (!HasLastUsedMove(targetData->moves))
{
return FALSE;
}
break;
case MOVE_SUPER_FANG:
if (targetData->HP <= 1)
{
return FALSE;
}
break;
case MOVE_PAIN_SPLIT:
if (targetData->HP <= userData->HP)
{
return FALSE;
}
break;
case MOVE_TORMENT:
if (HasDisabledMove(targetData->moves) || !HasLastUsedMove(targetData->moves))
{
return FALSE;
}
break;
case MOVE_COTTON_SPORE:
case MOVE_SCARY_FACE:
case MOVE_STRING_SHOT:
if (target->entityData->movementSpeed <= 0)
{
return FALSE;
}
break;
case MOVE_SCREECH:
if (targetData->defenseMultipliers[STAT_STAGE_DEFENSE] < STAT_MULTIPLIER_THRESHOLD)
{
return FALSE;
}
break;
case MOVE_FAKE_TEARS:
if (targetData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] <= 0)
{
return FALSE;
}
break;
case MOVE_SPITE:
if (LastUsedMoveOutOfPP(targetData->moves))
{
return FALSE;
}
break;
case MOVE_SMOKESCREEN:
if (targetData->moveStatus == MOVE_STATUS_WHIFFER)
{
return FALSE;
}
break;
case MOVE_MEMENTO:
if (targetData->attackMultipliers[STAT_STAGE_ATTACK] < STAT_MULTIPLIER_THRESHOLD &&
targetData->attackMultipliers[STAT_STAGE_SPECIAL_ATTACK] < STAT_MULTIPLIER_THRESHOLD)
{
return FALSE;
}
break;
case MOVE_WILL_O_WISP:
if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BURNED)
{
return FALSE;
}
break;
case MOVE_FORESIGHT:
case MOVE_ODOR_SLEUTH:
if (targetData->types[0] == TYPE_GHOST || targetData->types[1] == TYPE_GHOST)
{
if (!targetData->exposedStatus)
{
break;
}
}
if (targetData->accuracyStages[STAT_STAGE_EVASION] <= DEFAULT_STAT_STAGE)
{
return FALSE;
}
break;
case MOVE_DISABLE:
case MOVE_GLARE:
case MOVE_STUN_SPORE:
case MOVE_THUNDER_WAVE:
if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_PARALYZED)
{
return FALSE;
}
break;
case MOVE_ENDEAVOR:
if (targetData->HP - userData->HP <= 0)
{
return FALSE;
}
break;
case MOVE_LEER:
case MOVE_TAIL_WHIP:
if (targetData->defenseStages[STAT_STAGE_DEFENSE] <= 0)
{
return FALSE;
}
break;
case MOVE_METAL_SOUND:
if (targetData->defenseStages[STAT_STAGE_SPECIAL_DEFENSE] <= 0)
{
return FALSE;
}
break;
case MOVE_TICKLE:
if (targetData->attackStages[STAT_STAGE_ATTACK] <= 0 &&
targetData->defenseStages[STAT_STAGE_DEFENSE] <= 0)
{
return FALSE;
}
break;
case MOVE_BLOCK:
case MOVE_MEAN_LOOK:
case MOVE_SPIDER_WEB:
if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_IMMOBILIZED)
{
return FALSE;
}
break;
case MOVE_HAZE:
{
for (i = 0; i < 2; i++)
{
if (targetData->attackStages[i] < DEFAULT_STAT_STAGE) break;
if (targetData->defenseStages[i] < DEFAULT_STAT_STAGE) break;
if (targetData->accuracyStages[i] < DEFAULT_STAT_STAGE ||
targetData->attackMultipliers[i] < DEFAULT_STAT_MULTIPLIER ||
targetData->defenseMultipliers[i] < DEFAULT_STAT_MULTIPLIER)
{
break;
}
}
if (i == 2)
{
return FALSE;
}
break;
}
case MOVE_UPROAR:
if (targetData->sleepStatus == SLEEP_STATUS_SLEEPLESS)
{
return FALSE;
}
break;
case MOVE_PSYCH_UP:
{
for (i = 0; i < 2; i++)
{
if (userData->attackStages[i] < targetData->attackStages[i]) break;
if (userData->defenseStages[i] < targetData->defenseStages[i] ||
userData->accuracyStages[i] < targetData->accuracyStages[i] ||
userData->attackMultipliers[i] < targetData->attackMultipliers[i] ||
userData->defenseMultipliers[i] < targetData->defenseMultipliers[i])
{
break;
}
}
if (i == 2)
{
return FALSE;
}
break;
}
case MOVE_FLASH:
case MOVE_KINESIS:
case MOVE_SAND_ATTACK:
if (targetData->accuracyStages[STAT_STAGE_ACCURACY] <= 0)
{
return FALSE;
}
break;
case MOVE_TAUNT:
if (targetData->volatileStatus == VOLATILE_STATUS_TAUNTED)
{
return FALSE;
}
break;
case MOVE_TRICK:
if (!(userData->heldItem.itemFlags & ITEM_FLAG_EXISTS) ||
!(targetData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
{
return FALSE;
}
break;
case MOVE_KNOCK_OFF:
if (!(targetData->heldItem.itemFlags & ITEM_FLAG_EXISTS))
{
return FALSE;
}
break;
case MOVE_FEATHERDANCE:
case MOVE_GROWL:
if (targetData->attackStages[STAT_STAGE_ATTACK] <= 0)
{
return FALSE;
}
break;
case MOVE_ROLE_PLAY:
if (userData->abilities[0] == targetData->abilities[0] &&
userData->abilities[1] == targetData->abilities[1])
{
return FALSE;
}
break;
case MOVE_CURSE:
if (HasType(user, TYPE_GHOST))
{
if (targetData->waitingStatus == WAITING_STATUS_CURSED)
{
return FALSE;
}
}
else
{
if (userData->attackStages[STAT_STAGE_ATTACK] >= MAX_STAT_STAGE &&
userData->defenseStages[STAT_STAGE_DEFENSE] >= MAX_STAT_STAGE)
{
return FALSE;
}
}
break;
case MOVE_IMPRISON:
case MOVE_OBSERVER:
if (targetData->volatileStatus == VOLATILE_STATUS_PAUSED)
{
return FALSE;
}
break;
case MOVE_FALSE_SWIPE:
if (targetData->HP <= 1)
{
return FALSE;
}
break;
case MOVE_LEECH_SEED:
if (targetData->linkedStatus == LINKED_STATUS_LEECH_SEED)
{
return FALSE;
}
break;
case MOVE_PERISH_SONG:
if (targetData->perishSongTimer != 0)
{
return FALSE;
}
break;
case MOVE_MIMIC:
case MOVE_SKETCH:
if (!HasLastUsedMove(targetData->moves))
{
return FALSE;
}
break;
case MOVE_ATTRACT:
if (targetData->volatileStatus == VOLATILE_STATUS_INFATUATED)
{
return FALSE;
}
break;
case MOVE_WRAP:
if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_WRAPPED_AROUND_FOE)
{
return FALSE;
}
if (targetData->immobilizeStatus == IMMOBILIZE_STATUS_WRAPPED_BY_FOE)
{
return FALSE;
}
break;
case MOVE_TOXIC:
if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BADLY_POISONED)
{
return FALSE;
}
break;
case MOVE_POISON_GAS:
case MOVE_POISONPOWDER:
if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_POISONED)
{
return FALSE;
}
if (targetData->nonVolatileStatus == NON_VOLATILE_STATUS_BADLY_POISONED)
{
return FALSE;
}
break;
case MOVE_CONFUSE_RAY:
case MOVE_FLATTER:
case MOVE_SUPERSONIC:
case MOVE_SWAGGER:
case MOVE_SWEET_KISS:
case MOVE_TEETER_DANCE:
case MOVE_TOTTER:
if (targetData->volatileStatus == VOLATILE_STATUS_CONFUSED)
{
return FALSE;
}
break;
}
return TRUE;
}
bool8 HasDisabledMove(struct PokemonMove *moves)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].moveFlags & MOVE_FLAG_DISABLED)
{
return TRUE;
}
}
if (moves[STRUGGLE_MOVE_INDEX].moveFlags & MOVE_FLAG_DISABLED)
{
return TRUE;
}
return FALSE;
}
bool8 LastUsedMoveOutOfPP(struct PokemonMove *moves)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i].moveFlags & MOVE_FLAG_EXISTS &&
moves[i].moveFlags & MOVE_FLAG_LAST_USED &&
moves[i].PP == 0)
{
return TRUE;
}
}
return FALSE;
}
bool8 HasLastUsedMove(struct PokemonMove *moves)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].moveFlags & MOVE_FLAG_LAST_USED)
{
return TRUE;
}
}
if (moves[STRUGGLE_MOVE_INDEX].moveFlags & MOVE_FLAG_LAST_USED)
{
return TRUE;
}
return FALSE;
}

View File

@@ -28,7 +28,7 @@ bool8 HasNegativeStatus(struct DungeonEntity *pokemon)
for (i = 0; i < MAX_MON_MOVES; i++)
{
struct PokemonMove *moves = pokemonData->moves;
if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE)
if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].moveFlags2 & MOVE_FLAG_SEALED)
{
return TRUE;
}

View File

@@ -10,6 +10,7 @@
#include "input.h"
#include "text.h"
#include "team_inventory.h"
#include "code_800D090.h"
extern struct WonderMailStruct_203B2C4 *gUnknown_203B2C4;
@@ -217,7 +218,6 @@ extern void sub_802F2C0();
extern u32 sub_80144A4(s32 *r0);
extern void SetThankYouMailMenuState(u32);
extern struct PokemonStruct *GetPlayerPokemonStruct(void);
extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *text, ...);
extern void SetMenuItems(void *menu, struct UnkTextStruct2 *, u32, const struct UnkTextStruct2 *, const struct MenuItem *entries, u32, u32, u32);
extern void sub_80922B4(u8 *, u8 *, u32);
extern void sub_802F204(struct unkStruct_802F204 *, u32);
@@ -1286,7 +1286,7 @@ void UpdateThankYouMailText(void)
case 5:
pokeStruct = GetPlayerPokemonStruct();
sub_80922B4(auStack180,pokeStruct->name, POKEMON_NAME_LENGTH);
ExpandPlaceholdersBuffer(gUnknown_203B2C4->formattedString,gUnknown_80DF250,auStack180);
sprintf_2(gUnknown_203B2C4->formattedString,gUnknown_80DF250,auStack180);
sub_80141B4(gUnknown_203B2C4->formattedString,0,&gUnknown_203B2C4->faceFile,0x10d);
break;
case 0xe:
@@ -1445,7 +1445,7 @@ void UpdateThankYouMailText(void)
case THANK_YOU_MAIL_COMMS_CLEANUP:
pokeStruct2 = GetPlayerPokemonStruct();
sub_80922B4(auStack100, pokeStruct2->name, POKEMON_NAME_LENGTH);
ExpandPlaceholdersBuffer(gUnknown_203B2C4->formattedString,gUnknown_80DF63C,auStack100);
sprintf_2(gUnknown_203B2C4->formattedString,gUnknown_80DF63C,auStack100);
sub_80141B4(gUnknown_203B2C4->formattedString,0,&gUnknown_203B2C4->faceFile,0x10d);
break;
case CONFIRM_ITEM_TO_SEND:

27
src/type_chart.c Normal file
View File

@@ -0,0 +1,27 @@
#include "type_chart.h"
#define IMMUNE EFFECTIVENESS_IMMUNE
#define RESIST EFFECTIVENESS_RESIST
#define NEUTRAL EFFECTIVENESS_NEUTRAL
#define SUPER EFFECTIVENESS_SUPER
const s16 gTypeEffectivenessChart[NUM_TYPES][NUM_TYPES] = {
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, RESIST},
{NEUTRAL, NEUTRAL, RESIST, RESIST, SUPER, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, RESIST, NEUTRAL, RESIST, NEUTRAL, SUPER},
{NEUTRAL, NEUTRAL, SUPER, RESIST, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, NEUTRAL, NEUTRAL},
{NEUTRAL, NEUTRAL, RESIST, SUPER, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, SUPER, RESIST, NEUTRAL, RESIST, SUPER, NEUTRAL, RESIST, NEUTRAL, RESIST},
{NEUTRAL, NEUTRAL, NEUTRAL, SUPER, RESIST, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, IMMUNE, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, NEUTRAL},
{NEUTRAL, NEUTRAL, RESIST, RESIST, SUPER, NEUTRAL, RESIST, NEUTRAL, NEUTRAL, SUPER, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST},
{NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, NEUTRAL, RESIST, RESIST, RESIST, SUPER, NEUTRAL, NEUTRAL, SUPER, SUPER},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, RESIST, NEUTRAL, NEUTRAL, IMMUNE},
{NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, SUPER, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, IMMUNE, NEUTRAL, RESIST, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, SUPER},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, RESIST, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, RESIST},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, SUPER, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, IMMUNE, RESIST},
{NEUTRAL, NEUTRAL, RESIST, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, RESIST, RESIST, NEUTRAL, RESIST, SUPER, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, SUPER, RESIST},
{NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, RESIST, NEUTRAL, RESIST, SUPER, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, RESIST},
{NEUTRAL, IMMUNE, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, RESIST},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST},
{NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, RESIST, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, RESIST, RESIST},
{NEUTRAL, NEUTRAL, RESIST, RESIST, NEUTRAL, RESIST, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, NEUTRAL, SUPER, NEUTRAL, NEUTRAL, NEUTRAL, RESIST}
};

174
src/type_effectiveness.c Normal file
View File

@@ -0,0 +1,174 @@
#include "global.h"
#include "type_effectiveness.h"
#include "constants/ability.h"
#include "constants/status.h"
#include "constants/weather.h"
#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "status.h"
#include "type_chart.h"
#include "weather.h"
u32 gTypeEffectivenessMultipliers[] = {0, 1, 2, 4};
s32 WeightWeakTypePicker(struct DungeonEntity *user, struct DungeonEntity *target, u8 moveType)
{
s32 weight = 1;
bool8 checkExposed = FALSE;
struct DungeonEntityData *userData;
struct DungeonEntityData *targetData;
u8 *targetTypes;
u8 *targetType;
u32 moveTypeOffset;
if (!EntityExists(target))
{
return 1;
}
if (moveType == TYPE_NORMAL || moveType == TYPE_FIGHTING)
{
checkExposed = TRUE;
}
userData = user->entityData;
targetData = target->entityData;
if (moveType == TYPE_FIRE && GetFlashFireStatus(target) != FLASH_FIRE_STATUS_NONE)
{
return 0;
}
if (moveType == TYPE_ELECTRIC && HasAbility(target, ABILITY_VOLT_ABSORB))
{
return 0;
}
if (moveType == TYPE_WATER && HasAbility(target, ABILITY_WATER_ABSORB))
{
return 0;
}
if (moveType == TYPE_GROUND && HasAbility(target, ABILITY_LEVITATE))
{
return 1;
}
targetTypes = targetData->types;
moveTypeOffset = moveType * NUM_TYPES * sizeof(s16);
targetType = targetData->types;
do
{
s32 effectiveness;
u32 typeEffectivenessMultipliers[NUM_EFFECTIVENESS];
memcpy(typeEffectivenessMultipliers, gTypeEffectivenessMultipliers, NUM_EFFECTIVENESS * sizeof(u32));
if (checkExposed && *targetType == TYPE_GHOST && !targetData->exposedStatus)
{
effectiveness = 0;
gDungeonGlobalData->pokemonExposed = TRUE;
}
else
{
effectiveness = gTypeEffectivenessChart[moveType][*targetType];
// Used to swap variable initialization order at the loop start.
effectiveness = *(s16*)(((s8*) gTypeEffectivenessChart) + moveTypeOffset + *targetType * 2);
}
if (weight == 0)
{
goto breakLoop;
}
weight *= typeEffectivenessMultipliers[effectiveness];
weight /= 2;
if (weight == 0)
{
// BUG: If the Pokémon's first type resists the move, the second type is ignored.
// This calculates type effectiveness incorrectly if the first type resists the move and the second type is weak to the move.
// For example, a Fire-type move is considered not very effective against a Rock/Bug-type like Anorith.
return 2;
}
} while ((s32)(++targetType) <= (s32)(targetTypes + 1));
breakLoop:
if ((moveType == TYPE_FIRE || moveType == TYPE_ICE) && HasAbility(target, ABILITY_THICK_FAT))
{
return 2;
}
if (moveType == TYPE_WATER && HasAbility(user, ABILITY_TORRENT))
{
s32 maxHP = userData->maxHP;
if (maxHP < 0)
{
maxHP += 3;
}
if (maxHP >> 2 >= userData->HP)
{
weight *= 2;
}
}
if (moveType == TYPE_GRASS && HasAbility(user, ABILITY_OVERGROW))
{
s32 maxHP = userData->maxHP;
if (maxHP < 0)
{
maxHP += 3;
}
if (maxHP >> 2 >= userData->HP)
{
weight *= 2;
}
}
if (moveType == TYPE_BUG && HasAbility(user, ABILITY_SWARM))
{
s32 maxHP = userData->maxHP;
if (maxHP < 0)
{
maxHP += 3;
}
if (maxHP >> 2 >= userData->HP)
{
weight *= 2;
}
}
if (moveType == TYPE_FIRE && HasAbility(user, ABILITY_BLAZE))
{
s32 maxHP = userData->maxHP;
if (maxHP < 0)
{
maxHP += 3;
}
if (maxHP >> 2 >= userData->HP)
{
weight *= 2;
}
}
if (weight == 0)
{
return 2;
}
if (HasType(user, moveType))
{
weight *= 2;
}
targetTypes = targetData->types;
if (GetWeather(user) == WEATHER_SUNNY)
{
if (moveType == TYPE_FIRE)
{
weight *= 2;
}
else if (moveType == TYPE_WATER)
{
return 2;
}
}
if (gDungeonGlobalData->mudSportTurnsLeft != 0 && moveType == TYPE_ELECTRIC)
{
return 2;
}
if (gDungeonGlobalData->waterSportTurnsLeft != 0 && moveType == TYPE_FIRE)
{
return 2;
}
if (moveType == TYPE_ELECTRIC && userData->chargingStatus == CHARGING_STATUS_CHARGE)
{
weight *= 2;
}
if (weight > 2)
{
weight = 3;
}
return weight + 2;
}

Some files were not shown because too many files have changed in this diff Show More