Problem with tracking hps, both actor and game attributes, need serious help!

pjnolenpjnolen Member Posts: 152
edited November -1 in Working with GS (Mac)
I got a serious problem and I'm not gonna be able to finish my game without solving it. I've asked questions before and have had good luck with experienced GS users and I'm thankful for that.

I had a problem with my bullets, not doing damage to the player. It just so happens that at the time I had the hitpoints attribute on the player actor, and the rule to lower it when colliding with bullets on the actor as well. When multiple bullets hit at the same time, it only registers that 1 hit because the others overlaped at the same time. I was told to move the rule of -5 damage the bullet did from the player actor, to the bullet actor. BUT if I do that, I can't reference the actor's hitpoints attribute anymore, i have to make it a game.attribute.

Even though that worked for damage, I've now run into the problem of having an attribute for my badguys(I have to reference their hps at random times gamewide) but if the player shoots badguy 1 and lowers his hps to 0, that game.badguyhitpoints is 0 and I can't spawn him again. I have to create a rule that when he dies, to +25 hps that attribute, but sometimes it works and sometimes it doesn't, if I don't I can't spawn another badguy because he has 0 hitpoints. The other problem is that if he has 25 hps in a game.attribute and I want to have 5 difficulty levels, it almost seems insurmountable the amount of rules and attribute changes i need to do so that if I want each difficulty to have the badguy have more hps, say, easy is 25, med is 50, hard is 75, then i'll need a crapload of rules to take into account those amount.

I don't know, make a game change if game attribute easy is true change attribute to 25, if game attribute med is true change attribute to 50.

But each time they die I still need them to get back to 25, and 50, and 75...

I'm sure there's a more reasonable way of doing it than I'm thinking, and hoping someone can show me that!

thanks for the help

PJ

Comments

  • JeffreyShimaneJeffreyShimane Member Posts: 372
    For the difficulty level, create a game.attribute called Difficulty. Easy is 1, Medium is 2, and Hard is 3. For your bad guy's HP, use 25*game.Difficulty. This way, when the player sets the difficulty setting, it will change game.Difficulty to 1, 2, or 3. This will automatically boost/lower the bad guy's HP to the appropriate level (25x1=25, 25x2=5, 25x3=75).

    I'm unclear if you are using spawn/destroy or recycling for your bad guy actors. If you are using spawn/destroy, the bad guy actor should reset to his default health after being destroyed and re-spawned. If you are using recycling, when the bad guy's health reaches 0, I'm assuming its position will go off-screen (so it looks like it was destroyed) so that it can "re-spawn" and come on-screen again. Your rule would look something like this:

    When game.badguyshealth = 0,
    -- Change Attribute self.position.X or Y (depending on the orientation of your game) to some coordinate off-screen (this could be a set coordinate or some random coordinate)
    -- Change Attribute game.badguyshealth to 25*game.Difficulty

    Each bad guy on-screen would need its own game attribute to track its health. Otherwise, the fate of one bad guy would afflict all other bad guys. It'd probably be easier if you had the bad guy's health as a self attribute. That way, each instance of the bad guy actor would have its own self attribute for health but you mentioned something about needing to be able to reference their health game-wide so that may be out of the question.

    Hope that helps.

    - Jeff
  • pjnolenpjnolen Member Posts: 152
    I'm using a spawn/destroy, but his hitpoints do NOT reset because it's a game attribute and not an actor attribute. I HAVE to do it this way, because of the way collision is done by GS. If I have it as an actor attribute then i HAVE to put the damage done to him ON his actor, and if I do that, he can only take damage from 1 source at a time. It was another post I went through trying to solve that problem. If I have more than 2 bullets hit the goodguy, only 1 ever counts, whether it's 2 bullets or 20 bullets, only 1 ever does damage, if the bullet actors hit the player actor at around the same time. BUT if I move the damage rule to the bullet, then the player will take damage appropriate to how ever many bullets on the screen.

    The problem I'm running into is having the game, properly, reset the game attribute for the badguy hitpoints after I kill the first one. Once it's 0, it just stays 0, and won't spawn anymore.

    Yea, I need to reference their health from other badguys to do other stuff, and this can't be done from an actor attribute. I wish we were getting actors referencing other actors sooner, i wouldn't have any of these problems!

    I'll try the change attribute position to off screen. That may be the way to go, i didn't think of that. Hopefully they'll not just move there, but instead teleport there so it looks like they actually died lol

    Appreciated the help good sir!

    I may actually finish this game sometime during my lifetime lol
Sign In or Register to comment.