Beispiel #1
0
        protected internal override async Task UseAsync(L2Player admin, string alias)
        {
            await Task.Run(() =>
            {
                var processedVar    = alias.Replace("spawn", string.Empty).Trim();
                NpcTemplate npcTemp = null;

                int potentialInt;
                if (int.TryParse(processedVar, out potentialInt))
                {
                    npcTemp = NpcTable.GetTemplate(potentialInt);
                }
                else
                {
                    npcTemp = NpcTable.GetTemplateByName(processedVar);
                }
                if (npcTemp == null)
                {
                    throw new NullReferenceException($"npcTemp is null for {processedVar}");
                }

                L2Spawn spawn  = new L2Spawn(npcTemp, _idFactory, _spawnTable);
                spawn.Location = new SpawnLocation(admin.X, admin.Y, admin.Z, admin.Heading, 0);
                spawn.Spawn();
            });
        }
        internal void SetNpc(int id)
        {
            if (npcs == null)
            {
                npcs = new SortedList <int, L2Citizen>();
            }

            NpcTemplate t   = NpcTable.getInstance().getNpcTemplate(id);
            L2Citizen   npc = null;

            switch (t.NpcId)
            {
            case 35461:
                npc = new L2HideoutManager(this);
                break;

            case 35462:
                npc = new L2Doormen(this);
                break;
            }

            npc.setTemplate(t);

            StructureSpawn ss = StructureTable.getInstance().getSpawn(id);

            npc.X       = ss.x;
            npc.Y       = ss.y;
            npc.Z       = ss.z;
            npc.Heading = ss.heading;

            npcs.Add(t.NpcId, npc);
        }
        public void LoadTables()
        {
            npcTable = LoadData <NpcTable>("Tables/NpcTable.bytes");
            npcTable.Initialize();
            objectPoolTable = LoadData <ObjectPoolTable>("Tables/ObjectPoolTable.bytes");
            objectPoolTable.Initialize();
///[APPEND_TABLE]
        }
Beispiel #4
0
        public async void Start()
        {
            Config.Config config = ServiceProvider.GetService <Config.Config>();
            await config.Initialise();

            await ServiceProvider.GetService <PreReqValidation>().Initialise();

            CharTemplateTable.Initialize();

            // TODO: refactor NetworkBlock
            NetworkBlock.Instance.Initialize();
            GameTime.Initialize();

            await ServiceProvider.GetService <IdFactory>().Initialise();

            L2World.Initialize();

            MapRegionTable.Initialize();
            ZoneTable.Initialize();

            await ServiceProvider.GetService <ItemTable>().Initialise();

            ItemHandler.Initialize();

            NpcTable.Initialize();
            Capsule.Initialize();
            AttackStanceManager.Initialize();
            BlowFishKeygen.GenerateKeys();

            await ServiceProvider.GetService <IAdminCommandHandler>().Initialise();

            await ServiceProvider.GetService <AnnouncementManager>().Initialise();

            StaticObjTable.Initialize();
            await ServiceProvider.GetService <SpawnTable>().Initialise();

            await ServiceProvider.GetService <HtmCache>().Initialise();

            // TODO: review plugin system
            //PluginManager.Instance.Initialize(this);

            ServiceProvider.GetService <AuthThread>().Initialise();

            _listener = new TcpListener(IPAddress.Any, config.ServerConfig.Port);

            try
            {
                _listener.Start();
            }
            catch (SocketException ex)
            {
                Log.Halt($"Socket Error: '{ex.SocketErrorCode}'. Message: '{ex.Message}' (Error Code: '{ex.NativeErrorCode}')");
            }

            Log.Info($"Listening Gameservers on port {config.ServerConfig.Port}");

            Task.Factory.StartNew(WaitForClients);
        }
Beispiel #5
0
 public MonsterRunner(int npcId, int sys_string, int max_speed, int min_speed)
 {
     this.npcId       = npcId;
     this.npcTemplate = NpcTable.getInstance().getNpcTemplate(npcId);
     this.sys_string  = sys_string;
     this.max_speed   = max_speed;
     this.min_speed   = min_speed;
     this.id          = IdFactory.Instance.nextId();
 }
Beispiel #6
0
        public override TEffectResult onStart(world.L2Character caster, world.L2Character target)
        {
            L2Summon summon = new L2Summon();

            summon.setTemplate(NpcTable.getInstance().getNpcTemplate(npcId));
            summon.setOwner((L2Player)caster);
            summon.SpawmMe();

            return(nothing);
        }
 static int Initialize(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         NpcTable obj = (NpcTable)ToLua.CheckObject <NpcTable>(L, 1);
         obj.Initialize();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #8
0
        public void LoadTables()
        {
            globalConfigTable = LoadData <GlobalConfigTable>("Tables/GlobalConfigTable.bytes");
            globalConfigTable.Initialize();
            itemTable = LoadData <ItemTable>("Tables/ItemTable.bytes");
            itemTable.Initialize();
            npcTable = LoadData <NpcTable>("Tables/NpcTable.bytes");
            npcTable.Initialize();
            objectPoolTable = LoadData <ObjectPoolTable>("Tables/ObjectPoolTable.bytes");
            objectPoolTable.Initialize();
            qualityTable = LoadData <QualityTable>("Tables/QualityTable.bytes");
            qualityTable.Initialize();
///[APPEND_TABLE]
        }
 static int AddItem(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         NpcTable     obj  = (NpcTable)ToLua.CheckObject <NpcTable>(L, 1);
         NpcTableItem arg0 = (NpcTableItem)ToLua.CheckObject <NpcTableItem>(L, 2);
         obj.AddItem(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #10
0
 static int GetItems(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         NpcTable obj = (NpcTable)ToLua.CheckObject <NpcTable>(L, 1);
         System.Collections.Generic.List <NpcTableItem> o = obj.GetItems();
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        public override void UsePet(L2Pet pet, L2Item item)
        {
            if (!Pet)
            {
                base.UsePet(pet, item);
                return;
            }

            calcSkill(pet);
            calcEffect(pet);

            if (SummonStaticID != -1)
            {
                NpcTable.getInstance().spawnNpc(SummonStaticID, pet.X, pet.Y, pet.Z, pet.Heading);
            }
        }
Beispiel #12
0
 static int GetItemByKey(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         NpcTable     obj  = (NpcTable)ToLua.CheckObject <NpcTable>(L, 1);
         int          arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         NpcTableItem o    = obj.GetItemByKey(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #13
0
    static int get_name(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            NpcTable obj = (NpcTable)o;
            string   ret = obj.name;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index name on a nil value"));
        }
    }
Beispiel #14
0
    static int set_name(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            NpcTable obj  = (NpcTable)o;
            string   arg0 = ToLua.CheckString(L, 2);
            obj.name = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index name on a nil value"));
        }
    }
Beispiel #15
0
    static int get_Items(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            NpcTable obj = (NpcTable)o;
            System.Collections.Generic.List <NpcTableItem> ret = obj.Items;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Items on a nil value"));
        }
    }
    static int set_npcTable(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TableManager obj  = (TableManager)o;
            NpcTable     arg0 = (NpcTable)ToLua.CheckObject <NpcTable>(L, 2);
            obj.npcTable = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index npcTable on a nil value"));
        }
    }
    static int get_npcTable(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TableManager obj = (TableManager)o;
            NpcTable     ret = obj.npcTable;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index npcTable on a nil value"));
        }
    }
Beispiel #18
0
        private void GenNpc()
        {
            NpcTemplate nt = NpcTable.getInstance().getNpcTemplate(30995);

            raceManager1 = new L2RaceManager();
            raceManager1.setTemplate(nt);
            raceManager1.X       = 13691;
            raceManager1.Y       = 182627;
            raceManager1.Z       = -3561;
            raceManager1.Heading = 49152;

            raceManager2 = new L2RaceManager();
            raceManager2.setTemplate(nt);
            raceManager2.X       = 12962;
            raceManager2.Y       = 181603;
            raceManager2.Z       = -3561;
            raceManager2.Heading = 16384;
        }
        public virtual void onTransformStart(L2Player player)
        {
            player.TransformID     = id;
            player.MountType       = MoveMode;
            player.MountedTemplate = NpcTable.getInstance().getNpcTemplate(npcId);
            player.broadcastUserInfo();

            if (_skills != null && _skills.Count > 0)
            {
                foreach (int[] s in _skills)
                {
                    TSkill sk = TSkillTable.getInstance().get(s[0], s[1]);
                    if (sk != null)
                    {
                        player.addSkill(sk, false, false);
                    }
                }

                player.updateSkillList();
            }
        }
        public override void UsePlayer(L2Player player, L2Item item)
        {
            if (!Player)
            {
                base.UsePlayer(player, item);
                return;
            }

            if (Destroy)
            {
                player.Inventory.destroyItem(item, 1, true, true);
            }

            calcSkill(player);
            calcEffect(player);

            if (ExchangeItems != null)
            {
                foreach (int id in ExchangeItems.Keys)
                {
                    player.Inventory.addItem(id, ExchangeItems[id], true, true);
                }
            }

            if (PetID != -1)
            {
                player.PetSummon(item, PetID);
            }

            if (SummonID != -1)
            {
                player.PetSummon(item, SummonID, false);
            }

            if (SummonStaticID != -1)
            {
                NpcTable.getInstance().spawnNpc(SummonStaticID, player.X, player.Y, player.Z, player.Heading);
            }
        }
Beispiel #21
0
    static int _CreateNpcTable(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                NpcTable obj = new NpcTable();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: NpcTable.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #22
0
        public void Start()
        {
            Console.Title = "L2dotNET Gameserver";

            CLogger.form();
            Cfg.init("all");

            CharTemplateTable.Instance.Initialize();

            NetworkBlock.getInstance();
            GameTime.getInstance();

            IdFactory.Instance.Initialize();

            L2World.Instance.Initialize();

            // MapRegionTable.getInstance();
            ZoneTable.getInstance();

            NpcTable.getInstance();
            NpcData.getInstance();
            //  SpawnTable.getInstance();
            StaticObjTable.getInstance().read();
            StructureTable.getInstance().read();
            //  TSkillTable.getInstance();
            ItemTable.getInstance();
            ItemHandler.getInstance();
            MultiSell.getInstance();
            Capsule.getInstance();
            RecipeTable.getInstance();

            MonsterRace.getInstance();

            AIManager.getInstance();


            BlowFishKeygen.genKey();
            CLogger.info("generated 20 blowfish keys");

            AdminAccess.Instance.Initialize();;

            QuestManager.getInstance();

            AnnouncementManager.Instance.Initialize();

            AllianceTable.getInstance();
            ClanTable.getInstance();

            CLogger.info("NpcServer: ");
            StaticObjTable.getInstance().Spawn();
            MonsterRace.getInstance().Spawn();
            //  SpawnTable.getInstance().Spawn();
            StructureTable.getInstance().init();

            HtmCache.getInstance();

            AuthThread.getInstance();

            //   GeoData.getInstance();

            CLogger.extra_info("listening game clients on port " + Cfg.SERVER_PORT);
            _listener = new TcpListener(Cfg.SERVER_PORT);
            _listener.Start();

            TcpClient clientSocket = default(TcpClient);

            while (true)
            {
                clientSocket = _listener.AcceptTcpClient();
                accept(clientSocket);
            }
        }
Beispiel #23
0
 protected internal override void use(L2Player admin, string alias)
 {
     NpcTable.getInstance().spawnNpc(Convert.ToInt32(alias.Split(' ')[1]), admin.X, admin.Y, admin.Z, admin.Heading);
 }
Beispiel #24
0
        protected internal override void use(L2Player admin, string alias)
        {
            //  double dis = Calcs.calculateDistance(admin, admin._currentTarget, true);
            //  admin.sendMessage("dis "+dis);

            //  foreach (L2SkillCoolTime ct in admin._reuse.Values)
            //  {
            //      ct.forcedStop();
            //  }
            //  admin._reuse.Clear();
            //  admin.updateReuse();

            string s = alias.Split(' ')[1];

            if (s == "1")
            {
                admin.AbnormalBitMaskEvent = int.Parse(alias.Split(' ')[2]);
                admin.updateAbnormalEventEffect();
            }
            else if (s == "2")
            {
                int listid = int.Parse(alias.Split(' ')[2]);
                MultiSell.getInstance().showList(admin, null, listid);
            }
            else if (s == "4")
            {
                FortressOfTheDead d = new FortressOfTheDead();
                d.start();
            }
            else if (s == "5")
            {
                if (np == null)
                {
                    int[] x = new int[] { -81166, -80913, -81952, -82554 };
                    int[] y = new int[] { 245118, 246031, 246551, 245619 };
                    np = new ZoneNPoly(x, y, -3727, -3727);
                }

                int count = int.Parse(alias.Split(' ')[2]);

                for (int i = 0; i < count; i++)
                {
                    int[] rloc = this.rndXYZ();
                    // NpcTable.getInstance().spawnNpc("lector", rloc[0], rloc[1], rloc[3], new Random().Next(65000));
                }
            }
            else if (s == "6")
            {
                L2Citizen npc = (L2Citizen)admin.CurrentTarget;
                if (npc.Template.DropData == null)
                {
                    admin.sendMessage("no drops at this npc");
                }
                else
                {
                    npc.Template.DropData.showInfo(admin);
                }
            }
            else if (s == "7")
            {
                L2Citizen npc = (L2Citizen)admin.CurrentTarget;
                if (npc.Template.DropData == null)
                {
                    admin.sendMessage("no drops at this npc");
                }
                else
                {
                    npc.Template.roll_drops(npc, admin);
                }
            }
            else if (s == "8")
            {
                L2Citizen npc = (L2Citizen)admin.CurrentTarget;
                if (npc.Template.DropData == null)
                {
                    admin.sendMessage("no drops at this npc");
                }
                else
                {
                    npc.doDie(admin, false);
                    npc.Template.roll_drops(npc, admin);
                }
            }
            else if (s == "9")
            {
                admin.destx = admin.X + 200;
                admin.desty = admin.Y + 200;
                admin.destz = admin.Z;
                admin.sendPacket(new CharMoveToLocation(admin));
            }
            else if (s == "10")
            {
                InstanceManager.getInstance().create(1, admin);
            }
            else if (s == "11")
            {
                admin.Boat.destx   = -121385;
                admin.Boat.desty   = 261660;
                admin.Boat.destz   = -3610;
                admin.Boat.OnRoute = true;
                admin.Boat.broadcastPacket(new VehicleStarted(admin.Boat.ObjID, 1));
                admin.Boat.broadcastPacket(new VehicleDeparture(admin.Boat, 400, 1800));
            }
            else if (s == "12")
            {
                L2Boat boat = new L2Boat();
                boat.X = -96622;
                boat.Y = 261660;
                boat.Z = -3610;

                L2World.Instance.RealiseEntry(boat, null, true);
                boat.onSpawn();
            }
            else if (s == "13")
            {
                MonsterRace.getInstance().startRace();
            }
            else if (s == "17")
            {
                admin.Mount(NpcTable.getInstance().getNpcTemplate(13146));
            }
            else if (s == "18")
            {
                int count = int.Parse(alias.Split(' ')[2]);
                TransformManager.getInstance().transformTo(count, admin, 30);
            }
            else if (s == "19")
            {
                admin.sstt = int.Parse(alias.Split(' ')[2]);
                admin.broadcastUserInfo();
            }
            else if (s == "20")
            {
                int sx = int.Parse(alias.Split(' ')[2]);
                admin.broadcastPacket(new MagicSkillUse(admin, admin, sx, 1, 0));
            }
            else if (s == "21")
            {
                int sx = int.Parse(alias.Split(' ')[2]);
                admin.broadcastPacket(new MagicSkillUse(admin, admin, 261, 1, 1000, sx));
                adm = admin;
                if (t == null)
                {
                    t          = new System.Timers.Timer();
                    t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
                }

                t.Interval = 900;
                t.Enabled  = true;
            }
            else if (s == "22")
            {
                adm = admin;
                L2Warrior war = (L2Warrior)NpcTable.getInstance().spawnNpc(21003, 14107, 182287, -3586, 32500);

                war.destx = 13107;
                war.desty = 182287;
                war.destz = -3586;
                admin.sendPacket(new CharMoveToLocation(war));
                war.dtstart = DateTime.Now;
                admin.ChangeTarget(war);

                if (t == null)
                {
                    t          = new System.Timers.Timer();
                    t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
                }

                t.Interval = 2000 * 12;
                t.Enabled  = true;
            }
            // admin._privateStoreType = byte.Parse(alias.Split(' ')[1]);
            // admin.broadcastUserInfo();


            // int val = int.Parse(alias.Split(' ')[1]);

            //  StatusUpdate su = new StatusUpdate(admin);
            //  su.add(val, 5000);
            //  admin.sendPacket(su);
        }