Ejemplo n.º 1
0
        private void CheckSit(L2Player player)
        {
            if (player.IsCastingNow() || player.CantMove() || player.IsSittingInProgress())
            {
                player.SendActionFailed();
                return;
            }

            if (player.IsSitting())
            {
                player.Stand();
                return;
            }

            int staticId = 0;

            if (player.CurrentTarget is L2Chair)
            {
                L2Chair chair = (L2Chair)player.CurrentTarget;
                if (!chair.IsUsedAlready && (chair.ClanID != -1) && (player.ClanId == chair.ClanID))
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (player.Builder == 1)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (staticId > 0)
                {
                    player.SetChair(chair);
                }
            }

            player.Sit();
        }
Ejemplo n.º 2
0
        private void CheckSit(L2Player player)
        {
            if (!player.CharMovement.CanMove() || player.IsSittingInProgress())
            {
                player.SendActionFailedAsync();
                return;
            }

            if (player.IsSitting())
            {
                player.StandAsync();
                return;
            }

            int staticId = 0;

            if (player.Target is L2Chair)
            {
                L2Chair chair = (L2Chair)player.Target;
                if (!chair.IsUsedAlready)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (player.Builder == 1)
                {
                    double dis = Calcs.CalculateDistance(player, chair, true);
                    if (dis < 150)
                    {
                        staticId = chair.StaticId;
                    }
                }

                if (staticId > 0)
                {
                    player.SetChair(chair);
                }
            }

            player.SitAsync();
        }
Ejemplo n.º 3
0
        public void Initialize()
        {
            Objects = new SortedList <int, L2StaticObject>();
            using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine() ?? string.Empty;
                    if ((line.Length == 0) || line.StartsWithIgnoreCase("#"))
                    {
                        continue;
                    }

                    string[] pt = line.Split('\t');

                    L2StaticObject obj = null;

                    switch (pt[1])
                    {
                    case "map":
                        obj = new L2TownMap();
                        break;

                    case "chair":
                        obj = new L2Chair();
                        break;

                    case "pvp":
                        obj = new L2PvPSign();
                        break;

                    case "door":
                        obj = new L2Door();
                        break;
                    }

                    if (obj == null)
                    {
                        continue;
                    }

                    obj.StaticId = Convert.ToInt32(pt[0]);

                    for (byte ord = 2; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = parameter.Substring(parameter.IndexOf('{') + 1);
                        value = value.Remove(value.Length - 1);

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "spawn":
                            obj.SetLoc(value.Split(' '));
                            break;

                        case "tex":
                            obj.SetTex(value.Split(' '));
                            break;

                        case "htm":
                            obj.Htm = value;
                            break;

                        case "hp":
                            obj.MaxHp = Convert.ToInt32(value);
                            break;

                        case "defence":
                            obj.Pdef = Convert.ToInt32(value.Split(' ')[0]);
                            obj.Mdef = Convert.ToInt32(value.Split(' ')[1]);
                            break;

                        case "unlock":
                        {
                            foreach (string str in value.Split(' '))
                            {
                                switch (str)
                                {
                                case "trigger":
                                    obj.UnlockTrigger = true;
                                    break;

                                case "skill":
                                    obj.UnlockSkill = true;
                                    break;

                                case "drop":
                                    obj.UnlockNpc = true;
                                    break;
                                }
                            }
                        }

                        break;
                        }
                    }

                    Objects.Add(obj.StaticId, obj);
                }
            }

            foreach (L2StaticObject o in Objects.Values)
            {
                L2World.Instance.AddObject(o);
                o.OnSpawn();
            }

            Log.Info($"StaticObjTable: Spanwed {Objects.Count} objects.");
        }
Ejemplo n.º 4
0
        public void read()
        {
            objects = new SortedList <int, L2StaticObject>();
            StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line.Length == 0 || line.StartsWith("#"))
                {
                    continue;
                }

                string[] pt = line.Split('\t');

                L2StaticObject obj = null;

                switch (pt[1])
                {
                case "map":
                    obj = new L2TownMap();
                    break;

                case "chair":
                    obj = new L2Chair();
                    break;

                case "pvp":
                    obj = new L2PvPSign();
                    break;

                case "door":
                    obj = new L2Door();
                    break;
                }

                obj.StaticID = Convert.ToInt32(pt[0]);

                for (byte ord = 2; ord < pt.Length; ord++)
                {
                    string parameter = pt[ord];
                    string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                    switch (parameter.Split('{')[0].ToLower())
                    {
                    case "spawn":
                        obj.setLoc(value.Split(' '));
                        break;

                    case "tex":
                        obj.setTex(value.Split(' '));
                        break;

                    case "htm":
                        obj.htm = value;
                        break;

                    case "hp":
                        obj.MaxHP = Convert.ToInt32(value);
                        break;

                    case "defence":
                        obj.pdef = Convert.ToInt32(value.Split(' ')[0]);
                        obj.mdef = Convert.ToInt32(value.Split(' ')[1]);
                        break;

                    case "unlock":
                    {
                        foreach (string str in value.Split(' '))
                        {
                            switch (str)
                            {
                            case "trigger":
                                obj.UnlockTrigger = true;
                                break;

                            case "skill":
                                obj.UnlockSkill = true;
                                break;

                            case "drop":
                                obj.UnlockNpc = true;
                                break;
                            }
                        }
                    }
                    break;
                    }
                }

                objects.Add(obj.StaticID, obj);
            }
        }