private static void DamageCharacter(ICharacter character, IMap map, int dmg, Enums.KillType killType, PacketHitList hitlist, bool checkDeath) { int point = 0; try { character.HP -= dmg; if (dmg <= 0) { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took no damage!", Text.BrightRed), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took no damage!", Text.BrightRed); } else { hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " took " + dmg + " damage!", Text.BrightRed), character.X, character.Y, 10); //BothWaysBattleMsg(setup, setup.Defender.Name + " took " + damage + " damage!", Text.BrightRed); } point = 1; if (checkDeath && character.HP <= 0) { if (character.CharacterType == Enums.CharacterType.Recruit) { point = 2; hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("Oh, no! " + character.Name + " fainted!", Text.BrightRed)); point = 3; OnDeath(((Recruit)character).Owner, Enums.KillType.Other); point = 4; } else { if (character.HeldItem != null) { character.MapDropItem(character.HeldItem.Amount, null); } OnNpcDeath(hitlist, null, (MapNpc)character); //((MapNpc)character).Num = 0; //((MapNpc)character).HP = 0; map.ActiveNpc[((MapNpc)character).MapSlot] = new MapNpc(character.MapID, ((MapNpc)character).MapSlot); hitlist.AddPacketToMap(map, TcpPacket.CreatePacket("npcdead", ((MapNpc)character).MapSlot)); } } } catch(Exception ex) { Messenger.AdminMsg("Error: DamageCharacter", Text.Black); Messenger.AdminMsg(ex.ToString(), Text.Black); Messenger.AdminMsg(character.Name + " took " + dmg + " dmg at " + map.Name + " from " + killType + " with checkDeath=" + checkDeath + " and point=" + point, Text.Black); throw new Exception(); } }