- 好友
- 16
- 在线时间
- 95 小时
- 最后登录
- 2024-12-27
见习骑士
- UID
- 2462463
- 第纳尔
- 1587
- 精华
- 0
- 互助
- 23
- 荣誉
- 0
- 贡献
- 0
- 魅力
- 83
- 注册时间
- 2015-3-3
鲜花( 58) 鸡蛋( 0)
|
本帖最后由 agjib 于 2023-8-26 17:46 编辑
代码环境1.171
【战团】阿格兰魔球修改器——合集https://bbs.mountblade.com.cn/thread-2097734-1-1.html
参考资料:无。自己把"npc_decision_checklist_faction_ai_alt"全部研究了下。
为什么战团,战的内容却是烧烧村子,或者去保护村子呢?而自己当元帅,只能让一个国家能集中武装力量,无法让所有国家集中进攻。找不到改元帅进攻ai的方法,只能我自己来了。
代码实际效果:1.所有元帅ai只会带领集团军攻击城堡和休息,不会烧村,不会防御。如果集团军相遇还是会大规模团战的,但是别家的元帅也是去攻城的,不是来防守的。
2.元帅原本不会进攻太远的城堡,现在没有这个限制了。
3.非元帅ai没测试,估计还是会烧村和防御了。
4.城主是玩家的城堡,防御力以6倍计算。不会阻止敌国进攻,但是会优先攻打非玩家的城堡。(txt里找 空格6空格 修改该数值)
5.精简脚本,删减350多行语句
代码使用方式:scripts.txt里面整段替换,需要替换两处,不用装py环境。替换完后,不用开新档,等游戏机制刷新ai就会生效。
scripts.txt整段替换npc_decision_checklist_evaluate_enemy_center_for_attack -1(共有两段要替换)
90 23 2 1224979098644774912 1 23 2 1224979098644774913 2 23 2 1224979098644774914 3 23 2 1224979098644774915 4 521 3 1224979098644774916 1224979098644774913 0 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 -1 2133 2 1224979098644774919 0 2173 2 1224979098644774920 1224979098644774912 4 0 31 2 1224979098644774914 1 522 3 1224979098644774921 1224979098644774920 8 30 2 1224979098644774921 0 520 3 1224979098644774922 1224979098644774921 10 5 0 520 3 1224979098644774922 1224979098644774912 10 3 0 2133 2 144115188075857003 0 4 0 2147483780 1 1224979098644774922 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786821 5 0 2204 2 1224979098644774923 1224979098644774913 2190 3 1224979098644774924 1224979098644774923 1224979098644774920 30 2 1224979098644774924 0 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786822 5 0 1073741855 2 1224979098644774916 3 31 2 1224979098644774916 2 2133 2 1224979098644774925 -1 4 0 2147484189 3 1224979098644774913 54 -1 521 3 1224979098644774926 1224979098644774913 54 132 1 1224979098644774926 2204 2 1224979098644774925 1224979098644774926 3 0 2147483679 2 1224979098644774925 -1 2147483679 2 1224979098644774925 1224979098644774920 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786823 5 0 31 2 1224979098644774916 4 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786825 5 0 521 3 1224979098644774927 1224979098644774922 56 521 3 1224979098644774928 1224979098644774922 59 521 3 1224979098644774929 1224979098644774922 57 2120 3 1224979098644774930 1224979098644774927 1224979098644774928 2105 2 1224979098644774930 1224979098644774929 4 0 541 3 1224979098644774913 7 360287970189639680 521 3 1224979098644774931 1224979098644774913 56 521 3 1224979098644774932 1224979098644774913 57 2105 2 1224979098644774931 1224979098644774932 2107 2 1224979098644774931 6 5 0 521 3 1224979098644774931 1224979098644774913 56 521 3 1224979098644774932 1224979098644774913 57 2105 2 1224979098644774931 1224979098644774932 3 0 2111 2 1224979098644774931 1 2122 3 1224979098644774919 1224979098644774930 100 2108 2 1224979098644774919 1224979098644774931 2111 2 1224979098644774919 1 2105 2 1224979098644774919 300 2147483678 2 1224979098644774919 150 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786833 5 0 32 2 0 31 30 2 1224979098644774931 1224979098644774930 2133 2 1224979098644774917 -1 2133 2 1224979098644774918 216172782113786834 5 0 2133 2 1224979098644774933 1224979098644774919 2133 2 1224979098644774917 1224979098644774933 4 0 2147483680 2 1224979098644774933 144115188075856915 2147483680 2 1224979098644774915 311 2133 2 1224979098644774918 216172782113786837 5 0 2133 2 1224979098644774918 216172782113786838 3 0 3 0 2133 2 72057594037927936 1224979098644774917 2133 2 72057594037927937 1224979098644774918 2133 2 72057594037927938 1224979098644774919
scripts.txt整段替换 find_center_to_defend -1
11 23 2 1224979098644774912 1 2173 2 1224979098644774913 1224979098644774912 4 0 2147483679 2 1224979098644774913 -1 2133 2 1224979098644774914 -1 2133 2 1224979098644774915 0 2133 2 1224979098644774916 -1 3 0 2133 2 72057594037927936 1224979098644774914 2133 2 72057594037927937 1224979098644774915 2133 2 72057594037927938 1224979098644774916
py码:(module_scripts.py里修改两段,有“#Agland”备注)
代码原理:
1.元帅用"npc_decision_checklist_faction_ai_alt",下达命令给阵营。即先有元帅,再有国家战略。
2.修改"npc_decision_checklist_faction_ai_alt"兼容性非常差,因为里面涉及的call_script太多了,一旦换个mod,script的ID一边,会出大毛病。
3.那么只能欺骗上面这个大ai了:所有领主都觉得村子“如 果 被 化 为 一 片 废 墟 的 话 , 承 受 最 多 痛 苦 的 就 是 那 些 住 在 这 里 的 村 民 们 。 ”
4.改后ai:交战状态下,选防守弱的城堡先攻击,且无视距离。
4.长时间测试后,研究表明各种生产巡逻队的ai (party_set_ai_behavior,":party_no",ai_bhvr_patrol_party),对领主不生效。屏蔽领主ai需要停掉触发器,得不偿失。
("npc_decision_checklist_evaluate_enemy_center_for_attack",
[
#NOTES -- LAST OFFENSIVE TIME SCORE IS NOT USED
(store_script_param, ":troop_no", 1),
(store_script_param, ":potential_target", 2),
(store_script_param, ":attack_by_faction", 3),
(store_script_param, ":all_vassals_included", 4),
(party_get_slot,":party_type",":potential_target",0),#Agland
(assign, ":result", -1),
(assign, ":explainer_string", -1),
#(assign, ":reason_is_obvious", 0),
(assign, ":power_ratio", 0),
#(assign, ":hours_since_last_recce", -1),
#(assign, ":value_of_target", 0),
#(assign, ":difficulty_of_capture", 0),
(store_faction_of_troop, ":faction_no", ":troop_no"),
(try_begin),
(eq, ":attack_by_faction", 1),
(faction_get_slot, ":faction_marshal", ":faction_no", slot_faction_marshall),
(ge, ":faction_marshal", 0), #STEVE ADDITION TO AVOID MESSAGE SPAM
(troop_get_slot, ":party_no", ":faction_marshal", slot_troop_leaded_party),
(else_try),
(troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
(try_end),
(assign, "$g_use_current_ai_object_as_s8", 0),
#THE FIRST BATCH OF DISQUALIFYING CONDITIONS DO NOT REQUIRE THE ATTACKING PARTY TO HAVE CURRENT INTELLIGENCE ON THE TARGET
(try_begin),
(neg|party_is_active, ":party_no"),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_party_not_active"),
#(assign, ":reason_is_obvious", 1),
(else_try),
(store_faction_of_party, ":potential_target_faction", ":potential_target"),
(store_relation, ":relation", ":potential_target_faction", ":faction_no"),
(ge, ":relation", 0),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_is_friendly"),
#(assign, ":reason_is_obvious", 1),
(else_try),
#(is_between, ":potential_target", walled_centers_begin, walled_centers_end),
(this_or_next|eq, ":party_type", spt_town),#Agland
(eq, ":party_type", spt_castle),#Agland
(assign, ":faction_of_besieger_party", -1),
(try_begin),
(neg|party_slot_eq, ":potential_target", slot_center_is_besieged_by, -1),
(party_get_slot, ":besieger_party", ":potential_target", slot_center_is_besieged_by),
(party_is_active, ":besieger_party"),
(store_faction_of_party, ":faction_of_besieger_party", ":besieger_party"),
(try_end),
(neq, ":faction_of_besieger_party", -1),
(neq, ":faction_of_besieger_party", ":faction_no"),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_is_already_besieged"),
#(assign, ":reason_is_obvious", 1),
(else_try),
#(this_or_next|troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_upstanding),#Agland
#(troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_goodnatured),#Agland
#(is_between, ":potential_target", villages_begin, villages_end),
(eq, ":party_type", spt_village),#Agland
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_marshal_does_not_want_to_attack_innocents"),
#DECISIONS BASED ON ENEMY STRENGTH BEGIN HERE
(else_try),
(party_get_slot, ":party_strength", ":party_no", slot_party_cached_strength),
(party_get_slot, ":follower_strength", ":party_no", slot_party_follower_strength),
(party_get_slot, ":strength_of_nearby_friend", ":party_no", slot_party_nearby_friend_strength),
(store_add, ":total_strength", ":party_strength", ":follower_strength"),
(val_add, ":total_strength", ":strength_of_nearby_friend"),
#(party_get_slot, ":potential_target_nearby_enemy_exact_strength", ":potential_target", slot_party_nearby_friend_strength),
#(assign, ":potential_target_nearby_enemy_strength", ":potential_target_nearby_enemy_exact_strength"),
(try_begin),
# (eq, ":party_type", spt_village), #Agland #(is_between, ":potential_target", villages_begin, villages_end),#Agland
# (assign, ":enemy_strength", 10), (party_slot_eq, ":potential_target", slot_town_lord, "trp_player"), (party_get_slot, ":enemy_strength", ":potential_target", slot_party_cached_strength), (party_get_slot, ":enemy_strength_nearby", ":potential_target", slot_party_nearby_friend_strength), (val_add, ":enemy_strength", ":enemy_strength_nearby"), (val_mul, ":enemy_strength",6), (else_try),
(party_get_slot, ":enemy_strength", ":potential_target", slot_party_cached_strength),
(party_get_slot, ":enemy_strength_nearby", ":potential_target", slot_party_nearby_friend_strength),
(val_add, ":enemy_strength", ":enemy_strength_nearby"),
(try_end),
(val_max, ":enemy_strength", 1),
#(this_or_next|troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_martial),#Agland,
#(this_or_next|troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_quarrelsome),#Agland,
#(troop_slot_eq, ":troop_no", slot_lord_reputation_type, lrep_selfrighteous),#Agland,
(store_mul, ":power_ratio", ":total_strength", 100),
(val_div, ":power_ratio", ":enemy_strength"),
(val_max, ":power_ratio", 1),#Agland,newly added
(val_add,":power_ratio",300),#Agland,newly added
(lt, ":power_ratio", 150),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_protected_by_enemy_army_aggressive"),
(else_try),
(gt, 0, 31),#Agland
(ge, ":enemy_strength", ":total_strength"), #if enemy is powerful
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_protected_by_enemy_army_cautious"),
(else_try),
#Agland
#(call_script, "script_calculate_center_assailability_score", ":troop_no", ":potential_target", ":all_vassals_included"),
#(assign, ":score", reg0),
#(assign, ":power_ratio", reg1),
(assign, ":score", ":power_ratio"),#Agland,newly added
(assign, ":result", ":score"),
(try_begin),
(le, ":score", "$g_faction_object_score"),
(le, ":all_vassals_included", 311),#Agland,pointless
(assign, ":explainer_string", "str_center_value_outweighed_by_difficulty_of_capture"),
(else_try),
#To Steve, does not this sentence needs to explain why we are not attacking that city?
#This sentence says it justifies, so why we are not attacking?
(assign, ":explainer_string", "str_center_value_justifies_the_difficulty_of_capture"),
(try_end),
(try_end),
(assign, reg0, ":result"),
(assign, reg1, ":explainer_string"),
(assign, reg2, ":power_ratio"),
]),
第二段修改
#script_find_center_to_defend
# INPUT:
# param1: faction_no
# OUTPUT:
# reg0 = center_to_defend (-1 if none is logical)
# reg1 = maximum_defend_score
# reg3 = enemy_strength_near_most_threatened_center
(
"find_center_to_defend",
[
(store_script_param, ":troop_no", 1),
(store_faction_of_troop, ":faction_no", ":troop_no"),
(try_begin),
(neq, ":faction_no", -1),
(assign, ":most_threatened_center", -1),
(assign, ":maximum_threat_score", 0),
(assign, ":enemy_strength_near_most_threatened_center", -1),
(try_end),
(assign, reg0, ":most_threatened_center"),
(assign, reg1, ":maximum_threat_score"),
(assign, reg2, ":enemy_strength_near_most_threatened_center"),
]),
第一段精简版:
("npc_decision_checklist_evaluate_enemy_center_for_attack",
[
#NOTES -- LAST OFFENSIVE TIME SCORE IS NOT USED
(store_script_param, ":troop_no", 1),
(store_script_param, ":potential_target", 2),
(store_script_param, ":attack_by_faction", 3),
(store_script_param, ":all_vassals_included", 4),
(party_get_slot,":party_type",":potential_target",0),#Agland
(assign, ":result", -1),
(assign, ":explainer_string", -1),
(assign, ":power_ratio", 0),
(store_faction_of_troop, ":faction_no", ":troop_no"),
(try_begin),
(eq, ":attack_by_faction", 1),
(faction_get_slot, ":faction_marshal", ":faction_no", slot_faction_marshall),
(ge, ":faction_marshal", 0), #STEVE ADDITION TO AVOID MESSAGE SPAM
(troop_get_slot, ":party_no", ":faction_marshal", slot_troop_leaded_party),
(else_try),
(troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
(try_end),
(assign, "$g_use_current_ai_object_as_s8", 0),
#THE FIRST BATCH OF DISQUALIFYING CONDITIONS DO NOT REQUIRE THE ATTACKING PARTY TO HAVE CURRENT INTELLIGENCE ON THE TARGET
(try_begin),
(neg|party_is_active, ":party_no"),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_party_not_active"),
(else_try),
(store_faction_of_party, ":potential_target_faction", ":potential_target"),
(store_relation, ":relation", ":potential_target_faction", ":faction_no"),
(ge, ":relation", 0),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_is_friendly"),
(else_try),
(this_or_next|eq, ":party_type", spt_town),#Agland
(eq, ":party_type", spt_castle),#Agland
(assign, ":faction_of_besieger_party", -1),
(try_begin),
(neg|party_slot_eq, ":potential_target", slot_center_is_besieged_by, -1),
(party_get_slot, ":besieger_party", ":potential_target", slot_center_is_besieged_by),
(party_is_active, ":besieger_party"),
(store_faction_of_party, ":faction_of_besieger_party", ":besieger_party"),
(try_end),
(neq, ":faction_of_besieger_party", -1),
(neq, ":faction_of_besieger_party", ":faction_no"),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_is_already_besieged"),
(else_try),
(eq, ":party_type", spt_village),#Agland
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_marshal_does_not_want_to_attack_innocents"),
#DECISIONS BASED ON ENEMY STRENGTH BEGIN HERE
(else_try),
(party_get_slot, ":party_strength", ":party_no", slot_party_cached_strength),
(party_get_slot, ":follower_strength", ":party_no", slot_party_follower_strength),
(party_get_slot, ":strength_of_nearby_friend", ":party_no", slot_party_nearby_friend_strength),
(store_add, ":total_strength", ":party_strength", ":follower_strength"),
(val_add, ":total_strength", ":strength_of_nearby_friend"),
(try_begin),
#Agland,newly added
(party_slot_eq, ":potential_target", slot_town_lord, "trp_player"),
(party_get_slot, ":enemy_strength", ":potential_target", slot_party_cached_strength),
(party_get_slot, ":enemy_strength_nearby", ":potential_target", slot_party_nearby_friend_strength),
(val_add, ":enemy_strength", ":enemy_strength_nearby"),
(val_mul, ":enemy_strength",6),
(else_try),
(party_get_slot, ":enemy_strength", ":potential_target", slot_party_cached_strength),
(party_get_slot, ":enemy_strength_nearby", ":potential_target", slot_party_nearby_friend_strength),
(val_add, ":enemy_strength", ":enemy_strength_nearby"),
(try_end),
(val_max, ":enemy_strength", 1),
(store_mul, ":power_ratio", ":total_strength", 100),
(val_div, ":power_ratio", ":enemy_strength"),
(val_max, ":power_ratio", 1),#Agland,newly added
(val_add,":power_ratio",300),#Agland,newly added
(lt, ":power_ratio", 150),
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_protected_by_enemy_army_aggressive"),
(else_try),
(gt, 0, 31),#Agland
(ge, ":enemy_strength", ":total_strength"), #if enemy is powerful
(assign, ":result", -1),
(assign, ":explainer_string", "str_center_protected_by_enemy_army_cautious"),
(else_try),
(assign, ":score", ":power_ratio"),#Agland,newly added
(assign, ":result", ":score"),
(try_begin),
(le, ":score", "$g_faction_object_score"),
(le, ":all_vassals_included", 311),#Agland,pointless
(assign, ":explainer_string", "str_center_value_outweighed_by_difficulty_of_capture"),
(else_try),
(assign, ":explainer_string", "str_center_value_justifies_the_difficulty_of_capture"),
(try_end),
(try_end),
(assign, reg0, ":result"),
(assign, reg1, ":explainer_string"),
(assign, reg2, ":power_ratio"),
]),
[/hide]
|
评分
-
查看全部评分
|