BDR Ammo v1.1

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
  • 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
Equip scene Spoiler
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)

Battle scene Spoiler
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
Shoot the slimes !! Spoiler
http://www.mediafire.com/file/ndijgzmnmxy/BDR%20Ammo%20-%20v1.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.


Script
  1. #==============================================================================
  2. # ** BDR Ammo
  3. #------------------------------------------------------------------------------
  4. #  © Fustel, 2010
  5. #  02/04/10
  6. #  Version 1.0
  7. #------------------------------------------------------------------------------
  8. #  VERSION HISTORY:
  9. #   - 1.0 (02/04/10), Initial release
  10. #   - 1.1 (05/04/10)
  11. #      added cache for ammos to avoid redundant note parsing
  12. #      added saving of the current ammo list for each weapon
  13. #      added RPG::Weapon::ammo_add
  14. #      added RPG::Weapon::ammo_remove
  15. #------------------------------------------------------------------------------
  16. #  INSTRUCTIONS:
  17. #   - Install the 'BDR Damage' script
  18. #   - Place this script in the 'Materials' section, below 'BDR Damage'
  19. #   - Create a least one Weapon which will use ammos
  20. #   - Create a least one Item which will be used as ammo
  21. #   - Add one or more 'BDR_AMMO=<n>' lines in the Weapon note filed to link it
  22. #       with its usable ammo(s)
  23. #------------------------------------------------------------------------------
  24. # NOTES
  25. # Ammos are Items enhancig the actor weapon capacities
  26. # Ammos are used with the main weapon only
  27. # One unit of ammo is consumed after the attack
  28. #   unless the ammo is not consumable
  29. # When ammos are exhausted, the main weapon is still usable,
  30. #   but only with its base stats
  31. #
  32. # The ammos used with a weapon are defined by adding the following
  33. #   line in the "Note" field of the appropriate weapon in the database
  34. #
  35. # BDR_AMMO=<n>
  36. #
  37. #   where <n> is the index of the ammo item
  38. #
  39. # Multiple ammos may be specified for a single weapon
  40. # In case of multiple ammos, th one used is selected using
  41. #   the X and Y key (press F1 during play to determine X and
  42. #   Y keys) in the Equip screen when a "ammo weammos" is
  43. #   equiped, and during combat when on the "Attack" option for
  44. #   Actors using "ammo weapons"
  45. #
  46. # The ammo animation replaces that of its weapon
  47. # Tha followinh ammo parameters are taken into account for damage calculation:
  48. #   - its elemnt set
  49. #   - its plus state set
  50. #   - its base attack power ( <0 if considered 0)
  51. #   - its attack factor as a percentage time the actor attack stat
  52. #   - its spirit factor as a percentage time the actor spirit stat
  53. #   - its attack factor as a percentage time the target defense stat
  54. #   - its attack factor as a percentage time the target spirit stat
  55. #   - its "ignore_defense" flag
  56. #   - its "damage_to_mp" flag
  57. #   - its "absorb_damage" flag
  58. #   - its scope if "for_opponent?"
  59. #   - its common event (to be thoroughly tested)
  60. #
  61. # The ammo consumption (one for the whole attack or one for each
  62. #   hit is customizable trhough the BDR::Ammo::ONE_FOR_ALL constant.
  63. #
  64. # The visibility of the select and info window can be hidden via the
  65. #   following constant (false to hide):
  66. #   - BDR::Ammo::WINDOW_EQUIP_VISIBLE
  67. #   - BDR::Ammo::WINDOW_BATTLE_VISIBLE
  68. #   - BDR::Ammo::INFO_EQUIP_VISIBLE
  69. #   - BDR::Ammo::INFO_BATTLE_VISIBLE
  70. # NOTE: the select window must be visible for
  71. #   ammos to be selected
  72. # NOTE: the info window is invisible if the
  73. #   select window is invisible
  74. #
  75. # Somme other parameters (ammo windows position & appearance, ammo
  76. #   selection key) may be changed in the BDR::Ammo module, but do
  77. #   it at you own responsability
  78. #
  79. # And... I own a French version of RMVX, and didn't bother to translat
  80. #   a mere demo. But I think you'll nevertheless understand what's
  81. #   going on. So, just open the chest, equipe the Arc Long and talk
  82. #   to the thing to your right
  83. #=====================================================================
  84.  
  85. module BDR
  86.   module Ammo
  87.  
  88.     # true  = one ammo for the whole attack
  89.     # false = one ammo for each target/hit
  90.     #---------------------------------------
  91.     ONE_FOR_ALL = false
  92.  
  93.     # Visibility of select (WINDOW_) of info (INFO_)
  94.     #   window in $Scene_Equipe (EQUIP_) and
  95.     #   Scene_Battle (BATTL_)
  96.     # NOTE: the select window must be visible for
  97.     #   ammos to be selected
  98.     # NOTE: the info window is invisible if the
  99.     #   select window is invisible
  100.     #-----------------------------------------------
  101.     WINDOW_EQUIP_VISIBLE  = true
  102.     WINDOW_BATTLE_VISIBLE = true
  103.     INFO_EQUIP_VISIBLE    = true
  104.     INFO_BATTLE_VISIBLE   = true
  105.  
  106.  
  107.     # Keys for next & previous ammo
  108.     #------------------------------
  109.     KEY_PREV = Input::X
  110.     KEY_NEXT = Input::Y
  111.  
  112.     # displayed Item height
  113.     #----------------------
  114.     ITEM_HEIGHT = 24
  115.  
  116.     # Select window size
  117.     #-------------------
  118.     WINDOW_WIDTH = 80
  119.     WINDOW_HEIGHT = 80
  120.  
  121.     # Icon position in Select Window
  122.     #-------------------------------
  123.     WINDOW_ICON_X = 12
  124.     WINDOW_ICON_Y = 0
  125.  
  126.     # Show Ammo amount in select window
  127.     #----------------------------------
  128.     WINDOW_AMOUNT_SHOW = true
  129.  
  130.     # Position of the ammo selct window in Scene_Equip
  131.     #--------------------------------------------------
  132.     WINDOW_EQUIP_X = 464
  133.     WINDOW_EQUIP_Y = 56
  134.  
  135.     # Position of the selct window in Scene_Battle
  136.     #---------------------------------------------
  137.     WINDOW_BATTLE_X = 464
  138.     WINDOW_BATTLE_Y = 0
  139.  
  140.     # Position & size of the info window in Scene_Equip
  141.     #--------------------------------------------------
  142.     INFO_EQUIP_WIDTH = 336
  143.     INFO_EQUIP_HEIGHT = 80
  144.     INFO_EQUIP_X = 208
  145.     INFO_EQUIP_Y = 128
  146.  
  147.     # Position & size of the info window in Scene_Battle
  148.     #---------------------------------------------------
  149.     INFO_BATTLE_WIDTH = 416
  150.     INFO_BATTLE_HEIGHT = 80
  151.     INFO_BATTLE_X = 0
  152.     INFO_BATTLE_Y = 224
  153.   end
  154. end
  155.  
  156. # cache & save variable for weaponn ammos
  157. #========================================
  158. class Game_System
  159.   attr_reader :bdr_ammos
  160.  
  161.   alias bdr_ammo_initialize initialize
  162.   def initialize
  163.     @bdr_ammos = {}
  164.     bdr_ammo_initialize
  165.   end
  166. end
  167.  
  168. # return the ammo IDs for a database weapon
  169. #==========================================
  170. module RPG
  171.   class Weapon < BaseItem
  172.     BDR_AMMO = "BDR_AMMO="
  173.     def ammo_ids
  174.       return $game_system.bdr_ammos[ id] if $game_system.bdr_ammos[ id] != nil
  175.       result = []
  176.       for s in note.split( "\r\n")
  177.         s = s.upcase.delete " "
  178.         begin
  179.           result.push( s.sub( BDR_AMMO){|k| ""}.to_i) if s.index( BDR_AMMO) == 0
  180.         rescue
  181.         end
  182.       end
  183.       $game_system.bdr_ammos[ id] = result
  184.       return $game_system.bdr_ammos[ id]
  185.     end
  186.  
  187.     def ammo_add( ammo)
  188.       $game_system.bdr_ammos[ id].push( ammo) unless ammo_ids.include?( ammo)
  189.     end
  190.  
  191.     def ammo_remove( ammo)
  192.       $game_system.bdr_ammos[ id].delete( ammo) if ammo_ids.include?( ammo)
  193.     end
  194.   end
  195. end
  196.  
  197.  
  198. # Default ammo management methods
  199. #================================
  200. class Game_Battler
  201.   def ammo_ids
  202.     retur []
  203.   end
  204.  
  205.   def ammo
  206.     return nil
  207.   end
  208.  
  209.   def ammo_usable?
  210.     return false
  211.   end
  212.  
  213.   def ammo_idx
  214.     return 0
  215.   end
  216.  
  217.   def ammo_idx=( idx)
  218.   end
  219. end
  220.  
  221. # ammo management attributes & methods for actors
  222. #================================================
  223. class Game_Actor < Game_Battler
  224.   # initialize ammo to none
  225.   #------------------------
  226.   alias bdr_ammo_setup setup
  227.   def setup(actor_id)
  228.     bdr_ammo_setup(actor_id)
  229.     @ammo_idx = 0
  230.   end
  231.  
  232.   # returns the ammo IDs list for the current weapon
  233.   #-------------------------------------------------
  234.   def ammo_ids
  235.     return [] if weapons[ 0] == nil
  236.     return weapons[ 0].ammo_ids
  237.   end
  238.  
  239.   # return the ammo equiped for the current weapon
  240.   #-----------------------------------------------
  241.   def ammo
  242.     a = ammo_ids[ ammo_idx]
  243.     return nil if a == nil
  244.     return $data_items[ a]
  245.   end
  246.  
  247.   # test usability of ammo (existance and availability)
  248.   #----------------------------------------------------
  249.   def ammo_usable?
  250.     return ( ammo != nil and $game_party.item_number( ammo) > 0)
  251.   end
  252.  
  253.   # management of @ammo_idx
  254.   #------------------------
  255.   def ammo_idx
  256.     return [ [ @ammo_idx, ammo_ids.size-1].min, 0].max
  257.   end
  258.   def ammo_idx=( idx)
  259.     @ammo_idx = [ [ idx, ammo_ids.size-1].min, 0].max
  260.   end
  261. end
  262.  
  263. # animation, event & ammo consumption when attacking
  264. #===================================================
  265. class Game_Battler
  266.   alias bdr_ammo_attack_effect attack_effect
  267.   def attack_effect(attacker)
  268.     bdr_ammo_attack_effect(attacker)
  269.     return if @skipped
  270.     return unless attacker.ammo_usable?
  271.     $game_party.consume_item( attacker.ammo) unless BDR::Ammo::ONE_FOR_ALL
  272.   end
  273. end
  274.  
  275. class Scene_Battle < Scene_Base
  276.   alias bdr_ammo_execute_action_attack execute_action_attack
  277.   def execute_action_attack
  278.     $game_temp.common_event_id = @active_battler.ammo.common_event_id if @active_battler.ammo_usable?
  279.     mem_animation_id = @active_battler.weapons[ 0].animation_id if @active_battler.ammo != nil
  280.     @active_battler.weapons[ 0].animation_id = @active_battler.ammo.animation_id if @active_battler.ammo_usable?
  281.     bdr_ammo_execute_action_attack
  282.     @active_battler.weapons[ 0].animation_id = mem_animation_id if @active_battler.ammo != nil
  283.     $game_party.consume_item( @active_battler.ammo) if @active_battler.ammo != nil and BDR::Ammo::ONE_FOR_ALL
  284.   end
  285. end
  286.  
  287. # damage management
  288. # REQUIRES BRD_damage script
  289. #===========================================
  290. class Game_Actor < Game_Battler
  291. #class Game_Actor < Game_Battler
  292.   # adds ammo element to actor
  293.   #---------------------------
  294.   alias bdr_ammo_element_set element_set
  295.   def element_set
  296.     result = bdr_ammo_element_set
  297.     result |= ammo.element_set if ammo_usable?
  298.     return result
  299.   end
  300.  
  301.   # adds ammo plus state set to actor
  302.   #----------------------------------
  303.   alias bdr_ammo_plus_state_set plus_state_set
  304.   def plus_state_set
  305.     result = bdr_ammo_plus_state_set
  306.     result |= ammo.plus_state_set if ammo_usable?
  307.     return result
  308.   end
  309. end
  310.  
  311. class Game_Battler
  312.   # adds ammo base attack to damage
  313.   # adds ammo atk_f generate damage
  314.   # adds ammo spi_f generate damage
  315.   # NOTE: base damage < 0 if considered 0
  316.   #--------------------------------------
  317.   alias bdr_ammo_bdr_attack_damage_atk bdr_attack_damage_atk
  318.   def bdr_attack_damage_atk( attacker)
  319.     result = bdr_ammo_bdr_attack_damage_atk( attacker)
  320.     if attacker.ammo_usable?
  321.       a = attacker.ammo
  322.       result += [ bdr_obj_damage_base( attacker, a), 0].max
  323.       result += bdr_obj_damage_attacker_atk( attacker, a)
  324.       result += bdr_obj_damage_attacker_spi( attacker, a)
  325.     end
  326.     return result
  327.   end
  328.  
  329.   # adds ammo atk_f generated def
  330.   # adds ammo spi_f generated def
  331.   # takes ammo "ignore_defense" flag into account
  332.   #----------------------------------------------
  333.   alias bdr_ammo_bdr_attack_damage_def bdr_attack_damage_def
  334.   def bdr_attack_damage_def( attacker)
  335.     result = bdr_ammo_bdr_attack_damage_def( attacker)
  336.     if attacker.ammo_usable?
  337.       a = attacker.ammo
  338.       if bdr_obj_damage_ignore_defense( attacker, a)
  339.         result = 0
  340.       else
  341.         result += bdr_obj_damage_defender_def( attacker, a)
  342.         result += bdr_obj_damage_defender_spi( attacker, a)
  343.       end
  344.     end
  345.     return result
  346.   end
  347.  
  348.   # apply the ammo variance
  349.   #------------------------
  350.   alias bdr_ammo_bdr_attack_damage_apply_variance bdr_attack_damage_apply_variance
  351.   def bdr_attack_damage_apply_variance( attacker, damage)
  352.     result = 0
  353.     if attacker.ammo_usable?
  354.       result += bdr_obj_damage_apply_variance( attacker, attacker.ammo, damage)
  355.     else
  356.       result += bdr_ammo_bdr_attack_damage_apply_variance( attacker, damage)
  357.     end
  358.     return result
  359.   end
  360.  
  361.   # takes ammo "damage_to_mp" flag into account
  362.   # takes ammo "absorb_damage" flag into account
  363.   #---------------------------------------------
  364.   alias bdr_ammo_make_attack_damage_value make_attack_damage_value
  365.   def make_attack_damage_value(attacker)
  366.     if attacker.ammo_usable? and bdr_obj_damage_to_mp( attacker, attacker.ammo)
  367.       @mp_damage = bdr_attack_damage( attacker)
  368.     else
  369.       @hp_damage = bdr_attack_damage( attacker)
  370.     end
  371.     make_obj_absorb_effect( attacker, attacker.ammo) if attacker.ammo_usable?
  372.   end
  373. end
  374.  
  375. # management of the "for_opponent?" ammo scope
  376. # A target is still selected at action selection time
  377. #   in case no ammo is available at execution time
  378. #====================================================
  379.  
  380. class Game_BattleAction
  381.   alias bdr_ammo_make_targets make_targets
  382.   def make_targets
  383.     if attack? and (! battler.confusion?) and (! battler.berserker?) and battler.ammo_usable? and battler.ammo.for_opponent?
  384.       targets = make_obj_targets( battler.ammo)
  385.       targets += targets if battler.dual_attack
  386.     else
  387.       targets = bdr_ammo_make_targets
  388.     end
  389.     targets = targets[ 0, $game_party.item_number( battler.ammo)] if (! BDR::Ammo::ONE_FOR_ALL) and battler.ammo_usable?
  390.     return targets
  391.   end
  392. end
  393.  
  394. # Windows for ammo selection and info
  395. #====================================
  396. class Window_BDR_Ammo_Select < Window_Base
  397.   attr_accessor :actor
  398.  
  399.   def initialize( x, y)
  400.     super( x, y, BDR::Ammo::WINDOW_WIDTH, BDR::Ammo::WINDOW_HEIGHT)
  401.     active = false
  402.     visible = false
  403.     @actor = nil
  404.     @ammo_idx = nil
  405.     @old_actor = nil
  406.     @old_qty = nil
  407.   end
  408.  
  409.   def update
  410.     super
  411.     return if @actor == nil
  412.     return unless visible
  413.     return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
  414.  
  415.     @old_actor = @actor
  416.     @ammo_idx = @actor.ammo_idx
  417.     @old_qty = $game_party.item_number( @actor.ammo)
  418.  
  419.     contents.clear
  420.     draw_icon( @actor.ammo.icon_index, BDR::Ammo::WINDOW_ICON_X, BDR::Ammo::WINDOW_ICON_Y) if @actor.ammo != nil
  421.     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
  422.   end
  423. end
  424.  
  425. class Window_BDR_Ammo_Info < Window_Base
  426.   attr_accessor :actor
  427.  
  428.   def initialize( x, y, width, height)
  429.     super( x, y, width, height)
  430.     active = false
  431.     visible = false
  432.     @actor = nil
  433.     @ammo_idx = nil
  434.     @old_actor = nil
  435.   end
  436.  
  437.   def update
  438.     super
  439.     return if @actor == nil
  440.     return unless visible
  441.     return if @old_actor == @actor and @ammo_idx == @actor.ammo_idx and @old_qty == $game_party.item_number( @actor.ammo)
  442.  
  443.     @old_actor = @actor
  444.     @ammo_idx = @actor.ammo_idx
  445.  
  446.     contents.clear
  447.     contents.draw_text( 0, 0, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.name, 2) if @actor.ammo != nil
  448.     contents.draw_text( 0, BDR::Ammo::ITEM_HEIGHT, width-32, BDR::Ammo::ITEM_HEIGHT, @actor.ammo.description, 2) if @actor.ammo != nil
  449.   end
  450. end
  451.  
  452. # ammo Windows management
  453. #========================
  454. class Scene_Equip < Scene_Base
  455.   alias bdr_ammo_start start
  456.   def start
  457.     bdr_ammo_start
  458.     @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)
  459.     @bdr_ammo_window_info.actor = @actor
  460.     @bdr_ammo_window_info.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::INFO_EQUIP_VISIBLE)
  461.     @bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_EQUIP_X, BDR::Ammo::WINDOW_EQUIP_Y)
  462.     @bdr_ammo_window_select.actor = @actor
  463.     @bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
  464.   end
  465.  
  466.   alias bdr_ammo_terminate terminate
  467.   def terminate
  468.     @bdr_ammo_window_select.dispose
  469.     @bdr_ammo_window_info.dispose
  470.     bdr_ammo_terminate
  471.   end
  472.  
  473.   alias bdr_ammo_update update
  474.   def update
  475.     bdr_ammo_update
  476.     if @bdr_ammo_window_select.visible and @equip_window.active and @equip_window.index == 0
  477.       if Input.trigger?( BDR::Ammo::KEY_PREV)
  478.         Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
  479.         @bdr_ammo_window_select.actor.ammo_idx -= 1
  480.       end
  481.       if Input.trigger?( BDR::Ammo::KEY_NEXT)
  482.         Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
  483.         @bdr_ammo_window_select.actor.ammo_idx += 1
  484.       end
  485.     end
  486.     @bdr_ammo_window_select.visible = ( @equip_window.index == 0 and @bdr_ammo_window_select.actor.ammo != nil and BDR::Ammo::WINDOW_EQUIP_VISIBLE)
  487.     @bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_EQUIP_VISIBLE)
  488.     @bdr_ammo_window_info.update
  489.     @bdr_ammo_window_select.update
  490.   end
  491. end
  492.  
  493. class Scene_Battle < Scene_Base
  494.   alias bdr_ammo_create_info_viewport create_info_viewport
  495.   def create_info_viewport
  496.     bdr_ammo_create_info_viewport
  497.     @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)
  498.     @bdr_ammo_window_info.visible = false
  499.     @bdr_ammo_window_select = Window_BDR_Ammo_Select.new( BDR::Ammo::WINDOW_BATTLE_X, BDR::Ammo::WINDOW_BATTLE_Y)
  500.     @bdr_ammo_window_select.viewport = @info_viewport
  501.     @bdr_ammo_window_select.visible = false
  502.   end
  503.  
  504.   alias bdr_ammo_dispose_info_viewport dispose_info_viewport
  505.   def dispose_info_viewport
  506.     @bdr_ammo_window_select.dispose
  507.     @bdr_ammo_window_info.dispose
  508.     bdr_ammo_dispose_info_viewport
  509.   end
  510.  
  511.   alias bdr_ammo_start_actor_command_selection start_actor_command_selection
  512.   def start_actor_command_selection
  513.     bdr_ammo_start_actor_command_selection
  514.     @bdr_ammo_window_select.actor = @active_battler
  515.     @bdr_ammo_window_info.actor = @active_battler
  516.     @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)
  517.     @bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
  518.   end
  519.  
  520.   alias bdr_ammo_update_actor_command_selection update_actor_command_selection
  521.   def update_actor_command_selection
  522.     bdr_ammo_update_actor_command_selection
  523.     if @bdr_ammo_window_select.visible and @actor_command_window.active and @actor_command_window.index == 0
  524.       if Input.trigger?( BDR::Ammo::KEY_PREV)
  525.         Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx > 0
  526.         @bdr_ammo_window_select.actor.ammo_idx -= 1
  527.       end
  528.       if Input.trigger?( BDR::Ammo::KEY_NEXT)
  529.         Sound.play_equip if @bdr_ammo_window_select.actor.ammo_idx < @bdr_ammo_window_select.actor.ammo_ids.size-1
  530.         @bdr_ammo_window_select.actor.ammo_idx += 1
  531.       end
  532.     end
  533.     @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)
  534.     @bdr_ammo_window_info.visible = ( @bdr_ammo_window_select.visible and BDR::Ammo::INFO_BATTLE_VISIBLE)
  535.     @bdr_ammo_window_info.update
  536.     @bdr_ammo_window_select.update
  537.   end
  538. end
