Modmodding Q&A Thread

SoI modding question:
Can someone please add these three Portuguese UHV goals to the Victory.py file attached below

UHV 1:
Control all coastal cities on the Indian Ocean, Red Sea, and Persian Gulf in 1590
UHV 2:
Have at least 8,000 Gold in 1620
UHV 3:
Control at least 28 unique resources in 1650

I spent 3 hours trying to do it myself last night, but I broke the game, so I had to copy the Victory.py from SoI and make the minor changes that I am able to do (Byzantines require 15 provinces instead of 8, Seljuks require 9% of map instead of 10%, and Timurids require 11% of map instead of 12%.) I could do those because I just had to replace a few numbers, but the portuguese goals are way over my head, as I know virtually nothing about computer programming.

I am a musician, so If someone does this for me, I will make a 3 minute song in any style for your mod.
 

Attachments

My approach to this thread is that I will help you do stuff, but you still have to do it yourself.

Maybe you can find someone else.
 
Try looking for similar UHVs in other RFC modmods. There are plenty of gold UHVs everywhere, and I'm pretty sure there are a few resource ones too (Carthage from RFCCW comes to mind).
 
Just copy/paste goals from other civs that are near-identical and edit them to fit your needs. That's what I've done.
 
Since it works through events, it's spread out over multiple files. What exactly do you want to change?

I was going to make a Vinland building for the Viking AI but decided to do it through barbs city spawn which works. However I'm trying to spawn barbarians to destroy the colonies but they never spawn as far as I can tell.
Spoiler :
#inuit
if (iGameTurn >= getTurnForYear(1100) and iGameTurn <= getTurnForYear(1300)):
self.checkSpawn(iNative, con.iInuit, 2, (36, 54), (37, 53), self.spawnInvaders, iGameTurn, 20, 0, ["TXT_KEY_ADJECTIVE_INUIT"])
if (iGameTurn >= getTurnForYear(1300) and iGameTurn <= getTurnForYear(1500)):
self.checkSpawn(iNative, con.iInuit, 2, (38, 63), (42, 60), self.spawnInvaders, iGameTurn, 20, 0, ["TXT_KEY_ADJECTIVE_INUIT"])



I've added the TXT_KEY_ADJECTIVE_INUIT to the text files and added con.Inuit to the Constants file.
Do the barbarians spawn on a random tile between the rectangle formed by the coordinates?
What do the last two numbers before the TXT_KEY do?
 
The iPlayer = iGiftingPlayer.getID() part is yours, right?

Unless someone made a mistake in creating this event, iGiftingPlayer already is a player ID. So you can either use it directly, or just reassign it as iPlayer = iGiftingPlayer.

Generally variables starting with an i indicate that they're integers and therefore not objects that can have methods such as getID(). I don't know how familiar you are with object oriented programming.

Are you still doing this without enabled Python exceptions, by the way? You should have noticed that at least something went wrong in that line.

iPlayer = iGiftingPlayer.getID() is copied from def onCombatResult one.

I learned introductory level of python in two years ago but I forgot almost all of them. Is there any method that can check the classes of the variables?

I turned exceptions on, but it didn't give me any exception messages. It seems like the code worked in possible exceptional wrong way.
 
I was going to make a Vinland building for the Viking AI but decided to do it through barbs city spawn which works. However I'm trying to spawn barbarians to destroy the colonies but they never spawn as far as I can tell.
Spoiler :
#inuit
if (iGameTurn >= getTurnForYear(1100) and iGameTurn <= getTurnForYear(1300)):
self.checkSpawn(iNative, con.iInuit, 2, (36, 54), (37, 53), self.spawnInvaders, iGameTurn, 20, 0, ["TXT_KEY_ADJECTIVE_INUIT"])
if (iGameTurn >= getTurnForYear(1300) and iGameTurn <= getTurnForYear(1500)):
self.checkSpawn(iNative, con.iInuit, 2, (38, 63), (42, 60), self.spawnInvaders, iGameTurn, 20, 0, ["TXT_KEY_ADJECTIVE_INUIT"])



I've added the TXT_KEY_ADJECTIVE_INUIT to the text files and added con.Inuit to the Constants file.
Do the barbarians spawn on a random tile between the rectangle formed by the coordinates?
What do the last two numbers before the TXT_KEY do?
The second parameter refers to a unit - so unless you have added an actual Inuit unit to the game, adding a new constant in Consts.py will only mess up the constants for everything else.

Which tiles in the rectangle are eligible for spawns is controlled by the method passed as sixth parameter. Invaders spawns large forces in plots that are at least two tiles away from cities and free of units. spawnNatives is probably better for your purpose.

The first of the last two numbers is the turn interval between spawns (on normal speed). More accurately, if it is n, every a spawn occurs every nth turn. The second number is an offset, so not all spawns with the same periodicity occur on the same turn.

In other words, if the numbers are n and m, a spawn occures every turn where turn mod n = m.

iPlayer = iGiftingPlayer.getID() is copied from def onCombatResult one.
Oh, you are in the wrong event handler. I don't think that one is actually listening to events even (this is some legacy code from the BUG merge). You have to go to Python/CvRFCEventHandler.

I learned introductory level of python in two years ago but I forgot almost all of them. Is there any method that can check the classes of the variables?
Not that I know of. As I said, you can usually tell from the variable names which types to expect.

I turned exceptions on, but it didn't give me any exception messages. It seems like the code worked in possible exceptional wrong way.
Yep, the fact that you got no exception is because you were in the wrong event handler.
 
Yes, question train goes on.
Is there any method that prevents AI free colony settlers spawn in specific areas? Also, can I change AI settler map values when the game satisfies specific conditions?

Particularly about this idea.
Does this stop the British from settling Australia after your spawn? Not sure if the Dutch should also be stopped from doing so.
 
SoI modding question:
Can someone please add these three Portuguese UHV goals to the Victory.py file attached below

UHV 1:
Control all coastal cities on the Indian Ocean, Red Sea, and Persian Gulf in 1590
UHV 2:
Have at least 8,000 Gold in 1620
UHV 3:
Control at least 28 unique resources in 1650

I spent 3 hours trying to do it myself last night, but I broke the game, so I had to copy the Victory.py from SoI and make the minor changes that I am able to do (Byzantines require 15 provinces instead of 8, Seljuks require 9% of map instead of 10%, and Timurids require 11% of map instead of 12%.) I could do those because I just had to replace a few numbers, but the portuguese goals are way over my head, as I know virtually nothing about computer programming.

I am a musician, so If someone does this for me, I will make a 3 minute song in any style for your mod.

Try looking for similar UHVs in other RFC modmods. There are plenty of gold UHVs everywhere, and I'm pretty sure there are a few resource ones too (Carthage from RFCCW comes to mind).

Just copy/paste goals from other civs that are near-identical and edit them to fit your needs. That's what I've done.

there are also examples for counting coastal cities in Oman's goals from SoI and Egypt's goals in RFCCW.

don't forget to have python exceptions enabled.

part of my learning method was to open all the python files in the mod (or all the mods actually) so I can search all of them at once (using notepad++). then you can find all examples of "gold" or "coastal" or whatever you're trying to code.

and you should post what you tried, you may have been much closer than you thought.
 
Yes, question train goes on.
Is there any method that prevents AI free colony settlers spawn in specific areas? Also, can I change AI settler map values when the game satisfies specific conditions?

Particularly about this idea.

There are no free settler spawns in specific areas.

The settler maps themselves are constants as well. On some occasions settlement is forbidden in specific areas under certain conditions. One case would be the HRE and Poland, maybe you search for that?

there are also examples for counting coastal cities in Oman's goals from SoI and Egypt's goals in RFCCW.

don't forget to have python exceptions enabled.

part of my learning method was to open all the python files in the mod (or all the mods actually) so I can search all of them at once (using notepad++). then you can find all examples of "gold" or "coastal" or whatever you're trying to code.

and you should post what you tried, you may have been much closer than you thought.

You don't have to have a file open to be able to search it in Notepad++, you can search entire folders with it.
 
You might be referring to two things:
1) The Trading Company event can spawn settlers, but only in their target regions, which Australia isn't.
2) Most European civilizations receive free settlers, but they appear in their capital and have to be shipped to the target location.
 
Depends on the file type and maybe the type of change. The Tortoise client is too generous with merges on update in my opinion, so what you get is that it tries to merge where it can.

The merge means that the changes in the update will usually override what's there, even if you changed it. The other outcome (which will always happen for non-text files) is a version conflict. In that case a yellow warning sign appears next to the affected file/folder and you have to resolve the conflict yourself by choosing whether to use the new or the old revision (or merge particular lines depending on what you want to keep).
 
Is there a way I can add a popup-like screen in the civilopedia, when you click a button on the info page? I'm trying to add the stability maps to the civilopedia.

Screenshot 1 shows the button. When you click on it, another screen (like in screenshot 2) should popup. But I don't get that to work. (I forced the popupscreen to show in screenshot 2)

I tried the same method used for python actions. (Like the Byzantium UP is done) But it seems this method can't be used in the civilopedia.

Any ideas what method I can use?

Here is the code:
Spoiler :
Code:
	def placeStabilityMapButton(self):
		screen = self.top.getScreen()
		screen.addPanel(self.top.getNextWidgetName(), "", "", False, False, self.X_ICON + self.W_ICON/4 - 10, self.Y_ICON + 200 - 10, self.W_ICON/2 + 20, self.H_ICON/2 + 20, PanelStyles.PANEL_STYLE_MAIN)
		screen.setImageButton(self.top.getNextWidgetName(), "Art/Stab.dds", self.X_ICON + self.W_ICON/4, self.Y_ICON + 200, self.W_ICON/2, self.H_ICON/2, WidgetTypes.WIDGET_GENERAL, 10002, 10002)
		
	def placeStabilityMap(self):
		screen = self.top.getScreen()
		screen.addPanel(self.top.getNextWidgetName(), "", "", False, False, self.X_ICON - 100 - 5, self.Y_ICON - 100 - 5, 620 + 40, 340 + 40, PanelStyles.PANEL_STYLE_MAIN)
		screen.addDDSGFC(self.top.getNextWidgetName(), "Art/America.dds", self.X_ICON - 100 + 15, self.Y_ICON - 100 + 15, 620, 340, WidgetTypes.WIDGET_GENERAL, 10002, 10002)
				

	def handleInput (self, inputClass):
		if inputClass.getNotifyCode() == 11 and inputClass.getData1() == 10002:
			self.placeStabilityMap()
		return 0
 
I'm bad at interface stuff, so I can't really be helpful. I'd have to start from scratch as well. Maybe you make a new map category to the right side of the menu, where you can select the civilization to show the map? It's not as nice as pressing a button, but maybe you can add a hyperlink to it on the civilization screen instead.

I really like what you're doing there, though.
 
I experimented with that as well a little. I got to the point where I got a list of all the civs. But when you click on those, the page you should get to doesn't open

I will continue and hope I find a solution.
 
Back
Top Bottom