Page 1 of 1

Making Barbarians nations appear only a specific tech discovery

Posted: Wed Dec 16, 2020 1:51 am
by sc0ttj
Is making Barbarian nations appear only a specific tech discovery possible?

I'd like to have 2 or 3 Barbarians nations in the game (a custom civ2civ3 ruleset),
each with unique nations, flags, names and unit graphic, etc..

I'd like them to appear only after certain techs have been discovered by the World.

Is this possible?

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Wed Dec 16, 2020 10:10 am
by Ignatus
Only one nation can be land barbarians or sea barbarians at time. Their appearing mechanism is hardcoded but it's possible to set barbarian rate to "only from huts" and produce them by scripting engine. Actually, you can just take any AI nation and make a script to place its units randomly each turn, they won't be true barbarians but there is little difference.

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Wed Dec 16, 2020 10:51 am
by sc0ttj
you can just take any AI nation and make a script to place its units randomly each turn, they won't be true barbarians but there is little difference
Do u have some example code?

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Wed Dec 16, 2020 2:47 pm
by Ignatus
sc0ttj wrote:Do u have some example code?
Not particulary for this task but much of it is in standard */script.lua files. The API doc is on Wikia.

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Wed Dec 16, 2020 3:36 pm
by Wahazar
Another issue with barbarians is lack of sea unit flag, which guarantee spawning such unit if certain tech level i achieved by any player.
Such flag exists for land units, but not sea ones.

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Mon Dec 21, 2020 6:42 pm
by nef
Ignatus wrote:Only one nation can be land barbarians or sea barbarians at time. Their appearing mechanism is hardcoded but it's possible to set barbarian rate to "only from huts" and produce them by scripting engine.
The barb nations actually persist for some substantial period of time after the "is_alive" criteria becomes false. (Human and AI players are permanent.) You can tell (during ordinary game play) the difference; when the server wants to create new units and the nation/player does not exist it will announce the new leader. A script, of course, can know all the time. (Use the player.is_alive field or the equivalent combo methods of :num_cities and :num_units) I haven't tried it but if the barb player exists you should be able to use edit.create_unit as you can for any other player (at any time).

What I have NOT been able to do is to get edit.create_player to work. If someone can tell me what the arguments are really meant to be I would very much appreciate it.

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Mon Dec 21, 2020 6:51 pm
by nef
Wahazar wrote:Another issue with barbarians is lack of sea unit flag, which guarantee spawning such unit if certain tech level i achieved by any player.
Such flag exists for land units, but not sea ones.
What flag are you referring to? What appears to be missing is a distinction between "BarabarianBoat" and "BarbarianBoatTech" since the latter is not a flag. Land units ON the boat appear to be covered.

Re: Making Barbarians nations appear only a specific tech discovery

Posted: Mon Dec 21, 2020 9:23 pm
by Ignatus
nef wrote:
Wahazar wrote:Another issue with barbarians is lack of sea unit flag, which guarantee spawning such unit if certain tech level i achieved by any player.
Such flag exists for land units, but not sea ones.
What flag are you referring to? What appears to be missing is a distinction between "BarabarianBoat" and "BarbarianBoatTech" since the latter is not a flag. Land units ON the boat appear to be covered.
Likely yes, that's what was spoken about. Actually, it's not good to have barbarian caravels when nobody has a trireme yet, a nation with a single diplomat and a small amount of gold may bribe one at their coast and get a huge expansion boost by almost sheer random. That may be avoided if you put pirates with edit.create_unit_full() callback into a boat that you also put by Lua previously (the function to select it for world's tech level has to be written manually though).