mirror of
https://github.com/rh-hideout/pokeemerald-expansion.git
synced 2026-03-21 18:04:50 -05:00
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-expansion into pokedex-consolidation
This commit is contained in:
commit
3c5a88f46c
203
.github/workflows/build.yml
vendored
203
.github/workflows/build.yml
vendored
|
|
@ -7,69 +7,217 @@ on:
|
|||
- upcoming
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
GAME_REVISION: 0
|
||||
GAME_LANGUAGE: ENGLISH
|
||||
COMPARE: 0
|
||||
UNUSED_ERROR: 1
|
||||
DEPRECATED_ERROR: 1
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-emerald:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GAME_REVISION: 0
|
||||
GAME_LANGUAGE: ENGLISH
|
||||
COMPARE: 0
|
||||
UNUSED_ERROR: 1
|
||||
DEPRECATED_ERROR: 1
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install binutils
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
# build-essential and git are already installed
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
|
||||
- name: Cache build tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
tools/bin2c/bin2c
|
||||
tools/gbafix/gbafix
|
||||
tools/gbagfx/gbagfx
|
||||
tools/jsonproc/jsonproc
|
||||
tools/mapjson/mapjson
|
||||
tools/mid2agb/mid2agb
|
||||
tools/preproc/preproc
|
||||
tools/ramscrgen/ramscrgen
|
||||
tools/rsfont/rsfont
|
||||
tools/scaninc/scaninc
|
||||
tools/trainerproc/trainerproc
|
||||
tools/compresSmol/compresSmol
|
||||
tools/compresSmol/compresSmolTilemap
|
||||
tools/wav2agb/wav2agb
|
||||
key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }}
|
||||
|
||||
- name: ROM (Emerald)
|
||||
env:
|
||||
COMPARE: 0
|
||||
GAME_VERSION: EMERALD
|
||||
run: make -j${nproc} -O all
|
||||
run: make -j$(nproc) -O all
|
||||
|
||||
build-firered:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install binutils
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
|
||||
- name: Cache build tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
tools/bin2c/bin2c
|
||||
tools/gbafix/gbafix
|
||||
tools/gbagfx/gbagfx
|
||||
tools/jsonproc/jsonproc
|
||||
tools/mapjson/mapjson
|
||||
tools/mid2agb/mid2agb
|
||||
tools/preproc/preproc
|
||||
tools/ramscrgen/ramscrgen
|
||||
tools/rsfont/rsfont
|
||||
tools/scaninc/scaninc
|
||||
tools/trainerproc/trainerproc
|
||||
tools/compresSmol/compresSmol
|
||||
tools/compresSmol/compresSmolTilemap
|
||||
tools/wav2agb/wav2agb
|
||||
key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }}
|
||||
|
||||
- name: ROM (Firered)
|
||||
env:
|
||||
COMPARE: 0
|
||||
run: make firered -j$(nproc) -O
|
||||
|
||||
build-leafgreen:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install binutils
|
||||
run: |
|
||||
make firered -j${nproc} -O
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
|
||||
- name: Cache build tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
tools/bin2c/bin2c
|
||||
tools/gbafix/gbafix
|
||||
tools/gbagfx/gbagfx
|
||||
tools/jsonproc/jsonproc
|
||||
tools/mapjson/mapjson
|
||||
tools/mid2agb/mid2agb
|
||||
tools/preproc/preproc
|
||||
tools/ramscrgen/ramscrgen
|
||||
tools/rsfont/rsfont
|
||||
tools/scaninc/scaninc
|
||||
tools/trainerproc/trainerproc
|
||||
tools/compresSmol/compresSmol
|
||||
tools/compresSmol/compresSmolTilemap
|
||||
tools/wav2agb/wav2agb
|
||||
key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }}
|
||||
|
||||
- name: ROM (Leafgreen)
|
||||
env:
|
||||
COMPARE: 0
|
||||
run: make leafgreen -j$(nproc) -O
|
||||
|
||||
release:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install binutils
|
||||
run: |
|
||||
make leafgreen -j${nproc} -O
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
|
||||
- name: Cache build tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
tools/bin2c/bin2c
|
||||
tools/gbafix/gbafix
|
||||
tools/gbagfx/gbagfx
|
||||
tools/jsonproc/jsonproc
|
||||
tools/mapjson/mapjson
|
||||
tools/mid2agb/mid2agb
|
||||
tools/preproc/preproc
|
||||
tools/ramscrgen/ramscrgen
|
||||
tools/rsfont/rsfont
|
||||
tools/scaninc/scaninc
|
||||
tools/trainerproc/trainerproc
|
||||
tools/compresSmol/compresSmol
|
||||
tools/compresSmol/compresSmolTilemap
|
||||
tools/wav2agb/wav2agb
|
||||
key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }}
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GAME_VERSION: EMERALD
|
||||
run: make -j$(nproc) release
|
||||
|
||||
test:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install binutils
|
||||
run: |
|
||||
make tidy
|
||||
make -j${nproc} release
|
||||
# make tidy to purge previous build
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
|
||||
|
||||
- name: Cache build tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
tools/bin2c/bin2c
|
||||
tools/gbafix/gbafix
|
||||
tools/gbagfx/gbagfx
|
||||
tools/jsonproc/jsonproc
|
||||
tools/mapjson/mapjson
|
||||
tools/mid2agb/mid2agb
|
||||
tools/preproc/preproc
|
||||
tools/ramscrgen/ramscrgen
|
||||
tools/rsfont/rsfont
|
||||
tools/scaninc/scaninc
|
||||
tools/trainerproc/trainerproc
|
||||
tools/compresSmol/compresSmol
|
||||
tools/compresSmol/compresSmolTilemap
|
||||
tools/wav2agb/wav2agb
|
||||
tools/patchelf/patchelf
|
||||
tools/mgba-rom-test-hydra/mgba-rom-test-hydra
|
||||
key: tools-check-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }}
|
||||
|
||||
- name: Test
|
||||
env:
|
||||
GAME_VERSION: EMERALD
|
||||
TEST: 1
|
||||
run: |
|
||||
make -j${nproc} check
|
||||
run: make -j$(nproc) check
|
||||
|
||||
# Gate job: satisfies the "build" branch protection rule.
|
||||
# Passes only when all parallel build/test jobs succeed.
|
||||
build:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-emerald, build-firered, build-leafgreen, release, test]
|
||||
steps:
|
||||
- name: All builds passed
|
||||
run: echo "All builds and tests passed."
|
||||
|
||||
docs_validate:
|
||||
if: github.actor != 'allcontributors[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check that SUMMARY.md includes markdown doc files
|
||||
run: |
|
||||
.github/docs_validate/inclusive_summary.py
|
||||
run: .github/docs_validate/inclusive_summary.py
|
||||
|
||||
allcontributors:
|
||||
if: github.actor == 'allcontributors[bot]'
|
||||
|
|
@ -78,4 +226,3 @@ jobs:
|
|||
steps:
|
||||
- name: Automatically pass for allcontributors
|
||||
run: echo "CI automatically passes for allcontributors" && exit 0
|
||||
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -529,7 +529,7 @@ ifneq ($(NODEP),1)
|
|||
endif
|
||||
|
||||
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
|
||||
$(PREPROC) $< charmap.txt | $(CPP) $(CPPFLAGS) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
||||
$(PREPROC) -s $< charmap.txt | $(CPP) $(CPPFLAGS) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
||||
|
||||
$(DATA_ASM_BUILDDIR)/%.d: $(DATA_ASM_SUBDIR)/%.s
|
||||
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<
|
||||
|
|
|
|||
|
|
@ -4544,7 +4544,7 @@ BattleScript_SafeguardProtected::
|
|||
pause B_WAIT_TIME_SHORT
|
||||
printstring STRINGID_PKMNUSEDSAFEGUARD
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
end2
|
||||
goto BattleScript_MoveEnd
|
||||
|
||||
BattleScript_SafeguardEnds::
|
||||
pause B_WAIT_TIME_SHORT
|
||||
|
|
|
|||
|
|
@ -1062,7 +1062,7 @@ EventScript_AfterWhiteOutHeal::
|
|||
lockall
|
||||
msgbox gText_FirstShouldRestoreMonsHealth
|
||||
call EventScript_PkmnCenterNurse_TakeAndHealPkmn
|
||||
call_if_unset FLAG_DEFEATED_RUSTBORO_GYM, EventScript_AfterWhiteOutHealMsgPreRoxanne
|
||||
call_if_unset FLAG_DEFEATED_RUSTBORO_GYM, EventScript_AfterWhiteOutHealMsgPreFirstBoss
|
||||
call_if_set FLAG_DEFEATED_RUSTBORO_GYM, EventScript_AfterWhiteOutHealMsg
|
||||
applymovement VAR_LAST_TALKED, Movement_PkmnCenterNurse_Bow
|
||||
waitmovement 0
|
||||
|
|
@ -1070,7 +1070,7 @@ EventScript_AfterWhiteOutHeal::
|
|||
releaseall
|
||||
end
|
||||
|
||||
EventScript_AfterWhiteOutHealMsgPreRoxanne::
|
||||
EventScript_AfterWhiteOutHealMsgPreFirstBoss::
|
||||
msgbox gText_MonsHealedShouldBuyPotions
|
||||
return
|
||||
|
||||
|
|
@ -1080,6 +1080,7 @@ EventScript_AfterWhiteOutHealMsg::
|
|||
|
||||
EventScript_AfterWhiteOutMomHeal::
|
||||
lockall
|
||||
textcolor NPC_TEXT_COLOR_FEMALE
|
||||
applymovement LOCALID_PLAYERS_HOUSE_1F_MOM, Common_Movement_WalkInPlaceFasterDown
|
||||
waitmovement 0
|
||||
msgbox gText_HadQuiteAnExperienceTakeRest
|
||||
|
|
@ -1432,7 +1433,7 @@ gText_HadQuiteAnExperienceTakeRest::
|
|||
gText_MomExplainHPGetPotions::
|
||||
.string "MOM: Oh, good! You and your\n"
|
||||
.string "POKéMON are looking great.\p"
|
||||
.string "I just heard from PROF. BIRCH.\p"
|
||||
.string "I just heard from {STR_VAR_1}.\p"
|
||||
.string "He said that POKéMON's energy is\n"
|
||||
.string "measured in HP.\p"
|
||||
.string "If your POKéMON lose their HP,\n"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"connections": null,
|
||||
"object_events": [
|
||||
{
|
||||
"local_id": "LOCALID_MOM",
|
||||
"local_id": "LOCALID_PLAYERS_HOUSE_1F_MOM",
|
||||
"type": "object",
|
||||
"graphics_id": "OBJ_EVENT_GFX_MOM_FRLG",
|
||||
"x": 8,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ PalletTown_PlayersHouse_1F_EventScript_Mom::
|
|||
call_if_eq VAR_RESULT, MALE, PalletTown_PlayersHouse_1F_EventScript_MomOakLookingForYouMale
|
||||
call_if_eq VAR_RESULT, FEMALE, PalletTown_PlayersHouse_1F_EventScript_MomOakLookingForYouFemale
|
||||
closemessage
|
||||
applymovement LOCALID_MOM, Common_Movement_FaceOriginalDirection
|
||||
applymovement LOCALID_PLAYERS_HOUSE_1F_MOM, Common_Movement_FaceOriginalDirection
|
||||
waitmovement 0
|
||||
release
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,16 @@
|
|||
EventScript_AfterWhiteOutHeal_Frlg::
|
||||
lockall
|
||||
textcolor NPC_TEXT_COLOR_FEMALE
|
||||
msgbox gText_FirstShouldRestoreMonsHealth
|
||||
call EventScript_PkmnCenterNurse_TakeAndHealPkmn_Frlg
|
||||
call_if_unset FLAG_DEFEATED_BROCK, EventScript_AfterWhiteOutHealMsgPreFirstBoss
|
||||
call_if_set FLAG_DEFEATED_BROCK, EventScript_AfterWhiteOutHealMsg
|
||||
applymovement VAR_LAST_TALKED, Movement_Bow
|
||||
waitmovement 0
|
||||
fadedefaultbgm
|
||||
releaseall
|
||||
end
|
||||
|
||||
EventScript_PkmnCenterNurse_Frlg::
|
||||
message Text_WelcomeWantToHealPkmn_Frlg
|
||||
waitmessage
|
||||
|
|
|
|||
|
|
@ -1,138 +1,253 @@
|
|||
# Generation of struct Pokemon instances
|
||||
|
||||
This document describes the ways you generate an instance of struct Pokemon through script or through code.
|
||||
These Pokemon can be given to your players, be used as enemy trainer pokemon or as static wild pokemon.
|
||||
This document describes the ways you generate an instance of `struct Pokemon` through script or through code.
|
||||
These Pokemon can be given to your players, be used as enemy trainer Pokemon or as static wild Pokemon.
|
||||
|
||||
## Through script (`givemon` and `createmon`)
|
||||
|
||||
### `createmon`
|
||||
|
||||
`createmon` is a script command that allows you to generate a pokemon with any of the properties you might want.
|
||||
It has a lot of arguments in order to offer this flexibility.
|
||||
`side`, `slot`, `species` and `level` are the required arguments
|
||||
`side` determines if the pokemon will be created as a player pokemon or an enemy pokemon: 0 will put the pokemon in the player party and 1 in the enemy party
|
||||
`slot` determines the slot in the player or enemy party the pokemon will occupy. `slot` goes from 0 to 5 but if `side` is 0 (player pokemon), setting the slot to 6 will instead give the pokemon to player automatically putting it in the first empty slot or sending it to the PC when the party is the full. (Setting `slot` to 6 when trying to create an enemy pokemon will result in the `createmon` command being ignored)
|
||||
`species` and `level` refers to the species id and the level of the pokemon you want to generate
|
||||
`item`, `ball`, `nature`, `abilityNum`, `gender`, `hpEv`, `atkEv`, `defEv`, `speedEv`, `spAtkEv`, `spDefEv`, `hpIv`, `atkIv`, `defIv`, `speedIv`, `spAtkIv`, `spDefIv`, `move1`, `move2`, `move3`, `move4`, `shinyMode`, `gmaxFactor`, `teraType`, `dmaxLevel` are the optional arguments. They are pretty explicit in what they refer to but let's describe what they default to when they are not present.
|
||||
`item` refers to the item the mon is holding. If the argument is missing, the mon won't be holding anything
|
||||
`ball` refers to the type of ball the pokemon comes out of. This defaults to a PokeBall and if you are generating a wildmon, this will be overwritten if the pokemon is captured
|
||||
`nature`, and `gender` will default to random values
|
||||
`abilityNum` will default to the value corresponding to the personality they will roll (in practice, it's random but it will have correlations with other if the pokemon parameters)
|
||||
`hpEv`, `atkEv`, `defEv`, `speedEv`, `spAtkEv`, `spDefEv` will default to 0
|
||||
`hpIv`, `atkIv`, `defIv`, `speedIv`, `spAtkIv`, `spDefIv` will default to `USE_RANDOM_IVS` which tell the game to roll a random IV value (between 0 and 31). If the generated species has a `perfectIVCount`, only the random values will be eligible to be perfected.
|
||||
`move1`, `move2`, `move3`, `move4` will default to `MOVE_DEFAULT` which tells the game to fill the slot with the last level up move available
|
||||
`shinyMode` will default to SHINY_MODE_RANDOM doing random roll(s) to check if the mon is shiny. (The other possibile values for shinyMode are SHINY_MODE_ALWAYS and SHINY_MODE_NEVER to force the pokemon to be shiny or not be shiny respectively)
|
||||
`gmaxFactor` default to FALSE
|
||||
`teraType` will default to the value corresponding to the personality they will roll (in practice, it's random but it will have correlations with other if the pokemon parameters)
|
||||
`dmaxLevel` will deafult to 0
|
||||
`createmon` is a script command that allows you to generate a Pokemon with any of the properties you might want. It has a lot of arguments in order to offer this flexibility.
|
||||
|
||||
#### Required Arguments
|
||||
|
||||
> **side, slot, species, level** are the required arguments.
|
||||
|
||||
- **side** determines if the Pokemon will be created as a player Pokemon or an enemy Pokemon:
|
||||
- `0` will put the Pokemon in the player party
|
||||
- `1` in the enemy party
|
||||
|
||||
- **slot** determines the slot in the player or enemy party the Pokemon will occupy.
|
||||
- `slot` goes from `0` to `5`
|
||||
- If `side` is `0` (player Pokemon), setting the slot to `6` will instead give the Pokemon to player automatically putting it in the first empty slot or sending it to the PC when the party is the full.
|
||||
- Setting `slot` to `6` when trying to create an enemy Pokemon will result in the `createmon` command being ignored.
|
||||
|
||||
- **species** and **level** refer to the species id and the level of the Pokemon you want to generate.
|
||||
|
||||
#### Optional Arguments
|
||||
|
||||
> `item`, `ball`, `nature`, `abilityNum`, `gender`, `hpEv`, `atkEv`, `defEv`, `speedEv`, `spAtkEv`, `spDefEv`, `hpIv`, `atkIv`, `defIv`, `speedIv`, `spAtkIv`, `spDefIv`, `move1`, `move2`, `move3`, `move4`, `shinyMode`, `gmaxFactor`, `teraType`, `dmaxLevel`.
|
||||
|
||||
The purpose of these arguments is largely self-explanatory but we will briefly discuss what they default to when nothing is explicitly specified.
|
||||
|
||||
- **item** refers to the item the Pokemon is holding. If the argument is missing, the Pokemon won’t be holding anything.
|
||||
|
||||
- **ball** refers to the type of ball the Pokemon comes out of. The expected type is `enum Pokeball` defaults to a `BALL_POKE`. If the Pokemon being generated is a Wild Pokemon this will be overwritten if the Pokemon is captured.
|
||||
|
||||
- **nature** and **gender** will default to random values.
|
||||
|
||||
- **abilityNum** will default to the value corresponding to the personality rolled (This is essentially random but it will be have correlations to the other parameters of the Pokemon).
|
||||
|
||||
- **EVs**
|
||||
`hpEv, atkEv, defEv, speedEv, spAtkEv, spDefEv` will default to `0`.
|
||||
|
||||
- **IVs**
|
||||
`hpIv, atkIv, defIv, speedIv, spAtkIv, spDefIv` will default to `USE_RANDOM_IVS` which tell the game to roll a random IV value (between `0` and `31`). If the generated species has a `perfectIVCount`, only the random values will be eligible to be perfected.
|
||||
|
||||
- **moves**
|
||||
`move1, move2, move3, move4` will default to `MOVE_DEFAULT` which tells the game to fill the slot with the last level up move available.
|
||||
|
||||
- **shinyMode** will default to `SHINY_MODE_RANDOM` doing random roll(s) to check if the Pokemon is shiny.
|
||||
- `SHINY_MODE_ALWAYS` forces the Pokemon to be shiny
|
||||
- `SHINY_MODE_NEVER` forces the Pokemon to not be shiny
|
||||
|
||||
- **gmaxFactor** defaults to `FALSE`.
|
||||
|
||||
- **teraType** will default to the value corresponding to the personality they will roll (in practice, it’s random but it will have correlations with other if the Pokemon parameters).
|
||||
|
||||
- **dmaxLevel** will default to `0`.
|
||||
|
||||
---
|
||||
|
||||
### `givemon`
|
||||
|
||||
`givemon` uses the same arguments as `createmon` minus `side` and `slot`. This is because `givemon` is almost equivalent to `createmon 0 6 ...` and just gives the mon to the player after generating it. The exception being that `givemon` interacts with the abilities `Synchronize` and `Cute Charm` slightly differently than `createmon` when `nature` or `gender` are not explicitly set.
|
||||
`givemon` uses the same arguments as `createmon` minus `side` and `slot`.
|
||||
|
||||
### `setwildbattle (species:req, level:req, item=ITEM_NONE, species2=SPECIES_NONE, level2=0, item2=ITEM_NONE)`
|
||||
This is because `givemon` is almost equivalent to `createmon 0 6 ...` and just gives the Pokemon to the player after generating it.
|
||||
|
||||
The exception being that `givemon` interacts with the abilities `Synchronize` and `Cute Charm` somewhat differently than `createmon` when `nature` or `gender` are not explicitly set.
|
||||
|
||||
---
|
||||
|
||||
### `setwildbattle`
|
||||
|
||||
##### Arguments
|
||||
|
||||
> `species:req`, `level:req`, `item=ITEM_NONE`, `species2=SPECIES_NONE`, `level2=0`, `item2=ITEM_NONE`
|
||||
|
||||
`setwildbattle` is a much simpler way to generate a Wild Pokemon ready for the player to fight.
|
||||
|
||||
`setwildbattle` is a much simpler way to generate a wildmon ready for the player to fight.
|
||||
It only takes 3 arguments (or 6 if you want to make it a double wild battle)
|
||||
`species` and `level` refers to the species id and the level of the pokemon you want to generate
|
||||
`item` refers to the item the mon is holding. If the argument is missing, the mon won't be holding anything
|
||||
`species2`, `level2`, and `item2` are relate to the species, level and item of the second mon generated in case you want to make a double wild battle
|
||||
The other properties will like IVs and personality will be set random just like for a regular wild battle
|
||||
Mons generated with `setwildbattle` will always be considered static encounters (STATIC_WILDMON_ORIGIN) and will thus be eligible to be affected by Synchronize and Cute Charm
|
||||
|
||||
### Synchronize and Cute Charm
|
||||
- `species` and `level` refer to the `species` and the `level` of the Pokemon you want to generate.
|
||||
- `item` refers to the item the Pokemon is holding. If no argument is provided the Pokemon will not be holding an item.
|
||||
- `species2`, `level2`, and `item2` determine the `species`, `level` and `held item` respectively of the second Pokemon generated in case you want to make a double wild battle
|
||||
- The other properties like IVs and personality will be set randomly the same way as they are set in regular wild battles.
|
||||
|
||||
`nature` and `gender` also accept `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` respectively as arguments
|
||||
`NATURE_RANDOM` and `MON_GENDER_RANDOM` always return a random nature/gender and never check for Synchronize or Cute Charm. If you want the generated mon to have a chance to receive the effcets of Synchronize or Cute Charm, you need to use `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` respectively for nature and gender.
|
||||
When you use `NATURE_MAY_SYNCHRONIZE` or `MON_GENDER_MAY_CUTE_CHARM`, you are telling the game can check if the player has a pokemon with Synchronize or Cute Charm in the first slot of its party and roll a die to see if the nature or gender should be fixed based on the ability or rolled normally.
|
||||
The mon generated also need to be of the right "origin" to be eligible for Synchronize or Cute Charm. We don't want to "synchronize" a mon belonging to a trainer or change the gender of a gift mon with Cute Charm. So if a mon is generated for the player side, it will be considered a "gift mon" (GIFTMON_ORIGIN) and if a mon is generated on the enemy side, it will be considered a static wild encounter (STATIC_WILDMON_ORIGIN).
|
||||
`givemon` will default to use `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` because we assume you will use givemon to create "gift mons" but if you don't want it to apply in a specific script, you can explicitly use `NATURE_RANDOM` and `MON_GENDER_RANDOM` instead
|
||||
`createmon` on the other hand default to `NATURE_RANDOM` and `MON_GENDER_RANDOM` so you need to explicitly use `NATURE_MAY_SYNCHRONIZE` or `MON_GENDER_MAY_CUTE_CHARM` for the generated mon to be considered a gift mon or a static wild encounter
|
||||
Static encounters and Gift mons eligibility to Synchronize vary through generations in the official games so you can use the config `OW_SYNCHRONIZE_NATURE` to match your preference or you can check the `src/ow_synchronize.c` to modify the Synchronize and Cute Charm eligibility of different origins however you like
|
||||
Pokemon generated with `setwildbattle` will always be considered static encounters (`STATIC_WILDMON_ORIGIN`) and will thus be eligible to be affected by Synchronize and Cute Charm
|
||||
|
||||
#### Synchronize and Cute Charm
|
||||
|
||||
`nature` and `gender` also accept `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` respectively as arguments.
|
||||
|
||||
`NATURE_RANDOM` and `MON_GENDER_RANDOM` always return a random nature/gender and never check for Synchronize or Cute Charm. If you want the generated Pokemon to have a chance to receive the effects of Synchronize or Cute Charm, you need to use `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` respectively for nature and gender.
|
||||
|
||||
When you use `NATURE_MAY_SYNCHRONIZE` or `MON_GENDER_MAY_CUTE_CHARM`, you are telling the game can check if the player has a Pokemon with Synchronize or Cute Charm in the first slot of its party and roll a die to see if the nature or gender should be fixed based on the ability or rolled normally.
|
||||
|
||||
The Pokemon generated also need to be of the right "origin" to be eligible for Synchronize or Cute Charm. We don't want to "synchronize" a Pokemon belonging to a trainer or change the gender of a gift Pokemon with Cute Charm. So if a Pokemon is generated for the player side, it will be considered a "gift Pokemon" (`GIFTMON_ORIGIN`) and if a Pokemon is generated on the enemy side, it will be considered a static wild encounter (`STATIC_WILDMON_ORIGIN`).
|
||||
|
||||
`givemon` will default to use `NATURE_MAY_SYNCHRONIZE` and `MON_GENDER_MAY_CUTE_CHARM` because we assume you will use `givemon` to create "gift Pokemon" but if you don't want it to apply in a specific script, you can explicitly use `NATURE_RANDOM` and `MON_GENDER_RANDOM` instead
|
||||
|
||||
`createmon` on the other hand default to `NATURE_RANDOM` and `MON_GENDER_RANDOM` so you need to explicitly use `NATURE_MAY_SYNCHRONIZE` or `MON_GENDER_MAY_CUTE_CHARM` for the generated Pokemon to be considered a gift Pokemon or a static wild encounter
|
||||
|
||||
Static encounters and Gift Pokemon eligibility to Synchronize vary through generations in the official games so you can use the config `OW_SYNCHRONIZE_NATURE` to match your preference or you can check the `src/ow_abilities.c` to modify the Synchronize and Cute Charm eligibility of different origins however you like
|
||||
|
||||
---
|
||||
|
||||
## Through Code
|
||||
|
||||
A lot of places in the game generate mons, when you start a wild encounter, when a trainer generates its party from the data in trainers.party or even when you call one of the script described in the previous section. So let's go through some of the most common functions.
|
||||
Note: None of the functions described here allocate memory for the Pokemon struct, they all expect a pointer they will fill the data with.
|
||||
There are several instances of Pokemon generation throughout the game:
|
||||
- When you start a wild encounter,
|
||||
- When a trainer generates its party from the data in `trainers.party`,
|
||||
- Or when you call one of the scripts described in the previous section.
|
||||
|
||||
In this section we will go through some of the most common functions.
|
||||
|
||||
> NOTE: None of the functions described here allocate memory for the Pokemon struct, they all expect a pointer they will fill the data with.
|
||||
|
||||
It means they are usually called with `&gPlayerParty[index]` or `&gEnemyParty[index]` because these are places in memory reserved for Pokemon struct.
|
||||
|
||||
### The basics
|
||||
### The Basics
|
||||
|
||||
To generate a mon ready for battle, you usually need to go through these steps:
|
||||
- generate a personality value
|
||||
- fill the generic mon structure based on species, level and personality
|
||||
- set IVs and EVs
|
||||
- (re-)compute stats (this step does not happen if you are generating a `struct boxPokemon` instead of `struct Pokemon`)
|
||||
- set the moves
|
||||
To generate a Pokemon ready for battle, you usually need to go through the following steps:
|
||||
|
||||
1. Generate a personality value
|
||||
2. Fill the generic mon structure based on `species`, `level` and `personality`.
|
||||
3. Set IVs and EVs.
|
||||
4. (Re-)Compute stats (this step does not happen if you are generating a `struct BoxPokemon` instead of `struct Pokemon`).
|
||||
5. set the moves.
|
||||
|
||||
### `GetMonPersonality`
|
||||
|
||||
`GetMonPersonality` is the easiest way to make a personality value. It takes 4 arguments `species`, `gender`, `nature` and `unownLetter` then it rolls random personality values until it finds one that match all the selected criteria.
|
||||
|
||||
For example, if you want a personality for Wally's male Ralts, you would write:
|
||||
`personality = GetMonPersonality(SPECIES_RALTS, MON_MALE, NATURE_RANDOM, RANDOM_UNOWN_LETTER);`
|
||||
and if you want a personality for a brave J Unown, you would write
|
||||
`personality = GetMonPersonality(SPECIES_UNOWN, MON_GENDER_RANDOM, NATURE_BRAVE, 9);` (J is the 10th letter of alphabet but for unown A starts at 0 so B is 1 and J is 9)
|
||||
As you can see, you can use either a specific value or a special value `MON_GENDER_RANDOM`, `NATURE_RANDOM` or `RANDOM_UNOWN_LETTER` to tell the function to return any pokemon matching the other properties. This means, writing:
|
||||
`personality = GetMonPersonality(SPECIES_X, MON_GENDER_RANDOM, NATURE_RANDOM, RANDOM_UNOWN_LETTER);`
|
||||
id equivalent to
|
||||
`personality = Random32();`
|
||||
which is why `Random32()` is used throughout to generate a personality value in certain circumstances
|
||||
|
||||
```c
|
||||
personality = GetMonPersonality(SPECIES_RALTS, MON_MALE, NATURE_RANDOM, RANDOM_UNOWN_LETTER);
|
||||
```
|
||||
|
||||
And if you want a personality for a brave J Unown, you would write:
|
||||
|
||||
```c
|
||||
personality = GetMonPersonality(SPECIES_UNOWN, MON_GENDER_RANDOM, NATURE_BRAVE, 9);
|
||||
// J is the 10th letter of alphabet but for Unown A starts at 0 so B is 1 and J is 9
|
||||
```
|
||||
|
||||
As you can see, you can use either a specific value or a special value `MON_GENDER_RANDOM`, `NATURE_RANDOM` or `RANDOM_UNOWN_LETTER` to tell the function to return any Pokemon matching the other properties. This means, writing:
|
||||
|
||||
```
|
||||
personality = GetMonPersonality(SPECIES_X, MON_GENDER_RANDOM, NATURE_RANDOM, RANDOM_UNOWN_LETTER);
|
||||
```
|
||||
|
||||
is equivalent to `personality = Random32();` which is why `Random32()` is used throughout the codebase to generate fully random personality values.
|
||||
|
||||
---
|
||||
|
||||
### `CreateMon` and `CreateBoxMon`
|
||||
|
||||
`CreateMon` is the most basic function to create a generic Pokemon struct. It takes 5 arguments:
|
||||
`mon` is a pointer to the mon struct you want to set the data for
|
||||
`species` and `level` are fairly explicit
|
||||
`personality` is the personality value you want to use to create your mon, it will determine a lot of your mon properties and will usually be a number that you generated by following the instructions from the previous section
|
||||
`trainerID` is a special type of struct that explain how the function should set up the otId of the pokemon. Usually you will want to use one of these 3 macros for the argument:
|
||||
`OTID_STRUCT_PLAYER_ID` which means the pokemon should the player otId (used for wildmon so they the get the player id when captured)
|
||||
`OTID_STRUCT_PRESET(value)` which set a specific otId that you pick/write yourself
|
||||
`OTID_STRUCT_RANDOM_NO_SHINY` which picks a random otId and forces the mon to not be shiny even if the random otId and chosen personality would have made the mon shiny. It is used by NPC trainers.
|
||||
Both `CreateMon` and `CreateBoxMon` erase the pokemon data in the pointer before they add the new data so every value they don't set will be zero-ed in some way. This is why they are considered "base" functions.
|
||||
The values set by `CreateMon` and `CreateBoxMon` are the gender, ability num, tera type and nature (based on personality); the met info (location, level and game), the original trainer name, gender and language (always set to the player even for enemy trainer mons), the starting xp (based on the xp required to reach the level the pokemon is at), the starting friendship (based on the species info) and the shinyness.
|
||||
`CreateMon` and `CreateBoxMon` are very similar. In fact, the `CreateMon` function calls `CreateBoxMon` to generate the boxmon part of its structure but it also sets the level and a mail object (to an empty value)
|
||||
|
||||
- `mon` is a pointer to the Pokemon struct you want to set the data for
|
||||
|
||||
- `species` and `level` are self-explanatory.
|
||||
|
||||
- `personality` is the personality value you want to use to create your Pokemon, it will determine a lot of your Pokemon properties and will usually be a number that you generated by following the instructions from the previous section.
|
||||
|
||||
- `trainerID` is a special type of struct that explain how the function should set up the `otId` of the Pokemon. Usually you will want to use one of these 3 macros for the argument:
|
||||
|
||||
- `OTID_STRUCT_PLAYER_ID` which means the Pokemon will use the player `otId` (used by Wild Pokemon so they the get the player id when captured)
|
||||
|
||||
- `OTID_STRUCT_PRESET(value)` which set a specific `otId` that you pick/write yourself
|
||||
|
||||
- `OTID_STRUCT_RANDOM_NO_SHINY` which picks a random `otId` and forces the Pokemon to not be shiny even if the random `otId` and chosen `personality` would have made the Pokemon shiny. It is used by NPC trainers.
|
||||
|
||||
- Both `CreateMon` and `CreateBoxMon` erase the Pokemon data in the pointer before they add the new data so every value they don't set will be zero-ed in some way. This is why they are considered "base" functions.
|
||||
|
||||
The values set by `CreateMon` and `CreateBoxMon` are the `gender`, `ability num`, `tera type` and `nature` (based on personality); the `met info` (location, level and game), the `OT name` , `gender` and `language` (always set to the player even for enemy trainer Pokemon), the `starting xp` (based on the xp required to reach the level the Pokemon is at), the `starting friendship` (based on the species info) and the `shinyness`.
|
||||
|
||||
`CreateMon` and `CreateBoxMon` are very similar. In fact, the `CreateMon` function calls `CreateBoxMon` to generate the BoxPokemon part of its structure but it also sets the level and a mail object (to an empty value)
|
||||
|
||||
### Setting IVs and EVs
|
||||
|
||||
Usually, you will want to use `SetBoxMonIVs(mon->box, ivs)` to set the ivs of the pokemon you are generating. The reason is that not only can you quickly set all ivs of your mon to a single value: `SetBoxMonIVs(mon->box, 15)` will set all IVs to 15. You can also use the special argument `USE_RANDOM_IVS`. When used with `USE_RANDOM_IVS`, `SetBoxMonIvs` will not only pick a random value between 0 and 31 for each stat, it will also allocate some perfect iv if the species of the mon has a perfectIvCount set in the species data. For example if you are generating a legendary with a perfectIvCount of 3, using `SetBoxMonIVs(mon->box, USE_RANDOM_IVS)` will guarantee that at least 3 IVs are set to 31. This is done using the function `SetBoxMonPerfectIVs`, which can also be used elsewhere to assign a number of random perfect IVs.
|
||||
#### IVs
|
||||
|
||||
Usually, you will want to use `SetBoxMonIVs(mon->box, ivs)` to set the IVs of the Pokemon being generated. The reason is that not only can you quickly set all ivs of your Pokemon to a single value.
|
||||
|
||||
For instance `SetBoxMonIVs(mon->box, 15)` will set all IVs to 15.
|
||||
|
||||
You can also use the special argument `USE_RANDOM_IVS`. When used with `USE_RANDOM_IVS`, `SetBoxMonIvs` will not only pick a random value between 0 and 31 for each stat, it will also allocate some perfect iv if the species of the Pokemon has a `perfectIvCount` set in the species data.
|
||||
|
||||
For example if you are generating a legendary with a `perfectIvCount` of 3, using `SetBoxMonIVs(mon->box, USE_RANDOM_IVS)` will guarantee that at least 3 IVs are set to 31. This is done using the function `SetBoxMonPerfectIVs`, which can also be used elsewhere to assign a number of random perfect IVs.
|
||||
|
||||
The other way to assign IV is to use `SetMonData`, for example:
|
||||
`SetMonData(mon, MON_DATA_HP_IV, 15)`
|
||||
with the stats being in order `MON_DATA_HP_IV`, `MON_DATA_ATK_IV`, `MON_DATA_DEF_IV`, `MON_DATA_SPEED_IV`, `MON_DATA_SPATK_IV` and `MON_DATA_SPDEF_IV`
|
||||
|
||||
```c
|
||||
SetMonData(mon, MON_DATA_HP_IV, 15)
|
||||
```
|
||||
|
||||
with the stats being in the order `MON_DATA_HP_IV`, `MON_DATA_ATK_IV`, `MON_DATA_DEF_IV`, `MON_DATA_SPEED_IV`, `MON_DATA_SPATK_IV` and `MON_DATA_SPDEF_IV`
|
||||
|
||||
You can also use a loop like this:
|
||||
|
||||
```c
|
||||
for (i = 0; i < NUM_STATS; i++)
|
||||
SetMonData(mon, MON_DATA_HP_IV + i, iv_array[i])
|
||||
```
|
||||
if you happen to have an array containing the values you want but be careful about the order if you use this method
|
||||
EVs default to 0 when a mon is generated with `CreateMon` or `CreateBoxMon` so you may not need to anything if you want to keep it that way. If you want to change them, there are currently no utilities to set EVs at the moment so you will need to use the `SetMonData` method as well:
|
||||
`SetMonData(mon, MON_DATA_HP_EV, 252)`
|
||||
The stats have the same names as the IVs with I cheange into an E : `MON_DATA_HP_EV`, `MON_DATA_ATK_EV`, `MON_DATA_DEF_EV`, `MON_DATA_SPEED_EV`, `MON_DATA_SPATK_EV` and `MON_DATA_SPDEF_EV` so the loop method works here too
|
||||
|
||||
if you happen to have an array containing the values you want. However, you must be careful about the order of the stats if you use this method.
|
||||
#### EVs
|
||||
|
||||
EVs default to `0` when a Pokemon is generated with `CreateMon` or `CreateBoxMon`. You will not need to anything if you want to keep it that way.
|
||||
|
||||
If you want to change them, there are currently no utilities to set EVs. Thus you will need to use the `SetMonData` method:
|
||||
|
||||
```c
|
||||
SetMonData(mon, MON_DATA_HP_EV, 252)
|
||||
```
|
||||
|
||||
The stats have the same names as the IVs with I change into an E : `MON_DATA_HP_EV`, `MON_DATA_ATK_EV`, `MON_DATA_DEF_EV`, `MON_DATA_SPEED_EV`, `MON_DATA_SPATK_EV` and `MON_DATA_SPDEF_EV` so the loop method works here as well.
|
||||
|
||||
```c
|
||||
for (i = 0; i < NUM_STATS; i++)
|
||||
SetMonData(mon, MON_DATA_HP_EV + i, ev_array[i])
|
||||
```
|
||||
Just be careful when setting IVs and EVs with SetMonData because they are no check to make sure the IV and EV values you are setting are valid and this may cause some issues.
|
||||
|
||||
Just be careful when setting IVs and EVs with `SetMonData` because there is no check to make sure the IV and EV values you are setting are valid and this may cause some issues.
|
||||
|
||||
### `CalculateMonStats`
|
||||
|
||||
After all the IVs and EVs have been set for your mon, it's important to run `CalculateMonStats(mon)`. The function only has one argument so it's pretty simple but don't forget this step or you may have some isseus
|
||||
After all the IVs and EVs have been set for your Pokemon, it's important to run `CalculateMonStats(mon)`. The function only has one argument so it's pretty simple but don't forget this step or you may have some issues.
|
||||
|
||||
### Setting moves
|
||||
|
||||
To set a move in slot `slot`, you would need to write:
|
||||
|
||||
```c
|
||||
enum Move move = MOVE_X;
|
||||
u32 pp = GetMovePP(move);
|
||||
SetMonData(mon, MON_DATA_MOVE1 + slot, &move);
|
||||
SetMonData(mon, MON_DATA_PP1 + slot, &spp);
|
||||
```
|
||||
|
||||
where slot can be between 0 and 3 to represent the 1st to 4th move
|
||||
You can also call the function `GiveMonInitialMoveset(mon)` that will give your pokemon its last 4 level-up moves available similarly to the wild pokemon you might enciunter
|
||||
You can also call the function `GiveMonInitialMoveset(mon)` that will give your Pokemon its last 4 level-up moves available similarly to the wild Pokemon you might encounter.
|
||||
|
||||
## Going from 1.14 to 1.15
|
||||
|
||||
When going from 1.14 to 1.15, Expansion deleted multiple functions related to mon generation that were not used in Expansion anymore.
|
||||
When going from 1.14 to 1.15, Expansion deleted multiple functions related to Pokemon generation that were not used in Expansion anymore.
|
||||
The following functions were deleted
|
||||
|
||||
```c
|
||||
void CreateMonWithNature(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 nature);
|
||||
void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 gender, u8 nature, u8 unownLetter);
|
||||
|
|
@ -140,14 +255,18 @@ void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u
|
|||
void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread);
|
||||
void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId);
|
||||
```
|
||||
|
||||
If you add custom code relying on those functions, I would advise to simple recode them using the methods described in the previous section. If you follow the steps, you should be able to rewrite a function with the same effect easily.
|
||||
|
||||
However the move to 1.15 also completely rewrote these two functions:
|
||||
|
||||
```c
|
||||
void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
|
||||
void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
|
||||
```
|
||||
|
||||
`CreateMon` and `CreateBoxMon` now have different arguments and do less things than their 1.14 counterparts. If you have code that used those functions, we recommend you use these legacy version of `CreateMon` and `CreateBoxMon`:
|
||||
|
||||
```c
|
||||
void CreateMonLegacy(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId)
|
||||
{
|
||||
|
|
@ -166,4 +285,5 @@ void CreateBoxMonLegacy(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fix
|
|||
GiveBoxMonInitialMoveset(boxMon);
|
||||
}
|
||||
```
|
||||
|
||||
These two legacy functions use the 1.15 functions to recreate the 1.14 versions of `CreateMon` and `CreateBoxMon` with the same arguments and the same effects. Add these two legacy functions to your code then change your custom code that was relying on 1.14 `CreateMon` or `CreateBoxMon` to use `CreateMonLegacy` or `CreateBoxMonLegacy` instead and everything should work the same as before
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@ JASC-PAL
|
|||
0100
|
||||
16
|
||||
180 180 180
|
||||
164 226 197
|
||||
238 242 230
|
||||
139 170 180
|
||||
8 113 115
|
||||
0 157 156
|
||||
106 222 172
|
||||
41 182 189
|
||||
90 206 172
|
||||
90 182 180
|
||||
8 0 0
|
||||
65 190 189
|
||||
115 194 189
|
||||
0 117 131
|
||||
0 129 131
|
||||
0 12 0
|
||||
64 128 115
|
||||
92 163 114
|
||||
101 169 99
|
||||
69 171 140
|
||||
115 191 132
|
||||
72 141 162
|
||||
83 204 163
|
||||
72 176 192
|
||||
49 49 49
|
||||
149 210 138
|
||||
137 225 177
|
||||
190 237 195
|
||||
143 224 228
|
||||
255 255 255
|
||||
0 0 0
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 304 B After Width: | Height: | Size: 266 B |
|
|
@ -235,7 +235,8 @@ struct AiLogicData
|
|||
u32 shouldConsiderExplosion:1; // Determines whether AI should consider explosion moves this turn
|
||||
u32 shouldSwitch:4; // Stores result of ShouldSwitch, which decides whether a mon should be switched out
|
||||
u32 shouldConsiderFinalGambit:1; // Determines whether AI should consider Final Gambit this turn
|
||||
u32 padding2:19;
|
||||
u32 switchInCalc:1; // Indicates if we're doing switch in calcs, this is purely for Retaliate damage calcs
|
||||
u32 padding2:18;
|
||||
};
|
||||
|
||||
struct AiThinkingStruct
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData);
|
|||
void ResetDynamicAiFunctions(void);
|
||||
void AI_TrySwitchOrUseItem(enum BattlerId battler);
|
||||
void CalcBattlerAiMovesData(struct AiLogicData *aiData, enum BattlerId battlerAtk, enum BattlerId battlerDef, u32 weather, u32 fieldStatus);
|
||||
void AIDebugTimerStart(void);
|
||||
void AIDebugTimerEnd(void);
|
||||
|
||||
extern AiSwitchFunc gDynamicAiSwitchFunc;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ enum ShouldSwitchScenario
|
|||
SHOULD_SWITCH_NATURAL_CURE_WEAK_STATS_RAISED,
|
||||
SHOULD_SWITCH_REGENERATOR,
|
||||
SHOULD_SWITCH_REGENERATOR_STATS_RAISED,
|
||||
SHOULD_SWITCH_INTIMIDATE,
|
||||
SHOULD_SWITCH_INTIMIDATE_STATS_RAISED,
|
||||
SHOULD_SWITCH_ENCORE_STATUS,
|
||||
SHOULD_SWITCH_ENCORE_DAMAGE,
|
||||
SHOULD_SWITCH_CHOICE_LOCKED,
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ bool32 AI_IsBattlerAsleepOrComatose(enum BattlerId battlerId);
|
|||
// ability logic
|
||||
bool32 IsMoxieTypeAbility(enum Ability ability);
|
||||
bool32 DoesAbilityRaiseStatsWhenLowered(enum Ability ability);
|
||||
bool32 DoesIntimidateRaiseStats(enum Ability ability);
|
||||
bool32 ShouldTriggerAbility(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Ability ability);
|
||||
bool32 CanEffectChangeAbility(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Move move, struct AiLogicData *aiData);
|
||||
void AbilityChangeScore(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Move move, s32 *score, struct AiLogicData *aiData);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@ enum SubCheck
|
|||
};
|
||||
|
||||
void HandleAction_ThrowBall(void);
|
||||
uq4_12_t CalcTypeEffectivenessMultiplierHelper(enum Move move, enum Type moveType, enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Ability abilityAtk, enum Ability abilityDef, bool32 recordAbilities);
|
||||
u32 GetCurrentBattleWeather(void);
|
||||
bool32 EndOrContinueWeather(void);
|
||||
enum DamageCategory GetReflectDamageMoveDamageCategory(enum BattlerId battler, enum Move move);
|
||||
|
|
@ -214,7 +213,6 @@ void TryClearRageAndFuryCutter(void);
|
|||
bool32 HasNoMonsToSwitch(enum BattlerId battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2);
|
||||
bool32 TryChangeBattleWeather(enum BattlerId battler, u32 battleWeatherId, enum Ability ability);
|
||||
bool32 TryChangeBattleTerrain(enum BattlerId battler, u32 statusFlag);
|
||||
bool32 CanAbilityBlockMove(enum BattlerId battlerAtk, enum BattlerId battlerDef, enum Ability abilityAtk, enum Ability abilityDef, u32 move, enum ResultOption option);
|
||||
bool32 CanTargetBlockPranksterMove(struct BattleContext *ctx, s32 movePriority);
|
||||
bool32 CanPsychicTerrainProtectTarget(struct BattleContext *ctx, s32 movePriority);
|
||||
bool32 CanMoveBeBlockedByTarget(struct BattleContext *ctx, s32 movePriority);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@
|
|||
#define SHOULD_SWITCH_NATURAL_CURE_WEAK_STATS_RAISED_PERCENTAGE 10
|
||||
#define SHOULD_SWITCH_REGENERATOR_PERCENTAGE 50
|
||||
#define SHOULD_SWITCH_REGENERATOR_STATS_RAISED_PERCENTAGE 20
|
||||
#define SHOULD_SWITCH_INTIMIDATE_PERCENTAGE 25
|
||||
#define SHOULD_SWITCH_INTIMIDATE_STATS_RAISED_PERCENTAGE 10
|
||||
|
||||
// AI switchin considerations
|
||||
#define ALL_MOVES_BAD_STATUS_MOVES_BAD FALSE // If the AI has no moves that affect the target, ShouldSwitchIfAllMovesBad can prompt a switch. Enabling this config will ignore status moves that can affect the target when making this decision.
|
||||
|
|
|
|||
|
|
@ -630,6 +630,8 @@ extern const u8 EventScript_SelectWithoutRegisteredItem[];
|
|||
extern const u8 EventScript_WhiteOut[];
|
||||
extern const u8 EventScript_AfterWhiteOutMomHeal[];
|
||||
extern const u8 EventScript_AfterWhiteOutHeal[];
|
||||
extern const u8 EventScript_AfterWhiteOutHeal_Frlg[];
|
||||
extern const u8 EventScript_AfterWhiteOutHealMsgPreFirstBoss[];
|
||||
extern const u8 EventScript_ResetMrBriney[];
|
||||
extern const u8 EventScript_DoLinkRoomExit[];
|
||||
extern const u8 CableClub_EventScript_TooBusyToNotice[];
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ enum RandomTag
|
|||
RNG_AI_SWITCH_ABSORBING_STAY_IN,
|
||||
RNG_AI_SWITCH_NATURAL_CURE,
|
||||
RNG_AI_SWITCH_REGENERATOR,
|
||||
RNG_AI_SWITCH_INTIMIDATE,
|
||||
RNG_AI_SWITCH_ENCORE,
|
||||
RNG_AI_SWITCH_CHOICE_LOCKED,
|
||||
RNG_AI_SWITCH_STATS_LOWERED,
|
||||
|
|
|
|||
|
|
@ -142,6 +142,20 @@ static s32 (*const sBattleAiFuncTable[])(enum BattlerId, enum BattlerId, enum Mo
|
|||
};
|
||||
|
||||
// Functions
|
||||
void AIDebugTimerStart()
|
||||
{
|
||||
// Set delay timer to count how long it takes for AI to choose action/move
|
||||
gBattleStruct->aiDelayTimer = gMain.vblankCounter1;
|
||||
CycleCountStart();
|
||||
}
|
||||
|
||||
void AIDebugTimerEnd()
|
||||
{
|
||||
// We add to existing to compound multiple calls
|
||||
gBattleStruct->aiDelayFrames += gMain.vblankCounter1 - gBattleStruct->aiDelayTimer;
|
||||
gBattleStruct->aiDelayCycles += CycleCountEnd();
|
||||
}
|
||||
|
||||
void BattleAI_SetupAIData(u8 defaultScoreMoves, enum BattlerId battler)
|
||||
{
|
||||
u32 moveLimitations;
|
||||
|
|
@ -371,6 +385,9 @@ void ComputeBattlerDecisions(enum BattlerId battler)
|
|||
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerStart();
|
||||
|
||||
// Setup battler and prediction data
|
||||
BattleAI_SetupAIData(0xF, battler);
|
||||
SetupAIPredictionData(battler, SWITCH_MID_BATTLE_OPTIONAL);
|
||||
|
|
@ -390,6 +407,9 @@ void ComputeBattlerDecisions(enum BattlerId battler)
|
|||
BattlerChooseNonMoveAction();
|
||||
ModifySwitchAfterMoveScoring(battler);
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerEnd();
|
||||
|
||||
gAiLogicData->aiCalcInProgress = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -710,8 +730,10 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
if (!(gBattleTypeFlags & BATTLE_TYPE_HAS_AI) && !IsWildMonSmart())
|
||||
return;
|
||||
|
||||
// Set delay timer to count how long it takes for AI to choose action/move
|
||||
gBattleStruct->aiDelayTimer = gMain.vblankCounter1;
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerStart();
|
||||
|
||||
aiData->weatherHasEffect = HasWeatherEffect();
|
||||
weather = AI_GetWeather();
|
||||
|
|
@ -719,9 +741,6 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
// get/assume all battler data and simulate AI damage
|
||||
battlersCount = gBattlersCount;
|
||||
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
CycleCountStart();
|
||||
for (enum BattlerId battlerAtk = 0; battlerAtk < battlersCount; battlerAtk++)
|
||||
{
|
||||
if (!IsBattlerAlive(battlerAtk))
|
||||
|
|
@ -752,8 +771,8 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
}
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
// We add to existing to compound multiple calls
|
||||
gBattleStruct->aiDelayCycles += CycleCountEnd();
|
||||
AIDebugTimerEnd();
|
||||
|
||||
gAiLogicData->aiCalcInProgress = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ static void SetBattlerStatStagesForSwitchin(enum BattlerId battler, enum Battler
|
|||
static void SetBattlerHPChangeForSwitch(enum BattlerId battler, enum BattlerId opposingBattler);
|
||||
static void SetBattlerVolatilesForSwitchin(enum BattlerId battler, u32 weather, u32 fieldStatus);
|
||||
bool32 IsSwitchinTSpikesAffected(enum BattlerId battler);
|
||||
static bool32 IsOpponentPhysicalAttacker(enum BattlerId battler, enum BattlerId opposingBattler);
|
||||
static bool32 CanIntimidateLowerOpponentAtk(enum BattlerId battler, enum BattlerId opposingBattler);
|
||||
static bool32 ShouldSwitchIfIntimidateBenefit(enum BattlerId battler);
|
||||
|
||||
static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, u32 monIndex, struct Pokemon *mon)
|
||||
{
|
||||
|
|
@ -59,6 +62,8 @@ static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, u32 monI
|
|||
SetBattlerVolatilesForSwitchin(switchinBattler, switchinWeather, switchinFieldStatus);
|
||||
SetBattlerStatusForSwitchin(switchinBattler);
|
||||
gBattlerPartyIndexes[switchinBattler] = monIndex;
|
||||
gAiLogicData->switchInCalc = TRUE;
|
||||
|
||||
for (enum BattlerId battlerIndex = 0; battlerIndex < gBattlersCount; battlerIndex++)
|
||||
{
|
||||
if (switchinBattler == battlerIndex || !IsBattlerAlive(battlerIndex))
|
||||
|
|
@ -69,6 +74,7 @@ static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, u32 monI
|
|||
CalcBattlerAiMovesData(gAiLogicData, battlerIndex, switchinBattler, switchinWeather, switchinFieldStatus);
|
||||
}
|
||||
|
||||
gAiLogicData->switchInCalc = FALSE;
|
||||
gBattlerPartyIndexes[switchinBattler] = storeCurrBattlerPartyIndex;
|
||||
gAiThinkingStruct->saved[switchinBattler].saved = FALSE;
|
||||
}
|
||||
|
|
@ -183,6 +189,10 @@ u32 GetSwitchChance(enum ShouldSwitchScenario shouldSwitchScenario)
|
|||
return SHOULD_SWITCH_REGENERATOR_PERCENTAGE;
|
||||
case SHOULD_SWITCH_REGENERATOR_STATS_RAISED:
|
||||
return SHOULD_SWITCH_REGENERATOR_STATS_RAISED_PERCENTAGE;
|
||||
case SHOULD_SWITCH_INTIMIDATE:
|
||||
return SHOULD_SWITCH_INTIMIDATE_PERCENTAGE;
|
||||
case SHOULD_SWITCH_INTIMIDATE_STATS_RAISED:
|
||||
return SHOULD_SWITCH_INTIMIDATE_STATS_RAISED_PERCENTAGE;
|
||||
case SHOULD_SWITCH_ENCORE_STATUS:
|
||||
return SHOULD_SWITCH_ENCORE_STATUS_PERCENTAGE;
|
||||
case SHOULD_SWITCH_ENCORE_DAMAGE:
|
||||
|
|
@ -955,6 +965,103 @@ static bool32 GetHitEscapeTransformState(enum BattlerId battlerAtk, enum Move mo
|
|||
return isFasterThanAll;
|
||||
}
|
||||
|
||||
static bool32 IsOpponentPhysicalAttacker(enum BattlerId battler, enum BattlerId opposingBattler)
|
||||
{
|
||||
if (!IsBattlerAlive(opposingBattler))
|
||||
return FALSE;
|
||||
|
||||
if (GetBestDmgFromBattler(opposingBattler, battler, AI_DEFENDING) > 0 && HasPhysicalBestMove(opposingBattler, battler, AI_DEFENDING))
|
||||
return TRUE;
|
||||
|
||||
enum Move incomingMove = GetIncomingMove(battler, opposingBattler, gAiLogicData);
|
||||
return incomingMove != MOVE_NONE
|
||||
&& incomingMove != MOVE_UNAVAILABLE
|
||||
&& GetBattleMoveCategory(incomingMove) == DAMAGE_CATEGORY_PHYSICAL;
|
||||
}
|
||||
|
||||
static bool32 CanIntimidateLowerOpponentAtk(enum BattlerId battler, enum BattlerId opposingBattler)
|
||||
{
|
||||
enum Ability abilityDef = gAiLogicData->abilities[opposingBattler];
|
||||
|
||||
// If Attack is already at -2 or lower, repeated Intimidate cycles aren't worth it.
|
||||
if (gBattleMons[opposingBattler].statStages[STAT_ATK] <= DEFAULT_STAT_STAGE - 2)
|
||||
return FALSE;
|
||||
|
||||
if (gBattleMons[opposingBattler].volatiles.substitute)
|
||||
return FALSE;
|
||||
|
||||
if (gAiLogicData->holdEffects[opposingBattler] == HOLD_EFFECT_CLEAR_AMULET)
|
||||
return FALSE;
|
||||
|
||||
if (gSideStatuses[GetBattlerSide(opposingBattler)] & SIDE_STATUS_MIST)
|
||||
return FALSE;
|
||||
|
||||
if (IS_BATTLER_OF_TYPE(opposingBattler, TYPE_GRASS) && AI_IsAbilityOnSide(opposingBattler, ABILITY_FLOWER_VEIL))
|
||||
return FALSE;
|
||||
|
||||
switch (abilityDef)
|
||||
{
|
||||
case ABILITY_HYPER_CUTTER:
|
||||
case ABILITY_CLEAR_BODY:
|
||||
case ABILITY_FULL_METAL_BODY:
|
||||
case ABILITY_WHITE_SMOKE:
|
||||
return FALSE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetConfig(B_UPDATED_INTIMIDATE) >= GEN_8)
|
||||
{
|
||||
switch (abilityDef)
|
||||
{
|
||||
case ABILITY_INNER_FOCUS:
|
||||
case ABILITY_SCRAPPY:
|
||||
case ABILITY_OWN_TEMPO:
|
||||
case ABILITY_OBLIVIOUS:
|
||||
return FALSE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 ShouldSwitchIfIntimidateBenefit(enum BattlerId battler)
|
||||
{
|
||||
// Keep Intimidate cycling behavior restricted to smart-switching AI
|
||||
if (!(gAiThinkingStruct->aiFlags[battler] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
enum BattlerId opposingBattler = GetOppositeBattler(battler);
|
||||
enum BattlerId opposingPartner = BATTLE_PARTNER(opposingBattler);
|
||||
bool32 hasValidTarget = FALSE;
|
||||
|
||||
if (IsBattlerAlive(opposingBattler))
|
||||
{
|
||||
enum Ability abilityDef = gAiLogicData->abilities[opposingBattler];
|
||||
bool32 canLowerAtk = CanIntimidateLowerOpponentAtk(battler, opposingBattler);
|
||||
|
||||
if (canLowerAtk && (DoesIntimidateRaiseStats(abilityDef) || abilityDef == ABILITY_MIRROR_ARMOR))
|
||||
return FALSE;
|
||||
if (canLowerAtk && IsOpponentPhysicalAttacker(battler, opposingBattler))
|
||||
hasValidTarget = TRUE;
|
||||
}
|
||||
|
||||
if (IsDoubleBattle() && IsBattlerAlive(opposingPartner))
|
||||
{
|
||||
enum Ability abilityDef = gAiLogicData->abilities[opposingPartner];
|
||||
bool32 canLowerAtk = CanIntimidateLowerOpponentAtk(battler, opposingPartner);
|
||||
|
||||
if (canLowerAtk && (DoesIntimidateRaiseStats(abilityDef) || abilityDef == ABILITY_MIRROR_ARMOR))
|
||||
return FALSE;
|
||||
if (canLowerAtk && IsOpponentPhysicalAttacker(battler, opposingPartner))
|
||||
hasValidTarget = TRUE;
|
||||
}
|
||||
|
||||
return hasValidTarget;
|
||||
}
|
||||
|
||||
static bool32 ShouldSwitchIfAbilityBenefit(enum BattlerId battler)
|
||||
{
|
||||
bool32 hasStatRaised = AnyUsefulStatIsRaised(battler);
|
||||
|
|
@ -992,20 +1099,21 @@ static bool32 ShouldSwitchIfAbilityBenefit(enum BattlerId battler)
|
|||
|
||||
return FALSE;
|
||||
|
||||
case ABILITY_INTIMIDATE:
|
||||
// TODO: In ShouldSwitch cleanup, gate Intimidate cycling behind "stay in instead if the current mon wins the 1v1" to avoid duplicating Bad Odds logic here.
|
||||
if (ShouldSwitchIfIntimidateBenefit(battler)
|
||||
&& gAiLogicData->mostSuitableMonId[battler] != PARTY_SIZE
|
||||
&& (hasStatRaised ? RandomPercentage(RNG_AI_SWITCH_INTIMIDATE, GetSwitchChance(SHOULD_SWITCH_INTIMIDATE_STATS_RAISED)) : RandomPercentage(RNG_AI_SWITCH_INTIMIDATE, GetSwitchChance(SHOULD_SWITCH_INTIMIDATE))))
|
||||
break;
|
||||
|
||||
return FALSE;
|
||||
|
||||
case ABILITY_ZERO_TO_HERO:
|
||||
{
|
||||
enum Move hitEscapeMove = MOVE_NONE;
|
||||
|
||||
for (u32 moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++)
|
||||
{
|
||||
enum Move move = gBattleMons[battler].moves[moveIndex];
|
||||
|
||||
if (move != MOVE_NONE && GetMoveEffect(move) == EFFECT_HIT_ESCAPE)
|
||||
{
|
||||
hitEscapeMove = move;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GetBattlerMoveIndexWithEffect(battler, EFFECT_HIT_ESCAPE) < MAX_MON_MOVES)
|
||||
hitEscapeMove = gBattleMons[battler].moves[GetBattlerMoveIndexWithEffect(battler, EFFECT_HIT_ESCAPE)];
|
||||
|
||||
// Prefer to use a hit escape move if Palafin will move first and can hit
|
||||
if (hitEscapeMove != MOVE_NONE && GetHitEscapeTransformState(battler, hitEscapeMove))
|
||||
|
|
@ -2756,6 +2864,7 @@ static void SetBattlerStatStagesForSwitchin(enum BattlerId battler, enum Battler
|
|||
switch(GetItemHoldEffect(aiItem))
|
||||
{
|
||||
case HOLD_EFFECT_TERRAIN_SEED:
|
||||
{
|
||||
u32 seedParam = GetItemHoldEffectParam(aiItem);
|
||||
if ((seedParam == HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN && (fieldStatus & STATUS_FIELD_ELECTRIC_TERRAIN))
|
||||
|| (seedParam == HOLD_EFFECT_PARAM_GRASSY_TERRAIN && (fieldStatus & STATUS_FIELD_GRASSY_TERRAIN))
|
||||
|
|
@ -2763,6 +2872,7 @@ static void SetBattlerStatStagesForSwitchin(enum BattlerId battler, enum Battler
|
|||
|| (seedParam == HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN && (fieldStatus & STATUS_FIELD_PSYCHIC_TERRAIN)))
|
||||
gBattleMons[battler].statStages[STAT_DEF] += 1;
|
||||
break;
|
||||
}
|
||||
case HOLD_EFFECT_ATTACK_UP:
|
||||
if (HasEnoughHpToEatBerry(battler, aiAbility, GetItemHoldEffectParam(aiItem), aiItem))
|
||||
gBattleMons[battler].statStages[STAT_ATK] += 1;
|
||||
|
|
|
|||
|
|
@ -5934,8 +5934,9 @@ bool32 DoesIntimidateRaiseStats(enum Ability ability)
|
|||
case ABILITY_CONTRARY:
|
||||
case ABILITY_DEFIANT:
|
||||
case ABILITY_GUARD_DOG:
|
||||
case ABILITY_RATTLED:
|
||||
return TRUE;
|
||||
case ABILITY_RATTLED:
|
||||
return GetConfig(B_UPDATED_INTIMIDATE) >= GEN_8;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2003,8 +2003,6 @@ static void HandleChooseActionAfterDma3(enum BattlerId battler)
|
|||
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
||||
if (gBattleStruct->aiDelayTimer != 0)
|
||||
{
|
||||
gBattleStruct->aiDelayFrames = gMain.vblankCounter1 - gBattleStruct->aiDelayTimer;
|
||||
gBattleStruct->aiDelayTimer = 0;
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
{
|
||||
static const u8 sFramesText[] = _(" frames thinking\n");
|
||||
|
|
@ -2017,6 +2015,8 @@ static void HandleChooseActionAfterDma3(enum BattlerId battler)
|
|||
StringAppend(gDisplayedStringBattle, sCyclesText);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
||||
}
|
||||
gBattleStruct->aiDelayTimer = 0;
|
||||
gBattleStruct->aiDelayFrames = 0;
|
||||
}
|
||||
gBattlerControllerFuncs[battler] = HandleInputChooseAction;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3973,7 +3973,7 @@ void BattleTurnPassed(void)
|
|||
{
|
||||
if (gSideTimers[i].retaliateTimer > 0)
|
||||
gSideTimers[i].retaliateTimer--;
|
||||
}
|
||||
}
|
||||
|
||||
gFieldStatuses &= ~STATUS_FIELD_ION_DELUGE;
|
||||
|
||||
|
|
|
|||
|
|
@ -10002,6 +10002,7 @@ static void HandleRoomMove(u32 statusFlag, u16 *timer, u8 stringId)
|
|||
if (gFieldStatuses & statusFlag)
|
||||
{
|
||||
gFieldStatuses &= ~statusFlag;
|
||||
*timer = 0;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = stringId + 1;
|
||||
}
|
||||
else
|
||||
|
|
@ -10561,7 +10562,8 @@ static void FinalizeCapture(void)
|
|||
{
|
||||
u32 ballId = ItemIdToBallId(gLastThrownBall);
|
||||
enum NationalDexOrder natDexNo = SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species);
|
||||
if (GetConfig(B_CRITICAL_CAPTURE_IF_OWNED) >= GEN_9 && GetSetPokedexFlag(natDexNo, FLAG_GET_CAUGHT))
|
||||
if ((GetConfig(B_CRITICAL_CAPTURE_IF_OWNED) >= GEN_9 && GetSetPokedexFlag(natDexNo, FLAG_GET_CAUGHT))
|
||||
|| IsCriticalCapture())
|
||||
{
|
||||
gBattleSpritesDataPtr->animationData->isCriticalCapture = TRUE;
|
||||
gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE;
|
||||
|
|
@ -10944,6 +10946,9 @@ static void Cmd_handleballthrow(void)
|
|||
if (gBattleResults.catchAttempts[ballId] < 255)
|
||||
gBattleResults.catchAttempts[ballId]++;
|
||||
|
||||
gBattleSpritesDataPtr->animationData->isCriticalCapture = FALSE;
|
||||
gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = FALSE;
|
||||
|
||||
//Master Ball check occurs before critical capture check
|
||||
if (odds == CAPTURE_GUARANTEED)
|
||||
{
|
||||
|
|
@ -10954,9 +10959,6 @@ static void Cmd_handleballthrow(void)
|
|||
u8 shakes;
|
||||
u8 maxShakes;
|
||||
|
||||
gBattleSpritesDataPtr->animationData->isCriticalCapture = FALSE;
|
||||
gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = FALSE;
|
||||
|
||||
if (CriticalCapture(odds))
|
||||
{
|
||||
maxShakes = BALL_1_SHAKE; // critical capture doesn't guarantee capture
|
||||
|
|
@ -10981,8 +10983,6 @@ static void Cmd_handleballthrow(void)
|
|||
|
||||
if (shakes == maxShakes) // mon caught, copy of the code above
|
||||
{
|
||||
if (IsCriticalCapture())
|
||||
gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE;
|
||||
FinalizeCapture();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6470,9 +6470,12 @@ static inline u32 CalcMoveBasePowerAfterModifiers(struct BattleContext *ctx)
|
|||
modifier = uq4_12_multiply(modifier, UQ_4_12(2.0));
|
||||
break;
|
||||
case EFFECT_RETALIATE:
|
||||
if (gSideTimers[atkSide].retaliateTimer == 1)
|
||||
{
|
||||
u32 retaliateTimer = gSideTimers[atkSide].retaliateTimer;
|
||||
if (retaliateTimer == 1 || (gAiLogicData->switchInCalc && retaliateTimer == 2))
|
||||
modifier = uq4_12_multiply(modifier, UQ_4_12(2.0));
|
||||
break;
|
||||
}
|
||||
case EFFECT_SOLAR_BEAM:
|
||||
if ((GetConfig(B_SANDSTORM_SOLAR_BEAM) >= GEN_3 && IsBattlerWeatherAffected(ctx->holdEffectAtk, ctx->weather, B_WEATHER_LOW_LIGHT))
|
||||
|| IsBattlerWeatherAffected(ctx->holdEffectAtk, ctx->weather, (B_WEATHER_RAIN | B_WEATHER_ICY_ANY | B_WEATHER_FOG))) // Excludes Sandstorm
|
||||
|
|
|
|||
|
|
@ -2405,7 +2405,12 @@ static u8 TryForMutation(u8 berryTreeId, u8 berry)
|
|||
{
|
||||
x2 = gObjectEvents[j].currentCoords.x;
|
||||
y2 = gObjectEvents[j].currentCoords.y;
|
||||
if (Random() % 100 < (OW_BERRY_MUTATION_CHANCE * (mulch == ITEM_TO_MULCH(ITEM_SURPRISE_MULCH) || mulch == ITEM_TO_MULCH(ITEM_AMAZE_MULCH))) && (
|
||||
u32 rate = OW_BERRY_MUTATION_CHANCE;
|
||||
|
||||
if (mulch == ITEM_TO_MULCH(ITEM_SURPRISE_MULCH) || mulch == ITEM_TO_MULCH(ITEM_AMAZE_MULCH))
|
||||
rate *= 2;
|
||||
|
||||
if (Random() % 100 < rate && (
|
||||
(x1 == x2 && y1 == y2 - 1) ||
|
||||
(x1 == x2 && y1 == y2 + 1) ||
|
||||
(x1 == x2 - 1 && y1 == y2) ||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ EVs: 252 Atk / 252 Def / 6 SpA
|
|||
|
||||
=== DEBUG_TRAINER_AI ===
|
||||
Name: Debugger
|
||||
AI: Basic Trainer
|
||||
AI: Smart Trainer
|
||||
Class: Rival
|
||||
Battle Type: Singles
|
||||
Pic: Steven
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@
|
|||
"respawn_x": 8,
|
||||
"respawn_y": 5,
|
||||
"respawn_map": "MAP_PALLET_TOWN_PLAYERS_HOUSE_1F",
|
||||
"respawn_npc": "LOCALID_MOM"
|
||||
"respawn_npc": "LOCALID_PLAYERS_HOUSE_1F_MOM"
|
||||
},
|
||||
{
|
||||
"id": "HEAL_LOCATION_VIRIDIAN_CITY",
|
||||
|
|
|
|||
|
|
@ -1454,9 +1454,21 @@ static void Task_RushInjuredPokemonToCenter(u8 taskId)
|
|||
{
|
||||
DestroyTask(taskId);
|
||||
if (gTasks[taskId].tIsPlayerHouse)
|
||||
{
|
||||
if (IS_FRLG)
|
||||
StringCopy(gStringVar1, COMPOUND_STRING("PROF. OAK"));
|
||||
else
|
||||
StringCopy(gStringVar1, COMPOUND_STRING("PROF. BIRCH"));
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal);
|
||||
}
|
||||
else if (IS_FRLG)
|
||||
{
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal_Frlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,4 +102,5 @@ void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData *warp)
|
|||
warp->x = sWhiteoutRespawnHealCenterMapIdxs[healLocationId - 1][2];
|
||||
warp->y = sWhiteoutRespawnHealCenterMapIdxs[healLocationId - 1][3];
|
||||
gSpecialVar_LastTalked = healNpcLocalId;
|
||||
gSpecialVar_0x800B = healNpcLocalId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,9 @@ static const u32 sPokedexPlusHGSS_ScreenSearchNational_Tilemap[] = INCBIN_U32("g
|
|||
// for evolution method listings
|
||||
#define MAX_EVO_METHOD_LINES 10
|
||||
|
||||
// Width of pixels one line of text in the species box can be
|
||||
#define STATS_PAGE_SPECIES_MAX_WIDTH 55
|
||||
|
||||
extern EWRAM_DATA struct PokedexView *sPokedexView;
|
||||
extern EWRAM_DATA struct PokedexListItem *sPokedexListItem;
|
||||
//Pokedex Plus HGSS_Ui
|
||||
|
|
@ -2421,7 +2424,7 @@ static void PrintStatsScreen_NameGender(u8 taskId, u32 num, u32 value)
|
|||
|
||||
//Name
|
||||
const u8 *name = GetSpeciesName(species);
|
||||
if (GetStringWidth(FONT_SMALL, name, 0) <= 55)
|
||||
if (GetStringWidth(FONT_SMALL, name, 0) <= STATS_PAGE_SPECIES_MAX_WIDTH)
|
||||
PrintStatsScreenTextSmall(WIN_STATS_NAME_GENDER, name, base_x, base_y);
|
||||
else
|
||||
PrintStatsScreenTextSmallNarrower(WIN_STATS_NAME_GENDER, name, base_x, base_y);
|
||||
|
|
@ -4735,36 +4738,6 @@ void HandleCreateStatBarsDPAD_HGSS(void)
|
|||
CreateStatBars(&sPokedexView->pokedexList[sPokedexView->selectedPokemon]);
|
||||
}
|
||||
|
||||
static void TryLoadDarkModeArrowPalette(void)
|
||||
{
|
||||
if (!HGSS_DARK_MODE)
|
||||
return;
|
||||
|
||||
u32 index = IndexOfSpritePaletteTag(gSpritePalette_Arrow.tag);
|
||||
u32 colorArrow = RGB2GBA(72, 72, 72);
|
||||
u32 colorOutline = RGB2GBA(24, 24, 24);
|
||||
|
||||
LoadPalette(&colorArrow, OBJ_PLTT_ID(index) + 1, sizeof(colorArrow));
|
||||
LoadPalette(&colorOutline, OBJ_PLTT_ID(index) + 2, sizeof(colorOutline));
|
||||
}
|
||||
|
||||
static void FillCryMeterWindowTilemapWithBg(void)
|
||||
{
|
||||
// This fills the window behind the 'VU' text on the cry meter.
|
||||
// It is filled with blank tiles, showing as black.
|
||||
|
||||
struct Window windowLocal = gWindows[WIN_VU_METER];
|
||||
|
||||
FillBgTilemapBufferRect(
|
||||
3,
|
||||
0,
|
||||
windowLocal.window.tilemapLeft,
|
||||
windowLocal.window.tilemapTop,
|
||||
windowLocal.window.width,
|
||||
windowLocal.window.height,
|
||||
windowLocal.window.paletteNum);
|
||||
}
|
||||
|
||||
void HandleCaughtMonPageTypeIcons_HGSS(void)
|
||||
{
|
||||
if (!POKEDEX_PLUS_HGSS)
|
||||
|
|
@ -4799,3 +4772,33 @@ bool32 TryHandleCaughtMonPageFlicker_HGSS(u8 taskId)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void TryLoadDarkModeArrowPalette(void)
|
||||
{
|
||||
if (!HGSS_DARK_MODE)
|
||||
return;
|
||||
|
||||
u32 index = IndexOfSpritePaletteTag(gSpritePalette_Arrow.tag);
|
||||
u32 colorArrow = RGB2GBA(72, 72, 72);
|
||||
u32 colorOutline = RGB2GBA(24, 24, 24);
|
||||
|
||||
LoadPalette(&colorArrow, OBJ_PLTT_ID(index) + 1, sizeof(colorArrow));
|
||||
LoadPalette(&colorOutline, OBJ_PLTT_ID(index) + 2, sizeof(colorOutline));
|
||||
}
|
||||
|
||||
static void FillCryMeterWindowTilemapWithBg(void)
|
||||
{
|
||||
// This fills the window behind the 'VU' text on the cry meter.
|
||||
// It is filled with blank tiles, showing as black.
|
||||
|
||||
struct Window windowLocal = gWindows[WIN_VU_METER];
|
||||
|
||||
FillBgTilemapBufferRect(
|
||||
3,
|
||||
0,
|
||||
windowLocal.window.tilemapLeft,
|
||||
windowLocal.window.tilemapTop,
|
||||
windowLocal.window.width,
|
||||
windowLocal.window.height,
|
||||
windowLocal.window.paletteNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ static void PrintInstructionsOnWindow(struct PokemonSpriteVisualizer *data)
|
|||
{
|
||||
u8 fontId = FONT_SMALL;
|
||||
u8 x = 2;
|
||||
enum Species species = data->modifyArrows.currValue;
|
||||
enum Species species = IsSpeciesEnabled(data->modifyArrows.currValue) ? SanitizeSpeciesId(data->modifyArrows.currValue) : SPECIES_NONE;
|
||||
|
||||
u8 textBottom[] = _("BACK:\nFRONT:\nBG:$");
|
||||
u8 textBottomForms[] = _("BACK:\nFRONT:\nBG:\nFORMS:$");
|
||||
|
|
@ -575,7 +575,8 @@ static void SetStructPtr(u8 taskId, void *ptr)
|
|||
static void PrintDigitChars(struct PokemonSpriteVisualizer *data)
|
||||
{
|
||||
s32 i;
|
||||
enum Species species = data->modifyArrows.currValue;
|
||||
enum Species species = IsSpeciesEnabled(data->modifyArrows.currValue) ? data->modifyArrows.currValue : SPECIES_NONE;
|
||||
|
||||
u8 text[MODIFY_DIGITS_MAX + POKEMON_NAME_LENGTH + 8];
|
||||
|
||||
for (i = 0; i < data->modifyArrows.maxDigits; i++)
|
||||
|
|
@ -793,7 +794,7 @@ static void BattleLoadOpponentMonSpriteGfxCustom(enum Species species, bool8 isF
|
|||
|
||||
static void SetConstSpriteValues(struct PokemonSpriteVisualizer *data)
|
||||
{
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
data->constSpriteValues.frontPicCoords = gSpeciesInfo[species].frontPicYOffset;
|
||||
data->constSpriteValues.frontElevation = gSpeciesInfo[species].enemyMonElevation;
|
||||
data->constSpriteValues.backPicCoords = gSpeciesInfo[species].backPicYOffset;
|
||||
|
|
@ -810,7 +811,7 @@ static void ResetShadowSettings(struct PokemonSpriteVisualizer *data)
|
|||
{
|
||||
if (B_ENEMY_MON_SHADOW_STYLE <= GEN_3 || P_GBA_STYLE_SPECIES_GFX == TRUE)
|
||||
return;
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
data->shadowSettings.definedX = gSpeciesInfo[species].enemyShadowXOffset;
|
||||
data->shadowSettings.definedY = gSpeciesInfo[species].enemyShadowYOffset;
|
||||
data->shadowSettings.definedSize = gSpeciesInfo[species].enemyShadowSize;
|
||||
|
|
@ -910,7 +911,7 @@ static void SpriteCB_Follower(struct Sprite *sprite)
|
|||
static void LoadAndCreateEnemyShadowSpriteCustom(struct PokemonSpriteVisualizer *data)
|
||||
{
|
||||
bool8 invisible = FALSE;
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
|
||||
if (B_ENEMY_MON_SHADOW_STYLE >= GEN_4 && P_GBA_STYLE_SPECIES_GFX == FALSE)
|
||||
{
|
||||
|
|
@ -1040,7 +1041,7 @@ static void DrawFollowerSprite(struct PokemonSpriteVisualizer *data)
|
|||
if (!OW_POKEMON_OBJECT_EVENTS)
|
||||
return;
|
||||
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
u16 graphicsId = species + OBJ_EVENT_MON;
|
||||
if (data->isShiny)
|
||||
graphicsId += OBJ_EVENT_MON_SHINY;
|
||||
|
|
@ -1268,7 +1269,7 @@ void CB2_Pokemon_Sprite_Visualizer(void)
|
|||
SetStructPtr(taskId, data);
|
||||
|
||||
data->currentmonId = SPECIES_BULBASAUR;
|
||||
species = SanitizeSpeciesId(data->currentmonId);
|
||||
species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
|
||||
//Print instructions
|
||||
PrintInstructionsOnWindow(data);
|
||||
|
|
@ -1385,7 +1386,7 @@ static void ResetBGs_PokemonSpriteVisualizer(u16 a)
|
|||
|
||||
static void ApplyOffsetSpriteValues(struct PokemonSpriteVisualizer *data)
|
||||
{
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
//Back
|
||||
gSprites[data->backspriteId].y = VISUALIZER_MON_BACK_Y + gSpeciesInfo[species].backPicYOffset + data->offsetsSpriteValues.offset_back_picCoords;
|
||||
//Front
|
||||
|
|
@ -1398,7 +1399,7 @@ static void ApplyOffsetSpriteValues(struct PokemonSpriteVisualizer *data)
|
|||
static void UpdateSubmenuOneOptionValue(u8 taskId, bool8 increment)
|
||||
{
|
||||
struct PokemonSpriteVisualizer *data = GetStructPtr(taskId);
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
u8 option = data->submenuYpos[1];
|
||||
|
||||
switch (option)
|
||||
|
|
@ -1483,7 +1484,7 @@ static void UpdateSubmenuOneOptionValue(u8 taskId, bool8 increment)
|
|||
static void UpdateSubmenuTwoOptionValue(u8 taskId, bool8 increment)
|
||||
{
|
||||
struct PokemonSpriteVisualizer *data = GetStructPtr(taskId);
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
u8 option = data->submenuYpos[2];
|
||||
s8 offset;
|
||||
u8 y;
|
||||
|
|
@ -1703,7 +1704,7 @@ static void OpenSubmenu(u32 submenu, u8 taskId)
|
|||
static void HandleInput_PokemonSpriteVisualizer(u8 taskId)
|
||||
{
|
||||
struct PokemonSpriteVisualizer *data = GetStructPtr(taskId);
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
struct Sprite *Frontsprite = &gSprites[data->frontspriteId];
|
||||
struct Sprite *Backsprite = &gSprites[data->backspriteId];
|
||||
|
||||
|
|
@ -1987,7 +1988,7 @@ static void HandleInput_PokemonSpriteVisualizer(u8 taskId)
|
|||
static void ReloadPokemonSprites(struct PokemonSpriteVisualizer *data)
|
||||
{
|
||||
const u16 *palette;
|
||||
enum Species species = SanitizeSpeciesId(data->currentmonId);
|
||||
enum Species species = IsSpeciesEnabled(data->currentmonId) ? SanitizeSpeciesId(data->currentmonId) : SPECIES_NONE;
|
||||
s16 offset_y;
|
||||
u8 front_x = sBattlerCoords[0][1].x;
|
||||
u8 front_y;
|
||||
|
|
|
|||
|
|
@ -285,3 +285,24 @@ AI_SINGLE_BATTLE_TEST("Fillet Away AI handling")
|
|||
TURN { MOVE(player, move); EXPECT_MOVE(opponent, move == MOVE_SCALD ? MOVE_FILLET_AWAY : MOVE_AQUA_CUTTER); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("Retaliate sees damage correctly on the field")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Level(50); HP(100); Nature(NATURE_QUIRKY); Ability(ABILITY_TELEPATHY); Speed(58); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_RATTATA){ Level(1); HP(1); Nature(NATURE_QUIRKY); Speed(1); Moves(MOVE_TACKLE);}
|
||||
OPPONENT(SPECIES_KANGASKHAN) { Level(50); Nature(NATURE_QUIRKY); Ability(ABILITY_INNER_FOCUS); Speed(251); Moves(MOVE_RETALIATE, MOVE_SLASH); }
|
||||
} WHEN {
|
||||
TURN {
|
||||
MOVE(player, MOVE_TACKLE);
|
||||
EXPECT_MOVE(opponent, MOVE_TACKLE);
|
||||
EXPECT_SEND_OUT(opponent, 1);
|
||||
}
|
||||
TURN {
|
||||
MOVE(player, MOVE_TACKLE);
|
||||
SCORE_EQ_VAL(opponent, MOVE_RETALIATE, (AI_SCORE_DEFAULT + BEST_DAMAGE_MOVE + FAST_KILL));
|
||||
SCORE_EQ_VAL(opponent, MOVE_SLASH, (AI_SCORE_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1274,6 +1274,105 @@ AI_SINGLE_BATTLE_TEST("Switch AI: AI will switch out if it has <= 66% HP remaini
|
|||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will switch out to cycle Intimidate when facing a physical attacker")
|
||||
{
|
||||
PASSES_RANDOMLY(SHOULD_SWITCH_INTIMIDATE_PERCENTAGE, 100, RNG_AI_SWITCH_INTIMIDATE);
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TACKLE); EXPECT_SWITCH(opponent, 1); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will not cycle Intimidate when target blocks or punishes Attack drops")
|
||||
{
|
||||
u32 Species = SPECIES_NONE;
|
||||
enum Ability ability;
|
||||
PARAMETRIZE { Species = SPECIES_TENTACRUEL; ability = ABILITY_CLEAR_BODY; }
|
||||
PARAMETRIZE { Species = SPECIES_BRAVIARY; ability = ABILITY_DEFIANT; }
|
||||
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING);
|
||||
PLAYER(Species) { Ability(ability); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TACKLE); EXPECT_MOVE(opponent, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will not cycle Intimidate when target is a special attacker")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING);
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_WATER_GUN); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_WATER_GUN); EXPECT_MOVE(opponent, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will switch out to cycle Intimidate in doubles when at least one target is valid")
|
||||
{
|
||||
PASSES_RANDOMLY(SHOULD_SWITCH_INTIMIDATE_PERCENTAGE, 100, RNG_AI_SWITCH_INTIMIDATE);
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_WATER_GUN); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); MOVE(playerRight, MOVE_WATER_GUN, target: opponentRight); EXPECT_SWITCH(opponentLeft, 2); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will not cycle Intimidate in doubles when both targets block Attack drops")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_TENTACRUEL) { Ability(ABILITY_CLEAR_BODY); Moves(MOVE_TACKLE); }
|
||||
PLAYER(SPECIES_KINGLER) { Ability(ABILITY_HYPER_CUTTER); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); MOVE(playerRight, MOVE_TACKLE, target: opponentRight); EXPECT_MOVE(opponentLeft, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will not cycle Intimidate in doubles when one target punishes stat drops")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_BRAVIARY) { Ability(ABILITY_DEFIANT); Moves(MOVE_TACKLE); }
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); MOVE(playerRight, MOVE_TACKLE, target: opponentRight); EXPECT_MOVE(opponentLeft, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_DOUBLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will not cycle Intimidate in doubles when both targets are special attackers")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_WATER_GUN); }
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Moves(MOVE_WATER_GUN); }
|
||||
OPPONENT(SPECIES_ARCANINE) { Ability(ABILITY_INTIMIDATE); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(playerLeft, MOVE_WATER_GUN, target: opponentLeft); MOVE(playerRight, MOVE_WATER_GUN, target: opponentRight); EXPECT_MOVE(opponentLeft, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will switch out if it has been Encore'd into a status move")
|
||||
{
|
||||
PASSES_RANDOMLY(SHOULD_SWITCH_ENCORE_STATUS_PERCENTAGE, 100, RNG_AI_SWITCH_ENCORE);
|
||||
|
|
@ -2301,3 +2400,16 @@ AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_MON_CHOICES: AI sees HP changes on switchin
|
|||
TURN { MOVE(player, MOVE_EMBER); EXPECT_MOVE(opponent, MOVE_SCRATCH); EXPECT_SEND_OUT(opponent, 2); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("Retaliate sees damage correctly for post ko switch in")
|
||||
{
|
||||
GIVEN {
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_GABITE) { Level(50); Speed(2);}
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Level(1); Speed(3); HP(1); Moves(MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_GROUDON) { Level(85); Speed(3); Moves(MOVE_PRECIPICE_BLADES); }
|
||||
OPPONENT(SPECIES_STOUTLAND) { Level(50); Speed(3); Moves(MOVE_RETALIATE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TACKLE); EXPECT_SEND_OUT(opponent, 2); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,76 @@
|
|||
#include "global.h"
|
||||
#include "test/battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(GetMoveEffect(MOVE_TRICK_ROOM) == EFFECT_TRICK_ROOM);
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Trick Room doesn't print its ending message twice when used again")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Speed(10); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Speed(1); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TRICK_ROOM); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_TRICK_ROOM); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRICK_ROOM, player);
|
||||
MESSAGE("Wobbuffet twisted the dimensions!");
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRICK_ROOM, player);
|
||||
MESSAGE("The twisted dimensions returned to normal!");
|
||||
NOT MESSAGE("The twisted dimensions returned to normal!");
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Trick Room reverses move order for 5 turns including the turn it is used")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Speed(10); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TRICK_ROOM); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRICK_ROOM, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Trick Room does not affect move priority")
|
||||
{
|
||||
GIVEN {
|
||||
ASSUME(GetMovePriority(MOVE_CELEBRATE) == 0);
|
||||
ASSUME(GetMovePriority(MOVE_QUICK_ATTACK) == 1);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Speed(1); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Speed(10); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_TRICK_ROOM); MOVE(opponent, MOVE_CELEBRATE); }
|
||||
TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_QUICK_ATTACK); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRICK_ROOM, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_QUICK_ATTACK, opponent);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
|
||||
}
|
||||
}
|
||||
|
||||
TO_DO_BATTLE_TEST("TODO: Write Trick Room (Move Effect) test titles")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ For a given species, a move is considered teachable to that species if:
|
|||
from itertools import chain
|
||||
from textwrap import dedent
|
||||
|
||||
import glob
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
|
|
@ -32,9 +31,9 @@ import sys
|
|||
import typing
|
||||
|
||||
|
||||
CONFIG_ENABLED_PAT = re.compile(r"#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)")
|
||||
ALPHABETICAL_ORDER_ENABLED_PAT = re.compile(r"#define HGSS_SORT_TMS_BY_NUM\s+(?P<cfg_val>[^ ]*)")
|
||||
TM_LITTERACY_PAT = re.compile(r"#define P_TM_LITERACY\s+GEN_(?P<cfg_val>[^ ]*)")
|
||||
CONFIG_ENABLED_PAT = re.compile(r"^#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)", flags=re.MULTILINE)
|
||||
ALPHABETICAL_ORDER_ENABLED_PAT = re.compile(r"^#define HGSS_SORT_TMS_BY_NUM\s+(?P<cfg_val>[^ ]*)", flags=re.MULTILINE)
|
||||
TM_LITERACY_PAT = re.compile(r"^#define P_TM_LITERACY\s+GEN_(?P<cfg_val>[^ ]*)", flags=re.MULTILINE)
|
||||
TMHM_MACRO_PAT = re.compile(r"F\((\w+)\)")
|
||||
SNAKIFY_PAT = re.compile(r"(?!^)([A-Z]+)")
|
||||
|
||||
|
|
@ -64,7 +63,7 @@ def extract_tm_litteracy_config() -> bool:
|
|||
config = False
|
||||
with open("./include/config/pokemon.h", "r") as cfg_pokemon_fp:
|
||||
cfg_pokemon = cfg_pokemon_fp.read()
|
||||
cfg_defined = TM_LITTERACY_PAT.search(cfg_pokemon)
|
||||
cfg_defined = TM_LITERACY_PAT.search(cfg_pokemon)
|
||||
if cfg_defined:
|
||||
cfg_val = cfg_defined.group("cfg_val")
|
||||
if ((cfg_val == "LATEST") or (int(cfg_val) > 6)):
|
||||
|
|
@ -193,14 +192,13 @@ def main():
|
|||
print(__doc__, file=sys.stderr)
|
||||
quit(1)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
SOURCE_DIR = pathlib.Path(sys.argv[1])
|
||||
elif len(sys.argv) == 3:
|
||||
if len(sys.argv) == 3:
|
||||
if sys.argv[1] != "--tutors":
|
||||
print("Unknown make_teachables mode", file=sys.stderr)
|
||||
quit(1)
|
||||
tutor_mode = True
|
||||
SOURCE_DIR = pathlib.Path(sys.argv[2])
|
||||
|
||||
SOURCE_DIR = pathlib.Path(sys.argv[-1])
|
||||
|
||||
with open("src/data/pokemon/special_movesets.json", "r") as file:
|
||||
special_movesets = json.load(file)
|
||||
|
|
@ -219,7 +217,6 @@ def main():
|
|||
assert SOURCE_TEACHING_TYPES_JSON.is_file(), f"{SOURCE_TEACHING_TYPES_JSON=} is not a file"
|
||||
|
||||
repo_tms = list(extract_repo_tms())
|
||||
order_alphabetically = False
|
||||
|
||||
with open("./include/config/pokedex_plus_hgss.h", "r") as cfg_pokemon_fp:
|
||||
cfg_pokemon = cfg_pokemon_fp.read()
|
||||
|
|
|
|||
|
|
@ -1,16 +1,24 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Usage: python3 make_teaching_types.py OUTPUT_FILE
|
||||
|
||||
Build a primary store of "teaching-types" for each enabled species in the repository as an
|
||||
input for make_teachables.py.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import typing
|
||||
|
||||
CONFIG_ENABLED_PAT = re.compile(r"#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)")
|
||||
CONFIG_ENABLED_PAT = re.compile(r"^#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)", flags=re.MULTILINE)
|
||||
|
||||
TEACHING_TYPE_PAT = re.compile(r"\s*\.teachingType\s*=\s*(?P<teaching_type>[A-Z_]+),")
|
||||
LEARNSET_PAT = re.compile(r"\s*\.teachableLearnset\s*=\s*s(?P<name>\w+?)TeachableLearnset")
|
||||
PREPROC_START_PAT = re.compile(r"#if(def)?\s+\w+")
|
||||
PREPROC_END_PAT = re.compile(r"#endif\s*(//\s*\w+)?")
|
||||
PREPROC_START_PAT = re.compile(r"^#if(def)?\s+\w+", flags=re.MULTILINE)
|
||||
PREPROC_END_PAT = re.compile(r"^#endif\s*(//\s*\w+)?", flags=re.MULTILINE)
|
||||
|
||||
def enabled() -> bool:
|
||||
"""
|
||||
|
|
@ -35,7 +43,7 @@ def extract_repo_species_data() -> list:
|
|||
pokemon_list = []
|
||||
teaching_type = "DEFAULT_LEARNING"
|
||||
file_list = sorted(glob.glob("src/data/pokemon/species_info/*_families.h"))
|
||||
file_list.append(pathlib.Path("./src/data/pokemon/species_info.h"))
|
||||
file_list.append("./src/data/pokemon/species_info.h")
|
||||
for families_fname in file_list:
|
||||
with open(families_fname, "r") as family_fp:
|
||||
species_lines = family_fp.readlines()
|
||||
|
|
@ -66,7 +74,7 @@ def extract_repo_species_data() -> list:
|
|||
teaching_type = match.group("teaching_type")
|
||||
return species_data
|
||||
|
||||
def add_whitesspaces(parsed_list) ->list:
|
||||
def add_whitesspaces(parsed_list) -> list:
|
||||
for i, item in enumerate(parsed_list):
|
||||
if i == 0:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Usage: python3 make_tutors.py OUTPUT_FILE
|
||||
|
||||
Build a primary store of move-tutors in the repository and what moves they teach.
|
||||
"""
|
||||
|
||||
from itertools import chain
|
||||
from textwrap import dedent
|
||||
|
||||
import glob
|
||||
import json
|
||||
|
|
@ -8,7 +15,7 @@ import re
|
|||
import sys
|
||||
import typing
|
||||
|
||||
CONFIG_ENABLED_PAT = re.compile(r"#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)")
|
||||
CONFIG_ENABLED_PAT = re.compile(r"^#define P_LEARNSET_HELPER_TEACHABLE\s+(?P<cfg_val>[^ ]*)", flags=re.MULTILINE)
|
||||
INCFILE_HAS_TUTOR_PAT = re.compile(r"special ChooseMonForMoveTutor")
|
||||
INCFILE_HAS_TUTOR_PAT2 = re.compile(r"chooseboxmon SELECT_PC_MON_MOVE_TUTOR")
|
||||
INCFILE_MOVE_PAT = re.compile(r"setvar VAR_0x8005, (MOVE_[A-Z_]*)")
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ Directive AsmFile::GetDirective()
|
|||
return Directive::Unknown;
|
||||
}
|
||||
|
||||
// Checks if we're at label that ends with '::'.
|
||||
// Returns the name if so and an empty string if not.
|
||||
std::string AsmFile::GetGlobalLabel()
|
||||
// Checks if we're at label and if so, returns its symbol and scope.
|
||||
// Returns 'label::none' if not.
|
||||
Label AsmFile::GetLabel()
|
||||
{
|
||||
long start = m_pos;
|
||||
long pos = m_pos;
|
||||
|
|
@ -175,14 +175,57 @@ std::string AsmFile::GetGlobalLabel()
|
|||
pos++;
|
||||
}
|
||||
|
||||
if (m_buffer[pos] == ':' && m_buffer[pos + 1] == ':')
|
||||
if (m_buffer[pos] == ':')
|
||||
{
|
||||
m_pos = pos + 2;
|
||||
ExpectEmptyRestOfLine();
|
||||
return std::string(&m_buffer[start], pos - start);
|
||||
std::string symbol(&m_buffer[start], pos - start);
|
||||
if (m_buffer[pos + 1] == ':')
|
||||
{
|
||||
m_pos = pos + 2;
|
||||
ExpectEmptyRestOfLine();
|
||||
return Label(symbol, Label::global);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pos = pos + 1;
|
||||
return Label(symbol, Label::local);
|
||||
}
|
||||
}
|
||||
|
||||
return std::string();
|
||||
return Label("", Label::none);
|
||||
}
|
||||
|
||||
std::string AsmFile::PeekSection()
|
||||
{
|
||||
long oldPos = m_pos;
|
||||
std::string section;
|
||||
|
||||
SkipWhitespace();
|
||||
|
||||
// TODO: Support 'pushsection', 'popsection', '.previous'.
|
||||
if (CheckForDirective(".bss"))
|
||||
{
|
||||
section = ".bss";
|
||||
}
|
||||
else if (CheckForDirective(".data"))
|
||||
{
|
||||
section = ".data";
|
||||
}
|
||||
else if (CheckForDirective(".rodata"))
|
||||
{
|
||||
section = ".rodata";
|
||||
}
|
||||
else if (CheckForDirective(".text"))
|
||||
{
|
||||
section = ".text";
|
||||
}
|
||||
else if (CheckForDirective(".section"))
|
||||
{
|
||||
SkipWhitespace();
|
||||
section = ReadIdentifier();
|
||||
}
|
||||
|
||||
m_pos = oldPos;
|
||||
return section;
|
||||
}
|
||||
|
||||
// Skips tabs and spaces.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,17 @@ enum class Directive
|
|||
Unknown
|
||||
};
|
||||
|
||||
struct Label
|
||||
{
|
||||
std::string symbol;
|
||||
enum Type { none, global, local } type;
|
||||
|
||||
Label() : symbol(""), type(none) {}
|
||||
Label(const Label&) = default;
|
||||
Label(std::string symbol_, Type type_) : symbol(symbol_), type(type_) {}
|
||||
explicit operator bool() { return !symbol.empty() && type != none; }
|
||||
};
|
||||
|
||||
class AsmFile
|
||||
{
|
||||
public:
|
||||
|
|
@ -43,7 +54,8 @@ public:
|
|||
AsmFile(const AsmFile&) = delete;
|
||||
~AsmFile();
|
||||
Directive GetDirective();
|
||||
std::string GetGlobalLabel();
|
||||
Label GetLabel();
|
||||
std::string PeekSection();
|
||||
std::string ReadPath();
|
||||
int ReadString(unsigned char* s);
|
||||
int ReadBraille(unsigned char* s);
|
||||
|
|
|
|||
|
|
@ -51,9 +51,11 @@ void PrintAsmBytes(unsigned char *s, int length)
|
|||
}
|
||||
}
|
||||
|
||||
void PreprocAsmFile(std::string filename, bool isStdin, bool doEnum)
|
||||
void PreprocAsmFile(std::string filename, bool isStdin, bool doEnum, bool doSize)
|
||||
{
|
||||
std::stack<AsmFile> stack;
|
||||
Label prevLabel;
|
||||
bool inScriptData = false;
|
||||
|
||||
stack.push(AsmFile(filename, isStdin, doEnum));
|
||||
std::printf("# 1 \"%s\"\n", filename.c_str());
|
||||
|
|
@ -62,6 +64,11 @@ void PreprocAsmFile(std::string filename, bool isStdin, bool doEnum)
|
|||
{
|
||||
while (stack.top().IsAtEnd())
|
||||
{
|
||||
const char *ps = prevLabel.symbol.c_str();
|
||||
if (doSize && inScriptData && prevLabel)
|
||||
std::printf(".ifdef %s ; .size %s, . - %s ; .endif\n", ps, ps, ps);
|
||||
prevLabel = Label();
|
||||
|
||||
stack.pop();
|
||||
|
||||
if (stack.empty())
|
||||
|
|
@ -100,15 +107,28 @@ void PreprocAsmFile(std::string filename, bool isStdin, bool doEnum)
|
|||
}
|
||||
case Directive::Unknown:
|
||||
{
|
||||
std::string globalLabel = stack.top().GetGlobalLabel();
|
||||
Label label = stack.top().GetLabel();
|
||||
|
||||
if (globalLabel.length() != 0)
|
||||
if (label)
|
||||
{
|
||||
const char *s = globalLabel.c_str();
|
||||
std::printf("%s: ; .global %s\n", s, s);
|
||||
const char *s = label.symbol.c_str();
|
||||
const char *ps = prevLabel.symbol.c_str();
|
||||
|
||||
if (doSize && inScriptData && prevLabel)
|
||||
std::printf(".ifdef %s ; .size %s, . - %s ; .endif ; ", ps, ps, ps);
|
||||
|
||||
if (label.type == Label::global)
|
||||
std::printf(".global %s\n%s:\n", s, s);
|
||||
|
||||
prevLabel = label;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string section = stack.top().PeekSection();
|
||||
if (section == "script_data")
|
||||
inScriptData = true;
|
||||
else if (section != "")
|
||||
inScriptData = false;
|
||||
stack.top().OutputLine();
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +167,7 @@ const char* GetFileExtension(const char* filename)
|
|||
|
||||
static void UsageAndExit(const char *program)
|
||||
{
|
||||
std::fprintf(stderr, "Usage: %s [-i] [-e] SRC_FILE CHARMAP_FILE\nwhere -i denotes if input is from stdin\n -e enables enum handling\n", program);
|
||||
std::fprintf(stderr, "Usage: %s [-i] [-e] [-s] SRC_FILE CHARMAP_FILE\nwhere -i denotes if input is from stdin\n -e enables enum handling\n -s enables '.size' handling\n", program);
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -158,9 +178,10 @@ int main(int argc, char **argv)
|
|||
const char *charmap = NULL;
|
||||
bool isStdin = false;
|
||||
bool doEnum = false;
|
||||
bool doSize = false;
|
||||
|
||||
/* preproc [-i] [-e] SRC_FILE CHARMAP_FILE */
|
||||
while ((opt = getopt(argc, argv, "ie")) != -1)
|
||||
/* preproc [-i] [-e] [-s] SRC_FILE CHARMAP_FILE */
|
||||
while ((opt = getopt(argc, argv, "ies")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -170,6 +191,9 @@ int main(int argc, char **argv)
|
|||
case 'e':
|
||||
doEnum = true;
|
||||
break;
|
||||
case 's':
|
||||
doSize = true;
|
||||
break;
|
||||
default:
|
||||
UsageAndExit(argv[0]);
|
||||
break;
|
||||
|
|
@ -196,7 +220,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
{
|
||||
PreprocAsmFile(source, isStdin, doEnum);
|
||||
PreprocAsmFile(source, isStdin, doEnum, doSize);
|
||||
}
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user