Jump to content
Asophix

Trivia - Why Buildings Are Misplaced in the Shk Editor

Recommended Posts

Behind the scenes In the original SHK Editor there is a weird quirk, when it comes to displaying buildings.

Even not long after its release, people complained about the Engineer's Guild being off by one tile, when rotated east. Even though this itself is an easily fixable problem, delving into the buildings list reveals that almost every building has a whole slew of corrections applied on top. When adapting the Editor for the Legends buildings, all buildings got vastly different dimensions, so all corrections had to be painstakingly found out and updated. 

Still, the in-game Map Editor in SH2 & SHL is able to effortlessly rotate buildings. Is the math behind it so complex and difficult? What could cause this mismatch in HicRic's interpretation? The answer lies in the anatomy of a building.

See, building footprints starting with SH2 are slightly more complex than for example in SHC, as buildings are comprised of two components:

  • Occupied Area: this footprint is reserved for the building itself, and can't be built on
  • Walkable Area: this footprint outlines a general area for peasants / units to approach the building. While still can't be built on, walkable areas can overlap for multiple buildings.

Since most buildings effectively carve out a rectangle or square, HicRic's interpretation was that this could apply to every building, and as such a rectangular 2D area was assigned to each of them. There are however buildings with more complex footprints, like the Keep, where the campfire's 4x4 area is attached to the occupied area of the building:

image.png.5f0bb7b018818ff076ed007f52e71c10.png

Going further with the above theory, it seems that rotation around a center point always results in a consistent position, however it is almost never the case, if the building's footprint is not a perfect square and is included a walkable area. HicRic also realised this and implemented a correction system on top, which adjusts the building to its real position. This does not follow a pattern however and takes unjustified effort to implement.

What HicRic failed to account for, is the fact that the focal point of the rotation is the center of the occupied area, not the center of the building's effective rectangle footprint. See how the yellow point is about two tiles away compared to the real point of rotation, visibly misplaced:

image.png.3d0202e8e2a8352b3245fb8339f14a58.png

In short, all buildings in SH2 & SHL have occupied areas each that assumes the shape of a rectangle or square.

Using this knowledge, the brute force correction system can be dropped and building administration can become more intelligent, further improving invalid building placement checks and other related features.

Thanks for reading! 🙂 

Share this post


Link to post
Share on other sites

Well that makes a lot more sense. I always felt like it was a bit off. :classic_biggrin:

Share this post


Link to post
Share on other sites

  • Similar Topics

    • Introducing: the Stronghold Legends Ai Editor!

      Hello everyone! For some time now, @ Asophix has been working on refining and advancing the Stronghold Knights AI Castle Editor program, originally created to work with Stronghold 2. His intention is to create a program where the community can edit and create their own AI Castle Designs in Stronghold Legends. This is a truly historic moment and for the first time, you can now control aspects of Stronghold Legends which were previously never possible. The work far exceeds the orig

      in The Town Crier

    • Stronghold 2 Lord Editor Content Highlight

      Come one, come all! We have arrived to another milestone, as a new game's tough shell has been cracked open: Stronghold 2 has given its own Lord Editor! This version of the Legends Lord Editor has been adapted to SH2 and redesigned in its outlook. Alter the lords at your own leisure, while enjoying the generally darker atmosphere of SH2 with burgundy buttons and embellished parchment panels. Newfound additions to the editor are improvements in the design, as well as a lot

      in The Town Crier

    • Legends Lord Editor Released!

      Hello dear Lords and Ladies, I'm delighted to announce that Stronghold Legends has received another modding utility, the Community Lord Editor! 😄  This lightweight program allows you to view and tailor the Legends AI bot behaviours to your liking! Add Dietrich a few macemen to guard the Lord, or make Alfred launch sieges. Many things are possible now. The Lord Editor presents you the various lord attributes in a user-friendly way. If you need more information about a certain field

      in The Town Crier

    • Problems Creating Iron Mine on Map Editor

      Greetings, I'm currently stuck playing this game on an old laptop since my main computer crashed. I'm playing GOG Stronghold HD and decided to make a map myself. Problem is it won't allow me to paint irn on the map. Is there a certain elevation needed to place iron deposits? Everything else in the game seems to work fine except the editor when placing iron ore. Is there a stand alone editor I can try to create maps? ------------------ System Information ------------------    Operating

      in Stronghold 1

    • A map editor tutorial

      Now I'm sure others such as Lord_Vetka have made tutorials for this already, I have wanted to do this for a while, since the Stronghold 2 editor is my strongpoint. I hope these hints and tips help you out when creating your very own Stronghold 2 map. Whether it's Kingmaker, Free Build, a War Scenario or a Peace Scenario! Plus, the guide has pictures! :D   Key - Green = New topic Blue = Sub topic   Introduction The first thing you should know about the Stronghold 2 map editor is that n

      in Stronghold 2

×
×
  • Create New...