User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: How to make a sword attack affect only the targeted enemy

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to make a sword attack affect only the targeted enemy

    I am having issues with making attacks on enemies work properly.
    I want the sword attack to only affect the enemy/enemies it hits. Right now it affects every single enemy on screen.
    Every enemy has its own HP pool (some enemies have 3hp, others have 2hp). Every sword attack takes away 1hp from the enemy.
    Problem right now is that whenever i kill one enemy with the sword, they all die (or just stop moving?).

    I have attached the file i would like to get some help with. bw EXAMPLE.mfa

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,730
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Hi Andy. Try qualifiers for the enemies. This always works for me.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,275
    Mentioned
    90 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nivram View Post
    Hi Andy. Try qualifiers for the enemies. This always works for me.

    Marv
    He already is.


    Quote Originally Posted by AndyBazooka View Post
    I am having issues with making attacks on enemies work properly.
    I want the sword attack to only affect the enemy/enemies it hits. Right now it affects every single enemy on screen.
    Every enemy has its own HP pool (some enemies have 3hp, others have 2hp). Every sword attack takes away 1hp from the enemy.
    Problem right now is that whenever i kill one enemy with the sword, they all die (or just stop moving?).

    I have attached the file i would like to get some help with. bw EXAMPLE.mfa
    To fix it, delete the condition in red:



    For some reason, Fusion doesn't carry over the scope from the first condition (collision between...) to the second condition (health > 0). So, what's happening is this:

    1. Fusion reads the 1st condition and sees that there is a collision between the sword-swing-object and an enemy.
    2. Fusion is satisfied that the 1st condition was true, so keeps going with the event, but neglects to make a note of which enemy it was
    3. Fusion reads the 2nd condition, and selects all enemies that have health above zero.
    4. Fusion then applies the actions to all enemies that have health above zero.

    For some reason, when you delete the 2nd condition, the 1st condition does scope properly, and the actions are applied only to the object that collided.


    It turns out that that red condition was unecessary, since as it happens, you already measure death by testing for "Health <= 0" rather than "Health=0". So even if the above event makes the health of an enemy -1, it will still get caught by this event:





    A different way to solve the problem - and one that may prove to be more reliable in future situations for you - is to use a for each loop, as shown below. This will ensure correct scoping:


  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module

    Join Date
    Mar 2013
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Holy crap!
    Thanks so much for the very thorough explanation, Volnaiskra! I reworked the code and it works as intended now!
    The "Health of Enemy.Group >0" -issue, is that just a bug in CF2.5? I've encountered a couple more wierd bugs in the program when using the event editor, but nothing gamebreaking.

    Anyways, many thanks again!

  5. #5
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    106
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    For some reason, Fusion doesn't carry over the scope from the first condition (collision between...) to the second condition (health > 0). So, what's happening is this:
    I made a mfa with events like that......

    but I couldn't reproduce the bug you said.

    Weird.

    Collision_Bug.mfa

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    chrilley's Avatar
    Join Date
    Jul 2006
    Posts
    926
    Mentioned
    15 Post(s)
    Tagged
    1 Thread(s)
    @defisym - Try with multiple objects instead of instances of one object and I think you should be able to reproduce it as well. I've attached a simple example using 3 different objects under 1 qualifier to show what I mean...

    I asked about this issue in Discord last year(though I used alterable strings instead of values) and it turns out Clickteam seems to have been aware of this issue for some time. However it is a huge mess to fix and would most likely explode existing projects if they do attempt it. I think Volnaiskra second workaround is the best approach thus far. I've used the same one for a like a year now and no problems yet!
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleInstall CreatorInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Aug 2006
    Location
    France
    Posts
    1,158
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chrilley View Post
    @defisym - Try with multiple objects instead of instances of one object and I think you should be able to reproduce it as well. I've attached a simple example using 3 different objects under 1 qualifier to show what I mean...

    I asked about this issue in Discord last year(though I used alterable strings instead of values) and it turns out Clickteam seems to have been aware of this issue for some time. However it is a huge mess to fix and would most likely explode existing projects if they do attempt it. I think Volnaiskra second workaround is the best approach thus far. I've used the same one for a like a year now and no problems yet!
    Yes I send a topic with same bug: https://community.clickteam.com/threads/106356-Bug-with-child-events-filtering-object-instance-on-parent @Yves saw this, I think it's fix soon

    EDIT: It work fine if you replace "collision between" by "is overlapping"

  8. #8
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,275
    Mentioned
    90 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Xenon3000 View Post
    EDIT: It work fine if you replace "collision between" by "is overlapping"

    That's weird, because this doesn't seem to be the case with AndyBazooka's example. When I replace "collision" with "overlapping" there, it's still broken

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    chrilley's Avatar
    Join Date
    Jul 2006
    Posts
    926
    Mentioned
    15 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Xenon3000 View Post
    It would be super-amazing if he could solve it. According to my Discord exchange with @Danny they've already been at it before though. I'll keep my fingers crossed however!

    There are so many uses for Alterable Strings and Qualifiers when it comes to scoping. Especially if you have 2.5+ where the number of Alterable Strings went from 10 to 260. Now if only we could re-order the values/strings/flags as well, that would speed things up astronomically for me.

  10. #10
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    13,190
    Mentioned
    141 Post(s)
    Tagged
    2 Thread(s)
    I think I fixed it, though the fix was so easy that I wonder if I missed something... Would anyone volunteer to test the fix in real games to see if everything is OK or if this is causing any issue? (bug, performance, etc) Thanks!

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Trigger Enemy Attack at......
    By Warmachine in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 5th June 2017, 04:26 AM
  2. How to attack enemies with a sword?
    By Philtered_Khaos in forum Fusion 2.5
    Replies: 12
    Last Post: 19th October 2016, 04:43 PM
  3. Best way to go for enemy distance to attack
    By paobrasil in forum Fusion 2.5
    Replies: 12
    Last Post: 30th December 2015, 10:04 PM
  4. Replies: 10
    Last Post: 22nd June 2015, 09:31 PM
  5. attack when facing enemy only
    By ionside in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 25th November 2008, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •