• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Avoiding waits with local variables

Level 25
Joined
Jun 5, 2008
Messages
2,573

The Problem


This is an example i created due to the fact i have seen hundreds of spells which use waits.

The solution

This shows a simple example of how to make GUI spells with wait MUI with the usage of local variables.

The method

This consist of 4 steps:
  • declaring local variables for every global variable you are going to use
  • setting global variable to desired values
  • setting local variable values to global variable values
  • setting global variable values to local variable values

To declare a local variable just make a custom script which declares it.
Example
local *type* *name*

All global variables have a *udg_* + *name* prefix infront of them.
Example:
Target = udg_Target
Drain_value = udg_Drain_value

Local Variable Types

JASS:
effect // special effect
real // real value
integer // integer value
unit // unit
string // string
group // unit group
force // player force
trigger // trigger
boolean // boolean value(true or false)
rect // regiion
timer // a timer

And more, but i think these will prove sufficent for any spell.
The example spell is a simple spell which is MUI yet it uses waits.
Ther trigger is:

  • Malefice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Malefice
    • Actions
      • Custom script: local unit c
      • Custom script: local unit t
      • Custom script: local real value
      • Custom script: local effect e
      • -------- declaring local variables --------
      • -------- --- --------
      • Set Caster = (Casting unit)
      • Set Target = (Target unit of ability being cast)
      • Set Drain_value = (15.00 + (10.00 x (Real((Level of (Ability being cast) for (Casting unit))))))
      • Special Effect - Create a special effect attached to the overhead of (Target unit of ability being cast) using Abilities\Spells\NightElf\shadowstrike\shadowstrike.mdl
      • Set Effect = (Last created special effect)
      • -------- --- --------
      • Custom script: set c = udg_Caster
      • Custom script: set t = udg_Target
      • Custom script: set value = udg_Drain_value
      • Custom script: set e = udg_Effect
      • -------- Setting local variable values to the global variables values --------
      • -------- --- --------
        • Do Multiple ActionsFor each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Wait 2.00 seconds
            • -------- --- --------
            • Custom script: set udg_Caster = c
            • Custom script: set udg_Target = t
            • Custom script: set udg_Drain_value = value
            • -------- Fetching the local variables values and setting them into global variables --------
            • -------- --- --------
            • Unit - Cause Caster to damage Target, dealing Drain_value damage of attack type Spells and damage type Normal
            • Unit - Set mana of Target to ((Mana of Target) - Drain_value)
            • Unit - Set mana of Caster to ((Mana of Caster) + Drain_value)
            • Unit - Set mana of Caster to ((Life of Caster) + Drain_value)
            • Special Effect - Create a special effect attached to the origin of Caster using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
            • Special Effect - Destroy (Last created special effect)
      • Custom script: set udg_Effect = e
      • Special Effect - Destroy Effect


An example spell is also attached.
Hope anybody finds this tutorial useable, i made it to show newbies how to make MUI spells in GUI which use waits.
 

Attachments

  • example.w3x
    20 KB · Views: 79
Top