• 🏆 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!

Why does this trigger run multiple times?

Status
Not open for further replies.
Level 1
Joined
Mar 10, 2019
Messages
2
I'm having issues with a trigger that runs multiple times. Hopefully you can assist me in understanding the issue.

What I'm trying to have happen:
A unit with an inventory picks up multiple copies of the same item. Left clicking the item brings up a list of abilities that can be upgraded. Clicking an ability from the list consumes 1 copy of the item and levels up the relevant ability with 1 level.

What actually happens:

The unit has 3 copies of the item. When clicking an ability from the list it consumes all 3 copies of the item and the ability levels up 3 times instead of once.


The abilities in the list are dummy abilities, so the upgrading and removing of the item is done via a trigger. For unknown reasons this trigger runs multiple times instead of just once....

The trigger that runs multiple times looks like this:

Event:
Unit - A Unit Begins casting an ability

Condition:
(Ability being cast) Equal to "My custom dummy ability"

Actions:
Player - Set the current research level of "Custom Upgrade" to Current research level of "Custom Upgrade" + 1 for Owner of casting unit
Item - Remove Item carried by casting unit of type "My custom level up book"
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
I actually just encountered this bug last week: [General] - Spellbook causes spell cast events to fire twice If spells share an an orderstring and you put them inside/outside a spellbook it will attempt to fire all of the spells whenever you cast 1 of them. This is actually normal behavior when spells share orderstrings, since that will always cause a conflict; the problem here is that from within a spellbook it actually fires the cast event multiple times even though only one of the spells is actually cast.

To resolve this you need to remake your dummy abilities to all be based on different non-target unit abilities (Thunderclap, Warstomp, Roar, etc.) or make it based on Channel and alter the orderstrings for the spell. Channel is the only spell whose orderstring can be successfully changed; every other spell looks like you changed it but it still uses the original orderstring.
 
Level 1
Joined
Mar 10, 2019
Messages
2
Thanks for the reply it was driving me nuts.

The multicast issue I'm getting is actually with a dummy spell based on Thunderclap, but I will change it. It is also producing another buggy behavior that I figured might be related to the multicast issue. The unit that casts the dummy ability will sometimes lock up being unable to move or attack back if attacked. The only thing that seems to bring it back to life is to press the stop command on it.

It sounds like the way to go is using channel. @Pyrogasm How do I alter the orderstrings? I'm new to this so if you have a link the decribes it in detail that would be a great help.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
The unit that casts the dummy ability will sometimes lock up being unable to move or attack back if attacked. The only thing that seems to bring it back to life is to press the stop command on it.
Yes this is exactly in line with the bug I found. Thunderclap should be fine as long as there’s only one ability based on thunderclap in the spell book/on the hero.

Here’s an old but probably still good Channel tutorial: Spells - Channel
 
Status
Not open for further replies.
Top