[BTS] Why no barb spears?

Fish Man

Emperor
Joined
Feb 20, 2010
Messages
1,545
This is something I've been wondering for a long time, and I hope someone knows the answer.

Emperor and above, the barbs start with hunting and archery. So why can't barb spears spawn until much later (whereas barb archers and warriors can spawn as early as t6 on deity IIRC)? Or at least they don't seem to?

Is it:

1. Barbs somehow need to research bronze working to get metal units?

2. Barbs requiring a resource can only spawn on/near that resource?

3. Both of the above?

4. I'm completely wrong and the answer is something else???

A solution to this conundrum would be greatly appreciated.
 
Just out of memory, I think it's something like a majority of the players/AIs need to research BW (not hunting!) for spears to start appearing.
Similar to how a certain number need to know sailing for galleys to start spawning.

They do not need to have copper connected to some barb city.
 
Barb spawns are controlled by CvGame::createBarbarianUnits(). I believe the relevant line in the code for your question is

if (!GET_TEAM(BARBARIAN_TEAM).isHasTech((TechTypes)GC.getBonusInfo((BonusTypes)kUnit.getPrereqAndBonus()).getTechCityTrade()))

I'm not 100% sure I'm deciphering that line correctly (it's a little dense), but I think it's pointing to the <TechCityTrade> tag in Civ4BonusInfos.xml. Civ4BonusInfos carries information about "bonuses" (i.e., resources) like copper. With Copper, the line is <TechCityTrade>TECH_MINING</TechCityTrade>. No Mining, no spears. Get mining, make spears. But as I said, I'm not certain I'm right about that.
 
Well, that makes sense. I got a barb spear spawned ridicusly fast in a low level difficulty game recently. So that it's just mining that is required makes sense.
This is for barbarian spawns though, however, for barb cities to build spears, I do think they need the resource hooked up.

I did some searching for how barbs get their techs, and didn't find anything conclusive.
Do they get the tech when a certain number of players also have the tech? Or is there some randomness going on?
 
Have you (anyone :D ) actually seen barbs building (from cities) Spear? Was playing on Great Plains map (a lot of free place for barbs with regular number of AI for certain map size) and used GSpy (from very very logical Great Wall wonder) to walk around entire map (nice scout unit, can even use for short-term fog-bust for safe settler move :D ) and to see what they are doing all around. Connecting roads, building cottage etc. stuff, cities got Barracks, Monuments and Axemen with Copper or Swords with Iron, Galley in coastal cities (even have seen amphibious barbs attack using galley and 2 archers :eek: ) - yes, but didn't see Spears... Should I walk around with Chariots maybe? :mischief:
 
No, I have not seen it, haven't really studied barb behaviour.
I'm just going from the assumption that the code that decides what can be build in barb cities are similar to what happends in normal cities. And that only barb spawning uses it's own special laws.
Not at all certain, just making assumptions!

Amphibious barb attack!? I often leave small cities w/o defense, such crafty barbarians would have had the opportunity against me from time to time,
 
CvTeam::doTurn() handles that. Lines 843-873 of CvTeam.cpp.

Barbarians make progress every turn on every tech that any other civilization knows. There is no randomness involved, and it is directly proportional to what fraction of surviving civs have discovered a tech. They get no progress if nobody has discovered it, scaling up to BARBARIAN_FREE_TECH_PERCENT, 3%, if every surviving civ has discovered it (it would be 1.5% if half the civs knew the tech). If every single player started the game with Mining, barbarians would discover it 34 turns later. The percentage is after accounting for game speed, map size, and difficulty level - if everyone starts a game with Mining, the barbarians should discover it about 34 turns later on Deity, Tiny Map, Quick speed; they should discover it about 34 turns later on Settler, Huge map, Marathon speed.

I'm not sure whether things like tech prerequisite multiplier to beakers apply to that 0-3% tech the barbs get, and also not sure whether barbarians might also generate a small number of beakers the normal way from their cities or not. So the exact number of turns might vary a little from those factors.
 
Amphibious barb attack!? I often leave small cities w/o defense, such crafty barbarians would have had the opportunity against me from time to time,
Found some old screenshot with example of almost amphibious attack.
Spoiler :
 
Did check the code out too, it seems this is just a free bonus that barbarians get.
Where is the code that updates research progress for all teams? If that iterates over all teams (including barbarian)
"gc.getMAX_CIV_TEAMS() + 1"?
and there is no if(!Barbarian), they could get progress that way too.

If they are ommited as a team there, I think it's safe to say that they do not tech normal and that all their nice cottages don't do much for them.
 
Found some old screenshot with example of almost amphibious attack.
Spoiler :
Scary indeed :eek: as my cities often are undefended. Never happened to me tho. Can see screenshots was marathon game (never play that myself) so perhaps an effect of marathon?
 
Research is done individually in CvPlayer::doResearch(), which is called by CvPlayer::doTurn(). I'm pretty sure that if the barb leader didn't have a doTurn() cycle they wouldn't do anything - that's the core function that controls unit production in cities, movement of units on the map, basically everything.. So they probably get a doResearch() call every turn. But there are a lot of places in the code you might be able to tuck away a tweak that cripples or removes normal research. Like making their cities not generate commerce, or their commerce not turn into beakers, or their leader not select any tech to focus on, or unit upkeep leaving them perpetually pinned at 100% gold slider. I can't check all the places that might happen, so it's just guesswork to me whether they get normal research in addition to their free tech progress.
 
Research is done individually in CvPlayer::doResearch(), which is called by CvPlayer::doTurn(). I'm pretty sure that if the barb leader didn't have a doTurn() cycle they wouldn't do anything - that's the core function that controls unit production in cities, movement of units on the map, basically everything.. So they probably get a doResearch() call every turn. But there are a lot of places in the code you might be able to tuck away a tweak that cripples or removes normal research. Like making their cities not generate commerce, or their commerce not turn into beakers, or their leader not select any tech to focus on, or unit upkeep leaving them perpetually pinned at 100% gold slider. I can't check all the places that might happen, so it's just guesswork to me whether they get normal research in addition to their free tech progress.

Hmm, interesting.

That makes me think, actually - it really seems like barbs automatically do get free technologies after X civs or even a certain % of the population knows them. You can see this in a marathon noble space game I played a while back, where barbs were spawning rifles and building factories(!) despite the 2 remaining AIs being still in the medieval era - because I had the tech and my pop was 80-90% of the world, the barbs got rifling and AL too? Side note - it seems the most advanced land unit the barbs can build is riflemen. Everything else seems off-limits to them (otherwise I'm pretty sure I'd be seeing barb mech inf during the final turns before the win). Joao was probably very thankful for that - the barb rifles tried to attack his city guarded by longbows, and due to the AI's high anti-barb bonuses and some good luck he survived. But barely. Also...barb axes took over London (guarded by warriors) and some other English cities waaay back in the BCs. Marathon is weird. Save is attached below...

Oh, and they tried an amphibious invasion against my mechanized infantry. That was cute.

But I'm rambling here! If barb spears need mining then they could spawn almost immediately in a lot of games. I'm of the opinion that barbs need BW and hunting to get spears, then.
 

Attachments

  • Aggressive Axe-Crazy Absol AD-1356 what a game.CivBeyondSwordSave
    254.3 KB · Views: 30
Does the Raging Barbs setting change this at all? I could swear that Raging Barbs makes the barbs get better units faster, but if that's tied to what tech they have...
 
Bit weird, but in Iso deity i usually meet spears no later than t50.
Might have something to do with more space available, so chances for Spears are bigger as many barbs spawn.
And always before Axes, can be annoying if you count on chariots.. ;)

And yup, better barbs when raging, also explained by more spawning.
Must be some random factor involved.
 
Might have something to do with more space available, so chances for Spears are bigger as many barbs spawn.

Some of the "speed" at which you see the spears or any of the higher tier units show up has to do with fresh spawns of barb units. Even if the majority of the civs on that continent (tiebreaker rounds up, so 2/4 civs knowing BW will spawn Axes on your continent, etc) have the techs that allow better barb units, if they aren't being killed off to allow more new barb spawns you won't see them for a while longer.

So yeah, more space = more spawn potential = faster higher tier units coming in, since they aren't spawnbusting each other as much. This also explains why higher tier barbs are so much rarer, as the AI is usually killing them off and checking their spawns long before this point in non-iso when they can do things like tank spears with a Scout and stuff.

As far as I know animals will despawn on their own but the military units won't, possibly indefinitely. I play a lot of the default Earth18 scenario and due to South America being insurmountable for Monty/Huayna to settle until Astro, I always find it teeming with barb Warriors the instant I land when playing an Old World civ....as soon as they start rushing me and dying off, they are immediately replaced by fresh Axes and Swords, and eventually Longbows show up in the cities if the backwards New World gets Feudalism before I settle it out/put a colony there.
 
Just a theoretical question, then: as long as you don't have BW, you're pretty much safe from axes and spears?

Also, a barbed spear would then be your own spearman killed by a barbarian axe, right? :sheep:
 
Just a theoretical question, then: as long as you don't have BW, you're pretty much safe from axes and spears?
As long as you don't AND no AI has it either. And it was mining for spears.
As soon as the first civ gets mining, the barbs start to tech and eventually get spears.
 
And it was mining for spears.

I got it covered. Thanks for the clarification. First civ gets it - barb clock starts ticking.

mining-for-spears.jpg
 

Attachments

  • image.png
    image.png
    261 KB · Views: 152
Top Bottom