Set up Battle Factory macros

This commit is contained in:
GriffinR 2019-12-02 08:44:34 -05:00 committed by huderlem
parent 41c1c9ca8a
commit 9fcfbdbef5
10 changed files with 269 additions and 187 deletions

View File

@ -1 +1,103 @@
@ To be populated with macros for CallBattleFactoryFunction
@ TODO: Add explanatory comments
@
.macro factory_init
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_INIT
special CallBattleFactoryFunction
.endm
@
.macro factory_get data:req
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_GET_DATA
setvar VAR_0x8005, \data
special CallBattleFactoryFunction
.endm
@
.macro factory_set data:req, val=0xFFFF
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SET_DATA
setvar VAR_0x8005, \data
.if \val == 0xFFFF
@ argument not provided
.elseif \val >= VARS_START
copyvar VAR_0x8006, \val
.else
setvar VAR_0x8006, \val
.endif
special CallBattleFactoryFunction
.endm
@
.macro factory_save challengeStatus:req
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SAVE
setvar VAR_0x8005, \challengeStatus
special CallBattleFactoryFunction
.endm
@
.macro factory_rentmons
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SELECT_RENT_MONS
special CallBattleFactoryFunction
.endm
@
.macro factory_swapmons
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SWAP_RENT_MONS
special CallBattleFactoryFunction
.endm
@
.macro factory_setswapped
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SET_SWAPPED
special CallBattleFactoryFunction
.endm
@
.macro factory_setopponentmons
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SET_OPPONENT_MONS
special CallBattleFactoryFunction
.endm
@
.macro factory_setparties arg:req
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SET_PARTIES
setvar VAR_0x8005, \arg
special CallBattleFactoryFunction
.endm
@
.macro factory_setopponentgfx
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_SET_OPPONENT_GFX
special CallBattleFactoryFunction
.endm
@
.macro factory_generateopponentmons
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_GENERATE_OPPONENT_MONS
special CallBattleFactoryFunction
.endm
@
.macro factory_generaterentalmons
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_GENERATE_RENTAL_MONS
special CallBattleFactoryFunction
.endm
@
.macro factory_getopponentmontype
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_GET_OPPONENT_MON_TYPE
special CallBattleFactoryFunction
.endm
@
.macro factory_getopponentstyle
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_GET_OPPONENT_STYLE
special CallBattleFactoryFunction
.endm
@
.macro factory_resethelditems
setvar VAR_0x8004, BATTLE_FACTORY_FUNC_RESET_HELD_ITEMS
special CallBattleFactoryFunction
.endm

View File

@ -3,6 +3,7 @@
#include "constants/battle.h"
#include "constants/battle_arena.h"
#include "constants/battle_dome.h"
#include "constants/battle_factory.h"
#include "constants/battle_frontier.h"
#include "constants/battle_palace.h"
#include "constants/battle_pike.h"

View File

@ -66,8 +66,7 @@ BattleFrontier_BattleFactoryBattleRoom_EventScript_25AE67:: @ 825AE67
applymovement EVENT_OBJ_ID_PLAYER, BattleFrontier_BattleFactoryBattleRoom_Movement_25B17B
waitmovement 0
call BattleFrontier_BattleFactoryBattleRoom_EventScript_25B1B4
setvar VAR_0x8004, 11
special CallBattleFactoryFunction
factory_setopponentgfx
removeobject 2
setobjectxyperm 2, 7, 1
addobject 2
@ -90,7 +89,6 @@ BattleFrontier_BattleFactoryBattleRoom_EventScript_25AEA7:: @ 825AEA7
waitstate
switch VAR_RESULT
case 1, BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF0F
BattleFrontier_BattleFactoryBattleRoom_EventScript_25AEF8:: @ 825AEF8
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25AEF8:: @ 825AEF8
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_LOST
@ -98,16 +96,12 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25AEF8:: @ 825AEF8
@ goto BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25B190
BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF0F:: @ 825AF0F
setvar VAR_0x8004, 1
setvar VAR_0x8005, 3
special CallBattleFactoryFunction
factory_get FACTORY_DATA_WIN_STREAK_SWAPS
compare VAR_RESULT, MAX_STREAK
goto_if_eq BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF3E
addvar VAR_RESULT, 1
setorcopyvar VAR_0x8006, VAR_RESULT
setvar VAR_0x8004, 2
setvar VAR_0x8005, 3
special CallBattleFactoryFunction
factory_set FACTORY_DATA_WIN_STREAK_SWAPS @ uses VAR_0x8006 above
BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF3E:: @ 825AF3E
call BattleFrontier_EventScript_IncrementWinStreak
BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF43:: @ 825AF43
@ -196,26 +190,17 @@ BattleFrontier_BattleFactoryBattleRoom_EventScript_25B0E0:: @ 825B0E0
return
BattleFrontier_BattleFactoryBattleRoom_EventScript_25B105:: @ 825B105
setvar VAR_0x8004, 1
setvar VAR_0x8005, 3
special CallBattleFactoryFunction
factory_get FACTORY_DATA_WIN_STREAK_SWAPS
compare VAR_RESULT, MAX_STREAK
goto_if_eq BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF3E
addvar VAR_RESULT, 1
setorcopyvar VAR_0x8006, VAR_RESULT
setvar VAR_0x8004, 2
setvar VAR_0x8005, 3
special CallBattleFactoryFunction
setvar VAR_0x8004, 1
setvar VAR_0x8005, 1
special CallBattleFactoryFunction
factory_set FACTORY_DATA_WIN_STREAK_SWAPS @ uses VAR_0x8006 above
factory_get FACTORY_DATA_WIN_STREAK
compare VAR_RESULT, MAX_STREAK
goto_if_eq BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF43
addvar VAR_RESULT, 1
setvar VAR_0x8004, 2
setvar VAR_0x8005, 1
copyvar VAR_0x8006, VAR_RESULT
special CallBattleFactoryFunction
factory_set FACTORY_DATA_WIN_STREAK, VAR_RESULT
frontier_get FRONTIER_DATA_BATTLE_NUM
addvar VAR_RESULT, 1
goto BattleFrontier_BattleFactoryBattleRoom_EventScript_25AF85

View File

@ -28,20 +28,10 @@ BattleFrontier_BattleFactoryLobby_EventScript_25843A:: @ 825843A
lockall
msgbox BattleFrontier_BattleFactoryLobby_Text_258ECA, MSGBOX_DEFAULT
closemessage
setvar VAR_0x8004, 8
special CallBattleFactoryFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 3
setvar VAR_0x8006, 0
special CallBattleFactoryFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 1
setvar VAR_0x8006, 0
special CallBattleFactoryFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 0
special CallBattleFactoryFunction
factory_setswapped
factory_set FACTORY_DATA_WIN_STREAK_SWAPS, 0
factory_set FACTORY_DATA_WIN_STREAK, 0
factory_set FACTORY_DATA_WIN_STREAK_ACTIVE, FALSE
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, 0
setvar VAR_TEMP_0, 255
releaseall
@ -68,9 +58,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_2584C6:: @ 82584C6
waitmessage
frontier_checkairshow
special LoadPlayerParty
setvar VAR_0x8004, 3
setvar VAR_0x8005, 0
special CallBattleFactoryFunction
factory_save 0
playse SE_SAVE
waitse
goto BattleFrontier_BattleFactoryLobby_EventScript_25853B
@ -82,13 +70,8 @@ BattleFrontier_BattleFactoryLobby_EventScript_258506:: @ 8258506
waitmessage
frontier_checkairshow
special LoadPlayerParty
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 0
special CallBattleFactoryFunction
setvar VAR_0x8004, 3
setvar VAR_0x8005, 0
special CallBattleFactoryFunction
factory_set FACTORY_DATA_WIN_STREAK_ACTIVE, FALSE
factory_save 0
playse SE_SAVE
waitse
@ -117,9 +100,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_258592:: @ 8258592
lockall
message BattleFrontier_BattleFactoryLobby_Text_258E77
waitmessage
setvar VAR_0x8004, 3
setvar VAR_0x8005, 1
special CallBattleFactoryFunction
factory_save CHALLENGE_STATUS_SAVING
playse SE_SAVE
waitse
frontier_set FRONTIER_DATA_PAUSED, FALSE
@ -177,13 +158,9 @@ BattleFrontier_BattleFactoryLobby_EventScript_258653:: @ 8258653
BattleFrontier_BattleFactoryLobby_EventScript_2586B9:: @ 82586B9
setvar VAR_TEMP_0, 0
setvar VAR_0x8004, 0
special CallBattleFactoryFunction
factory_init
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_SAVING
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 1
special CallBattleFactoryFunction
factory_set FACTORY_DATA_WIN_STREAK_ACTIVE, TRUE
frontier_set FRONTIER_DATA_PAUSED, FALSE
closemessage
delay 2

View File

