An interesting problem with enemy health..

quantumsheepquantumsheep Member Posts: 8,188
edited November -1 in Tech Support
Hi all,

Got a teeny problem with my game at the mo'.

Essentially, you have to kill a set number of enemies onscreen before advancing to the next stage.

So, each enemy has its own hitpoint variable called 'health' which goes down by one when it collides with your bullet.

This all works fine - enemy health goes down from 10 to 1, say, enemy is destroyed.

Count how many enemies are dead, go to next scene.

Now I have a level select implemented, and can finish this level, go to the level select, and try it again.

The enemy count works as normal. Kill 5 enemies, move onto next scene.

The problem is, the enemies only take one hit to kill now...

Any ideas why? It doesn't affect my other actors (far as I know), just this particular enemy :(

Any theories/solutions would be helpful!

Cheers,

QS :D

Edit: I should add, the enemies are all onscreen at the start of a level i.e. no spawning - their health is a local variable which doesn't seem to be reset, while the global variable (how many are killed) is...

Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    A self attribute.

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Maybe try an off-screen imageless, invisible actor off-screen to put your change variables of your instances back to 10? Might help keeping it separate, I'm thinking...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • quantumsheepquantumsheep Member Posts: 8,188
    gyroscope said:
    Maybe try an off-screen imageless, invisible actor off-screen to put your change variables of your instances back to 10? Might help keeping it separate, I'm thinking...

    Hey Gyro - the variable is a self variable - it's on the actual actor - it's set to 30.

    I have a rule at the start of each actor saying: let self.health = (selfhealth*game.difficulty)/game.research

    So game difficulty and game research are the only two global variables, and they stay constant.

    This changes the health from the base health which is self.health.

    I just tried T-shirt's suggestion (brilliant btw mate - should have thought of that!).

    The first time you play the health is at 30, as expected.

    The second time, it shows just 2.

    I HAVE NO IDEA WHY!!! :*(

    (and to all the new people here - see, I've been doing this over a year and I *still* get stuck!).

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    tshirtbooth said:
    Try puting a change attribute self. Health to 10 rule right at the start.

    I will! Be right back! :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    Ok, I tried that.

    No dice. Still changes to '2'.

    I tried putting it in a timer too.

    Make self.health = 30

    Then after .4 seconds make health do the fancy maths bit described before.

    Still comes up as 2.

    I'll investigate further, but not a happy bunny :(

    QS

    Edit: And I've just investigated further and found there's nothing in the level select button that resets the health. Quite right too, as it's not a global variable.
    This looks increasingly like a bug to me, which is not good news for the sheep :(

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    More tests - it seems to work fine on other levels with other enemies. Weird as hell...

    Took the enemies out of the scene, then put them back in - no luck.

    Changed the name of the health to 'enemy health' - still no luck.

    I'm at a loss, really... :(

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    I'm guessing that game.difficulty is 1 and game.research is 3? I'm intrigued to know what game.research attribute is for...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    What I'm thinking is: if the difficulty is a one-off choice at the beginning of the game only, then your maths need only be once. Going into level 2 and subsequent levels, can't you just Change Attribute to self.health =10, without the maths?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • quantumsheepquantumsheep Member Posts: 8,188
    I appreciate the input, mate, but it doesn't quite work like that!

    All will be revealed soon :D

    I hope you've got a 3GS at least!

    Back on topic, I'm going to try spawning them into the level. See if that helps!

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    quantumsheep said:
    I appreciate the input, mate, but it doesn't quite work like that!

    All will be revealed soon :D

    Ah well, I gave it a shot! Look forward to seeing your latest game.
    quantumsheep said:
    I hope you've got a 3GS at least!

    No, I could only afford a 3G for the other half....not too bad?

    Hope your spawning works.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • quantumsheepquantumsheep Member Posts: 8,188
    I wouldn't play it on a 3G mate - sorry :(

    3GS and above only I'm afraid...

    And the spawning didn't work... bum!

    Not a very productive evening :(

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • hrsmediahrsmedia Member Posts: 522
    quantumsheep said:
    More tests - it seems to work fine on other levels with other enemies. Weird as hell...

    Actors on other levels work ok with the same rules?
  • quantumsheepquantumsheep Member Posts: 8,188
    Yeah - they're different enemies, but the health thing is exactly the same... though they use a different research variable...

    Let me check my variables a second!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    Aha!

    I just changed the research variable for that of another enemy and it worked perfectly - at least I have an idea where to look now!

    Thanks everyone for your help! I'll hunt this bug down :D

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • hrsmediahrsmedia Member Posts: 522
    Great, hope you get it resolved!
  • quantumsheepquantumsheep Member Posts: 8,188
    I just did!

    BRILLIANT!!!

    Seriously, thanks to everyone that tried to help in this thread - it certainly helped me think about how the scoring was working (or not in this case!) and I got it sorted in the end!

    As a bonus, going through my actors turned up another bug, but one which would not have been visible till achievements go live in the first update...

    Bloody hell. That feels good.

    The moral?

    TEST TEST TEST TEST TEST TEST TEST!!!!

    Thanks everyone, sincerely :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.