Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CheckDrowning()

void Terraria.Player.CheckDrowning ( )
inline

Definition at line 22224 of file Player.cs.

22225 {
22226 bool flag = Collision.DrownCollision(position, width, height, gravDir);
22227 if (armor[0].type == 250 || armor[0].type == 4275)
22228 {
22229 flag = true;
22230 }
22231 if (inventory[selectedItem].type == 186 && itemAnimation == 0)
22232 {
22233 try
22234 {
22235 int num = (int)((position.X + (float)(width / 2) + (float)(6 * direction)) / 16f);
22236 int num2 = 0;
22237 if (gravDir == -1f)
22238 {
22239 num2 = height;
22240 }
22241 int num3 = (int)((position.Y + (float)num2 - 44f * gravDir) / 16f);
22242 if (Main.tile[num, num3] != null && Main.tile[num, num3].liquid < 128)
22243 {
22244 if (Main.tile[num, num3] == null)
22245 {
22246 Main.tile[num, num3] = new Tile();
22247 }
22248 if (!Main.tile[num, num3].active() || !Main.tileSolid[Main.tile[num, num3].type] || Main.tileSolidTop[Main.tile[num, num3].type])
22249 {
22250 flag = false;
22251 }
22252 }
22253 }
22254 catch
22255 {
22256 }
22257 }
22258 if (gills)
22259 {
22260 flag = Main.getGoodWorld && !flag;
22261 }
22262 if (shimmering)
22263 {
22264 flag = false;
22265 }
22266 if (mount.Active && mount.Type == 4)
22267 {
22268 flag = false;
22269 }
22270 if (Main.myPlayer == whoAmI)
22271 {
22272 if (accMerman)
22273 {
22274 if (flag)
22275 {
22276 merman = true;
22277 }
22278 flag = false;
22279 }
22280 if (flag)
22281 {
22282 breathCD++;
22283 if (breathCD >= breathCDMax)
22284 {
22285 breathCD = 0;
22286 breath--;
22287 if (breath == 0)
22288 {
22290 }
22291 if (breath <= 0)
22292 {
22293 lifeRegenTime = 0f;
22294 breath = 0;
22295 statLife -= 2;
22296 if (statLife <= 0)
22297 {
22298 statLife = 0;
22299 KillMe(PlayerDeathReason.ByOther(1), 10.0, 0);
22300 }
22301 }
22302 }
22303 }
22304 else
22305 {
22306 breath += 3;
22307 if (breath > breathMax)
22308 {
22309 breath = breathMax;
22310 }
22311 breathCD = 0;
22312 }
22313 }
22314 if (flag && Main.rand.Next(20) == 0 && !lavaWet && !honeyWet)
22315 {
22316 int num4 = 0;
22317 if (gravDir == -1f)
22318 {
22319 num4 += height - 12;
22320 }
22321 if (inventory[selectedItem].type == 186)
22322 {
22323 Dust.NewDust(new Vector2(position.X + (float)(10 * direction) + 4f, position.Y + (float)num4 - 54f * gravDir), width - 8, 8, 34, 0f, 0f, 0, default(Color), 1.2f);
22324 }
22325 else
22326 {
22327 Dust.NewDust(new Vector2(position.X + (float)(12 * direction), position.Y + (float)num4 + 4f * gravDir), width - 8, 8, 34, 0f, 0f, 0, default(Color), 1.2f);
22328 }
22329 }
22330 }
static void PlaySound(int type, Vector2 position, int style=1)
static PlayerDeathReason ByOther(int type)
bool honeyWet
Definition Entity.cs:34
Vector2 position
Definition Entity.cs:14
bool Active
Definition Mount.cs:345
float lifeRegenTime
Definition Player.cs:1571
void KillMe(PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp=false)
Definition Player.cs:36665
Item[] inventory
Definition Player.cs:1257

References Terraria.DataStructures.PlayerDeathReason.ByOther(), Terraria.Collision.DrownCollision(), Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and System.type.