- 115
- Posts
- 15
- Years
- Seen Sep 4, 2023
Hello everyone,
I recently added ShallowWater as a terraintag and with it an associated encounter method. It is working fine, the background is changing accordingly and so on, the intended pok?mon do show up in the Shallow Water.
However, since I added it, I started finding Land encounters outside of the grass! I'm struggling to understand why, since I didn't touch anything related to grass. I'll post here the modifications I did. Can you help me figure out what went wrong?
My modifications to fresh essentials are in yellow, the rest is untouched.
The TerraingTag: in PBTerrain I added
In PFieldEncounter I added
Also for the battle background I modified PField_Battles
and modified def pbBackdrop in PokeBattle_Scene to include ShallowWater in water graphics of bases
What should be the correct way of adding this without messing up anything else?
Figured out the correct modification and altered the code here accordingly in case someone attempts to do the same.
Thanks a lot!
I recently added ShallowWater as a terraintag and with it an associated encounter method. It is working fine, the background is changing accordingly and so on, the intended pok?mon do show up in the Shallow Water.
My modifications to fresh essentials are in yellow, the rest is untouched.
The TerraingTag: in PBTerrain I added
Code:
module PBTerrain
[...]
[S-HIGHLIGHT] ShallowWater = 17 #modification[/S-HIGHLIGHT]
[...]
[S-HIGHLIGHT] def PBTerrain.isShallowWater?(tag)
return tag==PBTerrain::ShallowWater
end[/S-HIGHLIGHT]
In PFieldEncounter I added
Code:
module EncounterTypes
[...]
[S-HIGHLIGHT] ShallowWater = 13 #modification[/S-HIGHLIGHT]
Names = [
[...]
[S-HIGHLIGHT] "ShallowWater"[/S-HIGHLIGHT]
]
EnctypeChances = [
[...]
[S-HIGHLIGHT] [60,30,5,4,1] [/S-HIGHLIGHT]
]
EnctypeDensities = [25,10,10,0,0,0,0,0,0,25,25,25,25,[S-HIGHLIGHT]10[/S-HIGHLIGHT]]
EnctypeCompileDens = [ 1, 2, 3,0,0,0,0,0,0, 1, 1, 1, 1,[S-HIGHLIGHT]3[/S-HIGHLIGHT]]
end
class PokemonEncounters
[...]
[S-HIGHLIGHT] def isShallowWater? #modification
return false if @density==nil
return @enctypes[EncounterTypes::ShallowWater] ? true : false
end[/S-HIGHLIGHT]
[...]
def pbEncounterType
if $PokemonGlobal && $PokemonGlobal.surfing
return EncounterTypes::Water
[S-HIGHLIGHT] elsif PBTerrain.isShallowWater?(pbGetTerrainTag($game_player)) #modification
return EncounterTypes::ShallowWater[/S-HIGHLIGHT]
elsif PBTerrain.isIce?(pbGetTerrainTag($game_player))
return false
[...]
def isEncounterPossibleHere?
if $PokemonGlobal && $PokemonGlobal.surfing
return true
[S-HIGHLIGHT] elsif PBTerrain.isShallowWater?(pbGetTerrainTag($game_player)) #modification
return true[/S-HIGHLIGHT]
elsif PBTerrain.isIce?(pbGetTerrainTag($game_player))
return false
elsif self.isCave?
return true
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
end
return false
end
Code:
def pbGetEnvironment
return PBEnvironment::None if !$game_map
if $PokemonGlobal && $PokemonGlobal.diving
return PBEnvironment::Underwater
elsif $PokemonEncounters && $PokemonEncounters.isCave?
return PBEnvironment::Cave
elsif !pbGetMetadata($game_map.map_id,MetadataOutdoor)
return PBEnvironment::None
else
case $game_player.terrain_tag
when PBTerrain::Grass; return PBEnvironment::Grass # Normal grass
when PBTerrain::Sand; return PBEnvironment::Sand
when PBTerrain::Rock; return PBEnvironment::Rock
when PBTerrain::DeepWater; return PBEnvironment::MovingWater
when PBTerrain::StillWater; return PBEnvironment::StillWater
when PBTerrain::Water; return PBEnvironment::MovingWater
when PBTerrain::TallGrass; return PBEnvironment::TallGrass # Tall grass
when PBTerrain::SootGrass; return PBEnvironment::Grass # Sooty tall grass
when PBTerrain::Puddle; return PBEnvironment::StillWater
[S-HIGHLIGHT] when PBTerrain::ShallowWater; return PBEnvironment::MovingWater #modification[/S-HIGHLIGHT]
end
end
return PBEnvironment::None
end
Code:
# Choose bases
base=""
trialname=""
if environ==PBEnvironment::Grass || environ==PBEnvironment::TallGrass
trialname="Grass"
elsif environ==PBEnvironment::Sand
trialname="Sand"
elsif $PokemonGlobal.surfing [S-HIGHLIGHT]|| environ==PBEnvironment::MovingWater #modification[/S-HIGHLIGHT]
trialname="Water"
end
Figured out the correct modification and altered the code here accordingly in case someone attempts to do the same.
Thanks a lot!
Last edited: