THis is why you rarely see barbarians spawn naval units!

Ninja2

Great Engineer
Joined
Nov 17, 2005
Messages
1,142
Location
Denmarkia
A lot of people, including me, have asked questions about why there are so few Barbarian Naval units in the game. In the earlier versions of CIV, it was quite common for barbarians to suddenly appear in ships off your coast, and they would unload an invasion force that you had to deal with. Plus, their ships would attack your navy! Not so in CIV4, where you very rarely meet a Barbarian Galley! Sometimes you DO meet one... but it might be that this particular galley was simply built by a Barbarian coastal city, and not spawned onto the map. It is certainly a rarity. Some have modded the game to include more pirates, and the best results I have seen involve events, where Barbarians are created via python events (jkp1187's pirates, for example). But those random spawnings of Barbarian ships have remained elusive.

Well, this weekend I finally sat down to figure out why. And I'm pretty I have finally found the answer! :)

When the game spawns barbarian units, it does so based on a number of things:

First, it considers if there should even be any barbarians (there's the game option to turn them off).

Second, it checks to see if there are any animals in the game. If not, it will create some.

Third, it will see if enough time has passed to create barbarians (this is a setting connected with difficulty settings).

Fourth, it will determine how many barbarians are required for a certain map area. And this is where it gets really interesting! When you select a difficulty level, part of the difficulty deals with how many unowned tiles there should be per barbarian unit. So if it's set to 100, then the game will basically spawn one barbarian unit per 100 unowned tiles. The Settler difficulty is 150, so 150 unowned tiles to create one barbarian. The higher the difficulty, the lower the number. If you've selected Raging Barbarians, this number is divided by 2. When it's figured out how many barbarians are needed, it then subtracts the existing number of barbarians (including animals) on the map. Whatever is left, is placed on random plots - immediately. The type of units selected is restricted by normal build restrictions - that is, technology and resources, so no Axemen without the Barbarian nation having access to copper, for example. It also means that Galleys won't spawn until the barbarians have researched sailing!

There are a number of conditions, which make spawning of ships very unlikely:

1) There are two different types of unowned plots: Unowned land plots and unowned water plots. The number I've given above is for land plots (Settler=150 to Deity=25). The number of unowned water plots is much higher (Settler=3000 to Deity=1000). So even on Deity, if you have 2000 unowned water plots in one area, the math in the formula will be 2000 / 1000 = 2 water units. However, the 2 units are then divided by 4, and 1 is added. In the end, 2000 unowned water plots will still only support one galley.

2) The unowned number of plots is independent of map size. This may come as a surprise, it certainly did to me. A default Large map in CIV4 is 104 x 64 plots, a total of 6.656 plots. if 60% is water, that's less than 4.000 water plots. If all plots are unowned, AND regarded as one area (which I am unsure of), that's still only enough to support 1 galley (see point 1 above) on Deity.

3) As barbarian units get killed, more get placed. But as time goes by in the game, there are less and less unowned plots, so less and less room to support spawning barbarians. Remember, this is different from units getting built by barbarian cities, although those built units still count against the needed barbarians.

4) The barbarians need the appropriate technology to spawn units. If they never research sailing, a galley will never spawn. And the sooner you and the AI squash the barbarian cities, the less research the barbarians accumulate.

So, what to do? Well, it's possible to just tweak XML files to have this thing work. Yesterday, I tried to give the barbarians sailing as a starting tech, and lowered the number of unowned water plots to 10 on deity. After 10 turns , which is the Deity setting for turns without barbarians units (animals always spawn after 5 turns, regardless of difficulty), I had the oceans absolutely crawling with galleys!!

I haven't put together a modcomp of this yet, because I haven't quite decided on how to fix this. There are quite a few possibilities to fix this, ranging from inelegant XML modding like I did yesterday, to full-blown SDK changes. What I'd like to accomplish is for barbarians to keep spawning in the oceans right up to Privateers. So What I think is needed is some way for the game to grant free techs to the barbarians at appropriate points - like when two or three civs discover a particular tech on a predefined list, that tech is given to the barbarians.
 
What I'd like to accomplish is for barbarians to keep spawning in the oceans right up to Privateers. So What I think is needed is some way for the game to grant free techs to the barbarians at appropriate points - like when two or three civs discover a particular tech on a predefined list, that tech is given to the barbarians.
That's pretty much it in a nutshell... for the Barbarians to spawn at sea, they need the appropriate techs... you won't ever really even see Triremes from the Barbarians because it takes several tech-jumps for them to even learn that basic tech requirement.

Perhaps this could be settled by a special wonder? Give the Barbarians a UB Wonder or something that acts like the old Great Library did that the Barbs get any tech discovered by any two or three other civs or something like that... then ensure only the Barbarians can build it... make it dirt cheap to build, and make it instantly destroyed if/when the city is captured... or, perhaps even simpler... some sort of library that boosts research by a zillion times so they can keep up with the Joneses a little better. Any answer through a building or wonder would of course have to be Barbarian specific and instantly destroyed if captured... you couldn't give something like that to a human or regular AI player.
 
I'd rather have Barbarians somehow "borrow" techs from nearby players to build units with.
 
I'd rather have Barbarians somehow "borrow" techs from nearby players to build units with.
Probably be a LOT easier to get them to have a building that gives them techs then figure out how they get techs just from neighbors.

This is about practicality. You probably wouldn't notice the difference either way it was done... the trick is to get it done... and why take the long road if the short road is there and gets you the same desired end-result?

But yeah... like "Internet for Barbarians"... maybe Al Gore can show them how it works or something.
 
The Internet is a project, so you can't just give it to the barbarians. It wouldn't be hard to make a chance of a discovery going to the barbarians when a tech is researched, though.
I never once said "give the Internet Project to the Barbarians"... I said give them a BUILDING... a Wonder or a UB that has the same abilities as the Internet Project... I believe it is possible in the existing XML to do so (haven't checked it, but I believe it's possible). I'm somewhat confident you can indeed make a building (wonder or UB) that has those same benefits... it's just a matter of working it in. I could be wrong, but that was my statement all-along... I never once said "Give the Barbarians the Internet Project".
 
I'd ask for this to stay away from Python and do whatever can be done in XML -- it's easier for people to use.
 
It is not possible to make a building have the same effect without SDK changes. Buildings and projects are two different files with there own tags. I think it's better to mod the python to give them the techs rather than make the SDK changes necessary for a building.
It's totally possible if it's already there in XML... I think it is... that's my whole point... you have to think outside the box! There's usually more then one way to crack an egg.

Instead of continuing to say how things can't be done, why don't you help and offer a way to solve the problem instead of saying everything can't be done.
 
What I'd like to accomplish is for barbarians to keep spawning in the oceans right up to Privateers.
Why stop at privateers, if the stories are true there are still pirates at large in the Far East. Rubber boatloads of machine gun armed pirates waylaying yachts and, (if you want to believe the films) Cruise ships too.
 
I have already considered going the building/project route. Right now, only projects can have the effect of tech sharing. I don't think it's possible to move this effect to a building without making changes to the DLL. But even if we do create a special project for the barbarians (link it to a late, peaceful tech which the barbs then start with), there's no way to limit what techs are shared. Once they've completed the project, they will get all techs owned by any defined number of civs, and the effect won't stop just because the city where it's built is destroyed or conquered, since it's a project. Ideally, we only want to give the barbarians the minimum techs needed to build naval units up to privateer, and then stop.

One possible way to get around the tech problem is to create some duplicate unitclasses of, say, galleys, triremes, longboats and privateers. These classes should be buildable only by barbarians (controlled in CivilizationInfos) and have very low tech requirements. I'm thinking none for galleys and triremes, sailing for longboats and maybe compass for the privateer. Instead of the normal tech requirements, we put a resource requirement on triremes, longboats and the privateer. The resource can be any of Copper, Iron, Gold, Silver, Fur - any of the resources that may be found on the fringes of the map, where the barbs usually settle. This resource requirement adds some element of realism, since the barbarians need to be reasonably well settled, before any of the advanced pirates can exist. This gives the player an incentive to kill barbarians, and it ensures that the pirates will eventually cease to exist. The Galley upgrades to the Longboat, the Trireme and the Longboat to the Privateer. So if the barbarians ever reach the Compass, and still control a resource, you'll see the Privateers spawn! If they only get to Sailing and control a resource, you'll see Triremes and Longboats. If they never get to Sailing, but manage to control a resource, you'll see Galleys and Triremes. And if they never get to control a resource, you'll only ever see Galleys - and you'll actually keep seeing them, until the barbarians have researched Sailing. If they never do, barbarian Galleys will remain on the seas until the end of the game, I assume. But that's about the only downside to this approach, I think.

While doing the above, I'll adjust the unowned water tile requirements to more reasonable levels. My math was a little off in the first post, and there are some elements in the map process which I am unsure off. At the moment, given a default land percentage of 26%, a small map on Prince level allows one barbarian ship. These are the lowest possible requirements, the next are Settler/Standard and Immortal/Tiny, both also allow one barbarian ship. The max is of course Deity/Huge, which allow 7. With Raging Barbarians on, everything is double up starting at Chieftain/Tiny and Emperor/Duel. On maps with more land, the number of allowed barbarians obviously drops. The big question is how to balance this. If I set some level, which allows, say, 7 barbarians on a map size for a given difficulty, that's how many ships will be on the map - at all times - until the conditions above have been fulfilled. If you kill a ship, it will just respawn the next turn.

Now - is there anything obvious that I've missed? There probably is, and please point it out to me! :D
 
So I hit a snag... there's a limit on 4 'OR' resources per unit. That puts a limit on how easily the barbarians can get their advanced units, unfortunately.
 
Exactly... UUs would serve the same purpose... for instance (not sure if you ever noticed Ninja), I gave the Vikings a "Longboat" UU which replaces the Caravel... but it actually can carry one NORMAL unit (settler/military/whatever) and can sail the sea... it also comes one tech prior to the normal tech Caravels come at.

In other words, a UU for a civ can have different tech requirements then the unit it replaces.

Of course what you propose would probably require MASSIVE play-testing to get it to "feel" right.

I don't suppose there's just a simple way to hand "Tech-X" to the Barbarians in a certain year or if somebody else has that tech?
 
This still doesn't spawn barbarians in the longboats.

It also bases Barbarian spawnage off of the size of the oceans. Personally, I'd prefer if Naval Barbarians spawned based on the unoccupied coast squares.

Then spawn ships and units on the ships. Only place a unit on a ship if no non-barbarian player can see that ship.

Instead of a basic (# of squares/Barbarian_count), do a (random number from 0 to barbarian_count < (# of squares - Existing Barbarians*Barbarian_count)*(random number from 0 to 1)). This allows small regions to rarely spawn Barbarians, and large regions to sometimes not spawn a barbarian, instead of just never spawning or always spawning them.

Next, after each barbarian is spawned in a round, halve the number of "excess" squares for the above calcuation. That prevents "instant population" when barbarians are triggered. They spawn at a reasonably fast rate every turn, growing in numbers until they saturate the area. A killed barbarian could take multiple turns to come back, and killing barbarians is not _completely_ futile. :)
 
Exactly... UUs would serve the same purpose... for instance (not sure if you ever noticed Ninja), I gave the Vikings a "Longboat" UU which replaces the Caravel... but it actually can carry one NORMAL unit (settler/military/whatever) and can sail the sea... it also comes one tech prior to the normal tech Caravels come at.

In other words, a UU for a civ can have different tech requirements then the unit it replaces.

This is exactly what I have done. In my current test, I have four unique barbarian naval units, like I described above. The barbarian caravel is based off the Viking Longboat, but it only has Sailing plus either iron, copper, gold or silver a requirement.

Of course what you propose would probably require MASSIVE play-testing to get it to "feel" right.

I agree. It's really tricky, especially due to the unowned water tile function being totally independent of map size.
 
This still doesn't spawn barbarians in the longboats.

It also bases Barbarian spawnage off of the size of the oceans. Personally, I'd prefer if Naval Barbarians spawned based on the unoccupied coast squares.

Then spawn ships and units on the ships. Only place a unit on a ship if no non-barbarian player can see that ship.

Instead of a basic (# of squares/Barbarian_count), do a (random number from 0 to barbarian_count < (# of squares - Existing Barbarians*Barbarian_count)*(random number from 0 to 1)). This allows small regions to rarely spawn Barbarians, and large regions to sometimes not spawn a barbarian, instead of just never spawning or always spawning them.

Next, after each barbarian is spawned in a round, halve the number of "excess" squares for the above calcuation. That prevents "instant population" when barbarians are triggered. They spawn at a reasonably fast rate every turn, growing in numbers until they saturate the area. A killed barbarian could take multiple turns to come back, and killing barbarians is not _completely_ futile. :)

Oh, there are plenty of cool ways to do this if we re-wire the code. At the moment, I'm looking strictly at XML ways to at least get some ships in the game. In the current version of my Merged Mod, I have built in barbarian spawning in ships. So, in my new beta version, galleys spawn with warriors! But that is accomplished with python, and I didn't write it.
 
I just found this thread and I agree it is really good to have barbarian ships spawning. You could even go a little beyond the privateer. i think snafusmith made a cool modern pirate unit. It could be good against transports but nothing else, forcing you to protect them convoy style. Great work with this find, it is relatively doable to implement without a lot of code changing :goodjob:.
 
Top Bottom