• 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.

Encounters Script

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
I've looked into encounters, script and encounters.txt and stuff and looked at the Wiki on this, but, I see adding a Water or Cave encounter, causes the game to have no encounters at all, because in the scripts, it has to return a water or cave encounter... Is there any way to add a Water or Cave encounter at all, the Wiki only covers grass encounters, which is the easiest thing to work out anyway... I don't like the way all the encounters are at the moment, and I'm changing them all to what fits my game and my vision of what I want to achieve, but, this Water, Cave encounter thing has me in a pickle.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Are you saying you want to define a new encounter method, but for use in caves/surfing instead of grass?

All encounter methods are defined the same way, as described on the wiki. The important part is deciding when to use your new method rather than an existing one. I would suggest you look at the existing methods, and squeeze yours in somewhere that makes sense.

It's certainly possible to do, although if you want actual help you're going to have to provide more information.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
Yeah, new Cave and Water encounters...

So are you saying, instead of putting it where "return" is, I just put it underneath the grass encounter?

Also, on a side note, a quick question on how to use a different sprite, if I use 001, as the original front sprite, but when a certain switch is on, it should use 001_1, how would I go about this? I had this done before, but I seem to have lost this and now I can't work this out again!
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
You would define your new method in the same way as described on the wiki. The difference comes in how you enable it, although it's barely any different at all.

For cave encounters, edit def isCave? and def pbEncounterType. For water encounters, edit def pbEncounterType (def isWater? isn't used anywhere; instead it just checks whether you're surfing). Without knowing exactly how you want to use your new encounter methods, I can't say how you would edit pbEncounterType (and I probably wouldn't anyway because it's simple enough to figure out on your own).

I don't know what you're talking about when you refer to "return".



To change the Pokémon sprite used to depend on a switch, edit something in pbLoadPokemonBitmapSpecies.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
Code:
  def pbEncounterType
    if $PokemonGlobal && $PokemonGlobal.surfing
      return EncounterTypes::Water
    elsif self.isCave?
      return EncounterTypes::Cave
    elsif self.isGrass?
      time=Time.now
      enctype=EncounterTypes::Land
      enctype=EncounterTypes::Land4
      enctype=EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
      enctype=EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
      enctype=EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)

This is my pbEncounterType, at the minute, I will completely change this soon enough... But what I'm doing, is:

Obviously, Land4, (don't ask me why I used 4 instead of 1 or 2 haha) isn't an encouter type, so I've clearly created this myself, but this new encounter method has allowed me to use less work in encounters.txt (I hate having to use 12 lines to have Pidgey and Rattata appear on Route 01), this is why I'm creating new types, so this new method allows me to do exactly the same thing, but with the ability to just use;

Land4
PIDGEY,1,5
RATTATA,1,5

With the same outcome, I've also added a new feature where Pokémon are really really rare, meaning, it could take days or minutes to find them, due to trades obviously being unavailable at this time, I needed a new way to find a certain Pokémon.

However, if at any point I wanted to have 12 different encounters, I suppose mainly later in the game, I would just use the Land encounter type...

Land4 though, works, but any Cave or Water encounter causes the game to have no encounters at all... But notice, both cave and Water has a return value as land does not.

I have also edited isCave?, isGrass? and isWater?.

So for Cave and Water, I can't add return EncounterTypes::Water4, as it doesn't do anything in-game, at all...

I think I've covered everything to do with my encounters, if you need more information, let me know.

As for the pbLoadPokemonBitmapSpecies, I figured that's where I would edit, but I'm pretty sure I didn't do that before, but was just checking to make sure I didn't waste my time on it.

 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
If you look 6 lines below the code you quoted, you'll see return enctype. There's no difference in how it works; it all returns something eventually. Try copying that in the surfing/cave parts, rather than immediately returning something.

Note that, with the code you've shown, the "Land" method will never be used, as it is immediately and always overridden by "Land4". You should put a if self.hasEncounter?(EncounterTypes::Land4) on the end or something.

Doing this seems rather pointless to me, but if you do really hate filling up 12 slots when you only have 2 different species, then whatever. Remember that you can use the extra slots to make some levels of the species more common than other levels.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
I know this idea probably seems silly to you, but I have my reasons and yes, throwing 5 RATTATA from Level 1-2, 2-4, 1-3, 3, 3-4, onto a route when I could just simply stick 1 RATTATA Level 1-4 and have that pan out, seems the same, just less work, we all do things differently I suppose, I don't mind what levels are found, after all, it's unlikely I'm going to put a rare level 6 Rattata in an area with puney level 1-4's...

I battled 15 times with the orignal land and my new way... I now have 4 different rare counters, unique to my game and splits it from the rest, and I may add more, not too sure yet;

Common
Uncommon
Rare
More Rare
(I'm floating between: super, elite, ultra, epic and legendary. So until I work some things out, "more" is what I'm using.)

I play tested both these methods the same, used the same Pokémon (Level 11 Butterfree, Tackle, String Shot, Confusion, Harden), same amount of battles (15), same Wild Pokémon (Bulbasaur, Charmander, Squirtle, Pikachu, Dratini):

Spoiler:


The oringinal Land encounter in 15 battles, I encountered, 5 Bulbasaur, 5 Charmander, 2 Squirtle, 2 Pikachu, 1 Dratini... This is as clear as day that you will encounter the 20/100 more often than any other, but because there are more 10/100 encounters to be made, ironically, this equalled the highest end result, but, Dratini appeared once and Pikachu appeared twice.

My new way in 15 battles, I enountered, 8 Charmander, 5 Bulbasaur, 1 Squirtle, 1 Pikachu... However, Dratini didn't appear (I actually continued to play after this to see, IF, I used 20 battles instead, would I of found a Dratini, but 6 levels, 20 minutes and 30+ encounters later, I saw 1 Squirtle, the rest were Bulbasaur and Charmander)... So evidentally my way makes Pokémon more rare... I hope this makes sence on what I'm trying to achieve... Maybe this is the, "more information" you needed to understand what I'm doing.

Right, I took a look at the script myself and I see not using if self.hasEncounter, causes a problem, I added a new encounter method and they both work fine, so this probably would of fixed that, if I added an encounter I would of seen this, but thanks for saving me some time... I'll look into Caves and Water battles now.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Some (including myself) would say that having just 15 encounters is not statistically significant, and that you'd need to have at least 300 encounters before seeing the actual rarities appear. The "Land" encounter method really would give just a 2% chance of encountering a Dratini - you happened to be lucky to encounter one in your 15 tries with it.

How about Rumour for the really rare? As in, species X is rumoured to have been seen in this place.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
That's a good idea to have "rumour", it's a clever way to go too, thanks.

Yeah, but I literally did a quick 15 battle test and I did think it was lucky to of seen Dratini when I did, but the fact is, it did appear on the second battle, and if Dratini was as Legendary as it is supposed to be, seeing him almost immediately is not the look I am going for, I do understand however that if I did battle 300+ times I don't deny for a minute Dratini would only appear very fewer times, but in every game that I have played or my game when the encounters were how they were, I didn't take long for me to find the "rarest" Pokémon in that area.

On another note, without making a new thread when I have one here already.

I want a Pokémon to have a different battle front, when it is evolving, I don't really want to show what I'm doing as it's a secret revealed during game, I don't mind PM'ing you about it, but not here.

So yeah, I want the Pokémon to have it's original battle front when battling and viewing in the summary screen and stuff, but when it evolves, I want a different battle front to appear, how would I go about doing this? I'm having such a mare with this, I can either get the new picture to show but causes an error, soemthign to do with "width", sometimes it errors by keeping the original battle front, but animating it's evolved form (spinning it around), I know you answered this before, but I think that was for if I wanted to use a different sprite for battles, when I need it for Evolution.

If you want me to show you what I'm doing, let me know and I'll PM you.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
I suppose you could have a variable which counts the number of encounters you've had on the current map, and then use it to decide which encounter method you use. For example, if the variable is between 0 and 20, then always use "Land". If between 21 and 40, 5% chance of using "Land4" instead. And so on. Remember to reset the variable when moving between maps.

I'm a bit curious as to what you're doing with the evolving, but I'll answer here. In the script section PokemonEvolution is the def pbStartScreen. In there are two lines, one including setPokemonBitmap and the other including setPokemonBitmapSpecies. Immediately after these lines you would need to change rsprite1.bitmap and rsprite2.bitmap to something else for your changed evolutions. It's best to create a new def for this, and call it for each of the two sprites (with the sprite as a parameter).

If you want a better explanation, PM me. Knowing your plans would help (e.g. do you want to change many evolutions or just a couple?).
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
I see with the variable thing, but I will probably not go down this route for a lot of encounters I could possibly use this however to use swarms and stuff, right? Although I'm pretty sure there is already a swarm script available...

Actually, in saying this, you have given me an idea.

I suppose it could also work with different hours of the day a certain Pokémon will come out to play... Hey that rhymes... I may look into this a bit more.

I PM'd you by the way.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
The variable stuff can indeed be the basis of swarming encounters. Personally I wouldn't use extra encounter methods for them, but instead just have a big array of swarmers to choose from (the variable decides which swarmer is available that day). There's no existing swarming script in Essentials.

The existing encounter methods "LandMorning", "LandDay" and "LandNight" are very much the embodiment of Pokémon that can only be encountered at certain times of day.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
Oh okay, I get it.

Well I didn't mean say day and night encounters etc. I meant for say, a rare were Dunsparce for example, but I wanted them to swarm, this would make them therefore, common, if you understand that haha.

I'll look at you PM now by the way, I've only just come online.

Something I've wanted to know since you brought it up too, was:

Is it possible to say "hide" a Pokémon from the town map depending on it's rareness and wether or not you have encountered the Pokémon yourself as opposed to seeing it VIA a trainer? The problem with this, is, my PokéDex/battles work different, you can battle the Pokémon now but ask questions later (I.e. Battle any Pokémon WITHOUT registering that species to the PokéDex).
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Oh okay, I get it.

Well I didn't mean say day and night encounters etc. I meant for say, a rare were Dunsparce for example, but I wanted them to swarm, this would make them therefore, common, if you understand that haha.
I didn't really understand that, no. You just want swarming Pokémon?


Is it possible to say "hide" a Pokémon from the town map depending on it's rareness and wether or not you have encountered the Pokémon yourself as opposed to seeing it VIA a trainer? The problem with this, is, my PokéDex/battles work different, you can battle the Pokémon now but ask questions later (I.e. Battle any Pokémon WITHOUT registering that species to the PokéDex).
It's possible to set up swarming Pokémon in such a way that their swarming locations aren't shown on the Area map. Only Pokémon listed in encounter methods (in encounters.txt) are shown on the Area map, so you could put the swarmers elsewhere.

At the moment the Area map will always show all locations a particular species can be encountered. It is possible to make the locations shown depend on something (its rarity/how it was encountered), but that would involve a major change to how it works. There are two versions to how it could work - either show all locations only when a certain switch is on (like how the $Trainer.seen array decides to show the species at all in the Pokédex), or record each location separately when you encounter it in the wild (record the current map's ID in an array and use those to show the points on the Area map).

The latter version is basically "fill it in as you go along", and I've got a feeling that's what you want. The "hide it anyway if it's rare" thing is probably just you wanting to omit swarmers, which is done automatically by the way swarmers are set up anyway.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
You're right, the "fill it as you go along" is what I'm looking for, so the top bit is irrelevent as you have covered it.

So what you're saying is, I record:

MAPID = 001, from the encounters.txt, where the list of Pokémon are, and each one that is found, say:

PIDGEY=false
RATTATA=false
ONIX=false
MEW=false

But when they are encountered, it would return that Pokémon as true and therefore show up on the Area Map, right?

Because as I'm aware, the area map cannot find a Pokémon you haven't seen, but with editing, instead of it saying .seen, it would be .encountered, or something of the sort anyway.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
That's a rather unwieldy way of doing it.

No, you make an array called $Trainer.seenmaps. It looks the same as $Trainer.seen (i.e. one entry per species), but instead of each entry being a boolean (true/false), it is instead an array itself containing the map IDs of all maps on which that species has been encountered. They start off empty, of course.

When a Pokémon is encountered, the current map's ID is added to that species' array entry, if the map ID isn't already in there.

When it comes to the Area map, instead of scanning through all the maps and looking at their encounter data, it should instead simply look at the appropriate entry in the array, and for every map number listed for that species, plot a point (if it's in the correct region, of course). This is the most complex part, but it's not that difficult.
 
Back
Top