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

Wait action wont work!

Status
Not open for further replies.
Level 8
Joined
Feb 11, 2016
Messages
232
Actions after "Wait" are skipped, if I remove "Wait" aren't. Usually work but in this trigger won't whatever I do.
United217.png
United218.png

Effects aren't done, it's just an explanation I'm still working on it.
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
The actions aren't exactly being skipped. The cause is that (Target unit of ability being cast) doesn't work after waits, which means you are attempting to perform actions on "null".

Local variables can only be used with JASS code, which means you have to use custom script actions. Also, they must be the first thing to be declared/done in your actions. Since you'll be using a local var in GUI, a global variable is required in order to reference the local var data (target unit).

I suggest that you read the following thread in order to also understand what shadowing variables is.

upload_2019-1-19_8-52-11.png


  • Custom script: local unit udg_tmpUnit = GetSpellTargetUnit()
  • -------- Special Effect --------
  • Wait 2.00 seconds
  • Unit - Set life of tmpUnit to (Max life of tmpUnit)
  • Wait 2.00 seconds
  • Unit - Cause (Triggering unit) to damage tmpUnit, dealing ((Max life of tmpUnit) x 0.80) damage of attack type Spells and damage type Normal
  • Custom script: set udg_tmpUnit = null
I'm not sure if it's necessary to null shadow variables, but I'd take the safe way.

There are some other problems related to your trigger which I'd like to point out.
  1. The event you chose is not really the best, because players could simply order a unit to cast that spell, and interrupt them from casting it afterwards. Meaning that it won't consume mana, nor will the spell go into cooldown state, but the trigger will still be executed normally.
  2. The special effect will stay there "forever".
  3. There's a point/location leak, because the special effect action is creating a new point, but it's never destroyed. I suggest that you attach the effect to the target unit instead, or destroy the point right after creating the effect with the help of a variable.
  4. Waits aren't precise, and are based on real time instead of game-time.
Anyway, here's the final result (with waits)
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Curse
    • (Unit-type of (Target unit of ability being cast)) Not equal to UNIT_A
    • (Unit-type of (Target unit of ability being cast)) Not equal to UNIT_B
    • (Unit-type of (Target unit of ability being cast)) Not equal to UNIT_C
  • Actions
    • Custom script: local unit udg_tmpUnit = GetSpellTargetUnit()
    • Custom script: local effect udg_tmpSFX
    • Special Effect - Create a special effect attached to the chest of tmpUnit using Abilities\Spells\Orc\SpiritLink\SpiritLinkTarget.mdl
    • Custom script: set udg_tmpSFX = bj_lastCreatedEffect
    • Wait 2.00 seconds
    • Unit - Set life of tmpUnit to (Max life of tmpUnit)
    • Wait 2.00 seconds
    • Unit - Cause (Triggering unit) to damage tmpUnit, dealing ((Max life of tmpUnit) x 0.80) damage of attack type Spells and damage type Normal
    • Special Effect - Destroy tmpSFX
    • Custom script: set udg_tmpUnit = null
    • Custom script: set udg_tmpSFX = null
Oh, don't forget to create the global special effect variable.

EDIT: I'm attaching a test map to this post
 

Attachments

  • test.w3x
    18.3 KB · Views: 35
Last edited:
Status
Not open for further replies.
Top