System Cone Vision

Chewbalka

New Member
Reaction score
14
Cone vision system

Description:
This is a Cone Vision System, I could not find one here already so i made my own. A cone vision system changes the visual reach of each unit from a circle to a cone that is in front of there head. (Assuming they have ahead that faces forward)
Please give feedback, theres bound to be many things i forgot to talk about in this thread.
Let me know if i need to add/change anything because of the resource guidlines that i might have missed.

[video=youtube;oC8PAFdnsgE]http://www.youtube.com/watch?v=oC8PAFdnsgE[/video]
The text on the side shows what tiers are turned on, t1-t7. later that dissapears and the remaining text are large numbers they are unrelated. (For a fog system I created) Right, of course, on my way, of course.


Warnings:
  • Not for Unit Heavy Games
  • Made in NewGen (But was loaded in default worldeditor without errors)
  • Is not a spell



Features:
  • Its Multiplayer Compatible
  • Its MultiUnit Compatible // Works based off unit groups.
  • Its Environmentally friendly (Game Wise)
  • Flexible, Simple and in GUI



How many Units/Players?
This systems not for large unit heavy games my computer ran 24 units with no lag but 36 had small intervals of lag (That can be increased by editing). Its untested on Multiplayer but i assume it would be a shared 24 units over all players to run fine as the game would run the code for everyone no matter what. If its 24 Units per player that would be awesome & let me know.
I figured this would be used more in single player or games with 1-2 "Hero" like units anyway and as long as you specify what unit group you want it will probably run fine. (If its single player, choose units owned by player 1 instead of all units.)

Environmentally Friendly?
Units will not see Over/Past cliffs, but they will see in/Past Ditches if you don't use the terrain leveler tool they will see all terrain unless there is something like Rocks in the way. (Path blocking doodads) Water is path blocking but will not block vision.

How it Works:
In default the system works off a 7 Tier vision system (Which can be reduced for higher unit counts), It collects 7 points in front of each unit checks its pathing and then creates visibility modifiers at each point that passes the conditions, it deletes and recreates them every 0.50 seconds. (Default)


Installation Instructions:

1. Declare Variables:
  • VISCount int
  • VISGroup UnitGroup
  • VISLocation Point
  • VISTest Visibility Modifier (Array)


2. Copy Code: (Better to copy from attached Map)
Trigger:
  • Vision
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to ((Number of units in (Units owned by Player 1 (Red))) x 10), do (Actions)
        • Loop - Actions
          • Visibility - Disable VISTest[(Integer A)]
          • Visibility - Destroy VISTest[(Integer A)]
      • Custom script: call RemoveLocation (udg_VISLocation)
      • Custom script: call DestroyGroup (udg_VISGroup)
      • Set VISGroup = (Units of type Footman)
      • Unit Group - Pick every unit in VISGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
          • Set VISCount = (VISCount + 1)
          • -------- 1 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 50.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 150.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 50 to 100, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 2 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 100.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 225.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 100 to 200, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 3 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 200.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 300.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 200 to 310, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 4 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 310.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 400.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 310 to 475, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 5 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 475.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 400.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 475 to 600, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 6 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 600.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 480.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
          • For each (Integer A) from 600 to 850, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
          • -------- 7 --------
          • Custom script: call RemoveLocation (udg_VISLocation)
          • Set VISLocation = ((Position of (Picked unit)) offset by 750.00 towards (Facing of (Picked unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
                  • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
                • Then - Actions
                • Else - Actions
                  • Skip remaining actions
            • Else - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 550.00
              • Set VISTest[VISCount] = (Last created visibility modifier)
              • Set VISCount = (VISCount + 1)
      • Set VISCount = 1


Or The Jass Version

JASS:
function Trig_Vision_pathing takes nothing returns boolean
    if ( IsTerrainPathableBJ(udg_VISLocation, PATHING_TYPE_WALKABILITY) == true ) then
    	if ( IsTerrainPathableBJ(udg_VISLocation, PATHING_TYPE_FLOATABILITY) == true ) then
        	return true
    	endif
    endif
    return false
endfunction

function Trig_Vision_main takes nothing returns nothing
    local integer forLoopAIndex = 0
    local integer forLoopAIndexEnd = 0
    if ( IsUnitDeadBJ(GetEnumUnit()) == true ) then
        return
    else
    endif
    set udg_VISCount = ( udg_VISCount + 1 )
    // 1
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 50.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 150.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    set forLoopAIndex = 50
    set forLoopAIndexEnd = 100
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 2
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 100.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 225.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    set forLoopAIndex = 100
    set forLoopAIndexEnd = 200
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 3
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 200.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 300.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    set forLoopAIndex = 200
    set forLoopAIndexEnd = 310
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 4
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 310.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 400.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    call RemoveLocation (udg_VISLocation)
    set forLoopAIndex = 310
    set forLoopAIndexEnd = 475
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
            if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 5
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 475.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 400.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    call RemoveLocation (udg_VISLocation)
    set forLoopAIndex = 475
    set forLoopAIndexEnd = 600
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
            if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 6
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 600.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 480.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
    call RemoveLocation (udg_VISLocation)
    set forLoopAIndex = 600
    set forLoopAIndexEnd = 850
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
  	 if ( Trig_Vision_pathing () ) then
            set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), I2R(forLoopAIndex), GetUnitFacing(GetEnumUnit()))
        	call RemoveLocation (udg_VISLocation)
            if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
            else
                return
            endif
        else
        endif
        set forLoopAIndex = forLoopAIndex + 2
    endloop
    // 7
    call RemoveLocation (udg_VISLocation)
    set udg_VISLocation = PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 750.00, GetUnitFacing(GetEnumUnit()))
   if ( Trig_Vision_pathing () ) then
        	if ( ( GetTerrainCliffLevelBJ(udg_VISLocation) <= GetTerrainCliffLevelBJ(GetUnitLoc(GetEnumUnit())) ) )then
        else
            return
        endif
    else
        call CreateFogModifierRadiusLocBJ( true, GetOwningPlayer(GetEnumUnit()), FOG_OF_WAR_VISIBLE, udg_VISLocation, 550.00 )
        set udg_VISTest[udg_VISCount] = GetLastCreatedFogModifier()
        set udg_VISCount = ( udg_VISCount + 1 )
    endif
endfunction

function Trig_ConeVision_Actions takes nothing returns nothing
    local integer forLoopAIndex = 0
    local integer forLoopAIndexEnd = 0
    set forLoopAIndex = 1
    set forLoopAIndexEnd = ( CountUnitsInGroup(GetUnitsOfPlayerAll(Player(0))) * 7 )
    loop
        exitwhen forLoopAIndex > forLoopAIndexEnd
        call FogModifierStop( udg_VISTest[forLoopAIndex] )
        call DestroyFogModifier( udg_VISTest[forLoopAIndex] )
        set forLoopAIndex = forLoopAIndex + 1
    endloop
    call RemoveLocation (udg_VISLocation)
    call DestroyGroup (udg_VISGroup)
    set udg_VISGroup = GetUnitsOfPlayerAll(Player(0))
    call ForGroupBJ( udg_VISGroup, function Trig_Vision_main )
    set udg_VISCount = 1
endfunction

//===========================================================================
function InitTrig_ConeVision takes nothing returns nothing
    set gg_trg_ConeVision = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_ConeVision, 0.50 )
    call TriggerAddAction( gg_trg_ConeVision, function Trig_ConeVision_Actions )
endfunction


3. Set Day/Night Vision Radius to 100 for all units used your map/Will use the cone Vision.
For units that wont use it remember to shorten there vision to a reasonable amount.
Some units you will have to set larger some can be smaller, if it is to small the unit may not be able to see itself.


4. Set Proper Unit Group
Custom script: call DestroyGroup (udg_VISGroup)
Set VISGroup = (Units of type Footman)
Unit Group - Pick every unit in VISGroup and do (Actions)



Editing
Remember to read the code and create a understanding before asking questions.

