Quick Modding Questions Thread

Hi team, something I think someone here helped me figure out but am not sure how to do anymore, it's a C++ language question :


How do you refer in a function to "the ID of yourself" ?

Here for example, I just want to pass in my logic the ID of the LeaderHeadInfo (I've put 12 as a placeholder but it's not good enough of course, I need to pass the real ID as first attribute)
This is from CvInfo.cpp :
Code:
void CvLeaderHeadInfo::setHasTrait(int i, bool bNewValue)
{
    if (hasTrait(i) != bNewValue)
    {
        m_pbTraits = bNewValue;
    }
    //2.42n We need to store this, because some leaders will now have new traits and not be played
    GC.getGameINLINE().storeLeaderTrait(12,i,bNewValue);
}
 
How do you refer in a function to "the ID of yourself" ?
You need to store that as an int or better yet LeaderHeadTypes in CvLeaderHeadInfo. Perhaps the easiest way is to add readPass2 and loop leaderheads until getLeaderHead(i).getType() == getType(), in which case you know you have the same. Be aware that the getType() approach naturally won't work for xml files without the Type tag.
 
There's something I'm trying to achieve.
There is this nice electric railroad nif to which I'd like to add wires.
This is what I tried so far:
1755772552369.png

I duplicated the tracks, moved them on the Z axis and changed the texture:
1755772918856.png

But the tracks texture has changed along with it. So is there an easy way to avoid that?
 
You need to store that as an int or better yet LeaderHeadTypes in CvLeaderHeadInfo. Perhaps the easiest way is to add readPass2 and loop leaderheads until getLeaderHead(i).getType() == getType(), in which case you know you have the same. Be aware that the getType() approach naturally won't work for xml files without the Type tag.
Thank you so much for quick reply.
Spent the evening on it, had to attack the problem differently but resolved my issue(s) and got my new feature working ! Pfiou ! I think it removes all the bugs I know of from my mod :king:
 
I pasted them in art/units. I think the instructions are incomplete. I tried. There's not enough info.
probably best to use the resources' discussion thread. ts should be by to provide clarfication
 
probably best to use the resources' discussion thread. ts should be by to provide clarfication
am i crazy? the instructions are incomplete. i know i have to edit the xml, right? but the instructions say nothing about it. just says paste it in. i edited the xml and made sure the nif were in their directories, that the xml was pointing to the new nifs, etc. something is missing.
 
I want to make a civ where it begin any game with the civic State Property. So I set this in CIV4CivilizationInfos.xml:
Code:
            <InitialCivics>
                <CivicType>CIVIC_DESPOTISM</CivicType>
                <CivicType>CIVIC_BARBARISM</CivicType>
                <CivicType>CIVIC_TRIBALISM</CivicType>
                <CivicType>CIVIC_STATE_PROPERTY</CivicType>
                <CivicType>CIVIC_PAGANISM</CivicType>
            </InitialCivics>
But in-game, it's still Decentralization. Can you think of any tricks to enforce State Property w/o giving my civ the Communism as a free tech? The civic could be a temporary one: if I ever switch to another economy, I don't necessarily have to see it as an available option again, until Communism.
 
The game checks if you are able to run a civic and if you can't it reverts you back to one that you can run. I can't think of an XML only workaround for that. If you're willing to look into Python, there should be something you can do via the canDoCivic function.
 
Oh! Will try the State's Pyramid :)
Just to make sure: when I give State Pyramid to my civ as a free building, it'll only appear once, in the capital, at the start, right?
 
You probably need to make it replace a building that you can only have one of, such as a palace, or make a new building class that limits to one.
 
But then I'll have to do some compiling, I guess?
Python only does not require compiling the DLL. You should feel comfortable writing basic Python code though. The game provides a place where you can insert the new rules when a civic can be chosen.

You could perhaps make a Unique Building that enables State Property, ala the Pyramids in game
I initially wanted to suggest that as an XML only workaround, but iirc the building XML only allows you to unlock an entire category, not individual civics. So e.g. Free Market would become available alongside State Property with this approach. If that's acceptable, the approach would work though.
 
I also have a question of my own: If I add two entries in the art defines XML that refer to the same assets in the file system, do the art assets get loaded into memory twice or just once?

For example, currently I have ART_DEF_UNIT_ARCHER_CHINESE which points to Art/Units/Archer_Chinese/Archer_Chinese.nif. Let's assume I add ART_DEF_UNIT_ARCHER_JAPANESE but point it to the same Art/Units/Archer_Chinese/Archer_Chinese.nif. Does this approach waste memory because the game now loads Archer_Chinese.nif twice?

The reason why I am considering this is that my mod has a baseline set of unit art for only the major culture groups (same as the base game) and then an additional "module" that provides (almost) civ specific unit art similar to Varietas Delectat. Currently the VD art cannot be provided as a pure module because the civ definitions and unit art style assignments are completely different, requiring them to be kept in sync to be compatible. I am considering moving the civ specific art definitions into the main mod while still using mostly shared unit art. Then the module can simply provide new art definitions alongside the new art in a much cleaner way.

However I only want to do this if it doesn't have a negative memory impact - the entire point of keeping additional art in an optional module is so that people who prefer performance over detail can choose not to use it.
 
How to upload any file greater than 25 MB to, say, Modpack forum? Anything over 25 MB gets rejected and my zip file is just 48 MB. I was under impression that 146 MB was the magic limit number, has it been changed recently?
 
No idea about the limit changing but sourceforge is still there as a reliable upload host.
 
Back
Top Bottom