diff --git a/Data/Scripts/007_Events and files/003_Intl_Messages.rb b/Data/Scripts/007_Events and files/003_Intl_Messages.rb index 64849829b..8b50b8e79 100644 --- a/Data/Scripts/007_Events and files/003_Intl_Messages.rb +++ b/Data/Scripts/007_Events and files/003_Intl_Messages.rb @@ -587,30 +587,32 @@ end module MessageTypes # Value 0 is used for common event and map event text - Species = 1 - Kinds = 2 - Entries = 3 - FormNames = 4 - Moves = 5 - MoveDescriptions = 6 - Items = 7 - ItemPlurals = 8 - ItemDescriptions = 9 - Abilities = 10 - AbilityDescs = 11 - Types = 12 - TrainerTypes = 13 - TrainerNames = 14 - BeginSpeech = 15 - EndSpeechWin = 16 - EndSpeechLose = 17 - RegionNames = 18 - PlaceNames = 19 - PlaceDescriptions = 20 - MapNames = 21 - PhoneMessages = 22 - TrainerLoseText = 23 - ScriptTexts = 24 + Species = 1 + Kinds = 2 + Entries = 3 + FormNames = 4 + Moves = 5 + MoveDescriptions = 6 + Items = 7 + ItemPlurals = 8 + ItemDescriptions = 9 + Abilities = 10 + AbilityDescs = 11 + Types = 12 + TrainerTypes = 13 + TrainerNames = 14 + BeginSpeech = 15 + EndSpeechWin = 16 + EndSpeechLose = 17 + RegionNames = 18 + PlaceNames = 19 + PlaceDescriptions = 20 + MapNames = 21 + PhoneMessages = 22 + TrainerLoseText = 23 + ScriptTexts = 24 + RibbonNames = 25 + RibbonDescriptions = 26 @@messages = Messages.new @@messagesFallback = Messages.new("Data/messages.dat",true) diff --git a/Data/Scripts/011_Data/001_Game data/001_Game data.rb b/Data/Scripts/011_Data/001_Game data/001_Game data.rb index 8488f8211..915eb5091 100644 --- a/Data/Scripts/011_Data/001_Game data/001_Game data.rb +++ b/Data/Scripts/011_Data/001_Game data/001_Game data.rb @@ -140,5 +140,6 @@ module GameData Species.load Trainer.load Encounter.load + Ribbon.load end end diff --git a/Data/Scripts/011_Data/001_Game data/014_Ribbon.rb b/Data/Scripts/011_Data/001_Game data/014_Ribbon.rb new file mode 100644 index 000000000..77195cac5 --- /dev/null +++ b/Data/Scripts/011_Data/001_Game data/014_Ribbon.rb @@ -0,0 +1,31 @@ +module GameData + class Ribbon + attr_reader :id + attr_reader :id_number + attr_reader :real_name + attr_reader :real_description + + DATA = {} + DATA_FILENAME = "ribbons.dat" + + extend ClassMethods + include InstanceMethods + + def initialize(hash) + @id = hash[:id] + @id_number = hash[:id_number] || -1 + @real_name = hash[:name] || "Unnamed" + @real_description = hash[:description] || "???" + end + + # @return [String] the translated name of this ribbon + def name + return pbGetMessage(MessageTypes::RibbonNames, @id_number) + end + + # @return [String] the translated description of this ribbon + def description + return pbGetMessage(MessageTypes::RibbonDescriptions, @id_number) + end + end +end diff --git a/Data/Scripts/011_Data/Hardcoded game data/009_PBRibbons.rb b/Data/Scripts/011_Data/Hardcoded game data/009_PBRibbons.rb deleted file mode 100644 index 256a4810f..000000000 --- a/Data/Scripts/011_Data/Hardcoded game data/009_PBRibbons.rb +++ /dev/null @@ -1,258 +0,0 @@ -module PBRibbons - HOENNCOOL = 1 - HOENNCOOLSUPER = 2 - HOENNCOOLHYPER = 3 - HOENNCOOLMASTER = 4 - HOENNBEAUTY = 5 - HOENNBEAUTYSUPER = 6 - HOENNBEAUTYHYPER = 7 - HOENNBEAUTYMASTER = 8 - HOENNCUTE = 9 - HOENNCUTESUPER = 10 - HOENNCUTEHYPER = 11 - HOENNCUTEMASTER = 12 - HOENNSMART = 13 - HOENNSMARTSUPER = 14 - HOENNSMARTHYPER = 15 - HOENNSMARTMASTER = 16 - HOENNTOUGH = 17 - HOENNTOUGHSUPER = 18 - HOENNTOUGHHYPER = 19 - HOENNTOUGHMASTER = 20 - SINNOHCOOL = 21 - SINNOHCOOLSUPER = 22 - SINNOHCOOLHYPER = 23 - SINNOHCOOLMASTER = 24 - SINNOHBEAUTY = 25 - SINNOHBEAUTYSUPER = 26 - SINNOHBEAUTYHYPER = 27 - SINNOHBEAUTYMASTER = 28 - SINNOHCUTE = 29 - SINNOHCUTESUPER = 30 - SINNOHCUTEHYPER = 31 - SINNOHCUTEMASTER = 32 - SINNOHSMART = 33 - SINNOHSMARTSUPER = 34 - SINNOHSMARTHYPER = 35 - SINNOHSMARTMASTER = 36 - SINNOHTOUGH = 37 - SINNOHTOUGHSUPER = 38 - SINNOHTOUGHHYPER = 39 - SINNOHTOUGHMASTER = 40 - WINNING = 41 - VICTORY = 42 - ABILITY = 43 - GREATABILITY = 44 - DOUBLEABILITY = 45 - MULTIABILITY = 46 - PAIRABILITY = 47 - WORLDABILITY = 48 - CHAMPION = 49 - SINNOHCHAMP = 50 - RECORD = 51 - EVENT = 52 - LEGEND = 53 - GORGEOUS = 54 - ROYAL = 55 - GORGEOUSROYAL = 56 - ALERT = 57 - SHOCK = 58 - DOWNCAST = 59 - CARELESS = 60 - RELAX = 61 - SNOOZE = 62 - SMILE = 63 - FOOTPRINT = 64 - ARTIST = 65 - EFFORT = 66 - BIRTHDAY = 67 - SPECIAL = 68 - CLASSIC = 69 - PREMIER = 70 - SOUVENIR = 71 - WISHING = 72 - NATIONAL = 73 - COUNTRY = 74 - BATTLECHAMPION = 75 - REGIONALCHAMPION = 76 - EARTH = 77 - WORLD = 78 - NATIONALCHAMPION = 79 - WORLDCHAMPION = 80 - - def self.maxValue; 80; end - - def self.getName(id) - id = getID(PBRibbons,id) - names = ["", - _INTL("Cool Ribbon"), - _INTL("Cool Ribbon Super"), - _INTL("Cool Ribbon Hyper"), - _INTL("Cool Ribbon Master"), - _INTL("Beauty Ribbon"), - _INTL("Beauty Ribbon Super"), - _INTL("Beauty Ribbon Hyper"), - _INTL("Beauty Ribbon Master"), - _INTL("Cute Ribbon"), - _INTL("Cute Ribbon Super"), - _INTL("Cute Ribbon Hyper"), - _INTL("Cute Ribbon Master"), - _INTL("Smart Ribbon"), - _INTL("Smart Ribbon Super"), - _INTL("Smart Ribbon Hyper"), - _INTL("Smart Ribbon Master"), - _INTL("Tough Ribbon"), - _INTL("Tough Ribbon Super"), - _INTL("Tough Ribbon Hyper"), - _INTL("Tough Ribbon Master"), - _INTL("Cool Ribbon"), - _INTL("Cool Ribbon Great"), - _INTL("Cool Ribbon Ultra"), - _INTL("Cool Ribbon Master"), - _INTL("Beauty Ribbon"), - _INTL("Beauty Ribbon Great"), - _INTL("Beauty Ribbon Ultra"), - _INTL("Beauty Ribbon Master"), - _INTL("Cute Ribbon"), - _INTL("Cute Ribbon Great"), - _INTL("Cute Ribbon Ultra"), - _INTL("Cute Ribbon Master"), - _INTL("Smart Ribbon"), - _INTL("Smart Ribbon Great"), - _INTL("Smart Ribbon Ultra"), - _INTL("Smart Ribbon Master"), - _INTL("Tough Ribbon"), - _INTL("Tough Ribbon Great"), - _INTL("Tough Ribbon Ultra"), - _INTL("Tough Ribbon Master"), - _INTL("Winning Ribbon"), - _INTL("Victory Ribbon"), - _INTL("Ability Ribbon"), - _INTL("Great Ability Ribbon"), - _INTL("Double Ability Ribbon"), - _INTL("Multi Ability Ribbon"), - _INTL("Pair Ability Ribbon"), - _INTL("World Ability Ribbon"), - _INTL("Champion Ribbon"), - _INTL("Sinnoh Champ Ribbon"), - _INTL("Record Ribbon"), - _INTL("Event Ribbon"), - _INTL("Legend Ribbon"), - _INTL("Gorgeous Ribbon"), - _INTL("Royal Ribbon"), - _INTL("Gorgeous Royal Ribbon"), - _INTL("Alert Ribbon"), - _INTL("Shock Ribbon"), - _INTL("Downcast Ribbon"), - _INTL("Careless Ribbon"), - _INTL("Relax Ribbon"), - _INTL("Snooze Ribbon"), - _INTL("Smile Ribbon"), - _INTL("Footprint Ribbon"), - _INTL("Artist Ribbon"), - _INTL("Effort Ribbon"), - _INTL("Birthday Ribbon"), - _INTL("Special Ribbon"), - _INTL("Classic Ribbon"), - _INTL("Premier Ribbon"), - _INTL("Souvenir Ribbon"), - _INTL("Wishing Ribbon"), - _INTL("National Ribbon"), - _INTL("Country Ribbon"), - _INTL("Battle Champion Ribbon"), - _INTL("Regional Champion Ribbon"), - _INTL("Earth Ribbon"), - _INTL("World Ribbon"), - _INTL("National Champion Ribbon"), - _INTL("World Champion Ribbon") - ] - return names[id] - end - - def self.getDescription(id) - id = getID(PBRibbons,id) - desc = ["", - _INTL("Hoenn Cool Contest Normal Rank winner!"), - _INTL("Hoenn Cool Contest Super Rank winner!"), - _INTL("Hoenn Cool Contest Hyper Rank winner!"), - _INTL("Hoenn Cool Contest Master Rank winner!"), - _INTL("Hoenn Beauty Contest Normal Rank winner!"), - _INTL("Hoenn Beauty Contest Super Rank winner!"), - _INTL("Hoenn Beauty Contest Hyper Rank winner!"), - _INTL("Hoenn Beauty Contest Master Rank winner!"), - _INTL("Hoenn Cute Contest Normal Rank winner!"), - _INTL("Hoenn Cute Contest Super Rank winner!"), - _INTL("Hoenn Cute Contest Hyper Rank winner!"), - _INTL("Hoenn Cute Contest Master Rank winner!"), - _INTL("Hoenn Smart Contest Normal Rank winner!"), - _INTL("Hoenn Smart Contest Super Rank winner!"), - _INTL("Hoenn Smart Contest Hyper Rank winner!"), - _INTL("Hoenn Smart Contest Master Rank winner!"), - _INTL("Hoenn Tough Contest Normal Rank winner!"), - _INTL("Hoenn Tough Contest Super Rank winner!"), - _INTL("Hoenn Tough Contest Hyper Rank winner!"), - _INTL("Hoenn Tough Contest Master Rank winner!"), - _INTL("Super Contest Cool Category Normal Rank winner!"), - _INTL("Super Contest Cool Category Great Rank winner!"), - _INTL("Super Contest Cool Category Ultra Rank winner!"), - _INTL("Super Contest Cool Category Master Rank winner!"), - _INTL("Super Contest Beauty Category Normal Rank winner!"), - _INTL("Super Contest Beauty Category Great Rank winner!"), - _INTL("Super Contest Beauty Category Ultra Rank winner!"), - _INTL("Super Contest Beauty Category Master Rank winner!"), - _INTL("Super Contest Cute Category Normal Rank winner!"), - _INTL("Super Contest Cute Category Great Rank winner!"), - _INTL("Super Contest Cute Category Ultra Rank winner!"), - _INTL("Super Contest Cute Category Master Rank winner!"), - _INTL("Super Contest Smart Category Normal Rank winner!"), - _INTL("Super Contest Smart Category Great Rank winner!"), - _INTL("Super Contest Smart Category Ultra Rank winner!"), - _INTL("Super Contest Smart Category Master Rank winner!"), - _INTL("Super Contest Tough Category Normal Rank winner!"), - _INTL("Super Contest Tough Category Great Rank winner!"), - _INTL("Super Contest Tough Category Ultra Rank winner!"), - _INTL("Super Contest Tough Category Master Rank winner!"), - _INTL("Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 50 challenge."), - _INTL("Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 100 challenge."), - _INTL("A Ribbon awarded for defeating the Tower Tycoon at the Battle Tower."), - _INTL("A Ribbon awarded for defeating the Tower Tycoon at the Battle Tower."), - _INTL("A Ribbon awarded for completing the Battle Tower Double challenge."), - _INTL("A Ribbon awarded for completing the Battle Tower Multi challenge."), - _INTL("A Ribbon awarded for completing the Battle Tower Link Multi challenge."), - _INTL("A Ribbon awarded for completing the Wi-Fi Battle Tower challenge."), - _INTL("Ribbon for clearing the Pokémon League and entering the Hall of Fame in another region. "), - _INTL("Ribbon awarded for beating the Sinnoh Champion and entering the Hall of Fame."), - _INTL("A Ribbon awarded for setting an incredible record."), - _INTL("Pokémon Event Participation Ribbon."), - _INTL("A Ribbon awarded for setting a legendary record."), - _INTL("An extraordinarily gorgeous and extravagant Ribbon."), - _INTL("An incredibly regal Ribbon with an air of nobility."), - _INTL("A gorgeous and regal Ribbon that is the peak of fabulous."), - _INTL("A Ribbon for recalling an invigorating event that created life energy."), - _INTL("A Ribbon for recalling a thrilling event that made life more exciting."), - _INTL("A Ribbon for recalling feelings of sadness that added spice to life."), - _INTL("A Ribbon for recalling a careless error that helped steer life decisions."), - _INTL("A Ribbon for recalling a refreshing event that added sparkle to life."), - _INTL("A Ribbon for recalling a deep slumber that made life soothing."), - _INTL("A Ribbon for recalling that smiles enrich the quality of life."), - _INTL("A Ribbon awarded to a Pokémon deemed to have a top-quality footprint."), - _INTL("Ribbon awarded for being chosen as a super sketch model in Hoenn."), - _INTL("Ribbon awarded for being an exceptionally hard worker."), - _INTL("A Ribbon to celebrate a birthday."), - _INTL("A special Ribbon for a special day."), - _INTL("A Ribbon that proclaims love for Pokémon."), - _INTL("Special Holiday Ribbon."), - _INTL("A Ribbon to cherish a special memory."), - _INTL("A Ribbon said to make your wish come true."), - _INTL("A Ribbon awarded for overcoming all difficult challenges."), - _INTL("Pokémon League Champion Ribbon."), - _INTL("Battle Competition Champion Ribbon."), - _INTL("Pokémon World Championships Regional Champion Ribbon."), - _INTL("A Ribbon awarded for winning 100 matches in a row."), - _INTL("Pokémon League Champion Ribbon."), - _INTL("Pokémon World Championships National Champion Ribbon."), - _INTL("Pokémon World Championships World Champion Ribbon.") - ] - return desc[id] - end -end diff --git a/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb index 2640ba00e..d7077410e 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon-related/004_Pokemon_ShadowPokemon.rb @@ -19,7 +19,7 @@ critical hit. def pbPurify(pkmn, scene) return if !pkmn.shadowPokemon? || pkmn.heart_gauge != 0 pkmn.shadow = false - pkmn.giveRibbon(PBRibbons::NATIONAL) + pkmn.giveRibbon(:NATIONAL) scene.pbDisplay(_INTL("{1} opened the door to its heart!", pkmn.name)) old_moves = [] pkmn.moves.each { |m| old_moves.push(m.id) } diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 2f0b2dd22..cefc0ca44 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -35,7 +35,7 @@ class Pokemon attr_accessor :moves # @return [Array] the IDs of moves known by this Pokémon when it was obtained attr_accessor :first_moves - # @return [Array] an array of ribbons owned by this Pokémon + # @return [Array] an array of ribbons owned by this Pokémon attr_accessor :ribbons # @return [Integer] contest stats attr_accessor :cool, :beauty, :cute, :smart, :tough, :sheen @@ -662,50 +662,56 @@ class Pokemon return @ribbons.length end - # @param ribbon [Integer, Symbol, String] ribbon ID to check + # @param ribbon [Symbol, String, GameData::Ribbon, Integer] ribbon ID to check for # @return [Boolean] whether this Pokémon has the specified ribbon def hasRibbon?(ribbon) - ribbon = getID(PBRibbons, ribbon) - return ribbon > 0 && @ribbons.include?(ribbon) + ribbon_data = GameData::Ribbon.try_get(ribbon) + return ribbon_data && @ribbons.include?(ribbon_data.id) end # Gives a ribbon to this Pokémon. - # @param ribbon [Integer, Symbol, String] ID of the ribbon to give + # @param ribbon [Symbol, String, GameData::Ribbon, Integer] ID of the ribbon to give def giveRibbon(ribbon) - ribbon = getID(PBRibbons, ribbon) - return if ribbon == 0 - @ribbons.push(ribbon) if !@ribbons.include?(ribbon) + ribbon_data = GameData::Ribbon.try_get(ribbon) + return if !ribbon_data || @ribbons.include?(ribbon_data.id) + @ribbons.push(ribbon_data.id) end - # Replaces one ribbon with the next one along, if possible. + # Replaces one ribbon with the next one along, if possible. If none of the + # given ribbons are owned, give the first one. + # @return [Symbol, nil] ID of the ribbon that was gained def upgradeRibbon(*arg) for i in 0...arg.length - 1 + this_ribbon_data = GameData::Ribbon.try_get(i) + next if !this_ribbon_data for j in 0...@ribbons.length - next if @ribbons[j] != getID(PBRibbons, arg[i]) - @ribbons[j] = getID(PBRibbons, arg[i + 1]) + next if @ribbons[j] != this_ribbon_data.id + next_ribbon_data = GameData::Ribbon.try_get(arg[i + 1]) + next if !next_ribbon_data + @ribbons[j] = next_ribbon_data.id return @ribbons[j] end end - if !hasRibbon?(arg[arg.length - 1]) - first_ribbon = getID(PBRibbons, arg[0]) - giveRibbon(first_ribbon) - return first_ribbon + first_ribbon_data = GameData::Ribbon.try_get(arg[0]) + last_ribbon_data = GameData::Ribbon.try_get(arg[arg.length - 1]) + if first_ribbon_data && last_ribbon_data && !hasRibbon?(last_ribbon_data.id) + giveRibbon(first_ribbon_data.id) + return first_ribbon_data.id end - return 0 + return nil end # Removes the specified ribbon from this Pokémon. - # @param ribbon [Integer, Symbol, String] id of the ribbon to remove + # @param ribbon [Symbol, String, GameData::Ribbon, Integer] ID of the ribbon to remove def takeRibbon(ribbon) - return if !@ribbons - ribbon = getID(PBRibbons, ribbon) - return if ribbon == 0 + ribbon_data = GameData::Ribbon.try_get(ribbon) + return if !ribbon_data for i in 0...@ribbons.length - next if @ribbons[i] != ribbon + next if @ribbons[i] != ribbon_data.id @ribbons[i] = nil + @ribbons.compact! break end - @ribbons.compact! end # Removes all ribbons from this Pokémon. diff --git a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb index eb28479a0..d5b383bf7 100644 --- a/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/010_Pokemon_Deprecated.rb @@ -27,62 +27,64 @@ class PokeBattle_Pokemon def self.copy(pkmn) owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language) ret = Pokemon.new(pkmn.species, pkmn.level, owner, false) - ret.forced_form = pkmn.forcedForm if pkmn.forcedForm - ret.time_form_set = pkmn.formTime - ret.exp = pkmn.exp - ret.steps_to_hatch = pkmn.eggsteps - ret.status = pkmn.status - ret.statusCount = pkmn.statusCount - ret.gender = pkmn.genderflag - ret.shiny = pkmn.shinyflag - ret.ability_index = pkmn.abilityflag - ret.nature = pkmn.natureflag + ret.forced_form = pkmn.forcedForm if pkmn.forcedForm + ret.time_form_set = pkmn.formTime + ret.exp = pkmn.exp + ret.steps_to_hatch = pkmn.eggsteps + ret.status = pkmn.status + ret.statusCount = pkmn.statusCount + ret.gender = pkmn.genderflag + ret.shiny = pkmn.shinyflag + ret.ability_index = pkmn.abilityflag + ret.nature = pkmn.natureflag ret.nature_for_stats = pkmn.natureOverride - ret.item = pkmn.item - ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail + ret.item = pkmn.item + ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 } pkmn.firstmoves.each { |m| ret.add_first_move(m) } - ret.ribbons = pkmn.ribbons.clone if pkmn.ribbons - ret.cool = pkmn.cool if pkmn.cool - ret.beauty = pkmn.beauty if pkmn.beauty - ret.cute = pkmn.cute if pkmn.cute - ret.smart = pkmn.smart if pkmn.smart - ret.tough = pkmn.tough if pkmn.tough - ret.sheen = pkmn.sheen if pkmn.sheen - ret.pokerus = pkmn.pokerus if pkmn.pokerus - ret.name = pkmn.name - ret.happiness = pkmn.happiness - ret.poke_ball = pbBallTypeToItem(pkmn.ballused) - ret.markings = pkmn.markings if pkmn.markings - ret.iv = pkmn.iv.clone - ret.ivMaxed = pkmn.ivMaxed.clone if pkmn.ivMaxed - ret.ev = pkmn.ev.clone - ret.obtain_method = pkmn.obtainMode - ret.obtain_map = pkmn.obtainMap - ret.obtain_text = pkmn.obtainText - ret.obtain_level = pkmn.obtainLevel if pkmn.obtainLevel - ret.hatched_map = pkmn.hatchedMap - ret.timeReceived = pkmn.timeReceived - ret.timeEggHatched = pkmn.timeEggHatched + if pkmn.ribbons + pkmn.ribbons.each { |r| ret.giveRibbon(r) } + end + ret.cool = pkmn.cool if pkmn.cool + ret.beauty = pkmn.beauty if pkmn.beauty + ret.cute = pkmn.cute if pkmn.cute + ret.smart = pkmn.smart if pkmn.smart + ret.tough = pkmn.tough if pkmn.tough + ret.sheen = pkmn.sheen if pkmn.sheen + ret.pokerus = pkmn.pokerus if pkmn.pokerus + ret.name = pkmn.name + ret.happiness = pkmn.happiness + ret.poke_ball = pbBallTypeToItem(pkmn.ballused) + ret.markings = pkmn.markings if pkmn.markings + ret.iv = pkmn.iv.clone + ret.ivMaxed = pkmn.ivMaxed.clone if pkmn.ivMaxed + ret.ev = pkmn.ev.clone + ret.obtain_method = pkmn.obtainMode + ret.obtain_map = pkmn.obtainMap + ret.obtain_text = pkmn.obtainText + ret.obtain_level = pkmn.obtainLevel if pkmn.obtainLevel + ret.hatched_map = pkmn.hatchedMap + ret.timeReceived = pkmn.timeReceived + ret.timeEggHatched = pkmn.timeEggHatched if pkmn.fused ret.fused = PokeBattle_Pokemon.copy(pkmn.fused) if pkmn.fused.is_a?(PokeBattle_Pokemon) ret.fused = pkmn.fused if pkmn.fused.is_a?(Pokemon) end - ret.personalID = pkmn.personalID - ret.hp = pkmn.hp + ret.personalID = pkmn.personalID + ret.hp = pkmn.hp if pkmn.shadow - ret.shadow = pkmn.shadow - ret.heart_gauge = pkmn.heartgauge - ret.hyper_mode = pkmn.hypermode - ret.saved_exp = pkmn.savedexp - ret.saved_ev = pkmn.savedev.clone - ret.shadow_moves = [] + ret.shadow = pkmn.shadow + ret.heart_gauge = pkmn.heartgauge + ret.hyper_mode = pkmn.hypermode + ret.saved_exp = pkmn.savedexp + ret.saved_ev = pkmn.savedev.clone + ret.shadow_moves = [] pkmn.shadowmoves.each_with_index do |move, i| ret.shadow_moves[i] = GameData::Move.get(move).id if move end end # NOTE: Intentionally set last, as it recalculates stats. - ret.form_simple = pkmn.form || 0 + ret.form_simple = pkmn.form || 0 return ret end end diff --git a/Data/Scripts/017_UI/006_PScreen_Summary.rb b/Data/Scripts/017_UI/006_PScreen_Summary.rb index e462ffa6c..f0d5f956b 100644 --- a/Data/Scripts/017_UI/006_PScreen_Summary.rb +++ b/Data/Scripts/017_UI/006_PScreen_Summary.rb @@ -838,15 +838,14 @@ class PokemonSummary_Scene # Show all ribbons imagepos = [] coord = 0 - if @pokemon.ribbons - for i in @ribbonOffset*4...@ribbonOffset*4+12 - break if !@pokemon.ribbons[i] - ribn = @pokemon.ribbons[i]-1 - imagepos.push(["Graphics/Pictures/ribbons",230+68*(coord%4),78+68*(coord/4).floor, - 64*(ribn%8),64*(ribn/8).floor,64,64]) - coord += 1 - break if coord>=12 - end + for i in @ribbonOffset*4...@ribbonOffset*4+12 + break if !@pokemon.ribbons[i] + ribbon_data = GameData::Ribbon.get(@pokemon.ribbons[i]) + ribn = ribbon_data.id_number - 1 + imagepos.push(["Graphics/Pictures/ribbons", + 230 + 68 * (coord % 4), 78 + 68 * (coord / 4).floor, + 64 * (ribn % 8), 64 * (ribn / 8).floor, 64, 64]) + coord += 1 end # Draw all images pbDrawImagePositions(overlay,imagepos) @@ -862,8 +861,8 @@ class PokemonSummary_Scene nameBase = Color.new(248,248,248) nameShadow = Color.new(104,104,104) # Get data for selected ribbon - name = ribbonid ? PBRibbons.getName(ribbonid) : "" - desc = ribbonid ? PBRibbons.getDescription(ribbonid) : "" + name = ribbonid ? GameData::Ribbon.get(ribbonid).name : "" + desc = ribbonid ? GameData::Ribbon.get(ribbonid).description : "" # Draw the description box imagepos = [ ["Graphics/Pictures/Summary/overlay_ribbon",8,280] diff --git a/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb b/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb index 62df3a3b0..7c561ca49 100644 --- a/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb +++ b/Data/Scripts/021_Debug/001_Debug menus/004_Debug_PokemonCommands.rb @@ -840,28 +840,28 @@ PokemonDebugMenuCommands.register("setribbons", { cmd = 0 loop do commands = [] - for i in 1..PBRibbons.maxValue + ids = [] + GameData::Ribbon.each do |ribbon_data| commands.push(_INTL("{1} {2}", - (pkmn.hasRibbon?(i)) ? "[Y]" : "[ ]", PBRibbons.getName(i))) + (pkmn.hasRibbon?(ribbon_data.id)) ? "[Y]" : "[ ]", ribbon_data.name)) + ids.push(ribbon_data.id) end commands.push(_INTL("Give all")) commands.push(_INTL("Clear all")) cmd = screen.pbShowCommands(_INTL("{1} ribbons.", pkmn.numRibbons), commands, cmd) break if cmd < 0 - if cmd >= 0 && cmd < PBRibbons.maxValue # Toggle ribbon - if pkmn.hasRibbon?(cmd + 1) - pkmn.takeRibbon(cmd + 1) + if cmd >= 0 && cmd < ids.length # Toggle ribbon + if pkmn.hasRibbon?(ids[cmd]) + pkmn.takeRibbon(ids[cmd]) else - pkmn.giveRibbon(cmd + 1) + pkmn.giveRibbon(ids[cmd]) end elsif cmd == commands.length - 2 # Give all - for i in 1..PBRibbons.maxValue - pkmn.giveRibbon(i) + GameData::Ribbon.each do |ribbon_data| + pkmn.giveRibbon(ribbon_data.id) end elsif cmd == commands.length - 1 # Clear all - for i in 1..PBRibbons.maxValue - pkmn.takeRibbon(i) - end + pkmn.clearAllRibbons end end } diff --git a/Data/Scripts/022_Compiler/001_Compiler.rb b/Data/Scripts/022_Compiler/001_Compiler.rb index a7b76c9e1..9f3c665ca 100644 --- a/Data/Scripts/022_Compiler/001_Compiler.rb +++ b/Data/Scripts/022_Compiler/001_Compiler.rb @@ -707,6 +707,8 @@ module Compiler compile_shadow_movesets # Depends on Species, Move yield(_INTL("Compiling Regional Dexes")) compile_regional_dexes # Depends on Species + yield(_INTL("Compiling ribbon data")) + compile_ribbons # No dependencies yield(_INTL("Compiling encounter data")) compile_encounters # Depends on Species yield(_INTL("Compiling Trainer type data")) @@ -743,6 +745,7 @@ module Compiler "moves.dat", "phone.dat", "regional_dexes.dat", + "ribbons.dat", "shadow_movesets.dat", "species.dat", "species_eggmoves.dat", @@ -768,6 +771,7 @@ module Compiler "pokemon.txt", "pokemonforms.txt", "regionaldexes.txt", + "ribbons.txt", "shadowmoves.txt", "townmap.txt", "trainerlists.txt", diff --git a/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb index 8893402c0..a7f607a29 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_CompilePBS.rb @@ -823,6 +823,41 @@ module Compiler Graphics.update end + #============================================================================= + # Compile ribbon data + #============================================================================= + def compile_ribbons + GameData::Ribbon::DATA.clear + ribbon_names = [] + ribbon_descriptions = [] + pbCompilerEachPreppedLine("PBS/ribbons.txt") { |line, line_no| + line = pbGetCsvRecord(line, line_no, [0, "vnss"]) + ribbon_number = line[0] + ribbon_symbol = line[1].to_sym + if GameData::Ribbon::DATA[ribbon_number] + raise _INTL("Ribbon ID number '{1}' is used twice.\r\n{2}", ribbon_number, FileLineData.linereport) + elsif GameData::Ribbon::DATA[ribbon_symbol] + raise _INTL("Ribbon ID '{1}' is used twice.\r\n{2}", ribbon_symbol, FileLineData.linereport) + end + # Construct ribbon hash + ribbon_hash = { + :id => ribbon_symbol, + :id_number => ribbon_number, + :name => line[2], + :description => line[3] + } + # Add ribbon's data to records + GameData::Ribbon.register(ribbon_hash) + ribbon_names[ribbon_number] = ribbon_hash[:name] + ribbon_descriptions[ribbon_number] = ribbon_hash[:description] + } + # Save all data + GameData::Ribbon.save + MessageTypes.setMessages(MessageTypes::RibbonNames, ribbon_names) + MessageTypes.setMessages(MessageTypes::RibbonDescriptions, ribbon_descriptions) + Graphics.update + end + #============================================================================= # Compile wild encounter data #============================================================================= diff --git a/Data/Scripts/022_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/022_Compiler/003_Compiler_WritePBS.rb index 75cba228d..08bc37b23 100644 --- a/Data/Scripts/022_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/022_Compiler/003_Compiler_WritePBS.rb @@ -35,9 +35,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save map connections to PBS file - #=============================================================================== + #============================================================================= def normalize_connection(conn) ret = conn.clone if conn[1] < 0 && conn[4] < 0 @@ -96,9 +96,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save phone messages to PBS file - #=============================================================================== + #============================================================================= def write_phone data = load_data("Data/phone.dat") rescue nil return if !data @@ -129,9 +129,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save type data to PBS file - #=============================================================================== + #============================================================================= def write_types File.open("PBS/types.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -151,9 +151,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save ability data to PBS file - #=============================================================================== + #============================================================================= def write_abilities File.open("PBS/abilities.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -170,9 +170,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save move data to PBS file - #=============================================================================== + #============================================================================= def write_moves File.open("PBS/moves.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -203,9 +203,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save item data to PBS file - #=============================================================================== + #============================================================================= def write_items File.open("PBS/items.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -236,9 +236,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save berry plant data to PBS file - #=============================================================================== + #============================================================================= def write_berry_plants File.open("PBS/berryplants.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -256,9 +256,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Pokémon data to PBS file - #=============================================================================== + #============================================================================= def write_pokemon File.open("PBS/pokemon.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -351,9 +351,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Pokémon forms data to PBS file - #=============================================================================== + #============================================================================= def write_pokemon_forms File.open("PBS/pokemonforms.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -455,9 +455,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Shadow movesets to PBS file - #=============================================================================== + #============================================================================= def write_shadow_movesets shadow_movesets = pbLoadShadowMovesets File.open("PBS/shadowmoves.txt", "wb") { |f| @@ -472,9 +472,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Regional Dexes to PBS file - #=============================================================================== + #============================================================================= def write_regional_dexes dex_lists = pbLoadRegionalDexes File.open("PBS/regionaldexes.txt", "wb") { |f| @@ -503,9 +503,28 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= + # Save ability data to PBS file + #============================================================================= + def write_ribbons + File.open("PBS/ribbons.txt", "wb") { |f| + add_PBS_header_to_file(f) + f.write("\#-------------------------------\r\n") + GameData::Ribbon.each do |r| + f.write(sprintf("%d,%s,%s,%s\r\n", + r.id_number, + csvQuote(r.id.to_s), + csvQuote(r.real_name), + csvQuoteAlways(r.real_description) + )) + end + } + Graphics.update + end + + #============================================================================= # Save wild encounter data to PBS file - #=============================================================================== + #============================================================================= def write_encounters map_infos = load_data("Data/MapInfos.rxdata") File.open("PBS/encounters.txt", "wb") { |f| @@ -538,9 +557,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save trainer type data to PBS file - #=============================================================================== + #============================================================================= def write_trainer_types File.open("PBS/trainertypes.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -563,9 +582,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save individual trainer data to PBS file - #=============================================================================== + #============================================================================= def write_trainers File.open("PBS/trainers.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -607,9 +626,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save trainer list data to PBS file - #=============================================================================== + #============================================================================= def write_trainer_lists trainerlists = load_data("Data/trainer_lists.dat") rescue nil return if !trainerlists @@ -628,9 +647,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Battle Tower trainer data to PBS file - #=============================================================================== + #============================================================================= def write_battle_tower_trainers(bttrainers, filename) return if !bttrainers || !filename btTrainersRequiredTypes = { @@ -666,9 +685,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save Battle Tower Pokémon data to PBS file - #=============================================================================== + #============================================================================= def write_battle_tower_pokemon(btpokemon,filename) return if !btpokemon || !filename species = { 0 => "" } @@ -703,9 +722,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save metadata data to PBS file - #=============================================================================== + #============================================================================= def write_metadata File.open("PBS/metadata.txt", "wb") { |f| add_PBS_header_to_file(f) @@ -744,9 +763,9 @@ module Compiler Graphics.update end - #=============================================================================== + #============================================================================= # Save all data to PBS files - #=============================================================================== + #============================================================================= def write_all write_town_map write_connections @@ -760,6 +779,7 @@ module Compiler write_pokemon_forms write_shadow_movesets write_regional_dexes + write_ribbons write_encounters write_trainer_types write_trainers diff --git a/PBS/ribbons.txt b/PBS/ribbons.txt new file mode 100644 index 000000000..272368a29 --- /dev/null +++ b/PBS/ribbons.txt @@ -0,0 +1,82 @@ +# See the documentation on the wiki to learn how to edit this file. +#------------------------------- +1,HOENNCOOL,Cool Ribbon,"Hoenn Cool Contest Normal Rank winner!" +2,HOENNCOOLSUPER,Cool Ribbon Super,"Hoenn Cool Contest Super Rank winner!" +3,HOENNCOOLHYPER,Cool Ribbon Hyper,"Hoenn Cool Contest Hyper Rank winner!" +4,HOENNCOOLMASTER,Cool Ribbon Master,"Hoenn Cool Contest Master Rank winner!" +5,HOENNBEAUTY,Beauty Ribbon,"Hoenn Beauty Contest Normal Rank winner!" +6,HOENNBEAUTYSUPER,Beauty Ribbon Super,"Hoenn Beauty Contest Super Rank winner!" +7,HOENNBEAUTYHYPER,Beauty Ribbon Hyper,"Hoenn Beauty Contest Hyper Rank winner!" +8,HOENNBEAUTYMASTER,Beauty Ribbon Master,"Hoenn Beauty Contest Master Rank winner!" +9,HOENNCUTE,Cute Ribbon,"Hoenn Cute Contest Normal Rank winner!" +10,HOENNCUTESUPER,Cute Ribbon Super,"Hoenn Cute Contest Super Rank winner!" +11,HOENNCUTEHYPER,Cute Ribbon Hyper,"Hoenn Cute Contest Hyper Rank winner!" +12,HOENNCUTEMASTER,Cute Ribbon Master,"Hoenn Cute Contest Master Rank winner!" +13,HOENNSMART,Smart Ribbon,"Hoenn Smart Contest Normal Rank winner!" +14,HOENNSMARTSUPER,Smart Ribbon Super,"Hoenn Smart Contest Super Rank winner!" +15,HOENNSMARTHYPER,Smart Ribbon Hyper,"Hoenn Smart Contest Hyper Rank winner!" +16,HOENNSMARTMASTER,Smart Ribbon Master,"Hoenn Smart Contest Master Rank winner!" +17,HOENNTOUGH,Tough Ribbon,"Hoenn Tough Contest Normal Rank winner!" +18,HOENNTOUGHSUPER,Tough Ribbon Super,"Hoenn Tough Contest Super Rank winner!" +19,HOENNTOUGHHYPER,Tough Ribbon Hyper,"Hoenn Tough Contest Hyper Rank winner!" +20,HOENNTOUGHMASTER,Tough Ribbon Master,"Hoenn Tough Contest Master Rank winner!" +21,SINNOHCOOL,Cool Ribbon,"Super Contest Cool Category Normal Rank winner!" +22,SINNOHCOOLSUPER,Cool Ribbon Great,"Super Contest Cool Category Great Rank winner!" +23,SINNOHCOOLHYPER,Cool Ribbon Ultra,"Super Contest Cool Category Ultra Rank winner!" +24,SINNOHCOOLMASTER,Cool Ribbon Master,"Super Contest Cool Category Master Rank winner!" +25,SINNOHBEAUTY,Beauty Ribbon,"Super Contest Beauty Category Normal Rank winner!" +26,SINNOHBEAUTYSUPER,Beauty Ribbon Great,"Super Contest Beauty Category Great Rank winner!" +27,SINNOHBEAUTYHYPER,Beauty Ribbon Ultra,"Super Contest Beauty Category Ultra Rank winner!" +28,SINNOHBEAUTYMASTER,Beauty Ribbon Master,"Super Contest Beauty Category Master Rank winner!" +29,SINNOHCUTE,Cute Ribbon,"Super Contest Cute Category Normal Rank winner!" +30,SINNOHCUTESUPER,Cute Ribbon Great,"Super Contest Cute Category Great Rank winner!" +31,SINNOHCUTEHYPER,Cute Ribbon Ultra,"Super Contest Cute Category Ultra Rank winner!" +32,SINNOHCUTEMASTER,Cute Ribbon Master,"Super Contest Cute Category Master Rank winner!" +33,SINNOHSMART,Smart Ribbon,"Super Contest Smart Category Normal Rank winner!" +34,SINNOHSMARTSUPER,Smart Ribbon Great,"Super Contest Smart Category Great Rank winner!" +35,SINNOHSMARTHYPER,Smart Ribbon Ultra,"Super Contest Smart Category Ultra Rank winner!" +36,SINNOHSMARTMASTER,Smart Ribbon Master,"Super Contest Smart Category Master Rank winner!" +37,SINNOHTOUGH,Tough Ribbon,"Super Contest Tough Category Normal Rank winner!" +38,SINNOHTOUGHSUPER,Tough Ribbon Great,"Super Contest Tough Category Great Rank winner!" +39,SINNOHTOUGHHYPER,Tough Ribbon Ultra,"Super Contest Tough Category Ultra Rank winner!" +40,SINNOHTOUGHMASTER,Tough Ribbon Master,"Super Contest Tough Category Master Rank winner!" +41,WINNING,Winning Ribbon,"Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 50 challenge." +42,VICTORY,Victory Ribbon,"Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 100 challenge." +43,ABILITY,Ability Ribbon,"A Ribbon awarded for defeating the Tower Tycoon at the Battle Tower." +44,GREATABILITY,Great Ability Ribbon,"A Ribbon awarded for defeating the Tower Tycoon at the Battle Tower." +45,DOUBLEABILITY,Double Ability Ribbon,"A Ribbon awarded for completing the Battle Tower Double challenge." +46,MULTIABILITY,Multi Ability Ribbon,"A Ribbon awarded for completing the Battle Tower Multi challenge." +47,PAIRABILITY,Pair Ability Ribbon,"A Ribbon awarded for completing the Battle Tower Link Multi challenge." +48,WORLDABILITY,World Ability Ribbon,"A Ribbon awarded for completing the Wi-Fi Battle Tower challenge." +49,CHAMPION,Champion Ribbon,"Ribbon for clearing the Pokémon League and entering the Hall of Fame in another region. " +50,SINNOHCHAMP,Sinnoh Champ Ribbon,"Ribbon awarded for beating the Sinnoh Champion and entering the Hall of Fame." +51,RECORD,Record Ribbon,"A Ribbon awarded for setting an incredible record." +52,EVENT,Event Ribbon,"Pokémon Event Participation Ribbon." +53,LEGEND,Legend Ribbon,"A Ribbon awarded for setting a legendary record." +54,GORGEOUS,Gorgeous Ribbon,"An extraordinarily gorgeous and extravagant Ribbon." +55,ROYAL,Royal Ribbon,"An incredibly regal Ribbon with an air of nobility." +56,GORGEOUSROYAL,Gorgeous Royal Ribbon,"A gorgeous and regal Ribbon that is the peak of fabulous." +57,ALERT,Alert Ribbon,"A Ribbon for recalling an invigorating event that created life energy." +58,SHOCK,Shock Ribbon,"A Ribbon for recalling a thrilling event that made life more exciting." +59,DOWNCAST,Downcast Ribbon,"A Ribbon for recalling feelings of sadness that added spice to life." +60,CARELESS,Careless Ribbon,"A Ribbon for recalling a careless error that helped steer life decisions." +61,RELAX,Relax Ribbon,"A Ribbon for recalling a refreshing event that added sparkle to life." +62,SNOOZE,Snooze Ribbon,"A Ribbon for recalling a deep slumber that made life soothing." +63,SMILE,Smile Ribbon,"A Ribbon for recalling that smiles enrich the quality of life." +64,FOOTPRINT,Footprint Ribbon,"A Ribbon awarded to a Pokémon deemed to have a top-quality footprint." +65,ARTIST,Artist Ribbon,"Ribbon awarded for being chosen as a super sketch model in Hoenn." +66,EFFORT,Effort Ribbon,"Ribbon awarded for being an exceptionally hard worker." +67,BIRTHDAY,Birthday Ribbon,"A Ribbon to celebrate a birthday." +68,SPECIAL,Special Ribbon,"A special Ribbon for a special day." +69,CLASSIC,Classic Ribbon,"A Ribbon that proclaims love for Pokémon." +70,PREMIER,Premier Ribbon,"Special Holiday Ribbon." +71,SOUVENIR,Souvenir Ribbon,"A Ribbon to cherish a special memory." +72,WISHING,Wishing Ribbon,"A Ribbon said to make your wish come true." +73,NATIONAL,National Ribbon,"A Ribbon awarded for overcoming all difficult challenges." +74,COUNTRY,Country Ribbon,"Pokémon League Champion Ribbon." +75,BATTLECHAMPION,Battle Champion Ribbon,"Battle Competition Champion Ribbon." +76,REGIONALCHAMPION,Regional Champion Ribbon,"Pokémon World Championships Regional Champion Ribbon." +77,EARTH,Earth Ribbon,"A Ribbon awarded for winning 100 matches in a row." +78,WORLD,World Ribbon,"Pokémon League Champion Ribbon." +79,NATIONALCHAMPION,National Champion Ribbon,"Pokémon World Championships National Champion Ribbon." +80,WORLDCHAMPION,World Champion Ribbon,"Pokémon World Championships World Champion Ribbon." \ No newline at end of file