Added classes GameData::Environment and GameData::BattleTerrain

This commit is contained in:
Maruno17
2021-02-21 18:37:26 +00:00
parent c16311326c
commit 63e640c79b
23 changed files with 368 additions and 258 deletions

View File

@@ -45,7 +45,7 @@ module GameData
"TrainerVictoryME" => [17, "s"],
"WildCaptureME" => [18, "s"],
"MapSize" => [19, "us"],
"Environment" => [20, "e", :PBEnvironment]
"Environment" => [20, "e", :Environment]
}
extend ClassMethodsIDNumbers
@@ -53,26 +53,26 @@ module GameData
def self.editor_properties
return [
["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")],
["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")],
["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")],
["Weather", WeatherEffectProperty, _INTL("Weather conditions in effect for this map.")],
["MapPosition", RegionMapCoordsProperty, _INTL("Identifies the point on the regional map for this map.")],
["DiveMap", MapProperty, _INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")],
["DarkMap", BooleanProperty, _INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")],
["SafariMap", BooleanProperty, _INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")],
["SnapEdges", BooleanProperty, _INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")],
["Dungeon", BooleanProperty, _INTL("If true, this map has a randomly generated layout. See the wiki for more information.")],
["BattleBack", StringProperty, _INTL("PNG files named 'XXX_bg', 'XXX_base0', 'XXX_base1', 'XXX_message' in Battlebacks folder, where XXX is this property's value.")],
["WildBattleBGM", BGMProperty, _INTL("Default BGM for wild Pokémon battles on this map.")],
["TrainerBattleBGM", BGMProperty, _INTL("Default BGM for trainer battles on this map.")],
["WildVictoryME", MEProperty, _INTL("Default ME played after winning a wild Pokémon battle on this map.")],
["TrainerVictoryME", MEProperty, _INTL("Default ME played after winning a Trainer battle on this map.")],
["WildCaptureME", MEProperty, _INTL("Default ME played after catching a wild Pokémon on this map.")],
["MapSize", MapSizeProperty, _INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")],
["Environment", EnumProperty2.new(PBEnvironment), _INTL("The default battle environment for battles on this map.")]
["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")],
["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")],
["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")],
["Weather", WeatherEffectProperty, _INTL("Weather conditions in effect for this map.")],
["MapPosition", RegionMapCoordsProperty, _INTL("Identifies the point on the regional map for this map.")],
["DiveMap", MapProperty, _INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")],
["DarkMap", BooleanProperty, _INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")],
["SafariMap", BooleanProperty, _INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")],
["SnapEdges", BooleanProperty, _INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")],
["Dungeon", BooleanProperty, _INTL("If true, this map has a randomly generated layout. See the wiki for more information.")],
["BattleBack", StringProperty, _INTL("PNG files named 'XXX_bg', 'XXX_base0', 'XXX_base1', 'XXX_message' in Battlebacks folder, where XXX is this property's value.")],
["WildBattleBGM", BGMProperty, _INTL("Default BGM for wild Pokémon battles on this map.")],
["TrainerBattleBGM", BGMProperty, _INTL("Default BGM for trainer battles on this map.")],
["WildVictoryME", MEProperty, _INTL("Default ME played after winning a wild Pokémon battle on this map.")],
["TrainerVictoryME", MEProperty, _INTL("Default ME played after winning a Trainer battle on this map.")],
["WildCaptureME", MEProperty, _INTL("Default ME played after catching a wild Pokémon on this map.")],
["MapSize", MapSizeProperty, _INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")],
["Environment", GameDataProperty.new(:Environment), _INTL("The default battle environment for battles on this map.")]
]
end

View File

@@ -0,0 +1,129 @@
module GameData
class Environment
attr_reader :id
attr_reader :real_name
attr_reader :battle_base
DATA = {}
extend ClassMethodsSymbols
include InstanceMethods
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@battle_base = hash[:battle_base]
end
# @return [String] the translated name of this environment
def name
return _INTL(@real_name)
end
end
end
GameData::Environment.register({
:id => :None,
:name => _INTL("None")
})
GameData::Environment.register({
:id => :Grass,
:name => _INTL("Grass"),
:battle_base => "grass"
})
GameData::Environment.register({
:id => :TallGrass,
:name => _INTL("Tall grass"),
:battle_base => "grass"
})
GameData::Environment.register({
:id => :MovingWater,
:name => _INTL("Moving water"),
:battle_base => "water"
})
GameData::Environment.register({
:id => :StillWater,
:name => _INTL("Still water"),
:battle_base => "water"
})
GameData::Environment.register({
:id => :Puddle,
:name => _INTL("Puddle"),
:battle_basec => "puddle"
})
GameData::Environment.register({
:id => :Underwater,
:name => _INTL("Underwater")
})
GameData::Environment.register({
:id => :Cave,
:name => _INTL("Cave")
})
GameData::Environment.register({
:id => :Rock,
:name => _INTL("Rock")
})
GameData::Environment.register({
:id => :Sand,
:name => _INTL("Sand"),
:battle_base => "sand"
})
GameData::Environment.register({
:id => :Forest,
:name => _INTL("Forest")
})
GameData::Environment.register({
:id => :ForestGrass,
:name => _INTL("Forest grass"),
:battle_base => "grass"
})
GameData::Environment.register({
:id => :Snow,
:name => _INTL("Snow")
})
GameData::Environment.register({
:id => :Ice,
:name => _INTL("Ice"),
:battle_base => "ice"
})
GameData::Environment.register({
:id => :Volcano,
:name => _INTL("Volcano")
})
GameData::Environment.register({
:id => :Graveyard,
:name => _INTL("Graveyard")
})
GameData::Environment.register({
:id => :Sky,
:name => _INTL("Sky")
})
GameData::Environment.register({
:id => :Space,
:name => _INTL("Space")
})
GameData::Environment.register({
:id => :UltraSpace,
:name => _INTL("Ultra Space")
})

View File

@@ -1,30 +0,0 @@
begin
module PBEnvironment
None = 0
Grass = 1
TallGrass = 2
MovingWater = 3
StillWater = 4
Puddle = 5
Underwater = 6
Cave = 7
Rock = 8
Sand = 9
Forest = 10
ForestGrass = 11
Snow = 12
Ice = 13
Volcano = 14
Graveyard = 15
Sky = 16
Space = 17
UltraSpace = 18
def self.maxValue; return 18; end
end
rescue Exception
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
raise $!
end
end

View File

@@ -0,0 +1,56 @@
# These are in-battle terrain effects caused by moves like Electric Terrain.
module GameData
class BattleTerrain
attr_reader :id
attr_reader :real_name
attr_reader :animation
DATA = {}
extend ClassMethodsSymbols
include InstanceMethods
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@animation = hash[:animation]
end
# @return [String] the translated name of this battle terrain
def name
return _INTL(@real_name)
end
end
end
GameData::BattleTerrain.register({
:id => :None,
:name => _INTL("None")
})
GameData::BattleTerrain.register({
:id => :Electric,
:name => _INTL("Electric"),
:animation => "ElectricTerrain"
})
GameData::BattleTerrain.register({
:id => :Grassy,
:name => _INTL("Grassy"),
:animation => "GrassyTerrain"
})
GameData::BattleTerrain.register({
:id => :Misty,
:name => _INTL("Misty"),
:animation => "MistyTerrain"
})
GameData::BattleTerrain.register({
:id => :Psychic,
:name => _INTL("Psychic"),
:animation => "PsychicTerrain"
})

View File

@@ -1,25 +0,0 @@
# These are in-battle terrain effects caused by moves like Electric Terrain.
begin
module PBBattleTerrains
None = 0
Electric = 1
Grassy = 2
Misty = 3
Psychic = 4
def self.animationName(terrain)
case terrain
when Electric then return "ElectricTerrain"
when Grassy then return "GrassyTerrain"
when Misty then return "MistyTerrain"
when Psychic then return "PsychicTerrain"
end
return nil
end
end
rescue Exception
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
raise $!
end
end

View File

@@ -60,13 +60,13 @@ class PokeBattle_Battler
# Terrains immunity
if affectedByTerrain?
case @battle.field.terrain
when PBBattleTerrains::Electric
when :Electric
if newStatus == :SLEEP
@battle.pbDisplay(_INTL("{1} surrounds itself with electrified terrain!",
pbThis(true))) if showMessages
return false
end
when PBBattleTerrains::Misty
when :Misty
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
return false
end
@@ -175,7 +175,7 @@ class PokeBattle_Battler
# Trying to replace a status problem with another one
return false if self.status != :NONE
# Terrain immunity
return false if @battle.field.terrain==PBBattleTerrains::Misty && affectedByTerrain?
return false if @battle.field.terrain == :Misty && affectedByTerrain?
# Type immunities
hasImmuneType = false
case newStatus
@@ -282,8 +282,7 @@ class PokeBattle_Battler
def pbCanSleepYawn?
return false if self.status != :NONE
if affectedByTerrain?
return false if @battle.field.terrain==PBBattleTerrains::Electric
return false if @battle.field.terrain==PBBattleTerrains::Misty
return false if [:Electric, :Misty].include?(@battle.field.terrain)
end
if !hasActiveAbility?(:SOUNDPROOF)
@battle.eachBattler do |b|
@@ -453,7 +452,7 @@ class PokeBattle_Battler
return false
end
# Terrains immunity
if affectedByTerrain? && @battle.field.terrain==PBBattleTerrains::Misty
if affectedByTerrain? && @battle.field.terrain == :Misty
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
return false
end

View File

@@ -295,8 +295,7 @@ class PokeBattle_Battler
# Move-specific failures
return false if move.pbFailsAgainstTarget?(user,target)
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain==PBBattleTerrains::Psychic && target.affectedByTerrain? &&
target.opposes?(user) &&
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!",target.pbThis))
return false

View File

@@ -340,19 +340,15 @@ class PokeBattle_Move
end
end
# Terrain moves
if user.affectedByTerrain?
case @battle.field.terrain
when PBBattleTerrains::Electric
multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC
when PBBattleTerrains::Grassy
multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS
when PBBattleTerrains::Psychic
multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC
end
end
if @battle.field.terrain==PBBattleTerrains::Misty && target.affectedByTerrain? &&
type == :DRAGON
multipliers[:base_damage_multiplier] /= 2
case @battle.field.terrain
when :Electric
multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain?
when :Grassy
multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS && user.affectedByTerrain?
when :Psychic
multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC && user.affectedByTerrain?
when :Misty
multipliers[:base_damage_multiplier] /= 2 if type == :DRAGON && target.affectedByTerrain?
end
# Badge multipliers
if @battle.internalBattle

View File

@@ -1201,7 +1201,7 @@ class PokeBattle_Move_044 < PokeBattle_TargetStatDownMove
end
def pbBaseDamage(baseDmg,user,target)
if @id == :BULLDOZE && @battle.field.terrain==PBBattleTerrains::Grassy
if @id == :BULLDOZE && @battle.field.terrain == :Grassy
baseDmg = (baseDmg/2.0).round
end
return baseDmg
@@ -1287,8 +1287,7 @@ class PokeBattle_Move_049 < PokeBattle_TargetStatDownMove
targetOpposingSide.effects[PBEffects::Spikes]>0 ||
targetOpposingSide.effects[PBEffects::ToxicSpikes]>0 ||
targetOpposingSide.effects[PBEffects::StickyWeb])
return false if Settings::MECHANICS_GENERATION >= 8 &&
@battle.field.terrain != PBBattleTerrains::None
return false if Settings::MECHANICS_GENERATION >= 8 && @battle.field.terrain != :None
return super
end
@@ -1344,18 +1343,18 @@ class PokeBattle_Move_049 < PokeBattle_TargetStatDownMove
target.pbOpposingSide.effects[PBEffects::StickyWeb] = false if Settings::MECHANICS_GENERATION >= 6
@battle.pbDisplay(_INTL("{1} blew away sticky webs!",user.pbThis))
end
if Settings::MECHANICS_GENERATION >= 8 && @battle.field.terrain != PBBattleTerrains::None
if Settings::MECHANICS_GENERATION >= 8 && @battle.field.terrain != :None
case @battle.field.terrain
when PBBattleTerrains::Electric
when :Electric
@battle.pbDisplay(_INTL("The electricity disappeared from the battlefield."))
when PBBattleTerrains::Grassy
when :Grassy
@battle.pbDisplay(_INTL("The grass disappeared from the battlefield."))
when PBBattleTerrains::Misty
when :Misty
@battle.pbDisplay(_INTL("The mist disappeared from the battlefield."))
when PBBattleTerrains::Psychic
when :Psychic
@battle.pbDisplay(_INTL("The weirdness disappeared from the battlefield."))
end
@battle.field.terrain = PBBattleTerrains::None
@battle.field.terrain = :None
end
end
end
@@ -1872,22 +1871,22 @@ class PokeBattle_Move_060 < PokeBattle_Move
@newType = :NORMAL
checkedTerrain = false
case @battle.field.terrain
when PBBattleTerrains::Electric
when :Electric
if GameData::Type.exists?(:ELECTRIC)
@newType = :ELECTRIC
checkedTerrain = true
end
when PBBattleTerrains::Grassy
when :Grassy
if GameData::Type.exists?(:GRASS)
@newType = :GRASS
checkedTerrain = true
end
when PBBattleTerrains::Misty
when :Misty
if GameData::Type.exists?(:FAIRY)
@newType = :FAIRY
checkedTerrain = true
end
when PBBattleTerrains::Psychic
when :Psychic
if GameData::Type.exists?(:PSYCHIC)
@newType = :PSYCHIC
checkedTerrain = true
@@ -1895,28 +1894,27 @@ class PokeBattle_Move_060 < PokeBattle_Move
end
if !checkedTerrain
case @battle.environment
when PBEnvironment::Grass, PBEnvironment::TallGrass
when :Grass, :TallGrass
@newType = :GRASS
when PBEnvironment::MovingWater, PBEnvironment::StillWater,
PBEnvironment::Puddle, PBEnvironment::Underwater
when :MovingWater, :StillWater, :Puddle, :Underwater
@newType = :WATER
when PBEnvironment::Cave
when :Cave
@newType = :ROCK
when PBEnvironment::Rock, PBEnvironment::Sand
when :Rock, :Sand
@newType = :GROUND
when PBEnvironment::Forest, PBEnvironment::ForestGrass
when :Forest, :ForestGrass
@newType = :BUG
when PBEnvironment::Snow, PBEnvironment::Ice
when :Snow, :Ice
@newType = :ICE
when PBEnvironment::Volcano
when :Volcano
@newType = :FIRE
when PBEnvironment::Graveyard
when :Graveyard
@newType = :GHOST
when PBEnvironment::Sky
when :Sky
@newType = :FLYING
when PBEnvironment::Space
when :Space
@newType = :DRAGON
when PBEnvironment::UltraSpace
when :UltraSpace
@newType = :PSYCHIC
end
end
@@ -2539,7 +2537,7 @@ class PokeBattle_Move_076 < PokeBattle_Move
def pbModifyDamage(damageMult,user,target)
damageMult *= 2 if target.inTwoTurnAttack?("0CA") # Dig
damageMult /= 2 if @battle.field.terrain==PBBattleTerrains::Grassy
damageMult /= 2 if @battle.field.terrain == :Grassy
return damageMult
end
end

View File

@@ -419,7 +419,7 @@ class PokeBattle_Move_095 < PokeBattle_Move
def pbModifyDamage(damageMult,user,target)
damageMult *= 2 if target.inTwoTurnAttack?("0CA") # Dig
damageMult /= 2 if @battle.field.terrain==PBBattleTerrains::Grassy
damageMult /= 2 if @battle.field.terrain == :Grassy
return damageMult
end
end
@@ -870,39 +870,37 @@ class PokeBattle_Move_0A4 < PokeBattle_Move
# NOTE: This is Gen 7's list plus some of Gen 6 plus a bit of my own.
@secretPower = 0 # Body Slam, paralysis
case @battle.field.terrain
when PBBattleTerrains::Electric
when :Electric
@secretPower = 1 # Thunder Shock, paralysis
when PBBattleTerrains::Grassy
when :Grassy
@secretPower = 2 # Vine Whip, sleep
when PBBattleTerrains::Misty
when :Misty
@secretPower = 3 # Fairy Wind, lower Sp. Atk by 1
when PBBattleTerrains::Psychic
when :Psychic
@secretPower = 4 # Confusion, lower Speed by 1
else
case @battle.environment
when PBEnvironment::Grass, PBEnvironment::TallGrass,
PBEnvironment::Forest, PBEnvironment::ForestGrass
when :Grass, :TallGrass, :Forest, :ForestGrass
@secretPower = 2 # (Same as Grassy Terrain)
when PBEnvironment::MovingWater, PBEnvironment::StillWater,
PBEnvironment::Underwater
when :MovingWater, :StillWater, :Underwater
@secretPower = 5 # Water Pulse, lower Attack by 1
when PBEnvironment::Puddle
when :Puddle
@secretPower = 6 # Mud Shot, lower Speed by 1
when PBEnvironment::Cave
when :Cave
@secretPower = 7 # Rock Throw, flinch
when PBEnvironment::Rock, PBEnvironment::Sand
when :Rock, :Sand
@secretPower = 8 # Mud-Slap, lower Acc by 1
when PBEnvironment::Snow, PBEnvironment::Ice
when :Snow, :Ice
@secretPower = 9 # Ice Shard, freeze
when PBEnvironment::Volcano
when :Volcano
@secretPower = 10 # Incinerate, burn
when PBEnvironment::Graveyard
when :Graveyard
@secretPower = 11 # Shadow Sneak, flinch
when PBEnvironment::Sky
when :Sky
@secretPower = 12 # Gust, lower Speed by 1
when PBEnvironment::Space
when :Space
@secretPower = 13 # Swift, flinch
when PBEnvironment::UltraSpace
when :UltraSpace
@secretPower = 14 # Psywave, lower Defense by 1
end
end
@@ -1313,62 +1311,61 @@ class PokeBattle_Move_0B3 < PokeBattle_Move
# Attack in it?
@npMove = :TRIATTACK
case @battle.field.terrain
when PBBattleTerrains::Electric
when :Electric
@npMove = :THUNDERBOLT if GameData::Move.exists?(:THUNDERBOLT)
when PBBattleTerrains::Grassy
when :Grassy
@npMove = :ENERGYBALL if GameData::Move.exists?(:ENERGYBALL)
when PBBattleTerrains::Misty
when :Misty
@npMove = :MOONBLAST if GameData::Move.exists?(:MOONBLAST)
when PBBattleTerrains::Psychic
when :Psychic
@npMove = :PSYCHIC if GameData::Move.exists?(:PSYCHIC)
else
case @battle.environment
when PBEnvironment::Grass, PBEnvironment::TallGrass,
PBEnvironment::Forest, PBEnvironment::ForestGrass
when :Grass, :TallGrass, :Forest, :ForestGrass
if Settings::MECHANICS_GENERATION >= 6
@npMove = :ENERGYBALL if GameData::Move.exists?(:ENERGYBALL)
else
@npMove = :SEEDBOMB if GameData::Move.exists?(:SEEDBOMB)
end
when PBEnvironment::MovingWater, PBEnvironment::StillWater, PBEnvironment::Underwater
when :MovingWater, :StillWater, :Underwater
@npMove = :HYDROPUMP if GameData::Move.exists?(:HYDROPUMP)
when PBEnvironment::Puddle
when :Puddle
@npMove = :MUDBOMB if GameData::Move.exists?(:MUDBOMB)
when PBEnvironment::Cave
when :Cave
if Settings::MECHANICS_GENERATION >= 6
@npMove = :POWERGEM if GameData::Move.exists?(:POWERGEM)
else
@npMove = :ROCKSLIDE if GameData::Move.exists?(:ROCKSLIDE)
end
when PBEnvironment::Rock
when :Rock
if Settings::MECHANICS_GENERATION >= 6
@npMove = :EARTHPOWER if GameData::Move.exists?(:EARTHPOWER)
else
@npMove = :ROCKSLIDE if GameData::Move.exists?(:ROCKSLIDE)
end
when PBEnvironment::Sand
when :Sand
if Settings::MECHANICS_GENERATION >= 6
@npMove = :EARTHPOWER if GameData::Move.exists?(:EARTHPOWER)
else
@npMove = :EARTHQUAKE if GameData::Move.exists?(:EARTHQUAKE)
end
when PBEnvironment::Snow
when :Snow
if Settings::MECHANICS_GENERATION >= 6
@npMove = :FROSTBREATH if GameData::Move.exists?(:FROSTBREATH)
else
@npMove = :BLIZZARD if GameData::Move.exists?(:BLIZZARD)
end
when PBEnvironment::Ice
when :Ice
@npMove = :ICEBEAM if GameData::Move.exists?(:ICEBEAM)
when PBEnvironment::Volcano
when :Volcano
@npMove = :LAVAPLUME if GameData::Move.exists?(:LAVAPLUME)
when PBEnvironment::Graveyard
when :Graveyard
@npMove = :SHADOWBALL if GameData::Move.exists?(:SHADOWBALL)
when PBEnvironment::Sky
when :Sky
@npMove = :AIRSLASH if GameData::Move.exists?(:AIRSLASH)
when PBEnvironment::Space
when :Space
@npMove = :DRACOMETEOR if GameData::Move.exists?(:DRACOMETEOR)
when PBEnvironment::UltraSpace
when :UltraSpace
@npMove = :PSYSHOCK if GameData::Move.exists?(:PSYSHOCK)
end
end

View File

@@ -1774,7 +1774,7 @@ end
#===============================================================================
class PokeBattle_Move_154 < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.field.terrain==PBBattleTerrains::Electric
if @battle.field.terrain == :Electric
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1782,7 +1782,7 @@ class PokeBattle_Move_154 < PokeBattle_Move
end
def pbEffectGeneral(user)
@battle.pbStartTerrain(user,PBBattleTerrains::Electric)
@battle.pbStartTerrain(user, :Electric)
end
end
@@ -1795,7 +1795,7 @@ end
#===============================================================================
class PokeBattle_Move_155 < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.field.terrain==PBBattleTerrains::Grassy
if @battle.field.terrain == :Grassy
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1803,7 +1803,7 @@ class PokeBattle_Move_155 < PokeBattle_Move
end
def pbEffectGeneral(user)
@battle.pbStartTerrain(user,PBBattleTerrains::Grassy)
@battle.pbStartTerrain(user, :Grassy)
end
end
@@ -1816,7 +1816,7 @@ end
#===============================================================================
class PokeBattle_Move_156 < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.field.terrain==PBBattleTerrains::Misty
if @battle.field.terrain == :Misty
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1824,7 +1824,7 @@ class PokeBattle_Move_156 < PokeBattle_Move
end
def pbEffectGeneral(user)
@battle.pbStartTerrain(user,PBBattleTerrains::Misty)
@battle.pbStartTerrain(user, :Misty)
end
end
@@ -2409,7 +2409,7 @@ class PokeBattle_Move_16E < PokeBattle_Move
def pbEffectAgainstTarget(user,target)
hpGain = (target.totalhp/2.0).round
hpGain = (target.totalhp*2/3.0).round if @battle.field.terrain==PBBattleTerrains::Grassy
hpGain = (target.totalhp*2/3.0).round if @battle.field.terrain == :Grassy
target.pbRecoverHP(hpGain)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
end
@@ -2556,7 +2556,7 @@ end
#===============================================================================
class PokeBattle_Move_173 < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.field.terrain==PBBattleTerrains::Psychic
if @battle.field.terrain == :Psychic
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -2564,7 +2564,7 @@ class PokeBattle_Move_173 < PokeBattle_Move
end
def pbEffectGeneral(user)
@battle.pbStartTerrain(user,PBBattleTerrains::Psychic)
@battle.pbStartTerrain(user, :Psychic)
end
end

View File

@@ -109,7 +109,7 @@ class PokeBattle_Battle
@backdrop = ""
@backdropBase = nil
@time = 0
@environment = PBEnvironment::None # e.g. Tall grass, cave, still water
@environment = :None # e.g. Tall grass, cave, still water
@turnCount = 0
@decision = 0
@caughtPokemon = []
@@ -716,16 +716,17 @@ class PokeBattle_Battle
newTerrain,duration,user,self)
end
@field.terrainDuration = duration
pbCommonAnimation(PBBattleTerrains.animationName(@field.terrain))
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)
pbCommonAnimation(terrain_data.animation) if terrain_data
pbHideAbilitySplash(user) if user
case @field.terrain
when PBBattleTerrains::Electric
when :Electric
pbDisplay(_INTL("An electric current runs across the battlefield!"))
when PBBattleTerrains::Grassy
when :Grassy
pbDisplay(_INTL("Grass grew to cover the battlefield!"))
when PBBattleTerrains::Misty
when :Misty
pbDisplay(_INTL("Mist swirled about the battlefield!"))
when PBBattleTerrains::Psychic
when :Psychic
pbDisplay(_INTL("The battlefield got weird!"))
end
# Check for terrain seeds that boost stats in a terrain

View File

@@ -283,15 +283,16 @@ class PokeBattle_Battle
when PBWeather::ShadowSky then pbDisplay(_INTL("The sky is shadowy."))
end
# Terrain announcement
pbCommonAnimation(PBBattleTerrains.animationName(@field.terrain))
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)
pbCommonAnimation(terrain_data.animation) if terrain_data
case @field.terrain
when PBBattleTerrains::Electric
when :Electric
pbDisplay(_INTL("An electric current runs across the battlefield!"))
when PBBattleTerrains::Grassy
when :Grassy
pbDisplay(_INTL("Grass is covering the battlefield!"))
when PBBattleTerrains::Misty
when :Misty
pbDisplay(_INTL("Mist swirls about the battlefield!"))
when PBBattleTerrains::Psychic
when :Psychic
pbDisplay(_INTL("The battlefield is weird!"))
end
# Abilities upon entering battle

View File

@@ -113,29 +113,30 @@ class PokeBattle_Battle
# Count down terrain duration
@field.terrainDuration -= 1 if @field.terrainDuration>0
# Terrain wears off
if @field.terrain!=PBBattleTerrains::None && @field.terrainDuration==0
if @field.terrain != :None && @field.terrainDuration == 0
case @field.terrain
when PBBattleTerrains::Electric
when :Electric
pbDisplay(_INTL("The electric current disappeared from the battlefield!"))
when PBBattleTerrains::Grassy
when :Grassy
pbDisplay(_INTL("The grass disappeared from the battlefield!"))
when PBBattleTerrains::Misty
when :Misty
pbDisplay(_INTL("The mist disappeared from the battlefield!"))
when PBBattleTerrains::Psychic
when :Psychic
pbDisplay(_INTL("The weirdness disappeared from the battlefield!"))
end
@field.terrain = PBBattleTerrains::None
@field.terrain = :None
# Start up the default terrain
pbStartTerrain(nil,@field.defaultTerrain,false) if @field.defaultTerrain!=PBBattleTerrains::None
return if @field.terrain==PBBattleTerrains::None
pbStartTerrain(nil, @field.defaultTerrain, false) if @field.defaultTerrain != :None
return if @field.terrain == :None
end
# Terrain continues
pbCommonAnimation(PBBattleTerrains.animationName(@field.terrain))
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)
pbCommonAnimation(terrain_data.animation) if terrain_data
case @field.terrain
when PBBattleTerrains::Electric then pbDisplay(_INTL("An electric current is running across the battlefield."))
when PBBattleTerrains::Grassy then pbDisplay(_INTL("Grass is covering the battlefield."))
when PBBattleTerrains::Misty then pbDisplay(_INTL("Mist is swirling about the battlefield."))
when PBBattleTerrains::Psychic then pbDisplay(_INTL("The battlefield is weird."))
when :Electric then pbDisplay(_INTL("An electric current is running across the battlefield."))
when :Grassy then pbDisplay(_INTL("Grass is covering the battlefield."))
when :Misty then pbDisplay(_INTL("Mist is swirling about the battlefield."))
when :Psychic then pbDisplay(_INTL("The battlefield is weird."))
end
end
@@ -282,7 +283,7 @@ class PokeBattle_Battle
priority.each do |b|
next if b.fainted?
# Grassy Terrain (healing)
if @field.terrain==PBBattleTerrains::Grassy && b.affectedByTerrain? && b.canHeal?
if @field.terrain == :Grassy && b.affectedByTerrain? && b.canHeal?
PBDebug.log("[Lingering effect] Grassy Terrain heals #{b.pbThis(true)}")
b.pbRecoverHP(b.totalhp/16)
pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis))

