Jump to content
Sign in to follow this  
BennetArms

[Release] Bens Drag&Drop

Recommended Posts

Thanks for the update Bennet. So no word on when it'll be possible to make it compatible with items dropped into the mission via Zeus?

Share this post


Link to post
Share on other sites
Thanks for the update Bennet. So no word on when it'll be possible to make it compatible with items dropped into the mission via Zeus?

SpectreRSG I'll be completely honest with you :D I never did a loop of a script. One way to do this manually would be to run the

0 = execVM "greifer.sqf";

again when needed. I have to teach myself about "while" and stuff. Then i maybe able to loop this script every 60 secs or so.

If you or somebody else comes up with a simple solution for this in the meantime, i will be glad to have it added then. =)

Share this post


Link to post
Share on other sites

Running 0 = execVM "greifer.sqf"; in a live mission doesnt do the job. :/

Share this post


Link to post
Share on other sites

It shouldn't be too difficult to get going with Zues, it just needs the action adding to the Zeus created objects.

place the next line in the Zeus modules Init box

this addEventHandler ["CuratorObjectPlaced",{_this execvm "BDD\Add_Z_act.sqf"}];

save as "BDD\Add_Z_act.sqf"

// place the next line in the Zeus modules Init box
//this addEventHandler ["CuratorObjectPlaced",{_this execvm "BDD\Add_Z_act.sqf"}];


// array of Items that can be dragged 
_candrag = [
"Box_IND_Ammo_F","Land_MetalBarrel_F","Land_WaterTank_F","Land_WaterBarrel_F","BWA3_Box_Gear","WL_GER_Back_Box_Flecktarn","TF_NATO_Radio_Crate","B_supplyCrate_F","IG_supplyCrate_F","O_supplyCrate_F","I_supplyCrate_F","B_Mortar_01_F","B_HMG_01_F","B_HMG_01_high_F","B_HMG_01_A_F","B_GMG_01_F","B_GMG_01_high_F","B_GMG_01_A_F","B_static_AA_F","B_static_AT_F","B_G_Mortar_01_F","O_Mortar_01_F","O_HMG_01_F","O_HMG_01_high_F","O_HMG_01_A_F","O_GMG_01_F","O_GMG_01_high_F","O_GMG_01_A_F","O_static_AA_F","O_static_AT_F","O_G_Mortar_01_F","I_G_Mortar_01_F","I_Mortar_01_F","I_GMG_01_A_F","I_static_AT_F","I_static_AA_F","I_HMG_01_A_F","I_HMG_01_high_F","I_HMG_01_F","Land_BarrelEmpty_F", "Land_BarrelSand_F", "Land_BarrelTrash_F", "Land_BarrelWater_F", "Land_MetalBarrel_F","Box_NATO_Wps_F", "Box_East_Wps_F", "Box_IND_Wps_F", "Box_East_WpsLaunch_F", "Box_NATO_WpsLaunch_F", "Box_IND_WpsLaunch_F", "Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","Box_NATO_WpsSpecial_F","BWA3_Box_Gear","WL_GER_Back_Box_Flecktarn","TF_NATO_Radio_Crate","BWA3_Box_Weapons","BWA3_Box_Attachments","BWA3_Box_Ammo","Box_NATO_AmmoOrd_F", "Box_East_AmmoOrd_F", "Box_IND_AmmoOrd_F", "Box_NATO_Grenades_F", "Box_East_Grenades_F", "Box_IND_Grenades_F", "Box_NATO_Ammo_F", "Box_East_Ammo_F", "Box_IND_Ammo_F", "Box_IND_Support_F", "Box_East_Support_F", "Box_NATO_Support_F","Land_CargoBox_V1_F","x39_medicBox","Land_Pallet_MilBoxes_F","Land_PaperBox_closed_F","Land_PaperBox_open_empty_F","Land_PaperBox_open_full_F","Box_NATO_AmmoVeh_F","Box_East_AmmoVeh_F","Box_Ind_AmmoVeh_F","Land_MetalBarrel_empty_F","MetalBarrel_burning_F","Land_BarrelSand_grey_F","Land_BarrelWater_grey_F","Land_BarrelWater_F","Land_BarrelTrash_grey_F","Land_BarrelTrash_F"
];


if (typeof (_this select 1) in _candrag)  then {
(_this select 1)   addAction ["<t color=""#FFAD1F"" size='2.5' shadow='2'>" +"Drag","BDD\ziehen.sqf", "", 1,true, true, "", "!attached and player distance _target<2 and (_target getvariable ['nodrag',true])"];
};

Share this post


Link to post
Share on other sites

That worked, thanks F2k!

Edit: question for ya F2k.

If I have an object with an addaction that is a Hesco barrier spawner that runs the following sqf: _hesco = "Land_HBarrierBig_F" createVehicle (getMarkerPos "hesco");

How could I apply that to initialize with his script? I want people to spawn a barrier and be able to move it.

Edited by SpectreRSG

Share this post


Link to post
Share on other sites

It depends on the way you spawn it. If you are calling it via script you can easily do an addaction to the spawned hesco.

 _this addAction ["<t color=""#FFAD1F"" size='2.5' shadow='2'>" +"Drag","BDD\ziehen.sqf", "", 1,true, true, "", "!attached and player distance _target<2 and (_target getvariable ['nodrag',true])"];

Share this post


Link to post
Share on other sites

Well, there's an addaction on an object that calls up my sqf that just has this in it:

_hesco = "Land_HBarrierBig_F" createVehicle (getMarkerPos "hesco");

It just creates a Hesco barrier at the hesco marker. Nothing fancy or complex. Are you saying I just add what you put there in the code box underneath the _hesco string?

Share this post


Link to post
Share on other sites

underneath but change the name

_hesco addAction ["<t color=""#FFAD1F"" size='2.5' shadow='2'>" +"Drag","BDD\ziehen.sqf", "", 1,true, true, "", "!attached and player distance _target<2 and (_target getvariable ['nodrag',true])"];

Share this post


Link to post
Share on other sites

For some reason when I do what you stated, F2k, which worked by the way (thank you), I dont get the option to load it into the igiLoad vehicles. Any clue whats happening?

Share this post


Link to post
Share on other sites

Sorry I don't know what that is,another mod?

Maybe you need to drop it next to the vehicle, if it has it's own set of actions they may show.

Share this post


Link to post
Share on other sites

Yeah it was the igiload script not BDD. Had to add the objects to that too apparently.

Share this post


Link to post
Share on other sites

Hey guys...

I dont know wat´s going on wiht this amazing script either.... Like the igLoad script since the new arma 3 update the script doesnt work. Do you know why?

Share this post


Link to post
Share on other sites

Why is it you have to be holding a Rifle to Drag/Move a item ?

I've tried to drag a item with a handgun and also no gun in my hand...With the result of me just grabbing or dropping the item but not being able to Drag or Move the item ..?

Edited by Longboat

Share this post


Link to post
Share on other sites

I know this thread is a bit old, but I found it a good starting point to begin fiddling with drag/drop myself, as I had a need to make IgiLoad more accessible this way as well.

Problems I had with the script offered:

  • By default the script initializes only one time at the start, so any ammo boxes added dynamically during the game (via Zeus or any other spawn-in method) will not be draggable.
  • The script uses a fixed array of ammo crates. Which can be desirable, but I prefer adding it to all ammo crates dynamically. This has the benefit that it'll support all ammoboxes added by mods and addons you use.

So I changed the Greifer.sqf to

waitUntil { !(isNull player) };
waitUntil { time > 0 };

attached = false;
//Klassennamen der ziehbaren Objekte//Classnames of draggable objects 
private ["_ammo_classsnames", "_cfgvehicles", "_gueter"];
_gueter = [];
// Add any additional objects you want to be movable to "_ammo_classnames".
_ammo_classnames = ["Land_Pallet_MilBoxes_F","Land_PaperBox_closed_F","Land_PaperBox_open_empty_F","Land_PaperBox_open_full_F", "Land_MetalBarrel_empty_F","MetalBarrel_burning_F","Land_BarrelSand_grey_F","Land_BarrelWater_grey_F","Land_BarrelWater_F","Land_BarrelTrash_grey_F","Land_BarrelTrash_F"];

// Now we iterate over the entire cfgVehicles to find all ammoboxes there are. Big plus: This also checks for all addon-ammoboxes that you might use.
_cfgvehicles = configFile >> "cfgVehicles";
for "_i" from 0 to (count _cfgvehicles)-1 do {
_vehicle = _cfgvehicles select _i;
if (isClass _vehicle) then { // Sanity check
	private["_classname", "_vehicleclass"];
	_classname = configName(_vehicle); // Ammo box classname
	_vehicleclass = getText(_cfgvehicles >> _classname >> "vehicleClass"); // All ammo boxes have the "vehicleClass" == "Ammo"
	if (_vehicleclass == "Ammo") then {
		_ammo_classnames set [count _ammo_classnames, _classname];
	}
};
};


while {true} do {
/*
	We use a loop that checks for any valid draggable objects nearby every two seconds. Those get the "drag" option attached, while all objects that are now out of range will have theirs removed.
	TODO: Currently, the drag action gets removed for all objects, then added again for those nearby. A nicer solution would be to only remove it from those objects that have moved "out of range" since the last check.

*/
{
	private "_actionid";
	_actionid = _x getVariable "BDD_actionid";
	if (!isNil "_actionid") then {
		_x removeAction _actionid;
		_x setVariable ["BDD_actionid", nil];
	};
} foreach _gueter;
_gueter = nearestobjects [getpos player,_ammo_classnames,5] ; // The last number is the distance of objects to add the action to. The larger, the more CPU-demanding this gets (can cause lag).

{
	_bdd = _x  addAction ["<t color=""#FFAD1F"" size='1'>" +"Drag", "BDD\ziehen.sqf", "", 1,true, true, "", "!attached and player distance _target<2 and (_target getvariable ['nodrag',true])"]; // Only objects closer than 2m will be draggable.
	_x setVariable ["BDD_actionid", _bdd]; // This variable stores the action index of the "drag" action. Which we need so we know which action to remove later.
} foreach _gueter;

sleep 2;
};

hintSilent "BDD - Bens Drag&Drop initialisiert.";

It's not perfect, but maybe some of you find it useful.

I changed the action entry to no longer be "oversize" as well. The drop action however still is oversize, unless you edit the following line in the ziehen.sqf:

actionId = _spieler addAction ["<t color=""#FFAD1F"" size='1'>" +"Drop", "BDD\loslassen.sqf", [], 99, true, true, "", "(attached && (_target == _this))"];

Gathering ammoboxes dynamically from the config is nice in general, but it has the disadvantage that it might support ammoboxes that should not be draggable (e.g. if a mod adds a shipping container size ammo box for some reason). A "size constraint" could be added by checking the bounding box of each object. This way, all objects above a certain total size (width*height*length) would not be draggable. See KK's bounding box info for a hint on how to do that.

I reprocued the bug Longboat decribes (not being able to move while dragging an object when no primary/secondary/hand weapon is used), but have not found a fix yet.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×