New to XML modding

Chemist18

Chieftain
Joined
Jun 24, 2012
Messages
2
I've modded Half-life, Farcry and Fallout3 in the past but none of these worked in the same way.

There is one change I'd like to make to Civilization V that I haven't figured out how do make,

  • Increase the amount of fish placed in maps

I'm hoping the secret of this is hidden in one of the XML files :).


 
I hate to put a dampner on your hopes, but Quantities in CiV are not XML based. They are all assigned in lua, AssignStartingPlots.lua. Even though there are listings in the XML files for it they are currently unused by CiV. On the plus side you have picked 1 of the easier ones to edit since Fish has its own layer in AssignStartingPlots.lua, just search for PlaceFish, it will look like:
Code:
function AssignStartingPlots:PlaceFish(frequency, plot_list)
	-- This function places fish at members of plot_list. (Sounds fishy to me!)
	if plot_list == nil then
		--print("No fish were placed! -PlaceFish");
		return
	end
	local iW, iH = Map.GetGridSize();
	local iNumTotalPlots = table.maxn(plot_list);
	local iNumFishToPlace = math.ceil(iNumTotalPlots / frequency);
	-- Main loop
	local current_index = 1;
	for place_resource = 1, iNumFishToPlace do
		local placed_this_res = false;
		if current_index <= iNumTotalPlots then
			for index_to_check = current_index, iNumTotalPlots do
				if placed_this_res == true then
					break
				else
					current_index = current_index + 1;
				end
				local plotIndex = plot_list[index_to_check];
				if self.fishData[plotIndex] == 0 then
					local x = (plotIndex - 1) % iW;
					local y = (plotIndex - x - 1) / iW;
					local res_plot = Map.GetPlot(x, y)
					if res_plot:GetResourceType(-1) == -1 then
						-- Placing fish here. First decide impact radius of this fish.
						local fish_radius = Map.Rand(7, "Fish Radius - Place Fish LUA");
						if fish_radius > 5 then
							fish_radius = 3;
						end
						res_plot:SetResourceType(self.fish_ID, 1);
						self:PlaceResourceImpact(x, y, 4, fish_radius);
						placed_this_res = true;
						self.amounts_of_resources_placed[self.fish_ID + 1] = self.amounts_of_resources_placed[self.fish_ID + 1] + 1;
					end
				end
			end
		end
	end
end
 
It's easier to change the line that calls that fucntion rather than mess with the placement logic

Code:
self:PlaceFish(10 * bonus_multiplier, self.coast_list);

The number of fish placed is "number of entries in the coast_list divided by (10 times bonus_multiplier)"

The coast_list is just a list of all coastal tiles, you could change that to include other ocean hexes, but then the fish may not be workable by a city.

bonus_multiplier is set depending on whether the user has choosen "sparse", "normal", "abundant", etc resources, so you really don't wan't to change what the user has selected.

So that leaves the 10. Change that to 7 and you'll get approx 40% more fish, to 5 and you'll get twice as many fish as before (assuming they can all be placed, which may not be the case)

HTH

W
 
Back
Top Bottom