LUA How to add MinorCiv?

Nefliqus

Prince
Joined
Sep 16, 2010
Messages
400
Location
Poland
How to add MinorCiv? AddPlayer works for me only for Major Civs.

--Game.addPlayer(PlayerTypes eNewPlayer, LeaderHeadTypes eLeader, CivilizationTypes eCiv);
Game.AddPlayer(2, 13, 11); --2 next free player index, 11japan, 13oda
player = Players[2];
local x= 1;
local y= 1;
local plot = Map.GetPlot(x, y);
NewLandPlayerStartPlot = plot:GetNearestLandPlot();
player:SetStartingPlot(NewLandPlayerStartPlot);

This code adds Japan, but if I want to add Helsinki:

Game.AddPlayer(26, 3, 11); --26 next free player index, 3minor 11helsinki
player = Players[26];
player:SetOption(IsMinorCiv, true); --it doesn't work
player:SetOption(IsPlayable, false); --it doesn't work
local x= 1;
local y= 1;
local plot = Map.GetPlot(x, y);
NewLandPlayerStartPlot = plot:GetNearestLandPlot();
player:SetStartingPlot(NewLandPlayerStartPlot);

It adds Barbarian, not Helsinki?

Map Script: ------------------------------- CIVS:
Map Script: NEF: GetID(): 0 playerStartPlot: x- 13 y- 11 GetLeaderType(): 8 GetMinorCivTrait(): -1 Team: 0 Personality: -1 PersonalityType: 8 Playable: 1 GetName(): Gandhi
Map Script: NEF: GetID(): 1 playerStartPlot: x- 21 y- 8 GetLeaderType(): 19 GetMinorCivTrait(): -1 Team: 1 Personality: -1 PersonalityType: 19 Playable: 1 GetName(): Nebuchadnezzar II
Map Script: NEF: GetID(): 22 playerStartPlot: x- 19 y- 3 GetLeaderType(): 3 GetMinorCivTrait(): 2 Team: 22 Personality: -1 PersonalityType: 3 Playable: 0 GetName(): Cape Town
Map Script: NEF: GetID(): 23 playerStartPlot: x- 15 y- 16 GetLeaderType(): 3 GetMinorCivTrait(): 1 Team: 23 Personality: -1 PersonalityType: 3 Playable: 0 GetName(): Edinburgh
Map Script: NEF: GetID(): 24 playerStartPlot: x- 10 y- 16 GetLeaderType(): 3 GetMinorCivTrait(): 2 Team: 24 Personality: -1 PersonalityType: 3 Playable: 0 GetName(): Copenhagen
Map Script: NEF: GetID(): 25 playerStartPlot: x- 24 y- 3 GetLeaderType(): 3 GetMinorCivTrait(): 0 Team: 25 Personality: -1 PersonalityType: 3 Playable: 0 GetName(): Monaco
Map Script: NEF: GetID(): 26 playerStartPlot: x- 4 y- 8 GetLeaderType(): 3 GetMinorCivTrait(): -1 Team: 26 Personality: -1 PersonalityType: 3 Playable: 1 GetName(): Barbarian
Map Script: -------------------------------
 
I can try to use LUA commands

table.remove (table [, pos])

and

table.insert (table, [pos,] value)

but how to get players table description needed for table.insert (table, [pos,] value)? How to set values sentence?
 
I'll like to find a way to do it, I fear that AddPlayer works only for major civs :/
 
if I remember corretly my tests, in pregame addplayer is nil and using PreGame.SetCivilization(playerID, civ.ID) works only for major civs, using PreGame.SetCivilization(playerID, 18) crash the game (with playerID > 22 and 18=CIVILIZATION_MINOR ).

To allow a selection of CS in game, I set the max number of CS in pregame to #GameInfo.MinorCivilizations, then I delete the unwanted CS ingame at start. I suppose that the deleted CS could be reused during game, but we're limited by GameDefines.MAX_PLAYERS, if we have 60 CS in minorcivilisations, only 40 randomly selected will be available in game...
 
if I remember corretly my tests, in pregame addplayer is nil and using PreGame.SetCivilization(playerID, civ.ID) works only for major civs, using PreGame.SetCivilization(playerID, 18) crash the game (with playerID > 22 and 18=CIVILIZATION_MINOR ).

To allow a selection of CS in game, I set the max number of CS in pregame to #GameInfo.MinorCivilizations, then I delete the unwanted CS ingame at start. I suppose that the deleted CS could be reused during game, but we're limited by GameDefines.MAX_PLAYERS, if we have 60 CS in minorcivilisations, only 40 randomly selected will be available in game...

Could you paste code?, How do you set max CS and delete unwanted?
 
It's in my Earth Maps Pack.

I'm using a custom setup to change the option before game launch, see YnaemSetup.lua

In short, I set the num of minor to load to max
Code:
PreGame.SetNumMinorCivs(#GameInfo.MinorCivilizations)
then at first turn I kill the settlers of the CS I don't want ingame.

problem is that the max loaded CS is (MAX_CIV_PLAYERS - MAX_MAJOR_CIVS) = 41

if you have more in the MinorCivilizations table, then only 41 randomly selected will be ingame.

to do a true selection, I'm going to test DB change during game setup with that : http://forums.civfanatics.com/showpost.php?p=9951011&postcount=9

if I can put only the wanted CS in the MinorCivilizations table, then my problem is solved.

I guess that you want to add CS during game, I suppose that once you load the max selection, if you "kill" some at first turn, you can "revive" them later using lua.
 
EURECA :) it is how you can add or delete CS

self.city_state_validity_table[cs_number] = true; -- This is the line that marks a city state as valid to be processed by the rest of the system.

EDIT:
IS is valid only for AssignStartingPlots.lua :(
 
Game.AddPlayer(2, 13, 11); --2 next free player index, 11japan, 13oda
Game.AddPlayer(26, 3, 11); --26 next free player index, 3minor 11helsinki

Just at a glance, you've got the arguments wrong on the Helsinki call. The order is player ID, leader type, civ type; the Japan is correct, but you've swapped the 3 and 11 on the second one (civ type is Minor); what you'd create with that call was a Japan with leader #3.

Haven't actually tried it, so I don't know if you CAN add a city-state with that function; I'm just saying that the two calls you made weren't consistent.
 
Just at a glance, you've got the arguments wrong on the Helsinki call. The order is player ID, leader type, civ type; the Japan is correct, but you've swapped the 3 and 11 on the second one (civ type is Minor); what you'd create with that call was a Japan with leader #3.

Haven't actually tried it, so I don't know if you CAN add a city-state with that function; I'm just saying that the two calls you made weren't consistent.

hmm, good point it could work. minor as civ and city as leader. I cant check it at the moment but i will do it ASAP

i will test sth like that:

Game.AddPlayer(26, 11, 18); -- 11=helsniki/ 18=minor civ

i'm not sure if civ type for minor = 18?
 
Back
Top Bottom