Quick Modding Questions Thread

Once you have the unit in Blender, you can attach the unit's mesh to a Civ4 animation via Bone Weight Copy. Then most probably you will have to do a nifswap (information about that here) and reassign the textures with NifSkope.

Buildings should be easier, since they normally do not have any animation.
 
Hello, this is an unrelated question, but I think it's in the right place.
Does anyone know if it is possible to use Civ 5 unit or building art in Civ 4? I know that there are tutorials to import civ 4 models into a civ 5 mod, but I am wondering if the inverse is possible.
Thanks

I ask similar question, and i get this answer:
LOL, I have never heard of a request to downgrade a unit from Civ V to Civ IV before! I don't even know if I could get it to work, actually. To be honest, I only spend time converting units to Civ V because there are so few fantasy mods for Civ V and it has been out for 4 years already! I love all of the wonderful Civ IV mods and still play them, but I am trying to get that same potential into Civ V. The more I convert, the more incentive for modders to create more mods

I know 5 good active members, Nomad or What, Civitar, clanky4, SaibotLieh, ramzay1945
 
trying to get unit to rangestrike when move command is used (instead of suicide siege attack)
so instead of just a "false" I tried this:
PHP:
	if (bAttack)
	{
		if ((getDomainType() == DOMAIN_LAND) && (canRangeStrike()))
		{
			CvUnit* pDefender = pPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, true);
			rangeStrike(pDefender->getX_INLINE(), pDefender->getY_INLINE());
			return false;
		}
	}

but got this when compiling:
1>CvUnit.cpp(2668) : error C2662: 'CvUnit::rangeStrike' : cannot convert 'this' pointer from 'const CvUnit' to 'CvUnit &'

ehm... not really sure what that even means ...
 
cannot convert 'this' pointer from 'const CvUnit' to 'CvUnit &'
Without being able to see the whole code, I think the problem is that you have a const this pointer. This mean you are in a function named CvUnit::something() const. Const mean none of the member data can be changed and it is only allowed to call const member functions. It looks like CvUnit::rangeStrike() is not const and can't be called from const functions.

Const is a good way to avoid bugs, but naturally it has to be used correctly. If your current code is in fact aimed at losing movement points, attack counters or whatever, then it should not be const.

EDIT:

rangeStrike() written on its own is actually not what the compiler handles. It assumes this, meaning the line becomes
PHP:
this->rangeStrike(pDefender->getX_INLINE(), pDefender->getY_INLINE());
I can see how that can be confusing when this is written in the error message, but not in the code.

Also I'm not 100% sure because the error message isn't good and I only have a fraction of the code to look at. I'm making the best guess I can given what I do have.
 
Without being able to see the whole code, I think the problem is that you have a const this pointer. This mean you are in a function named CvUnit::something() const. Const mean none of the member data can be changed and it is only allowed to call const member functions. It looks like CvUnit::rangeStrike() is not const and can't be called from const functions.

Const is a good way to avoid bugs, but naturally it has to be used correctly. If your current code is in fact aimed at losing movement points, attack counters or whatever, then it should not be const.

EDIT:

rangeStrike() written on its own is actually not what the compiler handles. It assumes this, meaning the line becomes
PHP:
this->rangeStrike(pDefender->getX_INLINE(), pDefender->getY_INLINE());
I can see how that can be confusing when this is written in the error message, but not in the code.

Also I'm not 100% sure because the error message isn't good and I only have a fraction of the code to look at. I'm making the best guess I can given what I do have.
The above code is put into bool CvUnit::canMoveInto (which havent been changed from vanilla otherwise) right after the code below.
PHP:
	if (bAttack)
	{
		if (isMadeAttack() && !isBlitz())
		{
			return false;
		}
	}
Usually it would result in a direct attack, but since I wanted land rangestrikers not be able to do normal attacks I blocked it with
Code:
	if (bAttack)
	{
		if ((getDomainType() == DOMAIN_LAND) && (canRangeStrike()))
		{
			return false;
		}
	}
which works as intended. The unit can still rangestrike using the button, and cant move (or attack) into the plot with an enemy on it.
I wanted to expand it a bit to make it easier for rangestrike when range was 1, so a move into the plot would result in rangestrike. Even though I changed quite a bit on the rangestrike code, this part should work on vanilla as well.

edit : its not that important though. BTW I uploaded a new version of the Rangestrike in case someone wants to take a look on how to put Combat Focus on it
http://forums.civfanatics.com/downloads.php?do=file&id=24544
 
I have one problem and i really don't know how to fix it, my mod sometimes crash.
Crash occur when i during playing open menu in which i can choose Exit to Desktop, Exit to Main Menu and etc, and crash only occur (sometimes, not always), at the moment when i click Exit to Main Menu (in Debug and in Release .dll).
I don't know why ? Maybe something in Python or in SDK or something in Units graphics causes the crash or my just my PC causes the crash. Lots of people are downloaded my mod, and no one report me this crash (if they get this crash at all).
 
Crash occur when i during playing open menu in which i can choose Exit to Desktop, Exit to Main Menu and etc, and crash only occur (sometimes, not always), at the moment when i click Exit to Main Menu (in Debug and in Release .dll).
I have the same issue and are clueless to what happens. I managed to get it to crash with the debugger attached, but that didn't help me much as the crash happens in the exe. My guess is that it is trying to free memory, which has already been freed. I think the only way to figure out what actually goes on is to read the assembler code in the lines around the crashing line in the exe. My guess is that we will just have to accept this crash. It's not critical though as it only happens while the game shuts down, not during gameplay. No savegames or other data is lost in the crash.
 
I have the same issue and are clueless to what happens. I managed to get it to crash with the debugger attached, but that didn't help me much as the crash happens in the exe. My guess is that it is trying to free memory, which has already been freed. I think the only way to figure out what actually goes on is to read the assembler code in the lines around the crashing line in the exe. My guess is that we will just have to accept this crash. It's not critical though as it only happens while the game shuts down, not during gameplay. No savegames or other data is lost in the crash.

I test my uploaded RECONSTRUCTION version and there is no crash, all works perfect, but in this new version which i am making i get this crash.

I think that problem is in SDK. In one test merging, i was merged Reconstruction source code + capture city art style SDK mod component and i was get same problem like here.
Maybe is Visual Studio wrong installed. Maybe to reinstall them, i really don't know, i have qt add-on for C++ in VS.

Complete list what i do in this new version, and what of that can cause bug:
- I add new CIVIC_OPTION and add 3 new CIVICs
- I write some my code in CvGameUtilsReconstruction.py (total same as CvGameUtils.py but i add my code here, and i haven't file CvGameUtils.py in my mod because i have BUG mod component, there is some steps which you must do if you want to use CvGameUtils.py or SomeYourCvGameUtils.py if you have BUG mod component, for more info see HERE).
- I set in PythonCallbackDefines.xml

Code:
	<Define>
		<DefineName>USE_CANNOT_DO_CIVIC_CALLBACK</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>

- i add several new units in mod and edit lots of texture and effects and make lots of new buttons for units you can see this HERE and all my textures are DXT3 for units and buttons and DXT5 for effects and all are .dds
- i changed position of technologies in my tech-tree, because all was scattered.
- i add new SDK, i merged Fear from FFH2 source code and add one new promotion which use FEAR.
- i add several new promotions, some of them are classic like +15 strength or +30attack on features or defence, and several medic promotions, and i add several python promotions.
- My mod is based on Legends of Revolution source code, i am nothing remove from source, i just add new mod components.
- I use LoR sdk ability to make some units obsolete and i set that on lots of units.
- i think that is all.
- What i will do? I will compile again RECONSTRUCTION source code from uploaded version, and remove this fear promotion and test all without this new SDK add on.
Next test will be, remove Fear promotion and just copy RELEASE .dll from uploaded RECONSTRUCTION, and i will see, if i get crash again problem in Visual Studio or in some non-SDK component.
I will post result here, my think that this crash is some our mistake in SDK.
 
@Nightinggale

I do 3 type of test and two fails and one success.

1) I don't touch SDK, i just remove from all XML files FEAR promotion, and of course that wasn't any positive result, fail.

2) I compile new .dll with my source files (not new version, i think on uploaded version). First i compile BTS, after i replace that files with my source files and compile again, after i copy my dll to my mod, i must say that long time the game doesn't crash. Several times i create new game and play and not play and every time when i click on Exit to Main Menu all works fine, and in one playing, i click on Exit to Main Menu and game crashed.

3) I copy dll from my uploaded version and play long and many times and game doesn't crash, i try everything to crash the game and i fail to do that.

I am confused now, especially on 2) and 3).
Maybe Visual Studio 2010 Ultimate is wrong installed. I really don't know.
All .dll are compiled with same Visual Studio on same PC, this really confuse.
 
Due to how rare and seemingly random the crashes are for me, my guess is that there is a real risk that "no crash" might as well be "managed to avoid the crash each time".

I guess is that there is code like this:
PHP:
class myClass {int* myPointer;};

myClass A;
myClass B = A;
If the constructor allocates memory and the deconstructor frees it, then it will be a problem if the code is written like this. A will allocate memory and let myPointer points to it. Once A goes out of scope, it will free the memory pointed to by myPointer.
B will not allocate. Instead it will copy the content of A, meaning it will get myPointer to point to the same address. Once B goes out of scope, it will free the memory.

Say A goes out of scope and then B goes out of scope, then A will free the memory. However B points to the same memory and tries to free it, which will cause a crash. It is possible that the dll forwards a pointer to the exe and something like this happens, but since it takes place in the exe and not in the dll where the mistake takes place, then tracking it down will be problematic.

The version of MSVC is not important. We use 2003 for compiling regardless of which one you install. Otherwise the exe and dll will not talk together.
 
Due to how rare and seemingly random the crashes are for me, my guess is that there is a real risk that "no crash" might as well be "managed to avoid the crash each time".

I guess is that there is code like this:
PHP:
class myClass {int* myPointer;};

