################################################################################
#
# Societies 社團
# https://ck2.paradoxwikis.com/Society_modding
#
################################################################################
#
# 在2.7增加的新系統
# 社團十分適合模擬一個職業或生活方式，因為一個角色同時只能是一個社團的成員
# 參考：..\common\societies\*
#
################################################################################
########################################
# 結構
########################################
<society_name> = {
	primary_attribute = stewardship
	is_religious = yes
	opinion_to_other_members = +10
	opinion_per_rank_above = +5
	sound = monastic_orders_interface
	society_ranks_gfx = monk_ranks
	non_interference = {
		always = yes
	}
	
	active = {
		has_dlc = "Mystics"
	}
	indestructible = yes

	can_join_society = {
		hidden_trigger = {
			NAND = {
				ai = yes
				is_society_rank_full = { 
					society = <society_name>
					rank = 1
				}
			}
		}
		age = 16
		OR = {
			religion = catholic
			AND = {
				is_heretic = no
				OR = {
					religion = fraticelli
					religion = waldensian
					religion = lollard
					religion = cathar
				}
			}
		}
		NOT = { trait = excommunicated }
		custom_tooltip = {
			text = did_not_betray_society
			NOT = { has_character_flag = betrayed_<society_name> }
		}
		scaled_wealth = 0.25
	}
	
	show_society = {
		OR = {
			religion = catholic
			AND = {
				is_heretic = no
				OR = {
					religion = fraticelli
					religion = waldensian
					religion = lollard
					religion = cathar
				}
			}
		}
	}
	
	potential = {
		OR = {
			religion = catholic
			AND = {
				is_heretic = no
				OR = {
					religion = fraticelli
					religion = waldensian
					religion = lollard
					religion = cathar
				}
			}
		}
	}
	
	society_rank = {
		level = 1
		limit = 100 
		startup_limit = 10
		modifier = {
			monthly_character_piety = 0.05
			fertility = -0.15
		}
	}
	
	society_rank = {
		level = 2
		limit = 50
		startup_limit = 6
		modifier = { 
			monthly_character_piety = 0.1
			stewardship = 1
			fertility = -0.15
		}
		decisions = {
			monastic_orders_go_celibate #Power: toggle celibacy
			monastic_orders_stop_celibate
		}
	}
	
	society_rank = {
		level = 3
		limit = 25 
		startup_limit = 3
		modifier = {
			monthly_character_piety = 0.2
			stewardship = 2
			build_cost_temple_modifier = -0.25
			fertility = -0.15
		}
		decisions = {
			monastic_orders_invite_ascetic

		}
	}

	society_rank = { #todo add counselling power
		level = 4
		limit = 5
		startup_limit = 1
		modifier = { 
			monthly_character_piety = 0.5
			stewardship = 3
			build_cost_temple_modifier = -0.5 
			fertility = -0.15
		}
		custom_tooltip = benedictine_power_diligent_tt
	}

	monthly_currency_gain = {
		name = currency_name_<society_name>
    	
    	per_attribute = {
    		name = stewardship
    		value = 0.5
    	}
    	has_trait = {
			trait = monk
			value = 5
		}
		has_trait = {
			trait = nun
			value = 5
		}
		has_trait = {
			trait = diligent
			value = 3
		}
		has_trait = {
			trait = celibate
			value = 3
		}
    	has_trait = {
			trait = chaste
			value = 3
		}
		has_trait = {
			trait = temperate
			value = 3
		}
		has_trait = {
			trait = charitable
			value = 1
		}
		has_trait = {
			trait = kind
			value = 1
		}
		has_trait = {
			trait = patient
			value = 1
		}
		has_trait = {
			trait = humble
			value = 1
		}
		has_trait = {
			trait = zealous
			value = 1
		}
		has_trait = {
			trait = honest
			value = 1
		}
		has_trait = {
			trait = erudite
			value = 1
		}
		has_trait = {
			trait = pilgrim
			value = 1
		}
		has_trait = {
			trait = theologian
			value = 1
		}
		has_trait = {
			trait = gardener
			value = 1
		}
		society_rank = {
			rank = 4
			value = 10
		}
	}

	member_score_per_attribute = 3
	member_score_per_rank = 100

	member_score = {
		value = 10

		modifier = {
			is_priest = yes
			factor = 10
		}
		modifier = {
			trait = monk
			factor = 5
		}
		modifier = {
			trait = nun
			factor = 5
		}
		modifier = {
			trait = diligent
			factor = 1.3
		}
		modifier = {
			trait = celibate
			factor = 1.3
		}
    	modifier = {
			trait = chaste
			factor = 1.3
		}
		modifier = {
			trait = temperate
			factor = 1.3
		}
		modifier = {
			trait = charitable
			factor = 1.1
		}
		modifier = {
			trait = kind
			factor = 1.1
		}
		modifier = {
			trait = patient
			factor = 1.1
		}
		modifier = {
			trait = humble
			factor = 1.1
		}
		modifier = {
			trait = zealous
			factor = 1.1
		}
		modifier = {
			trait = honest
			factor = 1.1
		}
		modifier = {
			trait = erudite
			factor = 1.1
		}
		modifier = {
			trait = pilgrim
			factor = 1.1
		}
		modifier = {
			trait = theologian
			factor = 1.1
		}
		modifier = {
			trait = gardener
			factor = 1.1
		}
	}
	
	startup_populate = {
	    trigger = {
			ai = yes
	    	controls_religion = no
		   	religion = catholic
			age = 16
			is_in_society = no
			NOT = { higher_tier_than = DUKE }
			NOR = {
				mercenary = yes
				holy_order = yes
			}
			NOT = { trait = cynical }
			NOT = { trait = excommunicated }
			has_secret_religion_trait_trigger = no
			OR = {
				trait = zealous
				trait = scholar
				trait = theologian
				trait = gardener
				trait = monk
				trait = nun
				learning = 16
				is_priest = yes
			}
		}
	}
}

