GabrielBalas's Recent Forum Activity

  • yes, but when i make the action "Subtract 25 from vida" i can't especify to subtract only of the "instance 0" picked in the condition and then the damage go for all clones of the object type

  • But I want the bad soldier to hurt only one enemy at time, even when they're overlapped. For this he needs to choose on of the overlapped object types first and then choose one of the clones of this object type.

    The enemy soldier already can choose one of the overlapped clones but he can't choose just one of the overlapped object types. In a "good" group made of archers and soldiers, all overlapped, the enemy soldier hurts only one of the overlapped soldiers but he hurts at same time one of the overlapped archers. I want him to choose only archers or only soldiers and then one single of the choosed group.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm having problems when I wnat my enemies to hurt only one enemy at time . They already choose only one clone of a object type to attack, but they hurt one clone of each object type of the family.

    For example: When a "bad soldier" hits a "good soldiers" group it only hurt one of the soldier in the group, but at same time hurts a "good archer" that isn't in it's attack range just because the good archer make part of the same family that the good soldier.

    My code is:

    When "bad soldier" is overlapping "Good" family

    >System pick "Good" instance 0.

    >System pick "GoodSoldier" instance 0.

    -Make damage

    >System pick "GoodArcher" instance 0.

    -Make damage

    So how can I make the "bad soldier" hurt only the object type "good soldier" or "good archer" (the closest one) per time?

  • You mention that your enemies are "clones" of each other, which is fine. Is each "clone" though, just a SINGLE enemy as the sprite or do you have like 2 or 3 enemies per sprite that act as one object?

    If each enemy is it's own individual "clone" then you simply need to use object picking nearest/furthest as mentioned by celstrider. He basically explained in a shorter way what I was talking about in my post before. Just pick the enemy that's closest to your defender, and apply the damage to that enemy only (because you picked it specifically based on it's distance to the defending player).

    I think the reason that it's damaging ALL units right now, if because it hasn't been told to pick ONE unit specifically.

    ----------------------------------

    If overlapping ENEMY

    -> deal damage to enemy

    This will cause ALL enemies to be damaged when only ONE enemy is being overlapped.

    ----------------------------------

    If overlapping enemy & distance to enemy is less than 10

    -> deal damage to enemy

    This will cause only enemies that are within 10 pixels of you to take damage.

    ----------------------------------

    If overlapping enemy

    -> pick enemy closest to player

    ---> deal damage to enemy

    This will cause only the enemy that's closest to the player/defender/arrow to take damage.

    ----------------------------------

    The key is to make sure the game knows WHICH enemy you want it to pick, otherwise it will simply pick them ALL whenever there is overlapping.

    Hopefully this helps a bit more

    ~Sol

    IT WORKED!

    Thank you so much! You're awesome!

  • You can do this in a few ways... I'm guessing that your enemy units are all individual sprites, and not one sprite that represents a whole group of enemies?

    If they're all separate, you can set the target to the projectile when the projectile is being created (on shoot). You could make some instance variables for the arrow, or the soldier, and call them something like TargetX and TargetY. Then you can pick the enemy that's closest to your defending unit, and set the instance variables TargetX and TargetY to be the coordinates of the enemy.

    You can then use the coordinates (pick by comparison) to tell your soldier or arrow which unit to apply damage (and also to trigger to destroy your arrow sprite). Simply compare the TargetX and TargetY values to the coordinate position of the enemy. I would recommend setting a comparison RANGE of say, 3-5 pixels or more (depending on the size of your graphics).

    Hopefully this hint helps. If you still have problems just let me know here and I will see if I can make a quick example.

    ~Sol

    Hi, thanks for the atention.

    The sprites aren't individual sprites, they are all clones made by the system to defend the "CPU's" castle.

    My event sheet of the soldier being attacked by another soldier is:

    EnemySoldier is overlapping Soldier

    Is "Attack" animation playing.

    Animation frame="4"> Soldier subtract 25*EnemySoldier.PickedCount from life.

    The event for the arrow is:

    Soldier On collision with Arrow > Subtract 15 from vida.

    And then i'd like to maintain this codes and add the necessary to make sprites choose just one enemy at time to fight, and the arrows hurt just one enemy even when they are overlapped.

    A great exemple of what I'm talking is the game EpicWar 1 and 2. Even when the troops are all overlapped, they aim at only one sprite at time.

  • I'm making a project where you have your castle and need to defend him by sending troops that will fight the enemy troops and attack the enemy castle.

    When the troops begins to fight each other, they hurt all enemies that are being overlapped by them. A soldier dies with 4 hits of another soldier, this way, a single soldier can kill 3 overlapping enemy soldiers with 4 hits, a single arrow hurts 10 overlapping enemy soldiers, etc.

    I would like to fix this and make a soldier fights and hurts only one of the overlapping enemies in its front, make an arrow hits only one of the overlapping targets.

    How can I do it?

GabrielBalas's avatar

GabrielBalas

Member since 1 May, 2017

None one is following GabrielBalas yet!

Trophy Case

  • 7-Year Club
  • Email Verified

Progress

8/44
How to earn trophies