本帖最后由 杰喵喵 于 2022-11-10 21:59 编辑
代码思路,定时器设定到一定天数,激活入侵阵营,在特定地图坐标创建阵营的领主队伍。战团代码本身代码,当阵营非激活情况下,领主会叛变,同时没有据点的阵营的领主会进入失去目标状态。因此代码需要做到,1.修改原来代码让非激活阵营领主不叛变,同时不在地图上创建非激活阵营领主;2.给入侵阵营设置隐秘的据点,在入侵的时候变成正常据点。3.入侵的时候在特定地图坐标创建阵营的领主队伍,并且添加部队。
1.首先创建阵营与入侵阵营隐秘据点代码这里省略。module_script中"游戏开始"初始化阵营,设置国王等,中间部分代码省略!!!。- #script_game_start:
- # This script is called when a new game is started
- # INPUT: none
- ("game_start",
- [
-
-
- (faction_set_slot, "fac_kingdom_undead", slot_faction_state, sfs_inactive),#入侵阵营状态为失能
- (party_set_flags, "p_castle_51", pf_disabled, 1),#入侵阵营的隐藏城堡 设置无效状态
- (party_set_flags, "p_castle_52", pf_disabled, 1),#入侵阵营的隐藏城堡 设置无效状态
-
- ]),
复制代码
2.在module_simple_ttrigger中 "个人领主政治算计" 1061行中代码进行修改,参考我修改好的部分
- #Individual lord political calculations
- #Check for lords without fiefs, auto-defections, etc
- (0.5,
- [
- (val_add, "$g_lord_long_term_count", 1),
- (try_begin),
- (neg|is_between, "$g_lord_long_term_count", "trp_kingdom_heroes_including_player_begin", active_npcs_end),
- (assign, "$g_lord_long_term_count", "trp_kingdom_heroes_including_player_begin"),
- (try_end),
- (assign, ":troop_no", "$g_lord_long_term_count"),
-
- (try_begin),
- (eq, ":troop_no", "trp_kingdom_heroes_including_player_begin"),
- (assign, ":troop_no", "trp_player"),
- (try_end),
- (try_begin),
- (eq, "$cheat_mode", 1),
- (str_store_troop_name, s9, ":troop_no"),
- (display_message, "@{!}DEBUG -- Doing political calculations for {s9}"),
- (try_end),
-
- #Penalty for no fief
- (try_begin),
- (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
- (neq, ":troop_no", "trp_player"),
-
- (assign, ":fief_found", -1),
- (try_for_range, ":center", centers_begin, centers_end),
- (party_slot_eq, ":center", slot_town_lord, ":troop_no"),
- (assign, ":fief_found", ":center"),
- (try_end),
-
- (try_begin),
- (eq, ":fief_found", -1),
-
- (store_faction_of_troop, ":original_faction", ":troop_no"),
- (faction_get_slot, ":faction_leader", ":original_faction", slot_faction_leader),
- (troop_get_slot, ":troop_reputation", ":troop_no", slot_lord_reputation_type),
-
- (try_begin),
- (neq, ":faction_leader", ":troop_no"),
- (try_begin),
- (this_or_next|eq, ":troop_reputation", lrep_quarrelsome),
- (this_or_next|eq, ":troop_reputation", lrep_selfrighteous),
- (this_or_next|eq, ":troop_reputation", lrep_cunning),
- (eq, ":troop_reputation", lrep_debauched),
- (call_script, "script_troop_change_relation_with_troop", ":troop_no", ":faction_leader", -4),
- (val_add, "$total_no_fief_changes", -4),
- (else_try),
- (eq, ":troop_reputation", lrep_martial),
- (call_script, "script_troop_change_relation_with_troop", ":troop_no", ":faction_leader", -2),
- (val_add, "$total_no_fief_changes", -2),
- (try_end),
- (try_end),
- (try_end),
- (try_end),
-
- #Auto-indictment or defection
- (try_begin),
- (this_or_next|troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
- (eq, ":troop_no", "trp_player"),
- (try_begin),
- (eq, ":troop_no", "trp_player"),
- (assign, ":faction", "$players_kingdom"),
- (else_try),
- (store_faction_of_troop, ":faction", ":troop_no"),
- (try_end),
- (faction_get_slot, ":faction_leader", ":faction", slot_faction_leader),
- (neq, ":troop_no", ":faction_leader"),
-
- #I don't know why these are necessary, but they appear to be
- (neg|is_between, ":troop_no", "trp_kingdom_1_lord", "trp_knight_1_1"),
- (neg|is_between, ":troop_no", pretenders_begin, pretenders_end),
-
- (assign, ":num_centers", 0),
- (try_for_range,":cur_center", walled_centers_begin, walled_centers_end),
- (store_faction_of_party, ":faction_of_center", ":cur_center"),
- (eq, ":faction_of_center", ":faction"),
- (val_add, ":num_centers", 1),
- (try_end),
- #we are counting num_centers to allow defection although there is high relation between faction leader and troop.
- #but this rule should not applied for player's faction and player_supporters_faction so thats why here 1 is added to num_centers in that case.
- (try_begin),
- (this_or_next|eq, ":faction", "$players_kingdom"),
- (eq, ":faction", "fac_player_supporters_faction"),
- (val_add, ":num_centers", 1),
- (try_end),
-
- (call_script, "script_troop_get_relation_with_troop", ":troop_no", ":faction_leader"),
- (this_or_next|le, reg0, -90), #was -75
- (eq, ":num_centers", 0), #if there is no walled centers that faction has defection happens 100%.
- (call_script, "script_cf_troop_can_intrigue", ":troop_no", 0), #Should include battle, prisoner, in a castle with others
- (store_random_in_range, ":who_moves_first", 0, 2),
-
- (try_begin),
- (this_or_next|eq, ":num_centers", 0), #Thanks Caba`drin & Osviux
- (neq, ":who_moves_first", 0),
- (neq, ":troop_no", "trp_player"),
-
- #do a defection
- (try_begin),
- (neq, ":num_centers", 0),
- (assign, "$g_give_advantage_to_original_faction", 1),
- (try_end),
- #(assign, "$g_give_advantage_to_original_faction", 1),
-
- (store_faction_of_troop, ":orig_faction", ":troop_no"),
- #################修改非激活阵营不开启领主叛逃-开始#############################################
- (try_begin),
- (neg|faction_slot_eq, ":orig_faction", slot_faction_state, sfs_inactive),
- (call_script, "script_lord_find_alternative_faction", ":troop_no"),
- (assign, ":new_faction", reg0),
- (assign, "$g_give_advantage_to_original_faction", 0),
- (else_try),
- (assign, ":new_faction", ":orig_faction"),
- (try_end),
- #################修改非激活阵营-结束#############################################
-
- (try_begin),
- (neq, ":new_faction", ":orig_faction"),
-
- (is_between, ":new_faction", kingdoms_begin, kingdoms_end),
- (str_store_troop_name_link, s1, ":troop_no"),
- (str_store_faction_name_link, s2, ":new_faction"),
- (str_store_faction_name_link, s3, ":faction"),
- (call_script, "script_change_troop_faction", ":troop_no", ":new_faction"),
- (try_begin),
- (ge, "$cheat_mode", 1),
- (str_store_troop_name, s4, ":troop_no"),
- (display_message, "@{!}DEBUG - {s4} faction changed in defection"),
- (try_end),
- (troop_get_type, reg4, ":troop_no"),
- (str_store_string, s4, "str_lord_defects_ordinary"),
- (display_log_message, "@{!}{s4}"),
- (try_begin),
- (eq, "$cheat_mode", 1),
- (this_or_next|eq, ":new_faction", "$players_kingdom"),
- (eq, ":faction", "$players_kingdom"),
- (call_script, "script_add_notification_menu", "mnu_notification_lord_defects", ":troop_no", ":faction"),
- (try_end),
- (try_end),
- (else_try),
- (neq, ":faction_leader", "trp_player"),
- (call_script, "script_troop_get_relation_with_troop", ":troop_no", ":faction_leader"),
- (le, reg0, -50), #was -75
- (call_script, "script_indict_lord_for_treason", ":troop_no", ":faction"),
- (try_end),
- (else_try), #Take a stand on an issue
- (neq, ":troop_no", "trp_player"),
- (store_faction_of_troop, ":faction", ":troop_no"),
- (faction_slot_ge, ":faction", slot_faction_political_issue, 1),
- #This bit of complication is needed for savegame compatibility -- if zero is in the slot, they'll choose anyway
- (neg|troop_slot_ge, ":troop_no", slot_troop_stance_on_faction_issue, 1),
- (this_or_next|troop_slot_eq, ":troop_no", slot_troop_stance_on_faction_issue, -1),
- (neq, "$players_kingdom", ":faction"),
- (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
- (call_script, "script_npc_decision_checklist_take_stand_on_issue", ":troop_no"),
- (troop_set_slot, ":troop_no", slot_troop_stance_on_faction_issue, reg0),
- (try_end),
- (try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
- (call_script, "script_troop_get_relation_with_troop", ":troop_no", ":active_npc"),
- (lt, reg0, 0),
- (assign, ":relation", reg0),
- (store_sub, ":chance_of_convergence", 0, ":relation"),
- (store_random_in_range, ":random", 0, 300),
- (lt, ":random", ":chance_of_convergence"),
- (call_script, "script_troop_change_relation_with_troop", ":troop_no", ":active_npc", 1),
- (val_add, "$total_relation_changes_through_convergence", 1),
- (try_end),
- ]),
复制代码 3.在module_simple_ttrigger中"王国英雄从囚禁中释放后重生英雄队伍"- # Respawn hero party after kingdom hero is released from captivity.
- (48,
- [
- (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
- (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
- (str_store_troop_name, s1, ":troop_no"),
-
- (neg|troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0),
- (neg|troop_slot_ge, ":troop_no", slot_troop_leaded_party, 1),
- (store_troop_faction, ":cur_faction", ":troop_no"),
- (try_begin),
- (eq, ":cur_faction", "fac_outlaws"), #Do nothing
- ####################无效阵营不工作#########
- (else_try),
- (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_inactive),#Do nothing
- ###########################################
- (else_try),
- (try_begin),
- (eq, "$cheat_mode", 2),
- (str_store_troop_name, s4, ":troop_no"),
- (display_message, "str_debug__attempting_to_spawn_s4"),
- (try_end),
-
- (call_script, "script_cf_select_random_walled_center_with_faction_and_owner_priority_no_siege", ":cur_faction", ":troop_no"),#Can fail
- (assign, ":center_no", reg0),
- (try_begin),
- (eq, "$cheat_mode", 2),
- (str_store_party_name, s7, ":center_no"),
- (str_store_troop_name, s0, ":troop_no"),
- (display_message, "str_debug__s0_is_spawning_around_party__s7"),
- (try_end),
-
- (call_script, "script_create_kingdom_hero_party", ":troop_no", ":center_no"),
- (try_begin),
- (eq, "$g_there_is_no_avaliable_centers", 0),
- (party_attach_to_party, "$pout_party", ":center_no"),
- (try_end),
-
- #new
- #(troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
- #(call_script, "script_npc_decision_checklist_party_ai", ":troop_no"), #This handles AI for both marshal and other parties
- #(call_script, "script_party_set_ai_state", ":party_no", reg0, reg1),
- #new end
- (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
- (call_script, "script_party_set_ai_state", ":party_no", spai_holding_center, ":center_no"),
-
- (else_try),
- (neg|faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active),
- (try_begin),
- (is_between, ":troop_no", kings_begin, kings_end),
- (troop_set_slot, ":troop_no", slot_troop_change_to_faction, "fac_commoners"),
- (else_try),
- (store_random_in_range, ":random_no", 0, 100),
- (lt, ":random_no", 10),
- (call_script, "script_cf_get_random_active_faction_except_player_faction_and_faction", ":cur_faction"),
- (troop_set_slot, ":troop_no", slot_troop_change_to_faction, reg0),
- (try_end),
- (try_end),
- (try_end),
- ]),
复制代码 4.在module_ttrigger中写入代码,激活入侵阵营,创建国王与领主部队,领主部队代码省略,隐藏城堡激活,给予国王。
-
- (1, 24*50, ti_once,
- [],
- [
- (faction_set_slot,"fac_kingdom_undead",slot_faction_state,sfs_active),
- (call_script, "script_appoint_faction_marshall", "fac_kingdom_undead", "trp_kingdom_undead_lord"),
-
- (call_script, "script_create_kingdom_hero_party", "trp_kingdom_undead_lord", "p_town_6"),#国王NPC
- (try_for_range,":party_template","pt_kingdom_undead_reinforcements_inite_a","pt_kingdom_undead_reinforcements_inite_d"),
- (party_add_template, "$pout_party", ":party_template"),
- (try_end),
- (party_add_members,"$pout_party","trp_undead_knight_a",40),
- (party_add_members,"$pout_party","trp_undead_ogre",10),
- (party_set_flags, "p_castle_51", pf_disabled, 0),
- (call_script, "script_give_center_to_lord", "p_castle_51", "trp_kingdom_undead_lord", 0),
- (try_for_range,":party_template","pt_living_dead_army_reinforcements_a","pt_living_dead_army_reinforcements_d"),
- (party_add_template, "p_castle_51", ":party_template"),
- (try_end),
- ],
- ),
复制代码
6.该代码用于本人MOD”异教之歌“,有问题欢迎讨论,QQ群号:751831596。
|