Exemple #1
0
        private void SubmitButtonClick(object sender, EventArgs e)
        {
            IEnumerable <SkillCard> effectiveContributions;
            var crisisResults = SkillCheck.EvalSkillCheck(CrisisContributions.Select(x => x.Item1), _crisis, Rules, out effectiveContributions);

            var resultOutput = new StringBuilder();

            var totalPower = 0;

            foreach (var contribution in effectiveContributions.OrderBy(x => x.CardColor))
            {
                resultOutput.AppendLine(string.Format(FinalFormat, contribution.CardPower, contribution.Heading));
                totalPower += contribution.CardPower;
            }
            resultOutput.AppendLine(@"\b--------------------\b0");
            foreach (var consequence in crisisResults)
            {
                resultOutput.AppendLine(string.Format(OutputResultFormat, totalPower, consequence.Threshold, consequence.ConditionText));
            }
            resultOutput.Replace(Environment.NewLine, @" \line ");
            resultOutput.Insert(0, @"{\rtf1\ansi ");
            resultOutput.Append(@"}");

            Result = resultOutput.ToString();

            if (PlayerTakeCardsCheckBox.Checked)
            {
                PlayerTakingCards = (Player)PlayerTakeCardsDropdown.SelectedItem;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        public void Should_Pass_Skill_Check_Correctly()
        {
            var crisisCard =
                new CrisisCard
            {
                Heading        = "ExampleCrisis",
                PositiveColors = new List <SkillCardColor> {
                    SkillCardColor.Leadership, SkillCardColor.Tactics
                },
                PassLevels =
                    new List <Tuple <int, string> >
                {
                    new Tuple <int, string>(12, "pass"),
                    new Tuple <int, string>(0, "fail")
                }
            };
            var playedCards = new List <SkillCard>
            {
                new SkillCard {
                    CardPower = 5, CardColor = SkillCardColor.Leadership
                },
                new SkillCard {
                    CardPower = 5, CardColor = SkillCardColor.Tactics
                },
                new SkillCard {
                    CardPower = 3, CardColor = SkillCardColor.Leadership
                }
            };
            IEnumerable <SkillCard> effectiveCards;
            var ret = SkillCheck.EvalSkillCheck(playedCards, crisisCard, null, out effectiveCards);

            Assert.AreEqual(1, ret.Count());
            Assert.AreEqual("pass", ret.ElementAt(0).ConditionText);
            Assert.AreEqual(12, ret.ElementAt(0).Threshold);
        }
    // Use this for initialization
    void Start()
    {
        pickupSkill = GameObject.Find("Pickup Skill").GetComponent <SkillCheck>();
        arrowSkill  = GameObject.Find("Arrow Skill").GetComponent <SkillCheck>();
        healthSkill = GameObject.Find("Health Skill").GetComponent <SkillCheck>();
        buffSkill   = GameObject.Find("Buff Skill").GetComponent <SkillCheck>();

        m_GodHandler = this.GetComponentInParent <GodHandler>().God;

        // Listener for the power change
        m_GodHandler.onPowerChange += ReactToChange;

        // Listener for level change
        m_GodHandler.onLevelChange += ReactToChange;

        // Listener for skill point change;
        m_GodHandler.onPointsChange += ReactToChange;

        if (skill)
        {
            skill.SetValues(this.gameObject, m_GodHandler);
        }

        EnableSkills();
    }
Exemple #4
0
        private void RefreshResultPane()
        {
            IEnumerable <SkillCard> effectiveContributions;
            var crisisResults = SkillCheck.EvalSkillCheck(CrisisContributions.Select(x => x.Item1), _crisis, Rules, out effectiveContributions);

            var toDisplay = new StringBuilder();

            var totalPower = 0;

            var index = 0;

            foreach (var contribution in effectiveContributions)
            {
                toDisplay.AppendLine(string.Format(ResultFormat, contribution.CardPower, contribution.Heading, CrisisContributions[index].Item2));
                totalPower += contribution.CardPower;
                index++;
            }
            toDisplay.AppendLine(@"\b--------------------\b0");
            toDisplay.AppendLine(_crisis.ToString());
            toDisplay.AppendLine(@"\b--------------------\b0");
            foreach (var consequence in crisisResults)
            {
                toDisplay.AppendLine(string.Format(ResultFormat, consequence.ConditionText, consequence.Threshold, totalPower));
            }
            toDisplay.Replace(Environment.NewLine, @" \line ");
            toDisplay.Insert(0, @"{\rtf1\ansi ");
            toDisplay.Append(@"}");
            ResultTextBox.Rtf = toDisplay.ToString();
        }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        targetCamera = GameObject.FindObjectOfType <Camera>();
        character    = GameObject.Find("Character").GetComponent <Dunga>();

        pickupSkill = GameObject.Find("Pickup Skill").GetComponent <SkillCheck>();
    }
Exemple #6
0
        /// <summary>
        /// Construct all of the info required for appraising any WorldObject
        /// </summary>
        public AppraiseInfo(WorldObject wo, Player examiner, bool success = true)
        {
            //Console.WriteLine("Appraise: " + wo.Guid);
            Success = success;

            // get wielder, if applicable
            var wielder = GetWielder(wo);

            BuildProperties(wo, wielder);
            BuildSpells(wo);

            // Help us make sure the item identify properly
            NPCLooksLikeObject = wo.GetProperty(PropertyBool.NpcLooksLikeObject) ?? false;

            // armor / clothing / shield
            if (wo is Clothing || wo.IsShield)
            {
                BuildArmor(wo);
            }

            if (wo is Creature creature)
            {
                BuildCreature(creature);
            }

            if (wo is MeleeWeapon || wo is Missile || wo is MissileLauncher || wo is Ammunition || wo is Caster)
            {
                BuildWeapon(wo, wielder);
            }

            if (wo is Door || wo is Chest)
            {
                // If wo is not locked, do not send ResistLockpick value. If ResistLockpick is sent for unlocked objects, id panel shows bonus to Lockpick skill
                if (!wo.IsLocked && PropertiesInt.ContainsKey(PropertyInt.ResistLockpick))
                {
                    PropertiesInt.Remove(PropertyInt.ResistLockpick);
                }

                // If wo is locked, append skill check percent, as int, to properties for id panel display on chances of success
                if (wo.IsLocked)
                {
                    var playerLockPickSkill = examiner.Skills[Skill.Lockpick].Current;

                    var doorLockPickResistance = wo.ResistLockpick;

                    var lockpickSuccessPercent = SkillCheck.GetSkillChance((int)playerLockPickSkill, (int)doorLockPickResistance) * 100;

                    if (!PropertiesInt.ContainsKey(PropertyInt.AppraisalLockpickSuccessPercent))
                    {
                        PropertiesInt.Add(PropertyInt.AppraisalLockpickSuccessPercent, (int)lockpickSuccessPercent);
                    }
                }
            }

            BuildFlags();
        }
Exemple #7
0
        /// <summary>
        /// Returns the chance for creature to avoid monster attack
        /// </summary>
        public float GetEvadeChance(Creature attacker, Creature defender)
        {
            AccuracyMod = attacker.GetAccuracyMod(Weapon);

            EffectiveAttackSkill  = attacker.GetEffectiveAttackSkill();
            EffectiveDefenseSkill = defender.GetEffectiveDefenseSkill(attacker.CurrentAttack ?? CombatType.Melee);

            var evadeChance = 1.0f - SkillCheck.GetSkillChance(EffectiveAttackSkill, EffectiveDefenseSkill);

            return((float)evadeChance);
        }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        managerScript = GameObject.Find("GameManager").GetComponent <PauseGame>();
        //Call functions for initial values
        SetHealthBarPosition();
        currentScene = SceneManager.GetActiveScene();
        //Get Components attached to the Healthbar
        Rend        = GetComponent <Renderer>();
        my_image    = GetComponent <Image>();
        myCharacter = GameObject.Find("Character");
        cam1        = GameObject.Find("Main Camera").transform; ///Finds the main camera - used to position UI correctly later on
        LayerMask lMask = LayerMask.GetMask("UI");              ///Sets the layermask variable to the UI layer - used to find collision with ui elements later on

        healthSkill = GameObject.Find("Health Skill").GetComponent <SkillCheck>();
    }
 // Use this for initialization
 void Start()
 {
     managerScript = GameObject.Find("GameManager").GetComponent <PauseGame>();
     currentScene  = SceneManager.GetActiveScene();
     clickable     = false;
     stopped       = false;
     shootable     = false;
     shot          = false;
     anim          = gameObject.GetComponent <Animator>();
     arrowSkill    = GameObject.Find("Arrow Skill").GetComponent <SkillCheck>();
     if (currentScene.name == "TutorialScene")
     {
         managerScript.arrowCollider = gameObject;
         gameObject.SetActive(false);
     }
 }
