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

[General] Potion of Omniscience with pings that follow unit group

Status
Not open for further replies.
Level 11
Joined
Sep 11, 2013
Messages
324
Hi there!
I wanted to make an item which reveal the entire map for 12 seconds. If team 2 use that item, each team 2 must receive pings for each postion of team 1.
  • Omniscience Aluvians Pings
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Potion of Omniscience
      • ((Owner of (Hero manipulating item)) is in PG_TEAM2) Equal to True
    • Actions
      • Unit Group - Pick every unit in UG_TEAM1 and do (Actions)
        • Loop - Actions
          • Cinematic - Ping minimap for PG_TEAM2 at (Position of (Picked unit)) for 12.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
The trigger seems to work, but here is the problem.. How can i make that ping follow the position of TEAM1 every 1 second?
Right now, with this trigger, if TEAM1 move, the ping will remain in the same position and is not good because i want the ping to follow the TEAM1 for 12 seconds.

I tried this with my friend, but this is not MUI and will create problems if i spam the item 2 times in a row.
  • Omniscience Lixtrons Pings
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Potion of Omniscience
      • ((Owner of (Hero manipulating item)) is in PG_TEAM2) Equal to True
    • Actions
      • Trigger - Turn on Ping Every 1 Sec <gen>
      • Wait 12.00 seconds
      • Trigger - Turn on Turn off Ping <gen>
  • Ping Every 1 Sec
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UG_TEAM1 and do (Actions)
        • Loop - Actions
          • Cinematic - Ping minimap for PG_TEAM2 at (Position of (Picked unit)) for 1.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
  • Turn off Ping
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Trigger - Turn off Ping Every 1 Sec <gen>
      • Trigger - Turn off (This trigger)
Idk how to make this trigger efficient and without bugs..
Thanks for help!

Edit: I made a little mistake(I confused TEAM1 with TEAM2) in post and now i correct it, sorry
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Use Timers instead of a Wait.

A unit uses an item -> If unit belongs to Team 1 then -> Start PingTimer1 as a one-shot timer that will expire in 12.00 seconds -> Turn on PingTeam1 trigger

A unit uses an item -> If unit belongs to Team 2 then -> Start PingTimer2 as a one-shot timer that will expire in 12.00 seconds -> Turn on PingTeam2 trigger


PingTeam1 would be the Ping Every 1 Sec trigger except that it's setup to Ping all units in Team 2. You would have another trigger for Team 2 that would do the same thing except it would Ping all of the units in Team 1. You could also save yourself an additional trigger by using an If Then Else to manage this all in one trigger.

Then you create two more triggers that detect when either of these Timers expire:

PingTeam1Timer expires -> Turn off PingTeam1 trigger

PingTeam2Timer expires -> Turn off PingTeam2 trigger


When you Start a Timer that is already running it will simply reset that Timer. This is useful here since we can avoid the issue of having multiple Waits running at the same time that conflict with one another.


Also, this leaks a Point:
  • Cinematic - Ping minimap for PG_TEAM1 at (Position of (Picked unit)) for 12.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
(Position of (Picked unit)) will create a Point (also known as a Location) at the Position of the Picked unit that will never get removed and thus create a memory leak which can build up over time and hurt map performance. The solution is to create and use your own Point variable and manually remove it yourself.

So you would Set the Point variable to be equal to (Position of (Picked unit)), then reference the variable in your Ping action, and then use this Custom script to get rid of it, in that order:
  • Custom script: call RemoveLocation(udg_TheNameOfYourPointVariable)
 
Last edited:
Level 11
Joined
Sep 11, 2013
Messages
324
I didn't expect to receive a reply so quickly and I noticed that I wrote something wrong in the post above. (I confused TEAM1 with TEAM2) and now i correct it, sorry

Edit: I want to make it work for both teams, so i will try to create 2 timers.
 
Last edited:
Level 11
Joined
Sep 11, 2013
Messages
324
  • TEAM2 Use Omni
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Potion of Omniscience
          • ((Owner of (Hero manipulating item)) is in PG_TEAM2.) Equal to True
        • Then - Actions
          • Countdown Timer - Start PingTimer1 as a One-shot timer that will expire in 12.00 seconds
          • Trigger - Turn on PingTeam1 <gen>
        • Else - Actions
  • PingTeam1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UG_TEAM1 and do (Actions)
        • Loop - Actions
          • Set VariableSet TempLoc6 = (Position of (Picked unit))
          • Cinematic - Ping minimap for PG_TEAM2 at TempLoc6 for 1.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
      • Custom script: call RemoveLocation(udg_TempLoc6)
  • PingTeam1Timer expires
    • Events
      • Time - PingTimer1 expires
    • Conditions
    • Actions
      • Trigger - Turn off PingTeam1 <gen>
Is that all good?
I test it and work very good.
:peasant-thumbs-up-cheers:
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
You're making a couple of minor mistakes, here's how the triggers should look.

The Use Item trigger should be setup to work for both Teams:
  • Use Omni
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Potion of Omniscience
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Hero manipulating item)) is in PG_TEAM2.) Equal to True
        • Then - Actions
          • Countdown Timer - Start PingTimer1 as a One-shot timer that will expire in 12.00 seconds
          • Trigger - Turn on PingTeam1 <gen>
        • Else - Actions
          • Countdown Timer - Start PingTimer2 as a One-shot timer that will expire in 12.00 seconds
          • Trigger - Turn on PingTeam2 <gen>
Note: If a Unit that doesn't belong to PG_TEAM1 or PG_TEAM2 uses the Item then you should account for this in the Else - Actions part of the trigger.
Currently, the Else - Actions run as long as the Unit ISN'T in PG_TEAM2.

Your Custom Script is outside of the Loop - Actions which means you would only Remove a single TempLoc6 instead of all of them:
  • PingTeam1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UG_TEAM1 and do (Actions)
        • Loop - Actions
          • Set VariableSet TempLoc6 = (Position of (Picked unit))
          • Cinematic - Ping minimap for PG_TEAM2 at TempLoc6 for 1.00 seconds, using a Simple ping of color (100.00%, 0.00%, 0.00%)
          • Custom script: call RemoveLocation(udg_TempLoc6)
Your Timer Expires trigger is good.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Thank you for explanation and for the help!
For PingTeam2 - should i use the same TempLoc6 or a new one?
You can use the same variable. The issue with reusing variables happens under these circumstances:

1) You're referencing a Variable after a Wait action or after some kind of time delay. The delay in time creates a window of opportunity for another trigger to change the value of the Variable.

2) You have a trigger which has an Action that causes another trigger to run and insert it's Actions directly into the first trigger. This is a rare situation as most of the time triggers run in separate instances and aren't combined into one.

So, it's actually pretty safe to re-use variables as long as you avoid #1. The situation described in #2 is so rare that it almost feels wrong to to mention it since your map may not have any triggers with this issue. However, it's something to keep in the back of your mind if you experience any variable related issues.

When in doubt, create a new variable.
 
Last edited:
Status
Not open for further replies.
Top