What I've got almost-but-not-quite working are throwing weapons - like shurikens, grenades, darts etc. - that, rather than being a weapon with an associated ammo item, function as their own ammo. So, rather than selecting "Shuriken" from the item menu in battle to throw one, you equip one of them in your weapon slot, and every attack depletes one from your inventory. This works fine; I just changed the script so Range_ammo_id references weapons instead of items, then had throwing weapons use their own weapon ID as their ammo ID.
Ammo depletes as per normal. The snag is that the script is taking into account the number of ammo items in the party inventory, but not what the characters have equipped. This means that - for example - if you have five shurikens and equip the shuriken item, it'll only think you have four ammo, since the one you've got equipped isn't in the party inventory (I've also altered the Ammo HUD Script so that if you've got a thrown weapon equipped it displays one unit higher than normal).
What I'm looking to do is add a clause so that, should you have no ammo left, checks if the active battler's weapon id is equal to the id in gather_ammo, and if so performs the attack as normal - but then unequips the character's weapon and deletes it from the inventory (all thrown weapons use 1 ammo so there's no need to check gather_ammo_cost).
I attempted to do this in the actual script, but kept getting syntax errors whenever I added a new if / else clause. I'm guessing the most logical way to handle it would be to allow attacks when on 0 ammo with thrown weapons, which I've done thus:
CODE
if $game_party.weapon_number(gather_ammo) >= gather_ammo_cost or @active_battler.weapon_id == gather_ammo
...and then check at some later stage of the battle sequence if a character who attacked had a weapon id equal to its ammo id, then unequip them and delete it. Unless there's a simpler way.
For reference, here's the altered Syn's Ammo System script I'm using:
CODE
#============================================================================
# Syn's Ammo Requirements
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 15, 2007
# Tested with SDK 2.1
#============================================================================
#----------------------------------------------------------------------------
# Customization Section
#----------------------------------------------------------------------------
module Ammo
# Format = {weapon_id => Ammo_cost}
Range_weapons_id = {17 => 1}
# Format = {weapon_id => Item_id
Range_ammo_id = {17 => 17}
# Format = {skill_id => Ammo_cost}
Skill_ammo = {7 => 1}
# Note on Skills: When using Skills the Current Ammo for the equipped
# weapon will be used. So if Skill 73 is used and Weapon 17 is equipped
# then Ammo #33 will be used.
end
#----------------------------------------------------------------------------
# Begin Scene_Battle
#----------------------------------------------------------------------------
class Scene_Battle
# Alias Methods
alias syn_scene_battle_range make_basic_action_result
#----------------------------------------------------
# Alias the Attacking method
#----------------------------------------------------
def make_basic_action_result
# Gather the current Ammo Cost
gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]
# Gather the Current Ammo
gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]
# Check if the Active Battler is attacking and if they are using a ranged weapon
if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)
# Check the Ammo Count
if $game_party.weapon_number(gather_ammo) >= gather_ammo_cost or @active_battler.weapon_id == gather_ammo
# Sufficient Ammo, remove item
$game_party.lose_weapon(gather_ammo,gather_ammo_cost)
syn_scene_battle_range
else
# Insufficient Ammo
@help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)
end
# Call Default Code
else
syn_scene_battle_range
end
end
end
# Syn's Ammo Requirements
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 15, 2007
# Tested with SDK 2.1
#============================================================================
#----------------------------------------------------------------------------
# Customization Section
#----------------------------------------------------------------------------
module Ammo
# Format = {weapon_id => Ammo_cost}
Range_weapons_id = {17 => 1}
# Format = {weapon_id => Item_id
Range_ammo_id = {17 => 17}
# Format = {skill_id => Ammo_cost}
Skill_ammo = {7 => 1}
# Note on Skills: When using Skills the Current Ammo for the equipped
# weapon will be used. So if Skill 73 is used and Weapon 17 is equipped
# then Ammo #33 will be used.
end
#----------------------------------------------------------------------------
# Begin Scene_Battle
#----------------------------------------------------------------------------
class Scene_Battle
# Alias Methods
alias syn_scene_battle_range make_basic_action_result
#----------------------------------------------------
# Alias the Attacking method
#----------------------------------------------------
def make_basic_action_result
# Gather the current Ammo Cost
gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]
# Gather the Current Ammo
gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]
# Check if the Active Battler is attacking and if they are using a ranged weapon
if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)
# Check the Ammo Count
if $game_party.weapon_number(gather_ammo) >= gather_ammo_cost or @active_battler.weapon_id == gather_ammo
# Sufficient Ammo, remove item
$game_party.lose_weapon(gather_ammo,gather_ammo_cost)
syn_scene_battle_range
else
# Insufficient Ammo
@help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)
end
# Call Default Code
else
syn_scene_battle_range
end
end
end