How do I Make a global enemy HP system?

0 favourites
  • 3 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • Hey all! Thanks for taking time out to help a fellow in need.

    Lets start with some background info: Im working on a platformer/RPG crossover, and as it grows, so does its complexity. Right now im trying to add multiple types of unique AI (enemies). As of now i only have 3 but i expect to have a total of 10ish. My problem today is a damage system. AS OF NOW i have 2 things that damage enemies: Thrown Weapons and Melee Weapons both wielded by the player. Now what i want to do is that on collision with a weapon, there should be a global system of subtracting health form enemies (health is stored locally by each enemy as an instance variable, and once it falls below or is equal to 0, the enemy is destroyed). For example, as of now my code is *weapon* on collision with *enemy* => Subtract X health from *enemy*. However, this code has to be repeated for each discrete enemy. Is there a way, by making an enemies family, that i can create a system in which, when the weapon collides with anything from that family, health is subtracted from the discrete enemy? Because my melee attacks consist of "streaks" so each attack has a different damage and i have to code damage separately, making ti both arduous and (i assume) inefficient.

    Basically, what im trying to make is:

    say, enemyFamily on collision with weapon, subtract *damage* from enemy(who actually hit the weapon).HP

    Im not sure if this is clear to everyone so ill rephrase it:

    If my weapon collides with enemy1 from the family "enemies" , the equivalent weapon damage should be deducted from enemy1.

    Heres an image of my current event sheet for melee weapons. Basically the enemyGeneric should be generalized to mean whatever object from the "enemies" family the weapon hit.

    [attachment=0:1rua0nya][/attachment:1rua0nya]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have this working - just use FAMILY instance variables, remove related object instance variables and you can easily make a system where damage is done to any enemy within that family.

  • Can they be different for each member of a family? Because i tried and found no way to differentiate between family members.

    I have an enemy at 1000 HP and another at 15.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)