[Solved]Give attack damage to every entity

How do I…

I’m trying to make AI entities fight others AI entities by using a set damage of animation system so everytime an animation-type is played, collided entity will recieve x amount of damage. This also includes the player. I searched and reached the video tutorials and the extension “health” and analize it carefully seeing that, it was created with the intention of “recieve damage”, instead of “giving damage” something that is not what I was expecting. will take a long time doing it that way.
So, I need your help. I reached the Json files of minecraft mob entities. How they attack giving damage? How is it coded? I just need that (on javascript) so I can do the rest of the coding and non-coding. Thank you.

Here is a link for help:

In most cases it would be

Condition
Skeleton is in collision with Slime
Animation of Skeleton is Attack

Action
And here you deal whatever damage you want to Slime

To make Slime damage Skeleton
Conditon
Slime is in collision with Skeleton
Slime animation is Attack

Action
And here you damage Skeleton

If you don’t need them to damage each other with animation then just remove animation condition

I want it that damage value of this entity affect all entities. So if I decide to update new creatures…, all that long work can be done in minutes if it is with a attack variable. Even if it isn’t to give damage trought animations, if it can aply to all enemies at once it would be of big help.

Let’s say you have Zombie
You want all Zombies to attack with 10 damage
You give zombie object variable ATK and set it to 10

Now event
Condition
Zombie in collision with Vampire
Animation of Zombie is Attack

Action
Change variable HP of Vampire Subtract Zombie.Variable(ATK)

Now you can update your ATK variable on Zombie to deal whatever damage value you want
IDK if it would be more sense to call it DMG instead of ATK but whatever

And a BAD tip (THX to MrMen for clarification)

Add all enemies to group called Enemies

And instead of making above event for each enemy type you only need one

Condition
Enemies in collision with Enemies
Animation of Enemies is Attack

Action
Change variable HP of Enemies Subtract Enemies.Variable(ATK)

1 Like

Oh, I didn’t knew you can create groups. How you create groups? (I will check tutorials to see if it is explained). Thanks for your help.

In scene editor you have in upper right some icons one of them will show you groups section (hover over each icon with cursor to display their names)
And there you simply just add new group rename it and add crap to it

What @ZeroX4 wrote will not do exactly what you want.

If you want to affect all instances of an object if one of them is attacked, then you want to use something like the following:


This will not work. Think about it - which instance of Enemies has it’s HP reduced?

2 Likes

My god THX for that
I just realized it will damage the one who is in attack animation

Solution would be only if there is no Attack animation
And they damage each other on collision

But that would cut out option to have one distributing damage without taking it also

1 Like

I see. Zombie, who is an object, collision with Vampires, who is a group of objects; Pick all objects (of the mentioned group) and change the var HP (health) of mentioned group. One thing I’m confused. Is the substract a variable that I have to create? I guess I have to attach it to the entity.

Wait, does Zombie (first line) can be a group too? So “group one make collision with group two”?

It’s up to you how you set the amount to be deducted. I just followed @ZeroX4 example - it’s a way it could be implemented, but not the only way. You can hard code the value in, you can have it in variable (object, scene or global) or put in some formulae.


In this example, yes, it’s checking if a member of one group collides with a member of another group. But you could make it object vs object, or object vs group.

My example was only intended to show that you need to use the Pick all instances condition to affect all of the other objects.

BTW, keep in mind this is not a complete solution - if a zombie collides with a vampire then you’ll also want to separate the two colliding objects. Otherwise the collision will be actions every game frame, and lead to a sudden health depletion on the vampires.

1 Like

Yes. That’s why I wanted to aply the DMG var only when animation triggers with cooldown intrigued. Thanks for your time! @MrMen @ZeroX4