Ejemplo n.º 1
0
        public virtual async Task SpawnMeAsync(bool notifyOthers = true)
        {
            Region = L2World.GetRegion(new Location(X, Y, Z));

            L2World.AddObject(this);
            await OnSpawnAsync(notifyOthers);
        }
Ejemplo n.º 2
0
        public void GenZone()
        {
            zone         = new hideout_zone();
            zone.hideout = this;
            ZoneTemplate template = new ZoneTemplate();

            template.Name = "hideout #" + ID;
            template.Type = ZoneTemplate.ZoneType.hideout;
            template.setRange(zoneLoc);

            zone.Name      = template.Name;
            zone.Template  = template;
            zone.Territory = new ZoneNPoly(template._x, template._y, template._z1, template._z2);

            for (int i = 0; i < template._x.Length; i++)
            {
                L2WorldRegion region = L2World.Instance.GetRegion(template._x[i], template._y[i]);
                if (region != null)
                {
                    // region._zoneManager.addZone(zone);
                }
                else
                {
                    CLogger.error("AreaTable[hideout]: null region at " + template._x[i] + " " + template._y[i] + " for zone " + zone.Name);
                }
            }
        }
Ejemplo n.º 3
0
        public void GenZone()
        {
            ZoneTemplate template = new ZoneTemplate
            {
                Name = $"hideout #{ID}",
                Type = ZoneTemplate.ZoneType.Hideout
            };

            template.SetRange(zoneLoc);

            zone = new hideout_zone
            {
                hideout   = this,
                Name      = template.Name,
                Template  = template,
                Territory = new ZoneNPoly(template.X, template.Y, template.Z1, template.Z2)
            };

            for (int i = 0; i < template.X.Length; i++)
            {
                L2WorldRegion region = L2World.Instance.GetRegion(template.X[i], template.Y[i]);
                if (region != null)
                {
                    // region._zoneManager.addZone(zone);
                }
                else
                {
                    log.Error($"AreaTable[hideout]: null region at {template.X[i]} {template.Y[i]} for zone {zone.Name}");
                }
            }
        }
Ejemplo n.º 4
0
        public override async Task RunImpl()
        {
            L2Player      player  = _client.CurrentPlayer;
            L2WorldRegion prevReg = player.Region;

            int realX = player.X;
            int realY = player.Y;
            int realZ = player.Z;

            int dx = _x - realX;
            int dy = _y - realY;
            int dz = _z - realZ;

            double diffSq = Math.Sqrt(dx * dx + dy * dy);

            player.SendMessageAsync($"diff: {(int) diffSq}");

            player.Movement.UpdatePosition(_x, _y, _z);

            if (diffSq > 600)
            {
                Log.Error($"User {player.ObjectId}:{player.Account.Login}:{player.Name} coord is unsync with server");
                // TODO: Add teleport back
            }

            L2World.UpdateRegion(player);

            //Log.Info($"Current client position: X:{_x}, Y:{_y}, Z:{_z}"); //debug
            player.BroadcastUserInfoAsync();
        }
Ejemplo n.º 5
0
        public virtual void SpawnMe(bool notifyOthers = true)
        {
            Region = L2World.Instance.GetRegion(new Location(X, Y, Z));

            L2World.Instance.AddObject(this);
            OnSpawn(notifyOthers);
        }
