The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: Trihan on April 10, 2012, 11:37:50 PM

Title: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 10, 2012, 11:37:50 PM
Asagi's Gun License
Version: 1.07x
Author: Kread-EX, modified by Trihan
Date: April 11, 2012

Update History



Description


Kread-EX's original Asagi's Gun Licence script allows you to specify ammunition options for classes and skills.

At the request of Eternallight on IRC (and already requested, as I found later, by SirCumferance on Kread's Wordpress) I've modified the script so that you can set ammo types for individual weapons rather than the class. I've also modified skill assignment so that a skill can be used with more than one ammo type (say you wanted a skill that could be used with either arrows or bullets equipped)

I've also fixed some bugs; most of my own making and a couple from the original. One thing with the original script is that if you have multiple party members whose class can equip ammo type X, they'll both be able to equip it and both will draw from the same pool of items. I've fixed this by preventing ammo from being equipped if someone else is already equipping it.

I've also made a small fix to the items list where normally it would show less ammo than you actually have (because obviously one or more of the weapons is equipped). It now shows the full amount regardless of whether it's equipped on anyone.

And finally, I modified the skill notetags so you can assign an ammo cost in case you want the skill to use up more than a single arrow/bullet/dwarf.

Features


Screenshots

Without the proper weapon equipped, you can't equip ammo.
(http://rpgmaker.net/media/content/users/96/locker/ammo1.png)
Equip the proper weapon and as if by magic ammo appears!
(http://rpgmaker.net/media/content/users/96/locker/ammo2.png)
Once equipped, ammo no longer shows up in the list (like it usually would for weapons you have more than 1 of)
(http://rpgmaker.net/media/content/users/96/locker/ammo3.png)
Now that it's equipped, the ammo can't be used by anyone else.
(http://rpgmaker.net/media/content/users/96/locker/ammo4.png)
And if we look at our items menu, it'll display the correct amount even though it's equipped by someone.
(http://rpgmaker.net/media/content/users/96/locker/ammo5.png)

Instructions

Paste this script into its own slot in the Script Editor, above Main and below Materials.

Configuration is pretty much done through notetags; the syntax and instructions are included in the script comments.

If you have any questions, please feel free to post them here.

Script


Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  ? Asagi's Gun License
#  Author: Kread-EX
#  Modified by: Trihan
#  Version 1.07x
#  Release date: 10/04/2012
#
#  For Seiryuki.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#-------------------------------------------------------------------------------------------------
#  ? UPDATES
#-------------------------------------------------------------------------------------------------
# # 13/04/2012. Bugfix: Gaining a non-ranged weapon caused the script to crash
# # when moving the cursor over the ammo slot in the equipment menu.
# # 10/04/2012. Bugfix: unequipping non-weapon items caused a crash.
# # 10/04/2012. Modifications: Added slot names on a per-weapon basis.
# # 09/04/2012. Modifications: allowed ammo to be assigned on a per-weapon basis
# # rather than classes, and allowed skills to use multiple ammo types/IDs.
# # Implemented ammo costs for skills.
# # Prevented multiple ammo users from equipping the same ammo.
# # Equipped ammo is now removed from the equippable items list.
# # The item list now shows the correct quantity of ammo if a party member has
# # that ammo equipped.
# # 09/03/2012. Bugfix: skills without ammo could crash.
# # 08/03/2012. Bugfix: ammo stopped consuming because of my previous bugfixes.
# # 22/02/2012. Bugfix: some REGEXP didn't work with european characters.
# # 20/02/2012. Bugfix: all skills used to consume ammo.
#-------------------------------------------------------------------------------------------------
#  ? TERMS OF USAGE
#-------------------------------------------------------------------------------------------------
# #  You are free to adapt this work to suit your needs.
# #  You can use this work for commercial purposes if you like it.
# #  Credit is appreciated.
# #
# # For support:
# # grimoirecastle.wordpress.com
# # rpgmakervxace.net
# # rpgrevolution.com
#-------------------------------------------------------------------------------------------------
#  ? INTRODUCTION
  #-------------------------------------------------------------------------------------------------
  # # Enables the use of ammunition for skills.
#-------------------------------------------------------------------------------------------------
#  ? INSTRUCTIONS
#-------------------------------------------------------------------------------------------------
# # Three levels of configuration: Class, Weapon and Skill.
# # Class notetags:
# # <ammo_slot_id: x>
# # This determines the slot in the equip screen which will be replaced by the
# # ammo slot.
# # <ammo_slot_name: string> Just the name of the slot.
# #
# # Weapon notetags:
# # <ammo_type_id: x, y, z>
# # Replace x with the weapon types of the kind of ammo you want the
# # weapon to use.
# #
# # Skill notetags
# # <linked_ammo_types: x>
# # Will require and consume ammo of a specific type.
# # <linked_ammo_ids: x>
# # Will require and consume unique arrows. In this case, x isn't the weapon
# # type but the weapon ID.
# # <ammo_cost: x>
# # Determines how much ammo is required to use the skill, and will be expended
# # on use.
#-------------------------------------------------------------------------------------------------
#  ? COMPATIBILITY
#-------------------------------------------------------------------------------------------------
# # List of aliases and overwrites:
# #
# # DataManager
# # load_database (alias)
# # load_ammo_notetags (new method)
# #
# # RPG::Class
# # ammo_slot_id (new attr method)
# # ammo_slot_name (new attr method)
# # load_ammo_notetags (new method)
# # ammo_user? (new method)
# #
# # RPG::Skill
# # ammo_type_id (new attr method)
# # ammo_absolute_id (new attr method)
# # ammo_cost (new attr method)
# # load_ammo_notetags (new method)
# #
# # RPG::Weapon
# # ammo_type_ids (new attr method)
# # already_equipped (new attr method)
# # load_ammo_notetags (new method)
# # ammo_user? (new method)
# #
# # Game_Actor
# # change_equip (alias)
# # equip_slots (alias)
# # equippable? (alias)
# # release_unequippable_items (overload)
# # skill_cost_payable? (alias)
# # skill_ammo_reqs_ok? (new method)
# # pay_skill_cost (alias)
# # consume_ammo (new method)
# #
# # Game_Party
# # discard_members_equip (overload)
# #
# # Window_EquipSlot
# # draw_item (alias)
# # slot_name (alias)
# #
# # Window_EquipItem
# # include? (alias)
# # enable? (alias)
#-------------------------------------------------------------------------------------------------

$imported = {} if $imported.nil?
$imported['KRX-AsagisGunLicense'] = true

puts 'Load: Asagi\'s Gun License v1.03 by Kread-EX'

module KRX
 
  module REGEXP
    AMMO_SLOT_ID = /<ammo_slot_id:[ ]*(\d+)>/i
    AMMO_SLOT_NAME = /<ammo_slot_name:[ ]*(.+)>/
    AMMO_TYPE_ID = /<ammo_type_id:[ ]*(\d+)>/i
    AMMO_CONSUMPTION_TYPES = /<linked_ammo_types:[ ]*(.+?)>/i
    AMMO_CONSUMPTION_IDS = /<linked_ammo_ids:[ ]*(.+?)>/i
    AMMO_COST = /<ammo_cost:[ ]*(\d+)>/i
  end
 
end

#===========================================================================
# ? DataManager
#===========================================================================

module DataManager 
#--------------------------------------------------------------------------
# ? Loads the database
#--------------------------------------------------------------------------
class << self
alias_method(:krx_ammo_dm_load_database, :load_database)
end
def self.load_database
krx_ammo_dm_load_database
load_ammo_notetags
end 
#--------------------------------------------------------------------------
# ? Loads the note tags
#--------------------------------------------------------------------------
def self.load_ammo_notetags
groups = [$data_classes, $data_skills, $data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.load_ammo_notetags
end
end
puts "Read: Ammo Requirements Notetags"
end
end

#===========================================================================
# ? RPG::Class
#===========================================================================

class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# ? Public instance variables
#--------------------------------------------------------------------------
  attr_reader     :weapon_slot_id
  attr_reader     :ammo_slot_id
  attr_reader     :ammo_slot_name
#--------------------------------------------------------------------------
# ? Loads the note tags
#--------------------------------------------------------------------------
def load_ammo_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::AMMO_SLOT_ID
@ammo_slot_id = $1.to_i
        if @ammo_slot_id == 0
          @weapon_slot_id = 1
        else
          @weapon_slot_id = 0
        end
when KRX::REGEXP::AMMO_SLOT_NAME
@ammo_slot_name = $1
end
end
end
#--------------------------------------------------------------------------
# ? Determine if this class uses ammo
#--------------------------------------------------------------------------
  def ammo_user?
    return @ammo_slot_id != nil
  end
end

#===========================================================================
# ? RPG::Skill
#===========================================================================

class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# ? Public instance variables
#--------------------------------------------------------------------------
  attr_reader     :ammo_type_ids
  attr_reader     :ammo_absolute_ids
  attr_reader     :ammo_cost
#--------------------------------------------------------------------------
# ? Loads the note tags
#--------------------------------------------------------------------------
def load_ammo_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::AMMO_CONSUMPTION_TYPES
        @ammo_type_ids = []
@ammo_type_ids |= $1.scan(/\d+/).collect { |id| id.to_i }
when KRX::REGEXP::AMMO_CONSUMPTION_IDS
        @ammo_absolute_ids = []
@ammo_absolute_ids |= $1.scan(/\d+/).collect { |id| id.to_i }
      when KRX::REGEXP::AMMO_COST
        @ammo_cost = $1.to_i
end
end
end
end

class RPG::Weapon < RPG::EquipItem
#--------------------------------------------------------------------------
# ? Public instance variables
#--------------------------------------------------------------------------
  attr_reader     :ammo_type_id
  attr_reader     :ammo_slot_name
  attr_accessor   :already_equipped
  #--------------------------------------------------------------------------
  # ? Constructor
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_rw_init, :initialize)
  def initialize
    @already_equipped = false
    krx_ammo_rw_init
  end
#--------------------------------------------------------------------------
# ? Loads the note tags
#--------------------------------------------------------------------------
def load_ammo_notetags
@note.split(/[\r\n]+/).each do |line|
      case line
      when KRX::REGEXP::AMMO_SLOT_NAME
@ammo_slot_name = $1
when KRX::REGEXP::AMMO_TYPE_ID
@ammo_type_id = $1.to_i
end
end
end
  #--------------------------------------------------------------------------
# ? Determine if this weapon uses ammo
#--------------------------------------------------------------------------
  def ammo_user?
    return @ammo_type_id != nil
  end
end

#===========================================================================
# ? Game_Actor
#===========================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ? Gets the available equipment slots
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_ga_es, :equip_slots)
  def equip_slots
    base = krx_ammo_ga_es
    return base unless self.class.ammo_user?
    ammo_slot = self.class.ammo_slot_id
    result = []
    done = false
    base.each do |x|
      if x == ammo_slot && !done
        result.push(0)
        done = true
      else
        result.push(x)
      end
    end
    result
  end
  #--------------------------------------------------------------------------
  # ? Determines if an item can be equipped
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_ga_equippable?, :equippable?)
  def equippable?(item)
    if self.class.ammo_user? && item.is_a?(RPG::Weapon)
      weapon_slot = self.class.weapon_slot_id
      if self.equips[weapon_slot]
        return true if item.wtype_id == self.equips[weapon_slot].ammo_type_id
      end
    end
    return krx_ammo_ga_equippable?(item)
  end
  #--------------------------------------------------------------------------
  # ? Performs equipment change
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_ga_ce, :change_equip)
  def change_equip(slot_id, item)
    if item == nil && equips[slot_id] && equips[slot_id].is_a?(RPG::Weapon)
      equips[slot_id].already_equipped = false
    elsif self.class.ammo_slot_id == slot_id && item.is_a?(RPG::Weapon)
      weapon_slot = self.class.weapon_slot_id
      return unless item.is_a?(RPG::Weapon) && item.wtype_id == self.equips[weapon_slot].ammo_type_id
      return unless trade_item_with_party(item, equips[slot_id])
      if equips[slot_id] != nil && equips[slot_id].is_a?(RPG::Weapon)
        equips[slot_id].already_equipped = false
      end
      item.already_equipped = true
      @equips[slot_id].object = item
      return
    end
    krx_ammo_ga_ce(slot_id, item)
  end
  #--------------------------------------------------------------------------
  # * Remove Equipment that Cannot Be Equipped
  #     item_gain:  Return removed equipment to party.
  #--------------------------------------------------------------------------
  def release_unequippable_items(item_gain = true)
    loop do
      last_equips = equips.dup
      @equips.each_with_index do |item, i|
        if !equippable?(item.object) || item.object.etype_id != equip_slots[i]
          if item.object.is_a?(RPG::Weapon)
            item.object.already_equipped = false if item.object.already_equipped == true
          end
          trade_item_with_party(nil, item.object) if item_gain
          item.object = nil
        end
      end
      return if equips == last_equips
    end
  end
  #--------------------------------------------------------------------------
  # ? Determine if a skill can be used
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_ga_scp?, :skill_cost_payable?)
  def skill_cost_payable?(skill)
    return false unless skill_ammo_reqs_ok?(skill)
    return krx_ammo_ga_scp?(skill)
  end
  #--------------------------------------------------------------------------
  # ? Check the ammo requirements for the skill
  #--------------------------------------------------------------------------
  def skill_ammo_reqs_ok?(skill)
    return true if skill.ammo_type_ids.nil? && skill.ammo_absolute_ids.nil?
    result = false
    weapon_id = self.class.weapon_slot_id
    slot_id = self.class.ammo_slot_id
    if skill.ammo_type_ids != nil
      return false unless self.class.ammo_user?
      item = @equips[slot_id].object
      return false if item.nil?
      if skill.ammo_cost
        return false if $game_party.item_number(item) < skill.ammo_cost - 1
      end
      result = true if skill.ammo_type_ids.include?(item.wtype_id)
    end
    if skill.ammo_absolute_ids != nil
      return false unless self.class.ammo_user?
      item = @equips[slot_id].object
      return false if item.nil?
      if skill.ammo_cost
        return false if $game_party.item_number(item) < skill.ammo_cost - 1
      end
      result = true if skill.ammo_type_ids.include?(item.id)
    end
    result
  end
  #--------------------------------------------------------------------------
  # ? Pay the required cost for a skill
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_ga_psc, :pay_skill_cost)
  def pay_skill_cost(skill)
    krx_ammo_ga_psc(skill)
    consume_ammo(skill) if self.class.ammo_user?
  end
  #--------------------------------------------------------------------------
  # ? Consume the required ammo for a skill
  #--------------------------------------------------------------------------
  def consume_ammo(skill)
    return if skill.ammo_type_ids.nil? && skill.ammo_absolute_ids.nil?
    slot_id = self.class.ammo_slot_id
    item = @equips[slot_id].object
    if skill.ammo_cost
      $game_party.lose_item(item, skill.ammo_cost, true)
    else
      $game_party.lose_item(item, 1, true)
    end
  end
end
#===========================================================================
# ? Game_Party
#===========================================================================
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Discard Members' Equipment
  #--------------------------------------------------------------------------
  def discard_members_equip(item, amount)
    n = amount
    members.each do |actor|
      while n > 0 && actor.equips.include?(item)
        if item.is_a?(RPG::Weapon)
          item.already_equipped = false if item.already_equipped == true
        end
        actor.discard_equip(item)
        n -= 1
      end
    end
  end
end

#===========================================================================
# ? Window_ItemList
#===========================================================================

class Window_ItemList < Window_Selectable
  #--------------------------------------------------------------------------
  # * Draw Number of Items
  #--------------------------------------------------------------------------
  def draw_item_number(rect, item)
    quantity = 0
    for member in $game_party.all_members
      if member.class.ammo_user?
        if member.equips[member.class.ammo_slot_id]
          if member.equips[member.class.ammo_slot_id].id == item.id
            quantity += 1
          end
        end
      end
    end
    draw_text(rect, sprintf(":%2d", ($game_party.item_number(item) + quantity)), 2)
  end
end

#===========================================================================
# ? Window_EquipSlot
#===========================================================================

class Window_EquipSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ? Displays the equipped item
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_wes_di, :draw_item)
  def draw_item(index)
    krx_ammo_wes_di(index)
    rect = item_rect_for_text(index)
    item = @actor.equips[index]
    name = slot_name(index)
    if @actor.class.ammo_user? && name == @actor.class.ammo_slot_name
      unless item.nil?
        draw_text(rect, sprintf(":%2d", $game_party.item_number(item) + 1), 2)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? Determine the name of the slot
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_wes_sn, :slot_name)
  def slot_name(index)
    if @actor && @actor.class.ammo_slot_id == index
      if @actor.equips[@actor.class.weapon_slot_id]
        if @actor.equips[@actor.class.weapon_slot_id].ammo_slot_name != nil
          return @actor.equips[@actor.class.weapon_slot_id].ammo_slot_name         
        else
          return @actor.class.ammo_slot_name
        end
      else
        return @actor.class.ammo_slot_name
      end
    end
    krx_ammo_wes_sn(index)
  end
end

#===========================================================================
# ? Window_Item
#===========================================================================

class Window_EquipItem < Window_ItemList
  #--------------------------------------------------------------------------
  # ? Determine if an item goes in the list
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_wei_include?, :include?)
  def include?(item)
    if @actor.class.ammo_user?
      weapon_slot = @actor.class.weapon_slot_id
      if @slot_id == @actor.class.ammo_slot_id
        return true if item.nil?
        return false unless item.is_a?(RPG::Weapon) && @actor.equips[weapon_slot]
        return false if item.already_equipped == true
        if @actor.equips[@slot_id]
          return false if @actor.equips[@slot_id].id == item.id
        end
        return @actor.equips[weapon_slot].ammo_type_id == item.wtype_id
      else
        if item.is_a?(RPG::Weapon) && @actor.equips[weapon_slot]
          return false if @actor.equips[weapon_slot].ammo_type_id == item.wtype_id
        end
      end
    end
    krx_ammo_wei_include?(item)
  end
  #--------------------------------------------------------------------------
  # ? Determine if an item can be equipped
  #--------------------------------------------------------------------------
  alias_method(:krx_ammo_wei_enable?, :enable?)
  def enable?(item)
    if @actor.class.ammo_user?
      weapon_slot = @actor.class.weapon_slot_id
      if @slot_id == @actor.class.ammo_slot_id && @actor.equips[weapon_slot]
        return true if item.nil?
        return @actor.equips[weapon_slot].ammo_type_id == item.wtype_id
      end
    end
    krx_ammo_wei_enable?(item)
  end
end

Credit



Modifier's Notes


This modification was created to fulfil a specific need, but I tried to make it as flexible as possible to uses other people might have for it. If there's anything else you want to see the script do, let me know and I'll see if I can accommodate the request.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 12, 2012, 09:58:44 PM
Doesn't work with more equipement slots...
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 12, 2012, 10:26:31 PM
Can you elaborate?
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 12:41:17 PM
Well, I've made additional slot called "ammo". In script it has ID 10, in game it was 9th slot, so I've put ID 9 in ammo script.
I've tagged class, made one weapon - pistol, and second weapon - bullets, then I've tagged pistol with ID of bullets.
In game second weapon slot appeared just from nowhere, and if I was about to choose ammo slot to equip bullets, there was an error...
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 01:46:08 PM
If it's not too much trouble, can you tell me what your tags were for the class/weapon, what error you got, and which line it was on?
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 03:36:59 PM
Ok, first error. It's happening when I'm pressing down when I select last available slot. And also I have second Weapon slot, it's 4th.
(http://img51.imageshack.us/img51/5020/przechwytywaniegpp.png)
Second error is when I'm hitting "Best" option in equip menu:
(http://img860.imageshack.us/img860/9551/przechwytywanie2n.png)

Tags for class are:
<ammo_slot_id: 9>
<ammo_slot_name: Amunicja>
Tag for weapon is:
<ammo_type_id: 3>
And 3 is ID of ammo in weapons database.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 04:40:17 PM
When you say you have a second weapon slot, is this added by another script? I can't replicate your issue on my test project, so I'm guessing it's a compatibility error.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 04:42:36 PM
The thing is, that only when I have this ammo script I have also this second weapon slot...
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 04:55:42 PM
Wait, I just noticed something from the info you gave me.

For class, ammo_slot_id is the EQUIPMENT slot you want to be able to put ammo on. So 0 would be the first slot, 1 the second, 2 the third, 3 the fourth, 4 the fifth and so on. Your example has "9" but you don't have 10 equipment slots for heroes. I have it set to "1" so it replaces the shield slot.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 06:43:40 PM
You mean, that I have to replace one of the default slots? Ok, I'll try...

Edit: Right, I've changed it to 2, so now I have an error on 3rd slot...
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 06:44:54 PM
Yeah, that was how the original script worked.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 06:46:42 PM
It doesn't work. See edit.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 07:11:48 PM
Sorry, I don't seem to be able to replicate this error. Would you be able to compress your project and upload it somewhere for me to look at?
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 08:06:32 PM
Ok, it's not encrypted, but there's not much content. Although it's pretty big, so...
Ok, here you are: http://www.mediafire.com/download.php?81ziowc5906cxc0
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 08:23:00 PM
Aha.

Find these two lines in the include? method:

Code: [Select]
return false if item.already_equipped == true
return false unless item.is_a?(RPG::Weapon) && @actor.equips[weapon_slot]

And put them the other way around. That should fix it.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 08:32:18 PM
Updated in the OP.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 10:20:17 PM
Ok, now it works, but I can't equip ammo as ammo, just weapon ID 1 as an ammo... Its kinda silly to shoot axes :D
To be honest, it's not even ammo slot, it's completely random... And I have error in 190 line of Game_Actor, undefined method 'object=' for nil:NilClass when I'm trying to use "clear" option in equip menu... Maybe I should look for another ammo script...
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 13, 2012, 10:45:07 PM
If you've lost interest in it after one bug, that might be best. I'll see if I can figure out what went wrong and fix it for you, but to be perfectly honest I find your reply somewhat insulting.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 13, 2012, 11:20:33 PM
I didn't meant to insult you! No way! I was just wondering, if it's any other script for ammo, but i've searched, and there's no script that easy to use like yours (to be honest - somewhere is one script, but it's... Well... Crappy?). So don't be offended, I really need this script and it'll be great, if you will find a malfunction :)
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on April 14, 2012, 08:38:37 AM
I didn't think you truly meant to insult me, so it's cool. ^_^ I think I've found out what the problem is.

You're using a script that adds extra equipment slots, which works with some of the same methods my ammo script does. I'm going to have to do some testing with both to identify what the compatibility issues are.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Angius on April 14, 2012, 10:29:10 PM
Ok, great news! :D
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Lytanathan on May 19, 2012, 06:51:45 AM
So, as far as I can tell I have this set up right, but when I try to equip a character with ammunition after equipping the ammo-using weapon, the ammo items do not appear in the list. The only option I get is the one to equip nothing at all to the slot.

Tags:

Class:
<ammo_slot_id: 2>
<ammo_slot_name: Ammo>

Weapon:
<ammo_type_id: 21> (or 22, or 23; I have three different types of ammo-using weapons)

Ammo are set up as weapons with types of Bolt, Arrow, and Bullet, which are weapon types 21, 22, and 23, respectively.

Now, I do have a script in place which adds extra equipment slots, but when it didn't work properly I tried removing it first and then testing the game, and I still got the same results, that is to say, none at all.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Trihan on May 20, 2012, 11:54:38 PM
Would you be able to zip up your project and send it to me so I can figure out what's going wrong?
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Lytanathan on May 21, 2012, 04:48:25 AM
I found out where the issue was.
By removing Kread-Ex's Multiple Equip Types script, the ammo script works now. Sort of ironic that one of the script's original creator's other scripts caused the problem. I didn't really need that other script anyways (at least, not nearly as much as the ammo script), so don't worry about it if you don't want to.
Either way, thanks for the great script!
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: oriceles on June 29, 2012, 03:53:13 PM
How can i assing the default attack to consume arrows without making my other classes useless?.
And, the ammo is consumed by the skill use or the number of hits it does?


EDIT:
I just made a copy of the default attack and replaced with a copy that used the note tag using YEA Battle command list.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Tuomo L on August 12, 2012, 09:58:08 AM
Can you make it so that you have something like flintlock pistol that holds 1 round before you have to reload and something like shotgun that can use two rounds before reloading, and so on?

In short, can you make "reloading" skill with this and if so, how?
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: memberp on June 01, 2013, 01:29:11 PM
Trihan, I really like your script BUT have a lot of difficulties to get it to work. Instead of going back and forth with a tedious analysis that might or might not bring a solution, would it be possible - provided you got the time for it - to create a demo that demonstrates the script working? Let's say an example with two weapons; a handgun that uses 9mm bullets and a shotgun that uses shotgun shells.

Thanks for your time in advance!

Edit: Nevermind, I think I've figured it out!
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Amaroq on February 28, 2014, 04:48:30 PM
Hi there!

First of all I want to say that this is a very useful and great script and I want to thank the ones who made and edited it.
I managed to get it to work for the most part, however I am having one issue with it that I cannot resolve.

I cannot dedicate more than 1 ammunition type to a weapon.
The script orders me to write the following: <ammo_type_id: x, y, z> into the weapon's Note Box.
If I write let's say <ammo_type_id: 5> everything works just fine. Once I equip said weapon I can select the respective ammunition type in my ammunition slot.
However, if I type <ammo_type_id: 5, 6> in order to use two different ammunition types, NONE of the two show up in my ammunition slot, it just refuses to work at all. The same goes for all amounts of entries past 1. So <ammo_type_id: 5, 6, 7>
does not work either.
Since I am doing everything just like the script explained I cannot see why this is not working.

______
I am using RPG maker VX ace 1.02a, bought on steam in december 2013 (in case you need to know my version number)
I tested this in my original game AND a completely new game using only this script and no others. So isolation of this script does not affect the outcome.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: Quixxxotic on July 27, 2015, 01:36:38 PM
I wish this script would consider dual wielding weapons- This is perfect for my project, and I've spent weeks trying to work around that.
Title: Re: Kread-EX's ammo script - modified by Trihan
Post by: strike on July 27, 2015, 04:48:02 PM
Trihan appears to have been last active in June, it may take a while for them to notice your post to assist. (and obviously they may choose not to assist on an older script and also the fact that it's originally someone elses script with modifications so he might not be able to make the changes you want.)

That said had you tried tweaking it at all? I'm assuming you're looking to be able to equip a left gun and right gun individually? do they usually come in pairs? would it make more sense to have the twin guns be one item in the database? (with like a dual pistol icon or something?)