Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2021-10-20 12:17:27

nightbringer
Member
Registered: 2021-08-18
Post 5/10

Creating a 'Search Party for Type' Function

In pokecrystal, there are places where what happens in the game is conditional upon the pokemon in your party. For instance, if you show Elm that you have Togepi in your party, you can get an item. If you show the Battle Tower clerk that your party doesn't duplicate items, you can enter. These pre-existing functions can search your party for a particular species or for the items they are holding.

But what I want to do is create a function that searches your party for particular types, like the rock type, grass type etc. The idea here is that I want the player to have certain battles they can only enter if they do not bring with them particular pokemon types. E.g., there might be a hard version of Falkner you can only face if you don't have any rock, electric, or ice types in your party.

I'm still quite new to assembly, so I was hoping to be able to base the code off a pre-existing search script. For instance, the script for searching your party for a particular species is found in engine/pokemon/search2.asm, and it begins like this:

_FindPartyMonThatSpecies:
ld hl, wPartyMon1Species
jp FindThatSpecies

Sadly, I'm getting stuck at the first hurdle. I'm not aware of any pre-existing equivalent of wPartyMon1Species for types. And I can't find where wPartyMon1Species is defined to try and create an equivalent.

Would anyone be able to help with at least some of the first steps of creating this search function?

Much appreciation in advance for any help offered.

Offline

#2 2021-10-20 19:51:07

nightbringer
Member
Registered: 2021-08-18
Post 6/10

Re: Creating a 'Search Party for Type' Function

One approach I thought of was to create a manual list of, say, Rock Types, like:

RockMons:
db GEODUDE
db ONIX
db KABUTO

... etc

Then I could compare the species of the player's party mon to this list. I thought the following script might work in engine/events/specials.asm:

CheckForRockTypes:
ld a, [wPartyMon1Species]
ld hl, RockMons
ld de, 1
call IsInArray
ret
jr nc, FoundNone
jr FoundOne

Or at least, it would check the first pokemon in the player's party for the rock type, and then I could figure out how to check the rest of the party from there.

But having tested it, the script doesn't seem to work.

Any ideas where it might be going wrong?

Last edited by nightbringer (2021-10-20 19:52:37)

Offline

Board footer

Powered by FluxBB