Picking Up Ammo

In my game, the players start with some ammo. However, that ammo is finite. How do I have them pick up more later on? I used some of the tutorial code, but the tutorial doesn't tell you how to pick up more ammo. Could someone help me out?


Alrighty. Let's begin :D (Pardon me for my bad English)

If you're talking about how the ammo is finite, you may as well want it to be stackable. I did a little research, and probably this site may help you:
https://github.com/ThePix/quest/wiki/Library:-Stackable-items
..though it involves a custom library

Anyways, back to the main topic. So first of all, you said that the player begins with this, if you may, a stack of ammo, and by time, the player may need more ammo. (Btw if you're only having problem with picking up then you can go to the ammo object tab and click on inventory tab. Make sure you've got the "object can be taken" box ticked)

But is the ammo location is set specifically just like those in battle royale-like games? Or, are you talking about ammo whose location may change by time?

If you're thinking about games where the ammo location is set, you may want to put several other ammo in rooms. Just make sure the alias is the same for the same type of ammo (or you can do clone object) and make sure it works the same as the ammo the player has at the very beginning of the game.

If you're thinking about ammo whose location may change by time, you can do this by setting up a script MoveObject that takes effect every few seconds or every turn. I think a turn script is the most befitting for this job, though.
However, if this is what you're going to do, you may consider one problem: players may be irritated when they get into the room seeing the ammo laying in the same room but then it disappears few seconds after they get into the room. If that's the case, the players may have to keep running for hours just to pick up ammo, isn't that annoying?

