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