StarCraft® II

behavior/ability questions

I have 3 abilities/behaviors I'm trying to create on my map.

1) I'm trying to make a unit that when low on hp it tries to run up to it attacker and suicide. How do I get this unit to stop attacking and try to suicide?

2) Can I make a unit get extra minerals when it get a kill?

3) How can I make an ability that when used has the controlling player lose control. The unit then begins to attack allies and enemies alike.
Reply Quote
i am not a pro at the editor but i can answer question 2
Go to the triggers
In Events search for Unit Dies
Search for modify player property under actions
change "Set To" to "Add"
Change the "1" (which stands for the player number) to Killing player (go to function then search for killing player)
Change the "1000" to how much minerals u want him to get when the player kills a unit

This is how it should look like:
Events
Unit - Any Unit dies
Local Variables
Conditions
Actions
Player - Modify player (Killing player) Minerals: Add 5

And if u only want it for a specific unit then it should be like this:

Events
Unit - Any Unit dies
Local Variables
Conditions
(Unit type of (Triggering unit)) == Marine
Actions
Player - Modify player (Killing player) Minerals: Add 5

and lets say u want a zealot kill to give u ten minerals, then u simply add anther trigger and the triggers should look like this:

Events
Unit - Any Unit dies
Local Variables
Conditions
(Unit type of (Triggering unit)) == Zealot
Actions
Player - Modify player (Killing player) Minerals: Add 10

Feel free to ask any questions

EDIT: when u want help in anything, please add a tag in the title. Like for here add [Help] then continue with the title
Edited by TerranMaster on 11/11/2012 6:29 PM PST
Reply Quote
1) I'm trying to make a unit that when low on hp it tries to run up to it attacker and suicide. How do I get this unit to stop attacking and try to suicide?

This, as far as I know, is something to be dealt with through triggers. You're trying to modify how the AI of the game works, when you're trying to make it suicide only when low on hitpoints. I really can't help you here.

2) Can I make a unit get extra minerals when it get a kill?

There is a field somewhere in the Data Editor on every unit, under the Combat tab, that gives you what you're aiming for. It's called Kill Resources. Simply set the numbers correctly, but try to add anti-teamkilling features into your map, as this may have your team killing useless units entirely for the free resources.

3) How can I make an ability that when used has the controlling player lose control. The unit then begins to attack allies and enemies alike.

I believe that this will need a trigger. Make a trigger with an event that picks up any time that the ability is used, then have it find the triggering unit and give it to some computer player that is hostile to all other players. Make sure to have the ability place a behavior on the unit to time how long this will last, then have the behavior use some random effect when it expires. Make another trigger to find incidents of this specific effect going off (for performance reasons, please make sure that the effect you use is not called in any other triggers or abilities; an empty Set effect will do quite nicely), and have it restore the ownership of the unit to the original owner.
You will need a mechanism to track which player owned the unit originally. There are several ways to do this, but the one that comes to my mind is to make a set of dummy behaviors, one for each player in your map. Have your first trigger check which player owns the unit before it changes ownership, and apply a specific behavior based upon that check. Then have the second trigger check as to whether or not the unit has any of these behaviors (their duration should be infinite, and they should probably be hidden for visual reasons), and change the ownership accordingly, as well as remove the behavior.
Reply Quote
I wanted to reply to this sooner, but I didn't get to it. Sorry, I needed to double check a few of the details in the editor.

11/10/2012 11:40 AMPosted by Glacius
1) I'm trying to make a unit that when low on hp it tries to run up to it attacker and suicide. How do I get this unit to stop attacking and try to suicide?

Since it sounds like you intend it to target the unit that brought it below whatever threshold (If it can target any enemy unit it wants, you could do something much simpler with an auto-cast ability and an HP validator), a data-driven approach will require the use of a buff behavior with a "damage response".
That would look something like this:
1. Make an ability that executes the suicide attack. Since you haven't specified what that's supposed to look like, I'll leave the details for you to figure out.
2. Create an Issue Order effect (I will call it "Suicidal Attack Order" for reference below) that executes your ability (for most abilities, "ability command" should be 0). Under Effect: Unit set the Value to "Source", and under Target: Target set the Value to "Target Unit" (Or if you want the suicide attack to be dodgeable (i.e. by moving the attacker in time), Target Point should work nicely).
3. Create a Buff type Behavior. Under Combat: Damage Response set Chance to 1 (Don't miss this, it can be a really annoying mistake to make!) and Handled to Suicidal Attack Order. You may want to set the Target Filters here, too, e.g. to exclude Ally and Player, perhaps. This just determines whether there are any units it will not suicide-attack when they bring its hp down (actually, when they attack it all right now. See step 4).
4. To use the suicide ability only when low enough hp is reached, we need a validator. There are several existing validators of this nature, such as Caster Life LT15 Percent, Caster Life LT45, Life < 1/2 HP, and a few different numbers for each of those variations. If you're attaching the buff directly to the unit (in the data editor, in the Unit object), any of them should be usable if you like its number, but it's easy to duplicate one and set whatever fraction or absolute hit points suits your desire. If you need to cast this behavior on units, the validator may not work correctly (If it's important to you, I can go into details) if the "Value" under Validator: Unit is set to "Caster", but either Target or Source should work. Whatever validator you pick/create, apply it to your Buff, in the "Behavior: Validators (Disable)" field of the behavior.
5. Almost there, but a suicider under fire from a variety of units will keep changing target and may get stuck in a loop until it dies. There are a few ways around this, but I'm going to say the best one is to use a second validator, also in the (Disable) field of the Buff (This field is an array, just put both validators in there). This validator is of type Unit Order Queue and the non-default fields are "Validator: Ability" (Set to your suicide attack ability), "Validator: Find" (Set to Disabled), and Value under Validator: Unit (As with the above, the default of Caster may not work if your Buff is castable, in which case use Source or Target, but otherwise you can leave it if you want). The reason this approach is better than others I looked at is that if the suiciding unit's target dies before it gets there, it will be able to pick a new target (although not if you decided to use Target Point, back there).

11/10/2012 11:40 AMPosted by Glacius
2) Can I make a unit get extra minerals when it get a kill?

So you want a particular unit or category of units to get money, perhaps in addition to something standard, for the kills it earns, right? Well I thought I had a simple and pleasant solution for this, but since fatal damage responses at location attacker just don't work (my programmer's intuition says it checks whether the unit with the buff will die instead of the unit taking the damage), it gets more complicated to do this in a data-pure way, and I recommend you follow TerranMaster's advice for a trigger-based approach. You could use a damage response at location attacker to apply a buff with fatal damage response at location defender to issue order to target (attacker) to use ability (transient and not on command card) that grants the player more money, while restricting that ability to units that get this money bonus, though, if you really wanted a data editor solution.
And of course if you actually just want kills to give the player money in general, Palamani's advice is probably best, even though it does require configuration of all units individually.

11/10/2012 11:40 AMPosted by Glacius
3) How can I make an ability that when used has the controlling player lose control. The unit then begins to attack allies and enemies alike.

Easy. You just need to make the ability apply a Buff to the unit. In the Buff, set Value under Behavior: Player to "Hostile". That's honestly all there is to it. You can of course configure some things like duration of the behavior or any side effects you want it to have, but nothing else is required to basically achieve the functionality you describe.
Edited by TheFed on 11/11/2012 11:16 AM PST
Reply Quote
Thank you for your responses. I am looking for purely data editor solutions. My Map has a lot of triggers so far and I'd to learn more about the data editor.
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]