예제 #1
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public GamePiece(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #2
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Food(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #3
0
파일: PKModifier.cs 프로젝트: hooper82/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public PKModifier(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #4
0
        public static CreateResult Create(CharacterCreateInfo characterCreateInfo, Weenie weenie, ObjectGuid guid, uint accountId, WeenieType weenieType, out Player player)
        {
            var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[characterCreateInfo.Heritage];

            if (weenieType == WeenieType.Admin)
            {
                player = new Admin(weenie, guid, accountId);
            }
            else if (weenieType == WeenieType.Sentinel)
            {
                player = new Sentinel(weenie, guid, accountId);
            }
            else
            {
                player = new Player(weenie, guid, accountId);
            }

            player.SetProperty(PropertyInt.HeritageGroup, (int)characterCreateInfo.Heritage);
            player.SetProperty(PropertyString.HeritageGroup, heritageGroup.Name);
            player.SetProperty(PropertyInt.Gender, (int)characterCreateInfo.Gender);
            player.SetProperty(PropertyString.Sex, characterCreateInfo.Gender == 1 ? "Male" : "Female");

            //player.SetProperty(PropertyDataId.Icon, cgh.IconImage); // I don't believe this is used anywhere in the client, but it might be used by a future custom launcher

            // pull character data from the dat file
            var sex = heritageGroup.Genders[(int)characterCreateInfo.Gender];

            player.SetProperty(PropertyDataId.MotionTable, sex.MotionTable);
            player.SetProperty(PropertyDataId.SoundTable, sex.SoundTable);
            player.SetProperty(PropertyDataId.PhysicsEffectTable, sex.PhysicsTable);
            player.SetProperty(PropertyDataId.Setup, sex.SetupID);
            player.SetProperty(PropertyDataId.PaletteBase, sex.BasePalette);
            player.SetProperty(PropertyDataId.CombatTable, sex.CombatTable);

            // Check the character scale
            if (sex.Scale != 100u)
            {
                player.SetProperty(PropertyFloat.DefaultScale, (sex.Scale / 100f)); // Scale is stored as a percentage
            }
            // Get the hair first, because we need to know if you're bald, and that's the name of that tune!
            var hairstyle = sex.HairStyleList[Convert.ToInt32(characterCreateInfo.Apperance.HairStyle)];

            // Olthoi and Gear Knights have a "Body Style" instead of a hair style. These styles have multiple model/texture changes, instead of a single head/hairstyle.
            // Storing this value allows us to send the proper appearance ObjDesc
            if (hairstyle.ObjDesc.AnimPartChanges.Count > 1)
            {
                player.SetProperty(PropertyInt.Hairstyle, (int)characterCreateInfo.Apperance.HairStyle);
            }

            // Certain races (Undead, Tumeroks, Others?) have multiple body styles available. This is controlled via the "hair style".
            if (hairstyle.AlternateSetup > 0)
            {
                player.SetProperty(PropertyDataId.Setup, hairstyle.AlternateSetup);
            }

            player.SetProperty(PropertyDataId.EyesTexture, sex.GetEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald));
            player.SetProperty(PropertyDataId.DefaultEyesTexture, sex.GetDefaultEyeTexture(characterCreateInfo.Apperance.Eyes, hairstyle.Bald));
            player.SetProperty(PropertyDataId.NoseTexture, sex.GetNoseTexture(characterCreateInfo.Apperance.Nose));
            player.SetProperty(PropertyDataId.DefaultNoseTexture, sex.GetDefaultNoseTexture(characterCreateInfo.Apperance.Nose));
            player.SetProperty(PropertyDataId.MouthTexture, sex.GetMouthTexture(characterCreateInfo.Apperance.Mouth));
            player.SetProperty(PropertyDataId.DefaultMouthTexture, sex.GetDefaultMouthTexture(characterCreateInfo.Apperance.Mouth));
            player.Character.HairTexture        = sex.GetHairTexture(characterCreateInfo.Apperance.HairStyle);
            player.Character.DefaultHairTexture = sex.GetDefaultHairTexture(characterCreateInfo.Apperance.HairStyle);
            // HeadObject can be null if we're dealing with GearKnight or Olthoi
            var headObject = sex.GetHeadObject(characterCreateInfo.Apperance.HairStyle);

            if (headObject != null)
            {
                player.SetProperty(PropertyDataId.HeadObject, (uint)headObject);
            }

            // Skin is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette
            var skinPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.SkinPalSet);

            player.SetProperty(PropertyDataId.SkinPalette, skinPalSet.GetPaletteID(characterCreateInfo.Apperance.SkinHue));
            player.SetProperty(PropertyFloat.Shade, characterCreateInfo.Apperance.SkinHue);

            // Hair is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette
            var hairPalSet = DatManager.PortalDat.ReadFromDat <PaletteSet>(sex.HairColorList[Convert.ToInt32(characterCreateInfo.Apperance.HairColor)]);

            player.SetProperty(PropertyDataId.HairPalette, hairPalSet.GetPaletteID(characterCreateInfo.Apperance.HairHue));

            // Eye Color
            player.SetProperty(PropertyDataId.EyesPalette, sex.EyeColorList[Convert.ToInt32(characterCreateInfo.Apperance.EyeColor)]);

            if (characterCreateInfo.Apperance.HeadgearStyle < 0xFFFFFFFF) // No headgear is max UINT
            {
                var hat = GetClothingObject(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle), characterCreateInfo.Apperance.HeadgearColor, characterCreateInfo.Apperance.HeadgearHue);
                if (hat != null)
                {
                    player.TryEquipObject(hat, hat.ValidLocations ?? 0);
                }
                else
                {
                    player.TryAddToInventory(CreateIOU(sex.GetHeadgearWeenie(characterCreateInfo.Apperance.HeadgearStyle)));
                }
            }

            var shirt = GetClothingObject(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle), characterCreateInfo.Apperance.ShirtColor, characterCreateInfo.Apperance.ShirtHue);

            if (shirt != null)
            {
                player.TryEquipObject(shirt, shirt.ValidLocations ?? 0);
            }
            else
            {
                player.TryAddToInventory(CreateIOU(sex.GetShirtWeenie(characterCreateInfo.Apperance.ShirtStyle)));
            }

            var pants = GetClothingObject(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle), characterCreateInfo.Apperance.PantsColor, characterCreateInfo.Apperance.PantsHue);

            if (pants != null)
            {
                player.TryEquipObject(pants, pants.ValidLocations ?? 0);
            }
            else
            {
                player.TryAddToInventory(CreateIOU(sex.GetPantsWeenie(characterCreateInfo.Apperance.PantsStyle)));
            }

            var shoes = GetClothingObject(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle), characterCreateInfo.Apperance.FootwearColor, characterCreateInfo.Apperance.FootwearHue);

            if (shoes != null)
            {
                player.TryEquipObject(shoes, shoes.ValidLocations ?? 0);
            }
            else
            {
                player.TryAddToInventory(CreateIOU(sex.GetFootwearWeenie(characterCreateInfo.Apperance.FootwearStyle)));
            }

            string templateName = heritageGroup.Templates[characterCreateInfo.TemplateOption].Name;

            //player.SetProperty(PropertyString.Title, templateName);
            player.SetProperty(PropertyString.Template, templateName);
            player.AddTitle(heritageGroup.Templates[characterCreateInfo.TemplateOption].Title, true);

            // stats
            uint totalAttributeCredits = heritageGroup.AttributeCredits;
            uint usedAttributeCredits  = 0;

            player.Strength.StartingValue = ValidateAttributeCredits(characterCreateInfo.StrengthAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits         += player.Strength.StartingValue;

            player.Endurance.StartingValue = ValidateAttributeCredits(characterCreateInfo.EnduranceAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits          += player.Endurance.StartingValue;

            player.Coordination.StartingValue = ValidateAttributeCredits(characterCreateInfo.CoordinationAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits += player.Coordination.StartingValue;

            player.Quickness.StartingValue = ValidateAttributeCredits(characterCreateInfo.QuicknessAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits          += player.Quickness.StartingValue;

            player.Focus.StartingValue = ValidateAttributeCredits(characterCreateInfo.FocusAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits      += player.Focus.StartingValue;

            player.Self.StartingValue = ValidateAttributeCredits(characterCreateInfo.SelfAbility, usedAttributeCredits, totalAttributeCredits);
            usedAttributeCredits     += player.Self.StartingValue;

            if (usedAttributeCredits > heritageGroup.AttributeCredits)
            {
                return(CreateResult.TooManySkillCreditsUsed);
            }

            // data we don't care about
            //characterCreateInfo.CharacterSlot;
            //characterCreateInfo.ClassId;

            // characters start with max vitals
            player.Health.Current  = player.Health.Base;
            player.Stamina.Current = player.Stamina.Base;
            player.Mana.Current    = player.Mana.Base;

            // set initial skill credit amount. 52 for all but "Olthoi", which have 68
            player.SetProperty(PropertyInt.AvailableSkillCredits, (int)heritageGroup.SkillCredits);

            for (int i = 0; i < characterCreateInfo.SkillAdvancementClasses.Count; i++)
            {
                var sac = characterCreateInfo.SkillAdvancementClasses[i];

                if (sac == SkillAdvancementClass.Inactive)
                {
                    continue;
                }

                if (!DatManager.PortalDat.SkillTable.SkillBaseHash.ContainsKey((uint)i))
                {
                    log.ErrorFormat("Character {0} tried to create with skill {1} that was not found in Portal dat.", characterCreateInfo.Name, i);
                    return(CreateResult.InvalidSkillRequested);
                }

                var skill = DatManager.PortalDat.SkillTable.SkillBaseHash[(uint)i];

                var trainedCost     = skill.TrainedCost;
                var specializedCost = skill.UpgradeCostFromTrainedToSpecialized;

                foreach (var skillGroup in heritageGroup.Skills)
                {
                    if (skillGroup.SkillNum == i)
                    {
                        trainedCost     = skillGroup.NormalCost;
                        specializedCost = skillGroup.PrimaryCost;
                        break;
                    }
                }

                if (sac == SkillAdvancementClass.Specialized)
                {
                    if (!player.TrainSkill((Skill)i, trainedCost))
                    {
                        return(CreateResult.FailedToTrainSkill);
                    }
                    if (!player.SpecializeSkill((Skill)i, specializedCost))
                    {
                        return(CreateResult.FailedToSpecializeSkill);
                    }
                }
                else if (sac == SkillAdvancementClass.Trained)
                {
                    if (!player.TrainSkill((Skill)i, trainedCost))
                    {
                        return(CreateResult.FailedToTrainSkill);
                    }
                }
                else if (sac == SkillAdvancementClass.Untrained)
                {
                    player.UntrainSkill((Skill)i, 0);
                }
            }

            var isDualWieldTrainedOrSpecialized = player.Skills[Skill.DualWield].AdvancementClass > SkillAdvancementClass.Untrained;

            // Set Heritage based Melee and Ranged Masteries
            GetMasteries(player.HeritageGroup, out WeaponType meleeMastery, out WeaponType rangedMastery);

            player.SetProperty(PropertyInt.MeleeMastery, (int)meleeMastery);
            player.SetProperty(PropertyInt.RangedMastery, (int)rangedMastery);

            // Set innate augs
            SetInnateAugmentations(player);

            // grant starter items based on skills
            var starterGearConfig = StarterGearFactory.GetStarterGearConfiguration();
            var grantedWeenies    = new List <uint>();

            foreach (var skillGear in starterGearConfig.Skills)
            {
                var charSkill = player.Skills[(Skill)skillGear.SkillId];
                if (charSkill.AdvancementClass == SkillAdvancementClass.Trained || charSkill.AdvancementClass == SkillAdvancementClass.Specialized)
                {
                    foreach (var item in skillGear.Gear)
                    {
                        if (grantedWeenies.Contains(item.WeenieId))
                        {
                            var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId);
                            if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1)
                            {
                                continue;
                            }

                            existingItem.SetStackSize(existingItem.StackSize + item.StackSize);
                            continue;
                        }

                        var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
                        if (loot != null)
                        {
                            if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue)
                            {
                                loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize);
                            }
                        }
                        else
                        {
                            player.TryAddToInventory(CreateIOU(item.WeenieId));
                        }

                        if (loot != null && player.TryAddToInventory(loot))
                        {
                            grantedWeenies.Add(item.WeenieId);
                        }

                        if (isDualWieldTrainedOrSpecialized && loot != null)
                        {
                            if (loot.WeenieType == WeenieType.MeleeWeapon)
                            {
                                var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
                                if (dualloot != null)
                                {
                                    player.TryAddToInventory(dualloot);
                                }
                                else
                                {
                                    player.TryAddToInventory(CreateIOU(item.WeenieId));
                                }
                            }
                        }
                    }

                    var heritageLoot = skillGear.Heritage.FirstOrDefault(sh => sh.HeritageId == characterCreateInfo.Heritage);
                    if (heritageLoot != null)
                    {
                        foreach (var item in heritageLoot.Gear)
                        {
                            if (grantedWeenies.Contains(item.WeenieId))
                            {
                                var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClassId == item.WeenieId);
                                if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1)
                                {
                                    continue;
                                }

                                existingItem.SetStackSize(existingItem.StackSize + item.StackSize);
                                continue;
                            }

                            var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
                            if (loot != null)
                            {
                                if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue)
                                {
                                    loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize);
                                }
                            }
                            else
                            {
                                player.TryAddToInventory(CreateIOU(item.WeenieId));
                            }

                            if (loot != null && player.TryAddToInventory(loot))
                            {
                                grantedWeenies.Add(item.WeenieId);
                            }

                            if (isDualWieldTrainedOrSpecialized && loot != null)
                            {
                                if (loot.WeenieType == WeenieType.MeleeWeapon)
                                {
                                    var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
                                    if (dualloot != null)
                                    {
                                        player.TryAddToInventory(dualloot);
                                    }
                                    else
                                    {
                                        player.TryAddToInventory(CreateIOU(item.WeenieId));
                                    }
                                }
                            }
                        }
                    }

                    foreach (var spell in skillGear.Spells)
                    {
                        // Olthoi Spitter is a special case
                        if (characterCreateInfo.Heritage == (int)HeritageGroup.OlthoiAcid)
                        {
                            player.AddKnownSpell(spell.SpellId);
                            // Continue to next spell as Olthoi spells do not have the SpecializedOnly field
                            continue;
                        }

                        if (charSkill.AdvancementClass == SkillAdvancementClass.Trained && spell.SpecializedOnly == false)
                        {
                            player.AddKnownSpell(spell.SpellId);
                        }
                        else if (charSkill.AdvancementClass == SkillAdvancementClass.Specialized)
                        {
                            player.AddKnownSpell(spell.SpellId);
                        }
                    }
                }
            }

            player.Name           = characterCreateInfo.Name;
            player.Character.Name = characterCreateInfo.Name;


            // Index used to determine the starting location
            var startArea = characterCreateInfo.StartArea;

            var starterArea = DatManager.PortalDat.CharGen.StarterAreas[(int)startArea];

            player.Location = new Position(starterArea.Locations[0].ObjCellID,
                                           starterArea.Locations[0].Frame.Origin.X, starterArea.Locations[0].Frame.Origin.Y, starterArea.Locations[0].Frame.Origin.Z,
                                           starterArea.Locations[0].Frame.Orientation.X, starterArea.Locations[0].Frame.Orientation.Y, starterArea.Locations[0].Frame.Orientation.Z, starterArea.Locations[0].Frame.Orientation.W);

            var instantiation = new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); // ultimate fallback.
            var spellFreeRide = new Spell();

            switch (starterArea.Name)
            {
            case "OlthoiLair":        //todo: check this when olthoi play is allowed in ace
                spellFreeRide = null; // no training area for olthoi, so they start and fall back to same place.
                instantiation = new Position(player.Location);
                break;

            case "Shoushi":
                spellFreeRide = DatabaseManager.World.GetCachedSpell(3813);     // Free Ride to Shoushi
                break;

            case "Yaraq":
                spellFreeRide = DatabaseManager.World.GetCachedSpell(3814);     // Free Ride to Yaraq
                break;

            case "Sanamar":
                spellFreeRide = DatabaseManager.World.GetCachedSpell(3535);     // Free Ride to Sanamar
                break;

            case "Holtburg":
            default:
                spellFreeRide = DatabaseManager.World.GetCachedSpell(3815);     // Free Ride to Holtburg
                break;
            }
            if (spellFreeRide != null && spellFreeRide.Name != "")
            {
                instantiation = new Position(spellFreeRide.PositionObjCellId.Value, spellFreeRide.PositionOriginX.Value, spellFreeRide.PositionOriginY.Value, spellFreeRide.PositionOriginZ.Value, spellFreeRide.PositionAnglesX.Value, spellFreeRide.PositionAnglesY.Value, spellFreeRide.PositionAnglesZ.Value, spellFreeRide.PositionAnglesW.Value);
            }

            player.Instantiation = new Position(instantiation);

            player.Sanctuary = new Position(player.Location);

            player.SetProperty(PropertyBool.RecallsDisabled, true);

            if (PropertyManager.GetBool("pk_server").Item)
            {
                player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.PK);
            }
            else if (PropertyManager.GetBool("pkl_server").Item)
            {
                player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK);
            }

            if ((PropertyManager.GetBool("pk_server").Item || PropertyManager.GetBool("pkl_server").Item) && PropertyManager.GetBool("pk_server_safe_training_academy").Item)
            {
                player.SetProperty(PropertyFloat.MinimumTimeSincePk, -PropertyManager.GetDouble("pk_new_character_grace_period").Item);
                player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK);
            }

            if (player is Sentinel || player is Admin)
            {
                player.Character.IsPlussed = true;
                player.CloakStatus         = CloakStatus.Off;
                player.ChannelsAllowed     = player.ChannelsActive;
            }

            CharacterCreateSetDefaultCharacterOptions(player);

            return(CreateResult.Success);
        }
