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

[Trigger] Revealing units in Fog of War

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
So, I have this trigger:

  • Sense Calc
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • ((Picked unit) has buff Sense ) Equal to False
            • Then - Actions
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
            • Else - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Set CreatedUnit = (Last created unit group)
              • Unit - Kill (Random unit from CreatedUnit)
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
WHAT THIS DOES: A unit has an Aura, with a really long range. The range goes beyond it's own sight range. The Aura only effects enemy/neutral units. So, after that, if a unit has the buff that the Aura gives off, I create a dummy unit that has 200 sight at the point of the ENEMY unit.

However, it is not MPI compatible. To make it such, I'd have to make a new trigger for each player. What makes this challenging to come up with a solution for is there's no way to find out what player is actually generating the buff, to my knowledge.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I don't understand your trigger. If the first random unit you pick from your unit group doesn't have buff, then you destroy 2 groups and point... if it has buff, you create some random unit and then you copy the UnitsOnMap group into CreatedUnit group and kill random unit from that group... what's the reason for that?
Not to mention... your unit group does not differentiate between allies and enemies, it picks all units, so when you pick unit from this unit group which has buff, some random unit from that unit group dies - which may turn out to be even your own unit as that is in the unit group as well.

If the created unit is unit with locust, then it will stay there, as you did not add it anywhere.
This system will never work, the way you have it and to make it work with dummies... I think it will be a lot more complicated to do all things correctly and on top of that make it MPI.

Also, creating unit groups is a heavy process, more so if you pick all unit in map (which may be quite a lot when the map is finished and iterating through each unit to find out if it has buff... that's a lot), so it may be better for you to create 1 unique unit group which will permanently hold in it all picked (neutral/enemy) units - you pick those units once at map initialization and then through another trigger - unit enters (playable map area) you add newly created units and with "Unit dies" you remove them from your unit group.
 
Level 12
Joined
May 20, 2009
Messages
822
You didn't really help me solve my problem.

I'm aware of all the other issues with this trigger, and they are all a super-easy fix. I'm just too lazy to do them. I haven't needed to work on this trigger until now. I just finished remaking all my other triggers, but this one is really tricky.

The real issue here is making it MPI without having to have 12 different triggers. Once that's done, I can fix everything else.

This is also going into a melee mod, not something like Azeroth Wars. In melee, there's no more then MAYBE 70-100 units (Not including buildings, assuming 1v1) at one time. It won't be that bad.
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
There is no way to check which unit the aura comes from, so instead of checking units with sense buff, you should check the units around sensers.

This is only MPI, 1 unit per player.

  • SENSE LEARN
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to SenseAbility
    • Actions
      • Set SENSERUNIT[(Player number of (Owner of (Learning Hero)))] = (Learning Hero)

  • SENSE VISION
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SENSERUNIT[(Integer A)] Not equal to No unit
            • Then - Actions
              • -------- If Senser Unit of player integer A is a valid unit --------
              • Set TempPoint = (Position of SENSERUNIT[(Integer A)])
              • Unit Group - Pick every unit in (Units within 4000.00 of TempPoint) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Equal to False
                      • ((Picked unit) is Mechanical) Equal to False
                      • ((Picked unit) is alive) Equal to True
                      • (((Picked unit) belongs to an enemy of (Player((Integer A)))) Equal to True) or ((Owner of (Picked unit)) Equal to Neutral Passive)
                      • ((Picked unit) is visible to (Player((Integer A)))) Equal to False
                    • Then - Actions
                      • Set TempPoint2 = (Position of (Picked unit))
                      • Unit - Create 1 Dummy Sense Unit for (Player((Integer A))) at TempPoint2 facing 0.00 degrees
                      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
Dummy timed life should be less than or equal to trigger period.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
It is easy to convert this to MUI with little modifications.

1)In first trigger add learning units to a unit group instead of using a variable.

2)In second trigger instead of looping throught 1 to 12 pick all units inside that group variable

Last of all, you need to do something so that there won't be multiple dummies created for a player near same unit.
 
Level 12
Joined
May 20, 2009
Messages
822
It is easy to convert this to MUI with little modifications.

1)In first trigger add learning units to a unit group instead of using a variable.

2)In second trigger instead of looping throught 1 to 12 pick all units inside that group variable

Last of all, you need to do something so that there won't be multiple dummies created for a player near same unit.

1 - "Learning Unit" does not work for non-hero units.
3. That's what the buff was for, if a unit already had the buff, regardless of how many units with the ability is near that unit, it would still only spawn 1 unit =p
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
1 - "Learning Unit" does not work for non-hero units.
3. That's what the buff was for, if a unit already had the buff, regardless of how many units with the ability is near that unit, it would still only spawn 1 unit =p

1)Than pick every units at the start of the map, if the picked unit has sense ability add unit to SenserGroup.Also when a unit enters map and if entered unit has sense ability add this unit to group.

3)I see, however we have buff owner problem again so this is not an option now.
 
Level 12
Joined
May 20, 2009
Messages
822
I think this is how it would be done:


  • Sense Unit Enters
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to SenseGroup
  • Sense Calc Test
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SenseUnit[(Integer A)] Not equal to No unit
            • Then - Actions
              • Unit Group - Pick every unit in SenseGroup and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Equal to False
                      • ((Picked unit) is alive) Equal to True
                      • ((Picked unit) belongs to an enemy of (Player((Integer A)))) Equal to True
                      • ((Picked unit) has buff Sense ) Equal to True
                    • Then - Actions
                      • Set UnitPosition = (Position of (Picked unit))
                      • Unit - Create 1 Dummy Sense Unit for (Player((Integer A))) at UnitPosition facing (Position of (Picked unit))
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Custom script: call RemoveLocation(udg_UnitPosition)
                    • Else - Actions
            • Else - Actions
  • Sense Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from SenseGroup


The Periodic Event / Unit Removal usually needs to be at least 1 second, or else a LOT of lag will be made. I had that issue when making the original trigger.

EDIT: Doesn't seem to work.
EDIT2: Sense unit is not being set to anything, but after disabling that condition nothing still happens.
EDIT3: It would appear that " Unit - Create 1 Dummy Sense Unit for (Player((Integer A))) at UnitPosition facing (Position of (Picked unit))" cannot actually create the unit. I'm assuming it has something to do with it can't spawn it for the player...

So, here's the trigger again since I did some changes:

  • Sense Calc Test
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseTempInit) from 1 to 12, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Player + (String(SenseTempInit))) //For debug purposes
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • SenseUnit[(Integer A)] Not equal to No unit
              • Then - Actions
                • Unit Group - Pick every unit in SenseGroup and do (Actions)
                  • Loop - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • ((Picked unit) is A structure) Equal to False
                        • ((Picked unit) is alive) Equal to True
                        • ((Picked unit) has buff Sense ) Equal to True
                        • Or - Any (Conditions) are true
                          • Conditions
                            • ((Picked unit) belongs to an enemy of (Player(SenseTempInit))) Equal to True
                            • (Owner of (Picked unit)) Equal to Neutral Hostile
                            • (Owner of (Picked unit)) Equal to Neutral Victim
                            • (Owner of (Picked unit)) Equal to Neutral Extra
                            • (Owner of (Picked unit)) Equal to Neutral Passive
                      • Then - Actions
                        • Set UnitPosition = (Position of (Picked unit))
                        • Unit - Create 1 Dummy Sense Unit for (Player(SenseTempInit)) at UnitPosition facing (Position of (Picked unit))
                        • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                        • Custom script: call RemoveLocation(udg_UnitPosition)
                      • Else - Actions
              • Else - Actions
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
Because at vision trigger we are not dealing with array indexes anymore, we are using unit groups.

