示例#1
0
        public ZonePlayer(short entityId, Data.Character toon, ushort zoneId, Client client)
            : base(entityId, toon.Name, toon.Surname, toon.X, toon.Y, toon.Z, toon.Heading.Value)
        {
            this.Client = client;
            _acctId = toon.AccountID;
            _charId = toon.CharacterID;
            _acctStatus = toon.Account.Status;
            _connState = ZoneConnectionState.Connecting;

            // TODO: change storage to the cached profile

            _pp.ZoneId = (ushort)zoneId;
            this.Class = toon.Class.Value;
            this.Level = toon.CharLevel;
            _pp.XP = toon.XP;   // Bypass property setter to avoid packet sending
            _pp.Points = toon.PracticePoints.Value;

            _pp.STR = (uint)toon.STR.Value;
            _pp.STA = (uint)toon.STA.Value;
            _pp.DEX = (uint)toon.DEX.Value;
            _pp.AGI = (uint)toon.AGI.Value;
            _pp.INT = (uint)toon.INT.Value;
            _pp.WIS = (uint)toon.WIS.Value;
            _pp.CHA = (uint)toon.CHA.Value;

            this.Race = toon.Race.Value;
            _baseRace = toon.Race.Value;
            this.Gender = toon.Gender.Value;
            _baseGender = toon.Gender.Value;
            this.Deity = (uint)toon.Deity.Value;
            _hairColor = toon.HairColor.Value;
            _hairStyle = toon.HairStyle.Value;
            _beardColor = toon.BeardColor.Value;
            _beard = toon.Beard.Value;
            _eyeColor1 = toon.EyeColor1.Value;
            _eyeColor2 = toon.EyeColor2.Value;
            _luclinFace = toon.Face.Value;
            this.GMStatus = toon.GMStatus;
            this.Platinum = toon.Platinum;
            this.Gold = toon.Gold;
            this.Silver = toon.Silver;
            this.Copper = toon.Copper;

            _pp.Birthday = Utility.TimeTFromDateTime(toon.CreatedDate);
            _pp.LastLogin = _pp.Birthday;
            //_pp.TimePlayedMin = 0;
            _pp.HungerLevel = (uint)toon.HungerLevel.Value;
            _pp.ThirstLevel = (uint)toon.ThirstLevel.Value;
            _pp.Languages = Encoding.ASCII.GetBytes(toon.Languages);

            if (this.X == -1 && this.Y == -1 && this.Z == -1)  // -1 is what these were set to on char creation
            {
                // set to zone safe points
                this.X = toon.Zone.SafeX;
                this.Y = toon.Zone.SafeY;
                this.Z = toon.Zone.SafeZ;

                _log.Debug("Char coords set to safe points");
            }

            // TODO: factions

            // TODO: old emu has code for invalid Z position fix

            _invMgr = new InventoryManager(toon.InventoryItems, this);
            _invMgr.ItemChargeUsed += new EventHandler<ItemChargeUseEventArgs>(InvMgr_ItemChargeUsed);
            _invMgr.ItemMoved += new EventHandler<ItemMoveEventArgs>(InvMgr_ItemMoved);

            // TODO: guild stuff
            _pp.GuildRank = (byte)Guild.GuildRank.None;   // TODO: implement guild tables and fetch this live

            _size = Mob.GetSize((CharRaces)_race);

            // TODO: AAs

            // Spells
            foreach (ScribedSpell ss in toon.ScribedSpells)
                _pp.SpellBook[ss.SlotID] = ss.SpellID;

            foreach (MemorizedSpell ms in toon.MemorizedSpells) {
                _pp.MemSpells[ms.SlotID] = ms.SpellID;
                _memdSpells[ms.SlotID] = ms.Spell;
            }

            // TODO: buffs?
            for (int i = 0; i < Character.MAX_BUFF; i++)    // blank out the buffs spell id
                Buffer.BlockCopy(BitConverter.GetBytes((uint)Spell.BLANK_SPELL), 0, _pp.BuffsBlob, (20 * i) + 4, 4);
                //_pp.BuffsBlob[i] = 0xFF;

            // TODO: binds
            _pp.Binds[0].ZoneId = (uint)zoneId;
            _pp.Binds[0].X = this.X;
            _pp.Binds[0].Y = this.Y;
            _pp.Binds[0].Z = this.Z;
            _pp.Binds[0].Heading = this.Heading;

            _pp.Mana = 0u;  // TODO: Mana
            _pp.HP = (uint)toon.HP.Value;
            _curHP = toon.HP.Value; // Bypass property settors to avoid packet sending

            CalcStatModifiers();    // Calculate stats (ac, attack, hp, bonuses, etc.)

            if (_pp.HP <= 0) {
                _pp.HP = (uint)this.MaxHP;  // If they were dead, let's set things back to full
                _curHP = this.MaxHP;
            }

            _pp.Endurance = _maxEndurance;

            // TODO: group shit

            // TODO: once zone init is coded, do underworld checks

            // Skills
            for (int i = 0; i < toon.Skills.Length; i++)
                _pp.Skills[i] = (uint)toon.Skills[i];   // may want to turn the db representation into an nchar if skill levels get > 255

            // TODO: tribute
            _pp.TributeTimeRemaining = uint.MaxValue;

            InitPlayerProfile();

            // Init timers
            int autoSaveInterval = WorldServer.ServerConfig.AutosaveIntervalSec * 1000;
            _autoSaveTimer = new Timer(new TimerCallback(AutosaveTimerCallback), null, autoSaveInterval, autoSaveInterval);
            _ldTimer = new SimpleTimer(0);
            _deadTimer = new SimpleTimer(0);
            _hpUpdateTimer = new SimpleTimer(0);
            _campTimer = new SimpleTimer(0);

            _msgMgr = new MessagingManager(this);
        }
示例#2
0
 /// <summary>Sends the provided packet to all clients that meet the specified zone connection state.</summary>
 internal void QueuePacketToClients(Mob sender, EQRawApplicationPacket packet, ZoneConnectionState reqConnState, bool skipSender)
 {
     QueuePacketToClients(sender, packet, reqConnState, skipSender, true);
 }
示例#3
0
        internal void QueuePacketToClients(Mob sender, EQRawApplicationPacket packet, ZoneConnectionState reqConnState, bool skipSender, bool ackReq)
        {
            foreach (Client client in this.GetConnectedClients())
            {
                if (client.ZonePlayer == null || (client.ZonePlayer == sender && skipSender))
                    continue;   // Don't send to a client before its zonePlayer is set or to self if skip set

                QueuePacketToClient(client, packet, ackReq, reqConnState);
            }
        }
示例#4
0
        internal void QueuePacketToClient(Client client, EQRawApplicationPacket appPacket, bool ackReq, ZoneConnectionState reqConnState)
        {
            // TODO: when messaging filters are in, add support here

            // See if the packet should be deferred for later sending when the client is "connected"
            if (reqConnState == ZoneConnectionState.All || client.ZonePlayer.ConnectionState == reqConnState)
                client.SendApplicationPacket(appPacket);
            else
                client.ZonePlayer.AddDeferredPacket(new DeferredPacket(appPacket, true));
        }