Do barbs own cities in Civ5?

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
They do in Éa ... somehow :confused:. And it's causing problems. According to Lua.logs, I have GameEvents.CityCaptureComplete firing with barbs as new city owner. And right about the same time I have GameEvents.PlayerCanConstruct starting to fire with iPlayer=63. I don't know if it persists for >1 turn because the mod freaks out soon after for mod-specific accounting reasons.

I certainly didn't knowingly add barb cities as a feature. At least no knowingly.

But perhaps I don't understand basic Civ5 operation. Do barbs ever capture and own cities, even very briefly? And if not, how the heck did I accidentally add this feature?

(And unfortunately I'm traveling so trying to debug remotely without access to dll source code.)
 
Do barbs ever capture and own cities, even very briefly?

No. See CvUnitCombat::ResolveCityMeleeCombat()
Code:
	// Barbarians don't capture Cities

Barbs could only get cities from CvPlayer::acquireCity() (trade-deals, MOV purchase, etc), or by using a settler to found one (which calls CvPlayer::found()) - so the number of places for debug prints is fairly limited
 
It's definitely a city capture:

Code:
local function OnCityCaptureComplete(iPlayer, bCapital, x, y, iNewOwner)

	print("CityCaptureComplete", iPlayer, bCapital, x, y, iNewOwner)
	< snip >
end
GameEvents.CityCaptureComplete.Add(OnCityCaptureComplete)

Fire Tuner reports:
Code:
EaMain: CityCaptureComplete	3	true	14	18	63
(happened twice now for two different mod players)


Errrr... this makes me think of some Lua code I added a long time ago to allow archers to conquer cities. It runs with one of the combat events and simply teleports an archer onto the city plot if it is adjacent to city and city < 1 hp ... which then conquers the city. I wonder if this is how I inadvertently added the "barbs conquer city" feature...?

Edit: No, that's not it. I was smart enough to add an iAttackingPlayer < BARB_PLAYER_INDEX test in that archer code.
 
Can you print the unit(s) in the city plot when it is captured - that may help identify what's going on - could be a bug in the teleport to capture logic
 
Following the C++ code through, the ONLY ways to get the CityCaptureComplete event with bConquest=true (assuming you haven't added the same event name anywhere else) are
  • via Lua pPlayer:AcquireCity() API
  • via CvUnit::setXY() - ie follow-up after a city attack (but barbs don't do this)

So my money's on your teleporting code
 
I'm stuck for now debugging from existing two Lua.logs only. Two clues:
  1. None of the combat events ever involved that city's x,y coordinates.
  2. The city capture happened during player 3's turn, not player 63 (even though 63 is the new city owner)
Hmmm, I wonder if I inited a barb unit on the city?
 
Hmmm, I wonder if I inited a barb unit on the city?

That would do it, as Init() calls SetXY() which would trigger the AcquireCity() code

So would any other pBarbUnit:SetXY() into the city plot
 
Yep, that was it. I had some code that would cause reanimated dead to go hostile (ie, convert to barb player) without testing whether plot was a city. Thanks for helping me pin that one down whoward69.
 
Back
Top Bottom