Advertisement
Daemonion

xr_motivator.script

Oct 20th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. function motivator_binder:hear_callback(self, who, sound_type, sound_position, sound_power)
  2. local type = "NIL"
  3. --------if it is an NPC
  4. if who:id() ~= db.actor:id() then
  5. if bit_and(sound_type, snd_type.weapon) == snd_type.weapon then
  6. type = "WPN"
  7. if bit_and(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then
  8. --------------------------------use WPN_shoot
  9. type = "WPN_shoot"
  10. elseif bit_and(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then
  11. type = "WPN_empty"
  12. elseif bit_and(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then
  13. type = "WPN_hit"
  14. elseif bit_and(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then
  15. type = "WPN_reload"
  16. end
  17. elseif bit_and(sound_type, snd_type.item) == snd_type.item then
  18. type = "ITM"
  19. if bit_and(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then
  20. type = "ITM_pckup"
  21. elseif bit_and(sound_type, snd_type.item_drop) == snd_type.item_drop then
  22. type = "ITM_drop"
  23. elseif bit_and(sound_type, snd_type.item_hide) == snd_type.item_hide then
  24. type = "ITM_hide"
  25. elseif bit_and(sound_type, snd_type.item_take) == snd_type.item_take then
  26. type = "ITM_take"
  27. elseif bit_and(sound_type, snd_type.item_use) == snd_type.item_use then
  28. type = "ITM_use"
  29. end
  30. elseif bit_and(sound_type, snd_type.monster) == snd_type.monster then
  31. type = "MST"
  32. if bit_and(sound_type, snd_type.monster_die) == snd_type.monster_die then
  33. type = "MST_die"
  34. elseif bit_and(sound_type, snd_type.monster_injure) == snd_type.monster_injure then
  35. type = "MST_damage"
  36. elseif bit_and(sound_type, snd_type.monster_step) == snd_type.monster_step then
  37. type = "MST_step"
  38. elseif bit_and(sound_type, snd_type.monster_talk) == snd_type.monster_talk then
  39. type = "MST_talk"
  40. elseif bit_and(sound_type, snd_type.monster_attack) == snd_type.monster_attack then
  41. type = "MST_attack"
  42. elseif bit_and(sound_type, snd_type.monster_eat) == snd_type.monster_eat then
  43. type = "MST_eat"
  44. end
  45. end
  46. if type ~= "NIL" then
  47. printf("SND *%s* dist: %d [%f], %s -> %s", type, self:position():distance_to(who:position()), sound_power, who:name(), self:name())
  48. end
  49. end
  50. --------if it is the player
  51. if who:id() == db.actor:id() then
  52. if bit_and(sound_type, snd_type.weapon) == snd_type.weapon then
  53. type = "WPN"
  54. if bit_and(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then
  55. --------------------------------use WPN_shoot_actor
  56. type = "WPN_shoot_actor"
  57. elseif bit_and(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then
  58. type = "WPN_empty"
  59. elseif bit_and(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then
  60. type = "WPN_hit"
  61. elseif bit_and(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then
  62. type = "WPN_reload"
  63. end
  64. elseif bit_and(sound_type, snd_type.item) == snd_type.item then
  65. type = "ITM"
  66. if bit_and(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then
  67. type = "ITM_pckup"
  68. elseif bit_and(sound_type, snd_type.item_drop) == snd_type.item_drop then
  69. type = "ITM_drop"
  70. elseif bit_and(sound_type, snd_type.item_hide) == snd_type.item_hide then
  71. type = "ITM_hide"
  72. elseif bit_and(sound_type, snd_type.item_take) == snd_type.item_take then
  73. type = "ITM_take"
  74. elseif bit_and(sound_type, snd_type.item_use) == snd_type.item_use then
  75. type = "ITM_use"
  76. end
  77. elseif bit_and(sound_type, snd_type.monster) == snd_type.monster then
  78. type = "MST"
  79. if bit_and(sound_type, snd_type.monster_die) == snd_type.monster_die then
  80. type = "MST_die"
  81. elseif bit_and(sound_type, snd_type.monster_injure) == snd_type.monster_injure then
  82. type = "MST_damage"
  83. elseif bit_and(sound_type, snd_type.monster_step) == snd_type.monster_step then
  84. type = "MST_step"
  85. elseif bit_and(sound_type, snd_type.monster_talk) == snd_type.monster_talk then
  86. type = "MST_talk"
  87. elseif bit_and(sound_type, snd_type.monster_attack) == snd_type.monster_attack then
  88. type = "MST_attack"
  89. elseif bit_and(sound_type, snd_type.monster_eat) == snd_type.monster_eat then
  90. type = "MST_eat"
  91. end
  92. end
  93. if type ~= "NIL" then
  94. printf("SND *%s* dist: %d [%f], %s -> %s", type, self:position():distance_to(who:position()), sound_power, who:name(), self:name())
  95. end
  96. end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement