- 1
- Posts
- 1
- Years
- Seen Oct 1, 2024
Hi, i need help with the code i trying to add more land grass named: Landtw I'm trying to add two types of encounters in two different grasses on the same map
This is my code:
TerrainTag:
module GameData
class TerrainTag
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :can_surf
attr_reader :waterfall # The main part only, not the crest
attr_reader :waterfall_crest
attr_reader :can_fish
attr_reader :can_dive
attr_reader :deep_bush
attr_reader :shows_grass_rustle
attr_reader :land_wild_encounters
attr_reader :landtw_wild_encounters
more code..
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number]
@real_name = hash[:id].to_s || "Unnamed"
@can_surf = hash[:can_surf] || false
@waterfall = hash[:waterfall] || false
@waterfall_crest = hash[:waterfall_crest] || false
@can_fish = hash[:can_fish] || false
@can_dive = hash[:can_dive] || false
@deep_bush = hash[:deep_bush] || false
@shows_grass_rustle = hash[:shows_grass_rustle] || false
@land_wild_encounters = hash[:land_wild_encounters] || false
@landtw_wild_encounters = hash[:landtw_wild_encounters] || false
more code...
GameData::TerrainTag.register({
:id => :Landtw,
:id_number => 18,
:shows_grass_rustle => true,
:landtw_wild_encounters => true,
:battle_environment => :Grass
})
EncounterType:
GameData::EncounterType.register({
:id => :Landtw,
:type => :landtw,
:trigger_chance => 21
})
Overworld_WildEncounters:
def encounter_type
time = pbGetTimeNow
ret = nil
if $PokemonGlobal.surfing
ret = find_valid_encounter_type_for_time(:Water, time)
else # Land/Cave (can have both in the same map)
if has_land_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).land_wild_encounters
ret = :BugContest if pbInBugContest? && has_encounter_type?(:BugContest)
ret = find_valid_encounter_type_for_time(:Land, time) if !ret
end
if has_landtw_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).landtw_wild_encounters
ret = find_valid_encounter_type_for_time(:Landtw, time) if !ret
end
if !ret && has_cave_encounters?
ret = find_valid_encounter_type_for_time(:Cave, time)
end
end
return ret
end
Encounters.txt
#-------------------------------
[056] # Ciudad Verde / Ruta 2-22
Landtw,21
20,BULBASAUR,5
It is added in grass with id 18 with that pokemon encounter there is no error just nothing happens.
I'm new and it's my first time editing code I hope your help
thank you so much.
Update:
if i add another encounter to standard id grass (2) and other grass (18) in same map i get this:
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.5]
Exception: NoMethodError
Message: undefined method `has_landtw_encounters?' for #<PokemonEncounters>
Backtrace:
Overworld_WildEncounters:261:in `encounter_type'
Overworld:200:in `pbBattleOnStepTaken'
Overworld:193:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Game_Player:183:in `turn_generic'
Game_Character:825:in `turn_right'
Game_Player:448:in `update_command_new'
This is my code:
TerrainTag:
module GameData
class TerrainTag
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :can_surf
attr_reader :waterfall # The main part only, not the crest
attr_reader :waterfall_crest
attr_reader :can_fish
attr_reader :can_dive
attr_reader :deep_bush
attr_reader :shows_grass_rustle
attr_reader :land_wild_encounters
attr_reader :landtw_wild_encounters
more code..
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number]
@real_name = hash[:id].to_s || "Unnamed"
@can_surf = hash[:can_surf] || false
@waterfall = hash[:waterfall] || false
@waterfall_crest = hash[:waterfall_crest] || false
@can_fish = hash[:can_fish] || false
@can_dive = hash[:can_dive] || false
@deep_bush = hash[:deep_bush] || false
@shows_grass_rustle = hash[:shows_grass_rustle] || false
@land_wild_encounters = hash[:land_wild_encounters] || false
@landtw_wild_encounters = hash[:landtw_wild_encounters] || false
more code...
GameData::TerrainTag.register({
:id => :Landtw,
:id_number => 18,
:shows_grass_rustle => true,
:landtw_wild_encounters => true,
:battle_environment => :Grass
})
EncounterType:
GameData::EncounterType.register({
:id => :Landtw,
:type => :landtw,
:trigger_chance => 21
})
Overworld_WildEncounters:
def encounter_type
time = pbGetTimeNow
ret = nil
if $PokemonGlobal.surfing
ret = find_valid_encounter_type_for_time(:Water, time)
else # Land/Cave (can have both in the same map)
if has_land_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).land_wild_encounters
ret = :BugContest if pbInBugContest? && has_encounter_type?(:BugContest)
ret = find_valid_encounter_type_for_time(:Land, time) if !ret
end
if has_landtw_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).landtw_wild_encounters
ret = find_valid_encounter_type_for_time(:Landtw, time) if !ret
end
if !ret && has_cave_encounters?
ret = find_valid_encounter_type_for_time(:Cave, time)
end
end
return ret
end
Encounters.txt
#-------------------------------
[056] # Ciudad Verde / Ruta 2-22
Landtw,21
20,BULBASAUR,5
It is added in grass with id 18 with that pokemon encounter there is no error just nothing happens.
I'm new and it's my first time editing code I hope your help
thank you so much.
Update:
if i add another encounter to standard id grass (2) and other grass (18) in same map i get this:
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.5]
Exception: NoMethodError
Message: undefined method `has_landtw_encounters?' for #<PokemonEncounters>
Backtrace:
Overworld_WildEncounters:261:in `encounter_type'
Overworld:200:in `pbBattleOnStepTaken'
Overworld:193:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Game_Player:183:in `turn_generic'
Game_Character:825:in `turn_right'
Game_Player:448:in `update_command_new'
Last edited: