BDR Ammo Version: 1.1 for RMVX
By: Fustel
Introduction
This script ends the age of unlimited ammunitions. With it, you'll be able to count your arrows, select the best one usable with your bow, and add Item capacities to your Weapon.
In short, ammos are Items usable in conjunction with Weapons. They can be expendable (or not), When ammo are exhausted, your return back to just weapon base capabilities.
A single weapon may use multiple types of ammo. Just select the one you want to use in the Equip or Battle Scenes.
Also, an ammo type may be used by multiple weapns. The parameters are easy to set.
Features
Screenshots
Demo
Script
[rgss]#==============================================================================
# ** BDR Ammo
#------------------------------------------------------------------------------
# © Fustel, 2010
# 02/04/10
# Version 1.0
#------------------------------------------------------------------------------
# VERSION HISTORY:
# - 1.0 (02/04/10), Initial release
# - 1.1 (05/04/10)
# added cache for ammos to avoid redundant note parsing
# added saving of the current ammo list for each weapon
# added RPG::Weapon::ammo_add
# added RPG::Weapon::ammo_remove
#------------------------------------------------------------------------------
# INSTRUCTIONS:
# - Install the 'BDR Damage' script
# - Place this script in the 'Materials' section, below 'BDR Damage'
# - Create a least one Weapon which will use ammos
# - Create a least one Item which will be used as ammo
# - Add one or more 'BDR_AMMO=<n>' lines in the Weapon note filed to link it
# with its usable ammo(s)
#------------------------------------------------------------------------------
# NOTES
# Ammos are Items enhancig the actor weapon capacities
# Ammos are used with the main weapon only
# One unit of ammo is consumed after the attack
# unless the ammo is not consumable
# When ammos are exhausted, the main weapon is still usable,
# but only with its base stats
#
# The ammos used with a weapon are defined by adding the following
# line in the "Note" field of the appropriate weapon in the database
#
# BDR_AMMO=<n>
#
# where <n> is the index of the ammo item
#
# Multiple ammos may be specified for a single weapon
# In case of multiple ammos, th one used is selected using
# the X and Y key (press F1 during play to determine X and
# Y keys) in the Equip screen when a "ammo weammos" is
# equiped, and during combat when on the "Attack" option for
# Actors using "ammo weapons"
#
# The ammo animation replaces that of its weapon
# Tha followinh ammo parameters are taken into account for damage calculation:
# - its elemnt set
# - its plus state set
# - its base attack power ( <0 if considered 0)
# - its attack factor as a percentage time the actor attack stat
# - its spirit factor as a percentage time the actor spirit stat
# - its attack factor as a percentage time the target defense stat
# - its attack factor as a percentage time the target spirit stat
# - its "ignore_defense" flag
# - its "damage_to_mp" flag
# - its "absorb_damage" flag
# - its scope if "for_opponent?"
# - its common event (to be thoroughly tested)
#
# The ammo consumption (one for the whole attack or one for each
# hit is customizable trhough the BDR::Ammo::ONE_FOR_ALL constant.
#
# The visibility of the select and info window can be hidden via the
# following constant (false to hide):
# - BDR::Ammo::WINDOW_EQUIP_VISIBLE
# - BDR::Ammo::WINDOW_BATTLE_VISIBLE
# - BDR::Ammo::INFO_EQUIP_VISIBLE
# - BDR::Ammo::INFO_BATTLE_VISIBLE
# NOTE: the select window must be visible for
# ammos to be selected
# NOTE: the info window is invisible if the
# select window is invisible
#
# Somme other parameters (ammo windows position & appearance, ammo
# selection key) may be changed in the BDR::Ammo module, but do
# it at you own responsability
#
# And... I own a French version of RMVX, and didn't bother to translat
# a mere demo. But I think you'll nevertheless understand what's
# going on. So, just open the chest, equipe the Arc Long and talk
# to the thing to your right
#=====================================================================
module BDR
module Ammo
# true = one ammo for the whole attack
# false = one ammo for each target/hit
#---------------------------------------
ONE_FOR_ALL = false
# Visibility of select (WINDOW_) of info (INFO_)
# window in $Scene_Equipe (EQUIP_) and
# Scene_Battle (BATTL_)
# NOTE: the select window must be visible for
# ammos to be selected
# NOTE: the info window is invisible if the
# select window is invisible
#-----------------------------------------------
WINDOW_EQUIP_VISIBLE = true
WINDOW_BATTLE_VISIBLE = true
INFO_EQUIP_VISIBLE = true
INFO_BATTLE_VISIBLE = true
# Keys for next & previous ammo
#------------------------------
KEY_PREV = Input::X
KEY_NEXT = Input::Y
# displayed Item height
#----------------------
ITEM_HEIGHT = 24
# Select window size
#-------------------
WINDOW_WIDTH = 80
WINDOW_HEIGHT = 80
# Icon position in Select Window
#-------------------------------
WINDOW_ICON_X = 12
WINDOW_ICON_Y = 0
# Show Ammo amount in select window
#----------------------------------
WINDOW_AMOUNT_SHOW = true
# Position of the ammo selct window in Scene_Equip
#--------------------------------------------------
WINDOW_EQUIP_X = 464
WINDOW_EQUIP_Y = 56
# Position of the selct window in Scene_Battle
#---------------------------------------------
WINDOW_BATTLE_X = 464
WINDOW_BATTLE_Y = 0
# Position & size of the info window in Scene_Equip
#--------------------------------------------------
INFO_EQUIP_WIDTH = 336
INFO_EQUIP_HEIGHT = 80
INFO_EQUIP_X = 208
INFO_EQUIP_Y = 128
# Position & size of the info window in Scene_Battle
#---------------------------------------------------
INFO_BATTLE_WIDTH = 416
INFO_BATTLE_HEIGHT = 80
INFO_BATTLE_X = 0
INFO_BATTLE_Y = 224
end
end
# cache & save variable for weaponn ammos
#========================================
class Game_System
attr_reader :bdr_ammos
alias bdr_ammo_initialize initialize
def initialize
@bdr_ammos = {}
bdr_ammo_initialize
end
end
# return the ammo IDs for a database weapon
#==========================================
module RPG
class Weapon < BaseItem
BDR_AMMO = "BDR_AMMO="
def ammo_ids
return $game_system.bdr_ammos[ id] if $game_system.bdr_ammos[ id] != nil
result = []
for s in note.split( "\r\n")
s = s.upcase.delete " "
begin
result.push( s.sub( BDR_AMMO){|k| ""}.to_i) if s.index( BDR_AMMO) == 0
rescue
end
end
$game_system.bdr_ammos[ id] = result
return $game_system.bdr_ammos[ id]
end
def ammo_add( ammo)
$game_system.bdr_ammos[ id].push( ammo) unless ammo_ids.include?( ammo)
end
def ammo_remove( ammo)
$game_system.bdr_ammos[ id].delete( ammo) if ammo_ids.include?( ammo)
end
end
end
# Default ammo management methods
#================================
class Game_Battler
def ammo_ids
retur []
end
def ammo
return nil
end
def ammo_usable?
return false
end
def ammo_idx
return 0
end
def ammo_idx=( idx)
end
end
# ammo management attributes & methods for actors
#================================================
class Game_Actor < Game_Battler
# initialize ammo to none
#------------------------
alias bdr_ammo_setup setup
def setup(actor_id)
bdr_ammo_setup(actor_id)
@ammo_idx = 0
end
# returns the ammo IDs list for the current weapon
#-------------------------------------------------
def ammo_ids
return [] if weapons[ 0] == nil
return weapons[ 0].ammo_ids
end
# return the ammo equiped for the current weapon
#-----------------------------------------------
def ammo
a = ammo_ids[ ammo_idx]
return nil if a == nil
return $data_items[ a]
end
# test usability of ammo (existance and availability)
#----------------------------------------------------
def ammo_usable?
return ( ammo != nil and $game_party.item_number( ammo) > 0)
end
# management of @ammo_idx
#------------------------
def ammo_idx
return [ [ @ammo_idx, ammo_ids.size-1].min, 0].max
end
def ammo_idx=( idx)
@ammo_idx = [ [ idx, ammo_ids.size-1].min, 0].max
end
end
# animation, event & ammo consumption when attacking
#===================================================
class Game_Battler
alias bdr_ammo_attack_effect attack_effect
def attack_effect(attacker)
bdr_ammo_attack_effect(attacker)
return if @skipped
return unless attacker.ammo_usable?
$game_party.consume_item( attacker.ammo) unless BDR::Ammo::ONE_FOR_ALL
end
end
class Scene_Battle < Scene_Base
alias bdr_ammo_execute_action_attack execute_action_attack
def execute_action_attack
$game_temp.common_event_id = @active_battler.ammo.common_event_id if @active_battler.ammo_usable?
mem_animation_id = @active_battler.weapons[ 0].animation_id if @active_battler.ammo != nil
@active_battler.weapons[ 0].animation_id = @active_battler.ammo.animation_id if @active_battler.ammo_usable?
bdr_ammo_execute_action_attack
@active_battler.weapons[ 0].animation_id = mem_animation_id if @active_battler.ammo != nil
$game_party.consume_item( @active_battler.ammo) if @active_battler.ammo != nil and BDR::Ammo::ONE_FOR_ALL
end
end
# damage management
# REQUIRES BRD_damage script
#===========================================
class Game_Actor < Game_Battler
#class Game_Actor < Game_Battler
# adds ammo element to actor
#---------------------------
alias bdr_ammo_element_set element_set
def element_set
result = bdr_ammo_element_set
result |= ammo.element_set if ammo_usable?
return result
end
# adds ammo plus state set to actor
#----------------------------------
alias bdr_ammo_plus_state_set plus_state_set
def plus_state_set
result = bdr_ammo_plus_state_set
result |= ammo.plus_state_set if ammo_usable?
return result
end
end
class Game_Battler
# adds ammo base attack to damage
# adds ammo atk_f generate damage
# adds ammo spi_f generate damage
# NOTE: base damage < 0 if considered 0
#--------------------------------------
alias bdr_ammo_bdr_attack_damage_atk bdr_attack_damage_atk
def bdr_attack_damage_atk( attacker)
result = bdr_ammo_bdr_attack_damage_atk( attacker)
if attacker.ammo_usable?
a = attacker.ammo
result += [ bdr_obj_damage_base( attacker, a), 0].max
result += bdr_obj_damage_attacker_atk( attacker, a)
result += bdr_obj_damage_attacker_spi( attacker, a)
end
return result
end
# adds ammo atk_f generated def
# adds ammo spi_f generated def
# takes ammo "ignore_defense" flag into account
#----------------------------------------------
alias bdr_ammo_bdr_attack_damage_def bdr_attack_damage_def
def bdr_attack_damage_def( attacker)
result = bdr_ammo_bdr_attack_damage_def( attacker)
if attacker.ammo_usable?
a = attacker.ammo
if bdr_obj_damage_ignore_defense( attacker, a)
result = 0
else
result += bdr_obj_damage_defender_def( attacker, a)
result += bdr_obj_damage_defender_spi( attacker, a)
end
end
return result
end
# apply the ammo variance
#------------------------
alias bdr_ammo_bdr_attack_damage_apply_variance bdr_attack_damage_apply_variance
def bdr_attack_damage_apply_variance( attacker, damage)
result = 0
if attacker.ammo_usable?
result += bdr_obj_damage_apply_variance( attacker, attacker.ammo, damage)
else
result += bdr_ammo_bdr_attack_damage_apply_variance( attacker, damage)
end
return result
end
# takes ammo "damage_to_mp" flag into account
# takes ammo "absorb_damage" flag into account
#---------------------------------------------
alias bdr_ammo_make_attack_damage_value make_attack_damage_value
def make_attack_damage_value(attacker)
if attacker.ammo_usable? and bdr_obj_damage_to_mp( attacker, attacker.ammo)
@mp_damage = bdr_attack_damage( attacker)
else
@hp_damage = bdr_attack_damage( attacker)
end
make_obj_absorb_effect( attacker, attacker.ammo) if attacker.ammo_usable?
end
end
# management of the "for_opponent?" ammo scope
# A target is still selected at action selection time
# in case no ammo is available at execution time
#====================================================
class Game_BattleAction
alias bdr_ammo_make_targets make_targets
def make_targets
if attack? and (! battler.confusion?) and (! battler.berserker?) and battler.ammo_usable? and battler.ammo.for_opponent?
targets = make_obj_targets( battler.ammo)
targets += targets if battler.dual_attack
else
targets = bdr_ammo_make_targets
end
targets = targets[ 0, $game_party.item_number( battler.ammo)] if (! BDR::Ammo::ONE_FOR_ALL) and battler.ammo_usable?
return targets
end
end
# Windows for ammo selection and info
#====================================
class Window_BDR_Ammo_Select < Window_Base
attr_accessor :actor
def initialize( x, y)
super( x, y, BDR::Ammo::WINDOW_WIDTH, BDR::Ammo::WINDOW_HEIGHT)
active = false
visible = false
@actor = nil
@ammo_idx = nil
@old_actor = nil
@old_qty = nil
end
def update
super
return if @actor == nil
return unless visible
return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
@old_actor = @actor
@ammo_idx = @actor.ammo_idx
@old_qty = $game_party.item_number( @actor.ammo)
contents.clear
draw_icon( @actor.ammo.icon_index, BDR::Ammo::WINDOW_ICON_X, BDR::Ammo::WINDOW_ICON_Y) if @actor.ammo != nil
contents.draw_text( 0, BDR::Ammo::ITEM_HEIGHT, width-32, BDR::Ammo::ITEM_HEIGHT, "x"+$game_party.item_number( @actor.ammo).to_s, 1) if BDR::Ammo::WINDOW_AMOUNT_SHOW and @actor.ammo != nil
end
end
class Window_BDR_Ammo_Info < Window_Base
attr_accessor :actor
def initialize( x, y, width, height)
super( x, y, width, height)
active = false
visible = false
@actor = nil
@ammo_idx = nil
@old_actor = nil
end
def update
super
return if @actor == nil
return unless visible
return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
@old_actor = @actor
@ammo_idx = @actor.ammo_idx
contents.clear
contents.draw_text( 0, 0, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.name, 2) if @actor.ammo != nil
contents.draw_text( 0, BDR::Ammo::ITEM_HEIGHT, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.description, 2) if @actor.ammo != nil
end
end
# ammo Windows management
#========================
class Scene_Equip < Scene_Base
alias bdr_ammo_start start
def start
bdr_ammo_start
@bdr_ammo_window_info = Window_BDR_Ammo_Info.new( BDR::Ammo::INFO_EQUIP_X, BDR::Ammo::INFO_EQUIP_Y, BDR::Ammo::INFO_EQUIP_WIDTH, BDR::Ammo::INFO_EQUIP_HEIGHT)
@bdr_ammo_window_info.actor = @actor
@bdr_ammo_window_info.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::INFO_EQUIP_VISIBLE)
@bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_EQUIP_X, BDR::Ammo::WINDOW_EQUIP_Y)
@bdr_ammo_window_select.actor = @actor
@bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
end
alias bdr_ammo_terminate terminate
def terminate
@bdr_ammo_window_select.dispose
@bdr_ammo_window_info.dispose
bdr_ammo_terminate
end
alias bdr_ammo_update update
def update
bdr_ammo_update
if @bdr_ammo_window_select.visible and @equip_window.active and @equip_window.index == 0
if Input.trigger?( BDR::Ammo::KEY_PREV)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
@bdr_ammo_window_select.actor.ammo_idx -= 1
end
if Input.trigger?( BDR::Ammo::KEY_NEXT)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
@bdr_ammo_window_select.actor.ammo_idx += 1
end
end
@bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_EQUIP_VISIBLE)
@bdr_ammo_window_info.update
@bdr_ammo_window_select.update
end
end
class Scene_Battle < Scene_Base
alias bdr_ammo_create_info_viewport create_info_viewport
def create_info_viewport
bdr_ammo_create_info_viewport
@bdr_ammo_window_info = Window_BDR_Ammo_Info.new( BDR::Ammo::INFO_BATTLE_X, BDR::Ammo::INFO_BATTLE_Y, BDR::Ammo::INFO_BATTLE_WIDTH, BDR::Ammo::INFO_BATTLE_HEIGHT)
@bdr_ammo_window_info.visible = false
@bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_BATTLE_X, BDR::Ammo::WINDOW_BATTLE_Y)
@bdr_ammo_window_select.viewport = @info_viewport
@bdr_ammo_window_select.visible = false
end
alias bdr_ammo_dispose_info_viewport dispose_info_viewport
def dispose_info_viewport
@bdr_ammo_window_select.dispose
@bdr_ammo_window_info.dispose
bdr_ammo_dispose_info_viewport
end
alias bdr_ammo_start_actor_command_selection start_actor_command_selection
def start_actor_command_selection
bdr_ammo_start_actor_command_selection
@bdr_ammo_window_select.actor = @active_battler
@bdr_ammo_window_info.actor = @active_battler
@bdr_ammo_window_select.visible = ( @actor_command_window.active and @actor_command_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_BATTLE_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
end
alias bdr_ammo_update_actor_command_selection update_actor_command_selection
def update_actor_command_selection
bdr_ammo_update_actor_command_selection
if @bdr_ammo_window_select.visible and @actor_command_window.active and @actor_command_window.index == 0
if Input.trigger?( BDR::Ammo::KEY_PREV)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
@bdr_ammo_window_select.actor.ammo_idx -= 1
end
if Input.trigger?( BDR::Ammo::KEY_NEXT)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
@bdr_ammo_window_select.actor.ammo_idx += 1
end
end
@bdr_ammo_window_select.visible = ( @actor_command_window.active and @actor_command_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_BATTLE_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
@bdr_ammo_window_info.update
@bdr_ammo_window_select.update
end
end
[/rgss]
Instructions
FAQ
Compatibility
No issue known, but pay attention to 'BDR Damage'
Credits and Thanks
All done by myself
Author's Notes
As you may have spotted, I own a french version of RMVX, and didn't bother to make a whole translation for a mere demo. But I hope you'll be able to understand what is happening
Enjoy !!
Terms and Conditions
You may not use this in a commercial game without my explicit permission.
You may not post this script anywhere without my explict permission.
You must give me credit.
By: Fustel
Introduction
This script ends the age of unlimited ammunitions. With it, you'll be able to count your arrows, select the best one usable with your bow, and add Item capacities to your Weapon.
In short, ammos are Items usable in conjunction with Weapons. They can be expendable (or not), When ammo are exhausted, your return back to just weapon base capabilities.
A single weapon may use multiple types of ammo. Just select the one you want to use in the Equip or Battle Scenes.
Also, an ammo type may be used by multiple weapns. The parameters are easy to set.
Features
- Create Ammos as Items
- The Ammo animation is used in place of the Weapons one
- The following Ammo paramters are added to the weapon capabilities
- its elemnt set
- its plus state set
- its base attack power ( <0 if considered 0)
- its attack factor as a percentage time the actor attack stat
- its spirit factor as a percentage time the actor spirit stat
- its attack factor as a percentage time the target defense stat
- its attack factor as a percentage time the target spirit stat
- its "ignore_defense" flag
- its "damage_to_mp" flag
- its "absorb_damage" flag
- its scope if "for_opponent?"
- its common event (to be thoroughly tested)
- Links between Weapons and Ammos are made in the Database
- You may select the way the Ammos are expended (one per hit or one for the whole attack)
- When multiple Ammos are available for a Weapon, the one in use is selectable during Equip of Battle
- The Ammo Select Windows may be hidden to control when the Ammos are selectable
- The list of usable Ammos for a Weapon can be dynamically adjusted (add/remove)
Screenshots
I would have been glad to show you the scene, but don't have any idea on how to post an image from an outer source (like, say, MediaFire)
I would have been glad to show you the scene, but don't have any idea on how to post an image from an outer source (like, say, MediaFire)
Demo
http://www.mediafire.com/file/ndijgzmnmxy/BDR Ammo - v1.1.zip
Open the chest to get some stuff.
Equip the "Arc Long".
Shoot the thing to your right, selecting arrows at your convenience.
Talk to the 'people' to your lefts to add/remove arrow usage from your "Arc Long"
Save & load to note the usable ammo list was saved.
The arrows varaince are all set to 0 so that you may easily compute damage by yourself.
Open the chest to get some stuff.
Equip the "Arc Long".
Shoot the thing to your right, selecting arrows at your convenience.
Talk to the 'people' to your lefts to add/remove arrow usage from your "Arc Long"
Save & load to note the usable ammo list was saved.
The arrows varaince are all set to 0 so that you may easily compute damage by yourself.
Script
[rgss]#==============================================================================
# ** BDR Ammo
#------------------------------------------------------------------------------
# © Fustel, 2010
# 02/04/10
# Version 1.0
#------------------------------------------------------------------------------
# VERSION HISTORY:
# - 1.0 (02/04/10), Initial release
# - 1.1 (05/04/10)
# added cache for ammos to avoid redundant note parsing
# added saving of the current ammo list for each weapon
# added RPG::Weapon::ammo_add
# added RPG::Weapon::ammo_remove
#------------------------------------------------------------------------------
# INSTRUCTIONS:
# - Install the 'BDR Damage' script
# - Place this script in the 'Materials' section, below 'BDR Damage'
# - Create a least one Weapon which will use ammos
# - Create a least one Item which will be used as ammo
# - Add one or more 'BDR_AMMO=<n>' lines in the Weapon note filed to link it
# with its usable ammo(s)
#------------------------------------------------------------------------------
# NOTES
# Ammos are Items enhancig the actor weapon capacities
# Ammos are used with the main weapon only
# One unit of ammo is consumed after the attack
# unless the ammo is not consumable
# When ammos are exhausted, the main weapon is still usable,
# but only with its base stats
#
# The ammos used with a weapon are defined by adding the following
# line in the "Note" field of the appropriate weapon in the database
#
# BDR_AMMO=<n>
#
# where <n> is the index of the ammo item
#
# Multiple ammos may be specified for a single weapon
# In case of multiple ammos, th one used is selected using
# the X and Y key (press F1 during play to determine X and
# Y keys) in the Equip screen when a "ammo weammos" is
# equiped, and during combat when on the "Attack" option for
# Actors using "ammo weapons"
#
# The ammo animation replaces that of its weapon
# Tha followinh ammo parameters are taken into account for damage calculation:
# - its elemnt set
# - its plus state set
# - its base attack power ( <0 if considered 0)
# - its attack factor as a percentage time the actor attack stat
# - its spirit factor as a percentage time the actor spirit stat
# - its attack factor as a percentage time the target defense stat
# - its attack factor as a percentage time the target spirit stat
# - its "ignore_defense" flag
# - its "damage_to_mp" flag
# - its "absorb_damage" flag
# - its scope if "for_opponent?"
# - its common event (to be thoroughly tested)
#
# The ammo consumption (one for the whole attack or one for each
# hit is customizable trhough the BDR::Ammo::ONE_FOR_ALL constant.
#
# The visibility of the select and info window can be hidden via the
# following constant (false to hide):
# - BDR::Ammo::WINDOW_EQUIP_VISIBLE
# - BDR::Ammo::WINDOW_BATTLE_VISIBLE
# - BDR::Ammo::INFO_EQUIP_VISIBLE
# - BDR::Ammo::INFO_BATTLE_VISIBLE
# NOTE: the select window must be visible for
# ammos to be selected
# NOTE: the info window is invisible if the
# select window is invisible
#
# Somme other parameters (ammo windows position & appearance, ammo
# selection key) may be changed in the BDR::Ammo module, but do
# it at you own responsability
#
# And... I own a French version of RMVX, and didn't bother to translat
# a mere demo. But I think you'll nevertheless understand what's
# going on. So, just open the chest, equipe the Arc Long and talk
# to the thing to your right
#=====================================================================
module BDR
module Ammo
# true = one ammo for the whole attack
# false = one ammo for each target/hit
#---------------------------------------
ONE_FOR_ALL = false
# Visibility of select (WINDOW_) of info (INFO_)
# window in $Scene_Equipe (EQUIP_) and
# Scene_Battle (BATTL_)
# NOTE: the select window must be visible for
# ammos to be selected
# NOTE: the info window is invisible if the
# select window is invisible
#-----------------------------------------------
WINDOW_EQUIP_VISIBLE = true
WINDOW_BATTLE_VISIBLE = true
INFO_EQUIP_VISIBLE = true
INFO_BATTLE_VISIBLE = true
# Keys for next & previous ammo
#------------------------------
KEY_PREV = Input::X
KEY_NEXT = Input::Y
# displayed Item height
#----------------------
ITEM_HEIGHT = 24
# Select window size
#-------------------
WINDOW_WIDTH = 80
WINDOW_HEIGHT = 80
# Icon position in Select Window
#-------------------------------
WINDOW_ICON_X = 12
WINDOW_ICON_Y = 0
# Show Ammo amount in select window
#----------------------------------
WINDOW_AMOUNT_SHOW = true
# Position of the ammo selct window in Scene_Equip
#--------------------------------------------------
WINDOW_EQUIP_X = 464
WINDOW_EQUIP_Y = 56
# Position of the selct window in Scene_Battle
#---------------------------------------------
WINDOW_BATTLE_X = 464
WINDOW_BATTLE_Y = 0
# Position & size of the info window in Scene_Equip
#--------------------------------------------------
INFO_EQUIP_WIDTH = 336
INFO_EQUIP_HEIGHT = 80
INFO_EQUIP_X = 208
INFO_EQUIP_Y = 128
# Position & size of the info window in Scene_Battle
#---------------------------------------------------
INFO_BATTLE_WIDTH = 416
INFO_BATTLE_HEIGHT = 80
INFO_BATTLE_X = 0
INFO_BATTLE_Y = 224
end
end
# cache & save variable for weaponn ammos
#========================================
class Game_System
attr_reader :bdr_ammos
alias bdr_ammo_initialize initialize
def initialize
@bdr_ammos = {}
bdr_ammo_initialize
end
end
# return the ammo IDs for a database weapon
#==========================================
module RPG
class Weapon < BaseItem
BDR_AMMO = "BDR_AMMO="
def ammo_ids
return $game_system.bdr_ammos[ id] if $game_system.bdr_ammos[ id] != nil
result = []
for s in note.split( "\r\n")
s = s.upcase.delete " "
begin
result.push( s.sub( BDR_AMMO){|k| ""}.to_i) if s.index( BDR_AMMO) == 0
rescue
end
end
$game_system.bdr_ammos[ id] = result
return $game_system.bdr_ammos[ id]
end
def ammo_add( ammo)
$game_system.bdr_ammos[ id].push( ammo) unless ammo_ids.include?( ammo)
end
def ammo_remove( ammo)
$game_system.bdr_ammos[ id].delete( ammo) if ammo_ids.include?( ammo)
end
end
end
# Default ammo management methods
#================================
class Game_Battler
def ammo_ids
retur []
end
def ammo
return nil
end
def ammo_usable?
return false
end
def ammo_idx
return 0
end
def ammo_idx=( idx)
end
end
# ammo management attributes & methods for actors
#================================================
class Game_Actor < Game_Battler
# initialize ammo to none
#------------------------
alias bdr_ammo_setup setup
def setup(actor_id)
bdr_ammo_setup(actor_id)
@ammo_idx = 0
end
# returns the ammo IDs list for the current weapon
#-------------------------------------------------
def ammo_ids
return [] if weapons[ 0] == nil
return weapons[ 0].ammo_ids
end
# return the ammo equiped for the current weapon
#-----------------------------------------------
def ammo
a = ammo_ids[ ammo_idx]
return nil if a == nil
return $data_items[ a]
end
# test usability of ammo (existance and availability)
#----------------------------------------------------
def ammo_usable?
return ( ammo != nil and $game_party.item_number( ammo) > 0)
end
# management of @ammo_idx
#------------------------
def ammo_idx
return [ [ @ammo_idx, ammo_ids.size-1].min, 0].max
end
def ammo_idx=( idx)
@ammo_idx = [ [ idx, ammo_ids.size-1].min, 0].max
end
end
# animation, event & ammo consumption when attacking
#===================================================
class Game_Battler
alias bdr_ammo_attack_effect attack_effect
def attack_effect(attacker)
bdr_ammo_attack_effect(attacker)
return if @skipped
return unless attacker.ammo_usable?
$game_party.consume_item( attacker.ammo) unless BDR::Ammo::ONE_FOR_ALL
end
end
class Scene_Battle < Scene_Base
alias bdr_ammo_execute_action_attack execute_action_attack
def execute_action_attack
$game_temp.common_event_id = @active_battler.ammo.common_event_id if @active_battler.ammo_usable?
mem_animation_id = @active_battler.weapons[ 0].animation_id if @active_battler.ammo != nil
@active_battler.weapons[ 0].animation_id = @active_battler.ammo.animation_id if @active_battler.ammo_usable?
bdr_ammo_execute_action_attack
@active_battler.weapons[ 0].animation_id = mem_animation_id if @active_battler.ammo != nil
$game_party.consume_item( @active_battler.ammo) if @active_battler.ammo != nil and BDR::Ammo::ONE_FOR_ALL
end
end
# damage management
# REQUIRES BRD_damage script
#===========================================
class Game_Actor < Game_Battler
#class Game_Actor < Game_Battler
# adds ammo element to actor
#---------------------------
alias bdr_ammo_element_set element_set
def element_set
result = bdr_ammo_element_set
result |= ammo.element_set if ammo_usable?
return result
end
# adds ammo plus state set to actor
#----------------------------------
alias bdr_ammo_plus_state_set plus_state_set
def plus_state_set
result = bdr_ammo_plus_state_set
result |= ammo.plus_state_set if ammo_usable?
return result
end
end
class Game_Battler
# adds ammo base attack to damage
# adds ammo atk_f generate damage
# adds ammo spi_f generate damage
# NOTE: base damage < 0 if considered 0
#--------------------------------------
alias bdr_ammo_bdr_attack_damage_atk bdr_attack_damage_atk
def bdr_attack_damage_atk( attacker)
result = bdr_ammo_bdr_attack_damage_atk( attacker)
if attacker.ammo_usable?
a = attacker.ammo
result += [ bdr_obj_damage_base( attacker, a), 0].max
result += bdr_obj_damage_attacker_atk( attacker, a)
result += bdr_obj_damage_attacker_spi( attacker, a)
end
return result
end
# adds ammo atk_f generated def
# adds ammo spi_f generated def
# takes ammo "ignore_defense" flag into account
#----------------------------------------------
alias bdr_ammo_bdr_attack_damage_def bdr_attack_damage_def
def bdr_attack_damage_def( attacker)
result = bdr_ammo_bdr_attack_damage_def( attacker)
if attacker.ammo_usable?
a = attacker.ammo
if bdr_obj_damage_ignore_defense( attacker, a)
result = 0
else
result += bdr_obj_damage_defender_def( attacker, a)
result += bdr_obj_damage_defender_spi( attacker, a)
end
end
return result
end
# apply the ammo variance
#------------------------
alias bdr_ammo_bdr_attack_damage_apply_variance bdr_attack_damage_apply_variance
def bdr_attack_damage_apply_variance( attacker, damage)
result = 0
if attacker.ammo_usable?
result += bdr_obj_damage_apply_variance( attacker, attacker.ammo, damage)
else
result += bdr_ammo_bdr_attack_damage_apply_variance( attacker, damage)
end
return result
end
# takes ammo "damage_to_mp" flag into account
# takes ammo "absorb_damage" flag into account
#---------------------------------------------
alias bdr_ammo_make_attack_damage_value make_attack_damage_value
def make_attack_damage_value(attacker)
if attacker.ammo_usable? and bdr_obj_damage_to_mp( attacker, attacker.ammo)
@mp_damage = bdr_attack_damage( attacker)
else
@hp_damage = bdr_attack_damage( attacker)
end
make_obj_absorb_effect( attacker, attacker.ammo) if attacker.ammo_usable?
end
end
# management of the "for_opponent?" ammo scope
# A target is still selected at action selection time
# in case no ammo is available at execution time
#====================================================
class Game_BattleAction
alias bdr_ammo_make_targets make_targets
def make_targets
if attack? and (! battler.confusion?) and (! battler.berserker?) and battler.ammo_usable? and battler.ammo.for_opponent?
targets = make_obj_targets( battler.ammo)
targets += targets if battler.dual_attack
else
targets = bdr_ammo_make_targets
end
targets = targets[ 0, $game_party.item_number( battler.ammo)] if (! BDR::Ammo::ONE_FOR_ALL) and battler.ammo_usable?
return targets
end
end
# Windows for ammo selection and info
#====================================
class Window_BDR_Ammo_Select < Window_Base
attr_accessor :actor
def initialize( x, y)
super( x, y, BDR::Ammo::WINDOW_WIDTH, BDR::Ammo::WINDOW_HEIGHT)
active = false
visible = false
@actor = nil
@ammo_idx = nil
@old_actor = nil
@old_qty = nil
end
def update
super
return if @actor == nil
return unless visible
return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
@old_actor = @actor
@ammo_idx = @actor.ammo_idx
@old_qty = $game_party.item_number( @actor.ammo)
contents.clear
draw_icon( @actor.ammo.icon_index, BDR::Ammo::WINDOW_ICON_X, BDR::Ammo::WINDOW_ICON_Y) if @actor.ammo != nil
contents.draw_text( 0, BDR::Ammo::ITEM_HEIGHT, width-32, BDR::Ammo::ITEM_HEIGHT, "x"+$game_party.item_number( @actor.ammo).to_s, 1) if BDR::Ammo::WINDOW_AMOUNT_SHOW and @actor.ammo != nil
end
end
class Window_BDR_Ammo_Info < Window_Base
attr_accessor :actor
def initialize( x, y, width, height)
super( x, y, width, height)
active = false
visible = false
@actor = nil
@ammo_idx = nil
@old_actor = nil
end
def update
super
return if @actor == nil
return unless visible
return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
@old_actor = @actor
@ammo_idx = @actor.ammo_idx
contents.clear
contents.draw_text( 0, 0, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.name, 2) if @actor.ammo != nil
contents.draw_text( 0, BDR::Ammo::ITEM_HEIGHT, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.description, 2) if @actor.ammo != nil
end
end
# ammo Windows management
#========================
class Scene_Equip < Scene_Base
alias bdr_ammo_start start
def start
bdr_ammo_start
@bdr_ammo_window_info = Window_BDR_Ammo_Info.new( BDR::Ammo::INFO_EQUIP_X, BDR::Ammo::INFO_EQUIP_Y, BDR::Ammo::INFO_EQUIP_WIDTH, BDR::Ammo::INFO_EQUIP_HEIGHT)
@bdr_ammo_window_info.actor = @actor
@bdr_ammo_window_info.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::INFO_EQUIP_VISIBLE)
@bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_EQUIP_X, BDR::Ammo::WINDOW_EQUIP_Y)
@bdr_ammo_window_select.actor = @actor
@bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
end
alias bdr_ammo_terminate terminate
def terminate
@bdr_ammo_window_select.dispose
@bdr_ammo_window_info.dispose
bdr_ammo_terminate
end
alias bdr_ammo_update update
def update
bdr_ammo_update
if @bdr_ammo_window_select.visible and @equip_window.active and @equip_window.index == 0
if Input.trigger?( BDR::Ammo::KEY_PREV)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
@bdr_ammo_window_select.actor.ammo_idx -= 1
end
if Input.trigger?( BDR::Ammo::KEY_NEXT)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
@bdr_ammo_window_select.actor.ammo_idx += 1
end
end
@bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_EQUIP_VISIBLE)
@bdr_ammo_window_info.update
@bdr_ammo_window_select.update
end
end
class Scene_Battle < Scene_Base
alias bdr_ammo_create_info_viewport create_info_viewport
def create_info_viewport
bdr_ammo_create_info_viewport
@bdr_ammo_window_info = Window_BDR_Ammo_Info.new( BDR::Ammo::INFO_BATTLE_X, BDR::Ammo::INFO_BATTLE_Y, BDR::Ammo::INFO_BATTLE_WIDTH, BDR::Ammo::INFO_BATTLE_HEIGHT)
@bdr_ammo_window_info.visible = false
@bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_BATTLE_X, BDR::Ammo::WINDOW_BATTLE_Y)
@bdr_ammo_window_select.viewport = @info_viewport
@bdr_ammo_window_select.visible = false
end
alias bdr_ammo_dispose_info_viewport dispose_info_viewport
def dispose_info_viewport
@bdr_ammo_window_select.dispose
@bdr_ammo_window_info.dispose
bdr_ammo_dispose_info_viewport
end
alias bdr_ammo_start_actor_command_selection start_actor_command_selection
def start_actor_command_selection
bdr_ammo_start_actor_command_selection
@bdr_ammo_window_select.actor = @active_battler
@bdr_ammo_window_info.actor = @active_battler
@bdr_ammo_window_select.visible = ( @actor_command_window.active and @actor_command_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_BATTLE_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
end
alias bdr_ammo_update_actor_command_selection update_actor_command_selection
def update_actor_command_selection
bdr_ammo_update_actor_command_selection
if @bdr_ammo_window_select.visible and @actor_command_window.active and @actor_command_window.index == 0
if Input.trigger?( BDR::Ammo::KEY_PREV)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
@bdr_ammo_window_select.actor.ammo_idx -= 1
end
if Input.trigger?( BDR::Ammo::KEY_NEXT)
Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
@bdr_ammo_window_select.actor.ammo_idx += 1
end
end
@bdr_ammo_window_select.visible = ( @actor_command_window.active and @actor_command_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_BATTLE_VISIBLE)
@bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
@bdr_ammo_window_info.update
@bdr_ammo_window_select.update
end
end
[/rgss]
Instructions
- Install the 'BDR Damage' script. It is here: (in fact, still not calideted, but included in the demo)
- Copy the script in the 'Materials' section, below 'BDR Damage'
- Create at least one Weapon
- Create at least one ammo Item
- Add one or more of the following line in the 'note' field of the Weapon
- BDR_AMMO=<n> , where <n> id the ID of the ammo used (for ex: BDR_AMMO=30)
- Dynamically add an usable Ammo to a Weapon by calling the "ammo_add(<n>)" method for this Weapon (<n> beeing the Ammo ID)
- Dynamically remove an usable Ammo to a Weapon by calling the "ammo_remove(<n>)" method for this Weapon (<n> beeing the Ammo ID)
FAQ
Compatibility
No issue known, but pay attention to 'BDR Damage'
Credits and Thanks
All done by myself
Author's Notes
As you may have spotted, I own a french version of RMVX, and didn't bother to make a whole translation for a mere demo. But I hope you'll be able to understand what is happening
Enjoy !!
Terms and Conditions
You may not use this in a commercial game without my explicit permission.
You may not post this script anywhere without my explict permission.
You must give me credit.