I wish to create a spell that attacks for 20% more damage then the unit's regular attack. Normally, this would be easy. I would just create a second damage effect. If the unit normally deals 10 damage, the second effect would deal 12 damage.
However, my unit in question can wield multiple different weapons, each with different attack numbers.
My question is whether there is an easy way to create this spell, and if so, how?
Very simple, Select the ability, select a target (melee range), deal 120% damage after a short delay (created by a CP).
What I'm more interested in though is the principle of being able to reference the damage of a unit's weapon for other abilities. I might, for example, create a whirlwind ability that does 80% regular damage to all enemies around the caster.
So in the context of your OP, I am assuming this unit can somehow switch out its weapons and this ability needs to deal its damage (+20% bonus) based on whatever weapon is currently in use?
EDIT: If that is the case, I would have all weapons intended to be used by the unit to have the same base damage.
Then at the beginning of the effect chain, apply a behavior to the caster that increases the damage to what you want for that weapon.
Then as posted above, in the pre effect behavior of each weapon add a different behavior with a damage dealt fraction of 1.2
The annoying part is that Im not sure if behaviors can ADD fix damage values, so you would have to do some math to figure out what the per weapon behavior bonus is going to be.
So in the context of your OP, I am assuming this unit can somehow switch out its weapons and this ability needs to deal its damage (+20% bonus) based on whatever weapon is currently in use?
EDIT: If that is the case, I would have all weapons intended to be used by the unit to have the same base damage.
The different weapons are items, each with different attack values, so having them deal the same base damage is impossible.
Ive not messed with items much. After checking them out, I see what you mean.
The only thing I can think of is to have an apply behavior Effect for the bonus damage, then an Issue Order Effect that points to the Use Item (Target) command in the Inventory ability. Not sure how to tell it to use a specific item in the inventory tho. Like I said, Ive not messed with items much.
EDIT: Or maybe Use Magazine?
It has a "Ammo Unit" field that seems to accept Items.
How would I use triggers to find the damage of the caster's current weapon?
You can dynamically lookup the weapon a unit is using, then use catalog functions to look up its tooltip damage effect (which should be the weapon damage) and then use catalog functions again to get the damage effect's various damage fields. You then multiply this by your damage factor, and use triggers to deal the damage to the appropriate unit. Trigger dealt damage will automatically inherit all damage modifiers from the source (damaging) unit as permitted by the effect used to deal the damage. Eg if a unit has +400% weapon damage and the damage effect used is modified by weapon damage then the trigger damage will also deal +400%, hence why it is sufficient to look up the base effect damage.
For usability I recommend a trigger enhanced effect to do this. A trigger enhanced effect is a dummy effect, eg a Set effect that does nothing, that is used to fire a trigger using the Effect trigger event. As the event references a single effect link, the trigger will only fire when that dummy effect is used making it very efficient and highly scalable. Since a dummy effect is used, it merges seamlessly with data and the effect can be used in place of a normal damage effect. The trigger would resolve the weapon damage of the effect source unit, compute the damage to deal, and then deal damage from source effect unit to target effect unit using an appropriate Damage effect, which could be either a generic dummy damage effect used by many triggers or a special purpose dummy effect created just for a specific source of damage.
How would I use triggers to find the damage of the caster's current weapon?
You can dynamically lookup the weapon a unit is using, then use catalog functions to look up its tooltip damage effect (which should be the weapon damage) and then use catalog functions again to get the damage effect's various damage fields. You then multiply this by your damage factor, and use triggers to deal the damage to the appropriate unit.
Thanks for the advice.
How would I go about using this "catalog function"? haven't heard of this until now.
How would I go about using this "catalog function"?
Use them in the way I described above.
Here is an example trigger that when pressing esc it will print out all base damage amounts of all weapons (including hidden) for all selected units.
Weapon Damage Test
Events
UI - Player Any Player presses Escape key Down with shift Allow, control Allow, alt Allow
Local Variables
display player = (Triggering player) <Integer>
display player group = (Player group(display player)) <Player Group>
u = No Unit <Unit>
p = 0 <Integer>
i = 0 <Integer>
weapon n = 0 <Integer>
weapon = No Game Link <Game Link - Weapon>
effect = No Game Link <Game Link - Effect>
damage = 0.0 <Real>
text = No Text <Text>
Conditions
Actions
Unit Group - For each unit u in (Selected units for player (Triggering player)) do (Actions)
Actions
Variable - Set p = (Owner of u)
Variable - Set i = 1
Variable - Set weapon n = (Number of weapons on u)
General - While (Conditions) are true, do (Actions)
Conditions
i <= weapon n
Actions
Variable - Set weapon = (u weapon i)
Variable - Set effect = (Game Link((Value of Weapons weapon DisplayEffect for player p)))
Variable - Set damage = (Real((Value of Effects effect Amount for player p)))
Variable - Set text = (Combine ((Text((Unit tag of u))), " ", (Name of u), " : ", (Game text for (Value of Weapons weapon Name for player p)), " -> ", (Text(damage) with Any Precision decimal places)))
UI - Display text for display player group to Subtitle area
Variable - Modify i: + 1
Hello all,
I wish to create a spell that attacks for 20% more damage then the unit's regular attack.
Normally, this would be easy. I would just create a second damage effect. If the unit normally deals 10 damage, the second effect would deal 12 damage.
However, my unit in question can wield multiple different weapons, each with different attack numbers.
My question is whether there is an easy way to create this spell, and if so, how?
If the spell is a weapon:
I would try:
Make a non stacking Buff Behavior that has Modification > Damage Dealt Fraction set to 1.2
Set that behavior in the Weapon's Pre Effect Behavior field.
That should apply the behavior before the Weapon's Effects are started, and increase the units damage by 20%
Otherwise just make an ability that applies the behavior to the caster..
How exactly is this spell meant to be used?
Ah.
So in the context of your OP, I am assuming this unit can somehow switch out its weapons and this ability needs to deal its damage (+20% bonus) based on whatever weapon is currently in use?
EDIT:
If that is the case, I would have all weapons intended to be used by the unit to have the same base damage.
Then at the beginning of the effect chain, apply a behavior to the caster that increases the damage to what you want for that weapon.
Then as posted above, in the pre effect behavior of each weapon add a different behavior with a damage dealt fraction of 1.2
The annoying part is that Im not sure if behaviors can ADD fix damage values, so you would have to do some math to figure out what the per weapon behavior bonus is going to be.
Ok.
Ive not messed with items much. After checking them out, I see what you mean.
The only thing I can think of is to have an apply behavior Effect for the bonus damage, then an Issue Order Effect that points to the Use Item (Target) command in the Inventory ability. Not sure how to tell it to use a specific item in the inventory tho. Like I said, Ive not messed with items much.
EDIT:
Or maybe Use Magazine?
It has a "Ammo Unit" field that seems to accept Items.
I would advise using a dummy damage effect and triggers to do the correct damage amount.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
You can dynamically lookup the weapon a unit is using, then use catalog functions to look up its tooltip damage effect (which should be the weapon damage) and then use catalog functions again to get the damage effect's various damage fields. You then multiply this by your damage factor, and use triggers to deal the damage to the appropriate unit. Trigger dealt damage will automatically inherit all damage modifiers from the source (damaging) unit as permitted by the effect used to deal the damage. Eg if a unit has +400% weapon damage and the damage effect used is modified by weapon damage then the trigger damage will also deal +400%, hence why it is sufficient to look up the base effect damage.
For usability I recommend a trigger enhanced effect to do this. A trigger enhanced effect is a dummy effect, eg a Set effect that does nothing, that is used to fire a trigger using the Effect trigger event. As the event references a single effect link, the trigger will only fire when that dummy effect is used making it very efficient and highly scalable. Since a dummy effect is used, it merges seamlessly with data and the effect can be used in place of a normal damage effect. The trigger would resolve the weapon damage of the effect source unit, compute the damage to deal, and then deal damage from source effect unit to target effect unit using an appropriate Damage effect, which could be either a generic dummy damage effect used by many triggers or a special purpose dummy effect created just for a specific source of damage.
Use them in the way I described above.
Here is an example trigger that when pressing esc it will print out all base damage amounts of all weapons (including hidden) for all selected units.
Here is the same trigger but in galaxy form.