~ Forums of Enroth ~

An Enroth diehard fan community
 
HomeHome  ChatChat  FAQFAQ  SearchSearch  RegisterRegister  Log inLog in  
Latest topics
» [EN, RU][Offline] HoMM2 Tournament of the Landless 2017-2 (Турнир Безземельных)
by Orzie Today at 03:42

» [EN, RU][Offline] HoMM2 Treasure Hunt Tourney 2017 (Турнир Кладоискателей)
by Orzie Yesterday at 16:55

» [EN, RU][Offline] HoMM2 Main Tourney 2017 (Общий Турнир)
by Orzie Yesterday at 16:50

» What are you listening to?
by Daleron 2017-09-18, 03:07

» Enrothian Fan Art
by Orzie 2017-09-16, 02:44

» Currently open HoMM1/HoMM2 Tournaments!
by Orzie 2017-09-16, 02:33

» [EN, RU][Offline] HoMM2 Trade Guild Tourney 2017-2 (Турнир Торговой Гильдии)
by Orzie 2017-09-16, 02:05

Poll
"Wait" in HoMM2?
Yes
80%
 80% [ 44 ]
No
20%
 20% [ 11 ]
Total Votes : 55
Most Viewed Topics
H3SW: General Graphics discussion
Ragoon's Graphics For HoMM3SW
H3SW General Discussion
H3SW: Dwelling Development
H3SW Map List: Work in progress
Dervish Faction General Concept
Enrothian Fan Art
H3SW Recruitment Point - Enroth Needs You!
Серия книг "Земли Меча и Магии"
Heroes of Might and Magic 3: The Succession Wars - General info

Share | 
 

 How autoborder/autofixer works...

View previous topic View next topic Go down 
AuthorMessage
number128
Peasant
Peasant
avatar

Messages : 1
Quality Points : 0
Registration Date : 2017-04-29

PostSubject: How autoborder/autofixer works...   2017-08-15, 21:21

Hello! I need programming help with Heroes2 autoborder.

I'd want to ask if someone knows the rules for creating map borders in Heroes2 editor? I'll introduce briefly the problem:

Heroes 2 has several borders that connects different terrains, like in this screenshot:


The rules for connecting terrain are quite complicated but I have managed to implement it 100% correctly (though its not the most optimal way...). I've used a pattern matcher approach that scans all changed tiles and is looking for certain patterns to place borders. The implementation looks like this:

https://github.com/nullptr128/openheroes2/blob/master/src/Editor/Utils/AutoBorder/AutoBorder.ts

Example patterns for water can be found here:
https://github.com/nullptr128/openheroes2/blob/master/src/Editor/Utils/AutoBorder/WaterBorders.ts

And this works perfectly. There are no case where border will be placed wrong, as you can see:


However, in Heroes 2 there are some combinations, where its IMPOSSIBLE to generate border using these tiles, simplest example would be a 1x1 grass tile on ocean. Original Heroes2 editor can strip those situations, fixing tiles behind the scenes to make sure it can be borderized correctly. Original H2 editor does this perfectly 100% of time, and I am struggling for few days now to create such alghoritm.

Perhaps some of you guys played with that problem? How should this be addressed? I've tried to make pattern-based fixing but it looks like there are endless combinations of "wrong" borders. I've also tried to figure out some rules, while some of them are quite good (like a rule "any specific tile must be part of 2x2 tile block of same terrain" that fixes like 90% of bad tiles), but I believe that I am approaching problem in totally wrong way.

Here are some examples of invalid combinations that are impossible to borderize using h2 tileset:


If you want to play around with this, you can run the project:

1. Node.JS 6+ is required
2. git clone https://github.com/nullptr128/openheroes2
3. Move to cloned dir in console
4. npm install
5. npm run editor-dev

However this is not required as this is not really Heroes 2 specific problem, many tile-based games have there problems.
Back to top Go down
Unknown_Hero
Minotaur
Minotaur
avatar

Messages : 344
Quality Points : 40
Registration Date : 2015-09-06

PostSubject: Re: How autoborder/autofixer works...   2017-08-15, 23:31

Wow, a new Heroes 2 project, "OpenHeroes2". Great news. Very Happy
Welcome to the party.

Maybe Darmani should be able to help you, but you may have to wait a little before he goes through here.
Back to top Go down
Unknown_Hero
Minotaur
Minotaur
avatar

Messages : 344
Quality Points : 40
Registration Date : 2015-09-06

PostSubject: Re: How autoborder/autofixer works...   2017-08-23, 23:34

@number128

Maybe you should try to contact him by private message.

There is also an email address to join him in the last post of this thread.

Good luck. Smile
Back to top Go down
Darmani
Master Modder
Master Modder
avatar

Messages : 175
Quality Points : 32
Registration Date : 2014-12-27

PostSubject: Re: How autoborder/autofixer works...   2017-08-29, 18:44

You're right; it is very complicated.

You can trawl through the editor code: https://raw.githubusercontent.com/jkoppel/project-ironfist/master/src/raw_decompiled/EDITOR2W.c

I don't remember where exactly the logic for this is. You can look through everything that modifies gpMap.tiles .
Back to top Go down
 
How autoborder/autofixer works...
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» The Works of V.C. Andrews
» The Works of George R.R. Martin
» The Works of the Brontës
» The Works of L.M. Montgomery
» Complex Works of Hojyo Takashi.. [Many Diagram and CP]

Permissions in this forum:You cannot reply to topics in this forum
~ Forums of Enroth ~ :: General Board :: HoMM2 Discussion-
Jump to: