Well, I decided to write this tutorial for create an emerging faction using the Barons Alliance script. First, I must give credit to CeltiberoRamiroI, who helped me with the final step. This tutorial is for any Kingdoms's mod.
Necessary files
-Descr_sm_factions (Found in Data)
-Campaign_script (Found in Data/World/Maps/Campaign/Campaign_name
-Descr_strat (Found in Data/World/Maps/Campaign/Campaign_name
Steps
1) First, we have to decide which faction will emerge and from which other faction will do it. For example, I made emergent Portugal from Galicia (scotland) in Reconquista's mod.
2) The second step is go to descr_sm_factions and add to the faction that will emerge "Shadowing faction from where will emerge" and to the faction from where the other faction will emerge "Shadowed_by faction who will emerge" near the faction name. In my case is:
Code:
faction scotland, shadowed_by portugal
culture southern_european
religion catholic
symbol models_strat/symbol_scotland.CAS
rebel_symbol models_strat/symbol_rebels.CAS
primary_colour red 39, green 118, blue 216
secondary_colour red 243, green 219, blue 13
loading_logo loading_screen/symbols/symbol128_scotland.tga
standard_index 6
logo_index FACTION_LOGO_SCOTLAND
small_logo_index SMALL_FACTION_LOGO_SCOTLAND
triumph_value 5
custom_battle_availability yes
can_sap yes
prefers_naval_invasions yes
can_have_princess yes
has_family_tree yes
And for Portugal, faction who will emerge:
Code:
faction portugal, shadowing scotland
culture southern_european
religion catholic
symbol models_strat/symbol_portugal.CAS
rebel_symbol models_strat/symbol_rebels.CAS
primary_colour red 255, green 255, blue 255
secondary_colour red 0, green 0, blue 255
loading_logo loading_screen/symbols/symbol128_portugal.tga
standard_index 13
logo_index FACTION_LOGO_PORTUGAL
small_logo_index SMALL_FACTION_LOGO_PORTUGAL
triumph_value 5
custom_battle_availability yes
can_sap yes
prefers_naval_invasions yes
can_have_princess yes
has_family_tree yes
Warning: The factions should have a same culture and units in common (as a minim the bodyguard type).
3) Once done that, we will add an entry in descr_strat to the faction who will emerge:
Code:
faction portugal, balanced smith
ai_label catholic
dead_until_emerged
re_emergent
denari 15000
denari_kings_purse 3000
We must add some units to new faction too, then we must add units to the faction from where the new faction will emerge generals, and quite disloyals, in my case, to scotland (Galicia):
Code:
character John, named character, male, age 27, x 83, y 169
traits GoodRiskyAttacker 1 , NaturalMilitarySkill 1 , GoodCommander 1 , BattleDread 2 , StrategyDread 1 , LoyaltyStarter 1
army
unit SE Bodyguard exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
character George, named character, label portugal1, male, age 25, x 70, y 165
traits GoodRiskyAttacker 1 , BattleDread 2 , StrategyDread 1 , LoyaltyStarter 1
army
unit SE Bodyguard exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
unit Town Militia exp 0 armour 0 weapon_lvl 0
The generals are governors of the regions of Porto and Viseu.
4) We have to go now to campaign_script. The original script from Britannias campaign says this:
Code:
monitor_event FactionTurnEnd FactionType england
and I_NumberOfSettlements england > 15
and I_CompareCounter ba_first_emergence = 1
and I_NumberOfSettlements barons_alliance = 0
and I_EventCounter ba_last_spawn_timer > 10
generate_random_counter authority_value 1 100
;the lower the faction leaders authority, the greater the chance of the barons_alliance appearing
if I_FactionLeaderAttribute england Authority = 0
if I_EventCounter authority_value <= 33
faction_emerge barons_alliance england 5 50.0 145.0 0.9 town false
end_if
end_if
if I_FactionLeaderAttribute england Authority = 1
if I_EventCounter authority_value <= 25
faction_emerge barons_alliance england 6 60.0 135.0 0.9 town false
end_if
end_if
if I_FactionLeaderAttribute england Authority = 2
if I_EventCounter authority_value <= 20
faction_emerge barons_alliance england 6 65.0 130.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute england Authority = 3
if I_EventCounter authority_value <= 15
faction_emerge barons_alliance england 6 70.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute england Authority = 4
if I_EventCounter authority_value <= 10
faction_emerge barons_alliance england 6 80.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute england Authority = 5
if I_EventCounter authority_value <= 5
faction_emerge barons_alliance england 6 85.0 120.0 0.85 town false
end_if
end_if
if I_NumberOfSettlements barons_alliance > 0
set_event_counter ba_last_spawn_timer 0
historic_event barons_reemerge_poor_king
add_money barons_alliance 10000
end_if
end_monitor
I summed it up and changed the names, England by Scotland and Barons_alliance by Portugal, so:
Code:
declare_counter portugal_emerge
monitor_event and I_TurnNumber > 1
and I_TurnNumber < 5
and I_CompareCounter portugal_emerge == 0
faction_emerge portugal scotland 4 80.0 120.0 0.85 town false
if I_NumberOfSettlements portugal > 0
add_money portugal 10000
set_counter portugal_emerge 1
end_if
historic_event portugal_emerges
end_monitor
;check when English leaders authority is low
monitor_event FactionTurnEnd FactionType scotland
and I_NumberOfSettlements scotland > 2
and I_NumberOfSettlements portugal = 0
generate_random_counter authority_value 1 100
;the lower the faction leaders authority, the greater the chance of the portugal appearing
if I_FactionLeaderAttribute scotland Authority = 0
if I_EventCounter authority_value <= 33
faction_emerge portugal scotland 4 80.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute scotland Authority = 1
if I_EventCounter authority_value <= 25
faction_emerge portugal scotland 4 100.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute scotland Authority = 2
if I_EventCounter authority_value <= 20
faction_emerge portugal scotland 4 100.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute scotland Authority = 3
if I_EventCounter authority_value <= 15
faction_emerge portugal scotland 4 90.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute scotland Authority = 4
if I_EventCounter authority_value <= 10
faction_emerge portugal scotland 4 90.0 120.0 0.85 town false
end_if
end_if
if I_FactionLeaderAttribute scotland Authority = 5
if I_EventCounter authority_value <= 5
faction_emerge portugal scotland 4 80.0 120.0 0.85 town false
end_if
end_if
end_monitor
Portugal will emerge between the turn 1 and 5, and the script valores the authority of every general and according with it, gives different parameters to the future emergence (is it said like this?):
Code:
if I_FactionLeaderAttribute scotland Authority = 4
if I_EventCounter authority_value <= 10
faction_emerge portugal scotland 4 90.0 120.0 0.85 town false
end_if
If the leader authority is equal to 4, Portugal will emerge with the following parameters:
Code:
faction_emerge portugal scotland 4 90.0 120.0 0.85 town false
And they mean:
emerging_faction: portugal
target_faction: scotland
min_num_remain: 4 (Min of settlements that must keep the faction from where the emerging faction will emerge).
max_order_threshold: 90 (Maximum of public order allowed for the regions where will emerge the new faction, if the public order is more that 70 in this case, the faction will not emerge).
max_order_threshold_surrounding: 120 (The maximum order of the neightbour regions can't be larger than 120 for acheive the emerge).
max_order_dropoff: 0.85 (I don't know its meaning yet)
min_level_threshold: town (Minim level of the settlements where can emerge the new faction).
fire_emerge_message: false
leader_script_label: not used (optional)
leader_name: not used (optional)
leader_age: not used (optional)
(Thanks to CeltiberoRamiroI for his gelp giving me the meaning of the numbers).
Here, Porto region before the emerge:
Now, after Portugal has emerged:
I hope you liked this tutorial.