library CountExploration initializer Init
globals
private real MinX
private real MinY
private real MaxX
private real MaxY
private real tempx = 0
private player tempplayer
private real RESULT = 0
private integer CELLCOUNT = 0
endglobals
private function CalcHandler takes nothing returns nothing
local real y = MinY
loop
exitwhen y >= MaxY
if not IsMaskedToPlayer(tempx, y, tempplayer) then
set RESULT = RESULT + 1
endif
set y = y + 32
endloop
endfunction
function CalcExploredPercent takes player p returns real //Range 0-1
local real x = MinX
set RESULT = 0
loop
exitwhen x >= MaxX
set tempx = x
set tempplayer = p
call CalcHandler.execute()
set x = x + 32
endloop
return RESULT / I2R(CELLCOUNT)
endfunction
private function Init takes nothing returns nothing
set MinX = GetRectMinX(bj_mapInitialPlayableArea)
set MinY = GetRectMinY(bj_mapInitialPlayableArea)
set MaxX = GetRectMaxX(bj_mapInitialPlayableArea)
set MaxY = GetRectMaxY(bj_mapInitialPlayableArea)
set CELLCOUNT = R2I(((MaxX - MinX) * (MaxY - MinY)) / 1024)
endfunction
endlibrary
library Exploration initializer Init
globals
private constant integer MAX_PLAYERS = 1
private constant real STEP = 60.
private constant integer MAX_COLUMNS_PER_INTERVAL = 2
private constant real UPDATER_PERIOD = 0.1
private constant real AUTO_UPDATE_INTERVAL = 3.
endglobals
globals
private timer Updater
private timer AutoUpdater
private real START_X = 0.
private real START_Y = 0.
private real MAX_X = 0
private real MAX_Y = 0
private real momX = 0.
private real momY = 0.
private player array Players[MAX_PLAYERS]
private integer array Visible[MAX_PLAYERS]
private integer array Fogged[MAX_PLAYERS]
private integer All
endglobals
private function Update takes nothing returns nothing
local integer p
local integer i = 0
loop
exitwhen momX > MAX_X
set momY = START_Y
loop
exitwhen momY > MAX_Y
set p = 0
loop
exitwhen p > MAX_PLAYERS
if IsVisibleToPlayer(momX,momY,Players[p]) then
set Visible[p] = Visible[p] + 1
elseif IsFoggedToPlayer(momX,momY,Players[p]) and not IsMaskedToPlayer(momX,momY,Players[p]) then
set Fogged[p] = Fogged[p] + 1
endif
set p = p + 1
endloop
set momY = momY + STEP
endloop
set i = i + 1
set momX = momX + STEP
if i > MAX_COLUMNS_PER_INTERVAL then
return
endif
endloop
call BJDebugMsg("Visible: " + R2S((Visible[0]*100)/All) + "%")
call BJDebugMsg("Fogged: " + R2S((Fogged[0]*100)/All) + "%")
call BJDebugMsg("Masked: " + R2S(100.-(((Visible[0]+Fogged[0])*100)/All)) + "%")
call PauseTimer(Updater)
call Exploration_OrderTimerStart.execute()
endfunction
private function AutoUpdate takes nothing returns nothing
local integer i = 0
loop
exitwhen i > MAX_PLAYERS
set Visible<i>=0
set Fogged<i>=0
set i = i + 1
endloop
set momX = START_X
set momY = START_Y
call PauseTimer(AutoUpdater)
call TimerStart(Updater,UPDATER_PERIOD,true,function Update)
endfunction
public function OrderTimerStart takes nothing returns nothing
call TimerStart(AutoUpdater,AUTO_UPDATE_INTERVAL,false,function AutoUpdate)
endfunction
private function Init takes nothing returns nothing
local integer p = 0
loop
exitwhen p > MAX_PLAYERS
set Players[p] = Player(p)
set p = p + 1
endloop
set START_X = GetRectMinX(bj_mapInitialPlayableArea)
set START_Y = GetRectMinY(bj_mapInitialPlayableArea)
set MAX_X = GetRectMaxX(bj_mapInitialPlayableArea)
set MAX_Y = GetRectMaxY(bj_mapInitialPlayableArea)
set All = R2I((MAX_X-START_X)/STEP) * R2I((MAX_Y-START_Y)/STEP)
set AutoUpdater = CreateTimer()
set Updater = CreateTimer()
call TimerStart(AutoUpdater,AUTO_UPDATE_INTERVAL,false,function AutoUpdate)
endfunction
endlibrary</i></i>
JASS:library CountExploration initializer Init globals private real MinX private real MinY private real MaxX private real MaxY private real tempx = 0 private player tempplayer private real RESULT = 0 private integer CELLCOUNT = 0 endglobals private function CalcHandler takes nothing returns nothing local real y = MinY loop exitwhen y >= MaxY if not IsMaskedToPlayer(tempx, y, tempplayer) then set RESULT = RESULT + 1 endif set y = y + 32 endloop endfunction function CalcExploredPercent takes player p returns real //Range 0-1 local real x = MinX set RESULT = 0 loop exitwhen x >= MaxX set tempx = x set tempplayer = p call CalcHandler.execute() set x = x + 32 endloop return RESULT / I2R(CELLCOUNT) endfunction private function Init takes nothing returns nothing set MinX = GetRectMinX(bj_mapInitialPlayableArea) set MinY = GetRectMinY(bj_mapInitialPlayableArea) set MaxX = GetRectMaxX(bj_mapInitialPlayableArea) set MaxY = GetRectMaxY(bj_mapInitialPlayableArea) set CELLCOUNT = R2I(((MaxX - MinX) * (MaxY - MinY)) / 1024) endfunction endlibrary
Requires Newgen. Usage:
Trigger:
- Custom Script: set udg_TempInteger = CalcExploredPercent(Player(0))
Player(0) being Player 1 (Red), Player(1) being Player 2 (blue), etc.
This script checks for black mask, not fog of war.