Advertisement
VernonKun

fix_rat_fall_anim_skip

Nov 30th, 2020
1,125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. -- fix for rats skipping landing animation
  2. --
  3. -- Xq & VernonKun 2020
  4. --
  5. -- This adjustment is intended to work with QoL modpack
  6. -- To "install" copy the file to "steamapps\common\Warhammer End Times Vermintide\binaries\mods\patch"
  7.  
  8. local mod_name = "fix_rat_fall_anim_skip"
  9.  
  10.  
  11. local clear_jump_climb_finished = function(blackboard)
  12.     -- EchoConsole("jump_climb_finished set to nil")
  13.     blackboard.jump_climb_finished = nil
  14.     return
  15. end
  16.  
  17. local set_jump_climb_finished = function(blackboard)
  18.     -- EchoConsole("jump_climb_finished set to true")
  19.     blackboard.jump_climb_finished = true
  20.     return
  21. end
  22.  
  23. local JUMP_CLIMB_FINISHED_DELAY = 0.06  -- seconds
  24. local JUMP_CLIMB_FAILSAFE_TIME  = 3     -- seconds
  25. local mod_fall_data = {}
  26.  
  27. Mods.hook.set(mod_name , "BTFallAction.enter", function(func, self, unit, blackboard, t)
  28.     local ret = func(self, unit, blackboard, t)
  29.     clear_jump_climb_finished(blackboard)
  30.     -- mod_fall_data[unit] = nil
  31.     return ret
  32. end)
  33.  
  34. Mods.hook.set(mod_name , "BTFallAction.run", function(func, self, unit, blackboard, t, dt)
  35.    
  36.     -- if not mod_fall_data[unit] then
  37.         -- mod_fall_data[unit] =
  38.         -- {
  39.             -- land_start_time  = nil,
  40.             -- last_climb_state = "",
  41.             -- last_climb_state_1   = "",
  42.         -- }
  43.     -- end
  44.    
  45.     if blackboard.climb_state ==  "waiting_to_collide_down" and blackboard.jump_climb_finished then
  46.         clear_jump_climb_finished(blackboard)
  47.     end
  48.  
  49.     -- if blackboard.climb_state == "waiting_to_land" and mod_fall_data[unit].last_climb_state_1 == "waiting_to_collide_down" then
  50.         -- mod_fall_data[unit].land_start_time = t
  51.     -- end
  52.    
  53.     -- local land_started       = mod_fall_data[unit].land_start_time
  54.     -- local land_duration  = land_started and t - land_started
  55.    
  56.     -- if land_started and land_duration > JUMP_CLIMB_FAILSAFE_TIME then
  57.         -- EchoConsole("stuck in fall loop:" .. tostring(unit))
  58.         -- set_jump_climb_finished(blackboard)
  59.     -- end
  60.  
  61.     -- if land_started and blackboard.climb_state == "waiting_to_land" and blackboard.jump_climb_finished then
  62.         -- EchoConsole(land_duration)
  63.         -- if land_duration < JUMP_CLIMB_FINISHED_DELAY then
  64.             -- EchoConsole("bugged land found")
  65.             -- clear_jump_climb_finished(blackboard)
  66.         -- else
  67.             -- mod_fall_data[unit].land_start_time = nil
  68.         -- end
  69.     -- end
  70.  
  71.     local ret = func(self, unit, blackboard, t, dt)
  72.    
  73.     -- mod_fall_data[unit].last_climb_state_1 = mod_fall_data[unit].last_climb_state
  74.     -- mod_fall_data[unit].last_climb_state = blackboard.climb_state
  75.    
  76.    
  77.     -- for loop_unit,_ in pairs(mod_fall_data) do
  78.         -- if not Unit.alive(loop_unit) then
  79.             -- mod_fall_data[loop_unit] = nil
  80.         -- end
  81.     -- end
  82.    
  83.     return ret
  84. end)
  85.  
  86. -- Mods.hook.set(mod_name , "BTFallAction.leave", function(func, self, unit, blackboard, t, reason)
  87.     -- mod_fall_data[unit].land_start_time = nil
  88.  
  89.     -- func(self, unit, blackboard, t)
  90. -- end)
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement