Exemple #1
0
        public static void GuildDonate(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Coins coin = new Coins();
            int coinage;
            bool success = false;

            if (ch.IsNPC())
            {
                return;
            }

            Guild guild = ((PC)ch).GuildMembership;
            if (guild == null)
            {
                ch.SendText("You're not in a guild!\r\n");
                return;
            }
            if (str.Length == 0)
            {
                ch.SendText("Deposit what?\r\n");
                return;
            }
            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("&+LSyntax: &+RSoc deposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
                return;
            }
            if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0)
            {
                ch.SendText("You have none of that type of &+Lcoin&n yet.\r\n");
                return;
            }
            for (coinage = 0; coinage < 4; coinage++)
            {
                switch (coinage)
                {
                    case 0: //copper
                        if (coin.Copper < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Copper > ch.GetCopper())
                        {
                            ch.SendText("You don't have that much &+ycopper&n coin!\r\n");
                            continue;
                        }
                        if (coin.Copper == 0)
                            continue;
                        ch.SpendCopper(coin.Copper);
                        success = true;
                        break;
                    case 1: //silver
                        if (coin.Silver < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Silver > ch.GetSilver())
                        {
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                            continue;
                        }
                        if (coin.Silver == 0)
                            continue;
                        ch.SpendSilver(coin.Silver);
                        success = true;
                        break;

                    case 2: //gold
                        if (coin.Gold < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Gold > ch.GetGold())
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                            continue;
                        }
                        if (coin.Gold == 0)
                            continue;
                        ch.SpendGold(coin.Gold);
                        success = true;
                        break;
                    case 3: //platinum
                        if (coin.Platinum < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Platinum > ch.GetPlatinum())
                        {
                            ch.SendText("You don't have that much &+Wplatinum&n coin!\r\n");
                            continue;
                        }
                        if (coin.Platinum == 0)
                            continue;
                        ch.SpendPlatinum(coin.Platinum);
                        success = true;
                        break;
                } //end switch
            } //end for
            if (success)
            {
                int value = coin.Copper + 10 * coin.Silver + 100 * coin.Gold + 1000 * coin.Platinum;
                int count;
                for (count = 0; count < Limits.MAX_GUILD_MEMBERS; ++count)
                {
                    if (!MUDString.StringsNotEqual(guild.Members[count].Name, ch.Name))
                    {
                        guild.Members[count].Fine -= value;
                        if (guild.Members[count].Fine < 0)
                        {
                            guild.Members[count].Fine = 0;
                            ch.SendText("&+WThank you for the donation!&n\r\n");
                        }
                        else
                        {
                            ch.SendText("You reduce your fine.\r\n");
                        }
                    }
                }
                guild.GuildBankAccount.Copper += coin.Copper;
                guild.GuildBankAccount.Silver += coin.Silver;
                guild.GuildBankAccount.Gold += coin.Gold;
                guild.GuildBankAccount.Platinum += coin.Platinum;
                guild.Save();
                CharData.SavePlayer(ch);
            }
            else
            {
                ch.SendText("&+LSyntax:  &+RSoc deposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
            }
            return;
        }
