Jump to content
Sign in to follow this  
cigar0

[Script] Drag & Drop System

Recommended Posts

Drag&Drop System

---------------------------------------

dragdrop3cnk4exq3azkl0shj_thumb.jpg

---------------------------------------

v 0.2

Multiplayer: Yes

by [TSS] Cigar0

Download ExampleMission

You should drag bigger objects.

http://img5.fotos-hochladen.net/uploads/201403160000nd4bm72v6f.jpg

http://img5.fotos-hochladen.net/uploads/201403160000823rb0tzx1.jpg

http://img5.fotos-hochladen.net/uploads/2014031600006cjnsazf38.jpg

http://img5.fotos-hochladen.net/uploads/201403160000e04zxf2yod.jpg

http://img5.fotos-hochladen.net/uploads/2014031600000hx1qf7yzs.jpg

You can see, it works together with igiLoad ;-) That the goal.

Small Objects will be attached on the back. Its possible to edit every position of all small carryable objects.

http://img5.fotos-hochladen.net/uploads/201403160000jeui2yto0k.jpg

http://img5.fotos-hochladen.net/uploads/201403160000ce0d9ji7zo.jpg

http://img5.fotos-hochladen.net/uploads/2014031600002d854kt63h.jpg

http://img5.fotos-hochladen.net/uploads/201403160000ew08f3no1k.jpg

Install:

1)

Place a object on the map, best way is to place a object that supports igiLoad:

By example: Box_NATO_Ammo_F

Objectname: Chest1

2)

Write this in the init of the object:

clearMagazineCargo this;

Take1 = Chest1 addAction ["Drag","Objects\Attach_big.sqf",[],1,true,true,"","_this distance _target < 2"];

You see, we will performe a addaction on this object with the Text "Drag". Its also possible to put a Icon instead of the Text:

"<img image='Take.jpg' size='4.8' shadow=1 />"

3) create a folder "Objects" in you missionfolder.

4) Now we need a sqf file, called "Attach_big.sqf"

Attach_big.sqf:

player playAction "grabDrag";

Sleep (0.01);

waitUntil { ((AnimationState player) == "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2") || ((AnimationState player) == "AmovPercMstpSnonWnonDnon_AcinPknlMwlkSnonWnonDb_2")};

Chest1 attachTo [player, [0,1.0,0.3]];

player playMove "AcinPknlMwlkSrasWrflDb";

obj1attached=true;

PublicVariable "obj1attached";

Drop1 = player addAction ["<t color=""#930909"">" +"Drop</t>","Objects\Detach_big.sqf",[],1,true,true,"","obj1attached"];

while {obj1attached} do {

[] spawn {

{Player removeaction Take1} forEach allUnits;

};

};

5)

"Detach_big.sqf":

[] spawn {

{Player removeaction Drop1} forEach allUnits;

};

detach Chest1;

Chest1 setpos [getpos Chest1 select 0,getpos Chest1 select 1,0];

sleep 0.5;

obj1detached2=true;

PublicVariable "obj1detached2";

sleep 0.5;

player playMoveNow "AmovPknlMstpSrasWrflDnon";

---------------------------------------

---------------------------------------

---------------------------------------

Attach_small.sqf:

player playAction "PutDown";

Sleep (0.01);

waitUntil { ((AnimationState player) == "AinvPercMstpSrasWrflDnon_Putdown_AmovPercMstpSrasWrflDnon")};

RoadCone1 attachTo [player, [-0.15,-0.15,0.15],"Pelvis"];

RoadCone1 setVectorDirAndUp [[0.5,0.5,0],[-0.5,0.5,0]];

obj1attached=true;

PublicVariable "obj1attached";

Drop2 = player addAction ["<t color=""#930909"">" +"Ablegen</t>","Objects\Detach_small.sqf",[],1,true,true,"","obj1attached"];

while {obj1attached} do {

[] spawn {

{Player removeaction Take2} forEach allUnits;

};

};

Detach_small.sqf

[] spawn {

{Player removeaction Drop2} forEach allUnits;

};

player playMove "AinvPercMstpSrasWrflDnon_Putdown_AmovPercMstpSrasWrflDnon";

detach RoadCone1;

RoadCone1 setpos (player modelToWorld [0,1,0]);

sleep 0.5;

obj1detached=true;

PublicVariable "obj1detached";

sleep 0.5;

---------------------------------------

---------------------------------------

---------------------------------------

changelog 0.2

- added statusicons in the left cornor (dragging, carrying)

- small codechanges

---------------------------------------

---------------------------------------

---------------------------------------

Okay, now a question.

I'am busy and someone with the possibility of scripting could do something very good.

We need to implement the whole script in one init.sqf.

We need to activate the classnames with addaction.

Othervise you see:

You need to create 2 sqf file for one object. If you try to do this for 10 Objects, we need 20 sqf files.

We need a better way to do this.

If you like this idea, you will find maybe good information on this site:

TSS Forum

Its in german, i know ;-)

Edited by Cigar0
  • Like 1

Share this post


Link to post
Share on other sites

that is a really cool idea have to test it out.

is that working with the lifter addon and igi load together ?

Share this post


Link to post
Share on other sites

Only viewing on my phone. Not the best layout.

You will need to have an array of the objects that can be carried and the in conjunction with cursortarget ands in the addaction condition check if cursortarget in array

Will have a good look later and see what I can think of

Share this post


Link to post
Share on other sites

Thank you for helping.

As I said, i'am busy at the moment, so i will try to do something for this script in the next weeks.

But if someone will find a better way, it will help the community for every logistic mission. ;-)

And also it could help igiLoad for just putting both Script together.

Share this post


Link to post
Share on other sites

Ok, updatet post 1 + downloadlink and changelog 0.2

Share this post


Link to post
Share on other sites
Guest

New version frontpaged on the Armaholic homepage.

==================================================

You are not registered on Armaholic, or at least not that we are aware of. In the future we offer the possibility to authors to maintain their own pages.

If you wish to be able to do this as well please register on Armaholic and let me know about it.

This is not mandatory at all! Only if you wish to control your own content you are welcome to join, otherwise we will continue to follow your work like we have always done ;)

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Ok, I am not a great scripter but here is an idea to lose all of the extra scripts... addAction is already passing all of the info you need under the hood. Cant you just do this for your drag and drops scripts? Please note that I am writing this without testing it. You can rinse and repeat for the addSmall.sqf and detachSmall.sqf scripts. To make it even more automatted, all you need to do is have a script at launch that loops through all objects and compares there class name against a list, if true, then add the addaction to it.

new attachBig.sqf

_crate = _this select 0;  //  addaction is passing you the target of the action
_addId = _this select 2; //  addaction is passing you its own ID.

player playAction "grabDrag";
Sleep (0.01);
waitUntil { ((AnimationState player) == "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2 ") || ((AnimationState player) == "AmovPercMstpSnonWnonDnon_AcinPknlMwlkSnonWnonDb_2 ")};
_crate attachTo [player, [0,1.0,0.3]];
player playMove "AcinPknlMwlkSrasWrflDb";

obj1attached=true;
PublicVariable "obj1attached";

Drop1 = player addAction ["<t color=""#930909"">" +"Drop</t>","Objects\Detach_big.sqf",[],1,true,true,"","obj1attached"];

while {obj1attached} do {
[] spawn {
{Player removeaction _addId} forEach allUnits;
};
};

new detachBig.sqf

_crate = _this select 0;  //  addaction is passing you the target of the action
_dropId = _this select 2; //  addaction is passing you its own ID.

[] spawn {
{Player removeaction _dropId} forEach allUnits;
};
detach _crate;
_crate setpos [getpos _crate select 0,getpos _crate select 1,0];

sleep 0.5;

obj1detached2=true;
PublicVariable "obj1detached2";

sleep 0.5;

player playMoveNow "AmovPknlMstpSrasWrflDnon"; 

DasClark

ps - if there is something obvious I am missing, please be gentle...

Share this post


Link to post
Share on other sites

Ok i know what you mean and will search for a way but this is not working like this.

But thanks for the way. Maybe we will find a solution.

The other idea, with the list of classnames is also interesting.

Share this post


Link to post
Share on other sites

What about getting this to work when objects are spawned ingame? Example, in BECTI supply boxes and vehicle ammo crates are all purchased and spawned in by the server. How would this work with that?

Share this post


Link to post
Share on other sites

Thanks Cigar0, this is very useful and adds realism. I have my own scripts for putting barrels on the back of a truck (without your cool animations), and found that I need to restrict the cargo positions, otherwise units will board the truck and then overlap/clip with attached objects. I hardcoded a solution for my particular case.

I don't know if you care to take this on, but calculating and locking/unlocking cargo positions occupied by attached objects would be awesome. No worries if you don't--mission makers would have to do this on their own if they want to prevent cargo clipping.

Another thing to note is there is a game limitation where objects attached to the back of a truck look perfect while player not in truck. But if player boards truck, the attached objects appear to be outside of the truck. It looks terrible in that case. I concluded that I would always prevent the player from getting in a cargo position of a truck that has attached objects.

Share this post


Link to post
Share on other sites

This is only possible if i try to connect the classnames with the drag & drop script.

I'am busy, so there is no new version, but in the future i will try for sure.

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  

×