RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Ammo Requirements

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 88
Script Name: Ammo Requirements
Written by: Synthesize
Current Version: V.1.00
Release Date: August 15, 2007

What is it?
With this script the actors can only attack and/or do specific skills if they have enough ammo in the inventory. The designer can set every weapon to use it's very own unique ammo count and ammo easily via the options at the top.

Screenshots
Haha your funny.

Features
- Each weapon can use a different amount of ammo (Say a shotgun fires 5 rather then a pistol which fires 1)
- Each weapon can have it's own ammo
- Easily define skills that require ammo and the amount of ammo needed
- Skills use the current equipped weapons ammo rather then a defined value.

The Script
Place in a New Script Above Main.
Spoiler for:
Code: [Select]
#============================================================================
# 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 => 33}
  # Format = {skill_id => Ammo_cost}
  Skill_ammo = {73 => 3}
  # 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 syn_scene_battle_skill make_skill_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.item_number(gather_ammo) >= gather_ammo_cost
# Sufficient Ammo, remove item
$game_party.lose_item(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
  #----------------------------------------------------
  # Alias the Skill method
  #----------------------------------------------------
  def make_skill_action_result
# Gather the current Ammo Cost
gather_ammo_cost = Ammo::Skill_ammo[@active_battler.current_action.skill_id]
# Gather Ammo
gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]
# Check if the Actor is using a defiend skill
if Ammo::Skill_ammo.has_key?(@active_battler.current_action.skill_id)
  # Check if Ammo is present
  if $game_party.item_number(gather_ammo) >= gather_ammo_cost
# Sufficient Ammo, remove item
$game_party.lose_item(gather_ammo,gather_ammo_cost)
# Call Default Code
syn_scene_battle_skill
  else
# Set Window; Do Nothing
@help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)
  end
  # Otherwise SKip the check and call default code
else
  syn_scene_battle_skill
end
  end
end
#============================================================================
# Written by Synthesize
# Special Thanks: ~Emo~ for the request
#----------------------------------------------------------------------------
# Ammo Requirements
#============================================================================

Usage:
This script may be used in either a commercial project or a free ware project free of charge. However, credit must be present somewhere in the project.

Editing/Distribution:
Feel free to redistribute this post to other boards/websites. Just keep the wording the same. As for editing the script to suite your tastes feel free. Just keep the original header/footer in tact.

If you have any questions or you found a bug, please PM me or make a post with the following:
1.) SDK Version
2.) Other Scripts
3.) Factors of the bug (What did you do to make it happen?)
4.) version
5.) Error Line

Cheers,

Syn

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Nice script! Excellent contribution.

*waits for mod to move to Database ;8

**
Rep:
Level 85
The worlds ends on 21/12/12, where will you be?
great script. useful for futuristic games. ty :P

**
Rep:
Level 85
The worlds ends on 21/12/12, where will you be?
How do you add ammo requirements for more than 1 gun?
Also, can you have more than 99 of 1 item?

Thanks in advance! :lol:

*
Rep: +0/-0Level 2
RMRK Junior
Chronic fds.aagv.rmrk.net.byg.ya enucleation setting generic allopurinol flonase pharmacy cialis 5mg prednisone prednisone online bactericidal expedient <a href="http://disasterlesskerala.org/allopurinol/">allopurinol for sale</a> <a href="http://hackingdiabetes.org/flonase/">generic flonase</a> <a href="http://robots2doss.org/online-pharmacy-cialis/">canadian pharmacy online</a> <a href="http://modreview.net/cialis/">lowest price cialis 20mg</a> <a href="http://ralstoncommunity.org/prednisone-online/">prednisone</a> horizontal, stutter-free modulated http://disasterlesskerala.org/allopurinol/ allopurinol http://hackingdiabetes.org/flonase/ flonase http://robots2doss.org/online-pharmacy-cialis/ canadian pharmacy online http://modreview.net/cialis/ cialis  lowest cost http://ralstoncommunity.org/prednisone-online/ prednisone 20 mil grams plotted hypochromic, acne.