--[[ File: amk_mod .script copyright © AMK TEAM 2007-2008 --]] local nrg,med,cnt,gv,lv,w in_hide=false local sound_obj_right,sound_obj_left,snd_volume,snd_obj_eq local sync_done=false local dynlasthour zombied={} local weather_types={ l01_escape=0, l02_garbage=0, l03_agroprom=0, l03u_agr_underground=1, l04_darkvalley=0, l04u_labx18=1, l05_bar=0, l06_rostok=0, l07_military=0, l08_yantar=0, l08u_brainlab=1, l10_radar=0, l10u_bunker=1, l11_pripyat=0, l12_stancia=0, l12_stancia_2=0, l12u_control_monolith=1, l12u_sarcofag=1 } --'******************************************************************************* --' ** ** ** ** ** ** ** ** QUEST_AF_STAR ** ** ** ** ** ** ** ** --'******************************************************************************* local points={ { position={x=-24.2727108001709,y=-12.1660995483398,z=-100.200202941895}, gv=0, lv=73868 }, { position={x=159.56,y=4.72,z=88.60}, gv=155, lv=463808 }, { position={x=-4.11,y=2.90,z=108.09}, gv=85, lv=272619 } } function spawn_star(actor,npc,p1,p2) local a = points[math.random(table.getn(points))] local obj = alife():create("amk_af_night_star", vector():set(a.position.x,a.position.y,a.position.z), a.lv, a.gv) if (obj) then if is_debug==true then add_spot_on_map(obj.id, "red_location", "art") end end local m_where if news_main then m_where = news_main.get_point_description("l01_escape", vector():set(a.position.x,a.position.y,a.position.z)) else m_where = "Здесь, на Кордоне" end db.actor:give_talk_message(m_where.." скорее всего поискать стоит. Где-то там он, точно говорю.", "ui\\ui_iconstotal", Frect():set(0,0,10,10), "simple_answer_item") end --'******************************************************************************* --' ** ** ** ** ** ** ** ** FIRST_RUN ** ** ** ** ** ** ** ** ** --'******************************************************************************* -- Эта функция вызывается первой. Онлайновые объекты недоступны! db.actor недоступен! function on_game_start() math.randomseed (device ():time_global ()) end local tmp_intro=false function first_run() if amk.load_variable("x_first_run",true) then amk.g_start_timer("gg_need_sleep",0,0,6) amk.g_start_timer("show_news",0,0,10) amk.spawn_item_in_inv("matras") amk.save_variable("x_first_run",false) end if amk.load_variable("amk_12",0)==0 then amk.spawn_item("amk_zapiska",vector():set(-126.96,-28.41,-379.12),27,125181) amk.spawn_item("amk_zapiska",vector():set(21.6,-3.94,-18.28),1140,5991) amk.spawn_item("amk_zapiska",vector():set(-126.92,23.27,-36.98),1543,7083) amk.save_variable("amk_12",1) end if amk.load_variable("amk_13",0)==0 then -- pri_space_restrictor_0011 local obj = alife():story_object(830) if obj then alife():release(obj) alife():create(7373) end amk.save_variable("amk_13",1) end if amk.load_variable("amk_13",0)==0 then -- pri_space_restrictor_0011 local obj = alife():story_object(830) if obj then alife():release(obj) alife():create(7373) end amk.save_variable("amk_13",1) end if amk.load_variable("amk_version",0)<1400 then tmp_intro=true amk.save_variable("amk_version",1400) amk_anoms.pre_blow_off() amk_anoms.after_blow_on() spawn_military_btr() spawn_fuel() end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** CHECK_SPAWN ** ** ** ** ** ** ** ** --'******************************************************************************* function check_spawn() amk_anoms.init() spawn_unspawned_respawners() if (news_main) then news_main.init() end if (amk_offline_alife) then amk_offline_alife.init() end if (amk_corpses) then amk_corpses.init() end if (amk_objects) then amk_objects.init() end --спавним аномалии --initial_spawn() local obj = alife():story_object(6000) if not obj then alife():create(2) obj = alife():story_object(6000) end if amk.load_variable("freeplay",0)==1 then amk.save_variable("freeplay",2) elseif amk.load_variable("freeplay",0)==2 and (not has_alife_info("cit_fail_first_task")) then db.actor:give_info_portion("cit_fail_first_task") end if not db.actor:has_info("val_chase_start") then local objt = alife():story_object(6002) if objt then alife():release(objt) end end --level_changers section local lname = level.name() local sname = amk.load_variable("level_on_save","") if (amk_offline_alife) then amk_offline_alife.update_npc_tables() end if (amk_corpses) then amk_corpses.update_all_corpses() end if lname ~= sname and amk_objects then amk_objects.update() end -- Выдадим сообщения при переходе на уровень. if news_main then if (lname ~= sname and sname ~= "") then if (news_main.isIsolatedLevel(lname)== true and news_main.isIsolatedLevel(sname) == false) then -- Спустились под землю. news_main.on_disconnect() elseif (news_main.isIsolatedLevel(lname) == false and news_main.isIsolatedLevel(sname) == true) then -- Выбрались из-под земли. news_main.on_connect() end if (amk_offline_alife) then amk_offline_alife.update_trade() end end end if lname=="l01_escape" and sname=="l04_darkvalley" then local obj = alife():story_object(6002) if not obj then alife():create(0) end end if sname=="l01_escape" and lname=="l04_darkvalley" then db.actor:set_actor_position(vector():set(-44.38, 0.43, -541.47)) end --spots section obj = alife():story_object(6001) if obj then level.map_add_object_spot(obj.id, "level_changer", "to_pripyat") end obj = alife():story_object(6002) if obj then level.map_add_object_spot(obj.id, "level_changer", "to_darkvalley") end if weather_types[lname]==0 then w=amk.load_variable("dynweather",nil) or level.get_weather() else w=level.get_weather() end if amk.load_variable("blowout",0)>0 then amk.save_variable("weather",level.get_weather()) end level.set_weather("amk_for_blow",true) game.start_tutorial("restore_sun") if amk.load_variable("blowout",0)>0 and amk.load_variable("blowout",0)<4 then local bt=blowout_type() level.add_cam_effector("camera_effects\\earthquake.anm", 2002, true, "") if bt<1 then level.set_weather("amk_for_blow",true) level.add_pp_effector("vibros.ppe", 2001, true) blowout_psy_sound("start") end end if db.actor and not has_alife_info("game_over") then local flame = db.actor:object("wpn_flame") if flame then db.actor:iterate_inventory( function(dummy,item) if item:section()=="wpn_flame" then alife():release(alife():object(item:id())) end end ,db.actor) end end end function restore_sun() --update_anoms() --amk_anoms.init() if amk.load_variable("blowout",0)==0 then level.set_weather(w,true) end local lname = level.name() local sname = amk.load_variable("level_on_save","") amk.save_variable("level_on_save",lname) if sname=="l12_stancia_2" and lname=="l11_pripyat" then sleep_manager.main(1) end if amk.load_variable("blow_started",0)==0 then start_blow_timer() amk.save_variable("blow_started",1) end if tmp_intro then amk.send_tip(game.translate_string("amk_welcome_msg"),game.translate_string("amk_welcome_title"),nil,35,"monolith") tmp_intro=false end sync_done=true end --'******************************************************************************* --' ** ** ** ** ** ** ** ** FREEPLAY ** ** ** ** ** ** ** ** ** --'******************************************************************************* function freeplay() amk.save_variable("freeplay",1) local obj = alife():story_object(6001) if not obj then alife():create(1) end for a=1,5 do amk_anoms.after_blow_on() end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** NEWS_AMK ** ** ** ** ** ** ** ** ** --'******************************************************************************* function show_news() if (news_main and news_main.on_news) then news_main.on_news() end local ln = level.name() if (ln == "l03u_agr_underground" or ln == "l04u_labx18" or ln == "l08u_brainlab" or ln == "l10u_bunker") then -- Радиомолчание else if math.random()>0.2 then if math.random()>0.875 then if amk_dolg and math.random()>0.5 then local dolg_news=amk_dolg.get_strings() db.actor:give_game_news(dolg_news, "ui\\ui_iconsTotal", Frect():set(498,141,83,47), 0, 15000) elseif amk_freedom then local freedom_news=amk_freedom.get_strings() db.actor:give_game_news(freedom_news, "ui\\ui_iconsTotal", Frect():set(498,94,83,47), 0, 15000) end else if math.random()>0.57 then --amk.send_tip(when.." "..where.." "..text.." "..mat,name.." "..sname,nil,15,"gen_info") else --amk.send_tip(name.." "..sname..". "..dead..". "..reason,game.translate_string("stalker_died"),nil,10,"death") end end else if amk_uniq_news_lists and math.random()>0.5 then local uniq=amk_uniq_news_lists.get_strings() local name,sname = amk_names_lists.get_strings() amk.send_tip(uniq,name.." "..sname,nil,15,"uniq") elseif amk_modders then local mod_news=amk_modders.get_strings() db.actor:give_game_news(mod_news, "ui\\ui_iconsTotal", Frect():set(498,47,83,47), 0, 15000) end end end amk.g_start_timer("show_news",0,0,math.random(40,80)) end --'******************************************************************************* --' ** ** ** ** ** ** ** ** SLEEP_AMK ** ** ** ** ** ** ** ** ** --'******************************************************************************* function reduce_need_sleep(time) local tmp=amk.load_variable("gg_need_sleep",0) tmp=tmp-time*120 if tmp<0 then tmp=0 end amk.save_variable("gg_need_sleep_nrg",0) amk.save_variable("block_sleep_menu",0) amk.save_variable("gg_need_sleep",tmp) test_sleep_pp() end function test_for_need_sleep() if sleep_manager.is_sleep_active() == false then amk.save_variable("gg_need_sleep",amk.load_variable("gg_need_sleep",0)+1) test_sleep_pp() end amk.g_start_timer("gg_need_sleep",0,0,6) end function test_sleep_pp() local tmp=amk.load_variable("gg_need_sleep",0) if tmp>360 then sleep_manager.main(5+amk.load_variable("gg_need_sleep_nrg",0)) end if tmp>300 then level.add_pp_effector("yantar_underground_psi.ppe", 999, true) level.set_pp_effector_factor(999, 5.0) end if tmp<=300 then level.remove_pp_effector(999) end end function check_sleep_item(obj) local section = obj:section() local stype=nil if section=="energy_drink" then stype="nrg" --'elseif (section=="medkit" or section=="medkit_army" or section=="medkit_scientic") then --' stype="med" elseif section=="matras" then stype="matras" elseif section=="repbox_s1" then amk.start_timer("sleep_repbox",0.1,amk.pack_array_to_string( {obj:id(), obj:condition(), 1} )) elseif section=="repbox_s2" then amk.start_timer("sleep_repbox",0.1,amk.pack_array_to_string( {obj:id(), obj:condition(), 2} )) elseif section=="treasure_item" then stype="tr_item" end if stype~=nil then amk.start_timer("sleep_"..stype,0.1,obj:id()) end end function test_for_need_sleep_nrg(oid) if alife():object(oid)==nil then local n=amk.load_variable("gg_need_sleep_nrg",0) if n<3 then amk.save_variable("gg_need_sleep_nrg",n+1) amk.save_variable("gg_need_sleep",amk.load_variable("gg_need_sleep",0)-30+n*10) test_sleep_pp() end amk.g_start_timer("block_sleep_menu",0,1,0) amk.save_variable("block_sleep_menu",1) end end --[[ function test_for_need_sleep_med(oid) if alife():object(oid)==nil then amk.save_variable("gg_need_sleep",amk.load_variable("gg_need_sleep",0)+5) test_sleep_pp() end end ]]-- function test_for_need_sleep_matras(oid) if alife():object(oid)==nil then local enemy=false for a=0,65534 do local obj=level.object_by_id(a) if obj then if (( IsStalker(obj) and amk.get_npc_relation(obj,db.actor)=="enemy" ) or IsMonster(obj)) and obj:position():distance_to(db.actor:position())<40 and obj:see(db.actor) then enemy=true break end end end if enemy==true then amk.send_tip(game.translate_string("not_need_sleep_enemy"),nil,nil,5) else if amk.load_variable("blowout",-1)>-1 and amk.load_variable("blowout",-1)<5 then amk.send_tip(game.translate_string("blowout_not_sleep"),nil,nil,5) else if amk.load_variable("block_sleep_menu",0)==0 then if amk.load_variable("gg_need_sleep",0)>20 then local spwn=ui_cheat.cheat(get_hud()) level.start_stop_menu(spwn,true) else amk.send_tip(game.translate_string("not_need_sleep"),nil,nil,5) end else amk.send_tip(game.translate_string("not_need_sleep_nrg"),nil,nil,5) end end end amk.spawn_item_in_inv("matras") end end function test_for_need_sleep_tr_item(oid) if alife():object(oid)==nil then if news_main then news_main.create_treasurebox() end end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** RADAR_FIX ** ** ** ** ** ** ** ** ** --'******************************************************************************* function check_radar_off() if (level.name() == "l10_radar") then if not has_alife_info("bar_deactivate_radar_done") then local pos = db.actor:position() if pos.z>65 and pos.x>350 and pos.x<410 then if amk.load_variable("radar_fix",0)==0 then level.add_pp_effector("fire_hit.ppe", 1523, true) level.set_pp_effector_factor(1523, 0.5) amk.save_variable("radar_fix",1) amk.start_timer("radar_fix",5) end end end end end function radar_fix() level.remove_pp_effector(1523) local pos = db.actor:position() if pos.z>65 and pos.x>350 and pos.x<410 then db.actor:kill(db.actor) end amk.del_variable("radar_fix") end --'******************************************************************************* --' ** ** ** ** ** ** ** ** AF_TRANSFORM ** ** ** ** ** ** ** ** --'******************************************************************************* local cur_level=nil local havegoodart=false local afs={ --симбион "af_medusa", "af_blood", "af_rusty_thorn", --жарка "af_soul", "af_spirit_1", "af_spirit_2", "af_cry_1", "af_rusty_sea-urchin", "af_kol_3", "af_armor_3", --электра "af_spirit_3", "af_drops", -- +симбион "af_dummy_glassbeads", "af_dummy_dummy", "af_pudd_1", "af_pudd_2", "af_dik_1", --холодец "af_cry_2", "af_babka_1", "af_pudd_3", "af_dik_2", "af_kol_2", "af_armor_2", --карусель "af_babka_2", "af_kol_1", "af_armor_1", --трамплин "af_dik_3", "af_fuzz_kolobok", "af_dummy_pellicle" } function check_for_af_drop(obj) local section=obj:section() for a=1,table.getn(afs),1 do if afs[a]==section then local id,pos,radius,dist=amk_anoms.get_nearest_anomaly(obj) --amk.mylog("narad "..nearest_anomaly.radius.." nadist "..nearest_anomaly.dist) if id and radius-dist>-1 then local anom_sect=level.object_by_id(id):section() check_af_transform(obj,id,anom_sect) end return end end end function check_af_transform(af,anom_id,anom_sect) local af_sect=af:section() local pos=af:position() gv=level.object_by_id(anom_id):game_vertex_id() lv=level.object_by_id(anom_id):level_vertex_id() if gv==65535 then gv=af:game_vertex_id() end if gv==65535 then gv=db.actor:game_vertex_id() end if gv==65535 then return end local actor = db.actor --lv=db.actor:level_vertex_id() if string.find(anom_sect,"_zharka")~=nil then if af_sect=="af_soul" and actor:has_info("info_amk_recipt_souls") then af_flash(af) af_start_transform_timer(af_start_transform(70,25,af_sect,"af_spirit_1"), pos ,0,4,0,"Капля души") end if af_sect=="af_spirit_1" and actor:has_info("info_amk_recipt_souls") then af_flash(af) af_start_transform_timer(af_start_transform(60,20,af_sect,"af_spirit_2"), pos ,0,6,0,"Огненная душа") end if af_sect=="af_spirit_2" and actor:has_info("info_amk_recipt_souls") then af_flash(af) af_start_transform_timer(af_start_transform(50,35,af_sect,"af_spirit_3"), pos ,0,10,0,"Кристальная душа") end if af_sect=="af_cry_1" and actor:has_info("info_amk_recipt_tears_fire") then af_flash(af) af_start_transform_timer(af_start_transform(65,20,af_sect,"af_cry_2"), pos ,0,5,0,"Слёзы огня") end if af_sect=="af_rusty_sea-urchin" and actor:has_info("info_amk_recipt_dikoobraz") then af_flash(af) af_start_transform_timer(af_start_transform(65,20,af_sect,"af_dik_1"), pos ,0,3,0,"Дикобраз") end if af_sect=="af_kol_3" and actor:has_info("info_amk_recipt_giant_small_brother") then af_flash(af) af_start_transform_timer(af_start_transform(49,30,af_sect,"af_kol_4"), pos ,0,3,0,"Младший брат Гиганта") end if af_sect=="af_armor_3" and actor:has_info("info_amk_recipt_controller_skalp") then af_flash(af) af_start_transform_timer(af_start_transform(40,25,af_sect,"af_armor_4"), pos ,0,6,0,"Скальп контролёра") end end if string.find(anom_sect,"_galant")~=nil then if af_sect=="af_spirit_3" and actor:has_info("info_amk_recipt_souls") then af_flash(af) af_start_transform_timer(af_start_transform(50,30,af_sect,"af_spirit_4"), pos ,0,1,0,"Кристальная душа Бенгала") end if af_sect=="af_drops" and actor:has_info("info_amk_recipt_tears_electra") then af_flash(af) af_start_transform_timer(af_start_transform(75,10,af_sect,"af_cry_1"), pos ,0,5,0,"Слёзы Электры") end if af_sect=="af_dummy_glassbeads" and actor:has_info("info_amk_recipt_grandmother_glassbeards") then af_flash(af) af_start_transform_timer(af_start_transform(85,10,af_sect,"af_babka_1"), pos ,0,5,0,"Бабкины бусы") end if af_sect=="af_dummy_dummy" and actor:has_info("info_amk_recipt_dummy") then af_flash(af) af_start_transform_timer(af_start_transform(70,25,af_sect,"af_pudd_1"), pos ,0,3,0,"Огненная пустышка") end if af_sect=="af_pudd_1" and actor:has_info("info_amk_recipt_dummy") then af_flash(af) af_start_transform_timer(af_start_transform(59,20,af_sect,"af_pudd_2"), pos ,0,6,0,"Яркая пустышка") end if af_sect=="af_pudd_2" and actor:has_info("info_amk_recipt_dummy") then af_flash(af) af_start_transform_timer(af_start_transform(50,35,af_sect,"af_pudd_3"), pos ,0,8,0,"Лунная пустышка") end if af_sect=="af_dik_1" and actor:has_info("info_amk_recipt_electra_dikoobraz") then af_flash(af) af_start_transform_timer(af_start_transform(72,25,af_sect,"af_dik_2"), pos ,0,5,0,"Электрический дикобраз") end end if string.find(anom_sect,"_buzz")~=nil then if af_sect=="af_cry_2" and actor:has_info("info_amk_recipt_tears_chimaera") then af_flash(af) af_start_transform_timer(af_start_transform(55,25,af_sect,"af_cry_3"), pos ,0,2,0,"Слёзы химеры") end if af_sect=="af_babka_1" and actor:has_info("info_amk_recipt_pra_grandmother_glassbeards") then af_flash(af) af_start_transform_timer(af_start_transform(72,12,af_sect,"af_babka_2"), pos ,0,3,0,"Бусы прабабки") end if af_sect=="af_pudd_3" and actor:has_info("info_amk_recipt_dummy") then af_flash(af) af_start_transform_timer(af_start_transform(80,10,af_sect,"af_pudd_4"), pos ,0,12,0,"Пудинг") end if af_sect=="af_dik_2" and actor:has_info("info_amk_recipt_sopl_dikoobraz") then af_flash(af) af_start_transform_timer(af_start_transform(74,10,af_sect,"af_dik_3"), pos ,0,2,0,"Сопливый дикобраз") end if af_sect=="af_kol_2" and actor:has_info("info_amk_recipt_almaz_kolobok") then af_flash(af) af_start_transform_timer(af_start_transform(78,17,af_sect,"af_kol_3"), pos ,0,8,0,"Алмазный колобок") end if af_sect=="af_armor_2" and actor:has_info("info_amk_recipt_pancir") then af_flash(af) af_start_transform_timer(af_start_transform(65,25,af_sect,"af_armor_3"), pos ,0,2,0,"Панцирь") end if af_sect=="af_medusa" or af_sect=="af_drops" or af_sect=="af_blood" or af_sect=="af_rusty_thorn" and actor:has_info("info_amk_recipt_simbion") then local s={} s.aid=-1 s.koluchka=-1 s.medusa=-1 s.drop=-1 s.blood=-1 s=amk.unpack_array_from_string(amk.load_variable("af_simbion_activation",amk.pack_array_to_string(s))) if s.aid~=anom_id then s.aid=anom_id s.koluchka=-1 s.medusa=-1 s.drop=-1 s.blood=-1 end if af_sect=="af_medusa" and s.medusa==-1 then s.medusa=af:id() end if af_sect=="af_drops" and s.drop==-1 then s.drop=af:id() end if af_sect=="af_rusty_thorn" and s.koluchka==-1 then s.koluchka=af:id() end if af_sect=="af_blood" and s.blood==-1 then s.blood=af:id() end if s.medusa~=-1 and s.drop~=-1 and s.koluchka~=-1 and s.blood~=-1 then level.add_pp_effector("teleport.ppe", 1524, false) alife():release(alife():object(s.medusa), true) alife():release(alife():object(s.drop), true) alife():release(alife():object(s.koluchka), true) alife():release(alife():object(s.blood), true) amk.del_variable("af_simbion_activation") af_start_transform_timer(af_start_transform(75,25,"af_buliz","af_simbion") , pos ,0,5,0,"Симбион") return end amk.save_variable("af_simbion_activation",amk.pack_array_to_string(s)) end end if string.find(anom_sect,"_mincer")~=nil then if af_sect=="af_babka_2" and actor:has_info("info_amk_recipt_burer_grandmother_glassbeards") then af_flash(af) af_start_transform_timer(af_start_transform(85,10,af_sect,"af_babka_3"), pos ,0,0,10,"Бусы бабки бюрера") end if af_sect=="af_kol_1" and actor:has_info("info_amk_recipt_titan_kolobok") then af_flash(af) af_start_transform_timer(af_start_transform(55,35,af_sect,"af_kol_2"), pos ,0,5,0,"Титановый колобок") end if af_sect=="af_armor_1" and actor:has_info("info_amk_recipt_cheshya") then af_flash(af) af_start_transform_timer(af_start_transform(80,10,af_sect,"af_armor_2"), pos ,0,5,0,"Чешуя") end end if string.find(anom_sect,"_mosquito_bald")~=nil then if af_sect=="af_dik_3" and actor:has_info("info_amk_recipt_stone_dikoobraz") then af_flash(af) af_start_transform_timer(af_start_transform(50,28,af_sect,"af_dik_4"), pos ,0,9,0,"Каменный дикобраз") end if af_sect=="af_fuzz_kolobok" and actor:has_info("info_amk_recipt_steel_kolobok") then af_flash(af) af_start_transform_timer(af_start_transform(70,25,af_sect,"af_kol_1"), pos ,0,2,0,"Стальной колобок") end if af_sect=="af_dummy_pellicle" and actor:has_info("info_amk_recipt_shkura") then af_flash(af) af_start_transform_timer(af_start_transform(70,25,af_sect,"af_armor_1"), pos ,0,5,0,"Шкура") end end end function af_flash(af) level.add_pp_effector("teleport.ppe", 1524, false) amk.remove_item(af) end function af_start_transform(v1,v2,af_from,af_target) local rnd=math.random(0,100) if rnd>v1 then if rnd>v2+v1 then return af_from else return "af_buliz" end else return af_target end end function af_start_transform_timer(af,pos,delay_d,delay_h,delay_m,af_sect) local t={} t.section=af t.pos={} t.pos.x=pos.x t.pos.y=pos.y t.pos.z=pos.z t.gv=gv t.lv=lv t.from_sect=af_sect amk.g_start_timer("af_transform",delay_d,delay_h,delay_m,amk.pack_array_to_string(t)) end function af_transform_end(params) local from_sect="\""..params.from_sect.."\"" local obj obj=amk.spawn_item(params.section,vector():set(params.pos.x,params.pos.y,params.pos.z),params.gv,params.lv) amk.add_spot_on_map(obj.id,"red_location",game.translate_string("trans_finished_title").."%c[255,255,0,0]"..from_sect) amk.send_tip(game.translate_string("trans_finished_title").."%c[255,255,0,0]"..from_sect) end --'******************************************************************************* --' ** ** ** ** ** ** ** ** ** AMK_METKA ** ** ** ** ** ** ** ** ** --'******************************************************************************* local beakons={} function check_beacon_drop(obj) local sim=not (alife()==nil) local actor=db~=nil and db.actor~=nil local lp=level.present() local dp=device()==nil or device():is_paused() if obj:section()=="amk_metka" then beakons[obj:id()]=true end end function check_metka() for id,v in pairs(beakons) do local obj=level.object_by_id(id) if obj then beakons[id]=nil if obj:parent()==nil then local spwn=ui_dots.dots(get_hud(),id) level.start_stop_menu(spwn,true) end end end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** ** BLOWOUT ** ** ** ** ** ** ** ** ** --'******************************************************************************* function blowout_phantoms() local blow=amk.load_variable("blowout",-1) local bt=blowout_type() if blow>1 and blow<4 and bt<2 then local lname=level.name() if not in_hide and amk_hideouts.blowouts_phantoms[lname] then local phantoms=amk_hideouts.blowouts_phantoms[lname] if phantoms and phantoms.count>0 then if math.random()0 and blow<4 then local snd_obj = xr_sound.get_safe_sound_object(amk_hideouts.blowout_sounds[math.random(table.getn(amk_hideouts.blowout_sounds))]) local a=vector() a.x=math.random(0,10) a.y=math.random(0,10) a.z=math.random(0,10) snd_obj:play_at_pos(db.actor, db.actor:position():add(a)) amk.start_timer("blowout_ss",math.random(10,30),0) end end function blowout_psy_sound(action) if action=="start" then snd_obj_eq = sound_object([[ambient\earthquake]],sound_object.looped+sound_object.s2d) snd_obj_eq:play(db.actor, 4, sound_object.looped+sound_object.s2d) end if action == "stop" then if snd_obj_eq then snd_obj_eq:stop() end end local lname=level.name() if not amk_hideouts.blowouts_phantoms[lname] then return end local psy_sound=amk_hideouts.blowouts_phantoms[lname].psy_sounds or false if not psy_sound then return end if action=="start" then local level_vol=amk_hideouts.blowouts_phantoms[lname].level_vol or 1 sound_obj_right, sound_obj_left = xr_sound.get_sound_object("psy_voices", "random") sound_obj_left:play_at_pos (db.actor, vector():set(-1, 0, 1), 0, sound_object.s2d + sound_object.looped) sound_obj_right:play_at_pos(db.actor, vector():set( 1, 0, 1), 0, sound_object.s2d + sound_object.looped) snd_volume = level.get_snd_volume() level.set_snd_volume( level_vol ) end if action == "stop" then if sound_obj_left then sound_obj_left:stop() end if sound_obj_right then sound_obj_right:stop() end if snd_volume then level.set_snd_volume(snd_volume) end end end function Run_Blowout_pp() local blow_enabled = system_ini():r_float("blowout_period","enabled") if blow_enabled>0 then local bt=blowout_type() if bt==2 and amk.load_variable("freeplay",0)~=2 then return end sleep_manager.stopper() amk.save_variable("blowout",1) if bt<1 then level.add_pp_effector("monolith_off.ppe", 2003, false) level.add_cam_effector("camera_effects\\shell_shock.anm", 2004, false, "") local snd_obj = xr_sound.get_safe_sound_object([[ambient\organic_moan1]]) snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) end amk.start_timer("blowout_ss",math.random(5,15),0) amk.start_timer("blowout",11,0) end start_blow_timer() end function start_blow_timer() local shift = system_ini():r_float("blowout_period","shift") shift = math.random()*shift-shift local t_time = system_ini():r_float("blowout_period","time") amk.g_start_timer( "blow_shift",0,0, t_time+shift ) if (news_main and news_main.next_blow) then news_main.next_blow(t_time+shift) end end function Blowout_pp(phase) --------------------------------------------------- --' TimeFactor = 2 --' GameMin = 30 RealSec --' TimeBlowout = 180 RealSec --' Начало (Timer = 30 sec) --' Первая Фаза (Timer = 30 sec) --' Вторая Фаза (Timer = 30 sec) --' Третья Фаза (Timer = 30 sec) --' Четвертая Фаза (Timer = 60 sec) --' Конечнвя Фаза (Timer = 0 sec) --------------------------------------------------- amk.mylog("blowout "..phase) local bt=blowout_type() if phase==0 then amk_anoms.pre_blow_off() if bt<1 then level.set_weather("pre_blow",true) level.set_weather_fx("amk_surge_day") end amk.g_start_timer("blowout",0,0,1,1) elseif phase==1 then local snd_obj = xr_sound.get_safe_sound_object([[ambient\earthquake]]) snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) level.add_cam_effector("camera_effects\\earthquake.anm", 2002, true, "") snd_obj = xr_sound.get_safe_sound_object([[anomaly\blowout]]) snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) blowout_psy_sound("start") if bt<1 then level.add_pp_effector("vibros.ppe", 2001, true) end in_hide=false amk.g_start_timer("blowout",0,0,1,2) amk.save_variable("blowout",2) elseif phase==2 then amk.g_start_timer("blowout",0,0,1,3) elseif phase==3 then amk_anoms.after_blow_on() amk.save_variable("blowout",3) local h = hit() local cr h.type = hit.strike h.power = 1000 h.impulse = 1000 for a=1,65534,1 do cr=level.object_by_id(a) if cr~=nil and cr:section()=="m_crow" and math.random(0,100)<70 then h.draftsman = cr h.direction = cr:direction() cr:hit(h) end end amk.g_start_timer("blowout",0,0,1,4) elseif phase==4 then amk.save_variable("blowout",4) level.remove_cam_effector(2002) if bt<1 then level.remove_pp_effector(2001) level.add_pp_effector("monolith_off.ppe", 2003, false) end blowout_psy_sound("stop") amk.start_timer("blowout",2,5) elseif phase==5 then level.set_weather(amk.load_variable("weather","default")) if bt<1 then local snd_obj = xr_sound.get_safe_sound_object([[anomaly\teleport_work2]]) snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0) level.set_weather("amk_groza_groza_"..level.get_time_hours()) amk.save_variable("dynw","groza") amk.save_variable("dynlasthour", level.get_time_hours()) amk.save_variable("dynweather", "amk_groza_groza_"..level.get_time_hours()) end amk.del_variable("blowout") end end local next_actor_hit_time=0 function on_blowout_hit_actor() if next_actor_hit_time0 or amk.load_variable("blowout",-1)~=3 then if npc:id()==db.actor:id() then in_hide = true end return false end local lname=level.name() local need_hit need_hit=true local khit=1 if hide and hide.zone then need_hit = not check_npc_in_hideout(npc,hide) if not need_hit then if hide.defence then khit=hide.defence else khit=0 end end else local hides=amk_hideouts.hide[lname] local tmp if hides then for i,o in ipairs(hides) do if o.zone then for j,v in ipairs(o.zone) do if v.p3 then tmp=amk.check_npc_in_box(npc,vector():set(unpack(v.p1)),vector():set(unpack(v.p2)),vector():set(unpack(v.p3))) else tmp=amk.check_npc_in_box(npc,vector():set(unpack(v.p1)),vector():set(unpack(v.p2))) end need_hit = need_hit and not tmp if tmp then if o.defence then khit=o.defence else khit=0 end end end end end end end if npc:id()==db.actor:id() then in_hide = not need_hit end if (need_hit or khit>0) and amk.load_variable("blowout",-1)==3 then local h = hit() h.power = (amk_hideouts.blowout_damages[lname] or 0.01)*khit h.impulse = 0 h.draftsman = npc h.direction = vector():set(0,0,0) h:bone("bip01_spine") -- чтобы учитывалась броня h.type = hit.strike npc:hit(h) h.type = hit.telepatic npc:hit(h) h.type = hit.radiation npc:hit(h) end return need_hit or khit>0 end function check_npc_in_hideout(npc,hide) local not_in_zone=true if hide and hide.zone then for k,v in pairs(hide.zone) do if v.p3 then not_in_zone = not_in_zone and not amk.check_npc_in_box(npc,vector():set(unpack(v.p1)),vector():set(unpack(v.p2)),vector():set(unpack(v.p3))) else not_in_zone = not_in_zone and not amk.check_npc_in_box(npc,vector():set(unpack(v.p1)),vector():set(unpack(v.p2))) end end end return not not_in_zone end function initial_spawn(action) local fr=0 for i=0,amk_hideouts.anom_count-1,1 do local sobj = alife():story_object(amk_hideouts.anom_sid0+i) if not sobj then alife():create(i+amk_hideouts.anom_num0) fr=1 end end if fr==1 then create_anoms() end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** ANOMS SPAWN ** ** ** ** ** ** ** ** --'******************************************************************************* anomalies_state={} function remove_anoms() amk.save_variable("blowout_anoms",string.rep(string.char(128),math.ceil(amk_hideouts.anom_count/7))) update_anoms() end function create_anoms() anomalies_state={} for i=amk_hideouts.anom_sid0,amk_hideouts.anom_sid0+amk_hideouts.anom_count-1,1 do anomalies_state[i]=math.random(0,1)==1 end local str=pack_anoms(anomalies_state) amk.save_variable("blowout_anoms",str) update_anoms() end function update_anoms() local anoms=amk.load_variable("blowout_anoms",string.rep(string.char(128),math.ceil(amk_hideouts.anom_count/7))) anomalies_state=unpack_anoms(anoms) for i=amk_hideouts.anom_sid0,amk_hideouts.anom_sid0+amk_hideouts.anom_count-1,1 do local sobj=alife():story_object(i) if sobj then local obj=level.object_by_id(sobj.id) if obj then if anomalies_state[i] then obj:enable_anomaly() else obj:disable_anomaly() end end end end end -- anom_state[sid]==true для активных аномалий function pack_anoms(anom_state) local str="" for i=0,amk_hideouts.anom_count-1,7 do local cval=128 local mul=1 for j=0,6,1 do if anom_state[i+j+amk_hideouts.anom_sid0] then cval=cval+mul end mul=mul*2 end str=str..string.char(cval) end return str end function unpack_anoms(str) local anom={} for i=1,string.len(str),1 do local cval=string.byte(string.sub(str,i,i)) local mul=1 for j=0,6,1 do anom[(i-1)*7+j+amk_hideouts.anom_sid0]=bit_and(mul,cval)~=0 mul=mul*2 end end return anom end function blowout_type() local lname=level.name() local t=amk_hideouts.blowout_types[lname] if t>1 and amk.load_variable("freeplay",0)==2 then t=0 end return t or 0 end --'******************************************************************************* --' ** ** ** ** ** ** ** ** ** RECEPTS ** ** ** ** ** ** ** ** ** --'******************************************************************************* function check_usable_item(obj) local info=nil if obj:section()=="vehicle_btr" then db.actor:kill(db.actor) end if obj:name()=="mil_stalker0012" then info="info_amk_recipt_stone_dikoobraz" elseif level.name()=="l01_escape" and obj:section()=="amk_zapiska" then info="info_amk_recipt_shkura" amk.drop_item(db.actor,obj) amk.remove_item(obj) elseif level.name()=="l04u_labx18" and obj:section()=="amk_zapiska" then info="info_amk_recipt_simbion" amk.drop_item(db.actor,obj) amk.remove_item(obj) elseif level.name()=="l08u_brainlab" and obj:section()=="amk_zapiska" then info="info_amk_recipt_dummy" amk.drop_item(db.actor,obj) amk.remove_item(obj) else local recipes=amk.load_table("amk_body_recipe") info=recipes[obj:id()] end if db.actor==nil or info==nil or db.actor:has_info(info) then return end db.actor:give_info_portion(info) amk_dialogs.info_received() end function generate_recipe(obj) if IsMonster(obj) then return end local info=nil local prop=100 if level.name()=="l07_military" and obj.character_community and obj:character_community()=="killer" then info="info_amk_recipt_titan_kolobok" prob=30 elseif level.name()=="l10_radar" and obj.character_community and obj:character_community()=="monolith" then info="info_amk_recipt_controller_skalp" prob=10 end if not info then return end local recipes=amk.load_table("amk_body_recipe") -- Проверим не генерился ли уже этот рецепт for k,v in pairs(recipes) do if v==info then return end end -- Сгенерим рецепт if math.random(100)<=prob then recipes[obj:id()]=info amk.save_table("amk_body_recipe",recipes) end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** OUTFIT_HUD ** ** ** ** ** ** ** ** ** --'******************************************************************************* local currhud local curr_tex local cur_weapon_fov local hud_tbl={ --hud_gaz svoboda_gaz_outfit_m1="hud_gaz", dolg_gaz_outfit_m1="hud_gaz", neytral_gaz_outfit_m1="hud_gaz", neytral_novice_gaz_outfit_m1="hud_gaz", svoboda_heavy_gaz_outfit_m1="hud_gaz", bandit_gaz_outfit_m1="hud_gaz", --hud_exo neytral_exo_gaz_outfit_m1="hud_exo", svoboda_yellow_exo_outfit_m1="hud_exo", exo_outfit="hud_exo", --hud_merc killer_gaz_outfit_m1="hud_merc", --hud_sci dolg_scientific_outfit="hud_sci", ecolog_outfit="hud_sci", protection_outfit="hud_sci", scientific_outfit="hud_sci", --hud_military military_outfit="hud_military", militaryspec_outfit="hud_military" } local current_static local static_enabled local current_zoom=1 update_hud=false function set_hud_tex(static,enabled) local zoom=67.5/device().fov zoom=(zoom-1)*1.5+1 if zoom<1.001 then zoom=1.001 end local stretchy=0.75/(math.floor(device().aspect_ratio*1000)/1000) if stretchy<1 then stretchy=1 end local rect={x=-768*zoom+768,y=(-512*zoom+512)*stretchy-(stretchy-1)*300,w=1024*zoom,h=768*zoom*stretchy} if amk.load_variable("option_hud",2)==2 then set_blurs(enabled and curr_tex~="hud_sci" and static~=nil,rect) else set_blurs(false,rect) end if enabled==static_enabled and current_static==static and zoom==current_zoom and (not update_hud) then return end update_hud=false current_zoom=zoom local need_change=false if current_static~=static then if current_static then get_hud():RemoveCustomStatic(current_static) end if static then get_hud():AddCustomStatic(static) end need_change=true current_static=static end local wnd=get_hud():GetCustomStatic(current_static) and get_hud():GetCustomStatic(current_static):wnd() if (not enabled) and wnd then wnd:SetWidth(0) elseif wnd then wnd:SetWndRect(rect.x,rect.y,rect.w,rect.h) end static_enabled=enabled end local blurs=nil local blurval=0 -- уровень запотевания от 0 до 1 local blurlt=0 -- время последнего обновления local blurcyctime=0 -- время начала последнего цикла дыхания (выдох) local blurlastphase=0 function set_blurs(enabled,rect) if (not blurs) or get_hud():GetCustomStatic("hud_blur1")==nil then blurs={} for i=1,4 do get_hud():AddCustomStatic("hud_blur"..i) blurs[i]=get_hud():GetCustomStatic("hud_blur"..i):wnd() blurs[i]:SetWidth(0) end end if not enabled then for i=1,4 do blurs[i]:SetWidth(0) end return end -- Циклы в зависимости от силы дыхания: 0->1->0 0->1->2->4->5->0 0->1->2->3->4->5->0 5->4->3->4->5 4->3->4 local power=db.actor.power local period=1.0+power*power*1.0 -- текущая частота дыхания от 30 до 120 циклов в минуту local expirt=0.3 local breathpower=3 local delta=(time_global()-blurlt)/1000 -- дельта в секундах local phase=(time_global()-blurcyctime)/1000 -- фаза дыхательного цикла в сек. blurlt=time_global() if phase>period then phase=phase%period blurcyctime=blurlt-phase*1000 end if blurlastphase>phase then blurlastphase=0 end local blurdelta=delta*-0.7 -- работа вентилляции if blurlastphase0.999 then blurval=0.999 elseif blurval<0 then blurval=0 end local tm=math.floor(blurval*3) local tmn=(tm+1) local v=blurval*3-math.floor(blurval*3) v=1-v local v1=1-v if tm~=0 then blurs[tm]:SetColor(GetARGB(v*255,255,255,255)) end if tmn~=0 then blurs[tmn]:SetColor(GetARGB(v1*255,255,255,255)) end for i=1,4 do if i==tm or i==tmn then blurs[i]:SetWndRect(rect.x,rect.y,rect.w,rect.h) else blurs[i]:SetWndRect(rect.x,rect.y,0,0) end end end local lhup=0 function check_hud() local hudotf,actor if db and db.actor then actor=db.actor else return false end if amk.is_debug then if lhup0 and not (act_it and act_it:section()=="wpn_binoc" and device().fov<50) and device().fov>30 and amk.load_variable("option_hud",2)~=0 then set_hud_tex(tex,true) else set_hud_tex(tex,false) end if (ui_rad and db.actor.health>0 and amk.load_variable("option_rad",1) ~= 0) then if act_it and act_it:section()=="wpn_binoc" then local zoom=67.5/device().fov zoom=(zoom-1)*1.5+1 if zoom<1.001 then zoom=1.001 end if zoom > 1.3 then ui_rad.update(false) else ui_rad.update(true) end else ui_rad.update(true) end elseif (ui_rad) then ui_rad.update(false) end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** SPAWN_OBJ ** ** ** ** ** ** ** ** ** --'******************************************************************************* function spawn_fuel() local ballons = { {108.16, -6.30, -18.17, 412158, 115}, {370.12, 15.06, -39.48, 594401, 0}, {58.30, 19.36, 156.50, 345136, 97}, {-92.21, -1.18, -212.66, 115177, 268}, {-74.17, 1.80, 8.45, 127766, 329}, {3.18, 1.24, 42.48, 243919, 490}, {15.35, -1.90, 2.40, 255433, 479}, {77.54, 0.30, -108.47, 312366, 427}, {-145.54, -0.00, -199.61, 92520, 650}, {-130.08, 10.00, -196.67, 109214, 629}, {-140.13, 10.00, -197.94, 98647, 629}, {37.28, 1.02, -49.90, 220638, 1084}, {476.68, -46.94, -0.23, 155714, 1919}, {76.80, -2.54, -23.93, 36304, 1970}, {94.78, 0.03, -6.88, 88986, 1514}, {-3.24, -11.75, -263.07, 33794, 1448} } local kanisters = { {-293.80, -14.18, -15.36, 15703, 67}, {-16.57, 2.48, 58.82, 260308, 88}, {-74.81, -1.30, 160.52, 196218, 163}, {-69.94, 0.97, 6.51, 131411, 329}, {64.01, 0.60, 148.46, 235341, 364}, {63.29, -0.20, 5.10, 299326, 461}, {-28.52, -1.04, -181.84, 211644, 676}, {2.93, -1.88, -13.30, 176553, 1047}, {41.71, 4.54, -86.36, 227110, 1100}, {7.90, 1.41, -71.93, 183138, 1041}, {158.71, -0.76, -259.73, 358950, 962}, {-342.92, -13.60, 390.01, 11235, 1847}, {305.22, -36.99, -24.40, 68330, 1930}, {55.02, 1.17, 40.35, 68094, 1511}, {-114.14, -0.00, 121.75, 43453, 1315}, {31.33, 5.60, -13.51, 4683, 1538} } for k,v in pairs(ballons) do if table.getn(v) == 5 then local obj = alife():create("amk_ballon",vector():set(v[1], v[2], v[3]), v[4], v[5]) if obj and is_debug==true then amk.add_spot_on_map(obj.id, "red_location", "ballon") end end end for k,v in pairs(kanisters) do if table.getn(v) == 5 then local obj = alife():create("amk_kanistra",vector():set(v[1], v[2], v[3]), v[4], v[5]) if obj and is_debug==true then amk.add_spot_on_map(obj.id, "red_location", "kanistra") end end end end -- БТР на блокпосту function spawn_military_btr() spawn_military_tech_pack( alife():create("vehicle_btr",vector():set(-168.11, -29.71, -303.21),81808,38 ) ,"vehicle_btr") spawn_military_tech_pack( alife():create("vehicle_btr",vector():set(-237.85, -26.23, -378.81),17147,14 ) ,"vehicle_btr") spawn_military_tech_pack( alife():create("helicopter",vector():set(-150.0,-40.0,-620.0),128298,11 ) ,"helicopter") end function spawn_military_tech_pack(obj, spawn_item) local packet = net_packet() obj:STATE_Write(packet) -- свойства cse_alife_object local game_vertex_id = packet:r_u16() local cse_alife_object__unk1_f32 = packet:r_float() local cse_alife_object__unk2_s32 = packet:r_s32() local level_vertex_id = packet:r_s32() local object_flags = packet:r_s32() local custom_data = packet:r_stringZ() local story_id = packet:r_s32() local cse_alife_object__unk3_s32 = packet:r_s32() -- свойства cse_visual local model_visual = packet:r_stringZ() local cse_visual__unk1_u8 = packet:r_u8() local motion_name if spawn_item == "helicopter" then -- свойства cse_motion motion_name = packet:r_stringZ() end -- свойства cse_ph_skeleton local skeleton_name = packet:r_stringZ() local cse_ph_skeleton__unk1_u8 = packet:r_u8() local cse_ph_skeleton__unk2_u16 = packet:r_u16() local health local cse_alife_helicopter__unk1_sz local engine_sound if spawn_item == "helicopter" then -- свойства cse_alife_helicopter cse_alife_helicopter__unk1_sz = packet:r_stringZ() engine_sound = packet:r_stringZ() elseif spawn_item == "vehicle_btr" then health = packet:r_float() end -- теперь заполняем нужные параметры -- свойства cse_alife_object packet:w_begin(game_vertex_id) packet:w_float(cse_alife_object__unk1_f32) packet:w_s32(cse_alife_object__unk2_s32) packet:w_s32(level_vertex_id) object_flags = bit_not(5) -- ~5 = 0xfffffffa packet:w_s32(object_flags) if spawn_item == "helicopter" then packet:w_stringZ("[logic]\ncfg = scripts\\esc\\esc_blockpost_heli.ltx") elseif spawn_item == "vehicle_btr" then packet:w_stringZ("[logic]\ncfg = scripts\\esc\\esc_blockpost_btr.ltx") end packet:w_s32(-1) packet:w_s32(cse_alife_object__unk3_s32) -- свойства cse_visual packet:w_stringZ(model_visual) packet:w_u8(cse_visual__unk1_u8) if spawn_item == "helicopter" then packet:w_stringZ(motion_name) end -- свойства cse_ph_skeleton skeleton_name = "idle" packet:w_stringZ(skeleton_name) packet:w_u8(cse_ph_skeleton__unk1_u8) packet:w_u16(cse_ph_skeleton__unk2_u16) if spawn_item == "helicopter" then -- свойства cse_alife_helicopter cse_alife_helicopter__unk1_sz = "idle" engine_sound = "alexmx\\helicopter" packet:w_stringZ(cse_alife_helicopter__unk1_sz) packet:w_stringZ(engine_sound) elseif spawn_item == "vehicle_btr" then health = 1 packet:w_float(health) end -- считываем скорректированные параметры packet:r_seek(0) obj:STATE_Read(packet, packet:w_tell()) end --'******************************************************************************* --' ** ** ** ** ** ** ** ** DYNWEATHERS ** ** ** ** ** ** ** ** --'******************************************************************************* dynweathers={ clear={ clear=75, pasmurno=15, rain=10, groza=5 }, pasmurno={ clear=65, rain=20, groza=10, pasmurno=5 }, rain={ clear=65, groza=20, pasmurno=10, rain=5 }, groza={ clear=65, rain=20, pasmurno=10, groza=5 } } function weather_manager() if sync_done==false then return end local hour = level.get_time_hours() local dynlasthour = amk.load_variable("dynlasthour",-1) if dynlasthour"..next_weather) if (news_main and news_main.on_weather_change) then news_main.on_weather_change(dynw, next_weather) end amk.save_variable("dynw",next_weather) amk.save_variable("dynlasthour",hour) amk.save_variable("dynweather","amk_"..dynw.."_"..next_weather.."_"..hour) end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** AMK_RESPAWNS ** ** ** ** ** ** ** ** --'******************************************************************************* function switch_monster_online(obj) se_monster.need_be_online[obj.id]=true end function switch_monster_offline(obj) se_monster.need_be_online[obj.id]=false end function respawned(obj,respawner) if IsMonster(obj) then local sini = respawner:spawn_ini() if sini:line_exist ("respawn", "creature_binded_logic") == true then local cfg_name = utils.cfg_get_string(sini, "respawn", "creature_binded_logic", false, false, false, "") local t = amk.read_monster_params(obj) t.custom = "[logic]\ncfg = scripts\\amk\\"..cfg_name..".ltx" amk.write_monster_params(t, obj) end elseif IsStalker(obj) then local sini = respawner:spawn_ini() if sini:line_exist ("respawn", "creature_binded_logic") == true then local cfg_name = utils.cfg_get_string(sini, "respawn", "creature_binded_logic", false, false, false, "") local t = amk.read_stalker_params(obj) t.custom = "[logic]\ncfg = scripts\\amk\\"..cfg_name..".ltx" amk.write_stalker_params(t, obj) end end end local respawners={} function spawn_unspawned_respawners() for a=1,65534 do local obj = alife():object(a) if obj then local oini = obj:spawn_ini() if oini:line_exist ("respawn", "amk_name") == true then local amk_name = utils.cfg_get_string(oini, "respawn", "amk_name", false, false, false, false) if amk_name then respawners[amk_name]=true end end end end local sini = ini_file("scripts\\amk\\amk_respawns.ltx") local dv={} if sini:section_exist("default_values") then local result, id, value = nil, nil, nil for a=0,sini:line_count("default_values")-1 do result, id, value = sini:r_line("default_values",a,"","") if id~=nil and amk.trim(id)~="" and amk.trim(id)~=nil then dv[amk.trim(id)]=amk.trim(value) end end end if sini:section_exist("amk_respawns") then local tmp={} local result, id, value = nil, nil, nil for a=0,sini:line_count("amk_respawns")-1 do result, id, value = sini:r_line("amk_respawns",a,"","") if id~=nil and amk.trim(id)~="" and amk.trim(id)~=nil then table.insert(tmp, amk.trim(id)) end end for k,v in pairs(tmp) do local flag = utils.cfg_get_bool(sini, "amk_respawns", v, true, false, false) if not respawners[v] and flag==true then local t = amk.parse_ini_section_to_array(sini, v) local xyzlg = amk.str_explode(",",t.xyzlg,true) local pos = vector():set(tonumber(xyzlg[1]),tonumber(xyzlg[2]),tonumber(xyzlg[3])) local respawner = amk.spawn_item("respawn",pos,tonumber(xyzlg[5]),tonumber(xyzlg[4])) local tbl = amk.get_spawner_data(respawner) t.xyzlg = nil t.amk_name = v for kkk,vvv in pairs(dv) do if t[kkk]==nil then t[kkk]=vvv end end tbl.custom = amk.gen_custom_data({respawn=t}) --amk.mylog(tbl.custom) amk.set_spawner_data(tbl, respawner) se_respawn.reinit_spawner_params(respawner:name()) --amk.add_spot_on_map(respawner.id,"red_location", v) --amk.mylog("spawned respawn "..respawner.id) end if flag==false then local o = se_respawn.get_respawner_by_name(v) if o then --amk.mylog("released respawn "..o.id) alife():release(o) end end end end end --'******************************************************************************* --' ** ** ** ** ** ** ** ** ** OTHER ** ** ** ** ** ** ** ** ** --'******************************************************************************* local last_armor_id=0 local last_condition=0 function repair_armor(val) local armor = db.actor:item_in_slot(6) if armor then last_armor_id=armor:id() last_condition=val armor:set_condition(val) end end function check_armor() local armor = db.actor:item_in_slot(6) local weapon = db.actor:item_in_slot(2) if db.actor:active_slot()==2 and weapon then local tmp if armor then tmp = armor:section() else tmp = "none" end if (not string.find(tmp, "exo")) and weapon:section()=="wpn_pkm" then db.actor:drop_item(weapon) local tmpw = amk.spawn_item_in_inv("wpn_pkm") db.actor:transfer_item(weapon,db.actor) alife():release(tmpw) end end if not armor then last_armor_id=0 return end if armor:id()~=last_armor_id then last_armor_id=armor:id() last_condition=armor:condition() return end if last_condition0 and who and IsStalker(who) then --false для отключения local script if IsMonster(obj) then script=bind_monster elseif IsStalker(obj) then script=xr_motivator end if script then local weapon = who:active_item() if not weapon or weapon:section()~="wpn_flame" then return end if string.find(obj:section(), "zomb") and obj.health<0.2 then obj:kill(obj) end script.play_particle(obj, { obj=obj, particle="amk\\flame", bone="bip01_spine1" }) end end end local zombi_skeletons={ "physics\\dead_body\\skelet_combine_pose_03", "physics\\dead_body\\skelet_combine_pose_04", "physics\\dead_body\\skelet_combine_pose_05", "physics\\dead_body\\skelet_torso" } function zomby_blow(obj) if obj:object("wpn_flame") then amk_particle.amk_particle({ particle="explosions\\explosion_fuelcan", pos=obj:position(), sound=[[weapons\t_rgd5_explosion]] }) local dist = db.actor:position():distance_to(obj:position()) if dist < 10 and db.actor:see(obj) then local h = hit() h.impulse = 0 h.draftsman = db.actor h.direction = vector():set(0,0,0) h:bone("bip01_spine") -- чтобы учитывалась броня h.power = 1/dist h.type = hit.strike --chemical_burn db.actor:hit(h) h.power = 15/dist h.type = hit.chemical_burn db.actor:hit(h) end alife():release(alife():object(obj:id())) return end if obj:section()=="zombie_blow" then amk_particle.amk_particle({ particle="amk\\zomb_explode", pos=obj:position(), sound=[[anomaly\anomaly_body_tear_1]] }) local dist = db.actor:position():distance_to(obj:position()) if dist < 30 and db.actor:see(obj) then local h = hit() h.impulse = 0 h.draftsman = db.actor h.direction = vector():set(0,0,0) h:bone("bip01_spine") -- чтобы учитывалась броня h.power = 1/dist h.type = hit.strike --chemical_burn db.actor:hit(h) h.power = 15/dist h.type = hit.chemical_burn db.actor:hit(h) end local skel = amk.spawn_item("breakable_object",obj:position(),obj:game_vertex_id(),obj:level_vertex_id()) local t = amk.get_breakable_data(skel) t.visual = zombi_skeletons[math.random(table.getn(zombi_skeletons))] t.mass = 1.0 t.physic_type = 3 t.skeleton_flags = 1 amk.set_breakable_data(t,skel) alife():release(alife():object(obj:id())) end end function repair_weapon (st) local arr = amk.unpack_array_from_string(st) local oid = arr[1] local repbox_health = arr[2] local slot = arr[3] if alife():object(oid)==nil then local repair_coef = 0 local item_in_slot = db.actor:item_in_slot(slot) if repbox_health==1 then repair_coef=0.25 elseif repbox_health<1 then repair_coef=0.2 elseif repbox_health<0.8 then repair_coef=0.15 elseif repbox_health<0.6 then repair_coef=0.1 elseif repbox_health<0.4 then repair_coef=0.05 end --------------------------------------------------------------------------- local rem if item_in_slot == nil then amk.send_tip(game.translate_string("rep_no_weapon_in_slot"),nil,nil,5) rem = amk.spawn_item_in_inv("repbox_s"..slot) amk.start_timer("repbox_cond",0.1,amk.pack_array_to_string( {rem.id, repbox_health} )) else if item_in_slot:condition()>0.95 then amk.send_tip(game.translate_string("rep_not_need"),nil,nil,5) rem = amk.spawn_item_in_inv("repbox_s"..slot) amk.start_timer("repbox_cond",0.1,amk.pack_array_to_string( {rem.id, repbox_health} )) else if item_in_slot:condition()>=0.7 then item_in_slot:set_condition(item_in_slot:condition() + repair_coef) if repbox_health>0.3 then rem = amk.spawn_item_in_inv("repbox_s"..slot) amk.start_timer("repbox_cond",0.1,amk.pack_array_to_string( {rem.id, repbox_health-0.2} )) end else amk.send_tip(game.translate_string("rep_need_big"),nil,nil,5) rem = amk.spawn_item_in_inv("repbox_s"..slot) amk.start_timer("repbox_cond",0.1,amk.pack_array_to_string( {rem.id, repbox_health} )) end end end end end function after_repair_weapon (st) local arr = amk.unpack_array_from_string(st) local oid = arr[1] local repbox_health = arr[2] local lobj = level.object_by_id(oid) if lobj then lobj:set_condition(repbox_health) end end function firebat_ammo() local ammo=db.actor:object("ammo_flame") if ammo then db.actor:iterate_inventory( function(dummy,item) if item:section()=="ammo_flame" then alife():release(alife():object(item:id())) end end , db.actor) end end