Jump to content

[Release] Mystery Briefcase


Rocu

Recommended Posts

Great idea.

 

ItemBriefcase_Base - is this the same classname used for Epoch currency when combining bars?

 

ItemBriefcase_Base is just a base item for all the other briefcases. It looks exactly the same as any other briefcase except it doesn't have any properties. It's literally an item without a function. As CordlAsis said empty briefcases and all the other ones have different class names.

 

 

Once again thanks for the kind words people.

Link to comment
Share on other sites

Okay so, the first little update was pushed. New files are now up on my GitHub page. Thanks f3cuk for the loot tables & ideas.

To update just replace config.sqf and open_brief.sqf.

 

Changes:

* Added more items and balanced things out more evenly

* 1 magazine now correctly displays "+1 magazine"

* group_wep from config can now also be used for tools

* When creating a group_wep in config you can add quantity 0 for items that have no magazines (ie. for tools and chainsaws)

* Fixed bug where it showed "+2 magazines" even if magazines weren't added

* Randomizer idea changed a little. You don't have to have a total sum of 100% in the rarity field (updated first post for better explanation.

Link to comment
Share on other sites

Hey Rocu,

I made some changes to the files myself. Added support for the ItemSilvercase_Base. I'll just post them here so you can have a look and see if there's anything usefull in it for you :)

 

Cheers,

 

f3cuk

 

/*
        Mystery Briefcase addon by Rocu
        Configuration file
*/

MBT_NAME = "EpochPacks"; //Name of the item that spawns the reward (this is just a visual thing, code won't break if you change this to something random)
MBT_CRATEDELAY = 900; //How long until the reward crate disappears (in seconds) Default: 900 (15 minutes)
MBT_DIALOG_TITLE = "EpochPack opening"; //Reward dialog title
MBT_DIALOG_CLAIM = "Claim Your Reward"; //Claim reward button
MBT_DIALOG_NOTE = "* After claiming your prize the reward crate will disappear in 15 minutes."; //Notation warning about the crate's delay

/*
        REWARD CONFIGURATION
        Everything that has to do with the prize you get from the briefcase
*/

// Junk
_junk_group = ["HandRoadFlare","TrashTinCan","FoodCanUnlabeled","HandChemBlue","HandChemRed","HandChemGreen","ItemBook3","ItemBook4","ItemSodaR4z0rEmpty","ItemSodaDrwasteEmpty","ItemSodaLemonadeEmpty","ItemSodaLvgEmpty","ItemSodaMzlyEmpty","ItemSodaRabbitEmpty","ItemSodaClaysEmpty","TrashJackDaniels","TrashTinCan","ItemLetter","ItemBook1","ItemBook2","ItemTrashRazor","FoodCanOrlokEmpty","FoodCanDemonEmpty","FoodCanTylersEmpty","FoodCanCornEmpty","FoodCanBoneboyEmpty","FoodCanBadguyEmpty","FoodCanGriffEmpty","FoodCanPowellEmpty","FoodCanHerpyEmpty","FoodCanUnlabeledEmpty","FoodCanCurgonEmpty","FoodCanFraggleosEmpty","ItemTrashToiletpaper"];

// Common
_food_group = ["ItemWaterbottle","FoodNutmix","FoodPistachio","FoodMRE","ItemSodaOrangeSherbet","ItemSodaRbull","ItemSodaR4z0r","ItemSodaMdew","ItemSodaPepsi","ItemSodaCoke","FoodbaconCooked","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodchickenCooked","FoodmuttonCooked","FoodrabbitCooked","ItemTroutCooked","ItemTunaCooked","ItemSeaBassCooked","FoodCanGriff","FoodCanTylers","FoodCanDemon","FoodCanPowell","FoodCanCorn","FoodCanOrlok","FoodCanHerpy","FoodCanBadguy","FoodCanBoneboy","FoodCanCurgon","FoodCanFraggleos","ItemSodaRabbit","ItemSodaMtngreenEmpty","ItemSodaSmashtEmpty","ItemSodaMtngreen","ItemSodaDrwaste","ItemSodaSmasht","ItemSodaClays","ItemSodaLemonade","ItemSodaLvg"];
_military_group = ["FlareWhite_M203","FlareGreen_M203","1Rnd_Smoke_M203","HandGrenade_west","HandGrenade_east","SmokeShell","SmokeShellRed","SmokeShellGreen","FoodMRE","Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_Drake_Light_DZ"];
_medical_group = ["ItemAntibiotic","ItemBloodbag","ItemEpinephrine","ItemHeatPack","ItemMorphine","ItemBandage","FoodCanFrankBeans","FoodCanPasta"];
_vehicle_repair_group = ["PartEngine","PartFueltank","PartGeneric","PartGlass","PartVRotor","PartWheel"];

_common_group = ["ItemPlotDeed","ItemComboLock","ItemSledgeHead","ItemSledgeHandle","Skin_Sniper1_DZ","bulk_ItemSandbag"];
_assault_group = ["M16A4_ACG","Sa58V_RCO_EP1","SCAR_L_STD_Mk4CQT","M8_sharpshooter","M4A1_HWS_GL_camo","SCAR_L_STD_HOLO","M4A3_CCO_EP1","M4A1_AIM_SD_camo","M16A4","m8_carbine","BAF_L85A2_RIS_Holo","Sa58P_EP1","Sa58V_CCO_EP1","Sa58V_EP1","AKS_74_kobra","AKS_74_U","AKS_GOLD","AK_47_M","AK_74","FN_FAL","FN_FAL_ANPVS4","m8_compact","G36A_camo","G36C","m8_holo_sd","G36C_camo","G36K_camo","G36_C_SD_camo","M16A2","M16A2GL","M4A1","M4A1_Aim"];
_lmg_group = ["RPK_74","M249_EP1_DZ","M249_DZ","M240_DZ","m240_scoped_EP1_DZE","M249_m145_EP1_DZE","M60A4_EP1_DZE"];
_sniper_group = ["M14_EP1","SVD_CAMO","SVD","VSS_Vintorez","DMR_DZ","M40A3","M24","M24_des_EP1","SVD_des_EP1"];
_tools_group = ["ItemKeyKit","Binocular","Binocular_Vector","ItemCompass","ItemCrowbar","ItemEtool","ItemFishingPole","ItemFlashlightRed","ItemGPS","ItemHatchet_DZE","ItemKnife","ItemMachete","ItemMatchbox_DZE","ItemToolbox","NVGoggles"];
_chainbullets_group    = ["2000Rnd_762x51_M134","200Rnd_762x51_M240","100Rnd_127x99_M2","150Rnd_127x107_DSHKM"];

// Rares
_rares_group = ["ItemVault","ItemBriefcase100oz","ItemLockbox","30m_plot_kit"];
_rare_weapons_group = ["KSVK_DZE","MK_48_DZ","Pecheneg_DZ","M110_NVG_EP1","SCAR_H_LNG_Sniper_SD","M107_DZ","BAF_LRR_scoped"];

// Legendaries
_legend_group = ["PipeBomb","ItemHotwireKit"];
_chainsaw_group = ["Chainsaw","ChainsawB","ChainsawG","ChainsawP","BAF_AS50_scoped"];

MBC_REWARDLIST = [
    //Reward List format:
    //[type,item,quantity,raritylevel,rarity]
    //        type - item type. Available options:
    //            magazine - any type of magazine and most general items (briefcases, cinder blocks, ammunition, etc)
    //            weapon - any type of weapon, note that toolbelt items are also considered weapons in Arma
    //            group_mag - a group of magazines. This is an array of items from which only 1 will be randomly picked
    //            group_wep - a group of weapons. An array of weapons from which only 1 will be randomly picked
    //            group_tool - a group of tools. An array of tools from which only 1 will be randomly picked
    //            coins - this is for Zupa's Single Currency script only. Only use it if you have that script. If you don't do not use coins as a type for reward
    //            script - this is an experimental feature for more advanced users. I haven't tested it thoroughly so use it at your own risk.
    //                It was meant to work as a power-up rather than having an item as a reward. If you use "script" as a type, you must type the script's full path to the "item" field
    //        item - class name of item. If type is group, insert the group's variable. Example: 30m_plot_pole, ItemHotwireKit, _sniper_group, _junk_group
    //        quantity - number of items, set it to 1 if you're using grouping. Example: 15 (in case item is ItemHotwireKit then it will give you 15 Hotwire Kits)
    //        raritylevel - the level of rarity from 1 to 4 (1 = least rare, 4 = rarest), this is just visual for the UI
    //        rarity - how likely this item will be picked in percentage (from 0 to 100)
    //            Note: total sum of rarity must equal 100
    
    // Bad luck (junk items with low possibility)
     ["group_mag",_junk_group,1,1,4]
    
    // Common
    ,["group_wep",_assault_group,1,2,6]
    ,["group_wep",_lmg_group,1,2,6]
    ,["group_wep",_sniper_group,1,2,6]
    ,["group_mag",_military_group,1,2,4]
    ,["group_mag",_medical_group,5,2,4]
    ,["group_mag",_vehicle_repair_group,2,2,4]
    ,["group_mag",_common_group,1,2,6]
    ,["group_mag",_chainbullets_group,5,2,4]
    ,["group_tool",_tools_group,1,2,6]
    ,["coins","Coins",2500,2,5]
    ,["coins","Coins",3000,2,4]
    ,["coins","Coins",5000,2,3]
    ,["magazine","ItemGoldBar10oz",3,2,3]
    ,["magazine","PartPlywoodPack",15,2,3]
    ,["magazine","PartPlankPack",15,2,3]
    
    // Rare
    ,["group_wep",_rare_weapons_group,1,3,5]
    ,["group_mag",_rares_group,1,3,5]
    ,["magazine","ItemGoldBar10oz",6,3,2]
    ,["coins","Coins",10000,3,2]
    ,["magazine","CinderBlocks",15,3,2]
    ,["magazine","ItemSilvercase_Base",1,3,2]
    ,["magazine","PartPlywoodPack",30,3,2]
    ,["magazine","PartPlankPack",30,3,2]
    ,["magazine","ItemPole",30,3,2]
    
    // Legendary
    ,["group_wep",_chainsaw_group,1,4,1]
    ,["group_mag",_legend_group,1,4,1]
    ,["magazine","ItemBriefcase_Base",1,4,1]
    ,["coins","Coins",20000,4,1]
    ,["coins","Coins",50000,4,1]
];

 

disableSerialization;

private ["_slots","_type","_item","_spawnCrate","_crateName","_pos","_crateClass","_dir","_selectDelay","_inVehicle"];

_type = _this select 0;

call {

    if(_type == "Premium") exitWith {
        _slots = 6;
        _item = "ItemBriefcase_Base";
    };

    if(_type == "Silver") exitWith {
        _slots = 3;
        _item = "ItemSilvercase_Base";
    };
};

(findDisplay 106) closedisplay 0;
closeDialog 0;

_inVehicle = (vehicle player) != player;
if(_inVehicle) exitWith {
    cutText [format["You cannot open %1 in a vehicle.", MBT_NAME], "PLAIN DOWN"];
};

cutText [format["Opening EpochPack %1 (%2 items)..",_type,_slots], "PLAIN DOWN"];
player playActionNow "Medic";

r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
_briefSoundPlay = false;
_briefSoundCount = 0;

while {r_doLoop} do {
    _animState = animationState player;
    _isMedic = ["medic",_animState] call fnc_inString;
    _briefSoundCount = _briefSoundCount + 1;
    if (_briefSoundCount > 10 && !_briefSoundPlay) then { //Just to delay the sound a bit
        [objNull, player, rSAY, "Brief_Open_Sound", 30] call RE;
        _briefSoundPlay = true;
    };
    if (_isMedic) then {
        _started = true;
    };
    if (_started and !_isMedic) then {
        r_doLoop = false;
        _finished = true;
    };
    if (r_interrupt) then {
        r_doLoop = false;
    };
    sleep 0.1;
};
r_doLoop = false;

if (!_finished) exitWith {
    r_interrupt = false;
    if (vehicle player == player) then {
        [objNull, player, rSwitchMove,""] call RE;
        player playActionNow "stop";
    };
    cutText [format["Cancelled opening.."], "PLAIN DOWN"];
};

if (_finished) then {

    private ["_dialog","_cashToAdd","_canContinue"];
    mbc_rewardlist_temp = [];
    _canContinue = false;

    if (_item in magazines player) then {
        player removeMagazine _item;
        _canContinue = true;
    };
    
    if (!_canContinue) exitWith { //Anti-duping
        cutText [format["Opening EpochPack %1 failed.", _type] , "PLAIN DOWN"];
    };

    _crateClass = "USOrdnanceBox";

    _dir = getdir player;
    _pos = getposATL player;
    _pos = [(_pos select 0)+1*sin(_dir),(_pos select 1)+1*cos(_dir), (_pos select 2)];

    _spawnCrate = _crateClass createVehicleLocal _pos;

    _spawnCrate setDir _dir;
    _spawnCrate setposATL _pos;
    
    clearWeaponCargoGlobal _spawnCrate;
    clearMagazineCargoGlobal _spawnCrate;
    clearBackpackCargoGlobal _spawnCrate;
    
    _lootRandomizer = [];
    
    //Let's crate an array to randomize loot depending on rarity
    {
        private ["_forEachTempIndexNo"];
        _forEachTempIndexNo = _forEachIndex;
        for "_i" from 1 to (_x select 4) do {
            _lootRandomizer set [count _lootRandomizer, _forEachTempIndexNo];
        };
    } forEach MBC_REWARDLIST;
    
    Sleep 0.2;

    for "_i" from 1 to _slots do {
        private ["_loot","_lootIndex","_lootType"];
        _loot = [];
        _lootIndex = _lootRandomizer call BIS_fnc_selectRandom;
        _loot = + MBC_REWARDLIST;
        _loot = _loot select _lootIndex;
        _lootType = _loot select 0;
        
        //Let's pick the random items out of groups right away, so we can properly display it on the UI
        switch (_lootType) do {
            case "group_wep": {
                Sleep 0.2;
                _groupingArray = _loot select 1;
                _weapon = _groupingArray call BIS_fnc_selectRandom;
                _loot set [1, _weapon]; // Random weapon
                _loot set [2, (1 + floor(random 4))]; // Random amount of mags
            };
            case "group_tool": {
                Sleep 0.2;
                _groupingArray = _loot select 1;
                _tool = _groupingArray call BIS_fnc_selectRandom;
                _loot set [1, _tool]; // Random tool
            };
            case "group_mag": {
                Sleep 0.2;
                _mag = (_loot select 1) call BIS_fnc_selectRandom;
                _loot set [1, _mag]; // Random item
            };
        };
        mbc_rewardlist_temp set [count mbc_rewardlist_temp, _loot];
        _loot = [];
    };
    
    UpdateMBCDialog = {
        {
            private ["_pic","_text","_itemName","_qty","_addInfo"];
            
            ctrlSetText [81401, MBT_DIALOG_TITLE];
            ctrlSetText [81402, MBT_DIALOG_CLAIM];
            ctrlSetText [81403, MBT_DIALOG_NOTE];
            
            _addInfo = "";
            switch (_x select 0) do {
                case "group_wep": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    _text = format["%1\n+%2 magazines", _itemName, _qty];
                };
                case "group_tool": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _text = format["%1", _itemName];
                };
                case "group_mag": {
                    _pic = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "coins": {
                    _pic = getText (configFile >> 'CfgWeapons' >> 'EvMoney' >> 'picture');
                    _qty = _x select 2;
                    _text = format["%1 %2", _qty call BIS_fnc_numberText, _x select 1];
                };
                case "weapon": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "magazine": {
                    _pic = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    
                    if((_x select 1) == "ItemBriefcase_Base") then {
                        _itemName = "EpochPack Premium";
                    };

                    if((_x select 1) == "ItemSilvercase_Base") then {
                        _itemName = "EpochPack Silver";
                    };                    
                    
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "script": {
                    _pic = "";
                    _text = _x select 1;
                };
            };
            
            ctrlSetText [81201 + _forEachIndex, _pic];
            ctrlSetText [81301 + _forEachIndex, _text];
            
            _display = findDisplay 81000;
            _frame_ctrl = _display displayCtrl 81101 + _forEachIndex;
            _text_ctrl = _display displayCtrl 81301 + _forEachIndex;
            
            switch (_x select 3) do {
                case 1: {
                    _frame_ctrl ctrlSetTextColor [0.6,0.6,0.6,0.5];
                    _text_ctrl ctrlSetTextColor [0.6,0.6,0.6,0.5];
                };
                case 2: {
                    _frame_ctrl ctrlSetTextColor [1,1,1,0.5];
                    _text_ctrl ctrlSetTextColor [1,1,1,0.5];
                };
                case 3: {
                    _frame_ctrl ctrlSetTextColor [0.93,0.79,0,0.9];
                    _text_ctrl ctrlSetTextColor [0.93,0.79,0,0.9];
                };
                case 4: {
                    _frame_ctrl ctrlSetTextColor [0.83,0.29,0.41,1];
                    _text_ctrl ctrlSetTextColor [0.83,0.29,0.41,1];
                };
            };
        } forEach mbc_rewardlist_temp;
    };

    Sleep 0.2;
    _dialog = createdialog "MBC_DIALOG";
    call UpdateMBCDialog;
    waitUntil { !dialog };
    
    cutText ["Claiming reward..","PLAIN DOWN"];

    Sleep 0.2;

    _cashToAdd = 0;

    {
        private["_type","_magazines","_magazineClass","_currentMoney"];
        
        _type = _x select 0;
        
        call {
            if (_type == "group_wep") exitWith {
                _spawnCrate addWeaponCargoGlobal [_x select 1, 1];
                _magazines = getArray (configFile >> "CfgWeapons" >> _x select 1 >> "magazines");
                if (count _magazines > 0) then
                {
                    _magazineClass = _magazines select 0;
                    _spawnCrate addMagazineCargoGlobal [_magazineClass, _x select 2];
                }
            };
            if (_type == "group_tool")     exitWith { _spawnCrate addWeaponCargoGlobal [_x select 1, 1]; };
            if (_type == "group_mag")     exitWith { _spawnCrate addMagazineCargoGlobal [_x select 1, _x select 2];};
            if (_type == "coins")         exitWith { _cashToAdd = _cashToAdd + (_x select 2); };
            if (_type == "weapon")         exitWith { _spawnCrate addWeaponCargoGlobal [_x select 1, _x select 2]; };
            if (_type == "magazine")     exitWith { _spawnCrate addMagazineCargoGlobal [_x select 1, _x select 2]; };
            if (_type == "script") exitWith { [_x select 2] execVM _x select 1; };
        };
    } count mbc_rewardlist_temp;

    if (_cashToAdd > 0) then {
        _currentMoney = player getVariable["cashMoney",0];
        player setVariable["cashMoney",_currentMoney + _cashToAdd, true];
    };

    PVDZE_plr_Save = [player,(magazines player),true,true] ;
    publicVariableServer "PVDZE_plr_Save";

    PVDZE_log = [format["EPOCHPACK: Player %1 (%2) - Reward: %3",name player, getPlayerUID player, mbc_rewardlist_temp]];
    publicVariableServer "PVDZE_log"; // This is not in default Epoch, added it myself.

    cutText [format["Reward claimed - the contents have been put inside the box which will auto-remove in %1 minutes",(MBT_CRATEDELAY/60)],"PLAIN DOWN"];
    
    sleep MBT_CRATEDELAY;
    deletevehicle _spawnCrate;

};

Link to comment
Share on other sites

Hey Rocu,

I made some changes to the files myself. Added support for the ItemSilvercase_Base. I'll just post them here so you can have a look and see if there's anything usefull in it for you :)

 

Cheers,

 

f3cuk

 

/*
        Mystery Briefcase addon by Rocu
        Configuration file
*/

MBT_NAME = "EpochPacks"; //Name of the item that spawns the reward (this is just a visual thing, code won't break if you change this to something random)
MBT_CRATEDELAY = 900; //How long until the reward crate disappears (in seconds) Default: 900 (15 minutes)
MBT_DIALOG_TITLE = "EpochPack opening"; //Reward dialog title
MBT_DIALOG_CLAIM = "Claim Your Reward"; //Claim reward button
MBT_DIALOG_NOTE = "* After claiming your prize the reward crate will disappear in 15 minutes."; //Notation warning about the crate's delay

/*
        REWARD CONFIGURATION
        Everything that has to do with the prize you get from the briefcase
*/

// Junk
_junk_group = ["HandRoadFlare","TrashTinCan","FoodCanUnlabeled","HandChemBlue","HandChemRed","HandChemGreen","ItemBook3","ItemBook4","ItemSodaR4z0rEmpty","ItemSodaDrwasteEmpty","ItemSodaLemonadeEmpty","ItemSodaLvgEmpty","ItemSodaMzlyEmpty","ItemSodaRabbitEmpty","ItemSodaClaysEmpty","TrashJackDaniels","TrashTinCan","ItemLetter","ItemBook1","ItemBook2","ItemTrashRazor","FoodCanOrlokEmpty","FoodCanDemonEmpty","FoodCanTylersEmpty","FoodCanCornEmpty","FoodCanBoneboyEmpty","FoodCanBadguyEmpty","FoodCanGriffEmpty","FoodCanPowellEmpty","FoodCanHerpyEmpty","FoodCanUnlabeledEmpty","FoodCanCurgonEmpty","FoodCanFraggleosEmpty","ItemTrashToiletpaper"];

// Common
_food_group = ["ItemWaterbottle","FoodNutmix","FoodPistachio","FoodMRE","ItemSodaOrangeSherbet","ItemSodaRbull","ItemSodaR4z0r","ItemSodaMdew","ItemSodaPepsi","ItemSodaCoke","FoodbaconCooked","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodchickenCooked","FoodmuttonCooked","FoodrabbitCooked","ItemTroutCooked","ItemTunaCooked","ItemSeaBassCooked","FoodCanGriff","FoodCanTylers","FoodCanDemon","FoodCanPowell","FoodCanCorn","FoodCanOrlok","FoodCanHerpy","FoodCanBadguy","FoodCanBoneboy","FoodCanCurgon","FoodCanFraggleos","ItemSodaRabbit","ItemSodaMtngreenEmpty","ItemSodaSmashtEmpty","ItemSodaMtngreen","ItemSodaDrwaste","ItemSodaSmasht","ItemSodaClays","ItemSodaLemonade","ItemSodaLvg"];
_military_group = ["FlareWhite_M203","FlareGreen_M203","1Rnd_Smoke_M203","HandGrenade_west","HandGrenade_east","SmokeShell","SmokeShellRed","SmokeShellGreen","FoodMRE","Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_Drake_Light_DZ"];
_medical_group = ["ItemAntibiotic","ItemBloodbag","ItemEpinephrine","ItemHeatPack","ItemMorphine","ItemBandage","FoodCanFrankBeans","FoodCanPasta"];
_vehicle_repair_group = ["PartEngine","PartFueltank","PartGeneric","PartGlass","PartVRotor","PartWheel"];

_common_group = ["ItemPlotDeed","ItemComboLock","ItemSledgeHead","ItemSledgeHandle","Skin_Sniper1_DZ","bulk_ItemSandbag"];
_assault_group = ["M16A4_ACG","Sa58V_RCO_EP1","SCAR_L_STD_Mk4CQT","M8_sharpshooter","M4A1_HWS_GL_camo","SCAR_L_STD_HOLO","M4A3_CCO_EP1","M4A1_AIM_SD_camo","M16A4","m8_carbine","BAF_L85A2_RIS_Holo","Sa58P_EP1","Sa58V_CCO_EP1","Sa58V_EP1","AKS_74_kobra","AKS_74_U","AKS_GOLD","AK_47_M","AK_74","FN_FAL","FN_FAL_ANPVS4","m8_compact","G36A_camo","G36C","m8_holo_sd","G36C_camo","G36K_camo","G36_C_SD_camo","M16A2","M16A2GL","M4A1","M4A1_Aim"];
_lmg_group = ["RPK_74","M249_EP1_DZ","M249_DZ","M240_DZ","m240_scoped_EP1_DZE","M249_m145_EP1_DZE","M60A4_EP1_DZE"];
_sniper_group = ["M14_EP1","SVD_CAMO","SVD","VSS_Vintorez","DMR_DZ","M40A3","M24","M24_des_EP1","SVD_des_EP1"];
_tools_group = ["ItemKeyKit","Binocular","Binocular_Vector","ItemCompass","ItemCrowbar","ItemEtool","ItemFishingPole","ItemFlashlightRed","ItemGPS","ItemHatchet_DZE","ItemKnife","ItemMachete","ItemMatchbox_DZE","ItemToolbox","NVGoggles"];
_chainbullets_group    = ["2000Rnd_762x51_M134","200Rnd_762x51_M240","100Rnd_127x99_M2","150Rnd_127x107_DSHKM"];

// Rares
_rares_group = ["ItemVault","ItemBriefcase100oz","ItemLockbox","30m_plot_kit"];
_rare_weapons_group = ["KSVK_DZE","MK_48_DZ","Pecheneg_DZ","M110_NVG_EP1","SCAR_H_LNG_Sniper_SD","M107_DZ","BAF_LRR_scoped"];

// Legendaries
_legend_group = ["PipeBomb","ItemHotwireKit"];
_chainsaw_group = ["Chainsaw","ChainsawB","ChainsawG","ChainsawP","BAF_AS50_scoped"];

MBC_REWARDLIST = [
    //Reward List format:
    //[type,item,quantity,raritylevel,rarity]
    //        type - item type. Available options:
    //            magazine - any type of magazine and most general items (briefcases, cinder blocks, ammunition, etc)
    //            weapon - any type of weapon, note that toolbelt items are also considered weapons in Arma
    //            group_mag - a group of magazines. This is an array of items from which only 1 will be randomly picked
    //            group_wep - a group of weapons. An array of weapons from which only 1 will be randomly picked
    //            group_tool - a group of tools. An array of tools from which only 1 will be randomly picked
    //            coins - this is for Zupa's Single Currency script only. Only use it if you have that script. If you don't do not use coins as a type for reward
    //            script - this is an experimental feature for more advanced users. I haven't tested it thoroughly so use it at your own risk.
    //                It was meant to work as a power-up rather than having an item as a reward. If you use "script" as a type, you must type the script's full path to the "item" field
    //        item - class name of item. If type is group, insert the group's variable. Example: 30m_plot_pole, ItemHotwireKit, _sniper_group, _junk_group
    //        quantity - number of items, set it to 1 if you're using grouping. Example: 15 (in case item is ItemHotwireKit then it will give you 15 Hotwire Kits)
    //        raritylevel - the level of rarity from 1 to 4 (1 = least rare, 4 = rarest), this is just visual for the UI
    //        rarity - how likely this item will be picked in percentage (from 0 to 100)
    //            Note: total sum of rarity must equal 100
    
    // Bad luck (junk items with low possibility)
     ["group_mag",_junk_group,1,1,4]
    
    // Common
    ,["group_wep",_assault_group,1,2,6]
    ,["group_wep",_lmg_group,1,2,6]
    ,["group_wep",_sniper_group,1,2,6]
    ,["group_mag",_military_group,1,2,4]
    ,["group_mag",_medical_group,5,2,4]
    ,["group_mag",_vehicle_repair_group,2,2,4]
    ,["group_mag",_common_group,1,2,6]
    ,["group_mag",_chainbullets_group,5,2,4]
    ,["group_tool",_tools_group,1,2,6]
    ,["coins","Coins",2500,2,5]
    ,["coins","Coins",3000,2,4]
    ,["coins","Coins",5000,2,3]
    ,["magazine","ItemGoldBar10oz",3,2,3]
    ,["magazine","PartPlywoodPack",15,2,3]
    ,["magazine","PartPlankPack",15,2,3]
    
    // Rare
    ,["group_wep",_rare_weapons_group,1,3,5]
    ,["group_mag",_rares_group,1,3,5]
    ,["magazine","ItemGoldBar10oz",6,3,2]
    ,["coins","Coins",10000,3,2]
    ,["magazine","CinderBlocks",15,3,2]
    ,["magazine","ItemSilvercase_Base",1,3,2]
    ,["magazine","PartPlywoodPack",30,3,2]
    ,["magazine","PartPlankPack",30,3,2]
    ,["magazine","ItemPole",30,3,2]
    
    // Legendary
    ,["group_wep",_chainsaw_group,1,4,1]
    ,["group_mag",_legend_group,1,4,1]
    ,["magazine","ItemBriefcase_Base",1,4,1]
    ,["coins","Coins",20000,4,1]
    ,["coins","Coins",50000,4,1]
];
disableSerialization;

private ["_slots","_type","_item","_spawnCrate","_crateName","_pos","_crateClass","_dir","_selectDelay","_inVehicle"];

_type = _this select 0;

call {

    if(_type == "Premium") exitWith {
        _slots = 6;
        _item = "ItemBriefcase_Base";
    };

    if(_type == "Silver") exitWith {
        _slots = 3;
        _item = "ItemSilvercase_Base";
    };
};

(findDisplay 106) closedisplay 0;
closeDialog 0;

_inVehicle = (vehicle player) != player;
if(_inVehicle) exitWith {
    cutText [format["You cannot open %1 in a vehicle.", MBT_NAME], "PLAIN DOWN"];
};

cutText [format["Opening EpochPack %1 (%2 items)..",_type,_slots], "PLAIN DOWN"];
player playActionNow "Medic";

r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
_briefSoundPlay = false;
_briefSoundCount = 0;

while {r_doLoop} do {
    _animState = animationState player;
    _isMedic = ["medic",_animState] call fnc_inString;
    _briefSoundCount = _briefSoundCount + 1;
    if (_briefSoundCount > 10 && !_briefSoundPlay) then { //Just to delay the sound a bit
        [objNull, player, rSAY, "Brief_Open_Sound", 30] call RE;
        _briefSoundPlay = true;
    };
    if (_isMedic) then {
        _started = true;
    };
    if (_started and !_isMedic) then {
        r_doLoop = false;
        _finished = true;
    };
    if (r_interrupt) then {
        r_doLoop = false;
    };
    sleep 0.1;
};
r_doLoop = false;

if (!_finished) exitWith {
    r_interrupt = false;
    if (vehicle player == player) then {
        [objNull, player, rSwitchMove,""] call RE;
        player playActionNow "stop";
    };
    cutText [format["Cancelled opening.."], "PLAIN DOWN"];
};

if (_finished) then {

    private ["_dialog","_cashToAdd","_canContinue"];
    mbc_rewardlist_temp = [];
    _canContinue = false;

    if (_item in magazines player) then {
        player removeMagazine _item;
        _canContinue = true;
    };
    
    if (!_canContinue) exitWith { //Anti-duping
        cutText [format["Opening EpochPack %1 failed.", _type] , "PLAIN DOWN"];
    };

    _crateClass = "USOrdnanceBox";

    _dir = getdir player;
    _pos = getposATL player;
    _pos = [(_pos select 0)+1*sin(_dir),(_pos select 1)+1*cos(_dir), (_pos select 2)];

    _spawnCrate = _crateClass createVehicleLocal _pos;

    _spawnCrate setDir _dir;
    _spawnCrate setposATL _pos;
    
    clearWeaponCargoGlobal _spawnCrate;
    clearMagazineCargoGlobal _spawnCrate;
    clearBackpackCargoGlobal _spawnCrate;
    
    _lootRandomizer = [];
    
    //Let's crate an array to randomize loot depending on rarity
    {
        private ["_forEachTempIndexNo"];
        _forEachTempIndexNo = _forEachIndex;
        for "_i" from 1 to (_x select 4) do {
            _lootRandomizer set [count _lootRandomizer, _forEachTempIndexNo];
        };
    } forEach MBC_REWARDLIST;
    
    Sleep 0.2;

    for "_i" from 1 to _slots do {
        private ["_loot","_lootIndex","_lootType"];
        _loot = [];
        _lootIndex = _lootRandomizer call BIS_fnc_selectRandom;
        _loot = + MBC_REWARDLIST;
        _loot = _loot select _lootIndex;
        _lootType = _loot select 0;
        
        //Let's pick the random items out of groups right away, so we can properly display it on the UI
        switch (_lootType) do {
            case "group_wep": {
                Sleep 0.2;
                _groupingArray = _loot select 1;
                _weapon = _groupingArray call BIS_fnc_selectRandom;
                _loot set [1, _weapon]; // Random weapon
                _loot set [2, (1 + floor(random 4))]; // Random amount of mags
            };
            case "group_tool": {
                Sleep 0.2;
                _groupingArray = _loot select 1;
                _tool = _groupingArray call BIS_fnc_selectRandom;
                _loot set [1, _tool]; // Random tool
            };
            case "group_mag": {
                Sleep 0.2;
                _mag = (_loot select 1) call BIS_fnc_selectRandom;
                _loot set [1, _mag]; // Random item
            };
        };
        mbc_rewardlist_temp set [count mbc_rewardlist_temp, _loot];
        _loot = [];
    };
    
    UpdateMBCDialog = {
        {
            private ["_pic","_text","_itemName","_qty","_addInfo"];
            
            ctrlSetText [81401, MBT_DIALOG_TITLE];
            ctrlSetText [81402, MBT_DIALOG_CLAIM];
            ctrlSetText [81403, MBT_DIALOG_NOTE];
            
            _addInfo = "";
            switch (_x select 0) do {
                case "group_wep": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    _text = format["%1\n+%2 magazines", _itemName, _qty];
                };
                case "group_tool": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _text = format["%1", _itemName];
                };
                case "group_mag": {
                    _pic = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "coins": {
                    _pic = getText (configFile >> 'CfgWeapons' >> 'EvMoney' >> 'picture');
                    _qty = _x select 2;
                    _text = format["%1 %2", _qty call BIS_fnc_numberText, _x select 1];
                };
                case "weapon": {
                    _pic = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgWeapons' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "magazine": {
                    _pic = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'picture');
                    _itemName = getText (configFile >> 'CfgMagazines' >> _x select 1 >> 'displayName');
                    _qty = _x select 2;
                    
                    if((_x select 1) == "ItemBriefcase_Base") then {
                        _itemName = "EpochPack Premium";
                    };

                    if((_x select 1) == "ItemSilvercase_Base") then {
                        _itemName = "EpochPack Silver";
                    };                    
                    
                    if (_qty > 1) then {
                        _addInfo = format["\nx %1",_qty];
                    };
                    _text = format["%1%2", _itemName, _addInfo];
                };
                case "script": {
                    _pic = "";
                    _text = _x select 1;
                };
            };
            
            ctrlSetText [81201 + _forEachIndex, _pic];
            ctrlSetText [81301 + _forEachIndex, _text];
            
            _display = findDisplay 81000;
            _frame_ctrl = _display displayCtrl 81101 + _forEachIndex;
            _text_ctrl = _display displayCtrl 81301 + _forEachIndex;
            
            switch (_x select 3) do {
                case 1: {
                    _frame_ctrl ctrlSetTextColor [0.6,0.6,0.6,0.5];
                    _text_ctrl ctrlSetTextColor [0.6,0.6,0.6,0.5];
                };
                case 2: {
                    _frame_ctrl ctrlSetTextColor [1,1,1,0.5];
                    _text_ctrl ctrlSetTextColor [1,1,1,0.5];
                };
                case 3: {
                    _frame_ctrl ctrlSetTextColor [0.93,0.79,0,0.9];
                    _text_ctrl ctrlSetTextColor [0.93,0.79,0,0.9];
                };
                case 4: {
                    _frame_ctrl ctrlSetTextColor [0.83,0.29,0.41,1];
                    _text_ctrl ctrlSetTextColor [0.83,0.29,0.41,1];
                };
            };
        } forEach mbc_rewardlist_temp;
    };

    Sleep 0.2;
    _dialog = createdialog "MBC_DIALOG";
    call UpdateMBCDialog;
    waitUntil { !dialog };
    
    cutText ["Claiming reward..","PLAIN DOWN"];

    Sleep 0.2;

    _cashToAdd = 0;

    {
        private["_type","_magazines","_magazineClass","_currentMoney"];
        
        _type = _x select 0;
        
        call {
            if (_type == "group_wep") exitWith {
                _spawnCrate addWeaponCargoGlobal [_x select 1, 1];
                _magazines = getArray (configFile >> "CfgWeapons" >> _x select 1 >> "magazines");
                if (count _magazines > 0) then
                {
                    _magazineClass = _magazines select 0;
                    _spawnCrate addMagazineCargoGlobal [_magazineClass, _x select 2];
                }
            };
            if (_type == "group_tool")     exitWith { _spawnCrate addWeaponCargoGlobal [_x select 1, 1]; };
            if (_type == "group_mag")     exitWith { _spawnCrate addMagazineCargoGlobal [_x select 1, _x select 2];};
            if (_type == "coins")         exitWith { _cashToAdd = _cashToAdd + (_x select 2); };
            if (_type == "weapon")         exitWith { _spawnCrate addWeaponCargoGlobal [_x select 1, _x select 2]; };
            if (_type == "magazine")     exitWith { _spawnCrate addMagazineCargoGlobal [_x select 1, _x select 2]; };
            if (_type == "script") exitWith { [_x select 2] execVM _x select 1; };
        };
    } count mbc_rewardlist_temp;

    if (_cashToAdd > 0) then {
        _currentMoney = player getVariable["cashMoney",0];
        player setVariable["cashMoney",_currentMoney + _cashToAdd, true];
    };

    PVDZE_plr_Save = [player,(magazines player),true,true] ;
    publicVariableServer "PVDZE_plr_Save";

    PVDZE_log = [format["EPOCHPACK: Player %1 (%2) - Reward: %3",name player, getPlayerUID player, mbc_rewardlist_temp]];
    publicVariableServer "PVDZE_log"; // This is not in default Epoch, added it myself.

    cutText [format["Reward claimed - the contents have been put inside the box which will auto-remove in %1 minutes",(MBT_CRATEDELAY/60)],"PLAIN DOWN"];
    
    sleep MBT_CRATEDELAY;
    deletevehicle _spawnCrate;

};