Exemple #10
0
        private bool CanUse(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
                return(false);
            }

            if (SkillCheck.HasAnyAcceleratedSkillGain(from))
            {
                from.SendLocalizedMessage(1077951);                   // You are already under the effect of an accelerated skillgain scroll.
                return(false);
            }

            return(true);
        }
Exemple #11
0
        public static bool Mobile_SkillCheckDirectTarget(Mobile from, SkillName skillName, object target, double chance)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            // call the default skillcheck handler
            bool success = SkillCheck.Mobile_SkillCheckDirectTarget(from, skillName, target, chance);

            // call the xmlspawner skillcheck handler
            CheckSkillUse(from, skill, success);

            return(success);
        }
Exemple #12
0
        // alternate skillcheck hooks to replace those in SkillCheck.cs
        public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            // call the default skillcheck handler
            bool success = SkillCheck.Mobile_SkillCheckLocation(from, skillName, minSkill, maxSkill);

            // call the xmlspawner skillcheck handler
            CheckSkillUse(from, skill, success);

            return(success);
        }
Exemple #13
0
    public void TimeSkill()
    {
        SkillCheck skillCheck = GameObject.Find("Player").GetComponent <SkillCheck>();
        bool       check      = skillCheck.hazardcheck;



        if (check == true)
        {
            Switch();
            GameObject.Find("Audio Source_Skill").GetComponent <AudioSource>().Play();
        }
        else if (check == false)
        {
            SoundManager.instance.PlaySound("CannotChangeTime");
        }
    }
    // Use this for initialization
    void Start()
    {
        managerScript = GameObject.Find("GameManager").GetComponent <PauseGame>();
        GameObject newEnrage = Instantiate(enragePrefab, transform.position, Quaternion.identity);

        newEnrage.transform.SetParent(transform.parent);
        newEnrage.GetComponent <Enrage_Buff>().SetPosition();
        Time.timeScale = 1.0f;
        camLocation    = GameObject.Find("Main Camera").transform; ///Finds the main camera
        countdownText  = GetComponentInChildren <TextMeshPro>();
        SetPosition();
        iColl        = GetComponent <Collider>();
        destroyTimer = 10.0f;
        Invoke("Destroy", destroyTimer);
        InvokeRepeating("SubtractTime", 0, 0.1f);

        buffSkill = GameObject.Find("Buff Skill").GetComponent <SkillCheck>();
    }
        public void Use(Mobile from, bool firstStage)
        {
            if (Deleted)
            {
                return;
            }

            if (SkillCheck.HasAnyAcceleratedSkillGain(from))
            {
                from.SendLocalizedMessage(1077951);                   // You are already under the effect of an accelerated skillgain scroll.
                return;
            }

            if (IsChildOf(from.Backpack))
            {
                Skill skill = from.Skills[m_Skill];

                if (skill != null)
                {
                    if (firstStage)
                    {
                        from.CloseGump(typeof(ScrollOfTranscendence.InternalGump));
                        from.SendGump(BuildGump(from, this));
                    }
                    else
                    {
                        // calculamos las skills que puede bajar
                        double potentialFreeSkill = 0;

                        for (int i = 0; i < from.Skills.Length; i++)
                        {
                            Skill sk = from.Skills[i];

                            if (sk.Lock == SkillLock.Down)
                            {
                                potentialFreeSkill += sk.Base;
                            }
                        }

                        if (skill.Lock == SkillLock.Locked || skill.Lock == SkillLock.Down || skill.Base >= skill.Cap || from.Skills.Total - (10 * potentialFreeSkill) >= from.Skills.Cap)
                        {
                            from.SendLocalizedMessage(1094935);                               // You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu. If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.
                        }
                        else
                        {
                            double toRaise = Math.Min(m_Value, skill.Cap - skill.Base);

                            // bajamos las skills que necesitemos, o las que podamos bajar
                            double toFree = toRaise - ((double)(from.Skills.Cap - from.Skills.Total) / 10);

                            if (toFree < 0.0)
                            {
                                toFree = 0.0;
                            }

                            for (int i = 0; i < from.Skills.Length && toFree > 0; i++)
                            {
                                Skill sk = from.Skills[i];

                                if (sk.Lock == SkillLock.Down)
                                {
                                    if (sk.Base > toFree)
                                    {
                                        sk.Base -= toFree;
                                        toFree   = 0;
                                    }
                                    else
                                    {
                                        toFree -= sk.Base;
                                        sk.Base = 0;
                                    }
                                }
                            }

                            toRaise -= toFree;

                            skill.Base += toRaise;

                            Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0, 0, 0, 0, 0, 5060, 0);
                            Effects.PlaySound(from.Location, from.Map, 0x243);

                            Effects.SendMovingParticles(new DummyEntity(Serial.Zero, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
                            Effects.SendMovingParticles(new DummyEntity(Serial.Zero, new Point3D(from.X - 4, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
                            Effects.SendMovingParticles(new DummyEntity(Serial.Zero, new Point3D(from.X - 6, from.Y - 4, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);

                            Effects.SendTargetParticles(from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);

                            Delete();
                        }
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
        }
 public override void OnSingleClick(Mobile from)
 {
     LabelTo(from, "a skill mastery scroll");
     LabelTo(from, "(" + SkillCheck.GetSkillName(m_Skill) + ")");
 }
Exemple #17
0
        public void BuildProfile(WorldObject wo, Player examiner, bool success = true)
        {
            //Console.WriteLine("Appraise: " + wo.Guid);
            Success = success;

            // get wielder, if applicable
            var wielder = GetWielder(wo, examiner);

            BuildProperties(wo, wielder);
            BuildSpells(wo);

            // Help us make sure the item identify properly
            NPCLooksLikeObject = wo.GetProperty(PropertyBool.NpcLooksLikeObject) ?? false;

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedWielder))
            {
                if (!PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedWielder))
                {
                    PropertiesBool.Add(PropertyBool.AppraisalHasAllowedWielder, true);
                }
            }

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedActivator))
            {
                if (!PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedActivator))
                {
                    PropertiesBool.Add(PropertyBool.AppraisalHasAllowedActivator, true);
                }
            }

            if (PropertiesString.ContainsKey(PropertyString.ScribeAccount) && !examiner.IsAdmin && !examiner.IsSentinel && !examiner.IsEnvoy && !examiner.IsArch && !examiner.IsPsr)
            {
                PropertiesString.Remove(PropertyString.ScribeAccount);
            }

            if (PropertiesString.ContainsKey(PropertyString.HouseOwnerAccount) && !examiner.IsAdmin && !examiner.IsSentinel && !examiner.IsEnvoy && !examiner.IsArch && !examiner.IsPsr)
            {
                PropertiesString.Remove(PropertyString.HouseOwnerAccount);
            }

            if (PropertiesInt.ContainsKey(PropertyInt.Lifespan))
            {
                PropertiesInt[PropertyInt.RemainingLifespan] = wo.GetRemainingLifespan();
            }

            // armor / clothing / shield
            if (wo is Clothing || wo.IsShield)
            {
                BuildArmor(wo);
            }

            if (wo is Creature creature)
            {
                BuildCreature(creature);
            }

            if (wo.Damage != null || wo is MeleeWeapon || wo is Missile || wo is MissileLauncher || wo is Ammunition || wo is Caster)
            {
                BuildWeapon(wo, wielder);
            }

            if (wo is Door || wo is Chest)
            {
                // If wo is not locked, do not send ResistLockpick value. If ResistLockpick is sent for unlocked objects, id panel shows bonus to Lockpick skill
                if (!wo.IsLocked && PropertiesInt.ContainsKey(PropertyInt.ResistLockpick))
                {
                    PropertiesInt.Remove(PropertyInt.ResistLockpick);
                }

                // If wo is locked, append skill check percent, as int, to properties for id panel display on chances of success
                if (wo.IsLocked)
                {
                    var resistLockpick = LockHelper.GetResistLockpick(wo);

                    if (resistLockpick != null)
                    {
                        PropertiesInt[PropertyInt.ResistLockpick] = (int)resistLockpick;

                        var pickSkill = examiner.Skills[Skill.Lockpick].Current;

                        var successChance = SkillCheck.GetSkillChance((int)pickSkill, (int)resistLockpick) * 100;

                        if (!PropertiesInt.ContainsKey(PropertyInt.AppraisalLockpickSuccessPercent))
                        {
                            PropertiesInt.Add(PropertyInt.AppraisalLockpickSuccessPercent, (int)successChance);
                        }
                    }
                }
            }

            if (wo is Corpse)
            {
                PropertiesBool.Clear();
                PropertiesDID.Clear();
                PropertiesFloat.Clear();
                PropertiesInt64.Clear();

                var discardInts = PropertiesInt.Where(x => x.Key != PropertyInt.EncumbranceVal && x.Key != PropertyInt.Value).Select(x => x.Key).ToList();
                foreach (var key in discardInts)
                {
                    PropertiesInt.Remove(key);
                }
                var discardString = PropertiesString.Where(x => x.Key != PropertyString.LongDesc).Select(x => x.Key).ToList();
                foreach (var key in discardString)
                {
                    PropertiesString.Remove(key);
                }
            }

            if (wo is Portal)
            {
                if (PropertiesInt.ContainsKey(PropertyInt.EncumbranceVal))
                {
                    PropertiesInt.Remove(PropertyInt.EncumbranceVal);
                }
            }

            if (wo is SlumLord slumLord)
            {
                PropertiesBool.Clear();
                PropertiesDID.Clear();
                PropertiesFloat.Clear();
                PropertiesIID.Clear();
                //PropertiesInt.Clear();
                PropertiesInt64.Clear();
                PropertiesString.Clear();

                var longDesc = "";

                if (slumLord.HouseOwner.HasValue && slumLord.HouseOwner.Value > 0)
                {
                    longDesc = $"The current maintenance has {(slumLord.IsRentPaid() || !PropertyManager.GetBool("house_rent_enabled").Item ? "" : "not ")}been paid.\n";

                    PropertiesInt.Clear();
                }
                else
                {
                    //longDesc = $"This house is {(slumLord.HouseStatus == HouseStatus.Disabled ? "not " : "")}available for purchase.\n"; // this was the retail msg.
                    longDesc = $"This {(slumLord.House.HouseType == HouseType.Undef ? "house" : slumLord.House.HouseType.ToString().ToLower())} is {(slumLord.House.HouseStatus == HouseStatus.Disabled ? "not " : "")}available for purchase.\n";

                    var discardInts = PropertiesInt.Where(x => x.Key != PropertyInt.HouseStatus && x.Key != PropertyInt.HouseType && x.Key != PropertyInt.MinLevel && x.Key != PropertyInt.MaxLevel && x.Key != PropertyInt.AllegianceMinLevel && x.Key != PropertyInt.AllegianceMaxLevel).Select(x => x.Key).ToList();
                    foreach (var key in discardInts)
                    {
                        PropertiesInt.Remove(key);
                    }
                }

                if (slumLord.HouseRequiresMonarch)
                {
                    longDesc += "You must be a monarch to purchase and maintain this dwelling.\n";
                }

                if (slumLord.AllegianceMinLevel.HasValue)
                {
                    var allegianceMinLevel = PropertyManager.GetLong("mansion_min_rank", -1).Item;
                    if (allegianceMinLevel == -1)
                    {
                        allegianceMinLevel = slumLord.AllegianceMinLevel.Value;
                    }

                    longDesc += $"Restricted to characters of allegiance rank {allegianceMinLevel} or greater.\n";
                }

                PropertiesString.Add(PropertyString.LongDesc, longDesc);
            }

            if (wo is Storage)
            {
                var longDesc = "";

                if (wo.HouseOwner.HasValue && wo.HouseOwner.Value > 0)
                {
                    longDesc = $"Owned by {wo.ParentLink.HouseOwnerName}\n";
                }

                var discardString = PropertiesString.Where(x => x.Key != PropertyString.Use).Select(x => x.Key).ToList();
                foreach (var key in discardString)
                {
                    PropertiesString.Remove(key);
                }

                PropertiesString.Add(PropertyString.LongDesc, longDesc);

                if (PropertiesInt.ContainsKey(PropertyInt.Value))
                {
                    PropertiesInt[PropertyInt.Value] = wo.Biota.GetProperty(PropertyInt.Value, wo.BiotaDatabaseLock) ?? 200; // Value is masked to base value of Storage
                }
            }

            if (wo is Hook)
            {
                // If the hook has any inventory, we need to send THOSE properties instead.
                var hook = wo as Container;

                string baseDescString = "";
                if (wo.ParentLink.HouseOwner != null)
                {
                    // This is for backwards compatibility. This value was not set/saved in earlier versions.
                    // It will get the player's name and save that to the HouseOwnerName property of the house. This is now done when a player purchases a house.
                    if (wo.ParentLink.HouseOwnerName == null)
                    {
                        var houseOwnerPlayer = PlayerManager.FindByGuid((uint)wo.ParentLink.HouseOwner);
                        if (houseOwnerPlayer != null)
                        {
                            wo.ParentLink.HouseOwnerName = houseOwnerPlayer.Name;
                            wo.ParentLink.SaveBiotaToDatabase();
                        }
                    }
                    baseDescString = "This hook is owned by " + wo.ParentLink.HouseOwnerName + ". "; //if house is owned, display this text
                }

                var containsString = "";
                if (hook.Inventory.Count == 1)
                {
                    WorldObject hookedItem = hook.Inventory.First().Value;

                    // Hooked items have a custom "description", containing the desc of the sub item and who the owner of the house is (if any)
                    BuildProfile(hookedItem, examiner, success);

                    containsString = "It contains: \n";

                    if (PropertiesString.ContainsKey(PropertyString.LongDesc) && PropertiesString[PropertyString.LongDesc] != null)
                    {
                        containsString += PropertiesString[PropertyString.LongDesc];
                    }
                    else if (PropertiesString.ContainsKey(PropertyString.ShortDesc) && PropertiesString[PropertyString.ShortDesc] != null)
                    {
                        containsString += PropertiesString[PropertyString.ShortDesc];
                    }
                    else
                    {
                        containsString += PropertiesString[PropertyString.Name];
                    }

                    BuildHookProfile(hookedItem);
                }

                if (PropertiesString.ContainsKey(PropertyString.LongDesc) && PropertiesString[PropertyString.LongDesc] != null)
                {
                    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;
                }
                else if (PropertiesString.ContainsKey(PropertyString.ShortDesc) && PropertiesString[PropertyString.ShortDesc] != null)
                {
                    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;
                }
                else
                {
                    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;
                }
            }

            if (wo is ManaStone)
            {
                var useMessage = "";

                if (wo.ItemCurMana.HasValue)
                {
                    useMessage = "Use on a magic item to give the stone's stored Mana to that item.";
                }
                else
                {
                    useMessage = "Use on a magic item to destroy that item and drain its Mana.";
                }

                PropertiesString[PropertyString.Use] = useMessage;
            }

            if (wo is CraftTool && (wo.ItemType == ItemType.TinkeringMaterial || wo.WeenieClassId >= 36619 && wo.WeenieClassId <= 36628 || wo.WeenieClassId >= 36634 && wo.WeenieClassId <= 36636))
            {
                if (PropertiesInt.ContainsKey(PropertyInt.Structure))
                {
                    PropertiesInt.Remove(PropertyInt.Structure);
                }
            }

            if (!Success)
            {
                // todo: what specifically to keep/what to clear

                //PropertiesBool.Clear();
                //PropertiesDID.Clear();
                //PropertiesFloat.Clear();
                //PropertiesIID.Clear();
                //PropertiesInt.Clear();
                //PropertiesInt64.Clear();
                //PropertiesString.Clear();
            }

            BuildFlags();
        }
Exemple #18
0
        public void BuildProfile(WorldObject wo, Player examiner, bool success = true)
        {
            //Console.WriteLine("Appraise: " + wo.Guid);
            Success = success;

            BuildProperties(wo);
            BuildSpells(wo);

            // Help us make sure the item identify properly
            NPCLooksLikeObject = wo.GetProperty(PropertyBool.NpcLooksLikeObject) ?? false;

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedWielder) && !PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedWielder))
            {
                PropertiesBool.Add(PropertyBool.AppraisalHasAllowedWielder, true);
            }

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedActivator) && !PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedActivator))
            {
                PropertiesBool.Add(PropertyBool.AppraisalHasAllowedActivator, true);
            }

            if (PropertiesString.ContainsKey(PropertyString.ScribeAccount) && !examiner.IsAdmin && !examiner.IsSentinel && !examiner.IsEnvoy && !examiner.IsArch && !examiner.IsPsr)
            {
                PropertiesString.Remove(PropertyString.ScribeAccount);
            }

            if (PropertiesString.ContainsKey(PropertyString.HouseOwnerAccount) && !examiner.IsAdmin && !examiner.IsSentinel && !examiner.IsEnvoy && !examiner.IsArch && !examiner.IsPsr)
            {
                PropertiesString.Remove(PropertyString.HouseOwnerAccount);
            }

            if (PropertiesInt.ContainsKey(PropertyInt.Lifespan))
            {
                PropertiesInt[PropertyInt.RemainingLifespan] = wo.GetRemainingLifespan();
            }

            if (PropertiesInt.TryGetValue(PropertyInt.Faction1Bits, out var faction1Bits))
            {
                // hide any non-default factions, prevent client from displaying ???
                // this is only needed for non-standard faction creatures that use templates, to hide the ??? in the client
                var sendBits = faction1Bits & (int)FactionBits.ValidFactions;
                if (sendBits != faction1Bits)
                {
                    if (sendBits != 0)
                    {
                        PropertiesInt[PropertyInt.Faction1Bits] = sendBits;
                    }
                    else
                    {
                        PropertiesInt.Remove(PropertyInt.Faction1Bits);
                    }
                }
            }

            // armor / clothing / shield
            if (wo is Clothing || wo.IsShield)
            {
                BuildArmor(wo);
            }

            if (wo is Creature creature)
            {
                BuildCreature(creature);
            }

            if (wo.Damage != null && !(wo is Clothing) || wo is MeleeWeapon || wo is Missile || wo is MissileLauncher || wo is Ammunition || wo is Caster)
            {
                BuildWeapon(wo);
            }

            // TODO: Resolve this issue a better way?
            // Because of the way ACE handles default base values in recipe system (or rather the lack thereof)
            // we need to check the following weapon properties to see if they're below expected minimum and adjust accordingly
            // The issue is that the recipe system likely added 0.005 to 0 instead of 1, which is what *should* have happened.
            if (wo.WeaponMagicDefense.HasValue && wo.WeaponMagicDefense.Value > 0 && wo.WeaponMagicDefense.Value < 1 && ((wo.GetProperty(PropertyInt.ImbueStackingBits) ?? 0) & 1) != 0)
            {
                PropertiesFloat[PropertyFloat.WeaponMagicDefense] += 1;
            }
            if (wo.WeaponMissileDefense.HasValue && wo.WeaponMissileDefense.Value > 0 && wo.WeaponMissileDefense.Value < 1 && ((wo.GetProperty(PropertyInt.ImbueStackingBits) ?? 0) & 1) != 0)
            {
                PropertiesFloat[PropertyFloat.WeaponMissileDefense] += 1;
            }

            if (wo is Door || wo is Chest)
            {
                // If wo is not locked, do not send ResistLockpick value. If ResistLockpick is sent for unlocked objects, id panel shows bonus to Lockpick skill
                if (!wo.IsLocked && PropertiesInt.ContainsKey(PropertyInt.ResistLockpick))
                {
                    PropertiesInt.Remove(PropertyInt.ResistLockpick);
                }

                // If wo is locked, append skill check percent, as int, to properties for id panel display on chances of success
                if (wo.IsLocked)
                {
                    var resistLockpick = LockHelper.GetResistLockpick(wo);

                    if (resistLockpick != null)
                    {
                        PropertiesInt[PropertyInt.ResistLockpick] = (int)resistLockpick;

                        var pickSkill = examiner.Skills[Skill.Lockpick].Current;

                        var successChance = SkillCheck.GetSkillChance((int)pickSkill, (int)resistLockpick) * 100;

                        if (!PropertiesInt.ContainsKey(PropertyInt.AppraisalLockpickSuccessPercent))
                        {
                            PropertiesInt.Add(PropertyInt.AppraisalLockpickSuccessPercent, (int)successChance);
                        }
                    }
                }
                // if wo has DefaultLocked property and is unlocked, add that state to the property buckets
                else if (PropertiesBool.ContainsKey(PropertyBool.DefaultLocked))
                {
                    PropertiesBool[PropertyBool.Locked] = false;
                }
            }

            if (wo is Corpse)
            {
                PropertiesBool.Clear();
                PropertiesDID.Clear();
                PropertiesFloat.Clear();
                PropertiesInt64.Clear();

                var discardInts = PropertiesInt.Where(x => x.Key != PropertyInt.EncumbranceVal && x.Key != PropertyInt.Value).Select(x => x.Key).ToList();
                foreach (var key in discardInts)
                {
                    PropertiesInt.Remove(key);
                }
                var discardString = PropertiesString.Where(x => x.Key != PropertyString.LongDesc).Select(x => x.Key).ToList();
                foreach (var key in discardString)
                {
                    PropertiesString.Remove(key);
                }

                PropertiesInt[PropertyInt.Value] = 0;
            }

            if (wo is Portal)
            {
                if (PropertiesInt.ContainsKey(PropertyInt.EncumbranceVal))
                {
                    PropertiesInt.Remove(PropertyInt.EncumbranceVal);
                }
            }

            if (wo is SlumLord slumLord)
            {
                PropertiesBool.Clear();
                PropertiesDID.Clear();
                PropertiesFloat.Clear();
                PropertiesIID.Clear();
                //PropertiesInt.Clear();
                PropertiesInt64.Clear();
                PropertiesString.Clear();

                var longDesc = "";

                if (slumLord.HouseOwner.HasValue && slumLord.HouseOwner.Value > 0)
                {
                    longDesc = $"The current maintenance has {(slumLord.IsRentPaid() || !PropertyManager.GetBool("house_rent_enabled").Item ? "" : "not ")}been paid.\n";

                    PropertiesInt.Clear();
                }
                else
                {
                    //longDesc = $"This house is {(slumLord.HouseStatus == HouseStatus.Disabled ? "not " : "")}available for purchase.\n"; // this was the retail msg.
                    longDesc = $"This {(slumLord.House.HouseType == HouseType.Undef ? "house" : slumLord.House.HouseType.ToString().ToLower())} is {(slumLord.House.HouseStatus == HouseStatus.Disabled ? "not " : "")}available for purchase.\n";

                    var discardInts = PropertiesInt.Where(x => x.Key != PropertyInt.HouseStatus && x.Key != PropertyInt.HouseType && x.Key != PropertyInt.MinLevel && x.Key != PropertyInt.MaxLevel && x.Key != PropertyInt.AllegianceMinLevel && x.Key != PropertyInt.AllegianceMaxLevel).Select(x => x.Key).ToList();
                    foreach (var key in discardInts)
                    {
                        PropertiesInt.Remove(key);
                    }
                }

                if (slumLord.HouseRequiresMonarch)
                {
                    longDesc += "You must be a monarch to purchase and maintain this dwelling.\n";
                }

                if (slumLord.AllegianceMinLevel.HasValue)
                {
                    var allegianceMinLevel = PropertyManager.GetLong("mansion_min_rank", -1).Item;
                    if (allegianceMinLevel == -1)
                    {
                        allegianceMinLevel = slumLord.AllegianceMinLevel.Value;
                    }

                    longDesc += $"Restricted to characters of allegiance rank {allegianceMinLevel} or greater.\n";
                }

                PropertiesString.Add(PropertyString.LongDesc, longDesc);
            }

            if (wo is Storage)
            {
                var longDesc = "";

                if (wo.HouseOwner.HasValue && wo.HouseOwner.Value > 0)
                {
                    longDesc = $"Owned by {wo.ParentLink.HouseOwnerName}\n";
                }

                var discardString = PropertiesString.Where(x => x.Key != PropertyString.Use).Select(x => x.Key).ToList();
                foreach (var key in discardString)
                {
                    PropertiesString.Remove(key);
                }

                PropertiesString.Add(PropertyString.LongDesc, longDesc);

                if (PropertiesInt.ContainsKey(PropertyInt.Value))
                {
                    PropertiesInt[PropertyInt.Value] = wo.Biota.GetProperty(PropertyInt.Value, wo.BiotaDatabaseLock) ?? 200; // Value is masked to base value of Storage
                }
            }

            if (wo is Hook)
            {
                // If the hook has any inventory, we need to send THOSE properties instead.
                var hook = wo as Container;

                string baseDescString = "";
                if (wo.ParentLink.HouseOwner != null)
                {
                    // This is for backwards compatibility. This value was not set/saved in earlier versions.
                    // It will get the player's name and save that to the HouseOwnerName property of the house. This is now done when a player purchases a house.
                    if (wo.ParentLink.HouseOwnerName == null)
                    {
                        var houseOwnerPlayer = PlayerManager.FindByGuid((uint)wo.ParentLink.HouseOwner);
                        if (houseOwnerPlayer != null)
                        {
                            wo.ParentLink.HouseOwnerName = houseOwnerPlayer.Name;
                            wo.ParentLink.SaveBiotaToDatabase();
                        }
                    }
                    baseDescString = "This hook is owned by " + wo.ParentLink.HouseOwnerName + ". "; //if house is owned, display this text
                }

                var containsString = "";
                if (hook.Inventory.Count == 1)
                {
                    WorldObject hookedItem = hook.Inventory.First().Value;

                    // Hooked items have a custom "description", containing the desc of the sub item and who the owner of the house is (if any)
                    BuildProfile(hookedItem, examiner, success);

                    containsString = "It contains: \n";

                    if (!string.IsNullOrWhiteSpace(hookedItem.LongDesc))
                    {
                        containsString += hookedItem.LongDesc;
                    }
                    //else if (PropertiesString.ContainsKey(PropertyString.ShortDesc) && PropertiesString[PropertyString.ShortDesc] != null)
                    //{
                    //    containsString += PropertiesString[PropertyString.ShortDesc];
                    //}
                    else
                    {
                        containsString += hookedItem.Name;
                    }

                    BuildHookProfile(hookedItem);
                }

                //if (PropertiesString.ContainsKey(PropertyString.LongDesc) && PropertiesString[PropertyString.LongDesc] != null)
                //    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;
                ////else if (PropertiesString.ContainsKey(PropertyString.ShortDesc) && PropertiesString[PropertyString.ShortDesc] != null)
                ////    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;
                //else
                //    PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;

                PropertiesString[PropertyString.LongDesc] = baseDescString + containsString;

                PropertiesInt.Remove(PropertyInt.Structure);

                // retail should have removed this property and then server side built the same result for the hook longdesc replacement but didn't and ends up with some odd looking appraisals as seen on video/pcaps
                //PropertiesInt.Remove(PropertyInt.AppraisalLongDescDecoration);
            }

            if (wo is ManaStone)
            {
                var useMessage = "";

                if (wo.ItemCurMana.HasValue)
                {
                    useMessage = "Use on a magic item to give the stone's stored Mana to that item.";
                }
                else
                {
                    useMessage = "Use on a magic item to destroy that item and drain its Mana.";
                }

                PropertiesString[PropertyString.Use] = useMessage;
            }

            if (wo is CraftTool && (wo.ItemType == ItemType.TinkeringMaterial || wo.WeenieClassId >= 36619 && wo.WeenieClassId <= 36628 || wo.WeenieClassId >= 36634 && wo.WeenieClassId <= 36636))
            {
                if (PropertiesInt.ContainsKey(PropertyInt.Structure))
                {
                    PropertiesInt.Remove(PropertyInt.Structure);
                }
            }

            if (!Success)
            {
                // todo: what specifically to keep/what to clear

                //PropertiesBool.Clear();
                //PropertiesDID.Clear();
                //PropertiesFloat.Clear();
                //PropertiesIID.Clear();
                //PropertiesInt.Clear();
                //PropertiesInt64.Clear();
                //PropertiesString.Clear();
            }

            BuildFlags();
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }

            bool closeGump = true;

            switch (info.ButtonID)
            {
            //Guide
            case 1:
                closeGump = false;
                break;

            //Confirm
            case 2:
                switch (m_SkillMasteryPage)
                {
                case SkillMasteryPageType.Overview:
                    break;

                case SkillMasteryPageType.Orb:
                    if (m_SkillMasteryOrb == null)
                    {
                        m_Player.SendMessage("That item no longer exists.");
                        return;
                    }

                    if (m_SkillMasteryOrb.Deleted)
                    {
                        m_Player.SendMessage("That item no longer exists.");
                        return;
                    }

                    if (!m_SkillMasteryOrb.IsChildOf(m_Player.Backpack))
                    {
                        m_Player.SendMessage("This must be in your backpack in order to use it.");
                        return;
                    }

                    if (m_Player.SkillsCap < PlayerMobile.MaxSkillCap)
                    {
                        m_Player.SkillsCap += 10;

                        m_Player.FixedParticles(0x373A, 10, 15, 5036, EffectLayer.Head);
                        m_Player.PlaySound(0x3BD);

                        m_Player.SendMessage(63, "You increase your maximum total skill cap by 1.");

                        if (m_SkillMasteryOrb.Amount > 1)
                        {
                            m_SkillMasteryOrb.Amount--;

                            m_Player.CloseGump(typeof(SkillMasteryGump));
                            m_Player.SendGump(new SkillMasteryGump(m_Player, SkillMasteryPageType.Orb, m_SkillMasteryOrb));
                        }

                        else
                        {
                            m_SkillMasteryOrb.Delete();

                            m_Player.CloseGump(typeof(SkillMasteryGump));
                            m_Player.SendGump(new SkillMasteryGump(m_Player, SkillMasteryPageType.Overview, null));
                        }

                        return;
                    }

                    else
                    {
                        m_Player.SendMessage("You are already at your maximum total skill cap.");
                        return;
                    }
                    break;

                case SkillMasteryPageType.Scroll:
                    if (m_SkillMasteryScroll == null)
                    {
                        m_Player.SendMessage("That item no longer exists.");
                        return;
                    }

                    if (m_SkillMasteryScroll.Deleted)
                    {
                        m_Player.SendMessage("That item no longer exists.");
                        return;
                    }

                    if (!m_SkillMasteryScroll.IsChildOf(m_Player.Backpack))
                    {
                        m_Player.SendMessage("This must be in your backpack in order to use it.");
                        return;
                    }

                    SkillName skillName     = m_SkillMasteryScroll.Skill;
                    string    skillNameText = SkillCheck.GetSkillName(skillName);

                    if ((m_Player.Skills[skillName].CapFixedPoint / 10) < 120)
                    {
                        m_Player.Skills[skillName].CapFixedPoint += 10;

                        m_Player.FixedParticles(0x373A, 10, 15, 5036, EffectLayer.Head);
                        m_Player.PlaySound(0x3BD);

                        m_Player.SendMessage(63, "You increase your maximum skill cap in " + skillNameText + " by 1.");

                        m_SkillMasteryScroll.Delete();

                        m_Player.CloseGump(typeof(SkillMasteryGump));
                        m_Player.SendGump(new SkillMasteryGump(m_Player, SkillMasteryPageType.Overview, null));

                        return;
                    }

                    else
                    {
                        m_Player.SendMessage("You are already at the maximum skill cap for " + skillNameText + ".");
                        return;
                    }
                    break;
                }

                return;

                break;
            }

            if (closeGump)
            {
                m_Player.SendSound(0x058);
            }

            else
            {
                m_Player.CloseGump(typeof(SkillMasteryGump));
                m_Player.SendGump(new SkillMasteryGump(m_Player, m_SkillMasteryPage, m_Item));
            }
        }
Exemple #20
0
        public void FiftyFiftyIsAccurate()
        {
            var result = SkillCheck.GetSkillChance(100, 100);

            Assert.AreEqual(0.5d, result);
        }
        public static void Gain(Mobile from, LokaiSkill lokaiSkill)
        {
            if (from.Region.IsPartOf(typeof(Regions.Jail)))
            {
                return;
            }

            if (lokaiSkill.Base < lokaiSkill.Cap && lokaiSkill.Lock == LokaiSkillLock.Up)
            {
                int oldLokaiSkill = lokaiSkill.BaseFixedPoint;
                int toGain        = 1;

                if (lokaiSkill.Base <= 30.0)
                {
                    toGain = Utility.Random(3) + 1;
                }

                LokaiSkills lokaiSkills = LokaiSkillUtilities.XMLGetSkills(from);

                if (lokaiSkills.Total >= lokaiSkills.Cap)
                {
                    for (int i = 0; i < lokaiSkills.Length; ++i)
                    {
                        LokaiSkill toLower = lokaiSkills[i];

                        if (toLower != lokaiSkill && toLower.Lock == LokaiSkillLock.Down && toLower.BaseFixedPoint >= toGain)
                        {
                            toLower.BaseFixedPoint -= toGain;
                            break;
                        }
                    }
                }

                if ((lokaiSkills.Total + toGain) <= lokaiSkills.Cap)
                {
                    lokaiSkill.BaseFixedPoint += toGain;
                }
                if ((oldLokaiSkill <= 199 && lokaiSkill.BaseFixedPoint >= 200) ||
                    (oldLokaiSkill <= 299 && lokaiSkill.BaseFixedPoint >= 300) ||
                    (oldLokaiSkill <= 399 && lokaiSkill.BaseFixedPoint >= 400) ||
                    (oldLokaiSkill <= 499 && lokaiSkill.BaseFixedPoint >= 500) ||
                    (oldLokaiSkill <= 599 && lokaiSkill.BaseFixedPoint >= 600) ||
                    (oldLokaiSkill <= 699 && lokaiSkill.BaseFixedPoint >= 700) ||
                    (oldLokaiSkill <= 799 && lokaiSkill.BaseFixedPoint >= 800) ||
                    (oldLokaiSkill <= 899 && lokaiSkill.BaseFixedPoint >= 900))
                {
                    lokaiSkills.Teaching.BaseFixedPoint += (7 - toGain);
                }
            }

            if (lokaiSkill.Lock == LokaiSkillLock.Up)
            {
                LokaiSkillInfo info = lokaiSkill.Info;

                if (from.StrLock == StatLockType.Up && (info.StrScale / 33.3) > Utility.RandomDouble())
                {
                    SkillCheck.GainStat(from, SkillCheck.Stat.Str);
                }
                else if (from.DexLock == StatLockType.Up && (info.IntScale / 33.3) > Utility.RandomDouble())
                {
                    SkillCheck.GainStat(from, SkillCheck.Stat.Dex);
                }
                else if (from.IntLock == StatLockType.Up && (info.DexScale / 33.3) > Utility.RandomDouble())
                {
                    SkillCheck.GainStat(from, SkillCheck.Stat.Int);
                }
            }
        }
    public static void RunNode(ISkillNodeRun run, SkillNode node)
    {
        // UnityEngine.Debug.Log("runNode ["+node.trigger+"] "+node.type);
        switch (node.type)
        {
        case SkillNodeType.RotatePlayer:
            if (run.skill.player != null)
            {
                var rot = run.skill.player.Input.GetJoyStickDirection(run.skill.key);
                if (rot.magnitude < 0.1f)
                {
                    rot = run.skill.player.transform.forward;
                }
                run.skill.player.transform.Rotation = rot.ToRotation();
            }
            break;

        case SkillNodeType.MoveCtr:
            if (node.boolParams[0])
            {
                run.skill.player.CanMove = true;
                run.skill.player.animRootMotion(false);
            }
            else
            {
                run.skill.player.CanMove = false;
                run.skill.player.animRootMotion(true);
            }
            break;

        case SkillNodeType.WaitTime:

            run.skill.player.client.coroutine.WaitCall(node.fixedParams[0],
                                                       () =>
            {
                RunNodes(run, node.GetNodes(SkillTrigger.Time));
            });
            break;

        case SkillNodeType.LoopTime:
            //RunNodes(node.GetNodes(SkillTrigger.Time));
            //var c = run.player.client.coroutine.WaitCall(node.fixedParams[1],
            //    () =>
            //    {
            //        RunNodes(node.GetNodes(SkillTrigger.Time));
            //    }
            //    , true);
            //times.Add(node.fixedParams[0], c);
            break;

        case SkillNodeType.Damage:
            foreach (var other in run.skill.others)
            {
                if (other is HealthData)
                {
                    if (other != run.skill.player)
                    {
                        var enemy = other as HealthData;
                        //Debug.LogError("damage " + run.skill.weapon.weaponData.fixedParams["mainDamage"]);
                        if (run.skill.player.client.GetManager <TeamManager>().IsEnemy(enemy, run.skill.player))
                        {
                            enemy.GetHurt(node.fixedParams[0] + run.skill.weapon.weaponData.fixedParams["mainDamage"]);
                        }
                    }
                }
            }
            break;

        case SkillNodeType.StopLoop:
            //coroutine.StopCoroutine(times[node.fixedParams[0]]);
            //times.Remove(node.fixedParams[0]);
            break;

        case SkillNodeType.GunFire:
            run.skill.player.weaponSystem.curWeapon <Gun>().Fire(node, run);
            break;

        case SkillNodeType.CreatCheck:
            var check = new SkillCheck();
            check.skill = run.skill;
            check.Check(run.skill.player, node.fixedParams[0], node.fixedParams[1], node.fixedParams[2], node);
            break;

        case SkillNodeType.CreateBullet:
            ShootBullet(run.skill.player, run.skill.player.transform.Position, run.skill.player.transform.Rotation);
            break;

        default:
            break;
        }
    }
        public SkillMasteryScrollLibraryGump(PlayerMobile player, SkillMasteryScrollLibrary library, int pageNumber) : base(10, 10)
        {
            if (player == null)
            {
                return;
            }
            if (library == null)
            {
                return;
            }
            if (library.Deleted)
            {
                return;
            }

            m_Player     = player;
            m_Library    = library;
            m_PageNumber = pageNumber;

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddImage(205, 193, 11015, 2963);
            AddImage(204, 1, 11015, 2963);
            AddImage(3, 192, 11015, 2963);
            AddImage(3, 1, 11015, 2963);

            AddImage(302, 75, 2081, 2499);
            AddImage(300, 270, 2081, 2499);
            AddImage(301, 141, 2081, 2499);
            AddImage(301, 5, 2081, 2499);
            AddImage(301, 206, 2081, 2499);
            AddImage(299, 338, 2081, 2499);
            AddImage(44, 6, 2081, 2499);
            AddImage(44, 75, 2081, 2499);
            AddImage(43, 141, 2081, 2499);
            AddImage(43, 206, 2081, 2499);
            AddImage(41, 335, 2081);
            AddImage(43, 274, 2081, 2499);
            AddImage(41, 338, 2081, 2499);
            AddImage(49, 80, 3001, 2615);
            AddImage(56, 80, 3001, 2615);
            AddImage(306, 80, 3001, 2615);
            AddImage(315, 80, 3001, 2615);
            AddImageTiled(301, 2, 6, 405, 2701);

            AddItem(153, 24, 5360, 2963);

            AddLabel(95, 5, 2599, "Skill Mastery Scroll Library");

            AddLabel(88, 53, WhiteTextHue, "Add All in Backpack into Library");
            AddButton(65, 56, 2118, 2118, 1, GumpButtonType.Reply, 0);

            AddLabel(354, 5, 2615, "Locked Down Access Level");

            string accessName = "Owner";

            switch (m_Library.LockedDownAccessLevel)
            {
            case SkillMasteryScrollLibrary.LockedDownAccessLevelType.Owner: accessName = "Owner"; break;

            case SkillMasteryScrollLibrary.LockedDownAccessLevelType.CoOwner: accessName = "Co-Owner"; break;

            case SkillMasteryScrollLibrary.LockedDownAccessLevelType.Friend: accessName = "Friend"; break;

            case SkillMasteryScrollLibrary.LockedDownAccessLevelType.Anyone: accessName = "Anyone"; break;
            }

            AddLabel(Utility.CenteredTextOffset(435, accessName), 25, 2562, accessName);

            AddButton(366, 28, 2223, 2223, 2, GumpButtonType.Reply, 0);
            AddButton(488, 29, 2224, 2224, 3, GumpButtonType.Reply, 0);

            AddLabel(347, 53, WhiteTextHue, "Remove All Possible on Selection");
            if (m_Library.RemoveAllOnSelection)
            {
                AddButton(313, 48, 2154, 2151, 4, GumpButtonType.Reply, 0);
            }
            else
            {
                AddButton(313, 48, 2151, 2154, 4, GumpButtonType.Reply, 0);
            }

            //-----

            List <SkillName> m_SkillList = new List <SkillName>();

            foreach (SkillName skillName in SkillMasteryScroll.Skills)
            {
                m_SkillList.Add(skillName);
            }

            m_TotalEntries = m_SkillList.Count;
            m_TotalPages   = (int)(Math.Ceiling((double)m_TotalEntries / (double)EntriesPerPage));

            if (m_TotalPages == 0)
            {
                m_TotalPages = 1;
            }

            if (m_PageNumber < 1)
            {
                m_PageNumber = 1;
            }

            if (m_PageNumber > m_TotalPages)
            {
                m_PageNumber = m_TotalPages;
            }

            int startIndex = (m_PageNumber - 1) * EntriesPerPage;
            int endIndex   = startIndex + EntriesPerPage;

            if (endIndex > m_TotalEntries)
            {
                endIndex = m_TotalEntries;
            }

            int leftStartY  = 88;
            int rightStartY = 88;

            int entryCount = 0;

            for (int a = startIndex; a < endIndex; a++)
            {
                if (a < m_SkillList.Count)
                {
                    SkillName skillName = m_SkillList[a];
                    SkillMasteryScrollLibraryEntry entry = m_Library.GetLibraryEntry(skillName);

                    int numberTextHue = WhiteTextHue;

                    if (entry.Count > 0)
                    {
                        numberTextHue = 2963;
                    }

                    //Left Side
                    if (entryCount < EntriesPerSide)
                    {
                        AddLabel(60, leftStartY, 2599, SkillCheck.GetSkillName(entry.skillName));
                        AddButton(231, leftStartY + 3, 2118, 2118, 10 + entryCount, GumpButtonType.Reply, 0);
                        AddLabel(249, leftStartY, numberTextHue, entry.Count.ToString());

                        leftStartY += 38;
                    }

                    //Right Side
                    else
                    {
                        AddLabel(317, rightStartY, 2599, SkillCheck.GetSkillName(entry.skillName));
                        AddButton(488, rightStartY + 3, 2118, 2118, 10 + entryCount, GumpButtonType.Reply, 0);
                        AddLabel(506, rightStartY, numberTextHue, entry.Count.ToString());

                        rightStartY += 38;
                    }

                    entryCount++;
                }
            }

            if (m_PageNumber > 1)
            {
                AddButton(160, 380, 4014, 4016, 5, GumpButtonType.Reply, 0);
            }

            if (m_PageNumber < m_TotalPages)
            {
                AddButton(415, 380, 4005, 4007, 6, GumpButtonType.Reply, 0);
            }
        }
        public SkillMasteryGump(Mobile player, SkillMasteryPageType skillMasteryPageType, Item item) : base(10, 10)
        {
            m_Player           = player as PlayerMobile;
            m_SkillMasteryPage = skillMasteryPageType;
            m_Item             = item;

            if (m_Player == null)
            {
                return;
            }

            switch (skillMasteryPageType)
            {
            case SkillMasteryPageType.Overview:
                break;

            case SkillMasteryPageType.Orb:
                if (!(item is SkillMasteryOrb))
                {
                    return;
                }
                if (item == null)
                {
                    return;
                }
                if (item.Deleted)
                {
                    return;
                }

                m_SkillMasteryOrb = item as SkillMasteryOrb;
                break;

            case SkillMasteryPageType.Scroll:
                if (!(item is SkillMasteryScroll))
                {
                    return;
                }
                if (item == null)
                {
                    return;
                }
                if (item.Deleted)
                {
                    return;
                }

                m_SkillMasteryScroll = item as SkillMasteryScroll;
                break;
            }

            #region Images

            AddImage(5, 5, 103, 2499);
            AddImage(140, 5, 103, 2499);
            AddImage(266, 5, 103, 2499);
            AddImage(140, 92, 103, 2499);
            AddImage(5, 92, 103, 2499);
            AddImage(266, 92, 103, 2499);
            AddImage(140, 180, 103, 2499);
            AddImage(5, 180, 103, 2499);
            AddImage(266, 180, 103, 2499);
            AddImage(140, 264, 103, 2499);
            AddImage(5, 264, 103, 2499);
            AddImage(266, 264, 103, 2499);
            AddImage(400, 5, 103, 2499);
            AddImage(400, 92, 103, 2499);
            AddImage(400, 180, 103, 2499);
            AddImage(400, 265, 103, 2499);
            AddImage(400, 362, 103, 2499);
            AddImage(266, 361, 103, 2499);
            AddImage(140, 361, 103, 2499);
            AddImage(5, 361, 103, 2499);
            AddImage(100, 361, 5104, 2052);
            AddImage(19, 361, 5104, 2052);
            AddImage(164, 361, 5104, 2052);
            AddImage(253, 361, 5104, 2052);
            AddImage(312, 361, 5104, 2052);
            AddImage(398, 361, 5104, 2052);
            AddImage(442, 361, 5104, 2052);
            AddImage(273, 83, 2081, 2499);
            AddImage(271, 282, 2081, 2499);
            AddImage(272, 149, 2081, 2499);
            AddImage(272, 13, 2081, 2499);
            AddImage(272, 214, 2081, 2499);
            AddImage(15, 14, 2081, 2499);
            AddImage(15, 83, 2081, 2499);
            AddImage(14, 149, 2081, 2499);
            AddImage(14, 214, 2081, 2499);
            AddImage(14, 282, 2081, 2499);
            AddImageTiled(272, 10, 6, 341, 2701);

            AddItem(48, 390, 2942);
            AddItem(23, 376, 2943);
            AddItem(43, 381, 2507);
            AddItem(42, 397, 4030);
            AddItem(55, 376, 7716);
            AddItem(23, 368, 7717, 2652);
            AddItem(45, 387, 4031);

            AddImage(184, 12, 2446, 2401);
            AddLabel(232, 12, 2599, "Skill Mastery");

            AddLabel(65, 41, 149, "Skill");
            AddLabel(151, 41, 149, "Value");
            AddLabel(199, 41, 149, "Cap");

            AddLabel(324, 40, 149, "Skill");
            AddLabel(410, 40, 149, "Value");
            AddLabel(458, 40, 149, "Cap");

            AddLabel(95, 379, 149, "Total Skills");
            AddLabel(95, 405, 149, "Total Skill Cap");

            #endregion

            List <SkillName> m_SkillList = new List <SkillName>();

            foreach (SkillName skillName in SkillMasteryScroll.Skills)
            {
                m_SkillList.Add(skillName);
            }

            int leftStartY  = 60;
            int rightStartY = 60;

            int spacingY = 20;

            bool canUseOrb    = false;
            bool canUseScroll = false;

            if (m_Player.SkillsCap < PlayerMobile.MaxSkillCap)
            {
                canUseOrb = true;
            }

            for (int a = 0; a < m_SkillList.Count; a++)
            {
                int textHue = WhiteTextHue;

                SkillName skillName      = m_SkillList[a];
                string    skillValueText = m_Player.Skills[skillName].Base.ToString();
                string    skillCapText   = (m_Player.Skills[skillName].CapFixedPoint / 10).ToString();
                int       skillCap       = m_Player.Skills[skillName].CapFixedPoint / 10;

                if ((m_Player.Skills[skillName].CapFixedPoint / 10) > 100)
                {
                    textHue = 2599;
                }

                bool canIncrease = false;

                if (skillMasteryPageType == SkillMasteryPageType.Scroll)
                {
                    if (skillName == m_SkillMasteryScroll.Skill)
                    {
                        if (m_Player.Skills[skillName].Cap < 120)
                        {
                            canUseScroll = true;
                            canIncrease  = true;
                            textHue      = 63;

                            skillCapText = ((m_Player.Skills[skillName].CapFixedPoint / 10) + 1).ToString();
                        }
                    }
                }

                //Left Side
                if (a < EntriesPerSide)
                {
                    AddLabel(25, leftStartY, textHue, SkillCheck.GetSkillName(skillName));
                    AddLabel(Utility.CenteredTextOffset(165, skillValueText), leftStartY, textHue, skillValueText);
                    AddLabel(Utility.CenteredTextOffset(210, skillCapText), leftStartY, textHue, skillCapText);

                    if (canUseScroll && canIncrease)
                    {
                        AddImage(232, leftStartY + 1, 5600, 63);
                        AddLabel(252, leftStartY, 63, "+1");
                    }

                    leftStartY += spacingY;
                }

                //Right Side
                else
                {
                    AddLabel(285, rightStartY, textHue, SkillCheck.GetSkillName(skillName));
                    AddLabel(Utility.CenteredTextOffset(426, skillValueText), rightStartY, textHue, skillValueText);
                    AddLabel(Utility.CenteredTextOffset(470, skillCapText), rightStartY, textHue, skillCapText);

                    if (canUseScroll && canIncrease)
                    {
                        AddImage(488, rightStartY + 1, 5600, 63);
                        AddLabel(508, rightStartY, 63, "+1");
                    }

                    rightStartY += spacingY;
                }
            }

            //Guide
            AddButton(19, 15, 2094, 2095, 1, GumpButtonType.Reply, 0);
            AddLabel(15, 1, 149, "Guide");

            string actionText = "";
            string resultText = "";

            int totalSkills   = (m_Player.SkillsTotal / 10);
            int totalSkillCap = (m_Player.SkillsCap / 10);

            int totalSkillsHue   = WhiteTextHue;
            int totalSkillCapHue = WhiteTextHue;

            if (totalSkills > 700)
            {
                totalSkillsHue = 2599;
            }

            if (totalSkillCap > 700)
            {
                totalSkillCapHue = 2599;
            }

            switch (m_SkillMasteryPage)
            {
            case SkillMasteryPageType.Overview:
                AddLabel(199, 379, totalSkillsHue, totalSkills.ToString());
                AddLabel(199, 405, totalSkillCapHue, totalSkillCap.ToString());
                break;

            case SkillMasteryPageType.Orb:
                if (canUseOrb)
                {
                    int newSkillCap = totalSkillCap + 1;

                    AddLabel(199, 379, totalSkillsHue, totalSkills.ToString());
                    AddLabel(199, 405, 63, newSkillCap.ToString());
                    AddImage(232, 406, 5600, 63);
                    AddLabel(252, 405, 63, "+1");

                    actionText = "Use Mastery Orb?";
                    resultText = "(Increase Total Skill Cap to " + newSkillCap + ")";

                    AddLabel(Utility.CenteredTextOffset(400, actionText), 364, 63, actionText);
                    AddLabel(Utility.CenteredTextOffset(410, resultText), 382, 2599, resultText);
                    AddItem(375, 415, 22336, 2966);     //Orb
                    AddButton(423, 411, 247, 248, 2, GumpButtonType.Reply, 0);
                }

                else
                {
                    AddLabel(199, 379, totalSkillsHue, totalSkills.ToString());
                    AddLabel(199, 405, totalSkillCapHue, totalSkillCap.ToString());

                    actionText = "Mastery Orb Unusable";
                    resultText = "(Already at Maximum Total Skill Cap)";

                    AddLabel(Utility.CenteredTextOffset(400, actionText), 364, 149, actionText);
                    AddLabel(Utility.CenteredTextOffset(410, resultText), 382, 149, resultText);
                }

                break;

            case SkillMasteryPageType.Scroll:
                if (canUseScroll)
                {
                    AddLabel(199, 379, totalSkillsHue, totalSkills.ToString());
                    AddLabel(199, 405, totalSkillCapHue, totalSkillCap.ToString());

                    string skillName   = SkillCheck.GetSkillName(m_SkillMasteryScroll.Skill);
                    int    newSkillCap = (m_Player.Skills[m_SkillMasteryScroll.Skill].CapFixedPoint / 10) + 1;

                    actionText = "Use Mastery Scroll?";
                    resultText = "(Increase " + skillName + " Skill Cap to " + newSkillCap + ")";

                    AddLabel(Utility.CenteredTextOffset(400, actionText), 364, 63, actionText);
                    AddLabel(Utility.CenteredTextOffset(410, resultText), 382, 2599, resultText);
                    AddItem(372, 406, 5360, 2963);     //Scroll
                    AddButton(423, 411, 247, 248, 2, GumpButtonType.Reply, 0);
                }

                else
                {
                    AddLabel(199, 379, totalSkillsHue, totalSkills.ToString());
                    AddLabel(199, 405, totalSkillCapHue, totalSkillCap.ToString());

                    actionText = "Mastery Scroll Unusable";
                    resultText = "(Already At Skill's Maximum Cap)";

                    AddLabel(Utility.CenteredTextOffset(400, actionText), 364, 149, actionText);
                    AddLabel(Utility.CenteredTextOffset(410, resultText), 382, 149, resultText);
                }
                break;
            }
        }
Exemple #25
0
        public static void HandleTinkering(Player player, WorldObject tool, WorldObject target, bool confirmed = false)
        {
            Console.WriteLine($"{player.Name}.HandleTinkering({tool.Name}, {target.Name})");

            // calculate % success chance

            var toolWorkmanship = tool.Workmanship ?? 0;
            var itemWorkmanship = target.Workmanship ?? 0;

            var tinkeredCount = target.NumTimesTinkered;
            var attemptMod    = TinkeringDifficulty[tinkeredCount];

            var materialType = tool.MaterialType.Value;
            var salvageMod   = GetMaterialMod(materialType);

            var workmanshipMod = 1.0f;

            if (toolWorkmanship >= itemWorkmanship)
            {
                workmanshipMod = 2.0f;
            }

            var recipe      = DatabaseManager.World.GetCachedCookbook(tool.WeenieClassId, target.WeenieClassId);
            var recipeSkill = (Skill)recipe.Recipe.Skill;
            var skill       = player.GetCreatureSkill(recipeSkill);

            // thanks to Endy's Tinkering Calculator for this formula!
            var difficulty = (int)Math.Floor(((salvageMod * 5.0f) + (itemWorkmanship * salvageMod * 2.0f) - (toolWorkmanship * workmanshipMod * salvageMod / 5.0f)) * attemptMod);

            var successChance = SkillCheck.GetSkillChance((int)skill.Current, difficulty);

            // imbue: divide success by 3

            // handle rare foolproof material
            //if (tool.WeenieClassId >= 30094 && tool.WeenieClassId <= 30106)
            //successChance = 1.0f;

            // check for player option: 'Use Crafting Chance of Success Dialog'
            if (player.GetCharacterOption(CharacterOption.UseCraftingChanceOfSuccessDialog) && !confirmed)
            {
                var percent       = (float)successChance * 100;
                var decimalPlaces = 2;
                var truncated     = percent.Truncate(decimalPlaces);

                var templateMsg = $"You have a % chance of using {tool.Name} on {target.Name}.";
                var floorMsg    = templateMsg.Replace("%", (int)percent + "%");
                var truncateMsg = templateMsg.Replace("%", Math.Round(truncated, decimalPlaces) + "%");
                var exactMsg    = templateMsg.Replace("%", percent + "%");

                var confirm = new Confirmation(ConfirmationType.CraftInteraction, floorMsg, tool, target, player);
                ConfirmationManager.AddConfirmation(confirm);

                player.Session.Network.EnqueueSend(new GameEventConfirmationRequest(player.Session, ConfirmationType.CraftInteraction, confirm.ConfirmationID, floorMsg));
                player.Session.Network.EnqueueSend(new GameMessageSystemChat(exactMsg, ChatMessageType.Craft));

                player.SendUseDoneEvent();
                return;
            }

            var animLength = DoCraftMotion(player);

            var actionChain = new ActionChain();

            actionChain.AddDelaySeconds(animLength);
            actionChain.AddAction(player, () => DoTinkering(player, tool, target, (float)successChance));
            actionChain.EnqueueChain();
        }
Exemple #26
0
        public void BuildProfile(WorldObject wo, Player examiner, bool success = true)
        {
            //Console.WriteLine("Appraise: " + wo.Guid);
            Success = success;

            // get wielder, if applicable
            var wielder = GetWielder(wo, examiner);

            BuildProperties(wo, wielder);
            BuildSpells(wo);

            // Help us make sure the item identify properly
            NPCLooksLikeObject = wo.GetProperty(PropertyBool.NpcLooksLikeObject) ?? false;

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedWielder))
            {
                if (!PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedWielder))
                {
                    PropertiesBool.Add(PropertyBool.AppraisalHasAllowedWielder, true);
                }
            }

            if (PropertiesIID.ContainsKey(PropertyInstanceId.AllowedActivator))
            {
                if (!PropertiesBool.ContainsKey(PropertyBool.AppraisalHasAllowedActivator))
                {
                    PropertiesBool.Add(PropertyBool.AppraisalHasAllowedActivator, true);
                }
            }

            // armor / clothing / shield
            if (wo is Clothing || wo.IsShield)
            {
                BuildArmor(wo);
            }

            if (wo is Creature creature)
            {
                BuildCreature(creature);
            }

            if (wo is MeleeWeapon || wo is Missile || wo is MissileLauncher || wo is Ammunition || wo is Caster)
            {
                BuildWeapon(wo, wielder);
            }

            if (wo is Door || wo is Chest)
            {
                // If wo is not locked, do not send ResistLockpick value. If ResistLockpick is sent for unlocked objects, id panel shows bonus to Lockpick skill
                if (!wo.IsLocked && PropertiesInt.ContainsKey(PropertyInt.ResistLockpick))
                {
                    PropertiesInt.Remove(PropertyInt.ResistLockpick);
                }

                // If wo is locked, append skill check percent, as int, to properties for id panel display on chances of success
                if (wo.IsLocked)
                {
                    var resistLockpick = LockHelper.GetResistLockpick(wo);

                    if (resistLockpick != null)
                    {
                        PropertiesInt[PropertyInt.ResistLockpick] = (int)resistLockpick;

                        var pickSkill = examiner.Skills[Skill.Lockpick].Current;

                        var successChance = SkillCheck.GetSkillChance((int)pickSkill, (int)resistLockpick) * 100;

                        if (!PropertiesInt.ContainsKey(PropertyInt.AppraisalLockpickSuccessPercent))
                        {
                            PropertiesInt.Add(PropertyInt.AppraisalLockpickSuccessPercent, (int)successChance);
                        }
                    }
                }
            }

            if (wo is Corpse)
            {
                PropertiesBool.Clear();
                PropertiesDID.Clear();
                PropertiesFloat.Clear();
                PropertiesInt64.Clear();

                var discardInts = PropertiesInt.Where(x => x.Key != PropertyInt.EncumbranceVal && x.Key != PropertyInt.Value).Select(x => x.Key).ToList();
                foreach (var key in discardInts)
                {
                    PropertiesInt.Remove(key);
                }
                var discardString = PropertiesString.Where(x => x.Key != PropertyString.LongDesc).Select(x => x.Key).ToList();
                foreach (var key in discardString)
                {
                    PropertiesString.Remove(key);
                }
            }

            if (wo is Portal)
            {
                if (PropertiesInt.ContainsKey(PropertyInt.EncumbranceVal))
                {
                    PropertiesInt.Remove(PropertyInt.EncumbranceVal);
                }
            }

            if (wo is Hook)
            {
                // If the hook has any inventory, we need to send THOSE properties instead.
                var hook = wo as Container;
                if (hook.Inventory.Count == 1)
                {
                    WorldObject hookedItem = hook.Inventory.First().Value;

                    // Hooked items have a custom "description", containing the desc of the sub item and who the owner of the house is (if any)
                    BuildProfile(hookedItem, examiner, success);
                    string baseDescString = "";
                    if (wo.ParentLink.HouseOwner != null)
                    {
                        // This is for backwards compatibility. This value was not set/saved in earlier versions.
                        // It will get the player's name and save that to the HouseOwnerName property of the house. This is now done when a player purchases a house.
                        if (wo.ParentLink.HouseOwnerName == null)
                        {
                            var houseOwnerPlayer = PlayerManager.FindByGuid((uint)wo.ParentLink.HouseOwner);
                            if (houseOwnerPlayer != null)
                            {
                                wo.ParentLink.HouseOwnerName = houseOwnerPlayer.Name;
                                wo.ParentLink.SaveBiotaToDatabase();
                            }
                        }
                        baseDescString = "This hook is owned by " + wo.ParentLink.HouseOwnerName + ". "; //if house is owned, display this text
                    }
                    if (PropertiesString.ContainsKey(PropertyString.LongDesc) && PropertiesString[PropertyString.LongDesc] != null)
                    {
                        PropertiesString[PropertyString.LongDesc] = baseDescString + "It contains: \n" + PropertiesString[PropertyString.LongDesc];
                    }
                    else if (PropertiesString.ContainsKey(PropertyString.ShortDesc) && PropertiesString[PropertyString.ShortDesc] != null)
                    {
                        PropertiesString[PropertyString.LongDesc] = baseDescString + "It contains: \n" + PropertiesString[PropertyString.ShortDesc];
                    }

                    BuildHookProfile(hookedItem);
                }
            }

            BuildFlags();
        }
 /**
  * Startup this object
  */
 void Start()
 {
     skillCheck = Object.FindObjectOfType<SkillCheck>();
 }