1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  4. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  5. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] How to KnockBack Unit Groups ???

Discussion in 'World Editor Help Zone' started by [E]clipse, Jul 31, 2015.

  1. [E]clipse

    [E]clipse

    Joined:
    Jan 6, 2015
    Messages:
    559
    Resources:
    0
    Resources:
    0
    How do I knockback unit groups or multiple units ? I am using a trigger like this but it doesnt work :

    • Events
    • Time - Every 0.02 second of game time
    • Conditions
    • Actions
    • Set KnockBackGroup = Units within 500 of (Caster) matching (blaaa bla bla bla_)
    • Unit Group - Pick every unit in unit group and do actions-
      • Set Knock_Group_Loc = (Position of (picked unit))
      • Set Knock_Angle = (Angle Between (Cast_Point) and (Knock_Group_Loc)
      • Set Knock Point = (Knock_Group_Loc) Offset by 15 towards (Knock_Angle) Degrees.
      • Unit - Move (Picked Unit) instantly to Knock_Point


    Any help is appreciated...
     
    Last edited: Jul 31, 2015
  2. BloodDrunk

    BloodDrunk

    Joined:
    May 11, 2012
    Messages:
    1,963
    Resources:
    1
    Maps:
    1
    Resources:
    1
    You probably have an empty group.
    Where do you set the angle and the group?
     
  3. [E]clipse

    [E]clipse

    Joined:
    Jan 6, 2015
    Messages:
    559
    Resources:
    0
    Resources:
    0
    Well... The Knock_angle is the angle between the casters position and the picked units position.....The unit group is set in the spell cast trigger...
     
  4. modianoz

    modianoz

    Joined:
    Jan 7, 2013
    Messages:
    28
    Resources:
    0
    Resources:
    0
    First of all, the unit group you try to pick was not defined before. Try making a variable to be like: Set KnockBackGroup = Units within 500 range of triggering unit.
    Then put the Unit Group - Pick every unit in KnockBackGroup and then do actions
     
  5. [E]clipse

    [E]clipse

    Joined:
    Jan 6, 2015
    Messages:
    559
    Resources:
    0
    Resources:
    0
    Done.
     
  6. modianoz

    modianoz

    Joined:
    Jan 7, 2013
    Messages:
    28
    Resources:
    0
    Resources:
    0
    Do you mean you've done that or it's working now? If it's working now, I forgot to mention do not put the "set KnockBackGroup" in the trigger with the 0.02 periodic event but put it in the trigger that activates this trigger.
     
  7. Kakerate

    Kakerate

    Joined:
    Oct 18, 2013
    Messages:
    471
    Resources:
    0
    Resources:
    0
    Hmm. Is this trigger initially turn on? If not, this is a loop so unless there is not any ability that incorporates this, it will never be turned on. So let me assume you do have a trigger that activates this. (If i'm wrong on that, you can basically disregard everything I'm about to say, as it would be irrelevant. The only reason I could imagine this not being the case is if you want to have a unit that cannot be touched.)

    I would set the unit group variable on spell cast. Then, in the every .02 seconds trigger, you:
    A) Wouldn't have to weigh down your map by setting a unit group 50 times a second. I imagine that being seriously cumbersome if there are a lot of units by him.

    B) Could have it so that units don't magically stop being knocked back once they are out of range. If all units are knocked back the same amount, it allows for a more natural looking knockback.

    Also, just a question from me, do you destroy a group once you never want to use it again, or just to refresh it for the next use of it? I've just been removing each unit from the unit group when I want to refresh it. Is this incorrect?
     
  8. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,790
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Just some stuff that I feel should be mentioned:

    1) this is not MUI.
    2) you leak KnockBackGroup, Knock_Group_Loc and Knock_Point. Considering this is a high-frequency periodic trigger, you should definitely clean all those leaks

    In GUI, yes, unless you want to add units to it one by one using "Add unit to group". "Units within X range" always creates a fresh group, which will cause any existing group stored in the variable to be de-referenced (and thus, leak the group).

    Again, if you use any of the enumeration functions "Units within range" or "Units owned by Player", you must destroy the old group first or you will create a leak.

    If you want to add or remove units manually from a group after it's first creation via "Add unit to group" or "remove unit from group", that is a different story.
    To clear a group, you can use
    • Custom script: call GroupClear(udg_GROUP)
     
  9. [E]clipse

    [E]clipse

    Joined:
    Jan 6, 2015
    Messages:
    559
    Resources:
    0
    Resources:
    0
    First of all, the original trigger is not like this. Also that isnt supposed to be MUI and all the leaks have been cleared.

    Secondly, the trigger is turned on in a cast trigger and the unit group is set in the cast trigger only once and not 50 times a second.

    I think the problem could be very silly like picked unit instead of matching unit and stuff. i will recheck the trigger and get back to you guys.
     
  10. Shadow Fury

    Shadow Fury

    Joined:
    Nov 4, 2013
    Messages:
    1,630
    Resources:
    4
    Maps:
    3
    Template:
    1
    Resources:
    4
    Assuming that you'll remove all leaks, you should firstly put the "Set unit group" thing into the activating trigger (when the hero casts the spell I mean). I suppose you did that already. Secondly, can you tell me what's this matching (bla bla bla)? It could be that one of the conditions you've put hinders the picking of units.
     
  11. Kakerate

    Kakerate

    Joined:
    Oct 18, 2013
    Messages:
    471
    Resources:
    0
    Resources:
    0
    Haha, that's basically the point I was trying to drill in.

    That's a good point. Something commonly done that can cause this is using the wrong Event Response. I think just about every Event Respinse besides Matching Unit.
     
  12. SAUS

    SAUS

    Joined:
    May 22, 2015
    Messages:
    1,050
    Resources:
    0
    Resources:
    0
    You'd have to reset the group each time you run this trigger or it will cause problems with:
    - pushing units that are no longer within range (can be fixed with checks, though)
    - missing units that walk into range while it is active (cannot be fixed without resetting the group each time)

    If it is still not working, you may need to show all of the triggers. Try checking how many units are in the unit group during the loop to make sure it is properly grabbing units.