• 🏆 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!

[General] what is the right coordinates for spawning a barracks next to a town hall

Status
Not open for further replies.
Level 21
Joined
Mar 2, 2010
Messages
3,069
i am working on a project where heroes set up bases by building just the town hall. i want the barracks to appear at the right side of the town hall but not too far away. you are welcome to suggest the coordinates for the 2 farms, the arcane sanctum, the workshop and the altar.(i need some inspiration for where to place them.)
 
Level 9
Joined
May 21, 2014
Messages
580
W-Well I'm surely very busy to do this... Sorry :[ . But my suggestion remains though. Do it as if you're placing them in melee.

Set up computation and display triggers so that you'll know the exact distance from the town hall, then just do the math.
 
Level 9
Joined
May 21, 2014
Messages
580
it is not that easy as i can not see the coordinates in melee at all. trying to place the building in the editor only shows one of the offset coordinates. i also need suggestions on where to place the other buildings.
That's why I suggested triggering your computation and see it in-game. :p

Anyway, I could give you locations only though.

First of all, is it fixed, or the locations can be rotated? Locations are vital... For example the entrance for where your opponent can attack you is from north, then the barracks must be placed near there.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
the town hall can ble placed anywhere and i want the barracs to be to the right of it. (i already have a solution for when it is built on the right side of the map so all i need is the coordinates). i do not understand how coordinates is calculated at all in the point with offset trigger. (i tested it twice but both times it ended up either above or below the town hall). once i have the coordinates for the barracs i need suggestion for where the other buildings should be placed.(2 farms, 1 altar, 1 arcane sanctum and 1 workshop). the grphon aviary and towers is still build normally.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
as i wrote i do not understand how the coordinates are calculated so i really need help with calculating them. i am using the point with offset trigger and i will also use the point with polar offset trigger based on where on the map the town hall is built. there is still buildings to complete and as such i still have time to discuss this. please help me out.
 
Level 9
Joined
May 21, 2014
Messages
580
I don't have World editor right now...

But I think it's something to do with Triangles.
(Guys, correct me if my math is wrong.)

Before I give an example, what are you 'givens' in your trigger?
e.g. Distance from town hall, etc.

Again, I'm not sure if I understand you completely...
i do not understand how the coordinates are calculated so i really need help with calculating them.
What coordinates exactly? The coordinates where you need to place the building?
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
the coordinates where the building will need to be generated by the trigger in order to be placed correctly. i am using a trigger to place all buildings except chimera roost, grphon aviary, tauren totem, boneyeard and towers. town halls and other races`s town hall buildings, towers and chimery roosts, gryphin aviaries, tauren totems and bone yards is built. town halls is built by heroes and then generates base buildings while the other buildings are built in the regular way.
 
Level 9
Joined
May 21, 2014
Messages
580
the coordinates where the building will need to be generated by the trigger in order to be placed correctly. i am using a trigger to place all buildings except chimera roost, grphon aviary, tauren totem, boneyeard and towers. town halls and other races`s town hall buildings, towers and chimery roosts, gryphin aviaries, tauren totems and bone yards is built. town halls is built by heroes and then generates base buildings while the other buildings are built in the regular way.
can I see your trigger for barracks so I can 'base' it from that?
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
if you don't understand how to calculate coordinates then why don't you just use point with polar offset instead?
to get coordinates of a location, afaik you'll need to convert it from location using the
JASS:
set X = GetLocationX(YourLocVar)
set Y = GetLocationY(YourLocVar)
you can then add or substract the X or Y to make some distance.
just remember X is a horizontal line and Y is a vertical line.
 
Last edited:
Level 21
Joined
Mar 2, 2010
Messages
3,069
i need a flexible system because town halls can be placed anywhere on the map. once the town hall is built the other buildings spawn near it. the locations of the other buildings have to be calculated on the fly based on where the town hall is placed. i have tested it and know that it works but i need correct offset coordinates to get the buildings to appear in the right location relative to the town hall. please help me out.
 
Level 9
Joined
May 21, 2014
Messages
580
I think I have tried something similar to this one; the topic where I need to calculate placements so that units could move away just so I can properly put the structure in it's place. You need your complete data to be able to correctly compute these.

You need the exact numbers to determine the area of the building (the green texture that allows you to build if it's a correct terrain, and red if unable) + collision sizes of EACH building + the minimum range you want the structures to be apart from each other.

You need to dynamically create regions. Only by using checker triggers can you know the area of the structures.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
it can be done a lot simpler than that. my system is working as it is but i need the correct coordinates to place the buildings in the right area relative to the town hall. without that the buildings spawns in the wrong location. trees can be removed if they are in the way and nothing will be spawned above the town hall.
 
Level 4
Joined
Sep 13, 2014
Messages
106
1 Building unit = 64 normal units.

A farm = 1 unwalkable building unit in each direction from centre

A town hall = 3 unwalkable building units + 1 unbuildable building unit in each direction from centre

A barracks = a workshop = An arcane sanctuary = 2 unwalkable building units + 1 unbuildable building unit in each direction from centre

An altar = 1.5 unwalkable building units + 1 unbuildable building unit in each direction from centre.

Therefore, to place a barracks next to a town hall, you must go out 3+1+2+1 building units = 64 * 7 = 448 units.

You can do other calculations yourself.

You can count building units by placing in editor, enabling view of ground pathing, turning grid to small and count every second small grid line.

If you want to build buildings closer together, change the pathing map to that of another building. Specifically, you can change the pathing maps of the barracks etc to that of a blacksmith to remove the unbuildable building unit. Custom pathing map tutorial (not tested) http://world-editor-tutorials.thehelper.net/pathmaps.php
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
i did not get email about this response for some reason. this have nothing to do with pathing. this have to do with spawning buildings near the town hall. i just want to spawn each building after the town hall have completed construction. my current trigger works perfectly but i need the point with offset coordinates. please help me.
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
i need a flexible system because town halls can be placed anywhere on the map. once the town hall is built the other buildings spawn near it. the locations of the other buildings have to be calculated on the fly based on where the town hall is placed. i have tested it and know that it works but i need correct offset coordinates to get the buildings to appear in the right location relative to the town hall. please help me out.
that's exactly what I said.
Get the X & Y (the coordinates) of the town hall. you can then add or substract them and this one will be the new coordinates for the other buildings.
set them up where you want to put the buildings. Do experimenting which coordinates fit best to put them all together.
you're making it even more complicated for God's sake. This, unless I've misunderstood you completely from the beginning because your explanation is kinda confusing.
 
Level 9
Joined
May 21, 2014
Messages
580
there is one trigger per building. the coordinates shown when i place stuff is different from point with offset. point with offset moves the building either higher or lower on the grid based on wether i use x or y coordinates. i need a combination of both.
This is what I needed.
You need to test it in-game, because most things gets re-positioned just so that the structures are places correctly given the pathing and collision sizes they have in-game. Treat your world editor like a 99% accurate simulation of what you can see in-game.

You need to create triggers to display the point coordinates of what you needed in-game.
You need to extract values using triggers in-game.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
you've spent more time saying that you need the position than you have actually trying to resolve the issue. you literally could have just plugged in any number and tweaked it as needed. please put your brain into your work.
 
Level 4
Joined
Sep 13, 2014
Messages
106
I said, 448 units to the right, to place the barracks as close as you can to the town hall. To move it right 1 building unit, add 64 units. to move it vertically or horizontally to your heart's desire, add more multiples of 64 units.

If you cannot do the basic addition and/or multiplication to work out the coordinates required to place a building where you want it, you should not be here.

The tiny portion of my post about pathing maps was completely optional and was simply a relevant addition to my post.

If you really really want me to spell it out for you:

Place your town hall at (x,y)

Place your barracks at (x+448,y)

Place your arcane sanctum at (x+384, y-448)

Place your workshop at (x+384,y+448)

Place your altar at (x-416,y+32)

Place your first farm at (x-384,y+256)

Place your second farm at (x-384,y-192)

I don't know why I bothered.
 
Last edited:
Level 22
Joined
Aug 27, 2013
Messages
3,973
there is one trigger per building. the coordinates shown when i place stuff is different from point with offset. point with offset moves the building either higher or lower on the grid based on wether i use x or y coordinates. i need a combination of both.
Of course, it is different, it works just like Point with Polar Offset except that it is using coordinates if I get it right. Just use point with polar offset if you don't understand how to use point with offset.
Anyhow, your goal can be achieved without any of that. Get the coordinates like the ones ZerGreenOut has spelled out for you. Create them simply right there for each building.
 
Level 4
Joined
Sep 13, 2014
Messages
106
Or I guess, if you mean that you want to be able to work out the coordinates in-game, use these functions:

  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Town Hall
    • Actions
      • Game - Display to (All players) the text: New Town Hall is be...
      • Set townHall = (Constructing structure)
  • Untitled Trigger 002
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Not equal to Town Hall
    • Actions
      • Game - Display to (All players) the text: ((A building is being constructed at the relative coordinates to the town hall of X: + (String(((X of (Position of (Constructing structure))) - (X of (Position of townHall)))))) + ( Y: + (String(((Y of (Position of (Constructing structure))) - (Y of (Positi
They leak, but that shouldn't matter for testing purposes.

For easy copy/paste, use this function:

Code:
function Trig_Melee_Initialization_Func001C takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetConstructingStructure()) == 'htow' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Melee_Initialization_Actions takes nothing returns nothing
    if ( Trig_Melee_Initialization_Func001C() ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_001" )
        set udg_townHall = GetConstructingStructure()
    else
        call DisplayTextToForce( GetPlayersAll(), ( ( "A building is being constructed at the relative coordinates to the town hall of X: " + R2S(( GetLocationX(GetUnitLoc(GetConstructingStructure())) - GetLocationX(GetUnitLoc(udg_townHall)) )) ) + ( " Y: " + R2S(( GetLocationY(GetUnitLoc(GetConstructingStructure())) - GetLocationY(GetUnitLoc(udg_townHall)) )) ) ) )
    endif
endfunction

//===========================================================================
function InitTrig_Melee_Initialization takes nothing returns nothing
    set gg_trg_Melee_Initialization = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Melee_Initialization, EVENT_PLAYER_UNIT_CONSTRUCT_START )
    call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
endfunction
 
Last edited:
Level 21
Joined
Mar 2, 2010
Messages
3,069
there is no need to use variables in this case. one issue is that each time i save the map it becomes a little bit slower so i can only test it when i am going to save the map anyway. i therefore only save once a day. i set point with offset to 100,00 and 100,00 last night and then the barracks ended up to the right of the town hall but a bit lower.
 
Level 9
Joined
May 21, 2014
Messages
580
This is what I needed.
You need to test it in-game, because most things gets re-positioned just so that the structures are places correctly given the pathing and collision sizes they have in-game. Treat your world editor like a 99% accurate simulation of what you can see in-game.

You need to create triggers to display the point coordinates of what you needed in-game.
You need to extract values using triggers in-game.
if you are not going to help me and just troll you are welcome to stay away.

Oh my god? I am not trolling you. This is definitely true. *facedesk*
Oh well. It's up to you. I can't believe you saw that as trolling instead of informing you what's real...

i save the map it becomes a little bit slower so i can only test it when i am going to save the map anyway. i therefore only save once a day.

If only you had said this sooner...

Welp. :goblin_boom:
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
there is no need to use variables in this case. one issue is that each time i save the map it becomes a little bit slower so i can only test it when i am going to save the map anyway. i therefore only save once a day.
Nonsense. You can save a map infinitely and it should not take longer to save or perform worse in game. If it does that is a serious bug.

More likely any slowing is a result of you adding more content or your computer having to free used memory or pushing files out the file cache.
i set point with offset to 100,00 and 100,00 last night and then the barracks ended up to the right of the town hall but a bit lower.
Every 2*2 build area (size of melee farm) is 128*128 units. As such you will likely need a larger offset. Try something like 512 and 512 then reduce by 64 until it is in the right position. If you are afraid of saving your map for this then make a quick test map to find out the desired offset.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
i know that it is a serious bug.(it slows saving of the map and load times ingame). blizzard seem to be oblivious to it however. there is a lot of work remaining with adding the new gameplay mechanics so if you could find the coordinates for me it would save me a lot of time.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
i know that it is a serious bug.(it slows saving of the map and load times ingame). blizzard seem to be oblivious to it however. there is a lot of work remaining with adding the new gameplay mechanics so if you could find the coordinates for me it would save me a lot of time.
Well you have not stated the pathing sizes of the buildings or shown a diagram where you want them so one cannot really make such suggestions. In fact there are no perfect offsets because the offset would be based on the orientation of gold mine with respect to town hall.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
the size of the buildings is unchanged from basic warcraft 3. i want the barracks(or ancient of war or crypt) to be somewhat paralel to the town hall without being too close or too far away but the rest of the buildings i have no idea where to place.(workshop, arcane sanctum, 2 farms and an altar for the humans. spirit lodge, bestiary, altar and 2 pig farms for the orcs. ancients of wind and lore and moon well and altar for the night elves. slaughter house, temple of the damned, altar and nerubian ziggurat for undead.).
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
You will need to perform a transformation on any offset coordinates based on the orientation of the gold mine due to gold mines being able to be any direction from a starting Town Hall.

What I recommend you do is open a new map in the editor, place them how you want them (which we do not know as you have not shown us) and then make a trigger that reports the unit type name and its relative offset from the town hall. These are your offsets you use and then rotate based on the gold mine orientation.

We cannot do it for you as you have not given us enough details to get a useful result.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
what gold mine? i help people by checking stuff out in the actual game.
In melee your town hall is always placed next to a gold mine. Since what you have listed are melee buildings I assumed you still had the melee economy. No where in your first post did not make it clear, or even mention, the state of the gold mine.

In any case, as people suggested before, place the buildings how you want them and then use a trigger to read out the offsets. No guessing, minimal work and completely customizable to how you want them.
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
i am using a different resource system similar to the law faction in faction war where each town hall generate 10xtown hall level. that system is working perfectly but i could possibly fine tune it a bit but that is beside the point. i do not know how to calculate offsets however so it would be much better if someone that knows could help me out.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
i do not know how to calculate offsets
Get the position of the building at its desired placement and then subtract it by the position of the town hall (where you want point (0,0) to be). In other words...

Offset = (FarmX - TownHallX, FarmY - TownHallY)

Mathematically you are subtracting the Farm (or other building) position vector by the Town Hall position vector to get the difference vector from Town Hall to Farm. One can think of it as centering the entire coordinate system on the Town Hall.
 
Last edited:
Level 9
Joined
May 21, 2014
Messages
580
that is math i never learned because i never had math beyond 6th grade and as such i have no idea what you are talking about.(i never learned advanced math like that). please calculate the coordinates for meg.

I see.

Let's have this table.
Let % be your Town Hall.
Code:
+----------x----------
| +------------------+
| | 1 2 3 4 5 6 7 8 9|
| |1                 |
| |2                 |
| |3                 |
y |4                 |
| |5          %      |
| |6                 |
| |7                 |
| |8                 |
| |9                 |
| +------------------+

Now let's place a Farm named F.
Code:
+----------x----------
| +------------------+
| | 1 2 3 4 5 6 7 8 9|
| |1                 |
| |2                 |
| |3                 |
y |4                 |
| |5          %      |
| |6                 |
| |7        F        |
| |8                 |
| |9                 |
| +------------------+

As you can see, Farm F is located just south west of Town Hall %.
The coordinates of % is (6, 5).
The coordinates of F is (5, 7).
Basic will tell you that coordinates are in the form of (x, y).
Now to calculate the distance, you need this formula.
Let:
A = x coordinate of %
B = y coordinate of %
C = x coordinate of F
D = y coordinate of F
Code:
distance = sqrt( (C - A)^2 + (D - B)^2 )
sqrt is square root, ^2 is an exponent.

So, you need to actually want to know what C and D, right?

----

Okay, what if I want to know the coordinates of the building I wanted to place?
Let's take this sample again.
Code:
+----------x----------
| +------------------+
| | 1 2 3 4 5 6 7 8 9|
| |1                 |
| |2                 |
| |3                 |
y |4                 |
| |5          %      |
| |6                 |
| |7        F        |
| |8                 |
| |9                 |
| +------------------+
I wanted to play a Workshop W.
Let's review our given.
point of % = (6, 5)
distance of % and W = 3 units (assuming you want this distance)
the angle where the distance goes to = 135 degrees

In Trigonometry, You have SOH CAH TOA, a formula again in actuality.
Code:
sine THETA = OPPOSITE / HYPOTENUSE
cosine THETA = ADJACENT / HYPOTENUSE
tangent THETA = OPPOSITE / HYPOTENUSE
I've drawn something for you. About the trigo thing I'm saying.
pzfrU.png


So from here, you need to compute for the ADJACENT and OPPOSITE.
Deriving from the SOH CAH TOA formulae...
Code:
OPPOSITE = (sine THETA) * HYPOTENUSE
ADJACENT = (cosine THETA) * HYPOTENUSE
But wait, the angle is in 135 degrees. We want to get the actual angle as displayed in the drawing. We know that the angle from 0 (East) to 180 (West) is a full 180 degrees. So we will derive our angle...
Code:
180 - 135 = THETA
THETA = 45 degrees
So, in summary, the coordinates of W is (A [+-] ADJACENT, B [+-] OPPOSITE).
[+-] is either addition or subtraction, depending on what side of the Cartesian plane the point is located. Currently, the center of this is the TOWN HALL %.

Correct me if I am wrong somewhere guys. Also elaborate more on confusing parts that I just posted. For the Topic Starter, I'm sure this is a lot to take in, feel free to ask questions.
 
Last edited:
Status
Not open for further replies.
Top