Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createmon Script Cmd, Support for 2v1Wild Battles #4688

Merged
merged 6 commits into from
Jun 13, 2024

Conversation

ghoulslash
Copy link
Collaborator

@ghoulslash ghoulslash commented Jun 1, 2024

NOTE this requires a clean make to update all instances of givemon

Adds support for setting up 2v1 wild battles. It does this by adding 2 new script commands:

  1. createmon - this is the same setup as givemon but allows you to create the mon at a given side (0 for player, 1 for opponent) and slot (0-5). ScriptGiveMonParameterized has also been updated to handle a given slot/side. If slot = PARTY_SIZE, it will give the mon as normal
  2. setwilddoubleflag just sets sIsScriptedWildDouble, so in the example script below we can initiate a battle where the player has 2 mons and there is only 1 opponent

Example script:

    givemon SPECIES_TYRANITAR, 50
    givemon SPECIES_METAGROSS, 50
    
    createmon 1, 0, SPECIES_SALAMENCE, 50, ITEM_KINGS_ROCK, 0, NATURE_HARDY, 0, MON_MALE
    setwilddoubleflag
    dowildbattle

pokeemerald-0

But we could also create multiple enemy mons to set up a more advanced 2v2 wild battle

…mons at given player or enemy slots and setting up 2v1 battles
@@ -987,7 +987,9 @@
@ Gives the player a Pokémon of the specified species and level, and allows to customize extra parameters.
@ VAR_RESULT will be set to MON_GIVEN_TO_PARTY, MON_GIVEN_TO_PC, or MON_CANT_GIVE depending on the outcome.
.macro givemon species:req, level:req, item, ball, nature, abilityNum, gender, hpEv, atkEv, defEv, speedEv, spAtkEv, spDefEv, hpIv, atkIv, defIv, speedIv, spAtkIv, spDefIv, move1, move2, move3, move4, isShiny, ggMaxFactor, teraType
callnative ScrCmd_givemon
callnative ScrCmd_createmon
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct that both script commands are named ScrCmd_createmon?

Also is there a way to combine both scripts since most of it is the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both just call the same function which I edited to handle the addition inputs.

As far as using the same macros.. I don't think so since most are optional, but I could be wrong

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both just call the same function which I edited to handle the addition inputs.

Right.

Though for some reason the CI fails for tests without having run any tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both just call the same function which I edited to handle the addition inputs.

Right.

Though for some reason the CI fails for tests without having run any tests

yeah I don't get that... its saying PARTY_SIZE is undefined, but global.h is included which includes constants/global.h where that is defined...

@ghoulslash
Copy link
Collaborator Author

I've tried including and redefining PARTY_SIZE in a few places with no luck - I'm thinking of just changing .byte PARTY_SIZE to .byte 6 with a comment about PARTY_SIZE next to it to resolve the issue if that is acceptable

@AlexOn1ine
Copy link
Collaborator

I've tried including and redefining PARTY_SIZE in a few places with no luck - I'm thinking of just changing .byte PARTY_SIZE to .byte 6 with a comment about PARTY_SIZE next to it to resolve the issue if that is acceptable

I would do that unless someone has an idea what's going on.

asm/macros/event.inc Outdated Show resolved Hide resolved
asm/macros/event.inc Outdated Show resolved Hide resolved
asm/macros/event.inc Outdated Show resolved Hide resolved
src/script_pokemon_util.c Outdated Show resolved Hide resolved
src/script_pokemon_util.c Outdated Show resolved Hide resolved
src/script_pokemon_util.c Outdated Show resolved Hide resolved
src/script_pokemon_util.c Outdated Show resolved Hide resolved
src/script_pokemon_util.c Outdated Show resolved Hide resolved
@ghoulslash
Copy link
Collaborator Author

ready for review

Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The givemon macro now replaces the first slot mon in the party when you receive it.

Test to verify it:

TEST("givemon twice [simple]")
{
    ZeroPlayerPartyMons();

    RUN_OVERWORLD_SCRIPT(
        givemon SPECIES_WOBBUFFET, 100;
        givemon SPECIES_WYNAUT, 1;
    );

    EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_WOBBUFFET);
    EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_LEVEL), 100);

    EXPECT_EQ(GetMonData(&gPlayerParty[1], MON_DATA_SPECIES), SPECIES_WYNAUT);
    EXPECT_EQ(GetMonData(&gPlayerParty[1], MON_DATA_LEVEL), 10);
}

Could you also add it to the PR once fixed? Also could you make tests for createmon the same way they are done for givemon?

You can just check the enemy party. Here is the simple one:

TEST("createmon [simple]")
{
    ZeroPlayerPartyMons();

    RUN_OVERWORLD_SCRIPT(
        createmon 1, 0, SPECIES_WOBBUFFET, 100;
        createmon 1, 1, SPECIES_WYNAUT, 10;
    );

    EXPECT_EQ(GetMonData(&gEnemyParty[0], MON_DATA_SPECIES), SPECIES_WOBBUFFET);
    EXPECT_EQ(GetMonData(&gEnemyParty[0], MON_DATA_LEVEL), 100);
    EXPECT_EQ(GetMonData(&gEnemyParty[1], MON_DATA_SPECIES), SPECIES_WYNAUT);
    EXPECT_EQ(GetMonData(&gEnemyParty[1], MON_DATA_LEVEL), 10);
}

The tests are in test/pokemon.c

@ghoulslash
Copy link
Collaborator Author

The givemon macro now replaces the first slot mon in the party when you receive it.

Test to verify it:

TEST("givemon twice [simple]")
{
    ZeroPlayerPartyMons();

    RUN_OVERWORLD_SCRIPT(
        givemon SPECIES_WOBBUFFET, 100;
        givemon SPECIES_WYNAUT, 1;
    );

    EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_SPECIES), SPECIES_WOBBUFFET);
    EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_LEVEL), 100);

    EXPECT_EQ(GetMonData(&gPlayerParty[1], MON_DATA_SPECIES), SPECIES_WYNAUT);
    EXPECT_EQ(GetMonData(&gPlayerParty[1], MON_DATA_LEVEL), 10);
}

Its working in game...
pokeemerald-0

It looks like your test fails because your giving a level 1 Wynaut but checking that its level 10

Could you also add it to the PR once fixed? Also could you make tests for createmon the same way they are done for givemon?

Sure, just added

@AlexOn1ine
Copy link
Collaborator

That's weird. It doesn't work for me ingame. That's how I found it out.

givemon SPECIES_LATIOS, 100, nature=NATURE_HARDY
createmon.mp4

@AlexOn1ine
Copy link
Collaborator

Also just realized this supersedes setwildbattle. Should we get rid of it in this case?

@ghoulslash
Copy link
Collaborator Author

That's weird. It doesn't work for me ingame. That's how I found it out.

givemon SPECIES_LATIOS, 100, nature=NATURE_HARDY

createmon.mp4

weird... this is what I've tried and it worked

givemon SPECIES_TYRANITAR, 50
    givemon SPECIES_METAGROSS, 50, nature=NATURE_MODEST

You might have to make clean if you haven't previously?

@AlexOn1ine
Copy link
Collaborator

AlexOn1ine commented Jun 13, 2024

Also just realized this supersedes setwildbattle. Should we get rid of it in this case?

@ghoulslash what you think about this? We've retired the old givemon macro as well.

@AlexOn1ine
Copy link
Collaborator

That's weird. It doesn't work for me ingame. That's how I found it out.

givemon SPECIES_LATIOS, 100, nature=NATURE_HARDY

createmon.mp4

weird... this is what I've tried and it worked

givemon SPECIES_TYRANITAR, 50
    givemon SPECIES_METAGROSS, 50, nature=NATURE_MODEST

You might have to make clean if you haven't previously?

make clean worked but it is very odd. could you mentioned it in the description?

@ghoulslash
Copy link
Collaborator Author

ghoulslash commented Jun 13, 2024

Also just realized this supersedes setwildbattle. Should we get rid of it in this case?

@ghoulslash what you think about this? We've retired the old givemon macro as well.

not sure. On the one hand setwildbattle would not be needed, but I don't like the idea of current users needing to go back and update old scripts to handle the change. Because setwildbattle can set a single or double battle I don't think there's a way to make setwildbattle just call createmon, either. So I'm leaning towards keeping setwildbattle.
A bigger consideration is that setwildbattle calls ZeroEnemyPartyMons whereas createmon cannot

@AlexOn1ine
Copy link
Collaborator

Also just realized this supersedes setwildbattle. Should we get rid of it in this case?

@ghoulslash what you think about this? We've retired the old givemon macro as well.

not sure. On the one hand setwildbattle would not be needed, but I don't like the idea of current users needing to go back and update old scripts to handle the change. Because setwildbattle can set a single or double battle I don't think there's a way to make setwildbattle just call createmon, either. So I'm leaning towards keeping setwildbattle. A bigger consideration is that setwildbattle calls ZeroEnemyPartyMons whereas createmon cannot

that's fair

@AlexOn1ine AlexOn1ine merged commit 353727a into rh-hideout:upcoming Jun 13, 2024
1 check passed
@ghoulslash ghoulslash deleted the be/2v1 branch June 13, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants