Modmodding Q&A Thread

AAAAHHHHHHHHHHHHHHHHH forget it my brain turned LoR into DoC because the letters are similarly typed. I will never ever live this down...
 
How would I go about lowering the propensity for the AI to build preserve forest? Or is moving it back to Ecology in BuildInfos going to cause problems?
 
I'm trying to make UNITAI_ type for my slave unit. it's supposed to do 1 of 4 things:

rush a building using the normal mechanic (mini-engineer)

conduct a trade mission using the normal mechanic (mini-merchant)

settle in a city (mini-super specialist)

act as a worker

I added UNITAI_SLAVE and slaveMove(), which is, for now, just a copy of workerMove(), but the slaves either sit in cities and do nothing or go exploring.

any idea what might be missing?
 
How would I go about lowering the propensity for the AI to build preserve forest? Or is moving it back to Ecology in BuildInfos going to cause problems?
I couldn't think of anything besides modifying the improvement AI directly.

I'm trying to make UNITAI_ type for my slave unit. it's supposed to do 1 of 4 things:

rush a building using the normal mechanic (mini-engineer)

conduct a trade mission using the normal mechanic (mini-merchant)

settle in a city (mini-super specialist)

act as a worker

I added UNITAI_SLAVE and slaveMove(), which is, for now, just a copy of workerMove(), but the slaves either sit in cities and do nothing or go exploring.

any idea what might be missing?
Are slaves declared as starting with UNITAI_SLAVE and is it a possible AI for them? Are you sure slaveMove() is actually called when UNITAI_SLAVE is active? Conversely, are you sure that UNITAI_SLAVE is actually active for the units you are using for testing?

Might be obvious but worth a first check. I can dig into more code specific causes later.
 
Are slaves declared as starting with UNITAI_SLAVE
and is it a possible AI for them?

do you mean in CvUnitInfos.xml? it is their default unitai

Are you sure slaveMove() is actually called when UNITAI_SLAVE is active?

I don't know what is meant by the unit_ai "being active". the only changes I made were defining slaveMove(), adding it to the list under "switch (AI_getUnitAIType())" in CvUnitAI::AI_update()... which I just now realize is just a boolean so it's probably just asking asking whether or not to continue the action it's currently pursuing? I was using your unitai_statesman as a guide as to what needed to be added and only found those references. I guess I'm missing something.

Conversely, are you sure that UNITAI_SLAVE is actually active for the units you are using for testing?

you can see in cheat mode the that the unit has the proper unitai
 
Find where SoI stores its terrain art (terrains, features, resources), put it in your mod, look into the terrain art defines and correct the paths there accordingly.
 
I assume you added them add the end of the XML file? Because I'm pretty sure that's what determines the order in the menu.
 
You can edit the name of the city in WB of course, but to change how city names are assigned or renamed you need to edit CityNameManager.py.
 
You mean in Python? I don't think I have exported it yet.
 
Leoreth, do you have a preference for use of brackets in if-statements or for-loops? I'm currently running through plague.py and made several small code updates. In the process, I removed a lot of brackets, like below.

Code:
		if (iPreserveDefenders > 0):
Into
Code:
		if iPreserveDefenders > 0:

I see that you normally doesn't have the brackets. (I assume they are leftovers from Rhye) My concern is that it would make the comparison screen messy.

If you prefer to keep the brackets, I can revert them.

(I can also make split my updates in multiple commits. One containing the real updates. The other contains just the removal of the brackets)
 
No, not placing the brackets is more idiomatic in Python. Given his background in robotic engineering, I suspect Rhye's style is heavily influenced by C, where brackets around conditionals are mandatory. You often see him go for C-like constructs where Python offers a more elegant solution.
 
In CvUnit, what index in the array is Combat 1? I'm working on a mod where one Vic's UP is having all the land units start with that promotion.

Also, more general question, in mods that aren't offshoots of RFC, can you use getOwnerInline (I'm typing this on mobile, will clarify it once I get to my computer) to determine the identity of a civilization? Namely for unique powers. If not, is there any way besides maybe leader traits to do that in the DLL?
 
The ID associated with a promotion is its position in the XML file where it's defined, starting with 0.

I suppose you're talking about getOwnerINLINE() in CvUnit? That method returns the player that owns the unit. You can get the civilization with GET_PLAYER(getOwnerINLINE()).getCivilizationType() from there (i.e. getCivilizationType() is a method of CvPlayer). In RFC that step is often skipped because in the scenarios, players are associated with set civilizations so you always know which player is which civs, but in general you can't assume that.
 
The ID associated with a promotion is its position in the XML file where it's defined, starting with 0.

I suppose you're talking about getOwnerINLINE() in CvUnit? That method returns the player that owns the unit. You can get the civilization with GET_PLAYER(getOwnerINLINE()).getCivilizationType() from there (i.e. getCivilizationType() is a method of CvPlayer). In RFC that step is often skipped because in the scenarios, players are associated with set civilizations so you always know which player is which civs, but in general you can't assume that.

That makes sense, thanks!

Also, is there any way to do Russia's unique power in a mod derived from regular BTS? If so, where would you check? My first guess would be either in CvUnit and check if the unit is in Russian territory and its owner is at war with Russia, then decrement its health, or check the tile to see if hostile units are on it, then hurt them. Either way seems pretty inefficient. Also, would it be possible to port the civ 5 maya UP to civ 4? It's after they discover Theology (or whatever tech in this case), they get a great person of their choice every 394 years until all choices have been exhausted.
 
I think both units and plots have a doTurn() method where you can put all kinds of things that are checked every turn. I don't think it matters where you're doing it because it's such a simple check. But damage from features is probably done on a plot level so it might be a good idea to do it for a Russian UP type effect as well (and you can copy some code probably).

For a Maya UP type thing, the main challenges are creating a dialog to choose the GP (including attaching effects i.e. spawning the right GP) and storing some information (the initial turn when the effect was triggered and which types of GP where already chosen). Everything for that can be best implemented in Python in my opinion.
 
Top Bottom