f3cuk,

 

I think you have an error in your loot code. Pretty sure a Hotwire Kit is a tool/item which is classified as a weapon, not a magazine.

// Legendaries
_legend_group = ["PipeBomb","ItemHotwireKit"];
_chainsaw_group = ["Chainsaw","ChainsawB","ChainsawG","ChainsawP","BAF_AS50_scoped"];

...

,["group_wep",_chainsaw_group,1,4,1]
,["group_mag",_legend_group,1,4,1]
Link to comment
Share on other sites

 

f3cuk,

 

I think you have an error in your loot code. Pretty sure a Hotwire Kit is a tool/item which is classified as a weapon, not a magazine.

 

 

Hotwire kit is an item yes but not a tool. It's classified as a magazine. Trust me I debugged this script with that item the whole time.

Link to comment
Share on other sites

  • 2 weeks later...

Awesome man, works great! Have one small thing though.

When opening the briefcase i get allot of these messages spammed throughout my local .RPT (don't know if harmful?)

Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d
Ref to nonnetwork object 33268100# 1067028: usordnance.p3d

Can i just ignore them?

Link to comment
Share on other sites

Users love this i have to beat them with a bat to keep them away from the trader, only thing that does not seem to work for me is MBT_NAME =  any suggestions? No RPT errors from Admin,User or server.

 

Glad to hear, that's awesome :D . As for the MBT_NAME. Very strange. When you say it doesn't work you mean it doesn't change the name of your item in texts like "You have opened x"? Or if you mean that it doesn't change the name in traders then it's not supposed to. I have it in the video yes, but I ultimately decided not to include it in the installation to make the instructions as noob-friendly as possible. If you want it, you can see this post here: 

Link to comment
Share on other sites

Glad to hear, that's awesome :D . As for the MBT_NAME. Very strange. When you say it doesn't work you mean it doesn't change the name of your item in texts like "You have opened x"? Or if you mean that it doesn't change the name in traders then it's not supposed to. I have it in the video yes, but I ultimately decided not to include it in the installation to make the instructions as noob-friendly as possible. If you want it, you can see this post here: 

 

Ah ok ya i seen it in your video and was like OOO but if that is the case then everything is working switched over to Zupa Trading system so no need to change the name no more but i did like the thought of being able to change names = )

Link to comment
Share on other sites

  • 2 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...