Random Invisibility Mod

I think you should consider expanding this mod a little by including promotions, that make it more likely for units to spot subs. Would you be interested in that? :) Or would I need to do the hard work myself? :D

I had thought of doing that, but didn't get around to it. I was just making changes necessary to make it work with BetterBTSAI 1.01.
 
Oh, sorry, I forgot about this one. I don't have the mod as stand-alone, it's a part of my Merged Mod. But the code for this mod is actually very small, and the Civilopedia fix is also pretty tiny. You should be able to grab the code you need from the first post, and then fix the pedia the way I described above.

I'll have to try that civilopedia fix.
 
This works:

Code:
if (GC.getUnitInfo(eUnit).getNumSeeInvisibleTypes() > 0)
	{
	szBuffer.append(NEWLINE);
	szBuffer.append(gDLL->getText("TXT_KEY_UNIT_SEE_INVISIBLE", GC.getInvisibleInfo((InvisibleTypes) GC.getUnitInfo(eUnit).getSeeInvisibleType(iI)).getTextKeyWide()));
	}


Comment out the section four posts above this one, and put this section instead.

Nice job. This seems to work.
 
This works:

Comment out the section four posts above this one, and put this section instead.

I tested your fix. While it does eliminate the multiple entries in the civilopedia, it appears to break the world builder. Nothing shows up under the player mode of the World Builder. I attach a picture to illustrate.
 

Attachments

  • Broken WorldBuilder.png
    Broken WorldBuilder.png
    366.7 KB · Views: 89
Hmmm... That seems to solve the problem.

o_O it should not solve anything, only show the exception.
Sure you didn't do something else?

Should there be an error entry in one of the logs?

If you enabled logging before, then yes.
 
If you enabled logging before, then yes.

Alright, here is the error message:

Traceback (most recent call last):

File "CvScreensInterface", line 518, in showWorldBuilderScreen

File "CvWorldBuilderScreen", line 122, in interfaceSCreen

File "CvWorldBuilderScreen", line 2367, in refreshPlayerTabCtrl

RuntimeError: unidentifiable C++ exception
 
...er...:sad:...that doesn't say anything.

I've seen this error as side effect when other errors happend.
You might want to go now through your civilopedia, checking every unit entry, if an exception occurs. Maybe you'll find something there.
 
You might want to go now through your civilopedia, checking every unit entry, if an exception occurs. Maybe you'll find something there.

Yeah, clicking on any unit brings up this one:

Code:
Traceback (most recent call last):

File "CvScreensInterface", line 410, in pediaJumpToUnit

File "SevoPediaMain", line 256, in pediaJump

File "SevoPediaMain", line 305, in showContents

File "SevoPediaMain", line 446, in placeUnits

File "SevoPediaMain", line 727, in placeItems

RuntimeError: unidentifiable C++ exception
 
As usual, I have no clue why this doesn't work for you! :D I swear, I do not have this issue in my own version of this, and it's the exact change I've written in this thread. I have players using my mod that have werd issues with the civilopedia after I've made this change, but it doesn't affect me (anymore). There used to be an intermittent bug, that would only appear *sometimes*, and restarting the game made it go away. The workaround - I've had to remove the subspotting ability from the Airship, but after I did this all issues went away. I cannot figure out why, I only know it works on my machine. I can't fix what isn't broken! :) This workaround is of course included in the download that my users currently play, but some still have difficulties, similar to what NP300 is having.

EDIT: I just tried giving the Airship subspotting back. This brings back the same problems, and the python exceptions I get are similar to yours. Go figure! :(
 
Some things are just strange. I guess the .exe messes some things up here.

e.g. recently, i made a promotion in my mod, which can only be acquired via a building. So i made a circular prerequisite, so the promotion needed itself as a prereq.
This led to the strange thing, that i first got an exception and then the game crashed, when i opened a civilopedia entry of a unit, which was able to get the promotion and had the ability to intercept.
I haven't really figured out why this is a problem, but removing the circular prereq fixed it.
-> some things are just strange and we have no idea why.
 
As usual, I have no clue why this doesn't work for you! :D I swear, I do not have this issue in my own version of this, and it's the exact change I've written in this thread.

I have come up with what I think is a better solution. I'll post that later after I double check. For now, I think I have found a number of problems with your solution.

Your solution, if I understood correctly, is to comment out this:

Code:
	for (iI = 0; iI < GC.getUnitInfo(eUnit).getNumSeeInvisibleTypes(); ++iI)
	{
		if (bCivilopediaText || (GC.getUnitInfo(eUnit).getSeeInvisibleType(iI) != GC.getUnitInfo(eUnit).getInvisibleType()))
		{
			szBuffer.append(NEWLINE);
			szBuffer.append(gDLL->getText("TXT_KEY_UNIT_SEE_INVISIBLE", GC.getInvisibleInfo((InvisibleTypes) GC.getUnitInfo(eUnit).getSeeInvisibleType(iI)).getTextKeyWide()));
		}
	}

And put this instead:

Code:
if (GC.getUnitInfo(eUnit).getNumSeeInvisibleTypes() > 0)
	{
	szBuffer.append(NEWLINE);
	szBuffer.append(gDLL->getText("TXT_KEY_UNIT_SEE_INVISIBLE", GC.getInvisibleInfo((InvisibleTypes) GC.getUnitInfo(eUnit).getSeeInvisibleType(iI)).getTextKeyWide()));
	}

Now notice that the original code does a loop where it iterates through each See_Invisible type (variable iI). You have removed the "for loop" syntax, and removed the initial assignment of a zero value to variable iI. So you removed the loop but you continue to use iI without defining it. So most likely iI starts out using the last value it had in the lines of code well before these in the CvGameTextMgr.cpp file.

You have commented out the following check:

Code:
if (bCivilopediaText || (GC.getUnitInfo(eUnit).getSeeInvisibleType(iI) != GC.getUnitInfo(eUnit).getInvisibleType()))

And instead you just check to see if there is more than one value in the See_Invisible array. So the checks above are no longer being performed. This may be what is causing the problems.

Now, since you got rid of the loop syntax, your code only displays the very first See_Invisible value. If this is what you want to do there is probably an easier way to do it. I would propose replacing the initial chunk of code with this:

Code:
		if (bCivilopediaText || (GC.getUnitInfo(eUnit).getSeeInvisibleType(iI) != GC.getUnitInfo(eUnit).getInvisibleType()))
		{
			szBuffer.append(NEWLINE);
			szBuffer.append(gDLL->getText("TXT_KEY_UNIT_SEE_INVISIBLE", GC.getInvisibleInfo((InvisibleTypes) GC.getUnitInfo(eUnit).getSeeInvisibleType(0)).getTextKeyWide()));
		}

That will only display the very first See_Invisible value, and gets rid of the loop structure. Notice how the iI variable is simply replaced with the number zero—the first index number for the See_Invisible array.

I have a solution that I think is a bit more flexible, but I'll post that when I'm done with testing.
 
I think it's great that you're looking into this! :) I find it exceptionally hard to root out these problems, since I have no programming education or training, I'm really just fumbling in the dark. :D
 
I think it's great that you're looking into this! :) I find it exceptionally hard to root out these problems, since I have no programming education or training, I'm really just fumbling in the dark. :D

We are not that different. I have taken some programming classes but not that much. All along I just needed someone to point me to where the civilopedia code was. Now that you have done that I know where to look. There are so many files in the SDK I don't know where to start looking. I developed the random invisilibility mod after another mod showed me where the invisibility code was, and so I knew where to look. For the SDK modding I have done with Civ, I have done it by fumbling around in the dark (after being pointed to the right place by examples and mods) until I figured out a way to make it work. It took me many tries until I got the random invisibility mod to work.
 
"Search in files" functions are your friend. In this case, I searched for "Can see", because that it what the text help says in-game. I found the string TXT_KEY_UNIT_SEE_INVISIBLE in CIV4GameTextInfos.xml, and searching for TXT_KEY_UNIT_SEE_INVISIBLE in all the cpp-files turns up only two lines in CvGameTextMgr.cpp. :)
 
I'm adding your mod to my mod. I guess I don't have e-mail enabled on this site, for I haven't posted much :).
I hope to have my mod up in a few days.

Just saw a new version of your mod. I have .2, not .3, in my mod. Please forgive me. Vo.3 will be in my next version of my mod.
 
I'm adding your mod to my mod. I guess I don't have e-mail enabled on this site, for I haven't posted much :).
I hope to have my mod up in a few days.

Just saw a new version of your mod. I have .2, not .3, in my mod. Please forgive me. Vo.3 will be in my next version of my mod.

I have a new version coming up that fixes the civilopedia issue and also displays the probability of seeing the invisible unit in the civilopedia. Thought you might want to know...
 
Back
Top Bottom