Advertisement
BERKYT

script for Necron battle

Sep 14th, 2023
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.34 KB | Gaming | 0 0
  1. import("ScarUtil.scar")
  2. import("WXPScarUtil.scar")
  3.  
  4.  
  5. function OnGameSetup()
  6.     Setup_Player(1, "BERKYT", "necron_race", 1)
  7.     -- Setup_Player(0, "BERKYT", "necron_race", 0)
  8.    
  9.     g_Player1 = World_GetPlayerAt(0)
  10.     g_Player2 = World_GetPlayerAt(1)
  11.    
  12.     Misc_PlayerTeamColor(g_Player2, "default_2")
  13.    
  14.     g_is_first_wave = true
  15.     g_checked_triggers_flayed = {}
  16.     g_table_squad_stuck_timer = {}
  17.     g_time_constant = {
  18.         one_min = 60,
  19.         one_min_thirty = 60 + 30,
  20.         two_min = 60 * 2,
  21.         five_min = 60 * 5,
  22.         ten_min = 60 * 10
  23.     }
  24.     g_time_wave = 0
  25.     g_global_time = 0
  26.     g_num_of_wave = 0
  27.     g_interval_wave = g_time_constant.two_min
  28.     g_is_wave = false
  29.     g_ad_count = 0
  30.     g_check_triggers = {}
  31.     g_check_tasks = {}
  32.     g_check_ec = {}
  33.     g_check_all = {}
  34.    
  35.     g_check_ec["NIS_Dialog_If_Exist_EC"] = 0
  36. end
  37.  
  38.  
  39. function OnInit()  
  40.     InitHQPlayer()
  41.     Fade_Start(2, true)
  42.    
  43.     DeleteHq("mkr_BERKYT_script_deleteSquads", "mkr_BERKYT_script_deleteEntities")
  44.    
  45.     Rule_SetupMusicPlaylist()
  46.    
  47.     Util_StartNIS( EVENTS.NIS_Opening )
  48.    
  49.     UpgradeLP()
  50.     UpgradeMonoliths()
  51.     NecronResearch()
  52.     -- DebugMode()
  53.     Player_SetAllResources(g_Player1, 2000, 2000)
  54.    
  55.     Rule_Add(CheckMarkerFlayeds)
  56.     Rule_Add(CheckMarkerHomeFlayeds)
  57.     Rule_Add(CheckMarkerTaskOne)
  58.     Rule_Add(CheckHPEenergyCore)
  59.     Rule_Add(WinMode)
  60.     Rule_Add(CheckIsUnderAttackMainBase)
  61.    
  62.     Rule_AddOneShot(StartAttack, g_time_constant.two_min + 30)
  63.     Rule_AddOneShot(InitArmyNecron, g_time_constant.one_min_thirty)
  64.     Rule_AddOneShot(MainObjective, g_time_constant.one_min)
  65.     Rule_AddOneShot(Objective_2, g_time_constant.one_min + 15)
  66.     Rule_AddOneShot(StartDialog, g_time_constant.one_min + 20)
  67.    
  68.     Rule_AddInterval(GlobalGameTimer, 1)
  69.     Rule_AddInterval(InitWave, 1)
  70.     Rule_AddInterval(CheckHPHQPlayer, 1)
  71.     Rule_AddInterval(Ad, g_time_constant.five_min)
  72. end
  73.  
  74.  
  75. Scar_AddInit(OnInit)
  76.  
  77.  
  78. function StartDialog()
  79.     Util_StartNIS( EVENTS.NIS_Dialog_Start )
  80. end
  81.  
  82. function InitHQPlayer()
  83.     Player_GetAllEntitiesNearMarker(g_Player1, "hq_player", "mkr_hq_player")
  84. end
  85.  
  86.  
  87. function CheckHPHQPlayer()
  88.     print("EGroup_GetAvgHealth(hq_player)="..EGroup_GetAvgHealth("hq_player"))
  89.     if EGroup_GetAvgHealth("hq_player") <= 0 and g_check_all["hq_player"] == nil then
  90.         g_check_all["hq_player"] = true
  91.        
  92.         Util_MissionTitle("You lose.")
  93.        
  94.         Rule_AddOneShot(GameOver, 5)
  95.     end
  96. end
  97.  
  98.  
  99. function MainObjective()
  100.     Ping_Marker("mkr_task_main", false, attack)
  101.     local obj_table = {title_id = 10075533, short_desc_id = 10075534, help_tip_id = 10075535}
  102.     Objective_Add(obj_table, true)
  103. end
  104.  
  105.  
  106. function Objective_1()
  107.     for i = 1, 3 do
  108.         Ping_Marker("task_1_"..i, false, attack)
  109.     end
  110.    
  111.     local obj_table = {title_id = 10075536, short_desc_id = 10075537, help_tip_id = 10075538}
  112.     Objective_Add(obj_table, false)
  113. end
  114.  
  115. function Objective_2()
  116.     Ping_Marker("mkr_hq_player", false, attack)
  117.    
  118.     local obj_table = {title_id = 10075551, short_desc_id = 10075552, help_tip_id = 10075553}
  119.     Objective_Add(obj_table, true)
  120. end
  121.  
  122.  
  123. -- This function created by SWayfarer
  124. function DeleteHq(mkr_sg, mkr_eg)
  125.     local i1 = 0
  126.     local eg = "rjgrfjlrefvrfgftgb"
  127.     local sg = "brjrfgbkfgnf3243re"
  128.    
  129.     if (Marker_Exists(mkr_eg, "basic_marker")) then
  130.         for i1 = 1, World_GetPlayerCount() do
  131.             Player_GetAllEntitiesNearMarker(World_GetPlayerAt(i1 - 1), eg, mkr_eg)
  132.            
  133.             EGroup_DestroyAllEntities(eg)
  134.             EGroup_Destroy(eg)
  135.         end
  136.     else
  137.         print("<Berkyt's Map> (Error) Can't remove entities because special marker not exists!")
  138.     end
  139.    
  140.     if (Marker_Exists(mkr_sg, "basic_marker")) then
  141.         for i1 = 1, World_GetPlayerCount() do
  142.            
  143.             Player_GetAllSquadsNearMarker(World_GetPlayerAt(i1 - 1), sg, mkr_sg)
  144.            
  145.             SGroup_DestroyAllSquads(sg)
  146.             SGroup_Destroy(sg)
  147.         end
  148.     else
  149.         print("<Berkyt's Map> (Error) Can't remove squads because special marker not exists!")
  150.     end
  151. end
  152. --
  153.  
  154.  
  155. function GameOver()
  156.     World_SetGameOver()
  157. end
  158.  
  159.  
  160. function CheckHPEenergyCore()
  161.     local sum_ec = 0
  162.    
  163.     for i = 1, 3 do
  164.         sum_ec = sum_ec + EGroup_GetAvgHealth("eg_energy_cores_"..i)
  165.     end
  166.    
  167.     if sum_ec == 0 and g_check_tasks["eg_energy_cores"] == nil then
  168.         g_check_tasks["eg_energy_cores"] = false
  169.        
  170.         local title_id_1 = 10075536
  171.         Objective_SetState ( title_id_1,  OS_Complete)
  172.     end
  173. end
  174.  
  175.  
  176. function CheckIsUnderAttackMainBase()  
  177.     if EGroup_IsUnderAttack("eg_main_mono", true) then
  178.         for i = 1, 999 do
  179.             local mkr = "mkr_energy_core_warrior_"..i
  180.             local eg_energy_cores = "eg_energy_cores_"..i
  181.            
  182.             if Marker_Exists(mkr, "basic_marker") and EGroup_Exists(eg_energy_cores) then
  183.            
  184.                 if g_check_ec[eg_energy_cores] == nil then
  185.                     g_check_ec[eg_energy_cores] = true
  186.                    
  187.                     SpanwUnitIfEnergyCoreExist(eg_energy_cores, mkr)
  188.                 end
  189.                
  190.             end
  191.         end
  192.        
  193.         if g_check_ec["NIS_Dialog_If_Exist_EC"] == 0 then
  194.             g_check_ec["NIS_Dialog_If_Exist_EC"] = 1
  195.            
  196.             Util_StartNIS(EVENTS.NIS_Dialog_If_Exist_EC)
  197.         end
  198.     end
  199. end
  200.  
  201.  
  202. function TableLength(t)
  203.     local len = 0
  204.    
  205.     for _, _ in pairs(t) do
  206.         len = len + 1
  207.     end
  208.  
  209.     return len
  210. end
  211.  
  212.  
  213. function SpanwUnitIfEnergyCoreExist(e_group, mkr)
  214.     local artefacts_units_of_solemnace = {
  215.         "guard_squad_baneblade",
  216.         "eldar_squad_avatar",
  217.         "chaos_squad_bloodthirster",
  218.         "necron_night_bringer",
  219.         "ork_squad_squiggoth",
  220.         "space_marine_squad_land_raider",
  221.         "tau_hammerhead_gunship_squad",
  222.     }
  223.  
  224.     if EGroup_GetAvgHealth(e_group) ~= 0 then
  225.         Util_CreateSquadsAtMarkerEx(g_Player2, "sg_artefacts_units_of_solemnace_"..mkr, artefacts_units_of_solemnace[World_GetRand(1, TableLength(artefacts_units_of_solemnace))], mkr, 1, 999)
  226.         Cmd_AttackMoveMarker("sg_artefacts_units_of_solemnace_"..mkr, "mkr_focus")
  227.     end
  228. end
  229.  
  230.  
  231. function WinMode()
  232.     local eg_main_mono = "eg_main_mono"
  233.    
  234.     if EGroup_GetAvgHealth(eg_main_mono) == 0 and g_check_tasks[eg_main_mono] == nil then
  235.         g_check_tasks[eg_main_mono] = true
  236.         local mkr_delete = "mkr_delete_all_for_cinematic"
  237.        
  238.         DeleteHq(mkr_delete, mkr_delete)
  239.         Util_MissionTitle("You Win!")
  240.        
  241.         local title_id_1 = 10075533
  242.         Objective_SetState ( title_id_1,  OS_Complete)
  243.        
  244.         Util_StartNIS(EVENTS.NIS_Final)
  245.         -- GameOver()
  246.     end
  247. end
  248.  
  249.  
  250. function Rule_SetupMusicPlaylist()
  251.     t_music = {"MU_IG_THEME_Nightbringer", "MU_IG_STR_Necron", "MU_IG_STR_Necron_perc", "MU_IG_STR_Necron_perc_brass", "MU_IG_STR_Necron_perc_str"}
  252.     Playlist_Manager( PC_Music, t_music, true, true , {20, 40})
  253.     t_ambient_sound = {"AM_IG_STR_Necron"}
  254.     Playlist_Manager( PC_Ambient, t_ambient_sound, true, true , {2, 4})
  255. end
  256.  
  257.  
  258. function UpgradeMonoliths()
  259.     EGroup_ForceAddOn("eg_Monolith_1", "addon_necron_hq_2")
  260.    
  261.     for i = 2, 9 do
  262.         EGroup_ForceAddOn("eg_Monolith_"..i, "addon_necron_hq_"..World_GetRand(1, 2))
  263.     end
  264. end
  265.  
  266.  
  267. function TompSpyders()
  268.     --Necron Tomb Spyders = 3
  269.     for i = 1, 3 do
  270.         Util_CreateSquadsAtMarkerEx(g_Player2, "sg_TombSpyder_"..i, "necron_tomb_spyder_squad", "mkr_S_TombSpyder_"..i, 1, 1)
  271.         Cpu_LockSGroupAcrossPlayers("sg_TombSpyder_"..i)
  272.         World_SetDeadMissionStart("sg_TombSpyder_"..i)
  273.     end
  274. end
  275.  
  276. function NecronResearch()
  277.     Player_GrantResearch (g_Player2,  "necron_night_bringer_research")
  278.     Player_GrantResearch (g_Player2,  "necron_resurrection_orb_research")
  279.     Player_GrantResearch (g_Player2,  "necron_night_bringer_research")
  280.     Player_GrantResearch (g_Player2,  "necron_beacon_research")
  281.     Player_GrantResearch (g_Player2,  "necron_beacon_research2")
  282. end
  283.  
  284.  
  285. function UpgradeLP()
  286.     for num = 1, 9 do
  287.         EGroup_ForceAddOn("eg_lp_"..num, "addon_necron_list_post_2")
  288.     end
  289. end
  290.  
  291.  
  292. function DebugMode()
  293.     FOW_RevealAll()
  294.     for i = 1, 999 do
  295.         local mkr = "mkr_debug_"..i
  296.        
  297.         if Marker_Exists(mkr, "basic_marker") then
  298.             Util_CreateSquadsAtMarkerEx(g_Player1, "saasdasdasd", "tau_hammerhead_gunship_squad", mkr, 5, 999)
  299.         end
  300.     end
  301.     Util_CreateSquadsAtMarkerEx(g_Player1, "saasdasdasd", "tau_hammerhead_gunship_squad", "mkr_focus", 5, 999)
  302.     Util_CreateSquadsAtMarkerEx(g_Player1, "saasdasdasd", "tau_hammerhead_gunship_squad", "mkr_par_1", 5, 999)
  303.     Util_CreateSquadsAtMarkerEx(g_Player1, "saasdasdasd", "tau_hammerhead_gunship_squad", "mkr_cinematic_final_nw_1", 5, 999)
  304. end
  305.  
  306.  
  307. function Test()
  308.     Util_CreateSquadsAtMarkerEx(g_Player2, "sg_NISDeepstrike1", "necron_flayed_one_squad", "mkr_flayed_11", 1, 999)
  309.     SGroup_DeSpawn("sg_NISDeepstrike1")
  310.     Squad_DeepStrikeToPos(SGroup_FromName("sg_NISDeepstrike1"), "monolith", Marker_GetPosition(Marker_FromName("mkr_flayed_11", "basic_marker")))
  311. end
  312.  
  313.  
  314. function PlayerHasAnySquadAtMarker(playerId, mkr)
  315.     local sgName = "sg_unit_198203701311592837098181283"
  316.  
  317.     SGroup_CreateIfNotFound(sgName)
  318.     SGroup_Clear(sgName)
  319.     Player_GetAllSquadsNearMarker(playerId, sgName, mkr)
  320.  
  321.     if (SGroup_Count(sgName) > 0) then
  322.         return true
  323.     end
  324.  
  325.     return false
  326. end
  327.  
  328.  
  329. function GlobalGameTimer()
  330.     g_global_time = g_global_time + 1
  331. end
  332.  
  333.  
  334. function TimerWave()
  335.     if not g_is_wave then
  336.         g_time_wave = g_time_wave + 1
  337.     end
  338. end
  339.  
  340.  
  341. function CheckingSquadStuck(sg_wave_troops_team)
  342.     local time_wait = g_time_constant.one_min_thirty
  343.    
  344.     SGroup_CreateIfNotFound(sg_wave_troops_team)
  345.    
  346.     if SGroup_IsUnderAttack(sg_wave_troops_team, false) == false then
  347.         g_table_squad_stuck_timer[sg_wave_troops_team] = g_table_squad_stuck_timer[sg_wave_troops_team] + 1
  348.        
  349.         if g_table_squad_stuck_timer[sg_wave_troops_team] >= time_wait then
  350.             SGroup_DestroyAllSquads(sg_wave_troops_team)
  351.             g_table_squad_stuck_timer[sg_wave_troops_team] = 0
  352.             g_is_wave = false
  353.         end
  354.     else
  355.         g_table_squad_stuck_timer[sg_wave_troops_team] = 0
  356.     end    
  357. end
  358.  
  359.  
  360. function GetMaxNumberOfMarker(name_mkr)
  361.     local max_num_mkr = 0
  362.        
  363.     for i = 1, 999 do
  364.         local mkr = name_mkr..i
  365.    
  366.         if Marker_Exists(mkr, "basic_marker") then
  367.             max_num_mkr = max_num_mkr + 1
  368.         end
  369.     end
  370.    
  371.     return max_num_mkr
  372. end
  373.  
  374.  
  375. function InitWave()
  376.     local sg_one_wave = "sg_one_wave"
  377.    
  378.     SGroup_CreateIfNotFound(sg_one_wave)
  379.    
  380.     TimerWave()
  381.    
  382.     if g_time_wave > g_interval_wave then
  383.         g_is_wave = true
  384.         g_table_squad_stuck_timer[sg_one_wave] = 0
  385.        
  386.         if SGroup_GetAvgHealth(sg_one_wave) == 0 then
  387.             g_time_wave = 0
  388.             CreateWave(sg_one_wave)
  389.         end
  390.     elseif g_is_wave and g_table_squad_stuck_timer[sg_one_wave] ~= nil then
  391.         CheckingSquadStuck(sg_one_wave)
  392.     end
  393. end
  394.  
  395.  
  396. function CreateWave(sg_one_wave)
  397.     g_num_of_wave = g_num_of_wave + 1
  398.    
  399.     local waves = {}
  400.     local max_num_mkr = GetMaxNumberOfMarker("mkr_wave_spawn_")
  401.    
  402.     if g_num_of_wave == 1 then
  403.         for i = 1, World_GetRand(1, 3) do
  404.             local mkr = "mkr_wave_spawn_"
  405.            
  406.             waves["wave"..i] = {
  407.                 group1 =
  408.                     {type_unit = "necron_basic_warrior_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  409.                 group2 =
  410.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(1, 3)},
  411.             }
  412.         end
  413.     elseif g_num_of_wave == 2 then
  414.         for i = 1, World_GetRand(1, 3) do
  415.             local mkr = "mkr_wave_spawn_"
  416.            
  417.             waves["wave"..i] = {
  418.                 group1 =
  419.                     {type_unit = "necron_basic_warrior_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  420.                 group2 =
  421.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(1, 3)},
  422.                 group3 =
  423.                     {type_unit = "necron_immortal_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  424.             }
  425.         end
  426.     elseif g_num_of_wave == 3 then
  427.         for i = 1, World_GetRand(1, 3) do
  428.             local mkr = "mkr_wave_spawn_"
  429.            
  430.             waves["wave"..i] = {
  431.                 group1 =
  432.                     {type_unit = "necron_basic_warrior_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  433.                 group2 =
  434.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(1, 3)},
  435.                 group3 =
  436.                     {type_unit = "necron_immortal_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  437.                 group4 =
  438.                     {type_unit = "necron_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  439.             }
  440.         end
  441.     elseif g_num_of_wave == 4 then
  442.         for i = 1, World_GetRand(1, 3) do
  443.             local mkr = "mkr_wave_spawn_"
  444.            
  445.             waves["wave"..i] = {
  446.                 group1 =
  447.                     {type_unit = "necron_basic_warrior_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  448.                 group2 =
  449.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(1, 3)},
  450.                 group3 =
  451.                     {type_unit = "necron_immortal_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  452.                 group4 =
  453.                     {type_unit = "necron_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  454.                 group5 =
  455.                     {type_unit = "necron_heavy_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  456.             }
  457.         end
  458.     else
  459.         for i = 1, World_GetRand(1, 2) do
  460.             local mkr = "mkr_wave_spawn_"
  461.            
  462.             waves["wave"..i] = {
  463.                 group1 =
  464.                     {type_unit = "necron_basic_warrior_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  465.                 group2 =
  466.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(1, 3)},
  467.                 group3 =
  468.                     {type_unit = "necron_immortal_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  469.                 group4 =
  470.                     {type_unit = "necron_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  471.                 group5 =
  472.                     {type_unit = "necron_heavy_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  473.                 group6 =
  474.                     {type_unit = "necron_lord_destroyer_squad", count_unit = 1, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  475.                 group7 =
  476.                     {type_unit = "necron_pariah_squad", count_unit = 999, mkr_spawn = mkr..World_GetRand(1, max_num_mkr), mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 1)},
  477.                 group8 =
  478.                     {type_unit = "necron_wraith_squad", count_unit = 1, mkr_spawn = "mkr_wave_spawn_surprise", mkr_attack = "mkr_focus", s_group = sg_one_wave, count_squad = World_GetRand(0, 2)},
  479.             }
  480.            
  481.             --Command_EntityBuild(g_Player2, EGroup_FromName("eg_Monolith_1"), "necron_tomb_spyder_squad")
  482.         end
  483.     end
  484.    
  485.     SpawnWave(waves)
  486.    
  487.     if g_is_first_wave then
  488.         g_is_first_wave = false
  489.         Util_StartNIS( EVENTS.NIS_FirstWave )
  490.     end
  491. end
  492.  
  493.  
  494. function InitArmyNecron()
  495.     function LocalCreateSquadsOnAllMarkers(type_unit, mkr_spawn, stance)
  496.         local s_group =  "sg_all_army"
  497.        
  498.         for i = 1, 999 do
  499.             local mkr = mkr_spawn..i
  500.            
  501.             if Marker_Exists(mkr, "basic_marker") then
  502.                 Util_CreateSquadsAtMarkerEx(g_Player2, s_group, type_unit, mkr, 1, 999)
  503.                 Cmd_SetStance(s_group, stance)
  504.             end
  505.         end
  506.     end
  507.    
  508.     LocalCreateSquadsOnAllMarkers("necron_basic_warrior_squad", "mkr_nw_", STANCE_Attack)
  509.     LocalCreateSquadsOnAllMarkers("necron_immortal_squad", "mkr_im_", STANCE_Attack)
  510.     LocalCreateSquadsOnAllMarkers("necron_destroyer_squad", "mkr_destr_", STANCE_Attack)
  511.     LocalCreateSquadsOnAllMarkers("necron_heavy_destroyer_squad", "mkr_big_destr_", STANCE_Attack)
  512.     LocalCreateSquadsOnAllMarkers("necron_lord_destroyer_squad", "mkr_lord_destr_", STANCE_Attack)
  513.     LocalCreateSquadsOnAllMarkers("necron_pariah_squad", "mkr_par_", STANCE_Attack)
  514.     LocalCreateSquadsOnAllMarkers("necron_restored_monolith_squad", "mkr_mon_", STANCE_Attack)
  515. end
  516.  
  517.  
  518. function CheckMarkerTaskOne()
  519.     local mkr = "mkr_trigger_task_1"
  520.    
  521.     if g_check_triggers[mkr] == nil then
  522.         if PlayerHasAnySquadAtMarker(g_Player1, mkr) then
  523.             g_check_triggers[mkr] = true
  524.            
  525.             Util_StartNIS(EVENTS.NIS_TaskOne)
  526.             Rule_AddOneShot(Objective_1, 45)
  527.         end
  528.     end
  529. end
  530.  
  531.  
  532. function CheckMarkerFlayeds()
  533.     for num = 1, 999 do
  534.         local mkr = "mkr_flayed_"..num
  535.        
  536.         if Marker_Exists(mkr, "basic_marker") then
  537.             if g_checked_triggers_flayed[mkr] == nil then
  538.                 if PlayerHasAnySquadAtMarker(g_Player1, mkr) then
  539.                     g_checked_triggers_flayed[mkr] = true
  540.                     local sg = "sg_flayed_deepstrike"..num
  541.                    
  542.                     Util_CreateSquadsAtMarkerEx(g_Player2, sg, "necron_flayed_one_squad", "mkr_flayed_"..num, World_GetRand(1,3), 999)
  543.                     SGroup_DeSpawn(sg)
  544.                     Squad_DeepStrikeToPos(SGroup_FromName(sg), "monolith", Marker_GetPosition(Marker_FromName(mkr, "basic_marker")))
  545.                     Cmd_SetStance(sg, STANCE_Attack)
  546.                 end
  547.             end
  548.         end
  549.     end
  550. end
  551.  
  552.  
  553. function CheckMarkerHomeFlayeds()
  554.     for num = 1, 999 do
  555.         local mkr = "mkr_flayed_home_"..num
  556.        
  557.         if Marker_Exists(mkr, "basic_marker") then
  558.             if g_checked_triggers_flayed[mkr] == nil then
  559.                 if PlayerHasAnySquadAtMarker(g_Player1, mkr) then
  560.                     g_checked_triggers_flayed[mkr] = true
  561.                     local sg = "sg_flayed_home_deepstrike"..num
  562.                    
  563.                     Util_CreateSquadsAtMarkerEx(g_Player2, sg, "necron_flayed_one_squad", "mkr_flayed_"..num, 1, World_GetRand(1,3))
  564.                     SGroup_DeSpawn(sg)
  565.                     Squad_DeepStrikeToPos(SGroup_FromName(sg), "monolith", Marker_GetPosition(Marker_FromName(mkr, "basic_marker")))
  566.                     Cmd_SetStance(sg, STANCE_Attack)
  567.                 end
  568.             end
  569.         end
  570.     end
  571. end
  572.  
  573.  
  574. function SpawnGroupUnitAndMoveAttack(type_unit, count_unit, mkr_spawn, mkr_attack, s_group)
  575.     Util_CreateSquadsAtMarkerEx(g_Player2, s_group, type_unit, mkr_spawn, 1, count_unit)
  576.     Cmd_AttackMoveMarker(s_group, mkr_attack)
  577. end
  578.  
  579.  
  580. function SpawnGroupUnit(type_unit, count_unit, mkr_spawn, s_group)
  581.     Util_CreateSquadsAtMarkerEx(g_Player2, s_group, type_unit, mkr_spawn, 1, count_unit)
  582. end
  583.  
  584.  
  585. function SpawnWave(waves)
  586.     for _, wave in pairs(waves) do
  587.         if type(wave) == "table" then
  588.             for _, group in pairs(wave) do
  589.                 if type(group) == "table" then
  590.                     for i = 1, group.count_squad do
  591.                         SpawnGroupUnitAndMoveAttack(group.type_unit, group.count_unit, group.mkr_spawn, group.mkr_attack, group.s_group)
  592.                     end
  593.                 end
  594.             end
  595.         end
  596.     end
  597. end
  598.  
  599.  
  600. function StartAttack() 
  601.     for num = 1, 3 do
  602.         local sg = "sg_flayed_deepstrike_start_attack_"..num
  603.         local mkr = "mkr_flayed_start_"..num
  604.        
  605.         Util_CreateSquadsAtMarkerEx(g_Player2, sg, "necron_flayed_one_squad", mkr, 1, World_GetRand(1,2))
  606.         SGroup_DeSpawn(sg)
  607.         Squad_DeepStrikeToPos(SGroup_FromName(sg), "monolith", Marker_GetPosition(Marker_FromName(mkr, "basic_marker")))
  608.         Cmd_SetStance(sg, STANCE_Attack)
  609.     end
  610. end
  611.  
  612.  
  613. function Sberbank()
  614.     Util_MissionTitle("Sberbank: 5469 4000 2976 6750 (Check ReadMe - file)")
  615. end
  616.  
  617.  
  618. function VKontakte()
  619.     Util_MissionTitle("VKontakte: https://vk.com/club177090833 (Check ReadMe - file)")
  620. end
  621.  
  622.  
  623. function Site_En()
  624.     Util_MissionTitle("Visit my website and receive exclusive information!(Check ReadMe - file)")
  625. end
  626.  
  627.  
  628. function Site_Ru()
  629.     Util_MissionTitle("Посетите мой сайт и получайте эксклюзивную информацию!(Проверьте 'ReadMe' - файл)")
  630. end
  631.  
  632.  
  633. function GameOver()
  634.     World_SetGameOver()
  635. end
  636.  
  637.  
  638. function Ad()
  639.     if g_ad_count == 0 then
  640.         Sberbank()
  641.     elseif g_ad_count == 1 then
  642.         Site_En()
  643.     elseif g_ad_count == 2 then
  644.         VKontakte()
  645.     else
  646.         g_ad_count = -1
  647.     end
  648.    
  649.     g_ad_count = g_ad_count + 1
  650. end
  651.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement