Quick Modding Questions Thread

Thank you. Can I propose alternative method please? Click on download link, unzip the resulting mod folder, and see everything in original bug causing order.
 
It's up to you. My old internet laptop is showing signs of fatigue so I don't launch Civ4 anymore. I'm not gonna download 128MB of a mod that does not interest me.
 
Here we go. I hope it is possible to debug things without launching the exe files. This is not my mod, I am trying to help another nice guy there.
 

Attachments

Thanks, Tigranes.

In CIV4LeaderHeadInfos.xml, there are 6 times "CONTACT_TRADE_SLAVE". Such an addition should be reflected in GlobalTypes.xml (which also states that "Changes must be reflected in CvEnums.h" - dll).

Ask the modder where it comes from. Are the modifications in the dll? Does it work in game?

Solution: delete all these references OR add it (at least) in GlobalTypes.xml file which you can find in base XML folder (of BtS because it's not in the mod).
 
Thank you dear friend, I was too anxious to lose my title if I failed to deliver here! :D
 
Thanks, Tigranes.

In CIV4LeaderHeadInfos.xml, there are 6 times "CONTACT_TRADE_SLAVE". Such an addition should be reflected in GlobalTypes.xml (which also states that "Changes must be reflected in CvEnums.h" - dll).

Ask the modder where it comes from. Are the modifications in the dll? Does it work in game?

Solution: delete all these references OR add it (at least) in GlobalTypes.xml file which you can find in base XML folder (of BtS because it's not in the mod).

Thanks a ton! They took this from Rhye's original RFC where we have salves. And probably forgot to delete. I did -- and it worked like a magic. It's a shame you joined us so late, after this game was around for 10 years.
 
CvUnitAI::AI_rangeAttack in CvUnitAI.cpp

I cant figure out when this is used by the AI. Sometimes it does the Rangeattack, while other times it doesnt. The only other place I can find it is in CvUnitAI::AI_anyAttack
PHP:
	if (AI_rangeAttack(iRange))
	{
		return true;
	}
which doesnt make any sense to me.
Also I wanted to make sieges "Range Attack Only" by putting this into CvUnit.cpp
bool CvUnit::canAttack(const CvUnit& defender) const
PHP:
	if ((airRange() > 0) && !(getDomainType() == DOMAIN_AIR)) //Vincentz Ranged attack
	{
		return false;
	}
which works for the Human Player (unit cannot attack directly, but can rangeattack), but then the AI completely ignores the AI_rangeattack even though there is no canAttack in there.

Basically I want the AI to rangeattack every time it can, since there is no cost or damage to the unit for doing so.

edit : I'm thinking maybe setting <iCombatLimit> in CIV4UnitInfos.xml to 0 for the sieges, but then the
PHP:
bool CvUnit::canFight() const
{
	return (baseCombatStr() > 0);
}
in CvUnit.cpp will be False, and Im back to square one. And I suspect that even if I can set it to true with ((airRange() > 0) && !(getDomainType() == DOMAIN_AIR)) it wont change the AI's behavior.
 
One quick question, Does somewhere on forum, or somewhere in some mod, exist STAR-WARS units, especially ROBOTS. I was search, but i don't found.
 
I want to share my code with community and i have one question.
This code correct work and allow you to only once choose your civic from one civicoption (You can only choose once your affinity, choose wise between Harmony, Purity and Supremacy).
Solved idea from THIS post.
CvGameUtils.py:
Code:
	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		pPlayer = gc.getPlayer(ePlayer)
		if(pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_HARMONY")) == true):
			if(str(gc.getInfoTypeForString("CIVIC_NO_AFFINITY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_PURITY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_SUPREMACY")) == str(eCivic)):
				return True
		elif(pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_PURITY")) == true):
			if(str(gc.getInfoTypeForString("CIVIC_NO_AFFINITY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_HARMONY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_SUPREMACY")) == str(eCivic)):
				return True
		elif(pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SUPREMACY")) == true):
			if(str(gc.getInfoTypeForString("CIVIC_NO_AFFINITY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_HARMONY")) == str(eCivic) or str(gc.getInfoTypeForString("CIVIC_PURITY")) == str(eCivic)):
				return True
		return False

This demand,
PythonCallbackDefines.py:
Code:
	<Define>
		<DefineName>USE_CANNOT_DO_CIVIC_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
QUESTIONS:

1) Where is event, function, method or whatever, which trigger when i switch to some civic ?

2) I want to change cityart when some player switch to some civic, example:
ARABIA, (Saladin) have ARTSTYLE_ARABIA,
if Saladin switch to CIVIC_HARMONY, i want to ARABIA have ARTSTYLE_HARMONY,
if switch to CIVIC_PURITY it will have ARTSTYLE_PURITY,
if switch to CIVIC_SUPREMACY it will have ARTSTYLE_SUPREMACY.
here is some code improvisation / prototype but of course its not work and give a error (and if this code successful up and running, i want to put it in place from question 1)):
Code:
	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		pPlayer = gc.getPlayer(ePlayer)
		if(pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE")) == true):
			(loopCity, iter) = pPlayer.firstCity(false)
			while(loopCity):
				loopCity.setArtStyleType(0)
				(loopCity, iter) = pPlayer.nextCity(iter, false)
Do i must change artstyle of every city from player in this case ARABIA (Saladin) or it only enough to change civilization artstyle in game.
 
1) There is none.
2) There is no setArtStyleType in python unless you exposed it.

P.S.
If there are only 4 civics, you might as well just simply write:

Code:
	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		pPlayer = gc.getPlayer(ePlayer)
		if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_NO_AFFINITY")):
			return False
		return True
Why so troublesome.
 
1) dll - start with CvPlayer::canDoCivics

