- 好友
- 0
- 在线时间
- 77 小时
- 最后登录
- 2022-6-29
扈从
- UID
- 3014167
- 第纳尔
- 1456
- 精华
- 0
- 互助
- 0
- 荣誉
- 0
- 贡献
- 0
- 魅力
- 18
- 注册时间
- 2018-7-16
鲜花( 97) 鸡蛋( 0)
|
本帖最后由 wangxinming77 于 2020-5-16 20:14 编辑
大家好,这里是w,虽然潘德本身有枪骑ai,但是个人感觉时间复杂度有点高,所以在学习君越大佬的代码之后,肝(bug)了两天,终于写出了一个结合潘德的枪骑兵ai,话不多说下面是源码(因为潘德不开源,所以ai是用魔球写的,然后反编译拿出来的,不要问我为什么没有标局部变量名,问就是懒…)
源码如下:
(try_for_agents, ":var_0"), //历遍agent
(agent_is_alive, ":var_0"),
(agent_is_human, ":var_0"),
(agent_is_non_player, ":var_0"),
(agent_get_team, ":var_1", ":var_0"),
(agent_get_division, ":var_2", ":var_0"),
(team_get_weapon_usage_order, ":var_3", ":var_1", ":var_2"),
(eq, ":var_3", 0),
(agent_get_wielded_item, ":var_5", ":var_0", 0),
(gt, ":var_5", 0), //基本条件判断,包括活着的,是人,不是玩家,没被命令拿钝器等等
(assign, ":var_13", 0), //初始化变量,13是单/双手武器,14是各类骑枪或是黑铁矛(潘德基本所有骑兵都拿这两样)
(assign, ":var_14", 0),
(try_for_range, ":var_4", 0, 4), //查找agent的装备
(agent_get_item_slot, ":var_6", ":var_0", ":var_4"),
(gt, ":var_6", 0),
(item_get_type, ":var_17", ":var_6"),
(try_begin),
(this_or_next|eq, ":var_17", 2), //记录第一个单双手武器
(eq, ":var_17", 3),
(eq, ":var_13", 0),
(assign, ":var_13", ":var_6"),
(else_try),
(this_or_next|eq, ":var_6", "itm_black_iron_spear"), //存储第一个骑枪或黑铁矛
(2723, ":var_6", 2147483648),
(eq, ":var_14", 0),
(assign, ":var_14", ":var_6"),
(try_end),
(try_end),
(gt, ":var_13", 0),
(gt, ":var_14", 0), //判定是否是枪骑兵,一定要写,否则会干扰骑射ai
(try_begin),
(assign, ":var_18", 0), //18是判定变量,1是用短武器,-1是用长兵器
(agent_get_horse, ":var_7", ":var_0"), // 有马否
(try_begin),
(ge, ":var_7", 0),
(set_fixed_point_multiplier, 10),
(agent_get_speed, pos1, ":var_0"),
(position_get_y, ":var_8", pos1), //存储速度,骑砍里骑兵的x向速度恒为0,所以只要y向就可以了 (agent_ai_get_look_target, ":var_10", ":var_0"),
(gt, ":var_10", 0), //存储目标距离,这里一定不要忘,不要问我怎么知道的(╥╯^╰╥)
(agent_is_alive, ":var_10"),
(agent_is_human, ":var_10"),
(agent_get_team, ":var_11", ":var_10"),
(teams_are_enemies, ":var_11", ":var_1"),
(agent_get_position, pos2, ":var_0"),
(agent_get_position, pos3, ":var_10"),
(get_distance_between_positions, ":var_12", pos2, pos3),
(try_begin),
(ge, ":var_8", 55), //能跑起来而且距离大于300才用枪
(gt, ":var_12", 300),
(assign, ":var_18", -1),
(else_try),
(assign, ":var_18", 1),
(try_end),
(else_try),
(assign, ":var_18", 1),
(try_end),
(try_begin),
(eq, ":var_18", 1), //用短武器
(try_begin),
(this_or_next|eq, ":var_5", "itm_black_iron_spear"), //筛选那长杆的骑兵,因为潘德的骑兵最多多拿个黑铁矛,所以用在别的mod的时候大家记得改一下
(2723, ":var_5", 2147483648), //反编译器的版本有点落后,这里是判定武器是否可以咸鱼突刺
(agent_set_wielded_item, ":var_0", ":var_13"),
(try_end),
(else_try),
(eq, ":var_18", -1),
(try_begin),
(gt, ":var_5", 0),
(neg|eq, ":var_6", "itm_black_iron_spear"), //筛选拿单双手的骑兵,还是因为是潘德,所以ctrlcv偷了个懒,有投掷的枪骑兵(异端巨力:我莫得人权吗,w:莫得,再废话就删了你的投矛)需要改一下。
(neg|2723, ":var_5", 2147483648),
(agent_set_wielded_item, ":var_0", ":var_14"),
(try_end),
(try_end),
(try_end),
(try_end),
解决了上次说的不足,但是还是有问题,骑兵聚堆的时候一些后排的骑兵会因为掏刀子打不到人而发呆,而且看到高速跑来的敌方骑兵还是会用刀子而不是用枪然后被一抢放倒,但是为了我自己的肝(屁,你就是懒눈_눈 ),所以就先这样吧。
另附txt修改码,替换原版lead_charge里2.000000 0.000000 2.000000 0 145那些即可:
1.000000 0.000000 0.000000 0 75 12 1 1224979098644774912 1702 1 1224979098644774912 1704 1 1224979098644774912 1707 1 1224979098644774912 1770 2 1224979098644774913 1224979098644774912 1773 2 1224979098644774914 1224979098644774912 1787 3 1224979098644774915 1224979098644774913 1224979098644774914 31 2 1224979098644774915 0 1726 3 1224979098644774917 1224979098644774912 0 32 2 1224979098644774917 0 2133 2 1224979098644774925 0 2133 2 1224979098644774926 0 6 3 1224979098644774916 0 4 1804 3 1224979098644774918 1224979098644774912 1224979098644774916 32 2 1224979098644774918 0 1570 2 1224979098644774929 1224979098644774918 4 0 1073741855 2 1224979098644774929 2 31 2 1224979098644774929 3 31 2 1224979098644774925 0 2133 2 1224979098644774925 1224979098644774918 5 0 1073741855 2 1224979098644774918 288230376151713145 2723 2 1224979098644774918 2147483648 31 2 1224979098644774926 0 2133 2 1224979098644774926 1224979098644774918 3 0 3 0 32 2 1224979098644774925 0 32 2 1224979098644774926 0 4 0 2133 2 1224979098644774930 0 1714 2 1224979098644774919 1224979098644774912 4 0 30 2 1224979098644774919 0 2124 1 10 1689 2 1 1224979098644774912 727 2 1224979098644774920 1 2080 2 1224979098644774922 1224979098644774912 32 2 1224979098644774922 0 1702 1 1224979098644774922 1704 1 1224979098644774922 1770 2 1224979098644774923 1224979098644774922 1788 2 1224979098644774923 1224979098644774913 1710 2 2 1224979098644774912 1710 2 3 1224979098644774922 710 3 1224979098644774924 2 3 4 0 30 2 1224979098644774920 55 32 2 1224979098644774924 400 2133 2 1224979098644774930 -1 5 0 2133 2 1224979098644774930 1 3 0 5 0 2133 2 1224979098644774930 1 3 0 4 0 31 2 1224979098644774930 1 4 0 1073741855 2 1224979098644774917 288230376151713145 2723 2 1224979098644774917 2147483648 1747 2 1224979098644774912 1224979098644774925 3 0 5 0 31 2 1224979098644774930 -1 4 0 32 2 1224979098644774917 0 2147483679 2 1224979098644774917 288230376151713145 2147486371 2 1224979098644774917 2147483648 1747 2 1224979098644774912 1224979098644774926 3 0 3 0 3 0 3 0 |
鲜花鸡蛋砍出一片天 在2021-2-20 21:40 送朵鲜花 并说:我非常同意你的观点,送朵鲜花鼓励一下 叶锐坚 在2020-6-7 14:02 送朵鲜花 并说:我非常同意你的观点,送朵鲜花鼓励一下 没落的小贵族 在2020-6-7 11:43 送朵鲜花 并说:技术流应该支持,感谢您的努力! 佛罗伦萨的袖剑 在2020-5-9 12:46 送朵鲜花 并说:我非常同意你的观点,送朵鲜花鼓励一下
|