Foohy / jazztronauts

Jazztronauts is a cooperative theft-em-up for Garry's Mod, also known as prop hunt 2.
122 stars 35 forks source link

Add Player vs Player toggle #190

Closed Commenter25 closed 6 months ago

Commenter25 commented 1 year ago

This adds a new convar, jazz_player_pvp. When this is enabled, players will also collide, because otherwise hitscan weapons such as bullets and melee no longer function.

For collision to work properly, I had to add a system to get players unstuck if they spawn on each other. After spawning, it will check within your bounding box for another player. If one is found, you'll be allowed to pass through each other until you're no longer in contact, then the system deactivates and collision is normal.

I felt this would be of significant enough interest to add to the main menu, so it's an option there as well. Regardless of PvP, I also allowed self-damage at all times while I was here, since the only instance I can think of is explosive jumping, which is just fun.


This PR originally added another convar, jazz_player_collide, to allow toggling collisions separately. However, PvP relies on collision being on, and it's hard to consistently automatically toggle it without annoying the user. Particularly, seemingly due to Facepunch/garrysmod-issues#1440, toggling PvP in the menu won't run AddChangeCallback, so it can't enable collisions as well. It's a rather niche bit of customization anyway, so I've axed the extra convar and it's now just PvP.