From fac38e5a9cdc9e9b37c411c69a71a3b32c1d28dc Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 22 Mar 2020 19:21:14 +0700 Subject: [PATCH] Change `FixInventoryAbuse` behavior Changes behavior of `FixInventoryAbuse` on weight limit violation. Instead of destroying all weapons in the inventory of abuser, it drops them on the ground. This change is mainly caused by game behavior that allows regular players to accidental break weight limits. --- .../FixInventoryAbuse/FixInventoryAbuse.uc | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc b/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc index 819b6b8..4881386 100644 --- a/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc +++ b/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc @@ -142,8 +142,31 @@ private final function bool HasDuplicateGuns(KFHumanPawn playerPawn) return false; } +private final function Vector DropWeapon(KFWeapon weaponToDrop) +{ + local Vector x, y, z; + local Vector weaponVelocity; + local Vector dropLocation; + local KFHumanPawn playerPawn; + if (weaponToDrop == none) return Vect(0, 0, 0); + playerPawn = KFHumanPawn(weaponToDrop.instigator); + if (playerPawn == none) return Vect(0, 0, 0); + + // Calculations from 'PlayerController.ServerThrowWeapon' + weaponVelocity = Vector(playerPawn.GetViewRotation()); + weaponVelocity *= (playerPawn.velocity dot weaponVelocity) + 150; + weaponVelocity += Vect(0, 0, 100); + // Calculations from 'Pawn.TossWeapon' + GetAxes(playerPawn.rotation, x, y, z); + dropLocation = playerPawn.location + 0.8 * playerPawn.collisionRadius * x - + 0.5 * playerPawn.collisionRadius * y; + // Do the drop + weaponToDrop.velocity = weaponVelocity; + weaponToDrop.DropFrom(dropLocation); +} + // Kill the gun devil! -private final function DestroyEverything(KFHumanPawn playerPawn) +private final function DropEverything(KFHumanPawn playerPawn) { local int i; local Inventory inv; @@ -162,7 +185,7 @@ private final function DestroyEverything(KFHumanPawn playerPawn) // And destroy them later. for(i = 0; i < weaponList.length; i += 1) { - weaponList[i].Destroy(); + DropWeapon(weaponList[i]); } } @@ -185,7 +208,7 @@ event Timer() } if (IsWeightLimitViolated(nextPawn) || HasDuplicateGuns(nextPawn)) { - DestroyEverything(nextPawn); + DropEverything(nextPawn); } } }