show variables on screen rpg maker xp
#21
Okay, see, you've only set the Event Variable 001 when you first equiped the weapon. Variables only change when you tell them to, so if the amount of ammo changes you have to update the variable again. I edited the Syn's Ammo script, adding
Code:
    #update the Ammo variable
        $game_variables[1] = $game_party.item_number(gather_ammo)
to the methods make_skill_action_result and make_basic_action_result here is the edited script.
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 = {33 => 1, 34 => 1}
  # Format = {weapon_id => Item_id
  Range_ammo_id = {33 => 33, 34 => 34}
  # Format = {skill_id => Ammo_cost}
  Skill_ammo = {92 => 1, 93 => 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
        #update the Ammo variable
        $game_variables[1] = $game_party.item_number(gather_ammo)
      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)
        #update the Ammo variable
        $game_variables[1] = $game_party.item_number(gather_ammo)
        # 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
#============================================================================


As an aside, you are going to have to think about this ammo system. Like, since you can't change weapons in battle (you could fake it with skills that switched for you though!) if the player runs out of ammo, the player is guaranteed death. My advice is to use this Interactive Enemies event solution http://save-point.org/thread-2103.html and also modify the escape routine so the player can always escape after the first turn. But if you want to talk more about design ideas, you should make a new thread for your game project so we can all give feedback.
Reply }
#22
Topic move:
This topic belongs within 'Code Support' more than Script Request as it is more script conflict than requesting a new script. Winking That's all. [/i]
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#23
THANK YOU it works like a charm this game just could not exist without your help you been indispensable thank you so much.
I let the player change weapons with a skill which you learn the moment you pick up the gun it changes the variable to that of the weapons ammo and equips the gun and changes the picture on the hud
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Scan skill should show states Tumen 5 9,168 05-02-2017, 03:33 AM
Last Post: DerVVulfman
   Display State Ranks in Status Screen Mel 3 7,375 04-02-2017, 12:46 AM
Last Post: marketing small business ideas
   RMXP SKill animations too bright (overlaying the battle screen) Starmage 4 10,128 06-13-2016, 03:41 AM
Last Post: Starmage
   Custom Save/Load screen Raou 2 7,508 04-01-2015, 08:18 PM
Last Post: Raou
   Game Variables List for Copy/Paste JayRay 4 6,982 01-15-2015, 06:18 AM
Last Post: JayRay
   in FPLE touching events after battle causes rpg maker to crash ThePrinceofMars 1 5,479 11-27-2014, 09:11 PM
Last Post: MechanicalPen
   Script Request - Variables Specific Save File JayRay 2 5,090 04-28-2014, 05:15 AM
Last Post: JayRay
   Help with Shop Menu [RPG Maker XP] JackMonty 6 12,904 05-23-2013, 10:14 AM
Last Post: JackMonty
   Analyse show HP Bars Ace 12 16,692 12-28-2010, 04:39 PM
Last Post: Ace
   Showing the evade stat in the status screen corpsegirl 2 6,251 10-25-2010, 11:40 PM
Last Post: corpsegirl



Users browsing this thread: 1 Guest(s)