Mocno robocza wersja. Ale może dojdziemy do czegoś...
class RPG::Weapon < RPG::EquipItem
attr_accessor :can_use
attr_accessor :ammo_type
def can_use_ini
@can_use = true
@ammo_type = false
self.note.split(/[\r\n]+/).each { |line|
@ammo_type = true if line =~ /<(?:AMMO_TYPE|ammo_type)>/i
}
end
end
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class << DataManager
alias aye_dataman_loaddata load_database
end
def self.load_database
aye_dataman_loaddata
for weapon in $data_weapons
next if weapon.nil?
weapon.can_use_ini
end
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Determine Usability of Normal Attack
#--------------------------------------------------------------------------
def attack_usable?
for weapon in weapons
return false if weapon.ammo_type and !weapon.can_use
end
super
end
end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Increase/Decrease Items
#--------------------------------------------------------------------------
alias aye_gmparty_gain_item gain_item
def gain_item(*args)
item = args[0]
if item.is_a?(RPG::Weapon)
item.can_use = true if item.ammo_type
end
aye_gmparty_gain_item(*args)
end
end
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Add Attack Command to List
#--------------------------------------------------------------------------
def add_attack_command
text = Vocab::attack
for weapon in @actor.weapons
if weapon.ammo_type
amount = !weapon.can_use ? 0 : $game_party.item_number(weapon) + 1
text += sprintf("(%d)", amount)
end
end
add_command(text, :attack, @actor.attack_usable?)
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Execute Battle Actions
#--------------------------------------------------------------------------
alias aye_scbat_execute_action execute_action
def execute_action
if @subject.actor?
for weapon in @subject.weapons
if weapon.ammo_type
$game_party.item_number(weapon) == 0 ? weapon.can_use = false : $game_party.lose_item(weapon, 1, false)
end
end
end
aye_scbat_execute_action
end
end
Jeśli wpiszesz w oknie notatek broni <ammo_type> przyjmie ją jako zużywalną.