• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Creating and editing a Bonus Attack Damage permanent ability with triggers?

Status
Not open for further replies.
Level 4
Joined
Jun 10, 2019
Messages
69
Hi all,

I'm attempting to make an ability that's very similar to the Keeper of the Grove's Force of Nature spell, but with one key difference: the summoned treants (renamed to "entlings") get bonus attack damage equal to the hero's bonus intelligence (i.e., if the hero has 40 base intelligence + 15 intelligence from items, the entlings will have 15 bonus attack damage).

I thought this would be a very simple trigger - which it kind of is; it's only 6 lines long - but I'm running aground.

I've given the entlings an ability based on the item ability "Item Damage Bonus (+1)," and my goal is to use triggers to edit the integer data field "Data - Attack Bonus" so that it is equal to the hero's bonus intelligence.

Please see the trigger below:

  • Walking Woods Cast
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Entling
    • Actions
      • Set VariableSet bonusIntelligence = ((Intelligence of (Summoning unit) (Include bonuses)) - (Intelligence of (Summoning unit) (Exclude bonuses)))
      • Ability - Set Ability: (Unit: (Summoned unit)'s Ability with Ability Code: Attack Damage Bonus )'s Integer Level Field: Attack Bonus ('Iatt') of Level: 0 to bonusIntelligence
What I've checked and seems to work:

1) The trigger's event is working

2) The summoned entlings are registering as the summoned unit

3) The hero is registering as the summoning unit

4) The trigger is calculating bonusIntelligence correctly

5) Changing the level in the last line of the trigger has no effect; it stays at the default Attack Bonus value regardless

Any help you could provide would be greatly appreciated!

Thanks!

Edit: I do know that one workaround is to make multiple levels of the bonus attack damage ability, but I don't think that will work in this instance, as the hero I'm designing will (hopefully) be able to stack bonus intelligence without limit.
 
Last edited:
Hmm, try incrementing the ability level first, apply your changes, and decrement the ability level.

Pseudo-code (not valid JASS)
Code:
IncAbilLevel(unit, ability);
SetAbilLevelData(GetUnitAbility(unit, ability), field, level - 1, data) // The value of (level - 1) in this case is 0.
DecAbilLevel(unit, ability)
 
Level 4
Joined
Jun 10, 2019
Messages
69
MyPad, thank you so much for your response - it works perfectly now!

To provide added clarity in case someone in the future has a similar problem, the working trigger is:

  • Walking Woods Cast
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Entling
    • Actions
      • Unit - Increase level of Attack Damage Bonus for (Summoned unit)
      • Set VariableSet BonusIntelligence = ((Intelligence of (Summoning unit) (Include bonuses)) - (Intelligence of (Summoning unit) (Exclude bonuses)))
      • Ability - Set Ability: (Unit: (Summoned unit)'s Ability with Ability Code: Attack Damage Bonus )'s Integer Level Field: Attack Bonus ('Iatt') of Level: 0 to BonusIntelligence
      • Unit - Decrease level of Attack Damage Bonus for (Summoned unit)
Thanks again!
 
Level 4
Joined
Jun 10, 2019
Messages
69
ThompZon, I never would have guessed that you needed to do so (hence my post haha), but if it works, it works!

I was doubly surprised because I've used the 'set ability field' before successfully without having to 'refresh' the ability, but live and learn or something...

Thanks again everyone!

Lastly, how do I set this thread as solved?
 
Status
Not open for further replies.
Top