jerseymike25
Chieftain
- Joined
- Dec 24, 2005
- Messages
- 50
This builds off of the thread I started in the Main C&C Forum - however this is a completed version of the Mod, so this forum is more appropriate.
Airport
Required Tech: Flight
Cost: 600
Maintenance: 5
Purpose: When an Airport is built in a city, it allows a unit to be Airlifted to another city that also has an Airport, assuming that destination city does not have a Non-Garrisoned unit already. Late-game War, especially on bigger maps, is bogged-down by moving units great distances. This helps that problem (for the user, anyway.)
Compatability: Should be compatable with any Mod that does NOT use the Airlift InterfaceMode.
This building makes use of one of the left-over Civ4 stubs, the Airlift "mission" that was not otherwise implemented in Vanilla Civ 5. Included with this Mod, however, are UI treatments and restrictions on the standard Airlift logic when the mission is selected. When a unit is selected for Airlift, hexes under each of the user's Cities are highlighted in Green or Red indicating whether or not the unit can be Airlifted to that destination. Once the user clicks the left-mouse (typically to send the unit to its intended destination city), logic within this mod will determine if the Unit should actually be sent to the destination or not. For example, the vanilla "Airlift" functionality was to allow the Unit to be sent to any of the user's cities, regardless of whether or not the destination had an Airport or already had a non-garissoned unit there.
When I first made that other post, I mentioned that it required modifying Ingame.lua and Worldview.lua to achieve the kind of experience I was looking for with a Mod like this. I've since gone and figured out how to get what I wanted without modifying those files - something that I have not seen fully documented here (or much in general), although this post from Omni covers the stuff that I had previously placed into WorldView.lua.
The Hex highlighting, which was previously tacked into Ingame.lua, is accomplished by registering my mod with the Events.InterfaceModeChanged event. My mod will check if the InterfaceMode has changed to INTERFACE_AIRLIFT, and if so, it will do the Hex highlights and allow whatever else is registered with InterfaceModeChanged to do what it needs to. If the previous InterfaceMode was for airlift, it will clear all of the Hex highlights.
For the logic that controls whether or not a unit can be sent to the destination City, I used ContextPtr:SetInputHandler and took action on LButtonUp. If the selected Hex allowed for a unit to be airlifted to it, then I did the work required and passed the message into the Game.SelectionListGameNetMessage function (as seen in WorldView.lua in a few places), and returned true from my handler indicicating that the LButtonUp action had been handled.
Issues:
- No idea if the AI could make use of this. I would assume not.
- Does not create a Trade Route, as much as I would love it to do so.
- I can't get my GameSpy account to work, so I can't actually upload the Mod to be grabbed inside of the game. I used the Export function on ModBuddy to create a template and have attached it here.
- My kids are clamoring for my attention and my wife is giving me the evil eye, so I don't remember what other issues there might have been.
Airport
Required Tech: Flight
Cost: 600
Maintenance: 5
Purpose: When an Airport is built in a city, it allows a unit to be Airlifted to another city that also has an Airport, assuming that destination city does not have a Non-Garrisoned unit already. Late-game War, especially on bigger maps, is bogged-down by moving units great distances. This helps that problem (for the user, anyway.)
Compatability: Should be compatable with any Mod that does NOT use the Airlift InterfaceMode.
This building makes use of one of the left-over Civ4 stubs, the Airlift "mission" that was not otherwise implemented in Vanilla Civ 5. Included with this Mod, however, are UI treatments and restrictions on the standard Airlift logic when the mission is selected. When a unit is selected for Airlift, hexes under each of the user's Cities are highlighted in Green or Red indicating whether or not the unit can be Airlifted to that destination. Once the user clicks the left-mouse (typically to send the unit to its intended destination city), logic within this mod will determine if the Unit should actually be sent to the destination or not. For example, the vanilla "Airlift" functionality was to allow the Unit to be sent to any of the user's cities, regardless of whether or not the destination had an Airport or already had a non-garissoned unit there.
When I first made that other post, I mentioned that it required modifying Ingame.lua and Worldview.lua to achieve the kind of experience I was looking for with a Mod like this. I've since gone and figured out how to get what I wanted without modifying those files - something that I have not seen fully documented here (or much in general), although this post from Omni covers the stuff that I had previously placed into WorldView.lua.
The Hex highlighting, which was previously tacked into Ingame.lua, is accomplished by registering my mod with the Events.InterfaceModeChanged event. My mod will check if the InterfaceMode has changed to INTERFACE_AIRLIFT, and if so, it will do the Hex highlights and allow whatever else is registered with InterfaceModeChanged to do what it needs to. If the previous InterfaceMode was for airlift, it will clear all of the Hex highlights.
Spoiler :
Code:
function Airport_OnInterfaceModeChanged( oldInterfaceMode, newInterfaceMode)
--print("Airport_OnInterfaceModeChanged entered.");
if (newInterfaceMode == InterfaceModeTypes.INTERFACEMODE_AIRLIFT) then
ShowAirLiftView();
else if (oldInterfaceMode == InterfaceModeTypes.INTERFACEMODE_AIRLIFT) then
HideAirLiftView();
end
end
Events.InterfaceModeChanged.Add( Airport_OnInterfaceModeChanged );
For the logic that controls whether or not a unit can be sent to the destination City, I used ContextPtr:SetInputHandler and took action on LButtonUp. If the selected Hex allowed for a unit to be airlifted to it, then I did the work required and passed the message into the Game.SelectionListGameNetMessage function (as seen in WorldView.lua in a few places), and returned true from my handler indicicating that the LButtonUp action had been handled.
Spoiler :
Code:
----------------------------------------------------------------
-- Input handling
----------------------------------------------------------------
function Airport_InputHandler( uiMsg, wParam, lParam )
local interfaceMode = UI.GetInterfaceMode();
if (interfaceMode == InterfaceModeTypes.INTERFACEMODE_AIRLIFT) and (uiMsg == MouseEvents.LButtonUp) then
local plot = Map.GetPlot( UI.GetMouseOverHex() );
local plotX = plot:GetX();
local plotY = plot:GetY();
local bShift = UIManager:GetShift();
local eInterfaceModeMission = GameInfoTypes[GameInfo.InterfaceModes[interfaceMode].Mission];
-- Did the plot clicked actually have a city? If not, return and indicate the input is done, and reset the interface mode.
if plot:IsCity() == false then
--print("Plot is not a city. Return true, reset interface mode.");
UI.SetInterfaceMode(InterfaceModeTypes.INTERFACEMODE_SELECTION);
return true;
end
local city = plot:GetPlotCity();
if city:IsHasBuilding( GameInfo.Buildings["BUILDING_AIRPORT"].ID) then
local garrisonedUnit = city:GetGarrisonedUnit();
if (plot:GetNumUnits() == 0) or (garrisonedUnit and plot:GetNumUnits() == 1) then
if eInterfaceModeMission ~= MissionTypes.NO_MISSION then
if UI.CanDoInterfaceMode(interfaceMode) then
Game.SelectionListGameNetMessage(GameMessageTypes.GAMEMESSAGE_PUSH_MISSION, eInterfaceModeMission, plotX, plotY, 0, false, bShift);
UI.SetInterfaceMode(InterfaceModeTypes.INTERFACEMODE_SELECTION);
return true;
end
end
end
end
-- If we get here, return true to indicate that the input has been handled, because the city has no airport or there's too many units there.
-- print ("Attempted to send to a city without an Airport.");
return true;
end
-- Either the interface mode is not AIRLIFT or a different button was pushed. Indicate false and let other handlers take care of this one.
return false;
end
ContextPtr:SetInputHandler( Airport_InputHandler );
Issues:
- No idea if the AI could make use of this. I would assume not.
- Does not create a Trade Route, as much as I would love it to do so.
- I can't get my GameSpy account to work, so I can't actually upload the Mod to be grabbed inside of the game. I used the Export function on ModBuddy to create a template and have attached it here.
- My kids are clamoring for my attention and my wife is giving me the evil eye, so I don't remember what other issues there might have been.