Amount of map Explored

TheSpoon

New Member
Reaction score
10
Is there any way of working out as a number,
how much of the map a player has explored?

Eg. 0.5 = half of the map has been explored

Thanks in advance!
 
No, I'm afraid this would be quite impossible. Atleast in my GUI and Editor knowledge.
 
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.
 
Hehe, I also began coding such a little library, but I think yours does fit better :p. (And mine is still unfinished)

JASS:
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 &gt; 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 &gt;= 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 &gt;= 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.

Well, use his.
You need NewGen for this code.
When you have NewGen, make a new trigger.
Convert it to custom text.
Copy the whole library code and replace everything in the new trigger.
Now you can use the Custom Script he mentioned.
Simply make a new action called Custom Script.
And now fill in what you want to do with the new "CalcExploredPercent(Player(0))" function.
 
I tried dling newgen, I didn't have much luck.
Then I tried making something myself in GUI.

No luck though, it doesn't work for some reason D:
Trigger:
  • Extra Explored
    • Events
      • Player - Player 2 (Blue) types a chat message containing -check as An exact match
    • Conditions
    • Actions
      • Set TempPoint = (Center of Region 316 &lt;gen&gt;)
      • For each (Integer A) from 1 to 127, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 95, do (Actions)
            • Loop - Actions
              • Set pointcheck = (TempPoint offset by (((Real((Integer A))) x 128.00), ((Real((Integer B))) x 128.00)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (pointcheck is masked for Player 2 (Blue)) Equal to False
                • Then - Actions
                  • Set TotalVision = (TotalVision + 1.00)
                • Else - Actions
              • Custom script: call RemoveLocation (udg_pointcheck)
      • Set Extra = (Integer((((TotalVision / 12065.00) x 100.00) + 0.50)))
      • Game - Display to (All players) the text: ((String(Extra)) + %)
      • Custom script: call RemoveLocation (udg_TempPoint)


How it works:
Temppoint is bottom left corner,
I counted how many squares on the map
Add 1 for each square that is revealed
Divide by the number of squares,
Turn it into integer percentage
And then display it as text.


EDIT: Problem solved,
I used the one mentioned above, but I broke it up a bit.
I guess all that was a bit too much in 0 seconds.
Credit given to those who helped!
 
Yea, that was the point I tried to evade with my code.. I wanted to calculate the amount of map explored all 5 seconds, but in intervals. But as I'm lazy and this doesn't seem to be very important, let it be :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top