Exemple #2
0
        /// <summary>
        /// Drop an item.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Drop(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object cash;

            if (ch.IsAffected( Affect.AFFECT_HOLD) || ch.IsAffected( Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You muscles won't respond!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Drop what?\r\n");
                return;
            }

            if (MUDString.IsNumber(str[0]))
            {
                /* 'drop NNNN coins' */
                int amount;

                Int32.TryParse(str[0], out amount);

                if (amount <= 0)
                {
                    ch.SendText("Sorry, you can't do that.\r\n");
                    return;
                }

                if (str.Length < 2)
                {
                    ch.SendText("That's fine, but *what* do you want to drop?\r\n");
                    return;
                }

                if ("copper".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetCopper() < amount)
                    {
                        ch.SendText("You haven't got that many &n&+ycopper&n coins.\r\n");
                        return;
                    }
                    ch.SpendCopper(amount);
                    cash = Object.CreateMoney(amount, 0, 0, 0);
                    cash.AddToRoom(ch.InRoom);
                    cash.FlyLevel = ch.FlightLevel;
                }
                else if ("silver".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetSilver() < amount)
                    {
                        ch.SendText("You haven't got that many &n&+wsilver&n coins.\r\n");
                        return;
                    }
                    ch.SpendSilver(amount);
                    (Object.CreateMoney(0, amount, 0, 0)).AddToRoom(ch.InRoom);
                }
                else if ("gold".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetGold() < amount)
                    {
                        ch.SendText("You haven't got that many &+Ygold&n coins.\r\n");
                        return;
                    }
                    ch.SpendGold(amount);
                    (Object.CreateMoney(0, 0, amount, 0)).AddToRoom(ch.InRoom);
                }
                else if ("platinum".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetPlatinum() < amount)
                    {
                        ch.SendText("You haven't got that many &+Wplatinum&n coins.\r\n");
                        return;
                    }
                    ch.SpendPlatinum(amount);
                    (Object.CreateMoney(0, 0, 0, amount)).AddToRoom(ch.InRoom);
                }
                else
                {
                    ch.SendText("They haven't minted that type of &+Lcoin&n yet.\r\n");
                    return;
                }

                /* Disabled merging of coin types.  This should eventually be re-enabled
                for ( obj = ch.in_room.contents; obj; obj = obj_next )
                {
                obj_next = obj.next_content;

                switch ( obj.pIndexData.vnum )
                {
                case StaticObjects.OBJECT_NUMBER_MONEY_ONE:
                amount += 1;
                obj.ExtractFromWorld();;
                break;

                case StaticObjects.OBJECT_NUMBER_MONEY_SOME:
                amount += obj.value[0];
                obj.ExtractFromWorld();;
                break;
                }
                }
                */
                ch.SendText("Done.\r\n");
                SocketConnection.Act("$n&n drops some &n&+wcoins&n.", ch, null, null, SocketConnection.MessageTarget.room);
                return;
            }

            if (str[0] != "all" && MUDString.IsPrefixOf("all.", str[0]))
            {
                /* 'drop iobj' */
                Object iobj = ch.GetObjCarrying(str[0]);
                if (!iobj)
                {
                    ch.SendText("You do not have that item.\r\n");
                    return;
                }

                if (!ch.CanDropObject(iobj))
                {
                    ch.SendText("You can't release your grip on it.\r\n");
                    return;
                }

                iobj.RemoveFromChar();
                iobj.AddToRoom(ch.InRoom);

                // Prevent item duping - Xangis
                CharData.SavePlayer(ch);

                iobj.FlyLevel = ch.FlightLevel;
                SocketConnection.Act("You drop $p&n.", ch, iobj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n discards $p&n.", ch, iobj, null, SocketConnection.MessageTarget.room);
                if (iobj.HasFlag(ObjTemplate.ITEM_TRANSIENT))
                {
                    SocketConnection.Act("$p&n crumbles to dust.", ch, iobj, null, SocketConnection.MessageTarget.all);
                    iobj.RemoveFromWorld();
                }
                else if (ch.InRoom.TerrainType == TerrainType.lava && !iobj.HasFlag(ObjTemplate.ITEM_NOBURN))
                {
                    SocketConnection.Act("$p&n melts as it sinks into the &+RLava&n.", ch, iobj, null, SocketConnection.MessageTarget.all);
                    if (!ch.IsNPC())
                    {
                        ((PC)ch).Destroyed.AddItem(iobj);
                    }
                    iobj.RemoveFromWorld();
                }
            }
            else
            {
                /* 'drop all' or 'drop all.obj' */
                bool found = false;
                for (int i = ch.Carrying.Count - 1; i >= 0 ; i--)
                {
                    Object obj = ch.Carrying[i];
                    if ( (str.Length < 2 || MUDString.NameContainedIn(str[0].Substring(4), obj.Name))
                            && CharData.CanSeeObj(ch, obj)
                            && obj.WearLocation == ObjTemplate.WearLocation.none
                            && ch.CanDropObject(obj))
                    {
                        found = true;
                        obj.RemoveFromChar();
                        obj.AddToRoom(ch.InRoom);
                        SocketConnection.Act("You drop $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n drops $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                        if (obj.HasFlag(ObjTemplate.ITEM_TRANSIENT))
                        {
                            SocketConnection.Act("$p&n crumbles to dust.", ch, obj, null, SocketConnection.MessageTarget.all);
                            if (!ch.IsNPC())
                            {
                                ((PC)ch).Destroyed.AddItem(obj);
                            }
                            obj.RemoveFromWorld();
                        }
                        else if (ch.InRoom.TerrainType == TerrainType.lava && !obj.HasFlag(ObjTemplate.ITEM_NOBURN))
                        {
                            SocketConnection.Act("$p&n melts as it sinks into the &+RLava&n.", ch, obj, null, SocketConnection.MessageTarget.all);
                            if (!ch.IsNPC())
                            {
                                ((PC)ch).Destroyed.AddItem(obj);
                            }
                            obj.RemoveFromWorld();
                        }
                    }
                }

                if (!found)
                {
                    if (str.Length > 1)
                    {
                        ch.SendText("You are not carrying anything.");
                    }
                    else
                    {
                        SocketConnection.Act("You are not carrying any $T&n.",
                             ch, null, str[0].Substring(4), SocketConnection.MessageTarget.character);
                    }
                }
            }
            return;
        }
Exemple #3
0
        /// <summary>
        /// Give an item to someone.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Give(CharData ch, string[] str)
        {
            if( ch == null ) return;

            CharData victim;
            string arg1 = String.Empty;
            string arg2 = String.Empty;

            if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2))
            {
                ch.SendText("Give what to whom?\r\n");
                return;
            }

            if (MUDString.IsNumber(arg1))
            {
                /* 'give NNNN coins victim' */
                string buf;
                string arg3 = String.Empty;
                int amount;

                Int32.TryParse(arg1, out amount);
                if (amount <= 0)
                {
                    ch.SendText("Sorry, you can't do that.\r\n");
                    return;
                }

                if (String.IsNullOrEmpty(arg3))
                {
                    ch.SendText("Give what to whom?\r\n");
                    return;
                }

                victim = ch.GetCharRoom(arg3);
                if (victim == null)
                {
                    ch.SendText("They aren't here.\r\n");
                    return;
                }

                if (!MUDString.IsPrefixOf(arg2, "copper"))
                {
                    if (ch.GetCopper() < amount)
                    {
                        ch.SendText("You haven't got that many &+ycopper&n coins.\r\n");
                        return;
                    }
                    ch.SpendCopper(amount);
                    SocketConnection.Act("You give $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+ycopper&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount );
                    if (!ch.CheckQuest(victim, null, amount))
                    {
                        victim.ReceiveCopper(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "silver"))
                {
                    if (ch.GetSilver() < amount)
                    {
                        ch.SendText("You haven't got that many silver coins.\r\n");
                        return;
                    }
                    ch.SpendSilver(amount);
                    SocketConnection.Act("You give $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} silver.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount * 10);
                    if (!ch.CheckQuest(victim, null, (amount * 10)))
                        victim.ReceiveSilver(amount);
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "gold"))
                {
                    if (ch.GetGold() < amount)
                    {
                        ch.SendText("You haven't got that many &+Ygold&n coins.\r\n");
                        return;
                    }
                    ch.SpendGold(amount);
                    SocketConnection.Act("You give $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+Ygold&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount *100);
                    if (!ch.CheckQuest(victim, null, (amount * 100)))
                    {
                        victim.ReceiveGold(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "platinum"))
                {
                    if (ch.GetPlatinum() < amount)
                    {
                        ch.SendText("You haven't got that many &+Wplatinum&n coins.\r\n");
                        return;
                    }
                    ch.SpendPlatinum(amount);
                    SocketConnection.Act("You give $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+Wplatinum&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount* 1000 );
                    if (!ch.CheckQuest(victim, null, (amount * 1000)))
                    {
                        victim.ReceivePlatinum(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                ch.SendText("You don't have any of _that_ type of coin yet.\r\n");
                return;
            }

            Object obj = ch.GetObjCarrying(arg1);
            if (!obj)
            {
                ch.SendText("You do not have that item.\r\n");
                return;
            }

            if (obj.WearLocation != ObjTemplate.WearLocation.none)
            {
                ch.SendText("You must remove it first.\r\n");
                return;
            }

            victim = ch.GetCharRoom(arg2);
            if (victim == null)
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if (!ch.CanDropObject(obj))
            {
                ch.SendText("You couldn't possibly part with it.\r\n");
                return;
            }

            /*
            * How silly of shopkeepers to refuse blessed items... previously vampires would
            * refuse blessed items... now all undead types refuse blessed items.
            */
            if (obj.HasFlag(ObjTemplate.ITEM_BLESS) && victim.IsUndead())
            {
                SocketConnection.Act("$N&n refuses to touch the blessed $p&n.", ch, obj, victim, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n tries to give $N&n a $p&n but $E refuses.", ch, obj, victim, SocketConnection.MessageTarget.room);
                SocketConnection.Act("You refuse to accept the blessed $p&n from $n&n.", ch, obj, victim, SocketConnection.MessageTarget.victim);
                return;
            }

            if (victim.CarryNumber + 1 > Limits.MAX_CARRY)
            {
                SocketConnection.Act("$N&n has $S hands full.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (victim.CarryWeight + obj.GetWeight() > victim.MaxCarryWeight())
            {
                SocketConnection.Act("$N&n cannot carry that much weight.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (!CharData.CanSeeObj(victim, obj))
            {
                SocketConnection.Act("$N&n can't see it.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            obj.RemoveFromChar();
            obj.ObjToChar(victim);

            // Prevent item duplication.
            CharData.SavePlayer(ch);
            CharData.SavePlayer(victim);

            SocketConnection.Act("You give $p&n to $N&n.", ch, obj, victim, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n gives you $p&n.", ch, obj, victim, SocketConnection.MessageTarget.victim);
            SocketConnection.Act("$n&n gives $p&n to $N&n.", ch, obj, victim, SocketConnection.MessageTarget.everyone_but_victim);

            //    prog_give_trigger( victim, ch, obj );

            if (Database.IsArtifact(obj.ObjIndexData.IndexNumber))
            {
                string buf = String.Format("{0} has given artifact {1} to {2}", ch.Name, obj.ObjIndexData.IndexNumber, victim.Name);
                Log.Trace(buf);
            }

            if (!victim.IsNPC())
            {
                return;
            }

            // Destroy the item so they can't kill the mob for the item.
            if (ch.CheckQuest(victim, obj, 0))
            {
                obj.RemoveFromWorld();
            }
            return;
        }
Exemple #4
0
        /// <summary>
        /// This modified version for the 4-type coin system by Xangis
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Split(CharData ch, string[] str)
        {
            if( ch == null ) return;

            int members = 0;
            int coinage;
            bool success = false;
            Coins coin = new Coins();

            if (!ch.GroupLeader)
            {
                ch.SendText("Split with yourself?  How generous!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Split how much?\r\n");
                return;
            }

            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("Try 'split <number/all> <coin type>' or 'split all.coins' \r\n");
                return;
            }
            if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0)
            {
                ch.SendText("Try sharing some actual coins!\r\n");
                return;
            }
            foreach (CharData groupChar in ch.InRoom.People)
            {
                if (groupChar.IsSameGroup(ch))
                {
                    members++;
                }
            }

            if (members < 2)
            {
                ch.SendText("Just keep it all.\r\n");
                Log.Error("Commandsplit: managed to find a group of 1 person\r\n", 0);
                return;
            }
            for (coinage = 0; coinage < 4; coinage++)
            {
                switch (coinage)
                {
                    case 0: //copper
                        if (coin.Copper <= 0)
                            continue; //quietly ignore errors
                        int share;
                        int extra;
                        string buf;
                        if (coin.Copper <= ch.GetCopper())
                        {
                            share = coin.Copper / members;
                            extra = coin.Copper % members;
                            if (share == 0)
                                continue;
                            ch.SpendCopper(coin.Copper);
                            buf = String.Format(
                                      "You split {0} &+ycopper&n.  Your share is {1} coins.\r\n", coin.Copper, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+ycopper&n.  Your share is {0} coins.",
                                      share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceiveCopper(share);
                                }
                                else if (groupChar == ch)
                                    groupChar.ReceiveCopper(share + extra);
                            }
                            success = true;
                            continue;
                        }
                        ch.SendText("You don't have that much &+ycopper&n coin!\r\n");
                        break;
                    case 1: //silver
                        if (coin.Silver <= 0)
                            continue; //quietly ignore errors
                        if (coin.Silver <= ch.GetSilver())
                        {
                            share = coin.Silver / members;
                            extra = coin.Silver % members;
                            if (share == 0)
                                continue;
                            ch.SpendSilver(coin.Silver);
                            buf = String.Format(
                                      "You split {0} &+wsilver&n.  Your share is {1} coins.\r\n", coin.Silver, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+wsilver&n.  Your share is {0} coins.",
                                      share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceiveSilver(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceiveSilver(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        else
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                        break;
                    case 2: //gold
                        if (coin.Gold <= 0)
                            continue; //quietly ignore errors
                        if (coin.Gold <= ch.GetGold())
                        {
                            share = coin.Gold / members;
                            extra = coin.Gold % members;
                            if (share == 0)
                                continue;
                            ch.SpendGold(coin.Gold);
                            buf = String.Format("You split {0} &+Ygold&n.  Your share is {1} coins.\r\n", coin.Gold, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+Ygold&n.  Your share is {0} coins.", share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceiveGold(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceiveGold(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        else
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                        }
                        break;
                    case 3: //platinum
                        if (coin.Platinum <= 0)
                            continue; //quietly ignore errors
                        if (coin.Platinum <= ch.GetPlatinum())
                        {
                            share = coin.Platinum / members;
                            extra = coin.Platinum % members;
                            if (share == 0)
                                continue;
                            ch.SpendPlatinum(coin.Platinum);
                            buf = String.Format("You split {0} &+Wplatinum&n.  Your share is {1} coins.\r\n", coin.Platinum, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+Wplatinum&n.  Your share is {0} coins.", share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceivePlatinum(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceivePlatinum(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        ch.SendText("You don't have that much &+Wplatinum&n coin!\r\n");
                        break;
                } //end switch
            } //end for
            if (!success)
            {
                ch.SendText("You didn't seem to split anything.\r\n");
            }
            return;
        }
Exemple #5
0
        /// <summary>
        /// Put coins into a bank account.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Deposit(CharData ch, string[] str)
        {
            if( ch == null ) return;

            int coinage;
            bool success = false;
            Coins coin = new Coins();

            if (ch.IsNPC())
            {
                ch.SendText("NPCs do not have bank accounts!\r\n");
                return;
            }

            if (!ch.InRoom || !ch.InRoom.HasFlag(RoomTemplate.ROOM_BANK))
            {
                ch.SendText("You're not in a bank!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Deposit what?\r\n");
                return;
            }
            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("&+LSyntax:  &+RDeposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
                return;
            }
            if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0)
            {
                ch.SendText("You have none of that type of &+Lcoin&n yet.\r\n");
                return;
            }
            for (coinage = 0; coinage < 4; coinage++)
            {
                switch (coinage)
                {
                    case 0: //copper
                        if (coin.Copper < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Copper > ch.GetCopper())
                        {
                            ch.SendText("You don't have that much &+ycopper&n coin!\r\n");
                            continue;
                        }
                        if (coin.Copper == 0)
                            continue;
                        ch.SpendCopper(coin.Copper);
                        ((PC)ch).Bank.Copper += coin.Copper;
                        success = true;
                        break;
                    case 1: //silver
                        if (coin.Silver < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Silver > ch.GetSilver())
                        {
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                            continue;
                        }
                        if (coin.Silver == 0)
                            continue;
                        ch.SpendSilver(coin.Silver);
                        ((PC)ch).Bank.Silver += coin.Silver;
                        success = true;
                        break;
                    case 2: //gold
                        if (coin.Gold < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Gold > ch.GetGold())
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                            continue;
                        }
                        if (coin.Gold == 0)
                            continue;
                        ch.SpendGold(coin.Gold);
                        ((PC)ch).Bank.Gold += coin.Gold;
                        success = true;
                        break;
                    case 3: //platinum
                        if (coin.Platinum < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Platinum > ch.GetPlatinum())
                        {
                            ch.SendText("You don't have that much &+Wplatinum&n coin!\r\n");
                            continue;
                        }
                        if (coin.Platinum == 0)
                            continue;
                        ch.SpendPlatinum(coin.Platinum);
                        ((PC)ch).Bank.Platinum += coin.Platinum;
                        success = true;
                        break;
                } //end switch
            } //end for
            if (success)
            {
                ch.SendText("You make your deposit.\r\n");
                SocketConnection.Act("$n&n makes a transaction.", ch, null, null, SocketConnection.MessageTarget.room);
            }
            else
            {
                ch.SendText("&+LSyntax:  &+RDeposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
            }
            return;
        }
Exemple #6
0
        /// <summary>
        /// Shows a character's score screen.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Score(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string text = String.Empty;

            if (ch == null)
            {
                Log.Error("Command.Score(): null ch.", 0);
                return;
            }

            Affect prev;

            text += "&+WName: &+G" + ch.Name + "&n" + (ch.IsNPC() ? String.Empty : ((PC)ch).Title) + "\r\n";
            text += "&+WRace:&n " + MUDString.PadStr(Race.RaceList[ch.GetRace()].ColorName, 16);
            text += "&+WClass:&n " + MUDString.PadStr(ch.CharacterClass.WholistName, 32) + "&n\r\n";
            text += "&+WLevel: " + MUDString.PadInt(ch.Level, 5) + "     Played: " + (ch.TimePlayed.Hours) + " hours       &+WSex: ";
            text += System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(ch.GetSexString()) + "\r\n";
            if (ch.Fighting == null)
            {
                text += "&+WExperience: &+B" + StringConversion.ExperienceString(ch) + "&n\r\n\r\n";
            }
            text += "&+WCurrent/Max Health: [&n&+g" + MUDString.PadInt(ch.Hitpoints, 5) + "&+W / &n&+g" + MUDString.PadInt(ch.GetMaxHit(), 5);
            text += "&+W]     Coins:     Carried     In Bank\r\n";
            text += "&+WCurrent/Max Moves:  [&n&+g" + MUDString.PadInt(ch.CurrentMoves, 5) + "&+W / &n&+g" + MUDString.PadInt(ch.MaxMoves, 5);
            text += "&+W]     &+WPlatinum      " + MUDString.PadInt(ch.GetPlatinum(), 5) + "        ";
            text += (ch.IsNPC() ? 0 : ((PC)ch).Bank.Platinum) + "\r\n";
            text += "Current/Max Mana:   [&n&+g" + MUDString.PadInt(ch.CurrentMana, 5) + "&+W / &n&+g" + MUDString.PadInt(ch.MaxMana, 5);
            text += "&+W]     &+YGold          " + MUDString.PadInt(ch.GetGold(), 5) + "        " + (ch.IsNPC() ? 0 : ((PC)ch).Bank.Gold) + "\r\n";
            text += "                                        &n&+wSilver        " + MUDString.PadInt(ch.GetSilver(), 5) + "        ";
            text += (ch.IsNPC() ? 0 : ((PC)ch).Bank.Silver) + "\r\n";
            text += "&+WFrags: &+W" + MUDString.PadInt((ch.IsNPC() ? 0 : ((PC)ch).Frags), 3) + "&n                               &n&+yCopper        ";
            text += MUDString.PadInt(ch.GetCopper(), 5) + "        " + (ch.IsNPC() ? 0 : ((PC)ch).Bank.Copper) + "\r\n";
            if (!ch.IsNPC())
            {
                text += "&+WTotal Deaths: &+W" + MUDString.PadInt(((PC)ch).MobDeaths + ((PC)ch).PlayerDeaths, 5) + "&n     &+WMobs Killed: &+W";
                text += MUDString.PadInt(((PC)ch).MobKills, 5) + "&n\r\n&+WPlayers Killed: &+W" + MUDString.PadInt(((PC)ch).PlayerKills, 5);
                text += "&n   &+WPlayer Deaths: &+W" + MUDString.PadInt(((PC)ch).PlayerDeaths, 5) + "&n\r\n";
            }

            if (!ch.IsNPC())
            {
                int divisor = ((PC)ch).Created.Quantity;
                if (divisor == 0)
                    divisor = 1;
                text += String.Format("&+WItems Created: &n{0}    &+WTotal Value: &n{1}  &+WBest: &n{2}  &+WAvg: &n{3}\r\n",
                    MUDString.PadInt(((PC)ch).Created.Quantity, 5),
                    MUDString.PadInt(((PC)ch).Created.TotalCost, 5),
                    MUDString.PadInt(((PC)ch).Created.MaxCost, 5),
                    MUDString.PadInt((((PC)ch).Created.TotalCost / divisor), 5));
                divisor = ((PC)ch).Destroyed.Quantity;
                if (divisor == 0)
                    divisor = 1;
                text += String.Format("&+WItems Destroyed: &n{0}  &+WTotal Value: &n{1}  &+WBest: &n{2}  &+WAvg: &n{3}\r\n",
                    MUDString.PadInt(((PC)ch).Destroyed.Quantity, 5),
                    MUDString.PadInt(((PC)ch).Destroyed.TotalCost, 5),
                    MUDString.PadInt(((PC)ch).Destroyed.MaxCost, 5),
                    MUDString.PadInt((((PC)ch).Destroyed.TotalCost / divisor), 5));
            }

            if (!ch.IsNPC())
            {
                text += "&+WTotal Score: &+W" + ((PC)ch).Score + "&n\r\n";
            }

            if (ch.IsClass(CharClass.Names.monk) || ch.IsClass(CharClass.Names.mystic))
            {
                text += "&+WTradition: &+B" + TraditionData.Names[((PC)ch).Tradition] + "&n\r\n";
                text += "&+WTraining Points: &+B" + (ch.IsNPC() ? 0 : ((PC)ch).SkillPoints) + "&n\r\n";
            }

            if (ch.Followers != null && ch.Followers.Count > 0)
            {
                text += "&+BFollowers:&n\r\n";
                foreach (CharData follower in ch.Followers)
                {
                    if (follower == null)
                    {
                        continue;
                    }
                    text += follower.ShowNameTo(ch, true) + " &n\r\n";
                }
                text += "\r\n";
            }
            if (ch.IsAffected( Affect.AFFECT_POISON))
            {
                text += "&+GYou are poisoned.&n\r\n";
            }

            if ((ch.IsAffected( Affect.AFFECT_DETECT_MAGIC) || ch.IsImmortal())
                    && MUDString.StringsNotEqual(BitvectorFlagType.AffectString(ch.AffectedBy, true), "none"))
            {
                text += "&+BEnchantments: &+W" + BitvectorFlagType.AffectString(ch.AffectedBy, true) + "&n\r\n\r\n";
            }

            if (ch.Affected != null)
            {
                bool printed = false;
                prev = null;
                foreach (Affect affect in ch.Affected)
                {
                    if (!printed)
                    {
                        text += "&+BActive Spells:&+W\r\n";
                        printed = true;
                    }

                    /* Show only new affects to mortals. */
                    if (prev != null && prev.Value == affect.Value
                            && prev.Type == affect.Type && !ch.IsImmortal())
                    {
                        prev = affect;
                        continue;
                    }
                    prev = affect;

                    if (affect.Type == Affect.AffectType.skill && !String.IsNullOrEmpty(affect.Value) && ch.IsImmortal())
                    {
                        text += MUDString.CapitalizeANSIString( Skill.SkillList[affect.Value].Name );
                    }
                    else if (affect.Type == Affect.AffectType.skill && !String.IsNullOrEmpty(affect.Value))
                    {
                        continue;
                    }
                    else if (affect.Type == Affect.AffectType.spell && !String.IsNullOrEmpty(affect.Value))
                    {
                        text += MUDString.CapitalizeANSIString(Spell.SpellList[affect.Value].Name);
                    }
                    else if (affect.Type == Affect.AffectType.song && !String.IsNullOrEmpty(affect.Value))
                    {
                        text += MUDString.CapitalizeANSIString(affect.Value);
                    }
                    else
                    {
                        text += "Something";
                    }

                    if (ch.IsImmortal())
                    {
                        foreach (AffectApplyType apply in affect.Modifiers)
                        {
                            text += " modifies " + StringConversion.AffectApplyString(apply.Location) + " by " + apply.Amount;
                        }
                        text += " for " + affect.Duration + " hours with bits " + affect.AffectString(false) + ".\r\n";
                    }
                    else
                    {
                        if (affect.Duration == 0 && ch.IsAffected( Affect.AFFECT_DETECT_MAGIC))
                        {
                            text += " (fading rapidly)\r\n";
                        }
                        else if (affect.Duration == 1 && ch.IsAffected( Affect.AFFECT_DETECT_MAGIC))
                        {
                            text += " (fading)\r\n";
                        }
                        else
                        {
                            text += "\r\n";
                        }
                    }
                }
            }
            text += "&n";
            ch.SendText(text);
            return;
        }
Exemple #7
0
        /// <summary>
        /// Creates a duplicate of a mobile minus its inventory.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="clone"></param>
        public static void CloneMobile( CharData parent, CharData clone )
        {
            int i;

            if( parent == null || clone == null || !parent.IsNPC() )
                return;

            // Fix values.
            clone.Name = parent.Name;
            clone.ShortDescription = parent.ShortDescription;
            clone.FullDescription = parent.FullDescription;
            clone.Description = parent.Description;
            clone.Gender = parent.Gender;
            clone.CharacterClass = parent.CharacterClass;
            clone.SetPermRace( parent.GetRace() );
            clone.Level = parent.Level;
            clone.TrustLevel = 0;
            clone.SpecialFunction = parent.SpecialFunction;
            clone.SpecialFunctionNames = parent.SpecialFunctionNames;
            clone.Timer = parent.Timer;
            clone.Wait = parent.Wait;
            clone.Hitpoints = parent.Hitpoints;
            clone.MaxHitpoints = parent.MaxHitpoints;
            clone.CurrentMana = parent.CurrentMana;
            clone.MaxMana = parent.MaxMana;
            clone.CurrentMoves = parent.CurrentMoves;
            clone.MaxMoves = parent.MaxMoves;
            clone.SetCoins( parent.GetCopper(), parent.GetSilver(), parent.GetGold(), parent.GetPlatinum() );
            clone.ExperiencePoints = parent.ExperiencePoints;
            clone.ActionFlags = parent.ActionFlags;
            clone.Affected = parent.Affected;
            clone.CurrentPosition = parent.CurrentPosition;
            clone.Alignment = parent.Alignment;
            clone.Hitroll = parent.Hitroll;
            clone.Damroll = parent.Damroll;
            clone.Wimpy = parent.Wimpy;
            clone.Deaf = parent.Deaf;
            clone.Hunting = parent.Hunting;
            clone.Hating = parent.Hating;
            clone.Fearing = parent.Fearing;
            clone.Resistant = parent.Resistant;
            clone.Immune = parent.Immune;
            clone.Susceptible = parent.Susceptible;
            clone.CurrentSize = parent.CurrentSize;
            clone.PermStrength = parent.PermStrength;
            clone.PermIntelligence = parent.PermIntelligence;
            clone.PermWisdom = parent.PermWisdom;
            clone.PermDexterity = parent.PermDexterity;
            clone.PermConstitution = parent.PermConstitution;
            clone.PermAgility = parent.PermAgility;
            clone.PermCharisma = parent.PermCharisma;
            clone.PermPower = parent.PermPower;
            clone.PermLuck = parent.PermLuck;
            clone.ModifiedStrength = parent.ModifiedStrength;
            clone.ModifiedIntelligence = parent.ModifiedIntelligence;
            clone.ModifiedWisdom = parent.ModifiedWisdom;
            clone.ModifiedDexterity = parent.ModifiedDexterity;
            clone.ModifiedConstitution = parent.ModifiedConstitution;
            clone.ModifiedAgility = parent.ModifiedAgility;
            clone.ModifiedCharisma = parent.ModifiedCharisma;
            clone.ModifiedPower = parent.ModifiedPower;
            clone.ModifiedLuck = parent.ModifiedLuck;
            clone.ArmorPoints = parent.ArmorPoints;
            //clone._mpactnum = parent._mpactnum;

            for (i = 0; i < 6; i++)
            {
                clone.SavingThrows[i] = parent.SavingThrows[i];
            }

            // Now add the affects.
            foreach (Affect affect in parent.Affected)
            {
                clone.AddAffect(affect);
            }
        }
Exemple #8
0
        /// <summary>
        /// Turns a character into a corpse.
        /// 
        /// TODO: Add a corpse to the corpse list when a corpse is created.
        /// TODO: Also remove corpses from the corpse list when a corpse decays.
        /// </summary>
        /// <param name="ch"></param>
        static void MakeCorpse( CharData ch )
        {
            Object corpse;
            string name;
            int corpseIndexNumber;
            int timer;
            int level;

            // Need a bailout here if undead corpses are supposed to disintegrate.
            if( LeavesNoCorpse( ch ) )
            {
                return;
            }

            // Different corpse settings for players and mobs - Xangis
            if( ch.IsNPC() )
            {
                corpseIndexNumber = StaticObjects.OBJECT_NUMBER_CORPSE_NPC;
                name = ch.ShortDescription;
                timer = MUDMath.NumberRange( 15, 30 );
                level = ch.Level;  // Corpse level
            }
            else
            {
                corpseIndexNumber = StaticObjects.OBJECT_NUMBER_CORPSE_PC;
                name = ch.Name;
                timer = MUDMath.NumberRange( 180, 240 ) + ( ch.Level * 2 );
                level = ch.Level; // Corpse level
            }

            /*
            * This longwinded corpse creation routine comes about because
            * we dont want anything created AFTER a corpse to be placed
            * INSIDE a corpse.  This had caused crashes from ObjectUpdate()
            * in Object.Extract().
            */

            if( ch.GetCash() > 0 )
            {
                Object coins = Object.CreateMoney( ch.GetCopper(), ch.GetSilver(), ch.GetGold(), ch.GetPlatinum() );
                corpse = Database.CreateObject( Database.GetObjTemplate( corpseIndexNumber ), 0 );
                corpse.AddToObject( coins );
                ch.SetCoins( 0, 0, 0, 0 );
            }
            else
            {
                corpse = Database.CreateObject( Database.GetObjTemplate( corpseIndexNumber ), 0 );
            }

            corpse.Timer = timer;
            corpse.Values[ 0 ] = (int)Race.RaceList[ ch.GetRace() ].BodyParts;

            corpse.Level = level; // corpse level

            string buf = String.Format( "corpse of {0}", name );
            corpse.Name = buf;

            buf = String.Format( corpse.ShortDescription, name );
            corpse.ShortDescription = buf;

            buf = String.Format( corpse.FullDescription, name );
            corpse.FullDescription = buf;

            Object obj;
            for(int i = (ch.Carrying.Count - 1); i >= 0; i-- )
            {
                obj = ch.Carrying[i];

                // Remove items flagged inventory-only from all corpses.
                if (obj.HasFlag(ObjTemplate.ITEM_INVENTORY))
                {
                    Log.Trace("Removing inventory-item " + obj + " from character before creating corpse: " + corpse);
                    obj.RemoveFromWorld();
                }
                else
                {
                    if (ch.IsNPC() && ch.MobileTemplate.ShopData
                            && obj.WearLocation == ObjTemplate.WearLocation.none)
                    {
                        obj.RemoveFromChar();
                        obj.RemoveFromWorld();
                    }
                    else
                    {
                        obj.RemoveFromChar();
                        corpse.AddToObject(obj);
                    }
                }
            }

            corpse.AddToRoom( ch.InRoom );
            if( !corpse.InRoom )
            {
                Log.Error( "MakeCorpse: corpse " + corpse.ToString() + " sent to null room, deleting.", 0 );
                corpse.RemoveFromWorld();
            }

            return;
        }
Exemple #9
0
        /// <summary>
        /// Checks whether the mob should leave a corpse when it dies. If so, returns
        /// true. Otherwise, it prints a message, if appropriate, and returns false.
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        static bool LeavesNoCorpse( CharData ch )
        {
            string msg = String.Empty;
            bool noCorpse = false;

            if( ch.IsUndead() )
            {
                noCorpse = true;
                msg = String.Format( "$n&N crumbles to dust." );
            }

            else if( ch.IsElemental() )
            {
                noCorpse = true;
                msg = String.Format( "$n&n returns to the elements from which it formed." );
            }

            if( noCorpse )
            {
                SocketConnection.Act( msg, ch, null, null, SocketConnection.MessageTarget.room );
                if( ch.GetCash() > 0 )
                {
                    Object coins = Object.CreateMoney( ch.GetCopper(), ch.GetSilver(), ch.GetGold(), ch.GetPlatinum() );
                    coins.AddToRoom( ch.InRoom );
                }
                for( int i = (ch.Carrying.Count-1); i >= 0; i-- )
                {
                    Object obj = ch.Carrying[i];
                    obj.RemoveFromChar();
                    obj.AddToRoom( ch.InRoom );
                }
            }

            return noCorpse;
        }
Exemple #10
0
        /// <summary>
        /// Fills a coin structure based on some input text.  Valid inputs include:
        /// 3 platinum
        /// all.coins
        /// 1 p
        /// 2 p 3 copper all.gold
        /// all.silver
        /// all.g
        /// a
        /// </summary>
        /// <param name="str"></param>
        /// <param name="ch"></param>
        /// <returns></returns>
        public bool FillFromString( string[] str, CharData ch )
        {
            Copper = 0;
            Silver = 0;
            Gold = 0;
            Platinum = 0;

            if( ch == null || str.Length < 1 || String.IsNullOrEmpty(str[0] ))
            {
                return false;
            }

            int currentNumber = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if ("all.coins".StartsWith(str[i]))
                {
                    Copper = ch.GetCopper();
                    Silver = ch.GetSilver();
                    Gold = ch.GetGold();
                    Platinum = ch.GetPlatinum();
                    return true;
                }
                else if ("all.copper".StartsWith(str[i]))
                {
                    Copper = ch.GetCopper();
                }
                else if ("all.silver".StartsWith(str[i]))
                {
                    Silver = ch.GetSilver();
                }
                else if ("all.gold".StartsWith(str[i]))
                {
                    Gold = ch.GetGold();
                }
                else if ("all.platinum".StartsWith(str[i]))
                {
                    Platinum = ch.GetPlatinum();
                }
                else if ("copper".StartsWith(str[i]))
                {
                    Copper = currentNumber;
                }
                else if ("silver".StartsWith(str[i]))
                {
                    Silver = currentNumber;
                }
                else if ("gold".StartsWith(str[i]))
                {
                    Gold = currentNumber;
                }
                else if ("platinum".StartsWith(str[i]))
                {
                    Platinum = currentNumber;
                }
                // Treat it as a number.
                else
                {
                    Int32.TryParse(str[i], out currentNumber);
                }
            }
            if (Copper > 0 || Silver > 0 || Gold > 0 || Platinum > 0)
            {
                return true;
            }
            return false;
        }