Ejemplo n.º 6
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player       = _client.CurrentPlayer;
                L2WorldRegion prevReg = player.Region;

                int realX = player.X;
                int realY = player.Y;
                int realZ = player.Z;

                int dx        = _x - realX;
                int dy        = _y - realY;
                int dz        = _z - realZ;
                double diffSq = (dx * dx) + (dy * dy);

                if (diffSq < 360000)
                {
                    if (!player.IsMoving())
                    {
                        if (diffSq < 2500)
                        {
                            player.X = realX;
                            player.Y = realY;
                            player.Z = _z;
                        }
                        else
                        {
                            player.X = _x;
                            player.Y = _y;
                            player.Z = _z;
                        }
                    }
                }
                else
                {
                    player.X       = realX;
                    player.Y       = realY;
                    player.Z       = _z;
                    player.Heading = _heading;
                }
                L2WorldRegion NewRegion = L2World.Instance.GetRegion(new Location(player.X, player.Y, player.Z));
                if (prevReg != NewRegion)
                {
                    player.SetRegion(NewRegion);
                    player.SetupKnowsAsync();

                    //Add objects from surrounding regions into knows, this is a hack to prevent
                    //objects from popping into view as soon as you enter a new region
                    //TODO: Proper region transition
                    player.SetupKnowsAsync(NewRegion);
                }
                //Log.Info($"Current client position: X:{_x}, Y:{_y}, Z:{_z}"); //debug
                player.BroadcastUserInfoAsync();
                player.ValidateVisibleObjects(_x, _y, true);
            });
        }
Ejemplo n.º 7
0
        public virtual void SetRegion(L2WorldRegion newRegion)
        {
            List <L2WorldRegion> oldAreas = new List <L2WorldRegion>();

            if (Region != null)
            {
                Region.RemoveVisibleObject(this);
                oldAreas = Region.GetSurroundingRegions();
            }

            List <L2WorldRegion> newAreas = new List <L2WorldRegion>();

            if (newRegion != null)
            {
                newRegion.AddVisibleObject(this);
                newAreas = newRegion.GetSurroundingRegions();
            }

            foreach (L2WorldRegion region in oldAreas.Where(region => !newAreas.Contains(region)))
            {
                foreach (L2Object obj in region.GetObjects().Where(obj => obj != this))
                {
                    obj.RemoveKnownObject(this);
                    RemoveKnownObject(obj);
                }

                if (this is L2Player && region.IsEmptyNeighborhood())
                {
                    region.SetActive(false);
                }
            }

            foreach (L2WorldRegion region in newAreas.Where(region => !oldAreas.Contains(region)))
            {
                // Update all objects.
                foreach (L2Object obj in region.GetObjects().Where(obj => obj != this))
                {
                    obj.AddKnownObject(this);
                    AddKnownObject(obj);
                }

                // Activate the new neighbor region.
                if (this is L2Player)
                {
                    region.SetActive(true);
                }
            }

            Region = newRegion;
        }
Ejemplo n.º 8
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;

                switch (_command)
                {
                case 0:            // [loc]
                    int regId = 0; //MapRegionTable.getInstance().getRegionSysId(player.X, player.Y);
                    if (regId > 0)
                    {
                        player.SendPacketAsync(new SystemMessage((SystemMessageId)regId).AddNumber(player.X).AddNumber(player.Y).AddNumber(player.Z));
                    }
                    else
                    {
                        player.SendPacketAsync(new SystemMessage(SystemMessageId.NotImplementedYet2361).AddString("Nowhere"));
                    }

                    int x = (player.X >> 15) + 9 + 8;
                    int y = (player.Y >> 15) + 10 + 11;
                    player.SendMessageAsync($"Current loc is X:{player.X} Y:{player.Y} Z:{player.Z}");
                    player.BroadcastUserInfoAsync();     //for debug reasons
                    break;

                case 52:     // /unstuck

                    L2WorldRegion worldRegion = L2World.GetRegion(player.X, player.Y);
                    player.SetRegion(worldRegion);
                    List <L2Player> knowns = player.GetKnownPlayers();
                    //player.SpawnMeAsync();
                    player.SendMessageAsync("Unstuck not implemented yet.");
                    //player.knownObjects;
                    break;

                case 62:     // /dismount
                    player.SendMessageAsync("Dismount not implemented yet.");
                    break;

                case 77:     // [time]
                    GameTime.ShowInfoAsync(player);
                    break;

                default:
                    player.SendMessageAsync($"cmd alias {_command}");
                    break;
                }
            });
        }
