Toggle a weapons system between being active and inactive

RedHandRedHand Peterborough, onMember Posts: 17

I know I'm over thinking this and making it way more complicated than it has to be.
Please forgive me if this question has been posted a hundred times before.

I'm making a very basic shooter, enemies attack down from the top of the screen, you tap the enemy to shoot them, you start the game with very basic ammo and as you do better and make it further in the level and hit certain score goals, you arm special weapons that are on stand by until you touch said special weapon to arm and use it, in the same fashion as your regular weapon.

I originally had the game set up so it would force you to use these weapons when you hit the specific goals and it worked flawlessly but then i thought the game would be that much better if you had the option of activating and deactivating the weapons when ever you want, so your special ammo doesn't get wasted on enemies that can be simply destroyed using your basic ammo.

In no way do I know gamesalad as well as the majority of people on here which is why after hours and hours of frustration I turn to the community, this is how my weapons system is set up (its probably ass backwards) but I appreciate the help.

I have attributes set up as follows:
regular gun - Boolean true
oozie ready - Boolean false
oozie armed - Boolean false
special weapons - integer 0

(I have this set up on my regular bullet actor)
RULE
when SPEACIAL WEAPONS = 75
DO
change OOZIE READY to TRUE

(on the weapon button which you will touch on screen)
(touch to arm weapon)
RULE
when ALL the following are happening
when touch is pressed
if OOZIE READY is TRUE
DO
change OOZIE ARMED to TRUE
change REGULAR GUN to FALSE

(to disarm the weapon and switch back to regular gun)
RULE
when ALL the following are happening
when touch is pressed
when OOZIE ARMED is TRUE
DO
change OOZIE ARMED to FALSE
change REGULAR GUN to TRUE

If I disable the rule to disarm the special weapon, it works fine to activate the special weapon, and it shoots great, but if both rules are on then it wont switch to activate the weapon at all. obviously ive created a loop that cant be broken by setting it up this way but I cant figure out how to fix it, now my brain is mush as Ive spend way to long trying to figure it out and have caught myself in an endless loop of trying the same thing over and over again now.

Thanks for your time

Best Answer

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,922
    edited November 2015 Accepted Answer

    If you are only using one weapon at a time I would use one integer to chose the weapon. So assign each weapon a number. This way you only need one attribute to control the weapons selection and you will never have two weapons selected at once. By using a single variable you only need one fire button and two conditions in each weapon. One for if it is the selected weapon and on for if it is to fire. This is intergrated code. Basically all the info you need is in two variables. Which weapon is selected should communicate to displaying the weapon type et...

    Weapon Rule
    When all

    Game.Weapon.selected = self.weapon.number
    Game.fire = 1

    Spawn bullets

    Fire button rule

    When touch is pressed

    Change att Game.fire to 1

    otherwise

    Change att Game.fire to 0

    Gun image rule

    When attribute game.weapon.selected = 1

    Code for displaying gun type

    (Make rules for each gun number)

Answers

  • RedHandRedHand Peterborough, onMember Posts: 17

    Thanks for the quick response. I will let you know how it goes. I knew I was creating a loop while I was doing it but couldn't see how to do it any other way. Thank you very much

  • RedHandRedHand Peterborough, onMember Posts: 17

    Worked great, I knew I was over thinking it and making it to complicated. Thank you very much for the help

Sign In or Register to comment.