Merge pull request #166 from camthesaxman/battle_refactor

rename/refactor battle code
This commit is contained in:
Cameron Hall 2018-02-07 12:46:12 -06:00 committed by GitHub
commit 13bc7a8dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 10163 additions and 10132 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ sub_80A9C70: @ 80A9C70
lsrs r4, 24
lsls r5, 24
lsrs r5, 24
ldr r0, =gBankSpriteIds
ldr r0, =gBattlerSpriteIds
adds r0, r4, r0
ldrb r6, [r0]
ldr r0, =sub_80A9DB4
@ -331,10 +331,10 @@ sub_80A9EF4: @ 80A9EF4
push {r4-r6,lr}
lsls r0, 24
lsrs r6, r0, 24
ldr r4, =gAnimBankTarget
ldr r4, =gBattleAnimTarget
ldrb r0, [r4]
movs r1, 0x2
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 8
ldr r1, =0xffe00000
@ -342,7 +342,7 @@ sub_80A9EF4: @ 80A9EF4
lsrs r5, r0, 16
ldrb r0, [r4]
movs r1, 0x3
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 8
ldr r1, =0xffdc0000
@ -863,9 +863,9 @@ LaunchStatusAnimation: @ 80AA364
lsrs r4, 24
lsls r1, 24
lsrs r1, 24
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
strb r4, [r0]
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
strb r4, [r0]
ldr r0, =gBattleAnims_Statuses
movs r2, 0

View File

@ -12,7 +12,7 @@ sub_80D51AC: @ 80D51AC
lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs
ldrb r0, [r4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0xFF
@ -165,7 +165,7 @@ sub_80D52D0: @ 80D52D0
bgt _080D52FC
lsls r0, 24
lsrs r0, 24
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0xFF
@ -200,23 +200,23 @@ _080D5320:
_080D5324:
movs r0, 0x3
_080D5326:
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r4, r0, 24
adds r0, r4, 0
bl IsAnimBankSpriteVisible
bl IsBattlerSpriteVisible
lsls r0, 24
cmp r0, 0
bne _080D533C
movs r6, 0x1
_080D533C:
ldr r0, =gBankSpriteIds
ldr r0, =gBattlerSpriteIds
adds r0, r4, r0
b _080D5350
.pool
_080D5348:
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
adds r0, r1
_080D5350:
@ -379,7 +379,7 @@ sub_80D5484: @ 80D5484
lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs
ldrb r0, [r4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0xFF
@ -603,7 +603,7 @@ sub_80D5644: @ 80D5644
lsrs r4, 24
ldr r5, =gBattleAnimArgs
ldrb r0, [r5]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
ldr r2, =gSprites
@ -723,7 +723,7 @@ sub_80D5738: @ 80D5738
movs r6, 0x1
ldr r4, =gBattleAnimArgs
ldrb r0, [r4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r7, r0, 24
movs r1, 0x8
@ -842,9 +842,9 @@ sub_80D5830: @ 80D5830
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D584C
@ -871,9 +871,9 @@ sub_80D5860: @ 80D5860
movs r1, 0x4
orrs r0, r1
strb r0, [r2]
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5890
@ -891,8 +891,8 @@ _080D5894:
movs r0, 0
strh r2, [r4, 0x2E]
strh r0, [r4, 0x32]
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
adds r0, r1
ldrb r0, [r0]
@ -938,7 +938,7 @@ sub_80D58F8: @ 80D58F8
strb r0, [r2]
ldr r5, =gBattleAnimArgs
ldrb r0, [r5, 0x4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
ldrh r2, [r5]
@ -987,13 +987,13 @@ sub_80D5968: @ 80D5968
ldrsh r0, [r0, r1]
cmp r0, 0
bne _080D598C
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
b _080D5990
.pool
_080D598C:
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankTarget
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimTarget
_080D5990:
ldrb r0, [r0]
adds r0, r1
@ -1133,18 +1133,18 @@ sub_80D5A94: @ 80D5A94
ldrsh r0, [r0, r1]
cmp r0, 0
bne _080D5AB0
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _080D5AB2
.pool
_080D5AB0:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_080D5AB2:
ldrb r2, [r0]
ldr r0, =gBankSpriteIds
ldr r0, =gBattlerSpriteIds
adds r0, r2, r0
ldrb r6, [r0]
adds r0, r2, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5ADC
@ -1218,18 +1218,18 @@ sub_80D5B48: @ 80D5B48
ldrsh r0, [r0, r1]
cmp r0, 0
bne _080D5B70
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _080D5B72
.pool
_080D5B70:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_080D5B72:
ldrb r1, [r0]
ldr r0, =gBankSpriteIds
ldr r0, =gBattlerSpriteIds
adds r0, r1, r0
ldrb r7, [r0]
adds r0, r1, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5B9C
@ -1338,9 +1338,9 @@ sub_80D5C50: @ 80D5C50
bl __divsi3
lsls r0, 16
lsrs r7, r0, 16
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5C82
@ -1352,7 +1352,7 @@ sub_80D5C50: @ 80D5C50
strh r0, [r5, 0xA]
_080D5C82:
ldrb r0, [r5]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
ldr r1, =gTasks
lsls r4, r6, 2
adds r4, r6
@ -1508,7 +1508,7 @@ sub_80D5DB0: @ 80D5DB0
cmp r0, 0
blt _080D5E10
ldrb r0, [r1]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r2, r0, 24
b _080D5E18
@ -1518,20 +1518,20 @@ _080D5DD8:
beq _080D5DE8
b _080D5E10
_080D5DDE:
ldr r5, =gAnimBankAttacker
ldr r5, =gBattleAnimAttacker
b _080D5DEA
.pool
_080D5DE8:
ldr r5, =gAnimBankTarget
ldr r5, =gBattleAnimTarget
_080D5DEA:
ldrb r0, [r5]
movs r4, 0x2
eors r0, r4
bl IsAnimBankSpriteVisible
bl IsBattlerSpriteVisible
lsls r0, 24
cmp r0, 0
beq _080D5E10
ldr r1, =gBankSpriteIds
ldr r1, =gBattlerSpriteIds
ldrb r0, [r5]
eors r0, r4
adds r0, r1
@ -1549,9 +1549,9 @@ _080D5E18:
lsls r0, 3
adds r5, r0, r1
strh r2, [r5, 0x8]
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5E44
@ -1622,9 +1622,9 @@ sub_80D5EB8: @ 80D5EB8
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
ldr r6, =gAnimBankAttacker
ldr r6, =gBattleAnimAttacker
ldrb r0, [r6]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D5ED4
@ -1635,7 +1635,7 @@ sub_80D5EB8: @ 80D5EB8
_080D5ED4:
ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x8]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
@ -1660,7 +1660,7 @@ _080D5ED4:
b _080D5F18
.pool
_080D5F14:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r0, [r0]
_080D5F18:
strh r0, [r2, 0x12]
@ -1722,7 +1722,7 @@ sub_80D5F3C: @ 80D5F3C
.pool
_080D5F94:
ldrb r0, [r4, 0x12]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _080D5FBC
@ -1836,7 +1836,7 @@ sub_80D6064: @ 80D6064
lsrs r4, 24
ldr r6, =gBattleAnimArgs
ldrb r0, [r6, 0x6]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
adds r5, r0, 0
lsls r5, 24
lsrs r5, 24
@ -1939,7 +1939,7 @@ sub_80D6134: @ 80D6134
lsrs r7, r0, 24
ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
mov r8, r0
@ -1995,14 +1995,14 @@ _080D61B8:
ldrsh r0, [r6, r1]
cmp r0, 0
bne _080D61C8
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _080D61CA
.pool
_080D61C8:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_080D61CA:
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
movs r1, 0
lsls r0, 24
cmp r0, 0
@ -2057,7 +2057,7 @@ sub_80D622C: @ 80D622C
lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x4]
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
mov r8, r0
@ -2076,14 +2076,14 @@ sub_80D622C: @ 80D622C
ldrsh r0, [r4, r1]
cmp r0, 0
bne _080D6274
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _080D6276
.pool
_080D6274:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_080D6276:
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080D6288
@ -2290,7 +2290,7 @@ _080D63EE:
ldrh r0, [r1, 0x8]
strh r0, [r4, 0x1E]
movs r0, 0x1
bl GetAnimBankSpriteId
bl GetAnimBattlerSpriteId
lsls r0, 24
lsrs r0, 24
strh r0, [r4, 0x16]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ sub_8170478: @ 8170478
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x10]
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r4, [r0]
ldr r0, =gBattle_WIN0H
movs r1, 0
@ -56,7 +56,7 @@ sub_8170478: @ 8170478
movs r1, 0x3
movs r2, 0x1
bl SetAnimBgAttribute
ldr r0, =gHealthBoxesIds
ldr r0, =gHealthboxSpriteIds
adds r4, r0
ldrb r0, [r4]
ldr r1, =gSprites
@ -212,7 +212,7 @@ sub_8170660: @ 8170660
push {r7}
lsls r0, 24
lsrs r7, r0, 24
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
mov r8, r0
ldr r1, =gTasks
@ -373,7 +373,7 @@ _0817076C:
movs r1, 0x1
movs r2, 0
bl SetAnimBgAttribute
ldr r0, =gHealthBoxesIds
ldr r0, =gHealthboxSpriteIds
add r0, r8
ldrb r0, [r0]
lsls r1, r0, 4
@ -434,7 +434,7 @@ sub_8170834: @ 8170834
adds r7, r1, 0
lsls r2, 24
lsrs r2, 24
ldr r0, =gHealthBoxesIds
ldr r0, =gHealthboxSpriteIds
adds r2, r0
ldrb r0, [r2]
lsls r5, r0, 4
@ -540,7 +540,7 @@ sub_8170920: @ 8170920
lsrs r4, 24
mov r1, sp
adds r1, 0x1
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r2, [r0]
mov r0, sp
bl sub_8170834
@ -561,7 +561,7 @@ sub_817094C: @ 817094C
push {r5,r6}
lsls r0, 24
lsrs r0, 24
ldr r1, =gHealthBoxesIds
ldr r1, =gHealthboxSpriteIds
adds r0, r1
ldrb r0, [r0]
ldr r1, =gSprites
@ -628,7 +628,7 @@ sub_81709EC: @ 81709EC
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl sub_817094C
adds r0, r4, 0
@ -765,8 +765,8 @@ sub_8170B04: @ 8170B04
push {r4-r6,lr}
lsls r0, 24
lsrs r6, r0, 24
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
adds r0, r1
ldrb r5, [r0]
@ -851,17 +851,17 @@ sub_8170BB0: @ 8170BB0
sub sp, 0xC
lsls r0, 24
lsrs r5, r0, 24
ldr r1, =gBankSpriteIds
ldr r4, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r4, =gBattleAnimAttacker
ldrb r0, [r4]
adds r1, r0, r1
ldrb r1, [r1]
mov r9, r1
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _08170BF8
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
ldrb r0, [r4]
lsls r0, 1
adds r0, r1
@ -872,7 +872,7 @@ sub_8170BB0: @ 8170BB0
b _08170C08
.pool
_08170BF8:
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
ldrb r0, [r4]
lsls r0, 1
adds r0, r1
@ -904,16 +904,16 @@ _08170C08:
b _08170CEE
.pool
_08170C44:
ldr r5, =gAnimBankAttacker
ldr r5, =gBattleAnimAttacker
ldrb r0, [r5]
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldrb r0, [r5]
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
adds r1, r0, 0
lsls r1, 24
ldr r2, =gSprites
@ -1162,18 +1162,18 @@ sub_8170E04: @ 8170E04
adds r6, r4, r1
movs r0, 0x22
strh r0, [r6, 0x2E]
ldr r2, =gAnimBankTarget
ldr r2, =gBattleAnimTarget
mov r8, r2
ldrb r0, [r2]
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
strh r0, [r6, 0x30]
mov r1, r8
ldrb r0, [r1]
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
subs r0, 0x10
@ -1186,7 +1186,7 @@ sub_8170E04: @ 8170E04
ldr r0, =gBattleSpritesDataPtr
ldr r0, [r0]
ldr r3, [r0, 0x8]
ldr r1, =gBankSpriteIds
ldr r1, =gBattlerSpriteIds
mov r2, r8
ldrb r0, [r2]
adds r0, r1
@ -1283,7 +1283,7 @@ _08170F54:
lsls r4, 24
lsrs r4, 24
movs r0, 0x1
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r0, 24
bl sub_80A82E4
@ -1313,18 +1313,18 @@ _08170F54:
adds r6, r4, r0
movs r0, 0x22
strh r0, [r6, 0x2E]
ldr r1, =gAnimBankTarget
ldr r1, =gBattleAnimTarget
mov r8, r1
ldrb r0, [r1]
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
strh r0, [r6, 0x30]
mov r1, r8
ldrb r0, [r1]
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
subs r0, 0x10
@ -1335,8 +1335,8 @@ _08170F54:
ldr r0, =SpriteCallbackDummy
str r0, [r4]
movs r0, 0
bl GetBankByIdentity
ldr r1, =gBankSpriteIds
bl GetBattlerAtPosition
ldr r1, =gBattlerSpriteIds
lsls r0, 24
lsrs r0, 24
adds r0, r1
@ -1371,8 +1371,8 @@ sub_8171030: @ 8171030
lsrs r5, r0, 24
ldr r6, =gSprites
movs r0, 0
bl GetBankByIdentity
ldr r1, =gBankSpriteIds
bl GetBattlerAtPosition
ldr r1, =gBattlerSpriteIds
lsls r0, 24
lsrs r0, 24
adds r0, r1
@ -1422,8 +1422,8 @@ sub_81710A8: @ 81710A8
lsrs r5, r0, 24
ldr r6, =gSprites
movs r0, 0
bl GetBankByIdentity
ldr r4, =gBankSpriteIds
bl GetBattlerAtPosition
ldr r4, =gBattlerSpriteIds
lsls r0, 24
lsrs r0, 24
adds r0, r4
@ -1438,7 +1438,7 @@ sub_81710A8: @ 81710A8
cmp r0, 0
bge _081710F4
movs r0, 0
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r0, 24
adds r0, r4
@ -1550,7 +1550,7 @@ _08171188:
movs r2, 0x1
movs r3, 0x1C
bl LaunchBallStarsTask
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r1, [r0]
movs r0, 0
movs r2, 0xE
@ -1584,8 +1584,8 @@ sub_81711E8: @ 81711E8
ldr r0, =sub_8171240
str r0, [r4, 0x1C]
ldr r2, =gSprites
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankTarget
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimTarget
ldrb r0, [r0]
adds r0, r1
ldrb r1, [r0]
@ -1606,8 +1606,8 @@ _08171224:
sub_8171240: @ 8171240
push {r4-r7,lr}
adds r7, r0, 0
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankTarget
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimTarget
ldrb r0, [r0]
adds r0, r1
ldrb r4, [r0]
@ -2333,7 +2333,7 @@ sub_81717F8: @ 81717F8
push {r7}
sub sp, 0x4
adds r6, r0, 0
ldr r7, =gAnimBankTarget
ldr r7, =gBattleAnimTarget
ldrh r0, [r6, 0x36]
adds r0, 0x1
movs r1, 0
@ -2390,7 +2390,7 @@ _08171880:
cmp r1, r0
bne _081718BC
ldr r5, =gSprites
ldr r4, =gBankSpriteIds
ldr r4, =gBattlerSpriteIds
ldrb r0, [r7]
adds r0, r4
ldrb r1, [r0]
@ -2715,7 +2715,7 @@ sub_8171AE4: @ 8171AE4
movs r2, 0x1
movs r3, 0x1C
bl LaunchBallStarsTask
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r1, [r0]
movs r0, 0x1
movs r2, 0xE
@ -2723,8 +2723,8 @@ sub_8171AE4: @ 8171AE4
bl LaunchBallFadeMonTask
_08171B36:
ldr r6, =gSprites
ldr r5, =gBankSpriteIds
ldr r4, =gAnimBankTarget
ldr r5, =gBattlerSpriteIds
ldr r4, =gBattleAnimTarget
ldrb r0, [r4]
adds r0, r5
ldrb r1, [r0]
@ -2791,8 +2791,8 @@ sub_8171BAC: @ 8171BAC
strb r0, [r2]
_08171BCA:
ldr r4, =gSprites
ldr r3, =gBankSpriteIds
ldr r2, =gAnimBankTarget
ldr r3, =gBattlerSpriteIds
ldr r2, =gBattleAnimTarget
ldrb r0, [r2]
adds r0, r3
ldrb r1, [r0]
@ -2840,8 +2840,8 @@ _08171C24:
cmp r5, 0
beq _08171C8A
ldr r4, =gSprites
ldr r3, =gBankSpriteIds
ldr r2, =gAnimBankTarget
ldr r3, =gBattlerSpriteIds
ldr r2, =gBattleAnimTarget
ldrb r0, [r2]
adds r0, r3
ldrb r1, [r0]
@ -4729,8 +4729,8 @@ sub_8172BF0: @ 8172BF0
lsrs r7, r0, 24
movs r0, 0
mov r8, r0
ldr r0, =gBankSpriteIds
ldr r3, =gAnimBankAttacker
ldr r0, =gBattlerSpriteIds
ldr r3, =gBattleAnimAttacker
ldrb r2, [r3]
adds r0, r2, r0
ldrb r6, [r0]
@ -4764,7 +4764,7 @@ _08172C36:
adds r0, r4
strh r0, [r5, 0x8]
ldrb r0, [r3]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _08172C78
@ -4838,7 +4838,7 @@ _08172CDA:
adds r0, r2
strh r0, [r5, 0x8]
ldrb r0, [r3]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _08172D10
@ -4877,9 +4877,9 @@ _08172D28:
adds r0, r1
ldrb r1, [r0, 0x8]
strh r1, [r0, 0x8]
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
@ -4949,7 +4949,7 @@ _08172DC0:
beq _08172E4E
b _08172E84
_08172DC6:
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
bl sub_80A8364
lsls r0, 24
@ -5009,8 +5009,8 @@ _08172E14:
strh r0, [r4, 0x26]
b _08172E84
_08172E4E:
ldr r1, =gBankSpriteIds
ldr r4, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r4, =gBattleAnimAttacker
ldrb r0, [r4]
adds r0, r1
ldrb r1, [r0]
@ -5048,7 +5048,7 @@ sub_8172E9C: @ 8172E9C
ldr r3, =gBattleAnimArgs
ldr r1, =gBattleSpritesDataPtr
ldr r2, [r1]
ldr r1, =gAnimBankAttacker
ldr r1, =gBattleAnimAttacker
ldrb r1, [r1]
ldr r2, [r2]
lsls r1, 2
@ -5068,7 +5068,7 @@ sub_8172ED0: @ 8172ED0
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r2, =gAnimBankTarget
ldr r2, =gBattleAnimTarget
ldr r1, =gEffectBank
ldrb r1, [r1]
strb r1, [r2]
@ -5108,7 +5108,7 @@ sub_8172EF0: @ 8172EF0
bl GetMonData
adds r4, r0, 0
adds r0, r6, 0
bl IsAnimBankSpriteVisible
bl IsBattlerSpriteVisible
lsls r0, 24
cmp r0, 0
beq _08172FC8
@ -5234,12 +5234,12 @@ _0817303A:
ldrb r0, [r4, 0x8]
mov r8, r0
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r5, r0, 24
mov r0, r8
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r2, r0, 24
movs r1, 0x1E
@ -5347,7 +5347,7 @@ _08173118:
cmp r0, 0
bne _08173160
mov r0, r8
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
movs r1, 0x3F
cmp r0, 0
@ -5575,11 +5575,11 @@ sub_817330C: @ 817330C
movs r0, 0x1E
strh r0, [r4, 0x2E]
movs r0, 0x1
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r0, 24
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
ldr r5, =gBattleAnimArgs
lsrs r0, 24
@ -5587,11 +5587,11 @@ sub_817330C: @ 817330C
adds r0, r1
strh r0, [r4, 0x32]
movs r0, 0x1
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r0, 24
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
ldrh r5, [r5, 0x6]
@ -5602,8 +5602,8 @@ sub_817330C: @ 817330C
adds r0, r4, 0
bl sub_80A68D4
ldr r2, =gSprites
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
adds r0, r1
ldrb r1, [r0]
@ -5627,8 +5627,8 @@ sub_817339C: @ 817339C
push {lr}
adds r3, r0, 0
ldr r2, =gSprites
ldr r1, =gBankSpriteIds
ldr r0, =gAnimBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
adds r0, r1
ldrb r1, [r0]
@ -5678,8 +5678,8 @@ sub_8173400: @ 8173400
push {r4,r5,lr}
adds r4, r0, 0
ldr r5, =gSprites
ldr r3, =gBankSpriteIds
ldr r2, =gAnimBankAttacker
ldr r3, =gBattlerSpriteIds
ldr r2, =gBattleAnimAttacker
ldrb r0, [r2]
adds r0, r3
ldrb r1, [r0]
@ -5732,21 +5732,21 @@ sub_817345C: @ 817345C
.pool
_08173478:
movs r0, 0
bl GetBankByIdentity
ldr r1, =gAnimBankAttacker
bl GetBattlerAtPosition
ldr r1, =gBattleAnimAttacker
strb r0, [r1]
movs r0, 0x1
b _08173498
.pool
_0817348C:
movs r0, 0x1
bl GetBankByIdentity
ldr r1, =gAnimBankAttacker
bl GetBattlerAtPosition
ldr r1, =gBattleAnimAttacker
strb r0, [r1]
movs r0, 0
_08173498:
bl GetBankByIdentity
ldr r1, =gAnimBankTarget
bl GetBattlerAtPosition
ldr r1, =gBattleAnimTarget
strb r0, [r1]
_081734A0:
adds r0, r4, 0
@ -5812,13 +5812,13 @@ sub_817351C: @ 817351C
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r3, =gAnimBankAttacker
ldr r3, =gBattleAnimAttacker
ldr r1, =gBattleSpritesDataPtr
ldr r2, [r1]
ldr r1, [r2, 0x8]
ldrh r1, [r1]
strb r1, [r3]
ldr r3, =gAnimBankTarget
ldr r3, =gBattleAnimTarget
ldr r1, [r2, 0x8]
ldrh r1, [r1]
lsrs r1, 8

View File

@ -336,25 +336,25 @@ _08158DD0:
adds r2, r0, 0
cmp r1, 0
bne _08158DEC
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r4, [r0]
b _08158E12
.pool
_08158DEC:
cmp r1, 0x1
bne _08158DFC
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r4, [r0]
b _08158E12
.pool
_08158DFC:
cmp r1, 0x2
bne _08158E08
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _08158E0A
.pool
_08158E08:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_08158E0A:
ldrb r1, [r0]
movs r0, 0x2
@ -369,7 +369,7 @@ _08158E12:
bne _08158E38
_08158E1E:
adds r0, r4, 0
bl IsAnimBankSpriteVisible
bl IsBattlerSpriteVisible
lsls r0, 24
cmp r0, 0
bne _08158E38
@ -379,11 +379,11 @@ _08158E1E:
.pool
_08158E38:
adds r0, r4, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _08158E5C
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r1
ldrh r1, [r0]
@ -393,7 +393,7 @@ _08158E38:
b _08158E6A
.pool
_08158E5C:
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r1
ldrh r1, [r0]
@ -461,25 +461,25 @@ _08158EE0:
adds r2, r0, 0
cmp r1, 0
bne _08158EFC
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r4, [r0]
b _08158F22
.pool
_08158EFC:
cmp r1, 0x1
bne _08158F0C
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
ldrb r4, [r0]
b _08158F22
.pool
_08158F0C:
cmp r1, 0x2
bne _08158F18
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
b _08158F1A
.pool
_08158F18:
ldr r0, =gAnimBankTarget
ldr r0, =gBattleAnimTarget
_08158F1A:
ldrb r1, [r0]
movs r0, 0x2
@ -494,7 +494,7 @@ _08158F22:
bne _08158F48
_08158F2E:
adds r0, r4, 0
bl IsAnimBankSpriteVisible
bl IsBattlerSpriteVisible
lsls r0, 24
cmp r0, 0
bne _08158F48
@ -504,11 +504,11 @@ _08158F2E:
.pool
_08158F48:
adds r0, r4, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _08158F6C
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r1
ldrh r1, [r0]
@ -518,7 +518,7 @@ _08158F48:
b _08158F7A
.pool
_08158F6C:
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r1
ldrh r1, [r0]
@ -705,7 +705,7 @@ sub_81590B8: @ 81590B8
.pool
_081590F8:
ldr r1, =gAnimSpeciesByBanks
ldr r0, =gAnimBankAttacker
ldr r0, =gBattleAnimAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1

View File

@ -21034,7 +21034,7 @@ sub_81A5718: @ 81A5718
b _081A57D8
.pool
_081A576C:
ldr r0, =gBattleMoveFlags
ldr r0, =gMoveResultFlags
ldrb r1, [r0]
movs r0, 0x29
ands r0, r1

View File

@ -34,32 +34,32 @@ _0817C988:
movs r1, 0x81
lsls r1, 2
adds r7, r0, r1
ldr r5, =gBankAttacker
ldr r5, =gBattlerAttacker
ldrb r0, [r5]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r6, r0, 24
ldr r0, =gEffectBank
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
mov r9, r0
ldr r0, =gStringInfo
ldr r0, [r0]
ldrb r0, [r0, 0x7]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x4]
cmp r4, 0
bne _0817CA00
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
ldrb r0, [r5]
lsls r0, 1
adds r0, r2
@ -70,7 +70,7 @@ _0817C988:
b _0817CA10
.pool
_0817CA00:
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
ldrb r0, [r5]
lsls r0, 1
adds r0, r2
@ -83,7 +83,7 @@ _0817CA10:
str r1, [sp, 0x8]
cmp r6, 0
bne _0817CA3C
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
lsls r0, 1
adds r0, r2
@ -94,7 +94,7 @@ _0817CA10:
b _0817CA4C
.pool
_0817CA3C:
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
lsls r0, 1
adds r0, r2
@ -105,12 +105,12 @@ _0817CA3C:
_0817CA4C:
adds r1, r0
str r1, [sp, 0xC]
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
ldr r1, =gStringInfo
ldr r1, [r1]
ldrh r1, [r1]
bl GetBankMoveSlotId
bl GetBattlerMoveSlotId
lsls r0, 24
lsrs r0, 24
mov r10, r0
@ -134,20 +134,20 @@ _0817CA4C:
bl _0817E0A2
.pool
_0817CA9C:
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
bl GetBankIdentity
bl GetBattlerPosition
lsls r0, 24
lsrs r0, 25
mov r8, r0
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
bl GetBankIdentity
bl GetBattlerPosition
lsls r0, 24
lsrs r5, r0, 25
ldr r0, =gEffectBank
ldrb r0, [r0]
bl GetBankIdentity
bl GetBattlerPosition
lsls r0, 24
lsrs r3, r0, 25
ldr r1, [sp]
@ -571,8 +571,8 @@ _0817D0DC:
adds r3, r4
lsls r3, 2
adds r3, r7, r3
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -601,8 +601,8 @@ _0817D124:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -634,8 +634,8 @@ _0817D16C:
adds r0, r4
lsls r0, 2
adds r5, r7, r0
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -715,8 +715,8 @@ _0817D216:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -775,8 +775,8 @@ _0817D296:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -833,8 +833,8 @@ _0817D314:
lsls r0, r4, 4
adds r3, r0
adds r3, r7, r3
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -940,8 +940,8 @@ _0817D3F2:
bne _0817D3FE
bl _0817E0A6
_0817D3FE:
ldr r0, =gBankAttacker
ldr r1, =gBankTarget
ldr r0, =gBattlerAttacker
ldr r1, =gBattlerTarget
ldrb r0, [r0]
ldrb r1, [r1]
cmp r0, r1
@ -1014,8 +1014,8 @@ _0817D498:
lsls r0, r6, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1091,8 +1091,8 @@ _0817D53C:
lsls r0, r6, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1161,8 +1161,8 @@ _0817D5CE:
lsls r0, r6, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1226,8 +1226,8 @@ _0817D65E:
lsls r0, r6, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1301,7 +1301,7 @@ _0817D6F2:
strb r0, [r1]
bl _0817E0A6
_0817D704:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1314,7 +1314,7 @@ _0817D704:
lsls r4, 3
adds r2, r4
adds r2, r7, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1353,8 +1353,8 @@ _0817D76C:
bne _0817D77E
bl _0817E0A6
_0817D77E:
ldr r6, =gBattlePartyID
ldr r5, =gBankAttacker
ldr r6, =gBattlerPartyIndexes
ldr r5, =gBattlerAttacker
ldrb r0, [r5]
lsls r0, 1
adds r0, r6
@ -1395,7 +1395,7 @@ _0817D7B2:
b _0817D934
.pool
_0817D7D8:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1408,7 +1408,7 @@ _0817D7D8:
lsls r4, 3
adds r2, r4
adds r2, r7, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1439,7 +1439,7 @@ _0817D7D8:
b _0817D88C
.pool
_0817D838:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1452,7 +1452,7 @@ _0817D838:
lsls r4, 3
adds r2, r4
adds r2, r7, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1496,9 +1496,9 @@ _0817D8A4:
bne _0817D8B6
bl _0817E0A6
_0817D8B6:
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
mov r8, r2
ldr r6, =gBankAttacker
ldr r6, =gBattlerAttacker
ldrb r0, [r6]
lsls r0, 1
add r0, r8
@ -1573,8 +1573,8 @@ _0817D94C:
lsls r0, r6, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1627,7 +1627,7 @@ _0817D9AE:
movs r0, 0x9
b _0817E086
_0817D9C2:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1640,7 +1640,7 @@ _0817D9C2:
lsls r4, 3
adds r2, r4
adds r2, r7, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1671,8 +1671,8 @@ _0817D9C2:
b _0817DB76
.pool
_0817DA24:
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1702,7 +1702,7 @@ _0817DA48:
b _0817E0A6
.pool
_0817DA68:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1715,7 +1715,7 @@ _0817DA68:
lsls r4, 3
adds r2, r4
adds r2, r7, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1747,8 +1747,8 @@ _0817DA68:
b _0817DB76
.pool
_0817DACC:
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1790,7 +1790,7 @@ _0817DB10:
b _0817E0A6
.pool
_0817DB24:
ldr r5, =gBattlePartyID
ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank
ldrb r0, [r6]
lsls r0, 1
@ -1803,7 +1803,7 @@ _0817DB24:
lsls r4, 3
adds r3, r4
adds r3, r7, r3
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r5
@ -1838,8 +1838,8 @@ _0817DB76:
b _0817E0A6
.pool
_0817DB90:
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1875,8 +1875,8 @@ _0817DBD4:
lsls r0, r1, 4
adds r3, r0
adds r3, r7, r3
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -1943,8 +1943,8 @@ _0817DC62:
adds r2, r6
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2021,8 +2021,8 @@ _0817DCFC:
lsls r0, r4, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2049,8 +2049,8 @@ _0817DD38:
lsls r0, r4, 4
adds r2, r0
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2121,8 +2121,8 @@ _0817DDC8:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2154,8 +2154,8 @@ _0817DE10:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2253,8 +2253,8 @@ _0817DEDC:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2331,8 +2331,8 @@ _0817DF70:
adds r2, r4
lsls r2, 2
adds r2, r7, r2
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2413,8 +2413,8 @@ _0817DFE6:
negs r0, r0
ands r0, r2
strb r0, [r1]
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -2557,22 +2557,22 @@ _0817E122:
lsls r1, 2
adds r1, r0, r1
str r1, [sp, 0x8]
ldr r2, =gBankAttacker
ldr r2, =gBattlerAttacker
mov r10, r2
ldrb r0, [r2]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
mov r9, r0
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r4, r0, 24
mov r1, r10
ldrb r0, [r1]
adds r1, r7, 0
bl GetBankMoveSlotId
bl GetBattlerMoveSlotId
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0x3
@ -2593,7 +2593,7 @@ _0817E122:
_0817E184:
mov r2, r10
ldrb r0, [r2]
bl GetBankIdentity
bl GetBattlerPosition
lsls r0, 24
lsrs r0, 25
lsls r0, 3
@ -2604,7 +2604,7 @@ _0817E184:
mov r2, r10
ldrb r1, [r2]
lsls r1, 1
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
adds r1, r2
ldrh r2, [r1]
adds r2, 0x1
@ -2617,7 +2617,7 @@ _0817E184:
strb r1, [r0]
mov r1, r10
ldrb r0, [r1]
bl GetBankIdentity
bl GetBattlerPosition
lsls r0, 24
lsrs r0, 25
lsls r0, 3
@ -2685,7 +2685,7 @@ _0817E23C:
mov r1, r10
ldrb r0, [r1]
lsls r0, 1
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
adds r0, r2
ldrh r1, [r0]
adds r1, 0x1
@ -2723,7 +2723,7 @@ _0817E27A:
mov r1, r10
ldrb r0, [r1]
lsls r0, 1
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
adds r0, r1
ldrh r1, [r0]
adds r1, 0x1
@ -2812,9 +2812,9 @@ sub_817E32C: @ 817E32C
movs r1, 0x81
lsls r1, 2
adds r4, r0, r1
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r2, r0, 24
cmp r5, 0x12
@ -3244,14 +3244,14 @@ sub_817E684: @ 817E684
movs r2, 0x81
lsls r2, 2
adds r7, r0, r2
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r3, r0, 24
mov r0, r10
@ -3297,8 +3297,8 @@ _0817E6F0:
.4byte _0817E760
.4byte _0817E760
_0817E760:
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -3324,13 +3324,13 @@ _0817E760:
_0817E79C:
ldr r1, =gUnknown_0860A834
add r1, r12
ldr r7, =gBattlePartyID
ldr r7, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r4
lsls r2, r0, 4
ldr r4, =0x0000ffff
ldr r1, [r1]
ldr r3, =gBankAttacker
ldr r3, =gBattlerAttacker
ldrh r0, [r1]
cmp r6, r0
bne _0817E7E0
@ -3708,15 +3708,15 @@ sub_817EA80: @ 817EA80
movs r1, 0x81
lsls r1, 2
adds r5, r0, r1
ldr r3, =gBankAttacker
ldr r3, =gBattlerAttacker
mov r8, r3
ldrb r0, [r3]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r2, r0, 24
lsls r0, r4, 1
@ -4005,8 +4005,8 @@ _0817ECCC:
ldrb r0, [r0]
lsrs r0, 5
subs r6, r0, 0x1
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -4164,8 +4164,8 @@ _0817EE1C:
cmp r7, 0x1
bne _0817EEBC
adds r2, r4, 0
ldr r1, =gBattlePartyID
ldr r0, =gBankAttacker
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
@ -4227,7 +4227,7 @@ _0817EE8E:
b _0817EEBC
_0817EE96:
adds r2, r4, 0
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
mov r3, r8
ldrb r0, [r3]
lsls r0, 1
@ -4269,9 +4269,9 @@ sub_817EECC: @ 817EECC
beq _0817EEE6
b _0817F1FA
_0817EEE6:
ldr r4, =gBankAttacker
ldr r4, =gBattlerAttacker
ldrb r0, [r4]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -4291,7 +4291,7 @@ _0817EEF8:
bgt _0817EF10
b _0817F1FA
_0817EF10:
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
muls r0, r1
adds r0, r5
@ -4367,7 +4367,7 @@ _0817EF8A:
beq _0817EF98
b _0817F1FA
_0817EF98:
ldr r2, =gBankAttacker
ldr r2, =gBattlerAttacker
ldrb r0, [r2]
adds r0, r6
ldrb r0, [r0]
@ -4386,11 +4386,11 @@ _0817EF98:
mov r10, r3
mov r8, r0
add r7, sp, 0x10
ldr r4, =gBankTarget
ldr r4, =gBattlerTarget
mov r9, r4
_0817EFC2:
lsls r1, r5, 1
ldr r6, =gBankAttacker
ldr r6, =gBattlerAttacker
ldrb r0, [r6]
movs r2, 0x58
muls r0, r2
@ -4411,16 +4411,16 @@ _0817EFC2:
lsls r0, 24
cmp r0, 0
beq _0817F0B4
ldr r4, =gSideAffecting
ldr r4, =gSideStatuses
mov r1, r9
ldrb r0, [r1]
bl GetBankIdentity
bl GetBattlerPosition
movs r1, 0x1
ands r1, r0
lsls r1, 1
adds r1, r4
ldrh r3, [r1]
ldr r2, =gBankAttacker
ldr r2, =gBattlerAttacker
ldrb r0, [r2]
movs r4, 0x58
muls r0, r4
@ -4437,7 +4437,7 @@ _0817EFC2:
str r4, [sp]
movs r4, 0
str r4, [sp, 0x4]
ldr r6, =gBankAttacker
ldr r6, =gBattlerAttacker
ldrb r4, [r6]
str r4, [sp, 0x8]
mov r6, r9
@ -4448,7 +4448,7 @@ _0817EFC2:
ldr r4, =gBattleMoveDamage
str r3, [r4]
ldr r1, =gStatuses3
ldr r2, =gBankAttacker
ldr r2, =gBattlerAttacker
ldrb r0, [r2]
lsls r0, 2
adds r0, r1
@ -4472,7 +4472,7 @@ _0817EFC2:
str r0, [r4]
_0817F06A:
ldr r0, =gProtectStructs
ldr r6, =gBankAttacker
ldr r6, =gBattlerAttacker
ldrb r1, [r6]
lsls r1, 4
adds r1, r0
@ -4513,9 +4513,9 @@ _0817F0B4:
cmp r5, 0x3
ble _0817EFC2
movs r5, 0
ldr r3, =gBankAttacker
ldr r3, =gBattlerAttacker
ldr r6, =gMoveSelectionCursor
ldr r4, =gBattlePartyID
ldr r4, =gBattlerPartyIndexes
mov r8, r4
movs r7, 0x64
mov r9, r7
@ -4545,9 +4545,9 @@ _0817F0D8:
movs r7, 0
_0817F0F6:
movs r5, 0
ldr r4, =gBankTarget
ldr r4, =gBattlerTarget
ldr r6, =gEnemyParty
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
add r0, r10
ldrb r3, [r0]
@ -4582,7 +4582,7 @@ _0817F11A:
adds r6, r0, 0
lsls r6, 16
lsrs r6, 16
ldr r2, =gBankAttacker
ldr r2, =gBattlerAttacker
ldrb r0, [r2]
lsls r0, 1
add r0, r8
@ -4598,7 +4598,7 @@ _0817F11A:
adds r1, r0, 0
lsls r1, 16
lsrs r1, 16
ldr r4, =gBankAttacker
ldr r4, =gBattlerAttacker
ldrb r3, [r4]
mov r2, r10
adds r0, r3, r2
@ -4625,7 +4625,7 @@ _0817F1D4:
_0817F1DC:
ldr r2, =gBattleMoveDamage
ldr r1, =gMoveSelectionCursor
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
adds r0, r1
ldrb r0, [r0]
@ -4695,7 +4695,7 @@ _0817F270:
cmp r2, 0x95
bne _0817F294
ldr r2, =gBattleMons
ldr r0, =gBankAttacker
ldr r0, =gBattlerAttacker
ldrb r1, [r0]
movs r0, 0x58
muls r0, r1
@ -4793,15 +4793,15 @@ _0817F324:
.pool
thumb_func_end sub_817F2A8
thumb_func_start GetBankMoveSlotId
GetBankMoveSlotId: @ 817F33C
thumb_func_start GetBattlerMoveSlotId
GetBattlerMoveSlotId: @ 817F33C
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r1, 16
lsrs r7, r1, 16
adds r0, r5, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
ldr r6, =gEnemyParty
cmp r0, 0
@ -4809,7 +4809,7 @@ GetBankMoveSlotId: @ 817F33C
ldr r6, =gPlayerParty
_0817F356:
movs r4, 0
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1
adds r5, r0, r1
b _0817F36E
@ -4835,7 +4835,7 @@ _0817F388:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end GetBankMoveSlotId
thumb_func_end GetBattlerMoveSlotId
thumb_func_start sub_817F394
sub_817F394: @ 817F394

