From 4f554e91abd861323aaf9f46d75ff0350a519cef Mon Sep 17 00:00:00 2001 From: DarkoGNU <42816979+DarkoGNU@users.noreply.github.com> Date: Thu, 21 Apr 2022 20:56:21 +0200 Subject: Implement farmland trampling (#5401) * Add DarkoGNU to CONTRIBUTORS * HandleFarmlandTrampling function & its docs * Fix decimal separators (, -> .) * Fix style. Adjust thresholds. Make function non-virtual * Adjust thresholds again. Prepare for fixing #5402 * Trying to fix falling through farmlands * Another style fix * Add FarmlandTramplingEnabled to world.ini * Docs for IsFarmlandTramplingEnabled * Style * Farmland trampling - handling the random chance * Trampling kinda works, very buggy * Trying to fix clang-tidy * Fix trampling * Trying to fix the 'undocumented API symbol' * Implement bearbin's suggestions * Calculate volume properly * Don't use std::pow for squaring * Improved comments * Really, should comments' style be checked? --- src/Entities/Pawn.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Entities/Pawn.h') diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 222e8f3b8..c0801ebb3 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -33,6 +33,16 @@ public: virtual void HandleFalling(void); virtual void OnRemoveFromWorld(cWorld & a_World) override; + /** Handles farmland trampling when hitting the ground. + Algorithm: + fall height <= 0.6875 blocks: no trampling + fall height > 0.6875 and <= 1.0625: 25% chance of trampling + fall height > 1.0625 and <= 1.5625: 66% chance of trampling + fall height > 1.5625: always trample + The values may differ from vanilla, they were determined experimentally. + */ + void HandleFarmlandTrampling(double a_FallHeight); + /** Tells all pawns which are targeting us to stop targeting us. */ void StopEveryoneFromTargetingMe(); -- cgit v1.2.3