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

[MUI] Using a Global to Simplify

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2011
Messages
460
So I'm doing a lot of code where i have to do the call
JASS:
GetOwningPlayer(GetSpellAbilityUnit())
in GUI through Owner(CastingUnit) and I'm wondering if I store this value to a global variable through the gui
  • Set p = (Owner of (Casting unit))
if this makes the trigger not MUI. I really don't want to leave all those function calls as it's messy and not a good practice to have.
 
Owner of (Casting unit) ----> (Triggering player); it's the same and it procs faster.

You can use it, as long as you don't refer to it through another trigger, which will refer to the last saved value. However, if you create a dummy for that owner and add the dummy to a group, you can pick every unit in that group in the "other" trigger and the owner of picked unit will be the triggering player you want.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
also use trigger unit in that case because that also not changed till ur trigger end :p
if u dont want use any jass maybe the hashtable or array a potentional option too

example target[custom value of triggering unit] = ability target unit

since in trigger the triggering unit not changed then

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set Target[(Custom value of (Triggering unit))] = (Target unit of ability being cast)
      • Set Damage[(Custom value of (Triggering unit))] = 1000.00
      • Wait 2.00 seconds
      • -------- here still this variables same after wait even other unit cast ability --------
but warning, this only viable if u cant cast with same same time 2 ability :p
its just solution example when your unit after ability cast cant cast another ability until this ability is over, like omnislash, channel abilities, blinking etc

else unit group way better or linked list
 
Level 9
Joined
Apr 23, 2011
Messages
460
Here is the script being discussed.
  • Race GUI
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Race Selector
    • Actions
      • Set p = (Owner of (Casting unit))
      • Set pnum = (Player number of p)
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to pos_race[(Integer A)]
            • Then - Actions
              • Multiboard - Set the text for Multiboard item in column 2, row (pnum + 1) to pos_race_names[(Integer A)]
              • Unit - Remove Picker[pnum] from the game
              • Unit - Create 1 Hero_Selector[(Integer A)] for p at (Center of Player_Area[pnum]) facing Default building facing degrees
              • Set Picker[pnum] = (Last created unit)
              • Selection - Select Picker[pnum] for p
              • Custom script: set udg_p = null
              • Skip remaining actions
            • Else - Actions
If I use p as a common local variable, and continue to null it through my triggers, will it cause problem? I'm not using it for cross-trigger data allocation.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Here is the script being discussed.
  • Race GUI
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Race Selector
    • Actions
      • Set p = (Owner of (Casting unit))
      • Set pnum = (Player number of p)
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to pos_race[(Integer A)]
            • Then - Actions
              • Multiboard - Set the text for Multiboard item in column 2, row (pnum + 1) to pos_race_names[(Integer A)]
              • Unit - Remove Picker[pnum] from the game
              • Unit - Create 1 Hero_Selector[(Integer A)] for p at (Center of Player_Area[pnum]) facing Default building facing degrees
              • Set Picker[pnum] = (Last created unit)
              • Selection - Select Picker[pnum] for p
              • Custom script: set udg_p = null
              • Skip remaining actions
            • Else - Actions
If I use p as a common local variable, and continue to null it through my triggers, will it cause problem? I'm not using it for cross-trigger data allocation.

and instead nulling p just use variable instead
  • (Center of Player_Area[pnum])
and use call RemoveLocation(udg_yourvariablename) :p
 
Status
Not open for further replies.
Top