Modmodding Q&A Thread

How do I make it so that a civilizations leader changes at a set date?
 
In DynamicCivs.py, just reuse existing code such as
Code:
    elif iPlayer == iArabia:

        if iGameTurn >= getTurnForYear(1000): return iSaladin
 
Thanks.
Also how can I script wars.?

I want something like:
Civ A declares war on Civ B.
Civ A gets 1 unit at plot x.
 
There is a generalised pattern for this that is used by e.g. the Roman and Greek conquerors in AIWars.py, where you don't need to code anything but only need to specify the date, number of targeted cities etc. and the game will spawn appropriate units in a randomised interval around the date.
 
I scripted these conflicts:

iEnglandZuluYear = 1878
tEnglandZuluTL = (69, 13)
tEnglandZuluBR = (69, 15)
tConquestEnglandZulu = (13, iEngland, iZulu, tEnglandZuluTL, tEnglandZuluBR, 1, iEnglandZuluYear, 10)

iEnglandNetherlandsYear = 1899
tEnglandNetherlandsTL = (63, 10)
tEnglandNetherlandsBR = (67, 10)
tConquestEnglandNetherlands = (14, iEngland, iNetherlands, tEnglandNetherlandsTL, tEnglandNetherlandsBR, 1, iEnglandNetherlandsYear, 10)

I'm now getting the following error. Was wondering what mistake I made in the scripting of the wars in the AIWars.py?

Traceback (most recent call last):
File "BugEventManager", line 400, in _handleDefaultEvent
File "CvRFCEventHandler", line 598, in onBeginGameTurn
File "AIWars", line 146, in checkTurn
File "AIWars", line 159, in checkConquest
IndexError: list index out of range
 
You have to add tConquestEnglandZulu and tConquestEnglandNetherlands to lConquests, found just before the start of the AIWars class. You also have to increase iNumConquests in Consts.py.
 
It's sort of awkward that iNumConquests exists in Consts.py while everything else is in AIWars.py, but that's necessary for StoredData.py. Sorry, that really isn't very intuitive.
 
Does this unique ability look coded correctly? Its meant to give a 50% chance of a Zulu rifleman being created if a Zulu unit wins a combat.

def zuluUP(self, argsList): #Real Slavery by Sevo
if not pZulu.isAlive(): return
if utils.isReborn(iZulu): return

pWinningUnit, pLosingUnit = argsList

iWinningPlayer = pWinningUnit.getOwner()
pWinningPlayer = gc.getPlayer(iWinningPlayer)

iLosingPlayer = pLosingUnit.getOwner()
iLosingUnit = pLosingUnit.getUnitType()

if iWinningPlayer != iZulu:
return

# Only enslave land units!!
if pLosingUnit.isAnimal() or not (pLosingUnit.getDomainType() == DomainTypes.DOMAIN_LAND and gc.getUnitInfo(iLosingUnit).getCombat() > 0):
return

iRandom = gc.getGame().getSorenRandNum(100, 'capture chance')
if iRandom < 50:
pNewUnit = pWinningPlayer.initUnit(iZuluRifleman, pWinningUnit.getX(), pWinningUnit.getY(), UnitAITypes.UNITAI_ENGINEER, DirectionTypes.DIRECTION_SOUTH)
CyInterface().addMessage(iWinningPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ZULU_WIN", ()), 'SND_REVOLTEND', 1, 'Art/Units/kongolese_pombos/button_pombospombos/button_pombos.dds', ColorTypes(8), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
CyInterface().addMessage(iLosingPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ZULU_LOSE", ()), 'SND_REVOLTEND', 1, 'Art/Units/kongolese_pombos/button_pombos.dds', ColorTypes(7), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
if pLosingUnit.getOwner() not in lCivGroups[5] and pLosingUnit.getOwner() < iNumPlayers: # old world civs now
data.iZuluRifleman += 1


It's only a small sample size, but so far have killed 3 units but not had any Zulu rifleman created.

ps. Should be ready to release my first mod civilization on Monday, so hopefully will stop monopolizing this thread with my questions!
 
Why don't you try a 100% chance to see if the code works? Or put a message into the else block.
 
You have to call this function in CvRFCEventHandler.py first. Search for onCombatResult() function. You can use the Viking UP as an example.
 
So my Zulu civ runs fine on my computer, and also works when I have downloaded it myself (1700AD scenario). However I am getting reports that other people can't play them. The errors appear to be C++ related, so I assume the issue is in the dll. When I upload the dll it wont let me upload the cvgamecoredll sdf (I think its too big). Could that be the issue?
Thanks.
 
You only need to upload Assets/CvGameCoreDLL.dll.
 
You only need to upload Assets/CvGameCoreDLL.dll.

Ah, I didn't do that. Have uploaded now.

Anyone willing to try my Zulu civ and let me know if it is working? Pretty please!
 
What site is best to use to upload my mod (so that other people can download it), and how do I upload it?
Also is there a way to upload the whole mod to git (at the moment I am just selecting individual files from the mod to upload)?
Thanks,
 
There are several free host sites. Before I had git branches, I used Sourceforge for my files.

IIRC, if you select the mod folder and commit that one, all subfolders and files will automatically be selected to be uploaded.
 
Use git, please. It is very useful in keeping track of changes and ensures that we can download updates without downloading every single file all over again.
 
Looking at the cvgametxtmgr, which python file does it get the ecivilization data from?

// Historical Victory goals
if (bDawnOfMan)
{
szText = NEWLINE + gDLL->getText("TXT_KEY_UHV_GOALS");
swprintf(szTempString, SETCOLR L"%s:" NEWLINE ENDCOLR, TEXT_COLOR("COLOR_HIGHLIGHT_TEXT"), szText.GetCString());
}
else
{
szText = gDLL->getText("TXT_KEY_UHV_GOALS");
swprintf(szTempString, NEWLINE SETCOLR L"%s" ENDCOLR , TEXT_COLOR("COLOR_ALT_HIGHLIGHT_TEXT"), szText.GetCString());
}
szInfoText.append(szTempString);

if (bDawnOfMan)
szText = L" ";
else
szText = L"";
szText += gDLL->getText("TXT_KEY_ICON_BULLET");
szText += gDLL->getText(uniqueGoals[eCivilization][0]);
szText += NEWLINE L" " + gDLL->getText("TXT_KEY_ICON_BULLET");
szText += gDLL->getText(uniqueGoals[eCivilization][1]);
szText += NEWLINE L" " + gDLL->getText("TXT_KEY_ICON_BULLET");
szText += gDLL->getText(uniqueGoals[eCivilization][2]);
szText += NEWLINE L" ";
 
1. Please use [ code ] tags for better legibility.
2. Is this from DoC?
 
No its from RFC GW (I would ask the questions on that forum, but I suspect no one is monitoring that forum). So the main civ menu presents txt keys in the order of the BTS civs.
so Egyptians = America txt_key_uhv_ame
Babylonians = Arabia txt_key_uhv_ara
Phonecia = Aztecs txt_key_uhv_azt
and so on...

However for 3 of the civs the txt_key requests are missing and replaced with "XXX"
Coincidentally those 3 civs are in the spots that would have been occupied by Byzantium, Celts, and Holy Roman (all excluded from Rhys original Rhys and fall mod I believe).
So I am figuring (and I may be way off) that the cvgametxtmgr dll isn't pulling the text for those civs because they are not included on a list of civs to use somewhere in python.
I hope that all makes a kind of sense!!

upload_2018-7-1_15-24-38.png

upload_2018-7-1_15-25-24.png
 
There should be CvRhyes.h file where this is defined, but really every editor has a search function to answer this question.
 
Back
Top Bottom