本帖最后由 奥杜因阿卡托什 于 2024-3-3 21:55 编辑
https://bbs.mountblade.com.cn/thread-2092590-1-1.html新版血条看这个,优化了刷新需要的算力,并就高频刷新导致血条消失的问题作了修补。
由于老滚老环寿司神原这样,能够显示敌方血条的第三人称动作游戏我玩了很多,所以一直想给boss安个血条,今天终于得偿所愿做了个简单的血条。代码分享在下面,用的方法比较简单粗暴,贻笑大方了。
首先是最表层的mission_tamplate,将以下代码和那一串common_battle_XXXX = 并列:
common_boss_battle_lifebar = (
0, 0, ti_once, [
(call_script, "script_get_boss"),
(assign, ":cur_boss_1", reg1),
(assign, ":distance", reg4),
(assign, ":show_or_not", 0),
(try_for_agents, ":agent_no"),
(gt, ":cur_boss_1", 0),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(eq, ":troop_no", ":cur_boss_1"),
(agent_is_alive, ":agent_no"),
(agent_get_position, pos1, ":agent_no"),
(get_player_agent_no, ":player_no"),
(agent_get_position, pos2, ":player_no"),
(get_distance_between_positions_in_meters, ":cur_distance", pos1, pos2),
(le, ":cur_distance", ":distance"), #caculate the distance
(display_message, "@a"),
(assign, ":show_or_not", 1),
(try_end),
(neq, ":show_or_not", 0),
],
[
(start_presentation, "prsnt_boss_lifebar"),
])
这个代码的作用时当玩家第一次进入boss周围(距离接下来会设定)时,开始血条的presentation。
这个common也要和其他common_battle一样,加在需要用到它的mt下面。
然后是pesentation,代码如下:
("boss_lifebar", prsntf_read_only,0,[
(ti_on_presentation_load,
[(set_fixed_point_multiplier, 1000),
(call_script, "script_get_boss"),
(assign, ":cur_boss_1", reg1),
(assign, "$boss_1_display", 0),
(try_begin),
(gt, ":cur_boss_1", 0),
(assign, ":boss_hp", 0),
(try_for_agents, ":agent_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(eq, ":troop_no", ":cur_boss_1"),
(store_agent_hit_points, ":boss_hp", ":agent_no"),
(try_end),
(neq, ":boss_hp", 0),
(create_mesh_overlay, "$g_presentation_obj_1", "mesh_progressbar_handle"),
(position_set_x, pos1, 180),
(position_set_y, pos1, 700),
(overlay_set_position, "$g_presentation_obj_1", pos1),
(create_mesh_overlay, reg1, "mesh_progressbar"),
(position_set_x, pos1, 180),
(position_set_y, pos1, 700),
(overlay_set_position, reg1, pos1),
(str_store_troop_name, s1, ":cur_boss_1"),
(create_text_overlay, reg1, s1),
(position_set_x, pos1, 180),
(position_set_y, pos1, 710),
(overlay_set_position, reg1, pos1),
(position_set_x, pos1, 800),
(position_set_y, pos1, 800),
(overlay_set_size, reg1, pos1),
(overlay_set_color, reg1, 0xffffff),
(assign, "$boss_1_display", 1),
(try_end),
(presentation_set_duration, 999999),
]),
(ti_on_presentation_run,
[
(call_script, "script_get_boss"),
(assign, ":cur_boss_1", reg1),
(try_begin),
(gt, ":cur_boss_1", 0),
(try_for_agents, ":agent_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(eq, ":troop_no",":cur_boss_1"),
(try_begin),
(agent_is_alive, ":agent_no"),
(store_agent_hit_points, ":boss_hp", ":agent_no"),
(val_mul, ":boss_hp", 10),
(position_set_x, pos1, ":boss_hp"),
(position_set_y, pos1, 1000),
(overlay_set_size, "$g_presentation_obj_1", pos1),
(else_try),
(neg|agent_is_alive, ":agent_no"),
(eq, "$boss_1_display", 1),
(overlay_set_display, "$g_presentation_obj_1", 0),
(try_end),
(try_end),
(try_end),
(try_begin),
(is_presentation_active, "prsnt_boss_lifebar"),
(game_key_clicked, gk_view_orders),
(presentation_set_duration, 0),
(start_presentation, "prsnt_battle"),
(try_end),
]),
]),
加在最后一个]之前就行。这是一个只读格式的prsnt,因此不会影响正常攻击等的操作。
用来定义boss的script,代码如下:
("get_boss", [ #use for get boss id
(assign, ":boss_1", 0),
(assign, ":distance", 0), #to caculate in how far will the lifebar display, in the other hand can decide if the lifebar should display
(store_current_scene, ":cur_scene"),
(try_begin),
(check_quest_active, "qst_save_town_from_bandits"),
(party_get_slot, ":town_scene", "$g_starting_town", slot_town_center), #trp_devilman_berserker_mission
(eq, ":cur_scene", ":town_scene"),
(assign, ":boss_1", "trp_devilman_berserker_mission"),
(assign, ":distance", 20),#20 meter
(try_end),
(assign, reg1, ":boss_1"),
(assign, reg4, ":distance"),
]),
只要在中间那个try里面设定好boss是哪个兵种就行了,这个兵种出现、满足条件时血条就会显示。“:distance”便是之前说的距离,一样是在这里设置。
最后还有一个小尾巴,在presentation里,“battle”这个prsnt里,最后一个(try_end),前加上 (start_presentation, "prsnt_boss_lifebar"),作用是关闭战场面板时同时打开血条,战场面板和血条不能兼容,但这样至少能无缝切换。这部分来自Rubik前辈的兵种对比条,特此感谢。
以上便是boss血条的代码,像这样只能允许单boss,但是简单加工(ctrlc、v)之后就能允许多boss,就像附图中那个双人组一样。我自己用的是最高容纳三人的(腐败结晶人并感)
|