/// <summary>
        /// </summary>
        /// <param name="ServerInstruction">
        /// </param>
        public SpawnAvatar(string ServerInstruction) : base(ServerInstruction)
        {
            //Update What type we are
            if (ServerInstruction[0] == '<')
            {
                instructionType = ServerInstructionType.SpawnAvatar;
            }

            int ColTypePos = (ServerInstruction[ConvertFromBase220(ServerInstruction[11])] == 'w') ? 16 : 14;

            PlayerFlags = new CharacterFlags(ServerInstruction[ColTypePos]);

            Player = new Furre(ConvertFromBase220(ServerInstruction.Substring(1, 4)))
            {
                Name        = ServerInstruction.Substring(12, ConvertFromBase220(ServerInstruction[11])),
                Location    = new FurrePosition(ServerInstruction.Substring(5, 4)),
                Direction   = (AvatarDirection)ConvertFromBase220(ServerInstruction.Substring(9, 1)),
                Pose        = (FurrePose)ConvertFromBase220(ServerInstruction.Substring(10, 1)),
                AfkTime     = ConvertFromBase220(ServerInstruction.Substring(ColTypePos + 1, 4)),
                FurreColors = new ColorString(ServerInstruction.Substring(ColTypePos, (ServerInstruction[ColTypePos] == 'w') ? 16 : 14))
            };

            //player.kittersize

            // reserverd for Future updates as Character Profiles come into existance
            //if (PlayerFlags.HasFlag(CHAR_FLAG_HAS_PROFILE))
            //{
            //}
        }
Пример #2
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.CharacterCharacterFlags = ((CharacterFlags)(binaryReader.ReadInt32()));
     this.ParentCharacter         = binaryReader.ReadTagReference();
     this.Unit           = binaryReader.ReadTagReference();
     this.Creature       = binaryReader.ReadTagReference();
     this.Style          = binaryReader.ReadTagReference();
     this.MajorCharacter = binaryReader.ReadTagReference();
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(12));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(12));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(112));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(52));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(52));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(80));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(36));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(40));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(64));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(20));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(64));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(76));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(20));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(36));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(12));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(12));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(204));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(60));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(180));
     return(pointerQueue);
 }
