Exemple #1
0
        /// <summary>
        /// Sends the client the list of talents
        /// </summary>
        /// <param name="hasTalents">The IHasTalents to send the list from</param>
        public static void SendTalentGroupList(TalentCollection talents, int talentGroupId)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TALENTS_INFO))
            {
                var owner    = talents.Owner;
                var isPlayer = owner is Character;

                packet.Write((byte)(isPlayer ? 0 : 1));
                if (isPlayer)
                {
                    WritePlayerTalentList(packet, (Character)owner, talentGroupId);
                }
                else
                {
                    packet.Write(talents.FreeTalentPoints);
                    packet.Write((byte)talents.Count);
                    foreach (var talent in talents)
                    {
                        packet.Write((int)talent.Entry.Id);
                        packet.Write((byte)talent.Rank);
                    }
                }
                talents.OwnerCharacter.Send(packet);
            }
        }
Exemple #2
0
        /// <summary>Sends the client the list of talents</summary>
        /// <param name="hasTalents">The IHasTalents to send the list from</param>
        public static void SendTalentGroupList(TalentCollection talents, int talentGroupId)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_TALENTS_INFO))
            {
                Unit owner = talents.Owner;
                bool flag  = owner is Character;
                packet.Write(flag ? (byte)0 : (byte)1);
                if (flag)
                {
                    TalentHandler.WritePlayerTalentList((BinaryWriter)packet, (Character)owner, talentGroupId);
                }
                else
                {
                    packet.Write(talents.FreeTalentPoints);
                    packet.Write((byte)talents.Count);
                    foreach (Talent talent in talents)
                    {
                        packet.Write((int)talent.Entry.Id);
                        packet.Write((byte)talent.Rank);
                    }
                }

                talents.OwnerCharacter.Send(packet, false);
            }
        }
Exemple #3
0
		public Talent(TalentCollection talents, TalentEntry entry, int rank)
		{
			m_rank = -1;
			Talents = talents;
			Entry = entry;
			Rank = rank;
		}
Exemple #4
0
 /// <summary>
 /// Sends a request to wipe all talents, which must be confirmed by the player
 /// </summary>
 public static void SendClearQuery(TalentCollection talents)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.MSG_TALENT_WIPE_CONFIRM, 12))
     {
         packet.Write((ulong)talents.Owner.EntityId);
         packet.Write(talents.GetResetPrice());
         talents.OwnerCharacter.Send(packet, false);
     }
 }
Exemple #5
0
        /// <summary>
        /// Sends a request to wipe all talents, which must be confirmed by the player
        /// </summary>
        public static void SendClearQuery(TalentCollection talents)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_TALENT_WIPE_CONFIRM, 12))
            {
                packet.Write(talents.Owner.EntityId);
                packet.Write(talents.GetResetPrice());

                talents.OwnerCharacter.Send(packet);
            }
        }
Exemple #6
0
        public static void HandleLearnTalent(IRealmClient client, RealmPacketIn packet)
        {
            TalentId         id      = (TalentId)packet.ReadUInt32();
            int              rank    = packet.ReadInt32();
            TalentCollection talents = client.ActiveCharacter.Talents;

            if (talents.Learn(id, rank) == null)
            {
                return;
            }
            TalentHandler.SendTalentGroupList(talents);
        }
Exemple #7
0
        public static void HandleSaveTalentGroup(IRealmClient client, RealmPacketIn packet)
        {
            int num = packet.ReadInt32();
            TalentCollection talents = client.ActiveCharacter.Talents;

            for (int index = 0; index < num; ++index)
            {
                TalentId id   = (TalentId)packet.ReadUInt32();
                int      rank = packet.ReadInt32();
                talents.Learn(id, rank);
            }

            TalentHandler.SendTalentGroupList(talents);
        }
Exemple #8
0
        public static void HandlePetLearnTalent(IRealmClient client, RealmPacketIn packet)
        {
            EntityId  id1             = packet.ReadEntityId();
            Character activeCharacter = client.ActiveCharacter;
            NPC       npc             = activeCharacter.Map.GetObject(id1) as NPC;

            if (npc == null || !npc.IsAlive || npc != activeCharacter.ActivePet)
            {
                return;
            }
            TalentCollection talents = npc.Talents;
            TalentId         id2     = (TalentId)packet.ReadUInt32();
            int rank = packet.ReadInt32();

            talents.Learn(id2, rank);
            TalentHandler.SendTalentGroupList(talents);
        }
Exemple #9
0
        /// <summary>
        /// Sends the client the list of talents
        /// </summary>
        /// <param name="hasTalents">The IHasTalents to send the list from</param>
        public static void SendTalentGroupList(TalentCollection talents, int talentGroupId)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TALENTS_INFO))
            {
                var owner = talents.Owner;
                var isPlayer = owner is Character;

                packet.Write((byte)(isPlayer ? 0 : 1));
                if (isPlayer)
                {
                    WritePlayerTalentList(packet, (Character)owner, talentGroupId);
                }
                else
                {
                    packet.Write(talents.FreeTalentPoints);
                    packet.Write((byte)talents.Count);
                    foreach (var talent in talents)
                    {
                        packet.Write((int)talent.Entry.Id);
                        packet.Write((byte)talent.Rank);
                    }
                }
                talents.OwnerCharacter.Send(packet);
            }
        }
Exemple #10
0
 public static void SendTalentGroupList(TalentCollection talents)
 {
     SendTalentGroupList(talents, talents.CurrentSpecIndex);
 }
Exemple #11
0
		/// <summary>
		/// Creates a new character and loads all required character data from the database
		/// </summary>
		/// <param name="acc">The account the character is associated with</param>
		/// <param name="record">The name of the character to load</param>
		/// <param name="client">The client to associate with this character</param>
		internal protected void Create(RealmAccount acc, CharacterRecord record, IRealmClient client)
		{			client.ActiveCharacter = this;
			acc.ActiveCharacter = this;

			Type |= ObjectTypes.Player;
			ChatChannels = new List<ChatChannel>();

			m_logoutTimer = new TimerEntry(0.0f, DefaultLogoutDelay, totalTime => FinishLogout());

			Account = acc;
			m_client = client;

			m_record = record;
			EntityId = EntityId.GetPlayerId(m_record.EntityLowId);
			m_name = m_record.Name;

			Archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
			MainWeapon = GenericWeapon.Fists;
			PowerType = m_archetype.Class.PowerType;

			StandState = StandState.Sit;

			Money = (uint)m_record.Money;
			Outfit = m_record.Outfit;
			//ScaleX = m_archetype.Race.Scale;
			ScaleX = 1;
			Gender = m_record.Gender;
			Skin = m_record.Skin;
			Facial = m_record.Face;
			HairStyle = m_record.HairStyle;
			HairColor = m_record.HairColor;
			FacialHair = m_record.FacialHair;
			UnitFlags = UnitFlags.PlayerControlled;
			XP = m_record.Xp;
			RestXp = m_record.RestXp;
			Level = m_record.Level;
			NextLevelXP = XpGenerator.GetXpForlevel(m_record.Level + 1);
			MaxLevel = RealmServerConfiguration.MaxCharacterLevel;

			RestState = RestState.Normal;

			Orientation = m_record.Orientation;

			m_bindLocation = new ZoneWorldLocation(
				m_record.BindRegion,
				new Vector3(m_record.BindX, m_record.BindY, m_record.BindZ),
				m_record.BindZone);

			PvPRank = 1;
			YieldsXpOrHonor = true;

			foreach (var school in WCellDef.AllDamageSchools)
			{
				SetInt32(PlayerFields.MOD_DAMAGE_DONE_PCT + (int)school, 1);
			}
			SetFloat(PlayerFields.DODGE_PERCENTAGE, 1.0f);

			// Auras
			m_auras = new PlayerAuraCollection(this);

			// spells
			PlayerSpellCollection spells;
			if (!record.JustCreated && SpellHandler.PlayerSpellCollections.TryGetValue(EntityId.Low, out spells))
			{
				SpellHandler.PlayerSpellCollections.Remove(EntityId.Low);
				m_spells = spells;
				((PlayerSpellCollection)m_spells).OnReconnectOwner(this);
			}
			else
			{
				m_spells = new PlayerSpellCollection(this);
			}

			// factions
			WatchedFaction = m_record.WatchedFaction;
			Faction = FactionMgr.ByRace[(uint)record.Race];
			m_reputations = new ReputationCollection(this);

			// skills
			m_skills = new SkillCollection(this);

			// talents
			m_talents = new TalentCollection(this);

			// Items
			m_inventory = new PlayerInventory(this);

			m_mailAccount = new MailAccount(this);

			m_questLog = new QuestLog(this);

			// Talents
			m_record.SpecProfile = SpecProfile.NewSpecProfile(this);
			FreeTalentPoints = m_record.FreeTalentPoints;

			// tutorial flags
			TutorialFlags = new TutorialFlags(m_record.TutorialFlags);

			// Make sure client and internal state is updated with combat base values
			UnitUpdates.UpdateSpellCritChance(this);

			// Mask of activated TaxiNodes
			m_taxiNodeMask = new TaxiNodeMask();

			PowerCostMultiplier = 1f;

			m_lastPlayTimeUpdate = DateTime.Now;

			MoveControl.Mover = this;
			MoveControl.CanControl = true;

			BaseHealth = m_record.BaseHealth;
			SetBasePowerDontUpdate(m_record.BasePower);

			SetBaseStat(StatType.Strength, m_record.BaseStrength);
			SetBaseStat(StatType.Stamina, m_record.BaseStamina);
			SetBaseStat(StatType.Spirit, m_record.BaseSpirit);
			SetBaseStat(StatType.Intellect, m_record.BaseIntellect);
			SetBaseStat(StatType.Agility, m_record.BaseAgility);

			CanMelee = true;

			// basic setup
			if (record.JustCreated)
			{
				Power = PowerType == PowerType.Rage ? 0 : MaxPower;
				SetInt32(UnitFields.HEALTH, MaxHealth);
			}
			else
			{
				Power = m_record.Power;
				SetInt32(UnitFields.HEALTH, m_record.Health);
			}

		}
Exemple #12
0
 public static void SendTalentGroupList(TalentCollection talents)
 {
     SendTalentGroupList(talents, talents.CurrentSpecIndex);
 }
Exemple #13
0
		internal Talent(TalentCollection talents, TalentEntry entry)
		{
			Talents = talents;
			Entry = entry;
		}
Exemple #14
0
		protected internal virtual void SetupNPC(NPCEntry entry, SpawnPoint spawnPoint)
		{
			// auras
			m_auras = new NPCAuraCollection(this);

			var mainWeapon = entry.CreateMainHandWeapon();

			SpawnEntry spawnEntry;
			if (spawnPoint != null)
			{
				// Spawn-specific information
				spawnEntry = spawnPoint.SpawnEntry;
				m_spawnPoint = spawnPoint;
				Phase = spawnEntry.PhaseMask;
				m_orientation = spawnEntry.Orientation;
				if (spawnEntry.MountId != 0)
				{
					Mount(spawnEntry.MountId);
				}

				if (spawnEntry.DisplayIdOverride != 0)
				{
					DisplayId = spawnEntry.DisplayIdOverride;
				}

				SetUInt32(UnitFields.BYTES_0, spawnEntry.Bytes);
				SetUInt32(UnitFields.BYTES_2, spawnEntry.Bytes2);
			}
			else
			{
				Phase = 1;
				spawnEntry = entry.FirstSpawnEntry;
			}

			EmoteState = (spawnEntry != null && spawnEntry.EmoteState != 0) ? spawnEntry.EmoteState : entry.EmoteState;
			Entry = entry;
			NativeDisplayId = DisplayId;

			// misc stuff
			Faction = entry.Faction;
			NPCFlags = entry.NPCFlags;
			UnitFlags = entry.UnitFlags;
			DynamicFlags = entry.DynamicFlags;
			Class = entry.ClassId;
			Race = entry.RaceId;
			YieldsXpOrHonor = entry.GeneratesXp;
			SheathType = SheathType.Melee;

			// speeds
			m_runSpeed = entry.RunSpeed;
			m_swimSpeed = entry.RunSpeed;
			m_swimBackSpeed = entry.RunSpeed;
			m_walkSpeed = entry.WalkSpeed;
			m_walkBackSpeed = entry.WalkSpeed;
			m_flightSpeed = entry.FlySpeed;
			m_flightBackSpeed = entry.FlySpeed;

			Array.Copy(entry.Resistances, m_baseResistances, m_baseResistances.Length);

			MainWeapon = mainWeapon;

			// Set Level/Scale *after* MainWeapon is set:
			var level = entry.GetRandomLevel();
			Level = level;

			// Set model after Scale
			Model = m_entry.GetRandomModel();

			m_gossipMenu = entry.DefaultGossip; // set gossip menu

			// TODO: Init stats
			//for (int i = 0; i < 5; i++)
			//{
			//    m_baseStats[i] = statVal;
			//}
			PowerType = PowerType.Mana;
			SetBaseStat(StatType.Strength, 1, false);
			SetBaseStat(StatType.Agility, 1, false);
			SetBaseStat(StatType.Intellect, 1, false);
			SetBaseStat(StatType.Stamina, 1, false);
			SetBaseStat(StatType.Spirit, 1, false);

			// health + power
			var health = entry.GetRandomHealth();
			SetUInt32(UnitFields.MAXHEALTH, health);
			SetUInt32(UnitFields.BASE_HEALTH, health);

			if (spawnEntry == null || !spawnEntry.IsDead)
			{
				SetUInt32(UnitFields.HEALTH, health);
			}

			var mana = entry.GetRandomMana();
			SetInt32(UnitFields.MAXPOWER1, mana);
			SetInt32(UnitFields.BASE_MANA, mana);
			SetInt32(UnitFields.POWER1, mana);

			OffHandWeapon = entry.CreateOffhandWeapon();
			RangedWeapon = entry.CreateRangedWeapon();

			HoverHeight = entry.HoverHeight;

			m_Movement = new Movement(this);

			PowerCostMultiplier = 1f;

			if (PowerType == PowerType.Mana)
			{
				ManaRegenPerTickInterruptedPct = 20;
			}

			HealthRegenPerTickNoCombat = BaseHealth / 5;

			UpdateUnitState();

			if (m_entry.InhabitType.HasFlag(InhabitType.Air))
			{
				Flying++;
			}

			if (m_entry.Spells != null)
			{
				EnsureSpells();
			}

			if (m_entry.Type == NPCType.Totem || m_entry.Type == NPCType.None)
			{
				m_Movement.MayMove = false;
			}

			AddEquipment();

			CanMelee = mainWeapon != GenericWeapon.Peace;

			// TODO: Don't create talents if this is not a pet
			m_petTalents = new TalentCollection(this);

			m_brain = m_entry.BrainCreator(this);
			m_brain.IsRunning = true;
		}