MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / UpdateFalling

Method UpdateFalling

src/openrct2/entity/Peep.cpp:781–891  ·  view source on GitHub ↗

* Falling and its subset drowning * rct2: 0x690028 */

Source from the content-addressed store, hash-verified

779 * rct2: 0x690028
780 */
781 void Peep::UpdateFalling()
782 {
783 if (Action == PeepActionType::drowning)
784 {
785 // Check to see if we are ready to drown.
786 UpdateAction();
787 invalidate();
788 if (Action == PeepActionType::drowning)
789 return;
790
791 if (Config::Get().notifications.guestDied)
792 {
793 auto ft = Formatter();
794 FormatNameTo(ft);
795 News::AddItemToQueue(News::ItemType::blank, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16), ft);
796 }
797
798 auto& gameState = getGameState();
799 gameState.park.ratingCasualtyPenalty = std::min(gameState.park.ratingCasualtyPenalty + 25, 1000);
800 Remove();
801 return;
802 }
803
804 // If not drowning then falling. Note: peeps 'fall' after leaving a ride/enter the park.
805 TileElement* tile_element = MapGetFirstElementAt(CoordsXY{ x, y });
806 TileElement* saved_map = nullptr;
807 int32_t saved_height = 0;
808
809 if (tile_element != nullptr)
810 {
811 do
812 {
813 // If a path check if we are on it
814 if (tile_element->getType() == TileElementType::Path)
815 {
816 int32_t height = MapHeightFromSlope(
817 { x, y }, tile_element->asPath()->GetSlopeDirection(),
818 tile_element->asPath()->IsSloped())
819 + tile_element->getBaseZ();
820
821 if (height < z - 1 || height > z + 8)
822 continue;
823
824 saved_height = height;
825 saved_map = tile_element;
826 break;
827 } // If a surface get the height and see if we are on it
828 else if (tile_element->getType() == TileElementType::Surface)
829 {
830 // If the surface is water check to see if we could be drowning
831 if (tile_element->asSurface()->GetWaterHeight() > 0)
832 {
833 int32_t height = tile_element->asSurface()->GetWaterHeight();
834
835 if (height - 4 >= z && height < z + 20)
836 {
837 // Looks like we are drowning!
838 moveTo({ x, y, height });

Callers

nothing calls this directly

Calls 15

MapGetFirstElementAtFunction · 0.85
MapHeightFromSlopeFunction · 0.85
GuestReleaseBalloonFunction · 0.85
PeepWindowStateUpdateFunction · 0.85
TileElementHeightFunction · 0.85
insertNewThoughtMethod · 0.80
FormatterClass · 0.70
invalidateFunction · 0.50
getTypeMethod · 0.45
GetSlopeDirectionMethod · 0.45
asPathMethod · 0.45
IsSlopedMethod · 0.45

Tested by

no test coverage detected