How load shots before reload using variable? (FireBullet Behavior)

Hey there! im working on save and load state of ammo and magazine of my weapons.
Im using FireBullet behavior.

Ammo= Quantity of ammo (reserves).
Magazine= Quantity of ammo on magazine of the weapon (shots before reload).

Actually my save code is looking like this:

save weapon.FireBullet::AmmoQuantity() in “ammo_weapon” in “X_inventory”
save weapon.FireBullet::ShotsBeforeNextReload() in “magazine_weapon” in “X_inventory”

pretty simple and effective.

My load code look like this:

load “ammo_weapon” from “X_inventory” and save it on “ammo_weapon” (variable)
load “magazine_weapon” from “X_inventory” and save it on “magazine_weapon” (variable)
change ammo quantity of “weapon” = Variable(ammo_weapon) (load ammo quantity)

but i have a problem with magazine, because inside of FireBullet behavior you cant call the function "ShotsBeforeReload = “something” like change ammo quantity function.

I can save ShotsBeforeReload valor but i cant load it.

How can i manage ShotsBeforeReload valor? like ammo quantity function.

I don’t know if you need to save the exact state of the gun. There’s no reason the player couldn’t continue playing with a full magazine as long as the overall ammo is the same. I don’t think anyone would want to restart a game and have to reload after shooting 1 bullet should that be all that was left the last time. Let’s just assume that the player loaded their weapons in between gameplay.

If you truly want or need to then the fire extension could probably be modified. Either by you or you could try to contact the creator. I don’t know if a feature request is applicable for extension but you could probably post something to them or reference them.

Thanks for response!

My goal is the player be able to save inventory. Im currently on weapons phase with 2 slot equipment and 1 weapon equipped slot that works fine to choose what weapon player want to use .
At this moment i have 2 guns working on my game and i have plans to add more in future.

So my goal now is can save the state of magazine of the gun when players chose save the game.
Until now i only found ShotsBeforeReload as a count of magazine ammo, is there other function that works better for my purpouse?

I’m not super familiar with the fire behavior. I have a basic understanding. I don’t see any actions to set the current quantity before reload.

Finally my solution was create a ammo system apart based on player variables, and using firebullet in the fire system only.

For example:
Create a var on player with magazine_weapon

weapon is firing and magazine_weapon =/ 0 —> Var magazine_weapon - 1.

I made a ammo reserve in the same way, but decresead only on reload.

That is the basics, adding some extra condition for reload (for example reload only when magazine_weapon < 30 to emulate max ammo and a while condition adding 1 ammo to magazine until magazine_weapon = 30)

1 Like