Altering City Radius

3335d

CCtP Player
Joined
Jun 15, 2012
Messages
642
Would it be possible to alter the city radius through Lua? Nothing in the XML seems to have anything to do with city radius, so I'm hopeful that the Lua has something I can use. I'm working on a component of the Community Call to Power Project in order to allow food importation without needing the DLL, so making the city radius infinite would be an important step in that. I've already made the necessary XML to deal with other factors involved such as the gold cost and yield losses, so I'm not concerned about that now. Nor am I concerned about the UI for now, as I at least need to get this component off the ground.
 
Unless the radius is stored in the XML files (did you look at gamedefines?), I do not think so. Still there is something that may be worth a try: using LUA to forcefully make the city work hexes beyond the 3-hex radius. I would not bet on your success but it's worth trying.

To clarifying things up a little... Regarding the API, only two functions are relevant: the one to make the city work a tile (city:something), and the one to assign hexes to a city (plot:SetOwner). There is of course no "radius" concept anywhere in the API.
 
Unless the radius is stored in the XML files (did you look at gamedefines?), I do not think so. Still there is something that may be worth a try: using LUA to forcefully make the city work hexes beyond the 3-hex radius. I would not bet on your success but it's worth trying.

To clarifying things up a little... Regarding the API, only two functions are relevant: the one to make the city work a tile (city:something), and the one to assign hexes to a city (plot:SetOwner). There is of course no "radius" concept anywhere in the API.

GlobalDefines.xml does not have a <CityRadius> field. Perhaps, then, Firaxis decided to go the easy route and bundle that into the DLL. I'll see what I can do with plot:SetOwner, and then maybe I can enable working tiles with city:something. Perhaps then I can make the food importation feature that I've always wanted....

Thank you DonQuiche. But one more question - in which files can these functions be found?
 
The function to toggle the "worked" flag is city:AlterWorkingPlot. The examples are obviously in the city screen. No idea for setowner, though. I suggest you use notepad++ for its formidable "search in all files" feature (ctrl + shift + f), it totally rocks for civ5 modding (and for text edition in general).

Now you could also look at the IGE code, especially IGE_API_Terrain.lua which contains a function named UpdateOwnership. This function is used anytime a resource is set on a hex to prevent two civ5 bugs (one where the new resource is not completely taken into account unless you remove and add again the ownership, another bug that causes perment yield computations errors if you remove the ownership on a hex worked by a city).

So this function first stores the plots forcefully worked by the city ("forced plots"), then it removes the "worked" flag from this hex, then it removes ownership and adds it again, then it forces the city to reset worked plots to let the AI decides what it thinks is best now, then it restores forced plots. Which means it uses all the functions you could have to use.
 
I haven't found these functions anywhere in the city screen.

I'm new to Lua, so I really don't know how to program it to perform my desired function. I cannot find anywhere the definition of the function AlterWorkingPlot.
 
New to modding civ 5, what's the difference between Lua and modbuddy? I thought Lua was the language it used.

Anyways, tell me if something comes out of this, its incredibly annoying to have a tile in between 3 of your cities but not workable by any of them.
 
I'm new to Lua, so I really don't know how to program it to perform my desired function. I cannot find anywhere the definition of the function AlterWorkingPlot.
There is no documentation asides of a list of functions. You need to look at the game files and understand things by yourself.

New to modding civ 5, what's the difference between Lua and modbuddy? I thought Lua was the language it used.
Lua is indeed the proramming language. Modbuddy is the IDE (integrated environment development). If you don't know what an IDE is, it's basically a code editor with additional features that developers need.
 
Back
Top Bottom