Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - Modpacks

Notices

Reply
 
Thread Tools
Old Jun 18, 2011, 06:04 PM   #1
jerseymike25
Chieftain
 
Join Date: Dec 2005
Posts: 39
Airport (An Interface Mod without Modding Ingame.lua or Worldview.lua)

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.

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.
Attached Files
File Type: zip Airport.zip (13.8 KB, 139 views)
jerseymike25 is offline   Reply With Quote
Old Jun 19, 2011, 03:24 AM   #2
He-Who-Hunts
2nd Legionary Cohort
 
He-Who-Hunts's Avatar
 
Join Date: Jul 2005
Location: Earth
Posts: 253
Do you think it would be possible to make it so airports give trade routes? Im playing around with the idea of a mod myself and that would be a part of it.
__________________
“May you love like you've never been hurt, dance like no one is watching, sing as if no one were listening, screw like it's being filmed, and drink like a true Irishman”
He-Who-Hunts is offline   Reply With Quote
Old Jun 19, 2011, 07:24 AM   #3
Hyronymus
Emperor
 
Hyronymus's Avatar
 
Join Date: Nov 2003
Posts: 1,702
Quote:
Originally Posted by jerseymike25 View Post
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.
Quote:
Originally Posted by He-Who-Hunts View Post
Do you think it would be possible to make it so airports give trade routes? Im playing around with the idea of a mod myself and that would be a part of it.
Most likely can be done but jerseymike25 hasn't been succesful at it yet.
__________________
The best intentions are fraught with disappointment
Hyronymus is offline   Reply With Quote
Old Jun 19, 2011, 02:10 PM   #4
jerseymike25
Chieftain
 
Join Date: Dec 2005
Posts: 39
(Traderoutes) I'd played with it before - there isn't an attribute that can be added to a building that would do it, as best I can tell. The Harbor, for example, has the "AllowsWaterRoutes" attribute, but that seems to control whatever mechanism is responsible for calculating whether or not a city is connected to the capital. I think the calculation (of whether or not it's connected to the capital) is not something that can be accessed at the moment.

IF it can, though, it would be ideal - right now, a land-locked city on another contentent cannot possibly be connected via Trade Route, I believe.
jerseymike25 is offline   Reply With Quote
Old Jun 24, 2011, 05:15 AM   #5
mattpilot
Warlord
 
Join Date: Jan 2004
Posts: 157
awesome! thanks


Would it be possible to make it so that this also works with airports that workers build on tiles? (or combine its function with forts instead of adding another tile-improvement - thou i'd prefer a new tile improvement ).
mattpilot is offline   Reply With Quote
Old Jul 24, 2011, 12:49 PM   #6
OmegaKabob
Le Just Derpin' Around ~
 
OmegaKabob's Avatar
 
Join Date: Jun 2011
Location: Los Angeles!
Posts: 125
Actually, I'm pretty sure that there can be a trade route with a landlocked city on different continent than the capital. If I'm right you just need a city with a harbor on the continent with the landlocked city. Then just build a road between them. I may be wrong, but I'm almost certain you can do this.
OmegaKabob is offline   Reply With Quote
Old Feb 05, 2012, 06:40 AM   #7
Pablod
Warlord
 
Pablod's Avatar
 
Join Date: Sep 2005
Posts: 294
how to install it
where i save this in to
Pablod is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - Modpacks > [BUILDING] Airport (An Interface Mod without Modding Ingame.lua or Worldview.lua)

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 01:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR