Minor new additions for v20 (#147)

* Moved TMs/ TRs and HMs into their own handlers
* Improved Plugin Error Message
* Added sound effect when picking berries
* Allow player to always see quantity when buying items
* Trainers now require a Mega Ring item in their items (in trainers.txt) to Mega Evolve
This commit is contained in:
Golisopod-User
2021-12-30 00:06:26 +05:30
committed by GitHub
parent fb29f19a28
commit 13cc9790ce
11 changed files with 81 additions and 46 deletions

View File

@@ -54,6 +54,7 @@ class Battle
attr_reader :player # Player trainer (or array of trainers)
attr_reader :opponent # Opponent trainer (or array of trainers)
attr_accessor :items # Items held by opponents
attr_accessor :ally_items # Items held by allies
attr_accessor :endSpeeches
attr_accessor :endSpeechesWin
attr_accessor :party1starts # Array of start indexes for each player-side trainer's party
@@ -119,6 +120,7 @@ class Battle
@player = player # Array of Player/NPCTrainer objects, or nil
@opponent = opponent # Array of NPCTrainer objects, or nil
@items = nil
@ally_items = nil # Array of items held by ally. This is just used for Mega Evolution for now.
@endSpeeches = []
@endSpeechesWin = []
@party1 = p1
@@ -167,6 +169,8 @@ class Battle
else
@struggle = Move::Struggle.new(self, nil)
end
@mega_rings = []
GameData::Item.each { |item| @mega_rings.push(item.id) if item.has_flag?("MegaRing") }
end
#=============================================================================
@@ -259,8 +263,14 @@ class Battle
end
def pbGetOwnerItems(idxBattler)
return [] if !@items || !opposes?(idxBattler)
return @items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
if opposes?(idxBattler)
return [] if !@items
return @items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
else
return [] if !@ally_items
return @ally_items[pbGetOwnerIndexFromBattlerIndex(idxBattler)]
end
return []
end
# Returns whether the battler in position idxBattler is owned by the same

View File

@@ -62,21 +62,25 @@ class Battle
# Choosing to Mega Evolve a battler
#=============================================================================
def pbHasMegaRing?(idxBattler)
return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring
Settings::MEGA_RINGS.each { |item| return true if $bag.has?(item) }
if pbOwnedByPlayer?(idxBattler)
@mega_rings.each { |item| return true if $bag.has?(item) }
else
trainer_items = pbGetOwnerItems(idxBattler)
return false if !trainer_items
@mega_rings.each { |item| return true if trainer_items.include?(item) }
end
return false
end
def pbGetMegaRingName(idxBattler)
if pbOwnedByPlayer?(idxBattler)
Settings::MEGA_RINGS.each do |item|
return GameData::Item.get(item).name if $bag.has?(item)
if !@mega_rings.empty?
if pbOwnedByPlayer?(idxBattler)
@mega_rings.each { |item| return GameData::Item.get(item).name if $bag.has?(item) }
else
trainer_items = pbGetOwnerItems(idxBattler)
@mega_rings.each { |item| return GameData::Item.get(item).name if trainer_items&.include?(item) }
end
end
# NOTE: Add your own Mega objects for particular NPC trainers here.
# if pbGetOwnerFromBattlerIndex(idxBattler).trainer_type == :BUGCATCHER
# return _INTL("Mega Net")
# end
return _INTL("Mega Ring")
end