Vikings shouldnt get kjøbmandehavn(Copenhagen)

fattythefat

Chieftain
Joined
Feb 4, 2010
Messages
39
Why does vikings get Kjøbmandehavn when it was Roskilde that was the big town in that region when the Vikings ruled the seas?
 
Why does vikings get Kjøbmandehavn when it was Roskilde that was the big town in that region when the Vikings ruled the seas?
This should be changed, but the city on the tile could also change name later in the game. (Dynamic city names.)

Actually, I've been meaning to add an Independent city spawn on that very tile (as Roskilde) in my own game/mod. If you like I could show how you can do this yourself. (Or post a replacement file.) We could also add Birka on the Stockholm tile as that was the main trading outpost in Svealand in Viking times. This way you also make sure Stockholm is actually founded, as the AI seldom will do this on its own.
 
Yeah great idea! but dont now anything about modding... :(
No worries, I could just supply a replacement file for your copy of RFC. You would backup the original and copy-paste in the new one. Then you'd have to test the code to see if it does what I promised it would! :D

I'll get back to you in this thread as soon as I get the lead out. :mischief:
 
Ok, here's my quick'n'dirty little modmod then. The attached file is compressed (zip) and should be unpacked in the following directory:
...\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Rhye's and Fall of Civilization\Assets\Python\
But before you do this, rename the original file (called Barbs.py) to something else (like BarbsOrg.py, Barbs.org or Barbs.txt) so that it doesn't get replaced by my version. Because if you don't like the new additions, or then don't work, you could just rename the original file and replace mine.

Whatever you do, keep me posted on what actually happens in-game. I only checked that the cities will spawn, not what impact it will have on the game. :mischief: Also note that this simple mod doesn't include any dynamic city names - so you'll have to change the names to Stockholm/Copenhagen/whatever manually.

Also, the cities will be Independent once they show up. But they won't show up if there is foreign culture on the designated tile, or if a foreign unit is adjacent to that tile. Thus the cities won't turn up in every single game, like any other cities that spawn in RFC.

If you really want me to, I could make the dynamic names happen also. This way the AI would also get the new names once time comes. But lets just try this out first, shall we? :king:

edit: spoiler added

Spoiler :
The spawn dates are AD 790 for Birka and AD 990 for Roskilde.
 

Attachments

  • Roskilde_Birka.zip
    4.7 KB · Views: 75
Am I right in assuming that means the independent city will just appear and then a major civ such as Germany, Netherlands or the Vikings will usually (90%+) conquer it?

I've been trying to make changes to the mod to fix most civ's horrible city placement (Japan especially) and making cities spawn sounds like a good idea.
 
Am I right in assuming that means the independent city will just appear and then a major civ such as Germany, Netherlands or the Vikings will usually (90%+) conquer it?
Yeah, because giving free cities to one of the regular Civs (the Vikings) would be a bit over-the-top.

I've been trying to make changes to the mod to fix most civ's horrible city placement (Japan especially) and making cities spawn sounds like a good idea.
Any requests? :king: If you can find out the proper starting date, the actual plot on the map and whatnot that would also help.

The settings Rhye has made for city spawns are:

- city location, date and name
- city size and owner (any of the two types of independents, barbarians or natives)
- city defender (unit), number of units

Also, spawn areas and starting locations for Civs can easily be edited (thanks to Rhye). And the respawn area could differ from the initial spawn area.

If you wanna do it yourself I could just point you to the right place in the code...
 
Kjøbmandehavn is already ancient as hell since modern Danish is København, and it doesn't rename to the modern name in the game...
 
cool how did you do it? i want to learn how to mod Civ4 but i cant find any beginners guide :(
Oh, there are guides. You might start with the Civilization Modding Wiki, or the Modiki. There is a huge learning curve to this if you're not familiar with programming, though. I managed to learn some practical modding over the winter holidays though, but I did do some programming in Basic growing up, so that surely helped.

The Barbs.py file in RFC is actually a good place to start, so try and add some city spawns of your own! (We can get to unit spawns later on if you're interested.)

All I did to achieve my little modmod was add these two lines:
Code:
lBirka = [63, 58, 200, 0] #790AD
lRoskilde = [60, 55, 220, 0] #990AD
..and these two lines:
Code:
                self.foundCity(iIndependent, lBirka, "Birka", iGameTurn, 2, con.iLongbowman, 1)
                self.foundCity(iIndependent2, lRoskilde, "Roskilde", iGameTurn, 2, con.iLongbowman, 1)
The key to understanding what it does is to know that Rhye has set up "functions" for most of the things happening in RFC. The rest of the code is basically functions set up by Firaxis and are specific to CivIV. Everything is then wrappen around the programming language Python, so you need to understand the basics of that if you're gonna do your own code eventually.

But for now you could just add more city spawns (or manipulate the existing ones) by using the template created by Rhye. How's it done, then?

Firstly, you set up few variables. Well actually one variable containing several numerical values, but whatever. For example "lRoskilde" (above): the first value (60) is the X coordinate for the spawning tile, the second one (55) is the Y coordinate, the third one (220) is the game turn - and the fourth one (zero) is supposed to give you retries if the spawn is interrupted by something - but I'm not even sure if it does what it sets out to do, so I don't use it myself. (And neither does Rhye.) The stuff after the "#" is line commenting and does nothing, but it can still be useful for anyone reading the code. Here it actually states what year the game turn would be in the game.

Secondly, you call on one of Rhye's functions and in this case its "foundCity". (The "self." part only means that the function is defined in the same Barbs.py file, and not in any other file). You feed the function some values and stuff (inside the parenthesis) and out comes a city spawn. (Actually, if you read the definition for the function, it will call on another function native to CivIV in order to create the city, but Rhye has also added some code of his own. Like the possibility to also spawn the city defenders with the same function.)

This is a breakdown of all the values that go into the foundCity function (in order):

- City owner, indicated by a variable corresponding to the Civ ID (numerical value).
- Coordinates and spawning turn (which were determined earlier in the code, remember?).
- City name.
- Current game turn (represented by the variable iGameTurn) so that the function can determine if its the right turn to spawn (it checks it against the value mentioned above). Always use the same variable!
- City size, any value of 1 or above.
- City defender, the unit that will spawn simultaneously (in the form of a variable, it could just be replaced by a value if you know what index number a unit has). "-1" is none.
- Number of units spawned. A value of "-1" is none.

Now try it yourself! :king:

If you have any questions I will try to answer them.
 
How do I find out what the co-ords for a plot are?
Is it possible to make the cities spawn with buildings in them already?
 
How do I find out what the co-ords for a plot are?
Hold down Shift and hover on tile. You might have to have cheat mode active though, I don't remember. But try it.

Is it possible to make the cities spawn with buildings in them already?
No, at least not with the code I was talking about. Other than that - pretty much anything is possible with Python. Thats the reason you wanna learn it for yourself! :king:

So, one could make a function or a piece of code that spawns cities with buildings in them. All it requires is some time and knowhow.
 
Hold down Shift and hover on tile. You might have to have cheat mode active though, I don't remember. But try it.


No, at least not with the code I was talking about. Other than that - pretty much anything is possible with Python. Thats the reason you wanna learn it for yourself! :king:

So, one could make a function or a piece of code that spawns cities with buildings in them. All it requires is some time and knowhow.

how do you run that code, can you tell the file that the turn after the city appears to search that plot for the city and then add those buildings?
 
how do you run that code, can you tell the file that the turn after the city appears to search that plot for the city and then add those buildings?
Basically, yeah. But I actually think I'll create a new function altogether for city spawning. That would then allow for including buildings. I'll post it on the modmod forums if and when I do.

What would be most useful to you? I could either go for the more straight forward approach (easier to use) by adding one of a select few buildings with any spawned city. Or I could make it more complex (for the modder using the function at least) and allow for a buildings list for each city. Any preferences?

Personally I don't think I'd wanna give newly spawned cities more than one building each, but others might.

Also, I think I'll include settings for culture and religion. Again, is one preset religion enough or is there any real need for multiple religions in spawned cities?

Any other setting that could or should be added? :confused:
 
Basically, yeah. But I actually think I'll create a new function altogether for city spawning. That would then allow for including buildings. I'll post it on the modmod forums if and when I do.

What would be most useful to you? I could either go for the more straight forward approach (easier to use) by adding one of a select few buildings with any spawned city. Or I could make it more complex (for the modder using the function at least) and allow for a buildings list for each city. Any preferences?

Personally I don't think I'd wanna give newly spawned cities more than one building each, but others might.

Also, I think I'll include settings for culture and religion. Again, is one preset religion enough or is there any real need for multiple religions in spawned cities?

Any other setting that could or should be added? :confused:

That would be better because a city spawning in 200 BCE would need different buildings than one built in 800 CE
 
Useful settings would include:
- Preset religion (maybe add support for two)
- More freedom for whom the city goes to. Instead of just barbs/independants, make it so we can give cities to AI civs so their awful city placement doesn't impede them as much.
- Allow a buildings list, like you said. We don't need every building, at at least the main "must have" buildings such as a granary, harbour, market, library, forge. That way the modder could select which of these the city starts off with. Say I want to make it so that San Francisco or Los Angeles spawns in 1850 or whatever (because the USA never settles West Coast) we could give LA some buildings instead of having it spawn empty so late in the game :)

The main reason I wanted to be able to spawn cities is to make the late game more interesting. At the moment the main problems I see in my games are:
- AI civs such as Japan and the USA never do well due to terrible city placement or lack of expansion
- Huge population centres today are seldom settled. Panopticon came up with a great mod (his dynamic resource mod) to encourage more settling, and this would be a good extension to it imo

I like to focus on the late game because I don't know much about history so I always fear I'd be ruining RFC if I made too many early game changes :)

Ideally I'd like to be able to influence which cities an AI Japan (for instance) would spawn. The way I've tried so far is to edit the starting situation with WB and place 3 indy cities (Edo, Sapporo, Nagasaki), each with a Japanese unit in the next tile and set diplomacy so Japan is at war with indys. However this solution doesn't help solve my AI USA problem (which is they never settle further West than Denver) and it doesn't solve my South America problem (the Amazon is never cut down, not even a little bit - cities like Bogotá, La Paz, Asunción, Manaus, and so on never exist). A solution like this one is elegant for testing :)

The other thing I've tried is to place more independent cities around the world to "influence" which large cities we see in the late game. To do this I edited WB so that Casablanca, Algiers, and Tunis are pre-built as Independent with a defender and a harbour; Khartoum, Baghdad, and Tehran with a defender; and Inverness replaced with Edinburgh one tile south (that one is because I couldn't stand seeing Inverness as the central figure of Scotland :p). Now the last thing I need to know is... are my changes having much of an effect, and if they are - is it what I was looking for? Is there a way to set every civ as AI civ and see what the world looks like at the end, to quickly see if I'm getting close to what I need?
 
Right now Rhye's code pretty much require the modder to add two lines of code or settings to achieve one city spawn. The first one is a list variable (like lLosAngeles, where the first "l" stands for "list") containing the tile coordinates and the turn date. The second one is the foundCity() function which contains this list among other settings (like owner or the defending units).

I'm not looking to replace Rhye's function but rather to make another one with more features. So that you could leave all the spawns made by Rhye as is, but have the option of using another function for your own (or to modify Rhye's) spawns.

The way to add buildings to a spawn could be one of these:

1. You simply feed a number in the function that corresponds to a preset building or set of buildings. So the vale 0 (zero) would be a Granary, 1 would be a Forge and 2 would be a Granary and a Forge, and so forth. Easy to use as long as you know what value do what, but there would be limitations in the code as to what choices you have. The list of possible buildings and combinations could however be comprehensive, so that it would be sufficient for most purposes. Would this require 10 or maybe 20 different settings in order to be useful, you think?

2. You have the choice of enabling any of a select few buildings in any configuration by settings "False" values to "True" inside the function. So a set of "True, False, True, True" would give the city a Granary (True), no Library (False), a Forge (True), and a Harbor (True), as an example. This could mean a very long function that is difficult to handle, as you would have to keep track of what instance of True/False corresponds to what building. Anything above five different buildings could easily become a hassle resulting in the wrong buildings being enabled. Which buildings would be essential for a spawned city?

3. You have to create another list variable containing all the buildings you want for the city. The name of the variable would have to be different from the one mentioned above, but it could be something like lCityBuildings, where "City" is the City name. (So you'd end up with two variables for, say, Los Angeles: lLosAngeles and lLosAngelesBuildings.) The way the modder would set up the list could be like this:
Code:
lLosAngelesBuildings = [con.iGranary, con.iForge, con.iLibrary, con.iHarbor, con.iTheater]
There would be no limitations as to what, how many or what combination of buildings could be entered in the list - or in what order. Note that the iBuilding variables are taken from the file Consts.py where Rhye has defined variables for all the buildings. The con. part simply directs to the Consts.py file (con is short for consts, which in turn is short for constants, that is variables with values that never change).

The third option would arguable be the best as it has no real limitations. It requires some work to use though, and there are more things that could be wrong (as you have to type all the variables exactly as they are found in Costs.py). Also it could be harder to use for anyone who has never done this before.
 
- Preset religion (maybe add support for two)
Just one religion would make it easier to code - and easier to use. How important is the support for multiple religions? (To just add support for two makes little sense when you could as easily, or more easily, get all religions.)
- More freedom for whom the city goes to. Instead of just barbs/independants, make it so we can give cities to AI civs so their awful city placement doesn't impede them as much.
This is actually already doable within Rhye's code, but the variables for all the Civs aren't found inside the Barbs.py file. You could fetch them directly from Consts.py though by typing "con.iCiv" (where "Civ" is the name of the Civilization and the "con." directs to Consts.py). So to spawn an American city you type "con.iAmerica".
Now the last thing I need to know is... are my changes having much of an effect, and if they are - is it what I was looking for? Is there a way to set every civ as AI civ and see what the world looks like at the end, to quickly see if I'm getting close to what I need?
You can run autoplay as the Americans all the way to AD 1775, but AFAIK you pretty much have to click End of Turn to get the rest of the play. You wanna enable cheat mode though and press Ctrl + Z to get the entire world view. Also, you could play as one of the minor Civs by choosing which Civ you control with Alt + Z. Then the AI will take control over the Americans while you simply do nothing as the Natives or the Independents.

The experts might have yet better solution for you (and for me also).
 
Just one religion would make it easier to code - and easier to use. How important is the support for multiple religions? (To just add support for two makes little sense when you could as easily, or more easily, get all religions.)
You're right, it isn't very important. Forget I said it :)
Right now Rhye's code pretty much require the modder to add two lines of code or settings to achieve one city spawn. The first one is a list variable (like lLosAngeles, where the first "l" stands for "list") containing the tile coordinates and the turn date. The second one is the foundCity() function which contains this list among other settings (like owner or the defending units).

I'm not looking to replace Rhye's function but rather to make another one with more features. So that you could leave all the spawns made by Rhye as is, but have the option of using another function for your own (or to modify Rhye's) spawns.

The way to add buildings to a spawn could be one of these:

1. You simply feed a number in the function that corresponds to a preset building or set of buildings. So the vale 0 (zero) would be a Granary, 1 would be a Forge and 2 would be a Granary and a Forge, and so forth. Easy to use as long as you know what value do what, but there would be limitations in the code as to what choices you have. The list of possible buildings and combinations could however be comprehensive, so that it would be sufficient for most purposes. Would this require 10 or maybe 20 different settings in order to be useful, you think?

2. You have the choice of enabling any of a select few buildings in any configuration by settings "False" values to "True" inside the function. So a set of "True, False, True, True" would give the city a Granary (True), no Library (False), a Forge (True), and a Harbor (True), as an example. This could mean a very long function that is difficult to handle, as you would have to keep track of what instance of True/False corresponds to what building. Anything above five different buildings could easily become a hassle resulting in the wrong buildings being enabled. Which buildings would be essential for a spawned city?

3. You have to create another list variable containing all the buildings you want for the city. The name of the variable would have to be different from the one mentioned above, but it could be something like lCityBuildings, where "City" is the City name. (So you'd end up with two variables for, say, Los Angeles: lLosAngeles and lLosAngelesBuildings.) The way the modder would set up the list could be like this:
Code:
lLosAngelesBuildings = [con.iGranary, con.iForge, con.iLibrary, con.iHarbor, con.iTheater]
There would be no limitations as to what, how many or what combination of buildings could be entered in the list - or in what order. Note that the iBuilding variables are taken from the file Consts.py where Rhye has defined variables for all the buildings. The con. part simply directs to the Consts.py file (con is short for consts, which in turn is short for constants, that is variables with values that never change).

The third option would arguable be the best as it has no real limitations. It requires some work to use though, and there are more things that could be wrong (as you have to type all the variables exactly as they are found in Costs.py). Also it could be harder to use for anyone who has never done this before.
There aren't that many buildings we'd need to add in my opinion. The only thing I wanted to make sure is that cities spawned in the late game have the same things in them that they would if a settler went and did it manually (just like when you settle a city as America it automatically starts with size 4 and a granary, harbour, market, library and forge). I kinda like option 3 though. It takes a while but as long as the modder rememebers to add "con.iBuildingname" then it sounds easy to simply type out what buildings you want to see :)
 
Top Bottom