Quick Modding Questions Thread

What's the easiest way to throw a warning message in the logs from the dll ? Launching the game in terminal and "cout" ? Or is there a command that do that, an to which log file ?
 
You might try the logMsg function which should already be defined if you include CvDLLUtilityIFaceBase.h. Something like so:
Code:
gDLL->logMsg("TheLogFile.log", myMsg)
This is used in a few places in the BtS code.
 
In what order do the soundtracks play? Is it totally random?
 
In what order do the soundtracks play? Is it totally random?

It is random, except the era info has a bFirstSoundtrackFirst tag which probably makes the first one listed play first when you enter the era and then plays randomly after that. But neither I nor the Modiki are sure of that.
 
I have a problem. Civs stuck on distant islands, cant get the combat experience necessary to make the heroic epic, until astronomy, which is a huge disadvantage.

1. Since I buffed island starts, Im wondering if I can make Civil Service provide a free great general to everyone that researches it. Or a free level 4 unit to allow the creation of a heroic epic.

2. Either that, or a free combat experience point per turn after researching Civil Service...

No idea how to do either. Please help.
 
@Charles555nc: Of course it's possible :) I think the easier is in python :

1) In python, look at Assets/Python/CvEventManager.py, the function "onTechAcquired" is triggered everytime a tech is found (obviously). You can give a unit with the function CvUtil.spawnUnit(unitType, unitPlot, iPlayer).

2) For your second idea, you could look again in CvEventManager.py, function onBeginGameTurn, and use for instance the function CvPlayer::changeCombatExperience(int iChange) which is exposed to python, with a condition with player.isHasTech(eTech).

Welcome in the python modding ;)

Remember NEVER EDIT THE ORIGINAL FILES, follow instructions here to do safe modifications
 
Ok I went to python/CVEventManager.py and I found:

def onTechAcquired(self, argsList):
'Tech Acquired'
iTechType, iTeam, iPlayer, bAnnounce = argsList
# Note that iPlayer may be NULL (-1) and not a refer to a player object

# Show tech splash when applicable
if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iTechType)
popupInfo.setText(u"showTechSplash")
popupInfo.addPopup(iPlayer)

if (not self.__LOG_TECH):
return
CvUtil.pyPrint('%s was finished by Team %d'
%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))

Please tell me what to type for civil service to provide one great general to everyone that acquires civil service. And ill back up the file and maybe send it to custom assets? Will I have to do a recompile?
 
Yeah, for now you can just save it in custom assets, with the same path and the same name as in asset directory. It will have as effect to overwright the original file when you launch the game, without changing anything in the asset folder (so if you mess up, you can simply delete your file in cutom asset).

For a start, I'll add a simple code first to test out everything is ok and your file is loaded. So you can understand how python works. You first have to add :

Code:
import Popup as PyPopup

At the begining of the file, after the other imports. Then write in onTechAcquired :

Code:
		popup = PyPopup.PyPopup()
		popup.setBodyString( "Hello World" )
		popup.launch()

You can add that just after " # Note that iPlayer may be NULL (-1) and not a refer to a player object" for instance. Note that in python, indentation is important. You HAVE to be aligned with the previous line, with tabulations. This will add a popup saying "Hello world" everytime anyone get a tech.

Then, I don't know the ID of the civil service tech, so you can change a little bit your code to :

Code:
		popup = PyPopup.PyPopup()
		popup.setBodyString( "New tech : " + str(iTechType) )
		popup.launch()

The str() function convert the integer iTechType to a string. With that, you can just start a game and go to world builder. There if you add civil service to yourself, it will popup the ID.

Then, you can start your real code. Replace your popup message by :

Code:
if (iTechType == the_id_you_found_for_SC):
	CvUtil.spawnUnit(the_GG_ID, the_plot_you_want_to_spawn_it, iPlayer)

Note that :
  • This code is not so elegant. You should avoid using hardcoded ID in the code and get them dynamically instead.
  • You still have to get the ID of the GG, and the plot where you want to spawn it.

