mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Implemented GameData::Encounter, created new encounters.txt format, tweaked Vs animation filenames
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#===============================================================================
|
||||
class PokemonTemp
|
||||
attr_accessor :townMapData
|
||||
attr_accessor :encountersData
|
||||
attr_accessor :phoneData
|
||||
attr_accessor :regionalDexes
|
||||
attr_accessor :speciesShadowMovesets
|
||||
@@ -14,7 +13,6 @@ end
|
||||
def pbClearData
|
||||
if $PokemonTemp
|
||||
$PokemonTemp.townMapData = nil
|
||||
$PokemonTemp.encountersData = nil
|
||||
$PokemonTemp.phoneData = nil
|
||||
$PokemonTemp.regionalDexes = nil
|
||||
$PokemonTemp.speciesShadowMovesets = nil
|
||||
@@ -42,19 +40,6 @@ def pbLoadTownMapData
|
||||
return $PokemonTemp.townMapData
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Method to get wild encounter data.
|
||||
#===============================================================================
|
||||
def pbLoadEncountersData
|
||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||
if !$PokemonTemp.encountersData
|
||||
if pbRgssExists?("Data/encounters.dat")
|
||||
$PokemonTemp.encountersData = load_data("Data/encounters.dat")
|
||||
end
|
||||
end
|
||||
return $PokemonTemp.encountersData
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Method to get phone call data.
|
||||
#===============================================================================
|
||||
|
||||
@@ -40,6 +40,7 @@ module GameData
|
||||
return (self::DATA.has_key?(other)) ? self::DATA[other] : nil
|
||||
end
|
||||
|
||||
# Yields all data in order of their id_number.
|
||||
def each
|
||||
keys = self::DATA.keys.sort { |a, b| self::DATA[a].id_number <=> self::DATA[b].id_number }
|
||||
keys.each { |key| yield self::DATA[key] if !key.is_a?(Integer) }
|
||||
@@ -130,5 +131,6 @@ module GameData
|
||||
Type.load
|
||||
Species.load
|
||||
Trainer.load
|
||||
Encounter.load
|
||||
end
|
||||
end
|
||||
|
||||
78
Data/Scripts/011_Data/001_Game data/013_Encounter.rb
Normal file
78
Data/Scripts/011_Data/001_Game data/013_Encounter.rb
Normal file
@@ -0,0 +1,78 @@
|
||||
# $PokemonGlobal.encounter_version
|
||||
|
||||
module GameData
|
||||
class Encounter
|
||||
attr_accessor :id
|
||||
attr_accessor :map
|
||||
attr_accessor :version
|
||||
attr_reader :step_chances
|
||||
attr_reader :types
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "encounters.dat"
|
||||
|
||||
extend ClassMethods
|
||||
include InstanceMethods
|
||||
|
||||
# @param map_id [Integer]
|
||||
# @param map_version [Integer]
|
||||
# @return [Boolean] whether there is encounter data for the given map ID/version
|
||||
def self.exists?(map_id, map_version = 0)
|
||||
validate map_id => [Integer]
|
||||
validate map_version => [Integer]
|
||||
key = sprintf("%s_%d", map_id, map_version).to_sym
|
||||
return !self::DATA[key].nil?
|
||||
end
|
||||
|
||||
# @param map_id [Integer]
|
||||
# @param version [Integer]
|
||||
# @return [self, nil]
|
||||
def self.get(map_id, map_version = 0)
|
||||
validate map_id => Integer
|
||||
validate map_version => Integer
|
||||
trial_key = sprintf("%s_%d", map_id, map_version).to_sym
|
||||
key = (self::DATA.has_key?(trial_key)) ? trial_key : sprintf("%s_0", map_id).to_sym
|
||||
return self::DATA[key]
|
||||
end
|
||||
|
||||
# Yields all encounter data in order of their map and version numbers.
|
||||
def self.each
|
||||
keys = self::DATA.keys.sort do |a, b|
|
||||
if self::DATA[a].map == self::DATA[b].map
|
||||
self::DATA[a].version <=> self::DATA[b].version
|
||||
else
|
||||
self::DATA[a].map <=> self::DATA[b].map
|
||||
end
|
||||
end
|
||||
keys.each { |key| yield self::DATA[key] }
|
||||
end
|
||||
|
||||
# Yields all encounter data for the given version. Also yields encounter
|
||||
# data for version 0 of a map if that map doesn't have encounter data for
|
||||
# the given version.
|
||||
def self.each_of_version(version = 0)
|
||||
self.each do |data|
|
||||
yield data if data.version == version
|
||||
if version > 0
|
||||
yield data if data.version == 0 && !self::DATA.has_key?([data.map, version])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@map = hash[:map]
|
||||
@version = hash[:version] || 0
|
||||
@step_chances = hash[:step_chances]
|
||||
@types = hash[:types] || []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Deprecated methods
|
||||
#===============================================================================
|
||||
def pbLoadEncountersData
|
||||
Deprecation.warn_method('pbLoadEncountersData', 'v20', 'GameData::Encounter.get(map_id, version)')
|
||||
return nil
|
||||
end
|
||||
Reference in New Issue
Block a user