本帖最后由 vegetto 于 2024-2-23 14:32 编辑
主要应用于我的骑马与砍杀魔兽争霸mod里的丛林守护者的树根缠绕技能(https://bbs.mountblade.com.cn/forum.php?mod=viewthread&tid=2099079),
首先如下链接是树根缠绕的顶点动画源文件(凡是出现过捐赠、二维码等各种方式变相收费的mod,不可以使用本素材)
链接:https://pan.baidu.com/s/1gXrglp7b0rUpZ_--6HxW2A?pwd=7456
动画效果是一组树根从地面出来,螺旋收缩向中心缠绕,然后一段时间后收回到地面,具体参考视频
()
以下是使用代码参考,由于关联比较杂,包含了人物其他行为定义和其他三个技能,我暂时无空慢慢剥离纯净版来注释,我把关键部分的地方红色加粗一下,
(call_script, "script_warcraftrolecontrolmainway"),
(set_fixed_point_multiplier, 1000),
(get_player_agent_no, ":var_0"),
(agent_set_slot, ":var_0", 331, 1),
(agent_set_slot, ":var_0", 332, "itm_rangeattack4"),
(agent_get_team, ":var_1", ":var_0"),
(agent_get_position, pos30, ":var_0"),
(store_add, ":var_2", "$heroswitch", 647),
(troop_get_slot, ":var_3", "trp_player", ":var_2"),
(scene_prop_get_instance, ":var_4", ":var_3", 0),
(2616, ":var_5", ":var_4"),
(prop_instance_get_position, pos32, ":var_4"),
(position_copy_rotation, pos32, pos30),
(troop_get_slot, ":var_6", "trp_player", 729),
(troop_get_slot, ":var_7", "trp_player", 730),
(troop_get_slot, ":var_8", "trp_player", 731),
(troop_get_slot, ":var_9", "trp_player", 732),
(scene_prop_get_num_instances, ":var_10", "spr_eftwrap"),
(try_begin),
(eq, ":var_10", 0),
(troop_set_slot, "trp_651", 733, 1),
(copy_position, pos33, pos32),
(position_move_y, pos33, -10000),
(position_move_z, pos33, -10000),
(set_spawn_position, pos33),
(spawn_scene_prop, "spr_eftwrap"),
(scene_prop_set_slot, reg0, 200, -1),
(scene_prop_set_visibility, reg0, 0),
(2612, reg0, 0, 980, 8000), #这边是为了刷树根缠绕的顶点动画场景物spr_eftwrap,初始化位置、动画、场景物类别、隐身
(set_spawn_position, pos33),
(spawn_scene_prop, "spr_litneft2"),
(scene_prop_set_visibility, reg0, 0),
(2612, reg0, 0, 390, 400),
(assign, reg21, 410024),
(str_store_string, s21, "str_mjb"),
(2617, reg0, -1, 21),
(scene_prop_set_slot, reg0, 200, -1),
(troop_set_slot, "trp_player", 581, "spr_litneft2"),
(prop_instance_set_scale, reg0, 3000, 3000, 3000),
(set_spawn_position, pos33),
(spawn_scene_prop, "spr_lntburst"),
(scene_prop_set_visibility, reg0, 0),
(2612, reg0, 0, 380, 500),
(scene_prop_set_slot, reg0, 200, -1),
(troop_set_slot, "trp_player", 582, "spr_lntburst"),
(set_spawn_position, pos33),
(spawn_scene_prop, "spr_jqtf"),
(scene_prop_set_slot, reg0, 200, -1),
(scene_prop_set_visibility, reg0, 0),
(2612, reg0, 0, 300, 400),
(troop_set_slot, "trp_player", 583, "spr_jqtf"),
(set_spawn_position, pos33),
(spawn_scene_prop, "spr_litneft"),
(scene_prop_set_slot, reg0, 200, -1),
(scene_prop_set_visibility, reg0, 0),
(2612, reg0, 0, 390, 500),
(troop_set_slot, "trp_player", 584, "spr_litneft"),
(try_end),
(eq, ":var_10", 1),
(try_begin), #这边是为了树根缠绕动画场景物及其他类似场景物刷出特定数量后开始执行下面的技能判断
(assign, reg0, ":var_4"),
(try_begin),
(troop_slot_eq, "trp_player", 679, 0),
(assign, reg21, 900091),
(str_store_string, s21, "str_mjb"),
(2617, reg0, -1, 21),
(troop_set_slot, "trp_player", 650, 900115),
(troop_set_slot, "trp_player", 651, 900115),
(troop_set_slot, "trp_player", 652, 900111),
(troop_set_slot, "trp_player", 653, 900112),
(troop_set_slot, "trp_player", 654, 900113),
(troop_set_slot, "trp_player", 655, 900114),
(else_try),
(troop_slot_eq, "trp_player", 679, 1),
(assign, reg21, 900092),
(str_store_string, s21, "str_mjb"),
(2617, reg0, -1, 21),
(troop_set_slot, "trp_player", 650, 900115),
(troop_set_slot, "trp_player", 651, 900115),
(troop_set_slot, "trp_player", 652, 900111),
(troop_set_slot, "trp_player", 653, 900112),
(troop_set_slot, "trp_player", 654, 900113),
(troop_set_slot, "trp_player", 655, 900114),
(try_end),
(scene_prop_set_slot, reg0, 101, 0),
(scene_prop_set_slot, reg0, 102, 630),
(scene_prop_set_slot, reg0, 103, 89990),
(scene_prop_set_slot, reg0, 104, 99990),
(scene_prop_set_slot, reg0, 105, 5620),
(scene_prop_set_slot, reg0, 106, 5870),
(scene_prop_set_slot, reg0, 107, 89990),
(scene_prop_set_slot, reg0, 108, 99990),
(scene_prop_set_slot, reg0, 115, 1610),
(scene_prop_set_slot, reg0, 116, 1770),
(scene_prop_set_slot, reg0, 117, 1610),
(scene_prop_set_slot, reg0, 118, 1770),
(scene_prop_set_slot, reg0, 119, 4200),
(scene_prop_set_slot, reg0, 120, 4570),
(scene_prop_set_slot, reg0, 121, 2590),
(scene_prop_set_slot, reg0, 122, 4190),
(scene_prop_set_slot, reg0, 123, 1780),
(scene_prop_set_slot, reg0, 124, 2040),
(scene_prop_set_slot, reg0, 125, 4580),
(scene_prop_set_slot, reg0, 126, 4930),
(scene_prop_set_slot, reg0, 127, 89990),
(scene_prop_set_slot, reg0, 128, 99990),
(scene_prop_set_slot, reg0, 129, 89990),
(scene_prop_set_slot, reg0, 130, 99990),
(scene_prop_set_slot, reg0, 131, 89990),
(scene_prop_set_slot, reg0, 132, 99990),
(scene_prop_set_slot, reg0, 133, 89990),
(scene_prop_set_slot, reg0, 134, 99990),
(scene_prop_set_slot, reg0, 135, 6400),
(scene_prop_set_slot, reg0, 136, 3600),
(scene_prop_set_slot, reg0, 137, 2400),
(scene_prop_set_slot, reg0, 138, 1200),
(scene_prop_set_slot, reg0, 139, 1200),
(scene_prop_set_slot, reg0, 140, 1500),
(scene_prop_set_slot, reg0, 141, 1800),
(scene_prop_set_slot, reg0, 142, 2400),
(scene_prop_set_slot, reg0, 143, 2000),
(scene_prop_set_slot, reg0, 144, 3000),
(scene_prop_set_slot, reg0, 145, 300),
(scene_prop_set_slot, reg0, 146, 300),
(scene_prop_set_slot, reg0, 147, 500),
(store_random_in_range, ":var_11", 0, 100),
(try_begin),
(is_between, ":var_11", 0, 50),
(assign, ":var_12", 10230),
(assign, ":var_13", 10560),
(assign, ":var_14", 10600),
(assign, ":var_15", 10820),
(assign, ":var_16", 11090),
(assign, ":var_17", 11270),
(else_try),
(is_between, ":var_11", 50, 75),
(assign, ":var_12", 11400),
(assign, ":var_13", 11670),
(assign, ":var_14", 11770),
(assign, ":var_15", 12010),
(assign, ":var_16", 12380),
(assign, ":var_17", 12700),
(else_try),
(is_between, ":var_11", 75, 100),
(assign, ":var_12", 11400),
(assign, ":var_13", 11670),
(assign, ":var_14", 11770),
(assign, ":var_15", 12010),
(assign, ":var_16", 12380),
(assign, ":var_17", 12700),
(try_end),
(try_begin),
(neg|is_between, ":var_5", 10100, 12800),
(scene_prop_set_slot, reg0, 109, ":var_12"),
(scene_prop_set_slot, reg0, 110, ":var_13"),
(scene_prop_set_slot, reg0, 111, ":var_14"),
(scene_prop_set_slot, reg0, 112, ":var_15"),
(scene_prop_set_slot, reg0, 113, ":var_16"),
(scene_prop_set_slot, reg0, 114, ":var_17"),
(try_end), #以上一大堆黑体字都是为了定义顶点动画场景物类别的英雄人物各种行为的动画区间值
(try_end),
(try_begin),
(agent_get_slot, ":var_18", ":var_0", 503), #agentslot503号表示我的人物四个英雄技能的一技能的进程控制,0-3为技能无释放阶段,3-3000为技能释放阶段,但是受到动画最终帧数的限制,完整播放一次到终点帧就会终止本技能。
(scene_prop_get_instance, ":var_19", "spr_eftwrap", 0),
(2616, ":var_20", ":var_19"),
(try_begin),
(is_between, ":var_18", 0, 3),
(position_set_x, pos33, -500000),
(position_set_y, pos33, -500000),
(position_set_z, pos33, -500000),
(prop_instance_set_position, ":var_19", pos33),
(scene_prop_set_visibility, ":var_19", 0),
(2612, ":var_19", 0, 980, 8000),
(else_try),
(is_between, ":var_18", 3, 3000), #然后注意agentslot503这个量从0-3000再回归0的触发是在我其他触发器统一安排各技能持续时间变化的,变化情况是根据不同英雄触发指定的持续时间长度如本英雄的0-3000,按释放技能后slot由0变1,由1自动+1到3000,然后3000时归0。
(try_begin),
(eq, ":var_18", 3),
(scene_prop_set_visibility, ":var_19", 1),
(copy_position, pos33, pos32),
(position_move_y, pos33, 400),
(position_move_z, pos33, 1000),
(position_set_z_to_ground_level, pos33),
(prop_instance_set_position, ":var_19", pos33),
(else_try),
(is_between, ":var_18", 5, 2998),
(try_begin),
(neg|is_between, ":var_20", 0, 900), #下面两句意思就是人物动画帧时刻不在0-900,也就是跑到900-980已经回收下地的动画帧时刻区间时,强制让slot503号的值变成2999,然后由其他技能持续时间控制的触发器使得2999到3000再归0,停止技能效果
(agent_set_slot, ":var_0", 503, 2999),
(try_end),
(is_between, ":var_20", 300, 700), #下面就是动画帧时刻位于300-700,也就是缠绕树根成形状态时,形成伤害效果,由于人物伤害硬直时喜欢乱动,所以采用扣除生命值百分比的方式。
(try_for_agents, ":var_21"),
(agent_is_alive, ":var_21"),
(agent_is_human, ":var_21"),
(agent_get_team, ":var_22", ":var_21"),
(neg|eq, ":var_22", ":var_1"),
(neg|eq, ":var_22", 5),
(neg|eq, ":var_22", 6),
(prop_instance_get_position, pos33, ":var_19"),
(agent_get_position, pos34, ":var_21"),
(get_distance_between_positions, ":var_23", pos33, pos34),
(neg|ge, ":var_23", 250),
(agent_slot_eq, ":var_0", 329, 0), #329slot写在其他触发器中,代表技能伤害间隔,以329slot每次为0触发伤害代表了伤害间隔为1/2秒
(store_agent_hit_points, ":var_24", ":var_21", 0),
(val_sub, ":var_24", 3),
(val_max, ":var_24", 1),
(agent_set_hit_points, ":var_21", ":var_24", 0),
(try_end),
(try_end),
(try_end),
(try_end),
(try_begin),
(agent_get_slot, ":var_18", ":var_0", 504),
(scene_prop_get_instance, ":var_19", "spr_litneft2", 0),
(scene_prop_get_instance, ":var_25", "spr_jqtf", 0),
(try_begin),
(is_between, ":var_18", 0, 3),
(position_set_x, pos33, -500000),
(position_set_y, pos33, -500000),
(position_set_z, pos33, -500000),
(prop_instance_set_position, ":var_19", pos33),
(scene_prop_set_visibility, ":var_19", 0),
(scene_prop_set_visibility, ":var_25", 0),
(2612, ":var_19", 0, 380, 500),
(else_try),
(is_between, ":var_18", 3, 300),
(try_begin),
(eq, ":var_18", 3),
(scene_prop_set_visibility, ":var_19", 1),
(scene_prop_set_visibility, ":var_25", 0),
(copy_position, pos33, pos32),
(position_move_y, pos33, 800),
(position_move_z, pos33, 1000),
(position_set_z_to_ground_level, pos33),
(prop_instance_set_position, ":var_19", pos33),
(prop_instance_set_position, ":var_25", pos33),
(else_try),
(try_begin),
(store_mod, ":var_26", ":var_18", 20),
(eq, ":var_26", 0),
(prop_instance_get_position, pos34, ":var_25"),
(store_random_in_range, ":var_27", -180, 180),
(store_random_in_range, ":var_28", -800, 800),
(position_rotate_z, pos34, ":var_27"),
(position_move_y, pos34, ":var_28"),
(prop_instance_set_position, ":var_19", pos34),
(try_end),
(try_for_agents, ":var_21"),
(agent_is_alive, ":var_21"),
(agent_is_human, ":var_21"),
(agent_get_team, ":var_22", ":var_21"),
(neg|eq, ":var_22", ":var_1"),
(neg|eq, ":var_22", 5),
(neg|eq, ":var_22", 6),
(prop_instance_get_position, pos33, ":var_19"),
(agent_get_position, pos34, ":var_21"),
(get_distance_between_positions, ":var_23", pos33, pos34),
(neg|ge, ":var_23", 250),
(agent_deliver_damage_to_agent, ":var_0", ":var_21", ":var_8"),
(try_end),
(try_end),
(try_end),
(try_end),
(try_begin),
(agent_get_slot, ":var_18", ":var_0", 505),
(scene_prop_get_instance, ":var_19", "spr_litneft", 1),
(2616, ":var_20", ":var_19"),
(try_begin),
(is_between, ":var_18", 0, 3),
(position_set_x, pos33, -500000),
(position_set_y, pos33, -500000),
(position_set_z, pos33, -500000),
(prop_instance_set_position, ":var_19", pos33),
(scene_prop_set_visibility, ":var_19", 0),
(2612, ":var_19", 0, 390, 500),
(else_try),
(is_between, ":var_18", 3, 300),
(try_begin),
(eq, ":var_18", 3),
(scene_prop_set_visibility, ":var_19", 1),
(copy_position, pos33, pos32),
(position_move_y, pos33, 500),
(position_move_z, pos33, 1000),
(position_set_z_to_ground_level, pos33),
(prop_instance_set_position, ":var_19", pos33),
(else_try),
(ge, ":var_18", 5),
(try_for_agents, ":var_21"),
(agent_is_alive, ":var_21"),
(agent_is_human, ":var_21"),
(agent_get_team, ":var_22", ":var_21"),
(neg|eq, ":var_22", ":var_1"),
(neg|eq, ":var_22", 5),
(neg|eq, ":var_22", 6),
(prop_instance_get_position, pos33, ":var_19"),
(agent_get_position, pos34, ":var_21"),
(get_distance_between_positions, ":var_23", pos33, pos34),
(neg|ge, ":var_23", 350),
(agent_slot_eq, ":var_0", 329, 0),
(agent_deliver_damage_to_agent, ":var_0", ":var_21", ":var_8"),
(try_end),
(try_end),
(try_end),
(try_end),
(try_begin),
(agent_get_slot, ":var_18", ":var_0", 506),
(scene_prop_get_instance, ":var_19", "spr_lntburst", 0),
(try_begin),
(is_between, ":var_18", 0, 3),
(position_set_x, pos33, -500000),
(position_set_y, pos33, -500000),
(position_set_z, pos33, -500000),
(prop_instance_set_position, ":var_19", pos33),
(scene_prop_set_visibility, ":var_19", 0),
(2612, ":var_19", 0, 380, 500),
(else_try),
(is_between, ":var_18", 3, 500),
(copy_position, pos33, pos32),
(prop_instance_set_position, ":var_19", pos33),
(scene_prop_set_visibility, ":var_19", 1),
(try_for_agents, ":var_21"),
(agent_is_alive, ":var_21"),
(agent_is_human, ":var_21"),
(agent_get_team, ":var_22", ":var_21"),
(neg|eq, ":var_22", ":var_1"),
(neg|eq, ":var_22", 5),
(neg|eq, ":var_22", 6),
(agent_get_position, pos34, ":var_21"),
(get_distance_between_positions, ":var_23", pos33, pos34),
(neg|ge, ":var_23", 550),
(agent_slot_eq, ":var_0", 329, 0),
(agent_deliver_damage_to_agent, ":var_0", ":var_21", ":var_9"),
(try_end),
(try_end),
(try_end),
|