View File

@@ -2982,7 +2982,7 @@ class PokeBattle_AI
score += 50
score -= user.hp*100/user.totalhp
if skill>=PBTrainerAI.mediumSkill
score += 30 if @battle.field.terrain==PBBattleTerrains::Grassy
score += 30 if @battle.field.terrain == :Grassy
end
end
#---------------------------------------------------------------------------

View File

@@ -122,7 +122,7 @@ class PokeBattle_AI
!move.ignoresSubstitute?(user) && user.index!=target.index
return true if Settings::MECHANICS_GENERATION >= 7 && user.hasActiveAbility?(:PRANKSTER) &&
target.pbHasType?(:DARK) && target.opposes?(user)
return true if move.priority>0 && @battle.field.terrain==PBBattleTerrains::Psychic &&
return true if move.priority>0 && @battle.field.terrain == :Psychic &&
target.affectedByTerrain? && target.opposes?(user)
end
return false
@@ -397,19 +397,16 @@ class PokeBattle_AI
end
end
# Terrain moves
if user.affectedByTerrain? && skill>=PBTrainerAI.mediumSkill
if skill>=PBTrainerAI.mediumSkill
case @battle.field.terrain
when PBBattleTerrains::Electric
multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC
when PBBattleTerrains::Grassy
multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS
when PBBattleTerrains::Psychic
multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC
end
end
if target.affectedByTerrain? && skill>=PBTrainerAI.mediumSkill
if @battle.field.terrain==PBBattleTerrains::Misty && type == :DRAGON
multipliers[:base_damage_multiplier] /= 2
when :Electric
multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain?
when :Grassy
multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS && user.affectedByTerrain?
when :Psychic
multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC && user.affectedByTerrain?
when :Misty
multipliers[:base_damage_multiplier] /= 2 if type == :DRAGON && target.affectedByTerrain?
end
end
# Badge multipliers

View File

@@ -321,7 +321,7 @@ class PokeBattle_SafariZone
@backdrop = ""
@backdropBase = nil
@time = 0
@environment = PBEnvironment::None # e.g. Tall grass, cave, still water
@environment = :None # e.g. Tall grass, cave, still water
@weather = PBWeather::None
@decision = 0
@caughtPokemon = []

View File

@@ -37,7 +37,7 @@ BattleHandlers::SpeedCalcAbility.add(:SLUSHRUSH,
BattleHandlers::SpeedCalcAbility.add(:SURGESURFER,
proc { |ability,battler,mult|
next mult*2 if battler.battle.field.terrain==PBBattleTerrains::Electric
next mult*2 if battler.battle.field.terrain == :Electric
}
)
@@ -1183,7 +1183,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:FURCOAT,
BattleHandlers::DamageCalcTargetAbility.add(:GRASSPELT,
proc { |ability,user,target,move,mults,baseDmg,type|
if user.battle.field.terrain == PBBattleTerrains::Grassy
if user.battle.field.terrain == :Grassy
mults[:defense_multiplier] *= 1.5
end
}
@@ -2173,9 +2173,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:DROUGHT,
BattleHandlers::AbilityOnSwitchIn.add(:ELECTRICSURGE,
proc { |ability,battler,battle|
next if battle.field.terrain==PBBattleTerrains::Electric
next if battle.field.terrain == :Electric
battle.pbShowAbilitySplash(battler)
battle.pbStartTerrain(battler,PBBattleTerrains::Electric)
battle.pbStartTerrain(battler, :Electric)
# NOTE: The ability splash is hidden again in def pbStartTerrain.
}
)
@@ -2253,9 +2253,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:FRISK,
BattleHandlers::AbilityOnSwitchIn.add(:GRASSYSURGE,
proc { |ability,battler,battle|
next if battle.field.terrain==PBBattleTerrains::Grassy
next if battle.field.terrain == :Grassy
battle.pbShowAbilitySplash(battler)
battle.pbStartTerrain(battler,PBBattleTerrains::Grassy)
battle.pbStartTerrain(battler, :Grassy)
# NOTE: The ability splash is hidden again in def pbStartTerrain.
}
)
@@ -2292,9 +2292,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:INTIMIDATE,
BattleHandlers::AbilityOnSwitchIn.add(:MISTYSURGE,
proc { |ability,battler,battle|
next if battle.field.terrain==PBBattleTerrains::Misty
next if battle.field.terrain == :Misty
battle.pbShowAbilitySplash(battler)
battle.pbStartTerrain(battler,PBBattleTerrains::Misty)
battle.pbStartTerrain(battler, :Misty)
# NOTE: The ability splash is hidden again in def pbStartTerrain.
}
)
@@ -2323,9 +2323,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:PRIMORDIALSEA,
BattleHandlers::AbilityOnSwitchIn.add(:PSYCHICSURGE,
proc { |ability,battler,battle|
next if battle.field.terrain==PBBattleTerrains::Psychic
next if battle.field.terrain == :Psychic
battle.pbShowAbilitySplash(battler)
battle.pbStartTerrain(battler,PBBattleTerrains::Psychic)
battle.pbStartTerrain(battler, :Psychic)
# NOTE: The ability splash is hidden again in def pbStartTerrain.
}
)

View File

@@ -1432,7 +1432,7 @@ BattleHandlers::TerrainExtenderItem.add(:TERRAINEXTENDER,
BattleHandlers::TerrainStatBoostItem.add(:ELECTRICSEED,
proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Electric
next false if battle.field.terrain != :Electric
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler)
@@ -1442,7 +1442,7 @@ BattleHandlers::TerrainStatBoostItem.add(:ELECTRICSEED,
BattleHandlers::TerrainStatBoostItem.add(:GRASSYSEED,
proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Grassy
next false if battle.field.terrain != :Grassy
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler)
@@ -1452,7 +1452,7 @@ BattleHandlers::TerrainStatBoostItem.add(:GRASSYSEED,
BattleHandlers::TerrainStatBoostItem.add(:MISTYSEED,
proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Misty
next false if battle.field.terrain != :Misty
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler)
@@ -1462,7 +1462,7 @@ BattleHandlers::TerrainStatBoostItem.add(:MISTYSEED,
BattleHandlers::TerrainStatBoostItem.add(:PSYCHICSEED,
proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Psychic
next false if battle.field.terrain != :Psychic
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler)

View File

@@ -107,7 +107,7 @@ BallHandlers::ModifyCatchRate.add(:NETBALL,proc { |ball,catchRate,battle,battler
})
BallHandlers::ModifyCatchRate.add(:DIVEBALL,proc { |ball,catchRate,battle,battler,ultraBeast|
catchRate *= 3.5 if battle.environment==PBEnvironment::Underwater
catchRate *= 3.5 if battle.environment == :Underwater
next catchRate
})

View File

@@ -26,8 +26,8 @@ begin
@defaultWeather = PBWeather::None
@weather = PBWeather::None
@weatherDuration = 0
@defaultTerrain = PBBattleTerrains::None
@terrain = PBBattleTerrains::None
@defaultTerrain = :None
@terrain = :None
@terrainDuration = 0
end
end

View File

@@ -41,9 +41,13 @@ class PokemonTemp
when "setstyle" then rules["switchStyle"] = false
when "anims" then rules["battleAnims"] = true
when "noanims" then rules["battleAnims"] = false
when "terrain" then rules["defaultTerrain"] = getID(PBBattleTerrains, var)
when "terrain"
terrain_data = GameData::BattleTerrain.try_get(var)
rules["defaultTerrain"] = (terrain_data) ? terrain_data.id : nil
when "weather" then rules["defaultWeather"] = getID(PBWeather, var)
when "environment", "environ" then rules["environment"] = getID(PBEnvironment, var)
when "environment", "environ"
environment_data = GameData::Environment.try_get(var)
rules["environment"] = (environment_data) ? environment_data.id : nil
when "backdrop", "battleback" then rules["backdrop"] = var
when "base" then rules["base"] = var
when "outcome", "outcomevar" then rules["outcomeVar"] = var
@@ -138,28 +142,15 @@ def pbPrepareBattle(battle)
battle.backdrop = backdrop
# Choose a name for bases depending on environment
if battleRules["base"].nil?
case battle.environment
when PBEnvironment::Grass, PBEnvironment::TallGrass,
PBEnvironment::ForestGrass
base = "grass"
# when PBEnvironment::Rock
# base = "rock"
when PBEnvironment::Sand
base = "sand"
when PBEnvironment::MovingWater, PBEnvironment::StillWater
base = "water"
when PBEnvironment::Puddle
base = "puddle"
when PBEnvironment::Ice
base = "ice"
end
environment_data = GameData::Environment.try_get(battle.environment)
base = environment_data.battle_base if environment_data
else
base = battleRules["base"]
end
battle.backdropBase = base if base
# Time of day
if GameData::MapMetadata.exists?($game_map.map_id) &&
GameData::MapMetadata.get($game_map.map_id).battle_environment == PBEnvironment::Cave
GameData::MapMetadata.get($game_map.map_id).battle_environment == :Cave
battle.time = 2 # This makes Dusk Balls work properly in caves
elsif Settings::TIME_SHADING
timeNow = pbGetTimeNow
@@ -173,7 +164,7 @@ end
# Used to determine the environment in battle, and also the form of Burmy/
# Wormadam.
def pbGetEnvironment
ret = PBEnvironment::None
ret = :None
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
ret = map_metadata.battle_environment if map_metadata && map_metadata.battle_environment
if $PokemonTemp.encounterType == EncounterTypes::OldRod ||
@@ -185,15 +176,15 @@ def pbGetEnvironment
end
case terrainTag
when PBTerrain::Grass, PBTerrain::SootGrass
ret = (ret == PBEnvironment::Forest) ? PBEnvironment::ForestGrass : PBEnvironment::Grass
ret = (ret == :Forest) ? :ForestGrass : :Grass
when PBTerrain::TallGrass
ret = (ret == PBEnvironment::Forest) ? PBEnvironment::ForestGrass : PBEnvironment::TallGrass
when PBTerrain::Rock then ret = PBEnvironment::Rock
when PBTerrain::Sand then ret = PBEnvironment::Sand
when PBTerrain::DeepWater, PBTerrain::Water then ret = PBEnvironment::MovingWater
when PBTerrain::StillWater then ret = PBEnvironment::StillWater
when PBTerrain::Puddle then ret = PBEnvironment::Puddle
when PBTerrain::Ice then ret = PBEnvironment::Ice
ret = (ret == :Forest) ? :ForestGrass : :TallGrass
when PBTerrain::Rock then ret = :Rock
when PBTerrain::Sand then ret = :Sand
when PBTerrain::DeepWater, PBTerrain::Water then ret = :MovingWater
when PBTerrain::StillWater then ret = :StillWater
when PBTerrain::Puddle then ret = :Puddle
when PBTerrain::Ice then ret = :Ice
end
return ret
end

View File

@@ -172,9 +172,9 @@ MultipleForms.register(:KYOGRE,{
MultipleForms.register(:BURMY,{
"getFormOnCreation" => proc { |pkmn|
case pbGetEnvironment
when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave
when :Rock, :Sand, :Cave
next 1 # Sandy Cloak
when PBEnvironment::None
when :None
next 2 # Trash Cloak
else
next 0 # Plant Cloak
@@ -183,9 +183,9 @@ MultipleForms.register(:BURMY,{
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
next if !endBattle || !usedInBattle
case battle.environment
when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave
when :Rock, :Sand, :Cave
next 1 # Sandy Cloak
when PBEnvironment::None
when :None
next 2 # Trash Cloak
else
next 0 # Plant Cloak
@@ -196,9 +196,9 @@ MultipleForms.register(:BURMY,{
MultipleForms.register(:WORMADAM,{
"getFormOnCreation" => proc { |pkmn|
case pbGetEnvironment
when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave
when :Rock, :Sand, :Cave
next 1 # Sandy Cloak
when PBEnvironment::None
when :None
next 2 # Trash Cloak
else
next 0 # Plant Cloak