Ammo Script
#1
Ammo Script Version 1
Dubealex
May 27 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


This is a basic ammo script. It will check who is attacking, with which weapon, and it will decrease an item number that is linked with that weapon.

It also checks during the attack menu selection if you still have ammo for the weapon you have equiped, and if not, the attack option is disabled.

What happen afterward, and what the user can do, is up to you.

PART 1

OPen up SCENE_BATTLE4 and find the following line:

Code:
target.damage_pop = true



It should be around line #433. Then, BELOW it, add the following code:

Code:
#--------------------------------------------------------------------------
#DUBEALEX AMMO SCRIPT
#--------------------------------------------------------------------------
active_actor=@active_battler.index #Findind who is attacking

if @active_battler.is_a?(Game_Actor) and @active_battler.current_action.kind == 0
    actor=$game_party.actors[active_actor] #Shortcut
    ammo_type=actor.weapon_id #Shortcut again
  
    case ammo_type #Checking the Weapon ID
        when 1 #When weapon ID "number" is used...
            $game_party.lose_item(1, 1) #Decrease ammo: (Item ID, Number to decrease)
        when 2
            $game_party.lose_item(2, 1)
    end
end

#--------------------------------------------------------------------------
#END OF AMMO SCRIPT
#--------------------------------------------------------------------------



The only part you need to customize for your game in this block is the following part:

Code:
case ammo_type #Checking the Weapon ID
          when 1 #When weapon ID "number" is used...
            $game_party.lose_item(1, 1) #Decrease ammo: (Item ID, Number to decrease)
          when 2  
            $game_party.lose_item(2, 1)
        end



This is where you define which wepon ID# is linked with which Item ID#, and the amount to decrease on each attack. It's simple, you just add/remove more WHEN lines in the CASE block, and you change the numbers. The comments in the code should be enough to guide you.

- Your weapon ID and Ammo ID must be the same. It means that if your weapon SHOTGUN have ID#13, the ammo for the SHOTGUN must be ID#13 too.

PART 2

Open up SCENE_BATTLE3, and find the following line:

Code:
def update_phase3_basic_command


It should be around line #109. Then, BELOW it, add the following code:

Code:
#DUBEALEX AMMO SCRIPT - CHECK FOR AMMO
active_actor=@active_battler.index
actor=$game_party.actors[active_actor]
ammo_type=actor.weapon_id
weapon_name=$data_weapons[$game_actors[active_actor+1].weapon_id].name
ammo_count=$game_party.item_number(ammo_type)
can_attack=true
if ammo_count <= 0
    can_attack=false
    @help_window.set_text("Ammo Left: " + weapon_name + " " + "(NO AMMO)")
else
    @help_window.set_text("Ammo Left: " + weapon_name + " " + "[" + ammo_count.to_s + "]")
end
#END OF CHECKING FOR AMMO


This block actually checks your ammo before you can execute a normal attack, if you have no ammo, the ATTACK selection is disabled. This block also shows to the player at the top of the screen which weapon is equiped, and how much ammo is left in the weapon. You have nothing to customize in this block, unless you know how to script and want to enhance it with something, like more colors or images or even gradient bars.

PART 3

Then, in the same page (SCENE_BATTLE3), find the following line:

Code:
case @actor_command_window.index



It should be around line #137. Then, you should see, just BELOW it a line that says:

Code:
when 0  # 攻撃


You need to add the following code just BELOW the WHEN line:


Code:
#LOCKING ATTACK IF NO AMMO
unless can_attack
    $game_system.se_play($data_system.buzzer_se)
    return
end
#END OF LOCKING ATTACK



You dont need to change anything in that block. Thius block will ensure that when you are out of ammo, you cannot attack with the weapon.

CONCLUSION

There, you have a basic ammo script. What you do with it from this point on is up to you. Have fun !
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Modified Audio Encryption Script avatarmonkeykirby 0 2,671 07-28-2008, 01:00 PM
Last Post: avatarmonkeykirby
  Rotimikid's Enemy level Script ShockWave 0 2,825 08-24-2007, 01:00 PM
Last Post: ShockWave
  Script switch management GubiD 0 2,515 08-19-2007, 01:00 PM
Last Post: GubiD
  Nice game over script Moghunter 0 2,594 07-18-2007, 01:00 PM
Last Post: Moghunter
  Animated Options Script Samo the thief 0 2,580 06-18-2007, 01:00 PM
Last Post: Samo the thief
  Teleportation Script Digi 0 2,541 05-01-2007, 01:00 PM
Last Post: Digi
  Luck Script Darklord3652 0 2,549 04-10-2007, 01:00 PM
Last Post: Darklord3652
  GameOver Menu Script sasuke89 0 2,486 06-08-2006, 01:00 PM
Last Post: sasuke89
  Weapon Levelling Script GoldenShadow 0 2,481 07-05-2005, 01:00 PM
Last Post: GoldenShadow
  Item Detail Script jackatrades 0 2,645 05-19-2005, 01:00 PM
Last Post: jackatrades



Users browsing this thread: 2 Guest(s)