Advertisement
Aussiemon

ActionUtils.lua

Apr 8th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. ActionUtils.scale_powerlevels = function (power_level, power_type, attacker_unit)
  2.     --- BLOCK #0 1-4, warpins: 1 ---
  3.     local cap_to_difficulty = true
  4.     local actual_power_level = power_level
  5.     --- END OF BLOCK #0 ---
  6.  
  7.     slot3 = if cap_to_difficulty then
  8.     JUMP TO BLOCK #1
  9.     else
  10.     JUMP TO BLOCK #5
  11.     end
  12.  
  13.  
  14.     --- BLOCK #1 5-14, warpins: 1 ---
  15.     local difficulty_settings = Managers.state.difficulty:get_difficulty_settings()
  16.     local difficulty_power_level_cap = difficulty_settings.power_level_cap
  17.     local difficulty_power_level_max_target = difficulty_settings.power_level_max_target
  18.     --- END OF BLOCK #1 ---
  19.  
  20.     if difficulty_power_level_cap < actual_power_level then
  21.     JUMP TO BLOCK #2
  22.     else
  23.     JUMP TO BLOCK #4
  24.     end
  25.  
  26.  
  27.     --- BLOCK #2 15-16, warpins: 1 ---
  28.     --- END OF BLOCK #2 ---
  29.  
  30.     slot7 = if difficulty_power_level_max_target then
  31.     JUMP TO BLOCK #3
  32.     else
  33.     JUMP TO BLOCK #4
  34.     end
  35.  
  36.  
  37.     --- BLOCK #3 17-22, warpins: 1 ---
  38.     local above_cap = actual_power_level - difficulty_power_level_cap
  39.     local cap_to_max = difficulty_power_level_cap - 800
  40.     actual_power_level = difficulty_power_level_cap + difficulty_power_level_max_target*above_cap/cap_to_max
  41.     --- END OF BLOCK #3 ---
  42.  
  43.     UNCONDITIONAL JUMP; TARGET BLOCK #5
  44.  
  45.  
  46.     --- BLOCK #4 23-28, warpins: 2 ---
  47.     actual_power_level = math.min(power_level, difficulty_power_level_cap)
  48.     --- END OF BLOCK #4 ---
  49.  
  50.     FLOW; TARGET BLOCK #5
  51.  
  52.  
  53.     --- BLOCK #5 29-31, warpins: 3 ---
  54.     local min_cap_powerlevel = 200
  55.  
  56.     --- END OF BLOCK #5 ---
  57.  
  58.     if actual_power_level < min_cap_powerlevel then
  59.     JUMP TO BLOCK #6
  60.     else
  61.     JUMP TO BLOCK #7
  62.     end
  63.  
  64.  
  65.     --- BLOCK #6 32-32, warpins: 1 ---
  66.     return actual_power_level
  67.  
  68.     --- END OF BLOCK #6 ---
  69.  
  70.     FLOW; TARGET BLOCK #7
  71.  
  72.  
  73.     --- BLOCK #7 33-40, warpins: 2 ---
  74.     local starting_powerlevel_bonus = 50
  75.     local starting_bonus_range = 100
  76.     local powerlevel_diff_ratio = {
  77.         impact = 2,
  78.         attack = 3.5,
  79.         cleave = 3.5
  80.     }
  81.     local native_diff_ratio = 5
  82.     local scaled_powerlevel_section = nil
  83.     --- END OF BLOCK #7 ---
  84.  
  85.     if min_cap_powerlevel + starting_bonus_range <= actual_power_level then
  86.     JUMP TO BLOCK #8
  87.     else
  88.     JUMP TO BLOCK #9
  89.     end
  90.  
  91.  
  92.     --- BLOCK #8 41-47, warpins: 1 ---
  93.     scaled_powerlevel_section = (actual_power_level - min_cap_powerlevel)*(powerlevel_diff_ratio[power_type] - 1)/(native_diff_ratio - 1)
  94.     --- END OF BLOCK #8 ---
  95.  
  96.     UNCONDITIONAL JUMP; TARGET BLOCK #10
  97.  
  98.  
  99.     --- BLOCK #9 48-58, warpins: 1 ---
  100.     local starting_bonus = starting_powerlevel_bonus*((actual_power_level - 200)/starting_bonus_range - 1)
  101.     scaled_powerlevel_section = ((actual_power_level + starting_bonus) - min_cap_powerlevel)*(powerlevel_diff_ratio[power_type] - 1)/(native_diff_ratio - 1)
  102.     --- END OF BLOCK #9 ---
  103.  
  104.     FLOW; TARGET BLOCK #10
  105.  
  106.  
  107.     --- BLOCK #10 59-61, warpins: 2 ---
  108.     local scaled_powerlevel = min_cap_powerlevel + scaled_powerlevel_section
  109.     --- END OF BLOCK #10 ---
  110.  
  111.     slot2 = if attacker_unit then
  112.     JUMP TO BLOCK #11
  113.     else
  114.     JUMP TO BLOCK #12
  115.     end
  116.  
  117.  
  118.     --- BLOCK #11 62-67, warpins: 1 ---
  119.     scaled_powerlevel = ActionUtils.apply_buffs_to_power_level(attacker_unit, scaled_powerlevel)
  120.  
  121.     --- END OF BLOCK #11 ---
  122.  
  123.     FLOW; TARGET BLOCK #12
  124.  
  125.  
  126.     --- BLOCK #12 68-68, warpins: 2 ---
  127.     return scaled_powerlevel
  128.     --- END OF BLOCK #12 ---
  129.  
  130.  
  131.  
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement