Quick Modding Questions Thread

I see. That's not ideal. I want resources to give happy benefit only to the city they are placed in. Still thanks.



A citizen (not the specialist) gives 1 unhappiness, 1 unhealthiness, and eats two food. I wanna modify these. I can see the food_consumption in globaldefines, but I can't find the are two. Where are they?

I could be wrong but I THINK it's in the handicaps infos.
 
I could be wrong but I THINK it's in the handicaps infos.

Nah man. I've already looked at all xml files that I thought could potentially have it, but found nothing. It's kinda weird. I think it might be hard coded, but what do I know, I'm not familiar with all the code, you guys know better.
 
yeah i think handicap info only handles the starting health and happiness 'boost' for game difficulty per city..

I can't think of anyone or any mod that has tried to change this..

It wouldn't surprise me if it handled in the source code, but again I have never tried to change this either so no idea...

What were you hoping to change the values to? Maybe a 'fudgey' solution could be found to give the same effect until you discover a proper solution.
 
The core unhappiness code is in CvCity::unhappyLevel() where a whole list of factors that make up the total unhappiness level of the city are applied. The one that would interest you is CvCity::getOvercrowdingPercentAnger() which is the value that directly ties in with the population level:
Spoiler :
Code:
int CvCity::getOvercrowdingPercentAnger(int iExtra) const
{
	int iOvercrowding;
	int iAnger;

	iAnger = 0;

	iOvercrowding = ([COLOR="Red"]getPopulation()[/COLOR] + iExtra);

	if (iOvercrowding > 0)
	{
		iAnger += (((iOvercrowding * [COLOR="Red"]GC.getPERCENT_ANGER_DIVISOR()[/COLOR]) / std::max(1, ([COLOR="Red"]getPopulation()[/COLOR] + iExtra))) + 1);
	}

	return iAnger;
}
As you can see PERCENT_ANGER_DIVISOR from GlobalDefines (defaults to 1000) also plays its part as well, but the primary driver for the unhappiness is the getPopulation() call which equates to 1 pop = 1 unhappiness. The Handicap mentioned by Thunderbird is one of the factors applied in the unhappyLevel() function

Unhealthiness is defined in CvCity::unhealthyPopulation() and is directly related to the population in a 1:1 basis in the same way. If you want to change the effect of a working citizen, this is where to do it.
Spoiler :
Code:
int CvCity::unhealthyPopulation(bool bNoAngry, int iExtra) const
{
	if (isNoUnhealthyPopulation())
	{
		return 0;
	}

	return std::max(0, (([COLOR="Red"]getPopulation()[/COLOR] + iExtra - ((bNoAngry) ? angryPopulation(iExtra) : 0))));
}
I would be careful about changing the ratio as it has the potential to imbalance the game unless you check all the AI code to see whether there are any assumptions based on the default 1:1 values. The AI is weak enough without adding to its woes!
 
I talk about Utility Program which will help modders during modding their mods and that i will try to make alone (in C++ or in PHP or maybe in both), i don't talking about MOD COMPONENT, but your idea about mod component is very nice i will participate on that project but i don't want to make mod component alone.
 
When making popup lists (from the DLL) come up, let's say for example as a reaction to a mission, is it possible to set those to demand that the player make the selection and resolve that popup before any further processing is allowed to proceed? I know MS Access had something of a setting along these lines and I'm hoping we have an easy way to make that happen. I mean, it already seems to with some things... the next city in the city build popup stream at the beginning of the game demands that you make your selection before it will give you the next one so that's kinda what I'm looking to enforce here and I hoped someone would know how that's done. I was wondering if it had something to do with the bFront parameter on gDLL->getInterfaceIFace()->addPopup?
 
Does anyone know how I can change the missionary success rates? Ie. If a city has no religion, default success rate is 100%, 1 religion lowers the success rate to 90%, etc.?
 
@ Archid

Thanks man, that's awesome. What I wanted to do is reduce pollution caused by population to 0.5 per head in the early eras and then increase it back to 1 slowly as modern technology comes around, reflecting things like plastic and oil and modern excess waste. Mainly idea is to remove health as a limiting factor in the early eras. So that's what why I was looking for it. But now it looks like it will require more work than I'd be interested in doing.
Same as happiness, I wanted to play with increase of discontentment over time. Less in early ages, more in later ages, allowing more freedom in early ages.


@Zlatko
Who you talking to?
 
Does anyone know how I can change the missionary success rates? Ie. If a city has no religion, default success rate is 100%, 1 religion lowers the success rate to 90%, etc.?

It's determined by the religioninfos which only allows it to be set by religion. Anything more tricky would take dll work (simple dll work but dll work.)
 
I have some buildings in my mod which are built by great people, like shrines, but the AI is extremely reluctant to build them even though they have decent bonuses (like +100% great people). xml entries iAIweight, iAsset and iPower seem to have no effect. can anyone tell me how to get the AI to build these buildings or tell me where that code can be found?

edit: nvm I got it
 
I have some buildings in my mod which are built by great people, like shrines, but the AI is extremely reluctant to build them even though they have decent bonuses (like +100% great people). xml entries iAIweight, iAsset and iPower seem to have no effect. can anyone tell me how to get the AI to build these buildings or tell me where that code can be found?