@ -31,33 +31,26 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259AF9:: @ 8259AF9
waitmovement 0
compare VAR_0x8006, 2
goto_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E69
setvar VAR_0x8004, 13
special CallBattleFactoryFunction
setvar VAR_0x8004, 12
special CallBattleFactoryFunction
setvar VAR_0x8004, 14
special CallBattleFactoryFunction
factory_generaterentalmons
factory_generateopponentmons
factory_getopponentmontype
setorcopyvar VAR_0x8005, VAR_RESULT
setvar VAR_0x8004, 15
special CallBattleFactoryFunction
factory_getopponentstyle
setorcopyvar VAR_0x8006, VAR_RESULT
call BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E93
call BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A004
msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_25A1C8, MSGBOX_DEFAULT
fadescreen 1
setvar VAR_0x8004, 8
special CallBattleFactoryFunction
setvar VAR_0x8004, 6
special CallBattleFactoryFunction
factory_setswapped
factory_rentmons
waitstate
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259B74:: @ 8259B74
msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_25AB96, MSGBOX_DEFAULT
closemessage
call BattleFrontier_EventScript_GetLvlMode
compare VAR_RESULT, 0
compare VAR_RESULT, FRONTIER_LVL_50
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A17C
compare VAR_RESULT, 1
compare VAR_RESULT, FRONTIER_LVL_OPEN
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A18B
waitmovement 0
warp MAP_BATTLE_FRONTIER_BATTLE_FACTORY_BATTLE_ROOM, 255, 6, 11
@ -65,10 +58,8 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259B74:: @ 8259B74
end
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259BA5:: @ 8259BA5
setvar VAR_0x8004, 9
special CallBattleFactoryFunction
setvar VAR_0x8004, 16
special CallBattleFactoryFunction
factory_setopponentmons
factory_resethelditems
msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_25A22D, MSGBOX_DEFAULT
playfanfare MUS_ME_ASA
waitfanfare
@ -160,13 +151,10 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259D66:: @ 8259D66
case MULTI_B_PRESSED, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259C13
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259D98:: @ 8259D98
setvar VAR_0x8004, 12
special CallBattleFactoryFunction
setvar VAR_0x8004, 14
special CallBattleFactoryFunction
factory_generateopponentmons
factory_getopponentmontype
setorcopyvar VAR_0x8005, VAR_RESULT
setvar VAR_0x8004, 15
special CallBattleFactoryFunction
factory_getopponentstyle
setorcopyvar VAR_0x8006, VAR_RESULT
call BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E93
call BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A004
@ -178,13 +166,11 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259D98:: @ 8259D98
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259DF2:: @ 8259DF2
fadescreen 1
setvar VAR_0x8004, 7
special CallBattleFactoryFunction
factory_swapmons
waitstate
compare VAR_RESULT, 1
goto_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259B74
setvar VAR_0x8004, 8
special CallBattleFactoryFunction
factory_setswapped
msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_25AB6C, MSGBOX_DEFAULT
goto BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259B74
@ -221,9 +207,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E40:: @ 8259E40
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E47:: @ 8259E47
message BattleFrontier_BattleFactoryPreBattleRoom_Text_25ABAE
waitmessage
setvar VAR_0x8004, 3
setvar VAR_0x8005, 2
special CallBattleFactoryFunction
factory_save CHALLENGE_STATUS_PAUSED
playse SE_SAVE
waitse
fadescreen 1
@ -232,50 +216,48 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E47:: @ 8259E47
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E69:: @ 8259E69
special SavePlayerParty
setvar VAR_0x8004, 10
setvar VAR_0x8005, 0
special CallBattleFactoryFunction
factory_setparties 0
frontier_set FRONTIER_DATA_6, 1
special CalculatePlayerPartyCount
goto BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259C13
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259E93:: @ 8259E93
msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_25A3B4, MSGBOX_DEFAULT
compare VAR_0x8005, 0
compare VAR_0x8005, TYPE_NORMAL
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F62
compare VAR_0x8005, 1
compare VAR_0x8005, TYPE_FIGHTING
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F6B
compare VAR_0x8005, 2
compare VAR_0x8005, TYPE_FLYING
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F74
compare VAR_0x8005, 3
compare VAR_0x8005, TYPE_POISON
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F7D
compare VAR_0x8005, 4
compare VAR_0x8005, TYPE_GROUND
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F86
compare VAR_0x8005, 5
compare VAR_0x8005, TYPE_ROCK
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F8F
compare VAR_0x8005, 6
compare VAR_0x8005, TYPE_BUG
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259F98
compare VAR_0x8005, 7
compare VAR_0x8005, TYPE_GHOST
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FA1
compare VAR_0x8005, 8
compare VAR_0x8005, TYPE_STEEL
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FAA
compare VAR_0x8005, 10
compare VAR_0x8005, TYPE_FIRE
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FB3
compare VAR_0x8005, 11
compare VAR_0x8005, TYPE_WATER
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FBC
compare VAR_0x8005, 12
compare VAR_0x8005, TYPE_GRASS
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FC5
compare VAR_0x8005, 13
compare VAR_0x8005, TYPE_ELECTRIC
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FCE
compare VAR_0x8005, 14
compare VAR_0x8005, TYPE_PSYCHIC
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FD7
compare VAR_0x8005, 15
compare VAR_0x8005, TYPE_ICE
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FE0
compare VAR_0x8005, 16
compare VAR_0x8005, TYPE_DRAGON
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FE9
compare VAR_0x8005, 17
compare VAR_0x8005, TYPE_DARK
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FF2
compare VAR_0x8005, 18
compare VAR_0x8005, NUMBER_OF_MON_TYPES
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FFB
return
@ -352,23 +334,23 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_259FFB:: @ 8259FFB
return
BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A004:: @ 825A004
compare VAR_0x8006, 0
compare VAR_0x8006, FACTORY_STYLE_NONE
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A068
compare VAR_0x8006, 1
compare VAR_0x8006, FACTORY_STYLE_PREPARATION
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A071
compare VAR_0x8006, 2
compare VAR_0x8006, FACTORY_STYLE_SLOW_STEADY
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A07A
compare VAR_0x8006, 3
compare VAR_0x8006, FACTORY_STYLE_ENDURANCE
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A083
compare VAR_0x8006, 4
compare VAR_0x8006, FACTORY_STYLE_HIGH_RISK
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A08C
compare VAR_0x8006, 5
compare VAR_0x8006, FACTORY_STYLE_WEAKENING
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A095
compare VAR_0x8006, 6
compare VAR_0x8006, FACTORY_STYLE_UNPREDICTABLE
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A09E
compare VAR_0x8006, 7
compare VAR_0x8006, FACTORY_STYLE_WEATHER
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A0A7
compare VAR_0x8006, 8
compare VAR_0x8006, FACTORY_NUM_STYLES
call_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_25A0B0
return

View File

@ -41,8 +41,7 @@ SlateportCity_BattleTentBattleRoom_MapScript2_2099B4: @ 82099B4
SlateportCity_BattleTentBattleRoom_EventScript_2099BE:: @ 82099BE
applymovement 3, SlateportCity_BattleTentBattleRoom_Movement_209A99
waitmovement 0
setvar VAR_0x8004, 11
special CallBattleFactoryFunction
factory_setopponentgfx
setobjectxyperm 2, 5, 1
removeobject 2
addobject 2

View File

@ -57,10 +57,8 @@ SlateportCity_BattleTentCorridor_EventScript_208EB4:: @ 8208EB4
end
SlateportCity_BattleTentCorridor_EventScript_208EEE:: @ 8208EEE
setvar VAR_0x8004, 9
special CallBattleFactoryFunction
setvar VAR_0x8004, 16
special CallBattleFactoryFunction
factory_setopponentmons
factory_resethelditems
msgbox SlateportCity_BattleTentCorridor_Text_25A22D, MSGBOX_DEFAULT
playfanfare MUS_ME_ASA
waitfanfare
@ -136,9 +134,7 @@ SlateportCity_BattleTentCorridor_EventScript_209022:: @ 8209022
SlateportCity_BattleTentCorridor_EventScript_209044:: @ 8209044
special SavePlayerParty
setvar VAR_0x8004, 10
setvar VAR_0x8005, 0
special CallBattleFactoryFunction
factory_setparties 0
goto SlateportCity_BattleTentCorridor_EventScript_208F0D
SlateportCity_BattleTentCorridor_Movement_209059: @ 8209059

View File

@ -0,0 +1,37 @@
#ifndef GUARD_CONSTANTS_BATTLE_FACTORY_H
#define GUARD_CONSTANTS_BATTLE_FACTORY_H
#define FACTORY_STYLE_NONE 0
#define FACTORY_STYLE_PREPARATION 1
#define FACTORY_STYLE_SLOW_STEADY 2
#define FACTORY_STYLE_ENDURANCE 3
#define FACTORY_STYLE_HIGH_RISK 4
#define FACTORY_STYLE_WEAKENING 5
#define FACTORY_STYLE_UNPREDICTABLE 6
#define FACTORY_STYLE_WEATHER 7
#define FACTORY_NUM_STYLES 8
#define BATTLE_FACTORY_FUNC_INIT 0
#define BATTLE_FACTORY_FUNC_GET_DATA 1
#define BATTLE_FACTORY_FUNC_SET_DATA 2
#define BATTLE_FACTORY_FUNC_SAVE 3
#define BATTLE_FACTORY_FUNC_NULL 4
#define BATTLE_FACTORY_FUNC_NULL2 5
#define BATTLE_FACTORY_FUNC_SELECT_RENT_MONS 6
#define BATTLE_FACTORY_FUNC_SWAP_RENT_MONS 7
#define BATTLE_FACTORY_FUNC_SET_SWAPPED 8
#define BATTLE_FACTORY_FUNC_SET_OPPONENT_MONS 9
#define BATTLE_FACTORY_FUNC_SET_PARTIES 10
#define BATTLE_FACTORY_FUNC_SET_OPPONENT_GFX 11
#define BATTLE_FACTORY_FUNC_GENERATE_OPPONENT_MONS 12
#define BATTLE_FACTORY_FUNC_GENERATE_RENTAL_MONS 13
#define BATTLE_FACTORY_FUNC_GET_OPPONENT_MON_TYPE 14
#define BATTLE_FACTORY_FUNC_GET_OPPONENT_STYLE 15
#define BATTLE_FACTORY_FUNC_RESET_HELD_ITEMS 16
#define FACTORY_DATA_WIN_STREAK 1
#define FACTORY_DATA_WIN_STREAK_ACTIVE 2
#define FACTORY_DATA_WIN_STREAK_SWAPS 3
#endif // GUARD_CONSTANTS_BATTLE_FACTORY_H

View File

