• 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.

[Trigger] Trigger doesn't spawn unit after tree dies

Level 16
Joined
Feb 9, 2024
Messages
30
Greetings! I am currently working on an ability using the basis of "Eat Tree" where upon consuming a tree, a treant spawns in its place. However, I'm having trouble with the treant spawn position, and I can't seem to get it to spawn at the tree location(the treant instead spawns in the middle of the map).

This is the code I have so far below:
1746916413332.png


I hope somebody could help me out on a way to trigger the position of the tree, as I am new to triggers.
Thank you!
 

Attachments

  • 1746916361196.png
    1746916361196.png
    21.1 KB · Views: 5

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,895
That seems to have done it, thank you very much!
To add onto what Chaosium said, all the casting Events need to be used with care. Here's how some of them work, as far as I can remember.

Begins casting:
This happens before any ability costs are paid. The unit has just started playing their "spell" animation and the ability button is tinted green. This Event is useful if you want to manually interrupt your own ability. It can be interrupted with a simple "Stop" order or any disabling effects.

Stops casting:
This will always occur after Begins casting. This will happen when the unit is no longer trying to cast the ability, regardless of whether the unit failed or succeeded in doing so.

Starts the effect of an ability:
This occurs when the ability is successfully cast and is generally the Event you want to use. So this is when the Mana Cost has been paid for, Cooldown has started, and the effects have begun, ie: Storm Bolt missile has come into existence.

Finishing casting an ability:
This one is not even guaranteed to run and should be avoided unless you're certain it will work. I think it all depends on the Ability type and the Caster's Art - Cast Point field. I believe it's mostly used to determine when a unit finishes a full channeling of an ability.


Regarding your use of certain Event Responses, (Casting unit) is unsafe to use after a Wait and I'm pretty sure that (Target of ability being cast) will not work at all after a Wait. Here's a link where you can read more about this:

With that in mind, here's a version of your trigger that will work with a Wait. It also avoids minor issues like memory leaks:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Your Ability
  • Actions
    • Custom script: local location udg_TempPoint
    • Set Variable TempPoint = (Position of target destructible of ability being cast)
    • Wait 1.00 game-time seconds
    • Unit - Create 1 Treant (Druid) for (Owner of (Triggering unit)) at TempPoint
    • Unit - Play (Last created unit)'s birth animation
    • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: set udg_TempPoint = null
    • Set Variable TempPoint = (Position of (Last created unit))
    • Special Effect - Create a special effect at TempPoint using...
    • Special Effect - Destroy (Last created special effect)
    • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: set udg_TempPoint = null
TempPoint is a Point variable that you would create yourself.

Lastly, please try to post your triggers instead of using screenshots. It makes life easier for all of us.
 
Last edited:
Top