骑马与砍杀中文站论坛

 找回密码
 注册(Register!)

QQ登录

只需一步,快速开始

搜索
购买霸主CDKEY 购买战帆CDKEY
查看: 2803|回复: 4

[功能与代码] 武器击倒众多敌人效果

[复制链接]

16

主题

131

回帖

204

积分

见习骑士

Rank: 3

UID
3304622
第纳尔
690
精华
0
互助
26
荣誉
3
贡献
0
魅力
158
注册时间
2021-12-28
鲜花(31) 鸡蛋(0)
发表于 2023-5-3 22:47:59 | 显示全部楼层 |阅读模式
本帖最后由 杰喵喵 于 2023-5-4 22:16 编辑

武器击倒众多敌人效果,主要是为了制作巨型兵种打击效果,可以在挥舞武器的范围内将敌人打倒在地,话不多说上代码与素材:

一、参考资料与素材来源:
1.[狂人的知识]较为精细的特技攻击判定方法 - MOD制作技术区 - 骑马与砍杀中文站论坛 - Powered by Discuz! (mountblade.com.cn)
2.骨骼拼接理论及应用---火影须佐能乎(代码) - MOD制作技术区 - 骑马与砍杀中文站论坛 - Powered by Discuz! (mountblade.com.cn)

3.动作地摊 - 模型贴图制作与交流区 - 骑马与砍杀中文站论坛 - Powered by Discuz! (mountblade.com.cn)

4. 花糕大佬关于动作的咨询解答

二、效果演示:

20230502-150946_单机游戏热门视频 (bilibili.com)

三、代码

(一)、module_animations
  1. ["fall_flyback1_near_rise", acf_enforce_all|acf_align_with_ground|acf_displace_position, amf_play|amf_priority_mount|amf_accurate_body|amf_client_prediction,
  2. [1.8, "ani_fall_flyback1_near_rise",0,43,arf_make_custom_sound,0, (0, -1.5, 0), 0.0],
  3. ],

  4. ["fall_flyback3_far_rise", acf_enforce_all|acf_align_with_ground|acf_displace_position, amf_play|amf_priority_mount|amf_accurate_body|amf_client_prediction,
  5. [3, "ani_fall_flyback3_far_rise",0,64,arf_make_custom_sound,0, (0, -4, 0), 0.0],
  6. ],
复制代码
(二)、module_scripts.py
  1. ("cf_attack_agent_play_sound",
  2. [
  3.   (store_script_param, ":agent_no", 1),
  4.   (store_script_param, ":value", 2),
  5.   
  6.   (agent_is_human,":agent_no"),
  7.   (agent_get_troop_id,":troop_id",":agent_no"),
  8.   (troop_get_type,":type",":troop_id"),
  9.   
  10.   (try_begin),
  11.     (eq,":type",tf_female),
  12.     (agent_play_sound,":agent_no", "snd_woman_hit"),
  13.   (else_try),
  14.     (is_between,":type",tf_undead,tf_undead_giant),
  15.     (agent_play_sound,":agent_no", "snd_undead_hit"),
  16.   (else_try),
  17.     (eq,":type",tf_undead_giant),
  18.     (agent_play_sound,":agent_no", "snd_undead_giant_hit"),
  19.   (else_try),
  20.     (agent_play_sound,":agent_no", "snd_man_hit"),
  21.   (try_end),
  22.   
  23.   (ge,":value",1),
  24.   (agent_get_horse,":horse",":agent_no"),
  25.   (try_begin),
  26.     (gt,":horse",-1),
  27.     #(agent_set_animation,":agent_no","anim_dismount_horse"),
  28.   (else_try),
  29.     (try_begin),
  30.         (ge,":value",2),
  31.         (agent_set_animation,":agent_no","anim_fall_flyback3_far_rise"),
  32.     (else_try),
  33.         (agent_set_animation,":agent_no","anim_fall_flyback1_near_rise"),
  34.     (try_end),
  35.     (agent_force_rethink,":agent_no"),
  36.   (try_end),
  37.   

  38.   
  39.   ]
  40.   ),
复制代码
  1.    ##########################################################奥杜因阿卡托什[狂人的知识]较为精细的特技攻击判定方法-开始 #########################################################
  2. #参考地址: [狂人的知识]较为精细的特技攻击判定方法  https://bbs.mountblade.com.cn/thread-2098687-1-1.html
  3. #input pos1, pos2 and origin position pos3.
  4. #pos1 is weapon end point, pos2 is enemy position, pos3 is player position
  5. #If pos1 and pos2 are in same direction of pos1 and long enough, return reg1 = 1, means can hit.
  6.   ("cf_position_check_hit", [
  7.       (set_fixed_point_multiplier, 100),
  8.       (assign, reg1, 0),
  9.       (get_distance_between_positions, ":cur_distance_1", pos1, pos3),#weapon attack range
  10.       (get_distance_between_positions, ":cur_distance_2", pos2, pos3),#enemy distance
  11.       (ge, ":cur_distance_1", ":cur_distance_2"),#can hit
  12.       (position_get_x, ":cur_x_1", pos1),
  13.       (position_get_y, ":cur_y_1", pos1),
  14.       (position_get_z, ":cur_z_1", pos1),
  15.       (position_get_x, ":cur_x_2", pos2),
  16.       (position_get_y, ":cur_y_2", pos2),
  17.       (position_get_z, ":cur_z_2", pos2),
  18.       (position_get_x, ":cur_x", pos3),
  19.       (position_get_y, ":cur_y", pos3),
  20.       (position_get_z, ":cur_z", pos3),
  21.       (val_sub, ":cur_x_1", ":cur_x"),
  22.       (val_sub, ":cur_y_1", ":cur_y"),
  23.       (val_sub, ":cur_z_1", ":cur_z"),
  24.       (val_sub, ":cur_x_2", ":cur_x"),
  25.       (val_sub, ":cur_y_2", ":cur_y"),
  26.       (val_sub, ":cur_z_2", ":cur_z"),
  27.       (val_mul, ":cur_x_1", ":cur_x_2"),
  28.       (val_mul, ":cur_y_1", ":cur_y_2"),
  29.       (val_mul, ":cur_z_1", ":cur_z_2"),
  30.       (store_add, ":numerator", ":cur_x_1", ":cur_y_1"),
  31.       (val_add, ":numerator", ":cur_z_1"),#x1*x2+y1*y2+z1*z2, dot product
  32.       (store_mul, ":denominator", ":cur_distance_1", ":cur_distance_2"),#magnitude1*magnitude2
  33. #cos=numerator/denominator. When cos equals 1, these two are in the same direction. We need their included angle to be within plus or minus 60 degrees, that is, cos must be greater than 0.5
  34. #But considering that Python may not be able to obtain 0.5, let's transform the inequality and apply 0.5 to the denominator side, that is, the numerator must be greater than the denominator multiplied by 0.5
  35. #      (val_mul, ":denominator", 9),
  36.       (val_div, ":denominator", 2),
  37.       (ge, ":numerator", ":denominator"),
  38.       (assign, reg1, 1),#can hit
  39.     ]),

  40.     ##########################################################奥杜因阿卡托什[狂人的知识]较为精细的特技攻击判定方法-结束#########################################################
复制代码
(三)、module_mission_templates.py
  1. <blockquote>init_weep_weapon_hit_check = (
复制代码
将上述代码引用在lead_charge等需要地方。

您需要登录后才可以回帖 登录 | 注册(Register!)

本版积分规则

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

GMT+8, 2025-12-21 08:23 , Processed in 0.097424 second(s), 20 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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