View File

@ -5354,7 +5354,7 @@ sub_8164E04: @ 8164E04
adds r0, r2
ldrh r1, [r5]
bl sub_8165B88
ldr r6, =gBattlePartyID
ldr r6, =gBattlerPartyIndexes
ldrh r0, [r6, 0x2]
movs r5, 0x64
muls r0, r5

View File

@ -1048,7 +1048,7 @@ _080D8004:
bl sub_80DC594
bl sub_80DC5E8
bl sub_80DC7EC
ldr r1, =gBanksByIdentity
ldr r1, =gBattlerPositions
strb r4, [r1]
movs r0, 0x1
strb r0, [r1, 0x1]
@ -1058,12 +1058,12 @@ _080D8004:
strb r2, [r1, 0x3]
ldr r0, =gBattleTypeFlags
str r4, [r0]
ldr r4, =gBankAttacker
ldr r4, =gBattlerAttacker
strb r2, [r4]
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
strb r3, [r0]
bl sub_80DB0C4
ldr r2, =gBankSpriteIds
ldr r2, =gBattlerSpriteIds
ldrb r1, [r4]
adds r1, r2
strb r0, [r1]
@ -2547,8 +2547,8 @@ _080D8DD0:
lsls r4, 3
adds r4, r0
strh r5, [r4, 0xC]
ldr r1, =gBankSpriteIds
ldr r0, =gBankAttacker
ldr r1, =gBattlerSpriteIds
ldr r0, =gBattlerAttacker
ldrb r0, [r0]
adds r0, r1
strb r5, [r0]
@ -13796,9 +13796,9 @@ sub_80DEA20: @ 80DEA20
push {lr}
ldr r0, =SpriteCallbackDummy
bl CreateInvisibleSpriteWithCallback
ldr r1, =gBankSpriteIds
ldr r1, =gBattlerSpriteIds
strb r0, [r1, 0x3]
ldr r0, =gBankTarget
ldr r0, =gBattlerTarget
ldrb r0, [r0]
adds r0, r1
ldrb r1, [r0]
@ -13817,7 +13817,7 @@ sub_80DEA20: @ 80DEA20
thumb_func_start sub_80DEA5C
sub_80DEA5C: @ 80DEA5C
push {r4,lr}
ldr r0, =gBankSpriteIds
ldr r0, =gBattlerSpriteIds
ldrb r0, [r0, 0x3]
lsls r4, r0, 4
adds r4, r0
@ -13829,13 +13829,13 @@ sub_80DEA5C: @ 80DEA5C
strh r0, [r4, 0x26]
movs r0, 0x3
movs r1, 0
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
strh r0, [r4, 0x20]
movs r0, 0x3
movs r1, 0x1
bl GetBankPosition
bl GetBattlerSpriteCoord
lsls r0, 24
lsrs r0, 24
strh r0, [r4, 0x22]
@ -13905,12 +13905,12 @@ _080DEAD0:
.4byte _080DEB60
.4byte _080DEB60
_080DEB54:
ldr r1, =gBankTarget
ldr r1, =gBattlerTarget
movs r0, 0x2
b _080DEB64
.pool
_080DEB60:
ldr r1, =gBankTarget
ldr r1, =gBattlerTarget
movs r0, 0x3
_080DEB64:
strb r0, [r1]

View File

@ -1389,7 +1389,7 @@
.endm
.macro jumpifmovehadnoeffect jumpptr
jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr
jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_NO_EFFECT, \jumpptr
.endm
.macro jumpifbattletype flags, jumpptr

View File

@ -16041,14 +16041,14 @@ _081B8AF8:
b _081B8B24
_081B8AFC:
adds r0, r4, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _081B8B1E
adds r0, r5, 0
bl sub_81B8F38
lsls r0, 24
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
lsls r1, r4, 1
adds r1, r2
lsrs r0, 24
@ -16060,7 +16060,7 @@ _081B8B1E:
lsls r0, 24
lsrs r4, r0, 24
_081B8B24:
ldr r0, =gNoOfAllBanks
ldr r0, =gBattlersCount
ldrb r0, [r0]
cmp r4, r0
bcc _081B8AFC
@ -16115,7 +16115,7 @@ _081B8BA8:
ldr r1, =gUnknown_0203CEE8
movs r0, 0x1
strb r0, [r1]
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
ldr r0, =gBankInMenu
ldrb r0, [r0]
lsls r0, 1
@ -16150,7 +16150,7 @@ _081B8BFC:
_081B8C20:
ldr r0, =gBankInMenu
ldrb r0, [r0]
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, 1
adds r0, r1
ldrb r0, [r0]
@ -16228,9 +16228,9 @@ _081B8CBE:
bne _081B8CFC
movs r5, 0x1
movs r0, 0
bl GetBankByIdentity
bl GetBattlerAtPosition
mov r2, sp
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, 24
lsrs r0, 23
adds r0, r1
@ -16255,16 +16255,16 @@ _081B8CF0:
_081B8CFC:
movs r5, 0x2
movs r0, 0
bl GetBankByIdentity
bl GetBattlerAtPosition
mov r1, sp
ldr r4, =gBattlePartyID
ldr r4, =gBattlerPartyIndexes
lsls r0, 24
lsrs r0, 23
adds r0, r4
ldrh r0, [r0]
strb r0, [r1]
movs r0, 0x2
bl GetBankByIdentity
bl GetBattlerAtPosition
mov r1, sp
lsls r0, 24
lsrs r0, 23
@ -16339,24 +16339,24 @@ sub_81B8D88: @ 81B8D88
lsrs r7, r1, 24
lsls r0, 24
lsrs r0, 24
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _081B8DB0
movs r0, 0
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r4, r0, 24
movs r0, 0x2
b _081B8DBC
_081B8DB0:
movs r0, 0x1
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r4, r0, 24
movs r0, 0x3
_081B8DBC:
bl GetBankByIdentity
bl GetBattlerAtPosition
lsls r0, 24
lsrs r6, r0, 24
bl sub_81B1250
@ -16388,7 +16388,7 @@ _081B8DF0:
bne _081B8E28
movs r3, 0x1
mov r2, sp
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r1
ldrh r0, [r0]
@ -16412,7 +16412,7 @@ _081B8E1A:
_081B8E28:
movs r3, 0x2
mov r1, sp
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
lsls r0, r4, 1
adds r0, r2
ldrh r0, [r0]

View File

@ -581,7 +581,7 @@ _080689E4:
beq _080689CE
_080689F4:
adds r0, r5, 0
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
beq _080689CE

View File

@ -100,7 +100,7 @@ _0806BDBC:
lsrs r0, 24
_0806BDC4:
str r0, [sp, 0x34]
ldr r1, =gStringBank
ldr r1, =gStringBattler
ldr r0, =gBankInMenu
ldrb r2, [r0]
strb r2, [r1]
@ -114,23 +114,23 @@ _0806BDC4:
lsrs r1, r0, 24
cmp r1, 0
beq _0806BE64
ldr r0, =gActiveBank
ldr r0, =gActiveBattler
strb r2, [r0]
ldrb r0, [r0]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
negs r1, r0
orrs r1, r0
lsrs r1, 31
str r1, [sp, 0x1C]
ldr r0, =gNoOfAllBanks
ldr r0, =gBattlersCount
ldr r4, [sp, 0xC]
subs r4, 0xD
ldrb r0, [r0]
cmp r1, r0
bge _0806BE70
ldr r2, =gBattlePartyID
ldr r2, =gBattlerPartyIndexes
lsls r0, r1, 1
adds r0, r2
ldrh r3, [r0]
@ -148,7 +148,7 @@ _0806BE3C:
ldr r1, [sp, 0x1C]
adds r1, 0x2
str r1, [sp, 0x1C]
ldr r0, =gNoOfAllBanks
ldr r0, =gBattlersCount
ldrb r0, [r0]
cmp r1, r0
bge _0806BE70
@ -165,7 +165,7 @@ _0806BE3C:
b _0806BE70
.pool
_0806BE64:
ldr r0, =gActiveBank
ldr r0, =gActiveBattler
strb r1, [r0]
movs r3, 0x4
str r3, [sp, 0x38]
@ -200,7 +200,7 @@ _0806BE9A:
ands r0, r1
cmp r0, 0
beq _0806BECC
ldr r0, =gActiveBank
ldr r0, =gActiveBattler
ldrb r1, [r0]
lsls r0, r1, 3
subs r0, r1
@ -297,7 +297,7 @@ _0806BF76:
cmp r0, 0
beq _0806BFA4
ldr r1, =gBattleMons
ldr r0, =gActiveBank
ldr r0, =gActiveBattler
ldrb r2, [r0]
movs r0, 0x58
muls r0, r2
@ -323,7 +323,7 @@ _0806BFA4:
bl _0806CD4C
_0806BFB2:
ldr r6, =gBattleMons
ldr r5, =gActiveBank
ldr r5, =gActiveBattler
ldrb r0, [r5]
movs r4, 0x58
muls r0, r4
@ -362,7 +362,7 @@ _0806BFFC:
cmp r3, 0
beq _0806C042
ldr r7, =gBattleMons
ldr r5, =gActiveBank
ldr r5, =gActiveBattler
ldrb r0, [r5]
movs r4, 0x58
muls r0, r4
@ -396,7 +396,7 @@ _0806C042:
bl _0806CD4C
_0806C050:
ldr r6, =gBattleMons
ldr r5, =gActiveBank
ldr r5, =gActiveBattler
ldrb r0, [r5]
movs r4, 0x58
muls r0, r4
@ -433,7 +433,7 @@ _0806C08C:
cmp r3, 0
beq _0806C0D2
ldr r7, =gBattleMons
ldr r5, =gActiveBank
ldr r5, =gActiveBattler
ldrb r0, [r5]
movs r4, 0x58
muls r0, r4
@ -467,7 +467,7 @@ _0806C0D2:
bl _0806CD4C
_0806C0E0:
ldr r6, =gBattleMons
ldr r5, =gActiveBank
ldr r5, =gActiveBattler
ldrb r0, [r5]
movs r4, 0x58
muls r0, r4
@ -506,9 +506,9 @@ _0806C120:
cmp r0, 0
beq _0806C168
ldr r5, =gSideTimers
ldr r4, =gActiveBank
ldr r4, =gActiveBattler
ldrb r0, [r4]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
lsls r1, r0, 1
@ -519,7 +519,7 @@ _0806C120:
cmp r0, 0
bne _0806C168
ldrb r0, [r4]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
lsrs r0, 24
lsls r1, r0, 1
@ -965,7 +965,7 @@ _0806C4FC:
ldr r3, [sp, 0x38]
cmp r3, 0x4
beq _0806C55C
ldr r2, =gAbsentBankFlags
ldr r2, =gAbsentBattlerFlags
ldr r1, =gBitTable
lsls r0, r3, 2
adds r0, r1
@ -973,7 +973,7 @@ _0806C4FC:
ldrb r0, [r2]
bics r0, r1
strb r0, [r2]
ldr r1, =gBattlePartyID
ldr r1, =gBattlerPartyIndexes
lsls r0, r3, 1
adds r0, r1
ldrb r0, [r0]
@ -983,14 +983,14 @@ _0806C4FC:
lsrs r1, 24
ldr r0, [sp, 0x38]
bl CopyPlayerPartyMonToBattleData
ldr r0, =gActiveBank
ldr r0, =gActiveBattler
ldrb r0, [r0]
b _0806C574
.pool
_0806C55C:
ldr r3, =gAbsentBankFlags
ldr r3, =gAbsentBattlerFlags
ldr r1, =gBitTable
ldr r2, =gActiveBank
ldr r2, =gActiveBattler
ldrb r0, [r2]
eors r0, r4
lsls r0, 2
@ -1001,7 +1001,7 @@ _0806C55C:
strb r0, [r3]
ldrb r0, [r2]
_0806C574:
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _0806C5B2
@ -1135,9 +1135,9 @@ _0806C65E:
ands r0, r3
cmp r0, 0
bne _0806C6EC
ldr r4, =gActiveBank
ldr r4, =gActiveBattler
ldrb r0, [r4]
bl GetBankSide
bl GetBattlerSide
lsls r0, 24
cmp r0, 0
bne _0806C6EC
@ -1155,9 +1155,9 @@ _0806C6AE:
movs r0, 0
movs r1, 0
movs r2, 0
bl EmitGetMonData
bl BtlController_EmitGetMonData
ldrb r0, [r4]
bl MarkBufferBankForExecution
bl MarkBattlerForControllerExec
strb r5, [r4]
b _0806C6EC
.pool

View File

@ -45,21 +45,21 @@
.set OPPONENT_TELEPORTED, 0xA
@ identities
.set IDENTITY_PLAYER_MON1, 0
.set IDENTITY_OPPONENT_MON1, 1
.set IDENTITY_PLAYER_MON2, 2
.set IDENTITY_OPPONENT_MON2, 3
.set B_POSITION_PLAYER_LEFT, 0
.set B_POSITION_OPPONENT_LEFT, 1
.set B_POSITION_PLAYER_RIGHT, 2
.set B_POSITION_OPPONENT_RIGHT, 3
@ status 1
.set STATUS_SLEEP, 0x7
.set STATUS_POISON, 0x8
.set STATUS_BURN, 0x10
.set STATUS_FREEZE, 0x20
.set STATUS_PARALYSIS, 0x40
.set STATUS_TOXIC_POISON, 0x80
.set STATUS_TOXIC_COUNTER, 0xF00
.set STATUS1_SLEEP, 0x7
.set STATUS1_POISON, 0x8
.set STATUS1_BURN, 0x10
.set STATUS1_FREEZE, 0x20
.set STATUS1_PARALYSIS, 0x40
.set STATUS1_TOXIC_POISON, 0x80
.set STATUS1_TOXIC_COUNTER, 0xF00
.set STATUS_ANY, STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON
.set STATUS1_ANY, STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON
@ status 2
.set STATUS2_CONFUSION, 0x00000007
@ -160,11 +160,12 @@
.set HITMARKER_x8000000, 0x08000000
@ move flags
.set MOVESTATUS_MISSED, 0x1
.set MOVESTATUS_SUPEREFFECTIVE, 0x2
.set MOVESTATUS_NOTVERYEFFECTIVE, 0x4
.set MOVESTATUS_NOTAFFECTED, 0x8
.set MOVESTATUS_ONEHITKO, 0x10
.set MOVESTATUS_FAILED, 0x20
.set MOVESTATUS_ENDURED, 0x40
.set MOVESTATUS_HUNGON, 0x80
.set MOVE_RESULT_MISSED, 0x1
.set MOVE_RESULT_SUPER_EFFECTIVE, 0x2
.set MOVE_RESULT_NOT_VERY_EFFECTIVE, 0x4
.set MOVE_RESULT_DOESNT_AFFECT_FOE, 0x8
.set MOVE_RESULT_ONE_HIT_KO, 0x10
.set MOVE_RESULT_FAILED, 0x20
.set MOVE_RESULT_FOE_ENDURED, 0x40
.set MOVE_RESULT_FOE_HUNG_ON, 0x80
.set MOVE_RESULT_NO_EFFECT, (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED)

View File

@ -218,7 +218,7 @@ BattleAIScript_82DC2D4:
get_ability AI_TARGET
if_equal ABILITY_INSOMNIA, Score_Minus10
if_equal ABILITY_VITAL_SPIRIT, Score_Minus10
if_status AI_TARGET, STATUS_ANY, Score_Minus10
if_status AI_TARGET, STATUS1_ANY, Score_Minus10
if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10
end
@ -237,11 +237,11 @@ BattleAIScript_82DC31A:
BattleAIScript_82DC31B:
if_status2 AI_TARGET, STATUS2_NIGHTMARE, Score_Minus10
if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8
if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8
end
BattleAIScript_82DC330:
if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8
if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8
if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10
end
@ -350,7 +350,7 @@ BattleAIScript_82DC48C:
if_equal TYPE_POISON, Score_Minus10
get_ability AI_TARGET
if_equal ABILITY_IMMUNITY, Score_Minus10
if_status AI_TARGET, STATUS_ANY, Score_Minus10
if_status AI_TARGET, STATUS1_ANY, Score_Minus10
if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10
end
@ -402,7 +402,7 @@ BattleAIScript_82DC545:
if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10
get_ability AI_TARGET
if_equal ABILITY_LIMBER, Score_Minus10
if_status AI_TARGET, STATUS_ANY, Score_Minus10
if_status AI_TARGET, STATUS1_ANY, Score_Minus10
if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10
end
@ -428,7 +428,7 @@ BattleAIScript_82DC59D:
end
BattleAIScript_82DC5A5:
if_not_status AI_USER, STATUS_SLEEP, Score_Minus8
if_not_status AI_USER, STATUS1_SLEEP, Score_Minus8
end
BattleAIScript_82DC5B0:
@ -536,7 +536,7 @@ BattleAIScript_82DC6A9:
BattleAIScript_82DC6B4:
get_ability AI_TARGET
if_equal ABILITY_WATER_VEIL, Score_Minus10
if_status AI_TARGET, STATUS_ANY, Score_Minus10
if_status AI_TARGET, STATUS1_ANY, Score_Minus10
if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10
if_type_effectiveness AI_EFFECTIVENESS_x0_5, Score_Minus10
if_type_effectiveness AI_EFFECTIVENESS_x0_25, Score_Minus10
@ -566,7 +566,7 @@ BattleAIScript_82DC708:
end
BattleAIScript_82DC713:
if_not_status AI_USER, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, Score_Minus10
if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, Score_Minus10
end
BattleAIScript_82DC71E:
@ -1076,7 +1076,7 @@ BattleAIScript_82DCD3D:
score -1
BattleAIScript_82DCD4D:
if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCD6C
if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCD6C
if_hp_more_than AI_USER, 50, BattleAIScript_82DCD64
if_random_less_than 80, BattleAIScript_82DCD6C
@ -1263,7 +1263,7 @@ BattleAIScript_82DCF22:
score -2
BattleAIScript_82DCF32:
if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCF44
if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCF44
if_random_less_than 70, BattleAIScript_82DCF44
score +2
@ -1520,7 +1520,7 @@ BattleAIScript_82DD228:
end
BattleAIScript_82DD229:
if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD256
if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD256
if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD256
if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD256
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD256
@ -1673,7 +1673,7 @@ BattleAIScript_82DD381:
goto BattleAIScript_82DD3E9
BattleAIScript_82DD3B9:
if_not_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD3E1
if_not_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD3E1
goto BattleAIScript_82DD3E9
BattleAIScript_82DD3C8:
@ -1722,7 +1722,7 @@ BattleAIScript_82DD430:
end
BattleAIScript_82DD431:
if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD4D6
if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD4D6
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD4D6
if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD4D6
if_hp_more_than AI_USER, 30, BattleAIScript_82DD45E
@ -1901,7 +1901,7 @@ BattleAIScript_82DD582:
end
BattleAIScript_82DD583:
if_status AI_USER, STATUS_SLEEP, Score_Plus10
if_status AI_USER, STATUS1_SLEEP, Score_Plus10
score -5
end
@ -1952,8 +1952,8 @@ BattleAIScript_82DD60A:
end
BattleAIScript_82DD60B:
if_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD621
if_status_in_party AI_TARGET, STATUS_ANY, BattleAIScript_82DD621
if_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621
if_status_in_party AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621
score -5
BattleAIScript_82DD621:
@ -2012,7 +2012,7 @@ BattleAIScript_82DD693:
BattleAIScript_82DD694:
get_protect_count AI_USER
if_more_than 1, BattleAIScript_82DD75A
if_status AI_USER, STATUS_TOXIC_POISON, BattleAIScript_82DD751
if_status AI_USER, STATUS1_TOXIC_POISON, BattleAIScript_82DD751
if_status2 AI_USER, STATUS2_CURSED, BattleAIScript_82DD751
if_status3 AI_USER, STATUS3_PERISH_SONG, BattleAIScript_82DD751
if_status2 AI_USER, STATUS2_INFATUATION, BattleAIScript_82DD751
@ -2020,7 +2020,7 @@ BattleAIScript_82DD694:
if_status3 AI_USER, STATUS3_YAWN, BattleAIScript_82DD751
if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DD751
if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DD751
if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD730
if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD730
if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD730
if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD730
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD730
@ -2238,7 +2238,7 @@ BattleAIScript_82DD959:
end
BattleAIScript_82DD95A:
if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD9FF
if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD9FF
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD9FF
if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD9FF
if_hp_more_than AI_USER, 30, BattleAIScript_82DD987
@ -2323,7 +2323,7 @@ BattleAIScript_82DDA2F:
goto BattleAIScript_82DDAB4
BattleAIScript_82DDA3D:
if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DDAAC
if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DDAAC
if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DDAAC
if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DDAAC
get_weather
@ -2396,7 +2396,7 @@ BattleAIScript_82DDAF5:
end
BattleAIScript_82DDAF6:
if_not_status AI_TARGET, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, BattleAIScript_82DDB02
if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, BattleAIScript_82DDB02
score +1
BattleAIScript_82DDB02:
@ -2405,7 +2405,7 @@ BattleAIScript_82DDB02:
BattleAIScript_82DDB03:
if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDB42
if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDB42
if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDB59
if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDB59
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDB49
if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDB49
is_first_turn_for AI_USER
@ -2429,7 +2429,7 @@ BattleAIScript_82DDB5B:
end
BattleAIScript_82DDB5C:
if_status AI_TARGET, STATUS_PARALYSIS, BattleAIScript_82DDB6B
if_status AI_TARGET, STATUS1_PARALYSIS, BattleAIScript_82DDB6B
goto BattleAIScript_82DDB6D
BattleAIScript_82DDB6B:
@ -2571,7 +2571,7 @@ sItemsTable_82DDC6E:
.byte -1
BattleAIScript_82DDC72:
if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDC9D
if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDC9D
if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDC9D
if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDC9D
if_random_less_than 180, BattleAIScript_82DDC9D
@ -2960,7 +2960,7 @@ BattleAIScript_82DDFED:
end
BattleAIScript_82DDFF5:
if_status AI_USER, STATUS_ANY, BattleAIScript_82DE000
if_status AI_USER, STATUS1_ANY, BattleAIScript_82DE000
end
BattleAIScript_82DE000:
@ -3060,7 +3060,7 @@ BattleAIScript_82DE14A:
BattleAIScript_82DE14F:
get_ability AI_TARGET
if_not_equal ABILITY_GUTS, Score_Minus30_
if_status AI_TARGET, STATUS_ANY, Score_Minus30_
if_status AI_TARGET, STATUS1_ANY, Score_Minus30_
if_hp_less_than AI_USER, 91, Score_Minus30_
goto Score_Plus5

View File

@ -286,7 +286,7 @@ BattleScript_MoveEnd::
end
BattleScript_MakeMoveMissed::
orbyte gBattleMoveFlags, MOVESTATUS_MISSED
orbyte gMoveResultFlags, MOVE_RESULT_MISSED
BattleScript_PrintMoveMissed::
attackstring
ppreduce
@ -303,9 +303,9 @@ BattleScript_EffectSleep::
attackstring
ppreduce
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_SLEEP, BattleScript_AlreadyAsleep
jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_AlreadyAsleep
jumpifcantmakeasleep BattleScript_CantMakeAsleep
jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
attackanimation
@ -397,7 +397,7 @@ BattleScript_EffectExplosion::
faintifabilitynotdamp
setatkhptozero
waitstate
jumpifbyte NO_COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED, BattleScript_82D8B94
jumpifbyte NO_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_MISSED, BattleScript_82D8B94
call BattleScript_82D8BEA
goto BattleScript_82D8B96
BattleScript_82D8B94::
@ -436,16 +436,16 @@ BattleScript_82D8BCF::
end
BattleScript_82D8BEA::
bicbyte gBattleMoveFlags, MOVESTATUS_MISSED
bicbyte gMoveResultFlags, MOVE_RESULT_MISSED
attackanimation
waitanimation
orbyte gBattleMoveFlags, MOVESTATUS_MISSED
orbyte gMoveResultFlags, MOVE_RESULT_MISSED
return
BattleScript_EffectDreamEater::
attackcanceler
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_82D8C0E
jumpifstatus TARGET, STATUS_SLEEP, BattleScript_82D8C18
jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_82D8C18
BattleScript_82D8C0E::
attackstring
ppreduce
@ -487,7 +487,7 @@ BattleScript_EffectMirrorMove::
pause 0x40
trymirrormove
ppreduce
orbyte gBattleMoveFlags, MOVESTATUS_FAILED
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
printstring STRINGID_MIRRORMOVEFAILED
waitmessage 0x40
goto BattleScript_MoveEnd
@ -633,7 +633,7 @@ BattleScript_MultiHitLoop::
jumpifhasnohp ATTACKER, BattleScript_MultiHitEnd
jumpifhasnohp TARGET, BattleScript_MultiHitPrintStrings
jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_DoMultiHit
jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_MultiHitPrintStrings
jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_MultiHitPrintStrings
BattleScript_DoMultiHit::
movevaluescleanup
copybyte cEFFECT_CHOOSER, sMULTIHIT_EFFECT
@ -656,7 +656,7 @@ BattleScript_DoMultiHit::
addbyte sMULTIHIT_STRING + 4, 0x1
setbyte sMOVEEND_STATE, 0x0
moveend 0x2, 0x10
jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_MultiHitPrintStrings
jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_MultiHitPrintStrings
decrementmultihit BattleScript_MultiHitLoop
goto BattleScript_MultiHitPrintStrings
BattleScript_MultiHitNoMoreHits::
@ -712,9 +712,9 @@ BattleScript_EffectToxic::
ppreduce
jumpifability TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpiftype TARGET, TYPE_POISON, BattleScript_NotAffected
jumpiftype TARGET, TYPE_STEEL, BattleScript_NotAffected
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
@ -735,7 +735,7 @@ BattleScript_AlreadyPoisoned::
goto BattleScript_MoveEnd
BattleScript_ImmunityProtected::
copybyte gEffectBank, gBankTarget
copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PSNPrevention
goto BattleScript_MoveEnd
@ -759,7 +759,7 @@ BattleScript_EffectRest::
attackcanceler
attackstring
ppreduce
jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_RestIsAlreadyAsleep
jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_RestIsAlreadyAsleep
jumpifcantmakeasleep BattleScript_RestCantSleep
trysetrest BattleScript_AlreadyAtFullHp
pause 0x20
@ -835,7 +835,7 @@ BattleScript_EffectSuperFang::
attackstring
ppreduce
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
damagetohalftargethp
goto BattleScript_HitFromAtkAnimation
@ -845,7 +845,7 @@ BattleScript_EffectDragonRage::
attackstring
ppreduce
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
setword gBattleMoveDamage, 40
adjustsetdamage
goto BattleScript_HitFromAtkAnimation
@ -879,19 +879,19 @@ BattleScript_MoveMissedDoDamage::
pause 0x40
resultmessage
waitmessage 0x40
jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_NOTAFFECTED, BattleScript_MoveEnd
jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd
printstring STRINGID_PKMNCRASHED
waitmessage 0x40
damagecalc
typecalc
adjustnormaldamage
manipulatedamage ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP
bicbyte gBattleMoveFlags, MOVESTATUS_MISSED
bicbyte gMoveResultFlags, MOVE_RESULT_MISSED
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
healthbarupdate ATTACKER
datahpupdate ATTACKER
tryfaintmon ATTACKER, FALSE, NULL
orbyte gBattleMoveFlags, MOVESTATUS_MISSED
orbyte gMoveResultFlags, MOVE_RESULT_MISSED
goto BattleScript_MoveEnd
BattleScript_EffectMist::
@ -1012,11 +1012,11 @@ BattleScript_EffectPoison::
ppreduce
jumpifability TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
jumpifstatus TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpiftype TARGET, TYPE_POISON, BattleScript_NotAffected
jumpiftype TARGET, TYPE_STEEL, BattleScript_NotAffected
jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
attackanimation
@ -1035,8 +1035,8 @@ BattleScript_EffectParalyze::
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
typecalc
jumpifmovehadnoeffect BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_PARALYSIS, BattleScript_AlreadyParalyzed
jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed
jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
attackanimation
@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed::
goto BattleScript_MoveEnd
BattleScript_LimberProtected::
copybyte gEffectBank, gBankTarget
copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PRLZPrevention
goto BattleScript_MoveEnd
@ -1221,7 +1221,7 @@ BattleScript_EffectLevelDamage::
attackstring
ppreduce
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
dmgtolevel
adjustsetdamage
goto BattleScript_HitFromAtkAnimation
@ -1232,7 +1232,7 @@ BattleScript_EffectPsywave::
attackstring
ppreduce
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
psywavedamageeffect
adjustsetdamage
goto BattleScript_HitFromAtkAnimation
@ -1279,7 +1279,7 @@ BattleScript_EffectPainSplit::
BattleScript_EffectSnore::
attackcanceler
jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_SnoreIsAsleep
jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_SnoreIsAsleep
attackstring
ppreduce
goto BattleScript_ButItFailed
@ -1333,7 +1333,7 @@ BattleScript_EffectSketch::
BattleScript_EffectSleepTalk::
attackcanceler
jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_SleepTalkIsAsleep
jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_SleepTalkIsAsleep
attackstring
ppreduce
goto BattleScript_ButItFailed
@ -1415,7 +1415,7 @@ BattleScript_TripleKickLoop::
jumpifhasnohp ATTACKER, BattleScript_TripleKickEnd
jumpifhasnohp TARGET, BattleScript_TripleKickNoMoreHits
jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_DoTripleKickAttack
jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_TripleKickNoMoreHits
jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_TripleKickNoMoreHits
BattleScript_DoTripleKickAttack::
accuracycheck BattleScript_TripleKickNoMoreHits, ACC_CURR_MOVE
movevaluescleanup
@ -1440,18 +1440,18 @@ BattleScript_DoTripleKickAttack::
waitmessage 0x1
setbyte sMOVEEND_STATE, 0x0
moveend 0x2, 0x10
jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_TripleKickPrintStrings
jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_TripleKickPrintStrings
decrementmultihit BattleScript_TripleKickLoop
goto BattleScript_TripleKickPrintStrings
BattleScript_TripleKickNoMoreHits::
pause 0x20
jumpifbyte EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickPrintStrings
bicbyte gBattleMoveFlags, MOVESTATUS_MISSED
bicbyte gMoveResultFlags, MOVE_RESULT_MISSED
BattleScript_TripleKickPrintStrings::
resultmessage
waitmessage 0x40
jumpifbyte EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickEnd
jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_NOTAFFECTED, BattleScript_TripleKickEnd
jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TripleKickEnd
copyarray gBattleTextBuff1, sMULTIHIT_STRING, 0x6
printstring STRINGID_HITXTIMES
waitmessage 0x40
@ -1487,7 +1487,7 @@ BattleScript_EffectNightmare::
ppreduce
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
jumpifstatus2 TARGET, STATUS2_NIGHTMARE, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_SLEEP, BattleScript_NightmareWorked
jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_NightmareWorked
goto BattleScript_ButItFailed
BattleScript_NightmareWorked::
attackanimation
@ -1513,7 +1513,7 @@ BattleScript_EffectCurse::
jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed
jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed
BattleScript_CurseTrySpeed::
copybyte gBankTarget, gBankAttacker
copybyte gBattlerTarget, gBattlerAttacker
setbyte sANIM_TURN, 0x1
attackanimation
waitanimation
@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence::
BattleScript_CurseEnd::
goto BattleScript_MoveEnd
BattleScript_GhostCurse::
jumpifbytenotequal gBankAttacker, gBankTarget, BattleScript_DoGhostCurse
jumpifbytenotequal gBattlerAttacker, gBattlerTarget, BattleScript_DoGhostCurse
getmovetarget ATTACKER
BattleScript_DoGhostCurse::
attackcanceler
@ -1603,7 +1603,7 @@ BattleScript_PerishSongLoop::
jumpifability SCRIPTING_BANK, ABILITY_SOUNDPROOF, BattleScript_PerishSongNotAffected
BattleScript_PerishSongLoopIncrement::
addbyte sBANK, 0x1
jumpifbytenotequal sBANK, gNoOfAllBanks, BattleScript_PerishSongLoop
jumpifbytenotequal sBANK, gBattlersCount, BattleScript_PerishSongLoop
goto BattleScript_MoveEnd
BattleScript_PerishSongNotAffected::
@ -1748,7 +1748,7 @@ BattleScript_EffectSonicboom::
attackstring
ppreduce
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
setword gBattleMoveDamage, 20
adjustsetdamage
goto BattleScript_HitFromAtkAnimation
@ -2085,14 +2085,14 @@ BattleScript_ButItFailedPpReduce::
ppreduce
BattleScript_ButItFailed::
pause 0x20
orbyte gBattleMoveFlags, MOVESTATUS_FAILED
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
resultmessage
waitmessage 0x40
goto BattleScript_MoveEnd
BattleScript_NotAffected::
pause 0x20
orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED
orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE
resultmessage
waitmessage 0x40
goto BattleScript_MoveEnd
@ -2204,10 +2204,10 @@ BattleScript_EffectWillOWisp::
attackstring
ppreduce
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS_BURN, BattleScript_AlreadyBurned
jumpifstatus TARGET, STATUS1_BURN, BattleScript_AlreadyBurned
jumpiftype TARGET, TYPE_FIRE, BattleScript_NotAffected
jumpifability TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents
jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed
jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
attackanimation
@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp::
goto BattleScript_MoveEnd
BattleScript_WaterVeilPrevents::
copybyte gEffectBank, gBankTarget
copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_BRNPrevention
goto BattleScript_MoveEnd
@ -2275,7 +2275,7 @@ BattleScript_82DA15A::
goto BattleScript_MoveEnd
BattleScript_EffectFacade::
jumpifstatus ATTACKER, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, BattleScript_FacadeDoubleDmg
jumpifstatus ATTACKER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, BattleScript_FacadeDoubleDmg
goto BattleScript_EffectHit
BattleScript_FacadeDoubleDmg::
@ -2293,7 +2293,7 @@ BattleScript_EffectFocusPunch::
BattleScript_EffectSmellingsalt::
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_EffectHit
setmoveeffect EFFECT_REMOVE_PARALYSIS | CERTAIN
jumpifstatus TARGET, STATUS_PARALYSIS, BattleScript_SmellingsaltDoubleDmg
jumpifstatus TARGET, STATUS1_PARALYSIS, BattleScript_SmellingsaltDoubleDmg
goto BattleScript_EffectHit
BattleScript_SmellingsaltDoubleDmg::
@ -2452,7 +2452,7 @@ BattleScript_EffectBrickBreak::
typecalc
adjustnormaldamage
jumpifbyte EQUAL, sANIM_TURN, 0x0, BattleScript_BrickBreakAnim
bicbyte gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED
bicbyte gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE
BattleScript_BrickBreakAnim::
attackanimation
waitanimation
@ -2511,7 +2511,7 @@ BattleScript_EffectEndeavor::
accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE
typecalc
jumpifmovehadnoeffect BattleScript_HitFromAtkAnimation
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
copyword gBattleMoveDamage, gHpDealt
adjustsetdamage
goto BattleScript_HitFromAtkAnimation
@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance::
attackcanceler
attackstring
ppreduce
setbyte gBankTarget, 0x0
setbyte gBattlerTarget, 0x0
BattleScript_TeeterDanceLoop::
movevaluescleanup
setmoveeffect EFFECT_CONFUSION
jumpifbyteequal gBankAttacker, gBankTarget, BattleScript_TeeterDanceLoopIncrement
jumpifbyteequal gBattlerAttacker, gBattlerTarget, BattleScript_TeeterDanceLoopIncrement
jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents
jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused
@ -2618,8 +2618,8 @@ BattleScript_TeeterDanceDoMoveEndIncrement::
setbyte sMOVEEND_STATE, 0x0
moveend 0x2, 0x10
BattleScript_TeeterDanceLoopIncrement::
addbyte gBankTarget, 0x1
jumpifbytenotequal gBankTarget, gNoOfAllBanks, BattleScript_TeeterDanceLoop
addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TeeterDanceLoop
end
BattleScript_TeeterDanceOwnTempoPrevents::
@ -2706,7 +2706,7 @@ BattleScript_TickleEnd::
BattleScript_CantLowerMultipleStats::
pause 0x20
orbyte gBattleMoveFlags, MOVESTATUS_FAILED
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
printstring STRINGID_STATSWONTDECREASE2
waitmessage 0x40
goto BattleScript_MoveEnd
@ -2792,7 +2792,7 @@ BattleScript_CalmMindEnd::
BattleScript_CantRaiseMultipleStats::
pause 0x20
orbyte gBattleMoveFlags, MOVESTATUS_FAILED
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
printstring STRINGID_STATSWONTINCREASE2
waitmessage 0x40
goto BattleScript_MoveEnd
@ -2935,7 +2935,7 @@ BattleScript_82DA908::
switchinanim GBANK_1, FALSE
waitstate
switchineffects 5
jumpifbytenotequal gBank1, gNoOfAllBanks, BattleScript_82DA908
jumpifbytenotequal gBank1, gBattlersCount, BattleScript_82DA908
BattleScript_82DA92C::
end2
@ -2950,7 +2950,7 @@ BattleScript_LocalBattleWonLoseTexts::
waitstate
printstring STRINGID_TRAINER1LOSETEXT
jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_LocalBattleWonReward
trainerslideout IDENTITY_OPPONENT_MON1
trainerslideout B_POSITION_OPPONENT_LEFT
waitstate
trainerslidein GBANK_1
waitstate
@ -2991,7 +2991,7 @@ BattleScript_LocalBattleLostPrintTrainersWinText::
jumpifbattletype BATTLE_TYPE_x800000, BattleScript_LocalBattleLostDoTrainer2WinText
jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_LocalBattleLostEnd_
BattleScript_LocalBattleLostDoTrainer2WinText::
trainerslideout IDENTITY_OPPONENT_MON1
trainerslideout B_POSITION_OPPONENT_LEFT
waitstate
trainerslidein GBANK_1
waitstate
@ -3007,7 +3007,7 @@ BattleScript_82DAA0B::
trainerslidein ATTACKER
waitstate
printstring STRINGID_TRAINER1WINTEXT
trainerslideout IDENTITY_OPPONENT_MON1
trainerslideout B_POSITION_OPPONENT_LEFT
waitstate
trainerslidein GBANK_1
waitstate
@ -3035,7 +3035,7 @@ BattleScript_82DAA5C::
trainerslidein ATTACKER
waitstate
printstring STRINGID_TRAINER1LOSETEXT
trainerslideout IDENTITY_OPPONENT_MON1
trainerslideout B_POSITION_OPPONENT_LEFT
waitstate
trainerslidein GBANK_1
waitstate
@ -3058,7 +3058,7 @@ BattleScript_82DAAAE::
waitstate
printstring STRINGID_TRAINER1LOSETEXT
jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_82DAACB
trainerslideout IDENTITY_OPPONENT_MON1
trainerslideout B_POSITION_OPPONENT_LEFT
waitstate
trainerslidein GBANK_1
waitstate
@ -3228,7 +3228,7 @@ BattleScript_DamagingWeatherContinues::
playanimation2 ATTACKER, sANIM_ARG1, NULL
setbyte gBattleCommunication, 0x0
BattleScript_DamagingWeatherLoop::
copyarraywithindex gBankAttacker, gBanksByTurnOrder, gBattleCommunication, 0x1
copyarraywithindex gBattlerAttacker, gBattleTurnOrder, gBattleCommunication, 0x1
weatherdamage
jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement
printfromtable gSandStormHailDmgStringIds
@ -3243,7 +3243,7 @@ BattleScript_DamagingWeatherLoop::
BattleScript_DamagingWeatherLoopIncrement::
jumpifbyte NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamagingWeatherContinuesEnd
addbyte gBattleCommunication, 0x1
jumpifbytenotequal gBattleCommunication, gNoOfAllBanks, BattleScript_DamagingWeatherLoop
jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop
BattleScript_DamagingWeatherContinuesEnd::
bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE
end2
@ -3322,7 +3322,7 @@ BattleScript_BideAttack::
waitmessage 0x40
accuracycheck BattleScript_MoveMissed, ACC_CURR_MOVE
typecalc
bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE
bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
copyword gBattleMoveDamage, sBIDE_DMG
adjustsetdamage
setbyte sANIM_TURN, 0x1
@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway::
BattleScript_WrapFree::
printstring STRINGID_PKMNGOTFREE
waitmessage 0x40
copybyte gBankTarget, sBANK
copybyte gBattlerTarget, sBANK
return
BattleScript_LeechSeedFree::
@ -3564,16 +3564,16 @@ BattleScript_FutureAttackEnd::
moveend 0x1, 0x0
setbyte sMOVEEND_STATE, 0xB
moveend 0x2, 0xE
setbyte gBattleMoveFlags, 0
setbyte gMoveResultFlags, 0
end2
BattleScript_FutureAttackMiss::
pause 0x20
setbyte gBattleMoveFlags, 0
orbyte gBattleMoveFlags, MOVESTATUS_FAILED
setbyte gMoveResultFlags, 0
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
resultmessage
waitmessage 0x40
setbyte gBattleMoveFlags, 0
setbyte gMoveResultFlags, 0
end2
BattleScript_NoMovesLeft::
@ -4032,7 +4032,7 @@ BattleScript_WeatherFormChanges::
BattleScript_WeatherFormChangesLoop::
trycastformdatachange
addbyte sBANK, 0x1
jumpifbytenotequal sBANK, gNoOfAllBanks, BattleScript_WeatherFormChangesLoop
jumpifbytenotequal sBANK, gBattlersCount, BattleScript_WeatherFormChangesLoop
return
BattleScript_CastformChange::
@ -4053,7 +4053,7 @@ BattleScript_82DB4B8::
BattleScript_82DB4BE::
pause 0x20
BattleScript_82DB4C1::
setbyte gBankTarget, 0x0
setbyte gBattlerTarget, 0x0
setstatchanger ATK, 1, TRUE
BattleScript_82DB4CD::
trygetintimidatetarget BattleScript_82DB51B
@ -4068,7 +4068,7 @@ BattleScript_82DB4CD::
printstring STRINGID_PKMNCUTSATTACKWITH
waitmessage 0x40
BattleScript_82DB510::
addbyte gBankTarget, 0x1
addbyte gBattlerTarget, 0x1
goto BattleScript_82DB4CD
BattleScript_82DB51B::
return
@ -4117,7 +4117,7 @@ BattleScript_MoveHPDrain::
datahpupdate TARGET
printstring STRINGID_PKMNRESTOREDHPUSING
waitmessage 0x40
orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED
orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE
goto BattleScript_MoveEnd
BattleScript_MonMadeMoveUseless_PPLoss::
@ -4127,7 +4127,7 @@ BattleScript_MonMadeMoveUseless::
pause 0x20
printstring STRINGID_PKMNSXMADEYUSELESS
waitmessage 0x40
orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED
orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE
goto BattleScript_MoveEnd
BattleScript_FlashFireBoost_PPLoss::
@ -4474,7 +4474,7 @@ BattleScript_82DB887::
waitmessage 0x40
BattleScript_82DB89D::
addbyte gBattleCommunication + 1, 0x1
jumpifbytenotequal gBattleCommunication + 1, gNoOfAllBanks, BattleScript_82DB887
jumpifbytenotequal gBattleCommunication + 1, gBattlersCount, BattleScript_82DB887
setbyte gBattleCommunication, 0x0
setbyte gBattleCommunication + 1, 0x0
end2

View File

@ -4,35 +4,59 @@
// should they be included here or included individually by every file?
#include "battle_util.h"
#include "battle_script_commands.h"
#include "battle_2.h"
#include "battle_main.h"
#include "battle_ai_switch_items.h"
#include "battle_gfx_sfx_util.h"
#include "battle_util2.h"
#include "battle_bg.h"
/*
Banks are a name given to what could be called a 'battlerId' or 'monControllerId'.
Each bank has a value consisting of two bits.
0x1 bit is responsible for the side, 0 = player's side, 1 = opponent's side.
0x2 bit is responsible for the id of sent out pokemon. 0 means it's the first sent out pokemon, 1 it's the second one. (Triple battle didn't exist at the time yet.)
*/
* A battler may be in one of four positions on the field. The first bit determines
* what side the battler is on, either the player's side or the opponent's side.
* The second bit determines what flank the battler is on, either the left or right.
* Note that the opponent's flanks are drawn corresponding to their perspective, so
* their right mon appears on the left, and their left mon appears on the right.
* The battler ID is usually the same as the position, except in the case of link battles.
*
* + ------------------------- +
* | Opponent's side |
* | Right Left |
* | 3 1 |
* | |
* | Player's side |
* | Left Right |
* | 0 2 |
* ----------------------------+
* | |
* | |
* +---------------------------+
*/
#define BATTLE_BANKS_COUNT 4
#define MAX_BATTLERS_COUNT 4
#define IDENTITY_PLAYER_MON1 0
#define IDENTITY_OPPONENT_MON1 1
#define IDENTITY_PLAYER_MON2 2
#define IDENTITY_OPPONENT_MON2 3
#define B_POSITION_PLAYER_LEFT 0
#define B_POSITION_OPPONENT_LEFT 1
#define B_POSITION_PLAYER_RIGHT 2
#define B_POSITION_OPPONENT_RIGHT 3
#define SIDE_PLAYER 0x0
#define SIDE_OPPONENT 0x1
// These macros can be used with either battler ID or positions to get the partner or the opposite mon
#define BATTLE_OPPOSITE(id) ((id) ^ 1)
#define BATTLE_PARTNER(id) ((id) ^ 2)
#define BIT_SIDE 0x1
#define BIT_MON 0x2
#define B_SIDE_PLAYER 0
#define B_SIDE_OPPONENT 1
#define GET_BANK_IDENTITY(bank)((gBanksByIdentity[bank]))
#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & BIT_SIDE))
#define GET_BANK_SIDE2(bank)((GET_BANK_IDENTITY(bank) & BIT_SIDE))
#define B_FLANK_LEFT 0
#define B_FLANK_RIGHT 1
#define BIT_SIDE 1
#define BIT_FLANK 2
#define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler])
#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE)
#define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE)
// Battle Type Flags
#define BATTLE_TYPE_DOUBLE 0x0001
#define BATTLE_TYPE_LINK 0x0002
@ -66,6 +90,10 @@
#define BATTLE_TYPE_KYOGRE 0x20000000
#define BATTLE_TYPE_RAYQUAZA 0x40000000
#define BATTLE_TYPE_x80000000 0x80000000
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE)
extern u32 gBattleTypeFlags;
#define TRAINER_OPPONENT_3FE 0x3FE
#define TRAINER_OPPONENT_C00 0xC00
@ -73,56 +101,58 @@
#define STEVEN_PARTNER_ID 0xC03
#define SECRET_BASE_OPPONENT 0x400
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE)
#define B_OUTCOME_WON 0x1
#define B_OUTCOME_LOST 0x2
#define B_OUTCOME_DREW 0x3
#define B_OUTCOME_RAN 0x4
#define B_OUTCOME_PLAYER_TELEPORTED 0x5
#define B_OUTCOME_POKE_FLED 0x6
#define B_OUTCOME_CAUGHT_POKE 0x7
#define B_OUTCOME_NO_SAFARI_BALLS 0x8
#define B_OUTCOME_FORFEITED 0x9
#define B_OUTCOME_POKE_TELEPORTED 0xA
#define B_OUTCOME_LINK_BATTLE_RAN 0x80
#define BATTLE_WON 0x1
#define BATTLE_LOST 0x2
#define BATTLE_DREW 0x3
#define BATTLE_RAN 0x4
#define BATTLE_PLAYER_TELEPORTED 0x5
#define BATTLE_POKE_FLED 0x6
#define BATTLE_CAUGHT 0x7
#define BATTLE_SAFARI_OUT_OF_BALLS 0x8
#define BATTLE_FORFEITED 0x9
#define BATTLE_OPPONENT_TELEPORTED 0xA
extern u8 gBattleOutcome;
#define OUTCOME_LINK_BATTLE_RUN 0x80
// Non-volatile status conditions
// These persist remain outside of battle and after switching out
#define STATUS1_NONE 0x0
#define STATUS1_SLEEP 0x7
#define STATUS1_POISON 0x8
#define STATUS1_BURN 0x10
#define STATUS1_FREEZE 0x20
#define STATUS1_PARALYSIS 0x40
#define STATUS1_TOXIC_POISON 0x80
#define STATUS1_TOXIC_COUNTER 0xF00
#define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON)
#define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)
#define STATUS_NONE 0x0
#define STATUS_SLEEP 0x7
#define STATUS_POISON 0x8
#define STATUS_BURN 0x10
#define STATUS_FREEZE 0x20
#define STATUS_PARALYSIS 0x40
#define STATUS_TOXIC_POISON 0x80
#define STATUS_TOXIC_COUNTER 0xF00
#define STATUS_PSN_ANY ((STATUS_POISON | STATUS_TOXIC_POISON))
#define STATUS_ANY ((STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON))
#define STATUS2_CONFUSION 0x00000007
#define STATUS2_FLINCHED 0x00000008
#define STATUS2_UPROAR 0x00000070
#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200
#define STATUS2_LOCK_CONFUSE 0x00000C00
#define STATUS2_MULTIPLETURNS 0x00001000
#define STATUS2_WRAPPED 0x0000E000
#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank
#define STATUS2_INFATUATED_WITH(bank)((gBitTable[bank] << 16))
#define STATUS2_FOCUS_ENERGY 0x00100000
#define STATUS2_TRANSFORMED 0x00200000
#define STATUS2_RECHARGE 0x00400000
#define STATUS2_RAGE 0x00800000
#define STATUS2_SUBSTITUTE 0x01000000
#define STATUS2_DESTINY_BOND 0x02000000
#define STATUS2_ESCAPE_PREVENTION 0x04000000
#define STATUS2_NIGHTMARE 0x08000000
#define STATUS2_CURSED 0x10000000
#define STATUS2_FORESIGHT 0x20000000
#define STATUS2_DEFENSE_CURL 0x40000000
#define STATUS2_TORMENT 0x80000000
// Volatile status ailments
// These are removed after exiting the battle or switching out
#define STATUS2_CONFUSION 0x00000007
#define STATUS2_FLINCHED 0x00000008
#define STATUS2_UPROAR 0x00000070
#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200
#define STATUS2_LOCK_CONFUSE 0x00000C00
#define STATUS2_MULTIPLETURNS 0x00001000
#define STATUS2_WRAPPED 0x0000E000
#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16)
#define STATUS2_FOCUS_ENERGY 0x00100000
#define STATUS2_TRANSFORMED 0x00200000
#define STATUS2_RECHARGE 0x00400000
#define STATUS2_RAGE 0x00800000
#define STATUS2_SUBSTITUTE 0x01000000
#define STATUS2_DESTINY_BOND 0x02000000
#define STATUS2_ESCAPE_PREVENTION 0x04000000
#define STATUS2_NIGHTMARE 0x08000000
#define STATUS2_CURSED 0x10000000
#define STATUS2_FORESIGHT 0x20000000
#define STATUS2_DEFENSE_CURL 0x40000000
#define STATUS2_TORMENT 0x80000000
// Seems like per-battler statuses. Not quite sure how to categorize these
#define STATUS3_LEECHSEED_BANK 0x3
#define STATUS3_LEECHSEED 0x4
#define STATUS3_ALWAYS_HITS 0x18 // two bits
@ -141,8 +171,11 @@
#define STATUS3_UNDERWATER 0x40000
#define STATUS3_INTIMIDATE_POKES 0x80000
#define STATUS3_TRACE 0x100000
#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)
#define STATUS3_SEMI_INVULNERABLE ((STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER))
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
// Not really sure what a "hitmarker" is.
#define HITMARKER_x10 0x00000010
#define HITMARKER_x20 0x00000020
@ -168,8 +201,12 @@
#define HITMARKER_OBEYS 0x02000000
#define HITMARKER_x4000000 0x04000000
#define HITMARKER_x8000000 0x08000000
#define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C))
#define HITMARKER_UNK(bank) ((0x10000000 << bank))
#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 0x1C)
#define HITMARKER_UNK(battler) (0x10000000 << battler)
extern u32 gHitMarker;
// Per-side statuses that affect an entire party
#define SIDE_STATUS_REFLECT (1 << 0)
#define SIDE_STATUS_LIGHTSCREEN (1 << 1)
@ -180,49 +217,57 @@
#define SIDE_STATUS_MIST (1 << 8)
#define SIDE_STATUS_SPIKES_DAMAGED (1 << 9)
#define ACTION_USE_MOVE 0
#define ACTION_USE_ITEM 1
#define ACTION_SWITCH 2
#define ACTION_RUN 3
#define ACTION_WATCHES_CAREFULLY 4
#define ACTION_SAFARI_ZONE_BALL 5
#define ACTION_POKEBLOCK_CASE 6
#define ACTION_GO_NEAR 7
#define ACTION_SAFARI_ZONE_RUN 8
#define ACTION_9 9
#define ACTION_RUN_BATTLESCRIPT 10 // when executing an action
#define ACTION_CANCEL_PARTNER 12 // when choosing an action
#define ACTION_FINISHED 12 // when executing an action
#define ACTION_NOTHING_FAINTED 13 // when choosing an action
#define ACTION_INIT_VALUE 0xFF
extern u16 gSideStatuses[2];
#define MOVESTATUS_MISSED (1 << 0)
#define MOVESTATUS_SUPEREFFECTIVE (1 << 1)
#define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2)
#define MOVESTATUS_NOTAFFECTED (1 << 3)
#define MOVESTATUS_ONEHITKO (1 << 4)
#define MOVESTATUS_FAILED (1 << 5)
#define MOVESTATUS_ENDURED (1 << 6)
#define MOVESTATUS_HUNGON (1 << 7)
// Battle Actions
// These determine what each battler will do in a turn
#define B_ACTION_USE_MOVE 0
#define B_ACTION_USE_ITEM 1
#define B_ACTION_SWITCH 2
#define B_ACTION_RUN 3
#define B_ACTION_SAFARI_WATCH_CAREFULLY 4
#define B_ACTION_SAFARI_BALL 5
#define B_ACTION_SAFARI_POKEBLOCK 6
#define B_ACTION_SAFARI_GO_NEAR 7
#define B_ACTION_SAFARI_RUN 8
// The exact purposes of these are unclear
#define B_ACTION_UNKNOWN9 9
#define B_ACTION_EXEC_SCRIPT 10 // when executing an action
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_FINISHED 12 // when executing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF
#define MOVESTATUS_NOEFFECT ((MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED))
#define MOVE_RESULT_MISSED (1 << 0)
#define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1)
#define MOVE_RESULT_NOT_VERY_EFFECTIVE (1 << 2)
#define MOVE_RESULT_DOESNT_AFFECT_FOE (1 << 3)
#define MOVE_RESULT_ONE_HIT_KO (1 << 4)
#define MOVE_RESULT_FAILED (1 << 5)
#define MOVE_RESULT_FOE_ENDURED (1 << 6)
#define MOVE_RESULT_FOE_HUNG_ON (1 << 7)
#define MOVE_RESULT_NO_EFFECT (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED)
#define MAX_TRAINER_ITEMS 4
#define MAX_MON_MOVES 4
// Battle Weather flags
#define WEATHER_RAIN_TEMPORARY (1 << 0)
#define WEATHER_RAIN_DOWNPOUR (1 << 1)
#define WEATHER_RAIN_DOWNPOUR (1 << 1) // unused
#define WEATHER_RAIN_PERMANENT (1 << 2)
#define WEATHER_RAIN_ANY ((WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT))
#define WEATHER_RAIN_ANY (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT)
#define WEATHER_SANDSTORM_TEMPORARY (1 << 3)
#define WEATHER_SANDSTORM_PERMANENT (1 << 4)
#define WEATHER_SANDSTORM_ANY ((WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT))
#define WEATHER_SANDSTORM_ANY (WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT)
#define WEATHER_SUN_TEMPORARY (1 << 5)
#define WEATHER_SUN_PERMANENT (1 << 6)
#define WEATHER_SUN_ANY ((WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT))
#define WEATHER_SUN_ANY (WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT)
#define WEATHER_HAIL (1 << 7)
#define WEATHER_HAIL_ANY ((WEATHER_HAIL))
#define WEATHER_ANY ((WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY))
#define WEATHER_HAIL_ANY (WEATHER_HAIL)
#define WEATHER_ANY (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)
extern u16 gBattleWeather;
#define BATTLE_TERRAIN_GRASS 0
#define BATTLE_TERRAIN_LONG_GRASS 1
@ -235,6 +280,8 @@
#define BATTLE_TERRAIN_BUILDING 8
#define BATTLE_TERRAIN_PLAIN 9
extern u8 gBattleTerrain;
// array entries for battle communication
#define MULTIUSE_STATE 0x0
#define CURSOR_POSITION 0x1
@ -299,7 +346,7 @@ struct TrainerMonNoItemDefaultMoves
u16 species;
};
u8 GetBankSide(u8 bank);
u8 GetBattlerSide(u8 battler);
struct TrainerMonItemDefaultMoves
{
@ -382,8 +429,8 @@ struct DisableStruct
/*0x12*/ u8 chargeTimer2 : 4;
/*0x13*/ u8 tauntTimer1:4;
/*0x13*/ u8 tauntTimer2:4;
/*0x14*/ u8 bankPreventingEscape;
/*0x15*/ u8 bankWithSureHit;
/*0x14*/ u8 battlerPreventingEscape;
/*0x15*/ u8 battlerWithSureHit;
/*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter : 1;
@ -394,7 +441,7 @@ struct DisableStruct
/*0x1A*/ u8 unk1A[2];
};
extern struct DisableStruct gDisableStructs[BATTLE_BANKS_COUNT];
extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT];
struct ProtectStruct
{
@ -434,7 +481,7 @@ struct ProtectStruct
/* field_E */ u16 fieldE;
};
extern struct ProtectStruct gProtectStructs[BATTLE_BANKS_COUNT];
extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT];
struct SpecialStatus
{
@ -456,7 +503,7 @@ struct SpecialStatus
u8 field13;
};
extern struct SpecialStatus gSpecialStatuses[BATTLE_BANKS_COUNT];
extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT];
struct SideTimer
{
@ -478,12 +525,12 @@ extern struct SideTimer gSideTimers[];
struct WishFutureKnock
{
u8 futureSightCounter[BATTLE_BANKS_COUNT];
u8 futureSightAttacker[BATTLE_BANKS_COUNT];
s32 futureSightDmg[BATTLE_BANKS_COUNT];
u16 futureSightMove[BATTLE_BANKS_COUNT];
u8 wishCounter[BATTLE_BANKS_COUNT];
u8 wishUserID[BATTLE_BANKS_COUNT];
u8 futureSightCounter[MAX_BATTLERS_COUNT];
u8 futureSightAttacker[MAX_BATTLERS_COUNT];
s32 futureSightDmg[MAX_BATTLERS_COUNT];
u16 futureSightMove[MAX_BATTLERS_COUNT];
u8 wishCounter[MAX_BATTLERS_COUNT];
u8 wishUserID[MAX_BATTLERS_COUNT];
u8 weatherDuration;
u8 knockedOffPokes[2];
};
@ -506,16 +553,16 @@ struct AI_ThinkingStruct
struct UsedMoves
{
u16 moves[BATTLE_BANKS_COUNT];
u16 unknown[BATTLE_BANKS_COUNT];
u16 moves[MAX_BATTLERS_COUNT];
u16 unknown[MAX_BATTLERS_COUNT];
};
struct BattleHistory
{
struct UsedMoves usedMoves[BATTLE_BANKS_COUNT];
u8 abilities[BATTLE_BANKS_COUNT];
u8 itemEffects[BATTLE_BANKS_COUNT];
u16 trainerItems[BATTLE_BANKS_COUNT];
struct UsedMoves usedMoves[MAX_BATTLERS_COUNT];
u8 abilities[MAX_BATTLERS_COUNT];
u8 itemEffects[MAX_BATTLERS_COUNT];
u16 trainerItems[MAX_BATTLERS_COUNT];
u8 itemsNo;
};
@ -555,10 +602,6 @@ struct BattleResources
extern struct BattleResources* gBattleResources;
#define BATTLESCRIPTS_STACK (gBattleResources->battleScriptsStack)
#define BATTLE_CALLBACKS_STACK (gBattleResources->battleCallbackStack)
#define BATTLE_LVLUP_STATS (gBattleResources->statsBeforeLvlUp)
struct BattleResults
{
u8 playerFaintCounter; // 0x0
@ -621,9 +664,9 @@ struct BattleStruct
u16 expValue;
u8 field_52;
u8 sentInPokes;
bool8 selectionScriptFinished[BATTLE_BANKS_COUNT];
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
u8 field_58[4];
u8 monToSwitchIntoId[BATTLE_BANKS_COUNT];
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 field_60[4][3];
u8 runTries;
u8 caughtMonNick[11];
@ -635,8 +678,8 @@ struct BattleStruct
u8 field_7D;
u8 field_7E;
u8 formToChangeInto;
u8 chosenMovePositions[BATTLE_BANKS_COUNT];
u8 stateIdAfterSelScript[BATTLE_BANKS_COUNT];
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
u8 field_88;
u8 field_89;
u8 field_8A;
@ -669,12 +712,12 @@ struct BattleStruct
u8 synchronizeMoveEffect;
u8 field_B3;
void (*savedCallback)(void);
u16 usedHeldItems[BATTLE_BANKS_COUNT];
u16 usedHeldItems[MAX_BATTLERS_COUNT];
u8 chosenItem[4]; // why is this an u8?
u8 AI_itemType[2];
u8 AI_itemFlags[2];
u16 choicedMove[BATTLE_BANKS_COUNT];
u16 changedItems[BATTLE_BANKS_COUNT];
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
u8 intimidateBank;
u8 switchInItemsCounter;
u8 field_DA;
@ -682,7 +725,7 @@ struct BattleStruct
u8 fillerDC[0xDF-0xDC];
u8 field_DF;
u8 mirrorMoveArrays[32];
u16 castformPalette[BATTLE_BANKS_COUNT][16];
u16 castformPalette[MAX_BATTLERS_COUNT][16];
u8 field_180;
u8 field_181;
u8 field_182;
@ -695,7 +738,7 @@ struct BattleStruct
u8 field_1A4[96];
u8 field_204[104];
u8 field_26C[40];
u8 AI_monToSwitchIntoId[BATTLE_BANKS_COUNT];
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 field_298[8];
u8 field_2A0;
u8 field_2A1;
@ -797,9 +840,9 @@ struct BattleScripting
u8 animArg2;
u16 tripleKickPower;
u8 atk49_state;
u8 bankWithAbility;
u8 battlerWithAbility;
u8 multihitMoveEffect;
u8 bank;
u8 battler;
u8 animTurn;
u8 animTargetsHit;
u8 statChanger;
@ -831,9 +874,9 @@ enum
};
// rom_80A5C6C
u8 GetBankSide(u8 bank);
u8 GetBankIdentity(u8 bank);
u8 GetBankByIdentity(u8 bank);
u8 GetBattlerSide(u8 bank);
u8 GetBattlerPosition(u8 bank);
u8 GetBattlerAtPosition(u8 bank);
struct BattleSpriteInfo
{
@ -907,7 +950,7 @@ struct BattleBarInfo
struct BattleSpriteData
{
struct BattleSpriteInfo *bankData;
struct BattleSpriteInfo *battlerData;
struct BattleHealthboxInfo *healthBoxesData;
struct BattleAnimationInfo *animationData;
struct BattleBarInfo *battleBars;

View File

@ -4,9 +4,9 @@
void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves);
void BattleAI_SetupAIData(u8 defaultScoreMoves);
u8 BattleAI_ChooseMoveOrAction(void);
void ClearBankMoveHistory(u8 bank);
void ClearBattlerMoveHistory(u8 bank);
void RecordAbilityBattle(u8 bank, u8 abilityId);
void ClearBankAbilityHistory(u8 bank);
void ClearBattlerAbilityHistory(u8 bank);
void RecordItemEffectBattle(u8 bank, u8 itemEffect);
void ClearBankItemEffectHistory(u8 bank);

View File

@ -45,9 +45,9 @@ extern u8 gAnimFriendship;
extern u16 gWeatherMoveAnim;
extern s16 gBattleAnimArgs[ANIM_ARGS_COUNT];
extern u8 gAnimMoveTurn;
extern u8 gAnimBankAttacker;
extern u8 gAnimBankTarget;
extern u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT];
extern u8 gBattleAnimAttacker;
extern u8 gBattleAnimTarget;
extern u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT];
extern u8 gUnknown_02038440;
void ClearBattleAnimationVars(void);
@ -56,7 +56,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
void DestroyAnimSprite(struct Sprite *sprite);
void DestroyAnimVisualTask(u8 taskId);
void DestroyAnimSoundTask(u8 taskId);
bool8 IsAnimBankSpriteVisible(u8 bank);
bool8 IsBattlerSpriteVisible(u8 bank);
void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible);
bool8 IsContest(void);
s8 BattleAnimAdjustPanning(s8 pan);
@ -85,17 +85,17 @@ enum
BANK_Y_POS,
};
u8 GetBankPosition(u8 bank, u8 attributeId);
u8 GetBattlerSpriteCoord(u8 bank, u8 attributeId);
bool8 IsBankSpritePresent(u8 bank);
bool8 IsBattlerSpritePresent(u8 bank);
void sub_80A6C68(u8 arg0);
u8 GetAnimBankSpriteId(u8 wantedBank);
u8 GetAnimBattlerSpriteId(u8 wantedBank);
bool8 IsDoubleBattle(void);
u8 sub_80A6D94(void);
u8 sub_80A8364(u8);
void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*));
void oamt_add_pos2_onto_pos1(struct Sprite *sprite);
u8 GetBankSpriteDefault_Y(u8 bank);
u8 GetBattlerSpriteDefault_Y(u8 bank);
u8 sub_80A82E4(u8 bank);
u8 GetSubstituteSpriteDefault_Y(u8 bank);

View File

@ -181,62 +181,62 @@ void sub_8033648(void);
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);
// emitters
void EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck);
void EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes); // unused
void EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused
void EmitLoadMonSprite(u8 bufferId);
void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void EmitReturnMonToBall(u8 bufferId, u8 arg1);
void EmitDrawTrainerPic(u8 bufferId);
void EmitTrainerSlide(u8 bufferId);
void EmitTrainerSlideBack(u8 bufferId);
void EmitFaintAnimation(u8 bufferId);
void EmitPaletteFade(u8 bufferId); // unused
void EmitSuccessBallThrowAnim(u8 bufferId); // unused
void EmitBallThrowAnim(u8 bufferId, u8 caseId);
void EmitPause(u8 bufferId, u8 toWait, void *data); // unused
void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
void EmitPrintString(u8 bufferId, u16 stringId);
void EmitPrintSelectionString(u8 bufferId, u16 stringId);
void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2);
void EmitUnknownYesNoBox(u8 bufferId);
void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void EmitChooseItem(u8 bufferId, u8* arg1);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4);
void EmitCmd23(u8 bufferId); // unused
void EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
void EmitStatusXor(u8 bufferId, u8 b); // unused
void EmitDataTransfer(u8 bufferId, u16 size, void *data);
void EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused
void EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused
void EmitCmd32(u8 bufferId, u16 size, void *c); // unused
void EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2);
void EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c);
void EmitOneReturnValue(u8 bufferId, u16 arg1);
void EmitOneReturnValue_Duplicate(u8 bufferId, u16 b);
void EmitCmd37(u8 bufferId); // unused
void EmitCmd38(u8 bufferId, u8 b); // unused
void EmitCmd39(u8 bufferId); // unused
void EmitCmd40(u8 bufferId); // unused
void EmitHitAnimation(u8 bufferId);
void EmitCmd42(u8 bufferId);
void EmitPlaySE(u8 bufferId, u16 songId);
void EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM);
void EmitFaintingCry(u8 bufferId);
void EmitIntroSlide(u8 bufferId, u8 terrainId);
void EmitIntroTrainerBallThrow(u8 bufferId);
void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2);
void EmitCmd49(u8 bufferId);
void EmitCmd50(u8 bufferId);
void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2);
void EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void EmitCmd55(u8 bufferId, u8 arg1);
void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck);
void BtlController_EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes); // unused
void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused
void BtlController_EmitLoadMonSprite(u8 bufferId);
void BtlController_EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void BtlController_EmitReturnMonToBall(u8 bufferId, u8 arg1);
void BtlController_EmitDrawTrainerPic(u8 bufferId);
void BtlController_EmitTrainerSlide(u8 bufferId);
void BtlController_EmitTrainerSlideBack(u8 bufferId);
void BtlController_EmitFaintAnimation(u8 bufferId);
void BtlController_EmitPaletteFade(u8 bufferId); // unused
void BtlController_EmitSuccessBallThrowAnim(u8 bufferId); // unused
void BtlController_EmitBallThrowAnim(u8 bufferId, u8 caseId);
void BtlController_EmitPause(u8 bufferId, u8 toWait, void *data); // unused
void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
void BtlController_EmitPrintString(u8 bufferId, u16 stringId);
void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId);
void BtlController_EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2);
void BtlController_EmitUnknownYesNoBox(u8 bufferId);
void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void BtlController_EmitChooseItem(u8 bufferId, u8* arg1);
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4);
void BtlController_EmitCmd23(u8 bufferId); // unused
void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void BtlController_EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
void BtlController_EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
void BtlController_EmitStatusXor(u8 bufferId, u8 b); // unused
void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data);
void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused
void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused
void BtlController_EmitCmd32(u8 bufferId, u16 size, void *c); // unused
void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2);
void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c);
void BtlController_EmitOneReturnValue(u8 bufferId, u16 arg1);
void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 b);
void BtlController_EmitCmd37(u8 bufferId); // unused
void BtlController_EmitCmd38(u8 bufferId, u8 b); // unused
void BtlController_EmitCmd39(u8 bufferId); // unused
void BtlController_EmitCmd40(u8 bufferId); // unused
void BtlController_EmitHitAnimation(u8 bufferId);
void BtlController_EmitCmd42(u8 bufferId);
void BtlController_EmitPlaySE(u8 bufferId, u16 songId);
void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM);
void BtlController_EmitFaintingCry(u8 bufferId);
void BtlController_EmitIntroSlide(u8 bufferId, u8 terrainId);
void BtlController_EmitIntroTrainerBallThrow(u8 bufferId);
void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2);
void BtlController_EmitCmd49(u8 bufferId);
void BtlController_EmitCmd50(u8 bufferId);
void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2);
void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void BtlController_EmitCmd55(u8 bufferId, u8 arg1);
// player controller
void SetControllerToPlayer(void);

View File

@ -39,8 +39,8 @@ void sub_805EAE8(void);
void sub_805EB9C(u8 affineMode);
void LoadAndCreateEnemyShadowSprites(void);
void SpriteCB_SetInvisible(struct Sprite *sprite);
void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species);
void EnemyShadowCallbackToSetInvisible(u8 bank);
void SetBattlerShadowSpriteCallback(u8 bank, u16 species);
void HideBattlerShadowSprite(u8 bank);
void sub_805EF14(void);
void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute);
void AllocateMonSpritesGfx(void);

View File

@ -54,7 +54,7 @@ enum
HEALTHBOX_SAFARI_BALLS_TEXT
};
u8 CreateBankHealthboxSprites(u8 bank);
u8 CreateBattlerHealthboxSprites(u8 bank);
u8 CreateSafariPlayerHealthboxSprites(void);
void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue);
void SetHealthboxSpriteInvisible(u8 healthboxSpriteId);
@ -62,7 +62,7 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId);
void DestoryHealthboxSprite(u8 healthboxSpriteId);
void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly);
void UpdateOamPriorityInAllHealthboxes(u8 priority);
void SetBankHealthboxSpritePos(u8 bank);
void InitBattlerHealthboxCoords(u8 bank);
void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent);
void SwapHpBarsWithHpText(void);
u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart);

View File

@ -6,6 +6,6 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct
void sub_817E32C(u8 animationId);
void sub_817E3F4(void);
void sub_817F2A8(void);
u8 GetBankMoveSlotId(u8 bank, u16 move);
u8 GetBattlerMoveSlotId(u8 bank, u16 move);
#endif // GUARD_BATTLE_LINK_817C95C_H

View File

@ -1,5 +1,5 @@
#ifndef GUARD_BATTLE_2_H
#define GUARD_BATTLE_2_H
#ifndef GUARD_BATTLE_MAIN_H
#define GUARD_BATTLE_MAIN_H
void CB2_InitBattle(void);
void BattleMainCB2(void);
@ -52,4 +52,4 @@ extern const u8 gStatusConditionString_LoveJpn[8];
extern const u8 * const gStatusConditionStringsTable[7][2];
#endif // GUARD_BATTLE_2_H
#endif // GUARD_BATTLE_MAIN_H

View File

@ -52,7 +52,7 @@
void AI_CalcDmg(u8 bankAtk, u8 bankDef);
u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef);
u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility);
u8 BankGetTurnOrder(u8 bank);
u8 GetBattlerTurnOrderNum(u8 bank);
void SetMoveEffect(bool8 primary, u8 certain);
void BattleDestroyYesNoCursorAt(u8 cursorPosition);
void BattleCreateYesNoCursorAt(u8 cursorPosition);

View File

@ -48,8 +48,8 @@ u8 GetBattleBank(u8 caseId);
void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 bankAtk);
void PressurePPLoseOnUsingImprision(u8 bankAtk);
void MarkAllBufferBanksForExecution(void); // unused
void MarkBufferBankForExecution(u8 bank);
void MarkAllBattlersForControllerExec(void); // unused
void MarkBattlerForControllerExec(u8 bank);
void sub_803F850(u8 arg0);
void CancelMultiTurnMoves(u8 bank);
bool8 WasUnableToUseMove(u8 bank);

View File

@ -630,7 +630,7 @@ bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);
void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies);
bool8 IsTradedMon(struct Pokemon *mon);
void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality);
s32 GetBankMultiplayerId(u16 a1);
s32 GetBattlerMultiplayerId(u16 a1);
bool16 sub_806D82C(u8 id);
u16 MonTryLearningNewMove(struct Pokemon* mon, bool8);
void sub_8068AA4(void); // sets stats for deoxys

View File

@ -7,9 +7,9 @@ extern u8 gUnknown_0203C7B4;
void sub_8184DA4(u8 arg0);
void sub_8184E58(void);
void RecordedBattle_SetBankAction(u8 bank, u8 action);
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear);
u8 RecordedBattle_ReadBankAction(u8 bank);
void RecordedBattle_SetBattlerAction(u8 bank, u8 action);
void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear);
u8 RecordedBattle_GetBattlerAction(u8 bank);
u8 sub_81850D0(void);
u8 sub_81850DC(u8 *arg0);
void sub_81851A8(u8 *arg0);

View File

@ -59,7 +59,7 @@ SECTIONS {
src/decompress.o(.text);
asm/rom_8034C54.o(.text);
src/battle_bg.o(.text);
src/battle_2.o(.text);
src/battle_main.o(.text);
src/battle_util.o(.text);
src/battle_script_commands.o(.text);
src/battle_util2.o(.text);
@ -377,7 +377,7 @@ SECTIONS {
data/main_menu.o(.rodata);
data/battle_1.o(.rodata);
data/data2b.o(.rodata);
src/battle_2.o(.rodata);
src/battle_main.o(.rodata);
src/battle_util.o(.rodata);
src/battle_script_commands.o(.rodata);
src/battle_controller_player.o(.rodata);

View File

@ -45,19 +45,19 @@ AI scripts.
*/
extern u32 gBattleTypeFlags;
extern u8 gActiveBank;
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u8 gActiveBattler;
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gCurrentMove;
extern u8 gBankTarget;
extern u8 gAbsentBankFlags;
extern u16 gLastMoves[BATTLE_BANKS_COUNT];
extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags;
extern u16 gLastMoves[MAX_BATTLERS_COUNT];
extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B;
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
extern u16 gSideAffecting[2];
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern u16 gSideStatuses[2];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u16 gDynamicBasePower;
extern u8 gBattleMoveFlags;
extern u8 gMoveResultFlags;
extern s32 gBattleMoveDamage;
extern u8 gCritMultiplier;
extern u16 gBattleWeather;
@ -179,7 +179,7 @@ static void BattleAICmd_if_holds_item(void);
// ewram
EWRAM_DATA const u8 *gAIScriptPtr = NULL;
EWRAM_DATA static u8 sBank_AI = 0;
EWRAM_DATA static u8 sBattler_AI = 0;
// const rom data
@ -352,7 +352,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
defaultScoreMoves >>= 1;
}
moveLimitations = CheckMoveLimitations(gActiveBank, 0, 0xFF);
moveLimitations = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
// ignore moves that aren't possible to use
for (i = 0; i < 4; i++)
@ -363,18 +363,18 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16);
}
gBattleResources->AI_ScriptsStack->size = 0;
sBank_AI = gActiveBank;
sBattler_AI = gActiveBattler;
// decide a random target bank in doubles
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
gBankTarget = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE);
if (gAbsentBankFlags & gBitTable[gBankTarget])
gBankTarget ^= BIT_MON;
gBattlerTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattlerTarget ^= BIT_FLANK;
}
// in singles there's only one choice
else
{
gBankTarget = sBank_AI ^ BIT_SIDE;
gBattlerTarget = sBattler_AI ^ BIT_SIDE;
}
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -444,7 +444,7 @@ static u8 BattleAI_ChooseMoveOrAction_Singles(void)
for (i = 1; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason.
if (gBattleMons[sBattler_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason.
{
// in ruby, the order of these if statements are reversed.
if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i])
@ -479,7 +479,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
for (i = 0; i < 4; i++)
{
if (i == sBank_AI || gBattleMons[i].hp == 0)
if (i == sBattler_AI || gBattleMons[i].hp == 0)
{
actionOrMoveIndex[i] = -1;
bestMovePointsForTarget[i] = -1;
@ -491,9 +491,9 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
else
BattleAI_SetupAIData(0xF);
gBankTarget = i;
gBattlerTarget = i;
if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE))
if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE))
RecordLastUsedMoveByTarget();
AI_THINKING_STRUCT->aiLogicId = 0;
@ -521,7 +521,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
mostViableMovesNo = 1;
for (j = 1; j < 4; j++)
{
if (gBattleMons[sBank_AI].moves[j] != 0)
if (gBattleMons[sBattler_AI].moves[j] != 0)
{
if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j])
{
@ -542,7 +542,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
bestMovePointsForTarget[i] = mostViableMovesScores[0];
// don't use a move against ally if it has less than 100 pts
if (i == (sBank_AI ^ BIT_MON) && bestMovePointsForTarget[i] < 100)
if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100)
{
bestMovePointsForTarget[i] = -1;
mostViableMovesScores[0] = mostViableMovesScores[0]; // needed to match
@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
}
}
gBankTarget = mostViableTargetsArray[Random() % mostViableTargetsNo];
return actionOrMoveIndex[gBankTarget];
gBattlerTarget = mostViableTargetsArray[Random() % mostViableTargetsNo];
return actionOrMoveIndex[gBattlerTarget];
}
static void BattleAI_DoAIProcessing(void)
@ -587,13 +587,13 @@ static void BattleAI_DoAIProcessing(void)
break;
case AIState_SettingUp:
gAIScriptPtr = gBattleAI_ScriptsTable[AI_THINKING_STRUCT->aiLogicId]; // set AI ptr to logic ID.
if (gBattleMons[sBank_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
if (gBattleMons[sBattler_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
{
AI_THINKING_STRUCT->moveConsidered = 0;
}
else
{
AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBank_AI].moves[AI_THINKING_STRUCT->movesetIndex];
AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBattler_AI].moves[AI_THINKING_STRUCT->movesetIndex];
}
AI_THINKING_STRUCT->aiState++;
break;
@ -627,18 +627,18 @@ static void RecordLastUsedMoveByTarget(void)
for (i = 0; i < 4; i++)
{
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gLastMoves[gBankTarget])
if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget])
break;
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gLastMoves[gBankTarget] // HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == 0)
if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == 0)
{
gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gLastMoves[gBankTarget];
gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget];
break;
}
}
}
void ClearBankMoveHistory(u8 bank)
void ClearBattlerMoveHistory(u8 bank)
{
s32 i;
@ -651,7 +651,7 @@ void RecordAbilityBattle(u8 bank, u8 abilityId)
gBattleResources->battleHistory->abilities[bank] = abilityId;
}
void ClearBankAbilityHistory(u8 bank)
void ClearBattlerAbilityHistory(u8 bank)
{
gBattleResources->battleHistory->abilities[bank] = 0;
}
@ -721,9 +721,9 @@ static void BattleAICmd_if_hp_less_than(void)
u16 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -736,9 +736,9 @@ static void BattleAICmd_if_hp_more_than(void)
u16 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -751,9 +751,9 @@ static void BattleAICmd_if_hp_equal(void)
u16 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -766,9 +766,9 @@ static void BattleAICmd_if_hp_not_equal(void)
u16 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -782,9 +782,9 @@ static void BattleAICmd_if_status(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -800,9 +800,9 @@ static void BattleAICmd_if_not_status(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -818,9 +818,9 @@ static void BattleAICmd_if_status2(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -836,9 +836,9 @@ static void BattleAICmd_if_not_status2(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -854,9 +854,9 @@ static void BattleAICmd_if_status3(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -872,9 +872,9 @@ static void BattleAICmd_if_not_status3(void)
u32 status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
@ -890,14 +890,14 @@ static void BattleAICmd_if_side_affecting(void)
u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
side = GET_BANK_SIDE(bank);
side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2);
if ((gSideAffecting[side] & status) != 0)
if ((gSideStatuses[side] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@ -909,14 +909,14 @@ static void BattleAICmd_if_not_side_affecting(void)
u32 side, status;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
side = GET_BANK_SIDE(bank);
side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2);
if ((gSideAffecting[side] & status) == 0)
if ((gSideStatuses[side] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@ -1084,8 +1084,8 @@ static void BattleAICmd_if_user_has_attacking_move(void)
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0)
if (gBattleMons[sBattler_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
break;
}
if (i == 4)
@ -1100,8 +1100,8 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void)
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0)
if (gBattleMons[sBattler_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
break;
}
if (i != 4)
@ -1123,16 +1123,16 @@ static void BattleAICmd_get_type(void)
switch (typeVar)
{
case AI_TYPE1_USER: // AI user primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1;
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1;
break;
case AI_TYPE1_TARGET: // target primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1;
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1;
break;
case AI_TYPE2_USER: // AI user secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2;
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2;
break;
case AI_TYPE2_TARGET: // target secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2;
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2;
break;
case AI_TYPE_MOVE: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
@ -1146,14 +1146,14 @@ static u8 BattleAI_GetWantedBank(u8 bank)
switch (bank)
{
case AI_USER:
return sBank_AI;
return sBattler_AI;
case AI_TARGET:
default:
return gBankTarget;
return gBattlerTarget;
case AI_USER_PARTNER:
return sBank_AI ^ BIT_MON;
return sBattler_AI ^ BIT_FLANK;
case AI_TARGET_PARTNER:
return gBankTarget ^ BIT_MON;
return gBattlerTarget ^ BIT_FLANK;
}
}
@ -1196,24 +1196,24 @@ static void BattleAICmd_get_how_powerful_move_is(void)
gDynamicBasePower = 0;
*(&gBattleStruct->dynamicMoveType) = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
for (checkedMove = 0; checkedMove < 4; checkedMove++)
{
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
{
if (gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
break;
}
if (gBattleMons[sBank_AI].moves[checkedMove] != MOVE_NONE
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
&& gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1)
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
{
gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove];
AI_CalcDmg(sBank_AI, gBankTarget);
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
if (moveDmgs[checkedMove] == 0)
moveDmgs[checkedMove] = 1;
@ -1246,9 +1246,9 @@ static void BattleAICmd_get_how_powerful_move_is(void)
static void BattleAICmd_get_last_used_bank_move(void)
{
if (gAIScriptPtr[1] == AI_USER)
AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI];
AI_THINKING_STRUCT->funcResult = gLastMoves[sBattler_AI];
else
AI_THINKING_STRUCT->funcResult = gLastMoves[gBankTarget];
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerTarget];
gAIScriptPtr += 2;
}
@ -1271,7 +1271,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
static void BattleAICmd_if_user_goes(void)
{
if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) == gAIScriptPtr[1])
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
@ -1279,7 +1279,7 @@ static void BattleAICmd_if_user_goes(void)
static void BattleAICmd_if_user_doesnt_go(void)
{
if (GetWhoStrikesFirst(sBank_AI, gBankTarget, TRUE) != gAIScriptPtr[1])
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
@ -1303,26 +1303,26 @@ static void BattleAICmd_count_usable_party_mons(void)
AI_THINKING_STRUCT->funcResult = 0;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u32 identity;
bankOnField1 = gBattlePartyID[bank];
identity = GetBankIdentity(bank) ^ BIT_MON;
bankOnField2 = gBattlePartyID[GetBankByIdentity(identity)];
u32 position;
bankOnField1 = gBattlerPartyIndexes[bank];
position = GetBattlerPosition(bank) ^ BIT_FLANK;
bankOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(position)];
}
else // in singles there's only one bank by side
{
bankOnField1 = gBattlePartyID[bank];
bankOnField2 = gBattlePartyID[bank];
bankOnField1 = gBattlerPartyIndexes[bank];
bankOnField2 = gBattlerPartyIndexes[bank];
}
for (i = 0; i < PARTY_SIZE; i++)
@ -1356,11 +1356,11 @@ static void BattleAICmd_get_ability(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gActiveBank != bank)
if (gActiveBattler != bank)
{
if (BATTLE_HISTORY->abilities[bank] != 0)
{
@ -1482,18 +1482,18 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
dynamicMoveType = &gBattleStruct->dynamicMoveType;
*dynamicMoveType = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
AI_THINKING_STRUCT->funcResult = 0;
for (i = 0; i < 4; i++)
{
gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = gBattleMons[sBank_AI].moves[i];
gCurrentMove = gBattleMons[sBattler_AI].moves[i];
if (gCurrentMove)
{
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
// reduce by 1/3.
if (gBattleMoveDamage == 120)
@ -1505,7 +1505,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
if (gBattleMoveDamage == 15)
gBattleMoveDamage = AI_EFFECTIVENESS_x0_25;
if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED)
if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE)
gBattleMoveDamage = AI_EFFECTIVENESS_x0;
if (AI_THINKING_STRUCT->funcResult < gBattleMoveDamage)
@ -1522,13 +1522,13 @@ static void BattleAICmd_if_type_effectiveness(void)
gDynamicBasePower = 0;
gBattleStruct->dynamicMoveType = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
if (gBattleMoveDamage == 120)
gBattleMoveDamage = AI_EFFECTIVENESS_x2;
@ -1539,7 +1539,7 @@ static void BattleAICmd_if_type_effectiveness(void)
if (gBattleMoveDamage == 15)
gBattleMoveDamage = AI_EFFECTIVENESS_x0_25;
if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED)
if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE)
gBattleMoveDamage = AI_EFFECTIVENESS_x0;
// store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8.
@ -1569,14 +1569,14 @@ static void BattleAICmd_if_status_in_party(void)
switch(gAIScriptPtr[1])
{
case AI_USER:
bank = sBank_AI;
bank = sBattler_AI;
break;
default:
bank = gBankTarget;
bank = gBattlerTarget;
break;
}
party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@ -1606,14 +1606,14 @@ static void BattleAICmd_if_status_not_in_party(void)
switch(gAIScriptPtr[1])
{
case 1:
bank = sBank_AI;
bank = sBattler_AI;
break;
default:
bank = gBankTarget;
bank = gBattlerTarget;
break;
}
party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@ -1667,9 +1667,9 @@ static void BattleAICmd_if_stat_level_less_than(void)
u32 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1682,9 +1682,9 @@ static void BattleAICmd_if_stat_level_more_than(void)
u32 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1697,9 +1697,9 @@ static void BattleAICmd_if_stat_level_equal(void)
u32 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1712,9 +1712,9 @@ static void BattleAICmd_if_stat_level_not_equal(void)
u32 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1733,11 +1733,11 @@ static void BattleAICmd_if_can_faint(void)
gDynamicBasePower = 0;
gBattleStruct->dynamicMoveType = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBankTarget);
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
@ -1745,7 +1745,7 @@ static void BattleAICmd_if_can_faint(void)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
if (gBattleMons[gBankTarget].hp <= gBattleMoveDamage)
if (gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -1762,17 +1762,17 @@ static void BattleAICmd_if_cant_faint(void)
gDynamicBasePower = 0;
gBattleStruct->dynamicMoveType = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBankTarget);
TypeCalc(gCurrentMove, sBank_AI, gBankTarget);
AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
// this macro is missing the damage 0 = 1 assumption.
if (gBattleMons[gBankTarget].hp > gBattleMoveDamage)
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -1788,7 +1788,7 @@ static void BattleAICmd_if_has_move(void)
case AI_USER:
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] == *movePtr)
if (gBattleMons[sBattler_AI].moves[i] == *movePtr)
break;
}
if (i == 4)
@ -1802,7 +1802,7 @@ static void BattleAICmd_if_has_move(void)
return;
}
case AI_USER_PARTNER:
if (gBattleMons[sBank_AI ^ BIT_MON].hp == 0)
if (gBattleMons[sBattler_AI ^ BIT_FLANK].hp == 0)
{
gAIScriptPtr += 8;
return;
@ -1811,7 +1811,7 @@ static void BattleAICmd_if_has_move(void)
{
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI ^ BIT_MON].moves[i] == *movePtr)
if (gBattleMons[sBattler_AI ^ BIT_FLANK].moves[i] == *movePtr)
break;
}
}
@ -1829,7 +1829,7 @@ static void BattleAICmd_if_has_move(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr)
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr)
break;
}
if (i == 4)
@ -1856,7 +1856,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
case AI_USER_PARTNER: // UB: no separate check for user partner
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] == *movePtr)
if (gBattleMons[sBattler_AI].moves[i] == *movePtr)
break;
}
if (i != 4)
@ -1873,7 +1873,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *movePtr)
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr)
break;
}
if (i != 4)
@ -1899,7 +1899,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
case AI_USER_PARTNER:
for (i = 0; i < 4; i++)
{
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2])
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i == 4)
@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
// UB: checks sBank_AI instead of gBankTarget
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2])
// UB: checks sBattler_AI instead of gBattlerTarget
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i == 4)
@ -1933,7 +1933,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
case AI_USER_PARTNER:
for (i = 0; i < 4; i++)
{
if(gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2])
if(gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i != 4)
@ -1945,7 +1945,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++)
{
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2])
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i != 4)
@ -1961,9 +1961,9 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gAIScriptPtr[2] == 0)
{
@ -1993,7 +1993,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
switch (gAIScriptPtr[1])
{
case 0:
if (gDisableStructs[gActiveBank].disabledMove == AI_THINKING_STRUCT->moveConsidered)
if (gDisableStructs[gActiveBattler].disabledMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2001,7 +2001,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
gAIScriptPtr += 6;
return;
case 1:
if (gDisableStructs[gActiveBank].encoredMove == AI_THINKING_STRUCT->moveConsidered)
if (gDisableStructs[gActiveBattler].encoredMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2039,11 +2039,11 @@ static void BattleAICmd_get_hold_effect(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
if (gActiveBank != bank)
if (gActiveBattler != bank)
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
else
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item);
@ -2057,7 +2057,7 @@ static void BattleAICmd_if_holds_item(void)
u16 item;
u8 var1, var2;
if ((bank & BIT_SIDE) == (sBank_AI & BIT_SIDE))
if ((bank & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
item = gBattleMons[bank].item;
else
item = BATTLE_HISTORY->itemEffects[bank];
@ -2077,9 +2077,9 @@ static void BattleAICmd_get_gender(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
@ -2091,9 +2091,9 @@ static void BattleAICmd_is_first_turn_for(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
@ -2105,9 +2105,9 @@ static void BattleAICmd_get_stockpile_count(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
@ -2126,9 +2126,9 @@ static void BattleAICmd_get_used_held_item(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
// This is likely a leftover from Ruby's code and its ugly ewram access
#ifdef NONMATCHING
@ -2166,9 +2166,9 @@ static void BattleAICmd_get_protect_count(void)
u8 bank;
if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI;
bank = sBattler_AI;
else
bank = gBankTarget;
bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
@ -2221,7 +2221,7 @@ static void BattleAICmd_if_level_cond(void)
switch (gAIScriptPtr[1])
{
case 0: // greater than
if (gBattleMons[sBank_AI].level > gBattleMons[gBankTarget].level)
if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2229,7 +2229,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6;
return;
case 1: // less than
if (gBattleMons[sBank_AI].level < gBattleMons[gBankTarget].level)
if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2237,7 +2237,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6;
return;
case 2: // equal
if (gBattleMons[sBank_AI].level == gBattleMons[gBankTarget].level)
if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2249,7 +2249,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void)
{
if (gDisableStructs[gBankTarget].tauntTimer1 != 0)
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -2257,7 +2257,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void)
{
if (gDisableStructs[gBankTarget].tauntTimer1 == 0)
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -2265,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void)
{
if ((sBank_AI & BIT_SIDE) == (gBankTarget & BIT_SIDE))
if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;

View File

@ -10,16 +10,16 @@
#include "constants/items.h"
#include "pokemon_item_effects.h"
extern u8 gActiveBank;
extern u8 gAbsentBankFlags;
extern u8 gActiveBattler;
extern u8 gAbsentBattlerFlags;
extern u32 gBattleTypeFlags;
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT];
extern u8 gLastHitBy[BATTLE_BANKS_COUNT];
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT];
extern u8 gLastHitBy[MAX_BATTLERS_COUNT];
extern u16 gDynamicBasePower;
extern u8 gBattleMoveFlags;
extern u8 gMoveResultFlags;
extern u8 gCritMultiplier;
extern s32 gBattleMoveDamage;
@ -35,11 +35,11 @@ static bool8 ShouldUseItem(void);
static bool8 ShouldSwitchIfPerishSong(void)
{
if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG
&& gDisableStructs[gActiveBank].perishSongTimer1 == 0)
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG
&& gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
@ -48,7 +48,7 @@ static bool8 ShouldSwitchIfPerishSong(void)
static bool8 ShouldSwitchIfWonderGuard(void)
{
u8 opposingIdentity;
u8 opposingPosition;
u8 opposingBank;
u8 moveFlags;
s32 i, j;
@ -60,27 +60,27 @@ static bool8 ShouldSwitchIfWonderGuard(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
return FALSE;
opposingIdentity = GetBankIdentity(gActiveBank) ^ BIT_SIDE;
opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler));
if (gBattleMons[GetBankByIdentity(opposingIdentity)].ability != ABILITY_WONDER_GUARD)
if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD)
return FALSE;
// check if pokemon has a super effective move
for (opposingBank = GetBankByIdentity(opposingIdentity), i = 0; i < 4; i++)
for (opposingBank = GetBattlerAtPosition(opposingPosition), i = 0; i < 4; i++)
{
move = gBattleMons[gActiveBank].moves[i];
move = gBattleMons[gActiveBattler].moves[i];
if (move == MOVE_NONE)
continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
return FALSE;
}
// get party information
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -90,7 +90,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
firstId = 0, lastId = 6;
}
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -104,24 +104,24 @@ static bool8 ShouldSwitchIfWonderGuard(void)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue;
if (i == gBattlePartyID[gActiveBank])
if (i == gBattlerPartyIndexes[gActiveBattler])
continue;
GetMonData(&party[i], MON_DATA_SPECIES); // unused return value
GetMonData(&party[i], MON_DATA_ALT_ABILITY); // unused return value
for (opposingBank = GetBankByIdentity(opposingIdentity), j = 0; j < 4; j++)
for (opposingBank = GetBattlerAtPosition(opposingPosition), j = 0; j < 4; j++)
{
move = GetMonData(&party[i], MON_DATA_MOVE1 + j);
if (move == MOVE_NONE)
continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % 3 < 2)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2)
{
// we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
}
@ -141,42 +141,42 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3 != 0)
return FALSE;
if (gLastLandedMoves[gActiveBank] == 0)
if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE;
if (gLastLandedMoves[gActiveBank] == 0xFFFF)
if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0)
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
bankIn1 = gActiveBank;
if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)])
bankIn2 = gActiveBank;
bankIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler;
else
bankIn2 = GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON);
bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
}
else
{
bankIn1 = gActiveBank;
bankIn2 = gActiveBank;
bankIn1 = gActiveBattler;
bankIn2 = gActiveBattler;
}
if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_FIRE)
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_FIRE)
absorbingTypeAbility = ABILITY_FLASH_FIRE;
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_WATER)
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_WATER)
absorbingTypeAbility = ABILITY_WATER_ABSORB;
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_ELECTRIC)
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_ELECTRIC)
absorbingTypeAbility = ABILITY_VOLT_ABSORB;
else
return FALSE;
if (gBattleMons[gActiveBank].ability == absorbingTypeAbility)
if (gBattleMons[gActiveBattler].ability == absorbingTypeAbility)
return FALSE;
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -186,7 +186,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
firstId = 0, lastId = 6;
}
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -202,9 +202,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue;
if (i == gBattlePartyID[bankIn1])
if (i == gBattlerPartyIndexes[bankIn1])
continue;
if (i == gBattlePartyID[bankIn2])
if (i == gBattlerPartyIndexes[bankIn2])
continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
@ -220,8 +220,8 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (absorbingTypeAbility == monAbility && Random() & 1)
{
// we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
}
@ -231,34 +231,34 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
static bool8 ShouldSwitchIfNaturalCure(void)
{
if (!(gBattleMons[gActiveBank].status1 & STATUS_SLEEP))
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP))
return FALSE;
if (gBattleMons[gActiveBank].ability != ABILITY_NATURAL_CURE)
if (gBattleMons[gActiveBattler].ability != ABILITY_NATURAL_CURE)
return FALSE;
if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 2)
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2)
return FALSE;
if ((gLastLandedMoves[gActiveBank] == 0 || gLastLandedMoves[gActiveBank] == 0xFFFF) && Random() & 1)
if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0 && Random() & 1)
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTAFFECTED, 1))
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 1))
return TRUE;
if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTVERYEFFECTIVE, 1))
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1))
return TRUE;
if (Random() & 1)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
@ -267,25 +267,25 @@ static bool8 ShouldSwitchIfNaturalCure(void)
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
{
u8 opposingIdentity;
u8 opposingPosition;
u8 opposingBank;
s32 i;
u8 moveFlags;
u16 move;
opposingIdentity = GetBankIdentity(gActiveBank) ^ BIT_SIDE;
opposingBank = GetBankByIdentity(opposingIdentity);
opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler));
opposingBank = GetBattlerAtPosition(opposingPosition);
if (!(gAbsentBankFlags & gBitTable[opposingBank]))
if (!(gAbsentBattlerFlags & gBitTable[opposingBank]))
{
for (i = 0; i < 4; i++)
{
move = gBattleMons[gActiveBank].moves[i];
move = gBattleMons[gActiveBattler].moves[i];
if (move == MOVE_NONE)
continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
{
if (noRng)
return TRUE;
@ -297,18 +297,18 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return FALSE;
opposingBank = GetBankByIdentity(opposingIdentity ^ BIT_MON);
opposingBank = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition));
if (!(gAbsentBankFlags & gBitTable[opposingBank]))
if (!(gAbsentBattlerFlags & gBitTable[opposingBank]))
{
for (i = 0; i < 4; i++)
{
move = gBattleMons[gActiveBank].moves[i];
move = gBattleMons[gActiveBattler].moves[i];
if (move == MOVE_NONE)
continue;
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
{
if (noRng)
return TRUE;
@ -328,8 +328,8 @@ static bool8 AreStatsRaised(void)
for (i = 0; i < BATTLE_STATS_NO; i++)
{
if (gBattleMons[gActiveBank].statStages[i] > 6)
buffedStatsValue += gBattleMons[gActiveBank].statStages[i] - 6;
if (gBattleMons[gActiveBattler].statStages[i] > 6)
buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6;
}
return (buffedStatsValue > 3);
@ -345,32 +345,32 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
u16 move;
u8 moveFlags;
if (gLastLandedMoves[gActiveBank] == 0)
if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE;
if (gLastLandedMoves[gActiveBank] == 0xFFFF)
if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
return FALSE;
if (gLastHitBy[gActiveBank] == 0xFF)
if (gLastHitBy[gActiveBattler] == 0xFF)
return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0)
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
bankIn1 = gActiveBank;
if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)])
bankIn2 = gActiveBank;
bankIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler;
else
bankIn2 = GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON);
bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
}
else
{
bankIn1 = gActiveBank;
bankIn2 = gActiveBank;
bankIn1 = gActiveBattler;
bankIn2 = gActiveBattler;
}
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -380,7 +380,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
firstId = 0, lastId = 6;
}
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -396,9 +396,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue;
if (i == gBattlePartyID[bankIn1])
if (i == gBattlerPartyIndexes[bankIn1])
continue;
if (i == gBattlePartyID[bankIn2])
if (i == gBattlerPartyIndexes[bankIn2])
continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
@ -411,10 +411,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
else
monAbility = gBaseStats[species].ability1;
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBank], species, monAbility);
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility);
if (moveFlags & flags)
{
bankIn1 = gLastHitBy[gActiveBank];
bankIn1 = gLastHitBy[gActiveBattler];
for (j = 0; j < 4; j++)
{
@ -423,10 +423,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
continue;
moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability);
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % moduloPercent == 0)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
{
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE;
}
}
@ -446,19 +446,19 @@ static bool8 ShouldSwitch(void)
s32 i;
s32 availableToSwitch;
if (gBattleMons[*(activeBankPtr = &gActiveBank)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
if (gBattleMons[*(activeBankPtr = &gActiveBattler)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
return FALSE;
if (gStatuses3[gActiveBank] & STATUS3_ROOTED)
if (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
return FALSE;
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0))
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0))
return FALSE;
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0))
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
return FALSE; // misses the flying or levitate check
if (AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MAGNET_PULL, 0, 0))
{
if (gBattleMons[gActiveBank].type1 == TYPE_STEEL)
if (gBattleMons[gActiveBattler].type1 == TYPE_STEEL)
return FALSE;
if (gBattleMons[gActiveBank].type2 == TYPE_STEEL)
if (gBattleMons[gActiveBattler].type2 == TYPE_STEEL)
return FALSE;
}
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
@ -468,10 +468,10 @@ static bool8 ShouldSwitch(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
bankIn1 = *activeBankPtr;
if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankIdentity(*activeBankPtr) ^ BIT_MON)])
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK)])
bankIn2 = *activeBankPtr;
else
bankIn2 = GetBankByIdentity(GetBankIdentity(*activeBankPtr) ^ BIT_MON);
bankIn2 = GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK);
}
else
{
@ -481,7 +481,7 @@ static bool8 ShouldSwitch(void)
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -491,7 +491,7 @@ static bool8 ShouldSwitch(void)
firstId = 0, lastId = 6;
}
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -504,9 +504,9 @@ static bool8 ShouldSwitch(void)
continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue;
if (i == gBattlePartyID[bankIn1])
if (i == gBattlerPartyIndexes[bankIn1])
continue;
if (i == gBattlePartyID[bankIn2])
if (i == gBattlerPartyIndexes[bankIn2])
continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
@ -530,8 +530,8 @@ static bool8 ShouldSwitch(void)
return FALSE;
if (AreStatsRaised())
return FALSE;
if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTAFFECTED, 2)
|| FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTVERYEFFECTIVE, 3))
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 2)
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 3))
return TRUE;
return FALSE;
@ -543,9 +543,9 @@ void AI_TrySwitchOrUseItem(void)
u8 bankIn1, bankIn2;
s32 firstId;
s32 lastId; // + 1
u8 bankIdentity = GetBankIdentity(gActiveBank);
u8 bankIdentity = GetBattlerPosition(gActiveBattler);
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -554,25 +554,25 @@ void AI_TrySwitchOrUseItem(void)
{
if (ShouldSwitch())
{
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6)
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == 6)
{
s32 monToSwitchId = GetMostSuitableMonToSwitchInto();
if (monToSwitchId == 6)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{
bankIn1 = GetBankByIdentity(bankIdentity);
bankIn1 = GetBattlerAtPosition(bankIdentity);
bankIn2 = bankIn1;
}
else
{
bankIn1 = GetBankByIdentity(bankIdentity);
bankIn2 = GetBankByIdentity(bankIdentity ^ BIT_MON);
bankIn1 = GetBattlerAtPosition(bankIdentity);
bankIn2 = GetBattlerAtPosition(bankIdentity ^ BIT_FLANK);
}
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -586,9 +586,9 @@ void AI_TrySwitchOrUseItem(void)
{
if (GetMonData(&party[monToSwitchId], MON_DATA_HP) == 0)
continue;
if (monToSwitchId == gBattlePartyID[bankIn1])
if (monToSwitchId == gBattlerPartyIndexes[bankIn1])
continue;
if (monToSwitchId == gBattlePartyID[bankIn2])
if (monToSwitchId == gBattlerPartyIndexes[bankIn2])
continue;
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
@ -599,10 +599,10 @@ void AI_TrySwitchOrUseItem(void)
}
}
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = monToSwitchId;
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = monToSwitchId;
}
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank);
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
return;
}
else if (ShouldUseItem())
@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void)
}
}
EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBank ^ BIT_SIDE) << 8);
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8);
}
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
@ -651,34 +651,34 @@ u8 GetMostSuitableMonToSwitchInto(void)
u8 invalidMons;
u16 move;
if (*(gBattleStruct->monToSwitchIntoId + gActiveBank) != 6)
return *(gBattleStruct->monToSwitchIntoId + gActiveBank);
if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != 6)
return *(gBattleStruct->monToSwitchIntoId + gActiveBattler);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
return gBattlePartyID[gActiveBank] + 1;
return gBattlerPartyIndexes[gActiveBattler] + 1;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
bankIn1 = gActiveBank;
if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)])
bankIn2 = gActiveBank;
bankIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)])
bankIn2 = gActiveBattler;
else
bankIn2 = GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON);
bankIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK);
// UB: It considers the opponent only player's side even though it can battle alongside player;
opposingBank = Random() & BIT_MON;
if (gAbsentBankFlags & gBitTable[opposingBank])
opposingBank ^= BIT_MON;
opposingBank = Random() & BIT_FLANK;
if (gAbsentBattlerFlags & gBitTable[opposingBank])
opposingBank ^= BIT_FLANK;
}
else
{
opposingBank = GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_SIDE);
bankIn1 = gActiveBank;
bankIn2 = gActiveBank;
opposingBank = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_SIDE);
bankIn1 = gActiveBattler;
bankIn2 = gActiveBattler;
}
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000))
{
if ((gActiveBank & BIT_MON) == 0)
if ((gActiveBattler & BIT_FLANK) == 0)
firstId = 0, lastId = 3;
else
firstId = 3, lastId = 6;
@ -688,7 +688,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
firstId = 0, lastId = 6;
}
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -706,8 +706,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
if (species != SPECIES_NONE
&& GetMonData(&party[i], MON_DATA_HP) != 0
&& !(gBitTable[i] & invalidMons)
&& gBattlePartyID[bankIn1] != i
&& gBattlePartyID[bankIn2] != i
&& gBattlerPartyIndexes[bankIn1] != i
&& gBattlerPartyIndexes[bankIn2] != i
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn1)
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn2))
{
@ -734,7 +734,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
for (i = 0; i < 4; i++)
{
move = GetMonData(&party[bestMonId], MON_DATA_MOVE1 + i);
if (move != MOVE_NONE && TypeCalc(move, gActiveBank, opposingBank) & MOVESTATUS_SUPEREFFECTIVE)
if (move != MOVE_NONE && TypeCalc(move, gActiveBattler, opposingBank) & MOVE_RESULT_SUPER_EFFECTIVE)
break;
}
@ -752,7 +752,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
gDynamicBasePower = 0;
gBattleStruct->dynamicMoveType = 0;
gBattleScripting.dmgMultiplier = 1;
gBattleMoveFlags = 0;
gMoveResultFlags = 0;
gCritMultiplier = 1;
bestDmg = 0;
bestMonId = 6;
@ -764,9 +764,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
continue;
if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue;
if (gBattlePartyID[bankIn1] == i)
if (gBattlerPartyIndexes[bankIn1] == i)
continue;
if (gBattlePartyID[bankIn2] == i)
if (gBattlerPartyIndexes[bankIn2] == i)
continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue;
@ -779,8 +779,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
gBattleMoveDamage = 0;
if (move != MOVE_NONE && gBattleMoves[move].power != 1)
{
AI_CalcDmg(gActiveBank, opposingBank);
TypeCalc(move, gActiveBank, opposingBank);
AI_CalcDmg(gActiveBattler, opposingBank);
TypeCalc(move, gActiveBattler, opposingBank);
}
if (bestDmg < gBattleMoveDamage)
{
@ -817,10 +817,10 @@ static bool8 ShouldUseItem(void)
u8 validMons = 0;
bool8 shouldUse = FALSE;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBankIdentity(gActiveBank) == IDENTITY_PLAYER_MON2)
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT)
return FALSE;
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;
@ -855,14 +855,14 @@ static bool8 ShouldUseItem(void)
else
itemEffects = gItemEffectTable[item - 13];
*(gBattleStruct->AI_itemType + gActiveBank / 2) = GetAI_ItemType(item, itemEffects);
*(gBattleStruct->AI_itemType + gActiveBattler / 2) = GetAI_ItemType(item, itemEffects);
switch (*(gBattleStruct->AI_itemType + gActiveBank / 2))
switch (*(gBattleStruct->AI_itemType + gActiveBattler / 2))
{
case AI_ITEM_FULL_RESTORE:
if (gBattleMons[gActiveBank].hp >= gBattleMons[gActiveBank].maxHP / 4)
if (gBattleMons[gActiveBattler].hp >= gBattleMons[gActiveBattler].maxHP / 4)
break;
if (gBattleMons[gActiveBank].hp == 0)
if (gBattleMons[gActiveBattler].hp == 0)
break;
shouldUse = TRUE;
break;
@ -870,65 +870,65 @@ static bool8 ShouldUseItem(void)
paramOffset = GetItemEffectParamOffset(item, 4, 4);
if (paramOffset == 0)
break;
if (gBattleMons[gActiveBank].hp == 0)
if (gBattleMons[gActiveBattler].hp == 0)
break;
if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 4 || gBattleMons[gActiveBank].maxHP - gBattleMons[gActiveBank].hp > itemEffects[paramOffset])
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 4 || gBattleMons[gActiveBattler].maxHP - gBattleMons[gActiveBattler].hp > itemEffects[paramOffset])
shouldUse = TRUE;
break;
case AI_ITEM_CURE_CONDITION:
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) = 0;
if (itemEffects[3] & 0x20 && gBattleMons[gActiveBank].status1 & STATUS_SLEEP)
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0;
if (itemEffects[3] & 0x20 && gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x20;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20;
shouldUse = TRUE;
}
if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBank].status1 & STATUS_POISON || gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON))
if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBattler].status1 & STATUS1_POISON || gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_POISON))
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x10;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x10;
shouldUse = TRUE;
}
if (itemEffects[3] & 0x8 && gBattleMons[gActiveBank].status1 & STATUS_BURN)
if (itemEffects[3] & 0x8 && gBattleMons[gActiveBattler].status1 & STATUS1_BURN)
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x8;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8;
shouldUse = TRUE;
}
if (itemEffects[3] & 0x4 && gBattleMons[gActiveBank].status1 & STATUS_FREEZE)
if (itemEffects[3] & 0x4 && gBattleMons[gActiveBattler].status1 & STATUS1_FREEZE)
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x4;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4;
shouldUse = TRUE;
}
if (itemEffects[3] & 0x2 && gBattleMons[gActiveBank].status1 & STATUS_PARALYSIS)
if (itemEffects[3] & 0x2 && gBattleMons[gActiveBattler].status1 & STATUS1_PARALYSIS)
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x2;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2;
shouldUse = TRUE;
}
if (itemEffects[3] & 0x1 && gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION)
if (itemEffects[3] & 0x1 && gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION)
{
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x1;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1;
shouldUse = TRUE;
}
break;
case AI_ITEM_X_STAT:
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) = 0;
if (gDisableStructs[gActiveBank].isFirstTurn == 0)
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0;
if (gDisableStructs[gActiveBattler].isFirstTurn == 0)
break;
if (itemEffects[0] & 0xF)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x1;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1;
if (itemEffects[1] & 0xF0)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x2;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2;
if (itemEffects[1] & 0xF)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x4;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4;
if (itemEffects[2] & 0xF)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x8;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8;
if (itemEffects[2] & 0xF0)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x20;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20;
if (itemEffects[0] & 0x30)
*(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x80;
*(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x80;
shouldUse = TRUE;
break;
case AI_ITEM_GUARD_SPECS:
bankSide = GetBankSide(gActiveBank);
if (gDisableStructs[gActiveBank].isFirstTurn != 0 && gSideTimers[bankSide].mistTimer == 0)
bankSide = GetBattlerSide(gActiveBattler);
if (gDisableStructs[gActiveBattler].isFirstTurn != 0 && gSideTimers[bankSide].mistTimer == 0)
shouldUse = TRUE;
break;
case AI_ITEM_NOT_RECOGNIZABLE:
@ -937,8 +937,8 @@ static bool8 ShouldUseItem(void)
if (shouldUse)
{
EmitTwoReturnValues(1, ACTION_USE_ITEM, 0);
*(gBattleStruct->chosenItem + (gActiveBank / 2) * 2) = item;
BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
gBattleResources->battleHistory->trainerItems[i] = 0;
return shouldUse;
}

View File

@ -25,8 +25,8 @@
#define ANIM_SPRITE_INDEX_COUNT 8
extern u8 gBankAttacker;
extern u8 gBankTarget;
extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V;
extern u16 gBattle_WIN1H;
@ -35,8 +35,8 @@ extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
@ -130,9 +130,9 @@ EWRAM_DATA static u8 sMonAnimTaskIdArray[2] = {0};
EWRAM_DATA u8 gAnimMoveTurn = 0;
EWRAM_DATA static u8 sAnimBackgroundFadeState = 0;
EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused.
EWRAM_DATA u8 gAnimBankAttacker = 0;
EWRAM_DATA u8 gAnimBankTarget = 0;
EWRAM_DATA u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT] = {0};
EWRAM_DATA u8 gBattleAnimAttacker = 0;
EWRAM_DATA u8 gBattleAnimTarget = 0;
EWRAM_DATA u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gUnknown_02038440 = 0;
// const rom data
@ -214,15 +214,15 @@ void ClearBattleAnimationVars(void)
gAnimMoveTurn = 0;
sAnimBackgroundFadeState = 0;
sAnimMoveIndex = 0;
gAnimBankAttacker = 0;
gAnimBankTarget = 0;
gBattleAnimAttacker = 0;
gBattleAnimTarget = 0;
gUnknown_02038440 = 0;
}
void DoMoveAnim(u16 move)
{
gAnimBankAttacker = gBankAttacker;
gAnimBankTarget = gBankTarget;
gBattleAnimAttacker = gBattlerAttacker;
gBattleAnimTarget = gBattlerTarget;
LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE);
}
@ -234,12 +234,12 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
{
sub_80A8278();
UpdateOamPriorityInAllHealthboxes(0);
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBankSide(i) != 0)
gAnimSpeciesByBanks[i] = GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_SPECIES);
if (GetBattlerSide(i) != 0)
gAnimSpeciesByBanks[i] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
else
gAnimSpeciesByBanks[i] = GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_SPECIES);
gAnimSpeciesByBanks[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
}
}
else
@ -409,7 +409,7 @@ static void ScriptCmd_createsprite(void)
else
argVar *= -1;
subpriority = sub_80A82E4(gAnimBankTarget) + (s8)(argVar);
subpriority = sub_80A82E4(gBattleAnimTarget) + (s8)(argVar);
}
else
{
@ -418,13 +418,13 @@ static void ScriptCmd_createsprite(void)
else
argVar *= -1;
subpriority = sub_80A82E4(gAnimBankAttacker) + (s8)(argVar);
subpriority = sub_80A82E4(gBattleAnimAttacker) + (s8)(argVar);
}
if (subpriority < 3)
subpriority = 3;
CreateSpriteAndAnimate(template, GetBankPosition(gAnimBankTarget, 2), GetBankPosition(gAnimBankTarget, 3), subpriority);
CreateSpriteAndAnimate(template, GetBattlerSpriteCoord(gBattleAnimTarget, 2), GetBattlerSpriteCoord(gBattleAnimTarget, 3), subpriority);
gAnimVisualTaskCount++;
}
@ -565,7 +565,7 @@ static void sub_80A40F4(u8 taskId)
u8 newTaskId;
s16 *selfData = gTasks[taskId].data;
u8 bankSpriteId = gBankSpriteIds[selfData[t1_MONBG_BANK]];
u8 bankSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BANK]];
gSprites[bankSpriteId].invisible = 1;
if (!selfData[t1_CREATE_ANOTHER_TASK])
@ -607,14 +607,14 @@ static void ScriptCmd_monbg(void)
animBank = sBattleAnimScriptPtr[0];
if (animBank & ANIM_TARGET)
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
else
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
if (IsAnimBankSpriteVisible(bank))
if (IsBattlerSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
@ -629,11 +629,11 @@ static void ScriptCmd_monbg(void)
}
bank ^= BIT_MON;
if (IsAnimBankSpriteVisible(bank))
bank ^= BIT_FLANK;
if (IsBattlerSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
@ -652,20 +652,20 @@ static void ScriptCmd_monbg(void)
gAnimScriptCallback = WaitAnimFrameCount;
}
bool8 IsAnimBankSpriteVisible(u8 bank)
bool8 IsBattlerSpriteVisible(u8 bank)
{
if (IsContest())
{
if (bank == gAnimBankAttacker)
if (bank == gBattleAnimAttacker)
return TRUE;
else
return FALSE;
}
if (!IsBankSpritePresent(bank))
if (!IsBattlerSpritePresent(bank))
return FALSE;
if (IsContest())
return TRUE; // this line wont ever be reached.
if (!gBattleSpritesDataPtr->bankData[bank].invisible || !gSprites[gBankSpriteIds[bank]].invisible)
if (!gBattleSpritesDataPtr->battlerData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible)
return TRUE;
return FALSE;
@ -699,7 +699,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBankSpriteIds[bank];
bankSpriteId = gBattlerSpriteIds[bank];
gBattle_BG1_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->field_0))
@ -707,7 +707,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
gBattle_BG1_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBankSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
@ -718,7 +718,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
if (IsContest())
bankIdentity = 0;
else
bankIdentity = GetBankIdentity(bank);
bankIdentity = GetBattlerPosition(bank);
sub_8118FBC(1, 0, 0, bankIdentity, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA);
@ -736,13 +736,13 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(2, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(2, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBankSpriteIds[bank];
bankSpriteId = gBattlerSpriteIds[bank];
gBattle_BG2_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBankSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
@ -750,7 +750,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + 0x120), 0x20);
sub_8118FBC(2, 0, 0, GetBankIdentity(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
sub_8118FBC(2, 0, 0, GetBattlerPosition(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
}
}
@ -869,14 +869,14 @@ static void ScriptCmd_clearmonbg(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
else
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBankSpriteIds[bank]].invisible = 0;
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0;
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
@ -893,8 +893,8 @@ static void sub_80A4980(u8 taskId)
if (gTasks[taskId].data[1] != 1)
{
u8 to_BG2;
u8 identity = GetBankIdentity(gTasks[taskId].data[2]);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(gTasks[taskId].data[2]);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
to_BG2 = FALSE;
else
to_BG2 = TRUE;
@ -931,14 +931,14 @@ static void ScriptCmd_monbg_22(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
else
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
if (IsAnimBankSpriteVisible(bank))
if (IsBattlerSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
@ -946,11 +946,11 @@ static void ScriptCmd_monbg_22(void)
sub_80A438C(bank, toBG_2, FALSE);
}
bank ^= BIT_MON;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank))
bank ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
@ -976,14 +976,14 @@ static void ScriptCmd_clearmonbg_23(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
else
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
if (IsAnimBankSpriteVisible(bank))
gSprites[gBankSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON))
gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0;
if (IsBattlerSpriteVisible(bank))
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
@ -1001,15 +1001,15 @@ static void sub_80A4BB0(u8 taskId)
{
bool8 toBG_2;
u8 bank = gTasks[taskId].data[2];
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
if (IsAnimBankSpriteVisible(bank))
if (IsBattlerSpriteVisible(bank))
sub_80A477C(toBG_2);
if (gTasks[taskId].data[0] > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON))
if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
sub_80A477C(toBG_2 ^ 1);
DestroyTask(taskId);
@ -1145,7 +1145,7 @@ static void ScriptCmd_fadetobgfromset(void)
if (IsContest())
gTasks[taskId].tBackgroundId = bg3;
else if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER)
else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
gTasks[taskId].tBackgroundId = bg2;
else
gTasks[taskId].tBackgroundId = bg1;
@ -1270,21 +1270,21 @@ static void ScriptCmd_changebg(void)
s8 BattleAnimAdjustPanning(s8 pan)
{
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive)
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gBattleAnimAttacker].statusAnimActive)
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT;
else
pan = PAN_SIDE_PLAYER;
}
else if (IsContest())
{
if (gAnimBankAttacker != gAnimBankTarget || gAnimBankAttacker != 2 || pan != PAN_SIDE_OPPONENT)
if (gBattleAnimAttacker != gBattleAnimTarget || gBattleAnimAttacker != 2 || pan != PAN_SIDE_OPPONENT)
pan *= -1;
}
else if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER)
else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER)
if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
{
if (pan == PAN_SIDE_OPPONENT)
pan = PAN_SIDE_PLAYER;
@ -1292,7 +1292,7 @@ s8 BattleAnimAdjustPanning(s8 pan)
pan *= -1;
}
}
else if (GetBankSide(gAnimBankTarget) == SIDE_OPPONENT)
else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_OPPONENT)
{
if (pan == PAN_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT;
@ -1312,16 +1312,16 @@ s8 BattleAnimAdjustPanning(s8 pan)
s8 BattleAnimAdjustPanning2(s8 pan)
{
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive)
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gBattleAnimAttacker].statusAnimActive)
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT;
else
pan = PAN_SIDE_PLAYER;
}
else
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER || IsContest())
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER || IsContest())
pan = -pan;
}
return pan;
@ -1701,12 +1701,12 @@ static void ScriptCmd_monbgprio_28(void)
sBattleAnimScriptPtr += 2;
if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
else
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
bankIdentity = GetBankIdentity(bank);
if (!IsContest() && (bankIdentity == IDENTITY_PLAYER_MON1 || bankIdentity == IDENTITY_OPPONENT_MON2))
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);
@ -1731,15 +1731,15 @@ static void ScriptCmd_monbgprio_2A(void)
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (GetBankSide(gAnimBankAttacker) != GetBankSide(gAnimBankTarget))
if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget))
{
if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget;
bank = gBattleAnimTarget;
else
bank = gAnimBankAttacker;
bank = gBattleAnimAttacker;
bankIdentity = GetBankIdentity(bank);
if (!IsContest() && (bankIdentity == IDENTITY_PLAYER_MON1 || bankIdentity == IDENTITY_OPPONENT_MON2))
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);
@ -1751,7 +1751,7 @@ static void ScriptCmd_invisible(void)
{
u8 spriteId;
spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]);
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF)
gSprites[spriteId].invisible = 1;
@ -1762,7 +1762,7 @@ static void ScriptCmd_visible(void)
{
u8 spriteId;
spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]);
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF)
gSprites[spriteId].invisible = 0;
@ -1778,17 +1778,17 @@ static void ScriptCmd_doublebattle_2D(void)
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle()
&& GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget))
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{
if (wantedBank == ANIM_ATTACKER)
{
r4 = sub_80A8364(gAnimBankAttacker);
spriteId = GetAnimBankSpriteId(ANIM_ATTACKER);
r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
}
else
{
r4 = sub_80A8364(gAnimBankTarget);
spriteId = GetAnimBankSpriteId(ANIM_TARGET);
r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
}
if (spriteId != 0xFF)
{
@ -1813,17 +1813,17 @@ static void ScriptCmd_doublebattle_2E(void)
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle()
&& GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget))
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{
if (wantedBank == ANIM_ATTACKER)
{
r4 = sub_80A8364(gAnimBankAttacker);
spriteId = GetAnimBankSpriteId(ANIM_ATTACKER);
r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
}
else
{
r4 = sub_80A8364(gAnimBankTarget);
spriteId = GetAnimBankSpriteId(ANIM_TARGET);
r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
}
if (spriteId != 0xFF && r4 == 2)

View File

@ -273,13 +273,13 @@ static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY)
static void sub_8035C4C(void)
{
if (gBattleOutcome == BATTLE_DREW)
if (gBattleOutcome == B_OUTCOME_DREW)
{
BattleHandleAddTextPrinter(gText_Draw, 0x15);
}
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gBattleOutcome == BATTLE_WON)
if (gBattleOutcome == B_OUTCOME_WON)
{
switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18)
{
@ -324,7 +324,7 @@ static void sub_8035C4C(void)
}
}
}
else if (gBattleOutcome == BATTLE_WON)
else if (gBattleOutcome == B_OUTCOME_WON)
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0)
{
@ -363,7 +363,7 @@ void sub_8035D74(u8 taskId)
case 0:
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
name = gLinkPlayers[i].name;
linkPlayer = &gLinkPlayers[i];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,21 +22,21 @@
#include "data2.h"
#include "pokeblock.h"
extern u32 gBattleExecBuffer;
extern u8 gActiveBank;
extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT];
extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT];
extern u8 gNoOfAllBanks;
extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler;
extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim;
extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void);
extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
@ -180,15 +180,15 @@ static void nullsub_114(void)
void SetControllerToSafari(void)
{
gBattleBankFunc[gActiveBank] = SafariBufferRunCommand;
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
}
static void SafariBufferRunCommand(void)
{
if (gBattleExecBuffer & gBitTable[gActiveBank])
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{
if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sSafariBufferCommands))
sSafariBufferCommands[gBattleBufferA[gActiveBank][0]]();
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands))
sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]]();
else
SafariBufferExecCompleted();
}
@ -200,68 +200,68 @@ static void HandleInputChooseAction(void)
{
PlaySE(SE_SELECT);
switch (gActionSelectionCursor[gActiveBank])
switch (gActionSelectionCursor[gActiveBattler])
{
case 0:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0);
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
break;
case 1:
EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0);
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
break;
case 2:
EmitTwoReturnValues(1, ACTION_GO_NEAR, 0);
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
break;
case 3:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0);
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0);
break;
}
SafariBufferExecCompleted();
}
else if (gMain.newKeys & DPAD_LEFT)
{
if (gActionSelectionCursor[gActiveBank] & 1)
if (gActionSelectionCursor[gActiveBattler] & 1)
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
gActionSelectionCursor[gActiveBattler] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
else if (gMain.newKeys & DPAD_RIGHT)
{
if (!(gActionSelectionCursor[gActiveBank] & 1))
if (!(gActionSelectionCursor[gActiveBattler] & 1))
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
gActionSelectionCursor[gActiveBattler] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
else if (gMain.newKeys & DPAD_UP)
{
if (gActionSelectionCursor[gActiveBank] & 2)
if (gActionSelectionCursor[gActiveBattler] & 2)
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
gActionSelectionCursor[gActiveBattler] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
else if (gMain.newKeys & DPAD_DOWN)
{
if (!(gActionSelectionCursor[gActiveBank] & 2))
if (!(gActionSelectionCursor[gActiveBattler] & 2))
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
gActionSelectionCursor[gActiveBattler] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
}
}
}
static void CompleteOnBankSpriteCallbackDummy(void)
{
if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted();
}
@ -273,7 +273,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void CompleteOnHealthboxSpriteCallbackDummy(void)
{
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted();
}
@ -289,7 +289,7 @@ static void sub_81595E4(void)
static void CompleteOnSpecialAnimDone(void)
{
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
SafariBufferExecCompleted();
}
@ -297,7 +297,7 @@ static void SafariOpenPokeblockCase(void)
{
if (!gPaletteFade.active)
{
gBattleBankFunc[gActiveBank] = CompleteWhenChosePokeblock;
gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChosePokeblock;
FreeAllWindowBuffers();
OpenPokeblockCaseInBattle();
}
@ -307,36 +307,36 @@ static void CompleteWhenChosePokeblock(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
EmitOneReturnValue(1, gSpecialVar_ItemId);
BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId);
SafariBufferExecCompleted();
}
}
static void CompleteOnFinishedBattleAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
SafariBufferExecCompleted();
}
static void SafariBufferExecCompleted(void)
{
gBattleBankFunc[gActiveBank] = SafariBufferRunCommand;
gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP;
gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
{
gBattleExecBuffer &= ~gBitTable[gActiveBank];
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
SafariBufferExecCompleted();
}
@ -377,18 +377,18 @@ static void SafariHandleReturnMonToBall(void)
static void SafariHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBank);
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBankIdentity(gActiveBank));
gBankSpriteIds[gActiveBank] = CreateSprite(
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(
&gUnknown_0202499C,
80,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
30);
gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank;
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC;
gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
}
static void SafariHandleTrainerSlide(void)
@ -415,18 +415,18 @@ static void SafariHandleSuccessBallThrowAnim(void)
{
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
}
static void SafariHandleBallThrowAnim(void)
{
u8 ballThrowCaseId = gBattleBufferA[gActiveBank][1];
u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1];
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
}
static void SafariHandlePause(void)
@ -445,15 +445,15 @@ static void SafariHandlePrintString(void)
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBank][2]);
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
}
static void SafariHandlePrintSelectionString(void)
{
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
SafariHandlePrintString();
else
SafariBufferExecCompleted();
@ -465,7 +465,7 @@ static void HandleChooseActionAfterDma3(void)
{
gBattle_BG0_X = 0;
gBattle_BG0_Y = 160;
gBattleBankFunc[gActiveBank] = HandleInputChooseAction;
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction;
}
}
@ -473,13 +473,13 @@ static void SafariHandleChooseAction(void)
{
s32 i;
gBattleBankFunc[gActiveBank] = HandleChooseActionAfterDma3;
gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2);
for (i = 0; i < 4; i++)
ActionSelectionDestroyCursorAt(i);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 1);
}
@ -499,8 +499,8 @@ static void SafariHandleChooseItem(void)
s32 i;
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattleBankFunc[gActiveBank] = SafariOpenPokeblockCase;
gBankInMenu = gActiveBank;
gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase;
gBankInMenu = gActiveBattler;
}
static void SafariHandleChoosePokemon(void)
@ -525,7 +525,7 @@ static void SafariHandleExpUpdate(void)
static void SafariHandleStatusIconUpdate(void)
{
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_BALLS_TEXT);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT);
SafariBufferExecCompleted();
}
@ -613,25 +613,25 @@ static void SafariHandlePlaySE(void)
{
s8 pan;
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
pan = PAN_SIDE_PLAYER;
else
pan = PAN_SIDE_OPPONENT;
PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan);
PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan);
SafariBufferExecCompleted();
}
static void SafariHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
if (gBattleBufferA[gActiveBattler][3])
{
BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
}
else
{
PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8));
}
SafariBufferExecCompleted();
@ -639,7 +639,7 @@ static void SafariHandlePlayFanfareOrBGM(void)
static void SafariHandleFaintingCry(void)
{
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES);
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry1(species, 25);
SafariBufferExecCompleted();
@ -647,17 +647,17 @@ static void SafariHandleFaintingCry(void)
static void SafariHandleIntroSlide(void)
{
HandleIntroSlide(gBattleBufferA[gActiveBank][1]);
HandleIntroSlide(gBattleBufferA[gActiveBattler][1]);
gUnknown_020243FC |= 1;
SafariBufferExecCompleted();
}
static void SafariHandleIntroTrainerBallThrow(void)
{
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBank);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]);
gBattleBankFunc[gActiveBank] = CompleteOnHealthboxSpriteCallbackDummy;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
}
static void SafariHandleDrawPartyStatusSummary(void)
@ -682,13 +682,13 @@ static void SafariHandleSpriteInvisibility(void)
static void SafariHandleBattleAnimation(void)
{
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
SafariBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
}
static void SafariHandleLinkStandbyMsg(void)
@ -703,12 +703,12 @@ static void SafariHandleResetActionMoveSelection(void)
static void SafariHandleCmd55(void)
{
gBattleOutcome = gBattleBufferA[gActiveBank][1];
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
SafariBufferExecCompleted();
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD))
gBattleBankFunc[gActiveBank] = sub_81595E4;
gBattlerControllerFuncs[gActiveBattler] = sub_81595E4;
}
static void nullsub_115(void)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,17 +23,17 @@
#include "contest.h"
#include "constants/songs.h"
extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gActiveBank;
extern u8 gNoOfAllBanks;
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gActiveBattler;
extern u8 gBattlersCount;
extern u16 gUnknown_020243FC;
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u8 gBanksByIdentity[BATTLE_BANKS_COUNT];
extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT];
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
@ -109,7 +109,7 @@ static const struct CompressedSpriteSheet gUnknown_0832C100 =
gUnknown_08C1F8E8, 0x1000, TAG_HEALTHBOX_SAFARI_TILE
};
static const struct CompressedSpriteSheet gUnknown_0832C108[BATTLE_BANKS_COUNT] =
static const struct CompressedSpriteSheet gUnknown_0832C108[MAX_BATTLERS_COUNT] =
{
{gBlankGfxCompressed, 0x0100, 0xd704},
{gBlankGfxCompressed, 0x0120, 0xd705},
@ -127,10 +127,10 @@ static const struct SpritePalette gUnknown_0832C128[2] =
void AllocateBattleSpritesData(void)
{
gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData));
gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT);
gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT);
gBattleSpritesDataPtr->battlerData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT);
gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT);
gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo));
gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * BATTLE_BANKS_COUNT);
gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * MAX_BATTLERS_COUNT);
}
void FreeBattleSpritesData(void)
@ -141,7 +141,7 @@ void FreeBattleSpritesData(void)
FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->battlerData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr);
}
@ -149,17 +149,17 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
{
s32 i, var1, var2;
s32 chosenMoveId = -1;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBank, 0, 0xFF);
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
s32 percent = Random() % 100;
i = (gBattleStruct->field_92 & gBitTable[gActiveBank]) ? 2 : 0;
i = (gBattleStruct->field_92 & gBitTable[gActiveBattler]) ? 2 : 0;
var2 = i;
var1 = i + 2;
for (; i < var1; i++)
{
if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)][i] > percent)
if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)][i] > percent)
break;
}
@ -234,13 +234,13 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
if (Random() % 100 > 49)
{
gProtectStructs[gActiveBank].flag_x10 = 1;
gProtectStructs[gActiveBattler].flag_x10 = 1;
return 0;
}
}
else
{
gProtectStructs[gActiveBank].flag_x10 = 1;
gProtectStructs[gActiveBattler].flag_x10 = 1;
return 0;
}
}
@ -258,11 +258,11 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
}
if (var1 & MOVE_TARGET_x10)
chosenMoveId |= (gActiveBank << 8);
chosenMoveId |= (gActiveBattler << 8);
else if (var1 == MOVE_TARGET_SELECTED)
chosenMoveId |= (BattlePalaceGetTargetRetValue());
else
chosenMoveId |= (GetBankByIdentity((GetBankIdentity(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8);
chosenMoveId |= (GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE) << 8);
return chosenMoveId;
}
@ -297,21 +297,21 @@ static u16 BattlePalaceGetTargetRetValue(void)
{
u8 opposing1, opposing2;
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{
opposing1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
opposing2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
opposing1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposing2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
}
else
{
opposing1 = GetBankByIdentity(IDENTITY_PLAYER_MON1);
opposing2 = GetBankByIdentity(IDENTITY_PLAYER_MON2);
opposing1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
opposing2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
}
if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp)
return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)])
switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)])
{
case 0:
if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp)
@ -324,11 +324,11 @@ static u16 BattlePalaceGetTargetRetValue(void)
else
return opposing2 << 8;
case 2:
return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
}
}
return (gActiveBank ^ BIT_SIDE) << 8;
return (gActiveBattler ^ BIT_SIDE) << 8;
}
void sub_805D714(struct Sprite *sprite)
@ -388,36 +388,36 @@ static void sub_805D7EC(struct Sprite *sprite)
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1;
if (!isStatus2)
{
if (status == STATUS_FREEZE)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_FRZ);
else if (status == STATUS_POISON || status & STATUS_TOXIC_POISON)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PSN);
else if (status == STATUS_BURN)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_BRN);
else if (status & STATUS_SLEEP)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_SLP);
else if (status == STATUS_PARALYSIS)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PRZ);
if (status == STATUS1_FREEZE)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_FRZ);
else if (status == STATUS1_POISON || status & STATUS1_TOXIC_POISON)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PSN);
else if (status == STATUS1_BURN)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_BRN);
else if (status & STATUS1_SLEEP)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_SLP);
else if (status == STATUS1_PARALYSIS)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PRZ);
else // no animation
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0;
}
else
{
if (status & STATUS2_INFATUATION)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_INFATUATION);
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_INFATUATION);
else if (status & STATUS2_CONFUSION)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CONFUSION);
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CONFUSION);
else if (status & STATUS2_CURSED)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CURSED);
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CURSED);
else if (status & STATUS2_NIGHTMARE)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_NIGHTMARE);
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_NIGHTMARE);
else if (status & STATUS2_WRAPPED)
LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist
else // no animation
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0;
}
}
@ -432,22 +432,22 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank,
gBattleMonForms[activeBank] = (argument & ~(0x80));
return TRUE;
}
if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute
if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute
&& !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
{
return TRUE;
}
if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute
if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute
&& tableId == B_ANIM_SUBSTITUTE_FADE
&& gSprites[gBankSpriteIds[activeBank]].invisible)
&& gSprites[gBattlerSpriteIds[activeBank]].invisible)
{
LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBankSpriteIds[activeBank]);
LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBattlerSpriteIds[activeBank]);
ClearBehindSubstituteBit(activeBank);
return TRUE;
}
gAnimBankAttacker = atkBank;
gAnimBankTarget = defBank;
gBattleAnimAttacker = atkBank;
gBattleAnimTarget = defBank;
gBattleSpritesDataPtr->animationData->animArg = argument;
LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
@ -491,8 +491,8 @@ void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tab
{
u8 taskId;
gAnimBankAttacker = atkBank;
gAnimBankTarget = defBank;
gBattleAnimAttacker = atkBank;
gBattleAnimTarget = defBank;
LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
gTasks[taskId].tBank = activeBank;
@ -524,7 +524,7 @@ bool8 mplay_80342A4(u8 bank)
if (IsSEPlaying())
{
gBattleSpritesDataPtr->healthBoxesData[bank].field_8++;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_8 < 30)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_8 < 30)
return TRUE;
m4aMPlayStop(&gMPlayInfo_SE1);
@ -543,32 +543,32 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
{
u32 monsPersonality, currentPersonality, otId;
u16 species;
u8 identity;
u8 position;
u16 paletteOffset;
const void *lzPaletteData;
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
}
else
{
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies;
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank];
}
otId = GetMonData(mon, MON_DATA_OT_ID);
identity = GetBankIdentity(bank);
position = GetBattlerPosition(bank);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
species, currentPersonality);
paletteOffset = 0x100 + bank * 16;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
@ -585,7 +585,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
}
// transform's pink color
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
@ -596,42 +596,42 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
{
u32 monsPersonality, currentPersonality, otId;
u16 species;
u8 identity;
u8 position;
u16 paletteOffset;
const void *lzPaletteData;
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
}
else
{
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies;
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank];
}
otId = GetMonData(mon, MON_DATA_OT_ID);
identity = GetBankIdentity(bank);
position = GetBattlerPosition(bank);
if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE)
if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
species, currentPersonality);
}
else
{
HandleLoadSpecialPokePic(&gMonBackPicTable[species],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
species, currentPersonality);
}
paletteOffset = 0x100 + bank * 16;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
@ -648,7 +648,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
}
// transform's pink color
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
@ -665,18 +665,18 @@ void nullsub_24(u16 species)
void DecompressTrainerFrontPic(u16 frontPicId, u8 bank)
{
u8 identity = GetBankIdentity(bank);
u8 position = GetBattlerPosition(bank);
DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
SPECIES_NONE);
LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[frontPicId]);
}
void DecompressTrainerBackPic(u16 backPicId, u8 bank)
{
u8 identity = GetBankIdentity(bank);
u8 position = GetBattlerPosition(bank);
DecompressPicFromTable_2(&gTrainerBackPicTable[backPicId],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
SPECIES_NONE);
LoadCompressedPalette(gTrainerBackPicPaletteTable[backPicId].data,
0x100 + 16 * bank, 0x20);
@ -713,7 +713,7 @@ void sub_805DFFC(void)
numberOfBanks = 4;
}
for (i = 0; i < numberOfBanks; i++)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[i]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[i]]);
}
bool8 BattleLoadAllHealthBoxesGfx(u8 state)
@ -739,9 +739,9 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
else if (state == 3)
LoadCompressedObjectPic(&gUnknown_0832C0D8);
else if (state == 4)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[0]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[0]]);
else if (state == 5)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[1]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[1]]);
else
retVal = TRUE;
}
@ -756,13 +756,13 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
else if (state == 5)
LoadCompressedObjectPic(&gUnknown_0832C0F0[1]);
else if (state == 6)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[0]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[0]]);
else if (state == 7)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[1]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[1]]);
else if (state == 8)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[2]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[2]]);
else if (state == 9)
LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[3]]);
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[3]]);
else
retVal = TRUE;
}
@ -802,44 +802,44 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
break;
case 3:
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0)
gHealthBoxesIds[*bank] = CreateSafariPlayerHealthboxSprites();
gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites();
else
gHealthBoxesIds[*bank] = CreateBankHealthboxSprites(*bank);
gHealthboxSpriteIds[*bank] = CreateBattlerHealthboxSprites(*bank);
(*bank)++;
if (*bank == gNoOfAllBanks)
if (*bank == gBattlersCount)
{
*bank = 0;
(*state1)++;
}
break;
case 4:
SetBankHealthboxSpritePos(*bank);
if (gBanksByIdentity[*bank] <= 1)
DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], FALSE);
InitBattlerHealthboxCoords(*bank);
if (gBattlerPositions[*bank] <= 1)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], FALSE);
else
DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], TRUE);
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], TRUE);
(*bank)++;
if (*bank == gNoOfAllBanks)
if (*bank == gBattlersCount)
{
*bank = 0;
(*state1)++;
}
break;
case 5:
if (GetBankSide(*bank) == SIDE_PLAYER)
if (GetBattlerSide(*bank) == B_SIDE_PLAYER)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gPlayerParty[gBattlePartyID[*bank]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gPlayerParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
}
else
{
UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gEnemyParty[gBattlePartyID[*bank]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gEnemyParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
}
SetHealthboxSpriteInvisible(gHealthBoxesIds[*bank]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*bank]);
(*bank)++;
if (*bank == gNoOfAllBanks)
if (*bank == gBattlersCount)
{
*bank = 0;
(*state1)++;
@ -857,27 +857,27 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
void ClearSpritesHealthboxAnimData(void)
{
memset(gBattleSpritesDataPtr->healthBoxesData, 0, sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT);
memset(gBattleSpritesDataPtr->healthBoxesData, 0, sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT);
memset(gBattleSpritesDataPtr->animationData, 0, sizeof(struct BattleAnimationInfo));
}
static void ClearSpritesBankHealthboxAnimData(void)
{
ClearSpritesHealthboxAnimData();
memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT);
memset(gBattleSpritesDataPtr->battlerData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT);
}
void CopyAllBattleSpritesInvisibilities(void)
{
s32 i;
for (i = 0; i < gNoOfAllBanks; i++)
gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBankSpriteIds[i]].invisible;
for (i = 0; i < gBattlersCount; i++)
gBattleSpritesDataPtr->battlerData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible;
}
void CopyBattleSpriteInvisibility(u8 bank)
{
gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBankSpriteIds[bank]].invisible;
gBattleSpritesDataPtr->battlerData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible;
}
void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
@ -885,21 +885,21 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
u16 paletteOffset;
u32 personalityValue;
u32 otId;
u8 identity;
u8 position;
const u8 *lzPaletteData;
if (notTransform)
{
StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + bankAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk);
gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk);
}
else
{
@ -909,7 +909,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (IsContest())
{
identity = 0;
position = 0;
targetSpecies = gContestResources->field_18->field_2;
personalityValue = gContestResources->field_18->field_8;
otId = gContestResources->field_18->field_C;
@ -921,37 +921,37 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
}
else
{
identity = GetBankIdentity(bankAtk);
position = GetBattlerPosition(bankAtk);
if (GetBankSide(bankDef) == SIDE_OPPONENT)
targetSpecies = GetMonData(&gEnemyParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES);
if (GetBattlerSide(bankDef) == B_SIDE_OPPONENT)
targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES);
else
targetSpecies = GetMonData(&gPlayerParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES);
targetSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES);
if (GetBankSide(bankAtk) == SIDE_PLAYER)
if (GetBattlerSide(bankAtk) == B_SIDE_PLAYER)
{
personalityValue = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID);
personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
targetSpecies,
gTransformedPersonalities[bankAtk]);
}
else
{
personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID);
personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[identity],
gMonSpritesGfxPtr->sprites[position],
targetSpecies,
gTransformedPersonalities[bankAtk]);
}
}
src = gMonSpritesGfxPtr->sprites[identity];
dst = (void *)(VRAM + 0x10000 + gSprites[gBankSpriteIds[bankAtk]].oam.tileNum * 32);
src = gMonSpritesGfxPtr->sprites[position];
dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[bankAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800);
paletteOffset = 0x100 + bankAtk * 16;
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);
@ -960,7 +960,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (targetSpecies == SPECIES_CASTFORM)
{
gSprites[gBankSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies];
gSprites[gBattlerSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies];
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32);
}
@ -970,18 +970,18 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (!IsContest())
{
gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies = targetSpecies;
gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies = targetSpecies;
gBattleMonForms[bankAtk] = gBattleMonForms[bankDef];
}
gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk);
StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleMonForms[bankAtk]);
gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleMonForms[bankAtk]);
}
}
void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
{
u8 identity;
u8 position;
s32 i;
u32 var;
const void *substitutePal;
@ -989,23 +989,23 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
if (!loadMonSprite)
{
if (IsContest())
identity = 0;
position = 0;
else
identity = GetBankIdentity(bank);
position = GetBattlerPosition(bank);
if (IsContest())
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[identity]);
else if (GetBankSide(bank) != SIDE_PLAYER)
LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[identity]);
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
else if (GetBattlerSide(bank) != B_SIDE_PLAYER)
LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[position]);
else
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[identity]);
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
i = 1;
var = bank * 16;
substitutePal = gSubstituteDollPal;
for (; i < 4; i++)
{
register void *dmaSrc asm("r0") = gMonSpritesGfxPtr->sprites[identity];
register void *dmaSrc asm("r0") = gMonSpritesGfxPtr->sprites[position];
void *dmaDst = (i * 0x800) + dmaSrc;
u32 dmaSize = 0x800;
DmaCopy32(3, dmaSrc, dmaDst, dmaSize);
@ -1018,10 +1018,10 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
{
if (!IsContest())
{
if (GetBankSide(bank) != SIDE_PLAYER)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank);
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
else
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
}
}
}
@ -1034,18 +1034,18 @@ void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId)
if (!loadMonSprite)
gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(bank);
else
gSprites[spriteId].pos1.y = GetBankSpriteDefault_Y(bank);
gSprites[spriteId].pos1.y = GetBattlerSpriteDefault_Y(bank);
}
void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move)
{
if (move == MOVE_SUBSTITUTE)
gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 1;
gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 1;
}
void ClearBehindSubstituteBit(u8 bank)
{
gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 0;
gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 0;
}
void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
@ -1055,22 +1055,22 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED)
{
if (!gBattleSpritesDataPtr->bankData[bank].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[bank].lowHpSong)
{
if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
PlaySE(SE_HINSI);
gBattleSpritesDataPtr->bankData[bank].lowHpSong = 1;
gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 1;
}
}
else
{
gBattleSpritesDataPtr->bankData[bank].lowHpSong = 0;
gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 0;
if (!IsDoubleBattle())
{
m4aSongNumStop(SE_HINSI);
return;
}
if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong)
if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
{
m4aSongNumStop(SE_HINSI);
return;
@ -1080,11 +1080,11 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
void BattleStopLowHpSound(void)
{
u8 playerBank = GetBankByIdentity(IDENTITY_PLAYER_MON1);
u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0;
gBattleSpritesDataPtr->battlerData[playerBank].lowHpSong = 0;
if (IsDoubleBattle())
gBattleSpritesDataPtr->bankData[playerBank ^ BIT_MON].lowHpSong = 0;
gBattleSpritesDataPtr->battlerData[playerBank ^ BIT_FLANK].lowHpSong = 0;
m4aSongNumStop(SE_HINSI);
}
@ -1101,10 +1101,10 @@ void sub_805EAE8(void)
{
if (gMain.inBattle)
{
u8 playerBank1 = GetBankByIdentity(IDENTITY_PLAYER_MON1);
u8 playerBank2 = GetBankByIdentity(IDENTITY_PLAYER_MON2);
u8 bank1PartyId = pokemon_order_func(gBattlePartyID[playerBank1]);
u8 bank2PartyId = pokemon_order_func(gBattlePartyID[playerBank2]);
u8 playerBank1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
u8 playerBank2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
u8 bank1PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank1]);
u8 bank2PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank2]);
if (GetMonData(&gPlayerParty[bank1PartyId], MON_DATA_HP) != 0)
HandleLowHpMusicChange(&gPlayerParty[bank1PartyId], playerBank1);
@ -1117,19 +1117,19 @@ void sub_805EB9C(u8 affineMode)
{
s32 i;
for (i = 0; i < gNoOfAllBanks; i++)
for (i = 0; i < gBattlersCount; i++)
{
if (IsBankSpritePresent(i))
if (IsBattlerSpritePresent(i))
{
gSprites[gBankSpriteIds[i]].oam.affineMode = affineMode;
gSprites[gBattlerSpriteIds[i]].oam.affineMode = affineMode;
if (affineMode == 0)
{
gBattleSpritesDataPtr->healthBoxesData[i].field_6 = gSprites[gBankSpriteIds[i]].oam.matrixNum;
gSprites[gBankSpriteIds[i]].oam.matrixNum = 0;
gBattleSpritesDataPtr->healthBoxesData[i].field_6 = gSprites[gBattlerSpriteIds[i]].oam.matrixNum;
gSprites[gBattlerSpriteIds[i]].oam.matrixNum = 0;
}
else
{
gSprites[gBankSpriteIds[i]].oam.matrixNum = gBattleSpritesDataPtr->healthBoxesData[i].field_6;
gSprites[gBattlerSpriteIds[i]].oam.matrixNum = gBattleSpritesDataPtr->healthBoxesData[i].field_6;
}
}
}
@ -1143,14 +1143,14 @@ void LoadAndCreateEnemyShadowSprites(void)
LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow);
bank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankPosition(bank, 0), GetBankPosition(bank, 1) + 29, 0xC8);
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
if (IsDoubleBattle())
{
bank = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankPosition(bank, 0), GetBankPosition(bank, 1) + 29, 0xC8);
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
}
}
@ -1159,20 +1159,20 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{
bool8 invisible = FALSE;
u8 bank = shadowSprite->tBank;
struct Sprite *bankSprite = &gSprites[gBankSpriteIds[bank]];
struct Sprite *bankSprite = &gSprites[gBattlerSpriteIds[bank]];
if (!bankSprite->inUse || !IsBankSpritePresent(bank))
if (!bankSprite->inUse || !IsBattlerSpritePresent(bank))
{
shadowSprite->callback = SpriteCB_SetInvisible;
return;
}
if (gAnimScriptActive || bankSprite->invisible)
invisible = TRUE;
else if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->bankData[bank].transformSpecies] == 0)
else if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[bank].transformSpecies] == 0)
invisible = TRUE;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
if (gBattleSpritesDataPtr->battlerData[bank].behindSubstitute)
invisible = TRUE;
shadowSprite->pos1.x = bankSprite->pos1.x;
@ -1187,13 +1187,14 @@ void SpriteCB_SetInvisible(struct Sprite *sprite)
sprite->invisible = 1;
}
void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species)
void SetBattlerShadowSpriteCallback(u8 bank, u16 species)
{
if (GetBankSide(bank) == SIDE_PLAYER)
// The player's shadow is never seen
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies;
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
if (gEnemyMonElevation[species] != 0)
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow;
@ -1201,7 +1202,7 @@ void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species)
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
void EnemyShadowCallbackToSetInvisible(u8 bank)
void HideBattlerShadowSprite(u8 bank)
{
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
@ -1231,7 +1232,7 @@ void sub_805EF14(void)
void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute)
{
gBattleSpritesDataPtr->bankData[bank].transformSpecies = SPECIES_NONE;
gBattleSpritesDataPtr->battlerData[bank].transformSpecies = SPECIES_NONE;
gBattleMonForms[bank] = 0;
if (!dontClearSubstitute)
ClearBehindSubstituteBit(bank);
@ -1245,7 +1246,7 @@ void AllocateMonSpritesGfx(void)
gMonSpritesGfxPtr = AllocZeroed(sizeof(*gMonSpritesGfxPtr));
gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x8000);
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gMonSpritesGfxPtr->sprites[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000);
*(gMonSpritesGfxPtr->templates + i) = gUnknown_08329D98[i];
@ -1286,7 +1287,7 @@ bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon)
s16 hp, maxHP;
s32 barLevel;
if (GetMonData(mon, MON_DATA_STATUS) & (STATUS_ANY | STATUS_TOXIC_COUNTER))
if (GetMonData(mon, MON_DATA_STATUS) & (STATUS1_ANY | STATUS1_TOXIC_COUNTER))
return FALSE;
hp = GetMonData(mon, MON_DATA_HP);

View File

@ -153,10 +153,10 @@ enum
HEALTHBOX_GFX_117,
};
extern u8 gBanksByIdentity[BATTLE_BANKS_COUNT];
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gNoOfAllBanks;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount;
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern const u8 * const gNatureNamePointers[];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
@ -898,7 +898,7 @@ void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2)
// healthboxSpriteId_2 refers to the other part
// there's also one other sprite that appears to be a black square? dont fully understand its role
u8 CreateBankHealthboxSprites(u8 bank)
u8 CreateBattlerHealthboxSprites(u8 battler)
{
s16 data6 = 0;
u8 healthboxSpriteId_1, healthboxSpriteId_2;
@ -907,7 +907,7 @@ u8 CreateBankHealthboxSprites(u8 bank)
if (!IsDoubleBattle())
{
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1);
@ -932,10 +932,10 @@ u8 CreateBankHealthboxSprites(u8 bank)
}
else
{
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBankIdentity(bank) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBankIdentity(bank) / 2], 240, 160, 1);
healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2;
@ -947,8 +947,8 @@ u8 CreateBankHealthboxSprites(u8 bank)
}
else
{
healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBankIdentity(bank) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBankIdentity(bank) / 2], 240, 160, 1);
healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2;
@ -960,16 +960,16 @@ u8 CreateBankHealthboxSprites(u8 bank)
}
}
unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBanksByIdentity[bank]], 140, 60, 0);
unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[battler]], 140, 60, 0);
unkSpritePtr = &gSprites[unkSpriteId];
SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBankSide(bank)]);
SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(battler)]);
unkSpritePtr->subspriteMode = 2;
unkSpritePtr->oam.priority = 1;
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void*)(OBJ_VRAM0 + unkSpritePtr->oam.tileNum * 32), 64);
gSprites[healthboxSpriteId_1].data[5] = unkSpriteId;
gSprites[healthboxSpriteId_1].data[6] = bank;
gSprites[healthboxSpriteId_1].data[6] = battler;
gSprites[healthboxSpriteId_1].invisible = 1;
gSprites[healthboxSpriteId_2].invisible = 1;
@ -1087,11 +1087,11 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
{
s32 i;
for (i = 0; i < gNoOfAllBanks; i++)
for (i = 0; i < gBattlersCount; i++)
{
u8 healthboxSpriteId_1 = gHealthBoxesIds[i];
u8 healthboxSpriteId_2 = gSprites[gHealthBoxesIds[i]].oam.affineParam;
u8 healthboxSpriteId_3 = gSprites[gHealthBoxesIds[i]].data[5];
u8 healthboxSpriteId_1 = gHealthboxSpriteIds[i];
u8 healthboxSpriteId_2 = gSprites[gHealthboxSpriteIds[i]].oam.affineParam;
u8 healthboxSpriteId_3 = gSprites[gHealthboxSpriteIds[i]].data[5];
gSprites[healthboxSpriteId_1].oam.priority = priority;
gSprites[healthboxSpriteId_2].oam.priority = priority;
@ -1099,37 +1099,37 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
}
}
void SetBankHealthboxSpritePos(u8 bank)
void InitBattlerHealthboxCoords(u8 battler)
{
s16 x = 0, y = 0;
if (!IsDoubleBattle())
{
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
x = 44, y = 30;
else
x = 158, y = 88;
}
else
{
switch (GetBankIdentity(bank))
switch (GetBattlerPosition(battler))
{
case IDENTITY_PLAYER_MON1:
case B_POSITION_PLAYER_LEFT:
x = 159, y = 76;
break;
case IDENTITY_PLAYER_MON2:
case B_POSITION_PLAYER_RIGHT:
x = 171, y = 101;
break;
case IDENTITY_OPPONENT_MON1:
case B_POSITION_OPPONENT_LEFT:
x = 44, y = 19;
break;
case IDENTITY_OPPONENT_MON2:
case B_POSITION_OPPONENT_RIGHT:
x = 32, y = 44;
break;
}
}
UpdateSpritePos(gHealthBoxesIds[bank], x, y);
UpdateSpritePos(gHealthboxSpriteIds[battler], x, y);
}
static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
@ -1156,7 +1156,7 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, xPos, 3, 2, &windowId);
spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32;
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER)
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
objVram = (void*)(OBJ_VRAM0);
if (!IsDoubleBattle())
@ -1180,7 +1180,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent)
u8 text[32];
void *objVram;
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER && !IsDoubleBattle())
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER && !IsDoubleBattle())
{
spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32;
if (maxOrCurrent != HP_CURRENT) // singles, max
@ -1210,11 +1210,11 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent)
}
else
{
u8 bank;
u8 battler;
memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4));
bank = gSprites[healthboxSpriteId].data[6];
if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT)
battler = gSprites[healthboxSpriteId].data[6];
if (IsDoubleBattle() == TRUE || GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
UpdateHpTextInHealthboxInDoubles(healthboxSpriteId, value, maxOrCurrent);
}
@ -1223,7 +1223,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent)
u32 var;
u8 i;
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER)
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
if (maxOrCurrent == HP_CURRENT)
var = 29;
@ -1258,9 +1258,9 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
u8 text[32];
void *objVram;
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER)
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
if (gBattleSpritesDataPtr->bankData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible
if (gBattleSpritesDataPtr->battlerData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible
{
spriteTileNum = gSprites[gSprites[healthboxSpriteId].data[5]].oam.tileNum * 32;
objVram = (void*)(OBJ_VRAM0) + spriteTileNum;
@ -1294,7 +1294,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8));
bank = gSprites[healthboxSpriteId].data[6];
if (gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) // don't print text if only bars are visible
if (gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) // don't print text if only bars are visible
{
u8 var = 4;
u8 r7;
@ -1335,7 +1335,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
}
else
{
if (GetBankSide(bank) == SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side
if (GetBattlerSide(bank) == B_SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_116),
(void*)(OBJ_VRAM0) + ((gSprites[healthboxSpriteId].oam.tileNum + 52) * 32),
@ -1354,7 +1354,7 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon)
u8 i, var, nature, healthboxSpriteId_2;
memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4));
barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBankIdentity(gSprites[healthboxSpriteId].data[6]) * 384)];
barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].data[6]) * 384)];
var = 5;
nature = GetNature(mon);
StringCopy(text + 6, gNatureNamePointers[nature]);
@ -1415,17 +1415,17 @@ void SwapHpBarsWithHpText(void)
s32 i;
u8 spriteId;
for (i = 0; i < gNoOfAllBanks; i++)
for (i = 0; i < gBattlersCount; i++)
{
if (gSprites[gHealthBoxesIds[i]].callback == SpriteCallbackDummy
&& GetBankSide(i) != SIDE_OPPONENT
&& (IsDoubleBattle() || GetBankSide(i) != SIDE_PLAYER))
if (gSprites[gHealthboxSpriteIds[i]].callback == SpriteCallbackDummy
&& GetBattlerSide(i) != B_SIDE_OPPONENT
&& (IsDoubleBattle() || GetBattlerSide(i) != B_SIDE_PLAYER))
{
bool8 noBars;
gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars ^= 1;
noBars = gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars;
if (GetBankSide(i) == SIDE_PLAYER)
gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars ^= 1;
noBars = gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars;
if (GetBattlerSide(i) == B_SIDE_PLAYER)
{
if (!IsDoubleBattle())
continue;
@ -1434,17 +1434,17 @@ void SwapHpBarsWithHpText(void)
if (noBars == TRUE) // bars to text
{
spriteId = gSprites[gHealthBoxesIds[i]].data[5];
spriteId = gSprites[gHealthboxSpriteIds[i]].data[5];
CpuFill32(0, (void*)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_MAX_HP), HP_MAX);
UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), HP_MAX);
}
else // text to bars
{
UpdateStatusIconInHealthbox(gHealthBoxesIds[i]);
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gPlayerParty[gBattlePartyID[i]], HEALTHBOX_HEALTH_BAR);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_117), (void*)(OBJ_VRAM0 + 0x680 + gSprites[gHealthBoxesIds[i]].oam.tileNum * 32), 32);
UpdateStatusIconInHealthbox(gHealthboxSpriteIds[i]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gPlayerParty[gBattlerPartyIndexes[i]], HEALTHBOX_HEALTH_BAR);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_117), (void*)(OBJ_VRAM0 + 0x680 + gSprites[gHealthboxSpriteIds[i]].oam.tileNum * 32), 32);
}
}
else
@ -1453,26 +1453,26 @@ void SwapHpBarsWithHpText(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
{
sub_80730D4(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]]);
sub_80730D4(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]]);
}
else
{
spriteId = gSprites[gHealthBoxesIds[i]].data[5];
spriteId = gSprites[gHealthboxSpriteIds[i]].data[5];
CpuFill32(0, (void *)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_MAX_HP), HP_MAX);
UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), HP_MAX);
}
}
else // text to bars
{
UpdateStatusIconInHealthbox(gHealthBoxesIds[i]);
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]], HEALTHBOX_HEALTH_BAR);
UpdateStatusIconInHealthbox(gHealthboxSpriteIds[i]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], HEALTHBOX_HEALTH_BAR);
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]], HEALTHBOX_NICK);
UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], HEALTHBOX_NICK);
}
}
gSprites[gHealthBoxesIds[i]].data[7] ^= 1;
gSprites[gHealthboxSpriteIds[i]].data[7] ^= 1;
}
}
}
@ -1486,9 +1486,9 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
u8 ballIconSpritesIds[6];
u8 taskId;
if (!arg2 || GetBankIdentity(bank) != IDENTITY_OPPONENT_MON2)
if (!arg2 || GetBattlerPosition(bank) != B_POSITION_OPPONENT_RIGHT)
{
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
{
isOpponent = FALSE;
bar_X = 136, bar_Y = 96;
@ -1567,7 +1567,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
gSprites[ballIconSpritesIds[i]].data[2] = isOpponent;
}
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
@ -1712,7 +1712,7 @@ void sub_8073C30(u8 taskId)
{
for (i = 0; i < 6; i++)
{
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{
gSprites[sp[5 - i]].data[1] = 7 * i;
gSprites[sp[5 - i]].data[3] = 0;
@ -1964,7 +1964,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32;
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER)
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
sub_8075198((void*)(0x6010040 + spriteTileNum), windowTileData, 6);
ptr = (void*)(OBJ_VRAM0);
@ -1992,9 +1992,9 @@ static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
return;
bank = gSprites[healthboxSpriteId].data[6];
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return;
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
return;
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
@ -2016,9 +2016,9 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
bank = gSprites[healthboxSpriteId].data[6];
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
if (GetBankSide(bank) == SIDE_PLAYER)
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
{
status = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_STATUS);
status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
if (!IsDoubleBattle())
tileNumAdder = 0x1A;
else
@ -2026,31 +2026,31 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
}
else
{
status = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_STATUS);
status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
tileNumAdder = 0x11;
}
if (status & STATUS_SLEEP)
if (status & STATUS1_SLEEP)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, bank));
statusPalId = PAL_STATUS_SLP;
}
else if (status & STATUS_PSN_ANY)
else if (status & STATUS1_PSN_ANY)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, bank));
statusPalId = PAL_STATUS_PSN;
}
else if (status & STATUS_BURN)
else if (status & STATUS1_BURN)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, bank));
statusPalId = PAL_STATUS_BRN;
}
else if (status & STATUS_FREEZE)
else if (status & STATUS1_FREEZE)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, bank));
statusPalId = PAL_STATUS_FRZ;
}
else if (status & STATUS_PARALYSIS)
else if (status & STATUS1_PARALYSIS)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, bank));
statusPalId = PAL_STATUS_PAR;
@ -2062,7 +2062,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
for (i = 0; i < 3; i++)
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32);
if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64);
TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE);
@ -2075,9 +2075,9 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2);
CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2);
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96);
if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT)
if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT)
{
if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32);
@ -2181,9 +2181,9 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
u8 bank = gSprites[healthboxSpriteId].data[6];
if (elementId == HEALTHBOX_ALL && !IsDoubleBattle())
GetBankSide(bank); // pointless function call
GetBattlerSide(bank); // pointless function call
if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER)
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
u8 isDoubles;
@ -2275,7 +2275,7 @@ s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
8, expFraction);
}
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars))
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars))
sub_8074B9C(bank, whichBar);
if (var == -1)
@ -2323,7 +2323,7 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
array, 8);
level = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_LEVEL);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_LEVEL);
if (level == MAX_MON_LEVEL)
{
for (i = 0; i < 8; i++)

File diff suppressed because it is too large Load Diff

View File

@ -16,20 +16,20 @@
extern u16 gLastUsedItem;
extern u8 gLastUsedAbility;
extern u8 gActiveBank;
extern u8 gBankAttacker;
extern u8 gBankTarget;
extern u8 gStringBank;
extern u8 gActiveBattler;
extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
extern u8 gStringBattler;
extern u8 gEffectBank;
extern u8 gAbilitiesPerBank[BATTLE_BANKS_COUNT];
extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT];
extern u32 gBattleTypeFlags;
extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B;
extern u16 gPartnerTrainerId;
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT];
extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gUnknown_0203C7B4;
extern struct StringInfoBattle *gStringInfo;
@ -1430,18 +1430,18 @@ void BufferStringBattle(u16 stringID)
s32 i;
const u8* stringPtr = NULL;
gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBank][4]);
gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBattler][4]);
gLastUsedItem = gStringInfo->lastItem;
gLastUsedAbility = gStringInfo->lastAbility;
gBattleScripting.bank = gStringInfo->scrActive;
gBattleScripting.battler = gStringInfo->scrActive;
*(&gBattleStruct->field_52) = gStringInfo->unk1605E;
*(&gBattleStruct->hpScale) = gStringInfo->hpScale;
gStringBank = gStringInfo->StringBank;
gStringBattler = gStringInfo->StringBank;
*(&gBattleStruct->stringMoveType) = gStringInfo->moveType;
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gAbilitiesPerBank[i] = gStringInfo->abilities[i];
gBattlerAbilities[i] = gStringInfo->abilities[i];
}
for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++)
{
@ -1501,7 +1501,7 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_INTROSENDOUT: // poke first send-out
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
@ -1546,7 +1546,7 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_RETURNMON: // sending poke to ball msg
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{
if (*(&gBattleStruct->hpScale) == 0)
stringPtr = gText_PkmnThatsEnough;
@ -1573,7 +1573,7 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_SWITCHINMON: // switch-in msg
if (GetBankSide(gBattleScripting.bank) == SIDE_PLAYER)
if (GetBattlerSide(gBattleScripting.battler) == B_SIDE_PLAYER)
{
if (*(&gBattleStruct->hpScale) == 0 || gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
stringPtr = gText_GoPkmn2;
@ -1590,7 +1590,7 @@ void BufferStringBattle(u16 stringID)
{
if (gBattleTypeFlags & BATTLE_TYPE_x800000)
{
if (gBattleScripting.bank == 1)
if (gBattleScripting.battler == 1)
stringPtr = gText_Trainer1SentOutPkmn2;
else
stringPtr = gText_Trainer2SentOutPkmn;
@ -1609,7 +1609,7 @@ void BufferStringBattle(u16 stringID)
{
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gBattleScripting.bank == 1)
if (gBattleScripting.battler == 1)
stringPtr = gText_Trainer1SentOutPkmn2;
else
stringPtr = gText_Trainer2SentOutPkmn;
@ -1633,13 +1633,13 @@ void BufferStringBattle(u16 stringID)
stringPtr = gText_AttackerUsedX;
break;
case STRINGID_BATTLEEND: // battle end
if (gBattleTextBuff1[0] & OUTCOME_LINK_BATTLE_RUN)
if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN)
{
gBattleTextBuff1[0] &= ~(OUTCOME_LINK_BATTLE_RUN);
if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != BATTLE_DREW)
gBattleTextBuff1[0] ^= (BATTLE_LOST | BATTLE_WON);
gBattleTextBuff1[0] &= ~(B_OUTCOME_LINK_BATTLE_RAN);
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTextBuff1[0] == BATTLE_LOST || gBattleTextBuff1[0] == BATTLE_DREW)
if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW)
stringPtr = gText_GotAwaySafely;
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
stringPtr = gText_TwoWildFled;
@ -1648,23 +1648,23 @@ void BufferStringBattle(u16 stringID)
}
else
{
if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != BATTLE_DREW)
gBattleTextBuff1[0] ^= (BATTLE_LOST | BATTLE_WON);
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
switch (gBattleTextBuff1[0])
{
case BATTLE_WON:
case B_OUTCOME_WON:
if (gBattleTypeFlags & BATTLE_TYPE_x800000)
stringPtr = gText_TwoInGameTrainersDefeated;
else
stringPtr = gText_TwoLinkTrainersDefeated;
break;
case BATTLE_LOST:
case B_OUTCOME_LOST:
stringPtr = gText_PlayerLostToTwo;
break;
case BATTLE_DREW:
case B_OUTCOME_DREW:
stringPtr = gText_PlayerBattledToDrawVsTwo;
break;
}
@ -1673,13 +1673,13 @@ void BufferStringBattle(u16 stringID)
{
switch (gBattleTextBuff1[0])
{
case BATTLE_WON:
case B_OUTCOME_WON:
stringPtr = gText_PlayerDefeatedLinkTrainerTrainer1;
break;
case BATTLE_LOST:
case B_OUTCOME_LOST:
stringPtr = gText_PlayerLostAgainstTrainer1;
break;
case BATTLE_DREW:
case B_OUTCOME_DREW:
stringPtr = gText_PlayerBattledToDrawTrainer1;
break;
}
@ -1688,13 +1688,13 @@ void BufferStringBattle(u16 stringID)
{
switch (gBattleTextBuff1[0])
{
case BATTLE_WON:
case B_OUTCOME_WON:
stringPtr = gText_PlayerDefeatedLinkTrainer;
break;
case BATTLE_LOST:
case B_OUTCOME_LOST:
stringPtr = gText_PlayerLostAgainstLinkTrainer;
break;
case BATTLE_DREW:
case B_OUTCOME_DREW:
stringPtr = gText_PlayerBattledToDrawLinkTrainer;
break;
}
@ -1754,7 +1754,7 @@ static const u8* TryGetStatusString(u8* src)
}
#define HANDLE_NICKNAME_STRING_CASE(bank, monIndex) \
if (GetBankSide(bank) != SIDE_PLAYER) \
if (GetBattlerSide(bank) != B_SIDE_PLAYER) \
{ \
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
toCpy = gText_FoePkmnPrefix; \
@ -1836,80 +1836,80 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gStringVar3;
break;
case B_TXT_PLAYER_MON1_NAME: // first player poke name
GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(IDENTITY_PLAYER_MON1)]],
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name
GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(IDENTITY_OPPONENT_MON1)]],
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_PLAYER_MON2_NAME: // second player poke name
GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(IDENTITY_PLAYER_MON2)]],
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name
GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(IDENTITY_OPPONENT_MON2)]],
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_LINK_PLAYER_MON1_NAME: // link first player poke name
GetMonData(&gPlayerParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18]],
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_LINK_OPPONENT_MON1_NAME: // link first opponent poke name
GetMonData(&gEnemyParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 1]],
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 1]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_LINK_PLAYER_MON2_NAME: // link second player poke name
GetMonData(&gPlayerParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 2]],
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 2]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_LINK_OPPONENT_MON2_NAME: // link second opponent poke name
GetMonData(&gEnemyParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 3]],
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 3]],
MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1
HANDLE_NICKNAME_STRING_CASE(gBankAttacker,
gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker))])
HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker,
gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker))])
break;
case B_TXT_ATK_PARTNER_NAME: // attacker partner name
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text);
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text);
else
GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text);
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text);
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix
HANDLE_NICKNAME_STRING_CASE(gBankAttacker, gBattlePartyID[gBankAttacker])
HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker])
break;
case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix
HANDLE_NICKNAME_STRING_CASE(gBankTarget, gBattlePartyID[gBankTarget])
HANDLE_NICKNAME_STRING_CASE(gBattlerTarget, gBattlerPartyIndexes[gBattlerTarget])
break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlePartyID[gEffectBank])
HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlerPartyIndexes[gEffectBank])
break;
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBank, gBattlePartyID[gActiveBank])
HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
break;
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, gBattlePartyID[gBattleScripting.bank])
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler])
break;
case B_TXT_CURRENT_MOVE: // current move name
if (gStringInfo->currentMove > LAST_MOVE_INDEX)
@ -1930,10 +1930,10 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
if ((gBattleScripting.multiplayerId != 0 && (gStringBank & BIT_SIDE))
|| (gBattleScripting.multiplayerId == 0 && !(gStringBank & BIT_SIDE)))
if ((gBattleScripting.multiplayerId != 0 && (gStringBattler & BIT_SIDE))
|| (gBattleScripting.multiplayerId == 0 && !(gStringBattler & BIT_SIDE)))
{
StringCopy(text, gEnigmaBerries[gStringBank].name);
StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringAppend(text, gText_BerrySuffix);
toCpy = text;
}
@ -1944,9 +1944,9 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
}
else
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank)
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
{
StringCopy(text, gEnigmaBerries[gStringBank].name);
StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringAppend(text, gText_BerrySuffix);
toCpy = text;
}
@ -1970,16 +1970,16 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gAbilityNames[gLastUsedAbility];
break;
case B_TXT_ATK_ABILITY: // attacker ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBankAttacker]];
toCpy = gAbilityNames[gBattlerAbilities[gBattlerAttacker]];
break;
case B_TXT_DEF_ABILITY: // target ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBankTarget]];
toCpy = gAbilityNames[gBattlerAbilities[gBattlerTarget]];
break;
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.bank]];
toCpy = gAbilityNames[gBattlerAbilities[gBattleScripting.battler]];
break;
case B_TXT_EFF_ABILITY: // effect bank ability
toCpy = gAbilityNames[gAbilitiesPerBank[gEffectBank]];
toCpy = gAbilityNames[gBattlerAbilities[gEffectBank]];
break;
case B_TXT_TRAINER1_CLASS: // trainer class name
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
@ -2039,16 +2039,16 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gLinkPlayers[multiplayerID].name;
break;
case B_TXT_1F: // link partner name?
toCpy = gLinkPlayers[GetBankMultiplayerId(2 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(2 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break;
case B_TXT_20: // link opponent 1 name?
toCpy = gLinkPlayers[GetBankMultiplayerId(1 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(1 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break;
case B_TXT_21: // link opponent 2 name?
toCpy = gLinkPlayers[GetBankMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break;
case B_TXT_22: // link scripting active name
toCpy = gLinkPlayers[GetBankMultiplayerId(gBattleScripting.bank)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(gBattleScripting.battler)].name;
break;
case B_TXT_PLAYER_NAME: // player name
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -2085,7 +2085,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
}
break;
case B_TXT_26: // ?
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, *(&gBattleStruct->field_52))
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, *(&gBattleStruct->field_52))
break;
case B_TXT_PC_CREATOR_NAME: // lanette pc
if (FlagGet(FLAG_SYS_PC_LANETTE))
@ -2094,37 +2094,37 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gText_Someones;
break;
case B_TXT_ATK_PREFIX2:
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2;
else
toCpy = gText_FoePkmnPrefix3;
break;
case B_TXT_DEF_PREFIX2:
if (GetBankSide(gBankTarget) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2;
else
toCpy = gText_FoePkmnPrefix3;
break;
case B_TXT_ATK_PREFIX1:
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix;
else
toCpy = gText_FoePkmnPrefix2;
break;
case B_TXT_DEF_PREFIX1:
if (GetBankSide(gBankTarget) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix;
else
toCpy = gText_FoePkmnPrefix2;
break;
case B_TXT_ATK_PREFIX3:
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3;
else
toCpy = gText_FoePkmnPrefix4;
break;
case B_TXT_DEF_PREFIX3:
if (GetBankSide(gBankTarget) == SIDE_PLAYER)
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3;
else
toCpy = gText_FoePkmnPrefix4;
@ -2266,7 +2266,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 2;
break;
case B_BUFF_MON_NICK_WITH_PREFIX: // poke nick with prefix
if (GetBankSide(src[srcID + 1]) == SIDE_PLAYER)
if (GetBattlerSide(src[srcID + 1]) == B_SIDE_PLAYER)
{
GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, text);
}
@ -2292,7 +2292,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 3;
break;
case B_BUFF_MON_NICK: // poke nick without prefix
if (GetBankSide(src[srcID + 1]) == SIDE_PLAYER)
if (GetBattlerSide(src[srcID + 1]) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, dst);
else
GetMonData(&gEnemyParty[src[srcID + 2]], MON_DATA_NICKNAME, dst);
@ -2313,9 +2313,9 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
{
if (hword == ITEM_ENIGMA_BERRY)
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank)
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
{
StringCopy(dst, gEnigmaBerries[gStringBank].name);
StringCopy(dst, gEnigmaBerries[gStringBattler].name);
StringAppend(dst, gText_BerrySuffix);
}
else
@ -2490,10 +2490,10 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1)
void SetPpNumbersPaletteInMoveSelection(void)
{
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]);
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
const u16 *palPtr = gUnknown_08D85620;
u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBank]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBank]]);
u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]);
gPlttBufferUnfaded[92] = palPtr[(var * 2) + 0];
gPlttBufferUnfaded[91] = palPtr[(var * 2) + 1];

