• Civilization 7 has been announced. For more info please check the forum here .

Trouble making a civ change to another while using same Team Number in WBS!

GUSTAVUS II

Chieftain
Joined
Oct 12, 2007
Messages
44
Location
Malmo,Minnesota
I'm making a mod called All History.
I need to make a civ become a another civ while using the same world builder team
number. I won't have the limitations of total civs in my game if I figure this out!





Code:
#TURN 200: CARTHAGE CHANGES TO VANDALS
		elif(iGameTurn == 200):
			#Carthage Changes Leadership
			iNewPlayer = 0    # Player ID (= player's position in list) in your Map
			self.CarthagebecomesVandal(iNewPlayer, 13, 36)[CODE]


[CODE]def CarthagebecomesVandal(self, iNewPlayer, iX, iY):
                pNewPlayer = gc.getPlayer(iNewPlayer)
		if(pNewPlayer.isAlive()):
			#Create new Player
			pNewPlayer.setPlayable(True)
			g.addPlayer(iNewPlayer, pNewPlayer.getTeam(),pNewPlayer.getPersonalityType(), pNewPlayer.getCivilizationType(pNewPlayer,1))
         		pNewPlayer.initUnit(gc.getInfoTypeForString("UNIT_WORKER"), iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
                        #Add a message on screen
			CyInterface().addMessage(g.getActivePlayer(),true,15,"Year %s: The (%s) have had a revolution !" %(g.getGameTurnYear(), pNewPlayer.getCivilizationDescription(pNewPlayer.getCivilizationType())),'',0,'',ColorTypes(11), 1, 1, True,True)

                return[CODE]

I AM SPECIFICLY HAVING PROBLEMS WITH THIS LINE ONLY:

[CODE]pNewPlayer.getCivilizationType(pNewPlayer,1))[CODE]
 THE NUMBER ONE IS SUPPOSEDLY THE INTIGER I NEED TO SPECIFY THE SECOND CIV IN MY CIVILIZTION_INFOS LIST                                                             

I get "Argument Error: Python argument types in
  CyPlayer.getCivilizationType(CyPlayer,CyPlayer,int)
did not match C++ signature:
  getCivilizationType(class CyPlayer{lvalue})

I tried to figure this out on my own, I could find nothing on google or fanaticsforums
about this problem. Please Help.
 
I'm looking for a write function that will change a playing civ's complete idenity mid-game, I saw something in Rhye's Mod similar that just changes leaders midgame.


Code:
BeginPlayer
       (no change wanted)-Team=1    
  (change wanted)	LeaderType=LEADER_RAGNAR
  (change wanted)	LeaderName=Ragnar
  (change wanted)	CivDesc=Empire viking
  (change wanted)	CivShortDesc=Vikings
  (change wanted)	CivAdjective=Viking
  (change wanted)	FlagDecal=Art/Interface/TeamColor/FlagDECAL_Viking.dds
  (change wanted)	WhiteFlag=0
  (change wanted)CivType=CIVILIZATION_VIKING
  (change wanted)	Color=PLAYERCOLOR_LIGHT_PURPLE
  (change wanted)	ArtStyle=ARTSTYLE_EUROPEAN
	PlayableCiv=1
	MinorNationStatus=0
	StartingGold=0
	StartingX=23, StartingY=39
	StateReligion=
	StartingEra=ERA_ANCIENT
	RandomStartLocation=false
	CivicOption=CIVICOPTION_GOVERNMENT, Civic=CIVIC_DESPOTISM
	CivicOption=CIVICOPTION_LEGAL, Civic=CIVIC_BARBARISM
	CivicOption=CIVICOPTION_LABOR, Civic=CIVIC_TRIBALISM
	CivicOption=CIVICOPTION_ECONOMY, Civic=CIVIC_DECENTRALIZATION
	CivicOption=CIVICOPTION_RELIGION, Civic=CIVIC_PAGANISM
	Handicap=HANDICAP_NOBLE
EndPlayer[CODE]



THIS IS HOW THE PYTHON READS LEADERS:
[CODE]LeaderHeadTypes: (ALWAYS IN THE ORDER OF LEADERHEADINFOS.XML)
-1 = NO_LEADER
0 = LEADER_BARBARIAN
1 = LEADER_ALEXANDER
2 = LEADER_ASOKA
3 = LEADER_AUGUSTUS
4 = LEADER_BISMARCK
5 = LEADER_BOUDICA
6 = LEADER_BRENNUS
7 = LEADER_CATHERINE
8 = LEADER_CHARLEMAGNE
9 = LEADER_CHURCHILL
10 = LEADER_CYRUS
11 = LEADER_DARIUS
12 = LEADER_DE_GAULLE
13 = LEADER_ELIZABETH
14 = LEADER_FREDERICK
15 = LEADER_GANDHI
16 = LEADER_GENGHIS_KHAN
17 = LEADER_GILGAMESH
18 = LEADER_HAMMURABI
19 = LEADER_HANNIBAL
20 = LEADER_HATSHEPSUT
21 = LEADER_HUAYNA_CAPAC
22 = LEADER_ISABELLA
23 = LEADER_JOAO
24 = LEADER_JULIUS_CAESAR
25 = LEADER_JUSTINIAN
26 = LEADER_KUBLAI_KHAN
27 = LEADER_LINCOLN
28 = LEADER_LOUIS_XIV
29 = LEADER_MANSA_MUSA
30 = LEADER_CHINESE_LEADER
31 = LEADER_MEHMED
32 = LEADER_MONTEZUMA
33 = LEADER_NAPOLEON
34 = LEADER_PACAL
35 = LEADER_PERICLES
36 = LEADER_PETER
37 = LEADER_QIN_SHI_HUANG
38 = LEADER_RAMESSES
39 = LEADER_RAGNAR
40 = LEADER_FRANKLIN_ROOSEVELT
41 = LEADER_SALADIN
42 = LEADER_SHAKA
43 = LEADER_SITTING_BULL
44 = LEADER_STALIN
45 = LEADER_SULEIMAN
46 = LEADER_SURYAVARMAN
47 = LEADER_TOKUGAWA
48 = LEADER_VICTORIA
49 = LEADER_WANGKON
50 = LEADER_WASHINGTON
51 = LEADER_WILLEM_VAN_ORANJE
52 = LEADER_ZARA_YAQOB

THIS IS HOW THE PYTHON READS CIVS:

CivilizationTypes: (ALWAYS IN THE ORDER OF CIVILIZATIONINFOS.XML)

-1 = NO_CIVILIZATION
0 = CIVILIZATION_AMERICA
1 = CIVILIZATION_ARABIA
2 = CIVILIZATION_AZTEC
3 = CIVILIZATION_BABYLON
4 = CIVILIZATION_BYZANTIUM
5 = CIVILIZATION_CARTHAGE
6 = CIVILIZATION_CELT
7 = CIVILIZATION_CHINA
8 = CIVILIZATION_EGYPT
9 = CIVILIZATION_ENGLAND
10 = CIVILIZATION_ETHIOPIA
11 = CIVILIZATION_FRANCE
12 = CIVILIZATION_GERMANY
13 = CIVILIZATION_GREECE
14 = CIVILIZATION_HOLY_ROMAN
15 = CIVILIZATION_INCA
16 = CIVILIZATION_INDIA
17 = CIVILIZATION_JAPAN
18 = CIVILIZATION_KHMER
19 = CIVILIZATION_KOREA
20 = CIVILIZATION_MALI
21 = CIVILIZATION_MAYA
22 = CIVILIZATION_MONGOL
23 = CIVILIZATION_NATIVE_AMERICA
24 = CIVILIZATION_NETHERLANDS
25 = CIVILIZATION_OTTOMAN
26 = CIVILIZATION_PERSIA
27 = CIVILIZATION_PORTUGAL
28 = CIVILIZATION_ROME
29 = CIVILIZATION_RUSSIA
30 = CIVILIZATION_SPAIN
31 = CIVILIZATION_SUMERIA
32 = CIVILIZATION_VIKING
33 = CIVILIZATION_ZULU
34 = CIVILIZATION_MINOR
35 = CIVILIZATION_BARBARIAN[CODE]


By the way sorry for the strange formatting, the scripts for the fonts 
haven't been working.
 
Ah, sorry, didn't really see the problem.

Your last argument for addPlayer has to be OldPlayer.getID (), so you might have to check the ID first before calling your function, or you have to give the function the old CyPlayer instance as an argument.
 
I Still haven't found something that works yet.

Let's say you have two civs in XML one being Rome, other being Papal States.
If you wanted to change the civ idenity(Team ID in Worldbuilder Save) for
Team 0 from Rome to Papal State, what would a be a good sample code for
this?
 
There's no direct way to do it.
You would have to create one or two new players, switch all the units, cities, etc. from the old ones to the new ones, and then move them switched back.

Why do you ask? I can't see any real usage for something like that.
 
I am making a historical world mod called All History with a plan to have the non-player controlled civs change artwork and names according to historical dates.


Something Like This Would be an Example:

ANCIENT MEDEVIL MODERN

ISRAEL UNDER DAVID---KINGDOM OF JERUSALEM ----MODERN ISRAEL
RAGNAR'S DENMARK---CHRISTIAN IV'S DENMARK
VIKING SEDEN--------MEDEVIL SWEDEN
ROME----------------PAPAL STATES----------------MODERN ITALY
SAXONS--CHARLEMAGNE--HRE/BRANDENBURG/PRUSSIA---GERMANY
ANGLO-SAXONS------ENGLAND--------------------GREAT BRITIAN
MACEDONIA----------DUCHY OF ATHENS---------MODERN GREECE


This allows for an more authentic historical game.
Could it be done by killing off a civ then immediately replacing
its artinfos or civinfos?
I would like something similiar to the dynamic of Rhye's and Fall(The
Leaders change over time). Do you understand my goal now?
 
We have also talked here about it.

I guess, it's really time to do it and put it in the database.


Here's a simple hardcoded example:

PHP:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
		if iGameTurn ==2:
                        if iPlayer==1:
                                pPlayer = gc.getPlayer(iPlayer)                                
                                PlayerTeamID = gc.getTeam(pPlayer.getTeam()).getID()
                                iciv = pPlayer.getCivilizationType ()                                
                                leaderid = gc.getInfoTypeForString( 'LEADER_MEHMED' )
                                CyGame().addPlayer(17,leaderid,iciv)
                                otherPlayer = gc.getPlayer(17)
                                NumCities = pPlayer.getNumCities ()
                                otherteam = gc.getTeam(gc.getPlayer(17).getTeam())                                                              
                                otherteam.addTeam(PlayerTeamID)                                
                                for i in range (NumCities):
                                        TheCity = pPlayer.getCity(i)
                                        otherPlayer.acquireCity(TheCity,False,False)

This will "replace" the leader of the second civ in the second turn with mehmet.
I'll have to change the units, etc, make the ID dynamic, etc,
Shouldn't be too hard, i'll probably do it in the next days.

Sad thing here: It doesn't work for the human player :(.
If anybody has an idea, how to do this...
 
I hope somebody else will look in here.

The automatically change of leaders works nearly, but i have several problems, which i don't understand.

1. problem: Some stats are not re-applied.
Like you can see here:
Spoiler :

PHP:
for iNumTeams in range(gc.getMAX_TEAMS ()):                                                        
                                                        if iNumTeams == NewTeamID:
                                                                continue                                                        
                                                        LoopTeam = gc.getTeam(iNumTeams)
                                                        if LoopTeam.isOpenBorders(NewTeamID):
                                                                OpenBordersStatus.append(True)
                                                        else:
                                                                OpenBordersStatus.append(False)
                                                        if LoopTeam.isVassal(NewTeamID):
                                                                MasterStatus.append(True)
                                                        else:
                                                                MasterStatus.append(False)
                                                        if NewTeam.isVassal(iNumTeams):
                                                                VassalStatus.append(True)
                                                        else:
                                                                VassalStatus.append(False)
                                                        if NewTeam.isAtWar(iNumTeams):
                                                                WarStatus.append(True)                                                                
                                                        else:
                                                                WarStatus.append(False)
                                                        if NewTeam.isDefensivePact(iNumTeams):
                                                                DefPactStatus.append(True)
                                                        else:
                                                                DefPactStatus.append(False)
                                                        WarWearinessStatusOwn.append(NewTeam.getWarWeariness(iNumTeams))
                                                        WarWearinessStatusOther.append(LoopTeam.getWarWeariness(NewTeamID))
                                                        EspionageStatusOwn.append(NewTeam.getEspionagePointsAgainstTeam(iNumTeams))
                                                        EspionageStatusOther.append(LoopTeam.getEspionagePointsAgainstTeam(NewTeamID))

i save all the diplomatic values like open borders, vassal status, espionage points, etc. in several lists (yes, stupid, should have made a new class, i know it).

After that, i kill the old player, and give the new player these values:
Spoiler :

PHP:
                           CountTeams = 0
                                                for iNumTeams in range(gc.getMAX_TEAMS ()):
                                                        if iNumTeams == NewTeamID:
                                                                continue                                                                                                           
                                                        LoopTeam = gc.getTeam(iNumTeams)
                                                        if OpenBordersStatus[CountTeams]:                                                         
                                                                LoopTeam.signOpenBorders(NewTeamID)
                                                                NewTeam.signOpenBorders(iNumTeams)
                                                        if MasterStatus[CountTeams]:
                                                                LoopTeam.setVassal(NewTeamID,True,True)
                                                        if VassalStatus[CountTeams]:
                                                                NewTeam.setVassal(iNumTeams,True,True)
                                                        if WarStatus[CountTeams]:
                                                                NewTeam.declareWar(iNumTeams,True,WarPlanTypes.WARPLAN_LIMITED)
                                                        if DefPactStatus[CountTeams]:
                                                                NewTeam.signDefensivePact(iNumTeams)
                                                                LoopTeam.signDefensivePact(NewTeamID)
                                                        NewTeam.setWarWeariness(iNumTeams,WarWearinessStatusOwn[CountTeams])
                                                        LoopTeam.setWarWeariness(NewTeamID,WarWearinessStatusOwn[CountTeams])
                                                        NewTeam.changeEspionagePointsAgainstTeam(iNumTeams,EspionageStatusOwn[CountTeams])
                                                        LoopTeam.changeEspionagePointsAgainstTeam(NewTeamID,EspionageStatusOther[CountTeams])
                                                        CountTeams = CountTeams+1

Vassals: Works.
Master of somebody: works.
Declaring war: works.
Re-signing defensive pacts: doesn't work.
Re-signing open borders: doesn't work.
Adding the espionage points: doesn't work.

I have really completly no idea, why the last 3 things don't work.
Does anybody have an idea?
(intendation is right, only appears wrong here)


Another problem: How can i sign a treaty about resource trading?
Haven't found anything like that in the API :(.
 

Attachments

  • ChangingLeaders.zip
    12.4 KB · Views: 74
I don't need to do the switch for human players, but thanks for the help.

I entered the following code:
Code:
# When a turn begins :
	def onBeginGameTurn(self, argsList):
		iGameTurn, = argsList  

#TURN 1 : CIV SWITCHING
                #Vikings Changes Leadership
		if (iGameTurn ==1):
                                iPlayer = 1
			        pPlayer = gc.getPlayer(iPlayer)                                
                                PlayerTeamID = gc.getTeam(pPlayer.getTeam()).getID()
                                iciv = pPlayer.getCivilizationType ()                                
                                leaderid = gc.getInfoTypeForString( 'LEADER_MEHMED' )
                                CyGame().addPlayer(17,leaderid,iciv)
                                otherPlayer = gc.getPlayer(17)
                                NumCities = pPlayer.getNumCities ()
                                otherteam = gc.getTeam(gc.getPlayer(17).getTeam())                                                              
                                otherteam.addTeam(PlayerTeamID)                                
                                for i in range (NumCities):
                                        TheCity = pPlayer.getCity(i)
                                        otherPlayer.acquireCity(TheCity,False,False)


I GET THIS ERROR:
PHP:
Traceback(most recent call last)

File "CvEventInterface", line 30, in onEvent

File "CvCustomEventManager", line 135, in handleEvent

File "CvCustomEventManager", line 146, in_handleDefaultEvent

File "CvGustavusEventManager", line 58, in onBeginGameTurn

ArgumentError: Python argument types in
   CyGame.addPlayer(CyGame,int,int,int)
did not match C++ signature:
   addPlayer(class Cygame {lvalue},int,int,int,int)


Do you understand the problem?
 
Are you using a custom DLL that added a 4th parameter to CyGame::addPlayer()? BTS 3.19's function takes only 3 int parameters as you have in your code. This error messages means that the C++ function takes a 4th int.
 
Someone should update the API to the latest version :mischief:...

I don't to do the switch for human players, but thanks for the help.

You should look better in the attached files, because there i've added more things, but with the mentioned problems.
 
Someone should update the API to the latest version :mischief:...

I checked the C++ code itself before posting that, and it only takes 3 int parameters (both CyGame and CvGame). :confused:
 
Is there way to just change the "CivType" with a number or
gc.getInfoTypeForString"CIVILIZATION_CARTHAGE" in the right line of code?

Or could you change all of the artwork and infos for a particular civ on a set
turn?

I was using standard DLL. No C++ modifications.
 
It says it wants another int parameter. Try adding 0 as the 4th parameter and see what happens.
 
Top Bottom