Ammo requirements, and a conflict with my CBS

Started by Seox, June 09, 2009, 05:36:03 pm

Previous topic - Next topic

Seox

June 09, 2009, 05:36:03 pm Last Edit: June 16, 2009, 06:07:39 pm by Seox
Hiya. I'm having trouble with my ammo requirements script by synthesize:

#============================================================================
#                            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 = {1 => 1}
 Range_weapons_id = {2 => 5}
 Range_weapons_id = {4 => 1}
 Range_weapons_id = {5 => 1}
 Range_weapons_id = {6 => 3}
 # Format = {weapon_id => Item_id
 Range_ammo_id = {1 => 33}
 Range_ammo_id = {2 => 34}
 Range_ammo_id = {4 => 36}
 Range_ammo_id = {5 => 36}
 Range_ammo_id = {6 => 37}
 # Format = {skill_id => Ammo_cost}
 Skill_ammo = {81 => 15}
 # 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}'s weapon clicks - Empty! ", 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
#============================================================================



Whether I put it above or below my CBS (Tankentai side-view), it refuses to function. It works without the CBS, perfectly. It doesn't even throw an error - it just doesn't consume ammo. It aliases

# 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


And tankentai does this:

 def make_basic_action_result
   if @active_battler.current_action.basic == 0
     execute_action_attack
     return
   end
   if @active_battler.current_action.basic == 1
     @help_window.set_text("#{@active_battler.name} dives behind the nearest cover.", 1)
     @help_window.visible = true
     @active_battler.active = false
     wait(45)
     @help_window.visible = false
     return
   end
   if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2
     @spriteset.set_action(false, @active_battler.index, @active_battler.run_success)
     $game_system.se_play($data_system.escape_se)
     @active_battler.escape
     pop_help("#{@active_battler.name} escaped...")
     return
   end
   if @active_battler.current_action.basic == 3
     @active_battler.active = false
     $game_temp.forcing_battler = nil
     @phase4_step = 1
     return
   end
 end
 #--------------------------------------------------------------------------


Redefining the method, but I would think that the ammo script would still work fine. It only adds to the beginning, then calls the event as usual. What could the problem be?

Please and thank you ^_^



EDIT:

Anyone? Ammunition consumption is paramount to the gameplay of my game. If anyone thinks they can help, please don't hold back.
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)