Modmodding Q&A Thread

Okay, a few minor corrections of things you might have already realized but not explicitly stated there, to prevent you from running into trouble:

1. When you define a getText() method for CvEraInfo, you have already made sure that it isn't used by other classes. CvInfoBase is the class with the getText() method that is used by everyone else, which you cannot edit because you only want to change it for CvEraInfos.

2. All you need to do is call GC.getGame().getActivePlayer() in the new getText() method and then compare the returned value to the player constants.

This is definitely a good exercise to make something non-trivial yet simple happen with the DLL code, so I definitely suggest giving it a go

Edit: I've taken a look at the actual class and realized something else, so to give you some additional help, this is the CvInfoBase::getText() method:
Code:
const wchar* CvInfoBase::getText() const
{
	// used instead of getDescription for Info entries that are not objects
	// so they do not have gender/plurality/forms defined in the Translator system
	if(m_szCachedText.empty())
	{
		m_szCachedText = gDLL->getText(m_szTextKey);
	}

        // your code goes here

	return m_szCachedText;
}
Just copy this for CvEraInfo and recompile to see if it works, additional functionality can always be added later. Any special cases you want to handle go where I've made the comment. This might sound stupid now but an era also doesn't know what era it is (as in, it does know its name, but not the era type). So you have to use m_szCachedText itself to see what era it refers to, i.e. m_szCachedText == "TXT_KEY_ERA_MEDIEVAL" to check whether it is the medieval era and so on.

So the code I should input is as follow:
Code:
const wchar* CvInfoBase::getText() const
{
	// used instead of getDescription for Info entries that are not objects
	// so they do not have gender/plurality/forms defined in the Translator system
	if(m_szCachedText.empty())
	{
		m_szCachedText = gDLL->getText(m_szTextKey);
	}

        [B]GC.getGame().getActivePlayer()[/B]

	return m_szCachedText;
}

like that? or I should rename the CvInfoBase::getText() const into CvErainfo::getText() ?

Then, how do you compile a DLL? According to this guide, I need Microsoft Visual 2008? And the product is still CvInfos.cpp or will it be CvInfos.dll?
 
So the code I should input is as follow:
Code:
const wchar* CvInfoBase::getText() const
{
	// used instead of getDescription for Info entries that are not objects
	// so they do not have gender/plurality/forms defined in the Translator system
	if(m_szCachedText.empty())
	{
		m_szCachedText = gDLL->getText(m_szTextKey);
	}

        [B]GC.getGame().getActivePlayer()[/B]

	return m_szCachedText;
}

like that?
No, that code isn't doing anything. The getActivePlayer() method just gives you the ID of the human player, you would have to write the checks and return the appropriate texts yourself.

or I should rename the CvInfoBase::getText() const into CvErainfo::getText() ?
That too.

Then, how do you compile a DLL? According to this guide, I need Microsoft Visual 2008? And the product is still CvInfos.cpp or will it be CvInfos.dll?
Yes you do. Compiling creates the CvGameCore.dll file, which is a library containing all the compiled classes including CvInfos. I suggest you get that to work before we continue with the implementation details.
 
I wish to add a settler to the Turkish spawn. Unfortunately, the instructions given to me result in perpetual error messages upon loading DoC. Something is being left out.

Moderator Action: Merged into the appropriate thread.
 
I've figured out why I'm getting python errors- it was because of the changes that NKN made. It must have been leaving something out.

My guess is there's a problem with the whitespace, which Python is very picky about. Make sure that all of the neighboring lines have the same number of spaces and/or tabs at the beginning.
 
So I should probably post this. If you wish to change the opening music, go to CivilizationIV/Beyond the Sword/Assets/Sounds/Soundtrack and replace the OpeningMenuCiv4. For instance, I took the Beatles Within You Without You instrumental mp3, put it in that folder, and renamed it OpeningMenuCiv4 to overwrite the file.
 
My guess is there's a problem with the whitespace, which Python is very picky about. Make sure that all of the neighboring lines have the same number of spaces and/or tabs at the beginning.

I did, that's very obvious for me.
 
I would hit "Select All" followed by "Tabify Region" (choose 8 spaces or whatever) if you're using the Python editor. If you are using Notepad or whatever standard text editor, I would strongly advise you to download Python from python.org (it's free) and Tabify everything, because Notepad can really screw up the indentation, which is crucial in Python.

The other possible issue is that you might have missed one little character when copy-pasting over, which can cause huge problems. I would also advise copy-pasting NKN's code again over what you entered just to be safe. Again, copy-paste the entire line over, because one incorrect parenthesis or period can cause the entire thing to crash.
 
Leoreth, I would like to ask CFC's and the Moderator's Policy regarding the Musics in Mod. I'm currently making a Mod that includes supposedly copyrighted musics from Games/Movies/etc. So I would know whether that is fine or not, considering that you're both a Moderator and a Modder :D
 
This isn't really a question related to DoC modding, I've sent you a PM.
 
India with a Ravi Shankar soundtrack would be amazing.
 
Does the fact that 3000 BC, 600 AD, and 1700 AD give the error messages then say "You have been defeated" compared to the 500 AD crashing while loading mean anything? I would conclude that that means that the problem could be with the 500 AD scenario, not with Venice.
 
Does the fact that 3000 BC, 600 AD, and 1700 AD give the error messages then say "You have been defeated" compared to the 500 AD crashing while loading mean anything? I would conclude that that means that the problem could be with the 500 AD scenario, not with Venice.
Do you have Python exceptions enabled?
 
Yes, I do, and you saw the Python exceptions for 3000 BC.
 
Sorry, where?
 
attachment.php
 
Can you upload your version of Config/init.xml?
 
Spoiler :
Code:
[CONFIG]

; Modular XML Loading
ModularLoading = 0

; Skip Main menu
SkipMainMenu = 0

; Custom Art from user folder is not loaded
NoCustomArt = 0

; Custom XML and Python from user folder are not loaded
NoCustomAssets = 0

; No Custom Scenario option in main menu
NoCustomScenario = 1

; No team play allowed
NoTeams = 0

; Read Game options from XML, not .ini
ForceGameOptions = 0

; Always start in the standard era
ForceStandardEra = 0

; Scenario file (Single player)
ForceScenario = 0

; This mod is only for single player games
SinglePlayerOnly = 1

; Allow public maps to be used with this mod
AllowPublicMaps = 1

; Mod Image file
ImageFile = 0

; Name of Mod
Name = RFC Dawn of Alternate History

; Description of Mod
Description = Generic Mod
 
I meant Assets/Config/init.xml.
 
Spoiler :
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
	Main BUG Mod Initialization

	This file initializes the BUG Core and all mods.

	Copyright (c) 2008 The BUG Mod.
