本帖最后由 ggfgfgf 于 2023-3-11 20:02 编辑
rt,马被砍死的骑兵附近有马的话会上马,难以测试,如有问题欢迎指教:)算是个简易的bot吧
module_misson_templates.py中开头定义
添加
cavalry_ai_dismounted_remount = (
5, 0, 0.5, [],
[
(try_for_agents, ":agent"),
(agent_is_alive, ":agent"),
(agent_is_non_player, ":agent"),
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0),
(agent_get_troop_id, ":troop_id", ":agent"),
(troop_is_guarantee_horse, ":troop_id"),
(agent_get_horse, ":h", ":agent"),
(eq, ":h", -1), (set_show_messages, 0),
(agent_get_team, ":team", ":agent"),
(agent_get_division, ":division", ":agent"),
(team_give_order, ":team", ":division", 3),
(set_show_messages, 1),
(try_end),
])
形如
............
##############################......
pilgrim_disguise = [itm_pilgrim_hood,itm_pilgrim_disguise,itm_practice_staff, itm_throwing_daggers]
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian
#新增代码
cavalry_ai_dismounted_remount = (
5, 0, 0.5, [],
[
(try_for_agents, ":agent"),
(agent_is_alive, ":agent"),
(agent_is_non_player, ":agent"),
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0),
(agent_get_troop_id, ":troop_id", ":agent"),
(troop_is_guarantee_horse, ":troop_id"),
(agent_get_horse, ":h", ":agent"),
(eq, ":h", -1),
(set_show_messages, 0),
(agent_get_team, ":team", ":agent"),
(agent_get_division, ":division", ":agent"),
(team_give_order, ":team", ":division", 3),
(set_show_messages, 1),
(try_end),
])
#新增代码
............
在你需要的战场触发器中添加:
cavalry_ai_dismounted_remount,
这里以野战(lead_charge)为例
(
"lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
"You lead your men to battle.",
[
(1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
(0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
],
[
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_agent_reassign_team", ":agent_no"),
(assign, ":initial_courage_score", 5000),
............
cavalry_ai_dismounted_remount,#新增代码
common_battle_order_panel,
common_battle_order_panel_tick,
],
),
代码注释:
cavalry_ai_dismounted_remount = (
5, 0, 0.5, [], #每隔5秒触发一次,触发后延时0秒执行代码,执行后等待0.5秒
[
(try_for_agents, ":agent"), #循环遍历所有战场者
(agent_is_alive, ":agent"), #战场者是活的
(agent_is_non_player, ":agent"), #战场者不是玩家
(agent_get_class ,":class", ":agent"), #获取战场者兵种
(eq,":class",grc_archers), #是骑兵
(agent_get_horse, ":h", ":agent"), #获取战场者的马
(neg|ge, ":h", 0), #马编号小于0,骑兵没有马匹,为下马骑兵,即需下达上马命令,使之上马
#p.s.上马命令须在下达冲锋命令后下达,并须周围有无人骑的马匹
(agent_get_team, ":team", ":agent"), #获取下马骑兵(战场者)队伍
(agent_get_division, ":division", ":agent"),#获取下马骑兵所属分组
(team_set_relation, ":team", 6, 1), #设置临时队伍6与玩家队伍为友军
(get_player_agent_no, ":p"), #获取玩家战场编号
(team_set_leader, 6, ":p"), #设置临时队伍领导者为玩家
(agent_set_team, ":agent", 6), #将下马骑兵设入临时队伍
(agent_set_division, ":agent", ":division"),#将下马骑兵设入临时分组
(team_give_order, 6, ":division", 0), #向临时分组下达冲锋命令
(team_give_order, 6, ":division", 3), #向临时分组下达上马命令,此段意在单独向该战场者下达命令
# (agent_set_team, ":agent", ":team"), #还原战场者队伍为原先的
# (agent_set_division, ":agent", ":division"),#还原战场者所属分组为原先的
(try_end),
])
module_system教程导航,by 心中飞翔
Module System的简单教程(完整版本?) - MOD制作资料区 - 骑马与砍杀中文站论坛 - Powered by Discuz! (mountblade.com.cn)
|