Guest User

LTTZ / Arena Patch Merge xr_scripts.ltx

a guest
Apr 16th, 2021
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. blacklisted_maps = { -- List of maps to skip in scans
  3. -- North
  4. ["l13_generators"] = true,
  5. ["l12_stancia_2"] = true,
  6. ["l12_stancia"] = true,
  7. ["l11_pripyat"] = true,
  8. ["l10_radar"] = true,
  9. ["l11_hospital"] = true,
  10. -- Underground
  11. ["jupiter_underground"] = true,
  12. ["labx8"] = true,
  13. ["l03u_agr_underground"] = true,
  14. ["l04u_labx18"] = true,
  15. ["l08u_brainlab"] = true,
  16. ["l10u_bunker"] = true,
  17. ["l12u_control_monolith"] = true,
  18. ["l12u_sarcofag"] = true,
  19. ["l13u_warlab"] = true,
  20.  
  21. ["fake_start"] = true
  22. }
  23.  
  24.  
  25. --< Tronex >
  26. function unlock_note_mysteries_of_the_zone(actor,npc,p)
  27. SendScriptCallback("actor_on_interaction", "notes", nil, "mysteries_of_the_zone")
  28. end
  29. function unlock_note_living_legend(actor,npc,p)
  30. SendScriptCallback("actor_on_interaction", "notes", nil, "living_legend")
  31. end
  32. function unlock_note_mortal_sin(actor,npc,p)
  33. SendScriptCallback("actor_on_interaction", "notes", nil, "mortal_sin")
  34. end
  35.  
  36. function remove_quest_item(actor,npc,p)
  37. if (not p) or (p and #p == 0) then
  38. return
  39. end
  40.  
  41. local var = load_var(db.actor, p[1])
  42. if (not var) then
  43. return
  44. end
  45.  
  46. local t = {}
  47. if var.item_1_id then t[var.item_1_id] = var.item_1_sec end
  48. if var.item_2_id then t[var.item_2_id] = var.item_2_sec end
  49.  
  50. for k,v in pairs(t) do
  51. local obj = k and level.object_by_id(k)
  52. local se_obj = k and alife_object(k)
  53. if se_obj and obj and (obj:section() == v) then
  54. alife_release(se_obj)
  55. news_manager.relocate_item(db.actor,"out",v,1)
  56. end
  57. end
  58. end
  59.  
  60. function prepare_reward_money(actor,npc,p)
  61. -- Prepare money reward to give when actor complete the task
  62. -- p[1]: task id
  63. -- p[2]: amount of money
  64. -- p[3] (optional): maximum amount of money, if this field exists then a random amount of money between p[2] and p[2] will be chosen
  65.  
  66. local var = load_var(db.actor, p[1])
  67. if (not var) then return end
  68.  
  69. local multi = game_difficulties.get_eco_factor("rewards") or 1
  70.  
  71. local money = tonumber(p[2] or 500)
  72. if p[3] then
  73. money = math.random(money,tonumber(p[3]))
  74. end
  75. money = math.ceil(tonumber(money) * multi)
  76.  
  77. var.reward_money = money
  78. save_var(db.actor, p[1], var)
  79. end
  80.  
  81. function prepare_reward_item(actor,npc,p)
  82. -- p[1]: task id
  83. -- This function has 3 modes:
  84. -- Mode [1] - single item - pattern: (task_id:item) - effect: store item from p[2] - amount: 1
  85. -- Mode [2] - random single item - pattern: (task_id:item_1:item_2:item_3:item_4...) - effect: store an item from a random field (+p[2]) - amount: 1
  86. -- Mode [3] - multi items with defined amount - pattern: (task_id:item_1:amt_1:item_2:amt_2...) - effect: store items p[2],p[4],p[6]... with defined amounts p[3],p[5],p[7]...
  87.  
  88. local var = load_var(db.actor, p[1])
  89. if (not var) then return end
  90.  
  91. -- Set reward mode
  92. local mode = 1
  93. if (#p == 2) then mode = 1 -- give one item
  94. elseif (#p > 2) and (not tonumber(p[3])) then mode = 2 -- give a random item
  95. elseif (#p > 2) and tonumber(p[3]) then mode = 3 -- give a set of items with amount
  96. else return end
  97.  
  98. -- Validate sections
  99. local function check(sec)
  100. if (not ini_sys:section_exist(sec)) then
  101. abort("ERROR: Task: %s - Function: prepare_reward_item - Invalid item section found: %s",p[1],sec)
  102. end
  103. end
  104.  
  105. -- Fill reward table
  106. local t = {}
  107. if (mode == 1) then
  108. check(p[2])
  109. t[p[2]] = 1
  110. elseif (mode == 2) then
  111. local pick = p[math.random(2,#p)]
  112. check(pick)
  113. t[pick] = 1
  114. elseif (mode == 3) then
  115. for i=2,#p,2 do
  116. local p1 = p[i]
  117. local p2 = p[i+1]
  118. check(p1)
  119. t[p1] = t[p1] and (t[p1] + tonumber(p2)) or tonumber(p2)
  120. end
  121. end
  122.  
  123. -- stack the old reward table if it exists
  124. local t2 = var.reward_item or {}
  125. for k,v in pairs(t) do
  126. t2[k] = t2[k] and (t2[k] + v) or v
  127. end
  128.  
  129. var.reward_item = t2
  130. save_var(db.actor, p[1], var)
  131. end
  132.  
  133. function give_reward(actor,npc,p) -- Give stored rewards
  134. local var = load_var(db.actor, p[1])
  135. if (not var) then return end
  136.  
  137. -- money reward
  138. local money = var.reward_money
  139. if money then
  140. dialogs.relocate_money(db.actor,money,"in")
  141. end
  142.  
  143. -- item reward
  144. local items = var.reward_item
  145. if items then
  146. for k,v in pairs(items) do
  147. for i=1,v do
  148. local se_item = alife_create_item(k, db.actor)
  149. local cls = se_item:clsid()
  150. if IsWeapon(nil,cls) or IsOutfit(nil,cls) or IsHeadgear(nil,cls) then
  151. --se_item.condition = (math.random(70,90)/100)
  152. end
  153. end
  154. news_manager.relocate_item(db.actor,"in",k,v)
  155. end
  156. end
  157. end
  158.  
  159. function stalker_ceasefire()
  160. local blacklist = {
  161. ["bandit"] = true,
  162. ["monolith"] = true,
  163. ["zombied"] = true,
  164. ["army"] = true,
  165. }
  166.  
  167. local actor_comm = get_actor_true_community()
  168. if (not blacklist[actor_comm]) and game_relations.is_factions_enemies("stalker",actor_comm) then
  169. game_relations.save_relation ( "stalker" , actor_comm , 2000 )
  170. game_relations.save_relation ( "actor_stalker" , actor_comm , 2000 )
  171. game_relations.save_relation ( "stalker" , "actor_" .. actor_comm , 2000 )
  172. game_relations.send_news ("stalker" , actor_comm , "st_relations_cease_fire" , nil)
  173. end
  174. end
  175.  
  176. function reward_random_money_by_dist(actor,npc,p)
  177. local var = load_var(db.actor, p[1])
  178. local lvl_task = var and var.lvl_task or level.name()
  179. local lvl_target = var and var.lvl_target
  180. local n = lvl_task and lvl_target and txr_routes.get_shortest_path_num(lvl_task, lvl_target) or 1
  181.  
  182. local multi = game_difficulties.get_eco_factor("rewards") or 1
  183. local min_val = ( (tonumber(p[2]) or 500) * multi ) / 50
  184. local max_val = ( (tonumber(p[3]) or (min_val + 1000)) * multi ) / 50
  185. local money = math.random( math.ceil(min_val), math.ceil(max_val) ) * 50
  186. local sweets = math.ceil(n * money * tonumber(p[4] or 0.2))
  187.  
  188. dialogs.relocate_money( db.actor, (money + sweets), "in" )
  189. end
  190.  
  191. local pos_itms = {
  192. ["drx_x8_documents"] = {-101.9361038208, -31.361772537231, 90.615669250488, 636, 5090},
  193. ["drx_x16_documents"] = {-46.306594848633, 20.461000442505, 2.1229863166809, 2220, 3792},
  194. ["drx_x18_documents"] = {23.617618560791, -5.6467723846436, -18.183609008789, 6311, 3760},
  195. ["drx_x19_documents"] = {6.817852973938, -7.8305835723877, -15.558134078979, 7638, 3842},
  196. ["drx_agr_u_documents"] = {46.072761535645, 1.8872995376587, 75.970985412598, 3968, 3630},
  197. ["drx_jup_u_documents"] = {27.983295440674, 12.515381813049, -1.1357840299606, 39736, 4861},
  198.  
  199. ["lx8_history_documents"] = {-93.635635375977, -27.296674728394, 96.18310546875, 1318, 5079},
  200. ["lx8_history_2_documents"] = {-116.10192871094, -27.196212768555, 82.614562988281, 30, 5090},
  201. ["lx8_history_3_documents"] = {-43.184757232666, -19.527189254761, 67.334884643555, 6770, 5094},
  202.  
  203. ["wpn_gauss_quest"] = {-426.44213867188, 26.069364547729, -383.1135559082, 138111, 4140},
  204. }
  205. function spawn_item_at_pos(actor, npc, p)
  206. if not (p and p[1]) then return end
  207.  
  208. if (pos_itms[p[1]]) then
  209. local pos = vector():set( pos_itms[p[1]][1], pos_itms[p[1]][2], pos_itms[p[1]][3] )
  210. local se_obj = alife_create( p[1], pos, pos_itms[p[1]][4], pos_itms[p[1]][5] )
  211. if (not se_obj) then
  212. printe("!ERROR: spawn_item_at_pos | unable to spawn [%s]", p[1])
  213. end
  214. else
  215. printe("!ERROR: spawn_item_at_pos | no info found for item [%s]", p[1])
  216. end
  217. end
  218.  
  219. function give_letter(actor, npc, p)
  220. if not (p and ini_sys:section_exist(p[1])) then
  221. return
  222. end
  223.  
  224. if (not ui_pda_encyclopedia_tab.is_unlocked_note("encyclopedia__notes_" .. p[1])) then
  225. alife_create_item(p[1], db.actor)
  226. news_manager.relocate_item(db.actor, "in", p[1], 1)
  227. end
  228. end
  229.  
  230. function increase_rank(actor, npc, p)
  231. local value = p[1] and tonumber(p[1])
  232. if value then
  233. game_statistics.increment_rank(value)
  234. end
  235. end
  236.  
  237. function increase_rep(actor, npc, p)
  238. local value = p[1] and tonumber(p[1])
  239. if value then
  240. game_statistics.increment_reputation(value)
  241. end
  242. end
  243.  
  244. function decrease_rank(actor, npc, p)
  245. local value = p[1] and tonumber(p[1])
  246. if value then
  247. game_statistics.increment_rank(-value)
  248. end
  249. end
  250.  
  251. function decrease_rep(actor, npc, p)
  252. local value = p[1] and tonumber(p[1])
  253. if value then
  254. game_statistics.increment_reputation(-value)
  255. end
  256. end
  257.  
  258. function set_task_stage(actor, npc, p)
  259. local tm = task_manager.get_task_manager()
  260. local task_info = tm.task_info
  261. if p and p[1] and p[2] and tm.task_info[p[1]] and tonumber(p[2]) then
  262. -- printf('setting task %s stage to %s',p[1],p[2])
  263. task_info[p[1]].stage = tonumber(p[2])
  264. else
  265. if p then
  266. printf('set_task_stage: arguments incorrect: %s %s',p[1],p[2])
  267. else
  268. printf('set_task_stage: no arguments')
  269. end
  270. end
  271. end
  272.  
  273. function open_route(actor, npc, p)
  274. if p[1] and p[2] then
  275. txr_routes.open_route(p[1],p[2])
  276. end
  277. end
  278.  
  279. function snd_volume_off()
  280. _G.mus_vol = math.max(get_console_cmd(2,'snd_volume_music'),_G.mus_vol or 0)
  281. _G.amb_vol = math.max(get_console_cmd(2,'snd_volume_eff'),_G.amb_vol or 0)
  282. exec_console_cmd('snd_volume_music 0')
  283. exec_console_cmd('snd_volume_eff 0')
  284. end
  285.  
  286. function snd_volume_on()
  287. exec_console_cmd('snd_volume_music '..tostring(_G.mus_vol))
  288. exec_console_cmd('snd_volume_eff '..tostring(_G.amb_vol))
  289. end
  290.  
  291. function se_clear_var(actor, npc, p)
  292. -- mass clearing for variables that match specific value in server objects, useful for body release tagging
  293.  
  294. if not (p[1] and p[2]) then
  295. printe("!ERROR clear_se_var | missing vars: [%s] [%s]", p[1], p[2])
  296. return
  297. end
  298.  
  299. local m_data = alife_storage_manager.get_state()
  300. for id,v in pairs(m_data.se_object) do
  301. if (v[varname] == val) then
  302. printf("~se_clear_all_match_var | found match %s = %s in (%s)", varname, val, id)
  303. v[varname] = nil
  304. end
  305. end
  306. end
  307. --< Tronex >
  308.  
  309.  
  310. --< MLR >
  311. function disable_meet_nimble_info()
  312. db.actor:disable_info_portion("actor_meet_nimble_room")
  313. end
  314. -- Функции для управления мостом.
  315. function bridge_down()
  316. db.bridge_by_name["red_bridge"]:anim_forward()
  317. db.actor:give_info_portion("red_bridge_down_done_2")
  318. end
  319. function bridge_up()
  320. db.bridge_by_name["red_bridge"]:anim_backward()
  321. db.actor:disable_info_portion("red_bridge_down_done")
  322. db.actor:disable_info_portion("red_bridge_down_done_2")
  323. end
  324. function bridge_stop()
  325. db.bridge_by_name["red_bridge"]:anim_stop()
  326. end
  327.  
  328. function anim_obj_down(actor, npc, p)
  329. if p[1] ~= nil then
  330. db.anim_obj_by_name[p[1]]:anim_forward()
  331. end
  332. end
  333. function anim_obj_up(actor, npc, p)
  334. if p[1] ~= nil then
  335. db.anim_obj_by_name[p[1]]:anim_backward()
  336. end
  337. end
  338. function anim_obj_stop(actor, npc, p)
  339. if p[1] ~= nil then
  340. db.anim_obj_by_name[p[1]]:anim_stop()
  341. end
  342. end
  343.  
  344. function disable_begin_the_battle()
  345. db.actor:disable_info_portion("begin_the_battle")
  346. end
  347.  
  348. function teleport_for_totaliz_out(first_speaker, second_speaker)
  349. local box = get_story_object("bar_arena_inventory_box_2")
  350. if (box) then
  351. local function transfer_object_item(item)
  352. db.actor:transfer_item(item, box)
  353. end
  354. db.actor:inventory_for_each(transfer_object_item)
  355. end
  356.  
  357. xr_zones.purge_arena_items("bar_arena")
  358.  
  359. level.add_pp_effector ("fade_in.ppe", 200, false)
  360. db.actor:set_actor_position(vector():set(150.249435424805,0.429966986179352,72.1354370117188),40238,1684)
  361.  
  362. local box = get_story_object("bar_arena_inventory_box")
  363. if (box) then
  364. local function transfer_object_item(box,item)
  365. box:transfer_item(item, db.actor)
  366. end
  367. box:iterate_inventory_box(transfer_object_item,box)
  368. end
  369. end
  370.  
  371. function devushka_quest_one_reward(first_speaker, second_speaker)
  372. alife_create_item("nomad_outfit", db.actor)
  373. alife_create_item("wpn_knife3" , db.actor)
  374. alife_create_item("kit_hunt" , db.actor)
  375. news_manager.relocate_item(db.actor, "in", "nomad_outfit", 1)
  376. news_manager.relocate_item(db.actor, "in", "wpn_knife3" , 1)
  377. news_manager.relocate_item(db.actor, "in", "kit_hunt" , 1)
  378. end
  379. --< MLR >
  380.  
  381.  
  382. --< LTTZ >
  383. function spawn_strelok_notes()
  384. local pos = vector():set( 43.601459503174, 1.3544018268585, 75.227851867676 )
  385. local se_obj = alife_create( "strelok_notes", pos, 3762, 3630 )
  386. if ( not se_obj ) then
  387. printe("!ERROR: unable to spawn strelok_notes" )
  388. end
  389. end
  390.  
  391. function spawn_wpn_gauss_quest() -- not used
  392. -- Potential locations for quest item:
  393. local quest_item_locations_list = {
  394. {-421.80874633789, 23.745666503906, -328.25729370117, 145096, 4394}, -- location data for location 1
  395. {-411.07214355469, 32.196994781494, -334.24200439453, 161488, 4139}, -- location data for location 2
  396. {-424.48648071289, 24.198583602905, -381.48046875, 142021, 4140}, -- location data for location 3
  397. }
  398. -- Choose random location from the list:
  399. local i = math.random( #quest_item_locations_list )
  400. -- Set the position vector with the x, y, and z coordinates:
  401. local pos = vector():set( quest_item_locations_list[i][1], quest_item_locations_list[i][2], quest_item_locations_list[i][3] )
  402. -- Extract the level vertex id for the chosen location:
  403. local lvid = quest_item_locations_list[i][4]
  404. -- Extract the game vertex id:
  405. local gvid = quest_item_locations_list[i][5]
  406. -- Spawn the item at the chosen location:
  407. local se_obj = alife_create( "wpn_gauss_quest", pos, lvid, gvid )
  408. if ( not se_obj ) then
  409. printe("!ERROR: unable to spawn wpn_gauss_quest" )
  410. end
  411. end
  412.  
  413. function lttz_ll_take_wpn_gauss_quest(actor, npc)
  414. remove_item(actor, npc, {"wpn_gauss_quest"})
  415. end
  416.  
  417. function lttz_ll_take_strelok_notes(actor, npc)
  418. remove_item(actor, npc, {"strelok_notes"})
  419. dialogs.relocate_item_section(second_speaker, "af_glass_af_aam", "in",1)
  420. inc_faction_goodwill_to_actor(db.actor, nil, {"stalker", 50})
  421. end
  422.  
  423. function spawn_x8_documents()
  424. -- Potential locations for quest item:
  425. local quest_item_locations_list = {
  426. {-79.236862182617, -24.324705123901, 89.061508178711, 3417, 5077}, -- location data for location 1
  427. {-101.86143493652, -31.362953186035, 90.774269104004, 636, 5090}, -- location data for location 2
  428. {-79.810501098633, -15.038819313049, 114.17692565918, 3459, 5098}, -- location data for location 3
  429. }
  430. -- Choose random location from the list:
  431. local i = math.random( #quest_item_locations_list )
  432. -- Set the position vector with the x, y, and z coordinates:
  433. local pos = vector():set( quest_item_locations_list[i][1], quest_item_locations_list[i][2], quest_item_locations_list[i][3] )
  434. -- Extract the level vertex id for the chosen location:
  435. local lvid = quest_item_locations_list[i][4]
  436. -- Extract the game vertex id:
  437. local gvid = quest_item_locations_list[i][5]
  438. -- Spawn the item at the chosen location:
  439. local se_obj = alife_create( "x8_documents", pos, lvid, gvid )
  440. if ( not se_obj ) then
  441. printe("!ERROR: unable to spawn x8_documents" )
  442. end
  443. end
  444.  
  445. function eidolon_strelok_message()
  446. local msg = game.translate_string("st_lttz_eidolon_strelok_message")
  447. local name = game.translate_string("stalker_strelok_oa_name")
  448. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  449. local se = strformat("%s, %s",name,comm)
  450. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 20000)
  451. xr_sound.set_sound_play(AC_ID, "pda_task")
  452. end
  453.  
  454. function pri_eidolon_message()
  455. local msg = game.translate_string("st_lttz_pri_eidolon_message")
  456. local name = game.translate_string("monolith_eidolon_name")
  457. local comm = game.translate_string("st_dyn_news_comm_monolith_6")
  458. local se = strformat("%s, %s",name,comm)
  459. db.actor:give_game_news(se, msg, "ui_inGame2_monolit_1", 0, 20000)
  460. xr_sound.set_sound_play(AC_ID, "pda_task")
  461. end
  462.  
  463. function stancia_strelok_message()
  464. local msg = game.translate_string("st_lttz_stancia_strelok_message")
  465. local name = game.translate_string("stalker_strelok_oa_name")
  466. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  467. local se = strformat("%s, %s",name,comm)
  468. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 20000)
  469. xr_sound.set_sound_play(AC_ID, "pda_task")
  470. end
  471.  
  472. function mon_strelok_message()
  473. local msg = game.translate_string("st_lttz_mon_strelok_message")
  474. local name = game.translate_string("stalker_strelok_oa_name")
  475. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  476. local se = strformat("%s, %s",name,comm)
  477. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 20000)
  478. xr_sound.set_sound_play(AC_ID, "pda_task")
  479. end
  480. function spawn_monolith_shard()
  481. local pos = vector():set( 0.072339810431004, -34.356998443604, 17.800102233887 )
  482. local se_obj = alife_create( "monolith_shard", pos, 1849, 4055 )
  483. if ( not se_obj ) then
  484. printe("!ERROR: unable to spawn monolith_shard" )
  485. end
  486. end
  487.  
  488. function lttz_ll_take_x8_documents(actor, npc)
  489. remove_item(actor, npc, {"x8_documents"})
  490. end
  491.  
  492. function lttz_ll_give_wpn_gauss_quest(first_speaker, second_speaker)
  493. dialogs.relocate_item_section(second_speaker, "wpn_gauss_quest", "in",1)
  494. end
  495.  
  496. function lttz_ll_give_gauss_ammo(first_speaker, second_speaker)
  497. dialogs.relocate_item_section(second_speaker, "ammo_gauss", "in",2)
  498. end
  499.  
  500. function lttz_ll_take_monolith_shard(actor, npc)
  501. remove_item(actor, npc, {"monolith_shard"})
  502. end
  503.  
  504. function lttz_ll_give_strelok_pendrive(first_speaker, second_speaker)
  505. dialogs.relocate_item_section(second_speaker, "strelok_pendrive", "in",1)
  506. end
  507.  
  508. function lttz_ll_take_strelok_pendrive(actor, npc)
  509. remove_item(actor, npc, {"strelok_pendrive"})
  510. end
  511.  
  512. function lttz_ll_give_doctor_artefact(first_speaker, second_speaker)
  513. dialogs.relocate_item_section(second_speaker, "af_mincer_meat_af_aam", "in",1)
  514. inc_faction_goodwill_to_actor(db.actor, nil, {"stalker", 50})
  515. end
  516.  
  517. function spawn_stitch_decoder()
  518. -- Potential locations for quest item:
  519. local quest_item_locations_list = {
  520. {50.247924804688, 3.9755771160126, 156.77543640137, 509188, 5248}, -- location data for location 1
  521. {51.563461303711, 7.1993789672852, 224.42543029785, 514950, 5155}, -- location data for location 2
  522. {19.012723922729, 1.1766533851624, 112.65353393555, 472104, 5144}, -- location data for location 3
  523. }
  524. -- Choose random location from the list:
  525. local i = math.random( #quest_item_locations_list )
  526. -- Set the position vector with the x, y, and z coordinates:
  527. local pos = vector():set( quest_item_locations_list[i][1], quest_item_locations_list[i][2], quest_item_locations_list[i][3] )
  528. -- Extract the level vertex id for the chosen location:
  529. local lvid = quest_item_locations_list[i][4]
  530. -- Extract the game vertex id:
  531. local gvid = quest_item_locations_list[i][5]
  532. -- Spawn the item at the chosen location:
  533. local se_obj = alife_create( "stitch_decoder", pos, lvid, gvid )
  534. if se_obj then
  535. item_radio.add_target(se_obj.id, 171, 75)
  536. else
  537. printe("!ERROR: unable to spawn stitch_decoder" )
  538. end
  539. end
  540.  
  541. function lttz_ms_take_stitch_decoder(actor, npc)
  542. remove_item(actor, npc, {"stitch_decoder"})
  543. end
  544.  
  545. function lttz_ms_take_attackers_pda(actor, npc)
  546. remove_item(actor, npc, {"attackers_pda"})
  547. end
  548.  
  549. function limansk_rogue_message()
  550. local msg = game.translate_string("st_lttz_limansk_rogue_message")
  551. local name = game.translate_string("stalker_rogue_oa_name")
  552. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  553. local se = strformat("%s, %s",name,comm)
  554. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_merc", 0, 20000)
  555. xr_sound.set_sound_play(AC_ID, "pda_task")
  556. end
  557. function create_special_task_squad(actor,npc,p)
  558. level.add_pp_effector("black.ppe", 1500, false)
  559. create_squad(actor,npc,p)
  560. end
  561.  
  562. function spawn_contact_lost_pda()
  563. -- Potential locations for quest item:
  564. local quest_item_locations_list = {
  565. {-35.871238708496, -4.0057287216187, 139.02619934082, 8109, 2458}, -- location data for location 1
  566. {-18.989786148071, -3.9511435031891, 143.22698974609, 15620, 2477}, -- location data for location 2
  567. {-24.930610656738, -4.015763759613, 139.54330444336, 12734, 2458}, -- location data for location 3
  568. }
  569. -- Choose random location from the list:
  570. local i = math.random( #quest_item_locations_list )
  571. -- Set the position vector with the x, y, and z coordinates:
  572. local pos = vector():set( quest_item_locations_list[i][1], quest_item_locations_list[i][2], quest_item_locations_list[i][3] )
  573. -- Extract the level vertex id for the chosen location:
  574. local lvid = quest_item_locations_list[i][4]
  575. -- Extract the game vertex id:
  576. local gvid = quest_item_locations_list[i][5]
  577. -- Spawn the item at the chosen location:
  578. local se_obj = alife_create( "contact_lost_pda", pos, lvid, gvid )
  579. if ( not se_obj ) then
  580. printe("!ERROR: unable to spawn contact_lost_pda" )
  581. end
  582. end
  583.  
  584. function lttz_ms_take_contact_lost_pda(actor, npc)
  585. remove_item(actor, npc, {"contact_lost_pda"})
  586. end
  587.  
  588. function gen_stitch_message()
  589. local msg = game.translate_string("st_lttz_gen_stitch_message")
  590. local sender = game.translate_string("st_dyn_news_anonymous")
  591. db.actor:give_game_news(sender, msg, "ui_inGame2_Radiopomehi", 0, 20000)
  592. xr_sound.set_sound_play(AC_ID, "pda_task")
  593. end
  594.  
  595. function kat_rogue_message()
  596. local msg = game.translate_string("st_lttz_kat_rogue_message")
  597. local name = game.translate_string("stalker_rogue_oa_name")
  598. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  599. local se = strformat("%s, %s",name,comm)
  600. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_merc", 0, 20000)
  601. xr_sound.set_sound_play(AC_ID, "pda_task")
  602. end
  603.  
  604. function war_stitch_message()
  605. local msg = game.translate_string("st_lttz_war_stitch_message")
  606. local name = game.translate_string("stalker_stitch_oa_name")
  607. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  608. local se = strformat("%s, %s",name,comm)
  609. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_mask", 0, 20000)
  610. xr_sound.set_sound_play(AC_ID, "pda_task")
  611. end
  612. function premature_emission(actor, npc)
  613. level.set_weather_fx("fx_surge_day_3_stancia")
  614. xr_sound.set_sound_play(AC_ID, "blowout_hit_2")
  615. this.aes_earthshake(npc)
  616. end
  617.  
  618. function chernobog_vanish()
  619. xr_sound.set_sound_play(AC_ID, "chernobog_vanish")
  620. end
  621.  
  622. function chernobog_death_cry()
  623. xr_sound.set_sound_play(AC_ID, "chernobog_death_cry")
  624. end
  625.  
  626. function lttz_oa_give_decryption_radio(first_speaker, second_speaker)
  627. dialogs.relocate_item_section(second_speaker, "decryption_radio", "in",1)
  628. end
  629.  
  630. function lttz_ll_take_zat_b40_sarge_pda(actor, npc)
  631. remove_item(actor, npc, {"zat_b40_sarge_pda"})
  632. end
  633.  
  634. function lttz_oa_take_decryption_radio(actor, npc)
  635. remove_item(actor, npc, {"decryption_radio"})
  636. end
  637.  
  638. function decryption_noise()
  639. xr_sound.set_sound_play(AC_ID, "decryption_noise")
  640. end
  641.  
  642. function decoder_beep()
  643. xr_sound.set_sound_play(AC_ID, "decoder_beep")
  644. end
  645. function intercepted_transmission()
  646. local msg = game.translate_string("st_lttz_intercepted_transmission_message")
  647. local name = game.translate_string("st_dyn_news_unknown_contact")
  648. db.actor:give_game_news(name, msg, "ui_inGame2_Radiopomehi", 0, 12000)
  649. xr_sound.set_sound_play(AC_ID, "pda_task")
  650. end
  651.  
  652. function set_squad_enemy_lttz(actor, npc, p)
  653. local story_id = p[1]
  654. local squad = get_story_squad(story_id)
  655. if squad == nil then
  656. printf("There is no squad with id[%s]", tostring(story_id))
  657. return
  658. end
  659. squad:force_set_goodwill(-5000, actor)
  660. end
  661.  
  662. function yanov_invitation()
  663. local msg = game.translate_string("st_lttz_yanov_invitation_message")
  664. local name = game.translate_string("army_degtyarev_jup_name")
  665. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  666. local se = strformat("%s, %s",name,comm)
  667. db.actor:give_game_news(se, msg, "ui_inGame2_Hero", 0, 20000)
  668. xr_sound.set_sound_play(AC_ID, "pda_task")
  669. end
  670.  
  671. function yanov_invitation2()
  672. local msg = game.translate_string("st_lttz_yanov_invitation2_message")
  673. local name = game.translate_string("army_degtyarev_jup_name")
  674. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  675. local se = strformat("%s, %s",name,comm)
  676. db.actor:give_game_news(se, msg, "ui_inGame2_Hero", 0, 20000)
  677. xr_sound.set_sound_play(AC_ID, "pda_task")
  678. end
  679.  
  680. function lttz_oa_give_special_delivery_case(first_speaker, second_speaker)
  681. dialogs.relocate_item_section(second_speaker, "special_delivery_case", "in",1)
  682. end
  683.  
  684. function lttz_oa_take_special_delivery_case(actor, npc)
  685. remove_item(actor, npc, {"special_delivery_case"})
  686. end
  687.  
  688. function lttz_oa_give_army_isg_spy_pendrive(first_speaker, second_speaker)
  689. dialogs.relocate_item_section(second_speaker, "army_isg_spy_pendrive", "in",1)
  690. end
  691.  
  692. function lttz_oa_take_army_isg_spy_pendrive(actor, npc)
  693. remove_item(actor, npc, {"army_isg_spy_pendrive"})
  694. end
  695.  
  696. function spawn_jupiter_documents( )
  697. -- Potential locations for quest item:
  698. local quest_item_locations_list = {
  699. {304.7744140625, 28.783397674561, -299.32592773438, 1209997, 4517}, -- location data for location 1
  700. {324.68350219727, 31.384368896484, -305.80865478516, 1235548, 4517}, -- location data for location 2
  701. {351.95175170898, 27.543346405029, -343.99871826172, 1276714, 4516}, -- location data for location 3
  702. }
  703. -- Choose random location from the list:
  704. local i = math.random( #quest_item_locations_list )
  705. -- Set the position vector with the x, y, and z coordinates:
  706. local pos = vector( ):set( quest_item_locations_list[i][1], quest_item_locations_list[i][2], quest_item_locations_list[i][3] )
  707. -- Extract the level vertex id for the chosen location:
  708. local lvid = quest_item_locations_list[i][4]
  709. -- Extract the game vertex id:
  710. local gvid = quest_item_locations_list[i][5]
  711. -- Spawn the item at the chosen location:
  712. local se_obj = alife_create("jupiter_documents", pos, lvid, gvid )
  713. if ( not se_obj ) then
  714. printe("!ERROR: unable to spawn jupiter_documents" )
  715. end
  716. end
  717.  
  718. function lttz_oa_take_jupiter_documents(actor, npc)
  719. remove_item(actor, npc, {"jupiter_documents"})
  720. end
  721.  
  722. function pripyat_strelok_message()
  723. local msg = game.translate_string("st_lttz_pripyat_strelok_message")
  724. local name = game.translate_string("stalker_strelok_oa_name")
  725. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  726. local se = strformat("%s, %s",name,comm)
  727. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 20000)
  728. xr_sound.set_sound_play(AC_ID, "pda_task")
  729. end
  730.  
  731. function pripyat_rogue_message()
  732. local msg = game.translate_string("st_lttz_pripyat_rogue_message")
  733. local name = game.translate_string("stalker_rogue_oa_name")
  734. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  735. local se = strformat("%s, %s",name,comm)
  736. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_merc", 0, 20000)
  737. xr_sound.set_sound_play(AC_ID, "pda_task")
  738. end
  739.  
  740. function lttz_oa_take_drug_psy_blockade(actor, npc)
  741. remove_item(actor, npc, {"drug_psy_blockade"})
  742. end
  743.  
  744. function pripyat_stitch_message()
  745. local msg = game.translate_string("st_lttz_pripyat_stitch_message")
  746. local name = game.translate_string("stalker_stitch_oa_name")
  747. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  748. local se = strformat("%s, %s",name,comm)
  749. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_mask", 0, 20000)
  750. xr_sound.set_sound_play(AC_ID, "pda_task")
  751. end
  752.  
  753. function pripyat_degtyarev_message()
  754. local msg = game.translate_string("st_lttz_pripyat_degtyarev_message")
  755. local name = game.translate_string("army_degtyarev_name")
  756. local comm = game.translate_string("st_dyn_news_ssu")
  757. local se = strformat("%s, %s",name,comm)
  758. db.actor:give_game_news(se, msg, "ui_inGame2_Hero", 0, 30000)
  759. xr_sound.set_sound_play(AC_ID, "pda_task")
  760. end
  761.  
  762. function pripyat_strelok_message2()
  763. local msg = game.translate_string("st_lttz_pripyat_strelok_message2")
  764. local name = game.translate_string("stalker_strelok_oa_name")
  765. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  766. local se = strformat("%s, %s",name,comm)
  767. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 30000)
  768. xr_sound.set_sound_play(AC_ID, "pda_task")
  769. end
  770.  
  771. function pripyat_unisg_message()
  772. local msg = game.translate_string("st_lttz_pripyat_unisg_message")
  773. local name = game.translate_string("st_dyn_news_unknown_contact")
  774. db.actor:give_game_news(name, msg, "ui_inGame2_neutral_4", 0, 20000)
  775. xr_sound.set_sound_play(AC_ID, "pda_task")
  776. end
  777.  
  778. function mil_radogost_message()
  779. local msg = game.translate_string("st_lttz_mil_radogost_message")
  780. local name = game.translate_string("mil_greh_radogost_name")
  781. local comm = game.translate_string("st_dyn_news_comm_greh_6")
  782. local se = strformat("%s, %s",name,comm)
  783. db.actor:give_game_news(se, msg, "ui_inGame2_bandit_4", 0, 20000)
  784. xr_sound.set_sound_play(AC_ID, "pda_task")
  785. end
  786.  
  787. function dark_presence_invitation()
  788. xr_sound.set_sound_play(AC_ID, "chernobog_call")
  789. end
  790.  
  791. function dark_presence_whispers()
  792. xr_sound.set_sound_play(AC_ID, "dark_presence_whispers")
  793. end
  794.  
  795. function dark_presence_emission(actor, npc)
  796. if (level.get_time_hours() >= 5 and level.get_time_hours() <= 20) then
  797. level.set_weather_fx("fx_blowout_day")
  798. this.aes_earthshake(npc)
  799. xr_sound.set_sound_play(AC_ID, "dark_presence_rumble")
  800. else
  801. level.set_weather_fx("fx_blowout_night")
  802. this.aes_earthshake(npc)
  803. xr_sound.set_sound_play(AC_ID, "dark_presence_rumble")
  804. end
  805. end
  806.  
  807. function dark_presence_ambience()
  808. xr_sound.set_sound_play(AC_ID, "dark_presence_ambience")
  809. end
  810.  
  811. function x18_stitch_message()
  812. local msg = game.translate_string("st_lttz_x18_stitch_message")
  813. local name = game.translate_string("stalker_stitch_oa_name")
  814. local comm = game.translate_string("st_dyn_news_comm_zombied_6")
  815. local se = strformat("%s, %s",name,comm)
  816. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_mask", 0, 10000)
  817. end
  818.  
  819. function x18_rogue_message()
  820. local msg = game.translate_string("st_lttz_x18_rogue_message")
  821. local name = game.translate_string("stalker_rogue_oa_name")
  822. local comm = game.translate_string("st_dyn_news_comm_monolith_6")
  823. local se = strformat("%s, %s",name,comm)
  824. db.actor:give_game_news(se, msg, "ui_inGame2_neutral_2_merc", 0, 10000)
  825. end
  826.  
  827. function x18_degtyarev_message()
  828. local msg = game.translate_string("st_lttz_x18_degtyarev_message")
  829. local name = game.translate_string("army_degtyarev_name")
  830. local comm = game.translate_string("st_dyn_news_ssu")
  831. local se = strformat("%s, %s",name,comm)
  832. db.actor:give_game_news(se, msg, "ui_inGame2_Hero", 0, 10000)
  833. end
  834.  
  835. function x18_strelok_message()
  836. local msg = game.translate_string("st_lttz_x18_strelok_message")
  837. local name = game.translate_string("stalker_strelok_oa_name")
  838. local comm = game.translate_string("st_dyn_news_comm_stalker_6")
  839. local se = strformat("%s, %s",name,comm)
  840. db.actor:give_game_news(se, msg, "ui_inGame2_strelok_ico", 0, 10000)
  841. end
  842.  
  843. function x18_eidolon_message()
  844. local msg = game.translate_string("st_lttz_x18_eidolon_message")
  845. local name = game.translate_string("monolith_eidolon_name")
  846. local comm = game.translate_string("st_dyn_news_comm_monolith_6")
  847. local se = strformat("%s, %s",name,comm)
  848. db.actor:give_game_news(se, msg, "ui_inGame2_monolit_1", 0, 10000)
  849. end
  850.  
  851. function x18_chernobog_message()
  852. local msg = game.translate_string("st_lttz_x18_chernobog_message")
  853. local name = game.translate_string("kat_greh_sabaoth_name")
  854. local comm = game.translate_string("st_dyn_news_comm_greh_6")
  855. local se = strformat("%s, %s",name,comm)
  856. db.actor:give_game_news(se, msg, "ui_inGame2_monolit_4", 0, 10000)
  857. end
  858.  
  859. function x18_dark_presence_message()
  860. local msg = game.translate_string("st_lttz_x18_dark_presence_message")
  861. local name = game.translate_string("st_dyn_news_unknown_contact")
  862. db.actor:give_game_news(name, msg, "ui_inGame2_D_gonets_pravosudiya", 0, 10000)
  863. end
  864.  
  865. function dark_presence_final()
  866. xr_sound.set_sound_play(AC_ID, "dark_presence_rumble")
  867. end
  868.  
  869. function dark_presence_aftershock(actor,npc,p)
  870. level.add_pp_effector("psi.ppe", 5000, false)
  871. level.add_cam_effector("camera_effects\\fatigue.anm", 5000, false, "")
  872. end
  873. --< LTTZ >
  874.  
  875. --< DRX >
  876. function drx_sl_meet_random_honcho( actor, npc, p ) -- Give actor meet honcho task:
  877. -- Description: Finds a random friendly honcho and creates task to meet
  878. -- Usage: drx_sl_meet_random_honcho()
  879. -- Parameters: none
  880. -- Return value (type: none): none, creates task for player to meet next honcho
  881.  
  882. -- List of honchos and their surrounding factions:
  883. local drx_sl_honchos_table = axr_task_manager.drx_sl_honchos_table
  884.  
  885. -- Create list of valid honchos:
  886. local honcho_list = {}
  887. local size_t = 0
  888. -- Examine each honcho:
  889. for i = 1, #drx_sl_honchos_table do
  890.  
  891. -- Get the current honcho id:
  892. local honcho = drx_sl_honchos_table[i][1]
  893.  
  894. -- Check if honcho is alive and is not current task giver:
  895. if ( ((xr_conditions.is_alive( nil, nil, {honcho} )) or (honcho == "esc_m_trader")) and (honcho ~= load_var( db.actor, "drx_sl_current_honcho", "" )) ) then
  896.  
  897. -- Check if the honcho surrounding factions are not enemy of player:
  898. local is_enemy = false
  899. for j = 2, #drx_sl_honchos_table[i] do
  900. if ( relation_registry.community_relation( drx_sl_honchos_table[i][j], alife():actor():community() ) <= -1000 ) then
  901. is_enemy = true
  902. end
  903. end
  904.  
  905. -- Add the current honcho to the list of valid honchos:
  906. if ( is_enemy == false ) then
  907. size_t = size_t + 1
  908. honcho_list[size_t] = honcho
  909. end
  910.  
  911. end
  912.  
  913. end
  914.  
  915. -- Pick next honcho:
  916. local next_honcho = load_var( db.actor, "drx_sl_current_honcho", "" )
  917. if ( size_t > 0 ) then
  918. next_honcho = honcho_list[math.random( size_t )]
  919. end
  920. save_var( db.actor, "drx_sl_current_honcho", next_honcho )
  921.  
  922. -- Increment current task number:
  923. save_var( db.actor, "drx_sl_current_task_number", (load_var( db.actor, "drx_sl_current_task_number", 1 ) + 1) )
  924. printf( ("DRX SL task count: " .. load_var( db.actor, "drx_sl_current_task_number", 1 )) )
  925.  
  926. -- Build list of available meet current honcho tasks:
  927. task_ltx_file = task_manager.task_ini
  928. local honcho_task_list = {}
  929. size_t = 0
  930. local honcho_task_id = ""
  931. local i = 1
  932. while ( true ) do
  933. honcho_task_id = ("drx_sl_" .. next_honcho .. "_meet_task_" .. i)
  934. if ( task_ltx_file:section_exist( honcho_task_id ) ) then
  935. size_t = size_t + 1
  936. honcho_task_list[size_t] = honcho_task_id
  937. i = (i + 1)
  938. else
  939. break
  940. end
  941. end
  942.  
  943. -- Give player meet next honcho task:
  944. if ( size_t > 0 ) then
  945. honcho_task_id = honcho_task_list[math.random( size_t )]
  946. save_var( db.actor, "drx_sl_current_task", honcho_task_id )
  947. printf( ("DRX SL current storyline task: " .. honcho_task_id) )
  948. give_info( ("drx_sl_meet_honcho_" .. next_honcho) ) -- (\configs\gameplay\info_portions.xml)
  949. task_manager.get_task_manager():give_task( honcho_task_id )
  950. else
  951. printf( ("DRX SL no meet honcho tasks available for " .. next_honcho .. " !!") )
  952. return
  953. end
  954.  
  955. end
  956.  
  957. function drx_sl_change_factions( actor, npc, p ) -- Change actor faction:
  958. -- Description: Changes an actor to the specified faction
  959. -- Usage: drx_sl_change_factions( faction )
  960. -- Parameters:
  961. -- faction (type: string) Faction for the actor to join (stalker, dolg, freedom, csky, ecolog, killer, army, bandit, or monolith)
  962. -- Return value (type: none): none
  963.  
  964. if ( p and p[1] ~= nil and p[1] ~= ("actor_" .. character_community( db.actor )) ) then
  965.  
  966. -- Set actor faction:
  967. set_actor_true_community(p[1])
  968.  
  969. local communities = utils_obj.get_communities_list()
  970. -- for i, community in pairs( communities ) do
  971. -- relation_registry.set_community_goodwill( community, AC_ID, 0 )
  972. -- end
  973. printf( ("DRX SL: Actor faction changed to " .. p[1]) )
  974.  
  975. --[[ Set companion faction:
  976. for id, squad in pairs( axr_companions.companion_squads ) do
  977. if ( squad and squad.commander_id ) then
  978. for k in squad:squad_members() do
  979. local member = db.storage[k.id] and db.storage[k.id].object
  980. if ( member and member:alive() ) then
  981. member:set_character_community( p[1], 0, 0 )
  982. for i, community in pairs( communities ) do
  983. member:set_community_goodwill( community, 0 )
  984. end
  985. printf( ("DRX SL: Companion faction changed to " .. p[1]) )
  986. end
  987. end
  988. end
  989. end
  990. -]]
  991.  
  992. -- Send dynamic news alert:
  993. news_manager.send_tip( db.actor, (game.translate_string( "st_drx_questlines_joined" ) .. " " .. game.translate_string( p[1] ) .. " " .. game.translate_string( "st_drx_questlines_faction" )), nil, "completionist", nil, nil )
  994.  
  995. end
  996.  
  997. end
  998.  
  999. function drx_sl_setup_questlines( actor, npc, p )
  1000. local faction = p and p[1]
  1001. if (not faction) then
  1002. printe("! ERROR drx_sl_setup_questlines | no faction defined")
  1003. return
  1004. end
  1005.  
  1006. -- Determine total number of storyline tasks to complete for this game:
  1007. save_var( db.actor, "drx_sl_total_task_number", math.random( 8, 12 ) ) -- Set to range of total meet honcho tasks to complete to finish game
  1008. save_var( db.actor, "drx_sl_current_task_number", 1 )
  1009.  
  1010. -- Determine first honcho to start at:
  1011. local honcho_table = axr_task_manager.drx_sl_main_honcho_table
  1012. local start_game_honcho = honcho_table[faction] or ""
  1013. if (not honcho_table[faction]) then
  1014. printf( "DRX SL no available game start honchos !!" )
  1015. end
  1016.  
  1017. -- Build list of available start game versions for start game honcho:
  1018. honcho_start_ltx_file = task_manager.task_ini
  1019. local honcho_start_list = {}
  1020. local honcho_start_id = ""
  1021. local i = 1
  1022. while ( true ) do
  1023. honcho_start_id = ("drx_sl_" .. start_game_honcho .. "_start_game_" .. i)
  1024. if ( honcho_start_ltx_file:section_exist( honcho_start_id ) ) then
  1025. table.insert( honcho_start_list, honcho_start_id )
  1026. i = (i + 1)
  1027. else
  1028. break
  1029. end
  1030. end
  1031.  
  1032. -- Send actor to start game at current honcho:
  1033. if ( #honcho_start_list > 0 ) then
  1034. math.randomseed( device( ):time_global( ) )
  1035. honcho_start_id = honcho_start_list[math.random( #honcho_start_list )]
  1036. printf( ("DRX SL current storyline task: " .. honcho_start_id) )
  1037. save_var( db.actor, "drx_sl_start_task", honcho_start_id )
  1038. save_var( db.actor, "drx_sl_current_honcho", start_game_honcho )
  1039. give_info( ("drx_sl_start_game_" .. start_game_honcho) ) -- (\configs\gameplay\info_portions.xml)
  1040. --task_manager.get_task_manager( ):give_task( honcho_start_id )
  1041. printf( "DRX questlines are successfuly set for [%s] faction", faction )
  1042. else
  1043. printf( ("DRX SL no start game tasks available for " .. start_game_honcho .. " !!") )
  1044. end
  1045. end
  1046.  
  1047. function drx_sl_cancel_questlines( actor, npc, p ) -- Cancel all DRX questlines, and disabled info portion for them
  1048. save_var( db.actor, "drx_sl_start_task", nil )
  1049. save_var( db.actor, "drx_sl_current_honcho", nil )
  1050. save_var( db.actor, "drx_sl_current_task_number", nil )
  1051. save_var( db.actor, "drx_sl_current_task", nil )
  1052. save_var( db.actor, "drx_sl_total_task_number", nil )
  1053. save_var( db.actor, "drx_sl_current_task_number", nil )
  1054.  
  1055. local drx_sl_honchos_table = axr_task_manager.drx_sl_honchos_table
  1056. local task_cfg = axr_task_manager.CFG_CACHE
  1057. local tm = task_manager.get_task_manager()
  1058. local task_info = tm.task_info
  1059.  
  1060. -- Disable active info for DRX honcho
  1061. for i = 1, #drx_sl_honchos_table do
  1062. local honcho = drx_sl_honchos_table[i][1]
  1063.  
  1064. if has_alife_info("drx_sl_meet_honcho_" .. honcho) then
  1065. disable_info("drx_sl_meet_honcho_" .. honcho)
  1066. end
  1067. end
  1068.  
  1069. -- Cancel active DRX tasks
  1070. for task_id,tbl in pairs(task_info) do
  1071. if starts_with(task_id, "drx_sl_") then
  1072. tbl.forced_status = "fail"
  1073. tbl.cancelled_by_actor = true
  1074. end
  1075. end
  1076. end
  1077.  
  1078. function drx_sl_money_task_payment( actor, npc, p ) -- Take money task payment:
  1079. -- Description: Takes payment from actor for a money task
  1080. -- Usage: drx_sl_money_task_payment( task_id_var )
  1081. -- Parameters:
  1082. -- task_id_var (type: string) Var used for money task payment amount
  1083. -- Return value (type: none): none
  1084.  
  1085. if ( p and p[1] ~= nil ) then
  1086. local money = tonumber( load_var( db.actor, p[1], 0 ) )
  1087. db.actor:give_money( -(money) )
  1088. --game_stats.money_quest_update( -(money) )
  1089. news_manager.relocate_money( db.actor, "out", money )
  1090. end
  1091.  
  1092. end
  1093.  
  1094. function drx_sl_find_wish_granter( actor, npc, p ) -- Give actor find Wish Granter task:
  1095. -- Description: Gives task to find the Wish Granter
  1096. -- Usage: drx_sl_meet_random_honcho()
  1097. -- Parameters: none
  1098. -- Return value (type: none): none
  1099.  
  1100. local wish_granter_task = "drx_sl_find_wish_granter_task"
  1101. save_var( db.actor, "drx_sl_current_task", wish_granter_task )
  1102. printf( ("DRX SL current storyline task: " .. wish_granter_task) )
  1103. give_info( "drx_sl_on_find_wish_granter" ) -- (\configs\gameplay\info_portions.xml)
  1104. task_manager.get_task_manager():give_task( wish_granter_task )
  1105.  
  1106. end
  1107.  
  1108. function drx_sl_reward_random_rifle( actor, npc, p ) -- Give actor random rifle reward:
  1109. -- Description: Gives actor a random reward of a rifle within a specified value
  1110. -- Usage: drx_sl_reward_random_rifle( p[1]:p[2] )
  1111. -- Parameters:
  1112. -- p[1] (type: int) Minimum value of the reward
  1113. -- p[2] (type: int) Maximum value of the reward
  1114. -- Return value (type: none): none, allocates reward to actor
  1115.  
  1116. -- List of reward items:
  1117. local reward_items = {
  1118.  
  1119. -- --------------------------------------------
  1120. -- Tier 1 (1 - 99):
  1121.  
  1122. "wpn_bm16", -- [1] 200
  1123.  
  1124. -- --------------------------------------------
  1125. -- Tier 2 (100 - 999):
  1126.  
  1127. "wpn_toz34", -- [2] 1200
  1128.  
  1129. -- --------------------------------------------
  1130. -- Tier 3 (1000 - 1999):
  1131.  
  1132. "wpn_wincheaster1300", -- [3] 2400
  1133. "wpn_ak74u", -- [4] 3000
  1134. "wpn_mp5", -- [5] 3600
  1135. "wpn_ak74", -- [6] 4000
  1136.  
  1137. -- --------------------------------------------
  1138. -- Tier 4 (2000 - 2999):
  1139.  
  1140. "wpn_l85", -- [7] 5000
  1141. "wpn_spas12", -- [8] 5300
  1142. "wpn_abakan", -- [9] 6000
  1143. "wpn_lr300", -- [10] 6000
  1144.  
  1145. -- --------------------------------------------
  1146. -- Tier 5 (3000 - 3999):
  1147.  
  1148. "wpn_sig550", -- [11] 8000
  1149.  
  1150. -- --------------------------------------------
  1151. -- Tier 6 (4000 - 4999):
  1152.  
  1153. "wpn_protecta", -- [12] 9000
  1154. "wpn_val", -- [13] 9000
  1155.  
  1156. -- --------------------------------------------
  1157. -- Tier 7 (5000 - 5999):
  1158.  
  1159. "wpn_g36", -- [14] 10000
  1160. "wpn_groza", -- [15] 10000
  1161.  
  1162. -- --------------------------------------------
  1163. -- Tier 8 (6000 - 6999):
  1164.  
  1165. "wpn_vintorez", -- [16] 12000
  1166.  
  1167. -- --------------------------------------------
  1168. -- Tier 9 (7000 - 7999):
  1169.  
  1170. "wpn_fn2000", -- [17] 14000
  1171. "wpn_svd", -- [18] 16000
  1172.  
  1173. -- --------------------------------------------
  1174. -- Tier 10 (8000 - 8999):
  1175.  
  1176. "wpn_svu", -- [19] 17000
  1177.  
  1178. -- --------------------------------------------
  1179. -- Tier 11 (9000 - 9999):
  1180.  
  1181. "wpn_pkm", -- [20] 20000
  1182. "wpn_rg-6", -- [21] 20000
  1183.  
  1184. -- --------------------------------------------
  1185. -- Tier 12 (10000+):
  1186.  
  1187. "wpn_rpg7" -- [22] 26000
  1188.  
  1189. }
  1190.  
  1191. local reward_tbl = { -- Tiers
  1192. [100] = 2,
  1193. [1000] = 3,
  1194. [2000] = 7,
  1195. [3000] = 11,
  1196. [4000] = 12,
  1197. [5000] = 14,
  1198. [6000] = 16,
  1199. [7000] = 17,
  1200. [8000] = 19,
  1201. [9000] = 20,
  1202. [10000] = 22,
  1203. }
  1204.  
  1205. -- Find tier bottom for minimum reward:
  1206. local min_reward_value = tonumber( p[1] )
  1207. local min_reward_no = 1
  1208.  
  1209. local functor = function(t,a,b) return a < b end
  1210. for val,no in spairs(reward_tbl,functor) do
  1211. if min_reward_value >= val then
  1212. min_reward_no = no
  1213. end
  1214. end
  1215.  
  1216.  
  1217. -- Find tier top for maximum reward:
  1218. local max_reward_value = tonumber( p[2] )
  1219. local max_reward_no = 22
  1220.  
  1221. local functor2 = function(t,a,b) return a > b end
  1222. for val,no in spairs(reward_tbl,functor2) do
  1223. if ( max_reward_value < val ) then
  1224. max_reward_no = no - 1
  1225. end
  1226. end
  1227.  
  1228.  
  1229. -- Give actor rifle reward:
  1230. dialogs.relocate_item_section( db.actor, reward_items[math.random( min_reward_no, max_reward_no )], "in" )
  1231.  
  1232. end
  1233.  
  1234. function drx_sl_reward_random_artefact( actor, npc, p ) -- Give actor random artefact reward:
  1235. -- Description: Gives actor a random reward of an artefact within a specified value
  1236. -- Usage: drx_sl_reward_random_artefact( p[1]:p[2] )
  1237. -- Parameters:
  1238. -- p[1] (type: int) Minimum value of the reward
  1239. -- p[2] (type: int) Maximum value of the reward
  1240. -- Return value (type: none): none, allocates reward to actor
  1241.  
  1242. -- List of reward items:
  1243. local reward_items = {
  1244. -- Tier 1
  1245. "af_itcher",
  1246. "af_blood",
  1247. "af_electra_sparkler",
  1248. "af_cristall_flower",
  1249. "af_medusa",
  1250. "af_night_star",
  1251. "af_dummy_glassbeads",
  1252. "af_dummy_battery",
  1253. "af_soul",
  1254.  
  1255. -- Tier 2
  1256. "af_pin",
  1257. "af_mincer_meat",
  1258. "af_sponge",
  1259. "af_lobster_eyes",
  1260. "af_vyvert",
  1261. "af_cristall",
  1262. "af_bracelet",
  1263. "af_ring",
  1264. "af_electra_moonlight",
  1265. "af_empty",
  1266. "af_gravi",
  1267. "af_eye",
  1268. "af_dummy_dummy",
  1269. "af_fuzz_kolobok",
  1270.  
  1271. -- Tier 3
  1272. "af_fireball",
  1273. "af_baloon",
  1274. "af_electra_flash",
  1275. "af_black_spray",
  1276. "af_full_empty",
  1277. "af_gold_fish",
  1278. "af_fire",
  1279. "af_ice",
  1280. "af_glass",
  1281. }
  1282.  
  1283. local reward_tbl = { -- Money <-> Artefact index
  1284. [4000] = 5,
  1285. [5000] = 9,
  1286. [6000] = 14,
  1287. [7000] = 15,
  1288. [9000] = 19,
  1289. [10000] = 20,
  1290. [15000] = 23,
  1291. [20000] = 27,
  1292. [25000] = 32,
  1293. }
  1294.  
  1295. -- Find tier bottom for minimum reward:
  1296. local min_reward_value = tonumber( p[1] )
  1297. local min_reward_no = 1
  1298.  
  1299. local functor = function(t,a,b) return a < b end
  1300. for val,no in spairs(reward_tbl,functor) do
  1301. if min_reward_value >= val then
  1302. min_reward_no = no
  1303. end
  1304. end
  1305.  
  1306. -- Find tier top for maximum reward:
  1307. local max_reward_value = tonumber( p[2] )
  1308. local max_reward_no = 24
  1309.  
  1310. local functor2 = function(t,a,b) return a > b end
  1311. for val,no in spairs(reward_tbl,functor2) do
  1312. if ( max_reward_value < val ) then
  1313. max_reward_no = no - 1
  1314. end
  1315. end
  1316.  
  1317. -- Give actor artefact reward:
  1318. dialogs.relocate_item_section( db.actor, reward_items[math.random( min_reward_no, max_reward_no )], "in" )
  1319.  
  1320. end
  1321.  
  1322. function drx_sl_reset_stored_task( actor, npc, p ) -- Reset stored task for current NPC:
  1323. --
  1324. -- drx_sl_reset_stored_task function
  1325. -- Description: Removes a stored NPC task
  1326. -- Usage: drx_sl_reset_stored_task( [p1] )
  1327. -- Parameters:
  1328. -- p[1] (type: string)
  1329. -- - Task ID of finished task given by the task giver to unregister
  1330. -- Return value (type: none): none
  1331.  
  1332. -- Get task giver id:
  1333. if ( (#p < 1) or (not p[1]) ) then
  1334. return
  1335. end
  1336. local tm = task_manager.get_task_manager()
  1337. local task_info = tm.task_info
  1338. local giver_id = task_info[p[1]].task_giver_id
  1339.  
  1340. -- Reset stored task:
  1341. if ( giver_id ) then
  1342. save_var( db.actor, ("drx_sl_npc_stored_task_" .. giver_id), nil )
  1343. end
  1344.  
  1345. end
  1346.  
  1347. function drx_sl_unregister_task_giver( actor, npc, p ) -- Unregister current task giver:
  1348. -- Description: Unregisters a task giver as current
  1349. -- Usage: drx_sl_unregister_task_giver( [p1] )
  1350. -- Parameters:
  1351. -- p[1] (type: string)
  1352. -- - Task ID given by the task giver to unregister
  1353. -- Return value (type: none): none
  1354.  
  1355. -- Validate input parameters:
  1356. if ( (#p < 1) or (not p[1]) ) then
  1357. return
  1358. end
  1359.  
  1360. printf( ("DRX SL task ended: " .. p[1]) )
  1361.  
  1362. -- Get task giver id:
  1363. local tm = task_manager.get_task_manager()
  1364. local task_info = tm.task_info
  1365. local giver_id = task_info[p[1]].task_giver_id
  1366.  
  1367. -- Unregister task giver:
  1368. if ( giver_id and not string.find( "meet_task", p[1] ) ) then
  1369. local giver_task_count = (load_var( db.actor, ("drx_sl_task_giver_" .. giver_id), 0 ) - 1)
  1370. if ( giver_task_count < 0 ) then
  1371. giver_task_count = 0
  1372. end
  1373. save_var( db.actor, ("drx_sl_task_giver_" .. giver_id), giver_task_count )
  1374. printf( ("DRX SL: drx_sl_task_giver_" .. giver_id .. " unregistered (" .. giver_task_count .. " outstanding)") )
  1375. end
  1376.  
  1377. end
  1378.  
  1379. function drx_sl_unregister_hostage_giver( actor, npc, p ) -- Unregister current hostage task giver:
  1380. -- Description: Unregisters a hostage task giver as current
  1381. -- Usage: drx_sl_unregister_hostage_giver( [p1] )
  1382. -- Parameters:
  1383. -- p[1] (type: string) Task ID given by the task giver to unregister
  1384. -- Return value (type: none): none
  1385.  
  1386. -- Validate input parameters:
  1387. if ( (#p < 1) or (not p[1]) ) then
  1388. return
  1389. end
  1390.  
  1391. -- Get task giver id:
  1392. local tm = task_manager.get_task_manager()
  1393. local task_info = tm.task_info
  1394. local giver_id = task_info[p[1]].task_giver_id
  1395.  
  1396. -- Unregister task giver:
  1397. if ( giver_id ) then
  1398. save_var( db.actor, ("drx_sl_hostage_giver_" .. giver_id), false )
  1399. printf( ("DRX SL: drx_sl_hostage_giver_" .. giver_id .. " unregistered") )
  1400. end
  1401.  
  1402. end
  1403.  
  1404. function drx_sl_decrease_sl_tasks_count( actor, npc, p ) -- Decrease number of completed storyline tasks:
  1405. -- Description: Decreases the number of completed storyline tasks
  1406. -- Usage: drx_sl_decrease_sl_tasks_count()
  1407. -- Parameters: none
  1408. -- Return value (type: none): none
  1409.  
  1410. -- Get the current task count:
  1411. local task_count = load_var( db.actor, "drx_sl_current_task_number", 1 )
  1412.  
  1413. -- Decrement the current task count:
  1414. task_count = (task_count - 1)
  1415. if ( task_count < 1 ) then
  1416. task_count = 1
  1417. end
  1418.  
  1419. -- Save the current task count:
  1420. save_var( db.actor, "drx_sl_current_task_number", task_count )
  1421. printf( "DRX SL: player failed last storyline task, decrementing drx_sl_current_task_number" )
  1422. printf( ("DRX SL task count: " .. task_count) )
  1423.  
  1424. end
  1425. --< DRX >
  1426.  
  1427.  
  1428. -- ----------------------------------------------------------------------------------------------------
  1429. -- Общие функции
  1430. -- ----------------------------------------------------------------------------------------------------
  1431. -- TODO: Remove all unused COP story functions
  1432.  
  1433. local DIALOG_LAST_ID = nil
  1434. ---------------------------------------------------------------------------------------------------------------
  1435. function inc_task_stage(actor,npc,p)
  1436. local tsk = p[1] and task_manager.get_task_manager().task_info[p[1]]
  1437. if (tsk and tsk.stage) then
  1438. --printf("inc_task_stage=%s stage=%s",p[1],tsk.stage)
  1439. tsk.stage = tsk.stage + 1
  1440. end
  1441. end
  1442.  
  1443. function dec_task_stage(actor,npc,p)
  1444. local tsk = p[1] and task_manager.get_task_manager().task_info[p[1]]
  1445. if (tsk and tsk.stage) then
  1446. tsk.stage = tsk.stage - 1
  1447. end
  1448. end
  1449.  
  1450. function set_smart_faction(actor,npc,p)
  1451. local smart = p and p[1] and SIMBOARD.smarts_by_names[p[1]]
  1452. if not (smart) then
  1453. return false
  1454. end
  1455. smart.faction = p[2]
  1456. end
  1457.  
  1458. function fail_task_dec_goodwill(actor,npc,p)
  1459. local multi = game_difficulties.get_eco_factor("goodwill") or 1
  1460. local amt = tonumber(p[1])*multi or 50
  1461. for i=2,#p do
  1462. inc_faction_goodwill_to_actor(db.actor, nil, {p[i], -(amt), true})
  1463. end
  1464. end
  1465.  
  1466. -- Goodwill
  1467. function complete_task_inc_goodwill(actor,npc,p)
  1468. -- param1 - amount of goodwill to increase
  1469. -- param2+ - community
  1470. local multi = game_difficulties.get_eco_factor("goodwill") or 1
  1471. local amt = tonumber(p[1])*multi or 50
  1472. for i=2,#p do
  1473. inc_faction_goodwill_to_actor(db.actor, nil, {p[i], amt, true})
  1474. end
  1475. end
  1476.  
  1477. function inc_goodwill_by_tasker_comm(actor,npc,p)
  1478. -- param1 - task_id
  1479. -- param2 - amount of goodwill to increase
  1480.  
  1481. if not (p and p[1] and p[2]) then
  1482. return
  1483. end
  1484.  
  1485. local var = load_var(db.actor, p[1])
  1486. local comm = var and var.task_giver_comm
  1487. if (not comm) and db.actor:is_talking() then
  1488. local speaker = mob_trade.GetTalkingNpc()
  1489. comm = character_community(speaker)
  1490. end
  1491. if (not comm) then
  1492. printe("! ERROR %s | no community could be gathered")
  1493. return
  1494. end
  1495.  
  1496. comm = (comm == "trader") and "stalker" or comm
  1497. local multi = game_difficulties.get_eco_factor("goodwill") or 1
  1498. local amt = tonumber(p[2])*multi or 50
  1499. inc_faction_goodwill_to_actor(db.actor, nil, {comm, amt, true})
  1500. end
  1501.  
  1502. function inc_goodwill_by_tasker_id(actor,npc,p)
  1503. -- param1 - task_id
  1504. -- param2 - amount of goodwill to increase
  1505. if not (p and p[1] and p[2]) then
  1506. return
  1507. end
  1508.  
  1509. local tm = task_manager.get_task_manager()
  1510. local task_info = tm.task_info
  1511. local giver_id = task_info[p[1]].task_giver_id
  1512. local npc = giver_id and db.storage[giver_id] and db.storage[giver_id].object
  1513.  
  1514. if npc then
  1515. local comm = character_community(npc)
  1516. comm = (comm == "trader") and "stalker" or comm
  1517. local multi = game_difficulties.get_eco_factor("goodwill") or 1
  1518. local amt = tonumber(p[2])*multi or 50
  1519. inc_faction_goodwill_to_actor(db.actor, nil, {comm, amt, true})
  1520. end
  1521. end
  1522.  
  1523. function dec_goodwill_by_tasker_id(actor,npc,p)
  1524. -- param1 - task_id
  1525. -- param2 - amount of goodwill to increase
  1526. if not (p and p[1] and p[2]) then
  1527. return
  1528. end
  1529.  
  1530. local tm = task_manager.get_task_manager()
  1531. local task_info = tm.task_info
  1532. local giver_id = task_info[p[1]].task_giver_id
  1533. local npc = giver_id and db.storage[giver_id] and db.storage[giver_id].object
  1534.  
  1535. if npc then
  1536. local comm = character_community(npc)
  1537. comm = (comm == "trader") and "stalker" or comm
  1538. local multi = game_difficulties.get_eco_factor("goodwill") or 1
  1539. local amt = tonumber(p[2])*multi or 50
  1540. inc_faction_goodwill_to_actor(db.actor, nil, {comm, -(amt), true})
  1541. end
  1542. end
  1543.  
  1544. function reward_money(actor,npc,p)
  1545. local multi = game_difficulties.get_eco_factor("rewards") or 1
  1546. dialogs.relocate_money(db.actor,tonumber(p[1] or 500)*multi,"in")
  1547. end
  1548.  
  1549. function reward_stash(actor,npc,p)
  1550. if (p and p[1] ~= "true") or ((math.random(1,100)/100) <= 0.5) then
  1551. local bonus
  1552.  
  1553. if ((math.random(1,100)/100) <= 0.5) then
  1554. local stash_bonus = treasure_manager.stash_bonus
  1555. if stash_bonus and (#stash_bonus > 0) then
  1556. bonus = {stash_bonus[math.random(#stash_bonus)]}
  1557. end
  1558. end
  1559.  
  1560. --[[
  1561. if ((math.random(1,100)/100) <= 0.1) then
  1562. local t = {"itm_basickit","itm_advancedkit","itm_expertkit","itm_drugkit","itm_ammokit"}
  1563. bonus = {t[math.random(#t)]}
  1564. end
  1565. --]]
  1566. treasure_manager.create_random_stash(nil,nil,bonus, true)
  1567. end
  1568. end
  1569.  
  1570. function reward_item_cost_mult_and_remove(actor,npc,p)
  1571. local sec = load_var(db.actor,p[1])
  1572. if not (sec) then
  1573. return
  1574. end
  1575. local item = db.actor:object(sec)
  1576. if not (item) then
  1577. return
  1578. end
  1579.  
  1580. local cond = 1
  1581. if (item:condition()) then
  1582. cond = item:condition()
  1583. end
  1584. local multi = game_difficulties.get_eco_factor("rewards") or 1 -->>
  1585. dialogs.relocate_money(db.actor, math.floor((tonumber(p[2]) or 1)*item:cost()*cond*cond*cond*multi) ,"in")
  1586. remove_item(actor, npc, {sec,p[3]})
  1587. end
  1588.  
  1589. function reward_item(actor,npc,p)
  1590. if p and p[1] then
  1591. local section_d = p[1]
  1592.  
  1593. -- See if it's specific uses
  1594. local section, uses = utils_item.get_defined_uses(section_d)
  1595. if (section ~= "" and ini_sys:section_exist(section)) then
  1596.  
  1597. local se_item = alife_create_item(section, db.actor)
  1598. if se_item then
  1599. local cls = se_item:clsid()
  1600. if (IsWeapon(nil,cls) and cls ~= clsid.wpn_knife_s) then
  1601. se_item.condition = (math.random(70,90)/100)
  1602. news_manager.relocate_item(db.actor,"in",section,1)
  1603. elseif (IsItem("multiuse",section)) then
  1604. if (not uses) then
  1605. local max_uses = ini_sys:r_float_ex(section,"max_uses") or 1
  1606. uses = math.random(1,max_uses)
  1607. end
  1608. alife_process_item(section, se_item.id, {uses = uses})
  1609. news_manager.relocate_item(db.actor,"in",section,uses)
  1610. else
  1611. news_manager.relocate_item(db.actor,"in",section,1)
  1612. end
  1613. end
  1614. else
  1615. printe("!ERROR reward_item | section [%s] doesn't exist", section)
  1616. end
  1617. end
  1618. end
  1619.  
  1620. function reward_random_item(actor,npc,p)
  1621. if (#p > 0) then
  1622. local section_d = p[math.random(#p)]
  1623. reward_item(actor,npc,{section_d})
  1624. end
  1625. end
  1626.  
  1627. function reward_random_money(actor,npc,p)
  1628. --local multi = game_difficulties.get_eco_factor("rewards") or 1 -->>
  1629. --dialogs.relocate_money(db.actor,math.random(tonumber(p[1] or 500)*multi,tonumber(p[2] or 1000)*multi),"in")
  1630.  
  1631. local multi = game_difficulties.get_eco_factor("rewards") or 1
  1632. local min_val = ( (tonumber(p[1]) or 500) * multi ) / 50
  1633. local max_val = ( (tonumber(p[2]) or (min_val + 1000)) * multi ) / 50
  1634. local money = math.random( math.ceil(min_val), math.ceil(max_val) ) * 50
  1635. dialogs.relocate_money( db.actor, money, "in" )
  1636. --printf("reward_random_money | min: %s - max: %s - multi:%s - total: %s", min_val*50 , max_val*50, multi, money)
  1637. end
  1638.  
  1639. function remove_special_task_squad(actor,npc,p)
  1640. level.add_pp_effector("black.ppe", 1313, false)
  1641. remove_squad(actor,npc,p)
  1642. end
  1643.  
  1644. function reset_task_target_anomaly(actor,npc,p)
  1645. save_var(db.actor,"task_target_anomaly",nil)
  1646. if _G.WARFARE then
  1647. save_var(db.actor,"task_target_anomaly_analyzed","analyzed") -- xQd
  1648. end
  1649. end
  1650.  
  1651. -- xQd
  1652. function reset_warfare_escort_task()
  1653. save_var(db.actor,"warfare_escort_task_smart",nil)
  1654. save_var(db.actor,"task_target_anomaly_level",nil)
  1655. save_var(db.actor,"task_target_anomaly_analyzed",nil)
  1656. end
  1657. -- xQd end
  1658.  
  1659. -- setup for special escort to anomaly task
  1660. function setup_task_target_anomaly(actor,npc,p)-- xQd, heavily modified for warfare tasks
  1661. local targets = {}
  1662.  
  1663. if _G.WARFARE then
  1664. -- for k,v in pairs(db.anomaly_by_name) do
  1665. -- table.insert(targets,k)
  1666. -- end
  1667.  
  1668. local targets, target_name
  1669.  
  1670. if math.random(1,5) > 1 then -- 1/5 chance for the target anomaly zone to be in the same level
  1671. targets = str_explode(simulation_objects.config:r_value(level.name(),"target_maps",0,""), ",")
  1672.  
  1673. local remove_level = {l03u_agr_underground=true, l11_hospital=true, l10u_bunker=true, l12u_sarcofag=true, l12u_control_monolith=true, jupiter_underground=true, labx8=true, l08u_brainlab=true} -- these levels don't have anomaly zones or the anomaly zone is unreacheable for AI, so we remove them from targets
  1674.  
  1675. local i=1
  1676. while i <= #targets do
  1677. if remove_level[targets[i]] then
  1678. table.remove(targets, i)
  1679. else
  1680. i = i + 1
  1681. end
  1682. end
  1683.  
  1684. if (#targets <= 0) then
  1685. return
  1686. end
  1687.  
  1688. target_name = targets[math.random(#targets)]
  1689. else
  1690. target_name = level.name()
  1691. end
  1692.  
  1693. save_var(db.actor,"task_target_anomaly_level",target_name) -- xQd
  1694. save_var(db.actor,"task_target_anomaly_analyzed","not_analyzed") -- xQd
  1695. --save_var(db.actor,"task_target_anomaly",target_name)
  1696. else
  1697. for k,v in pairs(db.anomaly_by_name) do
  1698. targets[#targets+1] = k
  1699. end
  1700.  
  1701. if (#targets <= 0) then
  1702. return
  1703. end
  1704.  
  1705. local target_name = targets[math.random(#targets)]
  1706. save_var(db.actor,"task_target_anomaly",target_name)
  1707. end
  1708. end
  1709.  
  1710.  
  1711. function force_talk(actor,npc,p)
  1712. local allow_break = p[1] and p[1] == "true" or false
  1713. db.actor:run_talk_dialog(npc, allow_break)
  1714. end
  1715.  
  1716. function unlock_smart(actor,npc,p)
  1717. local var = p[1] and p[1] ~= "nil" and load_var(db.actor,p[1])
  1718. local smart_id = var and var.smart_id
  1719. local smart = smart_id and alife_object(smart_id)
  1720. if (smart) then
  1721. smart.locked = nil
  1722. else
  1723. printf("~ %s | failed to get smart (%s)", p[1], smart_id)
  1724. end
  1725. end
  1726.  
  1727. -- Принудительно апдейтит логику у объектов, переданных параметром. Пока работает только с НПС
  1728. function update_npc_logic(actor, object, p)
  1729. --printf("UPDATE NPC LOGIC %s", device():time_global())
  1730. for k,v in pairs(p) do
  1731. local npc = get_story_object(v)
  1732. if npc ~= nil then
  1733. xr_motivator.update_logic(npc)
  1734.  
  1735. local planner = npc:motivation_action_manager()
  1736. if planner and planner:initialized() then
  1737. planner:update()
  1738. planner:update()
  1739. planner:update()
  1740. end
  1741.  
  1742. db.storage[npc:id()].state_mgr:update()
  1743. db.storage[npc:id()].state_mgr:update()
  1744. db.storage[npc:id()].state_mgr:update()
  1745. db.storage[npc:id()].state_mgr:update()
  1746. db.storage[npc:id()].state_mgr:update()
  1747. db.storage[npc:id()].state_mgr:update()
  1748. db.storage[npc:id()].state_mgr:update()
  1749. end
  1750. end
  1751. end
  1752.  
  1753. function update_obj_logic(actor, object, p)
  1754. --printf("UPDATE OBJ LOGIC %s", device():time_global())
  1755. for k,v in pairs(p) do
  1756. local obj = get_story_object(v)
  1757. if obj ~= nil then
  1758.  
  1759. local st = db.storage[obj:id()]
  1760. xr_logic.try_switch_to_another_section(obj, st[st.active_scheme], actor)
  1761.  
  1762. -- if st.active_scheme == "sr_cutscene" then
  1763. -- st[st.active_scheme].cutscene_action
  1764. -- end
  1765.  
  1766. end
  1767. end
  1768. end
  1769.  
  1770. local ui_active_slot = 0
  1771.  
  1772. function disable_ui(actor, npc, p)
  1773. if db.actor:is_talking() then
  1774. db.actor:stop_talk()
  1775. end
  1776. level.show_weapon(false)
  1777.  
  1778. if not p or (p and p[1] ~= "true") then
  1779. local slot = db.actor:active_slot()
  1780. if(slot~=0) then
  1781. ui_active_slot = slot
  1782. db.actor:activate_slot(0)
  1783. end
  1784. end
  1785.  
  1786. level.disable_input()
  1787. show_indicators(false)
  1788. --hide_hud_inventory()
  1789. --hide_hud_pda()
  1790. hide_hud_all()
  1791. disable_actor_nightvision(nil,nil)
  1792. disable_actor_torch(nil,nil)
  1793. end
  1794.  
  1795. function disable_ui_only(actor, npc)
  1796. if db.actor:is_talking() then
  1797. db.actor:stop_talk()
  1798. end
  1799. level.show_weapon(false)
  1800.  
  1801. if not p or (p and p[1] ~= "true") then
  1802. local slot = db.actor:active_slot()
  1803. if(slot~=0) then
  1804. ui_active_slot = slot
  1805. db.actor:activate_slot(0)
  1806. end
  1807. end
  1808.  
  1809. level.disable_input()
  1810. show_indicators(false)
  1811. --hide_hud_inventory()
  1812. --hide_hud_pda()
  1813. hide_hud_all()
  1814. disable_actor_nightvision(nil,nil)
  1815. end
  1816.  
  1817. function disable_nv(actor, npc)
  1818. if db.actor:is_talking() then
  1819. db.actor:stop_talk()
  1820. end
  1821. level.show_weapon(false)
  1822.  
  1823. if not p or (p and p[1] ~= "true") then
  1824. local slot = db.actor:active_slot()
  1825. if(slot~=0) then
  1826. ui_active_slot = slot
  1827. db.actor:activate_slot(0)
  1828. end
  1829. end
  1830.  
  1831. disable_actor_nightvision(nil,nil)
  1832. disable_actor_torch(nil,nil)
  1833. end
  1834.  
  1835. function disable_ui_lite_with_imput(actor, npc)
  1836. if db.actor:is_talking() then
  1837. db.actor:stop_talk()
  1838. end
  1839. level.show_weapon(false)
  1840.  
  1841. if not p or (p and p[1] ~= "true") then
  1842. local slot = db.actor:active_slot()
  1843. if(slot~=0) then
  1844. ui_active_slot = slot
  1845. db.actor:activate_slot(0)
  1846. end
  1847. end
  1848.  
  1849. level.disable_input()
  1850. show_indicators(false)
  1851. end
  1852.  
  1853. function disable_ui_lite(actor, npc)
  1854. if db.actor:is_talking() then
  1855. db.actor:stop_talk()
  1856. end
  1857. level.show_weapon(false)
  1858.  
  1859. if not p or (p and p[1] ~= "true") then
  1860. local slot = db.actor:active_slot()
  1861. if(slot~=0) then
  1862. ui_active_slot = slot
  1863. db.actor:activate_slot(0)
  1864. end
  1865. end
  1866.  
  1867. show_indicators(false)
  1868. end
  1869.  
  1870. function disable_ui_inventory(actor, npc)
  1871. if db.actor:is_talking() then
  1872. db.actor:stop_talk()
  1873. end
  1874. -- level.show_weapon(false)
  1875.  
  1876. if not p or (p and p[1] ~= "true") then
  1877. local slot = db.actor:active_slot()
  1878. if(slot~=0) then
  1879. ui_active_slot = slot
  1880. db.actor:activate_slot(0)
  1881. end
  1882. end
  1883.  
  1884. --hide_hud_inventory()
  1885. --hide_hud_pda()
  1886. hide_hud_all()
  1887. end
  1888.  
  1889. function enable_ui(actor, npc, p)
  1890. --db.actor:restore_weapon()
  1891.  
  1892. if not p or (p and p[1] ~= "true") then
  1893. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1894. db.actor:activate_slot(ui_active_slot)
  1895. end
  1896. end
  1897.  
  1898. ui_active_slot = 0
  1899. level.enable_input()
  1900. level.show_weapon(true)
  1901. show_indicators(true)
  1902. enable_actor_nightvision(nil,nil)
  1903. enable_actor_torch(nil,nil)
  1904. end
  1905.  
  1906. function enable_ui_lite_with_imput(actor, npc, p)
  1907. --db.actor:restore_weapon()
  1908.  
  1909. if not p or (p and p[1] ~= "true") then
  1910. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1911. db.actor:activate_slot(ui_active_slot)
  1912. end
  1913. end
  1914.  
  1915. ui_active_slot = 0
  1916. level.enable_input()
  1917. level.show_weapon(true)
  1918. show_indicators(true)
  1919. enable_actor_nightvision(nil,nil)
  1920. enable_actor_torch(nil,nil)
  1921. end
  1922.  
  1923. function enable_ui_lite(actor, npc, p)
  1924. --db.actor:restore_weapon()
  1925.  
  1926. if not p or (p and p[1] ~= "true") then
  1927. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1928. db.actor:activate_slot(ui_active_slot)
  1929. end
  1930. end
  1931.  
  1932. ui_active_slot = 0
  1933. level.enable_input()
  1934. level.show_weapon(true)
  1935. show_indicators(true)
  1936. enable_actor_nightvision(nil,nil)
  1937. enable_actor_torch(nil,nil)
  1938. end
  1939.  
  1940. function enable_nv_and_imput(actor, npc, p)
  1941. --db.actor:restore_weapon()
  1942.  
  1943. if not p or (p and p[1] ~= "true") then
  1944. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1945. db.actor:activate_slot(ui_active_slot)
  1946. end
  1947. end
  1948.  
  1949. level.enable_input()
  1950. enable_actor_nightvision(nil,nil)
  1951. enable_actor_torch(nil,nil)
  1952. end
  1953.  
  1954. function enable_imput(actor, npc, p)
  1955. --db.actor:restore_weapon()
  1956.  
  1957. if not p or (p and p[1] ~= "true") then
  1958. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1959. db.actor:activate_slot(ui_active_slot)
  1960. end
  1961. end
  1962.  
  1963. level.enable_input()
  1964. end
  1965. function enable_nv(actor, npc, p)
  1966. --db.actor:restore_weapon()
  1967.  
  1968. if not p or (p and p[1] ~= "true") then
  1969. if ui_active_slot ~= 0 and db.actor:item_in_slot(ui_active_slot) ~= nil then
  1970. db.actor:activate_slot(ui_active_slot)
  1971. end
  1972. end
  1973. enable_actor_nightvision(nil,nil)
  1974. enable_actor_torch(nil,nil)
  1975. end
  1976.  
  1977. local cam_effector_playing_object_id = nil
  1978.  
  1979. function run_cam_effector(actor, npc, p)
  1980. if p[1] then
  1981. local loop, num = false, (1000 + math.random(100))
  1982. if p[2] and type(p[2]) == "number" and p[2] > 0 then
  1983. num = p[2]
  1984. end
  1985. if p[3] and p[3] == "true" then
  1986. loop = true
  1987. end
  1988. --level.add_pp_effector(p[1] .. ".ppe", num, loop)
  1989. level.add_cam_effector("camera_effects\\" .. p[1] .. ".anm", num, loop, "xr_effects.cam_effector_callback")
  1990. cam_effector_playing_object_id = npc:id()
  1991. end
  1992. end
  1993.  
  1994. function stop_cam_effector(actor, npc, p)
  1995. if p[1] and type(p[1]) == "number" and p[1] > 0 then
  1996. level.remove_cam_effector(p[1])
  1997. end
  1998. end
  1999.  
  2000. function run_cam_effector_global(actor, npc, p)
  2001. local num = 1000 + math.random(100)
  2002. if p[2] and type(p[2]) == "number" and p[2] > 0 then
  2003. num = p[2]
  2004. end
  2005. local fov = device().fov
  2006. if p[3] ~= nil and type(p[3]) == "number" then
  2007. fov = p[3]
  2008. end
  2009. level.add_cam_effector("camera_effects\\" .. p[1] .. ".anm", num, false, "xr_effects.cam_effector_callback", fov)
  2010. cam_effector_playing_object_id = npc:id()
  2011. end
  2012.  
  2013. function cam_effector_callback()
  2014. if cam_effector_playing_object_id == nil then
  2015. printf("cam_eff:callback1!")
  2016. return
  2017. end
  2018. local st = db.storage[cam_effector_playing_object_id]
  2019. if st == nil or st.active_scheme == nil then
  2020. printf("cam_eff:callback2!")
  2021. return
  2022. end
  2023.  
  2024. if st[st.active_scheme].signals == nil then
  2025. printf("cam_eff:callback3!")
  2026. return
  2027. end
  2028. st[st.active_scheme].signals["cameff_end"] = true
  2029. end
  2030.  
  2031. function run_postprocess(actor, npc, p)
  2032. if (p[1]) then
  2033. if(ini_sys:section_exist(p[1])) then
  2034. local num = 2000 + math.random(100)
  2035. if(p[2] and type(p[2]) == "number" and p[2]>0) then
  2036. num = p[2]
  2037. end
  2038. printf("adding complex effector [%s], id [%s], from [%s]", p[1], tostring(p[2]), tostring(npc:name()))
  2039. level.add_complex_effector(p[1], num)
  2040. else
  2041. printf("Complex effector section is no set! [%s]", tostring(p[1]))
  2042. end
  2043. end
  2044. end
  2045.  
  2046. function stop_postprocess(actor, npc, p)
  2047. if(p[1] and type(p[1]) == "number" and p[1]>0) then
  2048. printf("removing complex effector id [%s] from [%s]", tostring(p[1]), tostring(npc:name()))
  2049. level.remove_complex_effector(p[1])
  2050. end
  2051. end
  2052.  
  2053. function run_tutorial(actor, npc, p)
  2054. --printf("run tutorial called")
  2055. game.start_tutorial(p[1])
  2056. end
  2057.  
  2058. --[[
  2059. function run_tutorial_if_newbie(actor, npc, p)
  2060. if has_alife_info("esc_trader_newbie") then
  2061. game.start_tutorial(p[1])
  2062. end
  2063. end
  2064. ]]--
  2065.  
  2066. function jup_b32_place_scanner(actor, npc)
  2067. for i = 1, 5 do
  2068. if xr_conditions.actor_in_zone(actor, npc, {"jup_b32_sr_scanner_place_"..i})
  2069. and not has_alife_info("jup_b32_scanner_"..i.."_placed") then
  2070. db.actor:give_info_portion("jup_b32_scanner_"..i.."_placed")
  2071. db.actor:give_info_portion("jup_b32_tutorial_done")
  2072. remove_item(actor, npc, {"jup_b32_scanner_device"})
  2073. spawn_object(actor, nil, {"jup_b32_ph_scanner","jup_b32_scanner_place_"..i})
  2074. end
  2075. end
  2076. end
  2077.  
  2078. function jup_b32_pda_check(actor, npc)
  2079.  
  2080. end
  2081.  
  2082. function pri_b306_generator_start(actor, npc)
  2083. if xr_conditions.actor_in_zone(actor, npc, {"pri_b306_sr_generator"}) then
  2084. give_info("pri_b306_lift_generator_used")
  2085. end
  2086. end
  2087.  
  2088. function jup_b206_get_plant(actor, npc)
  2089. if xr_conditions.actor_in_zone(actor, npc, {"jup_b206_sr_quest_line"}) then
  2090. give_info("jup_b206_anomalous_grove_has_plant")
  2091. give_actor(actor, npc, {"jup_b206_plant"})
  2092. destroy_object(actor, npc, {"story", "jup_b206_plant_ph"})
  2093. end
  2094. end
  2095.  
  2096. function pas_b400_switcher(actor, npc)
  2097. if xr_conditions.actor_in_zone(actor, npc, {"pas_b400_sr_switcher"}) then
  2098. give_info("pas_b400_switcher_use")
  2099. end
  2100. end
  2101.  
  2102.  
  2103. function jup_b209_place_scanner(actor, npc)
  2104. if xr_conditions.actor_in_zone(actor, npc, {"jup_b209_hypotheses"}) then
  2105. scenario_autosave(db.actor, nil, {"st_save_jup_b209_placed_mutant_scanner"})
  2106. db.actor:give_info_portion("jup_b209_scanner_placed")
  2107. remove_item(actor, npc, {"jup_b209_monster_scanner"})
  2108. spawn_object(actor, nil, {"jup_b209_ph_scanner","jup_b209_scanner_place_point"})
  2109. end
  2110. end
  2111.  
  2112. function jup_b9_heli_1_searching(actor, npc)
  2113. if xr_conditions.actor_in_zone(actor, npc, {"jup_b9_heli_1"})
  2114. then
  2115. db.actor:give_info_portion("jup_b9_heli_1_searching")
  2116. end
  2117. end
  2118.  
  2119. function pri_a18_use_idol(actor, npc)
  2120. if xr_conditions.actor_in_zone(actor, npc, {"pri_a18_use_idol_restrictor"})
  2121. then
  2122. db.actor:give_info_portion("pri_a18_run_cam")
  2123. end
  2124. end
  2125.  
  2126. function jup_b8_heli_4_searching(actor, npc)
  2127. if xr_conditions.actor_in_zone(actor, npc, {"jup_b8_heli_4"})
  2128. then
  2129. db.actor:give_info_portion("jup_b8_heli_4_searching")
  2130. end
  2131. end
  2132.  
  2133. function jup_b10_ufo_searching(actor, npc)
  2134. if xr_conditions.actor_in_zone(actor, npc, {"jup_b10_ufo_restrictor"})
  2135. then
  2136. db.actor:give_info_portion("jup_b10_ufo_memory_started")
  2137. give_actor(db.actor,nil,{"jup_b10_ufo_memory"})
  2138. end
  2139. end
  2140.  
  2141.  
  2142. function zat_b101_heli_5_searching(actor, npc)
  2143. if xr_conditions.actor_in_zone(actor, npc, {"zat_b101_heli_5"})
  2144. then
  2145. db.actor:give_info_portion("zat_b101_heli_5_searching")
  2146. end
  2147. end
  2148.  
  2149. function zat_b28_heli_3_searching(actor, npc)
  2150. if xr_conditions.actor_in_zone(actor, npc, {"zat_b28_heli_3"})
  2151. then
  2152. db.actor:give_info_portion("zat_b28_heli_3_searching")
  2153. end
  2154. end
  2155.  
  2156. function zat_b100_heli_2_searching(actor, npc)
  2157. if xr_conditions.actor_in_zone(actor, npc, {"zat_b100_heli_2"}) then
  2158. db.actor:give_info_portion("zat_b100_heli_2_searching")
  2159. end
  2160. end
  2161.  
  2162. function teleport_actor(actor, npc, p)
  2163. local point = patrol(p[1])
  2164. if not (point) then
  2165. printf("xr_effects.teleport_actor no patrol path %s exists!",p[1])
  2166. return
  2167. end
  2168.  
  2169. local dir
  2170. if p[2] ~= nil then
  2171. local look = patrol(p[2])
  2172. dir = -look:point(0):sub(point:point(0)):getH()
  2173. db.actor:set_actor_direction(dir)
  2174. end
  2175.  
  2176. for k,v in pairs(db.no_weap_zones) do
  2177. if utils_obj.npc_in_zone(db.actor, k) then
  2178. db.no_weap_zones[k] = true
  2179. end
  2180. end
  2181.  
  2182. if npc and npc:name() ~= nil then
  2183. printf("teleporting actor from [%s]", tostring(npc:name()))
  2184. end
  2185.  
  2186. db.actor:set_actor_position(point:point(0))
  2187. end
  2188.  
  2189.  
  2190. local function reset_animation(npc)
  2191. local state_mgr = db.storage[npc:id()].state_mgr
  2192. if state_mgr == nil then
  2193. return
  2194. end
  2195. -- local planner = npc:motivation_action_manager()
  2196.  
  2197. state_mgr.animation:set_state(nil, true)
  2198. state_mgr.animation:set_control()
  2199. state_mgr.animstate:set_state(nil, true)
  2200. state_mgr.animstate:set_control()
  2201.  
  2202. state_mgr:set_state("idle", nil, nil, nil, {fast_set = true})
  2203.  
  2204. -- planner:update()
  2205. -- planner:update()
  2206. -- planner:update()
  2207.  
  2208. state_mgr:update()
  2209. state_mgr:update()
  2210. state_mgr:update()
  2211. state_mgr:update()
  2212. state_mgr:update()
  2213. state_mgr:update()
  2214. state_mgr:update()
  2215.  
  2216. npc:set_body_state(move.standing)
  2217. npc:set_mental_state(anim.free)
  2218.  
  2219. end
  2220.  
  2221. function teleport_npc_lvid(actor,npc,p)
  2222. local vid = tonumber(p[1])
  2223. if not (vid) then
  2224. return
  2225. end
  2226. local position = level.vertex_position(vid)
  2227. if (p[2]) then
  2228. local obj = get_story_object(p[2])
  2229. if (obj) then
  2230. obj:set_npc_position(position)
  2231. end
  2232. return
  2233. end
  2234. npc:set_npc_position(position)
  2235. end
  2236.  
  2237. function teleport_npc_pos(actor,npc,p)
  2238. for i=1,3 do
  2239. p[i] = string.gsub(p[i],"n","-")
  2240. end
  2241. local pos = vector():set(tonumber(p[1]),tonumber(p[2]),tonumber(p[3]))
  2242. if not (pos) then
  2243. return
  2244. end
  2245.  
  2246. if (p[4]) then
  2247. local obj = get_story_object(p[4])
  2248. if (obj) then
  2249. obj:set_npc_position(pos)
  2250. end
  2251. return
  2252. end
  2253. npc:set_npc_position(pos)
  2254. end
  2255.  
  2256. function teleport_squad_lvid(actor,npc,p)
  2257. local vid = tonumber(p[1])
  2258. if not (vid) then
  2259. return
  2260. end
  2261.  
  2262. local squad = p[2] and get_story_squad(p[2]) or get_object_squad(npc)
  2263. if not (squad) then
  2264. return
  2265. end
  2266.  
  2267. local position = level.vertex_position(vid)
  2268. squad:set_squad_position(position)
  2269. end
  2270.  
  2271. function teleport_npc(actor, npc, p)
  2272. if not (p[1]) then
  2273. return
  2274. end
  2275.  
  2276. local position = patrol(p[1]):point(tonumber(p[2]) or 0)
  2277. --reset_animation(npc)
  2278.  
  2279. npc:set_npc_position(position)
  2280. end
  2281.  
  2282. function teleport_npc_by_story_id(actor, npc, p)
  2283. local story_id = p[1]
  2284. local patrol_point = p[2]
  2285. local patrol_point_index = p[3] or 0
  2286. if story_id == nil or patrol_point == nil then
  2287. printf("Wrong parameters in 'teleport_npc_by_story_id' function!!!")
  2288. end
  2289. local position = patrol(tostring(patrol_point)):point(patrol_point_index)
  2290. local npc_id = get_story_object_id(story_id)
  2291. if npc_id == nil then
  2292. printf("There is no story object with id [%s]", story_id)
  2293. end
  2294. local cl_object = level.object_by_id(npc_id)
  2295. if cl_object then
  2296. reset_animation(cl_object)
  2297. cl_object:set_npc_position(position)
  2298. else
  2299. alife_object(npc_id).position = position
  2300. end
  2301. end
  2302.  
  2303. -- Teleports a squad, by story id, to another location
  2304. -- param1 - squad story id
  2305. -- param2 - path name
  2306. -- param3 - optional path index
  2307. function teleport_squad(actor, npc, p)
  2308. local squad = p[1] and get_story_squad(p[1])
  2309. if not (squad) then
  2310. printf("There is no squad with story id [%s]", p[1])
  2311. end
  2312.  
  2313. local path = patrol(p[2])
  2314. if not (path) then
  2315. printf("Wrong parameters in 'teleport_squad' function!!!")
  2316. return
  2317. end
  2318.  
  2319. local idx = p[3] or 0
  2320. TeleportSquad(squad,path:point(idx),path:level_vertex_id(idx),path:game_vertex_id(idx))
  2321. --squad:set_squad_position(path:point(idx))
  2322. end
  2323.  
  2324. function jup_teleport_actor(actor, npc)
  2325. local point_in = patrol("jup_b16_teleport_in"):point(0)
  2326. local point_out = patrol("jup_b16_teleport_out"):point(0)
  2327. local actor_position = actor:position()
  2328. local out_position = vector():set(actor_position.x - point_in.x + point_out.x, actor_position.y - point_in.y + point_out.y , actor_position.z - point_in.z + point_out.z)
  2329. db.actor:set_actor_position(out_position)
  2330. end
  2331. -----------------------------------------------------------------------------
  2332. --[[
  2333. local drop_point, drop_object = 0, 0
  2334. local function drop_object_item(item)
  2335. drop_object:drop_item_and_teleport(item, drop_point)
  2336. end
  2337.  
  2338. function drop_actor_inventory(actor, npc, p)
  2339. if p[1] then
  2340. drop_point = patrol(p[1]):point(0)
  2341. drop_object = actor
  2342. actor:inventory_for_each(drop_object_item)
  2343. end
  2344. end
  2345.  
  2346.  
  2347. -- FIXME: drop_npc_inventory doesn't work
  2348. function drop_npc_inventory(actor, npc, p)
  2349. if p[1] then
  2350. drop_point = patrol(p[1]):point(0)
  2351. drop_object = npc
  2352. npc:inventory_for_each(drop_object_item)
  2353. end
  2354. end
  2355.  
  2356. function drop_npc_item(actor, npc, p)
  2357. if p[1] then
  2358. local item = npc:object(p[1])
  2359. if item then
  2360. npc:drop_item(item)
  2361. end
  2362. end
  2363. end
  2364.  
  2365. function drop_npc_items(actor, npc, p)
  2366. local item = 0
  2367. for i, v in pairs(p) do
  2368. item = npc:object(v)
  2369. if item then
  2370. npc:drop_item(item)
  2371. end
  2372. end
  2373. end
  2374. ]]--
  2375.  
  2376. function give_items(actor, npc, p)
  2377. local pos, lv_id, gv_id, npc_id = npc:position(), npc:level_vertex_id(), npc:game_vertex_id(), npc:id()
  2378. for i, v in pairs(p) do
  2379. alife_create_item(v, npc)
  2380. --alife_create(v, pos, lv_id, gv_id, npc_id)
  2381. end
  2382. end
  2383.  
  2384. function give_item(actor, npc, p)
  2385. if p[2] ~= nil then
  2386. npc_id = get_story_object_id(p[2])
  2387. else
  2388. npc_id = npc:id()
  2389. end
  2390. local se_npc = alife_object(npc_id)
  2391. if not (se_npc) then
  2392. return
  2393. end
  2394.  
  2395. alife_create_item(p[1], se_npc)
  2396. end
  2397.  
  2398. function play_particle_on_path(actor, npc, p)
  2399. local name = p[1]
  2400. local path = p[2]
  2401. local point_prob = p[3]
  2402. if name == nil or path == nil then
  2403. return
  2404. end
  2405. if point_prob == nil then
  2406. point_prob = 100
  2407. end
  2408.  
  2409. local path = patrol(path)
  2410. local count = path:count()
  2411. for a = 0,count-1,1 do
  2412. local particle = particles_object(name)
  2413. if math.random(100) <= point_prob then
  2414. particle:play_at_pos(path:point(a))
  2415. end
  2416. end
  2417. end
  2418.  
  2419.  
  2420. -----------------------------------------------------------------------------
  2421. --[[
  2422. send_tip(news_id:sender:sender_id)
  2423. 1. news_id
  2424. 2. sender*
  2425. 3. sender_id*
  2426. * - not necessary
  2427. --]]
  2428. function send_tip(actor, npc, p)
  2429. news_manager.send_tip(actor, p[1], nil, p[2], nil, p[3])
  2430. end
  2431.  
  2432. function send_tip_task(actor,npc,p)
  2433. local tsk = p[1] and task_manager.get_task_manager().task_info[p[1]]
  2434. if (tsk and p[2]) then
  2435. news_manager.send_task(actor, p[2], tsk)
  2436. end
  2437. end
  2438. --[[
  2439. Дать сталкеру небольшой пинок. Например чтоб скинуть его с возвышения.
  2440. параметры: actor, npc, p[direction,bone,power,impulse,reverse=false]
  2441. 1. direction - если строка, то считается, что это имя пути и в сторону
  2442. первой точки производится толчек. Если же это число, то оно
  2443. рассматривается как story_id персонажа от которого должен поступить хит.
  2444. 2. bone - строка. Имя кости, по которой наносится удар.
  2445. 3. power - сила удара
  2446. 4. impulse - импульс
  2447. 5. reverse (true/false) - изменение направления удара. по умолчанию false
  2448. --]]
  2449. function hit_npc(actor, npc, p)
  2450. local h = hit()
  2451. local rev = p[6] and p[6] == 'true'
  2452. h.draftsman = npc
  2453. h.type = hit.wound
  2454. if p[1] ~= "self" then
  2455. local hitter = get_story_object(p[1])
  2456. if not hitter then return end
  2457. if rev then
  2458. h.draftsman = hitter
  2459. h.direction = hitter:position():sub(npc:position())
  2460. else
  2461. h.direction = npc:position():sub(hitter:position())
  2462. end
  2463. else
  2464. if rev then
  2465. h.draftsman = nil
  2466. h.direction = npc:position():sub(patrol(p[2]):point(0))
  2467. else
  2468. h.direction = patrol(p[2]):point(0):sub(npc:position())
  2469. end
  2470. end
  2471. h:bone(p[3])
  2472. h.power = p[4]
  2473. h.impulse = p[5]
  2474. --printf("HIT EFFECT: (%s, %s,%d,%d) health(%s)", npc:name(), p[2], h.power, h.impulse, npc.health)
  2475. npc:hit(h)
  2476. end
  2477.  
  2478. --[[
  2479. Дать обьекту, заданному story_id, хит.
  2480. параметры: actor, npc, p[sid,bone,power,impulse,hit_src=npc:position()]
  2481. 1. sid - story_id обьекта, по которому наносится хит.
  2482. 2. bone - строка. Имя кости, по которой наносится удар.
  2483. 3. power - сила удара
  2484. 4. impulse - импульс
  2485. 5. hit_src - если число, то рассматривается как story_id обьекта, со стороны
  2486. которого наносится хит (он же является и инициатором хита), иначе это
  2487. точка (waypoint), из которой по объекту наносится хит.
  2488. Если не задано, то берется позиция обьекта, из которого была вызвана
  2489. данная функция.
  2490. --]]
  2491. function hit_obj(actor, npc, p)
  2492. local h = hit()
  2493. local obj = get_story_object(p[1])
  2494. local sid = nil
  2495.  
  2496. if not obj then
  2497. -- printf("HIT_OBJ [%s]. Target object does not exist", npc:name())
  2498. return
  2499. end
  2500.  
  2501. h:bone(p[2])
  2502. h.power = p[3]
  2503. h.impulse = p[4]
  2504.  
  2505. if p[5] then
  2506. sid = get_story_object(sid)
  2507. if sid then
  2508. h.direction = vec_sub(sid:position(), obj:position())
  2509. end
  2510. if not sid then
  2511. h.direction = vec_sub(patrol(p[5]):point(0), obj:position())
  2512. end
  2513. else
  2514. h.direction = vec_sub(npc:position(), obj:position())
  2515. end
  2516. h.draftsman = sid or npc
  2517. h.type = hit.wound
  2518. obj:hit(h)
  2519. end
  2520.  
  2521.  
  2522. function hit_obj_chemical(actor, npc, p)
  2523. local h = hit()
  2524. local obj = get_story_object(p[1])
  2525. local sid = nil
  2526.  
  2527. if not obj then
  2528. -- printf("HIT_OBJ [%s]. Target object does not exist", npc:name())
  2529. return
  2530. end
  2531.  
  2532. h:bone(p[2])
  2533. h.power = p[3]
  2534. h.impulse = p[4]
  2535.  
  2536. if p[5] then
  2537. sid = get_story_object(sid)
  2538. if sid then
  2539. h.direction = vec_sub(sid:position(), obj:position())
  2540. end
  2541. if not sid then
  2542. h.direction = vec_sub(patrol(p[5]):point(0), obj:position())
  2543. end
  2544. else
  2545. h.direction = vec_sub(npc:position(), obj:position())
  2546. end
  2547.  
  2548. h.draftsman = sid or npc
  2549. h.type = hit.chemical_burn
  2550. obj:hit(h)
  2551. end
  2552.  
  2553. function hit_obj_fire_wound(actor, npc, p)
  2554. local h = hit()
  2555. local obj = get_story_object(p[1])
  2556. local sid = nil
  2557.  
  2558. if not obj then
  2559. -- printf("HIT_OBJ [%s]. Target object does not exist", npc:name())
  2560. return
  2561. end
  2562.  
  2563. h:bone(p[2])
  2564. h.power = p[3]
  2565. h.impulse = p[4]
  2566.  
  2567. if p[5] then
  2568. sid = get_story_object(sid)
  2569. if sid then
  2570. h.direction = vec_sub(sid:position(), obj:position())
  2571. end
  2572. if not sid then
  2573. h.direction = vec_sub(patrol(p[5]):point(0), obj:position())
  2574. end
  2575. else
  2576. h.direction = vec_sub(npc:position(), obj:position())
  2577. end
  2578.  
  2579. h.draftsman = sid or npc
  2580. h.type = hit.fire_wound
  2581. obj:hit(h)
  2582. end
  2583.  
  2584. --[[
  2585. Дать сталкеру небольшой пинок после смерти. Аналогично предыдущему, только направление хита теперь
  2586. вычисляется через убийцу. Поэтому параметра direction нет.
  2587. параметры: actor, npc, p[bone,power,impulse]
  2588. FIXME: killer:position() isn't working <-(Because you are fucking stupid)
  2589. --]]
  2590. function hit_by_killer(actor, npc, p)
  2591. if not npc then return end
  2592. local t = db.storage[npc:id()].death
  2593. if not (t) then
  2594. return false
  2595. end
  2596.  
  2597. if (t.killer == nil or t.killer == -1) then
  2598. return false
  2599. end
  2600.  
  2601. local killer = db.storage[t.killer].object or level.object_by_id(t.killer)
  2602. if not (killer) then
  2603. return false
  2604. end
  2605.  
  2606. local p1, p2
  2607. p1 = npc:position()
  2608. p2 = killer:position()
  2609. local h = hit()
  2610. h.draftsman = npc
  2611. h.type = hit.wound
  2612. h.direction = vector():set(p1):sub(p2)
  2613. h.bone = p[1]
  2614. h.power = p[2]
  2615. h.impulse = p[3]
  2616. npc:hit(h)
  2617. end
  2618.  
  2619.  
  2620. function hit_npc_from_actor(actor, npc, p)
  2621. local h = hit()
  2622. local sid = nil
  2623. h.draftsman = actor
  2624. h.type = hit.wound
  2625.  
  2626. if p and p[1] then
  2627. sid = get_story_object(p[1])
  2628. if sid then
  2629. h.direction = actor:position():sub(sid:position())
  2630. end
  2631. if not sid then
  2632. h.direction = actor:position():sub(npc:position())
  2633. end
  2634. else
  2635. h.direction = actor:position():sub(npc:position())
  2636. sid = npc
  2637. end
  2638.  
  2639. h:bone("bip01_spine")
  2640. h.power = 0.001
  2641. h.impulse = 0.001
  2642. sid:hit(h)
  2643. end
  2644.  
  2645. --[[
  2646. -- Хитует нпс от нпс, если задан один параметр (стори айди), то нпс с таким стори айди хитнет нпс у которого вызвали эту функцию.
  2647. -- если задано 2 стори айди , то нпс с 1-ым стори айди хитнет нпс со 2-ым стори айди.
  2648. function hit_npc_from_npc(actor, npc, p)
  2649. if p == nil then printf("Invalid parameter in function 'hit_npc_from_npc'!!!!") end
  2650. local h = hit()
  2651. local hitted_npc = npc
  2652. h.draftsman = get_story_object(p[1])
  2653. if p[2] ~= nil then
  2654. hitted_npc = get_story_object(p[2])
  2655. end
  2656. h.type = hit.wound
  2657. h.direction = h.draftsman:position():sub(hitted_npc:position())
  2658. h:bone("bip01_spine")
  2659. h.power = 0.03
  2660. h.impulse = 0.03
  2661. hitted_npc:hit(h)
  2662. end
  2663.  
  2664. function hit_actor(actor, npc, p)
  2665. local h = hit()
  2666. h.direction = VEC_ZERO
  2667. h.draftsman = actor
  2668. h.type = hit.shock
  2669. h:bone("bip01_spine")
  2670. h.power = (p and p[1] and tonumber(p[1])) or 0.001
  2671. h.impulse = 0.001
  2672. actor:hit(h)
  2673. end
  2674. ]]--
  2675.  
  2676. function restore_health_portion(actor, npc)
  2677. local health = npc.health
  2678. local diff = 1 - health
  2679. if diff > 0 then
  2680. npc.health = health + math.random(diff * 0.5, diff * 0.95)
  2681. end
  2682. end
  2683. function restore_health(actor, npc)
  2684. --printf("HEALTH RESTORE")
  2685. npc.health = 1
  2686. end
  2687.  
  2688. function make_enemy(actor, npc, p)
  2689. --[[
  2690. if p == nil then printf("Invalid parameter in function 'hit_npc_from_npc'!!!!") end
  2691. local h = hit()
  2692. local hitted_npc = npc
  2693. h.draftsman = get_story_object(p[1])
  2694. if p[2] ~= nil then
  2695. hitted_npc = get_story_object(p[2])
  2696. end
  2697. h.type = hit.wound
  2698. h.direction = h.draftsman:position():sub(hitted_npc:position())
  2699. h:bone("bip01_spine")
  2700. h.power = 0.03
  2701. h.impulse = 0.03
  2702. hitted_npc:hit(h)
  2703. --]]
  2704. local npc1 = get_story_object(p[1])
  2705. if not (npc1) then
  2706. return
  2707. end
  2708. local npc2 = get_story_object(p[2])
  2709. if not (npc2) then
  2710. return
  2711. end
  2712. npc1:set_relation(game_object.enemy,npc2)
  2713. npc2:set_relation(game_object.enemy,npc1)
  2714. end
  2715.  
  2716. function sniper_fire_mode(actor, npc, p)
  2717. if p[1] == "true" then
  2718. --printf("SNIPER FIRE MODE ON")
  2719. npc:sniper_fire_mode(true)
  2720. else
  2721. --printf("SNIPER FIRE MODE OFF")
  2722. npc:sniper_fire_mode(false)
  2723. end
  2724. end
  2725.  
  2726. function kill_npc(actor, npc, p)
  2727. if p and p[1] then
  2728. npc = get_story_object(p[1])
  2729. end
  2730. if npc ~= nil and npc:alive() then
  2731. npc:kill(npc)
  2732. end
  2733. end
  2734.  
  2735. function remove_npc(actor, npc, p)
  2736. if p and p[1] then
  2737. npc_id = get_story_object_id(p[1])
  2738. end
  2739. if npc_id ~= nil then
  2740. local se_obj = alife_object(npc_id)
  2741. if (se_obj) then
  2742. safe_release_manager.release(se_obj)
  2743. --alife_release(se_obj)
  2744. end
  2745. end
  2746. end
  2747.  
  2748. -- прибавить к указанному счётчику актёра 1
  2749. function inc_counter(actor, npc, p)
  2750. if p and p[1] then
  2751. local inc_value = p[2] or 1
  2752. local new_value = load_var(actor, p[1], 0) + inc_value
  2753. if npc and npc:name() then
  2754. printf("inc_counter '%s' to value [%s], by [%s]", p[1], tostring(new_value), tostring(npc:name()))
  2755. end
  2756. save_var(actor, p[1], new_value)
  2757. end
  2758. end
  2759.  
  2760. function dec_counter(actor, npc, p)
  2761. if p and p[1] then
  2762. local dec_value = p[2] or 1
  2763. local new_value = load_var(actor, p[1], 0) - dec_value
  2764. if new_value < 0 then
  2765. new_value = 0
  2766. end
  2767. save_var(actor, p[1], new_value)
  2768. if npc and npc:name() then
  2769. printf( "dec_counter [%s] value [%s] by [%s]", p[1], load_var(actor, p[1], 0), tostring(npc:name()))
  2770. end
  2771. end
  2772. end
  2773.  
  2774. function set_counter(actor, npc, p)
  2775. if p and p[1] then
  2776. local count = p[2] or 0
  2777. -- printf( "set_counter '%s' %s", p[1], count)
  2778. save_var(actor, p[1], count)
  2779. -- printf("counter [%s] value [%s]", p[1], load_var(actor, p[1], 0))
  2780. end
  2781. end
  2782.  
  2783.  
  2784. ------------------------------------------------------------------------------------------------------------------------
  2785. -- постпроцесс и влияние удара в морду
  2786. function actor_punch(npc)
  2787. if db.actor:position():distance_to_sqr(npc:position()) > 4 then
  2788. return
  2789. end
  2790.  
  2791. set_inactivate_input_time(30)
  2792. level.add_cam_effector("camera_effects\\fusker.anm", 999, false, "")
  2793.  
  2794. local active_slot = db.actor:active_slot()
  2795. if active_slot ~= 2 and
  2796. active_slot ~= 3
  2797. then
  2798. return
  2799. end
  2800.  
  2801. local active_item = db.actor:active_item()
  2802. if active_item and string.find(active_item:section(),'wpn_') then
  2803. db.actor:drop_item(active_item)
  2804. end
  2805. end
  2806.  
  2807. -- забывание обиды
  2808. function clearAbuse(npc)
  2809. printf("CLEAR_ABUSE")
  2810. xr_abuse.clear_abuse(npc)
  2811. end
  2812.  
  2813. function turn_off_underpass_lamps(actor, npc)
  2814. local lamps_table = {
  2815. ["pas_b400_lamp_start_flash"] = true,
  2816. ["pas_b400_lamp_start_red"] = true,
  2817. ["pas_b400_lamp_elevator_green"] = true,
  2818. ["pas_b400_lamp_elevator_flash"] = true,
  2819. ["pas_b400_lamp_elevator_green_1"] = true,
  2820. ["pas_b400_lamp_elevator_flash_1"] = true,
  2821. ["pas_b400_lamp_track_green"] = true,
  2822. ["pas_b400_lamp_track_flash"] = true,
  2823. ["pas_b400_lamp_downstairs_green"] = true,
  2824. ["pas_b400_lamp_downstairs_flash"] = true,
  2825. ["pas_b400_lamp_tunnel_green"] = true,
  2826. ["pas_b400_lamp_tunnel_flash"] = true,
  2827. ["pas_b400_lamp_tunnel_green_1"] = true,
  2828. ["pas_b400_lamp_tunnel_flash_1"] = true,
  2829. ["pas_b400_lamp_control_down_green"] = true,
  2830. ["pas_b400_lamp_control_down_flash"] = true,
  2831. ["pas_b400_lamp_control_up_green"] = true,
  2832. ["pas_b400_lamp_control_up_flash"] = true,
  2833. ["pas_b400_lamp_hall_green"] = true,
  2834. ["pas_b400_lamp_hall_flash"] = true,
  2835. ["pas_b400_lamp_way_green"] = true,
  2836. ["pas_b400_lamp_way_flash"] = true,
  2837. }
  2838. for k,v in pairs(lamps_table) do
  2839. local obj = get_story_object(k)
  2840.  
  2841. if obj then
  2842. obj:get_hanging_lamp():turn_off()
  2843. else
  2844. printf("function 'turn_off_underpass_lamps' lamp [%s] does not exist", tostring(k))
  2845. --printf("function 'turn_off_underpass_lamps' lamp [%s] does not exist", tostring(k))
  2846. end
  2847. end
  2848. end
  2849.  
  2850. ---Выключение динамической лампочки (hanging_lamp)
  2851. function turn_off(actor, npc, p)
  2852. for k,v in pairs(p) do
  2853. local obj = get_story_object(v)
  2854.  
  2855. if not obj then
  2856. printf("TURN_OFF. Target object with story_id [%s] does not exist", v)
  2857. return
  2858. end
  2859. obj:get_hanging_lamp():turn_off()
  2860. --printf("TURN_OFF. Target object with story_id [%s] turned off.", v)
  2861. end
  2862. end
  2863.  
  2864. function turn_off_object(actor, npc)
  2865. npc:get_hanging_lamp():turn_off()
  2866. end
  2867.  
  2868. ---Включение динамической лампочки (hanging_lamp)
  2869. function turn_on(actor, npc, p)
  2870. for k,v in pairs(p) do
  2871. local obj = get_story_object(v)
  2872.  
  2873. if not obj then
  2874. printf("TURN_ON [%s]. Target object does not exist", npc:name())
  2875. return
  2876. end
  2877. obj:get_hanging_lamp():turn_on()
  2878. end
  2879. end
  2880.  
  2881. ---Включение и запуск динамической лампочки (hanging_lamp)
  2882. function turn_on_and_force(actor, npc, p)
  2883. local obj = get_story_object(p[1])
  2884. if not obj then
  2885. printf("TURN_ON_AND_FORCE. Target object does not exist")
  2886. return
  2887. end
  2888. if p[2] == nil then p[2] = 55 end
  2889. if p[3] == nil then p[3] = 14000 end
  2890. obj:set_const_force(VEC_Y, p[2], p[3])
  2891. obj:start_particles("weapons\\light_signal", "link")
  2892. obj:get_hanging_lamp():turn_on()
  2893. end
  2894.  
  2895. ---Выключение динамической лампочки и партиклов (hanging_lamp)
  2896. function turn_off_and_force(actor, npc, p)
  2897. local obj = get_story_object(p[1])
  2898. if not obj then
  2899. printf("TURN_OFF [%s]. Target object does not exist", npc:name())
  2900. return
  2901. end
  2902. obj:stop_particles("weapons\\light_signal", "link")
  2903. obj:get_hanging_lamp():turn_off()
  2904. end
  2905.  
  2906.  
  2907. function turn_on_object(actor, npc)
  2908. npc:get_hanging_lamp():turn_on()
  2909. end
  2910.  
  2911. function turn_off_object(actor, npc)
  2912. npc:get_hanging_lamp():turn_off()
  2913. end
  2914.  
  2915.  
  2916. -- Вызов этой функции отключит обработчик [combat] боя для персонажа.
  2917. -- Используется в случаях, когда все необходимые действия, такие как переключение на другую секцию,
  2918. -- уже выполнены, и повторно выполнять их во время боя нельзя (а условия секции [combat] проверяются на каждом
  2919. -- апдейте, когда персонаж в бою, если, конечно, не отключены вызовом этой функции).
  2920. function disable_combat_handler(actor, npc)
  2921. if db.storage[npc:id()].combat then
  2922. db.storage[npc:id()].combat.enabled = false
  2923. end
  2924.  
  2925. if db.storage[npc:id()].mob_combat then
  2926. db.storage[npc:id()].mob_combat.enabled = false
  2927. end
  2928. end
  2929.  
  2930. -- Вызов этой функции отключит обработчик [combat_ignore] перехвата боя для персонажа.
  2931. function disable_combat_ignore_handler(actor, npc)
  2932. if db.storage[npc:id()].combat_ignore then
  2933. db.storage[npc:id()].combat_ignore.enabled = false
  2934. end
  2935. end
  2936.  
  2937. -------------------------------------------------------------------------------------
  2938. -- Функции для работы с вертолётами
  2939. -------------------------------------------------------------------------------------
  2940. --[[
  2941. function heli_set_enemy_actor(actor, npc)
  2942. local st = db.storage[npc:id()]
  2943. if not st.combat.enemy_id and actor:alive() then
  2944. st.combat.enemy_id = actor:id()
  2945. heli_snd.play_snd( st, heli_snd.snd_see_enemy, 1 )
  2946. end
  2947. end
  2948.  
  2949. function heli_set_enemy(actor, npc, p)
  2950. local st = db.storage[npc:id()]
  2951. local obj = get_story_object( p[1] )
  2952. if not st.combat.enemy_id and obj:alive() then
  2953. st.combat.enemy_id = obj:id()
  2954. heli_snd.play_snd( st, heli_snd.snd_see_enemy, 1 )
  2955. end
  2956. end
  2957.  
  2958. function heli_clear_enemy(actor, npc)
  2959. db.storage[npc:id()].combat:forget_enemy()
  2960. end
  2961. ]]--
  2962.  
  2963. function heli_start_flame(actor, npc)
  2964. bind_heli.heli_start_flame( npc )
  2965. end
  2966.  
  2967. function heli_die(actor, npc)
  2968. bind_heli.heli_die( npc )
  2969. end
  2970.  
  2971.  
  2972. --'-----------------------------------------------------------------------------------
  2973. --' Функции для работы с погодными эффектами
  2974. --'-----------------------------------------------------------------------------------
  2975.  
  2976. -- Принудительная установка погодных условий
  2977. -- =set_weather(<секция погоды>:true) - установка погоды сразу, false - через некоторое время
  2978. -- Будет использоваться на старте игры Зов Припяти и в сцене jup_b15 - утро после пьянки с Зулусом
  2979. function set_weather(actor, npc, p)
  2980. if(p[1]) then
  2981. if(p[2]=="true") then
  2982. level.set_weather(p[1],true)
  2983. else
  2984. level.set_weather(p[1],false)
  2985. end
  2986. end
  2987. end
  2988. --[[
  2989. function update_weather(actor, npc, p)
  2990. if p and p[1] then
  2991. if p[1] == "true" then
  2992. level_weathers.get_weather_manager():select_weather(true)
  2993. elseif p[1] == "false" then
  2994. level_weathers.get_weather_manager():select_weather(false)
  2995. end
  2996. end
  2997. end
  2998.  
  2999. function start_small_reject(actor, npc)
  3000. level.set_weather_fx("fx_surge_day_3")
  3001. level.add_pp_effector("vibros_p.ppe", 1974, false)
  3002. this.aes_earthshake(npc)
  3003. end
  3004.  
  3005. function start_full_reject(actor, npc)
  3006. level.set_weather_fx("fx_surge_day_3")
  3007. level.remove_pp_effector(1974)
  3008. level.remove_cam_effector(1975)
  3009. level.add_cam_effector("camera_effects\\earthquake.anm", 1975, true, "")
  3010. end
  3011.  
  3012. function stop_full_reject(actor, npc)
  3013. level.remove_pp_effector(1974)
  3014. level.remove_cam_effector(1975)
  3015. end
  3016.  
  3017. function run_weather_pp(actor,npc, p)
  3018. local weather_fx = p[1]
  3019. if weather_fx == nil then
  3020. weather_fx = "fx_surge_day_3"
  3021. end
  3022. level.set_weather_fx(weather_fx)
  3023. end
  3024. ]]--
  3025.  
  3026. function game_disconnect(actor, npc)
  3027. local c = get_console()
  3028. exec_console_cmd("disconnect")
  3029. -- c:execute_deferred("main_menu off")
  3030. -- c:execute_deferred("hide")
  3031. end
  3032.  
  3033. function game_credits(actor, npc)
  3034. db.gameover_credits_started = true
  3035. game.start_tutorial("credits_seq")
  3036. end
  3037.  
  3038. function game_over(actor, npc)
  3039. if db.gameover_credits_started ~= true then
  3040. return
  3041. end
  3042. printf("main_menu on console command is executed")
  3043. exec_console_cmd("main_menu on")
  3044. end
  3045.  
  3046. function after_credits(actor, npc)
  3047. exec_console_cmd("main_menu on")
  3048. end
  3049.  
  3050. function before_credits(actor, npc)
  3051. exec_console_cmd("main_menu off")
  3052. end
  3053.  
  3054. function on_tutor_gameover_stop()
  3055. printf("main_menu on console command is executed")
  3056. exec_console_cmd("main_menu on")
  3057. end
  3058.  
  3059. function on_tutor_gameover_quickload()
  3060. exec_console_cmd("load_last_save")
  3061. end
  3062.  
  3063.  
  3064. -- для смены работы
  3065. function get_stalker_for_new_job(actor, npc, p)
  3066. xr_gulag.find_stalker_for_job(npc,p[1])
  3067. end
  3068. function switch_to_desired_job(actor, npc, p)
  3069. xr_gulag.switch_to_desired_job(npc)
  3070. end
  3071.  
  3072. --[[
  3073. function death_hit(actor, npc, p)
  3074. local draftsman = get_story_object (p[1])
  3075. local hitted_obj = (p[2] ~= nil and get_story_object (p[2])) or npc
  3076. if draftsman == nil or hitted_obj == nil then
  3077. return
  3078. end
  3079. local h = hit()
  3080. h.power = 1000
  3081. h.direction = hitted_obj:direction()
  3082. h.draftsman = draftsman
  3083. h.impulse = 1
  3084. h.type = hit.wound
  3085. hitted_obj:hit(h)
  3086. end
  3087. ]]--
  3088.  
  3089. --'-----------------------------------------------------------------------------------
  3090. --' Функции для работы с подспауном
  3091. --'-----------------------------------------------------------------------------------
  3092. function spawn_object(actor, obj, p)
  3093. --' p[1] - секция кого спаунить
  3094. --' p[2] - имя патрульного пути где спа унить.
  3095. local spawn_sect = p[1]
  3096. if spawn_sect == nil then
  3097. printf("Wrong spawn section for 'spawn_object' function %s. For object %s", tostring(spawn_sect), obj:name())
  3098. end
  3099.  
  3100. local path_name = p[2]
  3101. if path_name == nil then
  3102. printf("Wrong path_name for 'spawn_object' function %s. For object %s", tostring(path_name), obj:name())
  3103. end
  3104.  
  3105. if not level.patrol_path_exists(path_name) then
  3106. printf("Path %s doesnt exist. Function 'spawn_object' for object %s ", tostring(path_name), obj:name())
  3107. end
  3108. local ptr = patrol(path_name)
  3109. local index = p[3] or 0
  3110. local yaw = p[4] or 0
  3111.  
  3112. --' printf("Spawning %s at %s, %s", tostring(p[1]), tostring(p[2]), tostring(p[3]))
  3113. local se_obj = alife_create(spawn_sect,ptr:point(index),ptr:level_vertex_id(0),ptr:game_vertex_id(0))
  3114. if (se_obj) then
  3115. if IsStalker( nil, se_obj:clsid()) then
  3116. se_obj:o_torso().yaw = yaw * math.pi / 180
  3117. elseif se_obj:clsid() == clsid.script_phys then
  3118. se_obj:set_yaw(yaw * math.pi / 180)
  3119. end
  3120. end
  3121. end
  3122.  
  3123. local jup_b219_position
  3124. local jup_b219_lvid
  3125. local jup_b219_gvid
  3126.  
  3127. function jup_b219_save_pos()
  3128. local obj = get_story_object("jup_b219_gate_id")
  3129. if obj and obj:position() then
  3130. jup_b219_position = obj:position()
  3131. jup_b219_lvid = obj:level_vertex_id()
  3132. jup_b219_gvid = obj:game_vertex_id()
  3133. else
  3134. return
  3135. end
  3136. alife_release_id(obj:id())
  3137. end
  3138.  
  3139. function jup_b219_restore_gate()
  3140. local yaw = 0
  3141. local spawn_sect = "jup_b219_gate"
  3142. if jup_b219_position then
  3143. local se_obj = alife_create(spawn_sect,vector():set(jup_b219_position),jup_b219_lvid,jup_b219_gvid)
  3144. if (se_obj) then
  3145. se_obj:set_yaw(yaw * math.pi / 180)
  3146. end
  3147. end
  3148. end
  3149.  
  3150. function spawn_corpse(actor, obj, p)
  3151. --' p[1] - секция кого спаунить
  3152. --' p[2] - имя патрульного пути где спаунить.
  3153. local spawn_sect = p[1]
  3154. if spawn_sect == nil then
  3155. printf("Wrong spawn section for 'spawn_corpse' function %s. For object %s", tostring(spawn_sect), obj:name())
  3156. end
  3157.  
  3158. local path_name = p[2]
  3159. if path_name == nil then
  3160. printf("Wrong path_name for 'spawn_corpse' function %s. For object %s", tostring(path_name), obj:name())
  3161. end
  3162.  
  3163. if not level.patrol_path_exists(path_name) then
  3164. printf("Path %s doesnt exist. Function 'spawn_corpse' for object %s ", tostring(path_name), obj:name())
  3165. end
  3166. local ptr = patrol(path_name)
  3167. local index = p[3] or 0
  3168.  
  3169. local se_obj = alife_create(spawn_sect,ptr:point(index),ptr:level_vertex_id(0),ptr:game_vertex_id(0))
  3170. if (se_obj) then
  3171. se_obj:kill()
  3172. end
  3173. end
  3174.  
  3175.  
  3176. function spawn_object_in(actor, obj, p)
  3177. --' p[1] - секция кого спаунить
  3178. --' p[2] - стори айди обьекта в который спавнить
  3179. local spawn_sect = p[1]
  3180. if spawn_sect == nil then
  3181. printf("Wrong spawn section for 'spawn_object' function %s. For object %s", tostring(spawn_sect), obj:name())
  3182. end
  3183. if p[2] == nil then
  3184. printf("Wrong target_name for 'spawn_object_in' function %s. For object %s", tostring(target_name), obj:name())
  3185. end
  3186. -- local box = alife_object(target_name)
  3187. -- if(box==nil) then
  3188.  
  3189. printf("xr_effects.spawn_object_in trying to find object %s", tostring(p[2]))
  3190.  
  3191. local target_obj_id = get_story_object_id(p[2])
  3192. if target_obj_id ~= nil then
  3193. box = alife_object(target_obj_id)
  3194. if box == nil then
  3195. printf("xr_effects.spawn_object_in There is no such object %s", p[2])
  3196. end
  3197. alife_create(spawn_sect, box.position, box.m_level_vertex_id, box.m_game_vertex_id, target_obj_id)
  3198. else
  3199. printf("xr_effects.spawn_object_in object is nil %s", tostring(p[2]))
  3200. end
  3201. end
  3202.  
  3203.  
  3204. function spawn_npc_in_zone(actor, obj, p)
  3205. --' p[1] - секция кого спаунить
  3206. --' p[2] - имя зоны в которой спаунить.
  3207. local spawn_sect = p[1]
  3208. if spawn_sect == nil then
  3209. printf("Wrong spawn section for 'spawn_object' function %s. For object %s", tostring(spawn_sect), obj:name())
  3210. end
  3211. local zone_name = p[2]
  3212. if zone_name == nil then
  3213. printf("Wrong zone_name for 'spawn_object' function %s. For object %s", tostring(zone_name), obj:name())
  3214. end
  3215. if db.zone_by_name[zone_name] == nil then
  3216. printf("Zone %s doesnt exist. Function 'spawn_object' for object %s ", tostring(zone_name), obj:name())
  3217. end
  3218. local zone = db.zone_by_name[zone_name]
  3219. -- printf("spawn_npc_in_zone: spawning %s at zone %s, squad %s", tostring(p[1]), tostring(p[2]), tostring(p[3]))
  3220. local spawned_obj = alife_create( spawn_sect,
  3221. zone:position(),
  3222. zone:level_vertex_id(),
  3223. zone:game_vertex_id())
  3224. spawned_obj.sim_forced_online = true
  3225. spawned_obj.squad = 1 or p[3]
  3226. db.script_ids[spawned_obj.id] = zone_name
  3227. end
  3228.  
  3229. function destroy_object(actor, obj, p)
  3230. local sobj
  3231. if (p == nil or p[1] == nil) then
  3232. sobj = alife_object(obj:id())
  3233. elseif (p[1] == "story" and p[2] ~= nil) then
  3234. local id = get_story_object_id(p[2])
  3235. if not (id) then
  3236. printf("destroy_object %s story id doesn't exist!",p[2])
  3237. end
  3238. sobj = id and alife_object(id)
  3239. end
  3240.  
  3241. if not (sobj) then
  3242. return
  3243. end
  3244.  
  3245. -- TODO: check this
  3246. local cls = sobj:clsid()
  3247. if (cls == clsid.online_offline_group_s or IsStalker(nil,cls) or IsMonster(nil,cls)) then
  3248. safe_release_manager.release(sobj)
  3249. else
  3250. alife_release(sobj)
  3251. end
  3252. end
  3253.  
  3254. function give_actor(actor, npc, p)
  3255. for k,v in pairs(p) do
  3256. alife_create(v,
  3257. db.actor:position(),
  3258. db.actor:level_vertex_id(),
  3259. db.actor:game_vertex_id(),
  3260. AC_ID)
  3261. news_manager.relocate_item(db.actor, "in", v)
  3262. end
  3263. end
  3264.  
  3265. function activate_weapon_slot(actor, npc, p)
  3266. db.actor:activate_slot(p[1])
  3267. end
  3268.  
  3269. function anim_obj_forward(actor, npc, p)
  3270. for k,v in pairs(p) do
  3271. if v ~= nil then
  3272. db.anim_obj_by_name[v]:anim_forward()
  3273. end
  3274. end
  3275. end
  3276. function anim_obj_backward(actor, npc, p)
  3277. if p[1] ~= nil then
  3278. db.anim_obj_by_name[p[1]]:anim_backward()
  3279. end
  3280. end
  3281. function anim_obj_stop(actor, npc, p)
  3282. if p[1] ~= nil then
  3283. db.anim_obj_by_name[p[1]]:anim_stop()
  3284. end
  3285. end
  3286.  
  3287. -- Функции для работы с огненными зонами.
  3288. --[[
  3289. function turn_on_fire_zone(actor, npc, p)
  3290. bind_campfire.fire_zones_table[ p[1] ]:turn_on()
  3291. end
  3292.  
  3293. function turn_off_fire_zone(actor, npc, p)
  3294. bind_campfire.fire_zones_table[ p[1] ]:turn_off()
  3295. end
  3296. ]]--
  3297. --'-----------------------------------------------------------------------------------
  3298. --' Функции для отыгрывания звука
  3299. --'-----------------------------------------------------------------------------------
  3300. function play_sound_on_actor(actor,obj,p)
  3301. local snd = sound_object(p[1])
  3302.  
  3303. if (snd) then
  3304. --snd:play_at_pos(db.actor,db.actor:position(),0,sound_object.s3d)
  3305. snd:play(db.actor, 0, sound_object.s2d)
  3306. end
  3307. end
  3308.  
  3309. function play_sound(actor, obj, p)
  3310. local theme = p[1]
  3311. local faction = p[2]
  3312. local point
  3313. if (p[3]) then
  3314. local smart = SIMBOARD.smarts_by_names[p[3]]
  3315. if (smart) then
  3316. point = smart.id
  3317. else
  3318. point = p[3]
  3319. end
  3320. end
  3321.  
  3322. if obj and IsStalker(obj) then
  3323. if not obj:alive() then
  3324. printf("Stalker [%s][%s] is dead, but you wants to say something for you: [%s]!", tostring(obj:id()), tostring(obj:name()), p[1])
  3325. end
  3326. end
  3327.  
  3328. xr_sound.set_sound_play(obj:id(), theme, faction, point)
  3329. end
  3330.  
  3331. function play_sound_by_story(actor, obj, p)
  3332. local story_obj = get_story_object_id(p[1])
  3333. local theme = p[2]
  3334. local faction = p[3]
  3335. local point = SIMBOARD.smarts_by_names[p[4]]
  3336. if point ~= nil then
  3337. point = point.id
  3338. elseif p[4]~=nil then
  3339. point = p[4]
  3340. end
  3341. xr_sound.set_sound_play(story_obj, theme, faction, point)
  3342. end
  3343.  
  3344. function stop_sound(actor, npc)
  3345. xr_sound.stop_sounds_by_id(npc:id())
  3346. end
  3347.  
  3348. function play_sound_looped(actor, obj, p)
  3349. local theme = p[1]
  3350. xr_sound.play_sound_looped(obj:id(), theme)
  3351. end
  3352.  
  3353. function stop_sound_looped(actor, obj)
  3354. xr_sound.stop_sound_looped(obj:id())
  3355. end
  3356.  
  3357. function barrel_explode (actor , npc , p)
  3358. local expl_obj = get_story_object (p[1])
  3359. if expl_obj ~= nil then
  3360. expl_obj:explode(0)
  3361. end
  3362. end
  3363.  
  3364. --com
  3365. function play_inv_repair_kit_use_fast_2p8()
  3366. xr_sound.set_sound_play(AC_ID,"inv_repair_kit_use_fast_2p8")
  3367. end
  3368.  
  3369. function play_inv_repair_kit_use_fast()
  3370. xr_sound.set_sound_play(AC_ID,"inv_repair_kit_use_fast")
  3371. end
  3372.  
  3373. function play_inv_repair_kit_with_brushes()
  3374. xr_sound.set_sound_play(AC_ID,"inv_repair_kit_with_brushes")
  3375. end
  3376.  
  3377. function play_inv_repair_sewing_kit()
  3378. xr_sound.set_sound_play(AC_ID,"inv_repair_sewing_kit")
  3379. end
  3380.  
  3381. function play_inv_repair_sewing_kit_fast()
  3382. xr_sound.set_sound_play(AC_ID,"inv_repair_sewing_kit_fast")
  3383. end
  3384.  
  3385. function play_inv_repair_spray_oil()
  3386. xr_sound.set_sound_play(AC_ID,"inv_repair_spray_oil")
  3387. end
  3388.  
  3389. function play_inv_repair_brushes()
  3390. xr_sound.set_sound_play(AC_ID,"inv_repair_brushes")
  3391. end
  3392.  
  3393. function play_inv_repair_kit()
  3394. xr_sound.set_sound_play(AC_ID,"inv_repair_kit")
  3395. end
  3396.  
  3397. function play_inv_drink_flask_2()
  3398. xr_sound.set_sound_play(AC_ID,"inv_drink_flask_2")
  3399. end
  3400.  
  3401. function play_inv_cooking()
  3402. xr_sound.set_sound_play(AC_ID,"inv_cooking")
  3403. end
  3404.  
  3405. function play_inv_cooking_cooker()
  3406. xr_sound.set_sound_play(AC_ID,"inv_cooking_cooker")
  3407. end
  3408.  
  3409. function play_inv_cooking_stove()
  3410. xr_sound.set_sound_play(AC_ID,"inv_cooking_stove")
  3411. end
  3412.  
  3413. function play_inv_aam_open()
  3414. xr_sound.set_sound_play(AC_ID,"inv_aam_open")
  3415. end
  3416.  
  3417. function play_inv_aam_close()
  3418. xr_sound.set_sound_play(AC_ID,"inv_aam_close")
  3419. end
  3420.  
  3421. function play_inv_aac_open()
  3422. xr_sound.set_sound_play(AC_ID,"inv_aac_open")
  3423. end
  3424.  
  3425. function play_inv_aac_close()
  3426. xr_sound.set_sound_play(AC_ID,"inv_aac_close")
  3427. end
  3428.  
  3429. function play_inv_iam_open()
  3430. xr_sound.set_sound_play(AC_ID,"inv_iam_open")
  3431. end
  3432.  
  3433. function play_inv_iam_close()
  3434. xr_sound.set_sound_play(AC_ID,"inv_iam_close")
  3435. end
  3436.  
  3437. function play_inv_lead_open()
  3438. xr_sound.set_sound_play(AC_ID,"inv_lead_open")
  3439. end
  3440.  
  3441. function play_inv_lead_close()
  3442. xr_sound.set_sound_play(AC_ID,"inv_lead_close")
  3443. end
  3444.  
  3445. function play_inv_batteries_switch()
  3446. xr_sound.set_sound_play(AC_ID,"inv_batt")
  3447. end
  3448.  
  3449. function play_inv_mask_clean()
  3450. xr_sound.set_sound_play(AC_ID,"inv_mask_clean")
  3451. end
  3452.  
  3453. function play_inv_drop()
  3454. xr_sound.set_sound_play(AC_ID,"inv_drop")
  3455. end
  3456.  
  3457. function play_inv_drop()
  3458. xr_sound.set_sound_play(AC_ID,"inv_drop")
  3459. end
  3460.  
  3461. function play_inv_empty()
  3462. xr_sound.set_sound_play(AC_ID,"inv_empty")
  3463. end
  3464.  
  3465. function play_inv_smoke_bag_open()
  3466. xr_sound.set_sound_play(AC_ID,"inv_smoke_bag_open")
  3467. end
  3468.  
  3469. function play_inv_eat_can_imm()
  3470. xr_sound.set_sound_play(AC_ID,"inv_eat_can_imm")
  3471. end
  3472.  
  3473. function play_inv_open()
  3474. xr_sound.set_sound_play(AC_ID,"inv_open")
  3475. end
  3476.  
  3477. function play_inv_briefcase_light_open()
  3478. xr_sound.set_sound_play(AC_ID,"inv_briefcase_light_open")
  3479. end
  3480.  
  3481. function play_inv_disassemble_metal_fast()
  3482. xr_sound.set_sound_play(AC_ID,"inv_disassemble_metal_fast")
  3483. end
  3484.  
  3485. function play_inv_disassemble_cloth_fast()
  3486. xr_sound.set_sound_play(AC_ID,"inv_disassemble_cloth_fast")
  3487. end
  3488.  
  3489. function play_inv_tear_patch()
  3490. xr_sound.set_sound_play(AC_ID,"inv_tear_patch")
  3491. end
  3492.  
  3493.  
  3494. --'-----------------------------------------------------------------------------------
  3495. --' Alife support
  3496. --'-----------------------------------------------------------------------------------
  3497. --[[
  3498. function start_sim(actor, obj)
  3499. SIMBOARD:start_sim()
  3500. end
  3501.  
  3502. function stop_sim(actor, obj)
  3503. SIMBOARD:stop_sim()
  3504. end
  3505.  
  3506. function update_faction_brain(actor, obj, p)
  3507. if p[1] == nil then
  3508. printf("Wrong parameters update_faction_brain")
  3509. end
  3510. local board = SIMBOARD
  3511. local player = board.players[ p[1] ]
  3512. if player == nil then
  3513. printf("Can't find player %s", tostring(p[1]))
  3514. end
  3515. player:faction_brain_update()
  3516. end
  3517. ]]--
  3518.  
  3519. function create_squad(actor, obj, p)
  3520.  
  3521. local squad_id = p[1]
  3522. if squad_id == nil then
  3523. printf("Wrong squad identificator [NIL] in create_squad function")
  3524. return
  3525. end
  3526. local smart_name = p[2]
  3527. if smart_name == nil then
  3528. printf("Wrong smart name [NIL] in create_squad function")
  3529. return
  3530. end
  3531.  
  3532. if not ini_sys:section_exist(squad_id) then
  3533. printf("Wrong squad identificator [%s]. Squad descr doesnt exist.", tostring(squad_id))
  3534. end
  3535.  
  3536. local board = SIMBOARD
  3537. local smart = board.smarts_by_names[smart_name]
  3538. if smart == nil then
  3539. printf("Wrong smart_name [%s] for [%s] faction in create_squad function", tostring(smart_name), tostring(player_name))
  3540. end
  3541.  
  3542. --printf("Create squad %s BEFORE",squad_id)
  3543. local squad = board:create_squad(smart, squad_id)
  3544. if not (squad) then
  3545. return
  3546. end
  3547. --printf("Create squad %s AFTER",squad_id)
  3548.  
  3549. --board:enter_smart(squad, smart.id)
  3550.  
  3551. local sim = alife()
  3552. for k in squad:squad_members() do
  3553. local se_obj = k.object or k.id and sim:object(k.id)
  3554. if (se_obj) then
  3555. board:setup_squad_and_group(se_obj)
  3556. end
  3557. end
  3558.  
  3559. --squad:update()
  3560. end
  3561.  
  3562. function create_squad_member(actor, obj, p)
  3563. local squad_member_sect = p[1]
  3564. local story_id = p[2]
  3565. local position = nil
  3566. local level_vertex_id = nil
  3567. local game_vertex_id = nil
  3568. if story_id == nil then
  3569. printf("Wrong squad identificator [NIL] in 'create_squad_member' function")
  3570. end
  3571. local board = SIMBOARD
  3572. local squad = get_story_squad(story_id)
  3573. if not (squad) then
  3574. return
  3575. end
  3576.  
  3577. local squad_smart = squad.smart_id and board.smarts[squad.smart_id].smrt
  3578. if not (squad_smart) then
  3579. return
  3580. end
  3581.  
  3582. if p[3] ~= nil then
  3583. local spawn_point
  3584. if p[3] == "simulation_point" then
  3585. spawn_point = ini_sys:r_string_ex(squad:section_name(),"spawn_point")
  3586. if spawn_point == "" or spawn_point == nil then
  3587. spawn_point = xr_logic.parse_condlist(obj, "spawn_point", "spawn_point", squad_smart.spawn_point)
  3588. else
  3589. spawn_point = xr_logic.parse_condlist(obj, "spawn_point", "spawn_point", spawn_point)
  3590. end
  3591. spawn_point = xr_logic.pick_section_from_condlist(db.actor, obj, spawn_point)
  3592. else
  3593. spawn_point = p[3]
  3594. end
  3595. position = patrol(spawn_point):point(0)
  3596. level_vertex_id = patrol(spawn_point):level_vertex_id(0)
  3597. game_vertex_id = patrol(spawn_point):game_vertex_id(0)
  3598. else
  3599. local commander = alife_object(squad:commander_id())
  3600. position = commander.position
  3601. level_vertex_id = commander.m_level_vertex_id
  3602. game_vertex_id = commander.m_game_vertex_id
  3603. end
  3604. local new_member_id = squad:add_squad_member(squad_member_sect, position, level_vertex_id, game_vertex_id)
  3605.  
  3606. local se_obj = new_member_id and alife_object(new_member_id)
  3607. if (se_obj) then
  3608. squad_smart:register_npc(se_obj)
  3609. board:setup_squad_and_group(se_obj)
  3610. end
  3611.  
  3612. --board:setup_squad_and_group(alife_object(new_member_id))
  3613. --squad_smart:refresh()
  3614. squad:update()
  3615. end
  3616.  
  3617. function remove_squad(actor, obj, p)
  3618. local story_id = p[1]
  3619. if story_id == nil then
  3620. printf("Wrong squad identificator [NIL] in remove_squad function")
  3621. end
  3622. local squad = get_story_squad(story_id)
  3623. if squad == nil then
  3624. assert("Wrong squad identificator [%s]. squad doesnt exist", tostring(story_id))
  3625. return
  3626. end
  3627. SIMBOARD:remove_squad(squad)
  3628. end
  3629.  
  3630. function kill_squad(actor, obj, p)
  3631. local story_id = p[1]
  3632. if story_id == nil then
  3633. printf("Wrong squad identificator [NIL] in kill_squad function")
  3634. end
  3635. local squad = get_story_squad(story_id)
  3636. if squad == nil then
  3637. return
  3638. end
  3639. local squad_npcs = {}
  3640. for k in squad:squad_members() do
  3641. squad_npcs[k.id] = true
  3642. end
  3643.  
  3644. for k,v in pairs(squad_npcs) do
  3645. local cl_obj = db.storage[k] and db.storage[k].object
  3646. if cl_obj == nil then
  3647. alife_object(tonumber(k)):kill()
  3648. else
  3649. cl_obj:kill(cl_obj)
  3650. end
  3651. end
  3652. end
  3653.  
  3654. function heal_squad(actor, obj, p)
  3655. local story_id = p[1]
  3656. local health_mod = 1
  3657. if p[2] and p[2] ~= nil then
  3658. health_mod = math.ceil(p[2]/100)
  3659. end
  3660. if story_id == nil then
  3661. printf("Wrong squad identificator [NIL] in heal_squad function")
  3662. end
  3663. local squad = get_story_squad(story_id)
  3664. if squad == nil then
  3665. return
  3666. end
  3667. for k in squad:squad_members() do
  3668. local cl_obj = db.storage[k.id] and db.storage[k.id].object
  3669. if cl_obj ~= nil then
  3670. cl_obj:change_health(health_mod)
  3671. end
  3672. end
  3673. end
  3674.  
  3675. --[[
  3676. function update_squad(actor, obj, p)
  3677. local squad_id = p[1]
  3678. if squad_id == nil then
  3679. printf("Wrong squad identificator [NIL] in remove_squad function")
  3680. end
  3681. local board = SIMBOARD
  3682. local squad = board.squads[squad_id]
  3683. if squad == nil then
  3684. assert("Wrong squad identificator [%s]. squad doesnt exist", tostring(squad_id))
  3685. return
  3686. end
  3687. squad:update()
  3688. end
  3689. ]]--
  3690.  
  3691. -- this deletes squads from a smart
  3692. function clear_smart_terrain(actor, obj, p)
  3693. local smart_name = p[1]
  3694. if smart_name == nil then
  3695. printf("Wrong squad identificator [NIL] in clear_smart_terrain function")
  3696. end
  3697.  
  3698. local board = SIMBOARD
  3699. local smart = board.smarts_by_names[smart_name]
  3700. local smart_id = smart.id
  3701. for k,v in pairs(board.smarts[smart_id].squads) do
  3702. local squad = alife_object(k)
  3703. if (squad) then
  3704. if p[2] and p[2] == "true" then
  3705. board:remove_squad(squad)
  3706. else
  3707. if not get_object_story_id(squad.id) then
  3708. board:remove_squad(squad)
  3709. end
  3710. end
  3711. end
  3712. end
  3713. end
  3714.  
  3715. -- This forces squads to leave a smart
  3716. function flush_smart_terrain(actor,obj,p)
  3717. local smart_name = p[1]
  3718. if smart_name == nil then
  3719. printf("Wrong squad identificator [NIL] in clear_smart_terrain function")
  3720. return
  3721. end
  3722.  
  3723. local function unregister(squad)
  3724. squad.assigned_target_id = nil
  3725. squad.current_target_id = nil
  3726. squad.current_action = nil
  3727. squad.was_forced_offline = true
  3728. SIMBOARD:assign_squad_to_smart(squad, nil)
  3729. for k in squad:squad_members() do
  3730. local se_obj = alife_object(k.id)
  3731. if (se_obj) then
  3732. local smart_id = se_obj.m_smart_terrain_id
  3733. if (smart_id and smart_id ~= 65535) then
  3734. local smart = alife_object(smart_id)
  3735. if (smart) then
  3736. smart:unregister_npc(se_obj)
  3737. end
  3738. end
  3739. end
  3740. end
  3741. end
  3742.  
  3743. local smart = SIMBOARD.smarts_by_names[smart_name]
  3744. local smart_id = smart.id
  3745. for k,v in pairs(SIMBOARD.smarts[smart_id].squads) do
  3746. local squad = alife_object(k)
  3747. if (squad) then
  3748. if p[2] and p[2] == "true" then
  3749. unregister(squad)
  3750. else
  3751. if not get_object_story_id(k) then
  3752. unregister(squad)
  3753. end
  3754. end
  3755. end
  3756. end
  3757. end
  3758.  
  3759.  
  3760. --[[
  3761. function set_actor_faction(actor, obj, p)
  3762. if p[1] == nil then
  3763. printf("Wrong parameters")
  3764. end
  3765. SIMBOARD:set_actor_community(p[1])
  3766. end
  3767. ]]--
  3768. --'-----------------------------------------------------------------------------------
  3769. --' Quest support
  3770. --'-----------------------------------------------------------------------------------
  3771. -- TODO: add param 2 for story_id which can be used to get the npc's squad id or object id for task_giver_id
  3772. function give_task(actor, obj, p)
  3773. if p[1] == nil then
  3774. printf("No parameter in give_task function.")
  3775. end
  3776. task_manager.get_task_manager():give_task(p[1])
  3777. end
  3778.  
  3779. function set_active_task(actor, npc, p)
  3780. if(p[1]) then
  3781. local t = db.actor:get_task(tostring(p[1]), true)
  3782. if(t) then
  3783. db.actor:set_active_task(t)
  3784. end
  3785. end
  3786. end
  3787.  
  3788. function set_task_completed(actor,npc,p)
  3789. if (p[1]) then
  3790. task_manager.get_task_manager():set_task_completed(p[1])
  3791. end
  3792. end
  3793.  
  3794. function set_task_failed(actor,npc,p)
  3795. if (p[1]) then
  3796. task_manager.get_task_manager():set_task_failed(p[1])
  3797. end
  3798. end
  3799.  
  3800. -- Функции для работы с отношениями
  3801.  
  3802. function actor_friend(actor, npc)
  3803. printf("_bp: xr_effects: actor_friend(): npc='%s': time=%d", npc:name(), time_global())
  3804. npc:force_set_goodwill( 1000, actor)
  3805. end
  3806.  
  3807. function actor_neutral(actor, npc)
  3808. npc:force_set_goodwill( 0, actor)
  3809. end
  3810.  
  3811. function actor_enemy(actor, npc)
  3812. npc:force_set_goodwill( -1000, actor)
  3813. end
  3814.  
  3815. function set_speaker_as_enemy(actor, npc)
  3816. npc:force_set_goodwill( -5000, actor)
  3817. end
  3818.  
  3819. function set_squad_neutral_to_actor(actor, npc, p)
  3820. local story_id = p[1]
  3821. local squad = get_story_squad(story_id)
  3822. if squad == nil then
  3823. printf("There is no squad with id[%s]", tostring(story_id))
  3824. return
  3825. end
  3826. squad:set_squad_relation("neutral")
  3827. end
  3828.  
  3829. function set_squad_friend_to_actor(actor, npc, p)
  3830. local story_id = p[1]
  3831. local squad = get_story_squad(story_id)
  3832. if squad == nil then
  3833. printf("There is no squad with id[%s]", tostring(story_id))
  3834. return
  3835. end
  3836. squad:set_squad_relation("friend")
  3837. end
  3838.  
  3839. --Сделать актера врагом к отряду, передается имя отряда
  3840. function set_squad_enemy_to_actor( actor, npc, p)
  3841. local story_id = p[1]
  3842. local squad = get_story_squad(story_id)
  3843. if squad == nil then
  3844. printf("There is no squad with id[%s]", tostring(story_id))
  3845. return
  3846. end
  3847. squad:set_squad_relation("enemy")
  3848. end
  3849.  
  3850. --[[
  3851. function set_friends(actor, npc, p)
  3852. local npc1
  3853. for i, v in pairs(p) do
  3854. npc1 = get_story_object(v)
  3855. if npc1 and npc1:alive() then
  3856. --printf("_bp: %d:set_friends(%d)", npc:id(), npc1:id())
  3857. npc:set_relation(game_object.friend, npc1)
  3858. npc1:set_relation(game_object.friend, npc)
  3859. end
  3860. end
  3861. end
  3862.  
  3863. function set_enemies(actor, npc, p)
  3864. local npc1
  3865. for i, v in pairs(p) do
  3866. --printf("_bp: set_enemies(%d)", v)
  3867. npc1 = get_story_object(v)
  3868. if npc1 and npc1:alive() then
  3869. npc:set_relation(game_object.enemy, npc1)
  3870. npc1:set_relation(game_object.enemy, npc)
  3871. end
  3872. end
  3873. end
  3874.  
  3875. function set_gulag_relation_actor(actor, npc, p)
  3876. if(p[1]) and (p[2]) then
  3877. game_relations.set_gulag_relation_actor(p[1], p[2])
  3878. end
  3879. end
  3880.  
  3881. function set_factions_community(actor, npc, p)
  3882. if(p[1]~=nil) and (p[2]~=nil) and (p[3]~=nil) then
  3883. game_relations.set_factions_community(p[1], p[2], p[3])
  3884. end
  3885. end
  3886.  
  3887. function set_squad_community_goodwill(actor, npc, p)
  3888. if(p[1]~=nil) and (p[2]~=nil) and (p[3]~=nil) then
  3889. game_relations.set_squad_community_goodwill(p[1], p[2], p[3])
  3890. end
  3891. end
  3892. ]]--
  3893.  
  3894. --sets NPC relation to actor
  3895. --set_npc_sympathy(number)
  3896. --call only from npc`s logic
  3897. function set_npc_sympathy(actor, npc, p)
  3898. if(p[1]~=nil) then
  3899. game_relations.set_npc_sympathy(npc, p[1])
  3900. end
  3901. end
  3902.  
  3903. --sets SQUAD relation to actor
  3904. --set_squad_goodwill(faction:number)
  3905. function set_squad_goodwill(actor, npc, p)
  3906. if(p[1]~=nil) and (p[2]~=nil) then
  3907. game_relations.set_squad_goodwill(p[1], p[2])
  3908. end
  3909. end
  3910.  
  3911. function set_squad_goodwill_to_npc(actor, npc, p)
  3912. if(p[1]~=nil) and (p[2]~=nil) then
  3913. game_relations.set_squad_goodwill_to_npc(npc, p[1], p[2])
  3914. end
  3915. end
  3916.  
  3917. function inc_faction_goodwill_to_actor(actor, npc, p)
  3918. local id = actor:id()
  3919. local community = p[1]
  3920. local delta = p[2]
  3921. if delta and community then
  3922. game_relations.change_factions_community_num(community, id, tonumber(delta))
  3923. printdbg("/ Goodwill (main) gained with %s: %s", community, delta)
  3924. else
  3925. printe("!Wrong parameters in function 'inc_faction_goodwill_to_actor'")
  3926. return
  3927. end
  3928. delta = tonumber(delta)
  3929.  
  3930. local is_gain = ((delta) > 0) and true or false
  3931. local delta_b = math.abs(delta)
  3932. local delta_b2 = math.ceil(delta_b * 0.5)
  3933. local delta_b3 = math.ceil(delta_b * 0.8)
  3934. local delta_rnd = ((delta_b) > 1) and math.random(delta_b2,delta_b3) or delta_b
  3935. local delta_rnd_sub = delta_b - delta_rnd
  3936.  
  3937. local pass_natural, pass_enemy
  3938. local rnd_enemy = game_relations.get_random_enemy_faction(community)
  3939. local rnd_natural = game_relations.get_random_natural_faction(community)
  3940.  
  3941. if is_gain and delta_rnd and delta_rnd_sub then
  3942. if rnd_enemy and (delta_rnd > 0) and (relation_registry.community_goodwill(rnd_enemy, id) > 0) then
  3943. game_relations.change_factions_community_num(rnd_enemy, id, ((-1) * delta_rnd ) )
  3944. pass_enemy = true
  3945. printdbg("/ Goodwill (side) lost with %s: %s", rnd_enemy, ((-1) * delta_rnd ))
  3946. end
  3947. if rnd_natural and (delta_rnd_sub > 0) and (relation_registry.community_goodwill(rnd_natural, id) > 0) then
  3948. game_relations.change_factions_community_num(rnd_natural, id, (delta_rnd_sub ) )
  3949. pass_natural = true
  3950. printdbg("/ Goodwill (side) gained with %s: %s", rnd_natural, (delta_rnd_sub ))
  3951. end
  3952. end
  3953.  
  3954.  
  3955. if community and p[3] then
  3956. dialogs_mlr.show_goodwill_change_message( community, (pass_natural and rnd_natural or nil), (pass_enemy and rnd_enemy or nil), is_gain )
  3957. end
  3958. end
  3959.  
  3960. function dec_faction_goodwill_to_actor(actor, npc, p)
  3961. local community = p[1]
  3962. local delta = p[2]
  3963. if delta and community then
  3964. game_relations.change_factions_community_num(community,actor:id(), -tonumber(delta))
  3965. else
  3966. printf("Wrong parameters in function 'dec_faction_goodwill_to_actor'")
  3967. end
  3968. end
  3969.  
  3970.  
  3971. --[[
  3972. function add_custom_static(actor, npc, p)
  3973. if p[1] ~= nil and p[2] ~= nil then
  3974. get_hud():AddCustomStatic(p[1], true)
  3975. get_hud():GetCustomStatic(p[1]):wnd():SetTextST(p[2])
  3976. else
  3977. printf("Invalid parameters in function add_custom_static!!!")
  3978. end
  3979. end
  3980.  
  3981. function remove_custom_static(actor, npc, p)
  3982. if p[1] ~= nil then
  3983. get_hud():RemoveCustomStatic(p[1])
  3984. else
  3985. printf("Invalid parameters in function remove_custom_static!!!")
  3986. end
  3987. end
  3988. ]]--
  3989.  
  3990. function kill_actor(actor, npc)
  3991. db.actor:kill(db.actor)
  3992. end
  3993.  
  3994. -----------------------------------------------------------------------
  3995. -- Treasures support
  3996. -----------------------------------------------------------------------
  3997. function give_treasure (actor, npc, p)
  3998.  
  3999. end
  4000.  
  4001. --[[
  4002. function change_tsg(actor, npc, p)
  4003. npc:change_team(p[1], p[2], p[3])
  4004. end
  4005.  
  4006. function exit_game(actor, npc)
  4007. exec_console_cmd("quit")
  4008. end
  4009. ]]--
  4010.  
  4011. function start_surge(actor, npc, p)
  4012. surge_manager.start_surge(p)
  4013. end
  4014.  
  4015. function stop_surge(actor, npc, p)
  4016. surge_manager.stop_surge()
  4017. end
  4018.  
  4019. function set_surge_mess_and_task(actor, npc, p)
  4020. if(p) then
  4021. surge_manager.set_surge_message(p[1])
  4022. if(p[2]) then
  4023. surge_manager.set_surge_task(p[2])
  4024. end
  4025. end
  4026. end
  4027.  
  4028. --[[
  4029. function enable_level_changer(actor, npc, p)
  4030. if(p[1]~=nil) then
  4031. local obj = get_story_object(p[1])
  4032. if(obj) then
  4033. if db.storage[obj:id()] and db.storage[obj:id()].s_obj then
  4034. db.storage[obj:id()].s_obj.enabled = true
  4035. db.storage[obj:id()].s_obj.hint = "level_changer_invitation"
  4036. else
  4037. return
  4038. end
  4039. obj:enable_level_changer(true)
  4040. level_tasks.add_lchanger_location()
  4041. obj:set_level_changer_invitation("level_changer_invitation")
  4042. end
  4043. end
  4044. end
  4045.  
  4046. function disable_level_changer(actor, npc, p)
  4047. if(p[1]~=nil) then
  4048. local obj = get_story_object(p[1])
  4049. if(obj) then
  4050. if not(db.storage[obj:id()] and db.storage[obj:id()].s_obj) then
  4051. return
  4052. end
  4053. obj:enable_level_changer(false)
  4054. level_tasks.del_lchanger_mapspot(tonumber(p[1]))
  4055. db.storage[obj:id()].s_obj.enabled = false
  4056. if(p[2]==nil) then
  4057. obj:set_level_changer_invitation("level_changer_disabled")
  4058. db.storage[obj:id()].s_obj.hint = "level_changer_disabled"
  4059. else
  4060. obj:set_level_changer_invitation(p[2])
  4061. db.storage[obj:id()].s_obj.hint = p[2]
  4062. end
  4063. end
  4064. end
  4065. end
  4066.  
  4067. function change_actor_community(actor, npc, p)
  4068. if(p[1]~=nil) then
  4069. set_actor_true_community(p[1])
  4070. end
  4071. end
  4072.  
  4073. function set_faction_community_to_actor(actor, npc, p)
  4074. -- run_string xr_effects.change_actor_community(nil,nil,{"actor_dolg"})
  4075. if(p[1]~=nil) and (p[2]~=nil) then
  4076. local rel = 0
  4077. if(p[2]=="enemy") then
  4078. rel = -3000
  4079. elseif(p[2]=="friend") then
  4080. rel = 1000
  4081. end
  4082. db.actor:set_community_goodwill(p[1], rel)
  4083. end
  4084. end
  4085.  
  4086. function disable_collision(actor, npc)
  4087. npc:wounded(true)
  4088. end
  4089. function enable_collision(actor, npc)
  4090. npc:wounded(false)
  4091. end
  4092.  
  4093. function disable_actor_collision(actor, npc)
  4094. actor:wounded(true)
  4095. end
  4096. function enable_actor_collision(actor, npc)
  4097. actor:wounded(false)
  4098. end
  4099.  
  4100. function relocate_actor_inventory_to_box(actor, npc, p)
  4101. local function transfer_object_item(item)
  4102. if item:section() ~= "wpn_binoc" and item:section() ~= "wpn_knife" and item:section() ~= "device_torch" then
  4103. db.actor:transfer_item(item, inv_box_1)
  4104. end
  4105. end
  4106. inv_box_1 = get_story_object (p[1])
  4107. actor:inventory_for_each(transfer_object_item)
  4108. end
  4109. ]]--
  4110.  
  4111. function make_actor_visible_to_squad(actor,npc,p)
  4112. local story_id = p and p[1]
  4113. local squad = get_story_squad(story_id)
  4114. if squad == nil then printf("There is no squad with id[%s]", story_id) end
  4115. for k in squad:squad_members() do
  4116. local obj = level.object_by_id(k.id)
  4117. if obj ~= nil then
  4118. obj:make_object_visible_somewhen( db.actor )
  4119. end
  4120. end
  4121. end
  4122.  
  4123. function pstor_set(actor,npc,p)
  4124. p[2] = tonumber(p[2])
  4125. if (p[1] and p[2]) then
  4126. save_var(db.actor,p[1],p[2])
  4127. end
  4128. end
  4129.  
  4130. function pstor_reset(actor,npc,p)
  4131. if (p[1]) then
  4132. save_var(db.actor,p[1],nil)
  4133. end
  4134. end
  4135.  
  4136. function stop_sr_cutscene(actor,npc,p)
  4137. local obj = db.storage[npc:id()]
  4138. if(obj.active_scheme~=nil) then
  4139. obj[obj.active_scheme].signals["cam_effector_stop"] = true
  4140. end
  4141. end
  4142.  
  4143. --[[
  4144. function reset_dialog_end_signal(actor, npc, p)
  4145. local st = db.storage[npc:id()]
  4146. if(st.active_scheme==nil) then
  4147. return
  4148. end
  4149. if(st[st.active_scheme].signals==nil) then
  4150. return
  4151. end
  4152. st[st.active_scheme].signals["dialog_end"] = nil
  4153. end
  4154.  
  4155. function add_map_spot(actor, npc, p)
  4156. if(p[1]==nil) then
  4157. printf("Story id for add map spot function is not set")
  4158. else
  4159. local story_id = tonumber(p[1])
  4160. local id = id_by_sid(story_id)
  4161. if(id==nil) then
  4162. local obj = alife_object(p[1])
  4163. id = obj and obj.id
  4164. end
  4165. if(id~=nil) then
  4166. if(p[2]==nil) then
  4167. p[2] = "primary_task_location"
  4168. end
  4169. if(p[3]==nil) then
  4170. p[3] = "default"
  4171. end
  4172. if level.map_has_object_spot(id, p[2]) == 0 then
  4173. level.map_add_object_spot_ser(id, p[2], p[3])
  4174. end
  4175. else
  4176. printf("Wrong story id or name [%s] for map spot function", tostring(story_id))
  4177. end
  4178. end
  4179. end
  4180.  
  4181. function remove_map_spot(actor, npc, p)
  4182. if(p[1]==nil) then
  4183. printf("Story id for add map spot function is not set")
  4184. else
  4185. local story_id = tonumber(p[1])
  4186. local id = id_by_sid(story_id)
  4187. if(id==nil) then
  4188. local obj = alife_object(p[1])
  4189. id = obj and obj.id
  4190. end
  4191. if(id~=nil) then
  4192. if(p[2]==nil) then
  4193. p[2] = "primary_task_location"
  4194. end
  4195. if level.map_has_object_spot(id, p[2]) ~= 0 then
  4196. level.map_remove_object_spot(id, p[2])
  4197. end
  4198. else
  4199. printf("Wrong story id or name [%s] for map spot function", tostring(story_id))
  4200. end
  4201. end
  4202. end
  4203. ]]--
  4204.  
  4205. -- add map spot from logic
  4206. -- param 1 is story_id of object to show on pda map
  4207. -- param 2 is ui icon tag from map_spots.xml
  4208. -- param 3 is name of ui_st_pda.xml string
  4209. function add_map_spot(actor, npc, p)
  4210. if(p[1]==nil) then
  4211. printf("Story id for add map spot function is not set")
  4212. else
  4213. -- local story_id = tonumber(p[1]) --original SOC/CS
  4214. local story_id = p[1]
  4215. -- local id = id_by_sid(story_id) --original SOC/CS
  4216. local id = get_story_object_id(story_id)
  4217. if(id==nil) then
  4218. local obj = alife_object(p[1])
  4219. id = obj and obj.id
  4220. end
  4221. if(id~=nil) then
  4222. if(p[2]==nil) then
  4223. p[2] = "primary_object"
  4224. end
  4225. if(p[3]==nil) then
  4226. p[3] = "default"
  4227. end
  4228. if level.map_has_object_spot(id, p[2]) == 0 then
  4229. level.map_add_object_spot_ser(id, p[2], p[3])
  4230. end
  4231. else
  4232. printf("Wrong story id or name [%s] for map spot function", tostring(story_id))
  4233. end
  4234. end
  4235. end
  4236.  
  4237. -- remove map spot from logic
  4238. -- param 1 is story_id of object to show on pda map
  4239. -- param 2 is ui icon tag from map_spots.xml
  4240. function remove_map_spot(actor, npc, p)
  4241. if(p[1]==nil) then
  4242. printf("Story id for add map spot function is not set")
  4243. else
  4244. -- local story_id = tonumber(p[1]) --original SOC/CS
  4245. local story_id = p[1]
  4246. -- local id = id_by_sid(story_id) --original SOC/CS
  4247. local id = get_story_object_id(story_id)
  4248. if(id==nil) then
  4249. local obj = alife_object(p[1])
  4250. id = obj and obj.id
  4251. end
  4252. if(id~=nil) then
  4253. if(p[2]==nil) then
  4254. p[2] = "primary_object"
  4255. end
  4256. if level.map_has_object_spot(id, p[2]) ~= 0 then
  4257. level.map_remove_object_spot(id, p[2])
  4258. end
  4259. else
  4260. printf("Wrong story id or name [%s] for map spot function", tostring(story_id))
  4261. end
  4262. end
  4263. end
  4264.  
  4265. function show_csky_squads_on_map(actor, npc)
  4266. local csky_squads_tbl =
  4267. { {target="csky_sim_squad_novice", hint="csky"},
  4268. {target="csky_sim_squad_advanced", hint="csky"},
  4269. {target="csky_sim_squad_veteran", hint="csky"}
  4270. }
  4271. if (squad.player_id == "csky") then
  4272. for k,v in pairs(csky_squads_tbl) do
  4273. local obj_id = get_story_squad(v.target)
  4274. if(obj_id) then
  4275. level.map_add_object_spot_ser(obj_id, "alife_presentation_squad_friend_1", v.hint)
  4276. end
  4277. end
  4278. end
  4279. end
  4280.  
  4281. function make_actor_visible_to_npc(actor, npc, p)
  4282. local act = db.actor
  4283. if act then
  4284. npc:make_object_visible_somewhen(act)
  4285. end
  4286. end
  4287. -- Anomal fields support
  4288. function enable_anomaly(actor, npc, p)
  4289. if p[1] == nil then
  4290. printf("Story id for enable_anomaly function is not set")
  4291. end
  4292.  
  4293. local obj = get_story_object(p[1])
  4294. if not obj then
  4295. printf("There is no object with story_id %s for enable_anomaly function", tostring(p[1]))
  4296. end
  4297. obj:enable_anomaly()
  4298. end
  4299.  
  4300. function disable_anomaly(actor, npc, p)
  4301. if p[1] == nil then
  4302. printf("Story id for disable_anomaly function is not set")
  4303. end
  4304.  
  4305. local obj = get_story_object(p[1])
  4306. if not obj then
  4307. printf("There is no object with story_id %s for disable_anomaly function", tostring(p[1]))
  4308. end
  4309. obj:disable_anomaly()
  4310. end
  4311.  
  4312. function launch_signal_rocket(actor, obj, p)
  4313. if p==nil then
  4314. printf("Signal rocket name is not set!")
  4315. end
  4316. if db.signal_light[p[1]] then
  4317. db.signal_light[p[1]]:launch()
  4318. else
  4319. printf("No such signal rocket: [%s] on level", tostring(p[1]))
  4320. end
  4321. end
  4322.  
  4323. --[[
  4324. function reset_faction_goodwill(actor, obj, p)
  4325. if db.actor and p[1] then
  4326. local board = SIMBOARD
  4327. local faction = board.players[ p[1] ]
  4328. if faction then
  4329. db.actor:set_community_goodwill(p[1], 0)
  4330. end
  4331. end
  4332. end
  4333. ]]--
  4334.  
  4335. function add_cs_text(actor, npc, p)
  4336. if p[1] then
  4337. local hud = get_hud()
  4338. if (hud) then
  4339. local cs_text = hud:GetCustomStatic("text_on_screen_center")
  4340. if cs_text then
  4341. hud:RemoveCustomStatic("text_on_screen_center")
  4342. end
  4343. hud:AddCustomStatic("text_on_screen_center", true)
  4344. cs_text = hud:GetCustomStatic("text_on_screen_center")
  4345. cs_text:wnd():TextControl():SetText(game.translate_string(p[1]))
  4346. end
  4347. end
  4348. end
  4349.  
  4350. function del_cs_text(actor, npc, p)
  4351. local hud = get_hud()
  4352. if (hud) then
  4353. cs_text = hud:GetCustomStatic("text_on_screen_center")
  4354. if cs_text then
  4355. hud:RemoveCustomStatic("text_on_screen_center")
  4356. end
  4357. end
  4358. end
  4359.  
  4360. function spawn_item_to_npc(actor, npc, p)
  4361. local new_item = p[1]
  4362. if p[1] then
  4363. alife_create(new_item,
  4364. npc:position(),
  4365. npc:level_vertex_id(),
  4366. npc:game_vertex_id(),
  4367. npc:id())
  4368. end
  4369. end
  4370.  
  4371. function give_money_to_npc(actor, npc, p)
  4372. local money = p[1] and tonumber(p[1])
  4373. if money then
  4374. npc:give_money(money)
  4375. end
  4376. end
  4377.  
  4378. function seize_money_to_npc(actor, npc, p)
  4379. local money = p[1] and tonumber(p[1])
  4380. if money then
  4381. npc:give_money(-money)
  4382. end
  4383. end
  4384.  
  4385. -- Передача предмета от непися к неписю
  4386. -- relocate_item(item_name:story_id_from:story_id_to)
  4387. function relocate_item(actor, npc, p)
  4388. local item = p and p[1]
  4389. local from_obj = p and get_story_object(p[2])
  4390. local to_obj = p and get_story_object(p[3])
  4391. if to_obj ~= nil then
  4392. if from_obj ~= nil and from_obj:object(item) ~= nil then
  4393. from_obj:transfer_item(from_obj:object(item), to_obj)
  4394. else
  4395. alife_create(item,
  4396. to_obj:position(),
  4397. to_obj:level_vertex_id(),
  4398. to_obj:game_vertex_id(),
  4399. to_obj:id())
  4400. end
  4401. else
  4402. printf("Couldn't relocate item to NULL")
  4403. end
  4404. end
  4405.  
  4406. -- Сделать сквады врагами, передаются два сквада set_squads_enemies(squad_name_1:squad_name_2)
  4407. function set_squads_enemies(actor, npc, p)
  4408. if (p[1] == nil or p[2] == nil) then
  4409. printf("Wrong parameters in function set_squad_enemies")
  4410. return
  4411. end
  4412.  
  4413. local squad_1 = get_story_squad(p[1])
  4414. local squad_2 = get_story_squad(p[2])
  4415.  
  4416. if squad_1 == nil then
  4417. assert("There is no squad with id[%s]", tostring(p[1]))
  4418. return
  4419. end
  4420. if squad_2 == nil then
  4421. assert("There is no squad with id[%s]", tostring(p[2]))
  4422. return
  4423. end
  4424.  
  4425. for k in squad_1:squad_members() do
  4426. local npc_obj_1 = db.storage[k.id] and db.storage[k.id].object
  4427. if npc_obj_1 ~= nil then
  4428. for kk in squad_2:squad_members() do
  4429. local npc_obj_2 = db.storage[kk.id] and db.storage[kk.id].object
  4430. if npc_obj_2 ~= nil then
  4431. npc_obj_1:set_relation(game_object.enemy, npc_obj_2)
  4432. npc_obj_2:set_relation(game_object.enemy, npc_obj_1)
  4433. printf("set_squads_enemies: %d:set_enemy(%d)", npc_obj_1:id(), npc_obj_2:id())
  4434. end
  4435. end
  4436. end
  4437. end
  4438. end
  4439.  
  4440. local particles_table = {
  4441. [1] = {particle = particles_object("anomaly2\\teleport_out_00"), sound = sound_object("anomaly\\teleport_incoming")},
  4442. [2] = {particle = particles_object("anomaly2\\teleport_out_00"), sound = sound_object("anomaly\\teleport_incoming")},
  4443. [3] = {particle = particles_object("anomaly2\\teleport_out_00"), sound = sound_object("anomaly\\teleport_incoming")},
  4444. [4] = {particle = particles_object("anomaly2\\teleport_out_00"), sound = sound_object("anomaly\\teleport_incoming")},
  4445. }
  4446.  
  4447. function jup_b16_play_particle_and_sound(actor, npc, p)
  4448. particles_table[p[1]].particle :play_at_pos(patrol(npc:name().."_particle"):point(0))
  4449. --particles_table[p[1]].sound :play_at_pos(actor, patrol(npc:name().."_particle"):point(0), 0, sound_object.s3d)
  4450. end
  4451. --Функция установки состояния видимости кровососа.
  4452. -- Возможный набор параметров --> story_id:visibility_state(можно вызывать откуда угодно) или visibility_state(если вызывается из кастомдаты кровососа)
  4453. -- visibility_state -->
  4454. -- 0 - невидимый
  4455. -- 1 - полувидимый
  4456. -- 2 - полностью видимый
  4457. function set_bloodsucker_state(actor, npc, p)
  4458. if (p and p[1]) == nil then printf("Wrong parameters in function 'set_bloodsucker_state'!!!") end
  4459. local state = p[1]
  4460. if p[2] ~= nil then
  4461. state = p[2]
  4462. npc = get_story_object(p[1])
  4463. end
  4464. if npc ~= nil then
  4465. if state == "default" then
  4466. npc:force_visibility_state(-1)
  4467. else
  4468. npc:force_visibility_state(tonumber(state))
  4469. end
  4470. end
  4471. end
  4472.  
  4473. --Функция вставки предмета в определенную точку, сделал для сцены б57
  4474. function drop_object_item_on_point(actor, npc, p)
  4475. local drop_object = db.actor:object(p[1])
  4476. local drop_point = patrol(p[2]):point(0)
  4477. db.actor:drop_item_and_teleport(drop_object, drop_point)
  4478. end
  4479.  
  4480. --Функция отнятия предмета у игрока
  4481. function remove_item(actor, npc, p)
  4482. local sec = p[1]
  4483. if not (sec) then
  4484. printf("Wrong parameters in function 'remove_item'!!!")
  4485. return
  4486. end
  4487. local amt = p[2] and tonumber(p[2]) or 1
  4488. local removed = 0
  4489. local se_item
  4490. local function release_actor_item(temp, item)
  4491. if (item:section() == sec and amt > 0) then
  4492. se_item = alife_object(item:id())
  4493. if (se_item) then
  4494. alife_release(se_item)
  4495. amt = amt - 1
  4496. removed = removed + 1
  4497. end
  4498. end
  4499. end
  4500. db.actor:iterate_inventory(release_actor_item,nil)
  4501. if (removed > 0) then
  4502. news_manager.relocate_item(db.actor,"out",sec,removed)
  4503. end
  4504. end
  4505.  
  4506. -- Сюжетное сохранение в важных местах
  4507. function scenario_autosave(actor, npc, p)
  4508. local save_name = p[1]
  4509. if save_name == nil then
  4510. printf("You are trying to use scenario_autosave without save name")
  4511. end
  4512.  
  4513. --[[ clear excess corpses everytime player saves
  4514. --release_body_manager.get_release_body_manager():clear()
  4515.  
  4516. if (IsImportantSave()) and (not ui_options.get("other/important_save")) then
  4517. local prefix = user_name()
  4518. local save_param = prefix.." - "..game.translate_string(save_name)
  4519.  
  4520. exec_console_cmd("save "..save_param)
  4521. end
  4522. --]]
  4523. end
  4524.  
  4525. function zat_b29_create_random_infop(actor, npc, p)
  4526. if p[2] == nil then
  4527. printf("Not enough parameters for zat_b29_create_random_infop!")
  4528. end
  4529.  
  4530. local amount_needed = p[1]
  4531. local current_infop = 0
  4532. local total_infop = 0
  4533.  
  4534. if (not amount_needed or amount_needed == nil) then
  4535. amount_needed = 1
  4536. end
  4537.  
  4538. for k,v in pairs(p) do
  4539. if k > 1 then
  4540. total_infop = total_infop + 1
  4541. disable_info(v)
  4542. end
  4543. end
  4544.  
  4545. if amount_needed > total_infop then
  4546. amount_needed = total_infop
  4547. end
  4548.  
  4549. for i = 1, amount_needed do
  4550. current_infop = math.random(1, total_infop)
  4551. for k,v in pairs(p) do
  4552. if k > 1 then
  4553. if (k == current_infop + 1 and (not has_alife_info(v))) then
  4554. db.actor:give_info_portion(v)
  4555. break
  4556. end
  4557. end
  4558. end
  4559. end
  4560. end
  4561.  
  4562. function give_item_b29(actor, npc, p)
  4563. -- local story_object = p and get_story_object(p[1])
  4564. local az_name
  4565. local az_table = {
  4566. "zat_b55_anomal_zone",
  4567. "zat_b54_anomal_zone",
  4568. "zat_b53_anomal_zone",
  4569. "zat_b39_anomal_zone",
  4570. "zaton_b56_anomal_zone",
  4571. }
  4572.  
  4573. for i = 16, 23 do
  4574. if has_alife_info(dialogs_zaton.zat_b29_infop_bring_table[i]) then
  4575. for k,v in pairs(az_table) do
  4576. if has_alife_info(v) then
  4577. az_name = v
  4578. disable_info(az_name)
  4579. break
  4580. end
  4581. end
  4582. pick_artefact_from_anomaly(nil, nil, {p[1], az_name, dialogs_zaton.zat_b29_af_table[i]})
  4583. break
  4584. end
  4585. end
  4586. end
  4587.  
  4588. function relocate_item_b29(actor, npc, p)
  4589. local item
  4590. for i = 16, 23 do
  4591. if has_alife_info(dialogs_zaton.zat_b29_infop_bring_table[i]) then
  4592. item = dialogs_zaton.zat_b29_af_table[i]
  4593. break
  4594. end
  4595. end
  4596. local from_obj = p and get_story_object(p[1])
  4597. local to_obj = p and get_story_object(p[2])
  4598. if to_obj ~= nil then
  4599. if from_obj ~= nil and from_obj:object(item) ~= nil then
  4600. from_obj:transfer_item(from_obj:object(item), to_obj)
  4601. else
  4602. alife_create(item,
  4603. to_obj:position(),
  4604. to_obj:level_vertex_id(),
  4605. to_obj:game_vertex_id(),
  4606. to_obj:id())
  4607. end
  4608. else
  4609. printf("Couldn't relocate item to NULL")
  4610. end
  4611. end
  4612.  
  4613. -- Функция ресетит секвенсную звукокую тему у непися. by peacemaker, hein, redstain
  4614. function reset_sound_npc(actor, npc, p)
  4615. local obj_id = npc:id()
  4616. if obj_id and xr_sound.sound_table and xr_sound.sound_table[obj_id] then
  4617. xr_sound.sound_table[obj_id]:reset(obj_id)
  4618. end
  4619. end
  4620.  
  4621. function jup_b202_inventory_box_relocate(actor, npc)
  4622. local inv_box_out = get_story_object("jup_b202_actor_treasure")
  4623. local inv_box_in = get_story_object("jup_b202_snag_treasure")
  4624. local items_to_relocate = {}
  4625. local function relocate(inv_box_out, item)
  4626. items_to_relocate[#items_to_relocate+1] = item
  4627. end
  4628. inv_box_out:iterate_inventory_box (relocate, inv_box_out)
  4629. for k,v in ipairs(items_to_relocate) do
  4630. inv_box_out:transfer_item(v, inv_box_in)
  4631. end
  4632. end
  4633.  
  4634. function clear_box(actor, npc, p)
  4635. if (p and p[1]) == nil then printf("Wrong parameters in function 'clear_box'!!!") end
  4636.  
  4637. local inv_box = get_story_object(p[1])
  4638.  
  4639. if inv_box == nil then
  4640. printf("There is no object with story_id [%s]", tostring(p[1]))
  4641. end
  4642.  
  4643. local items_table = {}
  4644.  
  4645. local function add_items(inv_box, item)
  4646. items_table[#items_table+1] = item
  4647. end
  4648.  
  4649. inv_box:iterate_inventory_box(add_items, inv_box)
  4650.  
  4651. local sim = alife()
  4652. for k,v in pairs(items_table) do
  4653. alife_release_id(v:id())
  4654. end
  4655. end
  4656.  
  4657. function activate_weapon(actor, npc, p)
  4658. local object = actor:object(p[1])
  4659. if object == nil then
  4660. assert("Actor has no such weapon! [%s]", p[1])
  4661. end
  4662. if object ~= nil then
  4663. actor:make_item_active(object)
  4664. end
  4665. end
  4666.  
  4667. function set_game_time(actor, npc, p)
  4668. local real_hours = level.get_time_hours()
  4669. local real_minutes = level.get_time_minutes()
  4670. local hours = tonumber(p[1])
  4671. local minutes = tonumber(p[2])
  4672. if p[2] == nil then
  4673. minutes = 0
  4674. end
  4675. local hours_to_change = hours - real_hours
  4676. if hours_to_change <= 0 then
  4677. hours_to_change = hours_to_change + 24
  4678. end
  4679. local minutes_to_change = minutes - real_minutes
  4680. if minutes_to_change <= 0 then
  4681. minutes_to_change = minutes_to_change + 60
  4682. hours_to_change = hours_to_change - 1
  4683. elseif hours == real_hours then
  4684. hours_to_change = hours_to_change - 24
  4685. end
  4686. level.change_game_time(0,hours_to_change,minutes_to_change)
  4687. level_weathers.get_weather_manager():forced_weather_change()
  4688. surge_manager.SurgeManager.time_forwarded = true
  4689. printf("set_game_time: time changed to [%d][%d]", hours_to_change, minutes_to_change)
  4690. end
  4691.  
  4692. function forward_game_time(actor, npc, p)
  4693. if not p then
  4694. printf("Insufficient or invalid parameters in function 'forward_game_time'!")
  4695. end
  4696.  
  4697. local hours = tonumber(p[1])
  4698. local minutes = tonumber(p[2])
  4699.  
  4700. if p[2] == nil then
  4701. minutes = 0
  4702. end
  4703. level.change_game_time(0,hours,minutes)
  4704. level_weathers.get_weather_manager():forced_weather_change()
  4705. surge_manager.SurgeManager.time_forwarded = true
  4706. printf("forward_game_time: time forwarded on [%d][%d]", hours, minutes)
  4707. end
  4708.  
  4709. function stop_tutorial()
  4710. --printf("stop tutorial called")
  4711. game.stop_tutorial()
  4712. end
  4713.  
  4714. function jup_b10_spawn_drunk_dead_items(actor, npc, p)
  4715. local items_all = {
  4716. ["wpn_ak74"] = 1,
  4717. ["ammo_5.45x39_fmj"] = 5,
  4718. ["ammo_5.45x39_ap"] = 3,
  4719. ["wpn_fort"] = 1,
  4720. ["ammo_9x18_fmj"] = 3,
  4721. ["ammo_12x70_buck"] = 5,
  4722. ["ammo_11.43x23_hydro"] = 2,
  4723. ["grenade_rgd5"] = 3,
  4724. ["grenade_f1"] = 2,
  4725. ["medkit_army"] = 2,
  4726. ["medkit"] = 4,
  4727. ["bandage"] = 4,
  4728. ["antirad"] = 2,
  4729. ["vodka"] = 3,
  4730. ["energy_drink"] = 2,
  4731. ["conserva"] = 1,
  4732. ["jup_b10_ufo_memory_2"] = 1,
  4733. }
  4734.  
  4735. local items = {
  4736. [2] = {
  4737. ["wpn_sig550_luckygun"] = 1,
  4738. },
  4739. [1] = {
  4740. ["ammo_5.45x39_fmj"] = 5,
  4741. ["ammo_5.45x39_ap"] = 3,
  4742. ["wpn_fort"] = 1,
  4743. ["ammo_9x18_fmj"] = 3,
  4744. ["ammo_12x70_buck"] = 5,
  4745. ["ammo_11.43x23_hydro"] = 2,
  4746. ["grenade_rgd5"] = 3,
  4747. ["grenade_f1"] = 2,
  4748. },
  4749. [0] = {
  4750. ["medkit_army"] = 2,
  4751. ["medkit"] = 4,
  4752. ["bandage"] = 4,
  4753. ["antirad"] = 2,
  4754. ["vodka"] = 3,
  4755. ["energy_drink"] = 2,
  4756. ["conserva"] = 1,
  4757. },
  4758. }
  4759.  
  4760. if p and p[1] ~= nil then
  4761. local cnt = load_var(actor, "jup_b10_ufo_counter", 0)
  4762. if cnt > 2 then return end
  4763. for k,v in pairs(items[cnt]) do
  4764. local target_obj_id = get_story_object_id(p[1])
  4765. if target_obj_id ~= nil then
  4766. box = alife_object(target_obj_id)
  4767. if box == nil then
  4768. printf("There is no such object %s", p[1])
  4769. end
  4770. for i = 1,v do
  4771. alife_create(k,vector(),0,0,target_obj_id)
  4772. end
  4773. else
  4774. printf("object is nil %s", tostring(p[1]))
  4775. end
  4776. end
  4777. else
  4778. for k,v in pairs(items_all) do
  4779. for i = 1,v do
  4780. alife_create(k,
  4781. npc:position(),
  4782. npc:level_vertex_id(),
  4783. npc:game_vertex_id(),
  4784. npc:id())
  4785. end
  4786. end
  4787. end
  4788.  
  4789. end
  4790.  
  4791. function pick_artefact_from_anomaly(actor, npc, p)
  4792. local se_obj
  4793. local az_name = p and p[2]
  4794. local af_name = p and p[3]
  4795. local af_id
  4796. local af_obj
  4797. local anomal_zone = db.anomaly_by_name[az_name]
  4798.  
  4799. if p and p[1] then
  4800. -- if p[1] == "actor" then
  4801. -- npc = db.actor
  4802. -- else
  4803. -- npc = get_story_object(p[1])
  4804. -- end
  4805.  
  4806. local npc_id = get_story_object_id(p[1])
  4807. if npc_id == nil then
  4808. printf("Couldn't relocate item to NULL in function 'pick_artefact_from_anomaly!'")
  4809. end
  4810. se_obj = alife_object(npc_id)
  4811. if se_obj and (not IsStalker(nil,se_obj:clsid()) or not se_obj:alive()) then
  4812. printf("Couldn't relocate item to NULL (dead or not stalker) in function 'pick_artefact_from_anomaly!'")
  4813. end
  4814. end
  4815.  
  4816. if anomal_zone == nil then
  4817. printf("No such anomal zone in function 'pick_artefact_from_anomaly!'")
  4818. end
  4819.  
  4820. if anomal_zone.spawned_count < 1 then
  4821. printf("No artefacts in anomal zone [%s]", az_name)
  4822. return
  4823. end
  4824.  
  4825. for k,v in pairs(anomal_zone.artefact_ways_by_id) do
  4826. if alife_object(tonumber(k)) and af_name == alife_object(tonumber(k)):section_name() then
  4827. af_id = tonumber(k)
  4828. af_obj = alife_object(tonumber(k))
  4829. break
  4830. end
  4831. if af_name == nil then
  4832. af_id = tonumber(k)
  4833. af_obj = alife_object(tonumber(k))
  4834. af_name = af_obj:section_name()
  4835. break
  4836. end
  4837. end
  4838.  
  4839. if af_id == nil then
  4840. printf("No such artefact [%s] found in anomal zone [%s]", tostring(af_name), az_name)
  4841. return
  4842. end
  4843.  
  4844. anomal_zone:on_artefact_take(af_obj)
  4845.  
  4846. alife_release(af_obj)
  4847. give_item(db.actor, se_obj, {af_name, p[1]})
  4848. -- alife_create(af_name,
  4849. -- npc.position,
  4850. -- npc.level_vertex_id,
  4851. -- npc.game_vertex_id,
  4852. -- npc.id)
  4853. end
  4854.  
  4855. function anomaly_turn_off (actor, npc, p)
  4856. local anomal_zone = db.anomaly_by_name[p[1]]
  4857. if anomal_zone == nil then
  4858. printf("No such anomal zone in function 'anomaly_turn_off!'")
  4859. end
  4860. anomal_zone:turn_off()
  4861. end
  4862.  
  4863. function anomaly_turn_on (actor, npc, p)
  4864. local anomal_zone = db.anomaly_by_name[p[1]]
  4865. if anomal_zone == nil then
  4866. printf("No such anomal zone in function 'anomaly_turn_on!'")
  4867. end
  4868. if p[2] then
  4869. anomal_zone:turn_on(true)
  4870. else
  4871. anomal_zone:turn_on(false)
  4872. end
  4873. end
  4874.  
  4875. function zat_b202_spawn_random_loot(actor, npc, p)
  4876. local si_table = {}
  4877. si_table[1] = {
  4878. [1] = {item = {"bandage","bandage","bandage","bandage","bandage","medkit","medkit","medkit","conserva","conserva"}},
  4879. [2] = {item = {"medkit","medkit","medkit","medkit","medkit","vodka","vodka","vodka","kolbasa","kolbasa"}},
  4880. [3] = {item = {"antirad","antirad","antirad","medkit","medkit","bandage","kolbasa","kolbasa","conserva"}},
  4881. }
  4882. si_table[2] = {
  4883. [1] = {item = {"grenade_f1","grenade_f1","grenade_f1"}},
  4884. [2] = {item = {"grenade_rgd5","grenade_rgd5","grenade_rgd5","grenade_rgd5","grenade_rgd5"}}
  4885. }
  4886. si_table[3] = {
  4887. [1] = {item = {"detector_elite"}},
  4888. [2] = {item = {"detector_advanced"}}
  4889. }
  4890. si_table[4] = {
  4891. [1] = {item = {"helm_hardhat"}},
  4892. [2] = {item = {"helm_respirator"}}
  4893. }
  4894. si_table[5] = {
  4895. [1] = {item = {"wpn_val","ammo_9x39_ap","ammo_9x39_ap","ammo_9x39_ap"}},
  4896. [2] = {item = {"wpn_spas12","ammo_12x70_buck","ammo_12x70_buck","ammo_12x70_buck","ammo_12x70_buck"}},
  4897. [3] = {item = {"wpn_desert_eagle","ammo_11.43x23_fmj","ammo_11.43x23_fmj","ammo_11.43x23_hydro","ammo_11.43x23_hydro"}},
  4898. [4] = {item = {"wpn_abakan","ammo_5.45x39_ap","ammo_5.45x39_ap"}},
  4899. [5] = {item = {"wpn_sig550","ammo_5.56x45_ap","ammo_5.56x45_ap"}},
  4900. [6] = {item = {"wpn_ak74","ammo_5.45x39_fmj","ammo_5.45x39_fmj"}},
  4901. [7] = {item = {"wpn_l85","ammo_5.56x45_ss190","ammo_5.56x45_ss190"}}
  4902. }
  4903. si_table[6] = {
  4904. [1] = {item = {"specops_outfit"}},
  4905. [2] = {item = {"stalker_outfit"}}
  4906. }
  4907. weight_table = {}
  4908. weight_table[1] = 2
  4909. weight_table[2] = 2
  4910. weight_table[3] = 2
  4911. weight_table[4] = 2
  4912. weight_table[5] = 4
  4913. weight_table[6] = 4
  4914. local spawned_item = {}
  4915. local max_weight = 12
  4916. repeat
  4917. local n = 0
  4918. repeat
  4919. n = math.random(1, #weight_table)
  4920. local prap = true
  4921. for k,v in pairs(spawned_item) do
  4922. if v == n then
  4923. prap = false
  4924. break
  4925. end
  4926. end
  4927. until (prap) and ((max_weight - weight_table[n]) >= 0)
  4928. max_weight = max_weight - weight_table[n]
  4929. spawned_item[#spawned_item+1] = n
  4930. local item = math.random(1, #si_table[n])
  4931. for k,v in pairs(si_table[n][item].item) do
  4932. spawn_object_in(actor, npc, {tostring(v),"jup_b202_snag_treasure"})
  4933. end
  4934. until max_weight <= 0
  4935. end
  4936.  
  4937. function zat_a1_tutorial_end_give(actor, npc)
  4938. -- level.add_pp_effector("black.ppe", 1313, true) ---do not stop on r1 !
  4939. db.actor:give_info_portion("zat_a1_tutorial_end")
  4940. end
  4941.  
  4942. function oasis_heal()
  4943. local d_health = 0.005
  4944. local d_power = 0.01
  4945. local d_bleeding = 0.05
  4946. local d_radiation = -0.05
  4947. if(db.actor.health<1) then
  4948. db.actor:change_health(d_health)
  4949. end
  4950. if(db.actor.power<1) then
  4951. db.actor:change_power(d_power)
  4952. end
  4953. if(db.actor.radiation>0) then
  4954. db.actor:change_radiation(d_radiation)
  4955. end
  4956. if(db.actor.bleeding>0) then
  4957. db.actor.bleeding = d_bleeding
  4958. end
  4959. db.actor:change_satiety(0.01)
  4960. end
  4961.  
  4962. --Функция принимает только одно значение, определяющее для какой групировки запускается. доступные значения [duty, freedom]
  4963. function jup_b221_play_main(actor, npc, p)
  4964. local info_table = {}
  4965. local main_theme
  4966. local reply_theme
  4967. local info_need_reply
  4968. local reachable_theme = {}
  4969. local theme_to_play = 0
  4970.  
  4971. if (p and p[1]) == nil then
  4972. printf("No such parameters in function 'jup_b221_play_main'")
  4973. end
  4974. --Составляем таблицу инфопоршинов определяющих доступность той или иной темы, определяем префиксы темы, ответа и реакции, соответственно для долга или для свободы.
  4975. if tostring(p[1]) == "duty" then
  4976. info_table = {
  4977. [1] = "jup_b25_freedom_flint_gone",
  4978. [2] = "jup_b25_flint_blame_done_to_duty",
  4979. [3] = "jup_b4_monolith_squad_in_duty",
  4980. [4] = "jup_a6_duty_leader_bunker_guards_work",
  4981. [5] = "jup_a6_duty_leader_employ_work",
  4982. [6] = "jup_b207_duty_wins"
  4983. }
  4984. main_theme = "jup_b221_duty_main_"
  4985. reply_theme = "jup_b221_duty_reply_"
  4986. info_need_reply = "jup_b221_duty_reply"
  4987. elseif tostring(p[1]) == "freedom" then
  4988. info_table = {
  4989. [1] = "jup_b207_freedom_know_about_depot",
  4990. [2] = "jup_b46_duty_founder_pda_to_freedom",
  4991. [3] = "jup_b4_monolith_squad_in_freedom",
  4992. [4] = "jup_a6_freedom_leader_bunker_guards_work",
  4993. [5] = "jup_a6_freedom_leader_employ_work",
  4994. [6] = "jup_b207_freedom_wins"
  4995. }
  4996. main_theme = "jup_b221_freedom_main_"
  4997. reply_theme = "jup_b221_freedom_reply_"
  4998. info_need_reply = "jup_b221_freedom_reply"
  4999. else
  5000. printf("Wrong parameters in function 'jup_b221_play_main'")
  5001. end
  5002. --Составляем таблицу достыпных тем(тлько номера тем).
  5003. for k,v in pairs(info_table) do
  5004. if (has_alife_info(v)) and (not has_alife_info(main_theme .. tostring(k) .. "_played")) then
  5005. table.insert(reachable_theme,k)
  5006. -- printf("jup_b221_play_main: table reachable_theme ------------------------------> [%s]", tostring(k))
  5007. end
  5008. end
  5009. --Если таблица доступных тем пуста играем ответ. Если же она не пуста играем основную тему. Если играем основную тему заносим значение счетчика для повторного выполнения функции. Тему выбираем по рандому.
  5010. if #reachable_theme ~= 0 then
  5011. disable_info(info_need_reply)
  5012. theme_to_play = reachable_theme[math.random(1, #reachable_theme)]
  5013. -- printf("jup_b221_play_main: variable theme_to_play ------------------------------> [%s]", tostring(theme_to_play))
  5014. save_var(actor,"jup_b221_played_main_theme",tostring(theme_to_play))
  5015. db.actor:give_info_portion(main_theme .. tostring(theme_to_play) .."_played")
  5016. if theme_to_play ~= 0 then
  5017. play_sound(actor, npc, {main_theme .. tostring(theme_to_play)})
  5018. else
  5019. printf("No such theme_to_play in function 'jup_b221_play_main'")
  5020. end
  5021. else
  5022. db.actor:give_info_portion(info_need_reply)
  5023. theme_to_play = tonumber(load_var(actor,"jup_b221_played_main_theme",0))
  5024. if theme_to_play ~= 0 then
  5025. play_sound(actor, npc, {reply_theme..tostring(theme_to_play)})
  5026. else
  5027. printf("No such theme_to_play in function 'jup_b221_play_main'")
  5028. end
  5029. save_var(actor,"jup_b221_played_main_theme","0")
  5030. end
  5031. end
  5032.  
  5033. function pas_b400_play_particle(actor, npc, p)
  5034. db.actor:start_particles("zones\\zone_acidic_idle","bip01_head")
  5035. end
  5036.  
  5037. function pas_b400_stop_particle(actor, npc, p)
  5038. db.actor:stop_particles("zones\\zone_acidic_idle","bip01_head")
  5039. end
  5040.  
  5041. function damage_pri_a17_gauss()
  5042. local obj = get_story_object("pri_a17_gauss_rifle")
  5043. --local obj = npc:object("pri_a17_gauss_rifle")
  5044. if obj ~= nil then
  5045. obj:set_condition(0.0)
  5046. end
  5047. end
  5048.  
  5049. function pri_a17_hard_animation_reset(actor, npc, p)
  5050. --db.storage[npc:id()].state_mgr:set_state("pri_a17_fall_down", nil, nil, nil, {fast_set = true})
  5051. db.storage[npc:id()].state_mgr:set_state("pri_a17_fall_down")
  5052.  
  5053. local state_mgr = db.storage[npc:id()].state_mgr
  5054. if state_mgr ~= nil then
  5055. state_mgr.animation:set_state(nil, true)
  5056. state_mgr.animation:set_state("pri_a17_fall_down")
  5057. state_mgr.animation:set_control()
  5058. end
  5059. end
  5060.  
  5061. function jup_b217_hard_animation_reset(actor, npc, p)
  5062. db.storage[npc:id()].state_mgr:set_state("jup_b217_nitro_straight")
  5063.  
  5064. local state_mgr = db.storage[npc:id()].state_mgr
  5065. if state_mgr ~= nil then
  5066. state_mgr.animation:set_state(nil, true)
  5067. state_mgr.animation:set_state("jup_b217_nitro_straight")
  5068. state_mgr.animation:set_control()
  5069. end
  5070. end
  5071.  
  5072.  
  5073.  
  5074. --[[
  5075. function set_tip_to_story(actor, npc, p)
  5076. if p == nil or p[2] == nil then
  5077. printf("Not enough parameters in 'set_tip_to_story' function!")
  5078. end
  5079.  
  5080. local obj = get_story_object(p[1])
  5081.  
  5082. if not obj then
  5083. return
  5084. end
  5085.  
  5086. local tip = p[2]
  5087.  
  5088. obj:set_tip_text(tip)
  5089. end
  5090.  
  5091. function clear_tip_from_story(actor, npc, p)
  5092. if p == nil or p[1] == nil then
  5093. printf("Not enough parameters in 'clear_tip_from_story' function!")
  5094. end
  5095.  
  5096. local obj = get_story_object(p[1])
  5097.  
  5098. if not obj then
  5099. return
  5100. end
  5101.  
  5102. obj:set_tip_text("")
  5103. end
  5104. ]]--
  5105.  
  5106. function mech_discount(actor, npc, p)
  5107. if(p[1]) then
  5108. inventory_upgrades.mech_discount(tonumber(p[1]) or 1)
  5109. end
  5110. end
  5111.  
  5112. function polter_actor_ignore(actor, npc, p)
  5113. if p[1] and p[1] == "true" then
  5114. npc:poltergeist_set_actor_ignore(true)
  5115. elseif p[1] and p[1] == "false" then
  5116. npc:poltergeist_set_actor_ignore(false)
  5117. end
  5118. end
  5119.  
  5120. function burer_force_gravi_attack(actor, npc)
  5121. npc:burer_set_force_gravi_attack(true)
  5122. end
  5123.  
  5124. function burer_force_anti_aim(actor, npc)
  5125. npc:set_force_anti_aim(true)
  5126. end
  5127.  
  5128. function show_freeplay_dialog(actor, npc, p)
  5129. if p[1] and p[2] and p[2] == "true" then
  5130. ui_freeplay_dialog.show("message_box_yes_no", p[1])
  5131. elseif p[1] then
  5132. ui_freeplay_dialog.show("message_box_ok", p[1])
  5133. end
  5134. end
  5135.  
  5136. -- Только для state_mgr
  5137. function get_best_detector(npc)
  5138. local detectors = { "detector_simple", "detector_advanced", "detector_elite", "detector_scientific" }
  5139. for k,v in pairs(detectors) do
  5140. local obj = npc:object(v)
  5141. if obj ~= nil then
  5142. obj:enable_attachable_item(true)
  5143. return
  5144. end
  5145. end
  5146. end
  5147.  
  5148. function hide_best_detector(npc)
  5149. local detectors = { "detector_simple", "detector_advanced", "detector_elite", "detector_scientific" }
  5150. for k,v in pairs(detectors) do
  5151. local obj = npc:object(v)
  5152. if obj ~= nil then
  5153. obj:enable_attachable_item(false)
  5154. return
  5155. end
  5156. end
  5157. end
  5158.  
  5159. -- Инфопоршны для синхронизации анимации нпс с прочими действиями, и для других целей
  5160. function pri_a18_radio_start(actor, npc)
  5161. db.actor:give_info_portion("pri_a18_radio_start")
  5162. end
  5163.  
  5164. function pri_a17_ice_climb_end(actor, npc)
  5165. db.actor:give_info_portion("pri_a17_ice_climb_end")
  5166. end
  5167.  
  5168. function jup_b219_opening(actor, npc)
  5169. db.actor:give_info_portion("jup_b219_opening")
  5170. end
  5171.  
  5172. function jup_b219_entering_underpass(actor, npc)
  5173. db.actor:give_info_portion("jup_b219_entering_underpass")
  5174. end
  5175.  
  5176. function pri_a17_pray_start(actor, npc)
  5177. db.actor:give_info_portion("pri_a17_pray_start")
  5178. end
  5179.  
  5180. function zat_b38_open_info(actor, npc)
  5181. db.actor:give_info_portion("zat_b38_open_info")
  5182. end
  5183.  
  5184. function zat_b38_switch_info(actor, npc)
  5185. db.actor:give_info_portion("zat_b38_switch_info")
  5186. end
  5187. function zat_b38_cop_dead(actor, npc)
  5188. db.actor:give_info_portion("zat_b38_cop_dead")
  5189. end
  5190.  
  5191. function jup_b15_zulus_drink_anim_info(actor, npc)
  5192. db.actor:give_info_portion("jup_b15_zulus_drink_anim_info")
  5193. end
  5194.  
  5195. function pri_a17_preacher_death(actor, npc)
  5196. db.actor:give_info_portion("pri_a17_preacher_death")
  5197. end
  5198.  
  5199. function zat_b3_tech_surprise_anim_end(actor, npc)
  5200. db.actor:give_info_portion("zat_b3_tech_surprise_anim_end")
  5201. end
  5202.  
  5203. function zat_b3_tech_waked_up(actor, npc)
  5204. db.actor:give_info_portion("zat_b3_tech_waked_up")
  5205. end
  5206.  
  5207. function zat_b3_tech_drinked_out(actor, npc)
  5208. db.actor:give_info_portion("zat_b3_tech_drinked_out")
  5209. end
  5210.  
  5211. function pri_a28_kirillov_hq_online(actor, npc)
  5212. db.actor:give_info_portion("pri_a28_kirillov_hq_online")
  5213. end
  5214.  
  5215. function pri_a20_radio_start(actor, npc)
  5216. db.actor:give_info_portion("pri_a20_radio_start")
  5217. end
  5218.  
  5219. function pri_a22_kovalski_speak(actor, npc)
  5220. db.actor:give_info_portion("pri_a22_kovalski_speak")
  5221. end
  5222.  
  5223. function zat_b38_underground_door_open(actor, npc)
  5224. db.actor:give_info_portion("zat_b38_underground_door_open")
  5225. end
  5226.  
  5227. function zat_b38_jump_tonnel_info(actor, npc)
  5228. db.actor:give_info_portion("zat_b38_jump_tonnel_info")
  5229. end
  5230.  
  5231. function jup_a9_cam1_actor_anim_end(actor, npc)
  5232. db.actor:give_info_portion("jup_a9_cam1_actor_anim_end")
  5233. end
  5234.  
  5235. function pri_a28_talk_ssu_video_end(actor, npc)
  5236. db.actor:give_info_portion("pri_a28_talk_ssu_video_end")
  5237. end
  5238.  
  5239. function set_torch_state(actor, npc, p)
  5240. if p == nil or p[2] == nil then
  5241. printf("Not enough parameters in 'set_torch_state' function!")
  5242. end
  5243.  
  5244. local obj = get_story_object(p[1])
  5245.  
  5246. if not obj then
  5247. return
  5248. end
  5249. local torch = obj:object("device_torch")
  5250. if torch then
  5251. if p[2] == "on" then
  5252. torch:enable_attachable_item(true)
  5253. elseif p[2] == "off" then
  5254. torch:enable_attachable_item(false)
  5255. end
  5256. end
  5257. end
  5258.  
  5259.  
  5260. local actor_nightvision = false
  5261. local actor_torch = false
  5262.  
  5263. function disable_actor_nightvision(actor, npc)
  5264. local nightvision = db.actor:object("device_torch")
  5265. if not (nightvision) then
  5266. return
  5267. end
  5268. if nightvision:night_vision_enabled() then
  5269. nightvision:enable_night_vision(false)
  5270. actor_nightvision = true
  5271. end
  5272. end
  5273.  
  5274. function enable_actor_nightvision(actor, npc)
  5275. local nightvision = db.actor:object("device_torch")
  5276. if not (nightvision) then
  5277. return
  5278. end
  5279. if not nightvision:night_vision_enabled() and actor_nightvision then
  5280. nightvision:enable_night_vision(true)
  5281. actor_nightvision = false
  5282. end
  5283. end
  5284.  
  5285. function disable_actor_torch(actor, npc)
  5286. local torch = db.actor:object("device_torch")
  5287. if not (torch) then
  5288. return
  5289. end
  5290. if torch:torch_enabled() then
  5291. torch:enable_torch(false)
  5292. actor_torch = true
  5293. end
  5294. end
  5295.  
  5296. function enable_actor_torch(actor, npc)
  5297. local torch = db.actor:object("device_torch")
  5298. if not (torch) then
  5299. return
  5300. end
  5301. if not torch:torch_enabled() and actor_torch then
  5302. torch:enable_torch(true)
  5303. actor_torch = false
  5304. end
  5305. end
  5306.  
  5307.  
  5308. function create_cutscene_actor_with_weapon(actor, npc, p)
  5309. --' p[1] - секция кого спаунить
  5310. --' p[2] - имя патрульного пути где спаунить.
  5311. --' p[3] - точка патрульного пути
  5312. --' p[4] - поворот по оси Y
  5313. --' p[5] - принудительный слот - будет работать даже при disable_ui
  5314. local spawn_sect = p[1]
  5315. if spawn_sect == nil then
  5316. printf("Wrong spawn section for 'spawn_object' function %s. For object %s", tostring(spawn_sect), obj:name())
  5317. end
  5318.  
  5319. local path_name = p[2]
  5320. if path_name == nil then
  5321. printf("Wrong path_name for 'spawn_object' function %s. For object %s", tostring(path_name), obj:name())
  5322. end
  5323.  
  5324. if not level.patrol_path_exists(path_name) then
  5325. printf("Path %s doesnt exist. Function 'spawn_object' for object %s ", tostring(path_name), obj:name())
  5326. end
  5327. local ptr = patrol(path_name)
  5328. local index = p[3] or 0
  5329. local yaw = p[4] or 0
  5330.  
  5331. local npc = alife_create(spawn_sect, ptr:point(index), ptr:level_vertex_id(0), ptr:game_vertex_id(0))
  5332. if IsStalker( nil, npc:clsid()) then
  5333. npc:o_torso().yaw = yaw * math.pi / 180
  5334. else
  5335. npc.angle.y = yaw * math.pi / 180
  5336. end
  5337.  
  5338. local slot_override = p[5] or 0
  5339.  
  5340. local slot
  5341. local active_item
  5342.  
  5343. if slot_override == 0 then
  5344. slot = db.actor:active_slot()
  5345. if(slot~=2 and slot~=3) then
  5346. return
  5347. end
  5348. active_item = db.actor:active_item()
  5349. else
  5350. if db.actor:item_in_slot(slot_override) ~= nil then
  5351. active_item = db.actor:item_in_slot(slot_override)
  5352. else
  5353. if db.actor:item_in_slot(3) ~= nil then
  5354. active_item = db.actor:item_in_slot(3)
  5355. elseif db.actor:item_in_slot(2) ~= nil then
  5356. active_item = db.actor:item_in_slot(2)
  5357. else
  5358. return
  5359. end
  5360. end
  5361. end
  5362.  
  5363. local actor_weapon = alife_object(active_item:id())
  5364. local section_name = actor_weapon:section_name()
  5365. if section_name == "pri_a17_gauss_rifle" then
  5366. section_name = "wpn_gauss"
  5367. end
  5368.  
  5369. if (active_item) then
  5370. local new_weapon = alife_create(section_name,
  5371. ptr:point(index),
  5372. ptr:level_vertex_id(0),
  5373. ptr:game_vertex_id(0),
  5374. npc.id)
  5375. if section_name ~= "wpn_gauss" then
  5376. new_weapon:clone_addons(actor_weapon)
  5377. end
  5378. end
  5379. end
  5380.  
  5381. -- Заставить играть уникальные анимации сна(у кровососа)
  5382. function set_force_sleep_animation(actor, npc, p)
  5383. local num = p[1]
  5384. npc:force_stand_sleep_animation(tonumber(num))
  5385. end
  5386. -- Убрать уникальные анимации сна(у кровососа)
  5387. function release_force_sleep_animation(actor, npc)
  5388. npc:release_stand_sleep_animation()
  5389. end
  5390.  
  5391. function zat_b33_pic_snag_container(actor, npc)
  5392. if xr_conditions.actor_in_zone(actor, npc, {"zat_b33_tutor"}) then
  5393. give_actor(actor, npc, {"zat_b33_safe_container"})
  5394. db.actor:give_info_portion("zat_b33_find_package")
  5395. if not has_alife_info("zat_b33_safe_container") then
  5396. local zone = db.zone_by_name["zat_b33_tutor"]
  5397. play_sound(actor, zone, {"pda_news"})
  5398. end
  5399. end
  5400. end
  5401.  
  5402. --Отключение воздействия вражеского нпс на индикатор видимости врага на хаде игрока.
  5403. --Исп. только из логики нпс.
  5404. function set_visual_memory_enabled(actor, npc, p)
  5405. if (p and p[1]) and (tonumber(p[1]) >= 0) and (tonumber(p[1]) <= 1) then
  5406. local boolval = false
  5407. if (tonumber(p[1]) == 1) then
  5408. boolval = true
  5409. end
  5410. npc:set_visual_memory_enabled(boolval)
  5411. end
  5412. end
  5413.  
  5414. function disable_memory_object (actor, npc)
  5415. local best_enemy = npc:best_enemy()
  5416. if best_enemy then
  5417. npc:enable_memory_object(best_enemy, false)
  5418. end
  5419. end
  5420.  
  5421. function zat_b202_spawn_b33_loot(actor, npc, p)
  5422. local info_table = {
  5423. "zat_b33_first_item_gived",
  5424. "zat_b33_second_item_gived",
  5425. "zat_b33_third_item_gived",
  5426. "zat_b33_fourth_item_gived",
  5427. "zat_b33_fifth_item_gived"
  5428. }
  5429. local item_table = {}
  5430. item_table[1] = {
  5431. "wpn_fort_snag"
  5432. }
  5433. item_table[2] = {
  5434. "medkit_scientic",
  5435. "medkit_scientic",
  5436. "medkit_scientic",
  5437. "antirad",
  5438. "antirad",
  5439. "antirad",
  5440. "bandage",
  5441. "bandage",
  5442. "bandage",
  5443. "bandage",
  5444. "bandage"
  5445. }
  5446. item_table[3] = {
  5447. "wpn_ak74u_snag"
  5448. }
  5449. item_table[4] = {
  5450. "af_soul"
  5451. }
  5452. item_table[5] = {
  5453. "helm_hardhat_snag"
  5454. }
  5455. for k,v in pairs(info_table) do
  5456. local obj_id
  5457. if (k == 1) or (k == 3) then
  5458. obj_id = "jup_b202_stalker_snag"
  5459. else
  5460. obj_id = "jup_b202_snag_treasure"
  5461. end
  5462. if not has_alife_info(tostring(v)) then
  5463. for l,m in pairs(item_table[k]) do
  5464. -- printf("zat_b202_spawn_b33_loot: number [%s] item [%s] to [%s]", tostring(k), tostring(m), tostring(obj_id))
  5465. spawn_object_in(actor, npc, {tostring(m),tostring(obj_id)})
  5466. end
  5467. end
  5468. end
  5469. end
  5470.  
  5471. function set_monster_animation (actor, npc, p)
  5472. if not (p and p[1]) then
  5473. printf("Wrong parameters in function 'set_monster_animation'!!!")
  5474. end
  5475. npc:set_override_animation (p[1])
  5476. end
  5477.  
  5478. function clear_monster_animation (actor, npc)
  5479. npc:clear_override_animation ()
  5480. end
  5481.  
  5482. local actor_position_for_restore
  5483. local actor_direction_for_restore
  5484.  
  5485. function save_actor_position()
  5486. actor_position_for_restore = get_story_object("actor"):position()
  5487. --actor_direction_for_restore = get_story_object("actor"):direction()
  5488. end
  5489.  
  5490. function restore_actor_position()
  5491. --db.actor:set_actor_direction(actor_direction_for_restore)
  5492. db.actor:set_actor_position(actor_position_for_restore)
  5493. end
  5494.  
  5495. function upgrade_hint(actor, npc, p)
  5496. if(p) then
  5497. inventory_upgrades.cur_hint = p
  5498. end
  5499. end
  5500.  
  5501. function force_obj(actor, npc, p)
  5502. local obj = get_story_object(p[1])
  5503. if not obj then
  5504. printf("'force_obj' Target object does not exist")
  5505. return
  5506. end
  5507. if p[2] == nil then p[2] = 20 end
  5508. if p[3] == nil then p[3] = 100 end
  5509. obj:set_const_force(VEC_Y, p[2], p[3])
  5510. end
  5511.  
  5512. function pri_a28_check_zones()
  5513. local story_obj_id
  5514. local dist
  5515. local index = 0
  5516.  
  5517. local zones_tbl = {
  5518. [1] = "pri_a28_sr_mono_add_1",
  5519. [2] = "pri_a28_sr_mono_add_2",
  5520. [3] = "pri_a28_sr_mono_add_3",
  5521. }
  5522.  
  5523. local info_tbl = {
  5524. [1] = "pri_a28_wave_1_spawned",
  5525. [2] = "pri_a28_wave_2_spawned",
  5526. [3] = "pri_a28_wave_3_spawned",
  5527. }
  5528.  
  5529. local squad_tbl = {
  5530. [1] = "pri_a28_heli_mono_add_1",
  5531. [2] = "pri_a28_heli_mono_add_2",
  5532. [3] = "pri_a28_heli_mono_add_3",
  5533. }
  5534.  
  5535. for k,v in pairs(zones_tbl) do
  5536. story_obj_id = get_story_object_id(v)
  5537. if story_obj_id then
  5538. local se_obj = alife_object(story_obj_id)
  5539. local curr_dist = se_obj.position:distance_to(db.actor:position())
  5540. if index == 0 then
  5541. dist = curr_dist
  5542. index = k
  5543. elseif dist < curr_dist then
  5544. dist = curr_dist
  5545. index = k
  5546. end
  5547. end
  5548. end
  5549.  
  5550. if index == 0 then
  5551. printf("Found no distance or zones in func 'pri_a28_check_zones'")
  5552. end
  5553.  
  5554. if has_alife_info(info_tbl[index]) then
  5555. for k,v in pairs(info_tbl) do
  5556. if not has_alife_info(info_tbl[k]) then
  5557. db.actor:give_info_portion(info_tbl[k])
  5558. end
  5559. end
  5560. else
  5561. db.actor:give_info_portion(info_tbl[index])
  5562. end
  5563.  
  5564. create_squad(db.actor,nil,{squad_tbl[index],"pri_a28_heli"})
  5565. end
  5566.  
  5567. function eat_vodka_script()
  5568. if db.actor:object("vodka_script") ~= nil then
  5569. db.actor:eat(db.actor:object("vodka_script"))
  5570. end
  5571. end
  5572.  
  5573. local mat_table = {
  5574. "jup_b200_material_1",
  5575. "jup_b200_material_2",
  5576. "jup_b200_material_3",
  5577. "jup_b200_material_4",
  5578. "jup_b200_material_5",
  5579. "jup_b200_material_6",
  5580. "jup_b200_material_7",
  5581. "jup_b200_material_8",
  5582. "jup_b200_material_9",
  5583. }
  5584.  
  5585. function jup_b200_count_found(actor)
  5586. local cnt = 0
  5587.  
  5588. for k,v in pairs(mat_table) do
  5589. local material_obj = get_story_object(v)
  5590. if material_obj then
  5591. local parent = material_obj:parent()
  5592. if parent then
  5593. local parent_id = parent:id()
  5594. if parent_id ~= 65535 and parent_id == actor:id() then
  5595. cnt = cnt + 1
  5596. end
  5597. end
  5598. end
  5599. end
  5600.  
  5601. cnt = cnt + load_var(actor, "jup_b200_tech_materials_brought_counter", 0)
  5602. save_var(actor, "jup_b200_tech_materials_found_counter", cnt)
  5603. end
  5604.  
  5605. function sr_teleport(actor,npc,p)
  5606. ui_sr_teleport.msg_box_ui(npc,p and p[1],p and p[2])
  5607. end
  5608.  
  5609. function make_a_wish(actor,npc,p)
  5610.  
  5611.  
  5612. -- ///////////////////////////////////////////////////////////////////////////////////////////////
  5613. --
  5614. -- End Find Wish Granter Storyline Task
  5615. --
  5616. -- Added by DoctorX
  5617. -- October 13, 2016
  5618. --
  5619. -- -----------------------------------------------------------------------------------------------
  5620.  
  5621. -- Remove on find wish granter infoportion:
  5622. disable_info( "drx_sl_on_find_wish_granter" )
  5623.  
  5624. -- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  5625.  
  5626.  
  5627. local action_list = {}
  5628.  
  5629. action_list[1] = function()
  5630. local str = game.translate_string("st_zone_disappeared")
  5631. error(str,2)
  5632. return
  5633. end
  5634.  
  5635. action_list[2] = function()
  5636. give_info("actor_made_wish")
  5637. give_info("actor_made_wish_for_control")
  5638. return
  5639. end
  5640.  
  5641. action_list[3] = function()
  5642. local sim = alife()
  5643. local function remove_this_squad(id)
  5644. local squad = id and sim:object(id)
  5645. if not (squad) then
  5646. return true
  5647. end
  5648.  
  5649. printf("DEBUG: removing squad %s from the game",squad:name())
  5650. SIMBOARD:assign_squad_to_smart(squad, nil)
  5651. squad:remove_squad()
  5652. return true
  5653. end
  5654. local squad
  5655. for i=1,65534 do
  5656. squad = sim:object(i)
  5657. if (squad and squad:clsid() == clsid.online_offline_group_s) then
  5658. CreateTimeEvent("remove_this_squad",squad.id,math.random(1,10),remove_this_squad,squad.id)
  5659. end
  5660. end
  5661. give_info("actor_made_wish_for_peace")
  5662. give_info("actor_made_wish")
  5663. return
  5664. end
  5665.  
  5666. action_list[4] = function()
  5667. local sim = alife()
  5668. local s_find = string.find
  5669. local ltx = ini_file("plugins\\spawner_blacklist.ltx")
  5670. local pos = db.actor:position()
  5671. local lid = db.actor:level_vertex_id()
  5672. local gid = db.actor:game_vertex_id()
  5673. ini_sys:section_for_each( function(section)
  5674. local cost = ini_sys:r_float_ex(section,"cost")
  5675. if cost and cost > 0 and (not ltx:line_exist("ignore_sections",section)) then
  5676. local parent = ini_sys:r_string_ex(section,"parent_section")
  5677. local qst_itm = ini_sys:r_bool_ex(section,"quest_item")
  5678. local anm_itm = IsItem("anim",section)
  5679. local tch_itm = s_find(section,"tch_") and true or false
  5680. local bse_itm = s_find(section,"base") and true or false
  5681. local main_itm = (not parent) or (parent and parent == section)
  5682.  
  5683. if not (qst_itm and anm_itm and tch_itm and bse_itm and main_itm) then
  5684. local x = ini_sys:r_float_ex(section,"inv_grid_x")
  5685. local y = ini_sys:r_float_ex(section,"inv_grid_y")
  5686. if (x and x ~= 0) and (y and y ~= 0) then
  5687. sim:create(section, pos, lid, gid, AC_ID)
  5688. end
  5689. end
  5690. end
  5691. end)
  5692.  
  5693. local function remove_backpack(id)
  5694. local function itr(npc,itm)
  5695. if (itm:section() == "itm_actor_backpack" or itm:section() == "itm_backpack") then
  5696. alife_release_id(itm:id())
  5697. return
  5698. end
  5699. end
  5700. db.actor:iterate_inventory(itr,db.actor)
  5701. end
  5702.  
  5703. CreateTimeEvent(0,"remove_backpack",1,remove_backpack,0)
  5704.  
  5705. give_info("actor_made_wish_for_riches")
  5706. give_info("actor_made_wish")
  5707. return
  5708. end
  5709.  
  5710. action_list[5] = function()
  5711. local se_actor = alife():actor()
  5712. local data = utils_stpk.get_actor_data(se_actor)
  5713. if (data) then
  5714. data.specific_character = "actor_zombied"
  5715. utils_stpk.set_actor_data(data,se_actor)
  5716. end
  5717.  
  5718. set_actor_true_community("zombied")
  5719. give_info("actor_made_wish_immortal")
  5720. give_info("actor_made_wish")
  5721.  
  5722. -- local spawn_path = patrol("spawn_player_stalker")
  5723. -- if (spawn_path) then
  5724. -- local pos = spawn_path:point(0)
  5725. -- local lvid = spawn_path:level_vertex_id(0)
  5726. -- local gvid = spawn_path:game_vertex_id(0)
  5727. -- local gg = game_graph()
  5728. -- if (gvid and gg:valid_vertex_id(gvid)) then
  5729. -- ChangeLevel(pos,lvid,gvid,VEC_ZERO)
  5730. -- end
  5731. -- end
  5732.  
  5733. -- Teleports the player to a smashed open grave in the Great Swamp.
  5734. -- Goodwill is increased with the Monolith and Zombified faction to ensure they aren't hostile.
  5735. inc_faction_goodwill_to_actor(db.actor, nil, {"monolith", 5000})
  5736. inc_faction_goodwill_to_actor(db.actor, nil, {"zombied", 5000})
  5737. ChangeLevel(vector():set(266.99, 0.00, -131.07), 310937, 181, VEC_ZERO)
  5738. return
  5739. end
  5740.  
  5741. -- Hide and disable the immortality wish if actor is in Zombified or Monolith factions.
  5742. if (character_community(db.actor) == "actor_zombied" or character_community(db.actor) == "actor_monolith") then
  5743. action_list[5] = nil
  5744. ui_dyn_msg_box.multi_choice(action_list,"st_wish_1","st_wish_2","st_wish_3","st_wish_4","st_wish_99")
  5745. else
  5746. ui_dyn_msg_box.multi_choice(action_list,"st_wish_1","st_wish_2","st_wish_3","st_wish_4","st_wish_5","st_wish_99")
  5747. end
  5748.  
  5749. end
  5750.  
  5751. function clear_logic(actor,npc,p)
  5752. local st = db.storage[npc:id()]
  5753. st.ini, st.ini_filename = xr_logic.get_customdata_or_ini_file(npc, "<customdata>")
  5754. st.active_section = nil
  5755. st.active_scheme = nil
  5756. st.section_logic = "logic"
  5757. xr_logic.switch_to_section(npc,nil,nil)
  5758. end
  5759.  
  5760. function set_new_scheme_and_logic(actor,npc,p)
  5761. local st = db.storage[npc:id()]
  5762. st.ini_filename = ini_filename
  5763. st.ini = ini_file(ini_filename)
  5764. if not (st.ini) then
  5765. printe("!ERROR: set_new_scheme_and_logic: can't find ini %s",ini_filename)
  5766. return
  5767. end
  5768.  
  5769. -- Set new section logic
  5770. st.section_logic = logic
  5771.  
  5772. -- Select new active section
  5773. local new_section = section or xr_logic.determine_section_to_activate(npc, st.ini, st.section_logic)
  5774.  
  5775. -- Switch to new section
  5776. xr_logic.switch_to_section(npc, st.ini, new_section)
  5777. st.overrides = xr_logic.cfg_get_overrides(st.ini, new_section, npc)
  5778. end
  5779.  
  5780. function set_script_danger(actor,npc,p)
  5781. xr_danger.set_script_danger(npc,p and tonumber(p[1]) or 5000)
  5782. end
  5783.  
  5784. function spawn_npc_at_position(actor,npc,p)
  5785. if not (p) then return end
  5786. local pos = vector():set(tonumber(p[2]),tonumber(p[3]),tonumber(p[4]))
  5787. alife_create(p[1],pos,p[5],p[6])
  5788. end
  5789.  
  5790. function kill_obj_on_job(actor,npc,p)
  5791. local board = SIMBOARD
  5792. local smart = p[1] and board and board.smarts_by_names[p[1]]
  5793. local obj = smart and smart.npc_by_job_section["logic@"..p[2]]
  5794. obj = obj and level.object_by_id(obj)
  5795. if not obj or not obj:alive() then
  5796. return false
  5797. end
  5798. local h = hit()
  5799.  
  5800. h:bone("bip01_neck")
  5801. h.power = 1
  5802. h.impulse = 1
  5803. h.direction = vec_sub(npc:position(), obj:position())
  5804. h.draftsman = npc
  5805. h.type = hit.wound
  5806. obj:hit(h)
  5807. end
  5808.  
  5809. function obj_at_job_switch_section(actor,npc,p)
  5810. local board = SIMBOARD
  5811. local smart = p[1] and board and board.smarts_by_names[p[1]]
  5812. local obj = smart and smart.npc_by_job_section["logic@"..p[2]]
  5813. obj = obj and level.object_by_id(obj)
  5814. if not obj or not obj:alive() then
  5815. return
  5816. end
  5817.  
  5818. local st = db.storage[obj:id()]
  5819. if not (st) then
  5820. return
  5821. end
  5822. xr_logic.switch_to_section(obj, st.ini, p[3])
  5823. end
  5824.  
  5825. function change_visual(actor,npc,p)
  5826. if (not axr_main) then
  5827. return
  5828. end
  5829. local sobj = alife_object(npc:id())
  5830. if not (sobj) then
  5831. return
  5832. end
  5833. if (axr_main) then
  5834. CreateTimeEvent(sobj.id,"update_visual",1,update_visual,sobj.id,p[1])
  5835. end
  5836. end
  5837.  
  5838. function switch_offline(actor,npc,p)
  5839. local se_obj = npc and alife_object(npc:id())
  5840. if (se_obj and se_obj:can_switch_offline()) then
  5841. se_obj:switch_offline()
  5842. end
  5843. end
  5844.  
  5845. ------------------- util functions
  5846. function update_visual(id,vis)
  5847. local se_npc = id and alife_object(id)
  5848. if not (se_npc) then
  5849. return true
  5850. end
  5851.  
  5852. if (se_npc.online) then
  5853. se_npc:switch_offline()
  5854. return false
  5855. end
  5856.  
  5857. if not (vis) then
  5858. return true
  5859. end
  5860.  
  5861. local data = utils_stpk.get_stalker_data(se_npc)
  5862. if (data) then
  5863. data.visual_name = vis
  5864. utils_stpk.set_stalker_data(data,se_npc)
  5865. end
  5866. return true
  5867. end
  5868.  
  5869.  
  5870. function up_start()
  5871. --up.up_objects_spawn()
  5872. --up.up_stalkers_spawn()
  5873. end
  5874.  
  5875. function up_freeplay()
  5876. --up.freeplay_clean_territory()
  5877. end
  5878.  
  5879. function stop_sr_cutscene(actor,npc,p)
  5880. local obj = db.storage[npc:id()]
  5881. if(obj.active_scheme~=nil) then
  5882. obj[obj.active_scheme].signals["cam_effector_stop"] = true
  5883. end
  5884. end
  5885.  
  5886. function update_weather(actor, npc, p)
  5887. if p and p[1] then
  5888. if p[1] == "true" then
  5889. level_weathers.get_weather_manager():select_weather(true)
  5890. elseif p[1] == "false" then
  5891. level_weathers.get_weather_manager():select_weather(false)
  5892. end
  5893. end
  5894. end
  5895.  
  5896. --X16 machine switch off
  5897. function yan_gluk (actor, npc)
  5898.  
  5899. local sound_obj_l = xr_sound.get_safe_sound_object( [[affects\psy_blackout_l]] )
  5900. local sound_obj_r = xr_sound.get_safe_sound_object( [[affects\psy_blackout_r]] )
  5901.  
  5902. sound_obj_l:play_no_feedback(db.actor, sound_object.s2d, 0, vector():set(-1, 0, 1), 1.0, 1.0)
  5903. sound_obj_r:play_no_feedback(db.actor, sound_object.s2d, 0, vector():set( 1, 0, 1), 1.0, 1.0)
  5904. level.add_cam_effector("camera_effects\\earthquake.anm", 1974, false, "")
  5905. end
  5906.  
  5907. function yan_saharov_message(actor, npc, p)
  5908. local actor_comm = get_actor_true_community()
  5909. if (not game_relations.is_factions_enemies(actor_comm,"ecolog")) then
  5910. if (p[1] == 1) then
  5911. news_manager.send_tip(db.actor, "st_yan_saharov_message", nil, "saharov", 15000, nil)
  5912. db.actor:give_info_portion("labx16_find")
  5913. elseif (p[1] == 2) and db.actor:object("bad_psy_helmet") then
  5914. news_manager.send_tip(db.actor, "st_yan_saharov_message_2", nil, "saharov", 20000, nil)
  5915. elseif (p[1] == 3) then
  5916. news_manager.send_tip(db.actor, "st_yan_saharov_message_3", nil, "saharov", 15000, nil)
  5917. elseif (p[1] == "free_upgrade") then
  5918. news_manager.send_tip(db.actor, "st_yan_saharov_message_free_upgrade", nil, "saharov", 15000, nil)
  5919. end
  5920. end
  5921. end
  5922.  
  5923. --X18 dream
  5924. function x18_gluk (actor, npc)
  5925. level.add_pp_effector ("blink.ppe", 234, false)
  5926. local sound_obj_l = xr_sound.get_safe_sound_object( [[affects\psy_blackout_l]] )
  5927. local sound_obj_r = xr_sound.get_safe_sound_object( [[affects\psy_blackout_r]] )
  5928. local snd_obj = xr_sound.get_safe_sound_object( [[affects\tinnitus3a]] )
  5929. snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0, 1.0)
  5930. sound_obj_l:play_no_feedback(db.actor, sound_object.s2d, 0, vector():set(-1, 0, 1), 1.0, 1.0)
  5931. sound_obj_r:play_no_feedback(db.actor, sound_object.s2d, 0, vector():set( 1, 0, 1), 1.0, 1.0)
  5932. level.add_cam_effector("camera_effects\\earthquake.anm", 1974, false, "")
  5933. end
  5934.  
  5935. function end_yantar_dream(actor, npc)
  5936. db.actor:give_info_portion("yantar_find_ghost_task_start")
  5937. end
  5938.  
  5939. function end_x18_dream(actor, npc)
  5940. db.actor:give_info_portion("dar_x18_dream")
  5941. end
  5942.  
  5943. function end_radar_dream(actor, npc)
  5944. db.actor:give_info_portion("bun_patrol_start")
  5945. end
  5946.  
  5947. function end_warlab_dream(actor, npc)
  5948. db.actor:give_info_portion("end_warlab_dream")
  5949. end
  5950.  
  5951. function end_final_peace(actor, npc)
  5952. db.actor:give_info_portion("end_final_peace")
  5953. end
  5954.  
  5955. ---------------------------------------------------------
  5956. -- Sarcofag2
  5957. ---------------------------------------------------------
  5958.  
  5959. function aes_earthshake (npc)
  5960. local snd_obj = xr_sound.get_safe_sound_object([[ambient\earthquake]])
  5961. snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0, 1.0)
  5962. level.add_cam_effector("camera_effects\\earthquake.anm", 1974, false, "")
  5963. --set_postprocess ("scripts\\earthshake.ltx")
  5964. end
  5965.  
  5966. function oso_init_dialod ()
  5967. -- local oso = level_object_by_sid(osoznanie)
  5968. -- db.actor:run_talk_dialog(oso)
  5969. end
  5970.  
  5971. function warlab_stop_particle(actor, npc, p)
  5972. db.actor:stop_particles("anomaly2\\control_monolit_holo", "link")
  5973. end
  5974.  
  5975. function play_snd_from_obj(actor, npc, p)
  5976. if p[1] and p[2] then
  5977. local snd_obj = xr_sound.get_safe_sound_object(p[2])
  5978. local obj = level_object_by_sid(p[1])
  5979. if obj ~= nil then
  5980. printf("can't find object with story id %s", tostring(p[1]))
  5981.  
  5982. -- snd_obj:play_at_pos(obj, obj:position(), sound_object.s3d)
  5983. snd_obj:play_no_feedback(obj, sound_object.s3d, 0, obj:position(), 1.0, 1.0)
  5984. end
  5985. end
  5986. end
  5987.  
  5988. function play_snd(actor, npc, p)
  5989. if p[1] then
  5990. local snd_obj = xr_sound.get_safe_sound_object(p[1])
  5991. --snd_obj:play(actor, p[2] or 0, sound_object.s2d)
  5992. snd_obj:play_no_feedback(actor, sound_object.s2d, p[2] or 0, vector(), 1.0, 1.0)
  5993. end
  5994. end
  5995.  
  5996. function erase_pstor_ctime(actor,npc,p)
  5997. if not (p[1]) then
  5998. return
  5999. end
  6000.  
  6001. save_ctime(db.actor,p[1],nil)
  6002. end
  6003.  
  6004. -- Shows progress bar health for last hit enemy with db.storage[id].show_health = true
  6005. -- param 1: Story ID
  6006. -- param 2: true or false; default is true. True will set db.storage[id].show_health = true while false will remove custom static from screen
  6007. function show_health(actor,npc,p)
  6008. if (p[2] == "false") then
  6009. ui_enemy_health.cs_remove()
  6010. else
  6011. local id = get_story_object_id(p[1])
  6012. local st = id and db.storage[id]
  6013. if (st) then
  6014. st.show_health = true
  6015. end
  6016. end
  6017. end
  6018.  
  6019.  
  6020. function disable_monolith_zones(actor,npc,p)
  6021. local remove_sections = {
  6022. ["zone_monolith"] = true
  6023. }
  6024. local sim = alife()
  6025. for i=1,65534 do
  6026. local se_obj = sim:object(i)
  6027. if (se_obj and remove_sections[se_obj:section_name()]) then
  6028. alife_release(se_obj)
  6029. end
  6030. end
  6031. end
  6032.  
  6033. function disable_generator_zones(actor,npc,p)
  6034. local remove_sections = {
  6035. ["generator_torrid"] = true,
  6036. ["generator_dust"] = true,
  6037. ["generator_electra"] = true,
  6038. ["generator_dust_static"] = true
  6039. }
  6040. local sim = alife()
  6041. for i=1,65534 do
  6042. local se_obj = sim:object(i)
  6043. if (se_obj and remove_sections[se_obj:section_name()]) then
  6044. alife_release(se_obj)
  6045. end
  6046. end
  6047. end
  6048.  
  6049. --OLD ARENA
  6050. function bar_arena_hit(actor, npc)
  6051. local h = hit()
  6052. h.power = 0.01
  6053. h.direction = npc:direction()
  6054. h.draftsman = db.actor
  6055. h.impulse = 1
  6056. h.type = hit.wound
  6057. npc:hit(h)
  6058. end
  6059.  
  6060. function bar_arena_introduce(actor, npc)
  6061. if db.actor:has_info("bar_arena_pseudodog_choosen") then
  6062. news_manager.send_tip(db.actor, "bar_arena_fight_pseudodog", nil, "arena", 24000, nil)
  6063. elseif db.actor:has_info("bar_arena_snork_choosen") then
  6064. news_manager.send_tip(db.actor, "bar_arena_fight_snork", nil, "arena", 30000, nil)
  6065. elseif db.actor:has_info("bar_arena_bloodsucker_choosen") then
  6066. news_manager.send_tip(db.actor, "bar_arena_fight_bloodsucker", nil, "arena", 30000, nil)
  6067. elseif db.actor:has_info("bar_arena_burer_choosen") then
  6068. news_manager.send_tip(db.actor, "bar_arena_fight_burer", nil, "arena", 52000, nil)
  6069. elseif db.actor:has_info("bar_arena_savage_choosen") then
  6070. news_manager.send_tip(db.actor, "bar_arena_fight_savage", nil, "arena", 34000, nil)
  6071. end
  6072. end
  6073.  
  6074. function bar_arena_fight_begin(actor, npc)
  6075. if db.actor:has_info("bar_arena_actor_lose") or db.actor:has_info("bar_arena_actor_victory") then
  6076. return
  6077. end
  6078.  
  6079. news_manager.send_tip(db.actor, "bar_arena_fight_begin", nil, "arena")
  6080. end
  6081.  
  6082. function bar_arena_fight_10(actor, npc)
  6083. news_manager.send_tip(db.actor, "bar_arena_fight_10", nil, "arena")
  6084. end
  6085.  
  6086. function bar_arena_fight_20(actor, npc)
  6087. news_manager.send_tip(db.actor, "bar_arena_fight_20", nil, "arena")
  6088. end
  6089.  
  6090. function bar_arena_fight_30(actor, npc)
  6091. news_manager.send_tip(db.actor, "bar_arena_fight_30", nil, "arena")
  6092. end
  6093.  
  6094. function bar_arena_fight_40(actor, npc)
  6095. news_manager.send_tip(db.actor, "bar_arena_fight_40", nil, "arena")
  6096. end
  6097.  
  6098. function bar_arena_fight_50(actor, npc)
  6099. news_manager.send_tip(db.actor, "bar_arena_fight_50", nil, "arena")
  6100. end
  6101.  
  6102. function bar_arena_fight_60(actor, npc)
  6103. news_manager.send_tip(db.actor, "bar_arena_fight_60", nil, "arena")
  6104. end
  6105.  
  6106. function bar_arena_fight_70(actor, npc)
  6107. news_manager.send_tip(db.actor, "bar_arena_fight_70", nil, "arena")
  6108. end
  6109.  
  6110. function bar_arena_fight_80(actor, npc)
  6111. news_manager.send_tip(db.actor, "bar_arena_fight_80", nil, "arena")
  6112. end
  6113.  
  6114. function bar_arena_fight_90(actor, npc)
  6115. news_manager.send_tip(db.actor, "bar_arena_fight_90", nil, "arena")
  6116. end
  6117.  
  6118. function bar_arena_check_lose(actor, npc)
  6119. if db.actor:has_info("bar_arena_100_p") then
  6120. if db.actor:has_info("bar_arena_fight_30") then
  6121. db.actor:give_info_portion("bar_arena_actor_lose")
  6122. news_manager.send_tip(actor, "bar_arena_fight_timeout", nil, "arena")
  6123. end
  6124. return
  6125. end
  6126. if db.actor:has_info("bar_arena_50_p") then
  6127. if db.actor:has_info("bar_arena_fight_90") then
  6128. db.actor:give_info_portion("bar_arena_actor_lose")
  6129. news_manager.send_tip(actor, "bar_arena_fight_timeout", nil, "arena")
  6130. end
  6131. return
  6132. end
  6133. end
  6134.  
  6135. function bar_arena_after_fight(actor, npc)
  6136. if db.actor:has_info("bar_arena_actor_lose") or db.actor:has_info("bar_arena_actor_victory") then
  6137. return
  6138. end
  6139.  
  6140. if db.actor:dont_has_info("bar_arena_actor_lose") then
  6141. db.actor:give_info_portion("bar_arena_actor_victory")
  6142. news_manager.send_tip(actor, "bar_arena_fight_victory", nil, "arena")
  6143. else
  6144. news_manager.send_tip(actor, "bar_arena_fight_lose", nil, "arena")
  6145. end
  6146.  
  6147. db.actor:give_info_portion("bar_arena_start_introduce")
  6148. end
  6149.  
  6150. function bar_arena_actor_afraid(actor, npc)
  6151. news_manager.send_tip(db.actor, "bar_arena_actor_afraid", nil, "arena")
  6152. end
  6153.  
  6154. function bar_arena_actor_dead(actor, npc)
  6155. news_manager.send_tip(db.actor, "bar_arena_fight_dead", nil, "arena")
  6156. end
  6157.  
  6158. --NEW ARENA
  6159.  
  6160. function bar_arena_teleport (actor, npc)
  6161. actor_effects.disable_effects_timer(100)
  6162.  
  6163. --hide_hud_inventory()
  6164. hide_hud_all()
  6165.  
  6166. local box = get_story_object("bar_arena_inventory_box")
  6167. if (box) then
  6168. local function transfer_object_item(item)
  6169. db.actor:transfer_item(item, box)
  6170. end
  6171. db.actor:inventory_for_each(transfer_object_item)
  6172. end
  6173.  
  6174. local spawn_items = {}
  6175.  
  6176. if has_alife_info("bar_arena_fight_1") then
  6177. table.insert(spawn_items, "novice_outfit")
  6178. table.insert(spawn_items, "wpn_pm")
  6179.  
  6180. --Mags
  6181. table.insert(spawn_items, "mag_wpn_pm_9x18_fmj_ready")
  6182. table.insert(spawn_items, "mag_wpn_pm_9x18_fmj_ready")
  6183. table.insert(spawn_items, "mag_wpn_pm_9x18_fmj_ready")
  6184.  
  6185. table.insert(spawn_items, "ammo_9x18_pmm")
  6186. table.insert(spawn_items, "ammo_9x18_pmm")
  6187. --table.insert(spawn_items, "wpn_knife")
  6188. elseif has_alife_info("bar_arena_fight_2") then
  6189. table.insert(spawn_items, "stalker_outfit")
  6190. table.insert(spawn_items, "wpn_mp5")
  6191. table.insert(spawn_items, "ammo_9x19_pbp")
  6192.  
  6193. --Mags
  6194. table.insert(spawn_items, "mag_wpn_mp5_9x19_fmj_ready")
  6195. table.insert(spawn_items, "mag_wpn_mp5_9x19_fmj_ready")
  6196. table.insert(spawn_items, "mag_wpn_mp5_9x19_fmj_ready")
  6197.  
  6198. --table.insert(spawn_items, "wpn_knife")
  6199. elseif has_alife_info("bar_arena_fight_3") then
  6200. table.insert(spawn_items, "stalker_outfit")
  6201. table.insert(spawn_items, "wpn_bm16")
  6202. table.insert(spawn_items, "ammo_12x70_buck")
  6203. table.insert(spawn_items, "ammo_12x70_buck")
  6204. --table.insert(spawn_items, "wpn_knife")
  6205. elseif has_alife_info("bar_arena_fight_4") then
  6206. table.insert(spawn_items, "stalker_outfit")
  6207. table.insert(spawn_items, "wpn_ak74")
  6208. table.insert(spawn_items, "ammo_5.45x39_ap")
  6209. table.insert(spawn_items, "ammo_5.45x39_ap")
  6210.  
  6211. --Mags
  6212. table.insert(spawn_items, "mag_wpn_ak74_5.45x39_fmj_ready")
  6213. table.insert(spawn_items, "mag_wpn_ak74_5.45x39_fmj_ready")
  6214. table.insert(spawn_items, "mag_wpn_ak74_5.45x39_fmj_ready")
  6215.  
  6216. --table.insert(spawn_items, "wpn_knife")
  6217. table.insert(spawn_items, "bandage")
  6218. table.insert(spawn_items, "bandage")
  6219. elseif has_alife_info("bar_arena_fight_5") then
  6220. table.insert(spawn_items, "wpn_abakan")
  6221. table.insert(spawn_items, "ammo_5.45x39_ap")
  6222. table.insert(spawn_items, "ammo_5.45x39_ap")
  6223. table.insert(spawn_items, "ammo_5.45x39_ap")
  6224.  
  6225. --Mags
  6226. table.insert(spawn_items, "mag_wpn_abakan_5.45x39_fmj_ready")
  6227. table.insert(spawn_items, "mag_wpn_abakan_5.45x39_fmj_ready")
  6228. table.insert(spawn_items, "mag_wpn_abakan_5.45x39_fmj_ready")
  6229.  
  6230. --table.insert(spawn_items, "wpn_knife")
  6231. table.insert(spawn_items, "bandage")
  6232. table.insert(spawn_items, "medkit")
  6233. table.insert(spawn_items, "svoboda_light_outfit")
  6234. elseif has_alife_info("bar_arena_fight_6") then
  6235. table.insert(spawn_items, "wpn_groza")
  6236. table.insert(spawn_items, "ammo_9x39_ap")
  6237. table.insert(spawn_items, "ammo_9x39_ap")
  6238. table.insert(spawn_items, "ammo_9x39_ap")
  6239.  
  6240. --Mags
  6241. table.insert(spawn_items, "mag_wpn_groza_9x39_pab9_ready")
  6242. table.insert(spawn_items, "mag_wpn_groza_9x39_pab9_ready")
  6243. table.insert(spawn_items, "mag_wpn_groza_9x39_pab9_ready")
  6244.  
  6245. --table.insert(spawn_items, "wpn_knife")
  6246.  
  6247. table.insert(spawn_items, "specops_outfit")
  6248. elseif has_alife_info("bar_arena_fight_7") then
  6249. table.insert(spawn_items, "wpn_knife")
  6250. table.insert(spawn_items, "bandage")
  6251. table.insert(spawn_items, "grenade_f1")
  6252. table.insert(spawn_items, "grenade_f1")
  6253. elseif has_alife_info("bar_arena_fight_8") then
  6254. table.insert(spawn_items, "wpn_g36")
  6255. table.insert(spawn_items, "exo_outfit")
  6256. table.insert(spawn_items, "ammo_5.56x45_ap")
  6257. table.insert(spawn_items, "ammo_5.56x45_ap")
  6258. table.insert(spawn_items, "ammo_5.56x45_ap")
  6259. table.insert(spawn_items, "ammo_5.56x45_ap")
  6260.  
  6261. --Mags
  6262. table.insert(spawn_items, "mag_wpn_g36_5.56x45_fmj_ready")
  6263. table.insert(spawn_items, "mag_wpn_g36_5.56x45_fmj_ready")
  6264. table.insert(spawn_items, "mag_wpn_g36_5.56x45_fmj_ready")
  6265.  
  6266. --table.insert(spawn_items, "wpn_knife")
  6267. end
  6268.  
  6269. local k,v = 0,0
  6270.  
  6271. for k,v in pairs(spawn_items) do
  6272. local se = alife_create(v,
  6273. db.actor:position(),
  6274. db.actor:level_vertex_id(),
  6275. db.actor:game_vertex_id(),
  6276. AC_ID)
  6277. se_save_var( se.id, se:name(), "unpatched", true )
  6278. end
  6279.  
  6280. end
  6281.  
  6282. function bar_arena_weapon_slot (actor,npc,p)
  6283. db.actor:activate_slot(tonumber(p[1]) or 1)
  6284. end
  6285.  
  6286. function bar_arena_teleport_2 (actor, npc)
  6287. actor_effects.disable_effects_timer(100)
  6288. --hide_hud_inventory()
  6289. hide_hud_all()
  6290.  
  6291. -- remove items from actor given to him by arena
  6292. local box = get_story_object("bar_arena_inventory_box_2")
  6293. if (box) then
  6294. local function transfer_object_item(item)
  6295. db.actor:transfer_item(item, box)
  6296. end
  6297. db.actor:inventory_for_each(transfer_object_item)
  6298. end
  6299.  
  6300. -- purge all marked items
  6301. xr_zones.purge_arena_items("bar_arena")
  6302.  
  6303. level.add_pp_effector ("blink.ppe", 234, false)
  6304.  
  6305. db.actor:set_actor_position(patrol("t_walk_2"):point(0))
  6306. local dir = patrol("t_look_2"):point(0):sub(patrol("t_walk_2"):point(0))
  6307. db.actor:set_actor_direction(-dir:getH())
  6308.  
  6309. -- give actor back his items that were taken
  6310. local box = get_story_object("bar_arena_inventory_box")
  6311. if (box) then
  6312. local function transfer_object_item(box,item)
  6313. box:transfer_item(item, db.actor)
  6314. end
  6315. box:iterate_inventory_box(transfer_object_item,box)
  6316. end
  6317. end
  6318.  
  6319. function purge_zone(actor,npc,p)
  6320. if (p and p[1]) then
  6321. xr_zones.purge_arena_items(p[1])
  6322. end
  6323. end
  6324.  
  6325. function clear_weather(actor,npc,p)
  6326.  
  6327. end
  6328.  
  6329. function actor_surge_immuned(actor,npc,p)
  6330. save_var(db.actor,"surge_immuned",p[1] == "true" or nil)
  6331. end
  6332.  
  6333. function force_always_online(actor,npc,p)
  6334. local squad = p[1] and get_story_squad(p[1])
  6335. if not (squad) then
  6336. return
  6337. end
  6338.  
  6339. alife():set_switch_offline(squad.id,false)
  6340. alife():set_switch_online(squad.id,true)
  6341. end
  6342.  
  6343. function set_smart_alarm_status(actor,npc,p)
  6344. local smart = p[1] and SIMBOARD:get_smart_by_name(p[1])
  6345. if (smart) then
  6346. smart:set_alarm()
  6347. end
  6348. end
  6349.  
  6350. function setup_base_defense_fail_conditions(actor,npc,p)
  6351. save_var(db.actor,"base_defense_level",level.name())
  6352. end
  6353. --// AWR (Функция отправки сообщения об окончании времени, отключение ламп, закрытия UI)
  6354. function awr_timer_msg_off(actor,npc,p)
  6355. local npc_name = npc:section()
  6356. if not (db.actor:has_info(string.format("awr_%s_dead", npc_name))) then
  6357. bind_awr.dout('xr_effects', 'Timer off for %s', npc_name)
  6358. actor_menu.set_item_news('fail', 'detail', "st_awr_timer_msg_off")
  6359. bind_awr.Lamp(npc:section(), false)
  6360. bind_awr.CloseDl()
  6361. db.actor:disable_info_portion(string.format('awr_%s_access', npc_name))
  6362. else
  6363. bind_awr.dout('xr_effects', "NPC %s is dead. Timer ignored", npc_name)
  6364. end
  6365. end
RAW Paste Data Copied