Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: Building Positioning in Town Creation
Thread: Building Positioning in Town Creation
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 04, 2013 02:23 PM bonus applied by Corribus on 09 Aug 2013.
Edited by Silaneo at 20:35, 10 Aug 2013.

Building Positioning in Town Creation

Hi I decided to make this topic about building positioning for people who are or might want to create his own town.I will write just about changing building possition as there are other topics that tell how to create a town in general like this one :

Adding a town to replace the Conflux: A No-Coding Tutorial

First of all we need to know how buildings are positioned in the screen.The location is determined by two coordinates - X and Y coordinate.On the image below i switched the Mage Guild.def with a random yellow image.We can see how these coordinates work.



The X coordinate shows the number of pixels between the left city border and the left side of the image

The Y coodinate shows the number of pixels between the upper city border and the upper side of the image

As you can see on the image i wrote the decimal value of how many pixels there are beetwen the borders.How can we know how many there are and how can we change the values ? There are a few ways to do it :

1.Changing values in the exe file

We can go directly into the heroes3.exe file to change it.To do it we need to use any hex editor we can find online.Here's what you will see when you open heroes3.exe in hex editor



What interests us is the 6 bit sequence describing the building coordinates.In the above example i highlighted the bits responsible for Conflux's Mage Guild lv1.Now what do these bits stand for ?

- the first two bits represent the number of frames in the animation in hexadecimal value.Here we have 00 00 which means the building is not animated.If we wanted for example 30 frames we would write 1E 00 .I will write later how to change decimal values to hex values.

- the next two bits represent the X coordinate.Here we have CE 00.This means 206 in decimal value.If we wanted to give bigger numbers like 689 we would write B1 02 because 2B1 is that number.We must remember that the first number comes after the second.With practise it becomes easy

- the last two bits represent the Y coordinate.Here we have 3A 00 which means 58.We change the values the same way as before


We can calculate the values easily by using windows calculator.Just set in the options "programist calculator" and you will be able to switch between hex and dec values





Ok but now how to find which bits represent which buildings ? You need to find the first bit sequence that represent castle building which is 00 00 C3 02 A6 00.It should be at 0028AA0C adress ( the most left column ) but it may vary depending on heroes version.Every next 6 bits will represent next buildings.You can check the order by opening heroes3 in dissasembler ( like IDA program ) and looking
at 0068A3DC adress.It will look like this :




Or you can just use my building list I made for Conflux If you want to modify this town

Conflux Buildings Hex Values


2.Using VCMI

you can use VCMI to change the coordinates.The VCMI uses structures.json file to do that.Heres the part of structures.json file:



Here the VCMI uses decimal values so there's no need to change them to hex values.You can see x,y and z values to change.The x and y values are said coordinates and z value is a values that shows which building is over other building.Buildings with higher z values "cover" the lower values

structues.json is one of many files one needs to create to make a city.Its good to download finished vcmi town to see how its organised.You can check how town's jsnon files work here : VCMI Town Format

The best and easiest way to create a town with VCMI is just to modify the existing vcmi town by changing these numbers and image paths



3.using ERM

I dont know anything about ERM so i cant tell you anything how it works but I found an info how to change the posisions using the ERM function.I guess it should also be here

Function to change building position:

!!VRy1:S0; //city (e.g. Castle)
!!VRy2:S5; //building ID (e.g Tavern)

!!VRy6:S2; //frames num in new def
!!VRy3:S250; //new x
!!VRy4:S200; //new y

!!VRy5:Sy1 *44 +y2 *6 +6859276;

!!UN:Cy5/2/y6;
!!VRy5:+2;
!!UN:Cy5/2/y3;
!!VRy5:+2;
!!UN:Cy5/2/y4;



Well that would be it.From my point of view its best to try to mod with VCMI,you wont get an error from thin air(or at least it will be unlikely^^), but if you want you can also try to mod in other ways

I hope it will be helpful and that this topic will be updated because there is still many things i dont know and also the ways for modding are always changing










 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 08, 2013 07:32 AM
Edited by fabien at 08:00, 08 Aug 2013.

Thanks a lot! This is just what I needed! I have followed what you said, and tried to position one of the building of my town to replace the conflux. Then I launched the game to check it.The building was at the right place, but I have one BIG issue:

When I move the mousse on the town screen, the all town gets "black" except the first dwelling... And when I click anywhere on this "black part" that cover all the screen, it opens the panel of the building that I am trying to replace...Moreover, the yellow things that is supposed to surround my new building is not displayed.

Do you know what's wrong?

Here is a picture of a part of my town to sow you what is wrong: http://postimg.org/image/w51aiddc7/

Thanks!  

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 08, 2013 03:07 PM
Edited by Silaneo at 15:59, 08 Aug 2013.

This looks to me like a problem with TOEL and TZEL files.Probably you still didnt modify them and TOEL image in the city has stretched itself to fit the def file and this makes the screen black when highlighing it.Match these files with the def and lets see if this works.In the link i gave in this post there is an instruction where and how to modify TOEL/TZEL files.Also pls write what resolution is the def you're working on

EDIT : BTW In these kind of situations when TOEL file (yellow hightlight) doesnt match and darkens/creates colour patterns etc. its easy to turn off this effect by making the whole toel file pitch black.If i remember well it was 8 bit black colour (000000).You can try something like this to check it.Of course its just temporary solution as we still need to at least to match TZEL file ( building area file) with the def

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 09, 2013 12:54 AM
Edited by fabien at 07:24, 09 Aug 2013.

Thanks for your help

I am convince it comes from the files you mentioned but I did modified them: I have followed the instructions you gave in the link. I did this before your nice tutorial. But, I must have missed something...

The files I am working on are made with PS, recorded in BMP 24 bits, the resolution of all my files is 800x374.

I tried to do it again with a yellow square just like in your example: I have the same issue...

EDIT: I don't get it.... I feel sorry to ask but: do you think that you could upload your example files? (def, toel and tzel + the bmp you used for the def).

I also did what you said, i made my toel full black. the result was positive: no more black effect all over the town screen.But of course, the problem is still here.

I know two issues in my process:

1. I read the other tutorial again, and I know that there is something that i didn't do, because I don't know how to do it: "Make sure you save these as indexed files using the H3 palette even" Could it be this?

2. With Photoshop, when I create something (let's say something black) on a cyan background, the border of this black object will extend on the cyan background making it a little darker(the cyan will become a little black while the black object will be come a little cyan on its borders. The separation between the object and the background is soften by Photoshop...Microsoft Paint would not bother to do this...

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 09, 2013 07:48 AM

Quote:
the resolution of all my files is 800x374.


You mean all the images you use for defs are 800x374 ? Well If so this will cause problems.Its cool to try to set all image coordinates to 0 and use these resolution images but unfortunately the game wont see the images that are "below" the images on the top.Well I cant write more,I'll have more time when i come back home in a few hours.Just try to use smaller images for now (just as big to fit the building size )and set the coordinates accordingly.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 09, 2013 08:24 AM
Edited by fabien at 11:08, 09 Aug 2013.

Oh I don't want to ruin your productivity . I know what I mean,  I am at work too .

I just did a small def, and same size toel and tzel. Then I kept the hex at 0, pretending that I want my building to appear on the top left corner of the screen. And this is what result I have on the top left corner:

The town screen no longer gets black. Seconfly I can open the building by clicking on the building AND the cyan part. There is more, the building is not visible anymore: the TOEL or TZEL are  yellow now (the color i have chosen to do the TZEL)

See the pic of my building in the top left corner: http://postimg.org/image/sf7ikwkzb/

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 09, 2013 03:35 PM
Edited by Silaneo at 15:39, 09 Aug 2013.

Yea,such colour pattern which i was writing about earlier is typical when something's wrong with TOEL/TZEL files,its the same as this darkening stuff just different scale.See If both TOEL and TZEL files are set as indexed images.And also use the colour red210/green180/blue110 for these images.This should help If all else is right I'll give you an example files for Mage guild lv 1 here : Mage Guild Lv1 files

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 10, 2013 03:18 AM

ok, i ould like to but, I don't know what you mean by "indexed".

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 10, 2013 08:08 AM

You just need to change the colour mode in which the image is displayed.It looks like that in Photoshop



If there is RGB checked just change it to "indexed"

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted August 10, 2013 09:01 AM
Edited by Warmonger at 09:01, 10 Aug 2013.

Quote:


Are you really sure that posting screenshot of a code is the best thing to do? This way no one can copy-paste it, at least.
____________
The future of Heroes 3 is here!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 10, 2013 09:58 AM

Warmonger said:
Quote:

Are you really sure that posting screenshot of a code is the best thing to do? This way no one can copy-paste it, at least.


Well this topic is just about positioning the buildings so i thought the town based example is best for it.There was no point in copy/ pasting it anyway There are too many json.files to write about here.But you're right this part is not much informative as a whole so i just added a link where to find more infos

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 11, 2013 04:36 AM
Edited by fabien at 05:27, 11 Aug 2013.

Thanks silaneo,

Now no more strange black or yellow things theer is progress. But when I put the mousse on the bulding, the TOEL displays over the bulding picture. The cyan is not considered as tansparent by the game.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 11, 2013 10:34 AM
Edited by Silaneo at 10:35, 11 Aug 2013.

Check color table ( under indexed color option )and see how many colors there are.This seems like a problem with a colour pallete.You can check palette options when changing to indexed mode.Cant write now,i'll be back in about 30 minutes

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
fabien
fabien

Tavern Dweller
posted August 11, 2013 11:29 AM

ahah I did it! Thanks to your exemple's color panel and your precious help. Thanks, now I can go on my projet!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 11, 2013 11:48 AM

Good job Just remember as you are making changes in the exe,dont forget to make town version backups after each building you make.You can never know when an error might come up,so its always good to have possibility to come back to last working town version

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Macron1
Macron1


Supreme Hero
posted August 13, 2013 12:32 PM

In VCMI I use 800X374 buildings DEFs, and there were no problems.
As there was no problem on ERA with Covenant town.
Just when make DEF from bmp, don't forget to point right transparency colour in DEFTool.
And border/area BMP-files must be only with standard colours to avoid problems (altrough for example green/blue borders work, area files with non-standard colours don't).

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 13, 2013 03:29 PM

Macron1 said:
In VCMI I use 800X374 buildings DEFs, and there were no problems.
As there was no problem on ERA with Covenant town.



Wow,I had to download Covenant to check the defs You're right.Strange because long time ago when i tried this i had problems with hightlighting images.But i guess i must have done something wrong with the TZEL files.Would be great if this worked, this would really speed up town making

Btw,I was thinking about the z coordinate used in VCMI.It was recreated from original files but i dont know where is it.Do you guys from VCMI or DF2.ru forum know where the z coordinates are located ?

This would really help in creating the city and remove possible bugs because I think if we use the defs one on another without changing the z values, there can be illogical z values that may cause problems like :

Building A is over building B
Building B is over building C
Building C is over building A

Thx for the info



 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Macron1
Macron1


Supreme Hero
posted August 13, 2013 03:39 PM
Edited by Macron1 at 15:41, 13 Aug 2013.

Silaneo said:

Btw,I was thinking about the z coordinate used in VCMI.It was recreated from original files but i dont know where is it.Do you guys from VCMI or DF2.ru forum know where the z coordinates are located ?

This would really help in creating the city and remove possible bugs because I think if we use the defs one on another without changing the z values, there can be illogical z values that may cause problems like :

Building A is over building B
Building B is over building C
Building C is over building A

Thx for the info




What you meant by z coordinates?
They are also in structures.json

for example,

"mageGuild3":     { "id" : 2,  "animation" : "TBCSMAG3.def", "x" : 704, "y" : 107, "z" : 1, "border" : "TOCSM301.bmp", "area" : "TZCSM301.bmp" },
"mageGuild4":     { "id" : 3,  "animation" : "TBCSMAG4.def", "x" : 704, "y" : 76,  "z" : 1, "border" : "TOCSM401.bmp", "area" : "TZCSM401.bmp" },
"tavern":         { "id" : 5,  "animation" : "TBCSTVRN.def", "x" : 0,   "y" : 230, "z" : 1, "border" : "TOCSTAV1.bmp", "area" : "TZCSTAV1.bmp" },


Just after x,y.
Or you meant something else?


This problem
Building A is over building B
Building B is over building C
Building C is over building A
is not solved by x,y,z in VCMI or in H3.
I think you can use "mode":"auto" to make these buildings.
For example, you make DEFs for
Building A
Building B
Building C
Buildings A,B,C together.
So when A,B,C builded, you autobuild fourth DEF (with "requires":[A,B,C]) (for it you don't use borders-areas, just place it on screen with z coordinate higher than z-coordinates of A,b,c alone. So old areas/borders will be accessible.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Silaneo
Silaneo


Adventuring Hero
Town Creator
posted August 13, 2013 03:52 PM
Edited by Silaneo at 15:54, 13 Aug 2013.



What you meant by z coordinates?
They are also in structures.json




Ye,I know these are in the structures.json and its great its so easy to modify I meant where are these in the exe file ( the offset adress ) for people who would like to change building position without VCMI , with hex editor

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
figva
figva

Tavern Dweller
posted May 24, 2014 03:11 PM

This is great,it helped
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0777 seconds