ralian / eai

Enfusion Artifical Intelligence for DayZ and future Bohemia Interactive games.
Apache License 2.0
68 stars 27 forks source link

AI dont spawn at Takistan Plus mission #24

Open ZXCTester opened 2 years ago

ZXCTester commented 2 years ago

Today I installed your mod on my server with a map of Takistan (I changed the coordinates of the patrols for the map of Takistan), but I had problems when entering the server and trying to find bots to check their work, I could not find any bot. The radial menu (which is on T) also refuses to work. When the server starts, it does not give any errors, mission code and AI.c file code are also here:

AI.c Code:

`// Patrol 11 = Ridges North of Loy Manara ref array patrol_11 = {"6903.27 609.027 3904.43", "6839.92 605.49 3839.49", "6803.18 599.883 3713.25", "6670.14 595.847 3551.35", "6514.56 610.807 3488.5", "6411.25 621.932 3435.46", "6141.8 647.294 3372.51", "6412.51 622.034 3435.06", "6690.18 597.046 3568.95", "6812.68 600.855 3728.06", "6922.25 607.672 3925.36"};

// Patrol 12 = Badlands ref array patrol_12 = {"5853.27 496.347 4254.25", "5981.08 475.242 4206.71", "6146.88 455.229 4154.61", "6273.63 450.806 4232.53", "6274.12 419.499 4418.06", "6173.25 383.236 4487.14", "6039.94 424.025 4358.68", "5967.61 449.901 4340.3", "5868.15 492.699 4263.49"};

// Patrol 13 = North Garmsar Mil Base ref array patrol_13 = {"10335.1 322.096 6613.35", "10349 285.215 6564.88", "10352.2 276.345 6554.09", "10357 265.646 6540.95", "10363.2 282.723 6569.35", "10360.4 309.76 6604.4", "10321 332.387 6634.36"};

// Patrol 14 = North Qarma ref array patrol_14 = {"6597.2 322.597 6356.89", "6645.04 297.822 6452.09", "6628.62 298.928 6602.77", "6652.33 292.891 6643.51", "6695.06 267.072 6671.22", "6722.08 259.507 6621.36", "6673.64 294.656 6558.48", "6708.05 278.135 6535.59", "6665.82 296.17 6505.84", "6635.88 308.887 6399.46"};

// Patrol 15 = North Feeruz Abad Radio Tower ref array patrol_15 = {"4511.23 345.949 6944.45", "4477.3 362.564 6956.82", "4426.06 380.027 6969.24", "4349.2 401.746 6978.34", "4284.1 425.928 6975.39", "4217.82 447.871 6960.24", "4108.14 495.623 6874.33", "4123.78 503.659 6811.35"};

// Patrol 16 = South Elthoubaroh ref array patrol_16 = {"1881.12 384.055 7287.97", "1954.92 353.698 7352.56", "1996.5 328.575 7419.13", "1905.47 322.901 7444.14", "1792.23 356.681 7442.36", "1750.51 362.55 7507.55", "1749.89 355.355 7536.28", "1818.09 342.171 7516.37", "1898.8 323.775 7445.71", "1992.44 327.07 7428.37"};

// Patrol 17 = North Airfield 17 ref array patrol_17 = {"5606.83 84.8426 11030.6", "5600.76 83.3308 11020.1", "5578.36 83.3683 11001.7", "5544.7 83.3736 11031.4", "5559.06 83.3736 11049.2", "5597.11 83.3441 11015.8", "5605.61 83.3571 11026.1", "5582.92 83.3612 11002.1", "5544.16 83.3736 11027.8"};

// If you add another patrol array, add it to this list ref array<array> patrol_list = {patrol_1, patrol_2, patrol_3, patrol_4, patrol_5, patrol_6, patrol_7, patrol_8, patrol_9, patrol_10, patrol_11, patrol_12, patrol_13, patrol_14, patrol_15, patrol_16, patrol_17};

// IMPORTANT: If you add an entry to the above list, pick the loadout for it by adding the loadout filename to this list ref array patrol_loadouts = {"HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json", "HumanLoadout.json"};

// you may change these quantities const int NUMBER_PER_PATROL = 3; // Number of AI per patrol const int MAXR = 800; // This is the main spawn radius- how close a player needs to be to spawn them in. const int MINR = 300; // If a player is this close to the patrol start point, it is too close for them to spawn const int DESPAWNR = 1000; // If all players are this far away, they despawn. const int RESPAWN_SECONDS = 300; // The amount of seconds before a new patrol will spawn, after they both die

class CustomPatrol : eAIDynamicPatrol { override void OnPatrolSpawn(eAIGroup patrol) { // Uncomment this line to change the faction of the patrol from Raiders (default) // eAIFactionGuards for example is a faction which only kills players who have their weapons out // patrol.SetFaction(new eAIFactionGuards());

    // Uncomment this line to slow down or speed up the patrol (1.0 to 3.0)
    // patrol.SetSpeedLimit(1.0);
}
override void OnUnitSpawn(eAIBase unit) {
    // Uncomment this to give the AI unlimited magazines (new one is added on reload)
    // unit.SetUnlimitedMags(true);

    // You can also do anything you would do in the StartingEquipSetup() for players here

    // These lines will add attachments the same way you would for a player. However, the AI must have the M4A1 class in the Loadout.json file already for it to work.
    //Weapon_Base weapon = Weapon_Base.Cast(unit.GetItemInHands());
    //weapon.GetInventory().CreateAttachment("M4_PlasticHndgrd");
    //weapon.GetInventory().CreateAttachment("M4_OEBttstck");
    //weapon.GetInventory().CreateAttachment("M4_CarryHandleOptic");
}

};

autoptr array patrols = {};

void InitDynamicPatrols() { for (int i = 0; i < patrol_list.Count(); i++) { string loadout = "SoldierLoadout.json"; // default if (i < patrol_loadouts.Count()) loadout = patrol_loadouts[i]; autoptr CustomPatrol pat = new CustomPatrol(patrol_list[i][0], patrol_list[i], loadout, NUMBER_PER_PATROL, MINR, MAXR, DESPAWNR, RESPAWN_SECONDS); patrols.Insert(pat); pat.UpdateTriggers(); } }

void SpawnSentry(vector pos, string loadout = "SoldierLoadout.json") { eAIGame game = MissionServer.Cast(GetGame().GetMission()).GetEAIGame(); eAIBase ai = game.SpawnAI_Sentry(pos, loadout); }

modded class CustomMission { void StartingEquipSetup(PlayerBase player, bool clothesChosen) { m_eaiGame.GetGroupByLeader(player); super.StartingEquipSetup(player, clothesChosen); } };`

