A couple more "quick" inquiries

Either way, I feel bad semi-derailing AW's thread, so I'll not investigate further, haha.

No, no! It's all very interesting and there's always the possibility that I might need to use it in the future.

You two have been very helpful, and I've basically been able to draft these two codes:
This one deals with #2...
Spoiler :
Code:
GameEvents.CityCaptureComplete.Add(
function(iPlayer, _, iX, iY, mPlayer, bConquest)
	local pPlayer = Players[iPlayer]
	local pCity = Map.GetPlot(iX, iY):GetPlotCity()
	if (pPlayer ~= Players[mPlayer]) and (bConquest) then
		if (pCity:IsHasBuilding(GameInfoTypes.BUILDING_MARKER_BUILDING_1)) then
			Players[mPlayer]:Disband(pCity)
		else
			return
		end
	end
end)
And this one concerns #4. I think the objective of this code may interest you... :mischief:
Spoiler :
Code:
GameEvents.CityCanTrain.Add(
function(_, iCity, iUnitType)
	local pPlot = Map.GetPlot(iCity:GetX(), iCity:GetY())
	if (iCity:IsHasBuilding(GameInfoTypes.BUILDING_MARKER_BUILDING_2)) then
		for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
			local pAdjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), direction)
			if pAdjacentPlot and pAdjacentPlot:IsLake() then
				for row in GameInfo.Units() do
					if (row.Type == iUnitType) and (row.Domain == GameInfoTypes.DOMAIN_SEA) then
						return true
					else
						return
					end
				end
			else
				return
			end
		end
	else
		return
	end
end)
I'll see how to integrate #3 later. In the mean time, I know it's a long shot, but there wouldn't happen to be an event that fires when barbarians spawn due to excessive unhappiness that I just can't find on the reference, is there? :p
 
Code:
		else
			[B]return[/B]
		end
	end
end)

This return is irrelevant.
There is already a 'hidden' return right before the last 'end' in each code.

The same is true for the other code where you have a 'return' but nothing else AFTER it, which means the code would return anyway. It's like telling people you're going to turn in a curve - you don't have an option, it's redundant.
Although, in *CanTrain hooks, you actually NEED a 'return true' in the first 'if', because it'll check for every unit (twice, even, for some reason), so if you don't have an 'else return true', it will default to false.

And one last thing, I believe you are making the check for water-based units overly complex.
 
And one last thing, I believe you are making the check for water-based units overly complex.

Probably. :lol: I just needed to find a way to find all units whose <Type> == iUnitType and whose <Domain> == DOMAIN_SEA. This is perfectly easy if we're dealing with iUnit, because of the Unit.GetDomainType() method, but I don't believe there's any such method as UnitType.GetAssociatedUnitDomainType()...
 
Yes, there are a load of redundant returns in your code. I'm also of the camp that believes in the "one return per function" mantra, but I understand it's a somewhat contested issue and people have different preferences, but that is still way too many that don't actually do anything.

Second, if CityCanTrain is anything like CityCanConstruct, you cannot use iCity in the way you've used it. At least I don't think so. My Civ has a function which relies on CityCanConstruct, and iCity is literally the ID of the City, but to perform methods on a City, you need the City Object, or pCity.

Admittedly, I haven't tried using iCity in its place in some time, since at some point I found out the safest method was to make sure to get the game object of whatever method I was about to perform (pCity, pUnit, pPlayer.) For this, you'll need a simple conversion:
Code:
local pCity = pPlayer:GetCityByID(iCity)
[...]
... pCity:IsHasBuilding(...) ....

Edit:
@bane_
Interesting. I had avoided all SerialEvents because I couldn't tell which ones would fire for the AI and which wouldn't.
Is there a convenient list somewhere?
I generally try to stay far away from SerialEvents that can only fire when in observance by a human player, unless it's something like viewing the City Screen, since the AI doesn't do that.
 
I thought I might as well revive this thread from a couple days ago rather than clutter the forums with yet another query thread. :p

I believe we still have not some to a consensus about #1... is anyone aware of a way add a new civilopedia section? Or at least a new subsection within the building section? I need somewhere, optimally other than just in "Ancient Era Buildings", to put the pedia entries for many, many buildings.

7) Correct me if I'm wrong, but it is possible to add new victory types, right? I'd like to add a new victory type that basically consists of requiring the player to hold every city in the world that has Building X for 10 turns, and it can only be pursued by a specific civ. This would certainly require lua; and I would use Game.SetWinner() once all requirements are met, correct?
7.5) On that note, is anyone aware of a method to get all cities in the world with Building X? If I had to guess, it would require iterating through every city in the world and checking to see if it has Building X, and if so, adds it to a table. But this sounds like a bit of a cumbersome process, especially since there's no GameEvents.BuildingConstructed event I was able to find, so it would need to fire on every turn, which would probably create massive lag.​

8) Using methods such as these, is it possible to make City X, a city of Player X, appear invisible to Player Y if Player Y does not have a unit adjacent to City X?

And as for the other requests, I have made the edits you two have suggested, albeit not tested them yet.
TIA.
 
Regarding new Civilopedia sections, I'm not aware, but I haven't tried modding it, so I cannot say definitively. I'll have to defer to someone who has actually tried this.

New Victory conditions, I know of a few threads where people discussed trying this, but I'm not sure what the outcome was. I do know there is a Lua method to invoke the end of a game, though.

For 7.5: The last BNW patch added a GameEvents.CityConstructed() event hook that does just this.

No idea on #8.
 
Due in most part to sheer stubbornness nowadays, I try to refrain from using BNW-exclusive methods. :/
Spoiler Why I'm Full of Slightly Less Crap Than You Think :
Back when I first started modding, if I remember correctly, BNW wasn't out yet. Then once BNW was out just a short time later, I didn't get it for at least several months. I have BNW now, but due mostly to my G&K-compatibility tradition, I do most anything I can to avoid using BNW-only methods.

Also because I'm sure there's someone out there who'd like to play Civ5 with mods but doesn't have BNW; this is my gift to them. Although I'm fairly certain that those people are becoming increasingly more rare.

Although I forgot Machiavelli made a Building Contructed event, so that could probably be used.
EDIT: Looking through the coding for the event, it adds a lot of dummy units. :/
 
Well, this would be slightly off-topic, but I'm of the opinion that if they can't be bothered to get BNW, then it's tough on them. I know I'm very stingy on buying games personally, especially with numerous expansions and DLC, but at this point with the game having gone on sale for what feels like at least a dozen times in the past few months alone, there should be no reason people don't have BNW by now. Not to mention it will be guaranteed to go on sale again next week during the Steam Winter Sale.

Making non-BNW compatible mods is fine, and they would definitely be appreciative, but consider how much more work and effort it takes to make that happen. I suppose in my case, my Civ absolutely requires trade routes and caravans, so I can fall back on that as justification.

In either case, if not that, you can simply link into PlayerDoTurn, and then just scan every player's Cities each turn for the presence of a building and add the City into a table. Then you can do what you wish with that table as you would any other Lua table.
 
The #8 is possible, but:

I - It will only 'work' for the human player, the AI does not care for graphics.
II - The banner doesn't vanish, only the city's graphics.

Not very useful, huh? :(

#7
Yes.
Spoiler :
Code:
From my own code:
		[...]
			if bAllCaps or iFollowers >= iVictory then
				local iWinner = pPlayer:GetTeam()
				Game.SetWinner(iWinner, 2)
			end
		[...]
#7.5
Stop hating on BNW.
 
7.5 check the source code, as I'm pretty sure every new event was added to all three code bases (Vanilla, G&K and BNW)
 
7.5 check the source code, as I'm pretty sure every new event was added to all three code bases (Vanilla, G&K and BNW)
This is with newest patch, I'm assuming? The one that added cocoa and bison to the main game? Or did I miss an even more recent patch?

Would you have any idea which source files I might look through to begin with? I would guess any .cpp file with "Building" in its name; whether or not that's a good method is beyond me.
Oh hey, Civ is on sale again.
BNW for $6, or Civ V Complete for $10, once you apply their 20% coupon.
Sales are nevertheless no cure for stubbornness with a pinch of OCD. :p
 
Yeah, it's the one that added Cocoa and Bison.

It's definitely no cure for stubbornness (I myself am very stubborn about paying anything more than $5 for a game) but considering how often it's gone on sale, and how much game you get for such a price, at this point I have no real issue with simply pointing those who complain about BNW to such sales. It's essentially the price of one lunch, and you get tons of gameplay out of it.
 
MAC, not PC. Fine for people who have MACs.

It doesn't matter in this case.
Civ5 is a Steamworks title, which means it must be activated through Steam (GMG says as much - uses Steam DRM.)
Due to this, Mac and PC keys are interchangeable -- activate one, and Steam will automatically provide you with both a Mac version alongside a PC version.

I've done this before with Borderlands 2; Only the Mac version was discounted at the time I purchased all the DLC at a discount, but of course I'm running a Windows PC. Steam just provided both versions upon activating the keys.
 
I think we all have a little OCD in real life. My brother, for instance, apparently has a strict set of mental rules about where he needs to put his writing utensil in relation to a paper when it's not in use. And I'm constantly consciously running algorithms while walking through hallways about where and when to change speed and direction, and how to optimize my path so that I stop and slow down minimally. Although that's probably more me being a nutjob than being slightly OCD. :p

I believe we are talking about internet OCD though.

So, there's no way to make a city banner disappear? Ever? Except by destroying the city in-game? There must a be a UI file which gives the command, "when city X is destroyed, remove city X's banner", which method could probably be exploited...
 
[...]
So, there's no way to make a city banner disappear? Ever? Except by destroying the city in-game? There must a be a UI file which gives the command, "when city X is destroyed, remove city X's banner", which method could probably be exploited...

Only hint I can provide is maybe CityBannerManager.lua since this pops up with Lua errors when I use city:kill() and then attempt to click on the City banner of the now-destroyed city.
 
Right, I was just about to edit my post with this segment I found in CityBannerManager, which might be of some use:
Code:
-------------------------------------------------
-- On City Destroyed
-------------------------------------------------
function OnCityDestroyed(hexPos, playerID, cityID, newPlayerID)
	
	local playerTable = Instances[ playerID ];
	local banner = playerTable[ cityID ];
	
	local active_team = Players[Game.GetActivePlayer()]:GetTeam();
	local team = Players[playerID]:GetTeam();
	
	if(active_team ~= team) 
	then
	    g_OtherIM:ReleaseInstance( banner.SubControls );
    else
	    g_TeamIM:ReleaseInstance( banner.SubControls );
	    
	    if (SVInstances[playerID] ~= nil) then
			local svInstance = SVInstances[playerID][cityID];
			if svInstance ~= nil then
				g_SVStrikeIM:ReleaseInstance( svInstance );
				SVInstances[playerID][cityID] = nil;
			end
		end
    end
	
	playerTable[cityID] = nil;
	
end
Events.SerialEventCityDestroyed.Add(OnCityDestroyed);
Events.SerialEventCityCaptured.Add(OnCityDestroyed);
So... that "ReleaseInstance" method, I would guess, would be the relevant line?
 
Back
Top Bottom