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

simple question

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
When i look at spells from other people they ALWAYS use "casting unit " and "targeting unit" in a variable.

I understand that this must be done when there is a wait action or a second loop trigger, but not always right?

I always see things like this:
  • Set Power_Slam_Caster = (Triggering unit)
  • Unit - Cause Power_Slam_Caster to damage Power_Slam_Target, dealing Power_Slam_Damage damage of attack type Spells and damage type Normal
but why dont they do like this?:
  • Unit - Cause (Triggering unit) to damage (Targeting unit), dealing (500) damage of attack type Spells and damage type Normal
Edit: Ahh thanks now i finaly understand. that question botherd me hehe
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Using a value stored in a variable is faster than calling a function.

Using Triggering unit calls a function GetTriggerUnit() which then returns the unit.

If you need some value more than once, save it into a variable.

Like:
  • Set p1 = (Position of (Triggering unit))
  • Set i1 = (Level of (Ability being cast) for (Triggering unit))
  • Set r1 = (Life of (Triggering unit))
->
  • Set u1 = (Triggering unit)
  • Set p1 = (Position of u1)
  • Set i1 = (Level of (Ability being cast) for u1)
  • Set r1 = (Life of u1)
 
Status
Not open for further replies.
Top