Unit builds like those are subject to being part of a priority of potential actions that can be taken by those units. Not all those units are even given the AI triggers to evaluate whether it's worth building a building like that. The key is in CvUnitAI code where it processes through the various unit AIs. Each 'thing the unit can do' will be processed for potential action in a sequence. So, for example, a Prophet will look to see if it can build a Shrine pretty much before it looks to see if it would want to join a city or become part of an effort to start a golden age. An Engineer will look to build a wonder if a wonder is possible to be built before it will look to do other things. But I think those, by default, are the only two that even look to see if they should be building anything because in Vanilla, they were the only ones that did (wait... the Spy does this too with Scotland Yard if I'm not mistaken.)

But other units may not even have any programming to determine if it's a good idea or not. If it's not a part of their AI sequence then they will never do it no matter how possible you make it for them to do otherwise. AI weights won't play a role because they aren't even beginning to evaluate the possibility because the possibility wasn't considered by Firaxis (nor should it have been... AI's should not be processing the potential to do something they can never do - that's a waste of processing time.)

The good news is that the Prophet, Engineer and Spy codes do give good examples of how it can be done and each is different in how it goes about it so are three differing models that can be easily copied to another AI.

If you can use the SDK that is...

If you CAN'T then it could be possible to use one of those three AI definitions on the units you want to be able to build like them. But this can come with all manner of unintended consequences and such units would not be programmed to ever have anything to do with battle (they'll assume it's just not for them in any way except to avoid danger as any Great Person should.) It can cause slowdowns as they may be evaluating a lot of things they can't do. And it's possible that other things are just flat taking priority over the builds because something else is being evaluated first and the unit always qualifies to do that other something and chooses to enact that action before it ever has a chance to evaluate whether to use the build action or not.

New and inventive actions are hard to work with if you aren't able to add them to the AI code routines. If I'm not mistaken, Python may have a way to program an AI action override routine but I'm not sure if that always must interrupt the normal dll evaluation process before, after or during the normal dll AI determinations. I'd assume it would come in at the beginning and thus would potentially cripple the unit from doing anything BUT what the Python tells it to if it can always find good reason enough to do so.

The unit AI mechanism would probably benefit more from a decision matrix style of determination rather than a linear step by step method that it currently uses but that's very complex programming and could have serious implications on performance. Particularly since there are potentially SO many units to consider actions on any given game turn.

Anyhow, if you do know the SDK a bit, open up the CvUnitAI and take a look... it's actually pretty intuitive which functions control these things. As a first timer I found the GP AI methods fairly self explaining. When you get into combat units it gets a LOT less direct and more complex thanks to the needs to arrange combat forces in stacks and such.
 
It's determined by the religioninfos which only allows it to be set by religion. Anything more tricky would take dll work (simple dll work but dll work.)

I don't mind dll work. Do you know which source file is the algorithm in? Thanks
 
I'm trying to eliminate some Handicap levels in my mod (I just want there to be 3).

when I cut them out and load the game it says it is missing the the Handicap xml tags in Civ4ForceControlInfos.xml, but that file doesn't contain those tags. can anyone help?
 
I'm trying to eliminate some Handicap levels in my mod (I just want there to be 3).

when I cut them out and load the game it says it is missing the the Handicap xml tags in Civ4ForceControlInfos.xml, but that file doesn't contain those tags. can anyone help?

I've gotten a similar error before. It has nothing to do with Civ4ForceControlInfos, that's just the last XML file the game calls. You should check in GlobalDefines.xml, it has some things you will need to change. For example:
Code:
	<Define>
		<DefineName>STANDARD_HANDICAP</DefineName>
		<DefineTextVal>HANDICAP_NOBLE</DefineTextVal>
	</Define>
	<Define>
		<DefineName>STANDARD_HANDICAP_QUICK</DefineName>
		<DefineTextVal>HANDICAP_CHIEFTAIN</DefineTextVal>
	</Define>
will probably need to be changed.

The same error happens if you remove eras. (FYI)
 
Does anyone know how I can change the missionary success rates? Ie. If a city has no religion, default success rate is 100%, 1 religion lowers the success rate to 90%, etc.?

CvUnit::spread(ReligionTypes eReligion) handles this with the relevant section being
Spoiler :
PHP:
		iSpreadProb = m_pUnitInfo->getReligionSpreads(eReligion);

		if (pCity->getTeam() != getTeam())
		{
			iSpreadProb /= 2;
		}

		bool bSuccess;

		iSpreadProb += (((GC.getNumReligionInfos() - pCity->getReligionCount()) * (100 - iSpreadProb)) / GC.getNumReligionInfos());

		if (GC.getGameINLINE().getSorenRandNum(100, "Unit Spread Religion") < iSpreadProb)
		{
			pCity->setHasReligion(eReligion, true, true, false);
			bSuccess = true;
		}
		else
		{
			szBuffer = gDLL->getText("TXT_KEY_MISC_RELIGION_FAILED_TO_SPREAD", getNameKey(), GC.getReligionInfo(eReligion).getChar(), pCity->getNameKey());
			gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_NOSPREAD", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pCity->getX_INLINE(), pCity->getY_INLINE());
			bSuccess = false;
		}
 
Back
Top Bottom