start working on battle setup

This commit is contained in:
DizzyEggg 2017-11-28 23:02:09 +01:00
parent 18c6b8efc2
commit 10470ef536
42 changed files with 763 additions and 1308 deletions

View File

@ -13887,7 +13887,7 @@ task_prev_quest: @ 81960A8
cmp r0, 0
bne _081960C2
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
bl sub_808B864
bl sub_808BCF4
_081960C2:

View File

@ -12380,7 +12380,7 @@ _081A0C8E:
sub_81A0C9C: @ 81A0C9C
push {lr}
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
bl sub_808B864
bl sub_808BCF4
movs r0, 0

File diff suppressed because it is too large Load Diff

View File

@ -3534,7 +3534,7 @@ _08163E10:
bl sub_80B100C
lsls r0, 24
lsrs r0, 24
bl sub_8145EF4
bl BattleTransition_StartOnField
b _08163E68
.pool
_08163E2C:
@ -3561,7 +3561,7 @@ _08163E2C:
movs r0, 0
bl PlayMapChosenOrBattleBGM
movs r0, 0x12
bl sub_8145EF4
bl BattleTransition_StartOnField
_08163E68:
add sp, 0x4
pop {r4-r6}

View File

@ -57,8 +57,8 @@ TestBattleTransition: @ 8145EDC
.pool
thumb_func_end TestBattleTransition
thumb_func_start sub_8145EF4
sub_8145EF4: @ 8145EF4
thumb_func_start BattleTransition_StartOnField
BattleTransition_StartOnField: @ 8145EF4
push {lr}
lsls r0, 24
lsrs r0, 24
@ -69,7 +69,7 @@ sub_8145EF4: @ 8145EF4
pop {r0}
bx r0
.pool
thumb_func_end sub_8145EF4
thumb_func_end BattleTransition_StartOnField
thumb_func_start sub_8145F10
sub_8145F10: @ 8145F10

View File

@ -1531,8 +1531,8 @@ _0809CB72:
.pool
thumb_func_end AdjustFriendship_step
thumb_func_start overworld_poison_timer_set
overworld_poison_timer_set: @ 809CB80
thumb_func_start ResetPoisonStepCounter
ResetPoisonStepCounter: @ 809CB80
push {lr}
ldr r0, =0x0000402b
movs r1, 0
@ -1540,7 +1540,7 @@ overworld_poison_timer_set: @ 809CB80
pop {r0}
bx r0
.pool
thumb_func_end overworld_poison_timer_set
thumb_func_end ResetPoisonStepCounter
thumb_func_start overworld_poison_step
overworld_poison_step: @ 809CB94

View File

@ -1961,7 +1961,7 @@ mapldr_080842E8: @ 80B69FC
movs r1, 0
bl CreateTask
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
@ -2057,7 +2057,7 @@ mapldr_08084390: @ 80B6AA4
bl FieldObjectTurn
_080B6AE6:
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
@ -2116,7 +2116,7 @@ sub_80B6B68: @ 80B6B68
bl sub_8085784
bl pal_fill_for_maplights
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r0, =sub_80B6B94
movs r1, 0
bl CreateTask
@ -2534,7 +2534,7 @@ _080B6E9A:
sub_80B6EC0: @ 80B6EC0
push {r4,lr}
adds r4, r0, 0
bl player_bitmagic
bl FreezeMapObjects
bl CameraObjectReset2
ldrb r0, [r4, 0xA]
bl sub_80E1558
@ -3476,7 +3476,7 @@ sub_80B764C: @ 80B764C
push {r4,r5,lr}
adds r4, r0, 0
adds r5, r1, 0
bl player_bitmagic
bl FreezeMapObjects
bl CameraObjectReset2
movs r0, 0
bl SetCameraPanningCallback
@ -3807,7 +3807,7 @@ sub_80B78EC: @ 80B78EC
adds r5, r0, 0
adds r4, r1, 0
bl CameraObjectReset2
bl player_bitmagic
bl FreezeMapObjects
ldr r1, =gPlayerAvatar
movs r0, 0x1
strb r0, [r1, 0x6]
@ -4055,7 +4055,7 @@ sub_80B7AE8: @ 80B7AE8
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
bl player_bitmagic
bl FreezeMapObjects
bl CameraObjectReset2
ldr r1, =gPlayerAvatar
movs r0, 0x1
@ -4287,7 +4287,7 @@ _080B7CC4:
sub_80B7CC8: @ 80B7CC8
push {lr}
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r0, =sub_80B7CE4
movs r1, 0x50
bl CreateTask
@ -4461,7 +4461,7 @@ mapldr_080859D4: @ 80B7E48
bl sub_8085784
bl pal_fill_for_maplights
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
@ -4672,7 +4672,7 @@ sub_80B800C: @ 80B800C
push {r4,lr}
adds r4, r0, 0
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
bl CameraObjectReset2
bl player_get_direction_lower_nybble
lsls r0, 24
@ -4906,7 +4906,7 @@ mapldr_08085D88: @ 80B8200
bl sub_8085784
bl pal_fill_for_maplights
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
@ -6334,7 +6334,7 @@ sub_80B8DB4: @ 80B8DB4
push {r6}
adds r4, r0, 0
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
ldr r5, =gPlayerAvatar
movs r0, 0x1
strb r0, [r5, 0x6]

View File

