I've seen people asking for help with missiles that continue in a certain direction until they come into contact with a wall or unit. Please note that this is NOT a traceline guide. There are many of those about already, or you can look at my Third Person Shooter System (
link).
I expect you to have some basic understanding of effect types and a bit of experience already with the data editor. I will be running through a demonstration, but will sum up the theory behind the whole thing afterward. You may name your buffs/effects/etc; whatever you wish as you follow along.
We will be using three Data Types: Effect, Validator, and Behavior. Others may be used to actually assign the finished product to an ability or weapon, but I won't be covering that, since it's unique to each person's final intentions.
Step 1: Behavior Tab
Switch over to the Behavior Tab.
Add an object named Contact with type: Buff
You can leave the rest default. This buff is completely invisible and really just allows us to create our validator.
Step 2: Validator Tab
Switch over to the Validator tab.
Add an object named Contact Val with type: Unit Compare Behavior Count
- Set Behavior to: Contact (our buff)
- Set Compare to: Equal to
- Set Unit+ to: Source
- Set Value to: 0
This Validator prevents our caster from continuing once his shot has come into contact with a unit, wall, etc;
Step 3: Effects Tab
Yep, you guessed it. It's time to wander over to the Effects tab. We actually won't need the other two again, so you can close them if you wish. This is going to take a little while...
With Effects, I always like to get a good idea of what I hope to achieve and then work backwards. That way, everything links correctly and you don't need to revisit anything.
Add object named Shoot (Damage) with Type: Damage
- Set Amount to: Whatever damage you want
- Set Response Flags and Notify Effects: to what suits your ability best
- Set Kind to: Again, whatever suits your ability best. You probably want Ranged
I don't think the damage effect needs much explanation...if you want to add an AoE effect upon impact, do it via the Area+ field in this effect.
Add object named Shoot (Buff) with Type: Apply Behavior
- Set Behavior Count to: 1
- Set Behavior to: Contact (our buff)
- Set Unit+ to: Source
This is what will add the buff to our caster if the attack hits an object.
Add object named Shoot (Set) with Type: Set
- Set Effects to: Shoot (Buff), Shoot (Damage)
That one's fairly simple. Sets are really just a way of using multiple effects at once.
Add object to named Shoot (Remove Buff) with Type: Remove Behavior
- Set Behaviors to: Contact (our buff)
- Set Unit+ to: Source
Add object named Shoot (Search Area) with Type: Search Area
- Set Areas+ to:
- Arc: 360
- Effect: Shoot (Set)
- Maximum Count: 1
- Radius: This is really up to you. The farther you want the missile to go before timing out, the higher you want this to be (you'll see why shortly). Ideally you want 0.5 or less. But it all comes down to how tolerant you are of monotonous copy/pasting. Keep in mind that the value you set this to will also be the WIDTH of your collision area, so lower is better for a bullet, or something similar.
- Set Maximum Count to: 1
- Set Search Filters to: These will (once again) be unique to you. You might want it to avoid hitting air units, structures, etc. Set whatever you please.
This Search Area effect is what helps our missile detect enemies as it travels.
Add object Shoot (Persistent) of Type: Create Persistent
- Set Period Effects to: Shoot (Search Area)
- Set Periodic Validator to: Contact Val (our Validator)
- Set Periodic Offsets to: This is where things get tricky and irritating. Basically, for every X distance you want the missile to check for targets, you need to set up a sequence of coordinates. An example would be a missile that only travels ten distance before disappearing being represented like so: {(0, -0.5), (0, -1), (0, -1.5)...(0, -9.5), (0, -10)}. The smaller the jump in the Y value (0.5 in my example) between values, the more realistic the shot will be (and the more thorough/precise). However, getting your missile to cover the entire map could be an absolute nightmare to input. Below I will put an example of how to get the computer to do the work for you over long distances. Ideally, your change in Y between coords should be equal to the radius you set in your Search Area effect.
- Set Period Count to: Set this field to however many values you have in the offset field. In my example above, I would have 20
- Set Period Duration to: The total amount of time you want the missile to take to reach its maximum distance divided by the Period Count. I've found there to be a limit to this. Going under 0.04 or so (which is still quite fast), the buff cannot be applied to the caster as quickly as the Persistent runs. Basically, stick to 0.04 or higher.
- Set Location to: Source Unit/Point (or just Source Point if you don't want your ability to target units)
- Set Location Offset - End+ to: The same as the above value ^
- Set Effect - Expire to: Shoot (Remove Buff)
- Set Effect - Expire Delay to: (your period duration + .001)
This persistent will check for collision ever X distance and prevent the check from continuing once contact has been made.
That's all there is to it really. Obviously you still need buttons/abilities/weapons set up to actually make use of your effect, but calling the Persistent will make the whole string work. However, I will walk through one bonus step that I recommend:
(Optional) Step 4: Actor Tab
Switch to the Actor Tab.
Add object named Shoot Beam with Type: Beam (Simple) - Beam Simple Animation Style One Shot
- Set Model to: A beam model of your choice. GhostSnipeAttackBeam is the best for standard bullets, I find.
- Set Events to:
- Event: Actor Creation
- Action: Animation Bracket Start: [Shoot (custom name), Birth, Stand, Death, Play Once, 0.05, Duration] (Keep in mind that not all Beam models have Birth, STand and Death animations)
- Event: Animation Done
- Term: Shoot (custom name)
- Action: Destroy
This is a beam model, which will represent your shot. It is used in conjunction with the next Actor.
Add object named Shoot Attack Launch with Type: Action - GenericAttack
- Set Beam to: Shoot Beam (our Beam Actor)
- Set Launch Attachment Query+ to: This will differ based on what unit is using the weapon/ability. Chances are you want it to be set to FilterWeapon
- Set Launch Assets+: I would recommend setting the Art and Sound to match the look and sound you desire on Launch
- Set Impact Map+: Same as above, except that this is obviously for Impact instead of Launch
- Set Events+ to:
- Effect > Shoot (Damage) > Start
- Action: Create (all fields blank)
And that should be it.
Fun Additions
Here are some fun ideas to consider:
- Setting the Validator to be Less than or Equal to X: This would let the missile pass through X number of units before finally being destroyed.
- Using Multiple Persistents: This is what I mentioned earlier in the Persistent section. For a really long distance, you could simply make 20 or so periodic offsets. If you then made 5 duplicates of the persistent and made them all link each other through expire effects, you turn those twenty offsets into 100 without actually having to write them all in.
- Miss Actors: One 'problem' you may have noticed above is that our beam will only appear if a missile makes contact. If the missile reaches its limit without colliding, no effect is displayed. You can get around this by doing the following:
- Create an Effect named Shoot (Damage Dummy) with Type: Damage. Don't edit anything.
- Create a new Set effect and connect the Remove Behavior and Damage Dummy effects.
- Go to your Persistent Effect (or the last in a chain if linking them) and set the Effect - Expire field to be your new Set Effect.
- Duplicate the last actor we made (Shoot Attack Launch) and change the event in the Events+ field to Effect > Shoot (Damage Dummy) > Start
- Shots with Projectiles: I understand some people might want to use a missile rather than a beam. Look a couple posts down for my detailed writeup of that.
- Channeled: Setting the Persistent Effect to Channeled in the Flags field will limit each caster to shooting one missile at a time.
The Theory
The way it works is like this:
The Persistent runs periodically. Every interval specified by your Periodic Duration field, it creates the Search Area effect. The Search Area effect searches for a single, targetable unit at the first offset specified in your persistent effect. If it finds an applicable target, it does adds our Collision Buff to the Caster and deals damage.
When our Persistent runs again, it will set the Search Effect to the second offset, unless the Validator we made fails to clear, which happens whenever the buff is found on our unit.
Finally, at the end of the Persistent, the buff is destroyed, so it doesn't remain on your unit for its next attack/cast.
No question it's not ideal for long ranges, but I wanted to show how simple something this daunting can be.
To use a Missile Instead of a Beam
Create your missile (I won't get into how to do that, I expect anybody following this know how)
Go to the Effects Tab and create a new object called Shoot (Launch) with Type: Launch Missile
- Set Impact Effect to: Shoot (Damage)
- Set Ammo Unit to: your missile unit
Return to Shoot (Set)
- Change the Effects field to: Shoot (Buff) and Shoot (Launch)
Go to the Actor tab and add an object named Shoot Attack with Type: Action - GenericAttack
- Set Art - Missile to: your missile unit's actor
- Set Launch Attachment Query to: Whatever attachment you want the missile to come from on your caster. You probably want FilterWeapon
- Set Launch Assets+ to: Change the Art and Sound values to whatever you want your attack launch to look/sound like
- Set Impact Map+ to: Same as above, but obviously it's for the Impact not the Launch
- Go into Events+ and remove all default items
- Set Events+ to look like this:
Event: Effect > Shoot (Launch) > Start
Term: At Caster
Action: Create
Event: Effect > Shoot (Damage) > Start
Term: At Caster
Term: FromEffectTreeDescendant
Action: ActionImpact