Expand to see the code.


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.
First of all, to solve the horrible problem of having screenshot spoilers, yet no screenshots in them (disasterous): http://www.imageshack.us/

Other than that... after looking at your few threads here and there, I notce the following:
  • you need to get used to using [rgss] instead of [code] for rgss scripts, as it's harder to read without that
  • you don't really explain what the hell BDR is, did you?
  • your three scripts seem to be much better held in a single thread, no? (though I can't quite tell that easily... depends on what BDR is, I figure...)
  • more constants than you'd ever need logically... IMO
  • your method of assigning ammo to weapons looks much like my Database Flag Reader, which is why I like it. However, I claim to have the neater code :p
  • you have too many different emphasises in your terms and conditions (does the super emphased 'must' weight more than the only intermediately emphased 'not'?)
Thanks for the ImageShak link. Alas, as I am near-blind (really nera-blind), It'll take me a little while to be accusomed with the site. Therefore, it'll take the same little while before I put the shots. But thanks anyway.

  • I just put thr [rgss] tag, but didn't see difference with the [code]. But take the above into acount :grin:
  • I should have know I'd get this one. Basically, BDR is my acronym at work, and was used for years to identify my production. I just kept the habit.
  • I considered posting posting the scripts together; but as they also may be used independantly (I am using 'BDR Damage' in some studies), independant posts semmed logicl.
  • constant are easier to find than number hidden among 100's of code liens. Alos I learned programming with many constant 10's of years ago. Habits remain.
  • I am not a Ruby pro', and wrote this in a couple of minutes. But if you have a better parsing code, just share it. It'd be glad to give you credit.
  • Ok, I'll take care of the terms, as I have many more scripts to share..
The difference between the [code] and the [rgss] tag is that [rgss] does syntax highlighting, aka you have the same code coloration that RMXX uses, making it easier to read the code. It's not needed for simple code structures, but walls of text like these scripts should have it, so people can easier read through it (while reading through it might not seem to important at first, if you ever visited a support thread that linked you to a script, you know what I mean).

The thing with the constants is, while they sometimes would prove a valid customization means (let's say MAX_PARTY_SIZE or something, aka stuff that is likely to differ in each game), most script submitters (like you, as I think ^^) use too generic stuff that noone would even want to change. If they do, however, they should know what they want (aka "make the window 20 pixels wider") and therefore shouldn't have too many problems doing it theirselves. I'm well aware that I'm the only person on the internets with that opinion, but yeah... I'm right >:(
;)

As far as the Database Flag Reader goes, there's a link in my signature. However, it's not completely different from what you wrote... just more in-general and allowing for more input from multiple scripts without having any clutter-ish stuff. I don't think you need to implement it at this point, however, if there's more BDR stuff coming up that wants to address more item attributes/flags, it should be interesting for you.

And yeah, the terms were more or less sarcasm ^^

Keep up the good work!
Et hop ...! Already a new version.
As soon as I began to use my own script, a couple additions became evident:
- caching of the ammo list to avoid redundant parsing of the note field
- dynamic addition/removal of ammo usable by a weapon (in-game weapon customization)
- saving of the ammo lists

As for the [rgss] tag. I think I didn't see the difference with the [/code] because I remove the embedded colors from the web pages in my browser whenever I can. If only I could do the same in the RMVX editor... :shades:

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=70414