enemies with health

Player_EPlayer_E Member, PRO Posts: 604
edited November -1 in Working with GS (Mac)
Okay dont know why this is not working any more, but I created an enemy with a health attribute of 10 and set it as integer.

then set up the rule when collides with actor??? change attribute self.health-3
and then the destroy when self.health=0 rule

I tested it and it worked out fine.

I went a little crazy and had the idea of my weapon doing a random amount of damage so i tried this.

rule: when collides with actor??? change attribute self.health random(-3,-1).
this did not work and I tried other way of putting it such as random-(1,3) -random(1,3)
but none of those worked.

Now when I put it back to the original way it was
collides with actor??? change attribute self.health-3
it does not destroy the actor when health should be at 0

I tested this and changed it to
collides with actor??? change attribute self.health-10

and it kills the actor in one shot.

I have no clue why the -3 is no longer working any ideas on this?
and hopefully someone knows how to set up a weapon that does random damage that would be cool.

Comments

  • Player_EPlayer_E Member, PRO Posts: 604
    I figured out the problem as to why the -3 was not working.
    Somehow I had moved the enemy to the HUD, so i guess it was not registering with my background.

    But if someone still knows how to make a weapon do a range of damage such as 1-3 let me know still trying to figure that out.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    you almost have it right...

    set an Attribute (integer) called Damage

    Use Change Attribute to set self.Damage to the expression: random(1,3)
    (don't use negative numbers)

    The apply the damage like this:

    Change Attribute: self.Health = self.Health - Damage

    Does that make sense?
    Hope this helps!
  • Player_EPlayer_E Member, PRO Posts: 604
    Okay I think Im doing it right.
    I have a game attribute called damage integer set at 0
    inside the actor that is taking damage I made when collides with??? change attribute damage random(1,3) also change attribute self.health = self.health - damage.

    When I start the game I shoot the enemy and it does not work out for me.
    I also tried making the game attribute an attribute under the actor taking damage and it still did not work.

    Maybe a little bit more clarifying would help clear this up for me.

    Thanks
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hmmmm...

    that should do it.

    to test, maybe change something visual as well, like the characters alpha or rotation.
    maybe set the rotation of the character to its health * 10
    just some way to see whats going on
Sign In or Register to comment.