How do I Make a global enemy HP system?

Get help using Construct 2

Post » Fri Jan 02, 2015 3:54 pm

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.

Event Sheet
You do not have the required permissions to view the files attached to this post.
Posts: 3
Reputation: 206

Post » Fri Jan 02, 2015 5:55 pm

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.
Posts: 1,101
Reputation: 6,146

Post » Sat Jan 03, 2015 4:38 am

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.
Posts: 3
Reputation: 206

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 38 guests