Expert Python Help Needed--Making units appear a certain gameturn.

GUSTAVUS II

Chieftain
Joined
Oct 12, 2007
Messages
44
Location
Malmo,Minnesota
:scan: Hello. I am working on a Historical Mod I like to call: 'ALL HISTORY MOD' I'm asking for a person with good python knowlege to help me
insert a python code to create a certain unit for a certain civ at a perticular
gameturn.


example: if (gameturn == 100 ) and (civilization_goths) is playable
than place (unit_settler) at x -29 y-77.


Can anyone make a simlple code like this and tell me which file to enter it in?

Please? :cool:

Note:I tried a code on a earlier post but it returned c++ errors.
 
The reason I need this code is that I can perfect my ALL HISTORY MOD.

50 CIVS! :D

INDIA BEGINNING
CHINA BEGINNING
EGYPT BEGINNING
SUMERIA BEGINNING
GERMANY 100 AD START
FRANCE 400 AD START
SPAIN 400 AD START
PORTUGAL700 AD START
DUTCH 700 AD START
ROME 510 BC START
GREECE 800 BC START
ARABIA 400 AD START
BABYLON 2400 BC START
CARTHAGE 800 BC START
ETHIOPIA 800 BC START
JAPAN 700 AD START
KHMER 800 AD START
KOREA 500 AD START
MALI 1200 AD START
MONGOL 1200 AD START
TURKEY 1200 AD START
PERSIA 800 BC START
RUSSIA 700 AD START
ENGLAND 700 AD START
AMERICA 1700 AD START
ISRAEL BEGINNING
ASSYRIA BEGINNING
HITTITES BEGINNING
PHOENICIANS 1200 BC START
ARMENIA 650 BC START
KUSHAN 100 AD START
GOTHS
NORWAY 700 AD START
SWEDEN 700 AD START
POLAND 700 AD START
TIBET 700 AD START
BULGARS 700 AD START
HUNGARY 900 AD START
KANEMBORNU 900 AD START
AUSTRIA
CANADA 1700 AD START

47 RELIGIONS:cool: (USES 47 RELIGION MODCOMP!)
I PROBABLY WON'T USE ALL FOR BALANCE SAKE!

:scan: ALL I NEED IS THE SIMPLE CODE IN THE POST ABOVE TO COMPLTE
THIS MOD! PLEASE HELP!:king:
 
:scan: Hello. I am working on a Historical Mod I like to call: 'ALL HISTORY MOD' I'm asking for a person with good python knowlege to help me
insert a python code to create a certain unit for a certain civ at a perticular
gameturn.


example: if (gameturn == 100 ) and (civilization_goths) is playable
than place (unit_settler) at x -29 y-77.


Can anyone make a simlple code like this and tell me which file to enter it in?

Please? :cool:

Note:I tried a code on a earlier post but it returned c++ errors.


I'm not an expert, but I can try to help...
This (not tested) could work :

Code:
[B]# My function that creates the new unit :
def CreateNewCiv(pNewPlayer, iX, iY):[/B]
        if(pNewPlayer.isPlayable()):
                #Create a settler
                pFirstGothUnit = pNewPlayer.initUnit(gc.getInfoTypeForString("UNIT_SETTLER"), iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
        return
        


[B]# When a turn begins :
def onBeginGameTurn(self, argsList):[/B]
        iGameTurn = argsList
        gc = CyGlobalContext()
        #TURN 100 : Goths
        if(iGameTurn == 100):
                #Goths have to starts
                pNewPlayer = gc.getPlayer(gc.getInfoTypeForString("CIVILIZATION_GOTHS"))
                self.CreateNewCiv(pNewPlayer, 29, 77)    # 29 (X) and 77 (Y) are coordonates of the plot where the unit will be created
                
        #TURN 400 : France & Spain
        elif(iGameTurn == 400):
                #France have to starts
                pNewPlayer = gc.getPlayer(gc.getInfoTypeForString("CIVILIZATION_FRANCE"))
                self.CreateNewCiv(pNewPlayer, 100, 15)    # 100 (X) and 15 (Y) are coordonates of the plot where the unit will be created
                #Spain have to starts too
                pNewPlayer = gc.getPlayer(gc.getInfoTypeForString("CIVILIZATION_SPAIN"))
                self.CreateNewCiv(pNewPlayer, 19, 93)    # 19 (X) and 93 (Y) are coordonates of the plot where the unit will be created
        
        #TURN ETC, ETC, ETC....
        elif(iGameTurn == etc, etc, etc....

You add that in a CvCustomEventManager.py file, and it should do what you need...
For exemples in adding CvCustomEventManager.py, get any Python Mod that gets one, and have a look. You should find how to do.
 
Thanks for the help, but unfortunately, I have tried the new code in two different CvCustomEventManager files and it didn't do anything.
The code I need might need to be a little different.
Does the code create a new civilization not being played?
I need one that will create a unit for a civ already in play.(I need to make
all civs playable from start.)
 
Thanks for the help, but unfortunately, I have tried the new code in two different CvCustomEventManager files and it didn't do anything.
:(
OK. I suppose that I have an error in the line "gc.getPlayer(gc.getInfoTypeForString("CIVILIZATION_GOTHS"))"... I'll try to write something for you and test it during the week-end. I'll upload it here on monday morning (France : GMT +2).
If it's possible, send me your XML files by PM (It'll be too late, today on 5pm, french hour). Thus, I'll write exactly the right python code for your mod.

The code I need might need to be a little different.
Does the code create a new civilization not being played?
I need one that will create a unit for a civ already in play.(I need to make
all civs playable from start.)
:confused:
The code will add a new civ with a settler if the civ is not already existing, and just add a settler if the civ is already active in game.
 
The code will add a new civ with a settler if the civ is not already existing, and just add a settler if the civ is already active in game.

If the quote above is true, then Great! It would probably be easier
If I could get a Cvcustomeventsfile with the right code. Then I
Could just edit the tags. (I don't have the best internet connection:( .,
so sending all the xml files probably won't work.)
 
I've written a little python mod for you.
I tested, and it runs.
You just have to add your modifications in the file Assets/python/CvGustavusEventManager.py
While testing, I set Germany appear at turn 1 and France + Spain at turn 4. You just have to change that to 100 and 400, and then add the other civs.

Be carefull : each civ MUST be defined in the map file (you'll find it in "PublicMaps" folder).

For any question, ask it here.


I did it very quickly, so it uses some "if" and "elif". If I have time, I'll write it with an other other method...
 

Attachments

:) LOOKS I FOUND WHAT I NEEDED. THANK YOU:goodjob: Can you make a
huge map for the same code, this will help, because you can only use the public map for this code.

You just have to create a new map and add the teams and players in it. The map I added is just an exemple.
 
Back
Top Bottom