#==============================================================================
# Game_Ammo
#------------------------------------------------------------------------------
# Stores and gives info on ammunitions.
#==============================================================================
class Game_Ammo
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
#YOU CAN EDIT WHAT IS BELOW
#For each of the arrays below, you need to fill them with sub arrays in this format:
#[weapon/skill id, item ammo id]
#Weapon example: @w_ammo = [[1, 1], [2, 1], [3, 2]] woould make it so weapon 1 (bronze sword)
#needs item 1 (potions) as its ammo, weapon 2 (iron sword) also uses potions for ammo.
#weapon 3 (steel sword) uses item 2 (high potions) for ammo.
#Skill example: @w_ammo = [[1, 1], [2, 1], [3, 2]] woould make it so skill 1 (heal)
#needs item 1 (potions) as its ammo, skill 2 (heal force) also uses potions for ammo.
#skill 3 (heal omega) uses item 2 (high potions) for ammo.
@w_ammo = [[1, 1], [5, 1]] #Weapon Ammo Array
@s_ammo = [[57, 1]] #Skill Ammo Array
#STOP EDITING
setup
end
#--------------------------------------------------------------------------
# Weapon Ammo ID
#--------------------------------------------------------------------------
def w_ammo_id(weapon_id)
id = @weapons.index(weapon_id)
if id == nil
return 0
end
return @w_ammo[id]
end
#--------------------------------------------------------------------------
# Skill Ammo ID
#--------------------------------------------------------------------------
def s_ammo_id(skill_id)
id = @skills.index(skill_id)
if id == nil
return 0
end
return @s_ammo[id]
end
#--------------------------------------------------------------------------
# Set Up
#--------------------------------------------------------------------------
def setup
@weapons = []
@skills = []
for i in 0...@w_ammo.size
@weapons.push(@w_ammo[i][0])
@w_ammo[i] = @w_ammo[i][1]
end
for i in 0...@s_ammo.size
@skills.push(@s_ammo[i][0])
@s_ammo[i] = @s_ammo[i][1]
end
end
end
#EDITS START HERE
class Game_Actor < Game_Battler
def skill_can_use?(skill_id)
if not skill_learn?(skill_id)
return false
end
#NEW
ammo_id = $game_ammo.s_ammo_id(skill_id)
if ammo_id > 0
return false if $game_party.item_number(ammo_id) < 1
end
#END NEW
return super
end
end
class Scene_Title
def main
if $BTEST
battle_test
return
end
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
#NEW
$game_ammo = Game_Ammo.new
#END NEW
$game_system = Game_System.new
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
s1 = "New Game"
s2 = "Continue"
s3 = "Exit"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.sav")
@continue_enabled = true
end
end
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
$game_system.bgm_play($data_system.title_bgm)
Audio.me_stop
Audio.bgs_stop
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@sprite.bitmap.dispose
@sprite.dispose
end
end
class Scene_Battle
def phase3_setup_command_window
@party_command_window.active = false
@party_command_window.visible = false
@actor_command_window.active = true
@actor_command_window.visible = true
#NEW
@actor_command_window.refresh
ammo_id = $game_ammo.w_ammo_id(@active_battler.weapon_id)
if ammo_id > 0
@actor_command_window.disable_item(0) if $game_party.item_number(ammo_id) < 1
end
#END NEW
@actor_command_window.x = @actor_index * 160
@actor_command_window.index = 0
end
def update_phase3_basic_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
phase3_prior_actor
return
end
if Input.trigger?(Input::C)
case @actor_command_window.index
when 0
#NEW
ammo_id = $game_ammo.w_ammo_id(@active_battler.weapon_id)
if ammo_id > 0
if $game_party.item_number(ammo_id) < 1
$game_system.se_play($data_system.buzzer_se)
return
end
end
#END NEW
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
start_enemy_select
when 1
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 1
start_skill_select
when 2
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
phase3_next_actor
when 3
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 2
start_item_select
end
return
end
end
def make_basic_action_result
if @active_battler.current_action.basic == 0
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
if @active_battler.is_a?(Game_Actor)
#NEW
ammo_id = $game_ammo.w_ammo_id(@active_battler.weapon_id)
if ammo_id > 0
if $game_party.item_number(ammo_id) > 0
$game_party.lose_item(ammo_id, 1)
else
@help_window.set_text("No ammo! Defending instead...", 1)
@active_battler.current_action.basic = 1
return
end
end
#END NEW
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
@target_battlers = [target]
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
if @active_battler.current_action.basic == 1
@help_window.set_text($data_system.words.guard, 1)
return
end
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
@help_window.set_text("逃ã’ã‚‹", 1)
@active_battler.escape
return
end
if @active_battler.current_action.basic == 3
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
def make_skill_action_result
@skill = $data_skills[@active_battler.current_action.skill_id]
unless @active_battler.current_action.forcing
unless @active_battler.skill_can_use?(@skill.id)
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
@active_battler.sp -= @skill.sp_cost
#NEW
if @active_battler.is_a?(Game_Actor)
ammo_id = $game_ammo.s_ammo_id(@skill.id)
if ammo_id > 0
$game_party.lose_item(ammo_id, 1)
end
end
#END NEW
@status_window.refresh
@help_window.set_text(@skill.name, 1)
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
@common_event_id = @skill.common_event_id
set_target_battlers(@skill.scope)
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
end