Advertisement
Guest User

axr_dynamic_spawn.script

a guest
Jan 16th, 2014
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 40.58 KB | None | 0 0
  1. ----------------------
  2. -- axr_dynamic_spawn
  3. -- Alundaio
  4. -- Modified by Yasti based on PR 1.12 mod:
  5. --                                      -Save\load functions for dynamic spawns added
  6. --                                      -Check function for corrupted dynamic_story_id table added
  7. --[[
  8.     Copyright (C) 2012 Alundaio
  9.     This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
  10. --]]
  11. local m_classes =
  12. {
  13. -- Credit: Barin
  14.     ["S_ACTOR"]  = "cse_alife_actor", -- actor (CS, COP)
  15.  
  16.     ["AI_STL_S"] = "cse_alife_stalker", -- stalker (SOC, CS, COP)
  17.  
  18.     ["SM_BLOOD"] = "se_monster", -- bloodsucker (SOC, CS, COP)
  19.     ["SM_BOARW"] = "se_monster", -- boar (SOC, CS, COP)
  20.     ["SM_BURER"] = "se_monster", -- burer (SOC, CS, COP)
  21.     ["SM_CAT_S"] = "se_monster", -- cat (SOC, CS)
  22.     ["SM_CHIMS"] = "se_monster", -- chimera (SOC, CS, COP)
  23.     ["SM_CONTR"] = "se_monster", -- controller (SOC, CS, COP)
  24.     ["AI_CROW"]  = "cse_alife_creature_abstract", --"cse_alife_creature_crow", -- crow (SOC, CS, COP)
  25.     ["SM_DOG_S"] = "se_monster", -- dog (SOC, CS, COP)
  26.     ["SM_FLESH"] = "se_monster", -- flesh (SOC, CS, COP)
  27.     ["SM_IZLOM"] = "se_monster", -- izlom (SOC, CS)
  28.     ["SM_GIANT"] = "se_monster", -- pseudogigant (SOC, CS, COP)
  29.     ["AI_PHANT"] = "cse_alife_creature_abstract", --"cse_alife_creature_phantom", -- phantom (SOC, CS, COP)
  30.     ["SM_POLTR"] = "se_monster", -- poltergeist (SOC, CS, COP)
  31.     ["SM_P_DOG"] = "se_monster", -- pseudodog (SOC, CS, COP)
  32.     ["SM_DOG_P"] = "se_monster", -- psy dog (SOC, CS, COP)
  33.     ["SM_DOG_F"] = "se_monster", -- psy dog phantom (SOC, CS, COP)
  34.     ["AI_RAT"]   = "se_monster", -- rat (SOC, CS)
  35.     ["SM_SNORK"] = "se_monster", -- snork (SOC, CS, COP)
  36.     ["SM_TUSHK"] = "se_monster", -- tushkano (SOC, CS, COP)
  37.     ["SM_ZOMBI"] = "se_monster", -- zombie (SOC, CS)
  38.  
  39.     ["C_HLCP_S"] = "cse_alife_helicopter", -- helicopter (SOC, CS, COP)
  40.     ["SCRPTCAR"] = "cse_alife_car", -- m_car (SOC, CS, COP)
  41.  
  42.     ["ARTEFACT"] = "cse_alife_item", --"cse_alife_item_artefact", -- artefact (SOC, CS, COP)
  43.     ["SCRPTART"] = "cse_alife_item", --"cse_alife_item_artefact", -- artefact (SOC, CS, COP)
  44.  
  45.     ["AI_GRAPH"] = "cse_alife_graph_point", -- graph_point (SOC, CS, COP)
  46.  
  47.     ["ON_OFF_S"] = "cse_alife_online_offline_group", -- online_offline_group (COP)
  48.  
  49.     ["LVL_CHNG"] = "cse_alife_level_changer", -- level_changer (SOC, CS, COP)
  50.     ["SCRIPTZN"] = "cse_alife_space_restrictor", -- script_zone (SOC, CS, COP); sim_faction (COP)
  51.     ["Z_TEAMBS"] = "cse_alife_team_base_zone", -- zone_team_base (SOC, CS, COP)
  52.     ["SPC_RS_S"] = "cse_alife_space_restrictor", -- space_restrictor (SOC, CS, COP); anomal_zone (CS, COP); camp_zone (COP)
  53.     ["SMRT_C_S"] = "cse_alife_smart_cover", -- smart_cover (CS, COP)
  54.     ["SMRTTRRN"] = "se_smart_terrain", -- smart_terrain (SOC, CS, COP)
  55.  
  56.     ["II_ATTCH"] = "cse_alife_item", -- attachable_item (SOC, CS, COP)
  57.     ["II_BTTCH"] = "cse_alife_item", -- new_attachable_item (SOC, CS, COP)
  58.  
  59.     ["II_DOC"]   = "cse_alife_item_document", -- document (SOC, CS, COP)
  60.  
  61.     ["SO_HLAMP"] = "cse_alife_object_hanging_lamp", -- lights_hanging_lamp, lights_signal_light (COP)
  62.     ["O_SEARCH"] = "cse_alife_object_projector", -- search_light (SOC, CS, COP)
  63.     ["TORCH_S"]  = "cse_alife_item_torch", -- device_torch (SOC, CS, COP)
  64.  
  65.     ["O_BRKBL"]  = "cse_alife_object_breakable", -- breakable_object (SOC, CS, COP)
  66.     ["O_CLMBL"]  = "cse_alife_object_climable", -- climable_object (SOC, CS, COP)
  67.  
  68.     ["O_PHYS_S"] = "cse_alife_object_physic", -- physic_object (SOC, CS, COP)
  69.     ["O_DSTR_S"] = "cse_alife_object_physic", -- physic_destroyable_object, physic_door (COP)
  70.     ["P_SKELET"] = "cse_alife_ph_skeleton_object", -- ph_skeleton_object (SOC, CS, COP)
  71.  
  72.     ["S_INVBOX"] = "cse_alife_inventory_box", -- inventory_box (COP)
  73.  
  74.     ["DET_SIMP"] = "cse_alife_item", --"cse_alife_item_detector", -- detector_simple (COP)
  75.     ["DET_ADVA"] = "cse_alife_item", --"cse_alife_item_detector", -- detector_advanced (COP)
  76.     ["DET_ELIT"] = "cse_alife_item", --"cse_alife_item_detector", -- detector_elite (COP)
  77.     ["DET_SCIE"] = "cse_alife_item", --"cse_alife_item_detector", -- detector_scientific (COP)
  78.  
  79.     ["E_STLK"]   = "cse_alife_item", -- outfit (SOC, CS, COP)
  80.     ["E_HLMET"]  = "cse_alife_item_helmet", -- helmet (COP)
  81.  
  82.     ["II_BANDG"] = "cse_alife_item", -- bandage (SOC, CS)
  83.     ["II_MEDKI"] = "cse_alife_item", -- meds (SOC, CS)
  84.     ["II_ANTIR"] = "cse_alife_item", -- antirad (SOC, CS)
  85.     ["II_BOTTL"] = "cse_alife_item", -- drink (SOC, CS)
  86.     ["II_FOOD"]  = "cse_alife_item", -- edibles (SOC, CS)
  87.     ["S_FOOD"]   = "cse_alife_item", -- edibles/meds (COP)
  88.  
  89.     ["S_PDA"]    = "cse_alife_item_pda", -- device_pda (COP)
  90.     ["D_PDA"]    = "cse_alife_item_pda", -- device_pda (SOC, CS); dev_flash_1, dev_flash_2 (CS, COP)
  91.  
  92.     ["II_BOLT"]  = "cse_alife_item", --"cse_alife_item_bolt", -- bolt (SOC, CS, COP)
  93.  
  94.     ["WP_KNIFE"] = "cse_alife_item_weapon", -- wpn_knife (SOC, CS, COP)
  95.  
  96.     ["WP_LR300"] = "cse_alife_item_weapon",
  97.     ["WP_GROZA"] = "cse_alife_item_weapon",
  98.     ["WP_PM"]    = "cse_alife_item_weapon",
  99.     ["WP_AK74"]  = "cse_alife_item_weapon",
  100.     ["WP_BINOC"] = "cse_alife_item_weapon", -- wpn_binoc (SOC, CS, COP)
  101.     ["WP_RPG7"]  = "cse_alife_item_weapon", -- wpn_rpg7 (SOC, CS, COP)
  102.     ["WP_HPSA"]  = "cse_alife_item_weapon", -- wpn_hpsa (SOC, CS, COP)
  103.     ["WP_VAL"]   = "cse_alife_item_weapon", -- wpn_val (SOC, CS, COP)
  104.     ["WP_SVU"]   = "cse_alife_item_weapon", -- wpn_svu (SOC, CS, COP)
  105.     ["WP_SVD"]   = "cse_alife_item_weapon", -- wpn_gauss, wpn_svd (SOC, CS, COP)
  106.  
  107.     ["W_MOUNTD"] = "cse_alife_mounted_weapon", -- mounted_weapon (SOC, CS, COP)
  108.     ["W_STMGUN"] = "cse_alife_mounted_weapon", -- stationary_mgun (SOC, CS, COP)
  109.  
  110.     ["S_EXPLO"]  = "cse_alife_item", --"cse_alife_item_explosive", -- explosives (COP)
  111.  
  112.     ["WP_BM16"]  = "cse_alife_item_weapon", -- wpn_bm16, wpn_toz34 (SOC, CS, COP)
  113.     ["WP_ASHTG"] = "cse_alife_item_weapon", -- wpn_protecta, wpn_spas12, wpn_wincheaster1300 (COP)
  114.     ["WP_RG6"]   = "cse_alife_item_weapon", -- wpn_rg-6 (SOC, CS, COP)
  115.  
  116.     ["AMMO_S"]   = "cse_alife_item_ammo", -- ammo (COP)
  117.     ["S_OG7B"]   = "cse_alife_item_ammo", -- ammo_og-7b (COP)
  118.     ["S_VOG25"]  = "cse_alife_item_ammo", -- ammo_vog-25 (COP)
  119.     ["S_M209"]   = "cse_alife_item_ammo", -- ammo_m209 (COP)
  120.  
  121.     ["G_F1_S"]   = "cse_alife_item", --"cse_alife_item_grenade", -- grenade_f1, grenade_gd-05 (COP)
  122.     ["G_RGD5_S"] = "cse_alife_item", --"cse_alife_item_grenade", -- grenade_rgd5 (COP)
  123.  
  124.     ["WP_SCOPE"] = "cse_alife_item", -- wpn_addon_scope, wpn_addon_scope_susat (SOC, CS, COP)
  125.     ["WP_SILEN"] = "cse_alife_item", -- wpn_addon_silencer (COP)
  126.     ["WP_GLAUN"] = "cse_alife_item", -- wpn_addon_grenade_launcher, wpn_addon_grenade_launcher_m203 (COP)
  127.  
  128.     ["ZS_MBALD"] = "cse_alife_anomalous_zone", -- buzz, zharka_static, witches_galantine, mosquito_bald (SOC, CS, COP); zone_mine_* (CS, COP)
  129.     ["ZS_GALAN"] = "cse_alife_anomalous_zone", -- zone_gravi_zone (SOC, CS, COP)
  130.     ["ZS_MINCE"] = "cse_alife_anomalous_zone", -- zone_mincer (SOC, CS, COP)
  131.     ["ZS_RADIO"] = "cse_alife_anomalous_zone", -- zone_field_* (COP)
  132.     ["ZS_TORRD"] = "se_zone_torrid", -- fireball_zone, fireball_electric_zone, fireball_acidic_zone (COP)
  133.     ["ZS_BFUZZ"] = "se_zone_visual", -- zone_burning_fuzz (SOC, CS, COP)
  134.  
  135.     ["Z_MBALD"]  = "cse_alife_anomalous_zone", -- zone_teleport, zone_mine_field (SOC, CS, COP)
  136.     ["Z_RADIO"]  = "cse_alife_anomalous_zone", -- zone_radioactive (SOC, CS, COP); zone_field_* (CS)
  137.     ["Z_CFIRE"]  = "cse_alife_anomalous_zone", -- campfire (CS, COP)
  138.     ["Z_NOGRAV"] = "cse_alife_anomalous_zone", -- zone_no_gravity (SOC, CS, COP)
  139. }
  140.  
  141. secret_stashes = {}
  142. dynamic_story_id = {}
  143. local corrupt_detect = false
  144.  
  145.  
  146. function on_game_start()
  147. --  callback_register("se_actor_on_register",on_register)
  148.     callback_register("on_game_load",on_game_load)
  149.     callback_register("actor_on_update",actor_on_update)
  150.     callback_register("actor_on_item_take_from_box",actor_on_item_take_from_box)
  151.     callback_register("actor_on_item_take",actor_on_item_take)
  152. end
  153.  
  154. ini = ini_file("dynamic_spawn.ltx")
  155. local dynamic = {}
  156. local on_info_sections
  157.  
  158. function on_register(actor)
  159.  
  160.     local file = io.open("gamedata\\configs\\dynamic_spawn.ltx","r")
  161.     if not (file) then
  162.         return
  163.     end
  164.  
  165.     local data = file:read("*all")
  166.     file:close()
  167.  
  168.     local sections = {}
  169.     local ltx,ltx_data
  170.  
  171.     -- collect all sections from main config
  172.     parse_ltx(actor,sections,data)
  173.  
  174.     -- collect all sections from #include configs
  175.     for fname in string.gmatch(data,[[%"(.-)%"]]) do
  176.         ltx = io.open("gamedata\\configs\\"..fname,"r")
  177.         if (ltx) then
  178.             ltx_data = ltx:read("*all")
  179.             parse_ltx(actor,sections,ltx_data)
  180.             ltx:close()
  181.         end
  182.     end
  183.  
  184.     interpret_spawn_data(sections)
  185. end
  186.  
  187. function on_game_load()
  188.     local file = io.open("gamedata\\configs\\dynamic_spawn.ltx","r")
  189.     if not (file) then
  190.         return
  191.     end
  192.  
  193.     local data = file:read("*all")
  194.     file:close()
  195.  
  196.     local sections = {}
  197.  
  198.     local actor = alife():object(db.actor:id())
  199.     -- Find all sections in dynamic_spawn.ltx as well as #include files
  200.     local deepest
  201.     local list = {}
  202.     while not deepest do
  203.         parse_ltx(actor,sections,data)
  204.         for fname in string.gmatch(data,[[%#include "(.-)%"]]) do
  205.             file = io.open("gamedata\\configs\\"..fname,"r")
  206.             if (file) then
  207.                 table.insert(list,file:read("*all"))
  208.                 file:close()
  209.             end
  210.         end
  211.  
  212.         if (#list > 0) then
  213.             data = list[#list]
  214.             list[#list] = nil
  215.         else
  216.             deepest = true
  217.         end
  218.     end
  219.  
  220.     interpret_spawn_data(sections)
  221. end
  222.  
  223. local tmr
  224.  
  225. function actor_on_update()
  226.     if not (on_info_sections) then
  227.         return
  228.     end
  229.  
  230.     local tg = time_global()
  231.  
  232.     if not (tmr) then
  233.         tmr = 0
  234.     end
  235.  
  236.     if (tg > tmr) then
  237.         tmr = tg + 5000
  238.         return
  239.     end
  240.  
  241.     interpret_spawn_data(on_info_sections)
  242. end
  243.  
  244.  
  245. function actor_on_item_take_from_box(box,obj)
  246.     local sid = story_objects.get_story_objects_registry():get_story_id(box:id())
  247.     if not (secret_stashes[sid]) then
  248.         return
  249.     end
  250.  
  251.     if (box:is_inv_box_empty()) then
  252.         local hud = get_hud()
  253.         hud:HideActorMenu()
  254.         level.map_remove_object_spot(box:id(), "treasure")
  255.         --story_objects.get_story_objects_registry():unregister_by_story_id(sid)
  256.         --alife():release(alife():object(box:id()),true)
  257.         xr_statistic.inc_founded_secrets_counter()
  258.         news_manager.send_treasure(1)
  259.         secret_stashes[sid] = false
  260.  
  261.         local info = alun_utils.read_from_ini(ini,sid,"secret_info","string",nil)
  262.         if (info) then
  263.             give_info(info)
  264.         end
  265.     end
  266. end
  267.  
  268. function actor_on_item_take(item)
  269.     local sid = story_objects.get_story_objects_registry():get_story_id(item:id())
  270.     if not (secret_stashes[sid]) then
  271.         return
  272.     end
  273.  
  274.     level.map_remove_object_spot(item:id(), "treasure")
  275.     xr_statistic.inc_founded_secrets_counter()
  276.     news_manager.send_treasure(1)
  277.     secret_stashes[sid] = false
  278.  
  279.     local info = alun_utils.read_from_ini(ini,sid,"secret_info","string",nil)
  280.     if (info) then
  281.         give_info(info)
  282.     end
  283. end
  284.  
  285. function actor_on_save(se_actor,packet)
  286.     local num = 0
  287.     for k,v in pairs(secret_stashes) do
  288.         num = num + 1
  289.     end
  290.     packet:w_u16(num)
  291.     for k,v in pairs(secret_stashes) do
  292.         packet:w_stringZ(k)
  293.         packet:w_bool(v)
  294.     end
  295.     --Yasti--
  296.     num = 0
  297.    
  298.     for k,v in pairs(dynamic_story_id) do
  299.         num = num + 1
  300.     end
  301.    
  302.     if (num > 0) then
  303.         packet:w_u16(num)
  304.         for story_id,id in pairs(dynamic_story_id) do
  305.             if is_bad_str(story_id) or id > 65535 then
  306.                 give_quick_news("Possible Save Corruption Detected. Reload the save to attempt recovery, load a previous save, or attempt to save again.")
  307.                 alun_utils.printf("axr_dynamic_spawn.save: save corruption detected: id|story_id = "..tostring(id).." | "..tostring(story_id))
  308.             else
  309.                 alun_utils.printf("axr_dynamic_spawn.save: save successful id|story_id = "..tostring(id).." | "..tostring(story_id))
  310.             end
  311.            
  312.             packet:w_stringZ(story_id)
  313.             packet:w_u16(id)
  314.         end
  315.     end
  316.     --End Yasti--
  317. end
  318.  
  319. function actor_on_load(se_actor,packet)
  320.     local num = packet:r_u16()
  321.     for i=1,num do
  322.         local k = packet:r_stringZ()
  323.         local v = packet:r_bool()
  324.         secret_stashes[k] = v
  325.     end
  326.    
  327.     --Yasti--
  328.     local count = packet:r_u16()
  329.     if (count > 0 and count < 65535) then
  330.         for i=1,count do
  331.             dynamic_story_id[packet:r_stringZ()] = packet:r_u16()
  332.         end
  333.     end
  334.        
  335.     for k,v in pairs(dynamic_story_id) do
  336.         local sor = story_objects.get_story_objects_registry()
  337.         local id_check = sor:get_story_id(v)
  338.         local story_check = sor:get(k)
  339.                
  340.         if not id_check or not story_check then
  341.             alun_utils.printf("axr_dynamic_spawn.on_load: dynamic object corruption detected. object does not exist. object name|id = "..tostring(k).." | "..tostring(v))
  342.             dynamic_story_id[k] = nil
  343.             corrupt_detect = true
  344.        
  345.         elseif is_bad_str(k) or v > 65535 then
  346.             alun_utils.printf("axr_dynamic_spawn.on_load: dynamic object corruption detected. bad string or invalid id. object name|id = "..tostring(k).." | "..tostring(v))
  347.             dynamic_story_id[k] = nil
  348.             corrupt_detect = true
  349.            
  350.         elseif id_check and id_check == k and story_check and story_check == v then
  351.             alun_utils.printf("axr_dynamic_spawn.load: load successful id|story_id = "..tostring(v).." | "..tostring(k))
  352.            
  353.         else
  354.             alun_utils.printf("axr_dynamic_spawn.on_load: dynamic object corruption detected. section or id mismatch. object name|id|story_id|obj_id = "..tostring(k).." | "..tostring(v).."|"..tostring(story_check).."|"..tostring(id_check))
  355.             dynamic_story_id[k] = nil
  356.             corrupt_detect = true
  357.         end        
  358.     end
  359.     --End Yasti--
  360. end
  361.  
  362. -------------------------------------------
  363. -- Yasti: function that attempts to repair corrupted dynamic_story_id table
  364. -------------------------------------------
  365. function dynamic_object_check(sec)
  366.     local sor = story_objects.get_story_objects_registry()
  367.     local t = alun_utils.collect_section(ini,sec,true)
  368.     local pos = alun_utils.string_to_vector(t.position)
  369.     local id_check
  370.     local story_check
  371. --  alun_utils.printf("test 0: "..tostring(sec))
  372.     local check = sor:get(sec)
  373. --  alun_utils.printf("test 1: "..tostring(sec).."|"..tostring(check))
  374.     if check and dynamic_story_id[sec] == nil then
  375.         dynamic_story_id[sec] = check
  376.         alun_utils.printf("axr_dynamic_spawn.object_checker: story object has been successfully repaired from corrupted load. id|section|section name: "..tostring(check).."|"..tostring(sec).."|"..tostring(t.section))
  377.         return
  378.    
  379.     elseif not check and dynamic_story_id[sec] == nil then
  380.         for i=1, 65535 do
  381.             id_check = alife():object(i)
  382.             story_check = sor:get_story_id(i)
  383.             for k,v in pairs(dynamic_story_id) do
  384.                 if id_check and string.find(id_check:section_name(), t.section) and sec ~= story_check then
  385.                     dynamic_story_id[sec] = i
  386.                     alun_utils.printf("axr_dynamic_spawn.object_checker: dynamic object has been successfully recovered from corrupted load. id|section name: "..tostring(i).."|"..tostring(id_check:section_name()))
  387.                     return
  388.                 end
  389.             end
  390.         end
  391.     end
  392. end
  393.  
  394. function parse_ltx(actor,sections,ltx_data)
  395.     local gvid,id
  396.     local sim = alife()
  397.     for sec in string.gmatch(ltx_data,"%[(.-)%]") do
  398.         gvid = alun_utils.read_from_ini(ini,sec,"game_vertex_id","float",nil)
  399.         if (gvid and is_on_the_same_level(actor,gvid)) then
  400.             if (ini:line_exist(sec,"on_info")) then
  401.                 if not (on_info_sections) then
  402.                     on_info_sections = {}
  403.                 end
  404.                 --alun_utils.printf("on_info sec = %s",sec)
  405.                 table.insert(on_info_sections,sec)
  406.             else
  407.                 --alun_utils.printf("sec = %s",sec)
  408.                 table.insert(sections,sec)
  409.             end
  410.         end
  411.     end
  412. end
  413.  
  414. function interpret_spawn_data(sections)
  415.     local sor = story_objects.get_story_objects_registry()
  416.     local sec,section,pos,lvid,gvid,lvl,se_obj
  417.     local data,t,enable,on_info
  418.     for i=1, #sections do
  419.         sec = sections[i]
  420.         --Yasti: Corruption Repair
  421.         if corrupt_detect == true then
  422.             dynamic_object_check(sec)
  423.         end
  424.  
  425.         if (dynamic_story_id[sec] == nil and secret_stashes[sec] == nil) then
  426.             t = alun_utils.collect_section(ini,sec,true)
  427.  
  428.             enable = alun_utils.read_from_ini(ini,sec,"enable","string","true")
  429.             enable = xr_logic.pick_section_from_condlist(db.actor,db.actor,xr_logic.parse_condlist(db.actor,"enable",sec,enable))
  430.  
  431.             on_info = alun_utils.read_from_ini(ini,sec,"on_info","string","true")
  432.             on_info = xr_logic.pick_section_from_condlist(db.actor,db.actor,xr_logic.parse_condlist(db.actor,"on_info",sec,on_info))
  433.  
  434.             if (enable == "true" and on_info == "true") then
  435.                 section = t.section
  436.                 pos = alun_utils.string_to_vector(t.position)
  437.  
  438.                 lvid = tonumber(t.level_vertex_id)
  439.                 gvid = tonumber(t.game_vertex_id)
  440.  
  441.                 if (section and pos and lvid and gvid) then
  442.                     se_obj = alife():create(section,pos,lvid,gvid)
  443.                    
  444.                     -- set dynamic name
  445.                     se_obj.dynamic_name = sec
  446.  
  447.                     -- dynamic section name as story_id
  448.                     dynamic_story_id[sec] = se_obj.id
  449.  
  450.                     -- Keep track of objects marked secret
  451.                     if (t.secret == "true" and secret_stashes[sec] ~= false) then
  452.                         secret_stashes[sec] = true
  453.                     end
  454.  
  455.                     -- Repack abstract properties
  456.                 --  se_obj.repack = {}
  457.                 --  se_obj.repack.direction = t.direction and alun_utils.string_to_vector(t.direction) or vector():set(0,0,0)
  458.  
  459.                     -- Alter packet properties
  460.                     local class = alun_utils.read_from_ini(nil,section,"class","string",nil)
  461.                     if (class and m_classes[class] and dynamic[m_classes[class]]) then
  462.                         dynamic[m_classes[class]](se_obj,t,sec)
  463.  
  464.                         local pid
  465.                         if (m_classes[class] == "cse_alife_inventory_box" or m_classes[class] == "cse_alife_stalker") then
  466.                             pid = se_obj.id
  467.                         end
  468.  
  469.                         -- Spawn supplemental items
  470.                         local i = 1
  471.                         local itm
  472.                         local sysini = system_ini()
  473.                         local sim = alife()
  474.                         while t["item"..i] do
  475.                             itm = alun_utils.str_explode(t["item"..i],",")
  476.                             if (itm[1] and sysini:section_exist(itm[1])) then
  477.                                 for n=1,itm[2] and tonumber(itm[2]) or 1 do
  478.                                     if (pid) then
  479.                                         sim:create(itm[1],se_obj.position,0,0,pid)
  480.                                     else
  481.                                         sim:create(itm[1],se_obj.position,se_obj.m_level_vertex_id,se_obj.m_game_vertex_id)
  482.                                     end
  483.                                 end
  484.                             end
  485.                             i = i + 1
  486.                         end
  487.                     end
  488.  
  489.                     -- Set Map Spot
  490.                     if (t.map_spot) then
  491.                         level.map_add_object_spot(se_obj.id,t.map_spot,t.hint)
  492.                     end
  493.                    
  494.                     if (t.angle) then
  495.                         se_obj.angle = alun_utils.string_to_vector(t.angle)
  496.                     end
  497.  
  498.                     alun_utils.printf("after create %s [%s]",se_obj:name(),sec)
  499.                 else
  500.                     alun_utils.printf("dynamic_spawn.ltx: ERROR improper values for section %s [ section=%s | pos=%s | lvid=%s | gvid=%s ]",sec,section,t.position,lvid,gvid)
  501.                 end
  502.             end
  503.         end
  504.     end
  505.     corrupt_detect = false
  506. end
  507.  
  508. last_secret = nil
  509. function random_secret()
  510.     local t = {}
  511.     for k,v in pairs(secret_stashes) do
  512.         if (v == true) then
  513.             table.insert(t,k)
  514.         end
  515.     end
  516.  
  517.     -- get random stash not marked, search for next stash not marked if not
  518.     local index = math.random(#t)
  519.     local id
  520.     for i=index,#t do
  521.         secret = t[i]
  522.         if (secret) then
  523.         --  id = story_objects.get_story_objects_registry():get(secret)
  524.             id = dynamic_story_id[secret]
  525.             if (id and level.map_has_object_spot(id,"treasure") == 0) then
  526.                 news_manager.send_treasure(0)
  527.                 level.map_add_object_spot_ser(id, "treasure", "")
  528.                 last_secret = secret
  529.                 return id
  530.             end
  531.         end
  532.     end
  533.  
  534.     for i=index,1 do
  535.         secret = t[i]
  536.         if (secret) then
  537.         --  id = story_objects.get_story_objects_registry():get(secret)
  538.             id = dynamic_story_id[secret]
  539.             if (id and level.map_has_object_spot(id,"treasure") == 0) then
  540.                 news_manager.send_treasure(0)
  541.                 level.map_add_object_spot_ser(id, "treasure", "")
  542.                 last_secret = secret
  543.                 return id
  544.             end
  545.         end
  546.     end
  547.  
  548.     last_secret = nil
  549. end
  550.  
  551. function is_on_the_same_level(actor,gvid)
  552.     return game_graph():vertex(actor.m_game_vertex_id):level_id() == game_graph():vertex(gvid):level_id()
  553. end
  554.  
  555. function get_object_flag_name(fl)
  556.     local flags = {
  557.         [1] = "UseSwitches",
  558.         [2] = "SwitchOnline",
  559.         [4] = "SwitchOfine",
  560.         [8] = "Interactive",
  561.         [16] = "VisibleForAI",
  562.         [32] = "UsefulForAI",
  563.         [64] = "OfflineNoMove",
  564.         [128] = "UsedAI_Locations",
  565.         [256] = "UseGroupBehaviour",
  566.         [512] = "CanSave",
  567.         [1024] = "VisibleForMap",
  568.         [2048] = "UseSmartTerrains",
  569.         [4096] = "CheckForSeparator",
  570.         [8192] = "CorpseRemoval"
  571.     }
  572.     return flags[fl]
  573. end
  574.  
  575. function get_object_flag(fl)
  576.     local flags = {
  577.         ["UseSwitches"]     = 1,
  578.         ["SwitchOnline"]    = 2,
  579.         ["SwitchOfine"]     = 4,
  580.         ["Interactive"]     = 8,
  581.         ["VisibleForAI"]    = 16,
  582.         ["UsefulForAI"]     = 32,
  583.         ["OfflineNoMove"]   = 64,
  584.         ["UsedAI_Locations"] = 128,
  585.         ["UseGroupBehaviour"] = 256,
  586.         ["CanSave"]         = 512,
  587.         ["VisibleForMap"]   = 1024,
  588.         ["UseSmartTerrains"] = 2048,
  589.         ["CheckForSeparator"] = 4096,
  590.         ["CorpseRemoval"]   = 8192
  591.     }
  592. end
  593. -------------------------------------------
  594. -- cse_alife_smart_cover
  595. -------------------------------------------
  596. function dynamic.cse_alife_smart_cover(se_obj,t,sec)
  597.     se_obj.last_description = t.last_description
  598.     se_obj.loopholes[t.description] = 1
  599.  
  600.     local data = stpk_utils.get_smart_cover_data(se_obj)
  601.  
  602.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  603.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  604.  
  605.     data.description = t.description
  606.     data.last_description = t.last_description or t.description
  607.     if not (data.loopholes) then
  608.         data.loopholes = {}
  609.     end
  610.  
  611.     if (t.loopholes) then
  612.         t.loopholes = alun_utils.str_explode(t.loopholes,",")
  613.         local size = #t.loopholes
  614.         for i=1,size,2 do
  615.             if (t.loopholes[i] and t.loopholes[i+1]) then
  616.                 data.loopholes[t.loopholes[i]] = tonumber(t.loopholes[i+1])
  617.                 --alun_utils.printf("data.loopholes[%s] = %s",t.loopholes[i],t.loopholes[i+1])
  618.             end
  619.         end
  620.     else
  621.         data.loopholes[t.description] = 1
  622.     end
  623.  
  624.     data.enter_min_enemy_distance = t.enter_min_enemy_distance and tonumber(t.enter_min_enemy_distance) or 0
  625.     data.exit_min_enemy_distance = t.exit_min_enemy_distance and tonumber(t.exit_min_enemy_distance) or 0
  626.     data.is_combat_cover = t.is_combat_cover and tonumber(t.is_combat_cover) or 0
  627.     data.can_fire = t.can_fire and tonumber(t.can_fire) or 0
  628.     data.unk2_f32 = t.unk2_f32 and tonumber(t.unk2_f32) or 0
  629.     stpk_utils.set_smart_cover_data(data,se_obj)
  630.  
  631.     se_obj.last_description = t.last_description
  632. --  se_obj.loopholes[t.description] = 1
  633.  
  634.     se_smart_cover.registered_smartcovers[se_obj:name()] = nil
  635.     se_smart_cover.registered_smartcovers[sec] = se_obj
  636. end
  637.  
  638. -------------------------------------------
  639. -- cse_alife_level_changer
  640. -------------------------------------------
  641. function dynamic.cse_alife_level_changer(se_obj,t)
  642.     local data = stpk_utils.get_level_changer_data(se_obj)
  643.  
  644.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  645.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  646.  
  647.     data.dest_game_vertex_id = tonumber(t.dest_game_vertex_id)
  648.     data.dest_level_vertex_id = tonumber(t.dest_level_vertex_id)
  649.     data.dest_position = alun_utils.string_to_vector(t.dest_position)
  650.     data.dest_direction = t.dest_direction and alun_utils.string_to_vector(t.dest_direction) or vector():set(0,0,0)
  651.     data.dest_level_name = t.dest_level_name or ""
  652.     data.dest_graph_point = t.dest_graph_point and t.dest_graph_point or ""
  653.     data.silent_mode = 1
  654.  
  655.     data.shape_count = t.shape_count and tonumber(t.shape_count) or 1
  656.  
  657.     t.shape_type = t.shape_type and alun_utils.str_explode(t.shape_type,",")
  658.     t.center = t.center and alun_utils.str_explode(t.center,",")
  659.     t.radius = t.radius and alun_utils.str_explode(t.radius,",")
  660.     t.v1 = t.v1 and alun_utils.str_explode(t.v1,":")
  661.     t.v2 = t.v2 and alun_utils.str_explode(t.v2,":")
  662.     t.v3 = t.v3 and alun_utils.str_explode(t.v3,":")
  663.     t.v4 = t.v4 and alun_utils.str_explode(t.v4,":")
  664.  
  665.     for i=1,data.shape_count do
  666.         data.shape_type[i] = t.shape_type and t.shape_type[i] and tonumber(t.shape_type) or 1
  667.         data.center[i] = t.center and t.center[i] and alun_utils.string_to_vector(t.center[i]) or vector():set(0,0,0)
  668.         data.radius[i] = t.radius and t.radius[i] and tonumber(t.radius[i]) or 10
  669.         data.v1[i] = t.v1 and t.v1[i] and alun_utils.string_to_vector(t.v1[i]) or vector():set(5,0,0)
  670.         data.v2[i] = t.v2 and t.v2[i] and alun_utils.string_to_vector(t.v2[i]) or vector():set(0,2,0)
  671.         data.v3[i] = t.v3 and t.v3[i] and alun_utils.string_to_vector(t.v3[i]) or vector():set(0,0,5)
  672.         data.v4[i] = t.v4 and t.v4[i] and alun_utils.string_to_vector(t.v4[i]) or vector():set(0,0,0)
  673.     end
  674.  
  675.     data.restrictor_type = t.restrictor_type and tonumber(t.restrictor_type) or 3
  676.  
  677.     data.hint = "level_changer_invitation"
  678.  
  679.     stpk_utils.set_level_changer_data(data,se_obj)
  680. end
  681.  
  682.  
  683. -------------------------------------------
  684. -- cse_alife_space_restrictor
  685. -------------------------------------------
  686. function dynamic.cse_alife_space_restrictor(se_obj,t,sec)
  687.     local data = stpk_utils.get_space_restrictor_data(se_obj)
  688.  
  689.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  690.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  691.  
  692.     data.shape_count = t.shape_count and tonumber(t.shape_count) or 1
  693.  
  694.     t.shape_type = t.shape_type and alun_utils.str_explode(t.shape_type,",")
  695.     t.center = t.center and alun_utils.str_explode(t.center,",")
  696.     t.radius = t.radius and alun_utils.str_explode(t.radius,",")
  697.     t.v1 = t.v1 and alun_utils.str_explode(t.v1,":")
  698.     t.v2 = t.v2 and alun_utils.str_explode(t.v2,":")
  699.     t.v3 = t.v3 and alun_utils.str_explode(t.v3,":")
  700.     t.v4 = t.v4 and alun_utils.str_explode(t.v4,":")
  701.  
  702.     for i=1,data.shape_count do
  703.         data.shape_type[i] = t.shape_type and t.shape_type[i] and tonumber(t.shape_type) or 1
  704.         data.center[i] = t.center and t.center[i] and alun_utils.string_to_vector(t.center[i]) or vector():set(0,0,0)
  705.         data.radius[i] = t.radius and t.radius[i] and tonumber(t.radius[i]) or 10
  706.         data.v1[i] = t.v1 and t.v1[i] and alun_utils.string_to_vector(t.v1[i]) or vector():set(5,0,0)
  707.         data.v2[i] = t.v2 and t.v2[i] and alun_utils.string_to_vector(t.v2[i]) or vector():set(0,2,0)
  708.         data.v3[i] = t.v3 and t.v3[i] and alun_utils.string_to_vector(t.v3[i]) or vector():set(0,0,5)
  709.         data.v4[i] = t.v4 and t.v4[i] and alun_utils.string_to_vector(t.v4[i]) or vector():set(0,0,0)
  710.     end
  711.  
  712.     stpk_utils.set_space_restrictor_data(data,se_obj)
  713. end
  714.  
  715. -------------------------------------------
  716. -- cse_alife_anomalous_zone
  717. -------------------------------------------
  718. function dynamic.cse_alife_anomalous_zone(se_obj,t,sec)
  719.     local data = stpk_utils.get_anom_zone_data(se_obj)
  720.  
  721.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  722.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  723.  
  724.     data.shape_count = t.shape_count and tonumber(t.shape_count) or 1
  725.  
  726.     t.shape_type = t.shape_type and alun_utils.str_explode(t.shape_type,",")
  727.     t.center = t.center and alun_utils.str_explode(t.center,",")
  728.     t.radius = t.radius and alun_utils.str_explode(t.radius,",")
  729.     t.v1 = t.v1 and alun_utils.str_explode(t.v1,":")
  730.     t.v2 = t.v2 and alun_utils.str_explode(t.v2,":")
  731.     t.v3 = t.v3 and alun_utils.str_explode(t.v3,":")
  732.     t.v4 = t.v4 and alun_utils.str_explode(t.v4,":")
  733.  
  734.     for i=1,data.shape_count do
  735.         data.shape_type[i] = t.shape_type and t.shape_type[i] and tonumber(t.shape_type) or 1
  736.         data.center[i] = t.center and t.center[i] and alun_utils.string_to_vector(t.center[i]) or vector():set(0,0,0)
  737.         data.radius[i] = t.radius and t.radius[i] and tonumber(t.radius[i]) or 10
  738.         data.v1[i] = t.v1 and t.v1[i] and alun_utils.string_to_vector(t.v1[i]) or vector():set(5,0,0)
  739.         data.v2[i] = t.v2 and t.v2[i] and alun_utils.string_to_vector(t.v2[i]) or vector():set(0,2,0)
  740.         data.v3[i] = t.v3 and t.v3[i] and alun_utils.string_to_vector(t.v3[i]) or vector():set(0,0,5)
  741.         data.v4[i] = t.v4 and t.v4[i] and alun_utils.string_to_vector(t.v4[i]) or vector():set(0,0,0)
  742.     end
  743.  
  744.     data.max_power = t.max_power and tonumber(t.maxpower) or 0
  745.     data.owner_id = t.owner_id and tonumber(t.owner_id) or data.owner_id
  746.     data.enabled_time = t.enabled_time and tonumber(t.enabled_time) or data.enabled_time
  747.     data.disabled_time = t.disabled_time and tonumber(t.disabled_time) or data.disabled_time
  748.     data.start_time_shift = t.start_time_shift and tonumber(t.start_time_shift) or data.start_time_shift
  749.  
  750.     data.offline_interactive_radius = 30
  751.     data.artefact_spawn_count = 32
  752.     data.artefact_position_offset = 0
  753.  
  754.     stpk_utils.set_anom_zone_data(data,se_obj)
  755. end
  756.  
  757. -------------------------------------------
  758. -- cse_alife_object_hanging_lamp_properties
  759. -------------------------------------------
  760. function dynamic.cse_alife_object_hanging_lamp_properties(se_obj,t)
  761.     local data = stpk_utils.get_lamp_data(se_obj)
  762.  
  763.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  764.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  765.  
  766.     data.main_color = t.main_color and tonumber(t.main_color) or data.main_color
  767.     data.main_brightness = t.main_brightness and tonumber(t.main_brightness) or data.main_brightness
  768.     data.main_color_animator = t.main_color_animator or data.main_color_animator
  769.     data.main_range = t.main_range and tonumber(t.main_range) or data.main_range
  770.     data.light_flags = t.light_flags and tonumber(t.light_flags) or data.light_flags
  771.     data.startup_animation = t.startup_animation or data.startup_animation
  772.     data.lamp_fixed_bones = t.lamp_fixed_bones or data.lamp_fixed_bones
  773.     data.health = t.health and tonumber(t.health) or data.health
  774.     data.main_virtual_size = t.main_virtual_size and tonumber(t.main_virtual_size) or data.main_virtual_size
  775.     data.ambient_radius = t.ambient_radius and tonumber(t.ambient_radius) or 5
  776.     data.ambient_power = t.ambient_power and tonumber(t.ambient_power) or 5
  777.     data.ambient_texture = t.ambient_texture or data.ambient_texture
  778.     data.main_texture = t.main_texture or data.main_texture
  779.     data.main_bone = t.main_bone or data.main_bone
  780.     data.main_cone_angle = t.main_cone_angle and tonumber(t.main_cone_angle) or data.main_cone_angle
  781.     data.glow_texture = t.glow_texture or data.glow_texture
  782.     data.glow_radius = t.glow_radius and tonumber(t.glow_radius) or data.glow_radius
  783.     data.ambient_bone = t.ambient_bone or data.ambient_bone
  784.  
  785.     stpk_utils.set_lamp_data(data,se_obj)
  786. end
  787.  
  788. -------------------------------------------
  789. -- cse_alife_item
  790. -------------------------------------------
  791. function dynamic.cse_alife_item(se_obj,t)
  792.     local data = stpk_utils.get_item_data(se_obj)
  793.  
  794.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  795.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  796.  
  797.     data.visual_name = t.visual_name or data.visual_name
  798.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  799.  
  800.     data.condition = t.condition and tonumber(t.condition) or data.condition
  801.     data.upgrades = t.upgrades or data.upgrades
  802.  
  803.     stpk_utils.set_item_data(data,se_obj)
  804. end
  805.  
  806. -------------------------------------------
  807. -- cse_alife_item_document
  808. -------------------------------------------
  809. function dynamic.cse_alife_item_document(se_obj,t)
  810.     local data = stpk_utils.get_item_data(se_obj)
  811.  
  812.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  813.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  814.  
  815.     data.visual_name = t.visual_name or data.visual_name
  816.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  817.  
  818.     data.condition = t.condition and tonumber(t.condition) or data.condition
  819.     data.upgrades = t.upgrades or data.upgrades
  820.  
  821.     data.info_portion = t.info_portion or data.info_portion
  822.  
  823.     stpk_utils.set_item_data(data,se_obj)
  824. end
  825.  
  826. -------------------------------------------
  827. -- cse_alife_item_pda
  828. -------------------------------------------
  829. function dynamic.cse_alife_item_pda(se_obj,t)
  830.     local data = stpk_utils.get_item_data(se_obj)
  831.  
  832.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  833.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  834.  
  835.     data.visual_name = t.visual_name or data.visual_name
  836.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  837.  
  838.     data.condition = t.condition and tonumber(t.condition) or data.condition
  839.     data.upgrades = t.upgrades or data.upgrades
  840.  
  841.     data.original_owner = t.original_owner and tonumber(t.original_owner) or data.original_owner
  842.     data.specific_character = t.specific_character or data.specific_character
  843.     data.info_portion = t.info_portion or data.info_portion
  844.  
  845.     stpk_utils.set_item_data(data,se_obj)
  846. end
  847.  
  848. -------------------------------------------
  849. -- cse_alife_item_weapon
  850. -------------------------------------------
  851. function dynamic.cse_alife_item_weapon(se_obj,t)
  852.     local data = stpk_utils.get_weapon_data(se_obj)
  853.  
  854.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  855.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  856.  
  857.     data.visual_name = t.visual_name or data.visual_name
  858.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  859.  
  860.     data.condition = t.condition and tonumber(t.condition) or data.condition
  861.     data.upgrades = t.upgrades or data.upgrades
  862.  
  863.     data.ammo_current = t.ammo_current and tonumber(t.ammo_current) or data.ammo_current
  864.     data.ammo_elapsed = t.ammo_elapsed and tonumber(t.ammo_elapsed) or data.ammo_elapsed
  865.     data.weapon_state = t.weapon_state and tonumber(t.weapon_state) or data.weapon_state
  866.     data.addon_flags = t.addon_flags and tonumber(t.addon_flags) or data.addon_flags
  867.     data.ammo_type = t.ammo_type and tonumber(t.ammo_type) or data.ammo_type
  868.  
  869.     stpk_utils.set_weapon_data(data,se_obj)
  870. end
  871.  
  872. -------------------------------------------
  873. -- cse_alife_helicopter
  874. -------------------------------------------
  875. function dynamic.cse_alife_helicopter(se_obj,t)
  876.     local data = stpk_utils.get_heli_data(se_obj)
  877.  
  878.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  879.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  880.  
  881.     data.visual_name = t.visual_name or data.visual_name
  882.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  883.  
  884.     data.motion_name = t.motion_name or [[helicopter\aaa.anm]]
  885.     data.startup_animation = t.startup_animation or "idle"
  886.     data.skeleton_name = t.startup_name or "idle"
  887.     data.engine_sound = t.engine_sound or [[vehicles\helicopter\helicopter]]
  888.  
  889.     stpk_utils.set_heli_data(data,se_obj)
  890. end
  891.  
  892. -------------------------------------------
  893. -- se_stalker
  894. -------------------------------------------
  895. function dynamic.cse_alife_stalker(se_obj,t)
  896.     local data = stpk_utils.get_stalker_data(se_obj)
  897.  
  898.     data.money = t.money and tonumber(t.money)
  899.     data.specific_character = t.specific_character or data.specific_character
  900.     data.trader_flags = t.trader_flags and tonumber(t.trader_flags) or data.trader_flags
  901.     data.character_profile = t.character_profile or data.character_profile
  902.     data.community_index = t.community_index and tonumber(t.community_index) or data.community_index
  903.     data.rank = t.rank and tonumber(t.rank) or data.rank
  904.     data.reputation = t.reputation and tonumber(t.reputation) or data.reputation
  905.     data.character_name = t.character_name or data.character_name
  906.  
  907.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  908.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  909.  
  910.     data.visual_name = t.visual_name or data.visual_name
  911.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  912.  
  913.     stpk_utils.set_stalker_data(data,se_obj)
  914. end
  915.  
  916. ---------------------------------------------
  917. -- cse_alife_inventory_box
  918. ---------------------------------------------
  919. function dynamic.cse_alife_inventory_box(se_obj,t)
  920.     local data = stpk_utils.get_inv_box_data(se_obj)
  921.  
  922.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  923.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  924.  
  925.     data.visual_name = t.visual_name or data.visual_name
  926.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  927.  
  928.     data.unk1_u8 = t.unk1_u8 and tonumber(t.unk1_u8) or data.unk1_u8
  929.     data.unk2_u8 = t.unk2_u8 and tonumber(t.unk2_u8) or data.unk2_u8
  930.     data.tip = t.secret == "true" and "Use Stash" or t.tip or data.tip
  931.  
  932.     stpk_utils.set_inv_box_data(data,se_obj)
  933. end
  934.  
  935. --------------------------------------------
  936. -- cse_alife_object_climable
  937. --------------------------------------------
  938. function dynamic.cse_alife_object_climable(se_obj,t)
  939.     local data = stpk_utils.get_climable_data(se_obj)
  940.  
  941.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  942.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  943.  
  944.     data.shape_count = t.shape_count and tonumber(t.shape_count) or 1
  945.  
  946.     t.shape_type = t.shape_type and alun_utils.str_explode(t.shape_type,",")
  947.     t.center = t.center and alun_utils.str_explode(t.center,",")
  948.     t.radius = t.radius and alun_utils.str_explode(t.radius,",")
  949.     t.v1 = t.v1 and alun_utils.str_explode(t.v1,":")
  950.     t.v2 = t.v2 and alun_utils.str_explode(t.v2,":")
  951.     t.v3 = t.v3 and alun_utils.str_explode(t.v3,":")
  952.     t.v4 = t.v4 and alun_utils.str_explode(t.v4,":")
  953.  
  954.     for i=1,data.shape_count do
  955.         data.shape_type[i] = t.shape_type and t.shape_type[i] and tonumber(t.shape_type) or 1
  956.         data.center[i] = t.center and t.center[i] and alun_utils.string_to_vector(t.center[i]) or vector():set(0,0,0)
  957.         data.radius[i] = t.radius and t.radius[i] and tonumber(t.radius[i]) or 10
  958.         data.v1[i] = t.v1 and t.v1[i] and alun_utils.string_to_vector(t.v1[i]) or vector():set(5,0,0)
  959.         data.v2[i] = t.v2 and t.v2[i] and alun_utils.string_to_vector(t.v2[i]) or vector():set(0,2,0)
  960.         data.v3[i] = t.v3 and t.v3[i] and alun_utils.string_to_vector(t.v3[i]) or vector():set(0,0,5)
  961.         data.v4[i] = t.v4 and t.v4[i] and alun_utils.string_to_vector(t.v4[i]) or vector():set(0,0,0)
  962.     end
  963.  
  964.     stpk_utils.set_climable_data(data,se_obj)
  965. end
  966.  
  967. --------------------------------------------
  968. -- cse_alife_object_physic
  969. --------------------------------------------
  970. function dynamic.cse_alife_object_physic(se_obj,t)
  971.     local data = stpk_utils.get_physic_data(se_obj)
  972.  
  973.     data.custom_data = t.custom_data and "[logic]\n cfg = " .. t.custom_data or data.custom_data
  974.     data.object_flags = t.object_flags and tonumber(t.object_flags) or data.object_flags
  975.  
  976.     data.visual_name = t.visual_name or data.visual_name
  977.     data.visual_flags = t.visual_flags and tonumber(t.visual_flags) or data.visual_flags
  978.  
  979.     data.physic_type = t.physic_type or "0x3"
  980.     data.mass = t.mass and tonumber(t.mass) or 10
  981.     data.fixed_bones = t.fixed_bones or data.fixed_bones
  982.  
  983.     data.skeleton_name = t.skeleton_name or data.skeleton_name
  984.     data.skeleton_flags = t.skeleton_flags and tonumber(t.skeleton_flags) or 1
  985.     data.source_id = t.source_id and tonumber(t.source_id) or data.source_id
  986.  
  987.     stpk_utils.set_physic_data(data,se_obj)
  988. end
  989.  
  990.  
  991. --------------------------------------------
  992. --Yasti: Save Corruption Functions
  993. --------------------------------------------
  994. function is_bad_str(str, check)
  995.     local allowed_codes_for_sid = {}
  996.     local codes_intervals = { {"a", "z"}, {"A", "Z"}, {"0", "9"}, {"_", "_"}, {"-", "-"} }
  997.  
  998.     for i = 1, #codes_intervals do
  999.         local code_start = codes_intervals[i][1]:byte()
  1000.         local code_end = codes_intervals[i][2]:byte()
  1001.        
  1002.         for j = code_start, code_end do
  1003.             allowed_codes_for_sid[j] = true
  1004.         end
  1005.     end        
  1006.  
  1007.     local flag = false
  1008.     --Yasti--
  1009.     if not str then
  1010.         alun_utils.printf("Warning! story_objects.is_bad_str: str = nil. You may be attempting to save too often.")
  1011.         flag = true
  1012.         return flag
  1013.     end
  1014. --  if check then
  1015. --      if string.find(str, "zat") or string.find(str, "jup") or string.find(str, "pri") or string.find(str, "disel") then
  1016. --          --alun_utils.printf("story_objects.is_bad_str: object string is correct: "..tostring(str))
  1017. --      else
  1018. --          flag = true
  1019. --          return flag
  1020. --      end
  1021. --  end
  1022.     --End Yasti--
  1023.     for i = 1, #str do
  1024.         if not allowed_codes_for_sid[str:sub(i, i):byte()] then
  1025.             flag = true
  1026.             break
  1027.         end
  1028.     end
  1029.  
  1030.     --get_console():execute(tostring(flag) )
  1031.     return flag
  1032. end
  1033.  
  1034. function give_quick_news(text)
  1035.    if db.actor~=nil then
  1036.       if text==true then
  1037.          news_manager.send_tip(db.actor,"true",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1038.       elseif text==false then
  1039.          news_manager.send_tip(db.actor,"false",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1040.       elseif text=="true" then
  1041.          news_manager.send_tip(db.actor,"true â êàâû÷êàõ",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1042.       elseif text=="false" then
  1043.          news_manager.send_tip(db.actor,"false â êàâû÷êàõ",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1044.       elseif text==nil then
  1045.          news_manager.send_tip(db.actor,"nil",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1046.       elseif text=="nil" then
  1047.          news_manager.send_tip(db.actor,"nil â êàâû÷êàõ",0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1048.       else
  1049.          news_manager.send_tip(db.actor,text,0,"diplomat",2000,nil,"Áûñòðîå ñîîáùåíèå:")
  1050.       end
  1051.    end
  1052. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement