Currently, my Weapon system is like this:
each weapon-derived class has its own field called
AMMO and its own enumeration called WeaponType used to identify that weapon in the game.
This way, if I want to pickup some ammo for that weapon, I just need to do something like:
That will cycle through my
until it finds the weapon with that enumeration and,
once found, gives it some ammo
I don’t like this system. I find it unflexible.
AMMUNITIONS to be independent and for each weapon that I will introduce in the game, I should define which kinds of ammo it uses for its PrimaryFire and which ones for its SecondaryFire
Let’s pretend I want to make a Lightning gun in Unreal Tournament style.
Well, there will be ammunitions called, for example, "Electricity"
Now let’s say I want to make another weapon, which uses Bullets for its PrimaryFire,
but as secondary fire it uses Electricity ammunitions.
From this example, you see that Electricity and Bullet are two kinds of Ammunitions that don’t really belong to a specific weapon.
How could I achieve this?
April 17, 2016, 9:45pm
Enumerate ammo and specify primary and secondary types of compatible ammo for each weapon as fields. Add type field to ammo. Check compatible types of ammo and weapon before pickup.
But where do I store information
for each type of ammo?
Each ammo type has its own ammount of projectiles and whatever weapon wants to use those, it just decreases that ammount.
You’re creating the Ammo class but not using it
Why you use CountPrimary and CountSecondary when you have the subclasses?
April 17, 2016, 9:55pm
Perhaps the rational use of StaticClass or DynamicClass (new feature) in this case as alternative to enumeraion of the ammo types.
April 17, 2016, 10:09pm
bool Compatible = *(Weapon->AmmoPrimary) == Ammo->GetClass();
April 17, 2016, 10:17pm
This is just an example of the actual number of ammo. Ammunition can contain its own parameters.
Weapon->CountPrimary = Ammo->Count;
My idea is to give the players an Inventory of Ammunitions, each one with its own EAmmoType (enumeration) and CurrentAmmo (int32) properties.
So the Player has an inventory of Ammo and he can add ammo to it through an Inventory search by EAmmoType.
Is this a good idea?
EAmmoType is an enum, so you don’t have to search through an array of structs, you can convert the enum to a byte, and use that as an index into an array of integers. just set up the array in the same order as the Enum.
What if I have a particular weapon where it’s secondary fire uses a kind of ammo which requires the weapon to change something like the way it traces?Should I make a C++ class for each of these ‘particular’ weapons?
January 29, 2018, 12:26pm
And now for blueprint form pls?
this is C++ buddy. You can create a wrapper for this C++ to call it from BP pretty easily. Its called google.