Advertisement
Guest User

Untitled

a guest
Feb 6th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. function hit_callback(victim_id, attacker_id, amount)
  2. --' áĺđĺě ęîěáŕň ěĺíĺäćĺđ ďîëó÷čâřĺăî őčň
  3. local my_squad = db.storage[victim_id].squad_obj
  4.  
  5. if db.actor and db.actor:id() == attacker_id and my_squad then
  6. local victim = db.storage[victim_id] and db.storage[victim_id].object
  7. if victim and not game_relations.is_factions_enemies(victim:character_community(), db.actor:character_community()) and not game_relations.check_all_squad_members(my_squad.squad_id, "enemy") then
  8. local companions = companion_manager.c_manager and companion_manager.c_manager.companions
  9. if victim:character_community() == "loner" then
  10. for k,v in pairs(db.storage) do
  11. local npc = v.object
  12. if npc and IsStalker(npc) and npc:alive() and npc:id() ~= db.actor:id() and npc:character_community() == "loner" then
  13. if db.actor:position():distance_to(npc:position()) <= 20 then
  14. if companions and not companions[npc:id()] then
  15. if npc:relation(db.actor) ~= game_object.enemy then
  16. --error_log(string.format("setting %s to enemy towards player",npc:character_name()))
  17. --npc:set_community_goodwill(db.actor:character_community(), -5000)
  18. npc:set_goodwill(-5000, db.actor)
  19. end
  20. for id,v in pairs(companions) do
  21. local comp = db.storage[id] and db.storage[id].object
  22. if comp then
  23. local en = npc
  24. if en then
  25. if comp:relation(en) ~= game_object.enemy then
  26. game_relations.set_npcs_relation(comp, en, "enemy")
  27. end
  28. if en:relation(comp) ~= game_object.enemy then
  29. game_relations.set_npcs_relation(en, comp, "enemy")
  30. end
  31. end
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end
  38. end
  39. if companions then
  40. for id,v in pairs(companions) do
  41. local comp = db.storage[id] and db.storage[id].object
  42. if comp then
  43. for sq_mem_id,vv in pairs(my_squad.squad_npc) do
  44. local en = db.storage[sq_mem_id] and db.storage[sq_mem_id].object
  45. if en then
  46. if comp:relation(en) ~= game_object.enemy then
  47. game_relations.set_npcs_relation(comp, en, "enemy")
  48. end
  49. if en:relation(comp) ~= game_object.enemy then
  50. game_relations.set_npcs_relation(en, comp, "enemy")
  51. end
  52. end
  53. end
  54. end
  55. end
  56. end
  57. end
  58. end
  59.  
  60. if companion_manager.c_manager.companions and companion_manager.c_manager.companions[victim_id] ~= nil then
  61. local npc = db.storage[victim_id].object
  62. --error_log(string.format("%s health = %s, amount = %s",npc:name(),npc.health,tostring(amount)))
  63. npc.health = 20
  64. companion_manager.hurt_npc(victim_id, attacker_id)
  65. --if attacker_id == db.actor:id() then
  66. -- companion_manager.c_manager.companions[victim_id] = nil
  67. --end
  68. end
  69.  
  70. if my_squad == nil then
  71. return
  72. end
  73.  
  74. if my_squad.current_action ~= nil then
  75. local combat_smart = nil
  76. local is_attacker = true
  77. if my_squad.current_action.name == "attack_point" then
  78. combat_smart = sim_board.get_sim_board().smarts[my_squad.current_action.dest_smrt_id].smrt
  79. else
  80. combat_smart = sim_board.get_sim_board().smarts[my_squad.smart_id].smrt
  81. is_attacker = false
  82. end
  83. combat_smart.combat_manager:hit_callback(my_squad, attacker_id, is_attacker)
  84. end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement