Scripting/Verse/Device assistance > Ammo Tracking

Hey all, I am still working out the Verse language. Coding/scripting is not my primary skillset so I still need hand-holding at times.

I have been looking at some gun game examples for suggestions but still have not found a clean route to solve the issue I have…

THE ISSUE:
I want to be able to activate an item granter, to grant the next weapon, once a condition is met. The usual condition is when a player is defeated. The condition I want to track is when the player runs out of ammo. I am having a hard time figuring out how to track the ammo and fire the event at all, much less activate it per player.

I am not necessarily looking for a free answer, although I will take it if someone has one, but any ideas or suggestions would be great. With any programming language I am sure there are many ways to do this. As a matter of fact, I have not explored doing this without verse, but having a device may be stronger anyway as I can use the event to fire off other things if needed later.

As usual, any assistance would be greatly appreciated! Thanks!

As a secondary thought I tried using a player marker to track ammo and that SHOULD work but does not. I am willing to accept a work around if it exists.

So I tried another avenue using devices and markers.

I have a marker that I tried using. I had it set so that when my light ammo hits zero, it initiates the hud message and item granter. This did not work. But I tried something else as an attempt to see if things were working as intended.

So there is an item granter that initially hands you a pistol when the match starts. So I set the marker to check to see if the player has a pistol and if so initiate the hud message and the next item granter. That worked… So I guess my issue is in fact, and inability to accurately track ammo.

If im not mistaken Player Markers&Conditional Buttons can’t track ammo inside weapons they only track the spare ammo in your inventory

1 Like

@Mineblo I am starting to get that impression. I am curious if anything, script or otherwise, can track this. The weapon API does not seem to be available at this point it seems.

There is NO way as far as I know to know if a gun is empty or full there was a bug letting you do it with player marker back in the day I think but its probably fixed.

@Mineblo that gave me an idea. It is not ideal… But if I am only able to track inventory, I can limit the gun in question to a specified amount of ammo from the granter and 1 additional round to inventory and then track when the single round leave inventory. It means that the reload will still fire but that is a fair trade for now rather than not have the functionality at all :confused:

The only solutions to this that I can think of are complicated enough to the point where you may as well just make your own weapon as you’d need to use a sphere trace in control rig to put a trigger between the player and the object located at the furthest distance in front of them (up to the maximum range of the weapon) that would trigger whenever they missed. You’d then need to create a listener that runs for both damage events and that triggers events (you’d run those against a conditional that checks the player IsHolding and then correlates the item to the ammo type) to subtract the bullet from the clip count.

At that point I’d just make a custom weapon with the control rig trace instead.

Edit: The other option would be to create your entire level out of props and then put them in a giant prop manipulator and listen for DamageEvent and then heal them back every time they’re hit. You could then use a combination of damage events and misses to calculate the ammo in the clip. The only issue you run into there is what if the player shoots directly into the sky? In order to handle that you’d have to create an invisible prop that sits at the highest point in the playspace you would use so that it would still trigger but not interfere with gameplay.

2 Likes

@LionUnchained That is a very interesting way to look at it. I may play with those ideas. For the time I have something that works…

1 Like

In all this research did you find out anyway to control ammo? Im also having a hard time in the API surrounding weapon ammo. Im trying to create a non distructive instant reload (on trigger) device. The current norm seems to be (on triggered) check if player has gun - remove gun - grant gun. Which works great, but you cant use weapon mods as it just gives you a fresh new gun. I know its possible, ive played a map that had this working Im just struggling to find any info on the verse code that can manipulate the clip ammo.

Obviously this is different from what your trying to do but they kind of cross the same path and was just wondering if you found anything interesting that I can also look into!