@ -10,6 +10,7 @@
#include "random.h"
#include "constants/species.h"
#include "constants/battle_ai.h"
#include "constants/battle_factory.h"
#include "constants/battle_frontier.h"
#include "constants/frontier_util.h"
#include "constants/layouts.h"
@ -49,14 +50,14 @@ static const u16 sMoves_TotalPreparation[] =
MOVE_MINIMIZE, MOVE_WITHDRAW, MOVE_DEFENSE_CURL, MOVE_BARRIER, MOVE_FOCUS_ENERGY, MOVE_AMNESIA,
MOVE_ACID_ARMOR, MOVE_SHARPEN, MOVE_CONVERSION, MOVE_CONVERSION_2, MOVE_BELLY_DRUM, MOVE_PSYCH_UP,
MOVE_CHARGE, MOVE_SNATCH, MOVE_TAIL_GLOW, MOVE_COSMIC_POWER, MOVE_IRON_DEFENSE, MOVE_HOWL, MOVE_BULK_UP, MOVE_CALM_MIND, MOVE_DRAGON_DANCE,
0
MOVE_NONE
};
static const u16 sMoves_ImpossibleToPredict[] =
{
MOVE_MIMIC, MOVE_METRONOME, MOVE_MIRROR_MOVE, MOVE_TRANSFORM, MOVE_SUBSTITUTE, MOVE_SKETCH, MOVE_CURSE,
MOVE_PRESENT, MOVE_FOLLOW_ME, MOVE_TRICK, MOVE_ROLE_PLAY, MOVE_ASSIST, MOVE_SKILL_SWAP, MOVE_CAMOUFLAGE,
0
MOVE_NONE
};
static const u16 sMoves_WeakeningTheFoe[] =
@ -64,7 +65,7 @@ static const u16 sMoves_WeakeningTheFoe[] =
MOVE_SAND_ATTACK, MOVE_TAIL_WHIP, MOVE_LEER, MOVE_GROWL, MOVE_STRING_SHOT, MOVE_SCREECH, MOVE_SMOKESCREEN, MOVE_KINESIS,
MOVE_FLASH, MOVE_COTTON_SPORE, MOVE_SPITE, MOVE_SCARY_FACE, MOVE_CHARM, MOVE_KNOCK_OFF, MOVE_SWEET_SCENT, MOVE_FEATHER_DANCE,
MOVE_FAKE_TEARS, MOVE_METAL_SOUND, MOVE_TICKLE,
0
MOVE_NONE
};
static const u16 sMoves_HighRiskHighReturn[] =
@ -73,7 +74,7 @@ static const u16 sMoves_HighRiskHighReturn[] =
MOVE_BIDE, MOVE_SELF_DESTRUCT, MOVE_SKY_ATTACK, MOVE_EXPLOSION, MOVE_FLAIL, MOVE_REVERSAL, MOVE_DESTINY_BOND,
MOVE_PERISH_SONG, MOVE_PAIN_SPLIT, MOVE_MIRROR_COAT, MOVE_MEMENTO, MOVE_GRUDGE, MOVE_FACADE, MOVE_FOCUS_PUNCH,
MOVE_BLAST_BURN, MOVE_HYDRO_CANNON, MOVE_OVERHEAT, MOVE_FRENZY_PLANT, MOVE_PSYCHO_BOOST, MOVE_VOLT_TACKLE,
0
MOVE_NONE
};
static const u16 sMoves_Endurance[] =
@ -82,7 +83,7 @@ static const u16 sMoves_Endurance[] =
MOVE_DETECT, MOVE_ENDURE, MOVE_MILK_DRINK, MOVE_HEAL_BELL, MOVE_SAFEGUARD, MOVE_BATON_PASS, MOVE_MORNING_SUN,
MOVE_SYNTHESIS, MOVE_MOONLIGHT, MOVE_SWALLOW, MOVE_WISH, MOVE_INGRAIN, MOVE_MAGIC_COAT, MOVE_RECYCLE, MOVE_REFRESH,
MOVE_MUD_SPORT, MOVE_SLACK_OFF, MOVE_AROMATHERAPY, MOVE_WATER_SPORT,
0
MOVE_NONE
};
static const u16 sMoves_SlowAndSteady[] =
@ -91,45 +92,46 @@ static const u16 sMoves_SlowAndSteady[] =
MOVE_THUNDER_WAVE, MOVE_TOXIC, MOVE_HYPNOSIS, MOVE_CONFUSE_RAY, MOVE_GLARE, MOVE_POISON_GAS, MOVE_LOVELY_KISS, MOVE_SPORE,
MOVE_SPIDER_WEB, MOVE_SWEET_KISS, MOVE_SPIKES, MOVE_SWAGGER, MOVE_MEAN_LOOK, MOVE_ATTRACT, MOVE_ENCORE, MOVE_TORMENT,
MOVE_FLATTER, MOVE_WILL_O_WISP, MOVE_TAUNT, MOVE_YAWN, MOVE_IMPRISON, MOVE_SNATCH, MOVE_TEETER_DANCE, MOVE_GRASS_WHISTLE, MOVE_BLOCK,
0
MOVE_NONE
};
static const u16 sMoves_DependsOnTheBattlesFlow[] =
{
MOVE_SANDSTORM, MOVE_RAIN_DANCE, MOVE_SUNNY_DAY, MOVE_HAIL, MOVE_WEATHER_BALL,
0
MOVE_NONE
};
static const u16 *const sMoveStyles[] =
// Excludes FACTORY_STYLE_NONE
static const u16 *const sMoveStyles[FACTORY_NUM_STYLES - 1] =
{
sMoves_TotalPreparation,
sMoves_SlowAndSteady,
sMoves_Endurance,
sMoves_HighRiskHighReturn,
sMoves_WeakeningTheFoe,
sMoves_ImpossibleToPredict,
sMoves_DependsOnTheBattlesFlow,
[FACTORY_STYLE_PREPARATION - 1] = sMoves_TotalPreparation,
[FACTORY_STYLE_SLOW_STEADY - 1] = sMoves_SlowAndSteady,
[FACTORY_STYLE_ENDURANCE - 1] = sMoves_Endurance,
[FACTORY_STYLE_HIGH_RISK - 1] = sMoves_HighRiskHighReturn,
[FACTORY_STYLE_WEAKENING - 1] = sMoves_WeakeningTheFoe,
[FACTORY_STYLE_UNPREDICTABLE - 1] = sMoves_ImpossibleToPredict,
[FACTORY_STYLE_WEATHER - 1] = sMoves_DependsOnTheBattlesFlow,
};
static void (* const sBattleFactoryFunctions[])(void) =
{
InitFactoryChallenge,
GetBattleFactoryData,
SetBattleFactoryData,
SaveFactoryChallenge,
nullsub_75,
nullsub_123,
SelectInitialRentalMons,
SwapRentalMons,
SetPerformedRentalSwap,
SetRentalsToOpponentParty,
SetPlayerAndOpponentParties,
SetOpponentGfxVar,
GenerateOpponentMons,
GenerateInitialRentalMons,
GetOpponentMostCommonMonType,
GetOpponentBattleStyle,
RestorePlayerPartyHeldItems,
[BATTLE_FACTORY_FUNC_INIT] = InitFactoryChallenge,
[BATTLE_FACTORY_FUNC_GET_DATA] = GetBattleFactoryData,
[BATTLE_FACTORY_FUNC_SET_DATA] = SetBattleFactoryData,
[BATTLE_FACTORY_FUNC_SAVE] = SaveFactoryChallenge,
[BATTLE_FACTORY_FUNC_NULL] = nullsub_75,
[BATTLE_FACTORY_FUNC_NULL2] = nullsub_123,
[BATTLE_FACTORY_FUNC_SELECT_RENT_MONS] = SelectInitialRentalMons,
[BATTLE_FACTORY_FUNC_SWAP_RENT_MONS] = SwapRentalMons,
[BATTLE_FACTORY_FUNC_SET_SWAPPED] = SetPerformedRentalSwap,
[BATTLE_FACTORY_FUNC_SET_OPPONENT_MONS] = SetRentalsToOpponentParty,
[BATTLE_FACTORY_FUNC_SET_PARTIES] = SetPlayerAndOpponentParties,
[BATTLE_FACTORY_FUNC_SET_OPPONENT_GFX] = SetOpponentGfxVar,
[BATTLE_FACTORY_FUNC_GENERATE_OPPONENT_MONS] = GenerateOpponentMons,
[BATTLE_FACTORY_FUNC_GENERATE_RENTAL_MONS] = GenerateInitialRentalMons,
[BATTLE_FACTORY_FUNC_GET_OPPONENT_MON_TYPE] = GetOpponentMostCommonMonType,
[BATTLE_FACTORY_FUNC_GET_OPPONENT_STYLE] = GetOpponentBattleStyle,
[BATTLE_FACTORY_FUNC_RESET_HELD_ITEMS] = RestorePlayerPartyHeldItems,
};
static const u32 sWinStreakFlags[][2] =
@ -201,7 +203,7 @@ static void InitFactoryChallenge(void)
sPerformedRentalSwap = FALSE;
for (i = 0; i < 6; i++)
gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF;
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
gUnknown_03006298[i] = 0xFFFF;
SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
@ -215,13 +217,13 @@ static void GetBattleFactoryData(void)
switch (gSpecialVar_0x8005)
{
case 1:
case FACTORY_DATA_WIN_STREAK:
gSpecialVar_Result = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode];
break;
case 2:
case FACTORY_DATA_WIN_STREAK_ACTIVE:
gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.winStreakActiveFlags & sWinStreakFlags[battleMode][lvlMode]) != 0);
break;
case 3:
case FACTORY_DATA_WIN_STREAK_SWAPS:
gSpecialVar_Result = gSaveBlock2Ptr->frontier.factoryRentsCount[battleMode][lvlMode];
break;
}
@ -234,16 +236,16 @@ static void SetBattleFactoryData(void)
switch (gSpecialVar_0x8005)
{
case 1:
case FACTORY_DATA_WIN_STREAK:
gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] = gSpecialVar_0x8006;
break;
case 2:
case FACTORY_DATA_WIN_STREAK_ACTIVE:
if (gSpecialVar_0x8006)
gSaveBlock2Ptr->frontier.winStreakActiveFlags |= sWinStreakFlags[battleMode][lvlMode];
else
gSaveBlock2Ptr->frontier.winStreakActiveFlags &= sWinStreakMasks[battleMode][lvlMode];
break;
case 3:
case FACTORY_DATA_WIN_STREAK_SWAPS:
if (sPerformedRentalSwap == TRUE)
{
gSaveBlock2Ptr->frontier.factoryRentsCount[battleMode][lvlMode] = gSpecialVar_0x8006;
@ -290,8 +292,8 @@ static void SetPerformedRentalSwap(void)
static void GenerateOpponentMons(void)
{
int i, j, k;
u16 species[3];
u16 heldItems[3];
u16 species[FRONTIER_PARTY_SIZE];
u16 heldItems[FRONTIER_PARTY_SIZE];
int firstMonId = 0;
u16 trainerId = 0;
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
@ -315,7 +317,7 @@ static void GenerateOpponentMons(void)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = trainerId;
i = 0;
while (i != 3)
while (i != FRONTIER_PARTY_SIZE)
{
u16 monSetId = GetMonSetId(lvlMode, challengeNum, FALSE);
if (gFacilityTrainerMons[monSetId].species == SPECIES_UNOWN)
@ -369,7 +371,7 @@ static void SetRentalsToOpponentParty(void)
else
gFacilityTrainerMons = gSlateportBattleTentMons;
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId = gUnknown_03006298[i];
gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ATK_IV, NULL);
@ -407,7 +409,7 @@ static void SetPlayerAndOpponentParties(void)
if (gSpecialVar_0x8005 < 2)
{
ZeroPlayerPartyMons();
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
monSetId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
ivs = gSaveBlock2Ptr->frontier.rentalMons[i].ivs;
@ -448,7 +450,7 @@ static void SetPlayerAndOpponentParties(void)
{
case 0:
case 2:
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
monSetId = gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId;
ivs = gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs;
@ -588,7 +590,7 @@ static void GetOpponentMostCommonMonType(void)
gFacilityTrainerMons = gBattleFrontierMons;
for (i = 0; i < NUMBER_OF_MON_TYPES; i++)
typesCount[i] = 0;
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
u32 species = gFacilityTrainerMons[gUnknown_03006298[i]].species;
@ -617,14 +619,14 @@ static void GetOpponentMostCommonMonType(void)
static void GetOpponentBattleStyle(void)
{
u8 i, j, count;
u8 stylePoints[8];
u8 stylePoints[FACTORY_NUM_STYLES];
count = 0;
gFacilityTrainerMons = gBattleFrontierMons;
for (i = 0; i < 8; i++)
for (i = 0; i < FACTORY_NUM_STYLES; i++)
stylePoints[i] = 0;
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
u16 monSetId = gUnknown_03006298[i];
for (j = 0; j < MAX_MON_MOVES; j++)
@ -635,7 +637,7 @@ static void GetOpponentBattleStyle(void)
}
gSpecialVar_Result = 0;
for (i = 1; i < 8; i++)
for (i = 1; i < FACTORY_NUM_STYLES; i++)
{
if (stylePoints[i] >= sRequiredMoveCounts[i - 1])
{
@ -644,8 +646,9 @@ static void GetOpponentBattleStyle(void)
}
}
// Has no singular style
if (count > 2)
gSpecialVar_Result = 8;
gSpecialVar_Result = FACTORY_NUM_STYLES;
}
static u8 GetMoveBattleStyle(u16 move)
@ -655,13 +658,13 @@ static u8 GetMoveBattleStyle(u16 move)
for (i = 0; i < ARRAY_COUNT(sMoveStyles); i++)
{
for (j = 0, moves = sMoveStyles[i]; moves[j] != 0; j++)
for (j = 0, moves = sMoveStyles[i]; moves[j] != MOVE_NONE; j++)
{
if (moves[j] == move)
return i + 1;
}
}
return 0;
return FACTORY_STYLE_NONE;
}
bool8 InBattleFactory(void)
@ -679,7 +682,7 @@ static void RestorePlayerPartyHeldItems(void)
else
gFacilityTrainerMons = gSlateportBattleTentMons;
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
SetMonData(&gPlayerParty[i],
MON_DATA_HELD_ITEM,
@ -703,8 +706,8 @@ u8 GetFactoryMonFixedIV(u8 arg0, u8 arg1)
void FillFactoryBrainParty(void)
{
int i, j, k;
u16 species[3];
u16 heldItems[3];
u16 species[FRONTIER_PARTY_SIZE];
u16 heldItems[FRONTIER_PARTY_SIZE];
u8 friendship;
int monLevel;
u8 fixedIV;
@ -718,7 +721,7 @@ void FillFactoryBrainParty(void)
i = 0;
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
while (i != 3)
while (i != FRONTIER_PARTY_SIZE)
{
u16 monSetId = GetMonSetId(lvlMode, challengeNum, FALSE);

View File

@ -42,7 +42,7 @@ EWRAM_DATA const struct BattleFrontierTrainer *gFacilityTrainers = NULL;
EWRAM_DATA const struct FacilityMon *gFacilityTrainerMons = NULL;
// IWRAM common
u16 gUnknown_03006298[4];
u16 gUnknown_03006298[MAX_FRONTIER_PARTY_SIZE];
// This file's functions.
static void InitTowerChallenge(void);
@ -2096,7 +2096,7 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
level = SetFacilityPtrsGetLevel();
otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
u16 monSetId = gUnknown_03006298[i];
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],
@ -2124,7 +2124,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId)
u8 fixedIV = 0;
u32 otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
for (i = 0; i < 3; i++)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
u16 monSetId = gUnknown_03006298[i];
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],