Jump to content
Sign in to follow this  
CaptainBravo

how to get AI to pick an item?

Recommended Posts

Hey everyone,

I was wondering how to get AI to pick an item and walkaway with it? like a suitecaase or notebook?

Thanks in advance for your help.

Share this post


Link to post
Share on other sites

deleteVehicle object;

:)

Maybe a doMove to the object, which won't be exact. Then a crouching animation perhaps, delete the item, then move away again.

Share this post


Link to post
Share on other sites

Thanks kylania. The only thing is I need the object to be intact as player will try to intercept and kill AI later to take the item from him.

Share this post


Link to post
Share on other sites

Then you'd create the item again for the user, either via an addAction of "Take the case" and use variables to keep track of where it is or if it's an actual item that they need to loot from a dead AI body, then use:

this addWeapon "Evkobalt";

To give the item to the AI. Might as well do that from the start, since you won't actually see the AI pick it up and have it displayed on their person. The list of items you can add to the inventory is found here.

Share this post


Link to post
Share on other sites

Thanks kylania, that should resolve the issue. How to you get a trigger to recognize the item you just picked up? so if you pick it up and take it back to base you win.

The mission is about 2 competing players groups intercepting an AI to take a certain item back to their own base.

Edited by CaptainBravo

Share this post


Link to post
Share on other sites

Trigger condition of:

this && (player hasWeapon "Evkobalt")

Note too that most of these little objects are ArmA2 content.

Share this post


Link to post
Share on other sites

works smoothly kylania, thanks!

Last related question, is it possible to get marker to follow item? I know how to do it with an item I named in editor, but since this was added as a weapon, I am not sure how to track it marker since it has no name?

Share this post


Link to post
Share on other sites

Got a proof of concept working for that using variables, trying to get it working with objects now too. Not sure quite the best way to handle what happens when you drop the item, but picking it up and the marker following that works.

Share this post


Link to post
Share on other sites

I have a mission where marker follows an item (placed in editor) if that helps I can post later this weekend.

Share this post


Link to post
Share on other sites
I have a mission where marker follows an item (placed in editor) if that helps I can post later this weekend.

That's basically what I did. Place it in the editor, assign a variable to the object then follow the variable with the marker. To "pickup" the item you addAction it, change the publicvariable to who has it, destroy the in game, give it as an item to the person that picked it up and go on.

The only problem is what to do when someone drops the item, not sure how to track that. I'm guessing a nearObject search kind of thing, but not sure.

Share this post


Link to post
Share on other sites

kylania checkout script below, it might help with the marker issue.

Marker follows item be it carried by a unit or droped on ground.

Hope it helps.

//// Local only

if (!local player) exitWith {};

/// spawn

[] spawn {

//// Create marker

_Marker = createMarkerLocal["suitcasemarker",(getPos suitcase)];

_Marker setMarkerShapeLocal "ICON";

_Marker setMarkerTypeLocal "DOT";

_Marker setMarkerTextLocal "suitcase position";

//// Attach marker

while {alive suitcase} do {

_Marker setMarkerPosLocal (getPos suitcase);

sleep 3;

};

};

// init field of a briefcase: this addAction ["Take case","case.sqf","take"]; caseholder = objNull

// trigger to check if case carrier is in an area/trigger, activation: any/side of the carrier, condition: caseholder in thislist

_o = _this select 0;

_p = _this select 1;

switch (_this select 3) do {

case "take": {

caseholder = _p;

publicvariable "caseholder";

deletevehicle _o;

_id = _p addaction ["Drop case","case.sqf","drop"];

if (isnil "markerCase") then {

_m = createmarker ["markerCase",getpos _p];

_m setmarkershape "icon";

_m setmarkertype "dot";

_m setmarkercolor "colororange";

};

while {sleep 3; alive _p && caseholder == _p} do {

"markerCase" setmarkerpos getpos _p;

};

_p removeaction _id;

_o = "Suitcase" createvehicle [1,1,1];

_o setposasl getposasl _p;

_o setvehicleinit "this addaction [""Take case"",""case.sqf"",""take""]";

_o setvehicleinit "player reveal this";

processInitCommands;

};

case "drop": {

_p removeaction (_this select 2);

caseholder = objnull;

publicvariable "caseholder";

};

Share this post


Link to post
Share on other sites

Ahh, yeah, that's pretty much exactly what I had, it just deletes the item and keeps track of it using a variable. I was actually using a physical item in inventory so the player could see it which made it quite a bit more difficult. :)

Share this post


Link to post
Share on other sites

the one you are wokring on would be the ideal and I know it is more challanging.

Did you manage to get it working?

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  

×