Can I make a key give itself to all players in co-op?
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.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
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.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 95
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Can I make a key give itself to all players in co-op?
When keys are spawned via a script, they don't stay in co-op. With other items I've easily been able to create a custom inventory object and then I can set up a pickup or use state. But if I make keys that inherit from DoomKey, I can't make them a custom inventory item. Since the items are spawned via ACS, I figured I could have them run a script when they're picked up but then the script treats the player who picks up the key as the activator, so CheckActorClass doesn't tell me which item to give to the player. I tried overriding HandlePickup and TryPickUp in Zscript to give all other players the item but one doesn't appear to work and the other crashes GZDoom. I'm scratching my head here. Any ideas?
-
- Posts: 95
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Can I make a key give itself to all players in co-op?
Nevermind! I got it working! I just added this to the PlayerPawn:
Code: Select all
override void HasReceived(Inventory item, class<Inventory> itemcls)
{
if (item && item is '(MyCustomKeyClass)')
{
A_RadiusGive(itemcls,16383,RGF_PLAYERS|RGF_NOSIGHT);
}
}
- Player701
-
- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Can I make a key give itself to all players in co-op?
There is also a CVAR you can use: sv_coopsharekeys. If you don't want to use it, you can also override ShouldShareItem for your custom key class to always return true.