You need 3 seperate triggers
1)At the start of map, find all units with Sense ability and add these units to unit group.
2)When a unit enters map, if unit has Sense ability, add this unit to unit group
3)Pick every unit in our SenseGroup, which stores senser units, and then check the units near these units for vision

  • SENSE INIT
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Banish for (Picked unit)) Greater than 0
            • Then - Actions
              • Unit Group - Add (Picked unit) to SenserGroup
            • Else - Actions
  • SENSE ENTER
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Level of Banish for (Entering unit)) Greater than 0
    • Actions
      • Unit Group - Add (Entering unit) to SenserGroup

  • SENSE VISION
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SenserGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • Set SenserUnit = (Picked unit)
          • Unit Group - Pick every unit in (Units within 4000.00 of TempPoint) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is Mechanical) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • (((Picked unit) belongs to an enemy of (Owner of SenserUnit)) Equal to True) or ((Owner of (Picked unit)) Equal to Neutral Passive)
                  • ((Picked unit) is visible to (Owner of SenserUnit)) Equal to False
                • Then - Actions
                  • Set TempPoint2 = (Position of (Picked unit))
                  • Unit - Create 1 Footman for (Owner of SenserUnit) at TempPoint2 facing 0.00 degrees
                  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
 
Level 12
Joined
May 20, 2009
Messages
822
Because at vision trigger we are not dealing with array indexes anymore, we are using unit groups.

You need 3 seperate triggers
1)At the start of map, find all units with Sense ability and add these units to unit group.
2)When a unit enters map, if unit has Sense ability, add this unit to unit group
3)Pick every unit in our SenseGroup, which stores senser units, and then check the units near these units for vision

  • SENSE INIT
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Banish for (Picked unit)) Greater than 0
            • Then - Actions
              • Unit Group - Add (Picked unit) to SenserGroup
            • Else - Actions
  • SENSE ENTER
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Level of Banish for (Entering unit)) Greater than 0
    • Actions
      • Unit Group - Add (Entering unit) to SenserGroup

  • SENSE VISION
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SenserGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • Set SenserUnit = (Picked unit)
          • Unit Group - Pick every unit in (Units within 4000.00 of TempPoint) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is Mechanical) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • (((Picked unit) belongs to an enemy of (Owner of SenserUnit)) Equal to True) or ((Owner of (Picked unit)) Equal to Neutral Passive)
                  • ((Picked unit) is visible to (Owner of SenserUnit)) Equal to False
                • Then - Actions
                  • Set TempPoint2 = (Position of (Picked unit))
                  • Unit - Create 1 Footman for (Owner of SenserUnit) at TempPoint2 facing 0.00 degrees
                  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)

You do not need those points, they add unneeded complexity.

Here are the working triggers:

  • Sensing Unit Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Archer
            • Then - Actions
              • Unit Group - Add (Picked unit) to SensingUnitGroup
              • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
            • Else - Actions
  • Sensing Unit Enters
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Picked unit)) Equal to Archer
        • Then - Actions
          • Unit Group - Add (Triggering unit) to SensingUnitGroup
        • Else - Actions
  • Sensing Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Picked unit)) Equal to Archer
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from SensingUnitGroup
        • Else - Actions
  • Sense Calc Test
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SensingUnitGroup and do (Actions)
        • Loop - Actions
          • Set SenseUnit = (Picked unit)
          • Unit Group - Pick every unit in (Units within 1000.00 of (Position of SenseUnit)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) has buff Sense ) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) belongs to an enemy of (Owner of SenseUnit)) Equal to True
                      • (Owner of (Picked unit)) Equal to Neutral Hostile
                      • (Owner of (Picked unit)) Equal to Neutral Victim
                      • (Owner of (Picked unit)) Equal to Neutral Extra
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                • Then - Actions
                  • Unit - Create 1 Dummy Sense Unit for (Owner of SenseUnit) at (Position of (Picked unit)) facing (Position of (Picked unit))
                  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                • Else - Actions
  • ((Picked unit) has buff Sense ) Equal to True
Can still be used, and it will prevent the spawning of unnecessary units. It won't prevent other players from picking up on the unit, if another player is giving them the buff.

This became a much bigger ability then I expected, but it was definitely worth it. +rep to you, Ceday. =)
 
Status
Not open for further replies.
Top