Hey!
I currently have a working mod for razing cities if they are hit by a nuclear weapon, and it works very well, the only issue is, it doesn't work for the AI.
This is something that I would like as it would be game changing if it could. A way of "fixing" the issue with the AI nuking the same city repeatedly.
I can't work out why it doesn't work for them, I'm assuming the events used to call it aren't used for AI actions?
Here is my WorldInput.lua:
I'm sure i'm doing something wrong as my Lua knowledge is very limited, but i'd love to know if there's a way for the AI to utilize this?
I currently have a working mod for razing cities if they are hit by a nuclear weapon, and it works very well, the only issue is, it doesn't work for the AI.
This is something that I would like as it would be game changing if it could. A way of "fixing" the issue with the AI nuking the same city repeatedly.
I can't work out why it doesn't work for them, I'm assuming the events used to call it aren't used for AI actions?
Here is my WorldInput.lua:
Code:
include("WorldInput_Expansion2.lua");
function WMDStrike( plot, unit, eWMD )
local tParameters = {};
tParameters[UnitOperationTypes.PARAM_X] = plot:GetX();
tParameters[UnitOperationTypes.PARAM_Y] = plot:GetY();
tParameters[UnitOperationTypes.PARAM_WMD_TYPE] = eWMD;
if (UnitManager.CanStartOperation(unit, UnitOperationTypes.WMD_STRIKE, nil, tParameters)) then
ExposedMembers.City_Razing.Strike_Parameters = {X = tParameters[UnitOperationTypes.PARAM_X], Y = tParameters[UnitOperationTypes.PARAM_Y], Warhead = eWMD};
UnitManager.RequestOperation(unit, UnitOperationTypes.WMD_STRIKE, tParameters);
UI.SetInterfaceMode(InterfaceModeTypes.SELECTION);
end
end
function ICBMStrike( fromCity, sourcePlotX, sourcePlotY, targetPlot, eWMD )
local tParameters = {};
tParameters[CityCommandTypes.PARAM_X0] = sourcePlotX;
tParameters[CityCommandTypes.PARAM_Y0] = sourcePlotY;
tParameters[CityCommandTypes.PARAM_X1] = targetPlot:GetX();
tParameters[CityCommandTypes.PARAM_Y1] = targetPlot:GetY();
tParameters[CityCommandTypes.PARAM_WMD_TYPE] = eWMD;
if (CityManager.CanStartCommand(fromCity, CityCommandTypes.WMD_STRIKE, tParameters)) then
ExposedMembers.City_Razing.Strike_Parameters = {X = tParameters[UnitOperationTypes.PARAM_X1], Y = tParameters[UnitOperationTypes.PARAM_Y1], Warhead = eWMD};
CityManager.RequestCommand(fromCity, CityCommandTypes.WMD_STRIKE, tParameters);
UI.SetInterfaceMode(InterfaceModeTypes.SELECTION);
end
end
function City_Razing_Initialize()
if (not ExposedMembers.City_Razing) then
ExposedMembers.City_Razing = {};
end
end
City_Razing_Initialize();
I'm sure i'm doing something wrong as my Lua knowledge is very limited, but i'd love to know if there's a way for the AI to utilize this?
Last edited: