This post will describe a simple mod which adds a new Town without eliminating an existing Town. The main reason I am posting it is as a template (or just an idea) for others to consider when adding new Towns.

Download Link: https://www.box.com/s/a8a7accc0b5436638aa5

This mod adds a new town, "Dragon Peak", via wogification under Era 2.3. The town is slightly similar to a Heroes II Dragon City, in that you have to fight dragons to win it, and it produces dragons weekly and 1000 gold daily. It contains Fairie, Rust, Crystal, and Azure Dragons.

I thank Bersy, Salamandre, and master_learn for valuable comments.

INSTALL: For this map you have to install the Heroes 3 "Era 2.3" addon, which you can download from http://heroescommunity.com/viewthread.php3?TID=37208 - see the installation instructions there. Note: this mod will not work under Era versions prior to 2.3.

Note: four WoG scripts have been revised to account for Dragon Peak Towns: Bersy's numbers 33, 43, 46, and 53. These scripts are in WoG/Data/s in the package. The revisions have "JHV" in their comments.

The DragonPeak mod can be used to add a new feature (new Town) to random maps. It can also be used in custom maps, by either wogifying them with the DragonPeaks mod enabled, or with the DragonPeaks.erm script (DragonPeaks/Data/s) placed in a Timed Event using the Map Editor. Custom DragonPeak cities can be added in the Map Editor by adding Rampart Towns whose names begin with "Dragon Peak", e.g. "Dragon Peak NW". Randomly added DP Towns will be named "Dragon Peak 1", "Dragon Peak 2", etc., so do not name a custom DP town with a number which will match one of these. That is, if you intend to add 8 randomly-placed DP Towns (using the script menues at the start of a game), number your custom DP Towns as "Dragon Peak 9" or higher (or do not use numbers in the name).

At the start of a game, DragonPeak.erm will attempt to add DP Towns to the map. Due to the large footprint of a Town, most random maps will not have enough clear space in which to add DP Towns. The script will ask if you wish to remove 1/3 of the map's resource piles, in hopes of clearing spaces for random placment. If the script cannot find space for a random placement (after about 200 random tries), it will then ask if you want to convert a neutral Town to a DP.

Mod Method:

I used DefPreview, H3DeftOOL, and MMARCHIVE (thanks to Grayface) to manipulate DEF and PCX files. I used GIMP to modify graphics. Bersy's new "RedirectFile" option, as well as other Era options, were crucial to the development.

The plan was to make a new Town type out of Rampart Towns, without eliminating the original Rampart Towns, by changing Town properties and graphics each time a Rampart Town named "Dragon Peak xx" is entered.

Towns whose names begin with "Dragon Peak" are changed to the new type, and other Rampart Towns are left unchanged.

Mod Details:

A Town can be entered by these methods:

1) A Hero visits the Town (!?OB trigger).

2) The player clicks on a Town in the Town List on the right side of the Adventure Screen (!?CM5 trigger).

3) The player clicks on a Town in the Town List in the Town Screen (!?CM1 trigger).

4) Click twice on a Town on the Adventure map.

5) Open the Kingom Overview, select Towns, and click on a Town icon.

All of these events except the last can be detected with ERM triggers and used to implement Town changes. (The last had to be prohibited in this mod.)

However, there is a limitation, under event 3): it seems the Heroes 3 program does not reload Town graphics (DEF's and background PCX) when transferring from one Ramparts Town Screen to another. So transferring from a Dragon Peaks Town to an ordinary Rampart Town via the Town Screen Town List leaves the modified DP graphics in place, and vice-versa.

Therefore the script checks for this type of transfer and prevents it. (You can transfer from a Dragon Peak Town to a standard Rampart (e.g., "Rainhaven") by transferring from the DP to another Town type (e.g., Castle), and then transferring from the Castle to Rainhaven.)

A Dragon Peaks Town is a simple town, with only four Creature Dwellings and an unmodifiable Town Hall. The following scriplet shows how their new graphics are implemented:

The option to convert neutral towns if random placement is limited by the lack of clear space:

A randomly-placed Dragon Peak:

A converted neutral Town (on a random map):

The download package contains two custom maps and a random map which can be used to test the mod. The custom maps ("Hint Test" and "Dragon Peak Test") are just test vehicles, with and without wogification, not playable maps.

Note: this post has been updated in response to changes made up to the edit date.

Very nice, thanks. I got two issues, right clicking in middle area of new town triggers mage guild question (hero had mysticism), from inside clicking on upper town icon or itself icon crashes the game

Thanks for the comments - some of which I am not smart enough to understand yet.

I am sure I should have used the Town Hall triggers, but I am not sure what for. I use CM1 to prevent use of the Dragon Peak Town Hall, because the Town is not modifiable and the graphics would not match. A more complex example might change the Town Hall menu also and use the TH trigger to implement the change - but I myself would replace it with a new DL rather than redirected graphics.

Good point about the redirects. I will un-redirect the redirections individually to make the script more general.

I could not start the saved game (dragons.gm1). It starts with an error message about secondary skills scrolling, and then crashes. I got numerous random crashes when I started developing the mod under Era 2.2, but they disappeared under Era 2.3 - so I am wondering which Era version you used. (And what other mods it might interfere with.) Clicking town icons everywhere I could think of on my system does not produce a crash. (Probably I am not finding the right place to click.)

Checking my notes, I started this mod on June 27, so I have not done as much testing as I should (of course, it is a very simple mod).

I have the Secondary Skills mod (+ WoG and Yona) enabled, under Era 2.3. DragonPeaks is my top priority, followed by SS. So probably something else is different between our systems - I will investigate further. I installed Era 2.3 about two days ago, and did not change anything except to add DragonPeaks to it.

Meanwhile, I have found a mistake - the "Hint Test" map in the zip package was for a different development. I have replaced it with the version used to test DragonPeaks at Box.net. (Bersy's recommended un-direct change has not been made yet as it needs testing, and probably there will be other suggestions if I wait a while.)

Update: I didn't see OxFea's post until I submitted the above.

"Units can be bought without visiting the town (kingdom overview, and, most important, AI procedures). Is it handling?"

I didn't know creatures could be bought from the Kingdom Overview, which shows one can play Heroes for about 15 years and not know everything about it! This was not handled, and I will have to add it to the script. Thanks for mentioning it.

I have seen AI's attack a Dragon Peak and leave it with dragons which they purchased there. I wondered during the development whether the AI has internal ways of buying creatures, but since there wasn't any good way which I could think of to handle such in ERM, I decided that if the AI wants to buy Elves and Dendroids instead of Dragons, I could live with that. Assuming Heroes 3 has assigned the right creature costs, it should not be a significant disadvantage to the AI. Of course internally-coded mods such as VCMI and others would be able to handle such things, but I am just a lowly ERM coder.

Weird, I re enabled secondary skills mod and now I have load game crash every time pointing to their script. Nothing about ERM in crash log, only one address. Save is now corrupted, no matter if sec skills On/Off.

Speaking for myself, I just added the folders and files to my Heroes 3 Era 2.3 folder using Windows Explorer.

When checking for transfers between standard Rampart Towns and Dragon Peaks within the Town Screen, I needed a way to get the name and Town type of a town in the scroll list - which ERM does not provide. Therefore I searched for the address of the hint text (which shows "View town-name, town-type" when the player clicks on a Town icon to transfer to it), and found the following:

[[[0x28085E0]+0x14]+0x234]+0x30114. This works (always, so far) on my Windows 7 laptop, and on an older XP laptop, so I hoped it was a general address which would always work. Now I think perhaps it does not work on Salamandre's system.

These may not happen soon as I will be undergoing surgery about 36 hours from now and there is a lot of Wimbledon tennis to watch in the meantime, but I appreciate the suggestions and will issue a revision based on them sooner or later.

The new object is a Town (object type 98, subtype 1). What you see on the map is a replacement for AVCRAMP4.def, the maximally demolished version of a Rampart town. (The revised AVCRAMP4.def is in the h3sprite.pac under DragonPeaks, so if this mod is active it will replace the WoG version.) The object should have a dragon flying around it, and may some day, but the graphics work to do that seemed excessive to me for now.

It is intended as a sort of "Dragon City", containing neutral Dragons, so it can be used by any faction. At the start of a new game, the script attempts to add a number of them (player-specified) to the map. The added ones are neutral, with garrisons of dragons which have to be conquered to own the town, similar to the Dragon Cities in Heroes II.

A map-maker can also add owned Dragon Peaks to a custom map by placing owned Rampart Towns on a map and naming them "Dragon Peak xx". At the start of the game, the script will convert these to the new object, but without garrison troops (unless they are neutral instead of owned).

It is a very simple type of town which only took a week to do, mainly as an illustration of Bersy's RedirectFile Era command. A more complete town could be done with this method - requiring a lot more graphics work and time. The main point of this type of mod is to have a new town without losing any of the existing town types - with some limitations on the new town.

Second - the first update has been uploaded to the Box.net site. I found an error: flag 412 is not unclaimed, but used by WoG, so the script now uses 413 instead of 412 (and I will revise the first post to eliminate references to 412 as soon as I finish this post). This did not cause noticeable problems during my tests, perhaps because I do not use the WoG option which uses 412, but it might explain Salamandre's problem - but probably not, as I am still unable to reproduce his results. I have added another test map, "Dragon Peaks Test", in which Sorsha has Expert Mysticism, and with the WoG Mysticism options enabled ... I see nothing in Dragon Peak 1. I also played the random map long enough to get a Hero with Expert Mysticism and saw nothing in three Dragon Peaks in that map either. I may need some saved games to figure out what is happening.

To do:

1) Still haven't done individual un-directs - maybe tomorrow.

2) Fix Kingdom Overview to prevent creature purchases there. There seem to be no ERM triggers (except CM1 on the KO button) I can use, so I will have to replace the internal KO menu with a new one. (Probably stripped down to the Mine and Income information.)