@ -7527,15 +7527,15 @@ SetSav1Weather: @ 80AED7C
.pool
thumb_func_end SetSav1Weather
thumb_func_start sav1_get_weather_probably
sav1_get_weather_probably: @ 80AEDAC
thumb_func_start GetSav1Weather
GetSav1Weather: @ 80AEDAC
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
adds r0, 0x2E
ldrb r0, [r0]
bx lr
.pool
thumb_func_end sav1_get_weather_probably
thumb_func_end GetSav1Weather
thumb_func_start sub_80AEDBC
sub_80AEDBC: @ 80AEDBC
@ -7565,7 +7565,7 @@ sub_80AEDBC: @ 80AEDBC
sub_80AEDF0: @ 80AEDF0
push {lr}
bl SetSav1Weather
bl sav1_get_weather_probably
bl GetSav1Weather
lsls r0, 24
lsrs r0, 24
bl weather_set
@ -7577,7 +7577,7 @@ sub_80AEDF0: @ 80AEDF0
sub_80AEE08: @ 80AEE08
push {lr}
bl SetSav1Weather
bl sav1_get_weather_probably
bl GetSav1Weather
lsls r0, 24
lsrs r0, 24
bl sub_80AB104
@ -7588,7 +7588,7 @@ sub_80AEE08: @ 80AEE08
thumb_func_start DoCurrentWeather
DoCurrentWeather: @ 80AEE20
push {r4,r5,lr}
bl sav1_get_weather_probably
bl GetSav1Weather
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0xF
@ -7632,7 +7632,7 @@ _080AEE6E:
thumb_func_start sub_80AEE84
sub_80AEE84: @ 80AEE84
push {r4,r5,lr}
bl sav1_get_weather_probably
bl GetSav1Weather
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0xF
@ -8382,7 +8382,7 @@ _080AF46C:
_080AF480:
movs r0, 0
bl sub_80AF0F4
bl player_bitmagic
bl FreezeMapObjects
adds r0, r6, 0
adds r1, r7, 0
bl PlayerGetDestCoords
@ -8508,7 +8508,7 @@ _080AF580:
_080AF58A:
movs r0, 0
bl sub_80AF0F4
bl player_bitmagic
bl FreezeMapObjects
adds r0, r6, 0
adds r1, r7, 0
bl PlayerGetDestCoords
@ -8583,7 +8583,7 @@ task_map_chg_seq_0807E2CC: @ 80AF610
b _080AF65A
.pool
_080AF634:
bl player_bitmagic
bl FreezeMapObjects
bl ScriptContext2_Enable
ldrh r0, [r4, 0x8]
adds r0, 0x1
@ -9062,7 +9062,7 @@ _080AFA34:
beq _080AFA6C
b _080AFA7C
_080AFA3A:
bl player_bitmagic
bl FreezeMapObjects
bl ScriptContext2_Enable
b _080AFA64
_080AFA44:
@ -9133,7 +9133,7 @@ _080AFAC0:
.4byte _080AFBB8
.4byte _080AFBD4
_080AFAD4:
bl player_bitmagic
bl FreezeMapObjects
adds r0, r4, 0
adds r1, r6, 0
bl PlayerGetDestCoords
@ -9290,7 +9290,7 @@ _080AFC1C:
beq _080AFC46
b _080AFC56
_080AFC22:
bl player_bitmagic
bl FreezeMapObjects
bl ScriptContext2_Enable
b _080AFC3E
_080AFC2C:
@ -9877,7 +9877,7 @@ sub_80B009C: @ 80B009C
lsls r0, 24
lsrs r0, 24
adds r4, r0, 0
bl sav1_get_flash_used_on_map
bl Overworld_GetFlashLevel
lsls r0, 24
lsrs r0, 24
movs r5, 0
@ -9982,7 +9982,7 @@ task0A_mpl_807E31C: @ 80B0160
b _080B01B6
.pool
_080B0184:
bl player_bitmagic
bl FreezeMapObjects
bl ScriptContext2_Enable
bl sub_808D194
ldrh r0, [r4, 0x8]
@ -10033,7 +10033,7 @@ _080B01E4:
beq _080B022A
b _080B023A
_080B01EE:
bl player_bitmagic
bl FreezeMapObjects
bl ScriptContext2_Enable
movs r0, 0x2D
bl PlaySE

View File

@ -2275,8 +2275,8 @@ overworld_posion_effect: @ 80FAEA8
.pool
thumb_func_end overworld_posion_effect
thumb_func_start c3_80A0DD8_is_running
c3_80A0DD8_is_running: @ 80FAEC0
thumb_func_start FieldPoisonEffectIsRunning
FieldPoisonEffectIsRunning: @ 80FAEC0
push {lr}
ldr r0, =task50_overworld_posion_effect
bl FuncIsActiveTask
@ -2285,7 +2285,7 @@ c3_80A0DD8_is_running: @ 80FAEC0
pop {r1}
bx r1
.pool
thumb_func_end c3_80A0DD8_is_running
thumb_func_end FieldPoisonEffectIsRunning
thumb_func_start sub_80FAED4
sub_80FAED4: @ 80FAED4

View File

@ -4748,7 +4748,7 @@ _081AD550:
cmp r6, 0x1
bne _081AD5C4
bl ScriptContext2_Enable
bl player_bitmagic
bl FreezeMapObjects
bl sub_808B864
bl sub_808BCF4
ldr r2, =gSpecialVar_ItemId

View File

@ -82,9 +82,9 @@ _0809748E:
bx r1
thumb_func_end sub_8097404
thumb_func_start player_bitmagic
@ void player_bitmagic()
player_bitmagic: @ 8097494
thumb_func_start FreezeMapObjects
@ void FreezeMapObjects()
FreezeMapObjects: @ 8097494
push {r4,r5,lr}
movs r4, 0
ldr r5, =gMapObjects
@ -113,7 +113,7 @@ _080974B8:
pop {r0}
bx r0
.pool
thumb_func_end player_bitmagic
thumb_func_end FreezeMapObjects
thumb_func_start sub_80974D0
sub_80974D0: @ 80974D0

View File

@ -62,7 +62,7 @@ _080983E2:
thumb_func_start ScriptFreezeMapObjects
ScriptFreezeMapObjects: @ 80983E8
push {lr}
bl player_bitmagic
bl FreezeMapObjects
ldr r0, =sub_80983A4
movs r1, 0x50
bl CreateTask

View File

@ -1880,15 +1880,15 @@ _080854FE:
.pool
thumb_func_end Overworld_SetFlashLevel
thumb_func_start sav1_get_flash_used_on_map
sav1_get_flash_used_on_map: @ 8085514
thumb_func_start Overworld_GetFlashLevel
Overworld_GetFlashLevel: @ 8085514
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
adds r0, 0x30
ldrb r0, [r0]
bx lr
.pool
thumb_func_end sav1_get_flash_used_on_map
thumb_func_end Overworld_GetFlashLevel
thumb_func_start sub_8085524
sub_8085524: @ 8085524
@ -2133,7 +2133,7 @@ sav1_map_get_music: @ 80856D4
lsls r0, 5
cmp r1, r0
bne _080856FC
bl sav1_get_weather_probably
bl GetSav1Weather
lsls r0, 24
lsrs r0, 24
cmp r0, 0x8
@ -3192,8 +3192,8 @@ CB2_NewGame: @ 8085EF8
.pool
thumb_func_end CB2_NewGame
thumb_func_start c2_whiteout
c2_whiteout: @ 8085F58
thumb_func_start CB2_WhiteOut
CB2_WhiteOut: @ 8085F58
push {lr}
sub sp, 0x4
ldr r1, =gMain
@ -3232,7 +3232,7 @@ _08085FB0:
pop {r0}
bx r0
.pool
thumb_func_end c2_whiteout
thumb_func_end CB2_WhiteOut
thumb_func_start c2_load_new_map
c2_load_new_map: @ 8085FCC
@ -3661,7 +3661,7 @@ sub_80863B0: @ 80863B0
b _080863F0
.pool
_080863D4:
bl sav1_get_flash_used_on_map
bl Overworld_GetFlashLevel
lsls r0, 24
lsrs r0, 24
cmp r0, 0

View File

@ -4180,7 +4180,7 @@ _0813785A:
thumb_func_start sp0C8_whiteout_maybe
sp0C8_whiteout_maybe: @ 813787C
push {lr}
ldr r0, =c2_whiteout
ldr r0, =CB2_WhiteOut
bl SetMainCallback2
movs r0, 0
pop {r1}

View File

@ -356,7 +356,7 @@ sub_809FA9C: @ 809FA9C
bl is_c1_link_related_active
cmp r0, 0
bne _0809FAB2
bl player_bitmagic
bl FreezeMapObjects
bl sub_808B864
bl sub_808BCF4
_0809FAB2:

View File

@ -19,7 +19,7 @@
.set BATTLE_TYPE_PALACE, 0x20000
.set BATTLE_TYPE_ARENA, 0x40000
.set BATTLE_TYPE_FACTORY, 0x80000
.set BATTLE_TYPE_x100000, 0x100000
.set BATTLE_TYPE_PIKE, 0x100000
.set BATTLE_TYPE_PYRAMID, 0x200000
.set BATTLE_TYPE_INGAME_PARTNER, 0x400000
.set BATTLE_TYPE_x800000, 0x800000

View File

@ -2868,7 +2868,7 @@ BattleScript_82DA816::
jumpifword NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_TRAINER, BattleScript_82DA8D0
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_LINK, BattleScript_82DA8D0
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_x2000000, BattleScript_82DA8D0
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID, BattleScript_82DA8D0
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID, BattleScript_82DA8D0
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_DOUBLE, BattleScript_82DA8D0
jumpifword COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_82DA8D0
jumpifbyte EQUAL, sBATTLE_STYLE, 0x1, BattleScript_82DA8D0
@ -2963,7 +2963,7 @@ BattleScript_PayDayMoneyAndPickUpItems::
BattleScript_LocalBattleLost::
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_DOME, BattleScript_CheckDomeDrew
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID, BattleScript_LocalBattleLostPrintTrainersWinText
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID, BattleScript_LocalBattleLostPrintTrainersWinText
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_x4000000, BattleScript_LocalBattleLostPrintTrainersWinText
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_EREADER_TRAINER, BattleScript_LocalBattleLostEnd
jumpifhalfword EQUAL, gTrainerBattleOpponent_A, 0x400, BattleScript_LocalBattleLostEnd

View File

@ -4,12 +4,6 @@
.section .rodata
.align 2, 0
gUnknown_0854FE88:: @ 854FE88
.byte 0x08, 0x09, 0x05, 0x0a, 0x00, 0x0a, 0x07, 0x06
gUnknown_0854FE90:: @ 854FE90
.byte 0x04, 0x0b, 0x02, 0x03, 0x00, 0x0a, 0x01, 0x06
gUnknown_0854FE98:: @ 854FE98
.byte 0x1d, 0x1e, 0x1f, 0x20, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29

View File

@ -72,7 +72,7 @@ AncientTomb_EventScript_23905A:: @ 823905A
waitmoncry
setwildbattle SPECIES_REGISTEEL, 40, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0A74
special StartRegiBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -88,7 +88,7 @@ BirthIsland_Exterior_EventScript_267FC1:: @ 8267FC1
setvar VAR_0x8006, 0
special DoScriptedWildBattle
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -72,7 +72,7 @@ DesertRuins_EventScript_22DA02:: @ 822DA02
waitmoncry
setwildbattle SPECIES_REGIROCK, 40, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0A74
special StartRegiBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -145,7 +145,7 @@ FarawayIsland_Interior_EventScript_267DF2:: @ 8267DF2
setvar VAR_0x8006, 0
special DoScriptedWildBattle
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -104,7 +104,7 @@ IslandCave_EventScript_238F58:: @ 8238F58
waitmoncry
setwildbattle SPECIES_REGICE, 40, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0A74
special StartRegiBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -38,7 +38,7 @@ MarineCave_End_EventScript_23B01B:: @ 823B01B
setvar VAR_LAST_TALKED, 1
setwildbattle SPECIES_KYOGRE, 70, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
setvar VAR_0x4001, 0

