Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

XP: Weapon accuracy & ammunition types

I'm making a sci-fi rpg with different types of firearms and I have a few questions.

1. Instead of having the hit chance determined by character's hit rate, I would like to have a weapon-specific hit rates, which would be modified by the characters Intelligence level (called Perception in my game) and the enemys Agility level. So, the weapon has a accuracy ranging from 1-100 and the character has a Int level ranging from 1-10 and the enemy has an Agi level ranging from 1-10 and the total accuracy would be a hit chance from 0-100%. The character's Int level would give bonuses to the base Acc of the weapon, and the enemy's Agi would give penalties. That is: (Bonus - Penalty) + Accuracy = Hit chance. Any hints on where to begin?

2. This far I have been using Syn's Ammo Requirements, but I would like to modify it so that I could make one weapon use more than one type of ammunition. In practice, you would equip a weapon to the Weapon slot and then equip the ammo type you want to use to one of the other equipment slots (for example Shield). Instead of equipping just 1 round, you would be able to equip or 'load' the amount of bullets equivalent to the magazine size of the equipped weapon (or less, if you don't have a whole clip). The ammunition would affect the weapon's Attack Power and Accuracy. Any help would be greatly appreciated!

These are the general ideas that I've been working on. I'm happy to give more information if needed. Thanks in advance!

PS.
At the moment, I'm not using any scripts that have to do with these classes, other than the mentioned Syn's Ammo Requirements, which is here:
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 = {11 => 1, 12 => 1, 13 => 1, 14 => 1, 15 => 1, 21 => 3, 22 => 3, 23 => 3, 24 => 3, 25 => 3, 26 => 3, 27 => 3, 28 => 3, 31 => 1, 32 => 1, 33 => 1, 34 => 1, 35 => 1, 36 => 1, 41 => 1, 42 => 1, 43 => 6, 44 => 12, 45 => 1, 46 => 1}

  # Format = {weapon_id => Item_id

  Range_ammo_id = {11 => 61, 12 => 61, 13 => 64, 14 => 64, 15 => 64, 21 => 61, 22 => 61, 23 => 69, 24 => 69, 25 => 69, 26 => 71, 27 => 71, 28 => 71, 31 => 66, 32 => 66, 33 => 66, 34 => 74, 35 => 74, 36 => 74, 41 => 76, 42 => 78, 43 => 74, 44 => 81, 45 => 79, 46 => 80}

  # Format = {skill_id => Ammo_cost}

  Skill_ammo = {1 => 0}

  # 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} is out of 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} is out of 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

#============================================================================
 
Bumb, but I understand if this is too complicated...

Anyway, I'm now using Gubid's TBS. Which rocks. Could someone give me some advice on getting the ammo requirement script working with the TBS?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top