4) Think about how to compensate the AI for buying Elves and Dendroids in Dragon peaks (via internal routines without entering the Towns) instead of Dragons.

5) More play-testing.

Second update: added more code to the script, to fix the growth of owned Dragon Peak troops, and keep the available troops for neutral Dragon Peak troops at one of each dragon (no growth until they are owned, similar to H2 Dragon Cities).

I have added an AI-owned Dragon Peak (98) to the Hint Test map. So far when I have attacked it (at the start of week 2), the AI has only been able to buy one Green Dragon and one Pegasus to defend it (with two of all four creature types available to be recruited, at that point). (The AI is too far away to visit it with a Hero yet, and Dragon Peaks do not have Taverns.) So in these cases, if the AI were forced to buy Faerie, Crystal, Rust, or Azure Dragons instead of Rampart creatures, it would not have enough resources and would have to leave the Town undefended.

Later in the game, an AI-owned Dragon Peak might have a defending Hero, in which case it would be able to purchase Dragon Peak creatures rather than Rampart creatures.

So I am not sure whether the ability of the AI to bypass my script is a disadvantage or advantage to it. If it is a disadvantage I need to compensate for it, but if it is an advantage and makes the game a bit more challenging, I would not be inclined to try to reduce the advantage.

I also believe it is more about adding a new object which, under some limitations-using only neutral creatures-, will act as a neutral town. The redirects allow amazing things, but they will be useless if one wants to replace the DP with for example Grove town, which uses 14 creatures whose ID are used by the replaced town. I am not sure I fully understand the redirects potential, but what will happen if the new town using 14 creatures ID will get in battle with the former town? We can't have angels on one side and angels using another def on the other side, can we?