• 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.

Limiting trigger to occur only once till new one occurs

Status
Not open for further replies.
Level 2
Joined
Aug 22, 2020
Messages
18
Hello fellow Hivers,

I want to create a unit near ressurection stone when my hero enters a certain area, so I can use the stone for reviving them. But in my map I have three heroes, hence everytime I step on the area, a new unit is created.

I want to create only one unit near the stone that lasts till my heroes come to another area where the trigger is repeated (with different region). Then the unit is removed and a new one created in the current area.

Hope I am specific enough. Will appreciate any help :psmile:


e3eda3bf2a1e8f2ee93dad5268102ae8.png
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
How about creating a Spirit for each player at the start of the game, hiding them, and then moving/unhiding them whenever necessary:
  • Create Spirits
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set VariableSet ActiveUsers = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)).)
      • Player Group - Pick every player in ActiveUsers and do (Actions)
        • Loop - Actions
          • Set VariableSet TempPoint = (Center of (Playable map area))
          • Unit - Create 1 Spirit for (Picked player) at TempPoint facing Default building facing degrees
          • Set VariableSet Spirit[(Player number of (Picked player))] = (Last created unit)
          • Unit - Hide (Last created unit)
          • Custom script: call RemoveLocation (udg_TempPoint)
  • Enter Level 1
    • Events
      • Unit - A unit enters Level 1 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet TempPoint = (Center of Level 1 Res <gen>)
      • Unit - Move Spirit[(Player number of (Triggering player))] instantly to TempPoint
      • Unit - Unhide Spirit[(Player number of (Triggering player))]
      • Custom script: call RemoveLocation (udg_TempPoint)
  • Enter Level 2
    • Events
      • Unit - A unit enters Level 2 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet TempPoint = (Center of Level 2 Res <gen>)
      • Unit - Move Spirit[(Player number of (Triggering player))] instantly to TempPoint
      • Unit - Unhide Spirit[(Player number of (Triggering player))]
      • Custom script: call RemoveLocation (udg_TempPoint)
The TempPoint is used to clean up a Point leak. You should read up on Memory Leaks (Things That Leak).

Note that cleaning up leaks can help with map performance but it's not the end of the world if you leak here and there.

Variables:
Spirit = Unit (Array)
TempPoint = Point
ActiveUsers = Player Group
 

Attachments

  • Spirit Example.w3m
    17.9 KB · Views: 15
Level 2
Joined
Aug 22, 2020
Messages
18
Great!

I didn't manage to make the trigger the same way you posted (I don't know how to open the file you attached, it says "level info data missing or invalid" when I try to open in in editor), but it helped me to solve the basic problem for now via spawning and moving units as you proposed. Guess I'll figure it out in detail later, gonna read the resources in the meantime, but the example gave me a valuable insights.

I want to leave this thread open though as I would like to return there after some time to fix even the details.

Thank you!
 
Status
Not open for further replies.
Top