MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / HandlePlayerStatusEffects

Function HandlePlayerStatusEffects

TombEngine/Game/Lara/lara_helpers.cpp:102–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWaterData& water)
103{
104 auto& player = GetLaraInfo(item);
105
106 // Update health status.
107 if (TestEnvironment(ENV_FLAG_DAMAGE, &item) && item.HitPoints > 0)
108 item.HitPoints--;
109
110 // Update poison status.
111 if (player.Status.Poison)
112 {
113 if (player.Status.Poison > LARA_POISON_MAX)
114 player.Status.Poison = LARA_POISON_MAX;
115
116 if (!(Wibble & 0xFF))
117 DoDamage(&item, player.Status.Poison, true);
118 }
119
120 // Update stamina status.
121 if (player.Status.Stamina < LARA_STAMINA_MAX && item.Animation.ActiveState != LS_SPRINT)
122 player.Status.Stamina++;
123
124 // TODO: Dehardcode values and make cleaner implementation.
125 // Handle environmental status effects.
126 switch (waterStatus)
127 {
128 case WaterStatus::Dry:
129 case WaterStatus::Wade:
130 // TODO: Find best height. -- Sezz 2021.11.10
131 if (water.IsSwamp && player.Context.WaterSurfaceDist < -(LARA_HEIGHT + 8))
132 {
133 if (item.HitPoints >= 0)
134 {
135 player.Status.Air -= 6;
136 if (player.Status.Air < 0)
137 {
138 player.Status.Air = -1;
139 DoDamage(&item, 10, true);
140 }
141 }
142 }
143 else if (player.Status.Air < LARA_AIR_MAX && item.HitPoints >= 0)
144 {
145 // HACK: Special case for UPV.
146 if (player.Context.Vehicle == NO_VALUE)
147 {
148 player.Status.Air += 10;
149 if (player.Status.Air > LARA_AIR_MAX)
150 player.Status.Air = LARA_AIR_MAX;
151 }
152 }
153
154 if (item.HitPoints >= 0)
155 {
156 if (player.Control.WaterStatus == WaterStatus::Dry)
157 {
158 // HACK: Special case for UPV.
159 if (player.Context.Vehicle != NO_VALUE)

Callers 1

LaraControlFunction · 0.85

Calls 7

TestEnvironmentFunction · 0.85
DoDamageFunction · 0.85
GetPointCollisionFunction · 0.85
StopSoundTracksFunction · 0.85
GetLevelMethod · 0.80
GetLaraTypeMethod · 0.80
GetRoomNumberMethod · 0.45

Tested by

no test coverage detected