File diff suppressed because it is too large Load Diff

View File

@ -990,14 +990,14 @@ static bool32 IsPlayerDefeated(u32 battleOutcome)
{
switch (battleOutcome)
{
case BATTLE_LOST:
case BATTLE_DREW:
case B_OUTCOME_LOST:
case B_OUTCOME_DREW:
return TRUE;
case BATTLE_WON:
case BATTLE_RAN:
case BATTLE_PLAYER_TELEPORTED:
case BATTLE_POKE_FLED:
case BATTLE_CAUGHT:
case B_OUTCOME_WON:
case B_OUTCOME_RAN:
case B_OUTCOME_PLAYER_TELEPORTED:
case B_OUTCOME_POKE_FLED:
case B_OUTCOME_CAUGHT_POKE:
return FALSE;
default:
return FALSE;

File diff suppressed because it is too large Load Diff

View File

@ -8,12 +8,12 @@
#include "random.h"
#include "battle_scripts.h"
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gUnknown_0203CF00[];
extern const u8 *gBattlescriptCurrInstr;
extern u8 gBattleCommunication[];
extern u8 gActiveBank;
extern u8 gActiveBattler;
extern void sub_81D55D0(void);
extern void sub_81D5694(void);
@ -87,33 +87,33 @@ void AdjustFriendshipOnBattleFaint(u8 bank)
{
u8 opposingBank2;
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
opposingBank2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level)
opposingBank = opposingBank2;
}
else
{
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
}
if (gBattleMons[opposingBank].level > gBattleMons[bank].level)
{
if (gBattleMons[opposingBank].level - gBattleMons[bank].level > 29)
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 8);
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 8);
else
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 6);
}
else
{
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 6);
}
}
void sub_80571DC(u8 bank, u8 arg1)
{
if (GetBankSide(bank) != SIDE_OPPONENT)
if (GetBattlerSide(bank) != B_SIDE_OPPONENT)
{
s32 i;
@ -122,7 +122,7 @@ void sub_80571DC(u8 bank, u8 arg1)
for (i = 0; i < 3; i++)
gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60));
sub_81B8FB0(pokemon_order_func(gBattlePartyID[bank]), pokemon_order_func(arg1));
sub_81B8FB0(pokemon_order_func(gBattlerPartyIndexes[bank]), pokemon_order_func(arg1));
for (i = 0; i < 3; i++)
*(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
@ -138,11 +138,11 @@ u32 sub_805725C(u8 bank)
switch (gBattleCommunication[MULTIUSE_STATE])
{
case 0:
if (gBattleMons[bank].status1 & STATUS_SLEEP)
if (gBattleMons[bank].status1 & STATUS1_SLEEP)
{
if (UproarWakeUpCheck(bank))
{
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
gBattleMons[bank].status1 &= ~(STATUS1_SLEEP);
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
@ -158,12 +158,12 @@ u32 sub_805725C(u8 bank)
else
toSub = 1;
if ((gBattleMons[bank].status1 & STATUS_SLEEP) < toSub)
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
if ((gBattleMons[bank].status1 & STATUS1_SLEEP) < toSub)
gBattleMons[bank].status1 &= ~(STATUS1_SLEEP);
else
gBattleMons[bank].status1 -= toSub;
if (gBattleMons[bank].status1 & STATUS_SLEEP)
if (gBattleMons[bank].status1 & STATUS1_SLEEP)
{
gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep;
effect = 2;
@ -181,7 +181,7 @@ u32 sub_805725C(u8 bank)
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 1:
if (gBattleMons[bank].status1 & STATUS_FREEZE)
if (gBattleMons[bank].status1 & STATUS1_FREEZE)
{
if (Random() % 5 != 0)
{
@ -189,7 +189,7 @@ u32 sub_805725C(u8 bank)
}
else
{
gBattleMons[bank].status1 &= ~(STATUS_FREEZE);
gBattleMons[bank].status1 &= ~(STATUS1_FREEZE);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
@ -206,9 +206,9 @@ u32 sub_805725C(u8 bank)
if (effect == 2)
{
gActiveBank = bank;
EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1);
MarkBufferBankForExecution(gActiveBank);
gActiveBattler = bank;
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
}
return effect;

View File

@ -177,7 +177,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
damage = damage / damageHelper;
damage /= 50;
if ((attacker->status1 & STATUS_BURN) && attacker->ability != ABILITY_GUTS)
if ((attacker->status1 & STATUS1_BURN) && attacker->ability != ABILITY_GUTS)
damage /= 2;
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)

View File

@ -42,7 +42,7 @@ static bool32 sub_80F958C(void)
static void sub_80F95C0(u8 partyIdx)
{
struct Pokemon *pokemon = gPlayerParty + partyIdx;
unsigned int status = STATUS_NONE;
unsigned int status = STATUS1_NONE;
AdjustFriendship(pokemon, 0x07);
SetMonData(pokemon, MON_DATA_STATUS, &status);
GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1);

View File

@ -89,7 +89,7 @@ extern void flagmods_08054D70(void);
extern u8* sub_806CF78(u16);
extern bool8 ExecuteTableBasedItemEffect_(struct Pokemon*, u16, u8, u8);
extern u8 gBankInMenu;
extern u16 gBattlePartyID[];
extern u16 gBattlerPartyIndexes[];
extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16);
extern struct MapConnection *sub_8088A8C(s16, s16);
@ -984,7 +984,7 @@ void sub_80FE440(u8 taskId)
void ItemUseInBattle_StatIncrease(u8 taskId)
{
u16 partyId = gBattlePartyID[gBankInMenu];
u16 partyId = gBattlerPartyIndexes[gBankInMenu];
if (ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE)
{

View File

@ -16,11 +16,11 @@
#include "graphics.h"
extern bool8 gDoingBattleAnim;
extern u8 gActiveBank;
extern u8 gBankTarget;
extern u16 gBattlePartyID[];
extern u8 gBankSpriteIds[];
extern u8 gHealthBoxesIds[];
extern u8 gActiveBattler;
extern u8 gBattlerTarget;
extern u16 gBattlerPartyIndexes[];
extern u8 gBattlerSpriteIds[];
extern u8 gHealthboxSpriteIds[];
extern struct MusicPlayerInfo gMPlayInfo_BGM;
// this file's functions
@ -334,12 +334,12 @@ u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
u8 taskId;
gDoingBattleAnim = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = 1;
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
gTasks[taskId].tPan = pan;
gTasks[taskId].tThrowId = kindOfThrow;
gTasks[taskId].tBank = gActiveBank;
gTasks[taskId].tBank = gActiveBattler;
return 0;
}
@ -363,10 +363,10 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
throwCaseId = gTasks[taskId].tThrowId;
bank = gTasks[taskId].tBank;
if (GetBankSide(bank) != SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
else
itemId = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL);
itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
ballId = ItemIdToBallId(itemId);
LoadBallGfx(ballId);
@ -378,25 +378,25 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
switch (throwCaseId)
{
case POKEBALL_PLAYER_SENDOUT:
gBankTarget = bank;
gBattlerTarget = bank;
gSprites[ballSpriteId].pos1.x = 24;
gSprites[ballSpriteId].pos1.y = 68;
gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1;
break;
case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].pos1.x = GetBankPosition(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBankPosition(bank, BANK_Y_POS) + 24;
gBankTarget = bank;
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24;
gBattlerTarget = bank;
gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut;
break;
default:
gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
notSendOut = TRUE;
break;
}
gSprites[ballSpriteId].sBank = gBankTarget;
gSprites[ballSpriteId].sBank = gBattlerTarget;
if (!notSendOut)
{
DestroyTask(taskId);
@ -405,12 +405,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
// this will perform an unused ball throw animation
gSprites[ballSpriteId].data[0] = 0x22;
gSprites[ballSpriteId].data[2] = GetBankPosition(gBankTarget, BANK_X_POS);
gSprites[ballSpriteId].data[4] = GetBankPosition(gBankTarget, BANK_Y_POS) - 16;
gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattlerTarget, BANK_X_POS);
gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattlerTarget, BANK_Y_POS) - 16;
gSprites[ballSpriteId].data[5] = -40;
sub_80A68D4(&gSprites[ballSpriteId]);
gSprites[ballSpriteId].oam.affineParam = taskId;
gTasks[taskId].tOpponentBank = gBankTarget;
gTasks[taskId].tOpponentBank = gBattlerTarget;
gTasks[taskId].func = TaskDummy;
PlaySE(SE_NAGERU);
}
@ -458,9 +458,9 @@ static void sub_80756E0(struct Sprite *sprite)
{
sprite->data[5] = 0;
sprite->callback = sub_807574C;
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->sBank]], 2);
AnimateSprite(&gSprites[gBankSpriteIds[sprite->sBank]]);
gSprites[gBankSpriteIds[sprite->sBank]].data[1] = 0;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 2);
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0;
}
}
@ -469,17 +469,17 @@ static void sub_807574C(struct Sprite *sprite)
sprite->data[5]++;
if (sprite->data[5] == 11)
PlaySE(SE_SUIKOMU);
if (gSprites[gBankSpriteIds[sprite->sBank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[sprite->sBank]].affineAnimEnded)
{
StartSpriteAnim(sprite, 2);
gSprites[gBankSpriteIds[sprite->sBank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[sprite->sBank]].invisible = TRUE;
sprite->data[5] = 0;
sprite->callback = sub_80757E4;
}
else
{
gSprites[gBankSpriteIds[sprite->sBank]].data[1] += 0x60;
gSprites[gBankSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBankSpriteIds[sprite->sBank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] += 0x60;
gSprites[gBattlerSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] >> 8;
}
}
@ -755,19 +755,19 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
u16 wantedCryCase;
u8 taskId;
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{
mon = &gEnemyParty[gBattlePartyID[bank]];
mon = &gEnemyParty[gBattlerPartyIndexes[bank]];
pan = 25;
}
else
{
mon = &gPlayerParty[gBattlePartyID[bank]];
mon = &gPlayerParty[gBattlerPartyIndexes[bank]];
pan = -25;
}
species = GetMonData(mon, MON_DATA_SPECIES);
if ((bank == GetBankByIdentity(IDENTITY_PLAYER_MON1) || bank == GetBankByIdentity(IDENTITY_OPPONENT_MON1))
if ((bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
&& IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
@ -783,7 +783,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1)
wantedCryCase = 0;
else if (bank == GetBankByIdentity(IDENTITY_PLAYER_MON1) || bank == GetBankByIdentity(IDENTITY_OPPONENT_MON1))
else if (bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
wantedCryCase = 1;
else
wantedCryCase = 2;
@ -795,21 +795,21 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
gTasks[taskId].tCryTaskPan = pan;
gTasks[taskId].tCryTaskWantedCry = wantedCryCase;
gTasks[taskId].tCryTaskBank = bank;
gTasks[taskId].tCryTaskMonSpriteId = gBankSpriteIds[sprite->sBank];
gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBank];
gTasks[taskId].tCryTaskMonPtr1 = (u32)(mon) >> 0x10;
gTasks[taskId].tCryTaskMonPtr2 = (u32)(mon);
gTasks[taskId].tCryTaskState = 0;
}
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->sBank]], 1);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 1);
if (GetBankSide(sprite->sBank) == SIDE_OPPONENT)
gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039B58;
if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039B58;
else
gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039E44;
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039E44;
AnimateSprite(&gSprites[gBankSpriteIds[sprite->sBank]]);
gSprites[gBankSpriteIds[sprite->sBank]].data[1] = 0x1000;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0x1000;
}
#undef tCryTaskSpecies
@ -836,35 +836,35 @@ static void HandleBallAnimEnd(struct Sprite *sprite)
bool8 affineAnimEnded = FALSE;
u8 bank = sprite->sBank;
gSprites[gBankSpriteIds[bank]].invisible = FALSE;
gSprites[gBattlerSpriteIds[bank]].invisible = FALSE;
if (sprite->animEnded)
sprite->invisible = TRUE;
if (gSprites[gBankSpriteIds[bank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[bank]].affineAnimEnded)
{
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[bank]], 0);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
affineAnimEnded = TRUE;
}
else
{
gSprites[gBankSpriteIds[bank]].data[1] -= 288;
gSprites[gBankSpriteIds[bank]].pos2.y = gSprites[gBankSpriteIds[bank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[bank]].data[1] -= 288;
gSprites[gBattlerSpriteIds[bank]].pos2.y = gSprites[gBattlerSpriteIds[bank]].data[1] >> 8;
}
if (sprite->animEnded && affineAnimEnded)
{
s32 i, doneBanks;
gSprites[gBankSpriteIds[bank]].pos2.y = 0;
gSprites[gBattlerSpriteIds[bank]].pos2.y = 0;
gDoingBattleAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
for (doneBanks = 0, i = 0; i < BATTLE_BANKS_COUNT; i++)
for (doneBanks = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == 0)
doneBanks++;
}
if (doneBanks == BATTLE_BANKS_COUNT)
if (doneBanks == MAX_BATTLERS_COUNT)
{
for (i = 0; i < POKEBALL_COUNT; i++)
FreeBallGfx(i);
@ -889,8 +889,8 @@ static void sub_80760F8(struct Sprite *sprite)
}
else if (sprite->data[4] == 315)
{
FreeOamMatrix(gSprites[gBankSpriteIds[sprite->sBank]].oam.matrixNum);
DestroySprite(&gSprites[gBankSpriteIds[sprite->sBank]]);
FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBank]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
DestroySpriteAndFreeResources(sprite);
if (gMain.inBattle)
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
@ -900,8 +900,8 @@ static void sub_80760F8(struct Sprite *sprite)
static void SpriteCB_PlayerMonSendOut_1(struct Sprite *sprite)
{
sprite->data[0] = 25;
sprite->data[2] = GetBankPosition(sprite->sBank, 2);
sprite->data[4] = GetBankPosition(sprite->sBank, 3) + 24;
sprite->data[2] = GetBattlerSpriteCoord(sprite->sBank, 2);
sprite->data[4] = GetBattlerSpriteCoord(sprite->sBank, 3) + 24;
sprite->data[5] = -30;
sprite->oam.affineParam = sprite->sBank;
sub_80A68D4(sprite);
@ -956,7 +956,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBankByIdentity(IDENTITY_PLAYER_MON2))
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
@ -982,7 +982,7 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite)
{
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBankByIdentity(IDENTITY_OPPONENT_MON2))
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
@ -1183,14 +1183,14 @@ static void DestroySpriteAndFreeResources_(struct Sprite *sprite)
void sub_8076918(u8 bank)
{
struct Sprite *healthboxSprite = &gSprites[gHealthBoxesIds[bank]];
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[bank]];
healthboxSprite->data[0] = 5;
healthboxSprite->data[1] = 0;
healthboxSprite->pos2.x = 0x73;
healthboxSprite->pos2.y = 0;
healthboxSprite->callback = sub_80769CC;
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{
healthboxSprite->data[0] = -healthboxSprite->data[0];
healthboxSprite->data[1] = -healthboxSprite->data[1];
@ -1198,7 +1198,7 @@ void sub_8076918(u8 bank)
healthboxSprite->pos2.y = -healthboxSprite->pos2.y;
}
gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]);
if (GetBankIdentity(bank) == IDENTITY_PLAYER_MON2)
if (GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT)
healthboxSprite->callback = sub_80769A8;
}
@ -1226,7 +1226,7 @@ void DoHitAnimHealthboxEffect(u8 bank)
spriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HitAnimHealthoxEffect);
gSprites[spriteId].data[0] = 1;
gSprites[spriteId].data[1] = gHealthBoxesIds[bank];
gSprites[spriteId].data[1] = gHealthboxSpriteIds[bank];
gSprites[spriteId].callback = SpriteCB_HitAnimHealthoxEffect;
}
@ -1275,8 +1275,8 @@ void FreeBallGfx(u8 ballId)
static u16 GetBankPokeballItemId(u8 bank)
{
if (GetBankSide(bank) == SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
else
return GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL);
return GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
}

