diff --git a/sources/Gameplay/BaseClasses/Frontend/EPawn.uc b/sources/Gameplay/BaseClasses/Frontend/EPawn.uc index cfed609..f38030f 100644 --- a/sources/Gameplay/BaseClasses/Frontend/EPawn.uc +++ b/sources/Gameplay/BaseClasses/Frontend/EPawn.uc @@ -23,6 +23,14 @@ class EPawn extends EPlaceable abstract; +/** + * If caller pawn is controlled by a player, this method returns that player. + * + * @return Player that controls caller pawn. `none` iff caller pawn is not + * controlled by a player. + */ +public function EPlayer GetPlayer(); + /** * Returns current amount of health caller `EPawn`'s referred entity has, * assuming that entity has a health component. diff --git a/sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc b/sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc index 08f5f6c..64b51c5 100644 --- a/sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc +++ b/sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc @@ -117,6 +117,19 @@ public function Vector GetLocation() return Vect(0.0, 0.0, 0.0); } +public function EPlayer GetPlayer() +{ + local Pawn pawnInstance; + + pawnInstance = GetNativeInstance(); + if (pawnInstance != none) + { + return _.players.FromController( + PlayerController(pawnInstance.controller)); + } + return none; +} + public function int GetHealth() { local Pawn pawnInstance;