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

            L2World.AddObject(this);
            await OnSpawnAsync(notifyOthers);
        }
Exemple #2
0
        public override async Task Restore(L2Character owner)
        {
            IEnumerable <ItemContract> models = await _itemService.RestoreInventory(owner.ObjectId);

            List <L2Item> items = RestoreFromDb(models.ToList());

            foreach (L2Item item in items)
            {
                L2World.AddObject(item);
                Owner = owner;
                AddItem(item, (L2Player)Owner);
            }
        }
Exemple #3
0
        public L2Item CreateItem(int itemId, int count, L2Player actor)
        {
            L2Item item = new L2Item(_itemCrudService, _idFactory, GetItem(itemId), _idFactory.NextId());

            L2World.AddObject(item);

            if (item.Template.Stackable && count > 1)
            {
                item.Count = count;
            }

            return(item);
        }
Exemple #4
0
        public void DropMe(int x, int y, int z, L2Character dropper, L2Character killer, int seconds)
        {
            X = x;
            Y = y;
            Z = z;
            DropItem pk = new DropItem(this);

            if (dropper != null)
            {
                Dropper = dropper.ObjectId;
            }

            Location = ItemLocation.Void;

            killer?.AddKnownObject(this, pk, true);

            L2World.AddObject(this);
        }
Exemple #5
0
 public virtual async Task SpawnMeAsync(bool notifyOthers = true)
 {
     L2World.AddObject(this);
     await OnSpawnAsync();
 }
Exemple #6
0
        public static void Initialize()
        {
            Objects = new Dictionary <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;
                    //TODO: Implement this
                    switch (pt[1])
                    {
                    case "map":
                        // obj = new L2TownMap(IdFactory.Instance.NextId(),null);
                        break;

                    case "chair":
                        // obj = new L2Chair(IdFactory.Instance.NextId(), null);
                        break;

                    case "pvp":
                        //obj = new L2PvPSign(IdFactory.Instance.NextId(), null);
                        break;

                    case "door":
                        //obj = new L2Door(IdFactory.Instance.NextId(), null);
                        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.CharacterStat = new CharacterStat(obj);
                            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.AddObject(o);
                o.OnSpawnAsync();
            }

            Log.Info($"Spawned {Objects.Count} objects.");
        }