LordRampantHump

Loot Search Exile

102 posts in this topic

8 hours ago, Kurewe said:

@LordRampantHump 

Ok, I tested it and everything seems to be working properly, even after committing suicide and respawning.
- You have the ability to change the failure rate of the search. (Noted in the Search_For_Apples.sqf")
- You have the ability to change the maximum number of apples found during the search. (Noted in the Search_For_Apples.sqf")
- You can change which apples you want to find (Noted in the Search_For_Apples.sqf")
- Found apples will be automatically put into any available inventory space. If the is no space in your inventory, they will be placed on the ground.
- While this is specifically for picking apples, you should be able to easily modify this for your specific needs. For example, if you're running Tanoa, you can adjust the code for finding bananas instead of apples.

Here is what I've put together. It's requires an override.

1st: Add the following code to the "CfgExileCustomCode" section of your mission config.cpp.


	//Apple Picking
	ExileClient_object_player_initialize = "overrides\ExileClient_object_player_initialize.sqf";

2nd: Copy the text from the spoiler below, paste it to your text editor and save it to your overrides folder as ExileClient_object_player_initialize.sqf

  Reveal hidden contents

/**
 * ExileClient_object_player_initialize
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_newPlayerObject", "_oldPlayerObject"];
_newPlayerObject = _this;
_oldPlayerObject = player;
player reveal [_newPlayerObject, 4];
selectPlayer _newPlayerObject;
if (_oldPlayerObject isKindOf "Exile_Unit_GhostPlayer") then 
{
    deleteVehicle _oldPlayerObject;
};
player setVariable ["ExileXM8IsOnline", (profileNamespace getVariable ["ExileEnable8GNetwork", false]), true];

// Apple Picking Start
AppleTrees = [ "t_malus1s.p3d" ];
player setVariable ["canloot",true];
player addAction ["Search For Apples", "custom\ApplePicker\Search_For_Apples.sqf", [], 0, false, true, "", "getModelInfo cursorObject select 0 in AppleTrees", 2];
// Apple Picking End

enableSentences false;
enableRadio false;
player setVariable ["BIS_noCoreConversations", true];
player disableConversation true;
player setSpeaker "NoVoice";
showSubtitles false;
[] call ExileClient_object_player_event_hook;
ExileGasMaskNextSoundAt = diag_tickTime;
if (ExileClientGasMaskVisible) then 
{
    false call ExileClient_gui_gasMask_toggle;
};
[] call ExileClient_object_player_stats_reset;
[] call ExileClient_gui_postProcessing_reset;
[] call ExileClient_system_breathing_event_onPlayerSpawned;
[] call ExileClient_system_snow_event_onPlayerSpawned;
[] call ExileClient_system_radiation_event_onPlayerSpawned;
ExileClientIsWaitingForInventoryMoneyTransaction = false;
true

3rd: In the root of your mission folder, create a folder named "custom" (if it doesn't already exist). Then, create a folder named "ApplePicker" inside the "custom" folder.

4th: Copy the text from the spoiler below. Paste it into your text editor and then save the file to the "ApplePicker" folder as "Search_For_Apples.sqf"

  Reveal hidden contents

/**
 * Exile Apple Picking Script
 * Search_For_Apples.sqf
 *
 * By Kurewe
 * CantankerousOldGoats.com
 *
 * For use with LordRampantHump's "Items Pack for Arma 3"
 * http://steamcommunity.com/sharedfiles/filedetails/?id=1082756693
 * 
 * Based on Larrow's Epoch looting script
 * https://forums.bistudio.com/forums/topic/184456-looting-trash-piles-bins/?do=findComment&comment=2942397
 */

private["_canAdd"];

// *** CHANGE WHICH APPLE(S) YOU WANT TO FIND BY CHANGING THE ARRAY TO ONE APPLE OR THE OTHER APPLE OR BOTH APPLES ***
Apples = [ "items_pack_apple_red", "items_pack_apple" ];

if !(player getVariable "canloot") exitWith {["ErrorTitleOnly", ["You can't pick apples right now!"]] call ExileClient_gui_toaster_addTemplateToast;};
if !(alive player) exitWith {};
player setVariable [ "canloot",false];
player playMove "AinvPknlMstpSlayWrflDnon_medic";
uiSleep 6;
// *** CHANGE (RANDOM 100 > 25) TO WHATEVER FAILURE RATE YOU WOULD LIKE ***
// *** I.E. (RANDOM 100 > 50) FOR A 50% FAILURE RATE FOR EACH SEARCH ***
if (random 100 > 25) then {
    _wh = createVehicle ["GroundWeaponHolder", getPosATL player, [], 0, "CAN_COLLIDE"];
    ["SuccessTitleOnly", ["You found something to eat!"]] call ExileClient_gui_toaster_addTemplateToast;
    // *** CHANGE ( RANDOM 5 ) TO HOWEVER MANY POSSIBLE APPLES YOU WANT PLAYER TO FIND ***
    // *** I.E. ( RANDOM 2 ) FOR FINDING A MAX OF 2 APPLES FROM EACH SEARCH ***
    for "_i" from 0 to floor( random 5 ) do { 
        _item = Apples call BIS_fnc_selectRandom;
        _canAdd = [player, _item] call ExileClient_util_playerCargo_canAdd;
        if (_canAdd) then {
            player addMagazine [ _item, 1 ];
        }
        else
        {
            _wh addItemCargoGlobal [ _item, 1];
        };
    };
    player setVariable ["canloot",true];
}
else
{
    ["ErrorTitleOnly", ["You had trouble reaching them apples! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;
    player setVariable ["canloot",true];
};

 

This works really well, thank you :)

 

Is it possible to not allow picking apples when in combat, if so how can it be done?

And, one other thing:

Is it possible to add more 'Random' reasons to the ErrorTitleOnly ?

Spoiler

else
{

["ErrorTitleOnly", ["You had trouble reaching the apples! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

["ErrorTitleOnly", [".....Another Reason Unsuccessful! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

["ErrorTitleOnly", [".....Yet Another Reason Unsuccessful! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

    player setVariable ["canloot",true];
};

 

Share this post


Link to post
Share on other sites
2 hours ago, Diddl3s said:

This works really well, thank you :)

 

Is it possible to not allow picking apples when in combat, if so how can it be done?

And, one other thing:

Is it possible to add more 'Random' reasons to the ErrorTitleOnly ?

  Reveal hidden contents

else
{

["ErrorTitleOnly", ["You had trouble reaching the apples! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

["ErrorTitleOnly", [".....Another Reason Unsuccessful! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

["ErrorTitleOnly", [".....Yet Another Reason Unsuccessful! Try again!"]] call ExileClient_gui_toaster_addTemplateToast;

    player setVariable ["canloot",true];
};

 

I'm sure both your suggestions are possible. However, my primary goal was to get a basic, functioning script without all the extra hoops and loops that were in the original. When I have some more time, I will look into it.

Share this post


Link to post
Share on other sites
Advertisement
2 hours ago, Kurewe said:

I'm sure both your suggestions are possible. However, my primary goal was to get a basic, functioning script without all the extra hoops and loops that were in the original. When I have some more time, I will look into it.

No problem man, understandable :)

I got it to not allow searching when in combat, if anyone wants it.

Add to Search_For_Apples.sqf:

Spoiler

if (ExileClientPlayerIsInCombat) exitWith {    ["ErrorTitleAndText", ["You cannot forage when in combat!"]] call ExileClient_gui_toaster_addTemplateToast;};

directly under:

Spoiler

Apples = [ "items_pack_apple_red", "items_pack_apple" ];

 

Edited by Diddl3s
  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Diddl3s said:

Is it possible to not allow picking apples when in combat, if so how can it be done?

 

I never understood this one... , cant fix a car, cant  eat cant breath while somone near you missfired! Granted a few things shouldn't be allowed but why could you not pick  apples while in combat?

(not having a go but this "Not while in combat" really gets me!)

  • Like 1

Share this post


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

I never understood this one... , cant fix a car, cant  eat cant breath while somone near you missfired! Granted a few things shouldn't be allowed but why could you not pick  apples while in combat?

(not having a go but this "Not while in combat" really gets me!)

Heheh, in the real world for sure :)

But sadly, it would be a crying point for some if they 'accidentally' begin to look for apples while trying to take cover during combat. I just cover all bases where I possibly can

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, Diddl3s said:

Heheh, in the real world for sure :)

But sadly, it would be a crying point for some if they 'accidentally' begin to look for apples while trying to take cover during combat. I just cover all bases where I possibly can

fair enough! ... could back a way to cancel the animation tho.

Edited by LordRampantHump

Share this post


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

fair enough! ... could back a way to cancel the animation tho.

Would I just need to add this: 

Spoiler

player switchMove "";

 

Share this post


Link to post
Share on other sites
18 hours ago, Diddl3s said:

Would I just need to add this: 

  Hide contents

player switchMove "";

 

You can do that with a distance check like this (i dont have tested it):

[_player] spawn 
{
	params["_player"];
	_animationToPlay = ["", ""] call BIS_fnc_selectRandom;
	if (_animationToPlay != "") then 
	{
		_startAnimTime = time;
		_player playMove _animationToPlay;
		waitUntil {animationState _player != _animationToPlay};
	}
	else
	{
		_player playAction "Crouch";
	};
									
	_searchtime = 3;
	_searchradius = 1.5;
	_searchPos = getPosATL _player;
	_playerInSearchArea = [_player, _searchPos, _searchradius] spawn 
	{
		params["_player", "_searchPos", "_searchradius"]; 
		waitUntil 
		{ 
			_player distanceSqr _searchPos >  ( _searchradius^2 ) 
		} 
	};
	for "_sleep" from _searchtime to 0 step -0.01 do 
	{
		sleep 0.01;
		if (scriptDone _playerInSearchArea) exitWith {};
	};
		if (scriptDone _playerInSearchArea) exitWith {};
		terminate _playerInSearchArea;
};

 

Edited by [RG] Salutesh

Share this post


Link to post
Share on other sites

I am confused.

How exactly has the script to look and to be started now, with all the new things added?

To not only search trees for fruits, but for trashpiles and stuff too.

Do i have to download the original like Salutesh said and just change the original LARs_lootSettings.sqf to LordRampants LARs_lootSettings.sqf? And don´t call the fn_initSearch.sqf in the initPlayerLocal.sqf?

Or do i have to to install it like said in the original post, but add

class CfgFunctions
{
	#include "LARs\LARs_searchLoot\functions.cpp"
};

to the description.ext, like Kurewe said? And what is with the missing UI stuff then?

I am completely confused now, could one please give us a final step by step description of how to add what exactly, and how and where to call it etc?

With all the newer tweaks from page 2 to page 4 in it.

PLEASE

  • Like 1

Share this post


Link to post
Share on other sites

For that apple tree thing, are there any apple trees on Tanoa?

We searched for hours now to test the script, but no apple trees.

And how is the classname of the banana trees/palms/plants. I don´t use Infistar and i couldn´t find any classnames of trees.

Thanks

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.