How to start player at certain turn?

Paolo80

Chieftain
Joined
Dec 20, 2019
Messages
85
Hi guys,

I would want to create a scenario where every player starts at a different turn.

For example, player 1 and player 2 start at the first turn, player 3 starts at 10th turn, player 4 starts at 15th turn and so on... If I selected player 4, I'd want him to start after other players play 15 turns.

Is it possible. How can I do?

Thank you for suggestions.
 
The Rhyse and Falls mod has a feature that creates civs mid game. That would be the first place I'd look.
 
I found the method doReviveActivePlayer in class CvGameUtils on Warlords. Maybe is this the right function? Is there a similar function on Vanilla version?
 
Maybe is there a function to force a player to skip some turns?
 
CvPlayer::setAlive is not exposed to Python, but giving a city or unit to a dead player should result in a setAlive(true) call inside the DLL (specifically in CvPlayer::verifyAlive, which gets executed periodically). CvPlayer::initUnit and initCity are exposed to Python.

So perhaps you can give player 3 no cities initially and then create a city or settler on turn 10? If this doesn't work, you could try giving player 3 just some unit at the South Pole through the scenario file, and delete that unit once the player has received a proper city or unit on turn 10.
 
If this doesn't work, you could try giving player 3 just some unit at the South Pole through the scenario file, and delete that unit once the player has received a proper city or unit on turn 10.
This gave me an idea that may work even with the use of events only:
Create a dummy unit at the proper start location, that is immobile and set to bGraphicalOnly (so it won't show up in the civilopedia).
Than create the event that will replace this dummy unit with the desired ones at the proper time.
And you also need a popup that tells this player, that everything is okay, just keep pressing the end turn until.
I think it is that simple :)
 
This gave me an idea that may work even with the use of events only:
Create a dummy unit at the proper start location, that is immobile and set to bGraphicalOnly (so it won't show up in the civilopedia).
Than create the event that will replace this dummy unit with the desired ones at the proper time.
And you also need a popup that tells this player, that everything is okay, just keep pressing the end turn until.
I think it is that simple :)

I did this solution. The problem is that the player must press end turn for many turns. I would want the player to skip turn without done anything.

I wrote this code, where pUnit is set over a terrain impassable, so that the player can't move it

Code:
if iGameTurn < 36 and iPlayer == 5:
            player = gc.getPlayer(iPlayer)
            if (player.isAlive() and player.isHuman()):
                for pUnit in PyPlayer(5).getUnitList():
                    pUnit.getGroup().pushMission(MissionTypes.MISSION_SKIP, -1, -1, 0, False, False, MissionAITypes.NO_MISSIONAI, pUnit.plot(), pUnit)
 
I hadn't realized that you needed to delay the start of a human player. It's pretty clear from your initial post, I just didn't read it carefully enough:
For example, player 1 and player 2 start at the first turn, player 3 starts at 10th turn, player 4 starts at 15th turn and so on... If I selected player 4, I'd want him to start after other players play 15 turns.
So depending on the civ that the human player picks, he or she may start on turn 0 (or 1) or on some later turn.

The AI Auto Play mod adds a function CvPlayer::setHuman(bool) that can put a human player under AI control – but that's a DLL mod. A different AI Auto Play feature already exists in Vanilla Civ 4 and can be started (from Python) through CyGame().setAIAutoPlay(iTurns).
Edit: No, it doesn't exist in Vanilla. So never mind this:
Spoiler :
This kills all human units and cities and thereby the human player, resulting in a "you have been defeated" message, but Auto Play status prevents the game from ending:
Code:
void CvGame::update()
{
   // ...
   testAlive();
   if (getAIAutoPlay() == 0 && !gDLL->GetAutorun())
   {
      if (countHumanPlayersAlive() == 0)
         setGameState(GAMESTATE_OVER);
   }
   // ...
}
When the Auto Play turns are over, the DLL revives the human player by placing a single unit (a Lion; unit id 0) in the lower left corner of the map:
Code:
void CvGame::reviveActivePlayer()
{
   if (!GET_PLAYER(getActivePlayer()).isAlive())
   {
       setAIAutoPlay(0);
       GC.getInitCore().setSlotStatus(getActivePlayer(), SS_TAKEN);
       GET_PLAYER(getActivePlayer()).initUnit((UnitTypes)0, 0, 0);
   }
}
So perhaps: Let the human player start with some unit, call setAIAutoPlay at game start (onGameStart? too early? onBeginPlayerTurn?), suppress the "you have been defeated message" by setting TXT_KEY_MISC_DEFEAT to an empty string in a game text file, create the proper starting units as soon as possible after AI Auto Play has ended and delete the Lion. Warlords adds doReviveActivePlayer, which allows the behavior at the end of AI Auto Play to be customized in Python, but I think that's dispensable. The DLL calls reviveActivePlayer just before
gDLL->getEventReporterIFace()->endGameTurn(getGameTurn());
so onEndGameTurn in Python should get called right after the Lion has been placed.

Alternative approach: Keep the human player alive (i.e. don't call setAIAutoPlay) and try using
CyGame().doControl(ControlTypes.CONTROL_FORCEENDTURN)
to end the human turns by force.
Edit: ^That also isn't available in Vanilla Civ 4.

All the above relies on the "active" player being the -singular- human player. In networked multiplayer games, however, the active player is the human player on whose computer the code is being executed. I.e. a solution that works in multiplayer would be an additional challenge.
 
Last edited:
Thank you all for your suggetions but they don't work.

Neither setAIAutoPlay and doControl are CyGame methods in vanilla
 
*sigh*
Sorry, I must've gotten confused. I had meant to check the Vanilla files, but apparently I looked in Warlords or BtS. Perhaps CyGame.setActivePlayer could somehow do the trick by making some AI player the active player for a number of turns. Or maybe that would just cause a crash or something.
 
This is exactly how I will be creating my mod of RFC Spain but to make it much more simple download the AI Autoplay modcomp and at the beggining of the turn make a unique popup for every civ which says how many turns you have to manually insert in the AI Autoplay window and to create the starting units use the Reinforcement script by Platyping.
 
Top Bottom