The Auto-cast problem

Status
Not open for further replies.
Level 1
Joined
Jan 2, 2023
Messages
15
The tutorials deal with auto-casting abilities using either unit is attacked / ability is being cast event.
This works nice if the unit in question feels threatened. "Inner fire" and "Raise dead" appears to be working fine if the enemy units are just "passing by" (they are issued a move to point command using triggers). But the "Curse" dummy ability wouldn't trigger, unless a unit becomes a target of attack ("feel threatened").


I think there are several ways to trigger a "Curse" auto-cast here:
  • Make a unit feel threatened (using a simple AI command or something like this)
  • Get an auto-casting ability that targets and triggers on every passing enemy
  • Trigger and check on each unit attack if we can cast an ability or not (extremely power hungry)
  • Add a damaging aura (dealing close to 0 points of damage) on each enemy unit (undesirable)
  • Attack a friendly unit from afar (doesn't work if the acquisition range is lower than a distance to the attacking tower)
  • Play around with a "Channel" ability (don't have enough knowledge to make it work)
  • Add auto-casting units to related groups, then check each 10 seconds whether they should attack or not (extremely performance hungry)
  • Use one of the above mentioned spells, "Inner fire", catch it using triggers, then pick an enemy in a group if it is present, then create a dummy unit / order cast, then cleanup (highly undesirable)

Since I'm creating a TD map with ~1000 possible towers and ~1'500 enemies present, limiting the amount of triggers (and the code therein) is preferable.
What would you recommend?
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,620
Find an autocast ability that works well, I imagine something like Slow would have the appropriate AI, and then use that on all of your Towers that cast spells. Then you can cast the real spell using a Dummy unit:
  • Storm Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt (Autocast)
    • Actions
      • Set Variable DummyPoint = (Position of (Triggering unit))
      • Unit - Create 1 Dummy Unit for (Triggering player) at DummyPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_DummyPoint)
      • Set Variable Dummy = (Last created unit)
      • Unit - Add a 0.50 second Generic expiration timer to Dummy
      • Unit - Add Storm Bolt (Dummy) to Dummy
      • Unit - Order Dummy to Human Mountain King - Storm Bolt (Target unit of ability being cast)
So Storm Bolt (Autocast) is based on Slow with a 0.001 second duration and will be used by your Tower. Storm Bolt (Dummy) is the actual Storm Bolt ability that will be cast in response by the Dummy unit.

The Dummy unit should be based on the Locust with these settings changed: Model: None, Shadow: None, Attacks Enabled: None, Movement Type: None, Speed Base: 0. This will allow it to cast spells instantly.

The Storm Bolt (Dummy) ability should have 999999 Cast Range, 0 Mana Cost, and 0 Cooldown. Always check to make sure the ability doesn't have any Requirements or incorrect Targets Allowed that will prevent it from casting.

Ideally, you would have a unique Dummy unit for each Player and reuse that whenever possible, instead of constantly creating new ones.
 
Last edited:
Level 1
Joined
Jan 2, 2023
Messages
15
Thanks for your input and your propositions.
I was thinking that the most popular auto-cast ability would trigger properly, but "curse" won't trigger unless the unit is a target of an attack. So far i have tried arrows, slow, faerie fire, curse.
Surprisingly: "Minion" works well even for a unit that does not have attack enabled and is not a target of a current attack. Unless you are targeting a summoned or a mechanical unit, in that case the unit can't auto-cast on it.

I like the idea of reusing a single dummy for abilities that allow it. But it won't work well for channeled abilities. Polluting the game by creating X dummy units doesn't look great, but the unit expiration timer should deal with it fine. Furthermore, since we are talking Tower Defense style map, having a unit with no attack and just a single spell ability (like blizzard) triggered by an auto-cast triggering dummy spell (in that case "Minion") seems fine.
 
Status
Not open for further replies.
Top