Ejemplo n.º 9
0
        public override void SetRegion(L2WorldRegion newRegion)
        {
            // confirm revalidation of old region's zones
            if (Region != null)
            {
                if (newRegion != null)
                {
                    Region.RevalidateZones(this);
                }
                else
                {
                    Region.RemoveFromZones(this);
                }
            }

            base.SetRegion(newRegion);
        }
Ejemplo n.º 10
0
        private void DesctructTime(object sender, ElapsedEventArgs e)
        {
            _selfDestruct.Enabled = false;

            NpcCenter.DecayMe();

            foreach (L2Object o in ObjectsInside.Values)
                OnExit(o, false);

            ObjectsInside.Clear();

            L2WorldRegion region = L2World.Instance.GetRegion(CylinderCenter[0], CylinderCenter[1]);
            if (region != null)
            {
                // region._zoneManager.remZone(this);
            }
        }
Ejemplo n.º 11
0
        public virtual List <L2Player> GetKnownPlayers(bool excludeSelf = true)
        {
            L2WorldRegion region = Region;

            if (region == null)
            {
                return(new List <L2Player>());
            }

            List <L2Player> result = new List <L2Player>();

            if (excludeSelf)
            {
                region.GetSurroundingRegions().ForEach(reg => result.AddRange(L2World.GetPlayers().Where(obj => obj != this)));
            }
            else
            {
                region.GetSurroundingRegions().ForEach(reg => result.AddRange(L2World.GetPlayers()));
            }
            return(result);
        }
Ejemplo n.º 12
0
        public override async Task RunImpl()
        {
            L2Player      player  = _client.CurrentPlayer;
            L2WorldRegion prevReg = player.Region;

            int realX = player.X;
            int realY = player.Y;
            int realZ = player.Z;

            int dx = _x - realX;
            int dy = _y - realY;
            int dz = _z - realZ;

            double diffSq = Math.Sqrt(dx * dx + dy * dy);

            player.SendMessageAsync($"diff: {(int) diffSq}");

            player.CharMovement.UpdatePosition(_x, _y, _z);

            if (diffSq > 600)
            {
                Log.Error($"User {player.ObjectId}:{player.Account.Login}:{player.Name} coord is unsync with server");
            }

            L2WorldRegion NewRegion = L2World.GetRegion(new Location(player.X, player.Y, player.Z));

            if (prevReg != NewRegion)
            {
                player.SetRegion(NewRegion);
                player.SetupKnowsAsync();

                //Add objects from surrounding regions into knows, this is a hack to prevent
                //objects from popping into view as soon as you enter a new region
                //TODO: Proper region transition
                player.SetupKnowsAsync(NewRegion);
            }
            //Log.Info($"Current client position: X:{_x}, Y:{_y}, Z:{_z}"); //debug
            player.BroadcastUserInfoAsync();
            player.ValidateVisibleObjects(realX, realY, true);
        }
Ejemplo n.º 13
0
        //public virtual void ReduceHp(L2Character attacker, double damage) { }

        public virtual void DecayMe()
        {
            Region = null;

            L2World.RemoveObject(this);
        }
Ejemplo n.º 14
0
        public ZoneTable()
        {
            int          ctx = 0, cta = 0;
            StreamReader reader = new StreamReader(new FileInfo(@"scripts\areadata_cur.txt").FullName);

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

                if (line.StartsWith("//"))
                {
                    continue;
                }

                if (line.StartsWith("area_begin"))
                {
                    L2Zone       zone     = null;
                    ZoneTemplate template = new ZoneTemplate();
                    string[]     d        = line.Split('\t');

                    for (int i = 1; i < d.Length; i++)
                    {
                        if (d[i].Equals("area_end"))
                        {
                            continue;
                        }

                        string param = d[i].Split('=')[0];
                        string val   = d[i].Substring(param.Length + 1);

                        switch (param)
                        {
                        case "name":
                            template.Name = val;
                            break;

                        case "map_no":
                            template._map_no = val;
                            break;

                        case "type":
                        {
                            template.Type = (ZoneTemplate.ZoneType)Enum.Parse(typeof(ZoneTemplate.ZoneType), val);

                            switch (template.Type)
                            {
                            case ZoneTemplate.ZoneType.battle_zone:
                                zone = new battle_zone();
                                break;

                            case ZoneTemplate.ZoneType.peace_zone:
                                zone = new peace_zone();
                                break;

                            case ZoneTemplate.ZoneType.water:
                                zone = new water();
                                break;

                            case ZoneTemplate.ZoneType.no_restart:
                                zone = new no_restart();
                                break;

                            case ZoneTemplate.ZoneType.ssq_zone:
                                zone = new ssq_zone();
                                break;

                            case ZoneTemplate.ZoneType.mother_tree:
                                zone = new mother_tree();
                                template._hp_regen_bonus = 2;
                                template._mp_regen_bonus = 1;
                                break;

                            case ZoneTemplate.ZoneType.damage:
                                zone = new damage();
                                template._damage_on_hp = 200;
                                template._damage_on_mp = 0;
                                break;

                            case ZoneTemplate.ZoneType.poison:
                                zone = new poison();
                                template.setSkill("s_area_a_speed_down");
                                break;

                            case ZoneTemplate.ZoneType.swamp:
                                zone = new swamp();
                                template._move_bonus = -50;
                                break;

                            case ZoneTemplate.ZoneType.instant_skill:
                                zone = new instant_skill();
                                break;
                            }
                        }
                        break;

                        case "affect_race":
                            template._affect_race = val;
                            break;

                        case "entering_message_no":
                            template._entering_message_no = int.Parse(val);
                            break;

                        case "leaving_message_no":
                            template._leaving_message_no = int.Parse(val);
                            break;

                        case "range":
                            template.setRange(val);
                            break;

                        case "move_bonus":
                            template._move_bonus = int.Parse(val);
                            break;

                        case "default_status":
                            template.DefaultStatus = val.Equals("on");
                            break;

                        case "event_id":
                            template._event_id = int.Parse(val);
                            break;

                        case "damage_on_hp":
                            template._damage_on_hp = int.Parse(val);
                            break;

                        case "damage_on_mp":
                            template._damage_on_mp = int.Parse(val);
                            break;

                        case "message_no":
                            template._message_no = int.Parse(val);
                            break;

                        case "target":
                            template._target = (ZoneTemplate.ZoneTarget)Enum.Parse(typeof(ZoneTemplate.ZoneTarget), val);
                            break;

                        case "skill_prob":
                            template._skill_prob = int.Parse(val);
                            break;

                        case "unit_tick":
                            template._unit_tick = int.Parse(val);
                            break;

                        case "initial_delay":
                            template._initial_delay = int.Parse(val);
                            break;

                        case "skill_list":
                            template.setSkillList(val);
                            break;

                        case "skill_name":
                            template.setSkill(val.Substring(1).Replace("]", ""));
                            break;

                        case "exp_penalty_per":
                            template._exp_penalty_per = int.Parse(val);
                            break;

                        case "item_drop":
                            template._item_drop = val.Equals("on");
                            break;
                        }
                    }
                    zone.Name      = template.Name;
                    zone.Template  = template;
                    zone.Territory = new ZoneNPoly(template._x, template._y, template._z1, template._z2);
                    cta++;
                    for (int i = 0; i < template._x.Length; i++)
                    {
                        L2WorldRegion region = L2World.Instance.GetRegion(template._x[i], template._y[i]);
                        if (region != null)
                        {
                            ctx++;
                            // region._zoneManager.addZone(zone);
                        }
                        else
                        {
                            CLogger.error("AreaTable: null region at " + template._x[i] + " " + template._y[i] + " for zone " + zone.Name);
                        }
                    }
                }
            }

            CLogger.info("AreaTable: intercepted " + ctx + " regions with " + cta + " zones");
        }