Advertisement
renard162

exo_backpack_servo_sounds.script

Sep 20th, 2022 (edited)
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | Gaming | 0 0
  1. exo_flag = false
  2. exo_footstep_sound = nil
  3. exo_jump_sound = nil
  4. exo_landing_sound = nil
  5.  
  6. local function get_exo_type(outfit)
  7.     local exo_types = {
  8.         [0] = "light", [1] = "light",  [2] = "light",  [3] = "middle" , [4] = "middle"
  9.     }
  10.     local weight = SYS_GetParam(0, outfit:section(), "inv_weight")
  11.     return exo_types[math.floor(weight / 10)] or "heavy"
  12. end
  13.  
  14. function actor_on_update() -- checking if player is wearing an exo
  15.     local outfit = db.actor:item_in_slot(7)
  16.     local backpack = db.actor:item_in_slot(13)
  17.     local is_exo_outfit = outfit and (SYS_GetParam(0, outfit:section(), "repair_type") == "outfit_exo")
  18.     local is_exo_backpack = backpack and (SYS_GetParam(0, backpack:section(), "repair_type") == "outfit_exo")
  19.     if is_exo_outfit then
  20.         exo_flag = true
  21.         local exo_type = get_exo_type(outfit)
  22.         local footstep_type = exo_type
  23.         if string.find(outfit:section(), "nosorog") then
  24.             footstep_type = "nosorog"
  25.         end
  26.         exo_footstep_sound = sound_object("exo-servo\\"..footstep_type.."_servo_exo_walk1")
  27.         exo_jump_sound = sound_object("exo-servo\\"..exo_type.."_servo_exo_jump")
  28.         exo_landing_sound = sound_object("exo-servo\\"..exo_type.."_servo_exo_landing")
  29.     elseif is_exo_backpack then
  30.         exo_flag = true
  31.         exo_footstep_sound = sound_object("exo-servo\\servo_exo_step")
  32.         exo_jump_sound = sound_object("exo-servo\\servo_exo_jump")
  33.         exo_landing_sound = sound_object("exo-servo\\servo_exo_landing")
  34.     else
  35.         exo_flag = false
  36.     end
  37. end
  38.  
  39. function actor_on_footstep(material,power,hud_view,flags)
  40.     if exo_flag and exo_footstep_sound then
  41.         exo_footstep_sound:play(db.actor, 0, sound_object.s2d)
  42.         exo_footstep_sound.volume = clamp(power, 0.5, 1.3) or 1
  43.         exo_footstep_sound.frequency = clamp(power, 0.8, 1.1) or 1
  44.     end
  45. end
  46.  
  47. function actor_on_jump()
  48.     if exo_flag and exo_jump_sound then
  49.         exo_jump_sound:play(db.actor, 0, sound_object.s2d)
  50.     end
  51. end
  52.  
  53. function actor_on_land(landing_speed)
  54.     if exo_flag and exo_landing_sound then
  55.         exo_landing_sound:play(db.actor, 0, sound_object.s2d)
  56.         exo_landing_sound.volume = clamp(landing_speed/6, 0.3, 2.5) or 1
  57.     end
  58. end
  59.  
  60. function on_game_start()
  61.     RegisterScriptCallback("actor_on_footstep", actor_on_footstep)
  62.     RegisterScriptCallback("actor_on_jump", actor_on_jump)
  63.     RegisterScriptCallback("actor_on_land", actor_on_land)
  64.     RegisterScriptCallback("actor_on_update", actor_on_update)
  65. end
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement