public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false) { if (!this.immune && !Main.godMode) { int num = Damage; PlayerHurtEvent playerEvent = new PlayerHurtEvent(); playerEvent.setSender(new Sender()); playerEvent.setDamage(Damage); Program.server.getPluginManager().processHook(Hooks.CONSOLE_COMMAND, playerEvent); if (playerEvent.getCancelled()) { return 0.0; } num = playerEvent.getDamage(); 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); } //CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(255, 80, 90, 255), string.Concat((int)num2)); 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; } //if (this.boneArmor) //{ // //Main.PlaySound(3, (int)this.position.X, (int)this.position.Y, 2); //} //else //{ // if (this.hair == 5 || this.hair == 6 || this.hair == 9 || this.hair == 11) // { // //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) { int num4 = 0; while ((double)num4 < num2 / (double)this.statLifeMax * 100.0) { if (this.boneArmor) { Dust.NewDust(this.position, this.width, this.height, 26, (float)(2 * hitDirection), -2f, 0, new Color(), 1f); } else { Dust.NewDust(this.position, this.width, this.height, 5, (float)(2 * hitDirection), -2f, 0, new Color(), 1f); } num4++; } } else { this.statLife = 0; if (this.whoAmi == Main.myPlayer) { this.KillMe(num2, hitDirection, pvp); } } } if (pvp) { num2 = Main.CalculateDamage(num, this.statDefense); } return num2; } return 0.0; }
public virtual void onPlayerHurt(PlayerHurtEvent Event) { }
public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...") { if (!this.immune) { int num = Damage; PlayerHurtEvent playerEvent = new PlayerHurtEvent(); playerEvent.Sender = this; playerEvent.Damage = Damage; Program.server.getPluginManager().processHook(Hooks.PLAYER_HURT, playerEvent); if (playerEvent.Cancelled) { return 0.0; } num = playerEvent.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); NetMessage.SendData(16, -1, -1, "", this.whoAmi); 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; } if (this.statLife > 0) { int num4 = 0; while ((double)num4 < num2 / (double)this.statLifeMax * 100.0) { if (this.boneArmor) { Dust.NewDust(this.Position, this.width, this.height, 26, (float)(2 * hitDirection), -2f, 0, default(Color), 1f); } else { Dust.NewDust(this.Position, this.width, this.height, 5, (float)(2 * hitDirection), -2f, 0, default(Color), 1f); } num4++; } } else { this.statLife = 0; if (this.whoAmi == Main.myPlayer) { this.KillMe(num2, hitDirection, pvp, deathText); } } } if (pvp) { num2 = Main.CalculateDamage(num, this.statDefense); } return num2; } return 0.0; }
public override void onPlayerHurt(PlayerHurtEvent Event) { //base.onPlayerHurt(Event); Player player = Event.Player; int xp = defenseXP.getPlayerValue(player.Name); xp++; defenseXP.setPlayerValue(player.Name, xp); defenseXP.Save(); player.sendMessage("+1 Defense XP"); Event.Cancelled = true; }
public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false, String deathText = " was slain...") { if (!this.immune) { int num = Damage; PlayerHurtEvent playerEvent = new PlayerHurtEvent(); playerEvent.Sender = this; playerEvent.Damage = Damage; Program.server.PluginManager.processHook(Hooks.PLAYER_HURT, playerEvent); if (playerEvent.Cancelled) { return 0.0; } num = playerEvent.Damage; if (pvp) { num *= 2; } double num2 = Main.CalculateDamage(num, this.statDefense); if (num2 >= 1.0) { 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; } if (this.statLife > 0) { int num4 = 0; while ((double)num4 < num2 / (double)this.statLifeMax * 100.0) { num4++; } } else { this.statLife = 0; if (this.whoAmi == Main.myPlayer) { this.KillMe(num2, hitDirection, pvp, deathText); } } } if (pvp) { num2 = Main.CalculateDamage(num, this.statDefense); } return num2; } return 0.0; }
public override void onPlayerHurt(PlayerHurtEvent Event) { Event.setCancelled(false); }