ref HeliWreck m_HeliWreck = new HeliWreck();
class HeliWreck
{
ref array<EntityAI> m_SpawnedZombies = new array<EntityAI>;
EntityAI Heli;
EntityAI Chest
const string boxtype = "SeaChest";
const int spawntime = 1200; //Время до спавна след. вертолета в сек.
ref TVectorArray SpawnCoords = {
"Тут координата"
};
int INT_MAX_ZOMBIES = 16; //Макс. кол-во зомби
int INT_MIN_ZOMBIES = 10; //Мин. кол-во зомби
void HeliWreck()
{
//s_Conf = new SpawnConfig();
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.SpawnHeli, spawntime * 1000, true);
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.clearplace, 10000, false);
}
void ~HeliWreck()
{
}
void clearplace()
{
for (int i = 0; i < SpawnCoords.Count(); ++i)
{
array<Object> PrivateObjects = new array<Object>; //Объекты в зонах
array<CargoBase> PrivateCargos = new array<CargoBase>;
GetGame().GetObjectsAtPosition3D( SnapToGroundZ(SpawnCoords.Get(i)), 15, PrivateObjects, PrivateCargos);
for (int j = 0; j < PrivateObjects.Count(); ++j)
{
EntityAI tempEnt = EntityAI.Cast(PrivateObjects.Get(j));
if (tempEnt && (tempEnt.GetType() == boxtype))
{
if (PrivateObjects.Get(j) != Chest)
GetGame().ObjectDelete(PrivateObjects.Get(j));
}
}
}
}
void SpawnHeli()
{
CleanUp();
vector pos = SnapToGroundZ(SpawnCoords.GetRandomElement());
//Heli = GetGame().CreateObject( "land_wrecked_mi8", pos, false, true );
Heli = GetGame().CreateObject( "Wreck_Mi8_Crashed", Vector(pos[0], pos[1]+1 , pos[2]), false, true );
TStringArray Trophy = Trophys.GetRandomElement();
vector pos1 = SnapToGroundZ(Vector(pos[0] - 3, pos[1] , pos[2] + 1));
Chest = GetGame().CreateObject(boxtype, pos1, false, true);
Container_Base loot = Container_Base.Cast(Chest);
//loot.Open();
if ( Trophy.Count() > 0 )
{
EntityAI trophy = loot.GetInventory().CreateEntityInCargo(Trophy[0]);
if (trophy)
{
loot.GetInventory().CreateEntityInCargo(Trophy[1]);
loot.GetInventory().CreateEntityInCargo(Trophy[1]);
for (private int j = 2; j < Trophy.Count(); j++)
{
loot.GetInventory().CreateEntityInCargo(Trophy[j]);
}
}
}
loot.GetInventory().CreateEntityInCargo(PossibleAttachmentsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAttachmentsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAttachmentsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAttachmentsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleAmmosDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleLootDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleLootDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleToolsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleToolsDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleFoodDrops.GetRandomElement());
loot.GetInventory().CreateEntityInCargo(PossibleFoodDrops.GetRandomElement());
//loot.Close();
int oRandValue = Math.RandomIntInclusive(INT_MIN_ZOMBIES,INT_MAX_ZOMBIES);
for (int i = 0; i < oRandValue; ++i)
{
int rndS1 = Math.RandomIntInclusive(-1,1);
float rndX = Math.RandomIntInclusive(5,10) * rndS1;
if (rndS1 == 0)
{
while (rndS1 == 0)
{
rndS1 = Math.RandomIntInclusive(-1,1);
rndX = Math.RandomIntInclusive(5,10) * rndS1;
}
}
else
{
rndS1 = Math.RandomIntInclusive(-1,1);
}
float rndY = Math.RandomIntInclusive(5,10) * rndS1;
pos1 = SnapToGroundZ(Vector(pos[0] + rndX, pos[1] , pos[2] + rndY));
EntityAI AIzmb = GetGame().CreateObject( ZombieClasses.GetRandomElement(), pos1, false, true );
if (AIzmb)
{
AIzmb.GetInventory().CreateInInventory("Ssh68Helmet");
}
ref ZombieBase Bszmb;
Class.CastTo(Bszmb,AIzmb);
if (Bszmb)
{
m_SpawnedZombies.Insert(AIzmb);
}
}
}
void CleanUp()
{
if (Heli) GetGame().ObjectDelete(Heli);
if (Chest) GetGame().ObjectDelete(Chest);
for (int i = 0; i < m_SpawnedZombies.Count(); ++i)
{
EntityAI zmb = m_SpawnedZombies.Get(i);
GetGame().ObjectDelete(zmb);
}
m_SpawnedZombies.Clear();
}
ref TStringArray PossibleAttachmentsDrops = {
"","AK_RailHndgrd","M4_RISHndgrd",
"AKS74U_Bttstck","","M4_OEBttstck","",
"Fal_FoldingBttstck","Mag_AK101_30Rnd","Mag_AK74_30Rnd",
"AKS74U_Bttstck","Mag_AK74_30Rnd","Mag_AKM_30Rnd",
"Mag_VSS_10Rnd","ACOGOptic","AK_RailHndgrd",
"AK_FoldingBttstck","M4_RISHndgrd","AKS74U_Bttstck",
"","","","AKS74U_Bttstck","",
"","Mag_AK74_30Rnd","Mag_CMAG_30Rnd",
"Mag_VSS_10Rnd","Mag_Saiga_8Rnd","","",
"AK_FoldingBttstck","","M4_OEBttstck","",
"","Mag_Saiga_5Rnd","Mag_VSS_10Rnd",
"AK_FoldingBttstck","M4_OEBttstck","",
"","Mag_Saiga_5Rnd","",
};
ref TStringArray PossibleAmmosDrops = {
"ammo_45acp", "ammo_556x45", "ammo_762x39",
"Ammo_545x39","Ammo_12gaSlug","Ammo_545x39",
"Ammo_12gaPellets","AmmoBox_556x45_20Rnd",
"ammo_762x39","Ammo_12gaPellets","ammo_45acp",
"AmmoBox_357_20Rnd","AmmoBox_545x39_20Rnd",
"AmmoBox_9x39AP_20Rnd","Ammo_9x39","ammo_45acp",
"","ammo_556x45", "AmmoBox_762x39_20Rnd",
"Ammo_12gaSlug","","Ammo_545x39","Ammo_12gaSlug",
"","Ammo_12gaPellets","AmmoBox_357_20Rnd",
"Ammo_9x39","","","Ammo_357","Ammo_357",
};
ref TStringArray PossibleClothesDrops = {
"NylonKnifeSheath","PlateCarrierHolster",
"HuntingJacket_Autumn","HunterPants_Autumn",
};
ref TStringArray PossibleClothesDropsMil = {
"","MilitaryBelt",
"",
};
ref TStringArray PossibleToolsDrops = {
"","","IO_Radiation_pills","",""
};
ref TStringArray PossibleLootDrops = {
"BandageDressing","BandageDressing","","","","",
};
ref TStringArray PossibleFoodDrops = {
"BandageDressing","BandageDressing","","",
};
ref array<ref TStringArray> Trophys = {
{"M4A1","Mag_CMAG_40Rnd","M4_OEBttstck","M4_RISHndgrd",},
{"M4A1","Mag_CMAG_40Rnd","","M4_OEBttstck","M4_RISHndgrd",},
{"AKM","Mag_AKM_30Rnd","AK_FoldingBttstck","AK_RailHndgrd",},
{"AKM","Mag_AKM_30Rnd","","AK_FoldingBttstck","AK_RailHndgrd",},
{"AK101","Mag_AK101_30Rnd","","AKS74U_Bttstck","AK_RailHndgrd_Black",},
{"AK101","Mag_AK101_30Rnd","","AKS74U_Bttstck","AK_RailHndgrd_Black",},
{"AK74","Mag_AK74_30Rnd","AKS74U_Bttstck","AK74_Hndgrd",},
{"AK74","Mag_AK74_30Rnd","","AKS74U_Bttstck","AK74_Hndgrd",},
};
ref TStringArray ZombieClasses = {
"Mutant_AoD_Snork1_Easy","Mutant_AoD_Snork2_Easy",
};
vector SnapToGroundZ(vector pos)
{
float pos_x = pos[0];
float pos_z = pos[2];
float pos_y = GetGame().SurfaceY( pos_x, pos_z );
vector tmp_pos = Vector( pos_x, pos_y, pos_z );
return tmp_pos;
}
}
#include "$CurrentDir:mpmissions\"Тут название папки миссии"\HeliCrash.c"
Сам файл так и должен называться: "HeliCrash.c" (Хотя можешь назвать как угодно)