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

[Solved] Why does my multi-carrion swarm auto cast?

Status
Not open for further replies.
Level 2
Joined
Dec 19, 2016
Messages
8
So I made an ability based on channel and made it to cast on a point. I created dummy unit with intervals who casted the modified carrion swarm ability, each with their own generic expiration timer every 0.3s.

The thing is, every first attack of the unit in the game will cast this ability, but this does not repeat.

How I made the ability:
Trigger A
The unit casts an ability
The certain ability is equal to the modded channel
Set variables for casting unit, target point, and casting unit position
Turn on the dummy creating trigger
Wait 1.5 sec
Turn off the dummy creating trigger

Trigger B
Every 0.3s of game time,
Play casting unit attack animation
Create 1 dummy unit at casting unit position
Order last created unit to carrion swarm to target point
Add 3s genetic expiration timer

What could have gone wrong? Is it a kind of leak, or the ability itself?

I'm sorry if I said anything wrong in this post, new to the Hive, like not even a day old. Thanks! :)

EDIT: I dunno what I did in the abilities without changing the triggers, but it stopped! But still, does this leak?

Untitled Trigger 005
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Moo[n]light Splitter
Actions
Set MS_caster = (Casting unit)
Set MS_point = (Target point of ability being cast)
Set MS_stand = (Position of (Casting unit))
Trigger - Turn on Untitled Trigger 002 <gen>
Wait 1.50 seconds
Trigger - Turn off Untitled Trigger 002 <gen>
Wait 0.10 seconds
Animation - Play MS_caster's stand animation

Untitled Trigger 002
Events
Time - Every 0.30 seconds of game time
Conditions
Actions
Animation - Play MS_caster's attack animation
Unit - Create 1 dummysplit for (Owner of MS_caster) at MS_stand facing Default building facing degrees
Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm MS_point
Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
 
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
It does leak, among other things.
  • You should avoid A unit Begins casting an ability event (in most cases) as it can be abused since this fires the trigger before manacost and cooldown are applied; use the event A unit Starts the effect of an ability instead.
  • I'd swap Casting unit for Triggering unit because it's slightly more efficient.
  • The points MS_point and MS_stand need to be removed via custom script to prevent them from leaking. To do this you need to type in call RemoveLocation(udg_YourVariableName) for both points. For more on leaks, check out these guides: Things That Leak, Complete list of things that leak, Memory Leaks. I also have this in the example triggers below.
  • This might be too advanced at the moment but I'd recommend using dynamic indexing to avoid using those dodgy waits. In the meantime, you could make your second trigger more efficient by creating a dummy and storing it in a variable before turning the trigger on. That way you won't be creating 5 dummies over the 1.5 second wait. Hopefully the triggers make more sense.
  • You probably don't need the second wait but you can remove that whenever. We can leave it for now.
  • This isn't really a problem with your triggers but an ability's name (as in the field Text - Name in the Object Editor) is never used in-game, so adding brackets is redundant. Yeah, I'm kinda OCD like that...
  • The triggers in their current state are not MUI (Multi-Unit Instanceability; allowing more than one unit to cast the same spell without "breaking" the trigger code) and neither are mine but that would be the next step and can be achieved using dynamic indexing. The other alternatives are to use hashtables or learn Jass.
Also, you can post your triggers between [TRIGGER][/TRIGGER] tags. I'd explain further but you seemed to have figured out how to copy triggers as text. There's this thread if you need it though: How to easily post triggers.

  • Test Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set MS_caster = (Triggering unit)
      • Set MS_point= (Target point of ability being cast)
      • Set MS_stand = (Position of MS_caster)
      • Unit - Create 1 dummy for (Owner of MS_caster) at MS_stand facing Default building facing degrees
      • Set MS_dummy = (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to MS_dummy
      • Trigger - Turn on Test Loop <gen>
      • Wait 1.50 seconds
      • Trigger - Turn off Test Loop <gen>
      • Wait 0.10 seconds
      • Animation - Play Caster's stand animation
      • Custom script: call RemoveLocation( udg_MS_point )
      • Custom script: call RemoveLocation( udg_MS_stand )
  • Test Loop
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Unit - Order MS_dummy to Undead Dreadlord - Carrion Swarm MS_point
 
Status
Not open for further replies.
Top