Because of that, add another script to the turn script and put the previously mentioned script within this one. This script will be something like: IF "player.parent=ammo.parent" (this is only if your player "name" is player and if your ammo "name", not alias, is ammo) then nothing happens. Else, move object ammo to object somewhere (if you're not using run script after few seconds)

I'm not really sure if that's what you're searching for, but hope it helps!


What I meant by the question was thus: If the player finds, say, twelve rounds in the environment somewhere, or finds ammo that has been dropped by an enemy. What would I include in the code to make it so the rounds would be added to the amount they already have.

But yeah, everything worked out. Thanks for the help.


What I meant by the question was thus: If the player finds, say, twelve rounds in the environment somewhere, or finds ammo that has been dropped by an enemy. What would I include in the code to make it so the rounds would be added to the amount they already have.

But yeah, everything worked out. Thanks for the help.


Personally I use a storage room for my items and I use volume as the amount I have which uses inventory limits as well. So if i pick up ammo after having non I pick up and increase volume by say 12, then when using ammo decrease volume of ammo by 1 then if equals 0 or lower set volume to 0 then move ammo to storage room for later use.

Edit: or you can do as I am in a Resident Evil game im porting over to quest by having currentammo and a max ammo attributes so your gun can only hold so many rounds when you reload.


It would be good if there is possible to pick up unlimited missiles at tank trouble game.


When I used an ammo system in one of my old projects, I toyed with the idea of having them be physical objects in the player's inventory. That would have been a nightmare to keep track of, however.

In the end, I made an attribute on the player object for each ammo type - pistol, rifle, shotgun, etc - starting at however much ammo they were meant to begin with. If the player found ammo - either a set amount, or a random drop decided by the DiceRoll("1dx") (Where x is the number of sides on the die; ie DiceRoll("1d4")) function, I added the amount to the corresponding ammo type. player.ammo pistol, as an example. (Named them ammo pistol, ammo rifle, etc to more easily track them. Consistency is key!)

Same thing with using the ammo. If the player performed an attack with their gun, my attack script would check the gun's ammo type and reduce the ammo count by that amount. It would also check to see if the gun had that much ammo to begin with, beforehand - if not, it would bring the player back to their options rather than wasting their turn.

As for keeping track of ammo, and other valuable items like crafting resources? I made a key 'bag' item on the player's person with some objects stored within it, which when used would display various things. A bandolier for ammo counts, a mirror for physical appearance, a compartment for listing off available resources, etc etc etc.


(filler for getting my edited post, updated/posted)


a really good (and very unique) design/mechanics/system of projectile combat:

Parasite Eve (1) (PS1)

I'd seriously look-at/study/research it's design, at least for ideas, it's done really well (and is quite unique)


briefly about it:


Object Types / Types:

projectile/ranged weapons:

(these 5 all use the same ammo type: there's really no reason for having different ammo types, unless it's for a vey specific game design/play reason)

  1. handguns
  2. shotguns
  3. rifles
  4. machine guns
  5. grenade launchers // (ya, a 'grenade' is not the same as a 'bullet', but we don't care because the game doesn't care, lol)
  1. rocket launchers (this uses its own, and very rare, ammo type: 'rockets', so, it's a 'novel' weapon mostly, not usually used in most normal game play): I'm going to ignore this weapon (as I don't want to write in its own 'rocket-ammo' inventory crate and 'rocket-ammo' storage crate objects and attributes below, lol)

melee weapons (mostly for a fall back, if you run out of ammo, a means of always being able to do damage, though you can also steal items from monsters/bosses if have the ability to do so on the club, which is separate from the dropped items from them):

  1. clubs (obviously, has no 'ammo' mechanic, lol)

Objects:

pretend examples (as I don't know guns/gun-names very well, lol)

  1. gun1A // (handgun type)

  2. gun1B // (handgun type) // just to show you there's multiple individual guns (of each gun type)

  3. gun2 // (machine gun type)

  4. gun3 // (rifle type)

  5. gun4 // (shotgun type)

  6. gun5 // (grenade launcher type)

  7. inventory_ammo_crate // you got a separate 'ammo crate' in your inventory to hold extra ammo

  8. storage_ammo_create // you also got another ammo crate in a specific storage area of the game


Attributes:

pretend examples

gun1A.attack = 10 // damage per shot/bullet (though it's a bit more complicated as there's a defense stat/attribute that reduces your damage done, and vice versa, as you can wear armors too, as well as some other stuff too)

gun1B.attack = 50 // damage per shot/bullet (though it's a bit more complicated as there's a defense stat/attribute that reduces your damage done, and vice versa, as you can wear armors too, as well as some other stuff too)

gun1A.range = 5 // if you attack outside of this range/distance, you'll either miss or do minimal damage (1-3)
gun3.range = 50 // if you attack outside of this range/distance, you'll either miss or do minimal damage (1-3)

gun1A.maximum_magazine = 6 // each gun has its own maximum magazine/ammo capacity (based on its gun type)
gun1A.current_magazine = 6 // hopefully self explanatory (current/remaining shots/ammo in your gun)

gun1B.maximum_magazine = 6 // each gun has its own maximum magazine/ammo capacity (based on its gun type)
gun1B.current_magazine = 6 // hopefully self explanatory (current/remaining shots/ammo in your gun)

gun2.maximum_magazine = 40 // each gun has its own maximum magazine/ammo capacity (based on its gun type)
gun2.current_magazine = 40 // hopefully self explanatory (current/remaining shots/ammo in your gun)

inventory_ammo_crate.maximum_capacity = 999
inventory_ammo_crate.current_capacity = 0

storage_ammo_crate.maximum_capacity = 999
storage_ammo_crate.current_capacity = 0

(being a real time game, there's also many duration attributes as well: reload duration, attacking duration, for guns with multiple shots per attack: duration between shots, recovery duration: after your attack or last shot, and likely a stun/damaged/recovery "stun-lock" duration)


you'll reload automatically during battle, if you got ammo still in your inventory ammo crate, though with this being a real time game, you got the reload animation duration, which leaves you vulnerable


you can also reload (or unload) your guns outside of battle, via in your menu inventory: transferring ammo to/from between your guns and your inventory ammo crate


when at the area with your storage ammo crate, you can transfer your ammo to/from between your inventory ammo crate and your storage ammo crate, or directly between your guns and the storage ammo crate too


the game also has various abilities (controlled by the number of 'slots': 'current_slots' and a hidden 'maximum_slots' on every weapon, on your weapons: 1 ability per slot) on your weapons as well, which you can transfer between weapons (one aspect of customizing/crafting an ultimate weapon, which is what makes it such a unique system/design/mechanic):

RoF (rate of fire = number of shots per attack, in this case, lol): x1, x2, x3, x5, x7, x10 // you don't want to slap 'x10 RoF' on a rifle type of gun, as they're very slow, for an example

and there's a bunch of other abilities too


also, every weapon has 'base stats' (attributes): which are NON-transferable

and also every weapon has 'plus stats' (attributes): which ARE transferable

base stat + plus stat = total stat

example: gun1A.base_attack + gun1A.plus_attack = gun1A.damage

there's items that will permanently increase a weapon's 'plus stat', but there's 'tool' items and 'super tool' items, that allows you to transfer all the plus stats (or just one ability) from one weapon to another weapon, so you can create/bulk-up a really powerful ultimate weapon

the same for armor as well, having stats and abilities too


so, this is a really fun, well/smoothly/cleanly, unique RPG and projectile combat design/mechanic/system game


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums