Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V  < 1 2  
Closed TopicStart new topic
> Ammo Requirements
JuliusHawke
post Nov 29 2009, 01:33 PM
Post #21



Group Icon

Group: Member
Posts: 1
Type: Developer
RM Skill: Beginner




Can you post a demo? I'd understand the script more if I could examine it in action.


__________________________

Go to the top of the page
 
+Quote Post
   
EchoRose13
post Apr 26 2010, 11:29 PM
Post #22


Level 1
Group Icon

Group: Member
Posts: 14
Type: Event Designer
RM Skill: Intermediate




QUOTE (KiteDXX @ Feb 15 2008, 12:55 PM) *
CODE
#----------------------------------------------------------------------------
# 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


In that section:

-Weapon ID 17 (The 17th weapon in the Database) uses 1 ammo in order to attack.
-Weapon ID 17 (The 17th weapon in the Database) uses Item ID 33 (The 33rd item in the Database) as ammo.
-Skill ID 73 (The 73rd skill in the Database) requires 3 ammo to use. The item ammo that is depleted to use Skill 73 is the weapon that you have equipped when you use it.

In order to add more weapons and ammo requirements to the script, you would add new sets to the hash. For example, if I wanted to add Weapon ID 18 to use 4 of Item ID 34 as ammo, I would change the section like so:

CODE
Range_weapons_id = {17 => 1, 18 => 4}
Range_ammo_id = {17 => 33, 18 => 34}


You basically add a comma, then add the ID of the weapon, a "=>", then the ID of the item (or the quantity you want to deplete in order to use the weapon, depending on which section you are in).

If you were to use the example addition I gave you, Weapon ID 18 would be "Bronze Bow" while Item ID 34 would be "Bronze Arrows". You would require 4 "Bronze Arrows" in order to attack with "Bronze Bow". You can freely change the numbers in the example to adapt to your own project.

As for the other question, that function does not exist in the script. However, it would be viable to just have something like "Throwing Knife Satchel" for the weapon and "Throwing Knife" as the item used. Otherwise, you would have to make additions or modifications to the script itself, and I'm not truly advanced with scripts to know how to do that. :/


I keep getting a syntax error on the lines I modify, exactly as you said to. Whats going on with it?
I modify with "{1 => 2, 2 =>2}" as an example. But it says there is a syntax error on the line in which I use this.
Go to the top of the page
 
+Quote Post
   
monzdname
post Dec 7 2010, 05:27 PM
Post #23


Level 1
Group Icon

Group: Member
Posts: 10
Type: None
RM Skill: Beginner




I really like this script and would like to use it, but I've encountered some problems.
At first, everything was ok, the script was running well and every time I attack, an ammo is consumed. As seen in my item menu.

Now here comes the problem..
First, when i used that skill thingy, wherein the battler consumes ammo when using skill, the ammo is not consumed. I've tested a gun skill
wherein it must consume 5 bullets. But it doesn't. I dont know what went wrong, coz the database are ok (the numbers corresponding to my database in the script) and the normal attack thing went fine anyway so why would not it work on skill..

Here's my bigger problem..
The attack thing was working perfectly fine, until i deplete my ammo. Every time I attack with my ammo depleted, instead of saying "not enough ammo" or something like that. I get a syntax error. Is this compatible with Minkoff/DerVVulfman's Animated Battller?? Coz I'm using it and the syntax error occured at "Battle Scene" script around line 254 of that animated battler.

Well thats it. Hope this can be fixed, coz I dont have any idea on scripting..


Go to the top of the page
 
+Quote Post
   
Night_Runner
post Dec 8 2010, 12:07 AM
Post #24


Level 50
Group Icon

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




@> monzdname: Welcome to the forums.

For your first problem, I can't replicate it. I used a skill enough times to depete my ammo, and it then stoped attacking, just like it should.
I then tried a few combinations of using the skill with the weapon, and it still worked.
You definitely don't delete in ammo for the weapon you have equipped, when using skills?


For your second problem, there's no need to credit fro this, I only wrote 1 extra line
[Show/Hide] Night_Runner's Ammo Requirements Edit
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, 18=> 2}
  # Format = {weapon_id => Item_id
  Range_ammo_id = {17 => 33, 18=> 34}
  # Format = {skill_id => Ammo_cost}
  Skill_ammo = {73 => 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 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)
        @active_battler.current_action.basic = 3
      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
#============================================================================


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
monzdname
post Dec 8 2010, 09:11 PM
Post #25


Level 1
Group Icon

Group: Member
Posts: 10
Type: None
RM Skill: Beginner




@Night_Runner

Thanks, about that first problem, i already solved it and is working perfectly fine.
Now I'm gonna try the script you posted and hope it'll work. Thank you
Go to the top of the page
 
+Quote Post
   
mafioso
post Jan 19 2011, 08:29 PM
Post #26



Group Icon

Group: Member
Posts: 3
Type: None
RM Skill: Undisclosed




Hello, need to ask one thing..
Is this compatible with Cogwheel's RTAB?
Because everytime i paste this script, an error occurs.
Go to the top of the page
 
+Quote Post
   

2 Pages V  < 1 2
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: 19th June 2013 - 02:58 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker