Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mod_name = "StaminaUIFix"
- -- Probably this isn't the cause of the bug, but OCD happens
- Mods.hook.set(mod_name, "FatigueUI.shield_state", function(func, self, shield_number, living_shields)
- local leftover = living_shields - shield_number
- if leftover >= 0 then
- return "state_1" -- full shield
- --edit--vv
- -- elseif leftover == -0.5 then
- elseif leftover >= -0.5 then
- return "state_2" -- half shield
- else
- return "state_3" -- no shield
- end
- end)
- Mods.hook.set(mod_name, "FatigueUI.update_shields", function(func, self, status_extension, dt)
- local current_fatigue = self.current_fatigue
- local fatigue_points, max_fatigue_points = status_extension:current_fatigue_points()
- if max_fatigue_points ~= self.max_fatigue_points then
- self:setup_hud(status_extension)
- end
- if fatigue_points == current_fatigue then
- return
- end
- local living_shields = max_fatigue_points * 0.5 - fatigue_points * 0.5
- local active_shields = self.active_shields
- local shields = self.shields
- for i = 1, active_shields, 1 do
- local shield = shields[i]
- local style = shield.style
- local current_state = shield.state
- local new_state = self:shield_state(i, living_shields)
- --edit--
- -- if current_state ~= new_state then
- -- local state_animations = style.state_animations[current_state]
- -- if state_animations and state_animations[new_state] then
- -- local animation_data = state_animations[new_state]
- -- UIWidget.animate(shield, UIAnimation.init(UIAnimation.picture_sequence, shield.content, "texture_id", animation_data.pictures, animation_data.time))
- -- else
- -- shield.content.texture_id = style.state_textures[new_state]
- -- end
- -- end
- local state_animations = style.state_animations[current_state]
- if state_animations and state_animations[new_state] then
- local animation_data = state_animations[new_state]
- -- Below is basically what UIWidget.animate does
- shield.break_animation = UIAnimation.init(UIAnimation.picture_sequence, shield.content, "texture_id", animation_data.pictures, animation_data.time)
- shield.animations[shield.break_animation] = true
- -- EchoConsole(shield.break_animation)
- else
- if new_state ~= "state_3" and shield.animations[shield.break_animation] then
- -- EchoConsole(shield.break_animation)
- shield.animations[shield.break_animation] = nil
- end
- shield.content.texture_id = style.state_textures[new_state]
- end
- --edit--
- shield.state = new_state
- end
- self.current_fatigue = fatigue_points
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement