Hi guys,
I while ago i made a weapon pickup and upgrade FSM system which was quite complicated and needed to be in every weapon to be functionable. Recently i got an idea to make a centralized system for that, but i'm hitting some walls.
Here's the setup:
I've got a hash table of all player weapons objects with key being their names (PulseGun1, PulseGun2 to PulseGun5...every level of weapon is considered a new weapon, but they share the same tag, PulseGun).
On the player, where the pickup system will be located, i have active and inactive weapon. So, when i hover over the pickup weapon, i compare the active weapon tag (let's say it's PulseGun, but we don't know of what level since levels 1-5 share the same tag) with pickup weapon which is also tagged PulseGun.
In that case, if we have PulseGun3 as active weapon, it should be upgraded to PulseGun4 since we picked up the weapon of the same type/tag.
Now, since we have no idea which tags matched on runtime, we need to to another tag check. Is Active Weapon X tag? No. Is Active Weapon Y tag? No. That would take maximum 30 iterations (total weapon number) until we get to is Active Weapon PulseGun Tag? Yes! Now all we need to do is run another check, this time by name. Is Active weapon name PulseGun1? No. Is active weapon name PulseGun2? No. Is Active Weapon Name PulseGun3? Yes! Despawn Active Weapon and Spawn PulseGun4 as active weapon.
Now this doesn't take much (35+ iterations top for each weapon), but it's a hell of a lot of states. I could make multitag and multistring comparison actions to shorten everything to two states (one for checking weapon tag PulseTag and one for checking weapon String, PulseGun1, PulseGun2...) But it still requires a lot of typing and is poorly scalable, especially if i pickup a weapon that's differently tagged than Active Weapon. In that case i'd need to check tag and name of Active Weapon to get to the information of which level is the Active Weapon and the replace it with the same level of Pickup Weapon, which is horrible.
Any advice on this one?