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

[Trigger] Local Variables

Status
Not open for further replies.
Level 5
Joined
Nov 21, 2014
Messages
151
Heya! I have a problem, I'm pretty new to locals, and I was wondering, can I reference the same local variable between two triggers? Or can I merge the triggers? (Two events :/) If someone could help me out, that'd be great!:thumbs_up::thumbs_up:

  • MarkofSuffering
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mark of Suffering
    • Actions
      • Custom script: local unit udg_MarkedUnit
      • Set MarkedUnit = (Target unit of ability being cast)
      • Special Effect - Create a special effect attached to the overhead of MarkedUnit using war3mapImported\Blood Presence.mdx
      • Animation - Change MarkedUnit's vertex coloring to (100.00%, 20.00%, 20.00%) with 0.00% transparency
      • Wait 10.00 seconds
      • Animation - Change MarkedUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
      • Special Effect - Destroy (Last created special effect)
      • Custom script: set udg_MarkedUnit = null
  • DrainOnHit
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to MarkedUnit
    • Actions
      • Unit - Set life of DamageEventSource to (DamageEventPrevAmt + (Life of (Triggering unit)))
And I might not need to make the second one local since it uses an indexer and triggering unit, but I would still like to know how :)
 
Level 14
Joined
Nov 30, 2013
Messages
926
Why you need to reference the local variable from a global variable?

Probably the global variable will not become null since the custom script only deals setting the local one null.
Merging the local variable from the global variable won't help, they only simply create a new variable I guess.
 
Level 5
Joined
Nov 21, 2014
Messages
151
Sooooo, how do I do it then? You can probably read what my abilty does from those triggers, you mark a unit, and when an other unit deals damage to the marked unit it has 50% lifesteal. (And some visuals but those don't matter)
 
Level 14
Joined
Nov 30, 2013
Messages
926
Sooooo, how do I do it then? You can probably read what my abilty does from those triggers, you mark a unit, and when an other unit deals damage to the marked unit it has 50% lifesteal. (And some visuals but those don't matter)

Like TriggerHappy said, you need to use global variable, hashtable, gamecache, or etc to transfer them into an another function.

If multiple players have access through that function, use global array variable, hashtable or gamecache (Which their parents will be the player's number).
 
Level 5
Joined
Nov 21, 2014
Messages
151
Like TriggerHappy said, you need to use global variable, hashtable, gamecache, or etc to transfer them into an another function.

If multiple players have access through that function, use global array variable, hashtable or gamecache (Which their parents will be the player's number).

I have no clue what "hashtable or gamecache" are, but i can do an array with Variable[player number of (owner of MarkedUnit)]

How to use globals with wait, and still have it be MUI?
 
Level 14
Joined
Nov 30, 2013
Messages
926
How to use globals with wait, and still have it be MUI?
JASS:
local integer a 
set a = *(Player number of (Owner of (Target unit of ability being cast)) )*
set udg_MarkedUnit[a] = *(Target unit of ability being cast)*
//End of the function after bypassing the wait command.
set udg_MarkedUnit[a] = null
Convert that into GUI since I stopped making maps.
As I heard from someone before, local variable don't get overwritten when someone is reinitializing the trigger.

Gamecache are somewhat like a save which allows you to transfer the data (items & current heroes) into an another map. It's pretty much common for making campaign maps. However, this will not worked on Online. (LAN/Battle.net)

Hashtable are similar to Gamecache. I don't use them very often before.
 
Level 5
Joined
Nov 21, 2014
Messages
151
JASS:
local integer a 
set a = *(Player number of (Owner of (Target unit of ability being cast)) )*
set udg_MarkedUnit[a] = *(Target unit of ability being cast)*
//End of the function after bypassing the wait command.
set udg_MarkedUnit[a] = null
Convert that into GUI since I stopped making maps.
As I heard from someone before, local variable don't get overwritten when someone is reinitializing the trigger.

Gamecache are somewhat like a save which allows you to transfer the data (items & current heroes) into an another map. It's pretty much common for making campaign maps. However, this will not worked on Online. (LAN/Battle.net)

Hashtable are similar to Gamecache. I don't use them very often before.

Heya! Thanks for helping me out this much!!! But I have one small problem ( think) I did what you told me, but I only get the life when the enemy hits me too, this might be because I use "DamageEventPrevAmt" and I don't actually know what this does... Also, did I do the condition correctly? here is my trigger:
  • DrainOnHit
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to MarkedArray[a]
    • Actions
      • Unit - Set life of DamageEventSource to ((DamageEventPrevAmt x 0.50) + (Life of DamageEventSource))
 
Level 14
Joined
Nov 30, 2013
Messages
926
Heya! Thanks for helping me out this much!!! But I have one small problem ( think) I did what you told me, but I only get the life when the enemy hits me too, this might be because I use "DamageEventPrevAmt" and I don't actually know what this does... Also, did I do the condition correctly? here is my trigger:
  • DrainOnHit
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to MarkedArray[a]
    • Actions
      • Unit - Set life of DamageEventSource to ((DamageEventPrevAmt x 0.50) + (Life of DamageEventSource))
Local variables can't be transferred into an another trigger so you didn't use the condition correctly. You can change the conditions into this:

  • Conditions
    • DamageEventTarget Equal to MarkedArray[0] //Player 1
    • DamageEventTarget Equal to MarkedArray[1] //Player 2
    • DamageEventTarget Equal to MarkedArray[2] //Player 3
    • //And so on...
 
Level 5
Joined
Nov 21, 2014
Messages
151
Local variables can't be transferred into an another trigger so you didn't use the condition correctly. You can change the conditions into this:

  • Conditions
    • DamageEventTarget Equal to MarkedArray[0] //Player 1
    • DamageEventTarget Equal to MarkedArray[1] //Player 2
    • DamageEventTarget Equal to MarkedArray[2] //Player 3
    • //And so on...

Well I assume you use the Conditions or, so that any of those fire of the trigger right?
 
Status
Not open for further replies.
Top