Quick Modding Questions Thread

How on earth do I change what units the game starts with?! :wallbash:
I want to change it from Warrior to something else: I have set up the unit. It upgrades to Warrior. Warrior requires techs that no civ starts with. I changed conscription value accordingly. :badcomp:
And it still doesn't work! [pissed]
 
How on earth do I change what units the game starts with?! :wallbash:
I want to change it from Warrior to something else: I have set up the unit. It upgrades to Warrior. Warrior requires techs that no civ starts with. I changed conscription value accordingly. :badcomp:
And it still doesn't work! [pissed]
Go to CIV4HandicapInfos.xml or CIV4WorldSize.xml both of them in GameInfo. It is pretty simple to understand if you take a look around.
 
Go to CIV4HandicapInfos.xml or CIV4WorldSize.xml both of them in GameInfo. It is pretty simple to understand if you take a look around.
No offence but I'd prefer a useful reply from someone who knows the answer.
FYI: I did check those files long ago and many others that seemed to be related but none proved to be relevant.
 
No offence but I'd prefer a useful reply from someone who knows the answer.
FYI: I did check those files long ago and many others that seemed to be related but none proved to be relevant.
Ok I have the real answer. Go to Assets/XML/Civilizations/CIV4CivilizationInfos.xml open the file.
Search for:
Code:
            <FreeUnitClasses>
                <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SETTLER</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
            </FreeUnitClasses>
and add an entry for whatever unit you want. Let's say scout.
Code:
            <FreeUnitClasses>
                <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SETTLER</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
               <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SCOUT</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
            </FreeUnitClasses>
So this is how it should look.
 
How on earth do I change what units the game starts with?! :wallbash:
I want to change it from Warrior to something else: I have set up the unit. It upgrades to Warrior. Warrior requires techs that no civ starts with. I changed conscription value accordingly. :badcomp:
And it still doesn't work! [pissed]
I don't have the answer. Louis second answer about the civinfos thing sounds the most plausible.
I'm actually more curious what this unit that upgrades to a warrior would be? Rock thrower? Knife weilding maniac? :backstab:
 
In Caveman2Cosmos they actually have the Rock Thrower!
Yes. But my idea is this:
You start with a Settler (renamed to Tribe). It can create a unit: Child, which can upgrade to Male (pre-warrior) or Female (pre-worker).
AND's dll can handle the above I just don't know how to get rid of the damned warriors you start with.
 
Ok I have the real answer. Go to Assets/XML/Civilizations/CIV4CivilizationInfos.xml open the file.
Search for:
Code:
            <FreeUnitClasses>
                <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SETTLER</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
            </FreeUnitClasses>
and add an entry for whatever unit you want. Let's say scout.
Code:
            <FreeUnitClasses>
                <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SETTLER</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
               <FreeUnitClass>
                    <UnitClassType>UNITCLASS_SCOUT</UnitClassType>
                    <iFreeUnits>1</iFreeUnits>
                </FreeUnitClass>
            </FreeUnitClasses>
So this is how it should look.
I gave it a try but just a I expected it is not the solution:
Spoiler :
upload_2020-11-26_8-42-24.png

It only added an extra unit, instead of replacing the Warrior :rolleyes:
 
I gave it a try but just a I expected it is not the solution:

It only added an extra unit, instead of replacing the Warrior :rolleyes:
Ok then, it might actually be hard coded in the DLL (not 100% sure) like that settlers cost 140 or something is hardcoded in the DLL.
An idea could be too just rename the Warrior and replace his art BUT leave the tag <UNITCALSS_WARRIOR> and <UNIT_WARRIOR> after that simply create a new unit and name it warrior! So then the game will think that the Tribe unit is a Warrior.
 
An idea could be too just rename the Warrior and replace his art BUT leave the tag <UNITCALSS_WARRIOR> and <UNIT_WARRIOR> after that simply create a new unit and name it warrior! So then the game will think that the Tribe unit is a Warrior.
Yes, that's what I did after all with both Settler and Warrior units. Not so elegant and now I fear what bugs or anomalies will it cause but that's it :rolleyes:
 
Yes, that's what I did after all with both Settler and Warrior units. Not so elegant and now I fear what bugs or anomalies will it cause but that's it :rolleyes:
I know one bug that it might cause but which you can fix. Open CIV4GoodyInfos.xml in the GameInfos folder and replace the Warrior and Settler with the real Warrior or Settler or simply remove them,
 
I know one bug that it might cause but which you can fix. Open CIV4GoodyInfos.xml in the GameInfos folder and replace the Warrior and Settler with the real Warrior or Settler or simply remove them,
Did that already :thumbsup:
I'm more worried about references to Warrior and Settler in the dll and python files.
XML are not a big issue since I well know them and most of them are modular (these changes won't be part of the main mod but an optional module).
 
Did that already :thumbsup:
I'm more worried about references to Warrior and Settler in the dll and python files.
XML are not a big issue since I well know them and most of them are modular (these changes won't be part of the main mod but an optional module).
Yeah XML is very easy to understand.
I don't think any Python files have references to units, the DLL probably does. I'll look in some of the DLL files and let you know!
 
How on earth do I change what units the game starts with?! :wallbash:
I want to change it from Warrior to something else: I have set up the unit. It upgrades to Warrior. Warrior requires techs that no civ starts with. I changed conscription value accordingly. :badcomp:
And it still doesn't work! [pissed]

The number of initial free units are actually set by CIV4EraInfos.xml. This gives values for <iStartingDefenseUnits>, <iStartingWorkerUnits>, and <iStartingExploreUnits>. If you set <iStartingExploreUnits> to 0 that should get rid of the free Warrior. The starting Explore unit is chosen by the combination of AI (must have UNITAI_EXPLORE), strength (as I read it, 2/3 if the unit is not defend-only, 1/2 if it is), +200 per move, +100 if it has the "no bad goodies" flag set. This allows that starting unit to scale by starting era.
 
I have an error where the game freezes right before it is supposed to end, and I am not sure why.

The game is on the second to last turn, and when you end the turn it advances to the last turn and gets stuck. What normally is supposed to happen is that a scoring victory is triggered, the game ends no matter if the player wins by score or loses to the AI. I have determined that an AI wins by score, and the game state is set to over. The popup that sends the "you have been defeated" popup (and the subsequent end of game screens) are launched, but never show up on screen. I assume that the game hangs somewhere else, before they can be shown, but I have no idea where.

My debugging shows that the CvGame::update() invocation that advances the turn and makes the AI the winner fully executed without getting stuck, but then I have no way of determining what is called next because it is called from the exe (but I do know that it is not called again before the freeze).

Any ideas where to look? Something I could try?
 
Has anyone found a way to make it so that *specific* buildings can benefit from the happiness/health modifiers of civics? I have limited experience in XML and Python, and most of what I know has been based off of trying to make a modmod for Realism Invictus - one of the goals being to make it so that certain civs have some direct incentives to play closer to some of the civics they historically trended towards. Unfortunately my limited testing hasn't found a way to make it so that a unique building can get a happiness/health bonus from a civic - I.E. the Castrum getting +1 Happiness from Republic but not the Barracks buildingclass as a whole. Is it hardcoded for buildingclasses or is there a way to make it so that specific buildings can benefit? Additionally, is it possible to give leaderheads more than one favorite civic?
 
Any ideas where to look? Something I could try?
Hopefully the infinite loop isn't entirely in the EXE. If it involves the DLL, then an external profiler should do the job. (I think the DLL-internal profiler only produces output when the game is exited gracefully, and the profiling macros cover only a small portion of the codebase.) On Nightinggale's suggestion, I've been using "Very Sleepy" for debugging infinite loops. My procedure is: Compile a DLL with debug symbols; get to the point where the game freezes; launch Very Sleepy; select the BtS process and the thread with 100% CPU load; "Profile Selected" (unless the current code location shown for the frozen thread already provides sufficient information). I'm attaching a screenshot.
 

Attachments

  • Very Sleepy example.jpg
    Very Sleepy example.jpg
    228.4 KB · Views: 46
Ah nice, thanks. I remembered the advice to use a profiler but couldn't make it work because I only tried using the internal one. That is definitely worth a look. What can I expect to see if the loop is in the exe instead?
 
Has anyone found a way to make it so that *specific* buildings can benefit from the happiness/health modifiers of civics? I have limited experience in XML and Python, and most of what I know has been based off of trying to make a modmod for Realism Invictus - one of the goals being to make it so that certain civs have some direct incentives to play closer to some of the civics they historically trended towards. Unfortunately my limited testing hasn't found a way to make it so that a unique building can get a happiness/health bonus from a civic - I.E. the Castrum getting +1 Happiness from Republic but not the Barracks buildingclass as a whole. Is it hardcoded for buildingclasses or is there a way to make it so that specific buildings can benefit? Additionally, is it possible to give leaderheads more than one favorite civic?
This is how to make a building in general get happiness through XML in the GameInfo folder and the CIV4CivicInfos.xml file
Code:
            <BuildingHappinessChanges>
                <BuildingHappinessChange>
                    <BuildingType>BUILDINGCLASS_BARRACKS</BuildingType>
                    <iHappinessChange>1</iHappinessChange>
                </BuildingHappinessChange>
            </BuildingHappinessChanges>
To make a unique building get modifiers is done either with python or C++. I wrote a quick code for you which works because I have tested it out! (I haven't modded in a while and my skills where kinda rusty, wasn't expecting it to work:crazyeye:!)
Code:
                serfdom = gc.getInfoTypeForString( "CIVIC_SERFDOM" )
                iPlayer = pCity.getOwner()
                pPlayer = gc.getPlayer(iPlayer)
                if (pPlayer.isCivic(serfdom)==True) and iBuildingType == gc.getInfoTypeForString("BUILDING_ROMAN_FORUM"):
                              (loopCity, iter) = pPlayer.firstCity(false)
                               while(loopCity):
                                      loopCity.changeExtraHappiness(1)
                                      (loopCity, iter) = pPlayer.nextCity(iter, false)
So this code will change the happiness with 1 if the player builds a Roman Forum and has Serfdom as a civic. You have to put it in the CvEventManager.py in the Python folder under the statement below.
Code:
    def onBuildingBuilt(self, argsList):
        'Building Completed'
        pCity, iBuildingType = argsList
        game = gc.getGame()
 
Last edited:
Back
Top Bottom