Quick Modding Questions Thread

Cvgameutils.
Disable all the unwanted civics with big chunks of if else
 
Cvgameutils.
Disable all the unwanted civics with big chunks of if else
All I found with civics was
Code:
	def canDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False

	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False
If I change it to
Code:
[COLOR="Red"]#[/COLOR]	def canDoCivic(self,argsList):
[COLOR="Red"]#[/COLOR]		ePlayer = argsList[0]
[COLOR="Red"]#[/COLOR]		eCivic = argsList[1]
[COLOR="Red"]#[/COLOR]		return False

[COLOR="Red"]#[/COLOR]	def cannotDoCivic(self,argsList):
[COLOR="Red"]#[/COLOR]		ePlayer = argsList[0]
[COLOR="Red"]#[/COLOR]		eCivic = argsList[1]
[COLOR="Red"]#[/COLOR]		return False
Would that work ? i.e. not run that function.
 
All I found with civics was
Code:
	def canDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False

	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False
If I change it to
Code:
[COLOR="Red"]#[/COLOR]	def canDoCivic(self,argsList):
[COLOR="Red"]#[/COLOR]		ePlayer = argsList[0]
[COLOR="Red"]#[/COLOR]		eCivic = argsList[1]
[COLOR="Red"]#[/COLOR]		return False

[COLOR="Red"]#[/COLOR]	def cannotDoCivic(self,argsList):
[COLOR="Red"]#[/COLOR]		ePlayer = argsList[0]
[COLOR="Red"]#[/COLOR]		eCivic = argsList[1]
[COLOR="Red"]#[/COLOR]		return False
Would that work ? i.e. not run that function.

No.

You need to put some code in cannotDoCivic to make it so they cannot use them. If you want to block everybody from ever changing any civic, try just changing the "return False" to "return True". That might work, or that might have some weird effect since it means they technically can't do their starting civics either - but I don't know if it checks this for the starting civics. If this is a problem then you have to put code in there such that it does not block each civ from having its starting civics, just all the others.

Someone may already know if just setting it to return True will lock them into their starting civics, or if more work than that is needed.
 
I have set the starting civics in scenario, but I just don't want them to be able to change them to any others throughout the game. I'll try the "true" option and see what happens.
 
If it creates problems, the simple way is

If it is not your current civics:
Return True

However, I believe UN resolutions overwrite these and can still force players to switch civics.
 
Hello..Sorry if this is wrong thread..Please someone help :)

I want to change the value for

<MemoryType>MEMORY_DENIED_JOIN_WAR</MemoryType><iMemoryRand>100</iMemoryRand>

But there's like 50 of these values and its very hard to change this for each and every leader individually.. Is there an easier way to change all the values? Im using Wordpad. There are also other similar modifiers i want to change for all leaders..PLease help!!!!!

Thx.
 
How do you get the game to Auto-Play without losing your current nation?

I discovered the game.aiplay console command, but that kills your civ.
 
I've added this:


Code:
			if ((GET_PLAYER(getOwnerINLINE()).getUnitClassCount(eUnitClass)) >= ((pCity->getNumBonuses((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus())) * 9))
			{
				return false;
			}
to CvPlot::canTrain to limit some units to a number per resource eg 9 horsemen per horse.

it seems to ignore the "*9" and just limit the unit to 1 per resource. I've moved the brackets around to no avail.
 
I've added this:


Code:
			if ((GET_PLAYER(getOwnerINLINE()).getUnitClassCount(eUnitClass)) >= ((pCity->getNumBonuses((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus())) * 9))
			{
				return false;
			}
to CvPlot::canTrain to limit some units to a number per resource eg 9 horsemen per horse.

it seems to ignore the "*9" and just limit the unit to 1 per resource. I've moved the brackets around to no avail.

I have no idea but the bit of code "Bonuses((BonusTypes)GC.ge" does not look right to me. Shouldn't there be some operator between the ")" and the "GC."?
 
this line appears right next to what I've added:

Code:
if (!pCity->hasBonus((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus()))

that's my source for the syntax. the code seems to work except for the multiplying by 9 part. it does restrict unit building to 1 unit per resource
 
"(BonusTypes)" casts the value of GC.getUnitInfo(eUnit).getPrereqAndBonus() from int to BonusTypes, it's alright. I was curious and tried your code, it worked fine for me.

Here's what I inserted at the beginning of CvPlot::canTrain(); maybe you had a wrong definition of eUnitClass?
Code:
UnitClassTypes eUnitClass = (UnitClassTypes) GC.getUnitInfo( eUnit ).getUnitClassType();

if( GC.getUnitInfo(eUnit).getPrereqAndBonus() != NO_BONUS )
	if ((GET_PLAYER(getOwnerINLINE()).getUnitClassCount(eUnitClass)) >= ((pCity->getNumBonuses((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus())) * 9) )
		return false;

btw, is there a reason you use CvPlot::canTrain() rather than CvCity::canTrain()?
 
I just tried it again with code cut and pasted from your post and it still allows only 1 unit per resource controlled, rather than 9 as it is supposed to. do you mean it was allowing 9 units per resource when you tried it?

I put it in CvPlot because that's where the resources were already referenced. my C++ is totally hack so I try to have as much done for me already as possible.
 
How do you get the game to Auto-Play without losing your current nation?

I discovered the game.aiplay console command, but that kills your civ.

This mod is a pretty well-known and good mod, as far as I know. I don't know of any way besides this that you can do that.
 
I just tried it again with code cut and pasted from your post and it still allows only 1 unit per resource controlled, rather than 9 as it is supposed to. do you mean it was allowing 9 units per resource when you tried it?

I put it in CvPlot because that's where the resources were already referenced. my C++ is totally hack so I try to have as much done for me already as possible.

9 per resource worked for me, definitely. I changed Axeman to only require Copper like this: <BonusType>BONUS_COPPER</BonusType>.
I guess you working with RFC or SoI as a base? It may have changed some functions, though I cannot think of anything that would make sense to change in the functions used by the bit of code we have here.

Do you know how to debug? If you do, you could watch the values of getUnitClassCount(...) and getNumBonuses(...). Else, if you have the complete code uploaded somewhere, I could try to figure out the problem.
 
it's working now. embarrassingly enough it was a leftover python callback from an earlier attempt of the same mechanic that I forgot to turn off.

thanks for confirming the syntax, forcing me to realize it was something else.
 
I wish I had made a save. I was attacking two new custom ships in a game. One a transport steamer with 7 strength and the other a dreadnought with strength 22 and my Destroyers and/or Battleships were attacking the weaker Steamers first. I can't reproduce it. I know that empty transports defend before a transport carrying a unit but that wasn't the case here. I believe the Dreadnought was damaged but the Steamers were at full health but that can't be the reason can it? The Steamers can't pillage or blockade if that matters - but they can attack so they're not quite like Transports.
 
I'm kinda confused by a weird thing happening in a Mod/Scenario I'm making. I want the game to start in the year 1700 and a starting era of industrial. I've edited the worldbuilder file to try and achieve this. However when I start the scenario it starts in Summer 1887 on turn 750, which is not what I planned :crazyeye: In the spoiler is what I currently have in the WB file. I've looked through every tutorial I can find that I think will help and tried several things, alas to no avail, I've altered it several times to turn 0 but everytime it just reverts back to turn 750 on loading.

Spoiler :
BeginGame
Era=ERA_INDUSTRIAL
Speed=GAMESPEED_MARATHON
Calendar=CALENDAR_SEASONS
Option=GAMEOPTION_NO_VASSAL_STATES
Victory=VICTORY_TIME
Victory=VICTORY_CONQUEST
Victory=VICTORY_DOMINATION
Victory=VICTORY_CULTURAL
Victory=VICTORY_SPACE_RACE
Victory=VICTORY_DIPLOMATIC
GameTurn=750
MaxTurns=1200
MaxCityElimination=0
NumAdvancedStartPoints=14400
TargetScore=0
StartYear=1700
Description=
ModPath=
EndGame


Can anyone tell me what I am doing wrong and how to fix it? Thanks for reading :)
 
I wish I had made a save. I was attacking two new custom ships in a game. One a transport steamer with 7 strength and the other a dreadnought with strength 22 and my Destroyers and/or Battleships were attacking the weaker Steamers first. I can't reproduce it. I know that empty transports defend before a transport carrying a unit but that wasn't the case here. I believe the Dreadnought was damaged but the Steamers were at full health but that can't be the reason can it? The Steamers can't pillage or blockade if that matters - but they can attack so they're not quite like Transports.

It doesn't matter whether X can pillage, blockade, damaged or what.
Unless it has cargo inside, all that matters is who is the better defender against that particular attacker.

If a Knight is attacking, naturally a Pikeman will defend, even though a Longbowman is usually better against other units.
However, if the Longbowman is Level 20 with tons of promotions, then it becomes the better defender.
Of course, if the Pikeman is half dead, then the Longbowman is better as well.

Thus, if your Dreadnought is already sinking... the Steamer may become the better defender.
 
It doesn't matter whether X can pillage, blockade, damaged or what.
Unless it has cargo inside, all that matters is who is the better defender against that particular attacker.

If a Knight is attacking, naturally a Pikeman will defend, even though a Longbowman is usually better against other units.
However, if the Longbowman is Level 20 with tons of promotions, then it becomes the better defender.
Of course, if the Pikeman is half dead, then the Longbowman is better as well.

Thus, if your Dreadnought is already sinking... the Steamer may become the better defender.

Yes I know those rules - I've got 1169 hours played! I've reproduced something here (not sure if it's the exact issue I saw the other night):

Notice how Alexander's Dreadnought is at 4.0 and the Steamers are at 7 but with my Destroyer selected the Dreadnought is still defending.

Spoiler :
ship1.jpg


When I switch to my Steamer, the enemy Steamer defends - as it should.

Spoiler :
ship2.jpg


I don't think I've ever seen this before and am wondering if it has something to do with my new Steamer unit.
 
Back
Top Bottom