Advertisement
Guest User

Bot Mission 1

a guest
May 12th, 2021
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.70 KB | None | 0 0
  1. class BotGroupMissionC1: MissionServer
  2. {
  3. //Spawns for Aisching!!
  4. void BotGroupMissionC1() { StartMissionAI(); }
  5.  
  6. AIWorld world = GetGame().GetWorld().GetAIWorld();
  7.  
  8. // Bot configs
  9. vector BotSpawnPoint = "8172.23 9.7125 7212.66"; // çàäàåì òî÷êó ñïàâíà áîòà
  10.  
  11. protected int m_botAcuracy = 30; // Setting the bot's accuracy (the higher the number, the more often the bot misses)
  12.  
  13. protected int BotSolderCountMin = 1; // assign the minimum number of bots
  14. protected int BotSolderCountMax = 10; // assign the maximum number of bots
  15.  
  16. protected int botLootCountMin = 5; // set the minimum amount of loot for the bot
  17. protected int botLootCountMax = 10; // assign the maximum amount of loot for the bot
  18.  
  19. protected float Zone_Radius = 900; // Trigger radius for the player to spawn bots
  20.  
  21. protected bool isUseCheckPoints = true; // set whether checkpoints are used true - used, fslse - not used
  22. protected bool isBotKaratist = false; // We set whether bots will carry weapons or will be fought with fists, by default they are with weapons, if needed without a firearm, write true
  23. protected bool onRespawnBot = true; // Enable or disable bot respawn (true - enabled, fslse - disabled)
  24. protected bool canUseTrigger = true; // Use trigger (true - enabled, fslse - disabled), if the trigger is not used, bots will spawn immediately after starting the server
  25. protected bool useKilFeed = true; // Enabling or disabling alerts when killing a bot
  26. protected bool m_Frendly = false; // Friendliness :) enable or disable. If enabled, then bots will not attack you until you attack it, if you attack a bot, you will become an enemy for all bots.
  27. protected bool onVoice = false; // Enable or disable bot voice (enabling this setting causes more server load)
  28. protected int m_spawnBotRadius = 100; // The radius of the spawn of bots in the territory, the center of the territory is the coordinate specified in BotSpawnPoint
  29. protected int m_SpeedPatrol = 3; // Setting the movement speed while patrolling (min = 1 max = 3)
  30.  
  31.  
  32. protected int m_TargetDist = 800; // We set the distance in meters at which the bot sees the target.
  33.  
  34. protected bool canBotSpawned = true; // Do not change !!!!!!!
  35.  
  36. // ------------------------------- end of config ------------------------------------------ //
  37.  
  38.  
  39. // Arrays with loot and clothes
  40. // If some type is not needed, just leave empty quotes example ---> TStringArray OtherEquip = {""};
  41. ref TStringArray Shirt = {"Military_Sweater", "Military_Sweater_Red", "Military_Sweater_Blue", "Military_Sweater_Green", "Military_Sweater_Black", "Military_Sweater_White", "Layered_Shirt_Base", "Layered_Shirt_White", "Layered_Shirt_Cheburashka", "Layered_Shirt_Courage", "Layered_Shirt_Lily", "Winter_Parka_Base", "Winter_Parka_White", "Winter_Parka_Green", "Medium_Sleeves_Shirt", "Medium_Sleeves_Shirt_Red", "Medium_Sleeves_Shirt_Blue", "GorkaEJacket_Autumn", "GorkaEJacket_Flat", "GorkaEJacket_PautRev", "GorkaEJacket_Summer", "WoolCoat_Beige", "WoolCoat_Black", "WoolCoat_BlackCheck", "WoolCoat_Blue", "WoolCoat_BlueCheck", "WoolCoat_BrownCheck", "WoolCoat_Green", "WoolCoat_GreyCheck", "WoolCoat_Red", "WoolCoat_RedCheck", "TrackSuitJacket_Black", "TrackSuitJacket_Blue", "TrackSuitJacket_Green", "TrackSuitJacket_LightBlue", "TrackSuitJacket_Red", "BDUJacket", "Raincoat_Orange", "Raincoat_Black", "Raincoat_Blue", "Raincoat_Green", "Raincoat_Pink", "Raincoat_Red", "Raincoat_Yellow", "LeatherShirt_Natural", "MedicalScrubsShirt_Blue", "MedicalScrubsShirt_Green", "MedicalScrubsShirt_White", "Shirt_BlueCheck", "Shirt_BlueCheckBright", "Shirt_GreenCheck", "Shirt_PlaneBlack", "Shirt_RedCheck", "Shirt_WhiteCheck", "TShirt_Beige", "TShirt_Black", "TShirt_Blue", "TShirt_Green", "TShirt_Grey", "TShirt_OrangeWhiteStripes", "TShirt_Red", "TShirt_RedBlackStripes", "TShirt_White", "TacticalShirt_Black", "TacticalShirt_Grey", "TacticalShirt_Olive", "TacticalShirt_Tan"};
  42. ref TStringArray Jeans = {"jeans_bluedark", "jeans_blue", "jeans_brown", "jeans_green", "jeans_grey", "cargopants_beige", "cargopants_black", "cargopants_blue", "cargopants_green", "cargopants_grey", "hunterpants_autumn", "hunterpants_brown", "hunterpants_spring", "hunterpants_summer", "hunterpants_winter", "canvaspants_beige", "canvaspants_blue", "canvaspants_grey", "canvaspants_red", "canvaspants_violet", "Blue_Leggings", "Msp_BoxingShorts_Blue", "Latex_Leggings", "Adidas_Leggings", "Red_Leggings", "Purple_Leggings", "Latex_White_Leggings", "Kneepads_Jeans_Base", "Kneepads_Jeans_Black", "GorkaPants_Autumn", "GorkaPants_PautRev", "GorkaPants_Summer", "TrackSuitPants_Blue", "TrackSuitPants_Black", "TrackSuitPants_Green", "TrackSuitPants_LightBlue", "TrackSuitPants_Red", "BDUPants"};
  43. ref TStringArray Shoes = {"AthleticShoes_Blue", "AthleticShoes_Grey", "AthleticShoes_Brown", "AthleticShoes_Green", "AthleticShoes_Black", "High_Knee_Sneakers", "High_Knee_Sneakers_Black", "FlipFlops_Colorbase", "TTSKOBoots", "WorkingBoots_Beige", "CombatBoots_Beige", "CombatBoots_Black", "CombatBoots_Brown", "Sneakers_Black", "Sneakers_Gray", "Sneakers_Green", "Sneakers_Red", "Sneakers_White"}; //Add boots ref TStringArray BackPack = {"CoyoteBag_Brown", "CoyoteBag_Green", "HuntingBag", "TortillaBag", "WaterproofBag_Green"}; //Add the Backpack
  44. ref TStringArray BackPack = {"CoyoteBag_Brown", "CoyoteBag_Green", "HuntingBag", "TortillaBag", "DryBag_Black", "DryBag_Blue", "DryBag_Green", "AliceBag_Black", "AssaultBag_Black", "AssaultBag_Green", "ChildBag_Blue", "ChildBag_Green", "ChildBag_Red", "CourierBag", "DryBag_Orange", "DryBag_Red", "DryBag_Yellow", "FurCourierBag", "FurImprovisedBag", "MountainBag_Blue", "MountainBag_Green", "MountainBag_Orange", "MountainBag_Red", "TaloonBag_Blue", "TaloonBag_Green", "TaloonBag_Orange", "TaloonBag_Violet"}; //Add the Backpack
  45. ref TStringArray Vest = {"HighCapacityVest_Black", "HighCapacityVest_Olive", "HuntingVest", "PlateCarrierVest", "UKAssVest_Camo"}; //Add Vest
  46. ref TStringArray Helm = {"Poncho_Red_Checkered", "Poncho_Blue_Checkered", "Poncho_Yellow_Checkered", "Poncho_Brown", "Poncho_Green", "Poncho_White", "Poncho_Red", "Poncho_Black", "Poncho_BlackAndWhite", "Poncho_BlackAndWhite2", "Slouch_Hat_Brown", "baseballcap_blue", "baseballcap_beige", "baseballcap_black", "baseballcap_olive", "baseballcap_pink", "baseballcap_red", "baseballcap_camo", "baseballcap_cmmg_black", "baseballcap_cmmg_pink", "pilothelmet_zsh3", "BeanieHat_Beige", "BeanieHat_Black", "BeanieHat_Blue", "BeanieHat_Brown", "BeanieHat_Green", "BeanieHat_Grey", "BeanieHat_Pink", "BeanieHat_Red", "Ushanka_Black", "Ushanka_Blue", "Ushanka_Green", "DarkMotoHelmet_Black", "DarkMotoHelmet_Blue", "DarkMotoHelmet_Green", "DarkMotoHelmet_Red", "DarkMotoHelmet_White", "headtorch_grey", "headtorch_black", "Bandana_Blackpattern", "RadarCap_Black", "RadarCap_Brown", "RadarCap_Green", "RadarCap_Red", "radarcap_black", "radarcap_blue", "radarcap_brown", "radarcap_green", "radarcap_red", "zmijovkacap_black", "zmijovkacap_blue", "zmijovkacap_brown", "zmijovkacap_green", "zmijovkacap_red", "MilitaryBeret_CDF", "MilitaryBeret_ChDKZ", "MilitaryBeret_Red", "MilitaryBeret_UN", "MilitaryBeret_NZ", "constructionhelmet_blue", "constructionhelmet_green2", "constructionhelmet_orange", "constructionhelmet_red", "constructionhelmet_white", "constructionhelmet_yellow", "DarkMotoHelmet_Lime", "cowboyhat_brown", "cowboyhat_black", "cowboyhat_darkbrown", "cowboyhat_green", "ballistichelmet_green", "ballistichelmet_black", "ballistichelmet_un", "flatcap_black", "flatcap_blue", "flatcap_red", "flatcap_brown", "flatcap_grey", "flatcap_check_brown", "flatcap_check_grey", "flatcap_check_black", "booniehat_black", "booniehat_blue", "booniehat_dpm", "booniehat_dubok", "booniehat_flecktran", "booniehat_navyblue", "booniehat_olive", "booniehat_orange", "booniehat_red", "booniehat_tan", "constructionhelmet_lime", "motohelmet_grey", "officerhat", "policecap", "pilotkacap", "Mich2001Helmet", "PumpkinHelmet", "SkateHelmet_Black", "GorkaHelmet", "BallisticHelmet_Black"}; //Add a helmet or headgear ref TStringArray Gloves = {"WorkingGloves_Beige", "WorkingGloves_Black", "NBCGlovesGray", "OMNOGloves_Brown", "SurgicalGloves_Blue"}; //Add gloves
  47. ref TStringArray Gloves = {"WorkingGloves_Beige", "WorkingGloves_Black", "NBCGlovesGray", "OMNOGloves_Brown", "SurgicalGloves_Blue", "LeatherGloves_Beige", "LeatherGloves_Black", "NBCGlovesGray", "SurgicalGloves_Green", "SurgicalGloves_LightBlue", "SurgicalGloves_White", "Fingerless_Gloves", "Fingerless_Gloves_Brown", "Fingerless_Gloves_Wool", "Fingerless_Gloves_Wool_Grey"}; //Add gloves
  48. ref TStringArray OtherEquip = {"CivilianBelt", "MilitaryBelt", "GasMask", "Balaclava3Holes_Beige", "Balaclava3Holes_Black", "Balaclava3Holes_Blue", "Balaclava3Holes_Green", "BalaclavaMask_Beige", "BalaclavaMask_Black", "BalaclavaMask_Blackskull", "BalaclavaMask_Blue", "BalaclavaMask_Green", "BalaclavaMask_Pink", "BalaclavaMask_White", "SurgicalMask", "DallasMask", "GP5GasMask", "HockeyMask", "HoxtonMask", "NioshFaceMask", "WeldingMask", "WolfMask", "PMK_5A_Gas_Mask", "SkullMask", "AirborneMask", "BandanaMask_BlackPattern", "BandanaMask_CamoPattern", "BandanaMask_GreenPattern", "BandanaMask_PolkaPattern"}; //Add an additional item of clothing, it can be anything :)
  49.  
  50. ref TStringArray RandomLoot = {"SardinesCan", "SodaCan_Cola", "SodaCan_Kvass", "Rice", "Rope", "Screwdriver", "AmmoBox_545x39_20Rnd", "AmmoBox_00buck_10rnd", "AmmoBox_12gaSlug_10Rnd", "AmmoBox_22_50Rnd", "AmmoBox_308Win_20Rnd", "AmmoBox_357_20Rnd", "AmmoBox_380_35rnd","AmmoBox_45ACP_25rnd", "AmmoBox_556x45_20Rnd", "AmmoBox_762x39_20Rnd", "AmmoBox_762x54_20Rnd", "AmmoBox_9x19_25rnd"}; //We add any loot to the array, the amount is not limited
  51. ref TStringArray MeleeWeap = {"WoodAxe", "FirefighterAxe", "Shovel", "Pickaxe"}; //Add melee weapons
  52.  
  53. // -------------------------------- end -------------------------------------------------------//
  54.  
  55. protected EntityAI itemEnt; // Do not change !!!!
  56.  
  57. // Function for creating checkpoints (register checkpoints here)
  58. void AddCeckPoint(SurvivorBotBase m_BotSolder)
  59. {
  60. m_BotSolder.SetUseCheckpoint(); // Do not touch this line!
  61.  
  62. m_BotSolder.AddCheckpoint("8266.25 9.72369 7280.59");
  63. m_BotSolder.AddCheckpoint("8362.73 9.71786 7329.12");
  64. m_BotSolder.AddCheckpoint("8379.96 10.2438 7224.36");
  65. m_BotSolder.AddCheckpoint("8343.43 18.1293 6975.42");
  66. m_BotSolder.AddCheckpoint("8520 46.5298 7023.95");
  67. m_BotSolder.AddCheckpoint("8212.65 9.71247 7219.08");
  68. }
  69. // ---------------------------------- end -------------------------------------- /
  70.  
  71. ref array<SurvivorBotBase> m_BotMass = new array<SurvivorBotBase>;
  72.  
  73.  
  74. // The function of creating weapons for the bot (here you can add 7 weapon wmds, enter at your discretion)
  75. void createWeapFromBot(SurvivorBotBase m_BotSolder)
  76. {
  77. int randomWeapon = Math.RandomInt(1, 4);
  78.  
  79. switch( randomWeapon )
  80. {
  81. case 1:
  82. {
  83. m_BotSolder.AddWeapon("M4A1"); //Weapon
  84. m_BotSolder.AddWeaponAtt("M4_RISHndgrd"); //Att 1
  85. m_BotSolder.AddWeaponAtt("M4_MPBttstck"); //Att 2
  86. m_BotSolder.AddWeaponAtt("ACOGOptic"); //Att 3
  87. // m_BotSolder.AddMagazine("Mag_STANAG_30Rnd"); //Mag
  88. break;
  89. //We add body kits as needed, magazines for weapons are issued automatically, no need to add them
  90. }
  91.  
  92. case 2:
  93. {
  94. m_BotSolder.AddWeapon("AKM");
  95. m_BotSolder.AddWeaponAtt("AK_WoodBttstck");
  96. m_BotSolder.AddWeaponAtt("AK_WoodHndgrd");
  97. // m_BotSolder.AddMagazine("Mag_AKM_Drum75Rnd");
  98. break;
  99. }
  100.  
  101. case 3:
  102. {
  103. m_BotSolder.AddWeapon("SVD");
  104. // m_BotSolder.AddMagazine("Mag_SVD_10Rnd");
  105. break;
  106. }
  107.  
  108. case 4:
  109. {
  110. m_BotSolder.AddWeapon("Rev_HK417");
  111. m_BotSolder.AddWeaponAtt("ReflexOptic");
  112. // m_BotSolder.AddMagazine("Rev_Mag_HK417_20rnd");
  113. break;
  114. }
  115. }
  116. }
  117. // ----------------------------- end ------------------------------------- //
  118.  
  119. // Bot spawn function (we don't change anything here !!!)
  120. void createBotUnit()
  121. {
  122. vector Navmesh;
  123. vector botSpPos;
  124. private SurvivorBotBase m_BotSolder;
  125.  
  126. ref TStringArray m_BotBody = { "BotM_Mirek", "BotM_Rolf", "BotM_Quinn", "BotM_Peter", "BotM_Oliver" };
  127.  
  128. PGFilter m_pgFilterNav = new PGFilter();
  129. m_pgFilterNav.SetFlags(PGPolyFlags.WALK, PGPolyFlags.INSIDE, 0);
  130.  
  131. float bspX = BotSpawnPoint[0];
  132. float bspY = BotSpawnPoint[2];
  133.  
  134. if (isUseCheckPoints)
  135. botSpPos = Vector(bspX + Math.RandomInt(-7, 7), BotSpawnPoint[1], bspY + Math.RandomInt(-7, 7));
  136. else
  137. botSpPos = Vector(bspX + Math.RandomInt(-m_spawnBotRadius, m_spawnBotRadius), BotSpawnPoint[1], bspY + Math.RandomInt(-m_spawnBotRadius, m_spawnBotRadius));
  138.  
  139. bool IsNavmesh = world.SampleNavmeshPosition( botSpPos, 2, m_pgFilterNav, Navmesh );
  140.  
  141. if (IsNavmesh)
  142. m_BotSolder = SurvivorBotBase.Cast(GetGame().CreateObject(m_BotBody.GetRandomElement(), Navmesh));
  143. else
  144. m_BotSolder = SurvivorBotBase.Cast(GetGame().CreateObject(m_BotBody.GetRandomElement(), botSpPos));
  145.  
  146.  
  147. m_BotSolder.GetInventory().CreateInInventory(Shirt.GetRandomElement());
  148. m_BotSolder.GetInventory().CreateInInventory(Jeans.GetRandomElement());
  149. m_BotSolder.GetInventory().CreateInInventory(Shoes.GetRandomElement());
  150. m_BotSolder.GetInventory().CreateInInventory(BackPack.GetRandomElement());
  151. m_BotSolder.GetInventory().CreateInInventory(Vest.GetRandomElement());
  152. m_BotSolder.GetInventory().CreateInInventory(Helm.GetRandomElement());
  153. m_BotSolder.GetInventory().CreateInInventory(Gloves.GetRandomElement());
  154. m_BotSolder.GetInventory().CreateInInventory(OtherEquip.GetRandomElement());
  155.  
  156. if (isBotKaratist)
  157. m_BotSolder.GetHumanInventory().CreateInHands(MeleeWeap.GetRandomElement());
  158. else
  159. createWeapFromBot(m_BotSolder);
  160.  
  161. int rndLootCnt = Math.RandomInt(botLootCountMin, botLootCountMax);
  162.  
  163. for (int i = 0; i < rndLootCnt; i++)
  164. {
  165. itemEnt = m_BotSolder.GetInventory().CreateInInventory(RandomLoot.GetRandomElement());
  166. if (itemEnt)
  167. {
  168. int rndHlt = Math.RandomInt(55,100);
  169. itemEnt.SetHealth("","",rndHlt);
  170. }
  171. }
  172.  
  173. m_BotSolder.SetAcuracy(m_botAcuracy);
  174. m_BotSolder.SetDistance(m_TargetDist);
  175. m_BotSolder.SetUseVoice(onVoice);
  176. m_BotSolder.SetUseKillFeed(useKilFeed);
  177. m_BotSolder.SetFrendly(m_Frendly);
  178. m_BotSolder.SetSpeedPatrol(m_SpeedPatrol);
  179.  
  180.  
  181. if (isUseCheckPoints)
  182. AddCeckPoint(m_BotSolder);
  183.  
  184.  
  185. m_BotMass.Insert(m_BotSolder);
  186. }
  187. // ----------------------------- end ------------------------------------- //
  188.  
  189. // ----------------------------- Bots respawn function ----------------------------------------//
  190. private void respawnBotUnitC1()
  191. {
  192. ref array<Man> players = new array<Man>;
  193. GetGame().GetPlayers( players );
  194. SurvivorBotBase Bot_Ar;
  195. vector posB;
  196. bool m_botRemoved = false;
  197. float distB;
  198. int m_countBot = m_BotMass.Count();
  199. if (canBotSpawned)
  200. {
  201. for ( int u = 0; u < players.Count(); u++ )
  202. {
  203.  
  204. PlayerBase player;
  205. Class.CastTo(player, players.Get(u));
  206. vector pos = player.GetPosition();
  207. float dist = vector.Distance( pos, BotSpawnPoint );
  208.  
  209. if ( dist < Zone_Radius )
  210. return;
  211.  
  212. if (dist > Zone_Radius)
  213. {
  214. for ( int a = 0; a < m_countBot; a++ )
  215. {
  216. Bot_Ar = m_BotMass.Get(a);
  217. if (Bot_Ar)
  218. {
  219. if (!Bot_Ar.IsAlive())
  220. {
  221. posB = Bot_Ar.GetPosition();
  222. distB = vector.Distance( posB, BotSpawnPoint );
  223. if (distB < Zone_Radius)
  224. {
  225. m_BotMass.Remove( a );
  226. }
  227.  
  228. if (m_BotMass.Count() == 0)
  229. m_botRemoved = true;
  230. }
  231. }
  232. }
  233.  
  234. if (m_botRemoved)
  235. {
  236. StartMissionAI();
  237. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(respawnBotUnitC1);
  238. m_botRemoved = false;
  239. }
  240. }
  241. }
  242. }
  243. }
  244. // ----------------------------- end ----------------------------------------//
  245.  
  246.  
  247.  
  248.  
  249. // Spawn function of a group of bots
  250. int delaySpawn = 0;
  251. void spawnBotGroup()
  252. {
  253. int rndBotGrpCnt = Math.RandomInt(BotSolderCountMin, BotSolderCountMax);
  254. Print("Bots spawned! Count " + rndBotGrpCnt);
  255. for (int a = 0; a < rndBotGrpCnt; a++)
  256. {
  257. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(createBotUnit, 500 + delaySpawn);
  258. delaySpawn +=1000;
  259. }
  260. }
  261. // --------------------------------------- end --------------------------------------- //
  262.  
  263. // Player trigger function
  264. void TriggerPlayersC1()
  265. {
  266. ref array<Man> players = new array<Man>;
  267. GetGame().GetPlayers( players );
  268. delaySpawn = 0;
  269.  
  270. if (canBotSpawned && IsGoodSrvFps())
  271. {
  272. for ( int u = 0; u < players.Count(); u++ )
  273. {
  274.  
  275. PlayerBase player;
  276. Class.CastTo(player, players.Get(u));
  277. vector pos = player.GetPosition();
  278. float dist = vector.Distance( pos, BotSpawnPoint );
  279.  
  280. if ( dist < Zone_Radius && !player.IsBot() )
  281. {
  282. spawnBotGroup();
  283. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(TriggerPlayersC1);
  284.  
  285. if (onRespawnBot)
  286. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(respawnBotUnitC1, 60000, true);
  287. }
  288. }
  289. }
  290. }
  291. // --------------------------------------- end --------------------------------------- //
  292.  
  293. void StartMissionAI()
  294. {
  295. Print("Start mission bot");
  296. if (canUseTrigger)
  297. {
  298. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TriggerPlayersC1, 5000, true);
  299. }
  300. else if (IsGoodSrvFps())
  301. {
  302. spawnBotGroup();
  303. }
  304. }
  305.  
  306. bool IsGoodSrvFps()
  307. {
  308. float TestFpsSrv = GetGame().GetFps();
  309.  
  310. if (TestFpsSrv < 2)
  311. {
  312. return true;
  313. }
  314. else
  315. {
  316. Print("Server FPS low! FPS = " + TestFpsSrv + " Bots not respawned!");
  317. return false;
  318. }
  319. }
  320. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement