View Full Version : [ModComp] Home Cities on Map - playable beta


koma13
Mar 31, 2009, 03:22 PM
Home Cities on Map Beta 002b - A modcomp for Mare Nostrum

After releasing two tech demos I further improved the concept of placing home cities on map and reached a state, where you can risk a game. :)

http://img187.imageshack.us/img187/4527/civ4screenshot0028.jpg

http://img17.imageshack.us/img17/5737/civ4screenshot0043.jpg

Concept:

I made a special version of the inland sea map script with similar climate like the mediterranean sea. After map generation each king player get a city on map. Your starting location is changed to that city. If you want to access Europe screen you have to travel back to your king's city. I adjusted the AI and interface to make full use of that new concept. :eek:

Install:

- make a clean install of MareNostrum BETA 0.03
- unrar HomeCitiesOnMap_002b.rar and copy content to your fresh installed Mare Nostrum Beta

Update!

New version - Major changes:

- compatible with Mare Nostrum Beta 003

- added Africa screen. It can be accessed on the Inland Sea map script by sailing down the big river in the south east area. Right now you can only buy and sell goods there but I will improve that in future releases.

- fixed revolution, REF will be spawned at home city

- improved home city initialization process

For a more detailed list of changes look inside spoiler.



002 Changelog:

- fixed a bug preventing player of purchasing units in Europe

- gave the king the ability to move his units inside home city radius

- gave king player and home city some goodies at game start (population, money, some units & buildings)

- increased size of Europe travel zone to home city radius

- Colonist players can't steal plots from home cities anymore

- fixed Revolution

- REF spawned at home city

- added Africa Screen

- can't send non cargo land units to Europe screen no more

- improved starting location process

- made sure there is a minimum distance between home cities

- fixed some issues in Europe screen

- added AOD2 Cheat menu

- rename inland sea map script to 'Inland_Sea_HCOM.py'



EDIT:

There were some issues with Europe screen and units on dock and I fixed them (HomeCitiesOnMap_002b.rar).

Dale
Mar 31, 2009, 04:25 PM
How stable is it, how clear are your code changes, does the King now operate like a normal colonizer or do they still accumulate units in the REF queue, and is there any bugs? :p

koma13
Mar 31, 2009, 04:38 PM
How stable is it

Well, as stable as Mare Nostrum. :p

how clear are your code changes,

I marked all changes with 'MareNostrum' (EDIT: except CvEuropeScreen.py, Inland sea.py (too many changes) and CIV4EuropeInfo.xml (travel time to 1)). C++ Syntax is still a pain. I should read a tutorial. :)

does the King now operate like a normal colonizer

No, right now he can't move. :D I set CvUnit::canMove to false for all king players. In next version I will try to remove that limit after revolution started. Diplomacy with foreign king players still isn't possible.

is there any bugs?
Read the issues. And you can send land units to Europe screen, looks a little strange right now and doesn't make much sense.

Onionsoilder
Mar 31, 2009, 05:07 PM
Wouldn't it make more sense just to use the mapscript that has the Mediterranean feature in-place? I forget the name of it, but I know it's there...

koma13
Mar 31, 2009, 05:11 PM
Wouldn't it make more sense just to use the mapscript that has the Mediterranean feature in-place?

Of course it would make more sense. I didn't know there is an existing one...

Dale
Mar 31, 2009, 06:36 PM
You mean the BtS inland sea script?

Flintlock1415
Mar 31, 2009, 08:00 PM
Wow, great job! :goodjob:
I'll have to use this once my Wild West mod gets going. ;)

koma13
Mar 31, 2009, 09:31 PM
You mean the BtS inland sea script?

They updated it for BTS? :confused: I used the normal one from Civ4.

Wow, great job!
I'll have to use this once my Wild West mod gets going.

Thx. :) Shouldn't be that hard to adopt for another mod. The only Mare Nostrum related change is the placement of the king cities (done with python).

Flintlock1415
Apr 01, 2009, 12:27 AM
Nice. Maybe I need to learn how to make map scripts. I know a bit of Python, so how difficult is it?

koma13
Apr 01, 2009, 12:57 AM
Maybe I need to learn how to make map scripts. I know a bit of Python, so how difficult is it?

It depends... Creating a script from scratch isn't easy (imho). But adjust an existing one should'nt be that hard. The trick is to find a script that already nearly does what you want. Then you just have to overload the plot and terrain functions and adopt them to your needs. I didn't touch the height map, it's based on fractals. :crazyeye:

EDIT: Ther is a 'great plains' script included in Civ4.

Flintlock1415
Apr 01, 2009, 11:00 AM
I was thinking just that, that I could modify the great plains script, just add rivers for navigating, change the ocean to the West coast, and make the Rockies. I think the Vanilla one goes from the Appalachians up to the Rockies, so I could almost flip the map & make a few minor changes.

What are the differences between Vanilla Civ terrain, feature, and bonus definitions? ie are they easy to pick out and change? (I've obviously never opened up a map script before. ;) )

koma13
Apr 01, 2009, 12:18 PM
What are the differences between Vanilla Civ terrain, feature, and bonus definitions? ie are they easy to pick out and change? (I've obviously never opened up a map script before. )

For terrain setting (desert, plains, grass, tundra...) watch out for a method called generateTerrainAtPlot. They check eaches plot latitude and height (determined by a height map created before) and depending on that values they set the terrain.
It's easy to identify, they call the terrain by name (eg self.terrainDesert).
For Features (forest) check out addFeaturesAtPlot. Works same as terrain. Bonus placement is done outside of map script, after generation.

koma13
Apr 01, 2009, 05:18 PM
I noticed a little bug in my modcomp preventing player from buying new ships in Europe screen (so much for testing. :p). I attached that fix to the first post.

koma13
Apr 05, 2009, 04:12 PM
'Home cities on map' update in first post.

Chimera
Apr 19, 2009, 12:34 PM
Any chance this works for beta 0.04 as well, and if not, is there a plan to update this?

koma13
Apr 20, 2009, 04:55 PM
Any chance this works for beta 0.04 as well, and if not, is there a plan to update this?

Don't waste too much time with current version of home cities on map, I discovered some annoying bugs. :blush: Right now I'm working on caravan access for Europe screen. If that is working I will make an update. :)

Chimera
Apr 20, 2009, 07:35 PM
Sounds good. I really like the concept and it makes more sense to me for the time period.

henryMCVII
May 08, 2009, 04:11 AM
I love the feature, how you can send your ships around. IMHO a must add to AoDII. :D

koma13
May 09, 2009, 08:02 AM
Thank you. :)
I made some progress with caravans. AI is using them now for trading with home cities. :goodjob:

http://img26.imageshack.us/img26/64/civ4screenshot0017.jpg

Next I added an oasis bonus (giving +2 food) to make the southern area/desert a little more habitable. I'd like to add flood plains too, but I don't know how to convert the nif from civ4 to c4c, maybe someone can help...?

Kailric
Aug 22, 2009, 10:23 AM
Does anyone have a copy of the Mare Nostrum 003 I could use for testing this? I am attempting to help add this to the Wild West mod and could use a working version?

koma13
Aug 22, 2009, 04:57 PM
Does anyone have a copy of the Mare Nostrum 003 I could use for testing this? I am attempting to help add this to the Wild West mod and could use a working version?

Here is a short description how you can make Home Cities on Map Beta 002b playable in vanilla c4c.

1. Extract HomeCitiesOnMap_002b.rar into your mod directory.
2. Delete /XML/Civilizations
3. Copy CvUtil.py and sdToolKit.py from MN into Assets/python
4. Edit CvEventManager.py and rename civs in 1113-1122 to vanilla names (eg. England, France, Spain).

Europe screen graphics are messed up but you can fix that by getting background.dds from MN and ship graphics from my Europe Screen 4.

You don't have to play on inland sea, any map should work.

TC01
Aug 22, 2009, 05:12 PM
For the record, Westward Ho uses different "Europe" civs, MEXICO, MEXICO_2, UNITED_STATES and UNITED_STATES_2.

So you'd need to use those instead.

Kailric
Aug 22, 2009, 05:27 PM
Thanks for the info. Westward Ho is still basiclly Vanilla Col at the moment as far as trading with Europe I should be able to do this with the Westward Ho mod right? If I do as TC01 says it should work as well it would stand to reason.

TC01
Aug 22, 2009, 05:46 PM
Thanks for the info. Westward Ho is still basiclly Vanilla Col at the moment as far as trading with Europe I should be able to do this with the Westward Ho mod right? If I do as TC01 says it should work as well it would stand to reason.

Yeah, I think it will work fine.

TC01
Aug 22, 2009, 09:29 PM
First, I get this:

Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 185, in handleEvent

File "CvEventManager", line 341, in onGameStart

File "CvEventManager", line 1155, in initKingCities

UnboundLocalError: local variable 'pCityPlot' referenced before assignment
ERR: Python function onEvent failed, module CvEventInterface

Then I get quite alot of these:

Traceback (most recent call last):

File "CvScreensInterface", line 556, in forceScreenRedraw

File "CvMainInterface", line 1120, in redraw

File "CvMainInterface", line 1756, in updateSelectionButtons

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenRedraw failed, module CvScreensInterface

If I disable python exceptions, the map loads, but I have no Unit control panel, everything is blacked out, and when I go into Worldbuilder there are no home cities.

The way I did it was manually copy over everything except the GameText_Objects file, since Westward Ho already modifies it. At least, I think I did everything.

I turned the event manager code into this:

if loopPlayer.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_UNITED_STATES"):
pStartPlot = CyMap().plot(iW / 3, iH)
if loopPlayer.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_UNITED_STATES_2"):
pStartPlot = CyMap().plot(iW, iH / 2)
if loopPlayer.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_MEXICO"):
pStartPlot = CyMap().plot(iW, iH / 2)
if loopPlayer.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_MEXICO_2"):
pStartPlot = CyMap().plot(iW / 3, 0)

(Note that this was using both the InlandSea_HCOM and the WildWest (Great_Plains) mapscripts.)

koma13
Aug 22, 2009, 11:02 PM
Try CIVILIZATION_TEXAS, CIVILIZATION_CALIFORNIA, CIVILIZATION_OREGON ....
And make sure your map has enough coastal land for city initialization, CvEventManager.py is optimized for inland sea script.

TC01
Aug 23, 2009, 08:47 AM
Try CIVILIZATION_TEXAS, CIVILIZATION_CALIFORNIA, CIVILIZATION_OREGON ....
And make sure your map has enough coastal land for city initialization, CvEventManager.py is optimized for inland sea script.

Inland_Sea_HCOM works fine now. I still get the error in WildWest, mainly because WildWest is 80%/90% land.

Would Kailric (SDK end) or me (Python/XML end) need to alter the Home City code to start you on land instead? Or both? I want my home cities to spawn in the eastern green region, which represents the Mississippi River area. They would have to be on land.

I guess I'd need to alter starting units, obviously, as well as the water start tag in CIV4CivilizationInfos.xml. But apart from that... would I just have to change this code?

if CyMap().isPlot(pLoopPlot.getX(), pLoopPlot.getY()):
if pLoopPlot.isCoastalLand() and not pLoopPlot.waterArea().isLake():
if not (iW * 3 / 4 - 5) < pLoopPlot.getX() < (iW * 3 / 4 + 5) or not pLoopPlot.getY() < iH / 2:
if loopPlayer.AI_foundValue(pLoopPlot.getX(), pLoopPlot.getY(), -1, true) > 1:
iDistance = plotDistance(pLoopPlot.getX(), pLoopPlot.getY(), pStartPlot.getX(), pStartPlot.getY())

Kailric
Aug 23, 2009, 09:24 AM
The water start tag doesn't do it all together. You'd need to change the SDK where the King checks every turn if you have a ship or if the player can afford to buy one on his own. If not the king automaticlly gives you one and raises your taxes. So by Vanilla rules after the first turn of a land start, the king would raise your taxes and give you a ship in Europe. This would need to be changed so that the king checks to see if you have a wagon train instead of a ship... or just do away with this altogether, but I guess it depends on how easy it is to lose your first wagon train.

TC01
Aug 23, 2009, 09:33 AM
The water start tag doesn't do it all together. You'd need to change the SDK where the King checks every turn if you have a ship or if the player can afford to buy one on his own. If not the king automaticlly gives you one and raises your taxes. So by Vanilla rules after the first turn of a land start, the king would raise your taxes and give you a ship in Europe. This would need to be changed so that the king checks to see if you have a wagon train instead of a ship... or just do away with this altogether, but I guess it depends on how easy it is to lose your first wagon train.

Well, since I plan on adding "Train Robber" units to replace Privateers, it might become pretty easy to loose a Wagon Train.

I guess for now it should be changed to check if you have a Wagon Train. We can decide to do away with it in the future.

Kailric
Aug 23, 2009, 10:01 AM
Well, since I plan on adding "Train Robber" units to replace Privateers, it might become pretty easy to loose a Wagon Train.

I guess for now it should be changed to check if you have a Wagon Train. We can decide to do away with it in the future.

K, I guess we sorta "highjacked" this thread for the moment, but I'll make some of the mentioned changes we talked about in the SDK and merge in the Home CIties on the map and hopefully we can get it working with Westward Ho.

TC01
Aug 24, 2009, 08:33 PM
Alright, sorry to keep "hijacking" this thread, but I have another question.

What graphics were used for the popup you get that lets you pick where you sail to? I'm guessing it's in Europe Screen 4? Currently that popup is just a pink box.

koma13
Aug 26, 2009, 12:15 PM
DialogBox.dds. Get it from MN or AOD2. ;)

LeftoverNoodles
Oct 26, 2009, 10:22 PM
This Mod still being worked on? Does it work with Beta5? If not any idea where I can find Beta3?

TC01
Nov 26, 2009, 09:16 AM
Found a HCOM bug. I fixed it in Westward Ho, but I thought I'd post it here as well.

You pass "player.getName()" into the array that you then pickle and save to script data. But "player.getName()" can change, very easily, by using the "Your Details" button in the options menu. So with the value of player.getName() changed, the game won't be able to find the correct home city data.

I made it use the player number intead, something more unique and something that will not change throughout the game. (0 for the human player, 1 for the first AI player, etc.)