예제 #5
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public SpellProjectile(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #6
0
        public void CreateSQLINSERTStatement(Weenie input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie` (`class_Id`, `class_Name`, `type`, `last_Modified`)");

            var output = $"VALUES ({input.ClassId}, '{input.ClassName}', {input.Type}, '{input.LastModified.ToString("yyyy-MM-dd HH:mm:ss")}') /* {Enum.GetName(typeof(WeenieType), input.Type)} */;";

            output = FixNullFields(output);

            writer.WriteLine(output);

            if (input.WeeniePropertiesInt != null && input.WeeniePropertiesInt.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesInt.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesInt64 != null && input.WeeniePropertiesInt64.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesInt64.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesBool != null && input.WeeniePropertiesBool.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesBool.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesFloat != null && input.WeeniePropertiesFloat.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesFloat.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesString != null && input.WeeniePropertiesString.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesString.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesDID != null && input.WeeniePropertiesDID.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesDID.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.WeeniePropertiesPosition != null && input.WeeniePropertiesPosition.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesPosition.OrderBy(r => r.PositionType).ToList(), writer);
            }

            if (input.WeeniePropertiesIID != null && input.WeeniePropertiesIID.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesIID.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.WeeniePropertiesAttribute != null && input.WeeniePropertiesAttribute.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesAttribute.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.WeeniePropertiesAttribute2nd != null && input.WeeniePropertiesAttribute2nd.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesAttribute2nd.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.WeeniePropertiesSkill != null && input.WeeniePropertiesSkill.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesSkill.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.WeeniePropertiesBodyPart != null && input.WeeniePropertiesBodyPart.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesBodyPart.OrderBy(r => r.Key).ToList(), writer);
            }

            if (input.WeeniePropertiesSpellBook != null && input.WeeniePropertiesSpellBook.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesSpellBook.OrderBy(r => r.Spell).ToList(), writer);
            }

            if (input.WeeniePropertiesEventFilter != null && input.WeeniePropertiesEventFilter.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesEventFilter.OrderBy(r => r.Event).ToList(), writer);
            }

            if (input.WeeniePropertiesEmote != null && input.WeeniePropertiesEmote.Count > 0)
            {
                //writer.WriteLine(); // This is not needed because CreateSQLINSERTStatement will take care of it for us on each Recipe.
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesEmote.OrderBy(r => r.Category).ToList(), writer);
            }

            if (input.WeeniePropertiesCreateList != null && input.WeeniePropertiesCreateList.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesCreateList.OrderBy(r => r.DestinationType).ToList(), writer);
            }

            if (input.WeeniePropertiesBook != null)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesBook, writer);
            }
            if (input.WeeniePropertiesBookPageData != null && input.WeeniePropertiesBookPageData.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesBookPageData.OrderBy(r => r.PageId).ToList(), writer);
            }

            if (input.WeeniePropertiesGenerator != null && input.WeeniePropertiesGenerator.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesGenerator.ToList(), writer);
            }

            if (input.WeeniePropertiesPalette != null && input.WeeniePropertiesPalette.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesPalette.OrderBy(r => r.SubPaletteId).ToList(), writer);
            }
            if (input.WeeniePropertiesTextureMap != null && input.WeeniePropertiesTextureMap.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesTextureMap.OrderBy(r => r.Index).ToList(), writer);
            }
            if (input.WeeniePropertiesAnimPart != null && input.WeeniePropertiesAnimPart.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.ClassId, input.WeeniePropertiesAnimPart.OrderBy(r => r.Index).ToList(), writer);
            }
        }
예제 #7
0
        /// <summary>
        /// Import or migrate a character.
        /// </summary>
        /// <returns>the result</returns>
        public static ImportAndMigrateResult ImportAndMigrate(PackageMetadata metadata, byte[] importBytes = null)
        {
            if ((metadata.PackageType == PackageType.Backup && !TransferConfigManager.Config.AllowImport) || (metadata.PackageType == PackageType.Migrate && !TransferConfigManager.Config.AllowMigrate))
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.OperationNotAllowed
                });
            }

            metadata.NewCharacterName = metadata.NewCharacterName.Trim();

            if (metadata.NewCharacterName.Length < GameConfiguration.CharacterNameMinimumLength || metadata.NewCharacterName.Length > GameConfiguration.CharacterNameMaximumLength)
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.NameTooShortOrTooLong
                });
            }

            if (TransferManagerUtil.StringContainsInvalidChars(GameConfiguration.AllowedCharacterNameCharacters, metadata.NewCharacterName))
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.NameContainsInvalidCharacters
                });
            }

            bool             NameIsGood = false;
            ManualResetEvent mre        = new ManualResetEvent(false);

            DatabaseManager.Shard.IsCharacterNameAvailable(metadata.NewCharacterName, isAvailable =>
            {
                NameIsGood = isAvailable;
                mre.Set();
            });
            mre.WaitOne();
            if (!NameIsGood)
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.NameIsUnavailable
                });
            }
            // TO-DO: restricted and weenie name matching
            if (DatManager.PortalDat.TabooTable.ContainsBadWord(metadata.NewCharacterName))
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.NameIsNaughty
                });
            }

            mre = new ManualResetEvent(false);
            bool slotCheck = false;

            DatabaseManager.Shard.GetCharacters(metadata.AccountId, false, new Action <List <Character> >((chars) =>
            {
                slotCheck = chars.Count + 1 <= GameConfiguration.SlotCount;
                mre.Set();
            }));
            mre.WaitOne();
            if (!slotCheck)
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.NoCharacterSlotsAvailable
                });
            }

            string selectedMigrationSourceThumb = null;
            CharacterMigrationDownloadResponseModel snapshotPack = null;
            CharacterTransfer xfer = null;

            if (importBytes == null)
            {
                mre = new ManualResetEvent(false);
                DatabaseManager.Shard.GetCharacterTransfers((xfers) =>
                {
                    xfer = xfers.FirstOrDefault(k => k.Cookie == metadata.Cookie);
                    mre.Set();
                });
                mre.WaitOne();
                if (xfer != null)
                {
                    // don't fail here, prevents inter-account same-server transfers and name changes
                    // return new ImportAndMigrateResult() { FailReason = ImportAndMigrateFailiureReason.CookieAlreadyUsed };
                }

                // try to verify we trust the server before downloading package, since migrations cause source server to delete the original char upon download of the package
                string unverifiedThumbprintsSerialized = null;
                string nonce = ThreadSafeRandom.NextString(TransferManagerConstants.NonceChars, TransferManagerConstants.NonceLength);
                try
                {
                    using (InsecureWebClient iwc = new InsecureWebClient())
                    {
                        unverifiedThumbprintsSerialized = iwc.DownloadString(metadata.ImportUrl.ToString() + $"api/character/migrationCheck?Cookie={metadata.Cookie}&Nonce={nonce}");
                    }
                }
                catch
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.CannotContactSourceServer
                    });
                }
                SignedMigrationCheckResponseModel signedMigrationCheckResult = null;
                try
                {
                    signedMigrationCheckResult = JsonConvert.DeserializeObject <SignedMigrationCheckResponseModel>(unverifiedThumbprintsSerialized, TransferManagerUtil.GetSerializationSettings());
                }
                catch
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.ProtocolError
                    });
                }
                ImportAndMigrateFailiureReason SignedMigrationCheckResultValidationStatus = TransferManagerUtil.Verify(signedMigrationCheckResult, nonce, out selectedMigrationSourceThumb);
                if (SignedMigrationCheckResultValidationStatus != ImportAndMigrateFailiureReason.None)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = SignedMigrationCheckResultValidationStatus
                    });
                }
                if (!signedMigrationCheckResult.Result.Ready)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.MigrationCheckFailed
                    });
                }
                if ((metadata.PackageType == PackageType.Migrate && !TransferConfigManager.Config.AllowMigrationFrom.Any(k => k == signedMigrationCheckResult.Result.Config.MyThumbprint)) || (metadata.PackageType == PackageType.Backup && !TransferConfigManager.Config.AllowImportFrom.Any(k => k == signedMigrationCheckResult.Result.Config.MyThumbprint)))
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.UnverifiedSourceServerNotAllowed
                    });
                }
                if (metadata.PackageType == PackageType.Migrate && !signedMigrationCheckResult.Result.Config.AllowMigrate)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.UnverifiedSourceServerDoesntAllowMigrate
                    });
                }
                try
                {
                    using (InsecureWebClient iwc = new InsecureWebClient())
                    {
                        string TransferManagerCharacterMigrationDownloadResponseModelSerialized = iwc.DownloadString(metadata.ImportUrl.ToString() + $"api/character/migrationDownload?Cookie={metadata.Cookie}");
                        snapshotPack = JsonConvert.DeserializeObject <CharacterMigrationDownloadResponseModel>(TransferManagerCharacterMigrationDownloadResponseModelSerialized, TransferManagerUtil.GetSerializationSettings());
                    }
                }
                catch (Exception)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.ProtocolError
                    });
                }
                if (snapshotPack == null)
                {
                    return(new ImportAndMigrateResult());
                }
                if (!snapshotPack.Success)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.SourceServerRejectedRequest
                    });
                }
            }

            string        tmpFilePath    = Path.GetTempFileName();
            DirectoryInfo diTmpDirPath   = Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(tmpFilePath), Path.GetFileNameWithoutExtension(tmpFilePath)));
            string        signerCertPath = Path.Combine(diTmpDirPath.FullName, "signer.crt");

            if (importBytes == null)
            {
                File.WriteAllBytes(tmpFilePath, snapshotPack.SnapshotPackage);
            }
            else
            {
                File.WriteAllBytes(tmpFilePath, importBytes);
            }

            using (ZipArchive zip = ZipFile.OpenRead(tmpFilePath))
            {
                zip.ExtractToDirectory(diTmpDirPath.FullName);
            }
            File.Delete(tmpFilePath);

            if (!File.Exists(signerCertPath))
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.PackageUnsigned
                });
            }

            string verifiedSourceThumbprint = string.Empty;

            using (X509Certificate2 signer = new X509Certificate2(signerCertPath))
            {
                verifiedSourceThumbprint = signer.Thumbprint;
                // verify that the signer is in the trusted signers list
                if ((metadata.PackageType == PackageType.Migrate && !TransferConfigManager.Config.AllowMigrationFrom.Any(k => k == verifiedSourceThumbprint)) || (metadata.PackageType == PackageType.Backup && !TransferConfigManager.Config.AllowImportFrom.Any(k => k == verifiedSourceThumbprint)))
                {
                    Directory.Delete(diTmpDirPath.FullName, true);
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.VerifiedSourceServerNotAllowed
                    });
                }
                if (!string.IsNullOrWhiteSpace(selectedMigrationSourceThumb) && verifiedSourceThumbprint != selectedMigrationSourceThumb)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.VerifiedMigrationSourceThumbprintMismatch
                    });
                }
                // verify that the signatures are valid
                foreach (FileInfo fil in diTmpDirPath.GetFiles("*.json"))
                {
                    if (!CertificateManager.VerifySignedFile(fil.FullName, signer))
                    {
                        Directory.Delete(diTmpDirPath.FullName, true);
                        return(new ImportAndMigrateResult()
                        {
                            FailReason = ImportAndMigrateFailiureReason.CharacterPackageSignatureInvalid
                        });
                    }
                }
            }

            // deserialize
            PackageMetadata packInfo = null;
            List <Biota>    snapshot = new List <Biota>();

            foreach (FileInfo fil in diTmpDirPath.GetFiles("*.json"))
            {
                if (fil.Name == "packinfo.json")
                {
                    packInfo = JsonConvert.DeserializeObject <PackageMetadata>(File.ReadAllText(fil.FullName), TransferManagerUtil.GetSerializationSettings());
                }
                else
                {
                    snapshot.Add(JsonConvert.DeserializeObject <Biota>(File.ReadAllText(fil.FullName), TransferManagerUtil.GetSerializationSettings()));
                }
            }

            if (packInfo == null)
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.PackInfoNotFound
                });
            }

            if (packInfo.PackageType != metadata.PackageType)
            {
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.WrongPackageType
                });
            }

            if (importBytes == null)
            {
                xfer = null;
                mre  = new ManualResetEvent(false);
                DatabaseManager.Shard.GetCharacterTransfers((xfers) =>
                {
                    xfer = xfers.FirstOrDefault(k => k.SourceId == packInfo.CharacterId);
                    mre.Set();
                });
                mre.WaitOne();

                if (xfer != null)
                {
                    return(new ImportAndMigrateResult()
                    {
                        FailReason = ImportAndMigrateFailiureReason.CharacterAlreadyPresent
                    });
                }
            }

            // isolate player biota
            List <Biota> playerCollection = snapshot.Where(k =>
                                                           (
                                                               k.WeenieType == (uint)WeenieType.Admin ||
                                                               k.WeenieType == (uint)WeenieType.Sentinel ||
                                                               k.WeenieType == (uint)WeenieType.Creature
                                                           )
                                                           ).ToList();

            if (playerCollection.Count > 1)
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.FoundMoreThanOneCharacter
                });
            }
            if (playerCollection.Count < 1)
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.CannotFindCharacter
                });
            }
            IEnumerable <Biota> possessedBiotas2 = snapshot.Except(playerCollection).ToList();
            Biota newCharBiota = playerCollection.First();
            uint  playerOrigId = newCharBiota.Id;

            // refactor
            ObjectGuid guid = GuidManager.NewPlayerGuid();

            newCharBiota = TransferManagerUtil.SetGuidAndScrubPKs(newCharBiota, guid.Full);
            List <BiotaPropertiesString> nameProp = newCharBiota.BiotaPropertiesString.Where(k => k.Type == (ushort)PropertyString.Name).ToList();

            if (nameProp.Count != 1)
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.MalformedCharacterData
                });
            }
            string FormerCharName = nameProp.First().Value;

            nameProp.First().Value = metadata.NewCharacterName;

            Collection <(Biota biota, ReaderWriterLockSlim rwLock)> possessedBiotas = new Collection <(Biota biota, ReaderWriterLockSlim rwLock)>();

            foreach (Biota possession in possessedBiotas2)
            {
                possessedBiotas.Add((TransferManagerUtil.SetGuidAndScrubPKs(possession, GuidManager.NewDynamicGuid().Full), new ReaderWriterLockSlim()));
            }
            foreach ((Biota biota, ReaderWriterLockSlim rwLock)item in possessedBiotas)
            {
                IEnumerable <BiotaPropertiesIID> instances = item.biota.BiotaPropertiesIID.Where(k => k.Value == playerOrigId);
                foreach (BiotaPropertiesIID instance in instances)
                {
                    instance.Value = guid.Full;
                }
            }
            foreach ((Biota biota, ReaderWriterLockSlim rwLock)item in possessedBiotas)
            {
                IEnumerable <BiotaPropertiesBookPageData> instances = item.biota.BiotaPropertiesBookPageData.Where(k => k.AuthorId == playerOrigId);
                foreach (BiotaPropertiesBookPageData instance in instances)
                {
                    instance.AuthorId = guid.Full;
                }
                //TO-DO: scrub other authors?
            }

            // build
            Weenie weenie = DatabaseManager.World.GetCachedWeenie(newCharBiota.WeenieClassId);

            weenie.Type = newCharBiota.WeenieType;
            Player newPlayer = new Player(weenie, guid, metadata.AccountId)
            {
                Location = new Position(0xD655002C, 126.918549f, 81.756134f, 49.698814f, 0.794878f, 0.000000f, 0.000000f, -0.606769f), // Shoushi starter area
                Name     = metadata.NewCharacterName,
            };

            newPlayer.Character.Name = metadata.NewCharacterName;

            // insert
            mre = new ManualResetEvent(false);
            bool addCharResult = false;

            DatabaseManager.Shard.AddCharacterInParallel(newCharBiota, newPlayer.BiotaDatabaseLock, possessedBiotas, newPlayer.Character, newPlayer.CharacterDatabaseLock, new Action <bool>((res2) =>
            {
                addCharResult = res2;
                mre.Set();
            }));
            mre.WaitOne();
            if (addCharResult)
            {
                // update server
                PlayerManager.AddOfflinePlayer(DatabaseManager.Shard.GetBiota(guid.Full));
                DatabaseManager.Shard.GetCharacters(metadata.AccountId, false, new Action <List <Character> >((chars) =>
                {
                    Session session = WorldManager.Find(metadata.AccountId);
                    if (session != null)
                    {
                        session.Characters.Add(chars.First(k => k.Id == guid.Full));
                    }
                }));
                DatabaseManager.Shard.SaveCharacterTransfer(new CharacterTransfer()
                {
                    AccountId        = metadata.AccountId,
                    SourceId         = packInfo.CharacterId,
                    TransferType     = (uint)metadata.PackageType,
                    TransferTime     = (ulong)Time.GetUnixTime(),
                    Cookie           = metadata.Cookie,
                    SourceBaseUrl    = (importBytes == null) ? metadata.ImportUrl.ToString() : null,
                    SourceThumbprint = verifiedSourceThumbprint,
                    TargetId         = guid.Full,
                }, new ReaderWriterLockSlim(), null);
            }
            else
            {
                Directory.Delete(diTmpDirPath.FullName, true);
                return(new ImportAndMigrateResult()
                {
                    FailReason = ImportAndMigrateFailiureReason.AddCharacterFailed
                });
            }

            // cleanup
            Directory.Delete(diTmpDirPath.FullName, true);

            // done
            return(new ImportAndMigrateResult()
            {
                Success = true,
                NewCharacterName = metadata.NewCharacterName,
                NewCharacterId = guid.Full
            });
        }
예제 #8
0
파일: LightSource.cs 프로젝트: hooper82/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public LightSource(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #9
0
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public Corpse(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
        {
            TimeToRot = DefaultDecayTime;

            SetEphemeralValues();
        }
예제 #10
0
        static void Main(string[] args)
        {
            // original DF directory that has both /weenies and /sandboxes
            string src = @"C:\dev\behemoth\Lifestoned-DF-Server-Data";

            // output new gdle directory
            string dst = @"C:\dev\behemoth\Lifestoned-GDLE-Server-Data";

            var    sourceFiles  = Directory.EnumerateFiles(src + "\\weenies");
            string weenieOutput = dst + @"\weenies";

            if (!Directory.Exists(weenieOutput))
            {
                Directory.CreateDirectory(weenieOutput);
            }

            int       weenieMigrations = 0;
            int       weenieFails      = 0;
            Stopwatch repoMigration    = new Stopwatch();

            repoMigration.Start();

            foreach (string sourceFile in sourceFiles)
            {
                string   content  = File.ReadAllText(sourceFile);
                DfWeenie dfWeenie = JsonConvert.DeserializeObject <DfWeenie>(content);

                Console.WriteLine($"Migrating {dfWeenie.WeenieClassId}, {dfWeenie.Name}...");

                if (dfWeenie.IntProperties?.FirstOrDefault(i => i.IntPropertyId == 9007) == null)
                {
                    Console.WriteLine("... is not possible - missing Weenie Type.");
                    continue;
                }

                try
                {
                    Weenie gdleWeenie = Weenie.ConvertFromWeenie(dfWeenie);
                    string migrated   = JsonConvert.SerializeObject(gdleWeenie);
                    File.WriteAllText(Path.Combine(weenieOutput, gdleWeenie.WeenieClassId + ".json"), migrated);

                    weenieMigrations++;
                    Console.WriteLine($"... done.");
                }
                catch (Exception ex)
                {
                    weenieFails++;
                    Console.WriteLine($"... failed.");
                }
            }
            repoMigration.Stop();

            int       sandboxMigrations  = 0;
            int       sandboxWeenies     = 0;
            int       sandboxWeenieFails = 0;
            Stopwatch sandboxMigration   = new Stopwatch();

            string tmp = Path.Combine(dst, "sandboxes");

            if (!Directory.Exists(tmp))
            {
                Directory.CreateDirectory(tmp);
            }

            tmp = Path.Combine(tmp, "weenies");
            if (!Directory.Exists(tmp))
            {
                Directory.CreateDirectory(tmp);
            }

            sandboxMigration.Start();
            var sandboxes = Directory.EnumerateDirectories(src + @"\sandboxes\weenies");

            foreach (var sandbox in sandboxes)
            {
                sourceFiles = Directory.EnumerateFiles(sandbox);
                foreach (string sourceFile in sourceFiles)
                {
                    string         content       = File.ReadAllText(sourceFile);
                    DfWeenieChange dfChange      = JsonConvert.DeserializeObject <DfWeenieChange>(content);
                    string         sandboxId     = sandbox.Substring(sandbox.LastIndexOf("\\") + 1);
                    string         sandboxFolder = dst + @"\sandboxes\weenies\" + sandboxId;

                    Console.WriteLine($"Migrating sandbox {sandboxId} - Weenie {dfChange.Weenie.WeenieClassId}, {dfChange.Weenie.Name}...");

                    if (dfChange.Weenie.IntProperties?.FirstOrDefault(i => i.IntPropertyId == 9007) == null)
                    {
                        Console.WriteLine("... is not possible - missing Weenie Type.");
                        continue;
                    }

                    if (!Directory.Exists(sandboxFolder))
                    {
                        Directory.CreateDirectory(sandboxFolder);
                    }

                    try
                    {
                        WeenieChange gdleWeenieChange = WeenieChange.ConvertFromDF(dfChange);
                        string       migrated         = JsonConvert.SerializeObject(gdleWeenieChange);
                        File.WriteAllText(Path.Combine(sandboxFolder, gdleWeenieChange.Weenie.WeenieClassId + ".json"), migrated);

                        sandboxWeenies++;
                        Console.WriteLine($"... done.");
                    }
                    catch (Exception ex)
                    {
                        sandboxWeenieFails++;
                        Console.WriteLine($"... failed.");
                    }
                }

                sandboxMigrations++;
            }
            sandboxMigration.Stop();

            Console.WriteLine($"{weenieMigrations} repository weenies migrated successfully ({weenieFails} failed) in {repoMigration.ElapsedMilliseconds} milliseconds.");
            Console.WriteLine($"{sandboxWeenies} weenies in {sandboxMigrations} sandboxes migrated successfully ({sandboxWeenieFails} failed) in {sandboxMigration.ElapsedMilliseconds} milliseconds.");
            Console.WriteLine("Press Enter to continue.");
            Console.ReadLine();
        }
예제 #11
0
파일: Admin.cs 프로젝트: roidzilla/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Admin(Weenie weenie, ObjectGuid guid, Session session) : base(weenie, guid, session)
 {
     SetEphemeralValues();
 }
예제 #12
0
        /// <summary>
        /// This will create a new WorldObject with a new GUID.
        /// </summary>
        public static WorldObject CreateNewWorldObject(Weenie weenie, AppliedRuleset ruleset)
        {
            var worldObject = CreateWorldObject(weenie, GuidManager.NewDynamicGuid(), ruleset);

            return(worldObject);
        }
예제 #13
0
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public static WorldObject CreateWorldObject(Weenie weenie, ObjectGuid guid, AppliedRuleset ruleset = null)
        {
            if (ruleset == null)
            {
                ruleset = RealmManager.DefaultRuleset;
            }

            if (weenie == null || guid == null)
            {
                return(null);
            }

            var objWeenieType = weenie.WeenieType;

            switch (objWeenieType)
            {
            case WeenieType.Undef:
                return(null);

            case WeenieType.LifeStone:
                return(new Lifestone(weenie, guid));

            case WeenieType.Door:
                return(new Door(weenie, guid));

            case WeenieType.Portal:
                return(new Portal(weenie, guid));

            case WeenieType.Book:
                return(new Book(weenie, guid));

            case WeenieType.PKModifier:
                return(new PKModifier(weenie, guid));

            case WeenieType.Cow:
                return(new Cow(weenie, guid, ruleset));

            case WeenieType.Creature:
                return(new Creature(weenie, guid, ruleset));

            case WeenieType.Container:
                return(new Container(weenie, guid));

            case WeenieType.Scroll:
                return(new Scroll(weenie, guid));

            case WeenieType.Vendor:
                return(new Vendor(weenie, guid, ruleset));

            case WeenieType.Coin:
                return(new Coin(weenie, guid));

            case WeenieType.Key:
                return(new Key(weenie, guid));

            case WeenieType.Food:
                return(new Food(weenie, guid));

            case WeenieType.Gem:
                return(new Gem(weenie, guid));

            case WeenieType.Game:
                return(new Game(weenie, guid));

            case WeenieType.GamePiece:
                return(new GamePiece(weenie, guid, ruleset));

            case WeenieType.AllegianceBindstone:
                return(new Bindstone(weenie, guid));

            case WeenieType.Clothing:
                return(new Clothing(weenie, guid));

            case WeenieType.MeleeWeapon:
                return(new MeleeWeapon(weenie, guid));

            case WeenieType.MissileLauncher:
                return(new MissileLauncher(weenie, guid));

            case WeenieType.Ammunition:
                return(new Ammunition(weenie, guid));

            case WeenieType.Missile:
                return(new Missile(weenie, guid));

            case WeenieType.Corpse:
                return(new Corpse(weenie, guid));

            case WeenieType.Chest:
                return(new Chest(weenie, guid));

            case WeenieType.Stackable:
                return(new Stackable(weenie, guid));

            case WeenieType.SpellComponent:
                return(new SpellComponent(weenie, guid));

            case WeenieType.Switch:
                return(new Switch(weenie, guid));

            case WeenieType.AdvocateFane:
                return(new AdvocateFane(weenie, guid));

            case WeenieType.AdvocateItem:
                return(new AdvocateItem(weenie, guid));

            case WeenieType.Healer:
                return(new Healer(weenie, guid));

            case WeenieType.Lockpick:
                return(new Lockpick(weenie, guid));

            case WeenieType.Caster:
                return(new Caster(weenie, guid));

            case WeenieType.ProjectileSpell:
                return(new SpellProjectile(weenie, guid));

            case WeenieType.HotSpot:
                return(new Hotspot(weenie, guid));

            case WeenieType.ManaStone:
                return(new ManaStone(weenie, guid));

            case WeenieType.House:
                return(new House(weenie, guid));

            case WeenieType.SlumLord:
                return(new SlumLord(weenie, guid));

            case WeenieType.Storage:
                return(new Storage(weenie, guid));

            case WeenieType.Hook:
                return(new Hook(weenie, guid));

            case WeenieType.Hooker:
                return(new Hooker(weenie, guid));

            case WeenieType.HousePortal:
                return(new HousePortal(weenie, guid));

            case WeenieType.SkillAlterationDevice:
                return(new SkillAlterationDevice(weenie, guid));

            case WeenieType.PressurePlate:
                return(new PressurePlate(weenie, guid));

            case WeenieType.PetDevice:
                return(new PetDevice(weenie, guid));

            case WeenieType.Pet:
                return(new Pet(weenie, guid, ruleset));

            case WeenieType.CombatPet:
                return(new CombatPet(weenie, guid, ruleset));

            case WeenieType.Allegiance:
                return(new Allegiance(weenie, guid));

            case WeenieType.AugmentationDevice:
                return(new AugmentationDevice(weenie, guid));

            case WeenieType.AttributeTransferDevice:
                return(new AttributeTransferDevice(weenie, guid));

            case WeenieType.CraftTool:
                return(new CraftTool(weenie, guid));

            case WeenieType.LightSource:
                return(new LightSource(weenie, guid));

            default:
                return(new GenericObject(weenie, guid));
            }
        }
예제 #14
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Allegiance(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     //Console.WriteLine($"Allegiance({weenie.ClassId}, {guid}): weenie constructor");
 }
예제 #15
0
파일: Container.cs 프로젝트: Thomasy388/ACE
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public Container(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
        {
            SetEphemeralValues();

            InventoryLoaded = true;
        }
예제 #16
0
파일: Container.cs 프로젝트: nwacks/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Container(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #17
0
 public void CreateSQLDELETEStatement(Weenie input, StreamWriter writer)
 {
     writer.WriteLine($"DELETE FROM `weenie` WHERE `class_Id` = {input.ClassId};");
 }
예제 #18
0
파일: PressurePlate.cs 프로젝트: klp2/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public PressurePlate(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #19
0
        /// <summary>
        /// This will create a default subfolder path with the following format:<para />
        /// [Weenie Type]\\[Creature Type]\\<para />
        /// or<para />
        /// [Weenie Type]\\[Item Type]\\
        /// </summary>
        public string GetDefaultSubfolder(Weenie input)
        {
            var subFolder = Enum.GetName(typeof(WeenieType), input.Type) + "\\";

            if (input.Type == (int)WeenieType.Creature)
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.CreatureType);

                if (property != null)
                {
                    Enum.TryParse(property.Value.ToString(), out CreatureType ct);

                    if (Enum.IsDefined(typeof(CreatureType), ct))
                    {
                        subFolder += Enum.GetName(typeof(CreatureType), property.Value) + "\\";
                    }
                    else
                    {
                        subFolder += "UnknownCT_" + property.Value + "\\";
                    }
                }
                else
                {
                    subFolder += "Unsorted" + "\\";
                }
            }
            else if (input.Type == (int)WeenieType.House)
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.HouseType);

                if (property != null)
                {
                    Enum.TryParse(property.Value.ToString(), out HouseType ht);

                    if (Enum.IsDefined(typeof(HouseType), ht))
                    {
                        subFolder += Enum.GetName(typeof(HouseType), property.Value) + "\\";
                    }
                    else
                    {
                        subFolder += "UnknownHT_" + property.Value + "\\";
                    }
                }
                else
                {
                    subFolder += "Unsorted" + "\\";
                }
            }
            else
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.ItemType);

                if (property != null)
                {
                    subFolder += Enum.GetName(typeof(ItemType), property.Value) + "\\";
                }
                else
                {
                    subFolder += Enum.GetName(typeof(ItemType), ItemType.None) + "\\";
                }
            }

            return(subFolder);
        }
예제 #20
0
파일: ManaStone.cs 프로젝트: Dimmae/ACE
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public ManaStone(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #21
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public CombatPet(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #22
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Lockpick(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #23
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public MeleeWeapon(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #24
0
        /// <summary>
        /// A new biota be created taking all of its values from weenie.
        /// </summary>
        public static WorldObject CreateWorldObject(Weenie weenie, ObjectGuid guid)
        {
            var objWeenieType = (WeenieType)weenie.Type;

            switch (objWeenieType)
            {
            case WeenieType.Undef:
                return(null);

            case WeenieType.LifeStone:
                return(new Lifestone(weenie, guid));

            case WeenieType.Door:
                return(new Door(weenie, guid));

            case WeenieType.Portal:
                return(new Portal(weenie, guid));

            case WeenieType.Book:
                return(new Book(weenie, guid));

            // case WeenieType.PKModifier:
            //    return new PKModifier(weenie, guid);
            case WeenieType.Cow:
                return(new Cow(weenie, guid));

            case WeenieType.Creature:
                return(new Creature(weenie, guid));

            case WeenieType.Container:
                return(new Container(weenie, guid));

            case WeenieType.Scroll:
                return(new Scroll(weenie, guid));

            case WeenieType.Vendor:
                return(new Vendor(weenie, guid));

            case WeenieType.Coin:
                return(new Coin(weenie, guid));

            case WeenieType.Key:
                return(new Key(weenie, guid));

            case WeenieType.Food:
                return(new Food(weenie, guid));

            case WeenieType.Gem:
                return(new Gem(weenie, guid));

            case WeenieType.Game:
                return(new Game(weenie, guid));

            case WeenieType.GamePiece:
                return(new GamePiece(weenie, guid));

            case WeenieType.AllegianceBindstone:
                return(new Bindstone(weenie, guid));

            case WeenieType.Clothing:
                return(new Clothing(weenie, guid));

            case WeenieType.MeleeWeapon:
                return(new MeleeWeapon(weenie, guid));

            case WeenieType.MissileLauncher:
                return(new MissileLauncher(weenie, guid));

            case WeenieType.Ammunition:
                return(new Ammunition(weenie, guid));

            case WeenieType.Missile:
                return(new Missile(weenie, guid));

            default:
                return(new GenericObject(weenie, guid));
            }
        }
예제 #25
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public CraftTool(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #26
0
        /// <summary>
        /// This will create a new WorldObject with a new GUID.
        /// </summary>
        public static WorldObject CreateNewWorldObject(Weenie weenie)
        {
            var worldObject = CreateWorldObject(weenie, GuidManager.NewDynamicGuid());

            return(worldObject);
        }
예제 #27
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Clothing(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #28
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public SkillAlterationDevice(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }
예제 #29
0
        public static Biota ConvertToBiota(this Weenie weenie, uint id, bool instantiateEmptyCollections = false, bool referenceWeenieCollectionsForCommonProperties = false)
        {
            var result = new Biota();

            result.Id            = id;
            result.WeenieClassId = weenie.WeenieClassId;
            result.WeenieType    = weenie.WeenieType;

            if (weenie.PropertiesBool != null && (instantiateEmptyCollections || weenie.PropertiesBool.Count > 0))
            {
                result.PropertiesBool = new Dictionary <PropertyBool, bool>(weenie.PropertiesBool);
            }
            if (weenie.PropertiesDID != null && (instantiateEmptyCollections || weenie.PropertiesDID.Count > 0))
            {
                result.PropertiesDID = new Dictionary <PropertyDataId, uint>(weenie.PropertiesDID);
            }
            if (weenie.PropertiesFloat != null && (instantiateEmptyCollections || weenie.PropertiesFloat.Count > 0))
            {
                result.PropertiesFloat = new Dictionary <PropertyFloat, double>(weenie.PropertiesFloat);
            }
            if (weenie.PropertiesIID != null && (instantiateEmptyCollections || weenie.PropertiesIID.Count > 0))
            {
                result.PropertiesIID = new Dictionary <PropertyInstanceId, uint>(weenie.PropertiesIID);
            }
            if (weenie.PropertiesInt != null && (instantiateEmptyCollections || weenie.PropertiesInt.Count > 0))
            {
                result.PropertiesInt = new Dictionary <PropertyInt, int>(weenie.PropertiesInt);
            }
            if (weenie.PropertiesInt64 != null && (instantiateEmptyCollections || weenie.PropertiesInt64.Count > 0))
            {
                result.PropertiesInt64 = new Dictionary <PropertyInt64, long>(weenie.PropertiesInt64);
            }
            if (weenie.PropertiesString != null && (instantiateEmptyCollections || weenie.PropertiesString.Count > 0))
            {
                result.PropertiesString = new Dictionary <PropertyString, string>(weenie.PropertiesString);
            }


            if (weenie.PropertiesPosition != null && (instantiateEmptyCollections || weenie.PropertiesPosition.Count > 0))
            {
                result.PropertiesPosition = new Dictionary <PositionType, PropertiesPosition>(weenie.PropertiesPosition.Count);

                foreach (var kvp in weenie.PropertiesPosition)
                {
                    result.PropertiesPosition.Add(kvp.Key, kvp.Value.Clone());
                }
            }


            if (weenie.PropertiesSpellBook != null && (instantiateEmptyCollections || weenie.PropertiesSpellBook.Count > 0))
            {
                result.PropertiesSpellBook = new Dictionary <int, float>(weenie.PropertiesSpellBook);
            }


            if (weenie.PropertiesAnimPart != null && (instantiateEmptyCollections || weenie.PropertiesAnimPart.Count > 0))
            {
                result.PropertiesAnimPart = new List <PropertiesAnimPart>(weenie.PropertiesAnimPart.Count);

                foreach (var record in weenie.PropertiesAnimPart)
                {
                    result.PropertiesAnimPart.Add(record.Clone());
                }
            }

            if (weenie.PropertiesPalette != null && (instantiateEmptyCollections || weenie.PropertiesPalette.Count > 0))
            {
                result.PropertiesPalette = new Collection <PropertiesPalette>();

                foreach (var record in weenie.PropertiesPalette)
                {
                    result.PropertiesPalette.Add(record.Clone());
                }
            }

            if (weenie.PropertiesTextureMap != null && (instantiateEmptyCollections || weenie.PropertiesTextureMap.Count > 0))
            {
                result.PropertiesTextureMap = new List <PropertiesTextureMap>(weenie.PropertiesTextureMap.Count);

                foreach (var record in weenie.PropertiesTextureMap)
                {
                    result.PropertiesTextureMap.Add(record.Clone());
                }
            }


            // Properties for all world objects that typically aren't modified over the original weenie

            if (referenceWeenieCollectionsForCommonProperties)
            {
                result.PropertiesCreateList  = weenie.PropertiesCreateList;
                result.PropertiesEmote       = weenie.PropertiesEmote;
                result.PropertiesEventFilter = weenie.PropertiesEventFilter;
                result.PropertiesGenerator   = weenie.PropertiesGenerator;
            }
            else
            {
                if (weenie.PropertiesCreateList != null && (instantiateEmptyCollections || weenie.PropertiesCreateList.Count > 0))
                {
                    result.PropertiesCreateList = new Collection <PropertiesCreateList>();

                    foreach (var record in weenie.PropertiesCreateList)
                    {
                        result.PropertiesCreateList.Add(record.Clone());
                    }
                }

                if (weenie.PropertiesEmote != null && (instantiateEmptyCollections || weenie.PropertiesEmote.Count > 0))
                {
                    result.PropertiesEmote = new Collection <PropertiesEmote>();

                    foreach (var record in weenie.PropertiesEmote)
                    {
                        result.PropertiesEmote.Add(record.Clone());
                    }
                }

                if (weenie.PropertiesEventFilter != null && (instantiateEmptyCollections || weenie.PropertiesEventFilter.Count > 0))
                {
                    result.PropertiesEventFilter = new HashSet <int>(weenie.PropertiesEventFilter);
                }

                if (weenie.PropertiesGenerator != null && (instantiateEmptyCollections || weenie.PropertiesGenerator.Count > 0))
                {
                    result.PropertiesGenerator = new List <PropertiesGenerator>(weenie.PropertiesGenerator.Count);

                    foreach (var record in weenie.PropertiesGenerator)
                    {
                        result.PropertiesGenerator.Add(record.Clone());
                    }
                }
            }


            // Properties for creatures

            if (weenie.PropertiesAttribute != null && (instantiateEmptyCollections || weenie.PropertiesAttribute.Count > 0))
            {
                result.PropertiesAttribute = new Dictionary <PropertyAttribute, PropertiesAttribute>(weenie.PropertiesAttribute.Count);

                foreach (var kvp in weenie.PropertiesAttribute)
                {
                    result.PropertiesAttribute.Add(kvp.Key, kvp.Value.Clone());
                }
            }

            if (weenie.PropertiesAttribute2nd != null && (instantiateEmptyCollections || weenie.PropertiesAttribute2nd.Count > 0))
            {
                result.PropertiesAttribute2nd = new Dictionary <PropertyAttribute2nd, PropertiesAttribute2nd>(weenie.PropertiesAttribute2nd.Count);

                foreach (var kvp in weenie.PropertiesAttribute2nd)
                {
                    result.PropertiesAttribute2nd.Add(kvp.Key, kvp.Value.Clone());
                }
            }

            if (referenceWeenieCollectionsForCommonProperties)
            {
                result.PropertiesBodyPart = weenie.PropertiesBodyPart;
            }
            else
            {
                if (weenie.PropertiesBodyPart != null && (instantiateEmptyCollections || weenie.PropertiesBodyPart.Count > 0))
                {
                    result.PropertiesBodyPart = new Dictionary <CombatBodyPart, PropertiesBodyPart>(weenie.PropertiesBodyPart.Count);

                    foreach (var kvp in weenie.PropertiesBodyPart)
                    {
                        result.PropertiesBodyPart.Add(kvp.Key, kvp.Value.Clone());
                    }
                }
            }

            if (weenie.PropertiesSkill != null && (instantiateEmptyCollections || weenie.PropertiesSkill.Count > 0))
            {
                result.PropertiesSkill = new Dictionary <Skill, PropertiesSkill>(weenie.PropertiesSkill.Count);

                foreach (var kvp in weenie.PropertiesSkill)
                {
                    result.PropertiesSkill.Add(kvp.Key, kvp.Value.Clone());
                }
            }


            // Properties for books

            if (weenie.PropertiesBook != null)
            {
                result.PropertiesBook = weenie.PropertiesBook.Clone();
            }

            if (weenie.PropertiesBookPageData != null && (instantiateEmptyCollections || weenie.PropertiesBookPageData.Count > 0))
            {
                result.PropertiesBookPageData = new List <PropertiesBookPageData>(weenie.PropertiesBookPageData);
            }


            return(result);
        }
예제 #30
0
 /// <summary>
 /// A new biota be created taking all of its values from weenie.
 /// </summary>
 public Stackable(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
 {
     SetEphemeralValues();
 }