here's the current development of v.17, with the 1936 files merged and first functions for maritime convoy...
those supply roads are specific to each scenario, I've put the define example in ScriptEuro1940.lua :
The functions to handle the convoy spawning and moving are a bit dispersed atm, I'll surely group them all in a SupplyRoute.lua soon... But defining multiple convoy routes using the above example for T_KCommanderbly maps is already possible
what's coded:
- convoy spawning, depending on the return of the condition fuction
- selecting a reachable destination
- automove to it (even for human player convoy, you'll have to protect them, but you won't directly control the convoy itself)
what's todo :
- change destination on the fly if the current one become unreachable (atm the convoy stop and the human player can control it until the original destination became open again)
- make it go for an adjacent plot of the destination if it can't reach it because of a friendly unit already on it...
- force subs to hunt convoys
- convoy safe arrival should give different bonuses : materiel, personnel, new unit... (only material now)
those supply roads are specific to each scenario, I've put the define example in ScriptEuro1940.lua :
Spoiler :
Code:
-- first define the check functions that will be stocked in the g_Convoy table...
function IsRouteOpenUStoFrance()
local bDebug = true
Dprint(" - Checking possible maritime route from US to France", bDebug)
local turn = Game.GetGameTurn()
if g_Calendar[turn] then
turnDate = g_Calendar[turn].Number
else
turnDate = 0
end
-- if turnDate < 194000101 then
if turnDate < 0 then -- testing
return false
end
local open = false
local destinationList = g_Convoy[US_TO_FRANCE].DestinationList
for i, destination in ipairs(destinationList) do
local plot = GetPlot (destination.X, destination.Y )
Dprint(" - Testing plot at : " .. destination.X .. "," .. destination.Y , bDebug)
if plot:IsCity() then
local city = plot:GetPlotCity()
Dprint(" - Plot is city...", bDebug)
if city:GetOwner() == GetPlayerIDFromCivID( FRANCE, false ) and not city:IsBlockaded() then
Dprint(" - " .. city:GetName() .. " is owned by france and not blockaded !", bDebug)
open = true
end
end
end
return open
end
-- Route list
US_TO_FRANCE = 1
-- Convoy table
g_Convoy = {
[US_TO_FRANCE] = {
Name = "US to France",
SpawnList = { {X=0, Y=50}, {X=0, Y=55}, {X=0, Y=60}, {X=0, Y=65}, {X=0, Y=70}, {X=0, Y=75}, },
RandomSpawn = true, -- true : random choice in spawn list
DestinationList = { {X=21, Y=42}, {X=21, Y=45}, {X=29, Y=50}, {X=29, Y=34}, }, -- La Rochelle, St Nazaire, Dunkerque, Marseille
RandomDestination = false, -- false : sequential try in destination list
CivID = FRANCE,
MaxFleet = 1, -- how many convoy can use that route at the same time (not implemented)
Frequency = 25, -- probability (in percent) of convoy spawning at each turn
Condition = IsRouteOpenUStoFrance,
},
}
The functions to handle the convoy spawning and moving are a bit dispersed atm, I'll surely group them all in a SupplyRoute.lua soon... But defining multiple convoy routes using the above example for T_KCommanderbly maps is already possible
what's coded:
- convoy spawning, depending on the return of the condition fuction
- selecting a reachable destination
- automove to it (even for human player convoy, you'll have to protect them, but you won't directly control the convoy itself)
what's todo :
- change destination on the fly if the current one become unreachable (atm the convoy stop and the human player can control it until the original destination became open again)
- make it go for an adjacent plot of the destination if it can't reach it because of a friendly unit already on it...
- force subs to hunt convoys
- convoy safe arrival should give different bonuses : materiel, personnel, new unit... (only material now)