Help trying to create additional formations (corps/army/?)

chillbaka1

Chieftain
Joined
Nov 13, 2016
Messages
46
I need some help figuring out how to add in additional formations that extend past armies. While experimenting with some AI tweeks, I set the PrereqCivic in UnitCommands for "Form Corps" and "Form Army" to null. The results were great, many more cities were taken throughout the game, they defended cities more effectively, and the AI did not run into its typical "um... how and where do we move, theres units everywhere" problem. It seems to have slightly fixed the 1 UPT issue, but I believe it could be better. (I at least want to try)

The only problem is, I have no idea how to start going about doing this. I know what changes to make in GlobalParameters and UnitCommands. I figured that I will need to add in a command somehow to form additional formations, update some part of the code to make math work correctly, 2+2=4 instead of the current 2+2=3. (corps + corps = army) Ill probably need to add some UI aspect as well, along with new descriptions to civics, ect. I just don't know which one i should start on first, and exactly where to add in new things.
 
I doubt it's possible.
That's the code in WorldInput.lua to form an army:
Code:
------------------------------------------------------------------------------------------------
-- Code related to the Unit's 'Form Army' mode
------------------------------------------------------------------------------------------------
function FormArmy( pInputStruct )
    local plotID = UI.GetCursorPlotID();
	if (Map.IsPlot(plotID)) then
		local plot = Map.GetPlotByIndex(plotID);
		local unitList	= Units.GetUnitsInPlotLayerID(  plot:GetX(), plot:GetY(), MapLayers.ANY );
		local pSelectedUnit = UI.GetHeadSelectedUnit();

		local tParameters :table = {};
		for i, pUnit in ipairs(unitList) do
			tParameters[UnitCommandTypes.PARAM_UNIT_PLAYER] = pUnit:GetOwner();
			tParameters[UnitCommandTypes.PARAM_UNIT_ID] = pUnit:GetID();
			if (UnitManager.CanStartCommand( pSelectedUnit, UnitCommandTypes.FORM_ARMY, tParameters)) then
				UnitManager.RequestCommand( pSelectedUnit, UnitCommandTypes.FORM_ARMY, tParameters);
    			UI.SetInterfaceMode(InterfaceModeTypes.SELECTION);	
			end
		end
	end
							
	return true;
end
It uses a UnitManager.RequestCommand call to make that army. That's something that is not moddable right now.

Now, theoritcally you could probably create custom code to replace two units for one new stronger, normally not buildable unit. But I don't think the AI will know about this.
 
I doubt it's possible.
That's the code in WorldInput.lua to form an army:
Code:
------------------------------------------------------------------------------------------------
-- Code related to the Unit's 'Form Army' mode
------------------------------------------------------------------------------------------------
function FormArmy( pInputStruct )
    local plotID = UI.GetCursorPlotID();
    if (Map.IsPlot(plotID)) then
        local plot = Map.GetPlotByIndex(plotID);
        local unitList    = Units.GetUnitsInPlotLayerID(  plot:GetX(), plot:GetY(), MapLayers.ANY );
        local pSelectedUnit = UI.GetHeadSelectedUnit();

        local tParameters :table = {};
        for i, pUnit in ipairs(unitList) do
            tParameters[UnitCommandTypes.PARAM_UNIT_PLAYER] = pUnit:GetOwner();
            tParameters[UnitCommandTypes.PARAM_UNIT_ID] = pUnit:GetID();
            if (UnitManager.CanStartCommand( pSelectedUnit, UnitCommandTypes.FORM_ARMY, tParameters)) then
                UnitManager.RequestCommand( pSelectedUnit, UnitCommandTypes.FORM_ARMY, tParameters);
                UI.SetInterfaceMode(InterfaceModeTypes.SELECTION);   
            end
        end
    end
                           
    return true;
end
It uses a UnitManager.RequestCommand call to make that army. That's something that is not moddable right now.

Now, theoritcally you could probably create custom code to replace two units for one new stronger, normally not buildable unit. But I don't think the AI will know about this.

That's too bad, but thanks for your help. I wont waste anymore time trying to figure it out, I figured it would be difficult. I'm also guessing that this still won't be moddable even with the SDK release and probably requires the DLL?
 
That's too bad, but thanks for your help. I wont waste anymore time trying to figure it out, I figured it would be difficult. I'm also guessing that this still won't be moddable even with the SDK release and probably requires the DLL?
Yeah, I suppose so.
 
Back
Top Bottom