Jump to content

[Release] FLoot - For adding custom loot to custom AI


FoamysWorld

Recommended Posts

FLoot 1.0 

 

Features:

Customizable loot table

Adjustable random chance on secondary loot load

 

I created this script because I like to create my own AI independent of the various AI systems. This script allows you to call it from any createUnit setup. This way you can do one off AI's with any skin and still have custom random loot for them easily.

 

To use it create a file called FLoot_XXXX.sqf where "XXXX" is the name of your ai, For instance I have one named FLoot_Bandit,sqf and I use it for all my bandits. You can look at my directory structure in the call example to see where I launch it from, although you can put it anywhere.

 

Here is the code to put in your FLoot_XXXX.sqf file

/*
	File Name: FLoot_XXXX.sqf
	File Created: 2/8/2014
	File Version: 1.0
	File Author: Foamy 
	File Last Edit Date: 2/8/2014
	File Description: FLoot Loadout Script

Parameters: [unitname]
*/

private ["_unitname","_lootChance","_diceRoll","_weaponrnd","_weapon","_magazine","_weaponslist","_magazinelist","_itemFood","_itemDrink","_itemMeds","_itemMisc","_itemslistFood","_itemslistDrink","_itemslistMeds","_itemslistMisc","_i"];

_unitname = _this select 0;
_lootChance = .20;
_diceRoll = random 1;

// Weapon Array
_weaponslist = ["M4A1","M16A2","M4A3_CCO_EP1","LeeEnfield","AK_47_M"];

// Magazine Array 
_magazinelist = ["30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","10x_303","30Rnd_762x39_AK47"];

// Items Arrays
_itemslistFood = ["FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodCanUnlabeled","FoodMRE","FoodNutmix","FoodPistachio"];

_itemslistDrink = ["ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaCoke","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaPepsi","ItemSodaMdew","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle","ItemWaterbottleUnfilled","ItemWaterbottleUnfilled"];

_itemslistMeds = ["ItemAntibiotic","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemBloodbag","ItemEpinephrine","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemHeatPack","ItemMorphine","ItemPainkiller"];

_itemslistMisc = ["Skin_Bandit1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_Bandit2_DZ","TrashJackDaniels","TrashJackDaniels","Skin_BanditW1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_BanditW2_DZ","TrashJackDaniels","TrashJackDaniels","Skin_Camo1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_CZ_Soldier_Sniper_EP1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_CZ_Special_Forces_GL_DES_EP1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_Drake_Light_DZ","TrashJackDaniels","TrashJackDaniels","Skin_FR_OHara_DZ","TrashJackDaniels","TrashJackDaniels","Skin_FR_Rodriguez_DZ","TrashJackDaniels","TrashJackDaniels","Skin_Functionary1_EP1_DZ","TrashJackDaniels","TrashJackDaniels","Skin_Graves_Light_DZ","TrashJackDaniels","TrashJackDaniels","Skin_GUE_Commander_DZ","TrashJackDaniels","TrashJackDaniels","Skin_GUE_Soldier_2_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_GUE_Soldier_CO_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_GUE_Soldier_Crew_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_GUE_Soldier_MG_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_GUE_Soldier_Sniper_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_Ins_Soldier_GL_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_Pilot_EP1_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_Priest_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_Rocker1_DZ","ItemSodaEmpty","ItemSodaEmpty","Skin_Rocker2_DZ","TrashTinCan","TrashTinCan","Skin_Rocker3_DZ","TrashTinCan","TrashTinCan","Skin_Rocker4_DZ","TrashTinCan","TrashTinCan","Skin_Rocket_DZ","TrashTinCan","TrashTinCan","Skin_RU_Policeman_DZ","TrashTinCan","TrashTinCan","Skin_Sniper1_DZ","TrashTinCan","TrashTinCan","Skin_Soldier1_DZ","TrashTinCan","TrashTinCan","Skin_Soldier_Bodyguard_AA12_PMC_DZ","TrashTinCan","TrashTinCan","Skin_Soldier_Sniper_PMC_DZ","TrashTinCan","TrashTinCan","Skin_Soldier_TL_PMC_DZ","TrashTinCan","TrashTinCan","Skin_SurvivorW3_DZ","TrashTinCan","TrashTinCan","Skin_SurvivorWcombat_DZ","TrashTinCan","TrashTinCan","Skin_SurvivorWdesert_DZ","TrashTinCan","TrashTinCan","Skin_SurvivorWpink_DZ","TrashTinCan","TrashTinCan","Skin_SurvivorWurban_DZ","TrashTinCan","TrashTinCan","Skin_TK_INS_Soldier_EP1_DZ","TrashTinCan","TrashTinCan","Skin_TK_INS_Warlord_EP1_DZ","TrashTinCan","TrashTinCan","ItemSodaEmpty","ItemTrashRazor","ItemTrashToiletpaper","TrashJackDaniels","TrashTinCan","ItemTinBar","ItemCopperBar","ItemSilverBar","ItemGoldBar","ItemTent","ItemTentDomed","ItemTentDomed2","ItemTentOld","ItemCanvas"];

_weaponrnd = floor random (count _weaponslist);
_weapon = _weaponslist select _weaponrnd;
_magazine = _magazinelist select _weaponrnd;

removeAllWeapons _unitname;
removeAllItems _unitname;

for [{_i=1},{_i<=3},{_i=_i+1}] do {
	_unitname addMagazine _magazine;
	};
	_unitname addWeapon _weapon;
	
_itemFood = _itemslistFood call BIS_fnc_selectRandom;
_unitname addMagazine _itemFood;
	
_itemDrink = _itemslistDrink call BIS_fnc_selectRandom;
_unitname addMagazine _itemDrink;
	
if (_diceRoll < _lootChance) then
{
	_itemMeds = _itemslistMeds call BIS_fnc_selectRandom;
	_unitname addMagazine _itemMeds;
	
	_itemMisc = _itemslistMisc call BIS_fnc_selectRandom;
	_unitname addMagazine _itemMisc;
	sleep 1;
}
else
{
diag_log("FLoot: Extra Loot Chance Failed");
sleep 1;
};

To launch it just add the following line to either your unit init or after the unit is created in the script.

_null = [unitname] execVM "\z\addons\dayz_server\addons\FLoot\FLoot_XXXX.sqf";

Change the path to your path and replace XXXX with the AI unit name. The unitname parameter you pass to it is the actual unit name in the script. (i.e. _myunit)

 

To adjust the chance of secondary loot adjust the following:

_lootChance = .20;

.20 = 20%

1 = 100%

 

Weapons and Magazines are in the same order in the arrays, so if you add/remove a weapon make sure to add/remove the correlating magazine in the same position in the magazine array.

 

To set the amount of magazines to spawn with the weapon edit the number in red:

for [{_i=1},{_i<=3},{_i=_i+1}] do

 

Hope this is as useful to others as it is to me. Enjoy!

Link to comment
Share on other sites

It's just a basic random loot generator that will generate random loot for any unit you create using createUnit. I don't use it to change loot on my Sarge AI, although I am guessing you could use it with any ai system, you would just call this script after the AI unit is called so it clears whatever loot the AI system assigned to the unit before creating new loot from my script. 

 

However, like I said, it's "intended" for creating your own custom AI independent of all the AI systems. I like to use it when making my custom missions. Creative scripting with custom AI can produce some wicked hard results.

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...