Pickup only for specific player

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Motombo
Posts: 1
Joined: Wed May 31, 2023 10:46 am

Pickup only for specific player

Post by Motombo »

I'm looking to make a specific item pickable only by a specific player. This would help in coop, so that -for example- Backpack 1 can only be picked up by Player 1, and Backpack 2 can only be picked up by Player 2. I've just started with mapping, and my scripting knowledge is minimal, but is there a way to do this?
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Pickup only for specific player

Post by ramon.dexter »

Well, this could be probably handled by zscript eventhandler. But I dont know how zscript handles multiplayer, yet if it even supports such use. I think this question belongs more into scripting than mapping. It's not a question of placement, but a scripting thing.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Pickup only for specific player

Post by Graf Zahl »

Event handlers won't help here. For this the TryPickup method needs to be overridden and check whether the player is allowed to take the item.
User avatar
Caffeine
Posts: 2
Joined: Mon Nov 21, 2022 8:19 pm
Operating System Version (Optional): Windows 11, Ubuntu 23.10
Graphics Processor: nVidia with Vulkan support

Re: Pickup only for specific player

Post by Caffeine »

While not the most flexible way, you could simply have multiple starting rooms: one for each player. Players can pick up their starting items then teleport, drop, or otherwise have a one-way trip into a common start room where they can group up before tackling the level. This has the advantage that it does not even require GZDoom: you can do this in the OG 1993 game which means every source port supports it.

Another option for GZDoom is using an ACS script defined for "ENTER" to give items to the script activator. Then when each player enters the level, the script populates some starting items.
User avatar
SPZ1
Posts: 362
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois

Re: Pickup only for specific player

Post by SPZ1 »

You could have 8 separate objects which all have A_CheckProximity(). You can specify a specific player pointer with this function such as :

A_CheckProximity ("PlayerMatchState", "DoomPlayer", 64.0, 1, 0 , AAPTR_PLAYER1)
A_CheckProximity ("PlayerMatchState", "DoomPlayer", 64.0, 1, 0 , AAPTR_PLAYER2)
A_CheckProximity ("PlayerMatchState", "DoomPlayer", 64.0, 1, 0 , AAPTR_PLAYER3)

Return to “Mapping”