[PY MODCOMP] BarbarianCiv - Barbarian cities settle down into full civs

Portus said:
Hi jdog5000

Looking for your work, it reminds me an old dream
suppose we have 1 civ with lots of leaders, well 1 leader for each era.
its possible write a code to automaticly change the leader and respective traits in the beguining of each era.....or maybe an oppion to write a pach for the sucessive leaders...
Yes, it would certainly be possible to do this. Check out my Revolution modpack, follow my sig to find it. Changing leaders (and thus traits and personalities) is already working in the ChangePlayer part of that mod (defaults to disabled, requires SDK changes) ... so, you could write a Python script that would, at a certain year, change the leader of a particular civ following this model :)
 
This MOD looks very interesting... some quick questions.

A) Will the barbarians turned into civs be able to learn any type of technology and unit available within the game? (hopefully yes)

B) Are these new civs strong enough to defend existing cities from the AI opponents? (weak civs can be swallowed quickly by AI opponents)

C) Does this mod have any other changes/updates coming in the future or is what we see the final version of the mod?

D) Will this mod work for multiplayer games?
 
NT_Jedi said:
This MOD looks very interesting... some quick questions.

A) Will the barbarians turned into civs be able to learn any type of technology and unit available within the game? (hopefully yes)
Absolutely! They are full-fledged civs.

NT_Jedi said:
B) Are these new civs strong enough to defend existing cities from the AI opponents? (weak civs can be swallowed quickly by AI opponents)
Yes, they're given a bunch of defensive units and in some cases offensive units as well. In fact, if you're lagging behind on building up your defensives, you may find Ghengis Khan has organized the barbarians and is no rolling Keshiks all over your empire!

NT_Jedi said:
C) Does this mod have any other changes/updates coming in the future or is what we see the final version of the mod?
No major changes ... I'm quite happy with it as is, there will only be minor tweaks unless someone proposes a cool new idea ...

NT_Jedi said:
D) Will this mod work for multiplayer games?
I haven't tried it, but I can see no reason why it shouldn't ... let me know if you give it a shot! Just be warned, if you're using the Python only version that kills off AI civs at the start of the game, you need to have enough AIs or a high enough fraction to free up some slots for barb settling. Enjoy :)
 
jdog5000 said:
I haven't tried it, but I can see no reason why it shouldn't ... let me know if you give it a shot! Just be warned, if you're using the Python only version that kills off AI civs at the start of the game, you need to have enough AIs or a high enough fraction to free up some slots for barb settling. Enjoy :)

I was just taking a look at the code, trying to help someone debug some OOS problems they were having in their mod. I don't think this mod was the cause of it, but these pieces of code do look pretty fishy to me, and might cause problems...

Code:
eraMod = [b]gc.getActivePlayer().getCurrentEra()[/b] - game.getStartEra()/2.0
			if( eraMod < .5 ) :
				eraMod = .5

			popChance = int(mod*numCitiesMod*gsm*eraMod*1.5*(pop*pop))

