LordRampantHump

Loot Search Exile

102 posts in this topic

This Post is by request from a couple of guys using my mod, It was somthing I found in the tinterwebs and managed to get it working (for the most part) with exile.

Its been a while since I looked at it and am offering it here for you guys to use/ discuss / fix / improve. I am not taking credit for it and wont be able to offer much advice on it. The original script was called "Lars Loot Search" all i did was get it working with exile and tweek it for my needs.

That said, here we go:

 

This script allow you to search various map items such as trash piles, trees etc etc for loot, it is a usefull start for anyone who want to implement scavenging of any description.

from your initPlayerLocal.sqf

[] execVM "LARs\LARs_searchLoot\fn_initSearch.sqf";

in your mpmissions\Exile.(Your Map)

Create a folder called LARs and other inide that called LARs_searchLoot.  You can change the paths if you want, this is just how I had it.  Result is:

mpmissions\Exile.Chernarus\LARs\LARs_searchLoot

inside the folder LARs_searchLoot create a file called fn_initSearch.sqf and paste the following:

Spoiler


if ( !hasInterface ) exitWith {};
waitUntil {!isNull player};
waitUntil {!isNull findDisplay 46};
uiSleep 10;	
if ( isNil "LARs_lootSettings" ) then {
	call compile preprocessFileLineNumbers "LARs\LARs_searchLoot\LARs_lootSettings.sqf";
	player setVariable [ "canloot",true];
};


systemChat ("##= Loading Loot Searcher =##");

Spawn_Checker = {
waitUntil{sleep 1; ExileClientPlayerIsSpawned}; 
waitUntil{player == player};

player setVariable [ "LARs_searchObjectID", player addAction [ "Search #", {
		nul = [] spawn {
		    if !(player getVariable "canloot") exitWith {["ErrorTitleOnly", ["You can't loot right now!"]] call ExileClient_gui_toaster_addTemplateToast;};
			if !(alive player) exitWith {};
			player setVariable [ "canloot",false];
			player playAction "Crouch";
			player playMove "AinvPknlMstpSlayWrflDnon_medic";
			
			  waitUntil {animationState player == "AinvPknlMstpSlayWrflDnon_medic" || !alive player};
			  player setVariable [ "LARs_searchObjectID",""];
              waitUntil {animationState player != "AinvPknlMstpSlayWrflDnon_medic" || !alive player};
			_wh = createVehicle [ "GroundWeaponHolder", getPosATL player, [], 0, "CAN_COLLIDE" ];
			if (random 100 > 75) then {
				for "_i" from 0 to floor( random 5 ) do {
					_item = LARs_loot call BIS_fnc_selectRandom;
					_itemType = _item call BIS_fnc_itemType;
					switch ( _itemType select 0 ) do {
						case "Equipment" : {
							if ( _itemType select 2 isEqualTo "Backpack" ) then {
								_wh addBackpackCargoGlobal [ _item, 1 ];
							}else{
								_wh addItemCargoGlobal [ _item, 1 ];
							};
						};
						case "Item" : {
							_wh addItemCargoGlobal [ _item, 1 ];
						};
						case "Weapon" : {
							_wh addWeaponCargoGlobal [ _item, 1 ];
						};
						case "Magazine" : {
							_wh addMagazineCargoGlobal [ _item, 1 ];
						};
					};
				};
			
			player action [ "Gear", _wh ];
			waitUntil{ count ( getPosATL _wh nearEntities [ "MAN", 15 ] ) isEqualTo 0 };
			deleteVehicle _wh;
			player setVariable ["canloot",true];
			}else {
				["ErrorTitleOnly", ["Found nothing but shit!"]] call ExileClient_gui_toaster_addTemplateToast;
				player setVariable ["canloot",true];
				
			};
		};
		
	},
	[],
	1,
	true,
	true,
	"",
	"
		if !( isnil 'LARs_searchObject') then {
			player setUserActionText [ player getvariable 'LARs_searchObjectID', format [ 'Search %1', LARs_searchObject] ];
			true
		};
	"
] ];
Checker_Loaded = true;
systemChat ("Loaded Spawn Checker");
};

EH = addMissionEventHandler ["Draw3D",{
	_objs = lineIntersectsSurfaces [ eyePos player, ( eyePos player ) vectorAdd ( getCameraViewDirection player vectorMultiply LARs_searchDistance ), player, objNull, true, 1, "VIEW", "GEOM" ];
	if ( !isNil "LARs_searchDebug" ) then {
		drawLine3D[ ASLToAGL eyePos player, (( ASLToAGL eyePos player ) vectorAdd ( getCameraViewDirection player vectorMultiply LARs_searchDistance )), [1,0,0,1] ];
	};
	if ( count _objs > 0 && { !isNull ( _objs select 0 select 2 ) } ) then {
		_obj = _objs select 0 select 2;
		if ( !( typeOf _obj isEqualTo "" ) && { typeOf _obj in LARs_lootClasses } ) then {
			LARs_searchObject = getText( configFile >> "CfgVehicles" >> typeOf _obj >> "displayname" );
			
		}else{
			_obj = (( str _obj splitString " " ) select 1);
			if ( _obj in LARs_lootModels ) then {
				LARs_searchObject = _obj select [ 0, ( count _obj ) - 6 ];
			};
		};
		_previousSearches = +( missionNamespace getVariable [ "LARs_searchedObjects", [] ] );
		if ( {
			_nul = _x params [ "_object", "_time", "_pos", "_radius" ];
			if ( _object == LARs_searchObject && { player distanceSqr _pos < ( _radius^2 ) } ) then { true }else{ false };
		}count _previousSearches > 0 ) then {
			LARs_searchObject = "Empty";
		};
	}else{
		LARs_searchObject = nil;
	};
	//systemChat format ["##= Loot Searcher Searching =## %1 - %2",LARs_searchObject,Checker_Loaded];
	if ( isNil {player getVariable "LARs_searchObjectID"}) then { 
	[] call Spawn_Checker;
	};
}];

systemChat ("##= Finished Loading Loot Searcher =##");

 

again inside the folder LARs_searchLoot create a file called LARs_lootSettings.sqf and paste the following:

Spoiler

//"AinvPknlMstpSlayWrflDnon_healed2"  "Acts_TreatingWounded03" "Acts_TreatingWounded06"

//Class types that can be looted
LARs_lootClasses = [ "Land_GarbagePallet_F", "Land_ToiletBox_F", "Land_CratesShabby_F", "Land_CratesWooden_F", "Land_BarrelSand_F", "Land_GarbageBags_F", "Land_Sacks_goods_F", "Land_CratesPlastic_F", "Land_Basket_F", "Land_BC_Basket_F", "Land_JunkPile_F", "Land_Sack_F", "Land_MetalBarrel_empty_F", "Land_Sacks_heap_F", "Land_GarbageWashingMachine_F" ]; 
LARs_lootModels = [ "garbagepallet_f.p3d", "toiletbox_f.p3d", "cratesshabby_f.p3d", "crateswooden_f.p3d", "barrelsand_f.p3d", "garbagebags_f.p3d", "sacks_goods_f.p3d", "cratesplastic_f.p3d", "basket_f.p3d", "junkpile_f.p3d", "sack_f.p3d", "metalbarrel_empty_f.p3d", "sacks_heap_f.p3d", "barrelwater_f.p3d","GarbageWashingMachine_F.p3d","garbage_misc.p3d","garbage_paleta.p3d","t_malus1s.p3d"  ]; 
LARs_loot = ["Exile_Item_InstantCoffee","Exile_Item_Bandage","11Rnd_45ACP_Mag","items_pack_apple_red","items_pack_apple","items_pack_apple_red","Exile_Item_BeefParts","Exile_Item_Matches","Exile_Item_Noodles","Exile_Item_Can_Empty","Exile_Item_PlasticBottleDirtyWater","Exile_Item_PlasticBottleEmpty","Exile_Item_PlasticBottleFreshWater","Exile_Item_ToiletPaper","Exile_Item_ZipTie","Exile_Item_Vishpirin","Exile_Item_SeedAstics","Exile_Item_Moobar","Exile_Item_MountainDupe"];

LARs_lootMaxFoundItems = 2;	//Max number of items that could be found per search
LARs_lootChanceFail = 75;	//Percent chance a search finds nothing
LARs_lootAnimations = [ "" ];	//ARRAY of animations to play when searching, a random one is chosen else player just crouches
LARs_lootSearchTime = 3;	//Overall delay between initiating search and items being displayed, if animation is used animation time is taken into consideration
LARs_lootDisplayEmpty = true;	//Show 'empty' action for area that have already been searched
LARs_lootEmptyStrings = [ "You find nothing of interest", "Looks like someones already searched here", "Nothing but junk!" ];

//**Fine tuning**
LARs_lootWHCleanUpDistance = 15;	//Old loot piles are cleaned up once there is no player/switchable within this distance to the pile
LARs_lootWHCleanUpDelay = 30;	//Time in seconds between checks for loot pile clean ups

LARs_searchDistance = 1.5;	//distance you have to be from the object you are looking at to be able to search it
LARs_searchRadius = 1.5;		//Area around player deemed as searched
LARs_searchCleanUpDelay = 300;	//time in seconds, before you can re-search an area
LARs_searchCleanUpDistance = 500;	//distance in meters, if a searched area becomes this far from the player we can likely forget about it

//Debug markers
LARs_searchDebug = false;	//Show searched areas debug markers

//Leave, flag for settings read
LARs_lootSettings = true;


Checker_Loaded = false;

 

again inside the folder LARs_searchLoot create a file called Functions.cpp and paste the following:

class LARs_loot {
	tag = "LARs";
	class Inventory {
		class lootSearch {
			file = "LARs\LARs_searchLoot\fn_initSearch.sqf";
			postInit = 1;
		};
	};
};

 

 

Forgive me as I have not been working on my server for a while and would need to remind myself how all this worked but i hope its enouth to get a few people going with it.

Happy Looting!

  • Like 3

Share this post


Link to post
Share on other sites
Advertisement

Can´t try and test it yet, waiting for my new video card and using onboard graphics now, but it would be so wonderfull if it would work correctly with Exile.

So many possibilities then, fruits from trees and bushes, for example!

Can´t wait for the weekend!!!

:monkey:

 

Share this post


Link to post
Share on other sites

Thanks for sharing this :)

I can confirm that the game crashes for me also when I am at a trash pile, I don't even get an option to loot.

This is spammed quiet a bit in rpt

Spoiler

waitUntil {animationState player == """"AinvPknlMstpSlayWrflDnon_medic"""" || !alive player};
player setVariable [ """"LARs_searchObjectID"""",""""""""];
waitUntil {animationState player != """"AinvPknlMstpSlayWrflDnon_medic"""" || !alive player};
_wh = createVehicle [ """"GroundWeaponHolder"""", getPosATL player, [], 0, """"CAN_COLLIDE"""" ];
if (random 100 > 75) then {
for """"_i"""" from 0 to floor( random 5 ) do {
_item = LARs_loot call BIS_fnc_selectRandom;
_itemType = _item call BIS_fnc_itemType;
switch ( _itemType select 0 ) do {
case """"Equipme
11:03:26 "<infiSTAR.de>SURVEILLANCELOG| Name(0000000000000000) | BadAction on player (content: additemcargo): [""Search #"",""
nul = [] spawn {
if !(player getVariable """"canloot"""") exitWith {[""""ErrorTitleOnly"""", [""""You can't loot right now!""""]] call ExileClient_gui_toaster_addTemplateToast;};
if !(alive player) exitWith {};
player setVariable [ """"canloot"""",false];
player playAction """"Crouch"""";
player playMove """"AinvPknlMstpSlayWrflDnon_medic"""";

 

Share this post


Link to post
Share on other sites

EDIT: After taking a look into your version and compare it with the original i just have to say that the original is working just fine for me without any errors with your provided configuration file. But your fn_initSearch.sqf is not working in this way. There are some things missing like for the conditions. 

Also you complete forget the ui things.

This is the original work from Larrow from the BI forums: https://dl.orangedox.com/gwWQyjU3k17b0S5Kcl/LARs_searchLoot.Stratis.zip

Use this and override the LARs_lootSettings.sqf file with that from the first post and place it into the LARs/LARs_searchLoot directory to start with a exile configuration.

Also no need for the call off the fn_initSearch.sqf in the initPlayerLocal.sqf bacause its a auto loaded function..

Salutesh out!

Edited by [RG] Salutesh
  • Like 2

Share this post


Link to post
Share on other sites

@[RG] Salutesh Hi, thanks for the info. As I said I am compleatly out of touch with this, I only posted it because some people had asked me what I was using,  however, you did exactly what I had hoped for on this thread and provided further information regarding Looting and I hope you will continue to share your finding with those who need it.

Thank You!

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, LordRampantHump said:

@[RG] Salutesh Hi, thanks for the info. As I said I am compleatly out of touch with this, I only posted it because some people had asked me what I was using,  however, you did exactly what I had hoped for on this thread and provided further information regarding Looting and I hope you will continue to share your finding with those who need it.

Thank You!

Well its quite simple to use, just use the provided files from the mission that Larrow postet in the BI forums let me loot stuff in the editor to get exile loot with your provided config file. The script is very usefull but for exile it could have much better implemetation.

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.