Reducing Tier count:

Reducing the Tier count is reducing the amount of visibility modifiers (Default 7) it will reduce the shape of the cone but also increase performance of the game allowing more units to use the system.

Everything between the numbers (----- X -----) Is a tier
This is Tier Six:


Trigger:
  • -------- 6 --------
    • Custom script: call RemoveLocation (udg_VISLocation)
    • Set VISLocation = ((Position of (Picked unit)) offset by 600.00 towards (Facing of (Picked unit)) degrees)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
            • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
          • Then - Actions
          • Else - Actions
            • Skip remaining actions
      • Else - Actions
        • Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 480.00
        • Set VISTest[VISCount] = (Last created visibility modifier)
        • Set VISCount = (VISCount + 1)
    • Custom script: call RemoveLocation (udg_VISLocation)
    • Set VISLocation = ((Position of (Picked unit)) offset by (Real((Integer A))) towards (Facing of (Picked unit)) degrees)
    • For each (Integer A) from 600 to 850, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Terrain pathing at VISLocation of type Walkability is off) Equal to True
            • (Terrain pathing at VISLocation of type Floatability is off) Equal to True
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Terrain cliff level at VISLocation) Less than or equal to (Terrain cliff level at (Position of (Picked unit)))
              • Then - Actions
              • Else - Actions
                • Skip remaining actions
          • Else - Actions


You can completely Delete, I would suggest leaving at least 3.
you will then need to change these values.

For each (Integer A) from 600 to 850, do (Actions)
These are the numbers between the Tiers, each tier has a single point which a visibility modifier is created, these are for checking the group in between those points, If deleted they can cause vision "Jumps" which is when there is a vision modifier on both sides of a cliff but because the points are not on the cliff itself you will see on both sides. You can remove these if all your cliffs are large but you have tones of small pathing blocker doodads that can set these off.
An example of what you would change them to is:
Tier one point is 100 tier 2 point is 300, so it would be 100 to 300 Its important you do not put 0 to 200 because it will not run properly.


Set VISLocation = ((Position of (Picked unit)) offset by 600.00 towards (Facing of (Picked unit)) degrees)
This is the position of the point in which the visibility modifier is created, in this case the offset in front of the unit is 600. This number and the same of another tier are what make up the section above. To make a cone shape the first tier must be the smallest and the last tier must be the largest.


Visibility - Create an initially Enabled visibility modifier for (Owner of (Picked unit)) emitting Visibility from VISLocation to a radius of 480.00
This the radius of the visibility modifier (Really?), To make a cone shape the first tier must be the smallest and the last tier must be the largest.


For each (Integer A) from 1 to ((Number of units in (Units owned by Player 1 (Red))) x 10),
This does not have to be changed unless you increase the amount of tiers above 10, other words you can actually reduce it to the amount of tiers you have.

End of Reducing tier Count
 

Attachments

  • Cone Vision.w3x
    23.7 KB · Views: 504

TheLegend

New Member
Reaction score
10
pls instead of code tags use wc3 or jass tags, it just looks better [.wc3][./wc3][.jass][./jass] , just remove the dots. As for the system itself, its nice to finally have "normal" unit vision, the game will be so much realistic with this and you should try rewriting it to vJass or normal Jass, triggers are really, really slow cause they're always calling and splitting into functions if there is a new block
 

Chewbalka

New Member
Reaction score
14
Thanks i was looking all over for those tags, have been off this forum so long i forgot it.
Changing it to jass will be difficult, as of now i have no jass experience and I'm preparing for exams (Starting Tomorrow) so it will take quite a while.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
its really not that hard, seeing as this system wont have any other functions calling it and rather just run on its own, it should be a relatively easy switch, all you need to know is Get/Set... HUGE modifiers at the front of function calls when renaming from gui to jass, ie: GetTriggerUnit() = (Triggering unit); SetUnitUserData(unit, integer) = Set the custom value of (unit) to (integer)
its just a lotta typing to convert something like this, and it would no longer work with the normal editor...
btw very nice system i was suprised when it was GUI
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top