myClass A;
myClass B = A;
If the constructor allocates memory and the deconstructor frees it, then it will be a problem if the code is written like this. A will allocate memory and let myPointer points to it. Once A goes out of scope, it will free the memory pointed to by myPointer.
B will not allocate. Instead it will copy the content of A, meaning it will get myPointer to point to the same address. Once B goes out of scope, it will free the memory.

Say A goes out of scope and then B goes out of scope, then A will free the memory. However B points to the same memory and tries to free it, which will cause a crash. It is possible that the dll forwards a pointer to the exe and something like this happens, but since it takes place in the exe and not in the dll where the mistake takes place, then tracking it down will be problematic.

The version of MSVC is not important. We use 2003 for compiling regardless of which one you install. Otherwise the exe and dll will not talk together.

I agree with you, but how to fix this? You said: " read the assembler code in the lines around the crashing line in the exe " I really don't know assembler, i know what is that and what he do, but...

Maybe to found someone who know to read that or find some software which can help to us or begin merging from begging and be very careful what and which code will be merged.
 
Question: when you zoom in on a city - you hear national music playing. where are these music files stored?
thank you!

Assets\Sounds\Diplomacy, depending on the leader either in Vanilla, Warlords or Beyond the Sword.
 
So I am having an issue with adding custom order and select sounds for Civ specific Units.

I have set it up in the same way as I had for a working set, but I get this error message when it tries to play them.

Illegal Index (-1) used in SoundIsDynamicRes() of FAudioManager

It also seems to crash the game as well... (Ok it looks like the minimap is causing the crash?!? what the hell is that about....)

Now as far as I can tell they are setup in exactly the same way as a working set of Select sounds, so I have no idea what the problem could be...

EDIT: Turns out the one that was working isn't working anymore either... though have not touched that one...

Any thoughts?
 
Hello,
I have a question related to unit importing. I followed the tutorials around here to get 3ds max 8 (took me forever to find an old version) to work, also added the Civ4 plugin this and the NIF plugin this. However there seems to be a problem while importing most units: String too long. Not a NIF file or unsupported format? (for example Bakuel`s new aztec jaguar warrior whom i wanted to edit, gives this error).
So my questions are:

1. Can this be fixed am i missing a newer plugin, or is there an extra step in importing a unit to 3ds Max?

2. Or what do people use nowadays to create/edit units? (and is there a tutorial to set it up, part about importing/exporting)
 
@Nightinggale
Previous:
Spoiler :
@Nightinggale

I do 3 type of test and two fails and one success.

1) I don't touch SDK, i just remove from all XML files FEAR promotion, and of course that wasn't any positive result, fail.

2) I compile new .dll with my source files (not new version, i think on uploaded version). First i compile BTS, after i replace that files with my source files and compile again, after i copy my dll to my mod, i must say that long time the game doesn't crash. Several times i create new game and play and not play and every time when i click on Exit to Main Menu all works fine, and in one playing, i click on Exit to Main Menu and game crashed.

3) I copy dll from my uploaded version and play long and many times and game doesn't crash, i try everything to crash the game and i fail to do that.

I am confused now, especially on 2) and 3).
Maybe Visual Studio 2010 Ultimate is wrong installed. I really don't know.
All .dll are compiled with same Visual Studio on same PC, this really confuse.

Due to how rare and seemingly random the crashes are for me, my guess is that there is a real risk that "no crash" might as well be "managed to avoid the crash each time".

I guess is that there is code like this:
PHP:
class myClass {int* myPointer;};

myClass A;
myClass B = A;
If the constructor allocates memory and the deconstructor frees it, then it will be a problem if the code is written like this. A will allocate memory and let myPointer points to it. Once A goes out of scope, it will free the memory pointed to by myPointer.
B will not allocate. Instead it will copy the content of A, meaning it will get myPointer to point to the same address. Once B goes out of scope, it will free the memory.

Say A goes out of scope and then B goes out of scope, then A will free the memory. However B points to the same memory and tries to free it, which will cause a crash. It is possible that the dll forwards a pointer to the exe and something like this happens, but since it takes place in the exe and not in the dll where the mistake takes place, then tracking it down will be problematic.

The version of MSVC is not important. We use 2003 for compiling regardless of which one you install. Otherwise the exe and dll will not talk together.

I agree with you, but how to fix this? You said: " read the assembler code in the lines around the crashing line in the exe " I really don't know assembler, i know what is that and what he do, but...

Maybe to found someone who know to read that or find some software which can help to us or begin merging from begging and be very careful what and which code will be merged.

I am now do two new tests and problem is not in .dll problem is in .EXE but i think that some from XML or Python or some configuration cause that crash.
My mod is based on LoR,
1) I was copied my new compiled in LoR and i was played LoR without any crash.
2) I was copied original LoR .dll in my mod and when i was clicked on Exit to Main Menu, i was get crash (CTD).
Now questions:
What can make this problem ?
Where i can found something which will check entire mod (XML, art, python) ?
Which is max limit of units, buildings, projects, promotions, civilizations, leaders in CIV4BTS ?
 
I don't believe so as that would apply to the container rather than the text itself.

The only ones I know are defined in CvDllTranslator.cpp with a few more in CvDefines.h
 
Back
Top Bottom