local not_alive = {[29]=1, [30]=1, [31]=1, [32]=1, [33]=1, [34]=1, [35]=1, [36]=1, [37]=1, [38]=1, [39]=1, [40]=1, [41]=1, [42]=1, [152]=1, [153]=1, [154]=1, [155]=1, [156]=1, [157]=1, [158]=1, [59]=1, [60]=1, [61]=1, [62]=1, [160]=1, [161]=1, [104]=1, [105]=1, [172]=1, [85]=1, [86]=1, [87]=1, [88]=1, [89]=1, [90]=1, [116]=1, [56]=1, [379]=1, [371]=1, [363]=1, [355]=1, [347]=1, [339]=1, [331]=1, [366]=1, [358]=1, [328]=1, [206]=1, [207]=1, [200]=1, [201]=1, [202]=1, [203]=1, [204]=1, [205]=1, [295]=1, [295]=1, [183]=1, [182]=1, [184]=1, [185]=1, [188]=1, [193]=1, [218]=1, [219]=1, [225]=1, [234]=1, [237]=1, [239]=1, [243]=1, [244]=1, [288]=1, [298]=1, [304]=1, [312]=1, [313]=1, [400]=1, [401]=1, [403]=1, [412]=1, [417]=1, [418]=1, [420]=1, [424]=1, [425]=1, [453]=1, [496]=1, [500]=1, [501]=1, [429]=1, [437]=1, [441]=1, [442]=1, [444]=1} local pack = function(...) return arg end function NHF_Hafad_TouchHero(hero) -- hero - имя вражеского героя local types = %pack(GetHeroCreaturesTypes(hero)) local died = 0 for slot=1,7 do local type = types[slot] if type == 0 then break end local num = GetHeroCreatures(type) local chance = 20 + GetHeroLevel"Hafad" * 2 local rnd = random(100) if rnd < chance then local tier = NHF_GetHeroTier(type) tier = tier ~= 0 and tier or random(7)+1 -- NCF default if not %not_alive[type] then local coef = 5 + GetHeroLevel"Hafad" / tier -- коэффициент в % if HasArtefact("Hafad", 61, 1) then coef = coef * 1.5 end if coef > 50 then coef = 50 end local n = round(num * coef / 100) if n >= 1 then died = died + n startThread(RemoveObjectCreatures, hero, type, n) end end end end if IsAIPlayer(GetObjectOwner"Hafad") == 0 and n >= 1 then local flt = GetPlayerFilter(GetObjectOwner"Hafad") + GetPlayerFilter(GetObjectOwner(hero)) PlayVisualEffect("/Effects/_(Effect)/Spells/Plague.xdb#xpointer(/Effect)", hero, "", 0, 0, 0, 0, 0, flt) ShowFlyingSign({"/MapObjects/Necropolis/NewHeroes/Hafad/died.txt"; died = died}, hero, GetObjectOwner"Hafad", 5) ShowFlyingSign({"/MapObjects/Necropolis/NewHeroes/Hafad/died.txt"; died = died}, hero, GetObjectOwner(hero), 5) Play3DSoundForPlayers(flt, "/Sounds/_(Sound)/Spells/Plague.xdb#xpointer(/Sound)", GetObjectPosition(hero)) end end function NHF_Hafad_InitMobs() errorHook(error_nhf_Hafad_F) for i, mob in GetObjectNamesByType"CREATURE" do SetObjectEnabled(mob, nil) Trigger(OBJECT_TOUCH_TRIGGER, mob, "NHF_Hafad_TouchMob") end errorHook(error_nhf_Hafad_F) end function NHF_Hafad_InitKiinaMobs() while 1 do local week = GetDate(WEEK) for i = 0, NHF_Kiina_array_number - 1 do local mob = NHF_Kiina_array_monsters[i] SetObjectEnabled(mob, nil) Trigger(OBJECT_TOUCH_TRIGGER, mob, "NHF_Hafad_TouchMob") end repeat sleep(5) until GetDate(WEEK) ~= week end end function NHF_Hafad_TouchMob(hero, mob) errorHook(error_nhf_Hafad_F) if IsObjectExists(mob) == nil then return nil end Trigger(OBJECT_TOUCH_TRIGGER, mob, nil) local mp = GetHeroStat(hero, STAT_MOVE_POINTS) local owner = GetObjectOwner(hero) if hero == "Hafad" then ChangeHeroStat(hero, STAT_MOVE_POINTS, -mp) local tiers = GetGuardsTier(mob) local died = 0 for slot=0,6 do local type, num = GetObjectArmySlotCreature(mob, slot) if type == 0 then break end local chance = 20 + GetHeroLevel(hero) * 2 local rnd = random(100) if rnd < chance then local tier = floor(tiers[slot]/2) if %not_alive[type] == nil then local coef = 5 + GetHeroLevel(hero) / sqrt(tier) if HasArtefact(hero, 61, 1) then coef = coef * 1.5 end if coef > 50 then coef = 50 end local n = round(num * coef / 100) if n >= 1 then died = died + n startThread(RemoveObjectCreatures, mob, type, n) end end end end if IsAIPlayer(owner) == 0 then if died >= 1 then local flt = GetPlayerFilter(owner) PlayVisualEffect("/Effects/_(Effect)/Spells/Plague.xdb#xpointer(/Effect)", mob, "", 0, 0, 0, 0, 0, flt) ShowFlyingSign({"/MapObjects/Necropolis/NewHeroes/Hafad/died.txt"; died = died}, mob, owner, 5) Play3DSoundForPlayers(flt, "/Sounds/_(Sound)/Spells/Plague.xdb#xpointer(/Sound)", GetObjectPosition(mob)) sleep(4) --else --ShowFlyingSign("/MapObjects/Necropolis/NewHeroes/Hafad/none.txt", mob, GetObjectOwner(hero), 5) end end end SetObjectEnabled(mob, 1) sleep(1) MakeHeroInteractWithObject(hero, mob) repeat sleep(1) if IsHeroAlive(hero) == nil and IsObjectExists(mob) then SetObjectEnabled(mob, nil) Trigger(OBJECT_TOUCH_TRIGGER, mob, "NHF_Hafad_TouchMob") break end until IsObjectExists(mob) == nil if IsHeroAlive(hero) and GetHeroStat(hero, 7) == 0 then ChangeHeroStat(hero, STAT_MOVE_POINTS, mp) end errorHook(error_nhf_Hafad_F) end --------------------------------- function error_nhf_Hafad_F () print("error:nhf_Hafad_F") end --------------------------------- startThread(NHF_Hafad_InitKiinaMobs) startThread(NHF_Hafad_InitMobs)