Ammo Requirements |
|
|
|
|
Aug 15 2007, 01:09 PM
|

Level 38

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed

|
Script Name: Ammo Requirements Written by: Synthesize Current Version: V.1.00 Release Date: August 15, 2007 What is it?With this script the actors can only attack and/or do specific skills if they have enough ammo in the inventory. The designer can set every weapon to use it's very own unique ammo count and ammo easily via the options at the top. Features- Each weapon can use a different amount of ammo (Say a shotgun fires 5 rather then a pistol which fires 1) - Each weapon can have it's own ammo - Easily define skills that require ammo and the amount of ammo needed - Skills use the current equipped weapons ammo rather then a defined value. The ScriptPlace in a New Script Above Main. 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 = {17 => 1} # Format = {weapon_id => Item_id Range_ammo_id = {17 => 33} # Format = {skill_id => Ammo_cost} Skill_ammo = {73 => 3} # 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 #============================================================================ Usage:This script may be used in either a commercial project or a free ware project free of charge. However, credit must be present somewhere in the project. Editing/Distribution:Feel free to redistribute this post to other boards/websites. Just keep the wording the same. As for editing the script to suite your tastes feel free. Just keep the original header/footer in tact. If you have any questions or you found a bug, please PM me or make a post with the following: 1.) SDK Version 2.) Other Scripts 3.) Factors of the bug (What did you do to make it happen?) 4.) version 5.) Error Line Cheers, Syn
This post has been edited by Ty: Sep 4 2010, 05:46 AM
__________________________
|
|
|
|
|
|
|
|
|
Feb 15 2008, 07:18 AM
|

Level 4

Group: Member
Posts: 51
Type: Event Designer
RM Skill: Undisclosed

|
Wait, I am completely confused - do i make an item called 'Bronze Arrows' etc. or what? and exactly how do I use the custimazation part of it. Sorry but the comments on this are hard to follow (atleast for me)  EDIT --------- 1 more thing if you dont mind, does anyone know a possible way to make the weapon ITSELF the ammo i.e throwing knives for my game. The module looks like you need an item id. Synth, can you tell me how i would go about doing this?
This post has been edited by Snarfinllama: Feb 15 2008, 07:31 AM
|
|
|
|
|
|
|
|
|
Feb 15 2008, 11:55 AM
|

Level 7

Group: Member
Posts: 96
Type: Event Designer
RM Skill: Skilled

|
CODE #---------------------------------------------------------------------------- # Customization Section #---------------------------------------------------------------------------- module Ammo # Format = {weapon_id => Ammo_cost} Range_weapons_id = {17 => 1} # Format = {weapon_id => Item_id Range_ammo_id = {17 => 33} # Format = {skill_id => Ammo_cost} Skill_ammo = {73 => 3} # 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 In that section: -Weapon ID 17 (The 17th weapon in the Database) uses 1 ammo in order to attack. -Weapon ID 17 (The 17th weapon in the Database) uses Item ID 33 (The 33rd item in the Database) as ammo. -Skill ID 73 (The 73rd skill in the Database) requires 3 ammo to use. The item ammo that is depleted to use Skill 73 is the weapon that you have equipped when you use it. In order to add more weapons and ammo requirements to the script, you would add new sets to the hash. For example, if I wanted to add Weapon ID 18 to use 4 of Item ID 34 as ammo, I would change the section like so: CODE Range_weapons_id = {17 => 1, 18 => 4} Range_ammo_id = {17 => 33, 18 => 34} You basically add a comma, then add the ID of the weapon, a "=>", then the ID of the item (or the quantity you want to deplete in order to use the weapon, depending on which section you are in). If you were to use the example addition I gave you, Weapon ID 18 would be "Bronze Bow" while Item ID 34 would be "Bronze Arrows". You would require 4 "Bronze Arrows" in order to attack with "Bronze Bow". You can freely change the numbers in the example to adapt to your own project. As for the other question, that function does not exist in the script. However, it would be viable to just have something like "Throwing Knife Satchel" for the weapon and "Throwing Knife" as the item used. Otherwise, you would have to make additions or modifications to the script itself, and I'm not truly advanced with scripts to know how to do that. :/
__________________________
|
|
|
|
|
|
|
|
|
Mar 8 2008, 07:22 AM
|
Level 3

