Many people don't understand how you change damage amount and inflict damage through triggers in the Starcraft 2 Editor. I searched for answers and found some cumbersome approaches and not-too-well explained ways of doing this.
So I made an Action Definition for you guys to use that works in the same way as the "Inflict damage" action event does in the Warcraft 3 Editor. You can just download the attached map and copy-paste everything to your map, but in case you want to know what is really going on behind it all, here goes:
What you need:
An Event Listener trigger, e.g. when a unit uses an ability on a target
An Effect of Effect Type "Damage" for inflicting the damage
An Action Definition for: (1) Changing the data in the Data Editor (through Catalog calls), (2) Inflicting damage based on the (new) Damage Amount in the Data Editor
The Event Listener
I made an ability based on the Ghost's Snipe ability and set the damage in this ability (read: Effect) to 0 (zero). I then made a trigger for listening at when this ability is used.
When the Snipe ability is used we get two key informations for the damage inflict Action Definition to work: The "(Triggering unit)" (caster unit) and the "(Triggering ability target unit)" (target unit).
Now all we need to do is feed these informations plus the amount of damage we want to inflict to our Action Definition.
The Dummy Effect
I based the dummy Effect for inflicting damage on the Snipe ability as well and named it "DamageUnit". You should of course change all unwanted features to something of your liking, e.g. set the armor reduction to 0. The damage amount you do not need to change as this will be done through the Action Definition.
The Action Definition
The Action Definition for inflicting damage takes the following three parameters:
A CasterUnit (the "Triggering unit" from the Event Listener)
A DamageAmount
A UnitTarget (the "Triggering ability target unit" from the Event Listener)
First in the Action Definition we must set the Damage Amount in the Catalog:
Catalog - Set value of Effects "DamageUnit" "Amount" for player (Owner of UnitCaster) to (String(DamageAmount) with 3 decimal places)
Now we can inflict the damage, using the Effect "DamageUnit":
Environment - Execute DamageUnit on UnitTarget from UnitCaster
You can change the Grammar Text (Syntax) in the Aciton Definition to something suitable. I change mine to:
Damage - Make UnitCaster inflict DamageAmount damage to UnitTarget.
The Map Example
I added one additional parameter to the Action Definition in my map example for changing the DamageKind, of which there are four: Melee, Ranged, Spell and Splash.
Suggestions for additional features
You can add features for the Action Definition such as damage versus a specific armor type, e.g. "vs Light: 5".
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Catalog entry 'DamageUnit' was not found
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Could not get 'entry' from parameter in 'CatalogFieldValueSet' (value: 4327983)
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Catalog entry 'DamageUnit' was not found
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Could not get 'entry' from parameter in 'CatalogFieldValueSet' (value: 6949418)
Hello my fellow mappers/modders
Many people don't understand how you change damage amount and inflict damage through triggers in the Starcraft 2 Editor. I searched for answers and found some cumbersome approaches and not-too-well explained ways of doing this.
So I made an Action Definition for you guys to use that works in the same way as the "Inflict damage" action event does in the Warcraft 3 Editor. You can just download the attached map and copy-paste everything to your map, but in case you want to know what is really going on behind it all, here goes:
What you need:
The Event Listener
I made an ability based on the Ghost's Snipe ability and set the damage in this ability (read: Effect) to 0 (zero). I then made a trigger for listening at when this ability is used. When the Snipe ability is used we get two key informations for the damage inflict Action Definition to work: The "(Triggering unit)" (caster unit) and the "(Triggering ability target unit)" (target unit). Now all we need to do is feed these informations plus the amount of damage we want to inflict to our Action Definition.
The Dummy Effect
I based the dummy Effect for inflicting damage on the Snipe ability as well and named it "DamageUnit". You should of course change all unwanted features to something of your liking, e.g. set the armor reduction to 0. The damage amount you do not need to change as this will be done through the Action Definition.
The Action Definition
The Action Definition for inflicting damage takes the following three parameters:
First in the Action Definition we must set the Damage Amount in the Catalog:
Now we can inflict the damage, using the Effect "DamageUnit":
You can change the Grammar Text (Syntax) in the Aciton Definition to something suitable. I change mine to:
The Map Example
I added one additional parameter to the Action Definition in my map example for changing the DamageKind, of which there are four: Melee, Ranged, Spell and Splash.
Suggestions for additional features
You can add features for the Action Definition such as damage versus a specific armor type, e.g. "vs Light: 5".
Hope some people find this useful.
DOWNLOAD EXMAPLE MAP:
http:dl.dropbox.com/u/249997/WC3LikeDamageSystem.SC2Map
I know there is an attachment feature on this website, couldn't find it. This is my first post, bear with me :)
EDIT Found it! Apparently you must create the post before attaching elements. ;)
I'm getting a trigger error in "get event listener".
I'm guessing I haven't done something right.
Unit - Any Unit uses Nova - Snipe (Nova) at Generic3 - Execute stage (Ignore shared abilities)
Damage - Make (Triggering unit) inflict 1.0 damage to (Triggering ability target unit) of damage type Ranged.
I wanted to test by changing snipe to 1.0 damage.
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Catalog entry 'DamageUnit' was not found
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Could not get 'entry' from parameter in 'CatalogFieldValueSet' (value: 4327983)
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Catalog entry 'DamageUnit' was not found
00:00:18.50 Trigger Error in 'gt_Eventlisteneregunitusesability_Func': Could not get 'entry' from parameter in 'CatalogFieldValueSet' (value: 6949418)
@gorang: Go
If you want to implement the above damage system directly in your map you have to copy the following in said order:
In your trigger for inflicting damage insert the call for the Action Definition like so:
Damage - Make (CasterUnit) inflict 1.0 damage to (TargetUnit) of damage type Spell.
@Kafoso: Go
This damage system is now obsolete due to the implementation of a built-in damage system in the editor that came with patch 1.1.0.
Added a trigger to deal damage from a unit.
OMG I LOVE YOU SSOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH!!!