I don't remember by heart how to get them easilly in python, but hopefully, someone will passby and give you some tips on that. But with what I wrote, you should at least be able to understand how it should work.

I guess some of the function you will need are in PyHelpers.py, like "getCapitalCity" if you want to spawn the GG in the capital.
 
Hi,

Got a quick modding question about the XML code in TraitInfos. I'm trying to add a +50% worker speed modifier to a trait, but not 100% sure how to go about doing it. I tried the lazy way of copying+pasting from the civic infos in the GameInfosSchema file, and while the game does load, the trait doesn't give workers the extra 50 percent. Can anyone point me in the right direction?

Thanks
 
Unfortunately, the way the XML works is that you can only modify aspects of the game that already have a predefined tag for it. There is no XML tag in TraitInfos.xml to increase worker speed (you can look up the available tags and their function here), and adding a new tag requires a DLL change.

So it appears that you are out of luck.
 
@Looking2Mod,
Create a promotion which boosts worker productivity.
Give this promotion as a free promotion to all worker units if the leader has your new trait.
 
Thanks.
I looked into a worker productivity promotion, but I couldn't find a tag that boosts it, so I've been trying to copy and paste a DLL change into CvInfo.h and .cpp. Unsurprisingly it hasn't worked.
 
Question,

I made changes to the spiritual civ trait...and instead of saying like "+1 happiness for monastery". Its says "+1 happiness to christian monastery, jewish monastery etc etc etc" for all 7 religions.

Any easy way to just condense the text? Ironically the "double production for a temple" is short and sweet.
 
@Charles555nc
Monasteries, like temples, have a special building class. Go into the custom assets/xml/buildings and you can alter the specialbuildingsinfos instead. there's no happinesstraits tag though.

Edit: Sorry, there is a happinesstraits tag. The temple building has it; it should be easy enough to copy and paste that.
 
Hi,
I'm new to modding, and not having much luck. I've played CIV4 for years and many of the MODS as well. I've decided I'd like to try modding to create new experiences, but its proving more difficult than I thought. I wanted to try and add a new building to BTS, I wasn't sure where to start, so after reading tutorials by kael and ninja2 I decided to just copy/paste the "herbalist" building from FFH Age of Ice into a new MOD as an "easy" introduction to modding. Since its the only new thing in my mod, I only copied over the following XML docs:
XML/Buildings/Buildingclassinfos
XML/Buildings/BuildingClass
XML/Text/CIV4GameText_Civilopedia_BTS
XML/Text/CIV4GameText_Objects_BTS
XML/Art/CIV4ArtDefines_Building

When i choose the herbalist for my production queue my MOD crashes every single time. I've gone over and over my files and can't find what's causing my issue based on information from the tutuorials. I've attached the XML files.

I would really appreciate any help.
Thanks!
 

Attachments

Chances are it is because you took it from FFH which has a lot more content than vanilla BTS. So there may well be xml tags and references that are not present in bts that are in your herbalist entry.

When starting out with just making a new building it would be better to take vanilla bts files and add something in there (obviously first copying them to the mod folders as you have done) by copying one of those existing entries. If you wanted to mod FFH instead, you would need to take a copy of the whle FFH mod, then make changes to those files.

Mods have XML, python and SDK (SDK is 'compiled' into a .dll and has what is commonly referred to as the core code.) Games like FFH have made changes to this core code which effect both xml and python, so xml entries from FFH won't work with other mods, unless they also have the FFH .dll.
 
What about the art of the building? I guess you added it to your mod.

That is wrong:
Code:
<Button>,Art/Structures/Buildings/Herbalist/Herbalist.dds</Button>

Delete the leading comma (it is not even in FfH-AoI). A leading comma is only for buttons in an Atlas file.

Like that, you have a sure crash.

PS: FfH - Age of Ice does not have a custom dll.
 
Back
Top Bottom