Beispiel #1
0
        private WearTypes FindEquipmentPosition(CharacterData character, ObjectData obj, string arg)
        {
            WearTypes where = WearTypes.Index;

            string[] keywords = new string[] {
                "!RESERVED!",
                "finger",
                "!RESERVED!",
                "neck",
                "!RESERVED!",
                "body",
                "head",
                "legs",
                "feet",
                "hands",
                "arms",
                "shield",
                "about",
                "waist",
                "wrist",
                "!RESERVED!",
                "!RESERVED!",
                "!RESERVED!",
                "\n"
            };

            if (String.IsNullOrEmpty (arg))
            {
                if (obj.WearFlagged (ObjectWearFlags.Finger)) where = WearTypes.RightFinger;
                if (obj.WearFlagged (ObjectWearFlags.Neck)) where = WearTypes.Neck1;
                if (obj.WearFlagged (ObjectWearFlags.Body)) where = WearTypes.Body;
                if (obj.WearFlagged (ObjectWearFlags.Head)) where = WearTypes.Head;
                if (obj.WearFlagged (ObjectWearFlags.Legs)) where = WearTypes.Legs;
                if (obj.WearFlagged (ObjectWearFlags.Feet)) where = WearTypes.Feet;
                if (obj.WearFlagged (ObjectWearFlags.Hands)) where = WearTypes.Hands;
                if (obj.WearFlagged (ObjectWearFlags.Arms)) where = WearTypes.Arms;
                if (obj.WearFlagged (ObjectWearFlags.Shield)) where = WearTypes.Shield;
                if (obj.WearFlagged (ObjectWearFlags.About)) where = WearTypes.About;
                if (obj.WearFlagged (ObjectWearFlags.Waist)) where = WearTypes.Waist;
                if (obj.WearFlagged (ObjectWearFlags.Wrist)) where = WearTypes.RightWrist;
            }
            else if (((where = (WearTypes)GlobalUtilities.SearchBlock(arg, keywords, false)) < 0) || (String.IsNullOrEmpty(arg) && arg[0] == '!'))
            {
                SendToCharacter (character, "'%s'? What part of your body is THAT?\r\n", arg);
                return WearTypes.None;
            }

            return (where);
        }
Beispiel #2
0
 internal string AnA(ObjectData obj)
 {
     switch (obj.Name[0])
     {
         case 'a':
         case 'A':
         case 'e':
         case 'E':
         case 'i':
         case 'I':
         case 'o':
         case 'O':
         case 'u':
         case 'U':
             return "An";
         default:
             return "A";
     }
 }
Beispiel #3
0
        void PerformAct(string text, CharacterData character, ObjectData obj, object victimObject, CharacterData to)
        {
            string str = "";
            CharacterData scriptVictim = null;
            ObjectData scriptTarget = null;

            string buffer = String.Empty;

            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == '$')
                {
                    switch (text[++i])
                    {
                        case 'n':
                            str = PersonString(character, to);
                            break;

                        case 'N':
                            scriptVictim = victimObject as CharacterData;

                            if (scriptVictim == null)
                                str = "<NULL>";
                            else
                                str = PersonString(scriptVictim, to);
                            break;

                        case 'm':
                            str = HimHer(character);
                            break;

                        case 'M':
                            scriptVictim = victimObject as CharacterData;

                            if (scriptVictim == null)
                                str = "<NULL>";
                            else
                                str = HimHer(scriptVictim);
                            break;

                        case 's':
                            str = HisHer(character);
                            break;

                        case 'S':
                            scriptVictim = victimObject as CharacterData;

                            if (scriptVictim == null)
                                str = "<NULL>";
                            else
                                str = HisHer(scriptVictim);
                            break;

                        case 'e':
                            str = HeShe(character);
                            break;

                        case 'E':
                            scriptVictim = victimObject as CharacterData;

                            if (scriptVictim == null)
                                str = "<NULL>";
                            else
                                str = HeShe(scriptVictim);
                            break;

                        case 'o':
                            if (obj == null)
                                str = "<NULL>";
                            else
                                str = ObjectName(obj, to);
                            break;

                        case 'O':
                            scriptTarget = victimObject as ObjectData;

                            if (scriptTarget == null)
                                str = "<NULL>";
                            else
                                str = ObjectName(scriptTarget, to);
                            break;

                        case 'p':
                            if (obj == null)
                                str = "<NULL>";
                            else
                                str = ObjectString(obj, to);
                            break;

                        case 'P':
                            scriptTarget = victimObject as ObjectData;

                            if (scriptTarget == null)
                                str = "<NULL>";
                            else
                                str = ObjectString(scriptTarget, to);
                            break;

                        case 'a':
                            if (obj == null)
                                str = "<NULL>";
                            else
                                str = SAnA(obj);
                            break;

                        case 'A':
                            scriptTarget = victimObject as ObjectData;

                            if (scriptTarget == null)
                                str = "<NULL>";
                            else
                                str = SAnA(scriptTarget);
                            break;

                        case 't':
                            if (obj == null)
                                str = "<NULL>";
                            else
                                str = obj.Name;
                            break;

                        case 'T':
                            scriptTarget = victimObject as ObjectData;

                            if (scriptTarget == null)
                                str = "<NULL>";
                            else
                                str = scriptTarget.Name;
                            break;

                        case 'F':
                            if (obj == null)
                                str = "<NULL>";
                            else
                                str = GlobalUtilities.FirstName(obj.Name);
                            break;

                        case 'u':
                            //for (j=buf; j > lbuf && !isspace((int) *(j-1)); j--);
                            //if (j != buf)
                            //  *j = UPPER(*j);
                            //i = "";
                            break;

                        case 'U':
                            //uppercasenext = TRUE;
                            //i = "";
                            break;

                        case '$':
                            str = "$";
                            break;

                        default:
                            Log("SYSERR: Illegal $-code to act(): " + text[i]);
                            Log("SYSERR: " + text);
                            str = "";
                            break;
                    }

                    buffer += str;
                }
                else
                {
                    buffer += text[i];
                }
                //else if (!(*(buf++) = *(orig++)))
                //{
                //    break;
                //}
                //else if (uppercasenext && !isspace((int) *(buf-1)))
                //{
                //    *(buf-1) = UPPER(*(buf-1));
                    //uppercasenext = FALSE;
                //}
            }

            buffer += "r\n\0";

            if (to.Descriptor != null)
                WriteToOutput(to.Descriptor, buffer);

            //if ((to.IsNPC && scriptActTrigger > 0) && (to != character))
              //act_mtrigger(to, lbuf, ch, dg_victim, obj, dg_target, dg_arg);
        }
Beispiel #4
0
        private void Act(string text, bool hideInvisible, CharacterData character, ObjectData obj, object victim, int type)
        {
            int toSleeping;

            if (String.IsNullOrEmpty(text))
                return;

            if ((toSleeping = (type & GlobalConstants.TO_SLEEP)) != 0)
                type &= ~GlobalConstants.TO_SLEEP;

            /* this is a hack as well - DG_NO_TRIG is 256 -- Welcor */
            if ((_actCheck = (type & GlobalConstants.DG_NO_TRIG)) != 0)
                type &= ~GlobalConstants.DG_NO_TRIG;

            if (type == GlobalConstants.TO_CHAR)
            {
                if (character != null && SendOK(character, toSleeping))
                    PerformAct(text, character, obj, victim, character);

                return;
            }

            if (type == GlobalConstants.TO_VICT)
            {
                CharacterData to = victim as CharacterData;

                if (to != null && SendOK(to, toSleeping))
                {
                    PerformAct(text, character, obj, victim, to);
                }

                return;
            }

            if (type == GlobalConstants.TO_GMOTE)
            {
                DescriptorData i;

                foreach (DescriptorData data in _descriptors)
                {
                    if (data.Character != null && data.Character.PreferenceFlagged(PreferenceFlags.NoGossip) && data.Character.PlayerFlagged(PlayerFlags.Writing) &&
                        _rooms[data.Character.InRoom].RoomFlagged(RoomFlags.Soundproof))
                    {
                        SendToCharacter(data.Character, "%s", CharacterData.ColorYellow(data.Character, GlobalConstants.C_NRM));
                        PerformAct(text, character, obj, victim, data.Character);
                        SendToCharacter(data.Character, "%s", CharacterData.ColorNormal(data.Character, GlobalConstants.C_NRM));
                    }
                }

                return;
            }

            List<CharacterData> people = null;

            if (character != null && character.InRoom != GlobalConstants.NOWHERE)
                people = _rooms[character.InRoom].People;
            else if (obj != null && obj.InRoom != GlobalConstants.NOWHERE)
                people = _rooms[obj.InRoom].People;
            else
            {
                Log("SYSERR: no valid target to Act()!");
                return;
            }

            foreach (CharacterData person in people)
            {
                if (!SendOK(person, toSleeping) || person == character)
                    continue;
                if (hideInvisible && character != null && !CanSee(person, character))
                    continue;
                if (type != GlobalConstants.TO_ROOM && person == victim)
                    continue;
                PerformAct(text, character, obj, victim, person);
            }
        }
Beispiel #5
0
 internal bool CanSeeObjectCarrier(CharacterData character, ObjectData obj)
 {
     return obj.CarriedBy != null || CanSee(character, obj.CarriedBy) && (obj.WornBy != null || !CanSee(character, obj.WornBy));
 }
Beispiel #6
0
 internal bool CanSeeObject(CharacterData character, ObjectData obj)
 {
     return (MortalCanSeeObject(character, obj) || (!character.IsNPC && character.PreferenceFlagged(PreferenceFlags.HolyLight)));
 }
Beispiel #7
0
 internal bool CanSee(CharacterData character, ObjectData target)
 {
     return false;
 }
Beispiel #8
0
 private bool ValidObjectRealNumber(ObjectData obj)
 {
     return (obj.Number <= _topOfObjectTable && obj.Number != GlobalConstants.NOTHING);
 }
Beispiel #9
0
 private int GetObjectVirtualNumber(ObjectData obj)
 {
     return (ValidObjectRealNumber (obj) ? _objectIndex[obj.Number].VirtualNumber : GlobalConstants.NOTHING);
 }
Beispiel #10
0
 private SpecialFunctionHandler GetObjectSpecial(ObjectData obj)
 {
     return (ValidObjectRealNumber (obj) ? _objectIndex[obj.Number].SpecialFunction : null);
 }
Beispiel #11
0
 internal string ObjectString(ObjectData obj, CharacterData victim)
 {
     return CanSeeObject(victim, obj) ? obj.ShortDescription : "something";
 }
Beispiel #12
0
 internal string ObjectName(ObjectData obj, CharacterData victim)
 {
     return CanSeeObject(victim, obj) ? GlobalUtilities.FirstName(obj.Name) : "something";
 }
Beispiel #13
0
 internal bool MortalCanSeeObject(CharacterData character, ObjectData obj)
 {
     return LightOK(character) && InvisibleOKObject(character, obj) && CanSeeObjectCarrier(character, obj);
 }
Beispiel #14
0
 internal bool InvisibleOKObject(CharacterData character, ObjectData obj)
 {
     return !obj.ObjectFlagged(ObjectFlags.Invisible) || character.AffectFlagged(AffectFlags.DetectInvisibility);
 }
Beispiel #15
0
        private bool LoadObjects(XmlDocument file, string filename)
        {
            XmlNodeList list = file.GetElementsByTagName ("ObjectData");

            foreach (XmlNode node in list)
            {
                ObjectData obj = new ObjectData ();
                int virtualNumber = -1;

                try
                {
                    virtualNumber = Int32.Parse (node.Attributes["Number"].Value);
                    obj.Number = _topOfObjectTable;

                    foreach (XmlNode child in node.ChildNodes)
                    {
                        switch (child.Name)
                        {
                            case "Name":
                                obj.Name = child.InnerText;
                                break;

                            case "ShortDescription":
                                obj.ShortDescription = child.InnerText;
                                break;

                            case "Description":
                                obj.Description = child.InnerText;
                                break;

                            case "ActionDescription":
                                obj.ActionDescription = child.InnerText;
                                break;

                            case "ObjectType":
                                obj.Type = (ObjectTypes)int.Parse (child.InnerText);
                                break;

                            case "ObjectFlags":
                                obj.Flags.ObjectFlags = long.Parse (child.InnerText);
                                break;

                            case "WearFlags":
                                obj.Flags.WearFlags = long.Parse (child.InnerText);
                                break;

                            case "Bitvector":
                                obj.Flags.Bitvector = long.Parse (child.InnerText);
                                break;

                            case "Values":
                                obj.Flags.Values[0] = Int32.Parse (child.Attributes["One"].Value);
                                obj.Flags.Values[1] = Int32.Parse (child.Attributes["Two"].Value);
                                obj.Flags.Values[2] = Int32.Parse (child.Attributes["Three"].Value);
                                obj.Flags.Values[3] = Int32.Parse (child.Attributes["Four"].Value);
                                break;

                            case "Weight":
                                obj.Flags.Weight = Int32.Parse (child.InnerText);
                                break;

                            case "Cost":
                                obj.Flags.Cost = Int32.Parse (child.InnerText);
                                break;

                            case "CostPerDay":
                                obj.Flags.CostPerDay = Int32.Parse (child.InnerText);
                                break;

                            case "MinimumLevel":
                                obj.Flags.MinimumLevel = Int32.Parse (child.InnerText);
                                break;

                            case "Affect":
                                ObjectAffectData affect = new ObjectAffectData ();
                                affect.Location = (ApplyTypes)Int32.Parse (child["Location"].InnerText);
                                affect.Modifier = Int32.Parse (child["Modifier"].InnerText);
                                obj.Affects.Add (affect);
                                break;

                            case "ExtraDescription":
                                ExtraDescriptionData description = new ExtraDescriptionData ();
                                description.Keyword = child["Keyword"].InnerText;
                                description.Description = child["Description"].InnerText;
                                obj.ExtraDescriptions.Add (description);
                                break;

                            case "Trigger":
                                // TODO: Add trigger stuff here.
                                break;
                        }
                    }
                }
                catch
                {
                    Log ("SYSERR: Error pasing XML for object [" + virtualNumber + "] in file: " + filename);
                    return false;
                }

                IndexData index = new IndexData ();
                index.VirtualNumber = virtualNumber;
                index.Count = 0;
                _objectIndex.Add (_topOfObjectTable, index);

                _objects.Add (_topOfObjectTable++, obj);
            }

            return true;
        }