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

◆ CheckDrowning()

void Terraria.NPC.CheckDrowning ( )
inline

Definition at line 91557 of file NPC.cs.

91558 {
91559 bool flag = Collision.DrownCollision(position, width, height, 1f);
91560 if (Main.netMode != 1)
91561 {
91562 if (flag)
91563 {
91564 if (++breathCounter >= 7)
91565 {
91566 breathCounter = 0;
91567 breath--;
91568 if (breath <= 0)
91569 {
91570 friendlyRegen = 0;
91571 breath = 0;
91572 life -= 2;
91573 if (life % 24 < 2)
91574 {
91575 netUpdate = true;
91576 }
91577 if (life <= 0)
91578 {
91579 life = 1;
91580 StrikeNPCNoInteraction(2, 0f, 0);
91581 if (Main.netMode != 0)
91582 {
91583 NetMessage.SendData(28, -1, -1, null, whoAmI, 2f);
91584 }
91585 }
91586 }
91587 }
91588 }
91589 else
91590 {
91591 breath += 3;
91592 if (breath > 200)
91593 {
91594 breath = 200;
91595 }
91596 breathCounter = 0;
91597 }
91598 }
91599 if (flag && Main.rand.Next(20) == 0 && !lavaWet && !honeyWet && !shimmerWet)
91600 {
91601 int num = 0;
91602 int num2 = 0;
91603 if (type == 369)
91604 {
91605 num2 = 8;
91606 }
91607 Dust.NewDust(new Vector2(position.X + (float)((10 + num) * direction), position.Y + (float)num2 + 4f), width - 8, 8, 34, 0f, 0f, 0, default(Color), 1.2f);
91608 }
91609 }
bool honeyWet
Definition Entity.cs:34
bool shimmerWet
Definition Entity.cs:32
Vector2 position
Definition Entity.cs:14
int breath
Definition NPC.cs:565
int friendlyRegen
Definition NPC.cs:563
int breathCounter
Definition NPC.cs:569
int type
Definition NPC.cs:445
double StrikeNPCNoInteraction(int Damage, float knockBack, int hitDirection, bool crit=false, bool noEffect=false, bool fromNet=false)
Definition NPC.cs:78015
int life
Definition NPC.cs:477
bool netUpdate
Definition NPC.cs:507

References Terraria.Collision.DrownCollision(), Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.Main.rand, Terraria.NetMessage.SendData(), System.type, and Microsoft.Xna.Framework.Graphics.Vector2.