View File

@ -14,10 +14,10 @@ struct Unknown_020249B4
struct SpriteTemplate* templates;
};
extern u8 gAbsentBankFlags;
extern u8 gActiveBank;
extern u8 gBankAttacker;
extern u8 gBankTarget;
extern u8 gAbsentBattlerFlags;
extern u8 gActiveBattler;
extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
extern u8 gLastUsedAbility;
extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags;
@ -34,9 +34,9 @@ extern const union AnimCmd* const * const gUnknown_0830536C[];
extern const u8 gText_BadEgg[];
extern const u8 gText_EggNickname[];
extern u8 GetBankSide(u8 bank);
extern u8 GetBankByIdentity(u8 bank);
extern u8 GetBankIdentity(u8 bank);
extern u8 GetBattlerSide(u8 bank);
extern u8 GetBattlerAtPosition(u8 bank);
extern u8 GetBattlerPosition(u8 bank);
u8 CountAliveMonsInBattle(u8 caseId)
{
@ -48,21 +48,21 @@ u8 CountAliveMonsInBattle(u8 caseId)
case BATTLE_ALIVE_EXCEPT_ACTIVE:
for (i = 0; i < 4; i++)
{
if (i != gActiveBank && !(gAbsentBankFlags & gBitTable[i]))
if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++)
{
if (GetBankSide(i) == GetBankSide(gBankAttacker) && !(gAbsentBankFlags & gBitTable[i]))
if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++)
{
if (GetBankSide(i) == GetBankSide(gBankTarget) && !(gAbsentBankFlags & gBitTable[i]))
if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
@ -75,7 +75,7 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 bank)
{
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER))
return FALSE;
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
return FALSE;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT)
return FALSE;
@ -86,11 +86,11 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 bank)
u8 GetDefaultMoveTarget(u8 bank)
{
u8 status = GetBankIdentity(bank) & 1;
u8 status = GetBattlerPosition(bank) & 1;
status ^= 1;
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return GetBankByIdentity(status);
return GetBattlerAtPosition(status);
if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1)
{
u8 val;
@ -99,14 +99,14 @@ u8 GetDefaultMoveTarget(u8 bank)
val = status ^ 2;
else
val = status;
return GetBankByIdentity(val);
return GetBattlerAtPosition(val);
}
else
{
if ((gAbsentBankFlags & gBitTable[status]))
return GetBankByIdentity(status ^ 2);
if ((gAbsentBattlerFlags & gBitTable[status]))
return GetBattlerAtPosition(status ^ 2);
else
return GetBankByIdentity(status);
return GetBattlerAtPosition(status);
}
}
@ -1353,7 +1353,7 @@ void CopyPlayerPartyMonToBattleData(u8 bank, u8 partyIndex)
StringCopy10(gBattleMons[bank].nickname, nickname);
GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_NAME, gBattleMons[bank].otName);
hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(bank)];
hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(bank)];
*hpSwitchout = gBattleMons[bank].hp;
for (i = 0; i < 8; i++)

View File

@ -25,15 +25,15 @@
extern struct BattlePokemon gBattleMons[4];
extern struct BattleEnigmaBerry gEnigmaBerries[4];
extern u8 gActiveBank;
extern u8 gActiveBattler;
extern u8 gBankInMenu;
extern u8 gBankTarget;
extern u8 gBankAttacker;
extern u8 gStringBank;
extern u8 gBattlerTarget;
extern u8 gBattlerAttacker;
extern u8 gStringBattler;
extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags;
extern u8 gBattleMonForms[4];
extern u16 gBattlePartyID[4];
extern u16 gBattlerPartyIndexes[4];
extern u8 gLastUsedAbility;
extern u16 gPartnerTrainerId;
extern u32 gHitMarker;
@ -113,7 +113,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
if (itemId == ITEM_ENIGMA_BERRY)
{
temp = gEnigmaBerries[gActiveBank].itemEffect;
temp = gEnigmaBerries[gActiveBattler].itemEffect;
}
itemEffect = temp;
@ -210,7 +210,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
void sub_806CF24(s32 stat)
{
gBankTarget = gBankInMenu;
gBattlerTarget = gBankInMenu;
StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]);
StringCopy(gBattleTextBuff2, gText_StatRose);
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2);
@ -233,7 +233,7 @@ u8 *sub_806CF78(u16 itemId)
itemEffect = gItemEffectTable[itemId - 13];
}
gStringBank = gBankInMenu;
gStringBattler = gBankInMenu;
for (i = 0; i < 3; i++)
{
@ -247,7 +247,7 @@ u8 *sub_806CF78(u16 itemId)
}
else
{
gBankAttacker = gBankInMenu;
gBattlerAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped);
}
}
@ -255,7 +255,7 @@ u8 *sub_806CF78(u16 itemId)
if (itemEffect[3] & 0x80)
{
gBankAttacker = gBankInMenu;
gBattlerAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist);
}
@ -615,7 +615,7 @@ bool16 sub_806D82C(u8 id)
return retVal;
}
s32 GetBankMultiplayerId(u16 a1)
s32 GetBattlerMultiplayerId(u16 a1)
{
s32 id;
for (id = 0; id < MAX_LINK_PLAYERS; id++)
@ -1366,12 +1366,12 @@ void sub_806E994(void)
gBattleTextBuff1[2] = gBattleStruct->field_49;
gBattleTextBuff1[4] = B_BUFF_EOS;
if (!GetBankSide(gBattleStruct->field_49))
gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[gBattleStruct->field_49]);
if (!GetBattlerSide(gBattleStruct->field_49))
gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->field_49]);
else
gBattleTextBuff1[3] = gBattlePartyID[gBattleStruct->field_49];
gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->field_49];
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBankInMenu, pokemon_order_func(gBattlePartyID[gBankInMenu]))
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBankInMenu, pokemon_order_func(gBattlerPartyIndexes[gBankInMenu]))
BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4);
}
@ -1478,7 +1478,7 @@ const u8 *GetTrainerPartnerName(void)
else
{
u8 id = GetMultiplayerId();
return gLinkPlayers[GetBankMultiplayerId(gLinkPlayers[id].lp_field_18 ^ 2)].name;
return gLinkPlayers[GetBattlerMultiplayerId(gLinkPlayers[id].lp_field_18 ^ 2)].name;
}
}

View File

@ -16,7 +16,7 @@ struct UnkAnimStruct
s16 field_8;
};
extern u16 gBattlePartyID[];
extern u16 gBattlerPartyIndexes[];
// this file's functions
static void pokemonanimfunc_00(struct Sprite *sprite);
@ -945,7 +945,7 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet)
gTasks[taskId].tPtrHI = (u32)(sprite);
bank = sprite->data[0];
nature = GetNature(&gPlayerParty[gBattlePartyID[bank]]);
nature = GetNature(&gPlayerParty[gBattlerPartyIndexes[bank]]);
animId = 3 * backAnimSet + sBackAnimNatureModTable[nature];
gTasks[taskId].tAnimId = sBackAnimationIds[animId];

View File

@ -25,11 +25,11 @@ extern u32 gBattleTypeFlags;
extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B;
extern u16 gPartnerTrainerId;
extern u8 gActiveBank;
extern u8 gNoOfAllBanks;
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT];
extern u8 gActiveBattler;
extern u8 gBattlersCount;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gUnknown_03001278;
extern u8 gUnknown_03001279;
@ -52,13 +52,13 @@ struct RecordedBattleSave
{
struct Pokemon playerParty[PARTY_SIZE];
struct Pokemon opponentParty[PARTY_SIZE];
u8 playersName[BATTLE_BANKS_COUNT][PLAYER_NAME_LENGTH];
u8 playersGender[BATTLE_BANKS_COUNT];
u32 playersTrainerId[BATTLE_BANKS_COUNT];
u8 playersLanguage[BATTLE_BANKS_COUNT];
u8 playersName[MAX_BATTLERS_COUNT][PLAYER_NAME_LENGTH];
u8 playersGender[MAX_BATTLERS_COUNT];
u32 playersTrainerId[MAX_BATTLERS_COUNT];
u8 playersLanguage[MAX_BATTLERS_COUNT];
u32 rngSeed;
u32 battleFlags;
u8 playersBank[BATTLE_BANKS_COUNT];
u8 playersBank[MAX_BATTLERS_COUNT];
u16 opponentA;
u16 opponentB;
u16 partnerId;
@ -75,14 +75,14 @@ struct RecordedBattleSave
u16 field_50E[6];
u8 field_51A;
u8 field_51B;
u8 battleRecord[BATTLE_BANKS_COUNT][BANK_RECORD_SIZE];
u8 battleRecord[MAX_BATTLERS_COUNT][BANK_RECORD_SIZE];
u32 checksum;
};
EWRAM_DATA u32 gRecordedBattleRngSeed = 0;
EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 0;
EWRAM_DATA static u8 sBattleRecords[BATTLE_BANKS_COUNT][BANK_RECORD_SIZE] = {0};
EWRAM_DATA static u16 sRecordedBytesNo[BATTLE_BANKS_COUNT] = {0};
EWRAM_DATA static u8 sBattleRecords[MAX_BATTLERS_COUNT][BANK_RECORD_SIZE] = {0};
EWRAM_DATA static u16 sRecordedBytesNo[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u16 sUnknown_0203C79C[4] = {0};
EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0};
EWRAM_DATA static u8 sUnknown_0203C7AC = 0;
@ -99,7 +99,7 @@ EWRAM_DATA static u32 sRecordedBattle_AI_Scripts = 0;
EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0};
EWRAM_DATA static u16 sRecordedBattle_PlayerMonMoves[2][4] = {0};
EWRAM_DATA static struct PlayerInfo sRecordedBattle_Players[BATTLE_BANKS_COUNT] = {0};
EWRAM_DATA static struct PlayerInfo sRecordedBattle_Players[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u8 sUnknown_0203CCD0 = 0;
EWRAM_DATA static u8 sUnknown_0203CCD1[8] = {0};
EWRAM_DATA static u8 sUnknown_0203CCD9 = 0;
@ -123,7 +123,7 @@ void sub_8184DA4(u8 arg0)
sUnknown_0203C7AC = arg0;
sUnknown_0203CCD0 = 0;
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
sRecordedBytesNo[i] = 0;
sUnknown_0203C79C[i] = 0;
@ -164,7 +164,7 @@ void sub_8184E58(void)
gUnknown_0203C7B4 = GetMultiplayerId();
linkPlayersCount = GetLinkPlayerCount();
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
sRecordedBattle_Players[i].trainerId = gLinkPlayers[i].trainerId;
sRecordedBattle_Players[i].gender = gLinkPlayers[i].gender;
@ -200,7 +200,7 @@ void sub_8184E58(void)
}
}
void RecordedBattle_SetBankAction(u8 bank, u8 action)
void RecordedBattle_SetBattlerAction(u8 bank, u8 action)
{
if (sRecordedBytesNo[bank] < BANK_RECORD_SIZE && sUnknown_0203C7AC != 2)
{
@ -208,7 +208,7 @@ void RecordedBattle_SetBankAction(u8 bank, u8 action)
}
}
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear)
void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear)
{
s32 i;
@ -221,12 +221,12 @@ void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear)
}
}
u8 RecordedBattle_ReadBankAction(u8 bank)
u8 RecordedBattle_GetBattlerAction(u8 bank)
{
// trying to read past array or invalid action byte, battle is over
if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF)
{
gSpecialVar_Result = gBattleOutcome = BATTLE_PLAYER_TELEPORTED; // hah
gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah
ResetPaletteFadeControl();
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
SetMainCallback2(CB2_QuitRecordedBattle);
@ -248,7 +248,7 @@ u8 sub_81850DC(u8 *arg0)
u8 i, j;
u8 ret = 0;
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (sRecordedBytesNo[i] != sUnknown_0203C79C[i])
{
@ -350,7 +350,7 @@ u32 MoveRecordedBattleToSaveData(void)
battleSave->opponentParty[i] = sSavedOpponentParty[i];
}
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
for (j = 0; j < PLAYER_NAME_LENGTH; j++)
{
@ -1339,7 +1339,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
gEnemyParty[i] = src->opponentParty[i];
}
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
for (var = FALSE, j = 0; j < PLAYER_NAME_LENGTH; j++)
{
@ -1386,7 +1386,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
gSaveBlock2Ptr->frontierChosenLvl = src->field_4FC;
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
for (j = 0; j < BANK_RECORD_SIZE; j++)
{
@ -1462,7 +1462,7 @@ u8 GetActiveBankLinkPlayerGender(void)
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayers[i].lp_field_18 == gActiveBank)
if (gLinkPlayers[i].lp_field_18 == gActiveBattler)
break;
}
@ -1501,7 +1501,7 @@ void RecordedBattle_CopyBankMoves(void)
{
s32 i;
if (GetBankSide(gActiveBank) == SIDE_OPPONENT)
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
return;
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
return;
@ -1510,7 +1510,7 @@ void RecordedBattle_CopyBankMoves(void)
for (i = 0; i < 4; i++)
{
sRecordedBattle_PlayerMonMoves[gActiveBank / 2][i] = gBattleMons[gActiveBank].moves[i];
sRecordedBattle_PlayerMonMoves[gActiveBattler / 2][i] = gBattleMons[gActiveBattler].moves[i];
}
}
@ -1523,9 +1523,9 @@ void sub_818603C(u8 arg0)
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
return;
for (bank = 0; bank < gNoOfAllBanks; bank++)
for (bank = 0; bank < gBattlersCount; bank++)
{
if (GetBankSide(bank) != SIDE_OPPONENT) // player's side only
if (GetBattlerSide(bank) != B_SIDE_OPPONENT) // player's side only
{
if (arg0 == 1)
{
@ -1536,14 +1536,14 @@ void sub_818603C(u8 arg0)
}
if (j != 4) // player's mon's move has been changed
{
RecordedBattle_SetBankAction(bank, ACTION_MOVE_CHANGE);
RecordedBattle_SetBattlerAction(bank, ACTION_MOVE_CHANGE);
for (j = 0; j < 4; j++)
{
for (k = 0; k < 4; k++)
{
if (gBattleMons[bank].moves[j] == sRecordedBattle_PlayerMonMoves[bank / 2][k])
{
RecordedBattle_SetBankAction(bank, k);
RecordedBattle_SetBattlerAction(bank, k);
break;
}
}
@ -1561,14 +1561,14 @@ void sub_818603C(u8 arg0)
u8 array3[8];
u8 var;
RecordedBattle_ReadBankAction(bank);
RecordedBattle_GetBattlerAction(bank);
for (j = 0; j < 4; j++)
{
ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1));
}
for (j = 0; j < 4; j++)
{
array1[j] = RecordedBattle_ReadBankAction(bank);
array1[j] = RecordedBattle_GetBattlerAction(bank);
movePp.moves[j] = gBattleMons[bank].moves[array1[j]];
movePp.pp[j] = gBattleMons[bank].pp[array1[j]];
array3[j] = ppBonuses[array1[j]];
@ -1591,28 +1591,28 @@ void sub_818603C(u8 arg0)
{
for (j = 0; j < 4; j++)
{
ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1));
ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1));
}
for (j = 0; j < 4; j++)
{
movePp.moves[j] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_MOVE1 + array1[j], NULL);
movePp.pp[j] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP1 + array1[j], NULL);
movePp.moves[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_MOVE1 + array1[j], NULL);
movePp.pp[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP1 + array1[j], NULL);
array3[j] = ppBonuses[array1[j]];
}
for (j = 0; j < 4; j++)
{
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_MOVE1 + j, &movePp.moves[j]);
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP1 + j, &movePp.pp[j]);
SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_MOVE1 + j, &movePp.moves[j]);
SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP1 + j, &movePp.pp[j]);
}
var = 0;
for (j = 0; j < 4; j++)
{
var |= (array3[j]) << (j << 1);
}
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP_BONUSES, &var);
SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, &var);
}
gChosenMovesByBanks[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)];
gChosenMoveByBattler[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)];
}
}
}

View File

@ -22,14 +22,14 @@ extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern u8 gReservedSpritePaletteCount;
extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBankInMenu;
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gNoOfAllBanks;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount;
extern u32 gBattleTypeFlags;
extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT];
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
@ -38,16 +38,16 @@ extern void ScanlineEffect_Clear(void);
extern void sub_8035658(void);
extern bool8 IsDoubleBattle(void);
extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
extern u8 GetBankSpriteDefault_Y(u8 bank);
extern u8 GetBattlerSpriteDefault_Y(u8 bank);
extern u8 sub_80A82E4(u8 bank);
extern void sub_806A068(u16 species, u8 bankIdentity);
extern void sub_806A12C(u16 backPicId, u8 bankIdentity);
extern u8 GetBankPosition(u8 bank, u8 caseId);
extern u8 GetBattlerSpriteCoord(u8 bank, u8 caseId);
// this file's functions
static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBankSpriteGfx(u8 bank);
static void CreateBankSprite(u8 bank);
static bool8 LoadBattlerSpriteGfx(u8 bank);
static void CreateBattlerSprite(u8 bank);
static void CreateHealthboxSprite(u8 bank);
static void sub_80A95F4(void);
@ -118,32 +118,32 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
}
break;
case 7:
if (!LoadBankSpriteGfx(0))
if (!LoadBattlerSpriteGfx(0))
gBattleScripting.reshowMainState--;
break;
case 8:
if (!LoadBankSpriteGfx(1))
if (!LoadBattlerSpriteGfx(1))
gBattleScripting.reshowMainState--;
break;
case 9:
if (!LoadBankSpriteGfx(2))
if (!LoadBattlerSpriteGfx(2))
gBattleScripting.reshowMainState--;
break;
case 10:
if (!LoadBankSpriteGfx(3))
if (!LoadBattlerSpriteGfx(3))
gBattleScripting.reshowMainState--;
break;
case 11:
CreateBankSprite(0);
CreateBattlerSprite(0);
break;
case 12:
CreateBankSprite(1);
CreateBattlerSprite(1);
break;
case 13:
CreateBankSprite(2);
CreateBattlerSprite(2);
break;
case 14:
CreateBankSprite(3);
CreateBattlerSprite(3);
break;
case 15:
CreateHealthboxSprite(0);
@ -164,15 +164,15 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
LoadAndCreateEnemyShadowSprites();
opponentBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES);
SetBankEnemyShadowSpriteCallback(opponentBank, species);
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES);
SetBattlerShadowSpriteCallback(opponentBank, species);
if (IsDoubleBattle())
{
opponentBank = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES);
SetBankEnemyShadowSpriteCallback(opponentBank, species);
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES);
SetBattlerShadowSpriteCallback(opponentBank, species);
}
ActionSelectionCreateCursorAt(gActionSelectionCursor[gBankInMenu], 0);
@ -208,25 +208,25 @@ static void sub_80A95F4(void)
regBgcnt2->charBaseBlock = 0;
}
static bool8 LoadBankSpriteGfx(u8 bank)
static bool8 LoadBattlerSpriteGfx(u8 battler)
{
if (bank < gNoOfAllBanks)
if (battler < gBattlersCount)
{
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{
if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank);
if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battler]], battler);
else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
}
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank);
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
DecompressTrainerBackPic(BACK_PIC_WALLY, bank);
else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank);
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, battler);
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
DecompressTrainerBackPic(BACK_PIC_WALLY, battler);
else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
gBattleScripting.reshowHelperState = 0;
}
@ -243,111 +243,111 @@ struct MonCoords
};
extern const struct MonCoords gTrainerBackPicCoords[];
static void CreateBankSprite(u8 bank)
static void CreateBattlerSprite(u8 battler)
{
if (bank < gNoOfAllBanks)
if (battler < gBattlersCount)
{
u8 posY;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
posY = GetSubstituteSpriteDefault_Y(bank);
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
posY = GetSubstituteSpriteDefault_Y(battler);
else
posY = GetBankSpriteDefault_Y(bank);
posY = GetBattlerSpriteDefault_Y(battler);
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{
if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0)
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
return;
sub_806A068(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBankIdentity(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankPosition(bank, 2), posY, sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES);
sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler));
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM)
gSprites[gBankSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM)
gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
}
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
{
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBankIdentity(IDENTITY_PLAYER_MON1));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50,
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
sub_80A82E4(0));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
}
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
{
sub_806A12C(BACK_PIC_WALLY, GetBankIdentity(0));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50,
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80,
sub_80A82E4(0));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
}
else
{
if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_HP) == 0)
if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
return;
sub_806A068(GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBankIdentity(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankPosition(bank, 2), posY, sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES);
sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler));
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM)
gSprites[gBankSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM)
gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
}
gSprites[gBankSpriteIds[bank]].invisible = gBattleSpritesDataPtr->bankData[bank].invisible;
gSprites[gBattlerSpriteIds[battler]].invisible = gBattleSpritesDataPtr->battlerData[battler].invisible;
}
}
static void CreateHealthboxSprite(u8 bank)
static void CreateHealthboxSprite(u8 battler)
{
if (bank < gNoOfAllBanks)
if (battler < gBattlersCount)
{
u8 healthboxSpriteId;
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
healthboxSpriteId = CreateSafariPlayerHealthboxSprites();
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
return;
else
healthboxSpriteId = CreateBankHealthboxSprites(bank);
healthboxSpriteId = CreateBattlerHealthboxSprites(battler);
gHealthBoxesIds[bank] = healthboxSpriteId;
SetBankHealthboxSpritePos(bank);
gHealthboxSpriteIds[battler] = healthboxSpriteId;
InitBattlerHealthboxCoords(battler);
SetHealthboxSpriteVisible(healthboxSpriteId);
if (GetBankSide(bank) != SIDE_PLAYER)
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gEnemyParty[gBattlePartyID[bank]], HEALTHBOX_ALL);
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_SAFARI_ALL_TEXT);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT);
else
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
if (GetBankIdentity(bank) == IDENTITY_OPPONENT_MON2 || GetBankIdentity(bank) == IDENTITY_PLAYER_MON2)
DummyBattleInterfaceFunc(gHealthBoxesIds[bank], TRUE);
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE);
else
DummyBattleInterfaceFunc(gHealthBoxesIds[bank], FALSE);
DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE);
if (GetBankSide(bank) != SIDE_PLAYER)
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{
if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0)
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId);
}
else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
{
if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_HP) == 0)
if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId);
}
}

View File

@ -108,20 +108,20 @@ void SafariZoneRetirePrompt(void)
void CB2_EndSafariBattle(void)
{
sSafariZoneFleedMons += gBattleResults.field_1F;
if (gBattleOutcome == BATTLE_CAUGHT)
if (gBattleOutcome == B_OUTCOME_CAUGHT_POKE)
sSafariZoneCaughtMons++;
if (gNumSafariBalls != 0)
{
SetMainCallback2(c2_exit_to_overworld_2_switch);
}
else if (gBattleOutcome == BATTLE_SAFARI_OUT_OF_BALLS)
else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
{
ScriptContext2_RunNewScript(EventScript_2A4B4C);
warp_in();
gFieldCallback = sub_80AF6F0;
SetMainCallback2(c2_load_new_map);
}
else if (gBattleOutcome == BATTLE_CAUGHT)
else if (gBattleOutcome == B_OUTCOME_CAUGHT_POKE)
{
ScriptContext1_SetupScript(EventScript_2A4B9B);
ScriptContext1_Stop();

View File

@ -1208,7 +1208,7 @@ void PutPokemonTodayFailedOnTheAir(void)
{
ct = 0xFF;
}
if (ct > 2 && (gBattleOutcome == BATTLE_POKE_FLED || gBattleOutcome == BATTLE_WON))
if (ct > 2 && (gBattleOutcome == B_OUTCOME_POKE_FLED || gBattleOutcome == B_OUTCOME_WON))
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE)
@ -2402,23 +2402,23 @@ void sub_80EE184(void)
show->breakingNews.poke1Species = gBattleResults.playerMon1Species;
switch (gBattleOutcome)
{
case BATTLE_LOST:
case BATTLE_DREW:
case B_OUTCOME_LOST:
case B_OUTCOME_DREW:
show->breakingNews.kind = TVSHOW_OFF_AIR;
return;
case BATTLE_CAUGHT:
case B_OUTCOME_CAUGHT_POKE:
show->breakingNews.outcome = 0;
break;
case BATTLE_WON:
case B_OUTCOME_WON:
show->breakingNews.outcome = 1;
break;
case BATTLE_RAN:
case BATTLE_PLAYER_TELEPORTED:
case BATTLE_SAFARI_OUT_OF_BALLS:
case B_OUTCOME_RAN:
case B_OUTCOME_PLAYER_TELEPORTED:
case B_OUTCOME_NO_SAFARI_BALLS:
show->breakingNews.outcome = 2;
break;
case BATTLE_POKE_FLED:
case BATTLE_OPPONENT_TELEPORTED:
case B_OUTCOME_POKE_FLED:
case B_OUTCOME_POKE_TELEPORTED:
show->breakingNews.outcome = 3;
break;
}

View File

@ -215,10 +215,10 @@ gBattleResults: @ 3005D10
gLeveledUpInBattle: @ 3005D54
.space 0xC
gBattleBankFunc: @ 3005D60
gBattlerControllerFuncs: @ 3005D60
.space 0x10
gHealthBoxesIds: @ 3005D70
gHealthboxSpriteIds: @ 3005D70
.space 0x4
gMultiUsePlayerCursor: @ 3005D74

View File

@ -270,25 +270,25 @@ gBattleBufferA: @ 2023064
gBattleBufferB: @ 2023864
.space 0x800
gActiveBank: @ 2024064
gActiveBattler: @ 2024064
.space 0x4
gBattleExecBuffer: @ 2024068
gBattleControllerExecFlags: @ 2024068
.space 0x4
gNoOfAllBanks: @ 202406C
gBattlersCount: @ 202406C
.space 0x2
gBattlePartyID: @ 202406E
gBattlerPartyIndexes: @ 202406E
.space 0x8
gBanksByIdentity: @ 2024076
gBattlerPositions: @ 2024076
.space 0x4
gActionsByTurnOrder: @ 202407A
.space 0x4
gBanksByTurnOrder: @ 202407E
gBattleTurnOrder: @ 202407E
.space 0x4
gCurrentTurnActionNumber: @ 2024082
@ -300,7 +300,7 @@ gCurrentActionFuncId: @ 2024083
gBattleMons: @ 2024084
.space 0x160
gBankSpriteIds: @ 20241E4
gBattlerSpriteIds: @ 20241E4
.space 0x4
gCurrMovePos: @ 20241E8
@ -333,10 +333,10 @@ gLastUsedItem: @ 2024208
gLastUsedAbility: @ 202420A
.space 0x1
gBankAttacker: @ 202420B
gBattlerAttacker: @ 202420B
.space 0x1
gBankTarget: @ 202420C
gBattlerTarget: @ 202420C
.space 0x1
gBank1: @ 202420D
@ -345,10 +345,10 @@ gBank1: @ 202420D
gEffectBank: @ 202420E
.space 0x1
gStringBank: @ 202420F
gStringBattler: @ 202420F
.space 0x1
gAbsentBankFlags: @ 2024210
gAbsentBattlerFlags: @ 2024210
.space 0x1
gCritMultiplier: @ 2024211
@ -360,7 +360,7 @@ gMultiHitCounter: @ 2024212
gBattlescriptCurrInstr: @ 2024214
.space 0x8
gActionForBanks: @ 202421C
gChosenActionByBattler: @ 202421C
.space 0x4
gSelectionBattleScripts: @ 2024220
@ -390,10 +390,10 @@ gLockedMoves: @ 2024268
gLastHitBy: @ 2024270
.space 0x4
gChosenMovesByBanks: @ 2024274
gChosenMoveByBattler: @ 2024274
.space 0x8
gBattleMoveFlags: @ 202427C
gMoveResultFlags: @ 202427C
.space 0x4
gHitMarker: @ 2024280
@ -408,7 +408,7 @@ gTakenDmgBanks: @ 2024288
gUnknown_0202428C: @ 202428C
.space 0x2
gSideAffecting: @ 202428E
gSideStatuses: @ 202428E
.space 0x6
gSideTimers: @ 2024294
@ -1146,7 +1146,7 @@ gUnknown_0203AB98: @ 203AB98
.include "src/coins.o"
.include "src/battle_transition.o"
gAbilitiesPerBank: @ 203ABA4
gBattlerAbilities: @ 203ABA4
.space 0x4
gStringInfo: @ 203ABA8