Advertisement
Faguss

Untitled

Nov 15th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1.  
  2.  
  3. ; Create dummy objects for playing sounds
  4. _i = -1
  5. _sound_players = []
  6. while "_i=_i+1; _i < 3" do "_logic=""logic"" createVehicle [0,0,0]; _sound_players set [count _sound_players, _logic]"
  7.  
  8.  
  9. ; Settings
  10. _damage_threshold = [0.24, 0.49, 0.74]
  11. _intervals = [8.87, 6.295, 4.23]
  12. _sound_names = ["heartslow", "heartmiddle", "heartfast"]
  13. _max = count _damage_threshold - 1
  14. _current_sound = -1
  15. _time_to_play = 0
  16.  
  17.  
  18.  
  19.  
  20. #Loop
  21. ~0.1
  22.  
  23.  
  24. ; Find which sound to play based on player's damage
  25. _current = 0
  26. _selected = -1
  27. _dmg = damage player
  28.  
  29. #FindDamage
  30. ? damage player > (_damage_threshold select _current) : _selected=_current
  31. ? _current < _max : _current=_current+1; goto "FindDamage"
  32.  
  33.  
  34. ; Play the sound
  35. ? _selected != _current_sound : if (_current_sound>=0) then {(_sound_players select _current_sound) setPos [0,0,0]}; _current_sound=_selected; _time_to_play=0
  36. ? _current_sound >= 0 && _time >= _time_to_play : (_sound_players select _current_sound) setPos getPos player; (_sound_players select _current_sound) say (_sound_names select _current_sound); _time_to_play=_time+(_intervals select _current_sound)
  37.  
  38.  
  39. goto "Loop"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement