Exemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            ++raceNbr;
            lbMenu.Items.Add("New race " + raceNbr);
            TabPage page = new TabPage();

            page.Name = "" + raceNbr;
            tbcEditor.TabPages.Add(page);
            FillTab(page, -1);
            ChrRacesEntry race = new ChrRacesEntry();

            race.RaceId          = (uint)raceNbr;
            race.RaceNameNeutral = "New race " + raceNbr;
            //Add an empty race for the up/down button
            DbcStores.ChrRaces.AddEntry((uint)raceNbr, race);
            lbMenu.Size = new Size(150, (raceNbr * 14 > 342) ? 342 : raceNbr * 14);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleCharCreate(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            string strName     = packetReader.ReadUTF8StringSafe();
            byte   iRace       = packetReader.ReadByte();
            byte   iClass      = packetReader.ReadByte();
            byte   iGender     = packetReader.ReadByte();
            byte   iSkin       = packetReader.ReadByte();
            byte   iFace       = packetReader.ReadByte();
            byte   iHairStyle  = packetReader.ReadByte();
            byte   iHairColor  = packetReader.ReadByte();
            byte   iFacialHair = packetReader.ReadByte();
            byte   iOutFitId   = packetReader.ReadByte();

            if (WorldPacketHandlers.VerifyName(strName) == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if (ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.GetPlayerInfo(strName) != null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacterCreateInfo wowCharacterCreateInfo = ProcessServer.WowZoneCluster.World.GlobalCreateInfo.GetCreateInfo(iRace, iClass);

            if (wowCharacterCreateInfo == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if ((iRace == WowRace.BloodElf || iRace == WowRace.Draenei) &&
                extendData.CommonData.IsTBC == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacterLevelInfo[] wowCharacterLevelInfo = ProcessServer.WowZoneCluster.World.GlobalLevelInfo.GetLevelInfo(iRace, iClass);
            if (wowCharacterLevelInfo == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacter wowPlayerInfo = new WowCharacter();

            wowPlayerInfo.Serial      = 0;
            wowPlayerInfo.IsTBC       = extendData.CommonData.IsTBC;
            wowPlayerInfo.AccountGuid = extendData.CommonData.AccountsGuid;

            wowPlayerInfo.Name       = strName;
            wowPlayerInfo.Race       = iRace;
            wowPlayerInfo.Class      = iClass;
            wowPlayerInfo.Gender     = iGender;
            wowPlayerInfo.Skin       = iSkin;
            wowPlayerInfo.Face       = iFace;
            wowPlayerInfo.HairStyle  = iHairStyle;
            wowPlayerInfo.HairColor  = iHairColor;
            wowPlayerInfo.FacialHair = iFacialHair;

            wowPlayerInfo.X      = wowCharacterCreateInfo.PositionX;
            wowPlayerInfo.Y      = wowCharacterCreateInfo.PositionY;
            wowPlayerInfo.Z      = wowCharacterCreateInfo.PositionZ;
            wowPlayerInfo.MapId  = wowCharacterCreateInfo.Map;
            wowPlayerInfo.ZoneId = wowCharacterCreateInfo.Zone;

            wowPlayerInfo.BindX      = 0;
            wowPlayerInfo.BindY      = 0;
            wowPlayerInfo.BindZ      = 0;
            wowPlayerInfo.BindMapId  = 0;
            wowPlayerInfo.BindZoneId = 0;

            ChrRacesEntry chrRacesEntry = DBCInstances.ChrRacesEntry.LookupIDEntry(iRace);

            if (chrRacesEntry == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if (chrRacesEntry.m_TeamId == 7)
            {
                wowPlayerInfo.TeamId = WowTeam.ALLIANCE;
            }
            else
            {
                wowPlayerInfo.TeamId = WowTeam.HORDE;
            }

            ChrClassesEntry chrClassesEntry = DBCInstances.ChrClassesEntry.LookupIDEntry(iClass);

            if (chrClassesEntry == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            wowPlayerInfo.PowerType = chrClassesEntry.m_PowerType;

            switch (iRace)
            {
            case (byte)WowRace.Tauren:
                wowPlayerInfo.TaxiMask[0] = 1 << (22 - 1);

                break;

            case (byte)WowRace.Human:
                wowPlayerInfo.TaxiMask[0] = 1 << (2 - 1);

                break;

            case (byte)WowRace.Dwarf:
                wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1);

                break;

            case (byte)WowRace.Gnome:
                wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1);

                break;

            case (byte)WowRace.Orc:
                wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1);

                break;

            case (byte)WowRace.Troll:
                wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1);

                break;

            case (byte)WowRace.Undead:
                wowPlayerInfo.TaxiMask[0] = 1 << (11 - 1);

                break;

            case (byte)WowRace.Nightelf:
                wowPlayerInfo.TaxiMask[0] = 1 << (27 - 1);

                break;

            case (byte)WowRace.BloodElf:
                wowPlayerInfo.TaxiMask[2] = 1 << (18 - 1);

                break;

            case (byte)WowRace.Draenei:
                wowPlayerInfo.TaxiMask[2] = 1 << (30 - 1);

                break;
            }

            wowPlayerInfo.Size = (iRace == WowRace.Tauren) ? 1.3f : 1.0f;

            wowPlayerInfo.Health = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.Mana   = wowCharacterLevelInfo[0].Mana;
            wowPlayerInfo.Rage   = 0;
            wowPlayerInfo.Focus  = 0;
            wowPlayerInfo.Energy = 0;

            wowPlayerInfo.MaxHealth = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.MaxMana   = wowCharacterLevelInfo[0].Mana;
            wowPlayerInfo.MaxRage   = 0;
            wowPlayerInfo.MaxFocus  = 0;
            wowPlayerInfo.MaxEnergy = 0;

            wowPlayerInfo.BaseHealth = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.BaseMana   = wowCharacterLevelInfo[0].Mana;

            wowPlayerInfo.FactionTemplate = 0;
            wowPlayerInfo.Level           = 1;

            wowPlayerInfo.Strength  = wowCharacterLevelInfo[0].Strength;
            wowPlayerInfo.Agility   = wowCharacterLevelInfo[0].Agility;
            wowPlayerInfo.Stamina   = wowCharacterLevelInfo[0].Stamina;
            wowPlayerInfo.Intellect = wowCharacterLevelInfo[0].Intellect;
            wowPlayerInfo.Spirit    = wowCharacterLevelInfo[0].Spirit;

            wowPlayerInfo.BoundingRadius = 0.388999998569489f;
            wowPlayerInfo.CombatReach    = 1.5f;

            if (iGender == 0)
            {
                wowPlayerInfo.DisplayId       = wowCharacterCreateInfo.MaleDisplayId;
                wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.MaleDisplayId;
            }
            else
            {
                wowPlayerInfo.DisplayId       = wowCharacterCreateInfo.FemaleDisplayId;
                wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.FemaleDisplayId;
            }


            wowPlayerInfo.AttackPower = 0;
            wowPlayerInfo.NextLevelXP = 400;
            wowPlayerInfo.MaxLevel    = 10;

            for (uint iIndex = 0; iIndex < DBCInstances.FactionEntry.Count; iIndex++)
            {
                FactionEntry factionEntry = DBCInstances.FactionEntry.LookupRowEntry(iIndex);
                if (factionEntry == null)
                {
                    continue;
                }

                if (factionEntry.m_RepListId < 0)
                {
                    continue;
                }

                int iReputation = 0;
                if ((factionEntry.m_BaseRepMask1 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue1;
                }
                else if ((factionEntry.m_BaseRepMask2 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue2;
                }
                else if ((factionEntry.m_BaseRepMask3 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue3;
                }
                else if ((factionEntry.m_BaseRepMask4 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue4;
                }
                else
                {
                    continue;
                }

                WowReputation wowReputation = new WowReputation()
                {
                    FactionId  = factionEntry.ID,
                    Reputation = iReputation,
                };

                if ((int)wowReputation.CalcRating() <= (int)WowFactionRating.Hostile)
                {
                    wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagAtWar;
                }

                if ((factionEntry.m_Team == 469 && wowPlayerInfo.TeamId == WowTeam.ALLIANCE) ||
                    (factionEntry.m_Team == 67 && wowPlayerInfo.TeamId == WowTeam.HORDE))
                {
                    wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagVisible;
                }

                wowPlayerInfo.ReputationManager.AddReputation(wowReputation.FactionId, wowReputation);
            }

            foreach (WowPlayerInfoSkill wowPlayerInfoSkill in wowCharacterCreateInfo.WowPlayerSkills.Skills)
            {
                WowSkillTemplate wowSkillTemplate = ProcessServer.WowZoneCluster.World.GlobalSkillTemplates.GetSkillTemplate((long)wowPlayerInfoSkill.Skill) as WowSkillTemplate;
                if (wowSkillTemplate == null)
                {
                    continue;
                }

                WowSkill wowSkill = new WowSkill()
                {
                    Serial        = wowSkillTemplate.SkillId,
                    SkillTemplate = wowSkillTemplate
                };

                wowPlayerInfo.SkillManager.AddSkill(wowSkill.Serial, wowSkill);
            }

            foreach (WowPlayerInfoSpell wowPlayerInfoSpell in wowCharacterCreateInfo.WowPlayerSpells.Spells)
            {
                WowSpellTemplate wowSpellTemplate = ProcessServer.WowZoneCluster.World.GlobalSpellTemplates.GetSpellTemplate((long)wowPlayerInfoSpell.Spell) as WowSpellTemplate;
                if (wowSpellTemplate == null)
                {
                    continue;
                }

                WowSpell wowSpell = new WowSpell()
                {
                    Serial        = wowSpellTemplate.SpellId,
                    SpellTemplate = wowSpellTemplate
                };

                wowPlayerInfo.SpellManager.AddSpell(wowSpell.Serial, wowSpell);
            }

            foreach (WowPlayerInfoItem wowPlayerInfoItem in wowCharacterCreateInfo.WowPlayerItems.Items)
            {
                WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate((long)wowPlayerInfoItem.ItemId) as WowItemTemplate;
                if (wowItemTemplate == null)
                {
                    continue;
                }

                WowItemContainer equipmentBag = wowPlayerInfo.BagManager.EquipmentBag;
                if (equipmentBag == null)
                {
                    break;
                }

                WowItem wowItem = equipmentBag.FindSubItemAtSlot(wowItemTemplate.InventoryType) as WowItem;
                if (wowItem == null)
                {
                    wowItem = new WowItem()
                    {
                        ItemTemplate = wowItemTemplate
                    };

                    equipmentBag.AddSubItem(wowItemTemplate.InventoryType, wowItem);
                }
                else
                {
                    WowItemContainer mainBag = wowPlayerInfo.BagManager.MainBag;
                    if (mainBag == null)
                    {
                        break;
                    }

                    wowItem = new WowItem()
                    {
                        ItemTemplate = wowItemTemplate
                    };

                    mainBag.AddToFreeSlot(wowItem);
                }
            }


            foreach (WowPlayerInfoAction wowPlayerInfoAction in wowCharacterCreateInfo.WowPlayerActions.Actions)
            {
                WowActionBar wowActionBar = new WowActionBar()
                {
                    Serial = wowPlayerInfoAction.Button,
                    Action = wowPlayerInfoAction.Action,
                    Type   = wowPlayerInfoAction.Type
                };

                wowPlayerInfo.ActionBarManager.AddActionBar(wowActionBar.Serial, wowActionBar);
            }

            if (wowPlayerInfo.SaveNewCreature() == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.AddPlayerInfo(wowPlayerInfo.Name, wowPlayerInfo.Serial, wowPlayerInfo);

            netState.Send(new Word_CharCreateResponse());
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbcStores.ChrRaces.ClearDbc();
            //Loop trough each tabs
            foreach (TabPage tab in tbcEditor.TabPages)
            {
                var race             = new ChrRacesEntry();
                int inputFieldscount = 0;
                //Loop trough each controls
                foreach (Control control in tab.Controls)
                {
                    //If it's an input field, get the value
                    if (control is TextBox || control is ComboBox)
                    {
                        switch (inputFieldscount)
                        {
                        case 0:
                            race.Flags = uint.Parse(control.Text);
                            break;

                        case 1:
                            race.FactionId = uint.Parse(control.Text);
                            break;

                        case 2:
                            race.ExplorationSoundId = uint.Parse(control.Text);
                            break;

                        case 3:
                            race.ModelM = uint.Parse(control.Text);
                            break;

                        case 4:
                            race.ModelF = uint.Parse(control.Text);
                            break;

                        case 5:
                            race.ClientPrefix = control.Text;
                            break;

                        case 6:
                            race.RequiredExpansion = uint.Parse(control.Text);
                            break;

                        case 7:
                            race.HairCustomization = control.Text;
                            break;

                        case 8:
                            race.FacialHairCustomization = control.Text;
                            break;

                        case 9:
                            race.FacialHairCustomization2 = control.Text;
                            break;

                        case 10:
                            race.BaseLanguage = uint.Parse(control.Text);
                            break;

                        case 11:
                            race.ClientFileString = control.Text;
                            break;

                        case 12:
                            race.CinematicSequenceId = uint.Parse(control.Text);
                            break;

                        case 13:
                            race.RaceNameNeutral = control.Text;
                            break;

                        case 14:
                            race.RaceNameFemale = control.Text;
                            break;

                        case 15:
                            race.RaceNameMale = control.Text;
                            break;

                        case 16:
                            race.Alliance = uint.Parse(control.Text);
                            break;

                        case 17:
                            race.ResSicknessSpellId = uint.Parse(control.Text);
                            break;

                        case 18:
                            race.CreatureType = uint.Parse(control.Text);
                            break;

                        case 19:
                            race.SplashSoundId = uint.Parse(control.Text);
                            break;
                        }

                        ++inputFieldscount;
                    }
                }

                race.RaceId = (uint)tbcEditor.TabPages.IndexOf(tab) + 1;
                DbcStores.ChrRaces.AddEntry(race.RaceId, race);
            }
            //Everything is ok, save
            DbcStores.ChrRaces.SaveDBC();
        }