Exemple #1
0
 public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false)
 {
     double result;
     if (this.immune || Main.godMode)
     {
         result = 0.0;
     }
     else
     {
         PlayerHurtEvent playerHurtEvent = new PlayerHurtEvent(this, Damage);
         PluginManager.callHook(Hook.PLAYER_HURT, playerHurtEvent);
         if (!playerHurtEvent.getState())
         {
             result = 0.0;
         }
         else
         {
             int num = Damage;
             if (pvp)
             {
                 num *= 2;
             }
             double num2 = Main.CalculateDamage(num, this.statDefense);
             if (num2 >= 1.0)
             {
                 if (Main.netMode == 1 && this.whoAmi == Main.myPlayer && !quiet)
                 {
                     int num3 = 0;
                     if (pvp)
                     {
                         num3 = 1;
                     }
                     NetMessage.SendData(13, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
                     NetMessage.SendData(16, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
                     NetMessage.SendData(26, -1, -1, "", this.whoAmi, (float)hitDirection, (float)Damage, (float)num3);
                 }
                 this.statLife -= (int)num2;
                 this.immune = true;
                 this.immuneTime = 40;
                 if (pvp)
                 {
                     this.immuneTime = 8;
                 }
                 if (!this.noKnockback && hitDirection != 0)
                 {
                     this.velocity.X = 4.5f * (float)hitDirection;
                     this.velocity.Y = -3.5f;
                 }
                 this.statLife = 0;
                 if (this.whoAmi == Main.myPlayer)
                 {
                     this.KillMe(num2, hitDirection, pvp);
                 }
             }
             if (pvp)
             {
                 num2 = Main.CalculateDamage(num, this.statDefense);
             }
             result = num2;
         }
     }
     return result;
 }
Exemple #2
0
 public virtual void onPlayerHurt(PlayerHurtEvent ev)
 {
 }