Group: Member
Posts: 44
Type: None
RM Skill: Beginner

|
in my game is a lot of bows and when i copy script it don't work. Bow shots when character don't have ammo
|
|
|
|
|
|
|
|
|
Mar 21 2008, 05:03 AM
|

Group: Member
Posts: 2
Type: None
RM Skill: Beginner

|
So, would it be possible to include more than one ammo for a weapon?
|
|
|
|
|
|
|
|
|
Mar 27 2008, 12:23 PM
|

Level 3

Group: Member
Posts: 37
Type: Developer
RM Skill: Intermediate

|
dude, it works, but only for ONE weapon! I tryed to double it with (a diferent wapon of course) but it just keep saying Errors! help please cuz I need for more than 3 weapons in my F1 game
__________________________
The percentages I present below go from -100% to 100% of completion having 0 of percentage the beginning of the actual making.
Projects in the making (that I'll surely work on only by Summer vacations): RPG Maker XP -Keyaku's Journey: Legends Live = 20% ====> Rewriting story script (not code) and most characters dialogues... -Formula 1: Quicker than the end (Title will SURELY change) = -20% ===> Making character graphics...
iPhone Unity -Avenger = -75% ===> Compiling story, writing script (not code), ideas on adapting it onto the iPhone scene (with actual code that'll bring visual effects)...
|
|
|
|
|
|
|
|
|
Mar 27 2008, 06:58 PM
|

Group: Member
Posts: 1
Type: None
RM Skill: Beginner

|
So... wait... I'm completely new at the whole scripting part.
Do I just create one new script in the Script Editor and paste all that in there, or do I have to cut parts out and paste them in different areas of the Script Editor?
Oh, by the way, I have RPG Maker VX. If this is for XP, how do I modify the script to run in VX?
This post has been edited by Trind: Mar 27 2008, 07:22 PM
|
|
|
|
|
|
|
|
|
Apr 2 2008, 02:54 PM
|
Level 2

Group: Member
Posts: 25
Type: None
RM Skill: Undisclosed

|
I'm having a tough time understanding this. Could somebody possibly explain it in simpler terms? I have NO scripting experience whatsoever so its going to take me some time to learn.
Pretty much for my game idea, I need to have ammo and such (its a zombie survival horror). Is it possible to make it so that there are clips of ammunition for lets say... a pistol with 16 shots? And when the ammo is used up, how can I have it so that it takes a round/turn to reload?
Also, is it possible to switch weapons during a battle? The point of this would be if your character ran out of ammo for gun A, he/she could switch to gun B or his/her knife.
To anyone who can help me with this questions, it would be greatly appreciated. Thanks again!
|
|
|
|
|
|
|
|
|
Apr 3 2008, 11:40 PM
|

Group: Member
Posts: 2
Type: None
RM Skill: Skilled

|
can you just make ammo for skills only, because i want to have the close range weapons as the primary weapons and long range weapons as skills
This post has been edited by funkidud3: Apr 4 2008, 03:12 AM
|
|
|
|
|
|
|
|
|
Apr 4 2008, 11:24 AM
|

L Did you know? Death gods... only eat apples

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled

|
QUOTE (funkidud3 @ Apr 3 2008, 11:54 PM)  can you just make ammo for skills only, because i want to have the close range weapons as the primary weapons and long range weapons as skills Hmm, this script may not be what you are looking for. Because the skills and weapons work together within the code. as stated in this line: CODE # 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. You should try Dervvulfman's Skills that Consume Items (DBS Version) instead.
__________________________
My RMXP Project:  Farewell RRR. =]
|
|
|
|
|
|
|
|
|
Apr 4 2008, 02:13 PM
|

Group: Member
Posts: 2
Type: None
RM Skill: Skilled

|
Thanks jens
|
|
|
|
|
|
|
|
|
Jun 23 2008, 02:32 AM
|
Level 3

Group: Member
Posts: 33
Type: None
RM Skill: Skilled

|
can someone edit this script? you know, more weapons with ammo, not only one ^^ or, how do it? ^^
Edit: sorry, it's easy to do that ^^' never mind
This post has been edited by Blaz3r: Jun 25 2008, 02:22 AM
__________________________
Be a part of Adventure Quest Worlds History!

|
|
|
|
|
|
|
|
|
Jul 2 2008, 04:52 AM
|

Group: Member
Posts: 2
Type: Developer
RM Skill: Beginner

|
Is it only me... I dunno, I done everything as it needed to be, but I can't find the effect of the script in the game...
Not in database, not in game itself... please help!
|
|
|
|
|
|
|
|
|
Jul 2 2008, 01:27 PM
|

Level 3

Group: Member
Posts: 37
Type: Developer
RM Skill: Intermediate

|
sorry repeating this but I really need help on this one... QUOTE dude, it works, but only for ONE weapon! I tried to double the script code, but the RM XP makes me delete sme lines or modify I copied your whole code, and I modified my parts (which means, the IDs of the weapons) but I can't seem to do it on more weapons, only on one... thank you
__________________________
The percentages I present below go from -100% to 100% of completion having 0 of percentage the beginning of the actual making.
Projects in the making (that I'll surely work on only by Summer vacations): RPG Maker XP -Keyaku's Journey: Legends Live = 20% ====> Rewriting story script (not code) and most characters dialogues... -Formula 1: Quicker than the end (Title will SURELY change) = -20% ===> Making character graphics...
iPhone Unity -Avenger = -75% ===> Compiling story, writing script (not code), ideas on adapting it onto the iPhone scene (with actual code that'll bring visual effects)...
|
|
|
|
|
|
|
|
|
Jul 11 2008, 12:12 PM
|

Level 38

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed

|
Well, time to answer some questions. Sorry for the looooong delay. QUOTE dude, it works, but only for ONE weapon! I tryed to double it with (a diferent wapon of course) but it just keep saying Errors! help please cuz I need for more than 3 weapons in my F1 game In the Configuration section of the script, you define which weapons use which ammo and how much ammo they use. You add additional weapons by making changes like this: CODE # Format = {weapon_id => Ammo_cost} Range_weapons_id = {17 => 1} The above is the default configuration line of code. Now all you do is add a comma (,) and insert a new weapon. Like so: CODE # Format = {weapon_id => Ammo_cost} Range_weapons_id = {17 => 1, 21 => 1} Now what we did is added a new option inside the Hash. The Hash is different, yet similar to the array (array = [0,1,2,3]). The biggest difference is that data inside a hash cannot be changed. This means you cannot do things like hash = {1 => 1} += 1. The way the Hash works is that is has a trigger value and a return value. When the trigger value is called somewhere in a script, the result will be the return value. So take the following example: CODE class something def something Hash = {"Yellow" => "Blue"} p hash["Yellow"] end end In the example above, the hash 'hash' is storing the information "Yellow." So when the information stored within the hash is called, in this case, "Yellow" is the trigger value, the result will be "Blue." After saying this, we can conclude that 'Ammo Requirements' searching the hash specified in the Configuration file for the weapon ID the actor currently has equipped, if the value is in the configuration, it will return the amount of ammo the weapon needs to fire. The script can have an unlimited amount of weapons that require ammo, all that is needed is a small modification to the configuration section. ---------------------------------------------------------------------- @Trend: This will not work for RPG Maker VX.
__________________________
|
|
|
|
|
|
|
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|