[AI] Stalker

DMS BANDIT MISSION NEW - ( Sorry - broken crate - do not use - will update when able )

19 posts in this topic

4 hours ago, [AI] Stalker said:

//_msgStart = ['#FFFF00',format["A %1 research camp has been spotted, find out what they are up to",_difficulty]];
_msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];

this seems a little odd (calling multiple messages), also I would do the random mission level select above any AI or static guns to make sure difficulties are set up before trying to call anything.

Share this post


Link to post
Share on other sites
45 minutes ago, red_ned said:

this seems a little odd (calling multiple messages), also I would do the random mission level select above any AI or static guns to make sure difficulties are set up before trying to call anything.


Setting up a template - that allows for variations on mission difficulty to be reflected in the flavor text.
IE:  Hardcore the loot includes say a 50cal static . Flavor text reflects this.
However , at easy .. the loot does not. And flavor text can reflect this.

 

47 minutes ago, red_ned said:

also I would do the random mission level select above any AI or static guns to make sure difficulties are set up before trying to call anything.

Yea.. this is an old version and that is exactly why the loot is not spawning. Putting up a fix later today ( In a rush atm )

Share this post


Link to post
Share on other sites
Advertisement
7 hours ago, [AI] Stalker said:

//_msgStart = ['#FFFF00',format["A %1 research camp has been spotted, find out what they are up to",_difficulty]];
_msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];

if (_difficulty isEqualTo "easy") then
{
    _pinCode = (1000 +(round (random 8999)));
            _vehicle = ["B_G_Offroad_01_armed_F",[(_pos select 0) +30, (_pos select 1) -0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
        _msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];
        _msgWIN = ['#0080ff',format ["AINC compound secured.Vehicle Code secured.Code is %1...",_pinCode]];

};

no sorry you misunderstand, see above you have 2 messages outside (1 commented out) and then you have one in each difficulty, plus the difficulty one is not formed correctly:

_msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];

should be

_msgStart = ['#FFFF00',format["AINC Security have set up a %1 re-supply compound. Raid them before they complete operations",_difficulty]];

the %1 is the placeholder for the first variable after the text, in this case _difficulty

I think the win message may also be badly formed (or not in English).

 

I do kind of like your new way of loading crates but its a little long winded for me but the original template I wrote can always be updated if people want to, I found that it was actually pretty difficult to make it readable after I had it working. Keep going its going well so far and I like the different ideas

 

Share this post


Link to post
Share on other sites

Ok doing a quick fix - should spawn loot in crate - but ..... i think there is still an issue -
Sorry using tablet for quick reference while at pool with my little girl - havent tested.

MISSION SQF

Spoiler

/*
    COMPOUND mission created by AINC_STALKER with credit to AINC_Trades.
    Extended Crate Array and Crate Lists added to difficulty levels.
    Allows more customisation of crate contents based on difficulty
    SPECIAL 1 and SPECIAL 2 are generally used for high value items.
    IE: If this was a building supply mission i would add metal to 1 and concrete to the 2nd.
    Easy/mod/difficult/hardcore based on work by [CiC]red_ned http://cic-gaming.co.uk
    Overall template based on work by Defent and eraser1
*/

private ["_num", "_side", "_pos", "_OK", "_difficulty", "_AICount", "_group", "_type", "_launcher", "_staticGuns", "_crate1", "_vehicle", "_pinCode", "_class", "_veh", "_crate_loot_values1", "_missionAIUnits", "_missionObjs", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added", "_cleanup", "_baseObjs", "_crate_weapons", "_crate_weapon_list", "_crate_items", "_crate_item_list", "_crate_backpacks", "_PossibleDifficulty"];

// For logging purposes
_num = DMS_MissionCount;


// Set mission side (only "bandit" is supported for now)
_side = "bandit";


// This part is unnecessary, but exists just as an example to format the parameters for "DMS_fnc_MissionParams" if you want to explicitly define the calling parameters for DMS_fnc_FindSafePos.
// It also allows anybody to modify the default calling parameters easily.
if ((isNil "_this") || {_this isEqualTo [] || {!(_this isEqualType [])}}) then
{
    _this =
    [
        [10,DMS_WaterNearBlacklist,DMS_MinSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist,DMS_ThrottleBlacklists],
        [
            []
        ],
        _this
    ];
};

// Check calling parameters for manually defined mission position.
// You can define "_extraParams" to specify the vehicle classname to spawn, either as _vehClass or [_vehClass]
_OK = (_this call DMS_fnc_MissionParams) params
[
    ["_pos",[],[[]],[3],[],[],[]],
    ["_extraParams",[]]
];

if !(_OK) exitWith
{
    diag_log format ["DMS ERROR :: Called MISSION nedresearch_mission.sqf with invalid parameters: %1",_this];
};


//create possible difficulty add more of one difficulty to weight it towards that
_PossibleDifficulty        =     [
                                "easy",
                                "easy",
                                "moderate",
                                "moderate",
                                "difficult",
                                "difficult",                            
                                "hardcore"
                            ];
//choose difficulty and set value
_difficulty = selectRandom _PossibleDifficulty;

 

switch (_difficulty) do
{
    case "easy":
    {
        _AICount = (20 + (round (random 5)));
        _crate_weapons                 = (10 + (round     (random 1)));
        _crate_weapons_scopes       = (10 + (round    (random    1)));
        _crate_weapons_suppressors  = (10 + (round    (random    1)));
        _crate_weapons_bipods       = (10 + (round    (random    1)));
        _crate_items                 = (10 + (round     (random 1)));
        _crate_meds                 = (10 + (round    (random    1)));
        _crate_uniforms             = (10 +    (round     (random 1)));
        _crate_vests                = (10 +    (round     (random 1)));
        _crate_backpacks            = (10 +    (round     (random 1)));
        _crate_helmets              = (10 + (round    (random    1)));
        _crate_nvgs                    = (10 + (round    (random    1)));
        _crate_rangefinders            = (10 + (round    (random    1)));
    
    };
    

    case "moderate":
    {
        _AICount = (25 + (round (random 5)));
        _crate_weapons                 = (15 + (round     (random 1)));
        _crate_weapons_scopes       = (15 + (round    (random    1)));
        _crate_weapons_suppressors  = (15 + (round    (random    1)));
        _crate_weapons_bipods       = (15 + (round    (random    1)));
        _crate_items                 = (15 + (round     (random 1)));
        _crate_meds                 = (15 + (round    (random    1)));
        _crate_uniforms             = (15 +    (round     (random 1)));
        _crate_vests                = (15 +    (round     (random 1)));
        _crate_backpacks            = (15 +    (round     (random 1)));
        _crate_helmets              = (15 + (round    (random    1)));
        _crate_nvgs                    = (15 + (round    (random    1)));
        _crate_rangefinders            = (15 + (round    (random    1)));
        _crate_explosives            = (15 + (round     (random 1)));    
        
    };

    case "difficult":
    {
        _AICount = (30 + (round (random 5)));
        _crate_weapons                 = (20 + (round     (random 1)));
        _crate_weapons_scopes       = (20 + (round    (random    1)));
        _crate_weapons_suppressors  = (20 + (round    (random    1)));
        _crate_weapons_bipods       = (20 + (round    (random    1)));
        _crate_items                 = (20 + (round     (random 1)));
        _crate_meds                 = (20 + (round    (random    1)));
        _crate_uniforms             = (20 +    (round     (random 1)));
        _crate_vests                = (20 +    (round     (random 1)));
        _crate_backpacks            = (20 +    (round     (random 1)));
        _crate_helmets              = (20 + (round    (random    1)));
        _crate_nvgs                    = (20 + (round    (random    1)));
        _crate_rangefinders            = (20 + (round    (random    1)));
        _crate_explosives            = (20 + (round     (random 1)));        
        _crate_breachingcharges     = (12 + (round     (random 1)));
        
    };
    
    case "hardcore":
    
    {
        _AICount = (35 + (round (random 5)));
        _crate_weapons                 = (25 + (round     (random 1)));
        _crate_weapons_scopes       = (25 + (round    (random    1)));
        _crate_weapons_suppressors  = (25 + (round    (random    1)));
        _crate_weapons_bipods       = (25 + (round    (random    1)));
        _crate_items                 = (25 + (round     (random 1)));
        _crate_meds                 = (25 + (round    (random    1)));
        _crate_uniforms             = (25 +    (round     (random 1)));
        _crate_vests                = (25 +    (round     (random 1)));
        _crate_backpacks            = (25 +    (round     (random 1)));
        _crate_helmets              = (25 + (round    (random    1)));
        _crate_nvgs                    = (25 + (round    (random    1)));
        _crate_rangefinders            = (25 + (round    (random    1)));
        _crate_explosives            = (25 + (round     (random 1)));        
        _crate_breachingcharges     = (12 + (round     (random 1)));
        _crate_MISSIONSPECIAL1         = (6 + (round    (random    1)));
        _crate_MISSIONSPECIAL2         = (3 + (round    (random    1)));

    };
};

_group =
[
    [[(_pos select 0)+2,(_pos select 1)+4,0],[(_pos select 0)-10,(_pos select 1)+0,0]],                    // Position AI in tent + 2nd squad
    _AICount,                // Number of AI
    _difficulty,            // "random","hardcore","difficult","moderate", or "easy"
    "random",                 // "random","assault","MG","sniper" or "unarmed" OR [_type,_launcher]
    _side                     // "bandit","hero", etc.
] call DMS_fnc_SpawnAIGroup_MultiPos;

// Create Buildings - use seperate file as found in the mercbase mission
_baseObjs =
[
    "STALKER_AINC_objects",
    _pos
] call DMS_fnc_ImportFromM3E_3DEN;

// add static guns
_staticGuns =
[
    [
        // make statically positioned relative to centre point, keep static as they are on top of building
        [(_pos select 0) -10,(_pos select 1) +10,0],
        [(_pos select 0) -10,(_pos select 1) -10,0],
        [(_pos select 0) +2,(_pos select 1) +18,+13],
        [(_pos select 0) +2,(_pos select 1) -16,+13],
        [(_pos select 0) -25,(_pos select 1) +15,+14],
        [(_pos select 0) -43,(_pos select 1) +18,+13],
        [(_pos select 0) -43,(_pos select 1) -16,+13]
    ],
    _group,
    "assault",
    "static",
    "bandit"
] call DMS_fnc_SpawnAIStaticMG;


//_msgStart = ['#FFFF00',format["A %1 research camp has been spotted, find out what they are up to",_difficulty]];
_msgStart = ['#FFFF00',format["AINC Security have set up a %1 re-supply compound. Raid them before they complete operations",_difficulty]];

        _crate_weapons_list                 =     ["arifle_MXC_F","arifle_MX_F","arifle_MX_GL_F","arifle_MXM_F","arifle_MXM_Black_F","arifle_MXC_Black_F","arifle_MX_Black_F","arifle_MX_GL_Black_F","arifle_SPAR_01_blk_F","arifle_SPAR_01_GL_blk_F","arifle_SPAR_02_blk_F","arifle_SPAR_03_blk_F","arifle_MX_SW_Black_F","LMG_Zafir_F","srifle_EBR_F","srifle_DMR_01_F","srifle_DMR_03_woodland_F"];    
        _crate_weapons_scopes_list          =    ["optic_MRCO","optic_DMS","optic_DMS_ghex_F","optic_ERCO_blk_F","optic_ERCO_khk_F","optic_ERCO_snd_F","optic_Arco","optic_Arco_blk_F","optic_Arco_ghex_F"];
        _crate_weapons_suppressors_list     =    ["muzzle_snds_H"];
        _crate_weapons_bipods_list          =    ["bipod_03_F_blk"];
        _crate_items_list                     =    ["Exile_Item_EMRE","Exile_Item_InstantCoffee"];
        _crate_meds_list                     =    ["Exile_Item_InstaDoc","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_InstaDoc","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin"];
        _crate_uniforms_list                 =    ["U_B_GEN_Commander_F","U_B_GEN_Soldier_F"];
        _crate_vests_list                    =    ["V_PlateCarrierGL_blk","V_PlateCarrierSpec_blk","V_PlateCarrier2_blk","V_PlateCarrierH_CTRG","V_PlateCarrierL_CTR","V_TacVestIR_bl","V_TacVestIR_blk","V_TacVestIR_blk"];
        _crate_backpacks_list                =    ["B_ViperLightHarness_blk_F","B_Carryall_oucamo","B_AssaultPack_blk"];
        _crate_helmets_list                  =    ["H_Beret_Colonel","H_MilCap_gen_F"];
        _crate_nvgs_list                    =    ["NVGoggles_OPFOR"];
        _crate_rangefinders_list            =    ["Rangefinder"];
        _crate_explosives_list                =    ["TMine_Range_Mag","APERSMine_Range_Mag","APERSBoundingMine_Range_Mag","SLAMDirectionalMine_Wire_Mag","APERSTripMine_Wire_Mag","ClaymoreDirectionalMine_Remote_Mag"];
        _crate_breachingcharges_list        =    ["BreachingChargeWood"];
        _crate_MISSIONSPECIAL1_list         =    ["BreachingChargeMetal"];
        _crate_MISSIONSPECIAL2_list             =    ["BreachingChargeBigMomma"];


if (_difficulty isEqualTo "easy") then
{
    _pinCode = (1000 +(round (random 8999)));
            _vehicle = ["B_G_Offroad_01_armed_F",[(_pos select 0) +30, (_pos select 1) -0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
        _msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];
        _msgWIN = ['#0080ff',format ["AINC compound secured.Vehicle Code secured.Code is %1...",_pinCode]];

};
    
if (_difficulty isEqualTo "moderate") then
{
    _pinCode = (1000 +(round (random 8999)));
        _vehicle = ["B_LSV_01_armed_olive_F",[(_pos select 0) +30, (_pos select 1) -0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
        _msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];
        _msgWIN = ['#0080ff',format ["AINC compound secured.Vehicle Code secured.Code is %1...",_pinCode]];

};
    
if (_difficulty isEqualTo "difficult") then
{
    _pinCode = (1000 +(round (random 8999)));
        _vehicle = ["I_MRAP_03_hmg_F",[(_pos select 0) +30, (_pos select 1) -0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
        _msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];
        _msgWIN = ['#0080ff',format ["AINC compound secured.Vehicle Code secured.Code is %1...",_pinCode]];

};
    
if (_difficulty isEqualTo "hardcore") then
{
    _pinCode = (1000 +(round (random 8999)));
        _vehicle = ["B_APC_Tracked_01_CRV_F",[(_pos select 0) +30, (_pos select 1) -0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
        _msgStart = ['#FFFF00',"AINC Security have set up a _difficulty re-supply compound. Raid them before they complete operations"];
        _msgWIN = ['#0080ff',format ["AINC compound secured.Vehicle Code secured.Code is %1...",_pinCode]];

};

// Create Crate type
_crate1 = ["Box_NATO_Wps_F",_pos] call DMS_fnc_SpawnCrate;


// setup crate iteself with items
_crate_loot_values1 =
[
    [_crate_weapons,_crate_weapons_list],
    [_crate_weapons_scopes,_crate_weapons_scopes_list],
    [_crate_weapons_suppressors,_crate_weapons_suppressors_list],
    [_crate_weapons_bipods,_crate_weapons_bipods_list],
    [_crate_items,_crate_items_list],
    [_crate_meds,_crate_meds_list],
    [_crate_uniforms,_crate_uniforms_list],
    [_crate_vests,_crate_vests_list],
    [_crate_backpacks,_crate_backpacks_list],
    [_crate_helmets,_crate_helmets_list],
    [_crate_nvgs,_crate_nvgs_list],
    [_crate_rangefinders,_crate_rangefinders_list],
    [_crate_explosives,_crate_explosives_list],
    [_crate_breachingcharges,_crate_breachingcharges_list],
    [_crate_MISSIONSPECIAL1,_crate_MISSIONSPECIAL1_list],
    [_crate_MISSIONSPECIAL2,_crate_MISSIONSPECIAL2_list]
    
];

// Define mission-spawned AI Units
_missionAIUnits =
[
    _group         // We only spawned the single group for this mission
];

// Define mission-spawned objects and loot values
_missionObjs =
[
    _staticGuns+_baseObjs+[_veh],            // armed AI vehicle, base objects, and static guns
    [_vehicle],                            //this is prize vehicle
    [[_crate1,_crate_loot_values1]]            //this is prize crate
];

// define start messages in difficulty choice

// Define Mission Win message defined in persistent choice

// Define Mission Lose message
_msgLOSE = ['#FF0000',"AINC security forces have secured the Compound"];

// Define mission name (for map marker and logging)
_missionName = "AINC COMPOUND";

// Create Markers
_markers =
[
    _pos,
    _missionName,
    _difficulty
] call DMS_fnc_CreateMarker;

// Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
_time = diag_tickTime;

// Parse and add mission info to missions monitor
_added =
[
    _pos,
    [
        [
            "kill",
            _group
        ],
        [
            "playerNear",
            [_pos,DMS_playerNearRadius]
        ]
    ],
    [
        _time,
        (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0))
    ],
    _missionAIUnits,
    _missionObjs,
    [_missionName,_msgWIN,_msgLOSE],
    _markers,
    _side,
    _difficulty,
    []
] call DMS_fnc_AddMissionToMonitor;

// Check to see if it was added correctly, otherwise delete the stuff
if !(_added) exitWith
{
    diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName];

    // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly)
    _cleanup = [];
    {
        _cleanup pushBack _x;
    } forEach _missionAIUnits;

    _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));

    {
        _cleanup pushBack (_x select 0);
    } foreach (_missionObjs select 2);

    _cleanup call DMS_fnc_CleanUp;


    // Delete the markers directly
    {deleteMarker _x;} forEach _markers;


    // Reset the mission count
    DMS_MissionCount = DMS_MissionCount - 1;
};


// Notify players
[_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;

 

if (DMS_DEBUG) then
{
    (format ["MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]) call DMS_fnc_DebugLog;
};

 

Known issue - only Weapons spawning (Ammo spawns 3 clips/belts per weapon automatically).
Cant seem to find the issue that is limiting it to just weapon spawn.
Log only seems to indicate  - Line 249 as a undefined array. Not sure what.
 

Spoiler

    [_crate_weapons_scopes,_crate_weapons_scopes_list],

 

 

Share this post


Link to post
Share on other sites
8 hours ago, [AI] Stalker said:

[_crate_weapons_scopes,_crate_weapons_scopes_list],

I think needs to be

[[_crate_weapons_scopes,_crate_weapons_scopes_list]],

to show the list is an array

Edited by red_ned

Share this post


Link to post
Share on other sites

I think i found my loot problem.

Turns out i did not have multiple array;s working , inaccurate reports from testers.

Currently the only way i can get loot to spawn is with the following default listing of

 

Spoiler


//Crate Loot used by all.
        _crate_weapons_list                 =     ["arifle_MXC_F","arifle_MX_F","arifle_MX_GL_F","arifle_MXM_F","arifle_MXM_Black_F","arifle_MXC_Black_F","arifle_MX_Black_F","arifle_MX_GL_Black_F","arifle_SPAR_01_blk_F","arifle_SPAR_01_GL_blk_F","arifle_SPAR_02_blk_F","arifle_SPAR_03_blk_F","arifle_MX_SW_Black_F","LMG_Zafir_F","srifle_EBR_F","srifle_DMR_01_F","srifle_DMR_03_woodland_F"];    
        _crate_weaponsscopes_list              =    ["optic_MRCO","optic_DMS","optic_DMS_ghex_F","optic_ERCO_blk_F","optic_ERCO_khk_F","optic_ERCO_snd_F","optic_Arco","optic_Arco_blk_F","optic_Arco_ghex_F"];
        _crate_weaponssuppressors_list         =    ["muzzle_snds_H"];
        _crate_weaponsbipods_list              =    ["bipod_03_F_blk"];
        _crate_items_list                     =    ["Exile_Item_EMRE","Exile_Item_InstantCoffee"];
        _crate_meds_list                     =    ["Exile_Item_InstaDoc","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_InstaDoc","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin","Exile_Item_Bandage","Exile_Item_Vishpirin"];
        _crate_uniforms_list                 =    ["U_B_GEN_Commander_F","U_B_GEN_Soldier_F"];
        _crate_vests_list                    =    ["V_PlateCarrierGL_blk","V_PlateCarrierSpec_blk","V_PlateCarrier2_blk","V_PlateCarrierH_CTRG","V_PlateCarrierL_CTR","V_TacVestIR_bl","V_TacVestIR_blk","V_TacVestIR_blk"];
        _crate_backpacks_list                =    ["B_ViperLightHarness_blk_F","B_Carryall_oucamo","B_AssaultPack_blk"];
        _crate_helmets_list                  =    ["H_Beret_Colonel","H_MilCap_gen_F"];
        _crate_nvgs_list                    =    ["NVGoggles_OPFOR"];
        _crate_rangefinders_list            =    ["Rangefinder"];
        _crate_explosives_list                =    ["TMine_Range_Mag","APERSMine_Range_Mag","APERSBoundingMine_Range_Mag","SLAMDirectionalMine_Wire_Mag","APERSTripMine_Wire_Mag","ClaymoreDirectionalMine_Remote_Mag"];
        _crate_breachingcharges_list        =    ["BreachingChargeWood"];
        _crate_MISSIONSPECIAL1_list         =    ["BreachingChargeMetal"];
        _crate_MISSIONSPECIAL2_list             =    ["BreachingChargeBigMomma"];

 


In this list , only the WEAPONS , ITEMS and BACKPACKS spawn their lists.
All other List entries do not spawn in the crate.

Further testing shows that changing WEAPONS (1st entry) , ITEMS (2nd entry) or BACKPACKS(3rd entry) from their positions in that list stops those lists from spawning as well.

I am under the impression that the following function under scripts.
 

Spoiler

/*
    DMS_fnc_FillCrate

    Inspired by WAI: https://github.com/nerdalertdk/WICKED-AI
    created by eraser1

    Usage:
    [
        _crate,                        // OBJECT: The crate object
        _lootValues,                // ARRAY, STRING, or NUMBER: String or number refers to a crate case in config.cfg; array determines random crate weapons/items/backpacks
        _rareLootChance                // (OPTIONAL) NUMBER: Manually define the percentage chance of spawning some rare items.
    ] call DMS_fnc_FillCrate;

    If the "_lootValues" parameter is a number or a string, the function will look for a value defined as "DMS_CrateCase_*", where the "*" is replaced by the "_lootValues" parameter. EG: DMS_CrateCase_Sniper.

    Otherwise, the "_lootValues" parameter must be defined as:
        [
            _weapons,
            _items,
            _backpacks
        ]

    Each loot argument can be an explicitly defined array of weapons with a number to spawn, or simply a number and weapons defined in the config.sqf are used.
    For example, if you want to configure the list from which weapons, items, and backpacks are selected, it should be of the form:
    [
        [
            _number_of_weapons,
            [
                "wepClassname1",
                "wepClassname2",
                ...
                "wepClassnameN"
            ]
        ],
        [
            _number_of_items,
            [
                "itemClassname1",
                "itemClassname2",
                ...
                "itemClassnameN"
            ]
        ],
        [
            _number_of_backpacks,
            [
                "backpackClassname1",
                "backpackClassname2",
                ...
                "backpackClassnameN"
            ]
        ]
    ]

    For example, _weapons could simply be a number, in which case the given number of weapons are selected from "DMS_boxWeapons",
    or an array as [_wepCount,_weps], where _wepCount is the number of weapons, and _weps is an array of weapons from which the guns are randomly selected.

    OR:
        [
            _customLootFunctionParams,
            _customLootFunction
        ]
        In this case, "_customLootFunctionParams" is passed to "_customLootFunction", and the custom loot function must return the loot in the form:
        [
            [
                weapon1,
                weapon2,
                [weapon_that_appears_twice,2],
                ...
                weaponN
            ],
            [
                item1,
                item2,
                [item_that_appears_5_times,5],
                ...
                itemN
            ],
            [
                backpack1,
                backpack2,
                [backpack_that_appears_3_times,3],
                ...
                backpackN
            ]
        ]
*/

if (!(params
[
    "_crate",
    "_lootValues"
])
||
{isNull _crate})
exitWith
{
    diag_log format ["DMS ERROR :: Calling DMS_FillCrate with invalid parameters: %1",_this];
};

_crate hideObjectGlobal false;

if !(_crate getVariable ["DMS_CrateGodMode",DMS_GodmodeCrates]) then
{
    _crate allowDamage true;
};

_crate enableSimulationGlobal true;
if (_crate getVariable ["DMS_CrateEnableRope",DMS_EnableBoxMoving]) then
{
    _crate enableRopeAttach true;
};


if ((_lootValues isEqualType []) && {!((_lootValues select 1) isEqualType {})}) then
{
    // Weapons
    private _wepValues = _lootValues select 0;
    private _wepCount = 0;
    private _weps =
        if (_wepValues isEqualType []) then
        {
            _wepCount    = _wepValues select 0;
            _wepValues select 1
        }
        else
        {
            _wepCount    = _wepValues;
            DMS_boxWeapons
        };


    // Items
    private _itemValues = _lootValues select 1;
    private _itemCount = 0;
    private _items =
        if (_itemValues isEqualType []) then
        {
            _itemCount    = _itemValues select 0;
            _itemValues select 1
        }
        else
        {
            _itemCount    = _itemValues;
            DMS_boxItems
        };


    // Backpacks
    private _backpackValues = _lootValues select 2;
    private _backpackCount = 0;
    private _backpacks =
        if ((_backpackValues) isEqualType []) then
        {
            _backpackCount    = _backpackValues select 0;
            _backpackValues select 1
        }
        else
        {
            _backpackCount = _backpackValues;
            DMS_boxBackpacks
        };

    if (DMS_DEBUG) then
    {
        (format["FillCrate :: Filling %4 with %1 guns, %2 items and %3 backpacks",_wepCount,_itemCount,_backpackCount,_crate]) call DMS_fnc_DebugLog;
    };


    if (count _weps>0) then
    {
        // Add weapons + mags
        for "_i" from 1 to _wepCount do
        {
            private _weapon = selectRandom _weps;
            private _ammo = _weapon call DMS_fnc_selectMagazine;
            if (_weapon isEqualType "") then
            {
                _weapon = [_weapon,1];
            };
            _crate addWeaponCargoGlobal _weapon;
            if !(_ammo in ["Exile_Magazine_Swing","Exile_Magazine_Boing","Exile_Magazine_Swoosh"]) then
            {
                _crate addItemCargoGlobal [_ammo, (DMS_MinimumMagCount + floor(random DMS_MagRange))];
            };
        };
    };


    if (count _items>0) then
    {
        // Add items
        for "_i" from 1 to _itemCount do
        {
            private _item = selectRandom _items;
            if (_item isEqualType "") then
            {
                _item = [_item,1];
            };
            _crate addItemCargoGlobal _item;
        };
    };


    if (count _backpacks>0) then
    {
        // Add backpacks
        for "_i" from 1 to _backpackCount do
        {
            private _backpack = selectRandom _backpacks;
            if (_backpack isEqualType "") then
            {
                _backpack = [_backpack,1];
            };
            _crate addBackpackCargoGlobal _backpack;
        };
    };
}
else
{
    private _crateValues =
        if (_lootValues isEqualType []) then
        {
            (_lootValues select 0) call (_lootValues select 1)
        }
        else
        {
            missionNamespace getVariable (format ["DMS_CrateCase_%1",_lootValues])
        };

    if !((_crateValues params
    [
        "_weps",
        "_items",
        "_backpacks"
    ]))
    exitWith
    {
        diag_log format ["DMS ERROR :: Invalid ""_crateValues"" (%1) generated from _lootValues: %2",_crateValues,_lootValues];
    };

    // Weapons
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addWeaponCargoGlobal _x;
    } forEach _weps;

    // Items/Mags
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addItemCargoGlobal _x;
    } forEach _items;

    // Backpacks
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addBackpackCargoGlobal _x;
    } forEach _backpacks;

    if (DMS_DEBUG) then
    {
        (format["FillCrate :: Filled crate %1 (at %5) with weapons |%2|, items |%3|, and backpacks |%4|",_crate, _weps, _items, _backpacks, getPosATL _crate]) call DMS_fnc_DebugLog;
    };
};


if (DMS_RareLoot) then
{
    private _rareLootChance =
        if ((count _this)>2) then
        {
            _this param [2,DMS_RareLootChance,[0]]
        }
        else
        {
            DMS_RareLootChance
        };

    // (Maybe) Add rare loot
    if(random 100 < _rareLootChance) then
    {
        for "_i" from 1 to DMS_RareLootAmount do
        {
            _item = selectRandom DMS_RareLootList;
            if (_item isEqualType "") then
            {
                _item = [_item,1];
            };
            _crate addItemCargoGlobal _item;
        };
    };
};

// You can choose if you want to enable/disable smoke individually using setVariable.
if (_crate getVariable ["DMS_AllowSmoke", true]) then
{
    if (DMS_SpawnBoxSmoke && {sunOrMoon == 1}) then
    {
        private _marker = "SmokeShellPurple" createVehicle getPosATL _crate;
        _marker setPosATL (getPosATL _crate);
        _marker attachTo [_crate,[0,0,0]];
    };

    if (DMS_SpawnBoxIRGrenade && {sunOrMoon != 1}) then
    {
        private _marker = "B_IRStrobe" createVehicle getPosATL _crate;
        _marker setPosATL (getPosATL _crate);
        _marker attachTo [_crate, [0,0,0.5]];
    };
};

 

Needs to have references to the other LISTS i have created for them to function.

Can i get any confirmation of this ?

@eraser1

Share this post


Link to post
Share on other sites

@[AI] Stalker DMS only supports Weapons, Items, and Backpacks as the default loot values parameters, as indicated in the function header.

You may also pass your own function and parameter(s) to the fillcrate function, and it will simply call the passed function with the passed parameters.

 

It's all in the documentation.

  • Like 1

Share this post


Link to post
Share on other sites

@eraser1 , thank you.

I have no doubt that all your functions are easily labeled and explained.

However , i am sadly lacking in basic deductive reasoning when it comes to reading your scripts.
Taken me a while to follow what i know are basic instructions.

I have a question for a basic example so i can follow thru with the rest of the variants i would like to add.
In the sqf  below
 

Spoiler

/*
    DMS_fnc_FillCrate

    Inspired by WAI: https://github.com/nerdalertdk/WICKED-AI
    created by eraser1

    Usage:
    [
        _crate,                        // OBJECT: The crate object
        _lootValues,                // ARRAY, STRING, or NUMBER: String or number refers to a crate case in config.cfg; array determines random crate weapons/items/backpacks
        _rareLootChance                // (OPTIONAL) NUMBER: Manually define the percentage chance of spawning some rare items.
    ] call DMS_fnc_FillCrate;

    If the "_lootValues" parameter is a number or a string, the function will look for a value defined as "DMS_CrateCase_*", where the "*" is replaced by the "_lootValues" parameter. EG: DMS_CrateCase_Sniper.

    Otherwise, the "_lootValues" parameter must be defined as:
        [
            _weapons,
            _items,
            _backpacks
        ]

    Each loot argument can be an explicitly defined array of weapons with a number to spawn, or simply a number and weapons defined in the config.sqf are used.
    For example, if you want to configure the list from which weapons, items, and backpacks are selected, it should be of the form:
    [
        [
            _number_of_weapons,
            [
                "wepClassname1",
                "wepClassname2",
                ...
                "wepClassnameN"
            ]
        ],
        [
            _number_of_items,
            [
                "itemClassname1",
                "itemClassname2",
                ...
                "itemClassnameN"
            ]
        ],
        [
            _number_of_backpacks,
            [
                "backpackClassname1",
                "backpackClassname2",
                ...
                "backpackClassnameN"
            ]
        ]
    ]

    For example, _weapons could simply be a number, in which case the given number of weapons are selected from "DMS_boxWeapons",
    or an array as [_wepCount,_weps], where _wepCount is the number of weapons, and _weps is an array of weapons from which the guns are randomly selected.

    OR:
        [
            _customLootFunctionParams,
            _customLootFunction
        ]
        In this case, "_customLootFunctionParams" is passed to "_customLootFunction", and the custom loot function must return the loot in the form:
        [
            [
                weapon1,
                weapon2,
                [weapon_that_appears_twice,2],
                ...
                weaponN
            ],
            [
                item1,
                item2,
                [item_that_appears_5_times,5],
                ...
                itemN
            ],
            [
                backpack1,
                backpack2,
                [backpack_that_appears_3_times,3],
                ...
                backpackN
            ]
        ]
*/

if (!(params
[
    "_crate",
    "_lootValues"
])
||
{isNull _crate})
exitWith
{
    diag_log format ["DMS ERROR :: Calling DMS_FillCrate with invalid parameters: %1",_this];
};

_crate hideObjectGlobal false;

if !(_crate getVariable ["DMS_CrateGodMode",DMS_GodmodeCrates]) then
{
    _crate allowDamage true;
};

_crate enableSimulationGlobal true;
if (_crate getVariable ["DMS_CrateEnableRope",DMS_EnableBoxMoving]) then
{
    _crate enableRopeAttach true;
};


if ((_lootValues isEqualType []) && {!((_lootValues select 1) isEqualType {})}) then
{
    // Weapons
    private _wepValues = _lootValues select 0;
    private _wepCount = 0;
    private _weps =
        if (_wepValues isEqualType []) then
        {
            _wepCount    = _wepValues select 0;
            _wepValues select 1
        }
        else
        {
            _wepCount    = _wepValues;
            DMS_boxWeapons
        };


    // Items
    private _itemValues = _lootValues select 1;
    private _itemCount = 0;
    private _items =
        if (_itemValues isEqualType []) then
        {
            _itemCount    = _itemValues select 0;
            _itemValues select 1
        }
        else
        {
            _itemCount    = _itemValues;
            DMS_boxItems
        };


    // Backpacks
    private _backpackValues = _lootValues select 2;
    private _backpackCount = 0;
    private _backpacks =
        if ((_backpackValues) isEqualType []) then
        {
            _backpackCount    = _backpackValues select 0;
            _backpackValues select 1
        }
        else
        {
            _backpackCount = _backpackValues;
            DMS_boxBackpacks
        };

    if (DMS_DEBUG) then
    {
        (format["FillCrate :: Filling %4 with %1 guns, %2 items and %3 backpacks",_wepCount,_itemCount,_backpackCount,_crate]) call DMS_fnc_DebugLog;
    };


    if (count _weps>0) then
    {
        // Add weapons + mags
        for "_i" from 1 to _wepCount do
        {
            private _weapon = selectRandom _weps;
            private _ammo = _weapon call DMS_fnc_selectMagazine;
            if (_weapon isEqualType "") then
            {
                _weapon = [_weapon,1];
            };
            _crate addWeaponCargoGlobal _weapon;
            if !(_ammo in ["Exile_Magazine_Swing","Exile_Magazine_Boing","Exile_Magazine_Swoosh"]) then
            {
                _crate addItemCargoGlobal [_ammo, (DMS_MinimumMagCount + floor(random DMS_MagRange))];
            };
        };
    };


    if (count _items>0) then
    {
        // Add items
        for "_i" from 1 to _itemCount do
        {
            private _item = selectRandom _items;
            if (_item isEqualType "") then
            {
                _item = [_item,1];
            };
            _crate addItemCargoGlobal _item;
        };
    };


    if (count _backpacks>0) then
    {
        // Add backpacks
        for "_i" from 1 to _backpackCount do
        {
            private _backpack = selectRandom _backpacks;
            if (_backpack isEqualType "") then
            {
                _backpack = [_backpack,1];
            };
            _crate addBackpackCargoGlobal _backpack;
        };
    };
}
else
{
    private _crateValues =
        if (_lootValues isEqualType []) then
        {
            (_lootValues select 0) call (_lootValues select 1)
        }
        else
        {
            missionNamespace getVariable (format ["DMS_CrateCase_%1",_lootValues])
        };

    if !((_crateValues params
    [
        "_weps",
        "_items",
        "_backpacks"
    ]))
    exitWith
    {
        diag_log format ["DMS ERROR :: Invalid ""_crateValues"" (%1) generated from _lootValues: %2",_crateValues,_lootValues];
    };

    // Weapons
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addWeaponCargoGlobal _x;
    } forEach _weps;

    // Items/Mags
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addItemCargoGlobal _x;
    } forEach _items;

    // Backpacks
    {
        if (_x isEqualType "") then
        {
            _x = [_x,1];
        };
        _crate addBackpackCargoGlobal _x;
    } forEach _backpacks;

    if (DMS_DEBUG) then
    {
        (format["FillCrate :: Filled crate %1 (at %5) with weapons |%2|, items |%3|, and backpacks |%4|",_crate, _weps, _items, _backpacks, getPosATL _crate]) call DMS_fnc_DebugLog;
    };
};


if (DMS_RareLoot) then
{
    private _rareLootChance =
        if ((count _this)>2) then
        {
            _this param [2,DMS_RareLootChance,[0]]
        }
        else
        {
            DMS_RareLootChance
        };

    // (Maybe) Add rare loot
    if(random 100 < _rareLootChance) then
    {
        for "_i" from 1 to DMS_RareLootAmount do
        {
            _item = selectRandom DMS_RareLootList;
            if (_item isEqualType "") then
            {
                _item = [_item,1];
            };
            _crate addItemCargoGlobal _item;
        };
    };
};

// You can choose if you want to enable/disable smoke individually using setVariable.
if (_crate getVariable ["DMS_AllowSmoke", true]) then
{
    if (DMS_SpawnBoxSmoke && {sunOrMoon == 1}) then
    {
        private _marker = "SmokeShellPurple" createVehicle getPosATL _crate;
        _marker setPosATL (getPosATL _crate);
        _marker attachTo [_crate,[0,0,0]];
    };

    if (DMS_SpawnBoxIRGrenade && {sunOrMoon != 1}) then
    {
        private _marker = "B_IRStrobe" createVehicle getPosATL _crate;
        _marker setPosATL (getPosATL _crate);
        _marker attachTo [_crate, [0,0,0.5]];
    };
};

 


So if i want to add _crate_weapons_scopes   do i do the following?

Spoiler

if ((_lootValues isEqualType []) && {!((_lootValues select 1) isEqualType {})}) then

    // _crate_weapons_scopes
    private_weapons_scopesValues = _lootValues select 1;
    private _weapons_scopesCount = 0;
    private _items =
        if (_weapons_scopesValues isEqualType []) then
        {
           _weapons_scopesCount    = _weapons_scopesValues select 0;
           _weapons_scopesValues select 1
        }

}

 

if (count if (count _weapons_scopes>0) then
    {
        // Add items
        for "_i" from 1 to __weapons_scopesCount do
        {
            private_weapons_scopes = selectRandom _items;
            if (_weapons_scopes isEqualType "") then
            {
                _weapons_scopes = [_weapons_scopes,1];
            };
         
        };
 

am i doing this correctly?

I appreciate your time very much @eraser1 , please forgive my ignorance with this.
 

Share this post


Link to post
Share on other sites

@[AI] Stalker That is incorrect due to a variety of reasons. The "fn_FillCrate" function is designed so that no modifications are needed to the script itself, thanks to the option to pass code (and its parameters) directly to the function. All you have to do is create a function that will return a list with 3 sets of values:

Weapons, Items, and Backpacks.

So if you had a list that defined "_crate_weapons_scopes", and you wanted to add each scope from that list one by one, you would do:

private _weapons = [];
private _items = [];
private _backpacks = [];

{
	_items pushBack _x;
} forEach _crate_weapons_scopes;


[
	_weapons,
	_items,
	_backpacks
]

You define and initialize the list of weapons, items, and backpacks at the top. No weapons or backpacks are added in this example, so they remain empty lists when they get to the bottom.

Then the script simply cycles through "_crate_weapons_scopes" and adds each scope to the list of items.

Finally, at the bottom, the values are "returned" to whatever script/function that called the script in the example. In this case, you would simply return a list with:
"Weapons, Items, and Backpacks" in the form that DMS expects/requires.

 

The fillCrate function will then handle the rest.

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.