R.E.D. World War II development thread

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 :

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 :D

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)
 
Yes I have that problem, I don't know if its true in the 1942 scenario but in the the 1936 scenario I'm unable to build American Projects which leads to planes, but I am looking into it maybe its because of the new formatting ?

EDIT: I've finished the fall of Poland and France. However I'm having trouble creating this event. In the console it does "updating territory map..." then keeps looping several times the same dprint, then freezes. Ive tried a couple different things but havn't been able to figure it out.

Spoiler :
Code:
-----------------------------------------
-- Fall of Denmark
-----------------------------------------
function FallOfDenmark(hexPos, playerID, cityID, newPlayerID)
	local cityPlot = Map.GetPlot( ToGridFromHex( hexPos.x, hexPos.y ) )

	local x, y = ToGridFromHex( hexPos.x, hexPos.y )
	local civID = GetCivIDFromPlayerID(newPlayerID, false)
	local pAxis = Players[newPlayerID]
	if x == 88 and y == 57 then -- city of Copenhagen 
		Dprint ("-------------------------------------")
		Dprint ("Scripted Event : Copenhagen Captured !")		

		if (civID == GERMANY) then -- captured by Germany...
			Dprint("- Captured by Germany ...")


			local iGermany = GetPlayerIDFromCivID (GERMANY, false, true)
			local pGermany = Players[iGermany]

			local iAmerica = GetPlayerIDFromCivID (AMERICA, false, true)
			local pAmerica = Players[iAmerica]

			local team = Teams[ pGermany:GetTeam() ]
			Dprint("- Germany Selected ...")
			local pCopenhagen = cityPlot:GetPlotCity()
			local savedData = Modding.OpenSaveData()
			local iValue = savedData.GetValue("DenmarkHasFalled")
			if (iValue ~= 1) then
				Dprint("- First occurence, launching Fall of Denmark script ...")

				local iDenmark = GetPlayerIDFromCivID (DENMARK, true, true)
				local pDenmark = Players[iDenmark]


				-- todo :
				-- save from units for UK
				--Dprint("- Change Denmark units ownership ...")	
				for unit in pDenmark:Units() do 
					--ChangeUnitOwner (unit, iEngland)
					unit:Kill()
				end						

				Dprint("- Change Denmark cities ownership ...")	
				for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
					local plot = Map.GetPlotByIndex(iPlotLoop)
					local x = plot:GetX()
					local y = plot:GetY()
					local plotKey = GetPlotKey ( plot )
					if plot:IsCity() then
						city = plot:GetPlotCity()
						local originalOwner = GetPlotFirstOwner(plotKey)
						if city:GetOwner() == iDenmark and originalOwner ~= iDenmark then -- liberate cities captured by Denmark
							Dprint(" - " .. city:GetName() .. " was captured, liberate...")	
							local originalPlayer = Players[originalOwner]
							originalPlayer:AcquireCity(city, false, true)
							--city:SetOccupied(false) -- needed in this case ?
						elseif originalOwner == iDenmark then
							if (x > 81 and x < 110)  then -- Germany
								Dprint(" - " .. city:GetName() .. " is in Germany sphere...")	
								if city:GetOwner() ~= iGermany then 
									pGermany:AcquireCity(city, false, true)
									city:SetPuppet(false)
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								else -- just remove resistance if city was already occupied
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
						elseif (x > 2 and x < 81) then -- AMERICA
									Dprint(" - " .. city:GetName() .. " is in America sphere...")
									if city:GetOwner() ~= iAmerica then 
										pAmerica:AcquireCity(city, false, true)
										city:SetPuppet(false)
										city:ChangeResistanceTurns(-city:GetResistanceTurns())
									else -- just remove resistance if city was already occupied
										city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
							end					
						end
					end
				
					-- remove resistance from Copenhagen
					pCopenhagen:ChangeResistanceTurns(-pCopenhagen:GetResistanceTurns())
--				
--					Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pDenmark:GetName() .. " government has fled the country, Denmark has fallen to Germany. The United Kingdom has assigned Greenland and Iceland to the American Government.", pDenmark:GetName() .. " has fallen !", -1, -1)
--
--					savedData.SetValue("DenmarkHasFalled", 1)
--				end
--			end
--		end
--	end
--end
---Events.SerialEventCityCaptured.Add( FallOfDenmark )
 
Yes I have that problem, I don't know if its true in the 1942 scenario but in the the 1936 scenario I'm unable to build American Projects which leads to planes, but I am looking into it maybe its because of the new formatting ?

Yes it is the same in the 1942 scenario. No USA planes can be built. There is a message at the start of the 42 scenario that indicates you have completed projects related to airplanes, but you can not build any.
 
thanks all, investigating the issue
 
@T_KCommanderbly : for the 1942 scenario, the new projects you've created for earlier units (P-40, P-38, B-17, B-25) to use in the 1936 scenario where note defined in the 1942 files (in g_Major_Projects and g_Projects_Done).

Units are linked to project, any scenario wanting to use a unit must have the corresponding project defined.

I had edited the 1940 files to reflect that, but forgot to do so in the 1942 one.

So I've removed the g_Major_Projects table from the 1942 and 1936 define files, as I suppose you want all units to be available there, and they are all listed in the g_Major_Projects table of main defines file.

When re-defined in the scenario define, g_Major_Projects allows you to restrict projects for the theater of operation of that scenario by removing unwanted reference.

And I've added the missing references in g_Projects_Done for the 1942 files.


Now I'm looking at the 1936 case, as they where correctly defined here...
 
I believe the term England - seen on the thread post - is incorrect. I'm not sure if this is the case in the game.

At the time, England was one of the four constituent countries of the United Kingdom, which was made up from England, Wales, Scotland and Northern Ireland (I beleive the Irish Republic split in the inter-war period).

So, basically, England should be United Kingdom, and English should be British.
 
Yep it's UK in game. But I'll check for English/British, thanks.

There are some inconsistency in my code on that part as I've taken the England civilization as a base for the UK... But in game it should always refer to UK, so you can report any missing text I've left there.
 
Now it should be :D

The PROJECT_M4A2 was not correctly defined (was defined as PROJECT_M4A2 and the game was looking for PROJECT_M4A2SHERMANIII, making it and all following entry of the USA projects table ignored...)

so here's v.17 beta2
 

Attachments

  • R.E.D. WWII Edition (v 17).7z
    1.1 MB · Views: 41
Roosevelt
Adolf Hitler - Furher of the First Reich

Chinese man
Cahrles de Gaulle - ... of France

Japan
Adolf Hitler - Furher of the Third Reich
 
Roosevelt
Adolf Hitler - Furher of the First Reich

Chinese man
Cahrles de Gaulle - ... of France

Japan
Adolf Hitler - Furher of the Third Reich

Yep, T_KCommanderbly has used some placeholder for the new nations needed in the 1936/1942 scenarii, if someone has the time to make the corresponding text that would help.
 
Yes I have that problem, I don't know if its true in the 1942 scenario but in the the 1936 scenario I'm unable to build American Projects which leads to planes, but I am looking into it maybe its because of the new formatting ?

EDIT: I've finished the fall of Poland and France. However I'm having trouble creating this event. In the console it does "updating territory map..." then keeps looping several times the same dprint, then freezes. Ive tried a couple different things but havn't been able to figure it out.

Spoiler :
Code:
-----------------------------------------
-- Fall of Denmark
-----------------------------------------
function FallOfDenmark(hexPos, playerID, cityID, newPlayerID)
	local cityPlot = Map.GetPlot( ToGridFromHex( hexPos.x, hexPos.y ) )

	local x, y = ToGridFromHex( hexPos.x, hexPos.y )
	local civID = GetCivIDFromPlayerID(newPlayerID, false)
	local pAxis = Players[newPlayerID]
	if x == 88 and y == 57 then -- city of Copenhagen 
		Dprint ("-------------------------------------")
		Dprint ("Scripted Event : Copenhagen Captured !")		

		if (civID == GERMANY) then -- captured by Germany...
			Dprint("- Captured by Germany ...")


			local iGermany = GetPlayerIDFromCivID (GERMANY, false, true)
			local pGermany = Players[iGermany]

			local iAmerica = GetPlayerIDFromCivID (AMERICA, false, true)
			local pAmerica = Players[iAmerica]

			local team = Teams[ pGermany:GetTeam() ]
			Dprint("- Germany Selected ...")
			local pCopenhagen = cityPlot:GetPlotCity()
			local savedData = Modding.OpenSaveData()
			local iValue = savedData.GetValue("DenmarkHasFalled")
			if (iValue ~= 1) then
				Dprint("- First occurence, launching Fall of Denmark script ...")

				local iDenmark = GetPlayerIDFromCivID (DENMARK, true, true)
				local pDenmark = Players[iDenmark]


				-- todo :
				-- save from units for UK
				--Dprint("- Change Denmark units ownership ...")	
				for unit in pDenmark:Units() do 
					--ChangeUnitOwner (unit, iEngland)
					unit:Kill()
				end						

				Dprint("- Change Denmark cities ownership ...")	
				for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
					local plot = Map.GetPlotByIndex(iPlotLoop)
					local x = plot:GetX()
					local y = plot:GetY()
					local plotKey = GetPlotKey ( plot )
					if plot:IsCity() then
						city = plot:GetPlotCity()
						local originalOwner = GetPlotFirstOwner(plotKey)
						if city:GetOwner() == iDenmark and originalOwner ~= iDenmark then -- liberate cities captured by Denmark
							Dprint(" - " .. city:GetName() .. " was captured, liberate...")	
							local originalPlayer = Players[originalOwner]
							originalPlayer:AcquireCity(city, false, true)
							--city:SetOccupied(false) -- needed in this case ?
						elseif originalOwner == iDenmark then
							if (x > 81 and x < 110)  then -- Germany
								Dprint(" - " .. city:GetName() .. " is in Germany sphere...")	
								if city:GetOwner() ~= iGermany then 
									pGermany:AcquireCity(city, false, true)
									city:SetPuppet(false)
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								else -- just remove resistance if city was already occupied
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
						elseif (x > 2 and x < 81) then -- AMERICA
									Dprint(" - " .. city:GetName() .. " is in America sphere...")
									if city:GetOwner() ~= iAmerica then 
										pAmerica:AcquireCity(city, false, true)
										city:SetPuppet(false)
										city:ChangeResistanceTurns(-city:GetResistanceTurns())
									else -- just remove resistance if city was already occupied
										city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
							end					
						end
					end
				
					-- remove resistance from Copenhagen
					pCopenhagen:ChangeResistanceTurns(-pCopenhagen:GetResistanceTurns())
--				
--					Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pDenmark:GetName() .. " government has fled the country, Denmark has fallen to Germany. The United Kingdom has assigned Greenland and Iceland to the American Government.", pDenmark:GetName() .. " has fallen !", -1, -1)
--
--					savedData.SetValue("DenmarkHasFalled", 1)
--				end
--			end
--		end
--	end
--end
---Events.SerialEventCityCaptured.Add( FallOfDenmark )
Here it is :

Spoiler :
Code:
-----------------------------------------
-- Fall of Denmark
-----------------------------------------
function FallOfDenmark(hexPos, playerID, cityID, newPlayerID)
	local cityPlot = Map.GetPlot( ToGridFromHex( hexPos.x, hexPos.y ) )

	local x, y = ToGridFromHex( hexPos.x, hexPos.y )
	local civID = GetCivIDFromPlayerID(newPlayerID, false)
	local pAxis = Players[newPlayerID]
	if x == 88 and y == 57 then -- city of Copenhagen 
		Dprint ("-------------------------------------")
		Dprint ("Scripted Event : Copenhagen Captured !")		

		if (civID == GERMANY) then -- captured by Germany...
			Dprint("- Captured by Germany ...")


			local iGermany = GetPlayerIDFromCivID (GERMANY, false, true)
			local pGermany = Players[iGermany]

			local iAmerica = GetPlayerIDFromCivID (AMERICA, false, true)
			local pAmerica = Players[iAmerica]

			local team = Teams[ pGermany:GetTeam() ]
			Dprint("- Germany Selected ...")
			local pCopenhagen = cityPlot:GetPlotCity()
			local savedData = Modding.OpenSaveData()
			local iValue = savedData.GetValue("DenmarkHasFalled")
			if (iValue ~= 1) then
				Dprint("- First occurence, launching Fall of Denmark script ...")

				local iDenmark = GetPlayerIDFromCivID (DENMARK, true, true)
				local pDenmark = Players[iDenmark]


				-- todo :
				-- save from units for UK
				--Dprint("- Change Denmark units ownership ...")	
				for unit in pDenmark:Units() do 
					--ChangeUnitOwner (unit, iEngland)
					unit:Kill()
				end						

				Dprint("- Change Denmark cities ownership ...")	
				for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
					local plot = Map.GetPlotByIndex(iPlotLoop)
					local x = plot:GetX()
					local y = plot:GetY()
					local plotKey = GetPlotKey ( plot )
					if plot:IsCity() then	
						city = plot:GetPlotCity()
						local originalOwner = GetPlotFirstOwner(plotKey)
						if city:GetOwner() == iDenmark and originalOwner ~= iDenmark then -- liberate cities captured by Denmark
							Dprint(" - " .. city:GetName() .. " was captured, liberate...")	
							local originalPlayer = Players[originalOwner]
							originalPlayer:AcquireCity(city, false, true)
							--city:SetOccupied(false) -- needed in this case ?
						elseif originalOwner == iDenmark then
							if (x > 81 and x < 110)  then -- Germany
								Dprint(" - " .. city:GetName() .. " is in Germany sphere...")	
								if city:GetOwner() ~= iGermany then 
									pGermany:AcquireCity(city, false, true)
									city:SetPuppet(false)
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								else -- just remove resistance if city was already occupied
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
							elseif (x > 2 and x < 81) then -- AMERICA
								Dprint(" - " .. city:GetName() .. " is in America sphere...")
								if city:GetOwner() ~= iAmerica then 
									pAmerica:AcquireCity(city, false, true)
									city:SetPuppet(false)
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								else -- just remove resistance if city was already occupied
									city:ChangeResistanceTurns(-city:GetResistanceTurns())
								end
							end					
						end
					end
				end
				
				-- remove resistance from Copenhagen
				pCopenhagen:ChangeResistanceTurns(-pCopenhagen:GetResistanceTurns())
				
				Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pDenmark:GetName() .. " government has fled the country, Denmark has fallen to Germany. The United Kingdom has assigned Greenland and Iceland to the American Government.", pDenmark:GetName() .. " has fallen !", -1, -1)

				savedData.SetValue("DenmarkHasFalled", 1)
	
			end
		end
	end
end
Events.SerialEventCityCaptured.Add( FallOfDenmark )

quickly tested, seems to work correctly now :D
 
Thanks, A lot! Everything seems to be working good. :)

I don't know what your guys opinions are but I'm going to leave out a fall of Yugoslavia and a fall of Greece event. I did add a Norway event so that Germany doesn't have to conquer every single city.

I'm hoping to add a Liberation of Africa and Liberation of Italy event (I'll probably wait on these), but are they planned for your 1940 scenario Gedemon?

And I could work on units, I don't know what units you have planned next.
 
There is a custom liberation of Africa event, when allies take back french colonies.

I've not started others, and I will surely use your Fall of Denmark event...

For new units I want to find a way to prevent the 256 limit first. I've a few ideas, but they may be difficult to integrate without messing your scenarii.
 
For new units I want to find a way to prevent the 256 limit first. I've a few ideas, but they may be difficult to integrate without messing your scenarii.

Unfortunately this is the point in which you need to take a step back and define exactly what criteria will allow a unit to be included in the game.

As hard and fast rules (examples):

- Is the unit choice appropriate at divisions/brigade level (assuming this is the scale being used)?

- Do production dates overlap? This could justify merging certain types of units. Example would be the Hummel and Wespe SP Guns being produced months apart and serving the same role. You could merge these vehicles into one group and utilize the member art def tags to show both types of vehicles in one unit.

- Were production runs long enough? Some PzKpfw IV variants only ran for a very short period of time and would only justify a few turns in your scenario.

- Do production numbers justify its usage? Good example here are the KV-2 (334?), Bison I (32?) AND II (12?) or some variants of tanks. Try having a hard target such as 400+ vehicles developed.

This is very hard to do in post-production stage, but a necessary evil at some point.

I also know that some of the WWII fans here would be upset if it means losing that beloved unique unit...but you need to draw a line in the sand unless Firaxis raises the cap limit.
 
Top Bottom