• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

NPC lets you past only if your party passes a type restriction check

1
Posts
9
Years
  • Age 34
  • Seen Jan 8, 2015
Hello, I've found a slight block in my attempts at game making (If this has already been posted by someone else, I apologize as I couldn't find one)

I'm trying to make an event where a person only let's you pass if all the pokemon on your team are of a specific type (Also looking for an enforced monotype challenge in the game)

But I can't work out what to put in the event.
 
119
Posts
10
Years
  • Seen Sep 1, 2023
I don't believe something like this exists yet, though I believe the code below should do the trick.

To use this in events; add a conditional branch, look on page 4 and type the following in the script section;
- To check if the player has a fire Pokémon in the party add: "pbTypeInParty(:FIRE) > 0"
- To check if the player only has fire Pokémon in the party add: "pbTypeInParty(:FIRE) == 2"
For any other type just replace "FIRE" with that type (make sure it's in all caps and not to remove the ":").

Add the code below to the bottom of PokemonUtilities;

Code:
# by Function which checks if the player has pokemon of a type in the party;
# returns: 0 if not, 1 if some, 2 if entire party
# use in conditional branch script; "pbTypeInParty(:FIRE) > 0"
# by Badhaas
def pbTypeInParty(type)
  magicnumber = 0
  for i in 0...$Trainer.party.length
    magicnumber += 1 if $Trainer.party[i].hasType?(type)
  end
  if magicnumber > 0
    magicnumber = 1 if magicnumber < $Trainer.party.length
    magicnumber = 2 if magicnumber == $Trainer.party.length
  end
  return magicnumber
end

NOTE: Copying code from the PokéCommunity forum might still be broken, to get the correct code use 'Threat Tools' and click on 'Show printable version'.
 
1
Posts
10
Years
  • Seen Aug 7, 2017
Thank you for your help!

I've tested it out and it works perfectly! :)
 
Back
Top