骑马与砍杀中文站论坛

 找回密码
 注册(Register!)

QQ登录

只需一步,快速开始

搜索
购买CDKEY 小黑盒加速器
查看: 3658|回复: 13

[功能与代码] 野怪攻城代码和城镇阵营绑定(魔球可用

[复制链接]

1

主题

15

回帖

20

积分

随仆

Rank: 1

UID
3335850
第纳尔
115
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2022-3-12
鲜花(0) 鸡蛋(0)
发表于 2022-7-7 16:41:05 | 显示全部楼层 |阅读模式
我最近经大佬的思路启发,制作了一个魔球可用的包含从野怪攻城到城镇阵营转变的触发器代码。代码都是放到触发器结果上的。触发器条件全填0即可。
野怪攻城代码优化.改
  1. (neg|eq,":var_3","fac_player_knights_1"),
  2. (store_random_in_range,":var_10",0,10),
  3. (try_begin),
  4.     (store_faction_of_party,":var_12","p_town_7"),
  5.     (neg|eq,":var_12","fac_player_knights_1"),
  6.     (assign,"$var_1337","p_town_7"),
  7. (try_end),
  8. (store_faction_of_party,":var_11","$var_1337"),
  9. (store_random_party_of_template,":var_2","pt_snake_cult_warband_4"),
  10. (try_begin),
  11.     (neg|eq,":var_11","fac_player_knights_1"),
  12.     (try_begin),
  13.         (gt,":var_10",5),
  14.         (2281,":var_4","$var_1337",":var_2"),
  15.         (try_begin),
  16.             (ge,100,":var_4"),
  17.             (party_set_ai_object,":var_2","$var_1337"),
  18.             (party_set_ai_behavior,":var_2",ai_bhvr_attack_party),
  19.         (else_try),
  20.             (party_set_ai_object,":var_2","$var_1337"),
  21.             (party_set_ai_behavior,":var_2",ai_bhvr_travel_to_party),
  22.         (try_end),
  23.     (else_try),
  24.     (try_end),
  25. (else_try),
  26.     (gt,":var_10",5),
  27.     (store_add,":var_1","p_castle_40",1),
  28.     (store_random_in_range,"$var_1337","p_town_1",":var_1"),
  29. (try_end),
  30. (try_begin),
  31. (party_get_num_companions,":var_13","$var_1337"),
  32. (ge,40,":var_13"),
  33. (party_set_faction,"$var_1337","fac_player_knights_1"),
复制代码
城村阵营绑定格式(附潘德g版绑定)
  1. (store_faction_of_party, <destination>, <party_id>), #城
  2. (party_set_faction,<destination>,<party_id>),#村(有几个套几个)
  3. #<destination>:变量  例:":var_0"
复制代码
潘德g版绑定
  1. (store_faction_of_party,":var_1","p_town_1"),
  2. (party_set_faction,"p_village_5",":var_1"),
  3. (party_set_faction,"p_village_75",":var_1"),
  4. (store_faction_of_party,":var_2","p_town_2"),
  5. (party_set_faction,"p_village_4",":var_2"),
  6. (party_set_faction,"p_village_63",":var_2"),
  7. (party_set_faction,"p_village_81",":var_2"),
  8. (party_set_faction,"p_village_35",":var_2"),
  9. (store_faction_of_party,":var_3","p_town_3"),
  10. (party_set_faction,"p_village_46",":var_3"),
  11. (party_set_faction,"p_village_73",":var_3"),
  12. (party_set_faction,"p_village_89",":var_3"),
  13. (party_set_faction,"p_village_40",":var_3"),
  14. (party_set_faction,"p_village_78",":var_3"),
  15. (party_set_faction,"p_village_47",":var_3"),
  16. (store_faction_of_party,":var_4","p_town_4"),
  17. (party_set_faction,"p_village_32",":var_4"),
  18. (party_set_faction,"p_village_71",":var_4"),
  19. (store_faction_of_party,":var_5","p_town_5"),
  20. (party_set_faction,"p_village_27",":var_5"),
  21. (party_set_faction,"p_village_84",":var_5"),
  22. (party_set_faction,"p_village_39",":var_5"),
  23. (party_set_faction,"p_village_70",":var_5"),
  24. (store_faction_of_party,":var_6","p_town_6"),
  25. (party_set_faction,"p_village_3",":var_6"),
  26. (party_set_faction,"p_village_1",":var_6"),
  27. (party_set_faction,"p_village_62",":var_6"),
  28. (store_faction_of_party,":var_7","p_town_7"),
  29. (party_set_faction,"p_village_7",":var_7"),
  30. (party_set_faction,"p_village_54",":var_7"),
  31. (store_faction_of_party,":var_8","p_town_8"),
  32. (party_set_faction,"p_village_14",":var_8"),
  33. (party_set_faction,"p_village_55",":var_8"),
  34. (store_faction_of_party,":var_9","p_town_9"),
  35. (party_set_faction,"p_village_85",":var_9"),
  36. (party_set_faction,"p_village_86",":var_9"),
  37. (store_faction_of_party,":var_10","p_town_10"),
  38. (party_set_faction,"p_village_79",":var_10"),
  39. (party_set_faction,"p_village_37",":var_10"),
  40. (party_set_faction,"p_village_83",":var_10"),
  41. (store_faction_of_party,":var_11","p_town_11"),
  42. (party_set_faction,"p_village_66",":var_11"),
  43. (party_set_faction,"p_village_21",":var_11"),
  44. (store_faction_of_party,":var_12","p_town_12"),
  45. (party_set_faction,"p_village_36",":var_12"),
  46. (party_set_faction,"p_village_87",":var_12"),
  47. (store_faction_of_party,":var_13","p_town_13"),
  48. (party_set_faction,"p_village_18",":var_13"),
  49. (store_faction_of_party,":var_14","p_town_14"),
  50. (party_set_faction,"p_village_59",":var_14"),
  51. (party_set_faction,"p_village_43",":var_14"),
  52. (store_faction_of_party,":var_15","p_town_15"),
  53. (party_set_faction,"p_village_24",":var_15"),
  54. (party_set_faction,"p_village_29",":var_15"),
  55. (party_set_faction,"p_village_64",":var_15"),
  56. (store_faction_of_party,":var_16","p_town_16"),
  57. (party_set_faction,"p_village_57",":var_16"),
  58. (party_set_faction,"p_village_13",":var_16"),
  59. (party_set_faction,"p_village_38",":var_16"),
  60. (store_faction_of_party,":var_17","p_town_17"),
  61. (party_set_faction,"p_village_44",":var_17"),
  62. (party_set_faction,"p_village_49",":var_17"),
  63. (store_faction_of_party,":var_18","p_town_18"),
  64. (party_set_faction,"p_village_42",":var_18"),
  65. (party_set_faction,"p_village_33",":var_18"),
  66. (party_set_faction,"p_village_23",":var_18"),
  67. (store_faction_of_party,":var_19","p_castle_1"),
  68. (party_set_faction,"p_village_45",":var_19"),
  69. (store_faction_of_party,":var_20","p_castle_2"),
  70. (party_set_faction,"p_village_52",":var_20"),
  71. (store_faction_of_party,":var_21","p_castle_3"),
  72. (party_set_faction,"p_village_22",":var_21"),
  73. (store_faction_of_party,":var_22","p_castle_4"),
  74. (party_set_faction,"p_village_53",":var_22"),
  75. (store_faction_of_party,":var_23","p_castle_5"),
  76. (party_set_faction,"p_village_31",":var_23"),
  77. (store_faction_of_party,":var_24","p_castle_6"),
  78. (party_set_faction,"p_village_67",":var_24"),
  79. (store_faction_of_party,":var_25","p_castle_7"),
  80. (party_set_faction,"p_village_8",":var_25"),
  81. (store_faction_of_party,":var_26","p_castle_8"),
  82. (party_set_faction,"p_village_10",":var_26"),
  83. (store_faction_of_party,":var_27","p_castle_9"),
  84. (party_set_faction,"p_village_90",":var_27"),
  85. (store_faction_of_party,":var_28","p_castle_10"),
  86. (party_set_faction,"p_village_30",":var_28"),
  87. (store_faction_of_party,":var_29","p_castle_11"),
  88. (party_set_faction,"p_village_61",":var_29"),
  89. (store_faction_of_party,":var_30","p_castle_12"),
  90. (party_set_faction,"p_village_80",":var_30"),
  91. (store_faction_of_party,":var_31","p_castle_13"),
  92. (party_set_faction,"p_village_65",":var_31"),
  93. (store_faction_of_party,":var_32","p_castle_14"),
  94. (party_set_faction,"p_village_26",":var_32"),
  95. (store_faction_of_party,":var_33","p_castle_15"),
  96. (party_set_faction,"p_village_6",":var_33"),
  97. (store_faction_of_party,":var_34","p_castle_16"),
  98. (party_set_faction,"p_village_9",":var_34"),
  99. (store_faction_of_party,":var_35","p_castle_17"),
  100. (party_set_faction,"p_village_11",":var_35"),
  101. (store_faction_of_party,":var_36","p_castle_18"),
  102. (party_set_faction,"p_village_41",":var_36"),
  103. (store_faction_of_party,":var_37","p_castle_19"),
  104. (party_set_faction,"p_village_20",":var_37"),
  105. (store_faction_of_party,":var_38","p_castle_20"),
  106. (party_set_faction,"p_village_74",":var_38"),
  107. (store_faction_of_party,":var_39","p_castle_21"),
  108. (party_set_faction,"p_village_48",":var_39"),
  109. (store_faction_of_party,":var_40","p_castle_22"),
  110. (party_set_faction,"p_village_72",":var_40"),
  111. (store_faction_of_party,":var_41","p_castle_23"),
  112. (party_set_faction,"p_village_34",":var_41"),
  113. (store_faction_of_party,":var_42","p_castle_24"),
  114. (party_set_faction,"p_village_25",":var_42"),
  115. (store_faction_of_party,":var_43","p_castle_25"),
  116. (party_set_faction,"p_village_15",":var_43"),
  117. (store_faction_of_party,":var_44","p_castle_26"),
  118. (party_set_faction,"p_village_69",":var_44"),
  119. (store_faction_of_party,":var_45","p_castle_27"),
  120. (party_set_faction,"p_village_2",":var_45"),
  121. (store_faction_of_party,":var_46","p_castle_28"),
  122. (party_set_faction,"p_village_56",":var_46"),
  123. (store_faction_of_party,":var_47","p_castle_29"),
  124. (party_set_faction,"p_village_50",":var_47"),
  125. (store_faction_of_party,":var_48","p_castle_30"),
  126. (party_set_faction,"p_village_88",":var_48"),
  127. (store_faction_of_party,":var_49","p_castle_31"),
  128. (party_set_faction,"p_village_76",":var_49"),
  129. (store_faction_of_party,":var_50","p_castle_32"),
  130. (party_set_faction,"p_village_82",":var_50"),
  131. (store_faction_of_party,":var_51","p_castle_33"),
  132. (party_set_faction,"p_village_12",":var_51"),
  133. (store_faction_of_party,":var_52","p_castle_34"),
  134. (party_set_faction,"p_village_77",":var_52"),
  135. (store_faction_of_party,":var_53","p_castle_35"),
  136. (party_set_faction,"p_village_60",":var_53"),
  137. (store_faction_of_party,":var_54","p_castle_36"),
  138. (party_set_faction,"p_village_51",":var_54"),
  139. (store_faction_of_party,":var_55","p_castle_37"),
  140. (party_set_faction,"p_village_58",":var_55"),
  141. (store_faction_of_party,":var_56","p_castle_38"),
  142. (party_set_faction,"p_village_68",":var_56"),
  143. (store_faction_of_party,":var_57","p_castle_39"),
  144. (party_set_faction,"p_village_17",":var_57"),
  145. (store_faction_of_party,":var_58","p_castle_40"),
  146. (party_set_faction,"p_village_28",":var_58"),
复制代码
附:大佬原代码
B站:杨浩瀚吹啊吹
顺序:
①创建野怪大军
②野怪大军巡逻
③随机对目标城堡/城镇/村子攻击
④若攻下该城堡,该城堡会自动招募野怪新兵进行驻守
⑤每隔一段时间城堡的野怪自动升级为更高级的兵种
⑥城堡被占领期间自动产生野怪城池护卫队进行巡逻
(1)重生部队代码
激发条件:
  1. (store_num_parties_of_template,reg2,"pt_looters_1"),
  2. (neg|ge,reg2,20),
复制代码
激发结果
  1. (set_spawn_radius,1),
  2. (store_add,":var_0","p_town_1",1),
  3. (store_random_in_range,":var_1","p_town_1",":var_0"),
  4. (spawn_around_party,":var_1","pt_looters_1"),
复制代码
(2)野怪攻城行为
激发条件空
激发结果
  1. (neg|eq,":var_3","fac_player_supporters_faction"),
  2. (store_random_in_range,":var_10",0,10),
  3. (try_begin),
  4.     (gt,":var_10",5),
  5.     (store_random_party_of_template,":var_0","pt_looters_1"),
  6.     (store_add,":var_1","p_town_2",1),
  7.     (store_random_in_range,":var_2","p_town_1",":var_1"),
  8.     (party_set_ai_behavior,":var_0",ai_bhvr_attack_party),
  9.     (party_set_ai_object,":var_0",":var_2"),
  10. (try_end),

复制代码
(3)攻下后驻兵-普通士兵模板和守城大将模板
激发条件为空

激发结果
  1. (try_for_range,":var_0","p_town_1","p_village_1"),
  2.     (store_faction_of_party,":var_1",":var_0"),
  3.     (party_count_members_of_type,":var_2",":var_0","trp_song_zhuangding"),
  4.     (try_begin),
  5.         (eq,":var_1","fac_player_supporters_faction"),
  6.         (try_begin),
  7.             (neg|ge,":var_2",300),
  8.             (party_add_members,":var_0","trp_song_zhuangding",50),
  9.         (try_end),
  10.     (try_end),
  11. (try_end),
复制代码
(4)攻下后驻兵自动升级(这里没有上限,你可以用加大时间周期来限制)
激发条件:空
激发结果
  1. (try_for_range,":var_0","p_town_1","p_village_1"),
  2.         (store_faction_of_party,":var_1",":var_0"),
  3.         (try_for_range,":var_2","trp_veteran_fighter","trp_kidnapped_girl"),
  4.             (party_count_companions_of_type,":var_3",":var_0",":var_2"),
  5.             (try_begin),
  6.                 (eq,":var_1","fac_player_supporters_faction"),
  7.                 (try_begin),
  8.                     (ge,":var_3",1),
  9.                     (party_remove_members,":var_0",":var_2",":var_3"),
  10.                     (party_add_members,":var_0","trp_forest_bandit",":var_3"),
  11.                 (try_end),
  12.             (try_end),
  13.         (try_end),
  14.     (try_end),
  15. (try_end),
复制代码
(5)野怪护城巡逻队
激发条件
  1. (store_num_parties_of_template,reg2,"pt_manhunters"),
  2. (neg|ge,reg2,4),
复制代码
激发结果
  1. (set_spawn_radius,1),
  2. (try_for_range,":var_3","p_town_1","p_castle_51"),
  3.     (store_faction_of_party,":var_4",":var_3"),
  4.     (try_begin),
  5.         (eq,":var_4","fac_outlaws"),
  6.         (spawn_around_party,":var_3","pt_taiga_bandits_22"),
  7.         (assign,":var_5",reg0),
  8.         (party_set_faction,":var_5",":var_4"),
  9.         (party_set_ai_object,":var_5",":var_3"),
  10.         (party_set_ai_behavior,":var_5",ai_bhvr_patrol_location),
  11.         (party_set_ai_patrol_radius,":var_5",10),
  12.     (try_end),
  13. (try_end),
复制代码

觉得很好用记得给大佬投币
大佬也做了一些魔球教程视频,欢迎支持

评分

参与人数 1第纳尔 +10 互助 +1 魅力 +1 收起 理由
幼稚园殺手 + 10 + 1 + 1 文章不错,继续努力!

查看全部评分

55

主题

2759

回帖

1769

积分

子爵[版主]

吟游诗人

Rank: 7Rank: 7Rank: 7

UID
3054380
第纳尔
23809
精华
2
互助
57
荣誉
44
贡献
916
魅力
1418
注册时间
2019-1-18

骑砍中文站APP会员勋章原版正版勋章战团正版勋章火与剑正版勋章拿破仑正版勋章维京征服正版勋章霸主正版勋章剧本设计大奖赛骑友真人秀Ⅷ勋章骑友真人秀Ⅶ勋章骑友真人秀Ⅸ勋章

QQ
鲜花(512) 鸡蛋(2)
发表于 2022-7-8 16:39:45 | 显示全部楼层
顶一下
珍惜 奉献 不负韶华

55

主题

2759

回帖

1769

积分

子爵[版主]

吟游诗人

Rank: 7Rank: 7Rank: 7

UID
3054380
第纳尔
23809
精华
2
互助
57
荣誉
44
贡献
916
魅力
1418
注册时间
2019-1-18

骑砍中文站APP会员勋章原版正版勋章战团正版勋章火与剑正版勋章拿破仑正版勋章维京征服正版勋章霸主正版勋章剧本设计大奖赛骑友真人秀Ⅷ勋章骑友真人秀Ⅶ勋章骑友真人秀Ⅸ勋章

QQ
鲜花(512) 鸡蛋(2)
发表于 2022-7-8 16:39:53 | 显示全部楼层
顶一下
珍惜 奉献 不负韶华

16

主题

837

回帖

396

积分

子爵[版主]

汉[Han]
联机ID:Han_DongHai

Rank: 7Rank: 7Rank: 7

UID
3033293
第纳尔
13438
精华
0
互助
24
荣誉
2
贡献
510
魅力
184
注册时间
2018-10-3

第十届战团中国联赛征战勋章汉匈决战正版勋章战团正版勋章霸主正版勋章

QQ
鲜花(39) 鸡蛋(0)
发表于 2022-7-8 19:00:56 | 显示全部楼层

54

主题

899

回帖

341

积分

见习骑士

游骑士战队[YQS]
联机ID:Apple_PAI

Rank: 3

UID
3218444
第纳尔
106
精华
0
互助
11
荣誉
0
贡献
0
魅力
26
注册时间
2021-1-30

战团正版勋章2022国庆青训杯冠军勋章第一届拿破仑中国刺刀联赛近卫勋章霸主正版勋章拿破仑正版勋章

鲜花(110) 鸡蛋(0)
发表于 2022-7-8 20:50:38 | 显示全部楼层
看起来比我的强
苹果派真好吃嘿嘿嘿

1

主题

15

回帖

20

积分

随仆

Rank: 1

UID
3335850
第纳尔
115
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2022-3-12
鲜花(0) 鸡蛋(0)
 楼主| 发表于 2022-7-9 01:22:57 | 显示全部楼层
野怪攻城代码优化.改 套用须知:本代码涉及全局变量的应用(如"$var_1337")修改前记得查看一下mod原有的全局变量数,以保证创建的是一个新的全局变量,不会对mod中别的触发器造成影响。(可在魔球中查看)剩余变量可自行对照进行修改

3

主题

12

回帖

15

积分

随仆

Rank: 1

UID
3355490
第纳尔
141
精华
0
互助
2
荣誉
0
贡献
0
魅力
0
注册时间
2022-5-2
鲜花(3) 鸡蛋(0)
发表于 2022-7-9 16:22:04 来自手机 | 显示全部楼层
我在修改下克上武家之殇,我能不能用这个代码做一个叛军攻城来自: Android客户端

1

主题

15

回帖

20

积分

随仆

Rank: 1

UID
3335850
第纳尔
115
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2022-3-12
鲜花(0) 鸡蛋(0)
 楼主| 发表于 2022-7-10 13:09:00 | 显示全部楼层
樱花太师 发表于 2022-7-9 16:22
我在修改下克上武家之殇,我能不能用这个代码做一个叛军攻城

理论上是可以的,只是目前攻下城后的一些功能有缺失,建议如果mod是开源的话优先使用py

7

主题

38

回帖

14

积分

随仆

Rank: 1

UID
3009983
第纳尔
269
精华
0
互助
0
荣誉
0
贡献
0
魅力
0
注册时间
2018-6-27
鲜花(0) 鸡蛋(0)
发表于 2022-12-13 17:38:50 | 显示全部楼层
这个随机好像会让攻城部队随机死板地攻城,不管刷多少个部队都是死板攻完同一个目标才会攻击下一个目标,对于做国家的突袭队不太理想,请问大佬能把他弄成按距离就近原则攻城吗

1

主题

15

回帖

20

积分

随仆

Rank: 1

UID
3335850
第纳尔
115
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2022-3-12
鲜花(0) 鸡蛋(0)
 楼主| 发表于 2022-12-25 23:40:30 | 显示全部楼层
2182270566 发表于 2022-12-13 17:38
这个随机好像会让攻城部队随机死板地攻城,不管刷多少个部队都是死板攻完同一个目标才会攻击下一个目标,对 ...

可以,很好的建议,之后有时间我会进试着行修改

0

主题

24

回帖

7

积分

平民

Rank: 1

UID
988936
第纳尔
196
精华
0
互助
0
荣誉
0
贡献
0
魅力
0
注册时间
2012-9-16
鲜花(0) 鸡蛋(0)
发表于 2023-1-29 15:48:02 | 显示全部楼层
感谢,这样很有意思

8

主题

26

回帖

10

积分

随仆

Rank: 1

UID
3425430
第纳尔
107
精华
0
互助
0
荣誉
0
贡献
0
魅力
10
注册时间
2022-10-7
鲜花(3) 鸡蛋(0)
发表于 2023-2-3 23:27:56 | 显示全部楼层
本帖最后由 saiopdjpaoi 于 2023-8-22 06:53 编辑

这个功能怎么加?实在太强!!!

1

主题

3

回帖

1

积分

平民

Rank: 1

UID
3507920
第纳尔
19
精华
0
互助
0
荣誉
0
贡献
0
魅力
0
注册时间
2023-4-19
鲜花(0) 鸡蛋(0)
发表于 2023-4-24 14:12:22 | 显示全部楼层
攻城里那些零需要修改吗,这个代码怎么选取攻城阵营及部队呢,大佬能教一下吗

1

主题

15

回帖

20

积分

随仆

Rank: 1

UID
3335850
第纳尔
115
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2022-3-12
鲜花(0) 鸡蛋(0)
 楼主| 发表于 2023-5-12 23:04:17 | 显示全部楼层
刘玄 发表于 2023-4-24 14:12
攻城里那些零需要修改吗,这个代码怎么选取攻城阵营及部队呢,大佬能教一下吗

这是一个教学视频,你可以看看
https://www.bilibili.com/video/B ... 31c7321a0f9752d1937
您需要登录后才可以回帖 登录 | 注册(Register!)

本版积分规则

Archiver|手机版|小黑屋|骑马与砍杀中文站

GMT+8, 2024-11-19 10:43 , Processed in 0.138868 second(s), 38 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表