public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool Crit = false)
{
if (this.immune)
return 0.0;
if (this.whoAmI == Main.myPlayer && this.blackBelt && Main.rand.Next(10) == 0)
{
this.NinjaDodge();
return 0.0;
}
if (this.whoAmI == Main.myPlayer && this.shadowDodge)
{
this.ShadowDodge();
return 0.0;
}
if (this.whoAmI == Main.myPlayer && this.panic)
this.AddBuff(63, 300, true);
this.stealth = 1f;
if (Main.netMode == 1)
NetMessage.SendData(84, -1, -1, "", this.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
int Damage1 = Damage;
double dmg = Main.CalculatePlayerDamage(Damage1, this.statDefense);
if (Crit)
Damage1 *= 2;
if (dmg >= 1.0)
{
if (this.invis)
{
for (int b = 0; b < 22; ++b)
{
if (this.buffType[b] == 10)
this.DelBuff(b);
}
}
dmg = (double)(int)((1.0 - (double)this.endurance) * dmg);
if (dmg < 1.0)
dmg = 1.0;
if (this.ConsumeSolarFlare())
{
dmg = (double)(int)((1.0 - 0.300000011920929) * dmg);
if (dmg < 1.0)
dmg = 1.0;
if (this.whoAmI == Main.myPlayer)
{
int index = Projectile.NewProjectile(this.Center.X, this.Center.Y, 0.0f, 0.0f, 608, 150, 15f, Main.myPlayer, 0.0f, 0.0f);
Main.projectile[index].Kill();
}
}
if (this.beetleDefense && this.beetleOrbs > 0)
{
dmg = (double)(int)((1.0 - (double)(0.15f * (float)this.beetleOrbs)) * dmg);
--this.beetleOrbs;
for (int b = 0; b < 22; ++b)
{
if (this.buffType[b] >= 95 && this.buffType[b] <= 97)
this.DelBuff(b);
}
if (this.beetleOrbs > 0)
this.AddBuff(95 + this.beetleOrbs - 1, 5, false);
this.beetleCounter = 0.0f;
if (dmg < 1.0)
dmg = 1.0;
}
if (this.magicCuffs)
{
int manaAmount = Damage1;
this.statMana += manaAmount;
if (this.statMana > this.statManaMax2)
this.statMana = this.statManaMax2;
this.ManaEffect(manaAmount);
}
if (this.paladinBuff && this.whoAmI != Main.myPlayer)
{
int Damage2 = (int)(dmg * 0.25);
dmg = (double)(int)(dmg * 0.75);
if (Main.player[Main.myPlayer].paladinGive)
{
int index = Main.myPlayer;
if (Main.player[index].team == this.team && this.team != 0)
{
float num1 = this.position.X - Main.player[index].position.X;
float num2 = this.position.Y - Main.player[index].position.Y;
if (Math.Sqrt((double)num1 * (double)num1 + (double)num2 * (double)num2) < 800.0)
Main.player[index].Hurt(Damage2, 0, false, false, "", false);
}
}
}
if (this.brainOfConfusion && Main.myPlayer == this.whoAmI)
{
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && !Main.npc[index].friendly)
{
int num1 = 300 + (int)dmg * 2;
if (Main.rand.Next(500) < num1)
{
float num2 = (Main.npc[index].Center - this.Center).Length();
float num3 = (float)Main.rand.Next(200 + (int)dmg / 2, 301 + (int)dmg * 2);
if ((double)num3 > 500.0)
num3 = (float)(500.0 + ((double)num3 - 500.0) * 0.75);
if ((double)num3 > 700.0)
num3 = (float)(700.0 + ((double)num3 - 700.0) * 0.5);
if ((double)num3 > 900.0)
num3 = (float)(900.0 + ((double)num3 - 900.0) * 0.25);
if ((double)num2 < (double)num3)
{
float num4 = (float)Main.rand.Next(90 + (int)dmg / 3, 300 + (int)dmg / 2);
Main.npc[index].AddBuff(31, (int)num4, false);
}
}
}
}
Projectile.NewProjectile(this.Center.X + (float)Main.rand.Next(-40, 40), this.Center.Y - (float)Main.rand.Next(20, 60), this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 565, 0, 0.0f, this.whoAmI, 0.0f, 0.0f);
}
if (Main.netMode == 1 && this.whoAmI == Main.myPlayer && !quiet)
{
int number5 = 0;
if (Crit)
number5 = 1;
int num = 0;
if (pvp)
num = 1;
NetMessage.SendData(13, -1, -1, "", this.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
NetMessage.SendData(16, -1, -1, "", this.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
NetMessage.SendData(26, -1, -1, "", this.whoAmI, (float)hitDirection, (float)Damage, (float)num, number5, 0, 0);
}
CombatText.NewText(new Microsoft.Xna.Framework.Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), Crit ? CombatText.DamagedFriendlyCrit : CombatText.DamagedFriendly, string.Concat((object)(int)dmg), Crit, false);
this.statLife -= (int)dmg;
this.immune = true;
if (dmg == 1.0)
{
this.immuneTime = 20;
if (this.longInvince)
this.immuneTime += 20;
}
else
{
this.immuneTime = 40;
if (this.longInvince)
this.immuneTime += 40;
}
this.lifeRegenTime = 0;
if (pvp)
this.immuneTime = 8;
if (this.whoAmI == Main.myPlayer)
{
if (this.starCloak)
{
for (int index1 = 0; index1 < 3; ++index1)
{
float num1 = this.position.X + (float)Main.rand.Next(-400, 400);
float num2 = this.position.Y - (float)Main.rand.Next(500, 800);
Vector2 vector2 = new Vector2(num1, num2);
float num3 = this.position.X + (float)(this.width / 2) - vector2.X;
float num4 = this.position.Y + (float)(this.height / 2) - vector2.Y;
float num5 = num3 + (float)Main.rand.Next(-100, 101);
float num6 = 23f / (float)Math.Sqrt((double)num5 * (double)num5 + (double)num4 * (double)num4);
float SpeedX = num5 * num6;
float SpeedY = num4 * num6;
int index2 = Projectile.NewProjectile(num1, num2, SpeedX, SpeedY, 92, 30, 5f, this.whoAmI, 0.0f, 0.0f);
Main.projectile[index2].ai[1] = this.position.Y;
}
}
if (this.bee)
{
int num = 1;
if (Main.rand.Next(3) == 0)
++num;
if (Main.rand.Next(3) == 0)
++num;
if (this.strongBees && Main.rand.Next(3) == 0)
++num;
for (int index = 0; index < num; ++index)
Projectile.NewProjectile(this.position.X, this.position.Y, (float)Main.rand.Next(-35, 36) * 0.02f, (float)Main.rand.Next(-35, 36) * 0.02f, this.beeType(), this.beeDamage(7), this.beeKB(0.0f), Main.myPlayer, 0.0f, 0.0f);
}
}
if (!this.noKnockback && hitDirection != 0 && (!this.mount.Active || !this.mount.Cart))
{
this.velocity.X = 4.5f * (float)hitDirection;
this.velocity.Y = -3.5f;
}
if (this.stoned)
Main.PlaySound(0, (int)this.position.X, (int)this.position.Y, 1);
else if (this.frostArmor)
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 27);
else if (this.wereWolf)
Main.PlaySound(3, (int)this.position.X, (int)this.position.Y, 6);
else if (this.boneArmor)
Main.PlaySound(3, (int)this.position.X, (int)this.position.Y, 2);
else if (!this.Male)
Main.PlaySound(20, (int)this.position.X, (int)this.position.Y, 1);
else
Main.PlaySound(1, (int)this.position.X, (int)this.position.Y, 1);
if (this.statLife > 0)
{
for (int index1 = 0; (double)index1 < dmg / (double)this.statLifeMax2 * 100.0; ++index1)
{
if (this.stoned)
Dust.NewDust(this.position, this.width, this.height, 1, (float)(2 * hitDirection), -2f, 0, new Color(), 1f);
else if (this.frostArmor)
{
int index2 = Dust.NewDust(this.position, this.width, this.height, 135, (float)(2 * hitDirection), -2f, 0, new Color(), 1f);
Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
}
else if (this.boneArmor)
{
int index2 = Dust.NewDust(this.position, this.width, this.height, 26, (float)(2 * hitDirection), -2f, 0, new Color(), 1f);
Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
}
else
Dust.NewDust(this.position, this.width, this.height, 5, (float)(2 * hitDirection), -2f, 0, new Color(), 1f);
}
}
else
{
this.statLife = 0;
if (this.whoAmI == Main.myPlayer)
this.KillMe(dmg, hitDirection, pvp, deathText);
}
}
if (pvp)
dmg = Main.CalculateDamage(Damage1, this.statDefense);
return dmg;
}