Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New CVars: mp_weapondrop and mp_ammodrop and fixes #840

Merged
merged 8 commits into from
Jul 10, 2023

Conversation

dystopm
Copy link
Contributor

@dystopm dystopm commented Jul 2, 2023

  • Added cvar mp_weapondrop which controls behaviour on weapon drop after death. You can choose between (0) do not drop anything after death, (1) drop your heaviest weapon (default behaviour), (2) drop your active weapon or (3) drop all your weapons. It works independently of mp_nadedrops cvar (and it's also an extension of it)
  • Added cvar mp_ammodrop which controls behaviour of ammo packing on weapon boxes drop. You can choose between (0) keep ammo on player always, (1) drop ammo on weaponbox only after death and (2) drop ammo on every weaponbox you drop either death or manual drop.
  • Fix: Ammo resetting inside CreateWeaponBox; ammo was not getting reset if packAmmo = true, no matter if weapon is not considered "exhaustible"
  • Fix: CanDrop used inside PackDeadPlayerItems in case modders want to make a weapon undroppable.
  • Code related: PackPlayerItem now returns the entity created.
  • Changed usage of constants meaning (GR_PLR_DROP_GUN_* inside DeadPlayerWeapons) and added an extra.

Related to/fixes close #520 #620 #758 #821
Tested, work as intended

PS: Cvar's names/description corrections are welcome

@StevenKal
Copy link
Contributor

StevenKal commented Jul 3, 2023

Nice!
But maybe dropping "all weapons" when "GR_PLR_DROP_GUN_ALL" is set could be added (all primary & secondary).
And keep "GR_PLR_DROP_GUN_ACTIVE" for only active weapon on death (if, it is a primary or secondary, however, get & drop best weapon). But a new rule like "GR_PLR_DROP_GUN_BEST" could also be welcomed.
Or, make "GR_PLR_DROP_GUN_ACTIVE" drops best primary/secondary weapon (default behavior), but this does not really match to the rule name...
So, questionable.

Copy link
Collaborator

@wopox1337 wopox1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style fixes

regamedll/dlls/multiplay_gamerules.cpp Outdated Show resolved Hide resolved
regamedll/dlls/multiplay_gamerules.cpp Outdated Show resolved Hide resolved
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
dystopm and others added 2 commits July 3, 2023 13:54
Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
regamedll/dlls/player.cpp Outdated Show resolved Hide resolved
@dystopm
Copy link
Contributor Author

dystopm commented Jul 3, 2023

Nice! But maybe dropping "all weapons" when "GR_PLR_DROP_GUN_ALL" is set could be added (all primary & secondary). And keep "GR_PLR_DROP_GUN_ACTIVE" for only active weapon on death (if, it is a primary or secondary, however, get & drop best weapon). But a new rule like "GR_PLR_DROP_GUN_BEST" could also be welcomed. Or, make "GR_PLR_DROP_GUN_ACTIVE" drops best primary/secondary weapon (default behavior), but this does not really match to the rule name... So, questionable.

I've been thinking on a nice way to implement that. Thing is: drop weapons separately guided by player angles (left to right, depending on how many weapons player will drop) or drop weapons in forward, each one further forward than the last (easy implementation, just store them into an array and apply an scalar to their current velocity since all are going forward) - will take a look and then test

dystopm and others added 3 commits July 3, 2023 14:08
Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
@dystopm dystopm requested a review from wopox1337 July 3, 2023 19:11
@dystopm
Copy link
Contributor Author

dystopm commented Jul 4, 2023

Added new behaviour: mp_weapondrop 3 (as @StevenKal requested) will ensure players drop all their weapons (primary and secondary) after death. It basically uses the same pattern but every box created has more velocity than its predecessor. Depending on physics, players can stand still, be on mid air or just running fast, and that will affect weapons drop spreading.

hl_g8EpmJvJFR
hl_PXYqh0CfDC
hl_taBKuYQ8LT

Used sv_cheats 1 and impulse 255 for testing purposes only, because in legit scenarios players can have at least 2 weapons.

Credits to @metita for his help in test scenarios.

@dystopm dystopm requested a review from wopox1337 July 7, 2023 17:48
@wopox1337 wopox1337 changed the title New CVars: mp_weapondrop and mp_ammodrop New CVars: mp_weapondrop and mp_ammodrop and fixes Jul 10, 2023
@@ -1386,78 +1395,130 @@ void PackPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
void CBasePlayer::PackDeadPlayerItems()
Copy link
Collaborator

@wopox1337 wopox1337 Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CBasePlayer::PackDeadPlayerItems() function looks terrible (it's not because of your PR). It needs refactoring (later), for the logic is hard to track. 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wopox1337 yeah you're right, I just tried to stick to the original code but indeed it is certainly bad coded

@wopox1337 wopox1337 merged commit 8ddda26 into s1lentq:master Jul 10, 2023
4 checks passed
@dystopm dystopm mentioned this pull request Jul 10, 2023
@dystopm dystopm deleted the new-mp-cvars branch October 11, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with ammo on dropped weapons
3 participants