Mission Code:

`#include "$CurrentDir:mpmissions/Offline.TakistanPlus/eAI/AI_init.c"

void main() {

//INIT ECONOMY--------------------------------------
Hive ce = CreateHive();
if ( ce )
    ce.InitOffline();

/*
  [Takistan] Weather init
   Warning: DO NOT ALTER following values as they are interconnected with Takistan weather system!
   To ensure correct functionality, it is necessary to include weaher init AFTER the hive init.
*/
Weather weather = GetGame().GetWeather();
weather.MissionWeather( true );
weather.GetOvercast().SetLimits( 0.0, 0.30 );
weather.GetRain().SetLimits( 0.0, 0.0 );
weather.GetFog().SetLimits( 0.0, 0.0 );
weather.GetOvercast().SetForecastChangeLimits( 0.1, 0.3 );
weather.GetOvercast().SetForecastTimeLimits( 1600, 2100 );
weather.GetOvercast().Set( 0.0, 0, 0 );
weather.GetRain().Set( 0, 0, 0 );
weather.GetFog().Set( 0, 0, 0 );
weather.SetWindMaximumSpeed( 30 );
weather.SetWindFunctionParams( 0.1, 1.0, 42 );
weather.SetStorm( 1, 0.7, 30 );
weather.SetRainThresholds( 0.0, 1.0, 0 );

/*
  [Takistan] Mission time init
   after CE init to determine if storage mission type is outside of the required time-frame
*/
int year, month, day, hour, minute;
GetGame().GetWorld().GetDate( year, month, day, hour, minute );
if ( ( month > 9 ) || ( month <= 6 ) )
{
    year = 2011;
    month = 7;
    day = 1;

    GetGame().GetWorld().SetDate( year, month, day, hour, minute );
}

}

class CustomMission: MissionServer { void SetRandomHealth(EntityAI itemEnt) { if ( itemEnt ) { float rndHlt = Math.RandomFloat( 0.25, 0.65 ); itemEnt.SetHealth01( "", "", rndHlt ); } }

override void OnInit()
{
    super.OnInit();

    // this piece of code is recommended otherwise the event system is switched on automatically and runs from default values
    if ( m_EventManager )
    {
        // min time between events, max time between events, max number of events at the same time
        m_EventManager.Run( 900, 2700, 1 );
        // registering events and their probability
        m_EventManager.RegisterEvent( Sandstorm, 1.0 );
    }
}

override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
{
    Entity playerEnt;
    playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
    Class.CastTo( m_player, playerEnt );

    GetGame().SelectPlayer( identity, m_player );

    return m_player;
}

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
    EntityAI itemClothing;
    EntityAI itemEnt;
    ItemBase itemBs;
    float rand;

    itemClothing = player.FindAttachmentBySlotName( "Body" );
    {
        itemEnt = player.GetInventory().CreateInInventory("Compass");

        itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");

        itemEnt = player.GetInventory().CreateInInventory("BandageDressing");

        itemEnt = player.GetInventory().CreateInInventory("TunaCan");

        itemEnt = player.GetInventory().CreateInInventory("Chemlight_White");           

    };
    if ( itemClothing )
    {
        SetRandomHealth( itemClothing );

        itemEnt = itemClothing.GetInventory().CreateInInventory( "TunaCan" );
                    if ( Class.CastTo( itemBs, itemEnt ) )
            itemBs.SetQuantity( 4 );

        SetRandomHealth( itemEnt );

        string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
        int rndIndex = Math.RandomInt( 0, 4 );
        itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
        SetRandomHealth( itemEnt );
    }

    itemClothing = player.FindAttachmentBySlotName( "Legs" );
    if ( itemClothing )
        SetRandomHealth( itemClothing );

    itemClothing = player.FindAttachmentBySlotName( "Feet" );
    if ( itemClothing )
        SetRandomHealth( itemClothing );
}

};

Mission CreateCustomMission(string path) { return new CustomMission(); }`

ZXCTester commented 2 years ago

I tried to fix this problem myself by transferring all files from the mission folder to the takistan folder, however this caused a server crash, with subsequent errors изображение_2021-10-22_175408 After opening the mod file in the necessary directory, I came across this line, and again json file loader, as well as in the case of the previous error.What is the endebug error, I have no idea.... image What was shown in the console at the time of the server crash: image