Steal something from another player

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
AlexMax
Forum Regular
Posts: 244
Joined: Tue May 29, 2012 10:14 pm
Contact:

Steal something from another player

#1

Post by AlexMax » Sat Oct 01, 2016 4:34 pm

This is an XY question, but I'm pretty sure if I can figure this out, the rest will follow.

Is it possible to "steal" something from the inventory of another player? For example, I would like to walk up to another player, interact with them somehow (either by pressing USE or by using a custom fist weapon) and by doing so take an inventory item out of their inventory and put it in my own.

+USESPECIAL tests on CustomInventory objects allows me to drop into an ACS_Execute on Use, but I don't know how to know who both the mark and the thief are. Using an ACS_Execute with a custom weapon has a similar problem.
The only limit to my freedom is the inevitable closure of the
universe, as inevitable as your own last breath. And yet,
there remains time to create, to create, and escape.

Escape will make me God.

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

Re: Steal something from another player

#2

Post by ZZYZX » Sat Oct 01, 2016 4:40 pm

The thief is activator. The target player is either AAPTR_TARGET of the activator or can be calculated manually like here if later you also want to steal from containers and such.
The best/easiest way to activate stealing is somehow making the thief execute the steal script on pressed button.
This is done by either while(true)/Delay(1) enter script that constantly checks for a button being pressed (along with some other checks, for example "is player's weapon MyQuickHandsWeapon"), or by making a special item/weapon that runs the script when using it.

Now that isn't the main problem you have. The main problem you have is enumerating the list of items the target player has to steal one of them :)

User avatar
AlexMax
Forum Regular
Posts: 244
Joined: Tue May 29, 2012 10:14 pm
Contact:

Re: Steal something from another player

#3

Post by AlexMax » Sun Oct 02, 2016 12:22 am

Finally found something that worked - in Zandronum 2.0 no less:

http://zdoom.org/wiki/SetActivatorToTarget

Thanks for at least pointing me in the right direction.
The only limit to my freedom is the inevitable closure of the
universe, as inevitable as your own last breath. And yet,
there remains time to create, to create, and escape.

Escape will make me God.

Catastrophe
Retired Staff / Community Team Member
Posts: 2569
Joined: Sat Jun 02, 2012 2:44 am

Re: Steal something from another player

#4

Post by Catastrophe » Sun Oct 02, 2016 4:32 am

In my mod I managed to make a way for players to steal weapons from each other via punching. The idea goes like this.
  • In the first weapon, whenever it attacks, execute an acs script
  • In the acs script use setactivatortotarget to find who the player is currently looking at
  • If no target is there just stop the script
  • Otherwise make sure the enemy player is in range
  • Then get what weapon he is holding and take it from them and force their current weapon to be the fist via setweapon
  • Then give a new copy of the stolen weapon you recorded to the original executor of the script.
Unfortunately in 2.0 we don't have the handy function getweapon(), thus you will need an array to manually parse through possible weapons using checkweapon().

Post Reply