Code:
# Put stuff in cities
for i,city in enumerate(cityList) :
	cityX = city.getX()
	cityY = city.getY()
	if( not iBestDefender == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iBestDefender,cityX,cityY,3)
	if( not iWorker == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iWorker,cityX,cityY,1)
	if( city.getPopulation() < 3 ) :
						city.setPopulation(3)
	if( city.getPopulation() < 6 ) :
						city.changePopulation( game.getSorenRandNum(7-city.getPopulation(),'BarbarianCiv: change city population') )
		if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - New population of %s is %d"%(city.getName(),city.getPopulation()))
	if( barbSettleType == 1 ) : # Military
		extraUnits = int( [b](gc.getActivePlayer().getCurrentEra()[/b]+1)/2.0 )
		if( len(closePlayers) == 0 ) : # Viking style, no horsies (but still allows elephants ... )
			if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,2+game.getSorenRandNum(5+[b]extraUnits[/b],'BarbarianCiv: give military infantry'))
			if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,2+game.getSorenRandNum(5+[b]extraUnits[/b],'BarbarianCiv: give military mobile'))
		else :
			if( not iCounter == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iCounter,cityX,cityY,1+game.getSorenRandNum(4+[b]extraUnits[/b],'BarbarianCiv: give military infantry'))
			if( not iMobile == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iMobile,cityX,cityY,1+game.getSorenRandNum(4+[b]extraUnits[/b],'BarbarianCiv: give military mobile'))
			if( not iAttack == UnitTypes.NO_UNIT ) : pyNewPlayer.initUnit(iAttack,cityX,cityY,1+game.getSorenRandNum(4+[b]extraUnits[/b],'BarbarianCiv: give military mobile'))
		if( city.canConstruct( iBarracks ) ) :
			if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iBarracks).getDescription(),city.getName()))
							city.setHasRealBuildingIdx(iBarracks,True)
	elif( barbSettleType == 2 ) : # Builder
		if( city.canConstruct( iLibrary ) ) :
			if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iLibrary).getDescription(),city.getName()))
							city.setHasRealBuildingIdx(iLibrary,True)
		if( city.canConstruct( iLighthouse ) ) :
			if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iLighthouse).getDescription(),city.getName()))
							city.setHasRealBuildingIdx(iLighthouse,True)
		if( city.canConstruct( iGranary ) ) :
			if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iGranary).getDescription(),city.getName()))
							city.setHasRealBuildingIdx(iGranary,True)
	iTotCul = city.GetCy().countTotalCulture()
	if( iTotCul > 0 ) :
		city.setCulture( int(iTotCul/2.0) )
		if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - Culture of %s set to %d"%(city.getName(),city.getCulture()))
						
	if( self.LOG_DEBUG ) : CvUtil.pyPrint("  BC - %d units placed in %s"%(city.plot().getNumUnits(),city.getName()))


Both parts appear to be the same problem, misuing gc.getActivePlayer(). If two players are playing online, and one is of a different era than the other, this function will return different values for each. Thus, all of the code following these lines that are dependent on the resulting variables will be slightly skewed, which will eventually throw the game OOS.

This is just a quick glance, so I may have missed something, but I do believe these issues might cause rare problems.
 
Gerikes said:
I was just taking a look at the code, trying to help someone debug some OOS problems they were having in their mod. I don't think this mod was the cause of it, but these pieces of code do look pretty fishy to me, and might cause problems...

This is just a quick glance, so I may have missed something, but I do believe these issues might cause rare problems.
Interesting ... I don't really know how things work in multiplayer, but I will change those lines in the next version to avoid any potential issue. Thanks for the heads up!
 
Hum, it's very interesting, i need a similar thing for my mod. I can't see your source code, but, can you explain how you can create new civs during the game with the SDK ?
 
jojoweb said:
Hum, it's very interesting, i need a similar thing for my mod. I can't see your source code, but, can you explain how you can create new civs during the game with the SDK ?
The short version is, each player has a slot, and players not in the game have uninitialized slots. So, I set up the civ and leader types for a new slot, then set up the players graphics (what city art style they use, etc), and their relations with other players. When this set up is done, they can be given cities and units just like any other player ...
 
It's a good idea, i have seen the initcore file in the source code, active and inactive slots, yes it must be good and not so hard. Can we have the uncompiled version of the source code ? ^_^ I want to see if i can create a new status for conquered cities by creating a new civilization. It would be Great ^_^ (if you don't want to share your source i can understand, or you can give me link by MP).

Thanx.
 
jojoweb said:
It's a good idea, i have seen the initcore file in the source code, active and inactive slots, yes it must be good and not so hard. Can we have the uncompiled version of the source code ? ^_^ I want to see if i can create a new status for conquered cities by creating a new civilization. It would be Great ^_^ (if you don't want to share your source i can understand, or you can give me link by MP).

Thanx.
The SDK code modifications should be in the SDK enabled version on the front page, or check out the Revolution mod in my sig ... they use the same DLL. Enjoy.
 
OK, a few tests and these are the results:
The new Civs, that are militaristic, gain too much units.
They attack in turn 100 (normal game pace) with 6 horse archers and 5 axeman, and there are definitely more units...
Is there a possibility to decrease their number?
 
Caesium said:
OK, a few tests and these are the results:
The new Civs, that are militaristic, gain too much units.
They attack in turn 100 (normal game pace) with 6 horse archers and 5 axeman, and there are definitely more units...
Is there a possibility to decrease their number?
Thanks for the feedback! A few tweaks have already been made from a similar complaint in the Revolution thread ... first, when barbs civs get multiple cities they don't get the same number in each. Second, the base unit rate has been decreased while the max potential random draw has been increased (so on average lower, but the worst case scenario remains). Finally, a config variable has been added so that you can alter their strength if you so desire. These will show up in the next version.

I do want to make sure the barbs are potent ... my aim has been to make them able to capture a couple of cities based on their initial rush. Approaching two cities, each defended by two archers, one on a hill/with walls and one not, I think 4 horses and 4 axes is a good baseline. They'll lose 1-3 units attacking one city, and 2-4 attacking the other. That leaves them with just enough to hold onto their gains. A player with better defences (an axe in each city, both with some defence) could escape unscathed. With the above changes, that will be the normal scenario, and sometimes the barb civ will be given extra units and simulate a large horde ... does that sound reasonable?

While the initial onslaught is daunting, the barbs really do run out of steam once they've lost a few units or have to switch to defense. Their infrastructure sucks, and they can't build enough units to support their rampage ... counter attacks can prove very successful.
 
I think I'm going to fold this mod into my goal, rather than attempt to remove the components I don't care about in the revolution mod.

In my InsaneBarbs mod, there is a problem in that the barbarians tend to dominate. In a "normal" game about 2 to 4 civizliations are taken out by the barbarian hordes.

This leaves large areas with a contiguous barbarian empire. I think it would be good for these large barbarian empire areas to form minicivlizations. At the very least, it would provide a distraction for the barbarian hordes. :)

Sadly, I really want BetterAI, so that means I gotta do an SDK merge.
 
I think I'm going to fold this mod into my goal, rather than attempt to remove the components I don't care about in the revolution mod.

In my InsaneBarbs mod, there is a problem in that the barbarians tend to dominate. In a "normal" game about 2 to 4 civizliations are taken out by the barbarian hordes.

This leaves large areas with a contiguous barbarian empire. I think it would be good for these large barbarian empire areas to form minicivlizations. At the very least, it would provide a distraction for the barbarian hordes. :)

Sadly, I really want BetterAI, so that means I gotta do an SDK merge.

I haven't kept this standalone component completely up to date, so I'd suggest you trim Revolution. It is actually very easy, you only need to modify one file: CvCustomEventManager.py

In the __init__ function, leave only calls to BarbarianCiv and RevUtils (although I'd recommend leaving AIAutoPlay and ChangePlayer as well for testing, your choice).

Then, you can delete the Revolution, RebelTypes, AutoUtils, Tester (and AIAutoPlay and ChangePlayer if not used) python files if you want, or leave them knowing they won't be called.

If you have any questions about this, PM me. I may be able to post an updated version of pure BarbarianCiv in the not too distant future, but it won't happen this week.
 
Thanks for the advice. I can understand how the components can fall behind the merged mod. :)

Does the Revolution/RebelTypes/AutoUtils/Tester have SDK code? Practically, I'm trying to eliminate the crash after 10 to 15 turns when I tried to use the BetterAI+Revolution DLL. And is the path to the INI file hard-coded anywhere in the DLL?
 
Thanks for the advice. I can understand how the components can fall behind the merged mod. :)

