Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hit_callback(victim_id, attacker_id, amount)
- --' áĺđĺě ęîěáŕň ěĺíĺäćĺđ ďîëó÷čâřĺăî őčň
- local my_squad = db.storage[victim_id].squad_obj
- if db.actor and db.actor:id() == attacker_id and my_squad then
- local victim = db.storage[victim_id] and db.storage[victim_id].object
- 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
- local companions = companion_manager.c_manager and companion_manager.c_manager.companions
- if victim:character_community() == "loner" then
- for k,v in pairs(db.storage) do
- local npc = v.object
- if npc and IsStalker(npc) and npc:alive() and npc:id() ~= db.actor:id() and npc:character_community() == "loner" then
- if db.actor:position():distance_to(npc:position()) <= 20 then
- if companions and not companions[npc:id()] then
- if npc:relation(db.actor) ~= game_object.enemy then
- --error_log(string.format("setting %s to enemy towards player",npc:character_name()))
- --npc:set_community_goodwill(db.actor:character_community(), -5000)
- npc:set_goodwill(-5000, db.actor)
- end
- for id,v in pairs(companions) do
- local comp = db.storage[id] and db.storage[id].object
- if comp then
- local en = npc
- if en then
- if comp:relation(en) ~= game_object.enemy then
- game_relations.set_npcs_relation(comp, en, "enemy")
- end
- if en:relation(comp) ~= game_object.enemy then
- game_relations.set_npcs_relation(en, comp, "enemy")
- end
- end
- end
- end
- end
- end
- end
- end
- end
- if companions then
- for id,v in pairs(companions) do
- local comp = db.storage[id] and db.storage[id].object
- if comp then
- for sq_mem_id,vv in pairs(my_squad.squad_npc) do
- local en = db.storage[sq_mem_id] and db.storage[sq_mem_id].object
- if en then
- if comp:relation(en) ~= game_object.enemy then
- game_relations.set_npcs_relation(comp, en, "enemy")
- end
- if en:relation(comp) ~= game_object.enemy then
- game_relations.set_npcs_relation(en, comp, "enemy")
- end
- end
- end
- end
- end
- end
- end
- end
- if companion_manager.c_manager.companions and companion_manager.c_manager.companions[victim_id] ~= nil then
- local npc = db.storage[victim_id].object
- --error_log(string.format("%s health = %s, amount = %s",npc:name(),npc.health,tostring(amount)))
- npc.health = 20
- companion_manager.hurt_npc(victim_id, attacker_id)
- --if attacker_id == db.actor:id() then
- -- companion_manager.c_manager.companions[victim_id] = nil
- --end
- end
- if my_squad == nil then
- return
- end
- if my_squad.current_action ~= nil then
- local combat_smart = nil
- local is_attacker = true
- if my_squad.current_action.name == "attack_point" then
- combat_smart = sim_board.get_sim_board().smarts[my_squad.current_action.dest_smrt_id].smrt
- else
- combat_smart = sim_board.get_sim_board().smarts[my_squad.smart_id].smrt
- is_attacker = false
- end
- combat_smart.combat_manager:hit_callback(my_squad, attacker_id, is_attacker)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement