Making Barbarians nations appear only a specific tech discovery

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
sc0ttj
Posts: 10
Joined: Wed Dec 09, 2020 3:56 pm

Making Barbarians nations appear only a specific tech discovery

Postby sc0ttj » Wed Dec 16, 2020 1:51 am

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?

Ignatus
Elite
Posts: 489
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Making Barbarians nations appear only a specific tech discovery

Postby Ignatus » Wed Dec 16, 2020 10:10 am

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.

sc0ttj
Posts: 10
Joined: Wed Dec 09, 2020 3:56 pm

Re: Making Barbarians nations appear only a specific tech discovery

Postby sc0ttj » Wed Dec 16, 2020 10:51 am

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?

Ignatus
Elite
Posts: 489
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Making Barbarians nations appear only a specific tech discovery

Postby Ignatus » Wed Dec 16, 2020 2:47 pm

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.

Wahazar
Elite
Posts: 362
Joined: Mon Jul 02, 2018 1:49 pm

Re: Making Barbarians nations appear only a specific tech discovery

Postby Wahazar » Wed Dec 16, 2020 3:36 pm

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.
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047

nef
Hardened
Posts: 246
Joined: Mon Jun 25, 2018 5:01 pm

Re: Making Barbarians nations appear only a specific tech discovery

Postby nef » Mon Dec 21, 2020 6:42 pm

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.

nef
Hardened
Posts: 246
Joined: Mon Jun 25, 2018 5:01 pm

Re: Making Barbarians nations appear only a specific tech discovery

Postby nef » Mon Dec 21, 2020 6:51 pm

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.

Ignatus
Elite
Posts: 489
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Making Barbarians nations appear only a specific tech discovery

Postby Ignatus » Mon Dec 21, 2020 9:23 pm

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).