Problem with tracking hps, both actor and game attributes, need serious help!
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
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
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
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