• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] How to KnockBack Unit Groups ???

Status
Not open for further replies.

Deleted member 242951

D

Deleted member 242951

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 by a moderator:

Deleted member 242951

D

Deleted member 242951

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...
 
Level 3
Joined
Jan 7, 2013
Messages
28
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
 

Deleted member 242951

D

Deleted member 242951

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

Done.
 
Level 3
Joined
Jan 7, 2013
Messages
28
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.
 
Level 13
Joined
Oct 18, 2013
Messages
691
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?
 
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

Also, just a question from me, do you destroy a group once you never want to use it again
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).

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?
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)
 

Deleted member 242951

D

Deleted member 242951

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.
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
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.
 
Level 13
Joined
Oct 18, 2013
Messages
691
you should firstly put the "Set unit group" thing into the activating trigger (when the hero casts the spell I mean)
Haha, that's basically the point I was trying to drill in.

It could be that one of the conditions you've put hinders the picking of units.
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.
 
Level 12
Joined
May 22, 2015
Messages
1,051
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.
 
Status
Not open for further replies.
Top