private void OnPlayerDamagesNPC(NpcDamageEvent args) { try { SkillPlayer player = PlayerManager.GetPlayer(args.PlayerIndex); SkillInformation info = player.GetSkillInformation(Name); if (info == null) { info = new SkillInformation() { Name = this.Name, Value = 0 }; player.SetSkillInformation(info); return; } if (info.Value > 0) { double ratio = Math.Min(info.Value / 20.0, 1.0); int health = (int)Math.Ceiling(ratio * args.Damage); player.Player.Heal(health); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private static void OnNpcDamageEvent(NpcDamageEvent Event) { if (Event.Master.Team == CombatTeam.B) { Dps_.ApplyDamage(Event.SourceName, Event.Damage); } }
private void OnNpcDamageEvent(NpcDamageEvent Event) { if (Event.Master.ID == Master.ID) { AttackerNpc = NpcManager.FindNpc(Event.AttackerID); } }
private void OnNpcDamageEvent(NpcDamageEvent Event) { if (Event.Master.ID != Args_.Master.ID) { return; } var Attacker = NpcManager.FindNpc(Event.AttackerID); if (Attacker == null) { return; } var Level = Args_.Master.Skill.GetSkillLevel(Args_.Skill.SkillID); Attacker.OnHitDamage(Args_.Master, Args_.Skill.Name, Event.RealValue * Level * 0.5f); }
private void OnNpcDamaged(TSPlayer player, int npcIndex, int damage, float knockback, byte direction, bool critical) { //DEBUG TShock.Log.ConsoleInfo("DEBUG [NPCDamage] NPCIndex {0}", npcIndex); //DEBUG NPC npc = Main.npc[npcIndex]; double damageDone = Main.CalculateDamage(damage, npc.ichor ? npc.defense - 20 : npc.defense); if (critical) { damageDone *= 2; } //Damage event var e = new NpcDamageEvent { NpcIndex = npcIndex, PlayerIndex = player.Index, Damage = damage, Knockback = knockback, Direction = direction, CriticalHit = critical, NpcHealth = Math.Max(0, npc.life - (int)damageDone) }; eventManager.InvokeHandler(e, EventType.NpcDamage); //This damage will kill the NPC. if (npc.active && npc.life > 0 && damageDone >= npc.life) { CustomNPCVars npcvar = NPCManager.NPCs[npcIndex]; if (npcvar != null) { npcvar.markDead(); } //Kill event var killedArgs = new NpcKilledEvent { NpcIndex = npcIndex, PlayerIndex = player.Index, Damage = damage, Knockback = knockback, Direction = direction, CriticalHit = critical, LastPosition = npc.position }; var SEconReward = new Money(npcvar.customNPC.SEconReward); // TODO: Improve Seconomy Code if needed // My Implementation of Seconomy Rewards, it's bountys for the last player who hits and kills the enemy, Not sure if this is the best way to do this // Remove when a actual fix is provide if (npcvar != null) { var economyPlayer = SEconomyPlugin.Instance.GetBankAccount(TSPlayer.Server.User.ID); if (!UsingSEConomy || !economyPlayer.IsAccountEnabled) { if (!economyPlayer.IsAccountEnabled) { TShock.Log.Error("You cannot gain any bounty because your account is disabled."); } } else { if (npcvar.customNPC.SEconReward > 0) { IBankAccount Player = SEconomyPlugin.Instance.GetBankAccount(TSPlayer.Server.User.ID); SEconomyPlugin.Instance.WorldAccount.TransferToAsync(Player, SEconReward, BankAccountTransferOptions.AnnounceToReceiver, npcvar.customNPC.customName + " Bountie", "Custom Npc Kill"); SEconReward = 0; } } } eventManager.InvokeHandler(killedArgs, EventType.NpcKill); if (npcvar != null && npcvar.isInvasion) { NPCManager.CustomNPCInvasion.WaveSize--; } } }