2) dll only - start here or here or here or here or here or there (prepare food supply for a week) ;)
 
1) There is none.
2) There is no setArtStyleType in python unless you exposed it.

P.S.
If there are only 4 civics, you might as well just simply write:

Code:
	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		pPlayer = gc.getPlayer(ePlayer)
		if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_NO_AFFINITY")):
			return False
		return True
Why so troublesome.

No, i don't have only 4 civics, i have several CIVICOPTION_... and i in every CIVICOPTION_... i have several CIVIC_...

I must in C++ code expose setArtStyleType in python ?

1) dll - start with CvPlayer::canDoCivics

2) dll only - start here or here or here or here or here or there (prepare food supply for a week) ;)

1) in CvPlayer::canDoCivics i must hardcode my idea ?

2) :(
 
I was once asked to implement 2) in RaR (colo mod, but this part of the code is the same), but due to complexity and since it wasn't actually my mod, I wasn't sure if it would even be accepted in it. Still I figured out that there are two ways to do it.

A: the DLL has a unit function the exe calls to get the art string. Edit that one to return whatever art string you want. You need getOwnerINLINE() and get the civic for that player to determine which one you have. Add more art tags to xml, which can then be used as return values. You may have to mark the screen dirty in CvPlayer::doCivic() to force the exe to ask the dll for unit art for all units again. The exe is quite good at caching data like that, which is good for performance, but it can prevent your graphical changes from being visible.

B: big hack. Alter the art in the info class. I'm not recommending it, but Age Of Discovery II use that approach when declaring revolution. Likewise you could change the info class from CvPlayer::doCivic(). However doing that would ensure your ticket to programmer hell. One issue is that it doesn't reset on load or new game, but there are several other issues as well. Changing the info classes after game start is generally not a good idea.

If you have the skill to make A, then it should be fine and releasing a standalone modcomp for it would be nice as other people could benefit from it. If you have to resort to B, then I would recommend that you stop for a moment and think if you really want this feature badly enough to violate the info class concept.
 
Looks like Zlatko posted before I was done writing :(

I must in C++ code expose setArtStyleType in python ?
C++ is way better for this than python is. If you aren't ready to make this in C++, I would say you aren't ready to make this at all. I know it's a bit harsh to say it like that, but really, it's part of the graphic drawing system. You don't want to introduce python execution speed.

Well I guess you could edit the dll to cache the art strings in CvPlayer and then set the strings from python. I would consider that a poor design though.
 
Zlatko,

1) didn't say that you have to hardcode things there, you just asked where was the trigger.

2) maybe check this Captured City Art mod comp for ideas on how to do it
 
Why me always think of some crazy ideas in modding ?

@Nightinggale
I will try to make this, something i maybe don't said, i want to change city artstyle, not units.

@isenchine
I will check.
 
Back
Top Bottom