Пример #3
0
        // Methods
        public EnterChatResponse(byte[] data) : base(data)
        {
            this.clientVersion  = -1;
            this.characterType  = BattleNetCharacter.Unknown;
            this.characterLevel = -1;
            this.characterAct   = -1;
            this.characterTitle = CharacterTitle.None;
            this.username       = ByteConverter.GetNullString(data, 3);
            int startIndex = 4 + this.username.Length;

            this.client = (BattleNetClient)BitConverter.ToUInt32(data, startIndex);
            if (data[startIndex += 4] == 0)
            {
                this.account = ByteConverter.GetNullString(data, startIndex + 1);
            }
            else
            {
                this.realm  = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.realm.Length;
                this.name   = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.name.Length;
                int num2 = ByteConverter.GetByteOffset(data, 0, startIndex);
                this.account = ByteConverter.GetNullString(data, (startIndex + num2) + 1);
                if (this.client == BattleNetClient.Diablo2LoD)
                {
                    this.characterFlags |= CharacterFlags.Expansion;
                }
                StatString.ParseD2StatString(data, startIndex, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
            }
        }
 public CharacterCreationRequest(byte[] data)
     : base(data)
 {
     this.Class = (CharacterClass)BitConverter.ToUInt32(data, 1);
     this.Flags = (CharacterFlags)BitConverter.ToUInt16(data, 5);
     this.Name  = ByteConverter.GetNullString(data, 7);
 }
Пример #5
0
        public Character(DocumentEntry entry, int relativeTextOffset, byte ch, CombinedColor color, CharacterFlags flags, byte layer = 0, sbyte shiftX = 0, sbyte shiftY = 0)
        {
            Char  = ch;
            Color = color;
            Entry = entry;
            Flags = flags;
            RelativeTextOffset = relativeTextOffset;

            Layer  = layer;
            ShiftX = shiftX;
            ShiftY = shiftY;
        }
 public void ChangeFlagForAllMembers(CharacterFlags inFlag, bool inSet)
 {
     for (int i = 0; i < members.Count; i++)
     {
         if (inSet)
         {
             members[i].SetFlags(inFlag);
         }
         else
         {
             members[i].UnsetFlags(inFlag);
         }
     }
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     // If player enters the area ...
     if (_playerLayer == (_playerLayer | (1 << collision.gameObject.layer)))
     {
         // Check flag to true
         _isPlayerIn = true;
         // Get component from player gameObject
         _characterFlags = collision.gameObject.GetComponent <CharacterFlags>();
         // Check flag to true
         if (_characterFlags != null)
         {
             _characterFlags.IsInGlideImpulseZone = true;
         }
     }
 }
 private void OnTriggerExit2D(Collider2D collision)
 {
     // If player leaves the area ...
     if (_playerLayer == (_playerLayer | (1 << collision.gameObject.layer)))
     {
         // Check flag to false
         _isPlayerIn = false;
         // Check flag to false
         if (_characterFlags != null)
         {
             _characterFlags.IsInGlideImpulseZone = false;
         }
         // Put reference to null
         _characterFlags = null;
         // Player leaves area, disable component
         _areaEffector2D.enabled = false;
     }
 }
Пример #9
0
    public Character(int maxTraits, int minLevel, int maxLevel)
    {
        GameObject.Find("GameController").GetComponent <GameController> ().CharacterDatabase.AssignID(this);
        SecondWindActive      = false;
        SecondWindEnergyGain  = 200;
        LevelUpThreshold      = 1000;
        SkillAdvanceThreshold = 1000;
        //TODO: Replace Array here with dynamic list, and the demands for executing one with a matching string in list
        //Alternatively, a game object or class instance per special move?
        SpecialMovesKnown      = new bool[2];
        RandomBonusRange       = 5;
        RandomHealthBonusRange = 100;
        RandomEnergyBonusRange = 400;

        UsedSpecialMoveThisTurn   = false;
        TurnsSinceLastSpecialMove = 0;
        IsInTeam = false;
        Traits   = new List <Trait>();
        TraitList    traitList  = new TraitList();
        List <Trait> allTraits  = traitList.GetTrait();
        RaceList     races      = new RaceList();
        List <Race>  allRaces   = races.GetRace();
        ClassList    classes    = new ClassList();
        List <Class> allClasses = classes.GetFClass();

        Level = 1;
        SetRace(allRaces);
        SetGender();
        SetAge();
        SetName();
        SetTraits(allTraits, maxTraits);
        SetFClass(allClasses);
        SetAllStats();
        SetBaseSpecialMoves();
        SetRandomFightMoneyCut();
        InitialLeveling(minLevel, maxLevel);
        CurrentHealth = MaxHealth;
        CurrentEnergy = MaxEnergy;

        ExperiencePoints = 0;

        Relations      = new CharacterRelations();
        CharacterFlags = new CharacterFlags();
    }
Пример #10
0
 public void SetFlags(CharacterFlags inFlags)
 {
     flags |= inFlags;
 }
    public static void CreateEnemyCharacters()
    {
        enemyCollection = new Dictionary <string, EnemyCharacterData>();

        //use this line to load from a json file
        //EnemyCharacterMap map = Utils.LoadJsonFromPath<EnemyCharacterMap>(inPath);

        /*
         *     {"id":"1:rat",                                                  "area": "CAVERNS|JAIL",     "rank":"NORM",        "size": "MD",               "base_stats" : ["hp=2",     "atk=1",      "spd=default"],                "spawn_rate": 1,        "area_spawn_range": "0-50",       "drop_rate":"3",                "drops": "6",                                                                   "fps":4,        "frames":3,           "shadow_size": 7,      "shadow_offset":0,         "fly_height": 0,        "fly_speed": 0,          "projectile_spawn_offset":"0,0",          "fade_amt":0,              "flags": "CANT_STRIKE",                                                      "variable_target_preference":1,     "skills":"CLAW"},
         *     {"id":"11:tunneler",                                          "area": "CAVERNS",          "rank":"MBOS",        "size": "LG",               "base_stats" : ["hp=8",     "atk=2",      "spd=default"],                "spawn_rate": 1,        "area_spawn_range": "0-50",       "drop_rate":"1",                "drops": "3",                                                                   "fps":4,        "frames":3,           "shadow_size": 0,      "shadow_offset":0,         "fly_height": 0,        "fly_speed": 0,          "projectile_spawn_offset":"0,0",          "fade_amt":0,              "flags": "IN_GROUND",                                                        "variable_target_preference":1,     "skills":""},
         *     {"id":"13:dragon",                                          "area": "CAVERNS",          "rank":"BOSS",        "size": "XL",               "base_stats" : ["hp=28",    "atk=3",      "spd=default"],                "spawn_rate": 1,        "area_spawn_range": "0-50",       "drop_rate":"50",               "drops": "55",                                                                  "fps":4,        "frames":3,           "shadow_size": 23,     "shadow_offset":0,         "fly_height": 30,       "fly_speed": 10,         "projectile_spawn_offset":"0,0",          "fade_amt":0,              "flags": "",                                                                 "variable_target_preference":1,     "skills":"METEOR"},
         */

        //instead, create the data manually
        var ratData = new EnemyCharacterRow()
        {
            id = "1:" + EnemyId.RAT, area = "CAVERNS|JAIL", rank = "NORM", size = "MD", base_stats = new string[] { "hp=2", "atk=1", "spd=default" }, spawn_rate = 1, area_spawn_range = "0-50", drop_rate = "3", drops = "6", flags = "", variable_target_preference = 1, skills = ""
        };
        var tunnelerData = new EnemyCharacterRow()
        {
            id = "11:" + EnemyId.TUNNELER, area = "CAVERNS", rank = "MBOS", size = "MD", base_stats = new string[] { "hp=8", "atk=2", "spd=default" }, spawn_rate = 1, area_spawn_range = "0-50", drop_rate = "1", drops = "", flags = "IN_GROUND", variable_target_preference = 1, skills = ""
        };
        var dragonData = new EnemyCharacterRow()
        {
            id = "13:" + EnemyId.DRAGON, area = "CAVERNS", rank = "BOSS", size = "MD", base_stats = new string[] { "hp=28", "atk=3", "spd=default" }, spawn_rate = 1, area_spawn_range = "0-50", drop_rate = "50", drops = "", flags = "", variable_target_preference = 1, skills = "METEOR"
        };

        EnemyCharacterMap map = new EnemyCharacterMap();

        map.enemy_characters = new EnemyCharacterRow[] { ratData, tunnelerData, dragonData };

        EnemyCharacterRow  row;
        EnemyCharacterData tempCharacter;

        string[] idPieces;

        for (int i = 0; i < map.enemy_characters.Length; i++)
        {
            row           = map.enemy_characters[i];
            tempCharacter = new EnemyCharacterData();
            tempCharacter.Init();

            idPieces = row.id.Split(':');
            int storageId = int.Parse(idPieces[0]);

            tempCharacter.SetId(idPieces[1]);
            tempCharacter.SetStorageId(storageId);
            tempCharacter.SetSpecies(Species.CREATURE);
            tempCharacter.SetBaseFaction(Faction.ENEMY);

            Stats.ParseArrayIntoStatObject(row.base_stats, tempCharacter.baseStats);

            tempCharacter.spawnAreas = Utils.ParseStringToFlagEnum <AdventureArea>(row.area, '|');

            EnemyRank parsedRank = (EnemyRank)Enum.Parse(typeof(EnemyRank), row.rank);
            EnemySize parsedSize = (EnemySize)Enum.Parse(typeof(EnemySize), row.size);
            tempCharacter.SetRankAndSize(parsedRank, parsedSize);

            int      spawnRate = row.spawn_rate;
            string[] rangeInfo = row.area_spawn_range.Split('-');
            if (rangeInfo.Length != 2)
            {
                throw new Exception("Spawn range for enemy " + row.id + " is not exactly two elements");
            }
            int minSpawnRange = int.Parse(rangeInfo[0]);
            int maxSpawnRange = int.Parse(rangeInfo[1]);
            tempCharacter.SetSpawnValues(spawnRate, minSpawnRange, maxSpawnRange);

            string[] drops = row.drops == "" ? new string[] { } : row.drops.Split('|');
            for (int j = 0; j < drops.Length; j++)
            {
                if (!ItemId.IsValid(drops[j]))
                {
                    throw new Exception("Item drop id '" + drops[j] + "' is not valid");
                }
            }

            int dropRate = 9;
            if (row.drop_rate != "default")
            {
                dropRate = int.Parse(row.drop_rate);
            }
            tempCharacter.SetItemDrops(dropRate, drops);

            tempCharacter.SetVisualValues(row.fps, row.frames, row.shadow_size, row.shadow_offset, row.fade_amt);
            tempCharacter.SetFlightValue(row.fly_height, row.fly_speed);

            CharacterFlags flags = Utils.ParseStringToFlagEnum <CharacterFlags>(row.flags, ',');
            flags |= CharacterFlags.CANT_DEFEND;
            tempCharacter.SetFlags(flags);
            tempCharacter.SetVariableTargetPreference(row.variable_target_preference);

            if (row.skills.Length > 0)
            {
                tempCharacter.SetBaseSkills(row.skills.Split(','));
            }

            //was the cant strike flag set? only allow this if the enemy has at least one other skill that costs 0 mp
            if (tempCharacter.FlagIsSet(CharacterFlags.CANT_STRIKE))
            {
                if (tempCharacter.baseSkills[0].mpCost != 0)
                {
                    throw new Exception("0 mp Default skill not provided for enemy " + row.id + " (cant_strike flag set)");
                }
            }

            enemyCollection.Add(tempCharacter.id, tempCharacter);
            characterCollection.Add(tempCharacter.id, tempCharacter);
        }

        enemyCollectionList = enemyCollection.Values.ToList();

        if (enemyCollection.Count > GameContext.MAX_NUM_ENEMIES_SUPPPORTED)
        {
            throw new Exception("Loaded " + enemyCollection.Count + " enemy types but game only allows a max of " + GameContext.MAX_NUM_ENEMIES_SUPPPORTED);
        }
    }
Пример #12
0
 // Methods
 public ChatEvent(byte[] data)
     : base(data)
 {
     this.clientVersion = -1;
     this.characterType = BattleNetCharacter.Unknown;
     this.characterLevel = -1;
     this.characterAct = -1;
     this.characterTitle = CharacterTitle.None;
     this.eventType = (ChatEventType) BitConverter.ToUInt32(data, 3);
     this.flags = BitConverter.ToUInt32(data, 7);
     this.ping = BitConverter.ToUInt32(data, 11);
     int length = ByteConverter.GetByteOffset(data, 0, 0x1b);
     int num2 = ByteConverter.GetByteOffset(data, 0x2a, 0x1b, length);
     if (num2 > 0)
     {
     this.name = ByteConverter.GetString(data, 0x1b, num2);
     length -= num2 + 1;
     num2 += 0x1c;
     }
     else if (num2 == 0)
     {
     num2 = 0x1c;
     length--;
     this.characterType = BattleNetCharacter.OpenCharacter;
     }
     else
     {
     num2 = 0x1b;
     }
     this.account = ByteConverter.GetString(data, num2, length);
     length += num2 + 1;
     if (this.eventType != ChatEventType.ChannelLeave)
     {
     if ((this.eventType == ChatEventType.ChannelJoin) || (this.eventType == ChatEventType.ChannelUser))
     {
         if ((data.Length - length) > 3)
         {
             this.client = (BattleNetClient) BitConverter.ToUInt32(data, length);
             length += 4;
         }
         if ((((this.client != BattleNetClient.StarcraftShareware) && (this.client != BattleNetClient.Starcraft)) && (this.client != BattleNetClient.StarcraftBroodWar)) && ((this.client == BattleNetClient.Diablo2) || (this.client == BattleNetClient.Diablo2LoD)))
         {
             if (this.client == BattleNetClient.Diablo2LoD)
             {
                 this.characterFlags |= CharacterFlags.Expansion;
             }
             if ((data.Length - length) >= 4)
             {
                 this.realm = ByteConverter.GetString(data, length, -1, 0x2c);
                 length += this.realm.Length + 1;
                 if (data.Length >= length)
                 {
                     length += ByteConverter.GetByteOffset(data, 0x2c, length) + 1;
                     if (((length != -1) && (data.Length > length)) && ((data.Length - length) >= 0x21))
                     {
                         StatString.ParseD2StatString(data, length, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
                     }
                 }
             }
         }
     }
     else
     {
         this.message = ByteConverter.GetNullString(data, length);
     }
     }
 }
Пример #13
0
 // Methods
 public EnterChatResponse(byte[] data)
     : base(data)
 {
     this.clientVersion = -1;
     this.characterType = BattleNetCharacter.Unknown;
     this.characterLevel = -1;
     this.characterAct = -1;
     this.characterTitle = CharacterTitle.None;
     this.username = ByteConverter.GetNullString(data, 3);
     int startIndex = 4 + this.username.Length;
     this.client = (BattleNetClient) BitConverter.ToUInt32(data, startIndex);
     if (data[startIndex += 4] == 0)
     {
     this.account = ByteConverter.GetNullString(data, startIndex + 1);
     }
     else
     {
     this.realm = ByteConverter.GetString(data, startIndex, -1, 0x2c);
     startIndex += 1 + this.realm.Length;
     this.name = ByteConverter.GetString(data, startIndex, -1, 0x2c);
     startIndex += 1 + this.name.Length;
     int num2 = ByteConverter.GetByteOffset(data, 0, startIndex);
     this.account = ByteConverter.GetNullString(data, (startIndex + num2) + 1);
     if (this.client == BattleNetClient.Diablo2LoD)
     {
         this.characterFlags |= CharacterFlags.Expansion;
     }
     StatString.ParseD2StatString(data, startIndex, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
     }
 }
Пример #14
0
 public static void ParseD2StatString(byte[] data, int index, ref int clientVersion, ref BattleNetCharacter characterType, ref int characterLevel, ref CharacterFlags characterFlags, ref int characterAct, ref CharacterTitle characterTitle)
 {
     int num2;
     clientVersion = data[index];
     int num = data[index + 13] - 1;
     if ((num < 0) || (num > 6))
     {
         characterType = BattleNetCharacter.Unknown;
     }
     else
     {
         characterType = (BattleNetCharacter)num;
         if (CharactersInfo.Genders[(int)characterType])
         {
             characterFlags |= CharacterFlags.Female;
         }
     }
     characterLevel = data[index + 0x19];
     characterFlags |= (CharacterFlags)data[index + 0x1a];
     int num3 = (data[index + 0x1b] & 0x3e) >> 1;
     if ((characterFlags & CharacterFlags.Expansion) == CharacterFlags.Expansion)
     {
         num2 = num3 / 5;
         num3 = num3 % 5;
     }
     else
     {
         num2 = num3 / 4;
         num3 = num3 % 4;
     }
     if (num2 == 3)
     {
         characterAct = 0x29a;
     }
     else
     {
         characterAct = num3 + 1;
     }
     if ((characterFlags & CharacterFlags.Hardcore) == CharacterFlags.Hardcore)
     {
         num2 |= 4;
     }
     if ((characterFlags & CharacterFlags.Expansion) == CharacterFlags.Expansion)
     {
         num2 |= 0x20;
     }
     if ((characterFlags & CharacterFlags.Female) == CharacterFlags.Female)
     {
         num2 |= 0x100;
     }
     characterTitle = (CharacterTitle)num2;
 }
Пример #15
0
        public static void ParseD2StatString(byte[] data, int index, ref int clientVersion, ref BattleNetCharacter characterType, ref int characterLevel, ref CharacterFlags characterFlags, ref int characterAct, ref CharacterTitle characterTitle)
        {
            int num2;

            clientVersion = data[index];
            int num = data[index + 13] - 1;

            if ((num < 0) || (num > 6))
            {
                characterType = BattleNetCharacter.Unknown;
            }
            else
            {
                characterType = (BattleNetCharacter)num;
                if (CharactersInfo.Genders[(int)characterType])
                {
                    characterFlags |= CharacterFlags.Female;
                }
            }
            characterLevel  = data[index + 0x19];
            characterFlags |= (CharacterFlags)data[index + 0x1a];
            int num3 = (data[index + 0x1b] & 0x3e) >> 1;

            if ((characterFlags & CharacterFlags.Expansion) == CharacterFlags.Expansion)
            {
                num2 = num3 / 5;
                num3 = num3 % 5;
            }
            else
            {
                num2 = num3 / 4;
                num3 = num3 % 4;
            }
            if (num2 == 3)
            {
                characterAct = 0x29a;
            }
            else
            {
                characterAct = num3 + 1;
            }
            if ((characterFlags & CharacterFlags.Hardcore) == CharacterFlags.Hardcore)
            {
                num2 |= 4;
            }
            if ((characterFlags & CharacterFlags.Expansion) == CharacterFlags.Expansion)
            {
                num2 |= 0x20;
            }
            if ((characterFlags & CharacterFlags.Female) == CharacterFlags.Female)
            {
                num2 |= 0x100;
            }
            characterTitle = (CharacterTitle)num2;
        }
 public static extern void AGSCharacter_flags_set(HandleRef jarg1, CharacterFlags jarg2);
Пример #17
0
 public void UnsetFlags(CharacterFlags inFlags)
 {
     flags &= ~inFlags;
 }
Пример #18
0
        public static bool BuildEnumData(SQLResult result, ref PacketWriter data)
        {
            for (int c = 0; c < result.Count; c++)
            {
                ObjectGuid guid      = new ObjectGuid(result.Read <ulong>(c, 0));
                ObjectGuid guildGuid = new ObjectGuid();//result.Read<uint>(c, 13));
                string     name      = result.Read <string>(c, 1);

                data.WriteBit(guid[7]);
                data.WriteBit(guid[0]);
                data.WriteBit(guid[4]);
                data.WriteBit(guildGuid[2]);
                data.WriteBit(guid[5]);
                data.WriteBit(guid[3]);
                data.WriteBits(name.Length, 7);
                data.WriteBit(guildGuid[0]);
                data.WriteBit(guildGuid[5]);
                data.WriteBit(guildGuid[3]);
                data.WriteBit(0);
                data.WriteBit(guildGuid[6]);
                data.WriteBit(guildGuid[7]);
                data.WriteBit(guid[1]);
                data.WriteBit(guildGuid[4]);
                data.WriteBit(guildGuid[1]);
                data.WriteBit(guid[2]);
                data.WriteBit(guid[6]);
            }
            data.WriteBit(1);
            data.BitFlush();

            for (int c = 0; c < result.Count; c++)
            {
                ObjectGuid   guid         = new ObjectGuid(result.Read <ulong>(c, 0));
                string       name         = result.Read <string>(c, 1);
                byte         plrRace      = result.Read <byte>(c, 2);
                Class        plrClass     = (Class)result.Read <byte>(c, 3);
                byte         gender       = result.Read <byte>(c, 4);
                byte         skin         = (byte)(result.Read <uint>(c, 5) & 0xFF);
                byte         face         = (byte)((result.Read <uint>(c, 5) >> 8) & 0xFF);
                byte         hairStyle    = (byte)((result.Read <uint>(c, 5) >> 16) & 0xFF);
                byte         hairColor    = (byte)((result.Read <uint>(c, 5) >> 24) & 0xFF);
                byte         facialHair   = (byte)(result.Read <uint>(c, 6) & 0xFF);
                byte         level        = result.Read <byte>(c, 7);
                uint         zone         = result.Read <uint>(c, 8);
                uint         mapId        = result.Read <uint>(c, 9);
                float        x            = result.Read <float>(c, 10);
                float        y            = result.Read <float>(c, 11);
                float        z            = result.Read <float>(c, 12);
                ObjectGuid   guildGuid    = new ObjectGuid();//result.Read<ulong>(c, 13));
                PlayerFlags  playerFlags  = (PlayerFlags)result.Read <uint>(c, 14);
                AtLoginFlags atLoginFlags = (AtLoginFlags)result.Read <uint>(c, 15);
                string[]     equipment    = result.Read <string>(c, 19).Split(' ');
                byte         slot         = result.Read <byte>(c, 21);

                CharacterFlags charFlags = 0;
                if (Convert.ToBoolean(playerFlags & PlayerFlags.HideHelm))
                {
                    charFlags |= CharacterFlags.HideHelm;
                }

                if (Convert.ToBoolean(playerFlags & PlayerFlags.HideCloak))
                {
                    charFlags |= CharacterFlags.HideCloak;
                }

                if (Convert.ToBoolean(playerFlags & PlayerFlags.Ghost))
                {
                    charFlags |= CharacterFlags.Ghost;
                }

                if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Rename))
                {
                    charFlags |= CharacterFlags.Rename;
                }

                //if (result.Read<uint>(c, 20) != 0)
                //charFlags |= CharacterFlags.LockedByBilling;

                //if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED) && !fields[22].GetString().empty())
                //charFlags |= CHARACTER_FLAG_DECLINED;

                CharacterCustomizeFlags customizationFlag = 0;
                if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Customize))
                {
                    customizationFlag = CharacterCustomizeFlags.Customize;
                }
                else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeFaction))
                {
                    customizationFlag = CharacterCustomizeFlags.Faction;
                }
                else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeRace))
                {
                    customizationFlag = CharacterCustomizeFlags.Race;
                }

                uint petDisplayId = 0;
                uint petLevel     = 0;
                uint petFamily    = 0;
                // show pet at selection character in character list only for non-ghost character
                if (!Convert.ToBoolean(playerFlags & PlayerFlags.Ghost) && (plrClass == Class.Warlock || plrClass == Class.Hunter || plrClass == Class.Deathknight))
                {
                    //uint entry = result.Read<uint>(c, 16);
                    //var creatureInfo = ObjMgr.GetCreatureTemplate(entry);
                    //if (creatureInfo != null)
                    {
                        //petDisplayId = result.Read<uint>(c, 17);
                        //petLevel = result.Read<uint>(c, 18);
                        //petFamily = creatureInfo.Family;
                    }
                }

                data.WriteUInt32(charFlags);
                data.WriteUInt32(petFamily);
                data.WriteFloat(z);
                data.WriteByteSeq(guid[7]);
                data.WriteByteSeq(guildGuid[6]);

                for (uint i = 0; i < InventorySlots.BagEnd; ++i)
                {
                    uint index = i * 2;
                    uint itemId;
                    uint.TryParse(equipment[index], out itemId);
                    var entry = ObjMgr.GetItemTemplate(itemId);
                    if (entry == null)
                    {
                        data.WriteInt32(0);
                        data.WriteInt8(0);
                        data.WriteInt32(0);
                        continue;
                    }

                    uint enchants;
                    SpellItemEnchantmentEntry enchant = null;
                    uint.TryParse(equipment[index + 1], out enchants);
                    for (int enchantSlot = (int)EnchantmentSlot.PERM_ENCHANTMENT_SLOT; enchantSlot <= (int)EnchantmentSlot.TEMP_ENCHANTMENT_SLOT; enchantSlot++)
                    {
                        // values stored in 2 uint16
                        uint enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
                        if (enchantId == 0)
                        {
                            continue;
                        }

                        enchant = DBCStorage.SpellItemEnchantmentStorage.LookupByKey(enchantId);
                        if (enchant != null)
                        {
                            break;
                        }
                    }
                    data.WriteInt32(0);//enchant != null ? enchant.aura_id : 0);
                    data.WriteInt8(entry.inventoryType);
                    data.WriteInt32(entry.DisplayInfoID);
                }

                data.WriteFloat(x);
                data.WriteUInt8(plrClass);
                data.WriteByteSeq(guid[5]);
                data.WriteFloat(y);
                data.WriteByteSeq(guildGuid[3]);
                data.WriteByteSeq(guid[6]);
                data.WriteUInt32(petLevel);
                data.WriteUInt32(petDisplayId);
                data.WriteByteSeq(guid[2]);
                data.WriteByteSeq(guid[1]);
                data.WriteUInt8(hairColor);
                data.WriteUInt8(facialHair);
                data.WriteByteSeq(guildGuid[2]);
                data.WriteUInt32(zone);
                data.WriteUInt8(slot);                                    // List order
                data.WriteByteSeq(guid[0]);
                data.WriteByteSeq(guildGuid[1]);
                data.WriteUInt8(skin);
                data.WriteByteSeq(guid[4]);
                data.WriteByteSeq(guildGuid[5]);
                data.WriteString(name);
                data.WriteByteSeq(guildGuid[0]);
                data.WriteUInt8(level);
                data.WriteByteSeq(guid[3]);
                data.WriteByteSeq(guildGuid[7]);
                data.WriteUInt8(hairStyle);
                data.WriteByteSeq(guildGuid[4]);
                data.WriteUInt8(gender);
                data.WriteUInt32(mapId);
                data.WriteUInt32((uint)customizationFlag);
                data.WriteUInt8(plrRace);
                data.WriteUInt8(face);
            }
            return(true);
        }
Пример #19
0
 public bool FlagIsSet(CharacterFlags inFlag)
 {
     return((flags & inFlag) == inFlag);
 }
Пример #20
0
        // Methods
        public ChatEvent(byte[] data) : base(data)
        {
            this.clientVersion  = -1;
            this.characterType  = BattleNetCharacter.Unknown;
            this.characterLevel = -1;
            this.characterAct   = -1;
            this.characterTitle = CharacterTitle.None;
            this.eventType      = (ChatEventType)BitConverter.ToUInt32(data, 3);
            this.flags          = BitConverter.ToUInt32(data, 7);
            this.ping           = BitConverter.ToUInt32(data, 11);
            int length = ByteConverter.GetByteOffset(data, 0, 0x1b);
            int num2   = ByteConverter.GetByteOffset(data, 0x2a, 0x1b, length);

            if (num2 > 0)
            {
                this.name = ByteConverter.GetString(data, 0x1b, num2);
                length   -= num2 + 1;
                num2     += 0x1c;
            }
            else if (num2 == 0)
            {
                num2 = 0x1c;
                length--;
                this.characterType = BattleNetCharacter.OpenCharacter;
            }
            else
            {
                num2 = 0x1b;
            }
            this.account = ByteConverter.GetString(data, num2, length);
            length      += num2 + 1;
            if (this.eventType != ChatEventType.ChannelLeave)
            {
                if ((this.eventType == ChatEventType.ChannelJoin) || (this.eventType == ChatEventType.ChannelUser))
                {
                    if ((data.Length - length) > 3)
                    {
                        this.client = (BattleNetClient)BitConverter.ToUInt32(data, length);
                        length     += 4;
                    }
                    if ((((this.client != BattleNetClient.StarcraftShareware) && (this.client != BattleNetClient.Starcraft)) && (this.client != BattleNetClient.StarcraftBroodWar)) && ((this.client == BattleNetClient.Diablo2) || (this.client == BattleNetClient.Diablo2LoD)))
                    {
                        if (this.client == BattleNetClient.Diablo2LoD)
                        {
                            this.characterFlags |= CharacterFlags.Expansion;
                        }
                        if ((data.Length - length) >= 4)
                        {
                            this.realm = ByteConverter.GetString(data, length, -1, 0x2c);
                            length    += this.realm.Length + 1;
                            if (data.Length >= length)
                            {
                                length += ByteConverter.GetByteOffset(data, 0x2c, length) + 1;
                                if (((length != -1) && (data.Length > length)) && ((data.Length - length) >= 0x21))
                                {
                                    StatString.ParseD2StatString(data, length, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.message = ByteConverter.GetNullString(data, length);
                }
            }
        }