Staggering civ spawn times

BobTheTerrible

Just Another Bob
Joined
Jan 5, 2003
Messages
927
Location
Middle of Nowhere
I'm trying to make a small script where rather than all spawning at 4000 BC, civs will spawn at a random time within the first 15 or so turns. This is the first script I'm trying to do with python and I really have no idea how to make this work, I know what steps I have to go through but I don't know how to put this into python. I've read the tutorial for python modding, but I still can't understand how I need to go about doing this. Here's the pseudo-code I have (mostly written by jdog from the revolution mod, my comments in italics, his after #):

Code:
from CvPythonExtensions import * [i](I can't locate this file on my computer 
so I have no idea what I'm being told to import here)[/i]

#(These set up useful shortcuts to commonly used classes) [i](again, not really sure what these do)[/i]
gc = CyGlobalContext()
game = CyGame()

#(This will keep record of player info)[i]I'm assuming this is the list to add/remove 
players from once they've spawned[/i]
playerInfoList = list()

register Events : [i] this is just defining the events I'll need?[/i]
     add GameStart event handler
     add BeginGameTurn event handler

onGameStart: [i]not sure exactly why I need this, either[/i]
     global playerInfoList #(so that you can write to this global variable and use it in other functions)

     game.setAIAutoPlay( 15 ) [i]autoplay is a feature of the mod I am modding. 
It allows AI to take control of the player for a set number of turns... now that I think of it, 
I probably don't need this bit in there...[/i]

     for each player:
          record player id number
          record x,y location of settler
          remove the player's units
          assign player random integer(1-15)
   

onBeginGameTurn:
     for each player in recorded list :
         if turn == random integer for player:
             if that x/y location has a barbarian unit/animal
                 remove that unit
             spawn settler/warrior at recorded location
                  
                     

              if game.getActivePlayer() == player id :
                  game.setAIAutoPlay( 0 )

              remove player info from list #(not strictly necessary, but might as well so it isn't checked unnecessarily later)

I'm also going to need to know how to call the script to run at at the game start, and make sure that the player doesn't lose the game right at the beginning until he's spawned. If someone could help me along here, hopefully by putting it into real python code and explaining what each bit does, I would greatly appreciate it.
 
May I suggest looking through Rhye's mod python code. It does civ spawning. :)
 
May I suggest looking through Rhye's mod python code. It does civ spawning. :)

I've been looking through Rhye's mod and Revolutions, both of which do civ spawning. The problem is I'm just not familiar enough with python, and moreover I'm just not familiar enough with the python code specifically for civ 4 (how to find the map coordinates of a unit to store them, for example). I've read the "Learn to Mod Civ 4 Today" thread but unfortunately there's not any lessons pertaining specifically to civ 4, which is pretty much what I am looking for.
 
I probably know even less about Python, but as I understand it the way Rhye does it, the civ spawns on the first turn, but the units are asleep and in some sort of hidden form for n turns, while the auto ai plays those n turns for other civs. With the turn screen hiding what's behind it, it creates the illusion of a civ spawn.
 
Back
Top Bottom