public void RemoveMob(NPC npc) { if (m_Mobs.Remove(npc)) { npc.Group = null; } }
/// <summary> /// Sends the packet to show the battleground window /// </summary> /// <param name="client"></param> /// <param name="speaker"></param> /// <param name="character"></param> /// <returns></returns> public bool SendBattlegroundWindow(IRealmClient client, NPC speaker, Character character) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_LIST)) { packet.WriteULong(speaker != null ? speaker.EntityId.Full : 0); packet.WriteUInt((uint)m_bgqueue.Template.BgID); packet.WriteByte(m_battlegroupId); //Battle group // TODO: Add sync'ing? //m_syncLock.EnterReadLock(); try { packet.WriteUInt(m_battlegrounds.Count); //Count foreach (var bg in m_battlegrounds.Values) { packet.WriteUInt(bg.InstanceId); } } finally { //m_syncLock.ExitReadLock(); } client.Send(packet); return true; } }
public static void RepairItem(IRealmClient client, NPC armorer, EntityId itemId, bool useGuildFunds) { var curChar = client.ActiveCharacter; uint totalCost = 0; if (itemId.Low != 0) { // Repairing an individual item. var item = GetItemByEntityId(curChar, itemId); if (item == null) return; if (!ArmorerCheatChecks(curChar, armorer, item)) return; totalCost += RepairItem(curChar, armorer, item, useGuildFunds); } else { // Case Repair all if (!ArmorerCheatChecks(curChar, armorer)) return; totalCost += RepairAllItems(curChar, armorer, useGuildFunds); } if (useGuildFunds) { /**************************** * TODO: record the funds usage in the guild log ****************************/ } }
protected internal override void Apply() { npc = (NPC)m_aura.Auras.Owner; if (caster != null && caster.IsInWorld) { npc.ThreatCollection.Taunter = caster; } }
protected AlteracTower(AlteracValley instance, GOEntry flagstand) { Instance = instance; FlagStand = flagstand; if (WarmasterEntry != null) WarmasterEntry.Activated += (warmaster) => { Warmaster = warmaster; }; }
private static void UnworthyInitiateActivated(NPC npc) { npc.StandState = StandState.Kneeling; npc.AddMessage( () => { var nearest = npc.GetNearbyNPC(NPCId.UnworthyInitiateAnchor, 7); if (nearest == null) return; nearest.SpellCast.Trigger(SpellId.ChainedPeasantChest, npc); }); }
private static uint RepairAllItems(Character curChar, NPC armorer, bool useGuildFunds) { uint totalCost = 0; // Repair all items in the Backpack and Bags curChar.Inventory.Iterate(false, invItem => { if (invItem.MaxDurability > 0) totalCost += RepairItem(curChar, armorer, invItem, useGuildFunds); return true; }); return totalCost; }
/// <summary> /// Prepare Svala and Artha's Mirror /// </summary> void PrepareEncounter(NPC svala) { m_svala = svala; m_arthasMirror = arthasMirrorEntry.Create(DifficultyIndex); m_arthasMirror.Orientation = 1.58825f; AddObject(m_arthasMirror, arthasPosition); // big bosses are idle m_arthasMirror.Brain.State = BrainState.Idle; svala.Brain.State = BrainState.Idle; }
public TestBrain(NPC owner) : base(owner) { var spawn = owner.SpawnPoint; if (spawn != null) { var spawnEntry = spawn.SpawnEntry; if (spawnEntry != null) { m_waypoints = spawnEntry.Waypoints; } } }
public static void SendMirrorImageData(IRealmClient client, NPC mirrorimage) { var owner = mirrorimage.PlayerOwner; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MIRRORIMAGE_DATA, 68)) { packet.Write(mirrorimage.EntityId); packet.Write(owner.DisplayId); if (owner != null) //player { packet.Write((byte)owner.Race); packet.Write((byte)owner.Gender); packet.Write((byte)owner.Class); packet.Write(owner.Skin); packet.Write(owner.Facial); packet.Write(owner.HairStyle); packet.Write(owner.HairColor); packet.Write(owner.FacialHair); packet.Write(owner.GuildId); foreach(VisibleEquipmentSlot slot in Enum.GetValues(typeof(VisibleEquipmentSlot))) { var item = owner.Inventory.Equipment[(EquipmentSlot)slot]; if (slot == VisibleEquipmentSlot.Head && ((owner.PlayerFlags & PlayerFlags.HideHelm) != 0)) { packet.Write(0); } else if (slot == VisibleEquipmentSlot.Back && ((owner.PlayerFlags & PlayerFlags.HideCloak) != 0)) { packet.Write(0); } else if (item != null) { packet.Write(item.Template.DisplayId); } else packet.Write(0); } } else //creature { for (int i = 0; i < 14; i++) { packet.Write(0); } } client.Send(packet); } }
public NPCSpellCollection(NPC owner) : base(owner, false) { m_byId = owner.Entry.Spells; m_readySpells = new List<Spell>(); if (m_byId != null) { m_defaultSpells = true; foreach (var spell in m_byId.Values) { AddReadySpell(spell); OnNewSpell(spell); } } else { m_defaultSpells = false; m_byId = new Dictionary<uint, Spell>(5); } }
public VendorEntry(NPC npc, List<VendorItemEntry> items) { NPC = npc; if (items != null) { foreach (var item in items) { ItemsForSale.Add(new VendorItemEntry { BuyStackSize = item.BuyStackSize, RemainingStockAmount = item.RemainingStockAmount, ExtendedCostEntry = NPCMgr.ItemExtendedCostEntries[(int)item.ExtendedCostId], StockAmount = item.StockAmount, StockRefillDelay = item.StockRefillDelay, Template = item.Template }); } } }
/// <summary> /// Returns the index of the given skeleton for the skeleton arrays /// </summary> static int GetSkeletonIndex(NPC skel) { if (skel.SpawnPoint == null) { // unrelated Skeleton return -1; } for (var i = 0; i < PrinceSkeletonSpawnEntries.Length; i++) { var spawn = PrinceSkeletonSpawnEntries[i]; if (spawn == skel.SpawnPoint.SpawnEntry) { return i; } } // unrelated Skeleton return -1; }
private static bool OnBeforeAmbusherDeath(NPC ambusher) { if (ambusher.FirstAttacker is Character) { var killer = (Character)ambusher.FirstAttacker; if (!killer.QuestLog.HasActiveQuest(AmbusherQuest)) { // quest isn't active return true; } // say something ambusher.Say("Oh kind sir, please don't kill me!"); // discarded the idea of the backstabber: //ambusher.MoveBehindThenExecute(killer, // attacker => attacker.SpellCast.Start(SpellId.ClassSkillBackstabRank1, false, killer)); // cast some AoE spell (ignoring all restrictions) ambusher.SpellCast.Trigger(SpellId.ClassSkillFrostNovaRank6); // Is now friendly with everyone ambusher.FactionId = FactionId.Friendly; // more health than ever before (not necessary here) ambusher.BaseHealth = ambusher.Health = 100000; // won't do anything stupid anymore ambusher.Brain.DefaultState = BrainState.Idle; ambusher.Brain.EnterDefaultState(); // never leave the killer alone: Approach again and again... ambusher.CallPeriodically(2000, obj => SeekForgiveness(ambusher, killer)); return false; // return false to indicate that the guy didn't die } return true; // die }
/// <summary> /// Repairs the item of the given Character at the given armorer and returns the costs /// </summary> /// <returns></returns> private static uint RepairItem(Character curChar, NPC armorer, Item item, bool useGuildFunds) { var cost = GetCostToRepair(item); cost = curChar.Reputations.GetDiscountedCost(armorer.Faction.ReputationIndex, cost); if (useGuildFunds) { //////////////////////// // TODO: Implement after Guilds are done... // Check that the character is a member of a guild, that they have guild fund usage priveleges // and that there is enough money in the guild bank. //////////////////////// } else if (curChar.Money < cost) { return 0; } else curChar.Money -= cost; item.RepairDurability(); return cost; }
internal protected virtual void OnMinionDied(NPC minion) { }
public void Enslave(NPC minion, int durationMillis) { //Enslave(minion, durationMillis != 0 ? DateTime.Now.AddMilliseconds(durationMillis) : (DateTime?)null); minion.Phase = Phase; minion.Master = this; var type = minion.Entry.Type; if (type != CreatureType.None && type != CreatureType.NotSpecified) { if (type == CreatureType.NonCombatPet) { minion.Brain.DefaultState = BrainState.Follow; } else if (type == CreatureType.Totem) { // can't move minion.Brain.DefaultState = BrainState.Roam; } else { minion.Brain.DefaultState = BrainState.Guard; } minion.Brain.EnterDefaultState(); } if (durationMillis != 0) { // ReSharper disable PossibleLossOfFraction minion.RemainingDecayDelay = durationMillis / 1000; // ReSharper restore PossibleLossOfFraction } }
public void Enslave(NPC minion) { Enslave(minion, 0); }
/// <summary> /// Called when interacting with an NPC. /// </summary> public void OnTalkWith(NPC npc) { var reputationIndex = npc.Faction.ReputationIndex; // Does this faction even have a rep? if (reputationIndex < 0 || reputationIndex >= FactionReputationIndex.End) return; Reputation rep = GetOrCreate(reputationIndex); // Faction is now visible if (!rep.IsForcedInvisible) { rep.IsVisible = true; // Let the client know the Faction is visible FactionHandler.SendVisible(m_owner.Client, reputationIndex); } }
public static NPCSpellCollection Obtain(NPC npc) { var spells = NPCSpellCollectionPool.Obtain(); spells.Initialize(npc); return spells; }
public OggleflintAttackAction(NPC oggleflint) : base(oggleflint) { }
public BazzalanAttackAction(NPC bazzalan) : base(bazzalan) { }
public JergoshAttackAction(NPC jergosh) : base(jergosh) { }
public TaragamanAttackAction(NPC taragaman) : base(taragaman) { }
public VrykulSkeletonAttackAction(NPC vrykulSkeleton) : base(vrykulSkeleton) { }
public PrinceKelesethAttackAction(NPC princeKeleseth) : base(princeKeleseth) { }
public PrinceKelesethBrain(NPC princeKeleseth) : base(princeKeleseth) { }
internal protected virtual void OnMinionEnteredRegion(NPC minion) { }
internal protected virtual void OnMinionLeftRegion(NPC minion) { }
/// <summary> /// Spawn the dead skeletons (if any are missing or happen to be alive) /// </summary> void SpawnDeadPrinceSkeletons(NPC prince) { // set this prince to be the one prince of the instance PrinceKeleseth = prince; // make Prince leader of group PrinceKeleseth.Group.Leader = PrinceKeleseth; // spawn missing skeletons and add them to array of dead skeletons for (var i = 0; i < PrinceSkeletonSpawnEntries.Length; i++) { // check if skeleton still exists, else, respawn it var skel = GetSkeleton(i); if (skel == null) { // Skeleton did not exist -> get SpawnPoint and spawn a new one var spawn = prince.SpawnPoint.Pool.SpawnPoints[i + 1]; spawn.SpawnNow(); } else if (skel.IsAlive) { // make sure Skeleton is dead skel.Kill(); } } }