I am working on a fps rpg I would like it if I equip a shotgun it will hurt more than one enemy when I attack but I would go back to attacking just one foe if I equip a pistol thanks in advance :)
(RPGMXP) melee attack which hurts more than one foe if a certain weapon is equipped
● ARCHIVED · READ-ONLY
-
-
Are you using the DBS? Or a custom battle system?
-
just the default combat system but I am using a ammo script which uses ammo every-time you attack here it is
#============================================================================
# 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 => 3, 35 => 3, 36 => 2, 37 => 1, 38 => 1}
# Format = {weapon_id => Item_id
Range_ammo_id = {33 => 48, 34 => 49, 35 => 50, 36 => 48, 37 => 51, 38 => 60}
# 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
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
#============================================================================ -
Alright, so here's a quick script that should do the trick. I haven't tested it extensively, so there may be a few bugs. If you find anything that doesn't work the way you want it to, just let me know and I'll try to fix it. Ok, so the way this script works is at the top there's a spot for you to enter weapon IDs. Just put in the IDs for whatever weapons you want to be treated as "shotguns" and the script will cause those weapons to target all enemies (or all allies if confused). Enter the IDs separated by commas. Example - IDs 5, 19, and 21 should be entered as "[5, 19, 21]" (without the quotes)
SpoilerCode:module Mobius module Shotgun SHOTGUN_WEAPONS = [] endendclass Scene_Battle alias mobius_update_phase3_basic_command update_phase3_basic_command alias mobius_make_basic_action_result make_basic_action_result #-------------------------------------------------------------------------- # * Frame Update (actor command phase : basic command) #-------------------------------------------------------------------------- def update_phase3_basic_command # If B button was pressed if Input.trigger?(Input:: # Play cancel SE $game_system.se_play($data_system.cancel_se) # Go to command input for previous actor phase3_prior_actor return end # If C button was pressed if Input.trigger?(Input::C) # Branch by actor command window cursor position case @actor_command_window.index when 0 # attack # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # Start enemy selection weapon_target_decide when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 1 # Start skill selection start_skill_select when 2 # guard # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 # Go to command input for next actor phase3_next_actor when 3 # item # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 2 # Start item selection start_item_select end return end end #-------------------------------------------------------------------------- # * Weapon Target Decide #-------------------------------------------------------------------------- def weapon_target_decide weapon_id = @active_battler.weapon_id if Mobius::Shotgun::SHOTGUN_WEAPONS.include?(weapon_id) # Go to command input for next actor phase3_next_actor else # Start enemy selection start_enemy_select end end #-------------------------------------------------------------------------- # * Make Basic Action Results #-------------------------------------------------------------------------- def make_basic_action_result if @active_battler.is_a?(Game_Actor) weapon_id = @active_battler.weapon_id if ( Mobius::Shotgun::SHOTGUN_WEAPONS.include?(weapon_id) ) and ( @active_battler.current_action.basic == 0 ) return make_shotgun_action_result end end mobius_make_basic_action_result end #-------------------------------------------------------------------------- # * Make Basic Action Results #-------------------------------------------------------------------------- def make_shotgun_action_result # Set anaimation ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # Determine restriction if @active_battler.restriction == 3 # force target ally for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end else for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end end # Apply normal attack results for target in @target_battlers target.attack_effect(@active_battler) end return endend -
thank you so much for taking the time to make this script unfortunately I do still have 2 problems one is that when I attack multiple foes it plays the animation of the player fireing the shotgun at every individual enemy so you see 3 pairs of arms firing 3 shotguns at the same time really I should of realized that would of happened the other problem is when i use your script it stop the ammo script I am using from working I would be asking to much to ask you to fiddle with someone else's script if you would be willing to help I would like to fix it that only one animation plays during attacks on more than one foe and that when you do that attack it takes an item out of you inventory namely the shotgun shells or rocket but that would take alot of scripting and I totally understand if you don't want to do that thank you again for trying to help
-
I'll take a look at it, and see what I can do.
EDIT: Ok, so these are both easy to fix. To get the ammo script working again, simply place my script below all of the default scripts but above main and then put the ammo
script below mine but still above main. To fix the animation issue, all you have to do is change the animation for the weapon in the database. If you've never done any
animation changing, all you have to do is select the animation for the shotgun, find where it says "position" and change the drop down to "screen". That will cause an
animation to display across the entire screen rather than single enemies. -
thank you so much it works perfectly thank you thank you thank you :D