示例#1
0
        public bool OnCast(Character caster, string args)
        {
            if (Map.IsNextToWall(caster))
            {
                if (!Rules.BreakHideSpell(caster))
                {
                    bool giveXP = false;
                    if (!caster.IsHidden && caster.BaseProfession == Character.ClassType.Thief)
                    {
                        giveXP = true;
                    }

                    Effect.CreateCharacterEffect(Effect.EffectTypes.Hide_in_Shadows, 1, caster, 0, caster);
                    caster.WriteToDisplay("You fade into the shadows.");

                    if (giveXP)
                    {
                        Skills.GiveSkillExp(caster, Skills.GetSkillLevel(caster.thievery) * 25, Globals.eSkillType.Thievery);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                caster.WriteToDisplay("You must be in the shadows to hide.");
            }

            return(true);
        }
示例#2
0
        public bool OnPerform(Character chr, string args)
        {
            // if character does not have a hand free they cannot steal
            if (chr.GetFirstFreeHand() == (int)Globals.eWearOrientation.None)
            {
                chr.WriteToDisplay("You don't have a hand free to steal with.");
                return(false);
            }

            // get the array of arguments -- should be target at [1] or item at [1] and target at [2]
            List <string> sArgs = new List <string>(args.Split(" ".ToCharArray()));

            sArgs.RemoveAll(s => s.Equals("from"));

            // target should be the last argument
            Character target = null;

            string itemTarget = "";

            if (sArgs.Count == 1)
            {
                target = TargetAcquisition.FindTargetInCell(chr, sArgs[0]);
            }
            else if (sArgs.Count >= 2)
            {
                if (Int32.TryParse(sArgs[0], out int countTo)) // steal from # <target>
                {
                    target = TargetAcquisition.FindTargetInCell(chr, sArgs[sArgs.Count - 1], countTo);
                }
                else if (sArgs.Count >= 3 && Int32.TryParse(sArgs[1], out countTo)) // steal <item> from # <target>
                {
                    itemTarget = sArgs[0];
                    target     = TargetAcquisition.FindTargetInCell(chr, sArgs[sArgs.Count - 1], countTo);
                }
            }

            // target not found
            if (target == null)
            {
                chr.WriteToDisplay("You don't see " + sArgs[sArgs.Count - 1] + " here.");
                return(false);
            }

            if (target == chr)
            {
                chr.WriteToDisplay("You cannot steal from yourself.");
                return(false);
            }

            if (target != null && target.IsImage)
            {
                chr.WriteToDisplay("You cannot steal from a conjured image.");
                return(false);
            }

            // give experience for a steal attempt
            if (target.IsPC && chr.IsPC)
            {
                Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) - Rules.GetExpLevel(target.Experience), Globals.eSkillType.Thievery);
            }
            else
            {
                Skills.GiveSkillExp(chr, target, Globals.eSkillType.Thievery);
            }

            // 50 percent base chance to steal
            int successChance = 50;

            // if going after a specific item success is reduced by max skill level minus thievery level
            if (sArgs.Count >= 2 && itemTarget != "")
            {
                successChance -= 19 - Skills.GetSkillLevel(chr.thievery);
            }

            Item item = null;

            // this is the 100 sided die roll plus the character's thievery skill level
            int roll = Rules.RollD(1, 100);

            // you successfully steal when the roll plus thievery skill level x 2 is greater than the chance
            if (roll + (Skills.GetSkillLevel(chr.thievery) * 2) > successChance)
            {
                if (target.sackList.Count <= 0)
                {
                    chr.WriteToDisplay("Your target has nothing to steal.");
                    return(true);
                }

                double sackGold = 0;

                foreach (Item sackItem in target.sackList)
                {
                    if (sackItem.itemType == Globals.eItemType.Coin)
                    {
                        sackGold = sackItem.coinValue;
                    }
                }

                // if there is no specific item being sought after
                if (itemTarget == "")
                {
                    // steal gold if gold is in sack and another d100 roll is equal to or greater than base chance
                    if (sackGold > 0 && Rules.RollD(1, 100) >= successChance)
                    {
                        item = Item.CopyItemFromDictionary(Item.ID_COINS);
                        double amount = Rules.RollD(1, (int)sackGold);
                        item.coinValue = amount;
                        sackGold      -= amount;
                        foreach (Item sackItem in target.sackList)
                        {
                            if (sackItem.itemType == Globals.eItemType.Coin)
                            {
                                sackItem.coinValue = sackGold;
                            }
                        }
                    }
                    else
                    {
                        int randomItem = Rules.Dice.Next(target.sackList.Count - 1);
                        item = (Item)target.sackList[randomItem];

                        // Attempting to steal an artifact.
                        if (item.IsArtifact() && chr.PossessesItem(item.itemID))
                        {
                            chr.WriteToDisplay("You have been caught!");
                            target.WriteToDisplay(chr.GetNameForActionResult() + " has attempted to steal " + item.shortDesc + " from you.");
                            Combat.DoFlag(chr, target);
                            Rules.BreakHideSpell(chr);
                            return(true);
                        }

                        target.sackList.RemoveAt(randomItem);
                    }
                }
                else
                {
                    if (!itemTarget.StartsWith("coin"))
                    {
                        item = target.RemoveFromSack(itemTarget);

                        // Attempting to steal an artifact.
                        if (item.IsArtifact() && (chr as PC).PossessesItem(item.itemID))
                        {
                            target.SackItem(item);

                            chr.WriteToDisplay("You have been caught!");
                            target.WriteToDisplay(chr.GetNameForActionResult() + " has attempted to steal " + item.shortDesc + " from you.");
                            Combat.DoFlag(chr, target);
                            Rules.BreakHideSpell(chr);
                            return(true);
                        }
                    }
                    else
                    {
                        if (sackGold > 0)
                        {
                            item = Item.CopyItemFromDictionary(Item.ID_COINS);
                            double amount = Rules.RollD(1, (int)sackGold);
                            item.coinValue = amount;
                            sackGold      -= amount;
                            foreach (Item sackItem in target.sackList)
                            {
                                if (sackItem.itemType == Globals.eItemType.Coin)
                                {
                                    sackItem.coinValue = sackGold;
                                }
                            }
                        }
                        else
                        {
                            chr.WriteToDisplay("You could not find a " + itemTarget + ".");
                            return(true);
                        }
                    }

                    if (item == null)
                    {
                        chr.WriteToDisplay("You could not find a " + itemTarget + ".");
                        return(true);
                    }
                    // further chance to be caught if going after a specific item
                    else if (roll - (Skills.GetSkillLevel(chr.thievery) * 2) > (successChance / 2))
                    {
                        chr.WriteToDisplay("You have been caught!");
                        target.WriteToDisplay(chr.GetNameForActionResult() + " has stolen " + item.shortDesc + " from you.");
                        Combat.DoFlag(chr, target);
                        Rules.BreakHideSpell(chr);
                    }
                }

                chr.EquipEitherHandOrDrop(item);

                Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) * 50, Globals.eSkillType.Thievery);
                //if (target.IsPC && chr.IsPC)
                //    Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) - Rules.GetExpLevel(target.Experience), Globals.eSkillType.Thievery);
                //else
                //    Skills.GiveSkillExp(chr, target, Globals.eSkillType.Thievery);

                chr.WriteToDisplay("You have stolen " + item.shortDesc + " from " + target.GetNameForActionResult(true) + ".");
            }
            else
            {
                chr.WriteToDisplay("You have been caught!");
                target.WriteToDisplay(chr.Name + " has attempted to steal from you!");
                Combat.DoFlag(chr, target);
                Rules.BreakHideSpell(chr);
            }
            return(true);
        }
示例#3
0
        public bool OnPerform(Character chr, string args)
        {
            if (!chr.IsHidden && !chr.IsImmortal)
            {
                chr.WriteToDisplay("You must be hidden to be successful.");
                return(false);
            }

            if (args == null)
            {
                chr.WriteToDisplay("Snoop at who?");
                return(false);
            }

            string[] sArgs = args.Split(" ".ToCharArray());

            Character target;

            int countTo;

            if (sArgs.Length >= 2 && Int32.TryParse(sArgs[0], out countTo))
            {
                target = TargetAcquisition.FindTargetInCell(chr, sArgs[1], countTo);
            }
            else
            {
                target = TargetAcquisition.FindTargetInCell(chr, sArgs[0]);
            }

            // failed to find the target
            if (target == null)
            {
                chr.WriteToDisplay("You don't see a " + (sArgs.Length >= 2 ? sArgs[0] + " " + sArgs[1] : sArgs[0]) + " here.");
                return(false);
            }

            int successChance = 19 - Skills.GetSkillLevel(chr.thievery);

            if (chr.IsImmortal || Rules.RollD(1, 20) > successChance)
            {
                if (target.sackList.Count > 0)
                {
                    int       z = 0, i = 0;
                    string    dispMsg     = "";
                    double    itemcount   = 0;
                    bool      moreThanOne = false;
                    ArrayList templist    = new ArrayList();
                    Item[]    itemList    = new Item[target.sackList.Count];
                    target.sackList.CopyTo(itemList);
                    foreach (Item item in itemList)
                    {
                        templist.Add(item);
                    }
                    z       = templist.Count - 1;
                    dispMsg = "In " + target.GetNameForActionResult(true) + "'s sack you see ";
                    while (z >= 0)
                    {
                        Item item = (Item)templist[z];

                        itemcount = 0;
                        for (i = templist.Count - 1; i > -1; i--)
                        {
                            Item tmpitem = (Item)templist[i];
                            if (tmpitem.name == item.name && tmpitem.name.IndexOf("coin") > -1)
                            {
                                templist.RemoveAt(i);
                                itemcount = itemcount + (int)item.coinValue;
                                z         = templist.Count;
                            }
                            else if (tmpitem.name == item.name)
                            {
                                templist.RemoveAt(i);
                                z          = templist.Count;
                                itemcount += 1;
                            }
                        }
                        if (itemcount > 0)
                        {
                            if (moreThanOne)
                            {
                                if (z == 0)
                                {
                                    dispMsg += " and ";
                                }
                                else
                                {
                                    dispMsg += ", ";
                                }
                            }
                            dispMsg += GameSystems.Text.TextManager.ConvertNumberToString(itemcount) + Item.GetLookShortDesc(item, itemcount);
                        }
                        moreThanOne = true;
                        z--;
                    }
                    dispMsg += ".";
                    chr.WriteToDisplay(dispMsg);
                }
                else
                {
                    chr.WriteToDisplay(target.GetNameForActionResult() + " isn't carrying anything in " + Character.POSSESSIVE[(int)target.gender].ToLower() + " sack.");
                }

                if (target.pouchList.Count > 0)
                {
                    int       z = 0, i = 0;
                    string    dispMsg     = "";
                    double    itemcount   = 0;
                    bool      moreThanOne = false;
                    ArrayList templist    = new ArrayList();
                    Item[]    itemList    = new Item[target.pouchList.Count];
                    target.pouchList.CopyTo(itemList);
                    foreach (Item item in itemList)
                    {
                        templist.Add(item);
                    }
                    z       = templist.Count - 1;
                    dispMsg = "In " + target.GetNameForActionResult(true) + "'s pouch you see ";
                    while (z >= 0)
                    {
                        Item item = (Item)templist[z];

                        itemcount = 0;
                        for (i = templist.Count - 1; i > -1; i--)
                        {
                            Item tmpitem = (Item)templist[i];
                            if (tmpitem.name == item.name && tmpitem.name.IndexOf("coin") > -1)
                            {
                                templist.RemoveAt(i);
                                itemcount = itemcount + (int)item.coinValue;
                                z         = templist.Count;
                            }
                            else if (tmpitem.name == item.name)
                            {
                                templist.RemoveAt(i);
                                z          = templist.Count;
                                itemcount += 1;
                            }
                        }
                        if (itemcount > 0)
                        {
                            if (moreThanOne)
                            {
                                if (z == 0)
                                {
                                    dispMsg += " and ";
                                }
                                else
                                {
                                    dispMsg += ", ";
                                }
                            }
                            dispMsg += GameSystems.Text.TextManager.ConvertNumberToString(itemcount) + Item.GetLookShortDesc(item, itemcount);
                        }
                        moreThanOne = true;
                        z--;
                    }
                    dispMsg += ".";
                    chr.WriteToDisplay(dispMsg);
                }
                else
                {
                    chr.WriteToDisplay(target.GetNameForActionResult() + " isn't carrying anything in " + Character.POSSESSIVE[(int)target.gender].ToLower() + " pouch.");
                }
            }
            else
            {
                chr.WriteToDisplay("Your attempt to snoop has failed.");

                // if an intelligence check succeeds then the peeking thief has been caught
                if (Rules.CheckPerception(target))
                {
                    target.WriteToDisplay(chr.Name + " has attempted to peek at your belongings.");
                    chr.WriteToDisplay("Your failure has been noticed!");
                    Rules.BreakHideSpell(chr);
                    Combat.DoFlag(chr, target);
                }
            }

            // give skill experience
            Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) * 20, Globals.eSkillType.Thievery);

            return(true);
        }
示例#4
0
        public bool OnPerform(Character chr, string args)
        {
            string[] sArgs = args.Split(" ".ToCharArray());

            GameWorld.Cell cell = GameWorld.Map.GetCellRelevantToCell(chr.CurrentCell, sArgs[0], true);

            if (cell == null || (!cell.IsLockedHorizontalDoor && !cell.IsLockedVerticalDoor))
            {
                chr.WriteToDisplay("There is no locked door there.");
                return(false);
            }

            if (cell.cellLock != null && cell.cellLock.key != "")
            {
                chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.UnlockingDoor));
                chr.WriteToDisplay("You have failed to pick the lock.");

                if (!Rules.FullStatCheck(chr, Globals.eAbilityStat.Dexterity))
                {
                    Rules.BreakHideSpell(chr);
                }
                return(true);
            }

            Item lockpick = chr.FindHeldItem("lockpick");

            if (lockpick == null || (lockpick != null && lockpick.skillType != Globals.eSkillType.Thievery))
            {
                chr.WriteToDisplay("You are not holding a lockpick.");
                return(false);
            }

            Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) * 50, Globals.eSkillType.Thievery);

            // 50 percent base chance to steal
            int successChance = 50;

            // this is the 100 sided die roll plus the character's thievery skill level
            int roll = Rules.RollD(1, 100);

            // you successfully steal when the roll plus thievery skill level x 2 is greater than the chance
            if (roll + (Skills.GetSkillLevel(chr.thievery) * 2) > successChance)
            {
                chr.WriteToDisplay("You have successfully picked the lock.");
                chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.UnlockingDoor));

                // give more experience
                Skills.GiveSkillExp(chr, Skills.GetSkillLevel(chr.thievery) * 50, Globals.eSkillType.Thievery);

                GameWorld.Map.UnlockDoor(cell, cell.cellLock.key);


                if (!Rules.FullStatCheck(chr, Globals.eAbilityStat.Dexterity))
                {
                    chr.WriteToDisplay("You have failed to remain hidden.");
                    Rules.BreakHideSpell(chr);
                }
            }
            else
            {
                chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.UnlockingDoor));
                chr.WriteToDisplay("You have failed to pick the lock.");

                if (!Rules.FullStatCheck(chr, Globals.eAbilityStat.Dexterity))
                {
                    chr.WriteToDisplay("You have failed to remain hidden.");
                    Rules.BreakHideSpell(chr);
                }
            }

            return(true);
        }