Esempio n. 1
0
        public void Initialize(Player player)
        {
            ForEnemy = false;

            MemberGuid = player.GetGUID();

            // Status
            MemberStats.Status = GroupMemberOnlineStatus.Online;

            if (player.IsPvP())
            {
                MemberStats.Status |= GroupMemberOnlineStatus.PVP;
            }

            if (!player.IsAlive())
            {
                if (player.HasFlag(PlayerFields.Flags, PlayerFlags.Ghost))
                {
                    MemberStats.Status |= GroupMemberOnlineStatus.Ghost;
                }
                else
                {
                    MemberStats.Status |= GroupMemberOnlineStatus.Dead;
                }
            }

            if (player.IsFFAPvP())
            {
                MemberStats.Status |= GroupMemberOnlineStatus.PVPFFA;
            }

            if (player.isAFK())
            {
                MemberStats.Status |= GroupMemberOnlineStatus.AFK;
            }

            if (player.isDND())
            {
                MemberStats.Status |= GroupMemberOnlineStatus.DND;
            }

            if (player.GetVehicle())
            {
                MemberStats.Status |= GroupMemberOnlineStatus.Vehicle;
            }

            // Level
            MemberStats.Level = (ushort)player.getLevel();

            // Health
            MemberStats.CurrentHealth = (int)player.GetHealth();
            MemberStats.MaxHealth     = (int)player.GetMaxHealth();

            // Power
            MemberStats.PowerType      = (byte)player.GetPowerType();
            MemberStats.PowerDisplayID = 0;
            MemberStats.CurrentPower   = (ushort)player.GetPower(player.GetPowerType());
            MemberStats.MaxPower       = (ushort)player.GetMaxPower(player.GetPowerType());

            // Position
            MemberStats.ZoneID    = (ushort)player.GetZoneId();
            MemberStats.PositionX = (short)player.GetPositionX();
            MemberStats.PositionY = (short)(player.GetPositionY());
            MemberStats.PositionZ = (short)(player.GetPositionZ());

            MemberStats.SpecID               = (ushort)player.GetUInt32Value(PlayerFields.CurrentSpecId);
            MemberStats.PartyType[0]         = (sbyte)(player.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType) & 0xF);
            MemberStats.PartyType[1]         = (sbyte)(player.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType) >> 4);
            MemberStats.WmoGroupID           = 0;
            MemberStats.WmoDoodadPlacementID = 0;

            // Vehicle
            if (player.GetVehicle() && player.GetVehicle().GetVehicleInfo() != null)
            {
                MemberStats.VehicleSeat = player.GetVehicle().GetVehicleInfo().SeatID[player.m_movementInfo.transport.seat];
            }

            // Auras
            foreach (AuraApplication aurApp in player.GetVisibleAuras())
            {
                PartyMemberAuraStates aura = new PartyMemberAuraStates();
                aura.SpellID     = (int)aurApp.GetBase().GetId();
                aura.ActiveFlags = aurApp.GetEffectMask();
                aura.Flags       = (byte)aurApp.GetFlags();

                if (aurApp.GetFlags().HasAnyFlag(AuraFlags.Scalable))
                {
                    foreach (AuraEffect aurEff in aurApp.GetBase().GetAuraEffects())
                    {
                        if (aurEff == null)
                        {
                            continue;
                        }

                        if (aurApp.HasEffect(aurEff.GetEffIndex()))
                        {
                            aura.Points.Add((float)aurEff.GetAmount());
                        }
                    }
                }

                MemberStats.Auras.Add(aura);
            }

            // Phases
            PhasingHandler.FillPartyMemberPhase(MemberStats.Phases, player.GetPhaseShift());

            // Pet
            if (player.GetPet())
            {
                Pet pet = player.GetPet();

                MemberStats.PetStats.HasValue = true;

                MemberStats.PetStats.Value.GUID    = pet.GetGUID();
                MemberStats.PetStats.Value.Name    = pet.GetName();
                MemberStats.PetStats.Value.ModelId = (short)pet.GetDisplayId();

                MemberStats.PetStats.Value.CurrentHealth = (int)pet.GetHealth();
                MemberStats.PetStats.Value.MaxHealth     = (int)pet.GetMaxHealth();

                foreach (AuraApplication aurApp in pet.GetVisibleAuras())
                {
                    PartyMemberAuraStates aura = new PartyMemberAuraStates();

                    aura.SpellID     = (int)aurApp.GetBase().GetId();
                    aura.ActiveFlags = aurApp.GetEffectMask();
                    aura.Flags       = (byte)aurApp.GetFlags();

                    if (aurApp.GetFlags().HasAnyFlag(AuraFlags.Scalable))
                    {
                        foreach (AuraEffect aurEff in aurApp.GetBase().GetAuraEffects())
                        {
                            if (aurEff == null)
                            {
                                continue;
                            }

                            if (aurApp.HasEffect(aurEff.GetEffIndex()))
                            {
                                aura.Points.Add((float)aurEff.GetAmount());
                            }
                        }
                    }

                    MemberStats.PetStats.Value.Auras.Add(aura);
                }
            }
        }