########################################
# 旗標
########################################
在大多數的觸發中，FROM 是社團
其中在位階修飾語中的 is_visible 以及 non_interference 和 obedient 是例外
可以使用 same_society 代替

<society_name>
社團名稱。需本地化

active
社團的啟動條件。ROOT是社團
Determine if the society is active. If not met, it will be impossible to see or join the society, and no members will be generated for it at game start, and all existing members will be booted out of it within a month. Note that events and the like that reference the society will continue to act as if the society existed normally. Note that the conditions for this trigger are not shown in the UI anywhere, so you may want a global event or similar if this is something that can happen *during* a campaign
類型：條件
例子：active = { has_dlc = "Mystics" }

ambitions
類型：從句
例子：
ambitions = {
	ambition1_tag
	ambition2_tag
}

can_join_society
加入條件
類型：條件
例子：can_join_society = { age = 16 }

primary_attribute
類型：diplomacy、martial、stewardship、intrigue、learning

potential
角色留在社團的條件。被認為是 can_join_society 的子集
類型：條件
例子：

criminal
是不道德類型
類型：布爾值

decisions
提示該社團位階可用決策（用於 society_rank）
類型：決策
例子：decisions = { monastic_orders_stop_celibate }

devil_worshipper
是魔鬼崇拜者類型（也用於抑制對其他成員的不同宗教意見修飾語）
類型：布爾值

indestructible
是不可摧毀
不可摧毀的社團會使用 startup_populate 觸發尋找一個角色領導社團
它會尋找所有角色中將會有最高成員分數的角色，有地角色的分數會降低到1/100
如果沒有符合的角色，on-action 的 on_society_failed_to_find_new_leader 將會觸發
類型：布爾值

is_religious
是宗教類型（用於意見數值）
類型：布爾值

is_secret
是祕密類型（no為社團服裝對非成員也可見）
類型：布爾值

member_score
基於觸發的成員分數。ROOT是成員
類型：MTTH
例子：
member_score = {
	value = 10
	modifier = {
		is_priest = yes
		factor = 10
	}
}

member_score_per_attribute
每一點社團屬性得到的成員分數
類型：浮點數
例子：member_score_per_attribute = 3

member_score_per_rank
每位階得到的成員分數
類型：整數
例子：member_score_per_rank = 100

monthly_currency_gain
每月currency。currency是因社團而異。需本地化
類型：從句
例子：
monthly_currency_gain = {
	name = currency_name_<society_name>
	per_attribute = {
		name = stewardship
		value = 0.5
	}
	has_trait = {
		trait = monk
		value = 5
	}
	society_rank = {
		rank = 4
		value = 10
	}
}

non_interference
不干擾另一個角色（不會對另一個角色進行敵對行動）（ROOT是外交互動目標，FROM是執行者）
類型：條件
例子：non_interference = { FROM = { same_realm = ROOT } }

non_interference_tooltip
本地化鍵值在 influence 下顯示，說明甚麼角色是不干擾
類型：本地化
例子：

obedient
服從。和 obedience_tooltip 一起使用（用於 society_rank）
類型：從句
例子：
obedient = {
	ROOT = {
		always = yes
	}
}

obedience_tooltip
服從提示。和 obedient 一起使用（用於 society_rank）
類型：obedience_tooltip
例子：obedience_tooltip = obedience_tooltip #this can be unique per rank/society 

opinion_to_other_members
對其他成員的意見
類型：整數
例子：opinion_to_other_members = +10

opinion_to_perceived_members
非成員對被認為是成員的角色的意見
類型：整數
例子：opinion_to_perceived_members = +10

opinion_to_pretenders
對被認為是成員（但實際上不是）的角色的意見
類型：整數
例子：opinion_to_pretenders = -40

opinion_per_rank_above
對比自己位階更高的成員的意見（每級疊加，參考例子中的+5即4級成員對1級成員有+15的意見加成）
類型：整數
例子：opinion_per_rank_above = +5

plots
類型：從句
例子：
plots = {
	plot1_tag
	plot2_tag
}

show_society
對符合條件的角色顯示社團
類型：條件
例子：show_society = { trait = secretly_orthodox }

society_rank
社團位階
參數：
level # 整數。社團位階等級
limit # 整數。該位階的最大成員數（通過 is_society_rank_full 條件檢查）
startup_limit # 整數。在 startup_populate 的過程中選擇成員的最大數量
modifier # 從句。該位階的增／減益
decisions # 決策。在該位階解鎖的決策
custom_tooltip # 本地化。Localisation key for modifiers in society ranks that is localized and added to the tooltip for rank icons
obedient # 條件。ROOT是該位階擁有者，FROM是潛在服從的角色。定義AI社團成員對該位階成員的服從條件
obedience_tooltip # 本地化。提示甚麼角色會服從該位階的角色
類型：從句
例子：modifier = { fertility = -0.15 }
類型：整數
類型：從句
例子：
society_rank = {
	level = 1
	limit = 100 
	startup_limit = 10
	modifier = {
		monthly_character_piety = 0.05
		fertility = -0.15
	}
}

society_ranks_gfx
社團位階圖像（參考：..\interface\domestic_societies.gfx 和 ..\gfx\interface\societies\*）
類型：gfx
例子：society_ranks_gfx = monk_ranks

society_rank_up_decision
成團成員上升位階的決策（？）
類型：決策
例子：society_rank_up_decision = request_to_rank_up_within_society

sound
在社團介面選擇指定社團時演奏的音樂（參考：..\interface\sound.sfx）
類型：sfx
例子：sound = monastic_orders_interface

startup_populate
用於在遊戲開始時尋找領導和加入社團的角色
類型：從句
例子：
startup_populate = {
	trigger = {
		ai = yes
		age = 16
	}
}

template
是樣版社團（參考：dynamic_cult_template）
類型：布爾值
例子：

associated_religion
相關宗教（設定後可作為範圍對照？）（參考：..\common\religions\*）
類型：宗教
例子：associated_religion = catholic

is_visible
是可見於其他角色。預設為可見（ROOT是觀察者，FROM是擁有者）
數值：從句
例子1：is_visible = { character = FROM }
例子2：
is_visible = {
	OR = {
		society_member_of = the_assassins
		character = FROM
	}
}

########################################
# 本地化
########################################
<society_name>
社團名稱（本地化參數 GetSocietyName / GetSocietyNameCap）
（參考：..\localisation\customizable_localisation\*）

<society_name>_desc
社團描述

<society_name>_leader_desc
社團領導者的描述

<society_name>_rank_<value>_female
社團女性成員位階稱呼（value = 1-4）（本地化參數 GetSocietyRank）
（參考：..\localisation\customizable_localisation\*）

<society_name>_rank_<value>_male
社團男性成員位階稱呼（value = 1-4）（本地化參數 GetSocietyRank）
（參考：..\localisation\customizable_localisation\*）

currency_name_<society_name>
社團的currency名稱（本地化參數 GetSocietyCurrency）
（參考：..\localisation\customizable_localisation\*）

注意：這些本地化指令也需要更新
GetSocietyCurrency, GetSocietyRank, GetSocietyName 和 GetSocietyNameCap

########################################
# 社團介面 個人補充
# 缺少相關圖片將不會在社團介面顯示
# 參考：..\interface\domestic_societies.gfx
########################################
以一個遊戲存在的社團作為基礎樣版，例如：monastic_order_benedictine

在該檔案裏搜尋 monastic_order_benedictine

將全部已登陸的名稱的前綴為 GFX_ 的該行的關鍵字改為社團名稱 <society_name>
下方的 texturefile 則為社團相關的圖像，如果不使用自訂圖像可以使用原版遊戲提供的
（參考：..\interface\societies\*）

########################################
# 詢問加入社團 個人補充
########################################
從社團介面加入一個社團需要透過點擊按鈕加入
點擊後會觸發在 on_action 的 on_character_ask_to_join_society 的事件
如果沒有在 on_character_ask_to_join_society 增加一個加入社團的事件，點擊按鈕後不會有任何反應
（參考：205_Event）

################################################################################
#
# Quests 任務
#
################################################################################
任務是通過腳本動態創建
任務擁有者必須是社團成員。任務目標可以是角色、省份、頭銜或者沒有

給予一個角色沒有目標的任務：
set_quest = <quest_id>

將一個對象設定為任務目標：
set_quest_target = {
	id = <quest_id>
	holder = ROOT # 得到任務的角色
}

這也可以用於設定或更新任務目標
任務的結果可以設定為：
成功時使用 clr_quest = <quest_id>
失敗時使用 clr_quest = { id = <quest_id> failure = yes }

獎勵需要通過事件腳本管理
使用 change_society_currency 指令獎勵任務擁有者在社團中擁有更多的權力

########################################
# 本地化
########################################
<quest_id>
任務名稱

<quest_id>_fallback
name of the quest if no target is found. Useful if your loc depends on the target. Needed to ensure it shows up nicely in triggers (E.G., "Evoke the Sympathy of [FromFrom.GetTitledFirstName]" would fail in a trigger if you don't have a quest, so you add a fallback of "Evoke the Sympathy of a Ruler"). Adding "_fallback" will work for the other loc keys too, so can be used if you have different versions of the same quest where not all versions target something

<quest_id>_desc
更長的任務描述。可以使用 $SOCIETY$ 作為社團（如有）、$WHO$ 作為執行任務的角色、$TARGET$ 作為任務的目標（如有）

<quest_id>_tooltip
任務工具提示。可以使用 $SOCIETY$ 作為社團（如有）、$WHO$ 作為執行任務的角色、$TARGET$ 作為任務的目標（如有）
