Note: This is for my own reference, and also to help out others who may be wondering about this.
This is a simple function. By default, units with a higher push priority can force units with a lower push priority out of the way. Units with a lower or equal push priority cannot push units of a equal or higher push priority.
We're going to be looking at EQUAL PRIORITY, which opens up some options for us.
Units with equal push priorities are a little unique. By default, they cannot push each other out of the way but this is where the trigger action "Set Alliance Aspect" comes into play which allows us to make them PUSHABLE!
Note: Remember, the default is OFF, not ON. When you realize you have to turn things ON, it becomes much easier because then you just deal with allies, not enemies.
So we have our two units both with an equal push priority.
In the trigger module, we can setup our pushable in one of two ways.
(Action) Set alliance
- This will set it up both ways, so setting the alliance to "allies with pushable" makes the all allied units with equal priority able to push each other out of the way when moving.
Now lets say player 2 is a computer and we dont want our allied (or enemy) computer player to push us, but we want to push them. This is where we set the alliance aspect.
In the trigger module, first define a new (Action)
:: Set alliance between player 1 and 2 to Ally
Then add a new (Action): Set Alliance Aspect
:: Player - Turn Player 2 Pushable On towards Player 1
This will allow us (player 1) to push the allied computer (player 2) out of the way, but they wont be able to push our units out of the way.
By now you should have the hang of it.
(Action) Set Alliance: Player - Make Player X and Ally Y treat each other as _allies and pushable_
(Action) Set Alliance: Player - Make Player X and Enemy Z treat each other as Enemy
The trick to remember is, a units pathing priority takes precedence. Units with a higher value will ALWAYS push lower priority units out of the way. However, EQUAL pathing DEFAULTS TO OFF (allies and enemies can NOT be pushed) but CAN BE TURNED ON VIA TRIGGERS (So allies or enemies CAN be pushed)!
A little more information:
Using this method is great for controlling the pushable aspect for team based games. One thing to mention though. Don't forget that by setting the pathing priority to everything equally, you are turning off pushable for EVERYONE. In a standard team game, you'll probably want to do something like
DO NOT set the pushable setting for two enemies
DO set pushable for a player towards himself (Ex: Turn Player 4 pushable On towards Player 4)
DO set pushable between allies on a team (Ex. Turn Player Ally6 pushable On towards Player 4 && Turn Player 4 Pushable On towards Ally6)
If using the pick each player in (allies of (player X)) function, don't forget this excludes player X, so youll want to define it outside the loop.
How would I make it so the following criteria are fulfilled?
1. Opposing players can not push each others' units at all.
2. Personal units of the same push priority can not push each other.
3. Personal units of greater push priority can push units of lower push priority, and lower push priority units can not push units with greater push priority.
For a different scenario, is it possible to have units of the same priority not push each other but units of different (either greater or less) priority push each other? For example, zergling == 5 and roach == 6. Zerglings can not push other zerglings, and roaches can not push other roaches. However, roaches can push zerglings, and zerglings can push roaches.
Note: In any of these cases, units that are on hold position or are attacking should not be able to be pushed. Only if they are just standing there ("stopped") that they should be able to be pushed.
Still experimenting, but for now...
Leave pushable off. Set all unit push priority equal.
Add a "push" behavior which has a periodic effect that runs every 0.5s -> run persistent that searches 60 times with a duration of 0.01 (not sure if this will cause much lag, but it produces a smooth result. Depends on the number of units in your map I suppose). The search effect searches for player ground units and applies a set effect that applies a "PUSH" behavior and then applies a force effect with mass and amount set to 1. The Push behavior has the "unstoppable" flag checked.
You can have multiple behaviors in this manner that all run the same periodic effect.
Ex: Push 10, 20, 30 etc.
Then in the set effect youd simply validate the behaviors to ensure a unit is pushable
Ex: Caster Has Push 10 && Target does not have Push 20 && Target does not have push 30.
Or, If you want to use triggers to apply behavior stacks, you can use one validator.
Validator: Unit compare behavior count
Behavior: "Push Priority"
Compare: Greater than (or equal to)
Value: Other Unit+: Target
Value: Unit+: Caster
So, In summary
Behavior: Push Behavior
- Periodic Search every 0.5s
Effect: Push Persistent
- Period Duration: 0.01
- Periods: 60
- Effect: Push Search
Effect: Push Search
- Filter: Required: Ground; Excluded: Enemy, Ally, Neutral, etc etc
- Radius: 0.1
- Effect: Push Set
- Extend & offset by unit radius, center at launch
Effect: Push Set
- Apply Push (Behavior)
- Apply Push (Force)
- Validator: (Put validators for what units can or cannot be pushed here.)
Effect: Apply Push (Behavior)
- Apply "Being Pushed"
Behavior: Being Pushed
- Flags: Unstoppable
Effect: Apply Push (Force)
- Amount: 1
- Mass: 1
Oh, and for same unit types, thats easy.
Validator: Unit Type
Other Unit+: Target
Leave value blank. This will make the unit type validator check if the target unit type is equal to the casters unit type. If not, itll preform the push.
Wow, thank you for the thorough reply. This definitely helps!
You must login to post a comment. Don't have an account? Register to get one!