I have wanted to do this since beginning of playing Civ IV.
When an AI dies their remaining units are now converted into barbarians.
Now, I used an existing function that was, as far as I can see, only used for killing remaining units when ai is defeated, but but also for when a map is regenerated ingame (i personally never use this, as it can only be done on the first turn) and when using aiAutoplay (a debug way of running a game with no human players).
Since it converts the units there might be some places where they cannot coexist with their previous positions, f.ex in friendly cities, o it might glitch out a bit (havent tested thoroughly).
PHP:
void CvPlayer::killUnits()
{
CvUnit* pLoopUnit;
CvUnit* pBarbUnit;
int iLoop;
for (pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
{
//Vincentz DEAD2BARB START
UnitTypes eUnit = pLoopUnit->getUnitType();
pBarbUnit = GET_PLAYER(BARBARIAN_PLAYER).initUnit(eUnit, pLoopUnit->getX_INLINE(), pLoopUnit->getY_INLINE(), pLoopUnit->AI_getUnitAIType());
pBarbUnit->convert(pLoopUnit);
//pLoopUnit->kill(false);
//Vincentz DEAD2BARB END
}
}
Fun Fact : I tested this in my current game, and thought about what would happen if there was a couple of missile submarines that was converted, so checked out my neighbor Zara in cheatmode.
In this game he have been a warmongering lunatic, dropping nukes everywhere. The scoreboard shows he isnt exactly a very popular guy, but who needs to be popular when you build Nuclear subs with 47 XP!
The fun part is that the nukedropping came the turn after he became UN SecGen (I lost by something like 17 votes iirc). The crazy part is he still out-techs me.
update:
Digging a bit deeper it shows that he is a force to be reckoned with. Besides these, he also had a bunch of nukes as well as 47 mobile artillery.
I would be in no position to combat him, except for perhaps a preemptive nuclear strike, but even if I did hit him hard, he have 4 or 5 vassals with nukes too.
Game have turned into a stalemate, with no chance of domination....
TBH im quite pleased with this, as usually in vanilla it is very rare to have a game with this kind of difficulty and opposition this late in the eras. The spacerace is literally a race!
For comparison here are mine