Skip to main content

CreateInInventory


void main()
{
        vector player_pos;
    int index;

    //TVectorArray positions = {"4548 0 10699"}; //NWAF
    TVectorArray positions = {"10337 0 1760"}; //Electro Docks
    //TVectorArray positions = {"9496 0 2039"}; //Electro gas station
   
    TStringArray tops = {"M65Jacket_Black"};
    TStringArray pants = {"HunterPants_Autumn"};
    TStringArray shoes = {"MilitaryBoots_Black"};
       
    Print(positions);
   
    index = Math.RandomInt(0, positions.Count() );
    player_pos = positions.Get(index);
    Print(player_pos);   

    //INIT WEATHER BEFORE ECONOMY INIT------------------------
    Weather weather = g_Game.GetWeather();

    weather.MissionWeather(false);    // false = use weather controller from Weather.c

    weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
    weather.GetRain().Set( 0, 0, 1);
    weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);
   
    weather.GetRain().SetLimits( 0, 0.1 );

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

    //DATE RESET AFTER ECONOMY INIT-------------------------
    int year;
    int month;
    int day;
    int hour;
    int minute;

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

    if (((month <= 9) && (day < 20)) || ((month >= 10) && (day > 20)))
    {
        month = 9;
        day = 20;
       
        GetGame().GetWorld().SetDate(year, month, day, hour, minute);
    }
   
    //-----------------------X-mas
    array<vector> treePositions = { "6560.29 0 2462.12",
                                    "1652.66 0 14230.71",
                                    "3801.06 0 8847.76",
                                    "9442.32 0 8829.03",
                                    "7903.16 0 12576.52",
                                    "11617.75 0 14663.98",
                                    "12830.08 0 10115.18",
                                    "11221.94 0 12225.89",
                                    "3471.93 0 12988.33",
                                    "13933.42 0 13228.44",
                                    "12022.64 0 9082.89",
                                    "10468.54 0 2373.16",
                                    "2725.48 0 5288.75",
    };
   

    Object treeEntity;
    for ( int i=0; i < treePositions.Count(); i++ )
    {
        vector treePos = treePositions[i];
        float posY = GetGame().SurfaceY(treePos[0], treePos[2]);
        treeEntity = GetGame().CreateObject("ChristmasTree", Vector( treePos[0], posY, treePos[2]), false);

    }
}

class CustomMission: MissionServer
{   
    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            int rndHlt = Math.RandomInt(55,100);
            itemEnt.SetHealth("","",rndHlt);
        }
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, "10354 0 2301", 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
       
        GetGame().SelectPlayer(identity, m_player);
       
        return m_player;
    }
   
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
/*
        player.RemoveAllItems();

        EntityAI item = player.GetInventory().CreateInInventory(topsMissionArray.GetRandomElement());
        EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
        EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
*/
        EntityAI itemTop;
        EntityAI itemEnt;
        EntityAI itemIn;
    int rndQnt;
        ItemBase itemBs;
        float rand;
       
        itemTop = player.FindAttachmentBySlotName("Body");
       
        if ( itemTop )
        {
            itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
            if ( Class.CastTo(itemBs, itemEnt ) )
                itemBs.SetQuantity(4);

           
            itemEnt = player.GetInventory().CreateInInventory("AliceBag_Camo");
            SetRandomHealth(itemEnt);   
           
            itemEnt = itemTop.GetInventory().CreateInInventory("RoadFlare");
            SetRandomHealth(itemEnt);
           
    itemEnt = player.GetInventory().CreateInInventory("Mag_IJ70_8Rnd");
    itemEnt = player.GetInventory().CreateInInventory("Mag_IJ70_8Rnd");
    //SetRandomHealth(itemEnt);

    itemEnt = player.GetInventory().CreateInInventory("HuntingKnife");
    //SetRandomHealth(itemEnt);

    itemEnt = player.GetInventory().CreateInInventory("MakarovIJ70");
    //SetRandomHealth(itemEnt);
    player.SetQuickBarEntityShortcut(itemEnt, 2);

    itemIn = itemEnt.GetInventory().CreateAttachment("PistolSuppressor");
    //SetRandomHealth(itemIn);

    itemEnt = player.GetInventory().CreateInInventory("AKM");
    //SetRandomHealth(itemEnt);
    player.SetQuickBarEntityShortcut(itemEnt, 0);
   
    itemEnt.GetInventory().CreateAttachment("AK_WoodBttstck");
    itemEnt.GetInventory().CreateAttachment("AK_WoodHndgrd");
   
        itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
       
            itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
                        itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
                        itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
                        itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
                        itemEnt = player.GetInventory().CreateInInventory("Mag_AKM_30Rnd");
                        itemEnt = player.GetInventory().CreateInInventory("EngineOil");
                            itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
                                itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
                                    itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
                                        itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
                                            itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
                                           
                                            EntityAI myVeh = EntityAI.Cast(GetGame().CreateObject("OffroadHatchback", player.GetPosition(), false, true));
        myVeh.GetInventory().CreateAttachment("HatchbackWheel");
        myVeh.GetInventory().CreateAttachment("HatchbackWheel");
        myVeh.GetInventory().CreateAttachment("HatchbackWheel");
        myVeh.GetInventory().CreateAttachment("HatchbackWheel");
        myVeh.GetInventory().CreateAttachment("HatchbackWheel");
        myVeh.GetInventory().CreateAttachment("HatchbackDoors_Driver");
        myVeh.GetInventory().CreateAttachment("HatchbackDoors_CoDriver");
        myVeh.GetInventory().CreateAttachment("HatchbackHood");
        myVeh.GetInventory().CreateAttachment("SparkPlug");
        myVeh.GetInventory().CreateAttachment("EngineBelt");
        myVeh.GetInventory().CreateAttachment("CarRadiator");
        myVeh.GetInventory().CreateAttachment("CarBattery");
        myVeh.GetInventory().CreateAttachment("HeadlightH7");
        myVeh.GetInventory().CreateAttachment("CanisterGasoline");
        myVeh.GetInventory().CreateInInventory("CanisterGasoline");
        myVeh.GetInventory().CreateInInventory("EngineOil");
                myVeh.GetInventory().CreateInInventory("EngineOil");
                        myVeh.GetInventory().CreateInInventory("EngineOil");
                                myVeh.GetInventory().CreateInInventory("EngineOil");
                                myVeh.GetInventory().CreateInInventory("Trumpet");
                                myVeh.GetInventory().CreateInInventory("HuntingOptic");
                                myVeh.GetInventory().CreateInInventory("ammo_22");
                                myVeh.GetInventory().CreateInInventory("ammo_22");
                                                                myVeh.GetInventory().CreateInInventory("ammo_22");
                                                    myVeh.GetInventory().CreateInInventory("ammo_22");
                                                            myVeh.GetInventory().CreateInInventory("ammo_22");
                                                        myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");
myVeh.GetInventory().CreateInInventory("WaterBottle");                                                       
                               
        itemEnt = player.GetInventory().CreateInInventory("CanisterGasoline");
        itemEnt = player.GetInventory().CreateInInventory("EngineOil");       
                itemEnt = player.GetInventory().CreateInInventory("EngineOil");   
                        itemEnt = player.GetInventory().CreateInInventory("EngineOil");   
                                itemEnt = player.GetInventory().CreateInInventory("EngineOil");   
       
        }

        rand = Math.RandomFloatInclusive(0.0, 1.0);
        if ( rand < 0.25 )
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Cola");
        else if ( rand > 0.75 )
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Spite");
        else
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
       
        SetRandomHealth(itemEnt);

        rand = Math.RandomFloatInclusive(0.0, 1.0);
        if ( rand < 0.35 )
            itemEnt = player.GetInventory().CreateInInventory("Apple");
        else if ( rand > 0.65 )
            itemEnt = player.GetInventory().CreateInInventory("Pear");
        else
            itemEnt = player.GetInventory().CreateInInventory("Plum");
       
        SetRandomHealth(itemEnt);
    }
};
 
Mission CreateCustomMission(string path)
{
    return new CustomMission();
}