How to choose enemies in LOT range and damage them after UID sorting?

0 favourites
  • 8 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • Hello friends! First of all sorry for my bad english...

    I'm trying to find a way to choose enemies in range by "line of sight" and damage them using there UID.

    I made a project with all mechanics that I can and can't fix.

    1) Check Distance. How to check distance to closest enemy?

    2) Choose closest enemy after distance check (works fine with LOT, but it's interesting to know where I'm making mistake without it)

    3) Choose all enemies after distance check (here is a lot of problems that I could't fix

    4) Land mine

    Here is a "c3p" https://www.dropbox.com/scl/fi/rs8zz7jnfkprt1allmoy3/Choose-Enemy-2.c3p?rlkey=agvoupl51yntnc5ued5ftn27u&st=bm7y45o8&dl=0

  • Don't use expressions like distance(Player.X, Player.Y, Enemy.X, Enemy.Y) without picking the enemy first!

    And you don't need distance() at all if you have "Line of sight" behavior. Just configure its settings correctly:

    You can also add several "Line of sight" behaviors to Player sprite with different settings. For example one for detecting enemies at short distance, another for long distance, another that ignores obstacles etc.

  • dop2000

    Your advice about pick enemy first worked and solved all my problems about picking and damaging one enemy, Thank you!

    After many tries I can't find solution for multiple picked enemies. I don't understand how to damage picked enemies using function. (maybe secret in taking parameters for function? But it can be only variables...) I don't know...

    Now it's picking multiple enemies but killing them only one by one... Why its not working for all enemies in the range and how can I fix that?

    Idea is:

    1) First enemy steps on the mine

    2) Mine check all enemies in range

    3) Damage them simultaneously (ideal version will damage enemy with coefficient of range: first enemy takes 100% or damage x 1, the last one of the mine blast radius gets 10% or damage x 0.1)

    updated c3p https://www.dropbox.com/scl/fi/mnkvc391xrmvnzxfsj206/Choose-Enemy-3-copy.c3p?rlkey=9y7k3raphqwaqye433glk501g&st=tja0kyh0&dl=0

  • LineOfSight can pick multiple instances. If you need to process them one by one, use For Each loop. You can add another parameter to the function - the amount of damage to deal, based on the distance.

    Mine has LOS to Enemy
    For Each Enemy : Call DamageEnemy(Enemy.UID, 100/distance(Mine.x, Mine.y, Enemy.x, Enemy.y))
    

    Also, you don't need LineOfSight check in "Enemy On collision with Mine".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000You saved me so much time, thank you!

  • dop2000 When I'm triggering mine with a keyboard key, it's working like expected. What I was trying to do is: after the first enemy triggers mine, all enemies in the LOT radius are taking damage. Why it's not working if the first check is on collision; that will change the state to true, right? Plus, there is one more check to see if there are more enemies in the range, and only after that should they get damage. Where am I making a mistake?

    .c3p https://www.dropbox.com/scl/fi/xwdtdss75wrn89sjzk1xz/Choose-Enemy-4-copy.c3p?rlkey=cwwpf4xgmrcpaatqjmdbt60td&st=fvvn197q&dl=0

  • "Enemy On Collision with Mine" event picks one enemy instance. You can't pick other instances in the same event, unless you use "System Pick All" condition.

    For example:

    Enemy On Collision with Mine 
     System Pick All Enemy
     Mine has LOS to Enemy -> Deal damage to all enemies in range
    

    Another option is to call a function, which will pick the enemies in mine range:

    Enemy On Collision with Mine -> Call MineDealDamageToEnemies(Mine.UID)
    
  • dop2000 Awesome! Now I understand. So first was picked enemy that was on collision and thats why we need to "reset it" to pick all and after that pick some enemies within all and than do actions, nice!

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