Jump to content
fuzi8n

How to make a unit pick up an object and take it [Ex: a Harddrive]

Recommended Posts

I have downloaded the A.R.P. mod for ArmA III to give the game a little more realism. However, if I release my mission, I want the player to be able to go around the camp looking for the harddrives... but being able to pick them up. Is there any script or something that I can put in the objects init line so I can make the player be able to pick it up? :confused:

Share this post


Link to post
Share on other sites

Read: http://community.bistudio.com/wiki/addAction

Create logic object somewhere are add this to init line:

pickedUpCount = 0;
pickup_code = {
deleteVehicle (_this select 0);
pickedUpCount = pickedUpCount + 1;
hint format ["Picked up object. Now I have %1", pickedUpCount];
};

pickedUpCount is variable that holds number of taken objects

pickup_code is variable that holds code that executes when you activate pick up action

Init line of objects you want to be able to pick up:

this addAction ["Pick up", pickup_code];

Share this post


Link to post
Share on other sites

I made the logic object and put the code in it's init line, and then I put the other code in the harddrives init line. I get the option to pick it up when I look at it and when I click it, the harddrive is still there and not in my inventory. Is there any way to get it in my inventory or delete it after I pick it up?

Share this post


Link to post
Share on other sites
I made the logic object and put the code in it's init line, and then I put the other code in the harddrives init line. I get the option to pick it up when I look at it and when I click it, the harddrive is still there and not in my inventory. Is there any way to get it in my inventory or delete it after I pick it up?

Its impossible to put vehicles (objects) into inventory, you can only simulate having some object through scripting. (or make an addon that create an actual item that you can put into inventory).

Probably reason why it doesn't work is order of initialization. Try this instead:

this addAction ["Pick up", {call pickup_code}]; 

Share this post


Link to post
Share on other sites

thank you so much, it works pretty much just like I wanted!

Share this post


Link to post
Share on other sites

Hi guys,

i´m new with the MAP EDITOR. My target is the bluefor unit arrived on the coast unarmed, undressed etc.......I want to place irems like maps, weapons etc in houses.

So i´ve done the same as indicated .Example: CLASS= OBJECT (small) UNIT=MAP OF STRATIS (OPEN) and in the init:

 pickup_code = {deleteVehicle (_this select 0);pickedUpCount = pickedUpCount + 1;hint format ["Picked up object. Now I have %1", pickedUpCount];  };this addAction ["Pick up", pickup_code];

So when i get close to the map on the ground , i can see the action "pick up" ,i click on it , i can see a massage "picked up object , now i have any" but nothing once i check in the inventory i don´t see it and nothing happend when i click on "M".

Where is my mistake ?

In advance thanks.

Share this post


Link to post
Share on other sites

There are no non military inventory items in ArmA3 at this point. The Object Small things, while seeming to be something you could pick up and put in a pocket, are just world objects and can't go in inventory.

If you wanted to pretend to open a map you'd do this:

this addAction["Pick up map", {deleteVehicle (_this select 0); player linkItem "ItemMap"; hint "I now have a map!"}];

Share this post


Link to post
Share on other sites

Thank you Sear ;)

it works perfectly ;)

Regarding the basics object like the map .Do you know why even if you put this:

removeallweapons this; removeallitems this; removeheadgear this; removevest this; this unassignItem "NVGoggles"; this removeitem "NVGoggles"; removeBackpack this;

into the init player, he stills with a watch , a map, a compass and radio in the inventory?

ps: maybe i should open an other thread to ask for this ?

Sorry , i´ve found out :

this unassignItem "ItemMap"; this removeitem "ItemMap"

etc.......Link for names items : http://browser.six-projects.net/cfg_weapons/classlist?utf8=%E2%9C%93&version=67&commit=Change&options%5Bgroup_by%5D=cfg_faction_classes&options%5Bcustom_type%5D=Item&options%5Bfaction%5D=Default

Edited by Phil671

Share this post


Link to post
Share on other sites

To strip a player just use:

removeAllWeapons this;
removeAllContainers this;
removeAllAssignedItems this;

Share this post


Link to post
Share on other sites

One more little question.

I´ve done the same for the radio, GPS, compass, watch: remove and unassign.

To pick it up on the ground as you say , i understand .

But i don´t find in CLASS=Objet (small): the watch, compass, GPS and the radio (radio, yes there is one call: portable long-range radio, but it does´nt look as the "original" one ...it Doesn´t matter).

Any trick to add this objets on the ground ?

---------- Post added at 22:48 ---------- Previous post was at 22:47 ----------

To strip a player just use:

removeAllWeapons this;
removeAllContainers this;
removeAllAssignedItems this;

Okay , good to know ....One more time , thank you ;)

Share this post


Link to post
Share on other sites

To put an inventory item on the ground you'd need to script it by spawning a weapon holder.

Place a GameLogic where you want the item to be and put this in it's init field:

_radio = this spawn {radioHolder = createVehicle ["groundWeaponHolder", getPos _this, [], 0, "can_collide"]; 
radioHolder addItemCargo ["ItemRadio", 1]};

If you do this you don't need the addAction at all, the player would be able to pick up the item since it's an inventory.

Share this post


Link to post
Share on other sites

Hi kylania,

thanks for your precious help.One more time everything works perfectly ;)

If i want to do the same with , let´s say with the compass , i should make it like this:

_compass = this spawn {compassHolder = createVehicle ["groundWeaponHolder", getPos _this, [], 0, "can_collide"]; 
radioHolder addItemCargo ["ItemCompass", 1]};

Correct or not?

---------- Post added at 06:04 ---------- Previous post was at 05:57 ----------

Yes correct works fine ;)

Share this post


Link to post
Share on other sites

Hello kylania,

Would you consider putting little treasure gems like this on your home page as archived scripting information?

I'd rather go straight to your page and get the answers there which is much more quicker than doing a search here (although of course I do enjoy this editing forums).

You've helped out a lot of people all over this forum. If only it could all be accumulated in one area (your home page).

Share this post


Link to post
Share on other sites

Greetings, I'm wanting to place small intel items that can be picked up and placed into the players backpack. I'm fairly noobish at scripting but I've tried a few things but I can't figure out how to get this to work. Any help would be appreciated.

Share this post


Link to post
Share on other sites

Hi, I'm trying to find something similar to Fuzi8n's question. Lets say there is a bucket of food, now i want an addaction to pick it up (or a gear menu) and when he picks it up it will be in the inventory, now how would I put an inventory pic of it and a name?

Share this post


Link to post
Share on other sites

I use this thread instead of creating a new one.

In a mission that I am creating one of the tasks is to steal a document.

My question is: how can I script it so that once I pick up the document, I complete the task? I have tried to place the 'task completed'-script inside the documents but nothing happens when I pick it up.

Share this post


Link to post
Share on other sites

Thank you!

[objNull, ObjNull, tskEvidence1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

did not work, its only for ARMA 2 I think, but I replaced that code with the regular arma-3 complete mission script and it fired properly. It worked.

Share this post


Link to post
Share on other sites

Hey,

Thanks for all the help thus far. I have been able to get the weapon on the ground where I want it, and I got the AI to literally walk to it and stand on top of it. now I can't get him to pick it up. I tried changing the addAction to {call "pickup_code";} but the weapon disappears. when I remove the {}, it returns to the original spawn position.

I got the AI to the weapon, is there another way to get him to pick it up?

Share this post


Link to post
Share on other sites
Thank you!

[objNull, ObjNull, tskEvidence1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

did not work, its only for ARMA 2 I think, but I replaced that code with the regular arma-3 complete mission script and it fired properly. It worked.

For Arma 3:

['task1','succeeded'] call bis_fnc_tasksetstate;

Share this post


Link to post
Share on other sites
On 2-10-2013 at 0:58 AM, kylania said:

To put an inventory item on the ground you'd need to script it by spawning a weapon holder.

Place a GameLogic where you want the item to be and put this in it's init field:

 


_radio = this spawn {radioHolder = createVehicle ["groundWeaponHolder", getPos _this, [], 0, "can_collide"]; 
radioHolder addItemCargo ["ItemRadio", 1]};
 

 

If you do this you don't need the addAction at all, the player would be able to pick up the item since it's an inventory.

 

Kylania, could you explain to me how to use this code to be able to pick up mobile phones etc.?

 

We are currently working on a mission where people have to pick up multiple different items at different locations and this code seems to be what we are looking for, but we don't know how to change it.

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

×