How to assign multiple lives on multiple bad guys?

AlanoAlano Member, PRO Posts: 70

Hey all,

So I've figured out how to let my bad guy destroy after 3 shots from the good guy's bullet. The problem is that my game has multiple room with multiple bad guys in them (It's like the game The Binding of Issac). Anyway, currently when I shoot one bad guy 3 times the ALL the 5 bad guys die at the same time (because they are instances of the same bad guy).
Q: How can I make the 5 bad guys take 3 hits to die individually?
Q: I plan on having various types of bad guys in other rooms. Is there an easy way to create these "hit lives" for various actors?

Thanks a bunch!
Alan

Comments

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375

    Create a self attribute (Integer) call it lives. Change this number to the default amount of lives. When actor overlaps or collides with bullet change self.lives to self.lives-1.
    When self.lives =0 destroy.
    And for the bullet if you want it to destroy on contact with an actor, create a tag with all of the enemies in it. When overlaps or collides with actor of tag: enemy, destroy.

  • AlanoAlano Member, PRO Posts: 70

    Thanks bjandthekatz.

    This rule I have figured out (newbie here) and it works. The problem I have is that when I shoot one bad guy 3 times to die they all die. I assume this happens because the 5 bad guys are all instances of the main bad guy.

    How can I make it so that if I shoot on bad guy 3 times the others don't die? Then have to shoot each bad guy 3 times individually to make them die. Also, I have multiple rooms and one room has various bad guys, the other room will have various monsters, and another room will have various snakes. Is there some game variant life rule that can affect different types of enemies? Am I opening up a whole can of worms here?

    -Alan

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375

    Here is a file on what I said before.

  • AlanoAlano Member, PRO Posts: 70

    Oh thank you!
    I see how you made the Lives attribute locally within the actor. I made the attribute a game attribute.
    Thanks for making the file!

    -Alan

  • AlanoAlano Member, PRO Posts: 70

    Follow up issue:
    My game is set so that after all the bad guys are dead the locked door to the room destroys. I did this by setting a rule within the locked door actor that when badlives=0, door is destroyed. Of course this worked because I made badlives a game attribute and it can be seen when setting up the rule.

    Now with the badlives attribute being an actor attribute I can no longer see it (badlives) when setting up the rule.

    Q: How can I have the locked door actor check for badlives in order to destroy the locked door?

    Thanks again!
    ALan

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    @Alano‌ You dont want it to check for badlives since that attribute is for each individual actor and determines when that individual actor dies. Like you said you want to know when all the bad guys are dead, not just one of their lives being down to zero.
    This will be different for each room. You will want to make a game attribute that is an integer. You could name it baddeaths.
    Whenever a bad guy dies:

    Change attribute game.baddeaths to game.baddeaths + 1

    This will tell you how many deaths there has been
    If a level has 10 bad guys make a rule in the door

    If game.baddeaths = 10 then unlock the door

  • AlanoAlano Member, PRO Posts: 70

    Hey thanks erockross! I had to figure what goes where but that worked like a champ!

    -Alan

Sign In or Register to comment.