Does the Revolution/RebelTypes/AutoUtils/Tester have SDK code? Practically, I'm trying to eliminate the crash after 10 to 15 turns when I tried to use the BetterAI+Revolution DLL. And is the path to the INI file hard-coded anywhere in the DLL?
The changes in the DLL fall into two categories: Revolution (most) and AIAutoPlay (only a few). The largest changes are the addition of the ability to create new players on the fly, which BarbarianCiv makes use of when this DLL is used. If you use a different DLL, BarbarianCiv can still work if you set the Python Only flag in the .ini, but it is much better to use the DLL (see first post of this thread for more info).

RebelTypes does not make use of the DLL (it's a helper file for Revolution), AutoUtils is never used at all, and Tester is where I test ideas (doesn't affect gameplay), so there's no SDK code to remove for these components. There is also no mention of the .ini file in my SDK code at all, as the python files control the function of the mod and the SDK changes simply allow new things to occur when the Python files request them. My guess would be there's something incompatible between BetterAI and other things you're doing if it's crashing that early. You could try using the Revolution only DLL (ie, no BetterAI) as a test.
 
I've merged the Wolfshanze mod with RevDCM. Been offering it as an add on in glider's RevDCM thread. It works great except I'm getting an annoying bug I can't track. The barb civs are getting gifted Optics when they spawn in the middle ages. They are not using a GP to bulb the tech either, often times they have optics even when they have neither Machinery, nor Compass. I tried removing all the python from the Wolf mod (this meant some events and certain upgrade costs, and minor issues like this would cause little bugs of their own, but I could go in and manually correct those), but even without the Wolfshanze python files I'm still seeing this.

RevDCM uses the SDK version which is merged with a couple of other mods, as I'm sure you're aware. I know you're not too keen on helping out merged mods, since you don't know what's causing the issue, and it isn't your code, but I'm really hoping you might have some insight as to what is causing this. If you have any idea where to look, or even an idea of how to implement a work around (such as snagging optics away from a barb civ that spawns with it) please give me some feedback. Never messed around with C++ before, but based on snippets that have been posted here it looks like most of what the modders code is pretty intuitively understandable. At least I picked up how to code basic stuff in Python fooling around with your mod. So I'll actually bite the bullet and figure out how to compile the source code and all that jazz, but first I need to have some sort of idea of where to look.

Would really apreciate any help you can provide. Peace.


EDIT: nevermind, figured out what was causing this, XML, the barbs were getting Optics on the game start up for some reason.
 
How can I install this mod alone?

I made a folder called Revolution and put it with the other mod folders. Inside I put everything as it is in BarbarianCiv.zip. It crashed when I tried to load the mod.
 
Hi Jdog,

[ I originally posted this in the RevDCM forum, but Glider suggested that I post this here ]

I'm playing a Noble game, standard map size, Epic game speed, PerfectWorldRevDCM map.

I only recently started playing with the Barbarian mod turned on... however, I've been a bit surprised by how powerful the barb armies initially are... in fact, I think they are way overpowered. This is an example:

http://www.pennington.net/Kublai_army.jpg

Due to revolts when I rex quickly, I've started scaling back my rexing and focus on wonder building / economy. At this point, it's 250BC and I only have 3 cities and two units in this border city... this bronze city is so new, I just now managed to hook up my civ's only source of bronze. Yet when these barb civs spawn, they show up with mature promotions on their units and piles of siege engines. This is way out of balance and I think it's worse than the undefendable barb bug that BetterAI squashed long ago. What's more, when I look at world builder, Kublai's iron isn't hooked up and he doesn't even have horses.

In the other thread, someone mentioned that you "have" to make these barb civs competitive... I disagree that they need to be competitive at all... they were quite frankly a little black flag hut maybe 50 turns ago. Just because I don't build some axemen quickly to kill them off, they are granted a dominating army?

Thoughts?
 
Top Bottom