Quick Modding Questions Thread

Is there a way to get the default leader name you start with when you set up a new game in the DLL code? Alternatively, is there a way to set it so that this name is by default the actual name of the leader I have chosen, instead of "Leoreth" or the like?
 
The EXE seems to read the most recently used human name from CivilizationIV.ini and, when the Custom Game screen or (under Play Now) the Civ Selection screen is opened, sets that name through CvInitCore::setLeaderName. Empty strings for the AI players, which, later, causes CvPlayer::getName to fall back on CvInfoBase::getDescription. If a different custom name is set during a game (e.g. through the Player Details popup), then I think the initial name will be lost. (Not sure if that's relevant to the question - whether the aim is to set the name while the game is being initialized or to restore that initial name at a later time.)

Perhaps also worth pointing out: On the scoreboard, BUG decides which name to display. (CvMainInterface.updateScoreStrings)
 
Thanks!

My intent was to skip the human name and make the default display name the name of the leader you have chosen (essentially as a prefill in the "name your leader" menu during game start) but allow you to manually enter your own name here as well to override that default. My current solution is to always override the leader name to the name of the leaderhead, which works for the former but prevents the player from changing it in any way.

I did not know that empty strings lead to a fallback to the leaderhead description, maybe I can make use of that.
 
I've run a test with
Code:
if (getCiv(eID) == NO_CIVILIZATION)
	return;
at the start of CvInitCore::setLeaderName. This discards the name loaded from the INI and causes the CvLeaderHeadInfo name to be shown in the edit box of the "Your Details" (YD) screen - or "[default]" if "Random" was chosen on the civ selection screen. In this latter case, typing in a different name doesn't work because the civ type is then still NO_CIVILIZATION when the YD screen comes up. So my condition for detecting the YD screen isn't quite right. (I also haven't checked whether the civ type gets reset upon returning to the opening menu.) Hopefully something like this will work to get the prefill right.
(All this only goes for the Play Now screen; don't know at which point the Custom Game screen sets the civ type and default player name.)
 
I'm trying to show an image (of a file) in game according to a path, I want to "catch" an error if the .dds file doesn't exist. (* just to be clear : it works fine when the file is there, but show a "pink" box when it's not)
The python command "Try: .. except" is not helping with this.
What's the most efficient way of doing this ?

You should be able to do that by using something like:
Python:
szFilePath = "PublicMaps\Pictures\BTG_"+ str(szCleanName) + ".dds"
if os.path.exists(szFilePath):
    popup.addDDS(szFilePath, 500, 500, 500, 500)
else:
    popup.setBodyString("[ No Map Picture]", CvUtil.FONT_LEFT_JUSTIFY)
You need to import os module to use os.path if it's not imported already.
 
I've run a test with
Code:
if (getCiv(eID) == NO_CIVILIZATION)
    return;
at the start of CvInitCore::setLeaderName. This discards the name loaded from the INI and causes the CvLeaderHeadInfo name to be shown in the edit box of the "Your Details" (YD) screen - or "[default]" if "Random" was chosen on the civ selection screen. In this latter case, typing in a different name doesn't work because the civ type is then still NO_CIVILIZATION when the YD screen comes up. So my condition for detecting the YD screen isn't quite right. (I also haven't checked whether the civ type gets reset upon returning to the opening menu.) Hopefully something like this will work to get the prefill right.
(All this only goes for the Play Now screen; don't know at which point the Custom Game screen sets the civ type and default player name.)
Oh great, thank you, I'm going to try that. And yes, all of this is for the Play Now screen. Actually, basically my goal is to emulate the setup I had for custom games where the scenario already dictated your leader name and you had to change it manually if you wanted (although there is not a specific prompt for that during game setup).
 
You should be able to do that by using something like:
Python:
szFilePath = "PublicMaps\Pictures\BTG_"+ str(szCleanName) + ".dds"
if os.path.exists(szFilePath):
    popup.addDDS(szFilePath, 500, 500, 500, 500)
else:
    popup.setBodyString("[ No Map Picture]", CvUtil.FONT_LEFT_JUSTIFY)
You need to import os module to use os.path if it's not imported already.
Worked like a charm, thanks a ton !
 
Can anyone tell me what file is used for the background of the tech tree? I can't find it anywhere in the XML files or the image files.
 
Can someone help me change the animation/effect that plays when a missionary unit is used to spread a religion?

I am trying to use the Luonnotar model from FfH2 as a Protestant missionary. Unfortunately, the model for it was apparently created based on the Jewish missionary, so in the nif file it is associated with EFFECT_MISSIONARY_ACTIVE_JEWISH, and consequently when it is used the Jewish missionary effect showing the star of David plays.

I would like to replace it with the Christian effect that shows a cross, but when I replace it with EFFECT_MISSIONARY_ACTIVE_CHRISTIANITY, the action does not play any effect at all (i.e. the unit animations play but no additional effect is displayed).

I tried to look into the nif file for the Christian missionary, but curiously it does not reference EFFECT_MISSIONARY_ACTIVE_CHRISTIANITY at all, as far as I can tell. Clearly I am missing something here. What do I have to do to associate the Christian missionary effect with this unit model?

ProtestantMissionary.png


Attached the nif files for this unit as well, in case it helps.
 

Attachments

  • Protestant Missionary.rar
    102.2 KB · Views: 8
The "effect" you see in a NIF file is NOT the name of the effect to be played. It is a node to which the .kf files will attach the effect to. The best way to think of it is like a reserved parking spot with a special name. By changing it all you did was make sure that there is no attachment point that the animation can find for the effect.

To actually change what effect is played start by making a copy of the entire original unit in question. In this case that's the jewish missionary. Than paste your NIF file into the same folder and rig up your XML to point to that nif and the copied KFM both. Finally edit the appropriate .kf file for that action in your new folder (in this case JewishMissionary_MD_Activate.kf) and change the effect name there.

You'll find the thing you need to change in the NiTextKeyExtraData node in the .kf file.
It should look something like this:
NIFSCOPE.png


The three underlined things are left to right:
  • A label telling the kf that the line describes an effect. See the above "sound" label for a line describing a sound.
  • The name of the node in the nif file you want the effect to attach to. For example changing this to BIP Head would cause the same effect to play but on the missionaries head instead.
  • The name of the effect to play. You want to change that bit.
So the whole line reads: Find the node called (blue) and attach the effect called (red) to it at Time.
 
Last edited:
I see. Already suspected the kf file was where this is actually controlled. I will try this at the next opportunity. Thank you!
 
I see. Already suspected the kf file was where this is actually controlled. I will try this at the next opportunity. Thank you!
The thing to remember is that the nif is always static. It's just a stage with all the props laid out on it. Any sort of dynamic behavior like animation is always in a .kf. And than the .kfm is a dispatcher that tells the game which .kf file to play for which action.
 
Nice, it worked! Also thank you for pointing out the existence of the associated sound effect in the same file, I otherwise would have probably missed to adjust that as well because I usually play without sound.

And yeah, I basically knew that everything animation related is in the kf files, I guess I was just confused by there not being any of them in the directory for this particular model because it was falling back on the Jewish missionary itself, and misunderstanding the presence of the XML key in the nif file. Always something to learn even after ten years of modding this game.
 
Hello! Can anyone here help us assess the feasibility of a Strait feature that can be implemented ingame?

The main idea is to implement a special kind of Route, or maybe a Terrain Feature, that when added to two water tiles in diagonal, splits off the land tiles on its perpendicular. Water units should be able to pass through the straits, following the usual cultural territory rules. It should look something like this:

1661622894403.png


The default implementation in the Civ 4 engine and/or DLL is that diagonally adjacent land tiles are visually connected on the map terrain, and water units cannot traverse between the bodies of water unless a friendly city is on one of the perpendicular land tiles. I had just come across the Canals modcomp while looking for the appropriate place to ask this, but I think that for this specific use case, it does not seem to be an appropriate solution given the scale.

Iirc, someone in another subforum I'm active in tried their hand on this, and managed to disconnect diagonal land tiles visually. However, the effect seemed to be global: not all of the similar instances should have the land tiles disconnected. Some areas should have it connected and act as contiguous landmasses, while others should have straits in between them.

Would this kind of feature be feasible to implement in the game? Or would it be difficult, given the scope of the SDK and the lack of source code for the engine?

PS: Please feel free to move this post to a different thread if appropriate :)
 
There is a modcomp for that already.
 
Which one?
I don't remember exactly. I ran into it a couple days back whilst randomly browsing through the modcomps. I think it was like a strait modcomp rather than what he wants. But it's easy enough to turn one into the other.
 
I think an easy solution for @h0spitall3rz's question would be this:

Create a New terrain feature: Strait. I already have such thing for the graphics in my mod called islets. Place this feature on a 1 tile wide ocean between 2 land masses.
Change the map generator to randomly place Straits on 1 tile wide ocean plots connecting 2 land masses and/or replace a land plot with coast terrain and strait feature, when there is a long, one tile wide landscape.
 
I went and made a search.
 
I went and made a search.
To my understanding that is just not what he wants.
I had just come across the Canals modcomp while looking for the appropriate place to ask this, but I think that for this specific use case, it does not seem to be an appropriate solution given the scale.
 
Top Bottom