View File

@ -61,7 +61,7 @@ NavelRock_Bottom_EventScript_2692A2:: @ 82692A2
setvar VAR_0x8006, 0
special DoScriptedWildBattle
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -65,7 +65,7 @@ NavelRock_Top_EventScript_26916F:: @ 826916F
setvar VAR_0x8006, 0
special DoScriptedWildBattle
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
setvar VAR_LAST_TALKED, 1

View File

@ -36,7 +36,7 @@ PetalburgCity_EventScript_1DC32E:: @ 81DC32E
applymovement 255, PetalburgCity_Movement_1DC430
waitmovement 0
msgbox PetalburgCity_Text_1EC1F8, 4
special sub_80B086C
special StartWallyTutorialBattle
waitstate
msgbox PetalburgCity_Text_1EC271, 4
applymovementat 2, PetalburgCity_Movement_2725A4, PETALBURG_CITY

View File

@ -53,7 +53,7 @@ SkyPillar_Top_EventScript_239722:: @ 8239722
waitmoncry
setwildbattle SPECIES_RAYQUAZA, 70, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -87,7 +87,7 @@ SouthernIsland_Interior_EventScript_242AD0:: @ 8242AD0
compare_var_to_value VAR_0x40D5, 0
call_if 5, SouthernIsland_Interior_EventScript_242BB7
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B08EC
special BattleSetup_StartLatiBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
specialvar VAR_RESULT, sub_8138B80

View File

@ -38,7 +38,7 @@ TerraCave_End_EventScript_23B0EC:: @ 823B0EC
setvar VAR_LAST_TALKED, 1
setwildbattle SPECIES_GROUDON, 70, ITEM_NONE
setflag FLAG_SYS_CTRL_OBJ_DELETE
special sub_80B0934
special BattleSetup_StartLegendaryBattle
waitstate
clearflag FLAG_SYS_CTRL_OBJ_DELETE
setvar VAR_0x4001, 0

View File

@ -167,7 +167,7 @@ gSpecials:: @ 81DBA64
def_special Special_StartWallClock
def_special Special_ViewWallClock
def_special sub_80B1138
def_special sub_80B086C
def_special StartWallyTutorialBattle
def_special ChangePokemonNickname
def_special sub_81B94B0
def_special GetFirstFreePokeblockSlot
@ -320,9 +320,9 @@ gSpecials:: @ 81DBA64
def_special sub_8139540
def_special sub_809E1C8
def_special sub_8139560
def_special sub_80B0A18
def_special sub_80B0934
def_special sub_80B0A74
def_special StartGroudonKyogreBattle
def_special BattleSetup_StartLegendaryBattle
def_special StartRegiBattle
def_special sub_80B16D8
def_special DoSealedChamberShakingEffect2
def_special sub_8139634
@ -332,7 +332,7 @@ gSpecials:: @ 81DBA64
def_special sub_80F8D28
def_special sub_80F8EB8
def_special sub_8162794
def_special sub_80B08EC
def_special BattleSetup_StartLatiBattle
def_special sub_8139648
def_special sub_8139668
def_special sub_80F8FA0

View File

@ -53,7 +53,7 @@
#define BATTLE_TYPE_PALACE 0x20000
#define BATTLE_TYPE_ARENA 0x40000
#define BATTLE_TYPE_FACTORY 0x80000
#define BATTLE_TYPE_x100000 0x100000
#define BATTLE_TYPE_PIKE 0x100000
#define BATTLE_TYPE_PYRAMID 0x200000
#define BATTLE_TYPE_INGAME_PARTNER 0x400000
#define BATTLE_TYPE_x800000 0x800000
@ -72,8 +72,8 @@
#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_x100000 | 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_x100000)
#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 BATTLE_WON 0x1
#define BATTLE_LOST 0x2
@ -228,9 +228,9 @@
#define BATTLE_TERRAIN_UNDERWATER 3
#define BATTLE_TERRAIN_WATER 4
#define BATTLE_TERRAIN_POND 5
#define BATTLE_TERRAIN_ROCK 6
#define BATTLE_TERRAIN_MOUNTAIN 6
#define BATTLE_TERRAIN_CAVE 7
#define BATTLE_TERRAIN_INSIDE 8
#define BATTLE_TERRAIN_BUILDING 8
#define BATTLE_TERRAIN_PLAIN 9
// array entries for battle communication
@ -327,10 +327,10 @@ struct TrainerMonItemCustomMoves
union TrainerMonPtr
{
struct TrainerMonNoItemDefaultMoves* NoItemDefaultMoves;
struct TrainerMonNoItemCustomMoves* NoItemCustomMoves;
struct TrainerMonItemDefaultMoves* ItemDefaultMoves;
struct TrainerMonItemCustomMoves* ItemCustomMoves;
struct TrainerMonNoItemDefaultMoves *NoItemDefaultMoves;
struct TrainerMonNoItemCustomMoves *NoItemCustomMoves;
struct TrainerMonItemDefaultMoves *ItemDefaultMoves;
struct TrainerMonItemCustomMoves *ItemCustomMoves;
};
struct Trainer

View File

@ -2,5 +2,51 @@
#define GUARD_BATTLE_TRANSITION_H
void sub_8149DFC(u8 a1);
void BattleTransition_StartOnField(u8 transitionID);
void BattleTransition_Start(u8 transitionID);
bool8 IsBattleTransitionDone(void);
#define TRANSITIONS_NO 25
enum // TRANSITION_MUGSHOT
{
MUGSHOT_SYDNEY,
MUGSHOT_PHOEBE,
MUGSHOT_GLACIA,
MUGSHOT_DRAKE,
MUGSHOT_STEVEN,
};
#define MUGSHOTS_NO 5
// credits for the names go to Dyskinesia and Tetrable
// names are naturally subject to change
#define B_TRANSITION_BLUR 0
#define B_TRANSITION_SWIRL 1
#define B_TRANSITION_SHUFFLE 2
#define B_TRANSITION_BIG_POKEBALL 3
#define B_TRANSITION_POKEBALLS_TRAIL 4
#define B_TRANSITION_CLOCKWISE_BLACKFADE 5
#define B_TRANSITION_RIPPLE 6
#define B_TRANSITION_WAVE 7
#define B_TRANSITION_SLICE 8
#define B_TRANSITION_WHITEFADE 9
#define B_TRANSITION_GRID_SQUARES 10
#define B_TRANSITION_SHARDS 11
#define B_TRANSITION_SYDNEY 12
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_STEVEN 16
// added in Emerald
#define B_TRANSITION_AQUA 17
#define B_TRANSITION_MAGMA 18
#define B_TRANSITION_REGICE 19
#define B_TRANSITION_REGISTEEL 20
#define B_TRANSITION_REGIROCK 21
#define B_TRANSITION_KYORGE 22
#define B_TRANSITION_GROUDON 23
#define B_TRANSITION_RAYQUAZA 24
#endif // GUARD_BATTLE_TRANSITION_H

View File

@ -3,5 +3,6 @@
const u8* GetTrainerClassNameFromId(u16 trainerId);
const u8* GetTrainerNameFromId(u16 trainerId);
void PlayMapChosenOrBattleBGM(u16 song);
#endif // GUARD_POKEMON_3_H

View File

@ -13,6 +13,8 @@ void ExitSafariMode(void);
bool8 SafariZoneTakeStep(void);
void SafariZoneRetirePrompt(void);
void CB2_EndSafariBattle(void);
struct Pokeblock *SafariZoneGetActivePokeblock(void);
void SafariZoneActivatePokeblockFeeder(u8 pokeblock_index);

View File

@ -372,20 +372,20 @@ enum
BGM_BATTLE_DOME_TOURNAMENT,
BGM_BATTLE_PIKE,
BGM_BATTLE_FACTORY,
BGM_BATTLE_LEGENDARY,
BGM_BATTLE_FRONTIER_BRAIN,
BGM_BATTLE_MEW,
BGM_BATTLE_DOME, // end of the human-readable names
/*0x1D6*/ BGM_BATTLE_LEGENDARY,
/*0x1D7*/ BGM_BATTLE_FRONTIER_BRAIN,
/*0x1D8*/ BGM_BATTLE_MEW,
/*0x1D9*/ BGM_BATTLE_DOME, // end of the human-readable names
/*0x1DA*/ BGM_BATTLE27, // wild
BGM_BATTLE31, // aqua/magma grunt
BGM_BATTLE20, // trainer
BGM_BATTLE32, // gym leader
BGM_BATTLE33, // champion
BGM_BATTLE36, // regi
BGM_BATTLE34, // weather trio
BGM_BATTLE35, // rival
BGM_BATTLE38, // elite four
BGM_BATTLE30, // aqua/magma leader
/*0x1DB*/ BGM_BATTLE31, // aqua/magma grunt
/*0x1DC*/ BGM_BATTLE20, // trainer
/*0x1DD*/ BGM_BATTLE32, // gym leader
/*0x1DE*/ BGM_BATTLE33, // champion
/*0x1DF*/ BGM_BATTLE36, // regi
/*0x1E0*/ BGM_BATTLE34, // weather trio
/*0x1E1*/ BGM_BATTLE35, // rival
/*0x1E2*/ BGM_BATTLE38, // elite four
/*0x1E3*/ BGM_BATTLE30, // aqua/magma leader
/*0x1E4*/ BGM_FRLG_FOLLOW_ME, // FR/LG names not known, human-readable again!
BGM_FRLG_GAMECORNER,
BGM_FRLG_ROCKET_HIDEOUT,
@ -453,14 +453,14 @@ enum
BGM_FRLG_ISLAND_FOUR,
BGM_FRLG_ISLAND_SIX,
BGM_FRLG_FLUTE,
BGM_FRLG_BATTLE_DEOXYS,
BGM_FRLG_BATTLE_MEWTWO,
BGM_FRLG_BATTLE_LEGENDARY,
BGM_FRLG_LEADER_EYE,
BGM_FRLG_DEOXYS_EYE,
BGM_FRLG_TRAINER_TOWER,
BGM_FRLG_HALL_OF_FAME_PALLET_TOWN,
/*0x22E*/BGM_FRLG_TEACHY_TV,
/*0x227*/ BGM_FRLG_BATTLE_DEOXYS,
/*0x228*/ BGM_FRLG_BATTLE_MEWTWO,
/*0x229*/ BGM_FRLG_BATTLE_LEGENDARY,
/*0x22A*/ BGM_FRLG_LEADER_EYE,
/*0x22B*/ BGM_FRLG_DEOXYS_EYE,
/*0x22C*/ BGM_FRLG_TRAINER_TOWER,
/*0x22D*/ BGM_FRLG_HALL_OF_FAME_PALLET_TOWN,
/*0x22E*/ BGM_FRLG_TEACHY_TV,
};
#endif // GUARD_SONGS_H

View File

@ -2,6 +2,11 @@
#define GUARD_TRAINER_IDS_H
#define NO_OF_TRAINERS 854
#define TRAINER_ID_SIDNEY 261
#define TRAINER_ID_PHOEBE 262
#define TRAINER_ID_GLACIA 263
#define TRAINER_ID_DRAKE 264
#define TRAINER_ID_STEVEN 804
#endif // GUARD_TRAINER_IDS_H

View File

@ -14,6 +14,7 @@
#define VAR_0x4008 0x4008
#define VAR_0x4009 0x4009
#define VAR_0x400A 0x400A
#define VAR_0x400E 0x400E
#define VAR_0x4010 0x4010
#define VAR_0x4011 0x4011
#define VAR_0x401F 0x401F

View File

@ -119,6 +119,7 @@ SECTIONS {
asm/battle_anim_80A9C70.o(.text);
asm/title_screen.o(.text);
asm/field_screen.o(.text);
src/battle_setup.o(.text);
asm/battle_setup.o(.text);
asm/cable_club.o(.text);
asm/trainer_see.o(.text);
@ -377,6 +378,7 @@ SECTIONS {
data/battle_anim_80A9C70.o(.rodata);
data/title_screen.o(.rodata);
data/field_screen.o(.rodata);
src/battle_setup.o(.rodata);
data/battle_setup.o(.rodata);
data/cable_club.o(.rodata);
data/trainer_see.o(.rodata);

586
src/battle_setup.c Normal file
View File

@ -0,0 +1,586 @@
#include "global.h"
#include "battle.h"
#include "battle_setup.h"
#include "battle_transition.h"
#include "main.h"
#include "task.h"
#include "pokemon_3.h"
#include "safari_zone.h"
#include "script.h"
#include "game_stat.h"
#include "event_data.h"
#include "species.h"
#include "songs.h"
#include "metatile_behavior.h"
#include "map_constants.h"
#include "field_player_avatar.h"
#include "fieldmap.h"
#include "trainer_classes.h"
#include "trainer_ids.h"
extern bool8 InBattlePyramid(void);
extern bool8 InBattlePike(void);
extern bool32 FieldPoisonEffectIsRunning(void);
extern void overworld_free_bg_tilemaps(void);
extern void prev_quest_postbuffer_cursor_backup_reset(void);
extern void ResetPoisonStepCounter(void);
extern void sub_81BE72C(void);
extern void FreezeMapObjects(void);
extern void sub_808BCF4(void);
extern void sub_80EECC8(void);
extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void);
extern void c2_exit_to_overworld_2_switch(void);
extern void CB2_WhiteOut(void);
extern void sub_80AF6F0(void);
extern u8 GetSav1Weather(void);
extern u8 Overworld_GetFlashLevel(void);
extern u32 gBattleTypeFlags;
extern u8 gBattleOutcome;
extern void (*gFieldCallback)(void);
extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B;
// this file's functions
void DoBattlePikeWildBattle(void);
void DoSafariBattle(void);
void DoStandardWildBattle(void);
void CB2_EndWildBattle(void);
void CB2_EndScriptedWildBattle(void);
u8 GetWildBattleTransition(void);
u8 GetTrainerBattleTransition(void);
u8 sub_80B100C(u8 arg0);
void sub_80B1218(void);
void sub_80B1234(void);
bool32 IsPlayerDefeated(u8 battleOutcome);
// const rom data
// The first transition is used if the enemy pokemon are lower level than our pokemon.
// Otherwise, the second transition is used.
static const u8 sBattleTransitionTable_Wild[][2] =
{
{B_TRANSITION_SLICE, B_TRANSITION_WHITEFADE}, // Normal
{B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES}, // Cave
{B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used
{B_TRANSITION_WAVE, B_TRANSITION_RIPPLE}, // Water
};
static const u8 sBattleTransitionTable_Trainer[][2] =
{
{B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_SHARDS}, // Normal
{B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL}, // Cave
{B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used
{B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, // Water
};
#define tState data[0]
#define tTransition data[1]
void Task_BattleStart(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (tState)
{
case 0:
if (!FieldPoisonEffectIsRunning()) // is poison not active?
{
BattleTransition_StartOnField(tTransition);
sub_81BE72C();
tState++; // go to case 1.
}
break;
case 1:
if (IsBattleTransitionDone() == TRUE)
{
overworld_free_bg_tilemaps();
SetMainCallback2(CB2_InitBattle);
prev_quest_postbuffer_cursor_backup_reset();
ResetPoisonStepCounter();
DestroyTask(taskId);
}
break;
}
}
void CreateBattleStartTask(u8 transition, u16 song)
{
u8 taskId = CreateTask(Task_BattleStart, 1);
gTasks[taskId].tTransition = transition;
PlayMapChosenOrBattleBGM(song);
}
#undef tState
#undef tTransition
void BattleSetup_StartWildBattle(void)
{
if (GetSafariZoneFlag())
DoSafariBattle();
else
DoStandardWildBattle();
}
void BattleSetup_StartBattlePikeWildBattle(void)
{
DoBattlePikeWildBattle();
}
void DoStandardWildBattle(void)
{
ScriptContext2_Enable();
FreezeMapObjects();
sub_808BCF4();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = 0;
if (InBattlePyramid())
{
VarSet(VAR_0x400E, 0);
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
}
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void BattleSetup_StartRoamerBattle(void)
{
ScriptContext2_Enable();
FreezeMapObjects();
sub_808BCF4();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = BATTLE_TYPE_ROAMER;
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void DoSafariBattle(void)
{
ScriptContext2_Enable();
FreezeMapObjects();
sub_808BCF4();
gMain.savedCallback = CB2_EndSafariBattle;
gBattleTypeFlags = BATTLE_TYPE_SAFARI;
CreateBattleStartTask(GetWildBattleTransition(), 0);
}
void DoBattlePikeWildBattle(void)
{
ScriptContext2_Enable();
FreezeMapObjects();
sub_808BCF4();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = BATTLE_TYPE_PIKE;
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void DoTrainerBattle(void)
{
CreateBattleStartTask(GetTrainerBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_TRAINER_BATTLES);
sub_80B1234();
}
void sub_80B0828(void)
{
if (InBattlePyramid())
CreateBattleStartTask(sub_80B100C(10), 0);
else
CreateBattleStartTask(sub_80B100C(11), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_TRAINER_BATTLES);
sub_80B1234();
}
// Initiates battle where Wally catches Ralts
void StartWallyTutorialBattle(void)
{
CreateMaleMon(&gEnemyParty[0], SPECIES_RALTS, 5);
ScriptContext2_Enable();
gMain.savedCallback = c2_exit_to_overworld_1_continue_scripts_restart_music;
gBattleTypeFlags = BATTLE_TYPE_WALLY_TUTORIAL;
CreateBattleStartTask(B_TRANSITION_SLICE, 0);
}
void BattleSetup_StartScriptedWildBattle(void)
{
ScriptContext2_Enable();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = 0;
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void BattleSetup_StartLatiBattle(void)
{
ScriptContext2_Enable();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY;
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void BattleSetup_StartLegendaryBattle(void)
{
ScriptContext2_Enable();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY;
switch (GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL))
{
default:
case SPECIES_GROUDON:
gBattleTypeFlags |= BATTLE_TYPE_GROUDON;
CreateBattleStartTask(B_TRANSITION_GROUDON, BGM_BATTLE34);
break;
case SPECIES_KYOGRE:
gBattleTypeFlags |= BATTLE_TYPE_KYORGE;
CreateBattleStartTask(B_TRANSITION_KYORGE, BGM_BATTLE34);
break;
case SPECIES_RAYQUAZA:
gBattleTypeFlags |= BATTLE_TYPE_RAYQUAZA;
CreateBattleStartTask(B_TRANSITION_RAYQUAZA, BGM_BATTLE_LEGENDARY);
break;
case SPECIES_DEOXYS:
CreateBattleStartTask(B_TRANSITION_BLUR, BGM_FRLG_BATTLE_DEOXYS);
break;
case SPECIES_LUGIA:
case SPECIES_HO_OH:
CreateBattleStartTask(B_TRANSITION_BLUR, BGM_FRLG_BATTLE_LEGENDARY);
break;
case SPECIES_MEW:
CreateBattleStartTask(B_TRANSITION_GRID_SQUARES, BGM_BATTLE_MEW);
break;
}
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void StartGroudonKyogreBattle(void)
{
ScriptContext2_Enable();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON;
if (gGameVersion == VERSION_RUBY)
CreateBattleStartTask(B_TRANSITION_SHARDS, BGM_BATTLE34); // GROUDON
else
CreateBattleStartTask(B_TRANSITION_RIPPLE, BGM_BATTLE34); // KYOGRE
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void StartRegiBattle(void)
{
u8 transitionId;
u16 species;
ScriptContext2_Enable();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI;
species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES);
switch (species)
{
case SPECIES_REGIROCK:
transitionId = B_TRANSITION_REGIROCK;
break;
case SPECIES_REGICE:
transitionId = B_TRANSITION_REGICE;
break;
case SPECIES_REGISTEEL:
transitionId = B_TRANSITION_REGISTEEL;
break;
default:
transitionId = B_TRANSITION_GRID_SQUARES;
break;
}
CreateBattleStartTask(transitionId, BGM_BATTLE36);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();
sub_80B1218();
}
void CB2_EndWildBattle(void)
{
CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE);
ResetOamRange(0, 128);
if (IsPlayerDefeated(gBattleOutcome) == TRUE && !InBattlePyramid() && !InBattlePike())
{
SetMainCallback2(CB2_WhiteOut);
}
else
{
SetMainCallback2(c2_exit_to_overworld_2_switch);
gFieldCallback = sub_80AF6F0;
}
}
void CB2_EndScriptedWildBattle(void)
{
CpuFill16(0, (void*)(BG_PLTT), BG_PLTT_SIZE);
ResetOamRange(0, 128);
if (IsPlayerDefeated(gBattleOutcome) == TRUE)
{
if (InBattlePyramid())
SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music);
else
SetMainCallback2(CB2_WhiteOut);
}
else
{
SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music);
}
}
u8 BattleSetup_GetTerrainId(void)
{
u16 tileBehavior;
s16 x, y;
PlayerGetDestCoords(&x, &y);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsTallGrass(tileBehavior))
return BATTLE_TERRAIN_GRASS;
if (MetatileBehavior_IsLongGrass(tileBehavior))
return BATTLE_TERRAIN_LONG_GRASS;
if (MetatileBehavior_IsSandOrDeepSand(tileBehavior))
return BATTLE_TERRAIN_SAND;
switch (gMapHeader.mapType)
{
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
break;
case MAP_TYPE_UNDERGROUND:
if (MetatileBehavior_IsMB_0B(tileBehavior))
return BATTLE_TERRAIN_BUILDING;
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
return BATTLE_TERRAIN_POND;
return BATTLE_TERRAIN_CAVE;
case MAP_TYPE_INDOOR:
case MAP_TYPE_SECRET_BASE:
return BATTLE_TERRAIN_BUILDING;
case MAP_TYPE_UNDERWATER:
return BATTLE_TERRAIN_UNDERWATER;
case MAP_TYPE_6:
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
return BATTLE_TERRAIN_WATER;
return BATTLE_TERRAIN_PLAIN;
}
if (MetatileBehavior_IsDeepOrOceanWater(tileBehavior))
return BATTLE_TERRAIN_WATER;
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
return BATTLE_TERRAIN_POND;
if (MetatileBehavior_IsMountain(tileBehavior))
return BATTLE_TERRAIN_MOUNTAIN;
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
{
if (MetatileBehavior_GetBridgeSth(tileBehavior))
return BATTLE_TERRAIN_POND;
if (MetatileBehavior_IsBridge(tileBehavior) == TRUE)
return BATTLE_TERRAIN_WATER;
}
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ROUTE113 && gSaveBlock1Ptr->location.mapNum == MAP_ID_ROUTE113)
return BATTLE_TERRAIN_SAND;
if (GetSav1Weather() == 8)
return BATTLE_TERRAIN_SAND;
return BATTLE_TERRAIN_PLAIN;
}
u8 GetBattleTransitionTypeByMap(void)
{
u16 tileBehavior;
s16 x, y;
PlayerGetDestCoords(&x, &y);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (Overworld_GetFlashLevel())
return B_TRANSITION_SHUFFLE;
if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
{
switch (gMapHeader.mapType)
{
case MAP_TYPE_UNDERGROUND:
return B_TRANSITION_SWIRL;
case MAP_TYPE_UNDERWATER:
return B_TRANSITION_BIG_POKEBALL;
default:
return B_TRANSITION_BLUR;
}
}
return B_TRANSITION_BIG_POKEBALL;
}
u16 GetSumOfPlayerPartyLevel(u8 numMons)
{
u8 sum = 0;
int i;
for (i = 0; i < PARTY_SIZE; i++)
{
u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
{
sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL);
if (--numMons == 0)
break;
}
}
return sum;
}
u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons)
{
u8 i;
u8 sum;
u32 count = numMons;
if (gTrainers[opponentId].partySize < count)
count = gTrainers[opponentId].partySize;
sum = 0;
switch (gTrainers[opponentId].partyFlags)
{
case 0:
{
const struct TrainerMonNoItemDefaultMoves *party;
party = gTrainers[opponentId].party.NoItemDefaultMoves;
for (i = 0; i < count; i++)
sum += party[i].lvl;
}
break;
case PARTY_FLAG_CUSTOM_MOVES:
{
const struct TrainerMonNoItemCustomMoves *party;
party = gTrainers[opponentId].party.NoItemCustomMoves;
for (i = 0; i < count; i++)
sum += party[i].lvl;
}
break;
case PARTY_FLAG_HAS_ITEM:
{
const struct TrainerMonItemDefaultMoves *party;
party = gTrainers[opponentId].party.ItemDefaultMoves;
for (i = 0; i < count; i++)
sum += party[i].lvl;
}
break;
case PARTY_FLAG_CUSTOM_MOVES | PARTY_FLAG_HAS_ITEM:
{
const struct TrainerMonItemCustomMoves *party;
party = gTrainers[opponentId].party.ItemCustomMoves;
for (i = 0; i < count; i++)
sum += party[i].lvl;
}
break;
}
return sum;
}
u8 GetWildBattleTransition(void)
{
u8 transitionType = GetBattleTransitionTypeByMap();
u8 enemyLevel = GetMonData(&gEnemyParty[0], MON_DATA_LEVEL);
u8 playerLevel = GetSumOfPlayerPartyLevel(1);
if (enemyLevel < playerLevel)
{
if (InBattlePyramid())
return B_TRANSITION_BLUR;
else
return sBattleTransitionTable_Wild[transitionType][0];
}
else
{
if (InBattlePyramid())
return B_TRANSITION_GRID_SQUARES;
else
return sBattleTransitionTable_Wild[transitionType][1];
}
}
u8 GetTrainerBattleTransition(void)
{
u8 minPartyCount;
u8 transitionType;
u8 enemyLevel;
u8 playerLevel;
if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT)
return B_TRANSITION_STEVEN;
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_ELITE_FOUR)
{
if (gTrainerBattleOpponent_A == TRAINER_ID_SIDNEY)
return B_TRANSITION_SYDNEY;
if (gTrainerBattleOpponent_A == TRAINER_ID_PHOEBE)
return B_TRANSITION_PHOEBE;
if (gTrainerBattleOpponent_A == TRAINER_ID_GLACIA)
return B_TRANSITION_GLACIA;
if (gTrainerBattleOpponent_A == TRAINER_ID_DRAKE)
return B_TRANSITION_DRAKE;
return B_TRANSITION_STEVEN;
}
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_CHAMPION)
return B_TRANSITION_STEVEN;
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_TEAM_MAGMA
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_MAGMA_LEADER
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_MAGMA_ADMIN)
return B_TRANSITION_MAGMA;
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_TEAM_AQUA
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_AQUA_LEADER
|| gTrainers[gTrainerBattleOpponent_A].trainerClass == CLASS_AQUA_ADMIN)
return B_TRANSITION_AQUA;
if (gTrainers[gTrainerBattleOpponent_A].doubleBattle == TRUE)
minPartyCount = 2; // double battles always at least have 2 pokemon.
else
minPartyCount = 1;
transitionType = GetBattleTransitionTypeByMap();
enemyLevel = GetSumOfEnemyPartyLevel(gTrainerBattleOpponent_A, minPartyCount);
playerLevel = GetSumOfPlayerPartyLevel(minPartyCount);
if (enemyLevel < playerLevel) // is wild mon level than the player's mon level?
return sBattleTransitionTable_Trainer[transitionType][0];
else
return sBattleTransitionTable_Trainer[transitionType][1];
}

View File

@ -1396,7 +1396,7 @@ static s32 GetWildMonTableIdInAlteringCave(u16 species)
void SetWildMonHeldItem(void)
{
if (!(gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID | BATTLE_TYPE_x100000)))
if (!(gBattleTypeFlags & (BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID | BATTLE_TYPE_PIKE)))
{
u16 rnd = Random() % 100;
u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, 0);

View File

@ -105,7 +105,7 @@ void SafariZoneRetirePrompt(void)
ScriptContext1_SetupScript(EventScript_2A4B6F);
}
void sub_80FC190(void)
void CB2_EndSafariBattle(void)
{
sSafariZoneFleedMons += gBattleResults.field_1F;
if (gBattleOutcome == BATTLE_CAUGHT)