Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Ammo Requirements
Ty
post Aug 15 2007, 01:09 PM
Post #1


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




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.

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.
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 => 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

This post has been edited by Ty: Sep 4 2010, 05:46 AM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   

Posts in this topic
- Synthesize   Ammo Requirements   Aug 15 2007, 01:09 PM
- - jens009   Sweet Script! Now we can fire only a limited a...   Aug 18 2007, 02:59 PM
- - Synthesize   Actually you can do that by making a simple mod to...   Aug 18 2007, 05:17 PM
- - Snarfinllama   Wait, I am completely confused - do i make an item...   Feb 15 2008, 07:18 AM
- - KiteDXX   CODE#---------------------------------------------...   Feb 15 2008, 11:55 AM
|- - EchoRose13   QUOTE (KiteDXX @ Feb 15 2008, 12:55 PM) C...   Apr 26 2010, 11:29 PM
|- - monzdname   I really like this script and would like to use it...   Dec 7 2010, 05:27 PM
- - Alrian   Hi guys I'm new here and I wanted to know if t...   Feb 17 2008, 03:31 PM
- - Synthesize   It could be useful in RMVX, but it won't work ...   Feb 18 2008, 11:56 AM
- - D3wil666   in my game is a lot of bows and when i copy script...   Mar 8 2008, 07:22 AM
- - saninu   Beautiful Script. =D   Mar 20 2008, 12:58 PM
- - Ceegamus   So, would it be possible to include more than one ...   Mar 21 2008, 05:03 AM
- - Krenic-The-Hedgehog   dude, it works, but only for ONE weapon! I try...   Mar 27 2008, 12:23 PM
- - Trind   So... wait... I'm completely new at the whole ...   Mar 27 2008, 06:58 PM
- - vVTalonVv   I'm having a tough time understanding this. Co...   Apr 2 2008, 02:54 PM
- - funkidud3   can you just make ammo for skills only, because i ...   Apr 3 2008, 11:40 PM
|- - jens009   QUOTE (funkidud3 @ Apr 3 2008, 11:54 PM) ...   Apr 4 2008, 11:24 AM
|- - funkidud3   Thanks jens   Apr 4 2008, 02:13 PM
- - Blaz3r   can someone edit this script? you know, more weapo...   Jun 23 2008, 02:32 AM
- - deathreaper123   Is it only me... I dunno, I done everything as it ...   Jul 2 2008, 04:52 AM
- - Krenic-The-Hedgehog   sorry repeating this but I really need help on thi...   Jul 2 2008, 01:27 PM
- - Ty   Well, time to answer some questions. Sorry for the...   Jul 11 2008, 12:12 PM
|- - JuliusHawke   Can you post a demo? I'd understand the script...   Nov 29 2009, 01:33 PM
- - Night_Runner   @> monzdname: Welcome to the forums. For your ...   Dec 8 2010, 12:07 AM
|- - monzdname   @Night_Runner Thanks, about that first problem, i...   Dec 8 2010, 09:11 PM
- - mafioso   Hello, need to ask one thing.. Is this compatible ...   Jan 19 2011, 08:29 PM


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 12:04 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker