The Immigration Mod

OK now CvMainInterface.py and the art files should be good. What repeatable error are you referring to?

For some reason now, it CTD's:confused: This is exactly what happend when i tried to make this mod also, its just something i nor anyone else could figure out what is going on:crazyeye:

Plus like i said, still no Join City etc.
 
For some reason now, it CTD's:confused: This is exactly what happend when i tried to make this mod also, its just something i nor anyone else could figure out what is going on:crazyeye:

Plus like i said, still no Join City etc.

I have a Join City in my Capture slaves.

I'm sure it is not the immigration mod as no one has reported any major problems with it. If you are using WoC modules, then you can remove one mod component at a time to find out which component is causing the CTD. Once you discover which component is at fault, then you can either fix it or just leave it out.

However, if it is the immigration mod, then you likely have an XML error somewhere where you have merged the mod.
 
However, if it is the immigration mod, then you likely have an XML error somewhere where you have merged the mod.

I cant have an XML error, in modules you should not even mess with that area. Just the proper path is needed.

I believe for some reason the ArtDefines_Interface is not working properly, or the PythonCallBack:(
 
1. Make sure you have installed the BTS 3.19 patch for Civ4.

2. Make sure you have merged the CvMainInterface.py properly, including the import at the top of the file.

OK. Check the following folder:

Code:
Modules\OrionsMods\Immigration\Art\Interface\Buttons\Units

Make sure these files are placed in that folder:

Immigrant.dds
JoinCity.dds

ive checked it out
but still no button to join city
moreover when i select the unit, the game seems slightly laggy :confused:
 
ive checked it out
but still no button to join city
moreover when i select the unit, the game seems slightly laggy :confused:

The file that controls the visibility of the JoinCity.dds file is the CvMainInterface.py file and the CIV4ArtDefines_Interface.xml file. You must have three modified sections in the CvMainInterface.py. There are no other edits to make in this file for the Immigration mod:

Spoiler :


Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
from CvPythonExtensions import *
import CvUtil
import ScreenInput
import CvScreenEnums
import CvEventInterface
import time
[COLOR="Red"]import Immigration[/COLOR]

Code:
# Immigration Mod	
					# ##### Join City Button ######
					pUnit = g_pSelectedUnit
					iUnitType = pUnit.getUnitType()
					iUnitOwner = pUnit.getOwner( )
					pUnitOwner = gc.getPlayer(iUnitOwner)

					if pUnitOwner.isTurnActive( ):						
						if gc.getMap().plot(pUnit.getX(), pUnit.getY() ).isCity():	
							if iUnitType == gc.getInfoTypeForString("UNIT_IMMIGRANT"):
								if Immigration.showJoinCityButton(pUnit):
									screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_JOIN_CITY").getPath(), 0, WidgetTypes.WIDGET_GENERAL, 680, 680, False )
									screen.show("BottomButtonContainer")
									iCount = iCount + 1
									return
# End Immigration Mod						

		elif (CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_HIDE_ALL and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_MINIMAP_ONLY):
		
			self.setMinimapButtonVisibility(True)

		return 0

Code:
	def handleInput (self, inputClass):
# Immigration Mod
		if (inputClass.getNotifyCode() == 11 and inputClass.getData1() == 680 and inputClass.getData2() == 680):			
			self.pPushedButtonUnit = g_pSelectedUnit			
			iOwner = g_pSelectedUnit.getOwner()
			iUnitID = g_pSelectedUnit.getID()
			pPlayer = gc.getPlayer(iOwner)
			pUnit = pPlayer.getUnit(iUnitID)
			Immigration.doJoinCity(pUnit)
			CyInterface().setDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT, True)
# End Immigration Mod


There is one key XML edit in the CIV4ArtDefines_Interface.xml file:

Spoiler :

Code:
		<!-- Orion's  Immigration Mod -->
		<InterfaceArtInfo>
			<Type>INTERFACE_JOIN_CITY</Type>
			<Path>Art/Interface/Buttons/Units/JoinCity.dds</Path>
		</InterfaceArtInfo>
		<!-- Orion's Immigration Mod -->


These edits will make the JoinCity button work.
 
@OV
Yes...
i forgot that code
now it works.. Thanks :D

btw, i have tested this mod on multiplayer and i got an OOS when the immigrant joined a city :(
 
Got this error when an immigrant tried to join a city?


Traceback (most recent call last):

File "CvScreensInterface", line 950, in handleInput

Spoiler :
Code:
# call handle input on that screen
    if ( screen and not ret):
        [B]return screen.handleInput(inputClass)[/B]
    return 0

File "CvMainInterface", line 6384, in handleInput

Spoiler :
Code:
# Immigration Mod
        if (inputClass.getNotifyCode() == 11 and inputClass.getData1() == 680 and inputClass.getData2() == 680):            
            self.pPushedButtonUnit = g_pSelectedUnit            
            iOwner = g_pSelectedUnit.getOwner()
            iUnitID = g_pSelectedUnit.getID()
            pPlayer = gc.getPlayer(iOwner)
            pUnit = pPlayer.getUnit(iUnitID)
            [B][B]Immigration.doJoinCity(pUnit)[/B][/B]
            CyInterface().setDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT, True)
# End Immigration Mod

File "Immigration", line 58, in doJoinCity

AttributeError: 'NoneType' object has no attribute 'getPopulation'
ERR: Python function handleInput failed, module CvScreensInterface

Spoiler :
Code:
def doJoinCity(pUnit):
    # Orion's Immigration Mod
    iOwner = pUnit.getOwner()
    pPlayer = gc.getPlayer(iOwner)
    iPlotX = pUnit.getX()
    iPlotY = pUnit.getY()
    pPlot = CyMap( ).plot( pUnit.getX( ), pUnit.getY( ) )
    pCity = pPlot.getPlotCity()
    [B]NewCityPopulation = pCity.getPopulation() + 1[/B]
 
Got this error when an immigrant tried to join a city?


Traceback (most recent call last):

File "CvScreensInterface", line 950, in handleInput

Spoiler :
Code:
# call handle input on that screen
    if ( screen and not ret):
        [B]return screen.handleInput(inputClass)[/B]
    return 0

File "CvMainInterface", line 6384, in handleInput

Spoiler :
Code:
# Immigration Mod
        if (inputClass.getNotifyCode() == 11 and inputClass.getData1() == 680 and inputClass.getData2() == 680):            
            self.pPushedButtonUnit = g_pSelectedUnit            
            iOwner = g_pSelectedUnit.getOwner()
            iUnitID = g_pSelectedUnit.getID()
            pPlayer = gc.getPlayer(iOwner)
            pUnit = pPlayer.getUnit(iUnitID)
            [B][B]Immigration.doJoinCity(pUnit)[/B][/B]
            CyInterface().setDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT, True)
# End Immigration Mod

File "Immigration", line 58, in doJoinCity

AttributeError: 'NoneType' object has no attribute 'getPopulation'
ERR: Python function handleInput failed, module CvScreensInterface

Spoiler :
Code:
def doJoinCity(pUnit):
    # Orion's Immigration Mod
    iOwner = pUnit.getOwner()
    pPlayer = gc.getPlayer(iOwner)
    iPlotX = pUnit.getX()
    iPlotY = pUnit.getY()
    pPlot = CyMap( ).plot( pUnit.getX( ), pUnit.getY( ) )
    pCity = pPlot.getPlotCity()
    [B]NewCityPopulation = pCity.getPopulation() + 1[/B]

You must specify the file where the getPopulation function runs, which is: PyHelpers

You need to add the following line at the top of your Immigration.py file:

import PyHelpers
 
You must specify the file where the getPopulation function runs, which is: PyHelpers

You need to add the following line at the top of your Immigration.py file:

import PyHelpers

Its already there?

# Sid Meier's Civilization 4
# Copyright Firaxis Games 2005
# Orion's Immigration Mod
from CvPythonExtensions import *
import BugUtil
import BugCore
import CvUtil
import CvTechChooser
import PyHelpers
import traceback
import os
import sys
import pickle
import CvGameUtils
import CvEventInterface
 
Its already there?

Hmmm. That should have worked, unless there is another function that is broke causing this problem. AttributeError: 'NoneType' object has no attribute 'getPopulation'

NoneType object is the key. The object here is a city: specifically pCity. There must be a condition with one of your cities that the python code has not accounted for. In your test game, check the status of all of your cities, owned, acquired, sacked, razed, whatever may be the case. There is a function, referencing a city or cities, somewhere in your mod that is just not running correctly, under the current conditions in your test game. It may take some time to find it. If you have modular code, you can remove the python code for each submod or place display messages to verify the lines with city references are working. I prefer the later method, as it usually confirms my suspicions fairly quick. That's all I can think of at the moment. As you may know, I am working on the Army mod, which is about 80% done. The Army mod's python has been very difficult to code, but I am making good progress each day. As for your python code, happy hunting, and never give up. You will find the problem eventually.
 
OK i have got it working ??? Well:hmm: but i think it is mistakenly taking the immigrant as a settler? see pic

Yes it is. This helps the AI to move the immigrant to a city, where it does infact join or settle in. In the Immigration_CIV4UnitInfos.xml file, you have this:

Code:
<UnitAIs>
	<UnitAI>
		<UnitAIType>UNITAI_SETTLE</UnitAIType>
		<bUnitAI>1</bUnitAI>
	</UnitAI>
</UnitAIs>

You might try another UnitAIType to see what it does. Congrats on getting the mod to work. :)
 
I'm trying to merge this with RFCMarathon, and it looks good for the most part, but I don't think the cityCanTrainImmigrant function in Immigration.py is working properly... For some reason, cities of any size can train them, resulting in cities with 0 and negative populations XD

Any advice?
 
I'm trying to merge this with RFCMarathon, and it looks good for the most part, but I don't think the cityCanTrainImmigrant function in Immigration.py is working properly... For some reason, cities of any size can train them, resulting in cities with 0 and negative populations XD

Any advice?

Yup. Please make sure you have the following entry in the PythonCallbackDefines.xml file:

Spoiler :

Code:
<Define>
	<DefineName>USE_CAN_TRAIN_CALLBACK</DefineName>
	<iDefineIntVal>1</iDefineIntVal>
</Define>
 
Hi,

I´ve merged this great component into my mod and it seems to work great. Since we use this mod in multiplayer and we had some OOS I had to check the MPLog. There I´ve found several entries like this for the AI-Player:

Code:
Unit stuck in loop: Immigrant(Zara Yaqob)[105, 38] (settle)

The numbers are coordinates of the cities of the AI.

I´m pretty sure that this is not causing the problem with the OOS (I´m using ModNetMessages for humans and AI works well without) but perhaps some other problems. Is there any way to find the code which is causing the loop? Or is this maybe just the following one, where he doesn´t find any city to join, because there are no cities with less than 7 population?

Code:
def doImmigrantPlacementAI(pUnit, pCity):
# Orion's Immigration Mod
	iOwner = pUnit.getOwner()
	pPlayer = gc.getPlayer(iOwner)
	MyPopulation = pCity.getPopulation()
	
	if MyPopulation > 0 and MyPopulation < 7:
		if pUnit.getX() != pCity.getX() or pUnit.getY() != pCity.getY():
			pUnit.getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, pCity.getX(), pCity.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, pUnit.plot(), pUnit)
			#CyInterface().addImmediateMessage("Push Immigrant", "")
			
		else:
			#CyInterface().addImmediateMessage("Do Join City", "")
			doJoinCityAI(pUnit)
# Orion's Immigration Mod
 
Hi,

I´ve merged this great component into my mod and it seems to work great. Since we use this mod in multiplayer and we had some OOS I had to check the MPLog. There I´ve found several entries like this for the AI-Player:

Code:
Unit stuck in loop: Immigrant(Zara Yaqob)[105, 38] (settle)

The numbers are coordinates of the cities of the AI.

I´m pretty sure that this is not causing the problem with the OOS (I´m using ModNetMessages for humans and AI works well without) but perhaps some other problems. Is there any way to find the code which is causing the loop? Or is this maybe just the following one, where he doesn´t find any city to join, because there are no cities with less than 7 population?

Code:
def doImmigrantPlacementAI(pUnit, pCity):
# Orion's Immigration Mod
	iOwner = pUnit.getOwner()
	pPlayer = gc.getPlayer(iOwner)
	MyPopulation = pCity.getPopulation()
	
	if MyPopulation > 0 and MyPopulation < 7:
		if pUnit.getX() != pCity.getX() or pUnit.getY() != pCity.getY():
			pUnit.getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, pCity.getX(), pCity.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, pUnit.plot(), pUnit)
			#CyInterface().addImmediateMessage("Push Immigrant", "")
			
		else:
			#CyInterface().addImmediateMessage("Do Join City", "")
			doJoinCityAI(pUnit)
# Orion's Immigration Mod

This function and ALL references to it, has been changed to eliminate the stuck in loop errors.

Code:
def doImmigrantPlacementAI(pImmigrantUnit):
# Orion's Immigration Mod
	iOwner = pImmigrantUnit.getOwner()
	pPlayer = gc.getPlayer(iOwner)
	intCity = getLeastPopulatedCity(iOwner)
	pMigrationCity = pPlayer.getCity(intCity)
	#pMigrationCityPlot = CyMap().plot(pMigrationCity.getX(), pMigrationCity.getY())
	bMoveOK = False
	
	if (pMigrationCity.getPopulation() < 7):
		if pImmigrantUnit.generatePath(pMigrationCity.plot(), 0, False, None):
			bMoveOK = True
			if pImmigrantUnit.getX() != pMigrationCity.getX() or pImmigrantUnit.getY() != pMigrationCity.getY():
				pImmigrantUnit.getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, pMigrationCity.getX(), pMigrationCity.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, pImmigrantUnit.plot(), pImmigrantUnit)
			
			elif pImmigrantUnit.getX() == pMigrationCity.getX() and pImmigrantUnit.getY() == pMigrationCity.getY():
				doJoinCity(pImmigrantUnit)
	
	if not bMoveOK:
		pImmigrantUnit.finishMoves()
# Orion's Immigration Mod
 
Back
Top Bottom