Advertisement
Guest User

Untitled

a guest
Jul 8th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.85 KB | None | 0 0
  1. import("ScarUtil.scar");
  2.  
  3. function OnGameSetup() -- Called as the first thing in the script no matter what
  4. player1 = World_GetPlayerAt(1);
  5. player2 = World_GetPlayerAt(2);
  6. player3 = World_GetPlayerAt(3);
  7. player4 = World_GetPlayerAt(4);
  8. player5 = World_GetPlayerAt(5);
  9. player6 = World_GetPlayerAt(6);
  10.  
  11. Setup_SetPlayerName(player1, "$f69d864ff41f412f91dfd87227648192:5");
  12. Setup_SetPlayerName(player2, "$f69d864ff41f412f91dfd87227648192:6");
  13. Setup_SetPlayerName(player3, "$f69d864ff41f412f91dfd87227648192:7");
  14. Setup_SetPlayerName(player4, "$f69d864ff41f412f91dfd87227648192:9");
  15. Setup_SetPlayerName(player5, "$f69d864ff41f412f91dfd87227648192:8");
  16. Setup_SetPlayerName(player6, "$f69d864ff41f412f91dfd87227648192:10");
  17.  
  18.  
  19. end
  20. -----------------------------------------------------
  21. function OnInit()
  22. -- More stuff
  23. AI_EnableAll(false);
  24.  
  25. -- Declaring groups
  26. sg_scout1 = SGroup_CreateIfNotFound("sg_scout1") -- Declare the SG
  27. sg_defender1 = SGroup_CreateIfNotFound("sg_defender1")
  28. sg_defendervet1 = SGroup_CreateIfNotFound("sg_defendervet1")
  29. sg_defendervet2 = SGroup_CreateIfNotFound("sg_defendervet2")
  30. sg_counter1 = SGroup_CreateIfNotFound("sg_counter1")
  31. sg_counter2 = SGroup_CreateIfNotFound("sg_counter2")
  32. sg_defenders = SGroup_CreateIfNotFound("sg_defenders")
  33. sg_defendertotal = SGroup_CreateIfNotFound("sg_defendertotal")
  34. sg_scout2 = SGroup_CreateIfNotFound("sg_scout2")
  35. sg_sdkfz251 = SGroup_CreateIfNotFound("sg_sdkfz251")
  36. sg_reinforcement = SGroup_CreateIfNotFound("sg_reinforcement")
  37. sg_reinforcement1 = SGroup_CreateIfNotFound("sg_reinforcement1")
  38. sg_totalscout = SGroup_CreateIfNotFound("sg_totalscout")
  39. sg_11attackforce = SGroup_CreateIfNotFound("sg_11attackforce")
  40. sg_6attackforce = SGroup_CreateIfNotFound("sg_6attackforce")
  41. sg_counterfarm = SGroup_CreateIfNotFound("sg_counterfarm")
  42.  
  43. -- Function call
  44. Restriction();
  45. InitializeObjectives();
  46. Villageattack(); -- Call villageattack function
  47. Modify_Enable_PlayerIssueRetreat();
  48.  
  49. -- Intervals
  50. Rule_AddOneShot(OBJ_Farm_Mission, 2);
  51. Rule_AddOneShot(CP_Meter, 1)
  52. Rule_AddOneShot(BaseStart, 1)
  53. Rule_AddOneShot(NoRetreat, 1)
  54.  
  55. Rule_AddInterval(Move, 2); -- Calls the function every 2th second
  56. Rule_AddInterval(InstantCapture, 2);
  57. Rule_AddInterval(Hintmessage, 2);
  58.  
  59. -- Functions to test stuff out
  60. testing();
  61. end
  62. Scar_AddInit(OnInit);
  63. -----------------------------------------------------
  64. function Restriction()
  65. g_manpowerrate = Modify_PlayerResourceRate(player1, RT_Manpower, 0, MUT_Multiplication);
  66. g_fuelrate = Modify_PlayerResourceRate(player1, RT_Fuel, 0, MUT_Multiplication);
  67. g_munitionrate = Modify_PlayerResourceRate(player1, RT_Munition, 0, MUT_Multiplication);
  68.  
  69. Player_SetResource(player1, RT_Manpower, 0);
  70. Player_SetResource(player1, RT_Fuel, 0);
  71. Player_SetResource(player1, RT_Munition, 0);
  72.  
  73. Player_SetAbilityAvailability(player1, ABILITY.GERMAN.ASSAULT_GRENADIER_GRENADE, ITEM_REMOVED)
  74. Player_SetAbilityAvailability(player1, ABILITY.GERMAN.GRENADIER_PANZERFAUST_MP, ITEM_REMOVED)
  75. Player_SetAbilityAvailability(player1, ABILITY.GERMAN.GRENADIER_RIFLE_GRENADE_ABILITY_MP, ITEM_REMOVED)
  76. Player_SetConstructionMenuAvailability( player1, "tp_construction_german_grenadier", ITEM_REMOVED )
  77. end
  78. -----------------------------------------------------
  79. function InitializeObjectives()
  80. -- Missions
  81. OBJ_FARM= {
  82. SetupUI = function()
  83. UI_CreateMinimapBlip(farm_point, 10, BT_General)
  84. end,
  85.  
  86. OnStart = function()
  87. Rule_AddInterval(OBJ_Farm_IsDone, 2);
  88. Rule_AddInterval(OBJ_Farm_Lose, 10);
  89. Rule_AddInterval(Farm_Attack_Reinforcement, 2);
  90. end,
  91.  
  92. OnComplete = function()
  93. Player_AddResource(player1, RT_Manpower, 150);
  94. Player_AddResource(player1, RT_Munition, 40);
  95.  
  96. Rule_AddOneShot(Resources_FarmComplete, 2);
  97.  
  98. BuildingExplode()
  99. TruckDrop()
  100.  
  101. Objective_Start(OBJ_COUNTERFARM, true); -- Main
  102. end,
  103.  
  104. OnFail = function()
  105. end,
  106.  
  107. Title = "$f69d864ff41f412f91dfd87227648192:1",
  108. Description = 0,
  109. Type = OT_Primary, -- main objective (the star)
  110. }
  111.  
  112. OBJ_COUNTERFARM= {
  113. SetupUI = function()
  114. end,
  115.  
  116. OnStart = function()
  117. Counterfarm()
  118. Rule_AddInterval(OBJ_Counter_Lose, 10);
  119. Rule_AddInterval(OBJ_Counter_IsDone, 2);
  120. end,
  121.  
  122. OnComplete = function()
  123. Cmd_MoveToAndDespawn(sg_sdkfz251, mkr_playerspawn1, true);
  124. BaseBuild()
  125.  
  126. hintretreat = HintPoint_Add(mkr_retreat, true, "$f69d864ff41f412f91dfd87227648192:14");
  127. HintPoint_Remove(hintreinforcetruck);
  128. Rule_AddOneShot(RemoveHint, 30)
  129. end,
  130.  
  131. OnFail = function()
  132. end,
  133.  
  134. Title = "$f69d864ff41f412f91dfd87227648192:3",
  135. Description = 0,
  136. Type = OT_Primary, -- main objective (the star)
  137. }
  138.  
  139.  
  140. Objective_Register(OBJ_FARM);
  141. Objective_Register(OBJ_COUNTERFARM);
  142.  
  143. end
  144. -----------------------------------------------------
  145. function CP_Meter()
  146. UI_SetCPMeterVisibility(false);
  147. end
  148. -----------------------------------------------------
  149. function Modify_Enable_PlayerIssueRetreat(playerid, value)
  150. if value == true then
  151. value = 1
  152. elseif value == false then
  153. value = 0
  154. end
  155.  
  156. -- Create the appropriate modifier
  157. local modifier = Modifier_Create(MAT_Player, "modifiers\\enable_player_issue_retreat.lua", MUT_Enable, false, value, "")
  158. Modifier_ApplyToPlayer(modifier, playerid)
  159. end
  160. -----------------------------------------------------
  161. function NoRetreat()
  162. Modify_Enable_PlayerIssueRetreat(player1, false)
  163. end
  164. -----------------------------------------------------
  165. function Resources_FarmComplete()
  166. Modifier_Remove(g_manpowerrate);
  167. Modifier_Remove(g_fuelrate);
  168. Modifier_Remove(g_munitionrate);
  169.  
  170. g_manpowerrate = Modify_PlayerResourceRate(player1, RT_Manpower, 0.15, MUT_Multiplication);
  171. g_fuelrate = Modify_PlayerResourceRate(player1, RT_Fuel, 0, MUT_Multiplication);
  172. g_munitionrate = Modify_PlayerResourceRate(player1, RT_Munition, 0.4, MUT_Multiplication);
  173. end
  174. -----------------------------------------------------
  175. function Villageattack()
  176. -- Player1 (17. Armee)
  177. Util_CreateSquads(player1, sg_scout1, BP_GetSquadBlueprint("assault_grenadier_squad_mp"), mkr_playerspawn2, nil, 10, nil, nil, nil, nil, nil);
  178. Util_CreateSquads(player1, sg_scout1, BP_GetSquadBlueprint("grenadier_squad_mp"), mkr_playerspawn, nil, 1, nil, nil, nil, nil, nil);
  179. Util_CreateSquads(player1, sg_scout1, BP_GetSquadBlueprint("grenadier_squad_mp"), mkr_playerspawn1, nil, 1, nil, nil, nil, nil, nil);
  180.  
  181. SGroup_AddGroup(sg_totalscout, sg_scout1);
  182.  
  183. -- Player2 (Soviet Union)
  184. Util_CreateSquads(player2, sg_defendervet1, BP_GetSquadBlueprint("conscript_squad_mp"), villageattack_building, nil, 1, nil, nil, nil, nil, nil);
  185.  
  186. Util_CreateSquads(player2, sg_defendervet2, BP_GetSquadBlueprint("combat_engineer_squad_mp"), mkr_defenderspawn3, nil, 1, nil, nil, nil, nil, nil);
  187. Cmd_SquadPatrolMarker( sg_defendervet2, mkr_defenderspawn3 )
  188.  
  189. Util_CreateSquads(player2, sg_defender1, BP_GetSquadBlueprint("conscript_squad_mp"), villageattack_building1, nil, 1, nil, nil, nil, nil, nil);
  190.  
  191. SGroup_IncreaseVeterancyRank(sg_defendervet1, World_GetRand(1, 2), true);
  192. SGroup_IncreaseVeterancyRank(sg_defendervet2, World_GetRand(1, 3), true);
  193.  
  194. Util_CreateSquads(player2, sg_counter1, BP_GetSquadBlueprint("conscript_squad_mp"), mkr_counterspawn, nil, 1, nil, true, nil, nil, nil);
  195. SGroup_IncreaseVeterancyRank(sg_counter1, World_GetRand(1, 2), true);
  196.  
  197. Util_CreateSquads(player2, sg_counter2, BP_GetSquadBlueprint("conscript_squad_mp"), mkr_counterspawn, nil, 1, nil, true, nil, nil, nil);
  198. SGroup_IncreaseVeterancyRank(sg_counter2, World_GetRand(1, 2), true);
  199.  
  200. SGroup_AddGroup(sg_defenders, sg_defendervet1);
  201. SGroup_AddGroup(sg_defenders, sg_defendervet2);
  202. SGroup_AddGroup(sg_defenders, sg_defender1);
  203.  
  204. SGroup_AddGroup(sg_defendertotal, sg_defenders);
  205. SGroup_AddGroup(sg_defendertotal, sg_counter1);
  206. SGroup_AddGroup(sg_defendertotal, sg_counter2);
  207.  
  208. -- Player3 (11. Armee)
  209. Util_CreateSquads(player3, sg_11attackforce, BP_GetSquadBlueprint("assault_grenadier_squad_mp"), mkr_11attackforce, nil, 1, nil, nil, nil, nil, nil);
  210. Util_CreateSquads(player3, sg_11attackforce, BP_GetSquadBlueprint("ostruppen_squad_mp"), mkr_11attackforce, nil, 2, nil, nil, nil, nil, nil);
  211.  
  212. -- Player5 (6. Armee)
  213. Util_CreateSquads(player5, sg_6attackforce, BP_GetSquadBlueprint("assault_grenadier_squad_mp"), mkr_6attackforce, nil, 1, nil, nil, nil, nil, nil);
  214. Util_CreateSquads(player5, sg_6attackforce, BP_GetSquadBlueprint("grenadier_squad_mp"), mkr_6attackforce, nil, 2, nil, nil, nil, nil, nil);
  215. end
  216. -----------------------------------------------------
  217. function Move()
  218. if (SGroup_Count(sg_defenders) <=1) then
  219. Cmd_Move(sg_counter1, mkr_defenderspawn1);
  220. Cmd_Move(sg_counter2, mkr_defenderspawn2);
  221. Rule_RemoveMe();
  222. end
  223. end
  224. -----------------------------------------------------
  225. function Farm_Attack_Reinforcement()
  226. if (SGroup_TotalMembersCount(sg_scout1, false) == 2) then
  227. Util_MissionTitle("$f69d864ff41f412f91dfd87227648192:2", 2.0, 5.0, 2.0);
  228. Util_CreateSquads(player1, sg_scout2, BP_GetSquadBlueprint("grenadier_squad_mp"), mkr_playerspawn, nil, 1, nil, nil, nil, nil, nil);
  229.  
  230. SGroup_AddGroup(sg_totalscout, sg_scout2);
  231.  
  232. Cmd_Move(sg_scout2, mkr_defenderspawn3);
  233. Rule_RemoveMe();
  234. end
  235. end
  236. -----------------------------------------------------
  237. function OBJ_Farm_Mission()
  238. -- Call mission
  239. Objective_Start(OBJ_FARM, true);
  240. end
  241. -----------------------------------------------------
  242. function OBJ_Farm_Lose()
  243. -- Lose condition OBJ_Farm_Lose
  244. if (SGroup_Count(sg_totalscout) == 0) then
  245. Game_EndSP(false);
  246. Rule_RemoveAll();
  247. end
  248. end
  249. -----------------------------------------------------
  250. function InstantCapture()
  251. if (SGroup_Count(sg_defendertotal) == 0) then
  252. EGroup_InstantCaptureStrategicPoint( farm_point, player1 )
  253. Rule_RemoveMe();
  254. end
  255. end
  256. -----------------------------------------------------
  257. function OBJ_Farm_IsDone()
  258. if (EGroup_IsCapturedByPlayer( farm_point, player1, ANY ) and SGroup_Count(sg_defendertotal) == 0) then
  259. Objective_Complete(OBJ_FARM, true);
  260. end
  261. end
  262. -----------------------------------------------------
  263. function TruckDrop()
  264. Util_CreateSquads(player5, sg_sdkfz251, BP_GetSquadBlueprint("sdkfz_251_halftrack_squad_mp"), mkr_playerspawn, mkr_truckfarm1, 1, nil, nil, nil, nil, nil);
  265. Util_CreateSquads(player5, sg_reinforcement1, BP_GetSquadBlueprint("mg42_heavy_machine_gun_squad_mp"), sg_sdkfz251, nil, 1, nil, nil, nil, nil, nil);
  266. Cmd_EjectOccupants(sg_sdkfz251, mkr_truckfarm1, true);
  267. SGroup_SetPlayerOwner(sg_reinforcement1, player1);
  268. end
  269. -----------------------------------------------------
  270. function Hintmessage()
  271. if (Prox_AreSquadsNearMarker(sg_sdkfz251, mkr_truckfarm1, false, 5)) then
  272. hintreinforcetruck = HintPoint_Add(mkr_truckfarm1, true, "$f69d864ff41f412f91dfd87227648192:12");
  273. Rule_RemoveMe();
  274. end
  275. end
  276. -----------------------------------------------------
  277. function BuildingExplode()
  278. Player_AddAbility(player2, BP_GetAbilityBlueprint("light_support_artillery"));
  279. t_villageblowup = {mkr_villageblowup, mkr_villageblowup1, mkr_villageblowup2, mkr_villageblowup3};
  280. Cmd_Ability(player2, BP_GetAbilityBlueprint("light_support_artillery"), t_villageblowup[World_GetRand(1, #t_villageblowup)], nil, true, false);
  281. end
  282. -----------------------------------------------------
  283. function Counterfarm()
  284. Util_CreateSquads(player2, sg_counterfarm, BP_GetSquadBlueprint("penal_battalion_mp"), mkr_counterfarm, mkr_farmattack3, 1, nil, nil, nil, nil, nil);
  285. Util_CreateSquads(player2, sg_counterfarm, BP_GetSquadBlueprint("conscript_squad_mp"), mkr_counterfarm1, mkr_farmattack2, 1, nil, nil, nil, nil, nil);
  286. Util_CreateSquads(player2, sg_counterfarm, BP_GetSquadBlueprint("conscript_squad_mp"), mkr_counterfarm2, mkr_farmattack1, 1, nil, nil, nil, nil, nil);
  287. Util_CreateSquads(player2, sg_counterfarm, BP_GetSquadBlueprint("penal_battalion_mp"), mkr_counterfarm3, mkr_farmattack, 1, nil, nil, nil, nil, nil);
  288. Rule_RemoveMe();
  289. end
  290. -----------------------------------------------------
  291. function OBJ_Counter_IsDone()
  292. if (SGroup_Count(sg_counterfarm) == 0) then
  293. Objective_Complete(OBJ_COUNTERFARM, true);
  294. end
  295. end
  296. -----------------------------------------------------
  297. function OBJ_Counter_Lose()
  298. -- Lose condition OBJ_Farm_Lose
  299. if (SGroup_Count(sg_totalscout) == 0) then
  300. Game_EndSP(false);
  301. Rule_RemoveAll();
  302. end
  303. end
  304. -----------------------------------------------------
  305. function BaseStart()
  306. EGroup_DeSpawn(baseobject);
  307. EGroup_DeSpawn(baseflag);
  308. EGroup_DeSpawn(baseflag1);
  309. EGroup_DeSpawn(basereinforce);
  310. EGroup_DeSpawn(basereinforce1);
  311. EGroup_DeSpawn(retreat);
  312. end
  313. -----------------------------------------------------
  314. function BaseBuild()
  315. Modify_Enable_PlayerIssueRetreat(player1, true)
  316. Camera_MoveTo(mkr_camerabase, true, SLOW_CAMERA_PANNING, true, true);
  317. Game_FadeToBlack(FADE_OUT, 2)
  318. EGroup_DeSpawn(firstbase);
  319.  
  320. if (EGroup_GetAvgHealth(villageattack_building) > 0) then
  321. hintbase = HintPoint_Add(mkr_villageblowup2, true, "$f69d864ff41f412f91dfd87227648192:13");
  322. EGroup_ReSpawn(baseobject);
  323. EGroup_ReSpawn(baseflag);
  324. EGroup_ReSpawn(basereinforce);
  325. EGroup_ReSpawn(retreat);
  326. else
  327. hintbase = HintPoint_Add(mkr_villageblowup, true, "$f69d864ff41f412f91dfd87227648192:13");
  328. EGroup_ReSpawn(baseobject);
  329. EGroup_ReSpawn(baseflag1);
  330. EGroup_ReSpawn(basereinforce1);
  331. EGroup_ReSpawn(retreat);
  332. end
  333. Game_FadeToBlack(FADE_IN, 0.5)
  334. end
  335. -----------------------------------------------------
  336. function RemoveHint()
  337. HintPoint_Remove(hintbase);
  338. HintPoint_Remove(hintretreat);
  339. end
  340. -----------------------------------------------------
  341. function testing()
  342. FOW_Enable(true)
  343. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement