Cycling weapons but only showing ones with ammo

Ok so a quick bit of background....

Basically I have a "choose weapon" button that when tapped changes the players weapon using the following expression:

( game.weapon-selected +1)%X

That works really well, however here is the issue... I only want weapons that have ammo > 0 to appear. (If the weapon doesn't have any ammo I don't want it to be selectable).

So I thought a quick hack around this would be to simply have a rule that says:

IF game.weapon1-ammo > 0

{ do something}

Otherwise

{change attribute ( game.weapon-selected +1)%X}

That way I check to see if the weapon has ammo and if not I just jump to the next one...now again this actually works well however the issue comes when I fire the last bit of ammo from weapon 1 it also fires the first shot of weapon 2 at the same time...

so my question is:

a) can anyone suggest a cleaner (better) method for this problem of cycling through weapons but only showing those that have ammo?

b) if not, then using my current method what can i do to stop firing the next weapon straight away when I run out of ammo of my previous gun?

Thanks in advance :-)

Comments

Sign In or Register to comment.