Octagonal Area

Joker(Div)

Always Here..
Reaction score
86
How would you check if someone entered an octagonal area? I'm trying to avoid a high-frequency terrain check.
 
I found Vexorian made "GroupEnumUnitInPolygon", try to find it. I think u may put 0.5 seconds checkup.
 
Just create a function that outputs a region with an octagonal shape.

JASS:
function CreateOctagonalRegion takes real centerX, real centerY, real radius returns region

RegionAddCell() will add 32x32 cells to the region. Some math is required here. Will you be alright?

Use this region with TriggerRegisterEnterRegion()
 
I did some research in an attempt to make a universal function for any regular polygon you could want added to a region. This is what I came up with. It does leave some spots open unfortunately.

As a workaround, you can reduce CELL to 16 to remove all spots. This will make the function half as fast though.

RegionAddPolygon:
JASS:
library RegionFunctions

globals
	private constant real CELL = 32.
	private constant real HALF_CELL = 16.
endglobals

private function RegionAddGon takes region whichRegion, real x1, real y1, real apothem, real angle, real side returns nothing
	local real length = HALF_CELL
	local real width
	local real offset
	local real dx = Cos(angle)
	local real dy = Sin(angle)
	local real x
	local real y
	loop
		set width = side * length / apothem
		set offset = -.5 * width + HALF_CELL
		loop
			set x = x1 + length * dx - offset * dy
			set y = y1 + length * dy + offset * dx
			call RegionAddCell(whichRegion, x, y)
			exitwhen(offset >= .5 * width)
			set offset = offset + CELL
		endloop
		exitwhen(length >= apothem)
		set length = length + CELL
	endloop
endfunction

function RegionAddPolygon takes region whichRegion, real x, real y, real radius, integer polygons, real angle returns nothing
	local real apothem = radius * Cos(bj_PI / polygons)
	local real side = 2. * radius * Sin(bj_PI / polygons)
	local real arc = 2. * bj_PI / polygons
	loop
		exitwhen(polygons <= 0)
		call RegionAddGon(whichRegion, x, y, apothem, angle + arc / 2., side)
		set angle = angle + arc
		set polygons = polygons - 1
	endloop
endfunction

endlibrary


If anyone have any suggestions for improvement, I'd very much like your input.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is weird seeing a way more realistic users online number
  • The Helper The Helper:
    Happy Tuesday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top