Make a non-coastal city, a coastal city (LUA script)

Can't be done with Lua, you'd need to mod the C++ code (ie the DLL).

A city is coastal if the plot it's on is coastal and there is no way to override this without modding the DLL
 
Can't be done with Lua, you'd need to mod the C++ code (ie the DLL).

A city is coastal if the plot it's on is coastal and there is no way to override this without modding the DLL

Hello and thank you for the reply.

I still have questions.

1). Is it possible to transform the plot into coastal?

2). When does the game check if the city is coastal? when you open the production menu? when we found the city?

3). Is it possible to decompile a DLL, because I already use a custom DLL but it is not mine. so I don't have the code.

4). Do you know the location of the piece of code that checks if the vile is coastal in all the c++ files because there are a lot of them, or if you know what I have to look for, I'm listening.

Thanks again for your response.
 
1). Is it possible to transform the plot into coastal?

2). When does the game check if the city is coastal? when you open the production menu? when we found the city?

3). Is it possible to decompile a DLL, because I already use a custom DLL but it is not mine. so I don't have the code.

4). Do you know the location of the piece of code that checks if the vile is coastal in all the c++ files because there are a lot of them, or if you know what I have to look for, I'm listening.
1) Same issue as a city, the code to ascertain if a plot is coastal is in the C++ code and there is no Lua override available

2) Many, many places. A city doesn't store if it's coastal or not, it asks the plot every time it needs to know.

3) In theory yes, in practice no. Without the source code for the DLL you're using it's just not worth the weeks of effort it will take.

4) Get yourself a good multi-file search tool (eg Agent Ransack) and search all the .cpp/.h files for "isCoastal"
 
1) Same issue as a city, the code to ascertain if a plot is coastal is in the C++ code and there is no Lua override available

2) Many, many places. A city doesn't store if it's coastal or not, it asks the plot every time it needs to know.

3) In theory yes, in practice no. Without the source code for the DLL you're using it's just not worth the weeks of effort it will take.

4) Get yourself a good multi-file search tool (eg Agent Ransack) and search all the .cpp/.h files for "isCoastal"
Hey tanks for your reply
I already found this:

CvCity.h
Line 267 :
bool isCoastal(int iMinWaterSize = -1) const;


CvCity.cpp
Line 6535 :
bool CvCity::isCoastal(int iMinWaterSize) const
{
VALIDATE_OBJECT
return plot()->isCoastalLand(iMinWaterSize);
}
What is the variable int "iMinWatersize" ?
So if i make the IsCoastal function return true, it will make the city coastal ?

EDIT
if I create a first table that contains the ids of the cities (or if it is possible to create a city table, a bit like the units you have their id in the game and their id in the DB, but their id in the game is called Unit and id in the DB Unit ID)
and another which contains bools if the city is coastal or not.

The first table will serve as an index, because I would have to look for the "i" of the city in the index, and this "i" will correspond to the "i" of if the city is coastal.

Then I modified the function, so that if the city is not coastal with the table, it looks if the Plot is coastal, and if when we look in the table, it is coastal then it does not even look at the plot.

EDIT 2

can you explain, in a nutshell, what happens when you call a function via lua, is the function executed in a kind of virtual environment, for example all the variables are recreated for this environment and therefore each city has its environment with it varies. where the function is executed regardless of the city?
for example what makes me ask is this: pPolt:GetImprovementType() in this function pPlot is a variable which represents the plot but how does the code of this function know that it must execute at this plot?
 
Last edited:
It's C++, so will need to be compiled to make a DLL, but you're using a modded DLL that you don't have the source code for so you can't do that. Also, your approach ignores the fact that a) you have no way of working out what the city ids are for each game and b) that city ids are not unique among players, c) other stuff
 
Hi, I've been trying to contact the creator of the DLL for a while now but I think he's dead, so I looked for an alternative. my research led me to this page: https://forums.civfanatics.com/threads/bridges-and-canals.561332/
you are discussing the same DLL that I use, him from the Canals and bridges mod, I saw that there is an alternative to this DLL and it is yours. https://github.com/whoward69/DLL-VMC
He would add the <MakesPassable> tag. Does this tag work the same way as the other DLL, i.e. does it allow naval units and naval trade routes to pass through a land plot? Like the other DLL I have to add the <MakesPassable> tag in the Improvement table via SQL? and the biggest question, can I edit your code and then send you the changes?
Is your DLL available as a mod on the worshop? I could say that my mod is dependent on yours.
 
All my mods can be found from the link in my sig. Do I accept code changes, no Can you make your changes and then release the mod-mod yourself, yes. Does it work the same - don't know as a) I don't use that mod and b) the source code is unavailable. You can use SQL/or XML to make changes, please look at any of my other mods to work out for yourself how to do this.
 
Back
Top Bottom