• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Weird stuff: Issue Order No Target after Research

Level 2
Joined
Jul 14, 2024
Messages
3
Hi,
I've encountered a weird problem when trying to issue an order after a research is completed.
  • ResearchProblem
    • Events
      • Unit - A unit Finishes research
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • Unit - Add Well Spring 08 to (Triggering unit)
      • Unit - Order (Triggering unit) to Undead Obsidian Statue - Activate Spirit Touch
Without the Wait instruction this trigger won't work at all.
I've found a lot of threads regarding autocasts, but none of the solutions did work until I added the wait.
Even worse. No ABILITY WITHOUT TARGET would fire at all (e.g. Thunder Clap), but another RESEARCH could be issued to start.
(I did not test abilities with target, since they won't suffice with my Use Case).

I guess there is something asynchronous going on internally regarding researches, since they apply a faction-wide action changes.
Is there some trick to make it work without a wait that could create synchronocity problems?
I don't want the ability icon to be shown in its darkened version telling the player that it requires research abc.


Thanks :)
 
Last edited:
You're right. I'm guessing it is because upgrades temporarily disable other actions--and the event likely fires just before it re-enables the actions.

Your code is fine as-is with respect to synchronicity (triggering unit is "local" to the event fired so it won't conflict even if that trigger runs multiple times). But that version of a wait is imprecise, especially if you're doing a 0 second wait (it often ends up waiting around 0.1-0.3 seconds).

Instead, we usually recommend using a timer as they are a lot more precise and will allow you to wait the minimal amount of time that the engine allows. The only downside is that it'll require an additional trigger to handle the timer expiration--and since "triggering unit" won't work in the timer expiration trigger, we'll need to use some globals to pass the data around between the triggers.

Fortunately, you can set up a simple stack for this. But you'll need a few variables:
  1. Research_Timer - Timer
  2. Research_Units - Unit array
  3. Research_UnitCount - Integer
  4. Research_LoopInteger - Integer
  • Research
    • Events
      • Unit - A unit Finishes research
    • Conditions
    • Actions
      • Set VariableSet Research_UnitCount = (Research_UnitCount + 1)
      • Set VariableSet Research_Units[Research_UnitCount] = (Triggering unit)
      • Countdown Timer - Start Research_Timer as a One-shot timer that will expire in 0.00 seconds
  • Expire
    • Events
      • Time - Research_Timer expires
    • Conditions
    • Actions
      • For each (Integer Research_LoopInteger) from 1 to Research_UnitCount, do (Actions)
        • Loop - Actions
          • Unit - Add Well Spring 08 to Research_Units[Research_LoopInteger]
          • Unit - Order Research_Units[Research_LoopInteger] to Undead Obsidian Statue - Activate Spirit Touch
      • Set VariableSet Research_UnitCount = 0
With this set-up, it'll end up being MUI (multi-unit instanceable)--so even if multiple units complete the research at the same tick, it'll add well spring and issue the order to each of them correctly.
 
Top