Future Worlds

Well, for the time being I was planning to just switch over to using

Code:
for i = 0, pCity:GetNumCityPlots() - 1, 1 do
	local pPlot = pCity:GetCityIndexPlot( i );

instead, to handle walking through the city plots. I'm not certain if this is more or less efficient than using a plot iterator to go through all the possible city plots...
 
That's more efficient, as it is purely a list of all the plots owned by the city and no others, so you don't need to allow for overlaps
 
That's more efficient, as it is purely a list of all the plots owned by the city and no others, so you don't need to allow for overlaps
It runs for all 36 possible plots the city could own, not just the ones it does own. This:
Code:
function CityPlotOwnerShip(pCity)
	local iNumPlots = pCity:GetNumCityPlots()
	for i = 0, iNumPlots - 1 do
		local pPlot = pCity:GetCityIndexPlot(i)
		local plotowner = pPlot:GetOwner()
		if plotowner ~= -1 then
			print("CityPlotOwnerShip: someone owns the plot " .. i .. " near city of " .. pCity:GetName())
		else
			print("CityPlotOwnerShip: the plot is not owned " .. i .. " near city of " .. pCity:GetName())
		end
	end
end
Gives me this in the lua.log:
Spoiler :
Code:
[1120529.500] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 0 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 1 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 2 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 3 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 4 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 5 near city of Washington
[1120529.515] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 6 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 7 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 8 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 9 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 10 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 11 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 12 near city of Washington
[1120529.531] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 13 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 14 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 15 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 16 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 17 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 18 near city of Washington
[1120529.546] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 19 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 20 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 21 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 22 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 23 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 24 near city of Washington
[1120529.562] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 25 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 26 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 27 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 28 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 29 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 30 near city of Washington
[1120529.578] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 31 near city of Washington
[1120529.593] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 32 near city of Washington
[1120529.593] GeneralEventsScripting: CityPlotOwnerShip: the plot is not owned 33 near city of Washington
[1120529.593] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 34 near city of Washington
[1120529.593] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 35 near city of Washington
[1120529.593] GeneralEventsScripting: CityPlotOwnerShip: someone owns the plot 36 near city of Washington
I d'jinnied up the quoted code from a far more complex function I use in one of my mods. Hence some of the variables that aren't really necessary for that test.

You have to account for overlapping city possible ownership of the same plot.
 
I would have sworn blind that each city maintains a list of all the plots it owns in the C++ code, but it doesn't. So not quite as efficient as I thought, but still more efficient than looping X and Y in lua.

(There are 37 plots, not 36 - the one the city is on is counted)
 
I would have sworn blind that each city maintains a list of all the plots it owns in the C++ code, but it doesn't. So not quite as efficient as I thought, but still more efficient than looping X and Y in lua.

(There are 37 plots, not 36 - the one the city is on is counted)
I think it does keep a track of which city owns the plot, but that method does not use it.

Right -- I keep forgetting plot '0'.
 
A plot knows which city owns it. pPlot:SetOwner() takes TWO parameters, the owning player AND the owning city.

Firaxis added a new method (which I can never remember the name of) to get the owning city for a plot - the reason I can never remember is that I modded the DLL such that pPlot:GetOwner() returns TWO values ... local iOwningPlayer, iOwningCity = pPlot:GetOwner() ... and I just use that.
 
Right -- I keep forgetting plot '0'.
Yup, but for the Network Combat promotion he ll need plot '0'
In the LUA, he is using this code
Code:
for pAdjacentPlot in PlotAreaSpiralIterator(pPlot, iRadius, SECTOR_NORTH, DIRECTION_CLOCKWISE, DIRECTION_OUTWARDS, CENTRE_EXCLUDE) do
CENTRE_EXCLUDE, thats the problem for Network Core and Network Node. And the problem with vivarium, drone hive, and sactuary is by adding this.
Code:
local iBuildingVivarium = GameInfoTypes.BUILDING_FW_VIVARIUM
local iBuildingDroneHive = GameInfoTypes.BUILDING_FW_DRONE_HIVE
local iBuildingSanctuary = GameInfoTypes.BUILDING_FW_SANCTUARY
 
Yup, but for the Network Combat promotion he ll need plot '0'
In the LUA, he is using this code
Code:
for pAdjacentPlot in PlotAreaSpiralIterator(pPlot, iRadius, SECTOR_NORTH, DIRECTION_CLOCKWISE, DIRECTION_OUTWARDS, CENTRE_EXCLUDE) do
CENTRE_EXCLUDE, thats the problem for Network Core and Network Node. And the problem with vivarium, drone hive, and sactuary is by adding this.
Code:
local iBuildingVivarium = GameInfoTypes.BUILDING_FW_VIVARIUM
local iBuildingDroneHive = GameInfoTypes.BUILDING_FW_DRONE_HIVE
local iBuildingSanctuary = GameInfoTypes.BUILDING_FW_SANCTUARY
  1. Variable iBuildingVivarium appears not to be defined before being used, so
    Code:
    if pCity:IsHasBuilding(iBuildingVivarium) then
    will default to looking for the Floating Gardens.
  2. Not seeing where there is a problem with either of iBuildingDroneHive or iBuildingSanctuary in the way the two variables are defined.
  3. And I meant that when stating the number of tiles that pCity:GetNumCityPlots() checks I always say '36' when it is 36 outlying tiles plus the city tile itself, '0', for an actual total of 37 tiles checked
 
They're defined in V3 except for iBuildingVivarium
Code:
local [COLOR="Blue"]iBuildingSanctuary[/COLOR] = GameInfoTypes.BUILDING_FW_SANCTUARY
local iBuildingChimeralGarden = GameInfoTypes.BUILDING_FW_CHIMERAL_GARDEN
local [COLOR="blue"]iBuildingDroneHive [/COLOR]= GameInfoTypes.BUILDING_FW_DRONE_HIVE
local iBuildingFeedsiteNode = GameInfoTypes.BUILDING_FW_FEEDSITE_NODE
 
They're defined in V3 except for iBuildingVivarium
Oh, you are right. I was trying to fix the error and mix everything, including the previous version. Haha... :crazyeye:

And I meant that when stating the number of tiles that pCity:GetNumCityPlots() checks I always say '36' when it is 36 outlying tiles plus the city tile itself, '0', for an actual total of 37 tiles checked
When the city just found. It has 6 workable tiles, right. So, the GetNumCityPlots. Is it checking the whole 36 tiles or just 6 tiles?
 
Oh, you are right. I was trying to fix the error and mix everything, including the previous version. Haha... :crazyeye:


When the city just found. It has 6 workable tiles, right. So, the GetNumCityPlots. Is it checking the whole 36 tiles or just 6 tiles?

erm....read upthread about 1/2 of a thread page to posts 161-165
 
As noted, it appears to check all 37 plots. (Which is why the method typically checks to see who owns the plot...)

I should have most of those bugs fixed at this point, although it still needs some more proper testing. I keep getting sidetracked by working on modifying the Undersea Mining Platform building a bit...

Spoiler :




People were pointing out that the Aquaculture Lab tends to be nearly always better than the Undersea Mining Platform, so I figured this tweak might help make it more appealing... :p
 
As noted, it appears to check all 37 plots. (Which is why the method typically checks to see who owns the plot...)

I should have most of those bugs fixed at this point, although it still needs some more proper testing. I keep getting sidetracked by working on modifying the Undersea Mining Platform building a bit...

Spoiler :




People were pointing out that the Aquaculture Lab tends to be nearly always better than the Undersea Mining Platform, so I figured this tweak might help make it more appealing... :p

Also be sure to keep in mind that when two or more cities of the same player can potentially work the same plot you'll have to account for that as well. Usually when I am interested in Improvements, Resources, and the like near cities, I also make a check on whether the plot is being worked, and which city is working the plot. Checking which city is seen by the game as 'owning' the plot is not actually reliable in my experience because when you use the UI to swap which city is working a plot, the original owning city of the plot is still seen as owning the plot.
 
Also be sure to keep in mind that when two or more cities of the same player can potentially work the same plot you'll have to account for that as well. Usually when I am interested in Improvements, Resources, and the like near cities, I also make a check on whether the plot is being worked, and which city is working the plot. Checking which city is seen by the game as 'owning' the plot is not actually reliable in my experience because when you use the UI to swap which city is working a plot, the original owning city of the plot is still seen as owning the plot.

Yes, I've been using IsWorkingPlot to check whether or not a particular city is actually working the plot with an improvement for the Vivarium and Ecosanctuary checks. I've intentionally avoided it with the Drone Hive, because it's supposed to represent automated drones doing the work (rather than human citizens). This does mean a Drone Hive can double-dip on improvements located between two cities, but ah well... I suppose it just means more drones working on the site. :p

I've been considering doing the same thing with the Ecosanctuary, as it reflects happiness/culture derived from having pristine/preserved nature around the city, so it shouldn't really matter who's actually working the tile...
 
Yes, I've been using IsWorkingPlot to check whether or not a particular city is actually working the plot with an improvement for the Vivarium and Ecosanctuary checks. I've intentionally avoided it with the Drone Hive, because it's supposed to represent automated drones doing the work (rather than human citizens). This does mean a Drone Hive can double-dip on improvements located between two cities, but ah well... I suppose it just means more drones working on the site. :p

I've been considering doing the same thing with the Ecosanctuary, as it reflects happiness/culture derived from having pristine/preserved nature around the city, so it shouldn't really matter who's actually working the tile...
You can stick a plot reference into a temporary lua-table that gets set back to 'empty'
Code:
local tTable={}
at the beginning of each player turn. You would do this in each of your PlayerDoTurn events at the very top of the function, then insert data for plots into the temporary table as the code checks all the cities, and then check whether the plot has already been processed for a different city to avoid double-ups of the same plot.
 
People were pointing out that the Aquaculture Lab tends to be nearly always better than the Undersea Mining Platform, so I figured this tweak might help make it more appealing... :p
LOL i thought it was Bionic Tower wonder. Any plan to giving the 3D model for wonders?

Anyway, i was buying the arsenal ship and it can carry 4 missiles. But, when i upgrade the missile cruiser to arsenal ship, it can carry 7 missiles.
I think you gotta give the free promotion: "can carry 3 cargo" and "can carry 1 cargo", instead of "can carry 4 cargo".

And, when we can build the network core improvement, the network node becomes useless. I think you should make it faster to build. When the network core is in 5 turns, perhaps the network node should be in 2 turns.

I saw your code that you put different times for forest, jungle, and marsh when building network node and core. But the worker is chopping down the forest and jungle. And cleaning the marsh when building the network core. But not for network node on marsh.
 
By the way... because this wasn't properly mentioned in the mod itself...

What does the 'Gengineered' promotion exactly do? Apparently it's supposed to enable some new promotion tree or something? I think I've seen a lot of related promotions in the code, but so far they don't work for me. The units get the Gengineered promotion just fine, but there's no change to selectable promotions upon levelup.

Is this not working just for me? Or is there a problem with it for other people as well?

Oh, and another question for the mod creator: When do you think you'll be able to release a new version with the problems mentioned so far ironed out? Sure hope it gets finished soon...
 
By the way... because this wasn't properly mentioned in the mod itself...

What does the 'Gengineered' promotion exactly do? Apparently it's supposed to enable some new promotion tree or something? I think I've seen a lot of related promotions in the code, but so far they don't work for me. The units get the Gengineered promotion just fine, but there's no change to selectable promotions upon levelup.

Is this not working just for me? Or is there a problem with it for other people as well?

I'll take a look into it.

Oh, and another question for the mod creator: When do you think you'll be able to release a new version with the problems mentioned so far ironed out? Sure hope it gets finished soon...

Well, it's currently a victim of feature creep -- as I'm trying to fix the various buggy buildings, I'm doing a pass over them all (including the Wonders) to make some tweaks. The Hyperstructure buildings have all been revised, so hopefully they'll be more interesting, and I'm trying to clarify how some Wonders (such as Digital Emancipation) works. There's also the changes to Undersea Mining (which, in turn, requires assets for a new resource), as well as some new buildings and Wonders I've been wanting to add in.

I still need to go through and update some of the icons, as well as any other bugfixes or changes that need to be made. XD It'll probably be another week or two until its fully ready to go.
 
On the subject of "possible tweaks/bugfixes", I've been wondering if I should adjust how the Node and Core work. Most importantly, currently the code for each uses "SetUnitXY" to check whether or not they're in range of a Node or Core, but that gets to be very time-intensive in the late game when there may be a lot of units running around. A more efficient variation would be to have it just check for units in range of a Node or Core at the start of the turn and provide them with the bonuses -- essentially, rather than continuously updating units in range, it would be a periodic battlefield update for affected units.

So any thoughts?
 
Top Bottom