This tutorial explains how to apply data behaviors to units that provide simple but useful AI. In this tutorial, basic data editing knowledge is assumed (intermediate level or advanced). We will re-create two example behaviors from my custom map:
Suicide Fire Elemental - Attack outward from the ability caster's facing.
Bovine Warp Trooper - Provides merc. support by following the caster around and attacking things.
Each unit is autonomous and does not allow player control.
Key points will be highlighted like this
Videos
Fire Elemental
Warp Trooper
Suicide Fire Elemental
The suicide fire elemental runs forward until it finds a close target to explode itself on. Follow the recipe below to recreate the elemental's running behavior:
1. New issue order effect - Fire Elemental Action - Attack
Set Ability - Ability = Attack
Set Effect - Player + = (None):Source
Set Target - Target + = (None):Target Unit/Point
Set Unit + = (None):Source
This causes the fire elemental to attack to some location depending on how it is called from other data entries.
2. New persistent effect - Fire Elemental Attack Forward
Set Effect - Period Count = 1
Set Effect - Period Durations = (0.0)
Set Periodic Effects = (Fire Elemental Action - Attack)
Set Periodic Offsets = { (0,-3,0) }
Set Target - Location + = (None):Source Unit
This causes the fire elemental to attack move three spaces forward from its current position.
3. New behavior - Fire Elemental Behavior
Set Stats - Flags - Hidden = true
Set Stats - Period - .5
Set Behavior - Category Permanent (optional)
Set Effect - Initial = Fire Elemental Attack Forward
Set Effect - Periodic = Fire Elemental Attack Forward
This behavior forces the fire elemental to continue attacking forward every .5 seconds.
4. New apply behavior effect - Fire Elemental Behavior Apply
Set Behavior - Behavior = Fire Elemental Behavior
This applies the attack move forward behavior.
5. New behavior based on Timed Life - Fire Elemental Timed Life
Set Stats - Duration = 7
Effect - Expire Effect = Fire Elemental Target Explosion <Your custom explosion effect as you see fit...>
This behavior causes the fire elemental to explode if it cannot find a target after a short duration.
6. New apply behavior effect - Fire Elemental Timed Life Apply
Set Behavior - Behavior = Fire Elemental Timed Life
7. New set effect - Fire Elemental Buffs
Set Effects - Effects = (Fire Elemental Behavior Apply, Fire Elemental Timed Life Apply)
This applies all the fire elemental buffs to a target unit.
8. New weapon - Fire Elemental Suicide Explode
Set Effect - Effect = <Your custom explosion effect as you see fit...>
Set Stats - Backswing = 0.0
Set Stats - Minimum scan range = 7
Set Random Delay Maximum = 0.0
Set Random Delay Minimum = 0.0
Set Stats - Range = 0.4
Set Weapon - Allowed Movement = Moving
Set Weapon - Target Filters as you see fit...
The weapon is incredibly important for the behavior because it dictates the distance your minion acquires a target. This is handled by the minimum scan range field.
9. New unit and actor - Fire Elemental Unit / Fire Elemental Actor
Duplicate the spectre unit from SC2, make copies of the unit entry and its actor. Change names to 'Fire Elemental'
Set Unit - Flags = Uncommandable, Invulnerable
Remove the spectre abilities in Ability - Abilities+ and Ability - Command Card
Set movement - speed = 4.4
Set combat - Weapon = Fire Elemental Suicide Explode
For the fire effects, I made some modifications to the actor (optional). I modified the tint color of the spectre to red with a increased HDR setting. In addtion, added a fire animation on top of the tint change. The final touch was to always make the spectre use the cover animation group so its gun would be holstered.
10. New create unit effect - Fire Elemental Create
Set Effect - Creation Options - Set Facing = TrueNote, all boxes are checked except facing by default
Set Effect - Effect - Spawn = (Fire Elemental Buffs)
Set Target - Location + = (None):Target Unit / Point
Set Unit - Spawn Owner + = (None):Caster
Set Unit - Spawn Unit = Fire Elemental
This creates the fire elemental and applies a set of behaviors to it. It also ensures the fire elemental will run in the same direction the caster was facing.
11. New persistent effect - Fire Elemental Init
Set Effect - Period Count = 1
Set Effect - Period Durations = (0.0)
Set Effect - Period Effects = (Fire Elemental Create Unit)
Set Effect - Periodic Offsets = { (0, -1, 0) }
Set Target - Location + = (None):Caster Unit/Point
This creates the fire elemental 1 space in front of the caster.
12. Create new button - Fire Elemental Button
Create button as you see fit...
13. Create new effect-target ability - Fire Elemental Ability
Set Effect - Effect - Fire Elemental Init
Set Stats - Range = (16)
Set cost / commands / cast time as you see fit...
Conclusion
Alternatively, you could have added the behaviors to the Initial Unit Behavior Field in the Unit Tab for the Fire Elemental Unit. The advantage here is that we created effects which are more flexible in their application. We could retool some of the effects here to be more generic for reuse. The overall effect is that a casting unit uses an ability called fire elemental. A unit is created 1 position in front of the caster which runs forward attack-moving. The weapon minimum scan range dictates the distance threshold that your fire elemental will track on to enemy units like a homing missile. The fire elemental has a timed life so that it expires after 7 seconds.
Bovine Warp Troopers
Bovines warp troopers follow the caster around the battle field like a hired merc. Follow the recipe below to recreate the merc. behavior:
1. New unit and actor - Bovine Warp Trooper
Duplicate the tauren marine unit from SC2, make copies of the unit entry and its actor. Change names to 'Bovine Warp Trooper'
Set Unit - Flags = Uncommandable
Set movement - speed = 3.5
I increased the movement speed to 3.5 so the unit will always catch up to the caster. You want it to be uncommandable since it is a mercenary AI. In addition, you can lower its pathing priority if you don't want it to get in the way of your main hero.
Set Effect - Target Location + = (None):Caster Unit
This method tells the tauren to attack move to a location on the caster's 'six'. Using random periodic offsets cause the tauren to shuffle around making things a bit more believable. Also note that the target location is the caster unit, while effects above issue orders to the source unit, which is the tauren.
4. Create new behavior - Warp Trooper Behavior
Set Behavior - Categories = Permanent (OPTIONAL)
Set Effect - Effect Initial = Warp Trooper Attack Forward
Set Effect - Effect Periodic = Warp Trooper Attack Forward
Set Stats - Flags: Hidden = True
Set Stats - Period = 1.0
This continually requests that the tauren follow the caster.
Set Target - Location + = (None):Caster Unit/Point
This effect spawns multiple warp troopers around the caster.
9. Create new effect-instant ability - Universal Warp Troopers
Set Effect - Effect - Warp Troopers Create
Set cost / commands / cast time as you see fit...
For the warp in/out effects, I used a behavior that prevents using abilities. An actor applies the warp animation and blue tint color while the warp behavior is active. I also added a custom weapon that is similar to a plasma rifle. These are just to make things pretty, it's not necessary for the tutorial.
Conclusion
Issuing attack move to a random location behind the caster creates a very believable mercenary effect that is easy to create and manage. The above behavior could be improved by added validators based on the distance to the caster. If the caster is too far away, the warp troopers could move instead of attack to the caster's position. Alternatively, they could warp to the caster's positions since they seem to have the technology.
Tutorial writing complete. I plan to write more AI tutorials in the future. Next up I will probably do a tutorial on how to write 'bots' for MOBA games. If you have any questions or comments, please let me know what you thought of this tutorial.
Tutorial writing complete. I plan to write more AI tutorials in the future. Next up I will probably do a tutorial on how to write 'bots' for MOBA games. If you have any questions or comments, please let me know what you thought of this tutorial.
It's fine if you show how do the bots too, in fact you probably know a better way than me. (I just attack move them thru a series of points) I just didn't want you to waste your time on or anything so I figured I'd let you know.
As for the tutorial, having 'mercs' follow you around like an escort is something I wanted to know how to do. Nice tutorial :D
Ah, no conflict then. I'll be doing a tutorial on how to write bots that take the place of an actual player. I'm glad you linked that though so I won't do that type of tutorial also.
good tutorial. i made the fire elemental one but when i cast it it doesnt move. ive checked everything and everything seems to be ok. if you could tell me what the prob is i would thank you
good tutorial. i made the fire elemental one but when i cast it it doesnt move. ive checked everything and everything seems to be ok. if you could tell me what the prob is i would thank you
Did you check to make sure the behavior is applied to the fire elemental? If the behavior is there, does the fire elemental have a caster?
Hi there.
This tutorial is pretty well made and quite useful, yet i've got a problem adapting the system to suit my needs.
I'm trying to have a building that can recruit units that follow around other units using the Bovine Warptroopers' example.
I tried doing the following so far:
-Created Unit:
Name: Marine
Duplicate of a normal Space-Marine + Behaviour Escort
-Created Unit:
Name: Basic Truck
Attributes: Mechanical, Armored
The doodad as unit. Can move and all that, but not attack - that's what the escorts are for.
-Created a behaviour buff:
Name: Escort
Phase: 2
Effect Initial: Escort Search Area
Effect Periodic: Escort Set
So the idea is to basically have the marine initially search for the truck unit and apply the Forward effect for the first time. Then it would always refer to that unit via Keep Going and hold onto the truck.
Yet, that doesn't work.
What happens is that the marines do find the point where the truck stood initially, but when i move the truck, the marines will keep escorting that point, so it would look like they were dancing around that spot. And sometimes they go even further than i thought they would...
However, i hope you can help me point out my mistake.
Thanks in advance,
ParanoidPenguin
i create new behavior but their are no
Set Stats - Period - .5
or Set Effect - Initial = Fire Elemental Attack Forward
Set Effect - Periodic = Fire Elemental Attack Forward
can u help me with this
Any chance of getting a test map for this to download. Because i've followed the guide for the warp troopers and they just don't follow the caster unit and I would like to see where I went wrong.
edit*
found out why it wasn't working. It was because I removed the commands from the command card.
Introduction
This tutorial explains how to apply data behaviors to units that provide simple but useful AI. In this tutorial, basic data editing knowledge is assumed (intermediate level or advanced). We will re-create two example behaviors from my custom map:
Each unit is autonomous and does not allow player control.
Key points will be highlighted like this
Videos
Fire Elemental
Warp Trooper
Suicide Fire Elemental
The suicide fire elemental runs forward until it finds a close target to explode itself on. Follow the recipe below to recreate the elemental's running behavior:
1. New issue order effect - Fire Elemental Action - Attack
This causes the fire elemental to attack to some location depending on how it is called from other data entries.
2. New persistent effect - Fire Elemental Attack Forward
This causes the fire elemental to attack move three spaces forward from its current position.
3. New behavior - Fire Elemental Behavior
This behavior forces the fire elemental to continue attacking forward every .5 seconds.
4. New apply behavior effect - Fire Elemental Behavior Apply
This applies the attack move forward behavior.
5. New behavior based on Timed Life - Fire Elemental Timed Life
This behavior causes the fire elemental to explode if it cannot find a target after a short duration.
6. New apply behavior effect - Fire Elemental Timed Life Apply
7. New set effect - Fire Elemental Buffs
This applies all the fire elemental buffs to a target unit.
8. New weapon - Fire Elemental Suicide Explode
The weapon is incredibly important for the behavior because it dictates the distance your minion acquires a target. This is handled by the minimum scan range field.
9. New unit and actor - Fire Elemental Unit / Fire Elemental Actor
For the fire effects, I made some modifications to the actor (optional). I modified the tint color of the spectre to red with a increased HDR setting. In addtion, added a fire animation on top of the tint change. The final touch was to always make the spectre use the cover animation group so its gun would be holstered.
10. New create unit effect - Fire Elemental Create
This creates the fire elemental and applies a set of behaviors to it. It also ensures the fire elemental will run in the same direction the caster was facing.
11. New persistent effect - Fire Elemental Init
This creates the fire elemental 1 space in front of the caster.
12. Create new button - Fire Elemental Button
13. Create new effect-target ability - Fire Elemental Ability
Conclusion
Alternatively, you could have added the behaviors to the Initial Unit Behavior Field in the Unit Tab for the Fire Elemental Unit. The advantage here is that we created effects which are more flexible in their application. We could retool some of the effects here to be more generic for reuse. The overall effect is that a casting unit uses an ability called fire elemental. A unit is created 1 position in front of the caster which runs forward attack-moving. The weapon minimum scan range dictates the distance threshold that your fire elemental will track on to enemy units like a homing missile. The fire elemental has a timed life so that it expires after 7 seconds.
Bovine Warp Troopers
Bovines warp troopers follow the caster around the battle field like a hired merc. Follow the recipe below to recreate the merc. behavior:
1. New unit and actor - Bovine Warp Trooper
I increased the movement speed to 3.5 so the unit will always catch up to the caster. You want it to be uncommandable since it is a mercenary AI. In addition, you can lower its pathing priority if you don't want it to get in the way of your main hero.
2. Create issue order effect - Warp Trooper Action - Attack
This tells the tauren to attack move to a target location specified in the parent effect.
3. Create persistent effect - Warp Trooper Attack Forward
This method tells the tauren to attack move to a location on the caster's 'six'. Using random periodic offsets cause the tauren to shuffle around making things a bit more believable. Also note that the target location is the caster unit, while effects above issue orders to the source unit, which is the tauren.
4. Create new behavior - Warp Trooper Behavior
This continually requests that the tauren follow the caster.
5. Create new apply buff effect - Warp Trooper Apply Behavior
6. Create new set effect - Warp Trooper Buffs Set
The timed life effect in the video is optional and we already did an example of timed life above.
7. Create new create unit effect - Warp Troopers Create Unit
This spawns the warp trooper and applies a set of behaviors to it.
8. Create new persistent effect - Warp Troopers Create
This effect spawns multiple warp troopers around the caster.
9. Create new effect-instant ability - Universal Warp Troopers
For the warp in/out effects, I used a behavior that prevents using abilities. An actor applies the warp animation and blue tint color while the warp behavior is active. I also added a custom weapon that is similar to a plasma rifle. These are just to make things pretty, it's not necessary for the tutorial.
Conclusion
Issuing attack move to a random location behind the caster creates a very believable mercenary effect that is easy to create and manage. The above behavior could be improved by added validators based on the distance to the caster. If the caster is too far away, the warp troopers could move instead of attack to the caster's position. Alternatively, they could warp to the caster's positions since they seem to have the technology.
Tutorial writing complete. I plan to write more AI tutorials in the future. Next up I will probably do a tutorial on how to write 'bots' for MOBA games. If you have any questions or comments, please let me know what you thought of this tutorial.
Don't mean to sound mean or anything but I made a MOBA/DOTA tutorial series already here: http://forums.sc2mapster.com/resources/tutorials/16045-complete-noobs-guide-to-dota-style-maps-part-1/#p2
It's fine if you show how do the bots too, in fact you probably know a better way than me. (I just attack move them thru a series of points) I just didn't want you to waste your time on or anything so I figured I'd let you know.
As for the tutorial, having 'mercs' follow you around like an escort is something I wanted to know how to do. Nice tutorial :D
@zeldarules28: Go
Ah, no conflict then. I'll be doing a tutorial on how to write bots that take the place of an actual player. I'm glad you linked that though so I won't do that type of tutorial also.
Ohh lol. I tried to make one bot with triggers back in wc3 and it was so stupid lol... Keep up the good work. :D
good tutorial. i made the fire elemental one but when i cast it it doesnt move. ive checked everything and everything seems to be ok. if you could tell me what the prob is i would thank you
Did you check to make sure the behavior is applied to the fire elemental? If the behavior is there, does the fire elemental have a caster?
Hi there.
This tutorial is pretty well made and quite useful, yet i've got a problem adapting the system to suit my needs.
I'm trying to have a building that can recruit units that follow around other units using the Bovine Warptroopers' example.
I tried doing the following so far:
-Created Unit:
Name: Marine
Duplicate of a normal Space-Marine + Behaviour Escort
-Created Unit:
Name: Basic Truck
Attributes: Mechanical, Armored
The doodad as unit. Can move and all that, but not attack - that's what the escorts are for.
-Created a behaviour buff:
Name: Escort
Phase: 2
Effect Initial: Escort Search Area
Effect Periodic: Escort Set
-Created Search Area Effect:
Name: Escort Search Area
Area: Arc 360; Range 5; Effect: Escort Attack Forward
MaxCount: 1
Filters: Mechanical, Armored, Player, Visible; Exclude Self, Dead, Enemy, Ally, Neutral
Target: Targetunit
-Created Create Persistent Effect:
Name: Escort Forward
Flags: Random Offset
Periodic Effect: Escort Attack
Periodic Offsets: 1,1,0; 1,0,0; -1,1,0; etc...
Phasedurations: 0
Phasecount: 1
Target: Targetunit
Created Issue Order Effect:
Name: Escort Attack
Ability: Attack
Target: Targetunit/Targetpoint
Player: Source
Unit: Source
Created Set Effect:
Name: Escort Set
Effects: Escort Keep Going, Escort Forward
Created Search Area Effect:
Name: Escort Keep Going
Search Include: Escort Search Area, Target
Filter: Excluded Self, Dead, Enemy, Ally, Neutral
Area: 360; Max 1; Radius 10; Effect Escort Forward
Maxcount: 1
Mincount: 1
So the idea is to basically have the marine initially search for the truck unit and apply the Forward effect for the first time. Then it would always refer to that unit via Keep Going and hold onto the truck.
Yet, that doesn't work.
What happens is that the marines do find the point where the truck stood initially, but when i move the truck, the marines will keep escorting that point, so it would look like they were dancing around that spot. And sometimes they go even further than i thought they would...
However, i hope you can help me point out my mistake.
Thanks in advance,
ParanoidPenguin
@Ultimaswc3: Go
when it says new behavior fire elemental behavior
i create new behavior but their are no Set Stats - Period - .5 or Set Effect - Initial = Fire Elemental Attack Forward Set Effect - Periodic = Fire Elemental Attack Forward can u help me with this
@Citiz3nSnip3s: Go
Yes, there should be. Trying typing the the 'field filter' (text box top right titled 'search') for the word 'period'.
@Ultimaswc3: Go
Thanks for the advice
Any chance of getting a test map for this to download. Because i've followed the guide for the warp troopers and they just don't follow the caster unit and I would like to see where I went wrong.
found out why it wasn't working. It was because I removed the commands from the command card.
3. New behavior - Fire Elemental Behavior
What type of behavior?
@Selfcreation: Go
Buff