Advertisement
Vatinas

Darktide mod - Holier Revenant - Temporary fix

Nov 17th, 2023 (edited)
860
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.75 KB | None | 0 0
  1. local mod = get_mod("holier_revenant")
  2.  
  3. local UIWorkspaceSettings = require("scripts/settings/ui/ui_workspace_settings")
  4. local UIWidget = require("scripts/managers/ui/ui_widget")
  5. local UIFontSettings = require("scripts/managers/ui/ui_font_settings")
  6. local UISoundEvents = require("scripts/settings/ui/ui_sound_events")
  7.  
  8. local UIHudSettings = require("scripts/settings/ui/ui_hud_settings")
  9. local get_hud_color = UIHudSettings.get_hud_color
  10.  
  11. local buff_name_hr = "zealot_resist_death_improved_with_leech"
  12. local buff_name_ud = "zealot_resist_death"
  13.  
  14. local settings = {
  15.     icon_size = { 92, 80 },
  16.     icon_margin = 20,
  17.     frame = {
  18.         size = { 128, 128 },
  19.         glow_colour = { 255, 255, 255, 255 },
  20.         active_colour = { 255, 181, 196, 167 },
  21.         inactive_colour = { 255, 115, 121, 109 }
  22.     },
  23.     triangles = {
  24.         offset = { 25, 40 },
  25.         colour = { 0, 0, 0, 255 }
  26.     },
  27.     icon_path = "content/ui/textures/icons/talents/zealot_2/zealot_2_base_2"
  28. }
  29.  
  30. settings.icon_position = {
  31.     -450 - settings.icon_size[1] - settings.icon_margin,
  32.     -40,
  33.     1
  34. }
  35.  
  36. local sg_defs = {
  37.     screen = UIWorkspaceSettings.screen,
  38.     icon = {
  39.         vertical_alignment = "bottom",
  40.         parent = "screen",
  41.         horizontal_alignment = "right",
  42.         size = settings.icon_size,
  43.         position = settings.icon_position
  44.     }
  45. }
  46.  
  47. local counter_text_style = table.clone(UIFontSettings.hud_body)
  48. counter_text_style.horizontal_alignment = "center"
  49. counter_text_style.vertical_alignment = "center"
  50. counter_text_style.text_horizontal_alignment = "center"
  51. counter_text_style.text_vertical_alignment = "center"
  52. counter_text_style.size = settings.icon_size
  53. counter_text_style.text_color = { 255, 255, 192, 0 }
  54. counter_text_style.font_type = "machine_medium"
  55. counter_text_style.font_size = 32
  56. counter_text_style.offset = { 0, 0, 2 }
  57. counter_text_style.drop_shadow = true
  58.  
  59. local widget_defs = {
  60.     icon = UIWidget.create_definition({
  61.         {
  62.             value_id = "counter_text",
  63.             style_id = "counter_text",
  64.             pass_type = "text",
  65.             value = "",
  66.             style = counter_text_style
  67.         }, {
  68.             style_id = "ability_frame_container",
  69.             pass_type = "texture",
  70.             value = "content/ui/materials/icons/talents/hud/combat_container",
  71.             style = {
  72.                 material_values = {
  73.                     progress = 1,
  74.                     talent_icon = settings.icon_path
  75.                 },
  76.                 offset = { 0, 0, 0 },
  77.                 color = { 255, 126, 255, 255 }
  78.             },
  79.             visibility_function = function(content, style)
  80.                 return mod:get_cached("use_ability_frame")
  81.             end
  82.         }, {
  83.             value = "content/ui/materials/icons/talents/hud/combat_frame_inner",
  84.             style_id = "ability_frame_inner",
  85.             pass_type = "texture",
  86.             style = {
  87.                 vertical_alignment = "center",
  88.                 horizontal_alignment = "center",
  89.                 offset = { 0, 0, 3 },
  90.                 color = settings.frame.active_colour,
  91.                 size = settings.frame.size
  92.             },
  93.             visibility_function = function(content, style)
  94.                 return mod:get_cached("use_ability_frame")
  95.             end
  96.         }, {
  97.             value = "content/ui/materials/icons/buffs/hud/buff_frame",
  98.             style_id = "basic_frame",
  99.             pass_type = "texture",
  100.             style = {
  101.                 vertical_alignment = "center",
  102.                 horizontal_alignment = "center",
  103.                 size = { 118, 118 },
  104.                 offset = { 0, 0, 3 },
  105.                 color = { 220, 216, 229, 207 }
  106.             },
  107.             visibility_function = function(content, style)
  108.                 return not mod:get_cached("use_ability_frame")
  109.             end
  110.         }, {
  111.             value = "content/ui/materials/icons/buffs/hud/buff_container_with_background",
  112.             style_id = "basic_frame_container",
  113.             pass_type = "texture",
  114.             style = {
  115.                 vertical_alignment = "center",
  116.                 horizontal_alignment = "center",
  117.                 material_values = {
  118.                     progress = 1,
  119.                     talent_icon = settings.icon_path
  120.                 },
  121.                 offset = { 0, 0, 0 },
  122.                 size = { 72, 72 },
  123.                 color = settings.frame.active_colour
  124.             },
  125.             visibility_function = function(content, style)
  126.                 return not mod:get_cached("use_ability_frame")
  127.             end
  128.         }, {
  129.             value = "content/ui/materials/effects/hud/combat_talent_glow",
  130.             style_id = "ability_frame_glow",
  131.             pass_type = "texture",
  132.             style = {
  133.                 vertical_alignment = "center",
  134.                 horizontal_alignment = "center",
  135.                 offset = { 0, 0, 4 },
  136.                 color = settings.frame.glow_colour,
  137.                 size = settings.frame.size
  138.             },
  139.             visibility_function = function(content, style)
  140.                 return mod:get_cached("use_ability_frame")
  141.             end
  142.         }, {
  143.             style_id = "triangle_top_left",
  144.             pass_type = "triangle",
  145.             style = {
  146.                 offset = { 0, 0, 1 },
  147.                 color = settings.triangles.colour,
  148.                 triangle_corners = {
  149.                     { 0, 0 },
  150.                     { settings.triangles.offset[1], 0 },
  151.                     { 0, settings.triangles.offset[2] }
  152.                 }
  153.             },
  154.             visibility_function = function(content, style)
  155.                 return mod:get_cached("use_ability_frame")
  156.             end
  157.         }, {
  158.             style_id = "triangle_top_right",
  159.             pass_type = "triangle",
  160.             style = {
  161.                 offset = { settings.icon_size[1], 0, 1 },
  162.                 color = settings.triangles.colour,
  163.                 triangle_corners = {
  164.                     { 0, 0 },
  165.                     { -settings.triangles.offset[1], 0 },
  166.                     { 0, settings.triangles.offset[2] }
  167.                 }
  168.             },
  169.             visibility_function = function(content, style)
  170.                 return mod:get_cached("use_ability_frame")
  171.             end
  172.         }, {
  173.             style_id = "triangle_bottom_left",
  174.             pass_type = "triangle",
  175.             style = {
  176.                 offset = { 0, settings.icon_size[2], 1 },
  177.                 color = settings.triangles.colour,
  178.                 triangle_corners = {
  179.                     { 0, 0 },
  180.                     { settings.triangles.offset[1], 0 },
  181.                     { 0, -settings.triangles.offset[2] }
  182.                 }
  183.             },
  184.             visibility_function = function(content, style)
  185.                 return mod:get_cached("use_ability_frame")
  186.             end
  187.         }, {
  188.             style_id = "triangle_bottom_right",
  189.             pass_type = "triangle",
  190.             style = {
  191.                 offset = { settings.icon_size[1], settings.icon_size[2], 1 },
  192.                 color = settings.triangles.colour,
  193.                 triangle_corners = {
  194.                     { 0, 0 },
  195.                     { -settings.triangles.offset[1], 0 },
  196.                     { 0, -settings.triangles.offset[2] }
  197.                 }
  198.             },
  199.             visibility_function = function(content, style)
  200.                 return mod:get_cached("use_ability_frame")
  201.             end
  202.         }
  203.     }, "icon")
  204. }
  205.  
  206. local HudElementHolierRevenant = class("HudElementHolierRevenant", "HudElementBase")
  207.  
  208. HudElementHolierRevenant.init = function(self, parent, draw_layer, start_scale, ...)
  209.     HudElementHolierRevenant.super.init(self, parent, draw_layer, start_scale, {
  210.         scenegraph_definition = sg_defs,
  211.         widget_definitions = widget_defs
  212.     })
  213.  
  214.     self._player_unit = parent:player_unit()
  215. end
  216.  
  217. HudElementHolierRevenant.update = function(self, dt, t, ui_renderer,
  218.         render_settings, input_service)
  219.     HudElementHolierRevenant.super.update(self, dt, t, ui_renderer,
  220.         render_settings, input_service)
  221.  
  222.     local widget = self._widgets_by_name.icon
  223.     widget.visible = false
  224.  
  225.     if self._player_unit then
  226.         local buff_extension = ScriptUnit.extension(self._player_unit, "buff_system")
  227.  
  228.         if buff_extension and buff_extension._buffs then
  229.             for i = 1, #buff_extension._buffs do
  230.                 local buff = buff_extension._buffs[i]
  231.                 local template = buff._template
  232.  
  233.                 if buff._template_name == buff_name_hr or buff._template_name == buff_name_ud then
  234.                     local cd = template.cooldown_duration + 5
  235.                     local active_start_time = buff._active_start_time
  236.                     local lapsed = Managers.time:time("gameplay") - active_start_time
  237.  
  238.                     if lapsed < cd then
  239.                         if mod:get("gradual_background_update") then
  240.                             local pc = lapsed / cd
  241.                             widget.style.ability_frame_container.material_values.progress = pc
  242.                             widget.style.basic_frame_container.material_values.progress = pc
  243.                         else
  244.                             widget.style.ability_frame_container.material_values.progress = 0
  245.                             widget.style.basic_frame_container.material_values.progress = 0
  246.                         end
  247.  
  248.                         widget.style.ability_frame_inner.color = settings.frame.inactive_colour
  249.                         widget.style.ability_frame_container.color = get_hud_color("color_tint_main_4", 200)
  250.                         widget.style.basic_frame_container.color = settings.frame.inactive_colour
  251.                         widget.style.basic_frame.color = settings.frame.inactive_colour
  252.                         widget.style.ability_frame_glow.visible = false
  253.                         widget.content.counter_text = string.format("%.0f", (cd - lapsed))
  254.                     elseif widget.style.ability_frame_container.material_values.progress ~= 1 then
  255.                         widget.style.basic_frame_container.material_values.progress = 1
  256.                         widget.style.ability_frame_container.material_values.progress = 1
  257.                         widget.style.ability_frame_container.color = settings.frame.active_colour
  258.                         widget.style.ability_frame_inner.color = settings.frame.active_colour
  259.                         widget.style.basic_frame_container.color = settings.frame.active_colour
  260.                         widget.style.basic_frame.color = { 220, 216, 229, 207 }
  261.                         widget.style.ability_frame_glow.visible = true
  262.                         widget.content.counter_text = " "
  263.                         Managers.ui:play_2d_sound(UISoundEvents.ability_off_cooldown)
  264.                     end
  265.  
  266.                     widget.visible = true
  267.                 end
  268.             end
  269.         end
  270.     end
  271.  
  272.     widget.dirty = true
  273. end
  274.  
  275. return HudElementHolierRevenant
  276.  
Advertisement
Comments
  • Vatinas
    186 days
    # text 0.15 KB | 0 0
    1. For installation instructions, please refer to my (Vatinas) comment on the following page:
    2. https://www.nexusmods.com/warhammer40kdarktide/mods/72?tab=posts
Add Comment
Please, Sign In to add comment
Advertisement