• 🏆 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] Show invisible units using trigger

Status
Not open for further replies.
Level 7
Joined
Nov 19, 2007
Messages
253
Hello everyone,

I have this problem i made this abillity which detects all enemy units with less than 30% health around unit and gives vision of those enemy units to player but i have a problem when i use:
  • Unit - Grant shared vision of (enemy unit) to (Owner of Unit)
this wont show units that are invisible i can only see them on minimap, i thought using faerie fire to be cast on that unit but if there is more than 1 it could mess up.. anyone got any idea how to fix this ?

EDIT: found solution with faerie fire if anyone is intrested heres code

Find the Pray - dummy abillity does nothing just tooltip.
Spell Book Find - disabled spellbook contains "Find the Pray (Movement bonus)".
Find the Pray (Movement bonus) - endurance aura just with movement speed bonus (5 levels (1 level does nothing, 2-5 level gives movement speed).
Detect Invisible(Find the Pray) - faerie fire.
Find the Pray (target) - farie fire buff.
  • Find the Pray Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Find the Pray
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Find the Pray for (Learning Hero)) Equal to 1
        • Then - Actions
          • Unit - Add Spell Book Find the Pray to (Learning Hero)
          • Unit - Set level of Find the Pray (Movement bonus) for (Learning Hero) to 5
          • Set FindThePrayUnitGroup[2] = (Units of type Peasant)
        • Else - Actions
  • Find the Pray
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set FindThePrayUnitGroup[0] = (Units in (Entire map) matching ((Level of Find the Pray for (Matching unit)) Greater than 0))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FindThePrayUnitGroup[0]) Not equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in FindThePrayUnitGroup[0] and do (Actions)
            • Loop - Actions
              • Set FindThePrayUnit = (Picked unit)
              • Set FindThePrayPoint[0] = (Position of (Picked unit))
              • Set FindThePrayUnitGroup[1] = (Units in (Entire map) matching ((((((Matching unit) is A Hero) Equal to True) and ((Percentage life of (Matching unit)) Less than or equal to 30.00)) and (((Region centered at FindThePrayPoint[0] with size (6000.00, 6000.00)) contains (Matching unit)) Equal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in FindThePrayUnitGroup[1]) Not equal to 0
                • Then - Actions
                  • Unit Group - Pick every unit in FindThePrayUnitGroup[1] and do (Actions)
                    • Loop - Actions
                      • Unit - Grant shared vision of (Picked unit) to (Owner of FindThePrayUnit)
                      • Unit Group - Add (Picked unit) to FindThePrayUnitGroup[2]
                      • Set FindThePrayUnitGroup[3] = (Units of type Footman)
                      • For each (Integer A) from 1 to (Number of units in FindThePrayUnitGroup[1]), do (Actions)
                        • Loop - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (FindThePrayVictim[(Integer A)] is in FindThePrayUnitGroup[3]) Equal to False
                            • Then - Actions
                              • Set FindThePrayVictim[(Integer A)] = (Random unit from FindThePrayUnitGroup[1])
                              • Unit Group - Add FindThePrayVictim[(Integer A)] to FindThePrayUnitGroup[3]
                            • Else - Actions
                      • For each (Integer A) from 1 to (Number of units in FindThePrayUnitGroup[1]), do (Actions)
                        • Loop - Actions
                          • Set Point[1] = (Center of (Entire map))
                          • Unit - Create 1 Dummy for (Owner of FindThePrayUnit) at Point[1] facing Default building facing degrees
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Custom script: call RemoveLocation(udg_Point[1])
                          • Unit - Add Detect Invisible(Find the Pray) to (Last created unit)
                          • Unit - Order (Last created unit) to Night Elf Druid Of The Talon - Faerie Fire (Picked unit)
                      • Custom script: call DestroyGroup(udg_FindThePrayUnitGroup[3])
                  • Unit - Set level of Find the Pray (Movement bonus) for FindThePrayUnit to ((Level of Find the Pray for FindThePrayUnit) + 1)
                • Else - Actions
                  • Unit - Set level of Find the Pray (Movement bonus) for FindThePrayUnit to 1
              • Unit Group - Pick every unit in FindThePrayUnitGroup[2] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in FindThePrayUnitGroup[1]) Equal to False
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from FindThePrayUnitGroup[2]
                      • Unit - Remove Find the Pray (target) buff from (Picked unit)
                      • Unit - Deny shared vision of (Picked unit) to (Owner of FindThePrayUnit)
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_FindThePrayUnitGroup[1])
              • Custom script: call RemoveLocation(udg_FindThePrayPoint[0])
        • Else - Actions
      • Custom script: call DestroyGroup(udg_FindThePrayUnitGroup[0])
EDIT 2: one question does this leaks?
  • Set FindThePrayUnitGroup[0] = (Units in (Entire map) matching ((Level of Find the Pray for (Matching unit)) Greater than 0))
(Entire map) <<< this part
 
Last edited:
Status
Not open for further replies.
Top