Jump to content

Recommended Posts

Hey

I would like to make pickpocket skill for my RPG but don't know if this is possible?

 

I tried the createGearDialog command to view AI's inventory but to no avail.

 

thx!

Share this post


Link to post
Share on other sites
29 minutes ago, gc8 said:

Hey

I would like to make pickpocket skill for my RPG but don't know if this is possible?

 

I tried the createGearDialog command to view AI's inventory but to no avail.

 

thx!

The answer is right on the wiki, simply use the action instead:

player action ["Gear", enemyUnit];

You have to be within 5m of the unit so the inventory stays open.

 

Cheers

Share this post


Link to post
Share on other sites

@Grumpy Old Man thanks I did try that too but don't know why it didn't work. But now it works...

 

is there a event handler to check when item is being taken from the inventory?

 

Share this post


Link to post
Share on other sites
5 minutes ago, gc8 said:

@Grumpy Old Man thanks I did try that too but don't know why it didn't work. But now it works...

 

is there a event handler to check when item is being taken from the inventory?

 

Sure, take EH:

 

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

 

3 minutes ago, Grumpy Old Man said:

Sure, take EH:

 

Thanks a lot. I don't know why this stuff doesn't catch my eye when browsing the wiki :)

 

My last question though, is there a way to cancel the take?

 

maybe I just use additem to add the item back to AIs inventory but that doesn't seem to be so easy solution for previously equipped guns etc.

 

  • Like 1

Share this post


Link to post
Share on other sites

How about saving the loadout with getUnitLoadout when pickpocketing starts and when canceling the take restore it with setUnitLoadout?

Share this post


Link to post
Share on other sites

@7erra that's a nice idea thanks! But I was thinking that I will always let the player take the item but then I make a check if the AI noticed this. Problem is take command uses class name of the item so I don't seem to have a way to detect where the player took the item from. Was it weapon from weapon slot or some item from backpack. I need this functionality so that if player grabs the weapon of AI the AI will always notice this. So that player can only try to take unequipped items.

Share this post


Link to post
Share on other sites

Nevermind I figured a way to do this by taking a snapshot of the inventory when player opens it and then comparing to another snapshot in the take event.

Share this post


Link to post
Share on other sites

If you want to check if the item is equipped you can use the second param of the "Take" EH. If the container is a unit it will is assigned:

// action to open unit's inventory
_this addAction ["Pickpocket",{
	params ["_target","_caller","_id","_args"];
	_caller action ["Gear",_target];
}];

// take eh
player addEventHandler ["Take",{
	params ["_unit", "_container", "_item"];
	if (_container isKindOf "Man") then {
		systemChat "noticed";
	}
}];

 

2 minutes ago, gc8 said:

Nevermind

Well I tried to find a solution over the last half an hour so I'm posting this anyway :don15:

Share this post


Link to post
Share on other sites
7 minutes ago, 7erra said:

If you want to check if the item is equipped you can use the second param of the "Take" EH. If the container is a unit it will is assigned:


// action to open unit's inventory
_this addAction ["Pickpocket",{
	params ["_target","_caller","_id","_args"];
	_caller action ["Gear",_target];
}];

// take eh
player addEventHandler ["Take",{
	params ["_unit", "_container", "_item"];
	if (_container isKindOf "Man") then {
		systemChat "noticed";
	}
}];

 

Well I tried to find a solution over the last half an hour so I'm posting this anyway :don15:

 

Sorry I don't quite follow. I don't know how isKindOf helps here.

 

thx though!

Share this post


Link to post
Share on other sites

When you are opening the inventory with the addAction you will see the inventory of the unit. When you now take something out of the units inventory the container will depend on where you got the item from. If it was directly on the unit it will return the unit (object). If it was taken from the uniform it will return the uniform (object, but not typeOf "Man"). Same goes for the backpack and vest.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
33 minutes ago, 7erra said:

When you are opening the inventory with the addAction you will see the inventory of the unit. When you now take something out of the units inventory the container will depend on where you got the item from. If it was directly on the unit it will return the unit (object). If it was taken from the uniform it will return the uniform (object, but not typeOf "Man"). Same goes for the backpack and vest.

 

That's really cool, I didn't know that. thanks! :)

 

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

×