-->
<bug>
	
	<!-- BUG Core -->
	
	<load mod="BUG Config"/>
	<load mod="BUG Core"/>
	
	
	<!-- Civilization Core -->
	
	<!-- Domestic and Military Advisors and Civilopedia are chosen by options -->
	<init module="CvScreensInterface"/>
	
	
	<!-- Utility Modules -->
	
	<init module="FontUtil" immediate="True"/>
	<symbol id="war" from="COMMERCE_GOLD" offset="25"/>
	<symbol id="peace"/>
	<symbol id="space"/>  <!-- blank symbol the same size as other standard symbols -->
	<symbol id="militaryinstructor" name="MILITARY_INSTRUCTOR"/>
	<symbol id="land" name="DOMAIN_LAND"/>
	<symbol id="sea" name="DOMAIN_SEA"/>
	<symbol id="air" name="DOMAIN_AIR"/>
	<symbol id="sentry" name="ORDER_SENTRY"/>
	<symbol id="fortify" name="ORDER_FORTIFY"/>
	<symbol id="wait" name="ORDER_WAIT"/>
	<symbol id="upgrade"/>
	<symbol id="cancel"/>
	<symbol id="ss casing" from="HAPPY" offset="-25"/>
	<symbol id="ss cockpit"/>
	<symbol id="ss docking bay"/>
	<symbol id="ss engine"/>
	<symbol id="ss life support"/>
	<symbol id="ss stasis chamber"/>
	<symbol id="ss thruster"/>
	<symbol id="citizen" from="POWER" offset="1"/>
	<symbol id="greatgeneral" name="GREAT_GENERAL"/>
	
	<init module="AttitudeUtil">
		<!-- Furious, Annoyed, Cautious, Pleased, Friendly -->
		<arg name="colors" type="tuple">
			"COLOR_RED", 
			"COLOR_CYAN", 
			"COLOR_CLEAR", 
			"COLOR_GREEN", 
			"COLOR_YELLOW"
		</arg>
		<!-- Non-memory attitude modifier keys -->
		<arg name="modifiers" type="tuple">
			"TXT_KEY_MISC_ATTITUDE_LAND_TARGET",
			"TXT_KEY_MISC_ATTITUDE_WAR",
			"TXT_KEY_MISC_ATTITUDE_PEACE",
			"TXT_KEY_MISC_ATTITUDE_SAME_RELIGION",
			"TXT_KEY_MISC_ATTITUDE_DIFFERENT_RELIGION",
			"TXT_KEY_MISC_ATTITUDE_BONUS_TRADE",
			"TXT_KEY_MISC_ATTITUDE_OPEN_BORDERS",
			"TXT_KEY_MISC_ATTITUDE_DEFENSIVE_PACT",
			"TXT_KEY_MISC_ATTITUDE_RIVAL_DEFENSIVE_PACT",
			"TXT_KEY_MISC_ATTITUDE_RIVAL_VASSAL",
			"TXT_KEY_MISC_ATTITUDE_SHARE_WAR",
			"TXT_KEY_MISC_ATTITUDE_FAVORITE_CIVIC",
			"TXT_KEY_MISC_ATTITUDE_TRADE",
			"TXT_KEY_MISC_ATTITUDE_RIVAL_TRADE",
			"TXT_KEY_MISC_ATTITUDE_FREEDOM",
			"TXT_KEY_MISC_ATTITUDE_EXTRA_GOOD",
			"TXT_KEY_MISC_ATTITUDE_EXTRA_BAD"
		</arg>
	</init>
	<event type="LanguageChanged" module="AttitudeUtil" function="initModifiers"/>
	<symbol id="furious" name="ATTITUDE_FURIOUS" from="POWER" offset="4"/>
	<symbol id="annoyed" name="ATTITUDE_ANNOYED"/>
	<symbol id="cautious" name="ATTITUDE_CAUTIOUS"/>
	<symbol id="pleased" name="ATTITUDE_PLEASED"/>
	<symbol id="friendly" name="ATTITUDE_FRIENDLY"/>
	
	<init module="ColorUtil">
		<!--
			You can safely modify this list to change the color dropdown menus
			for color options. You can change the text displayed in the menus by
			adding translations for your new colors to Colors_CIV4GameText.xml
			in the XML/Text directory. 
		-->
		<arg name="colors" type="tuple">
			"COLOR_RED",
			"COLOR_YELLOW",
			"COLOR_CYAN",
			"COLOR_GREEN",
			"COLOR_BLUE",
			"COLOR_MAGENTA",
			"COLOR_WHITE",
			"COLOR_LIGHT_GREY",
			"COLOR_GREY",
			"COLOR_DARK_GREY",
			"COLOR_BLACK"
		</arg>
	</init>
	<event type="LanguageChanged" module="ColorUtil" function="createColors"/>
	
	<events module="DealUtil" function="addEvents"/>
	<events module="DiplomacyUtil" function="addEvents"/>
	<extend how="after" module="DiplomacyUtil" function="handleAIComment" to="CvDiplomacyInterface" as="beginDiplomacy"/>
	<extend how="after" module="DiplomacyUtil" function="handleUserResponse" to="CvDiplomacyInterface" as="handleUserResponse"/>
	
	<init module="GGUtil"/>
	<init module="GPUtil"/>
	<init module="ReligionUtil"/>
	<init module="TechUtil"/>
	<init module="TradeUtil"/>
	<init module="TraitUtil"/>
	<init module="UnitUtil"/>
    <gameutils module="WidgetUtil" handler="getWidgetHelp"/>
    
	<event type="OnLoad" module="CvTechChooser" function="resetTechPrefs"/>
	<event type="GameStart" module="CvTechChooser" function="resetTechPrefs"/>
	
	
	<!-- Mods -->
	
	<load mod="BUG Main Interface"/>
	<load mod="BUG City Screen"/>
	<load mod="BUG Advisors"/>
	
	<load mod="Customizable Domestic Advisor"/>
	<load mod="Better Espionage"/>
	<load mod="All Eras Dawn of Man Screen"/>
	<load mod="TechWindow"/>
	
	<load mod="Not Just Another Game Clock"/>
	<load mod="Advanced Scoreboard"/>
	<load mod="Plot List Enhancements"/>
	
	<load mod="Autolog"/>
	<load mod="Reminder"/>  <!-- requires Autolog -->
	<load mod="Civ4lerts"/>
	<load mod="MoreCiv4lerts"/>
	<load mod="Unit Naming"/>
	<load mod="FavoriteCivicDetector"/>
	<load mod="EventSigns"/>
	<load mod="Strategy Overlay"/>
	<load mod="StatusDump"/>
	
	<!-- BULL -->
	
	<load mod="BULL Core"/>
	<load mod="BULL Actions"/>
	<load mod="BULL City Bar"/>
	<load mod="BULL Misc Hovers"/>
	
	<load mod="AutoSave"/>
	<load mod="MapFinder"/>
	<load mod="Advanced Combat Odds"/>
	
	<!-- BUFFY -->
	
	<load mod="BUFFY"/>
	
	
	<!-- Options Screen -->
	
	<screen id="BUGFull">
		<tab module="BugGeneralOptionsTab"/>
		<tab module="BugMapOptionsTab"/>
		<tab module="BugCityScreenOptionsTab"/>
		
		<tab module="BugAdvisorOptionsTab"/>
		
		<tab module="BugAlertsOptionsTab"/>
		<tab module="BugScoreOptionsTab"/>
		<tab module="BugNJAGCOptionsTab"/>
		
		<tab module="BugPleOptionsTab"/>
		<tab module="BugACOOptionsTab"/>
		<tab module="BugUnitNameOptionsTab"/>
		
		<tab module="BugAutologOptionsTab"/>
		
		<tab module="BugSystemOptionsTab"/>
		<tab module="BugCreditsOptionsTab"/>
	</screen>
</bug>
 
Okay, no, that matches my version of the file.

What does your PythonErr.log say, if logging is enabled?
 
Back
Top Bottom