public static Task Load() { return(Task.Run(() => { foreach (var portalFile in Directory.GetDirectories("RAW\\Portals\\").SelectMany(Directory.GetFiles)) { using (var reader = new KeyValueFormat(portalFile)) { var obj = new Portal { MapId = reader.Load <ushort>("FromMap"), ToMap = reader.Load <ushort>("ToMap"), ToX = reader.Load <ushort>("ToX"), ToY = reader.Load <ushort>("ToY"), UniqueId = UniqueIdGenerator.GetNext(EntityType.Portal) }; obj.Location.X = reader.Load <ushort>("FromX"); obj.Location.Y = reader.Load <ushort>("FromY"); if (obj.MapId == 0) { continue; } if (GameWorld.Maps.ContainsKey(obj.MapId)) { Portal.Portals.Add(obj.UniqueId, obj); //GameWorld.Maps[obj.MapId].LoadInEntity(obj); } } } })); }
public static Task Load() { return(Task.Run(async() => { short counter = 0; foreach (var mobName in Directory.GetDirectories("RAW\\MonsterSpawns\\").SelectMany(Directory.GetDirectories)) { for (var i = 0; i < Directory.GetFiles(mobName).Length; i++) { var file = Directory.GetFiles(mobName)[i]; using (var reader = new KeyValueFormat(file)) { var spawn = new Spawn { MapId = reader.Load <ushort>("mapid"), MobId = reader.Load <uint>("npctype"), Xstart = reader.Load <ushort>("bound_x"), Ystart = reader.Load <ushort>("bound_y"), Xend = reader.Load <short>("bound_cx"), Yend = reader.Load <short>("bound_cy"), RespawnDelay = reader.Load <ushort>("rest_secs"), Amount = reader.Load <ushort>("max_per_gen") }; if (!Collections.Spawns.ContainsKey(counter)) { Collections.Spawns.TryAdd(counter, spawn); } counter++; } } } await LoadMobs(); })); }
public static void Load() { Collections.Npcs.Clear(); foreach (var file in Directory.EnumerateFileSystemEntries("RAW\\Npcs\\")) { using (var reader = new KeyValueFormat(file)) { var obj = new Npc { UniqueId = reader.Load <int>("id"), Type = reader.Load <byte>("type"), Look = reader.Load <uint>("lookface"), MapId = reader.Load <ushort>("mapid"), Base = reader.Load <byte>("base"), Sort = reader.Load <byte>("sort") }; UniqueIdGenerator.Goto(obj.UniqueId, EntityType.Npc); obj.Location.X = reader.Load <ushort>("cellx"); obj.Location.Y = reader.Load <ushort>("celly"); if (obj.MapId == 0) { continue; } if (GameWorld.Maps.ContainsKey(obj.MapId)) { Collections.Npcs.Add(obj.UniqueId, obj); GameWorld.Maps[obj.MapId].LoadInEntity(obj); } } } DynamicNpcDb.Load(); }
private static Task LoadMobs() { return(Task.Run(async() => { foreach (var file in Directory.EnumerateFileSystemEntries("RAW\\Monsters\\")) { using (var reader = new KeyValueFormat(file)) { var name = reader.Load <string>("name"); var id = reader.Load <uint>("id"); Collections.MonsterNames.AddOrUpdate(id, name); var monster = new Monster { Name = name.Size16(), Id = id, Look = reader.Load <uint>("lookface"), CurrentHp = (ushort)Math.Min(reader.Load <int>("life"), ushort.MaxValue), MaximumHp = (ushort)Math.Min(reader.Load <int>("life"), ushort.MaxValue), MaximumPhsyicalAttack = reader.Load <int>("attack_max"), MinimumPhsyicalAttack = reader.Load <int>("attack_min"), Defense = reader.Load <ushort>("defence"), Dexterity = reader.Load <ushort>("dodge"), AttackRange = reader.Load <byte>("attack_range"), AttackSpeed = reader.Load <int>("attack_speed"), Level = reader.Load <byte>("level"), Drops = new Drops { Money = reader.Load <ushort>("drop_money"), ItemType = (short)reader.Load <int>("drop_itemtype"), Armet = (short)reader.Load <int>("drop_armet"), Necklace = (short)reader.Load <int>("drop_necklace"), Armor = (short)reader.Load <int>("drop_armor"), Ring = (short)reader.Load <int>("drop_ring"), Weapon = (short)reader.Load <int>("drop_weapon"), Shield = (short)reader.Load <int>("drop_shield"), Shoes = (short)reader.Load <int>("drop_shoes"), Hp = reader.Load <int>("drop_hp"), Mp = reader.Load <int>("drop_mp") }, MagicType = (short)reader.Load <int>("magic_type"), MagicDefense = reader.Load <int>("magic_def"), MagicHitRate = (short)reader.Load <int>("magic_hitrate"), }; monster.MaximumPhsyicalAttack += (short)reader.Load <int>("extra_damage"); monster.MinimumPhsyicalAttack += (short)reader.Load <int>("extra_damage"); Collections.BaseMonsters.AddOrUpdate(id, monster); } } await Spawn(); })); }
public static void Load() { var count = 100000; foreach (var file in Directory.EnumerateFileSystemEntries("RAW\\DynNpcs\\")) { using (var reader = new KeyValueFormat(file)) { var map = reader.Load <int>("Map"); if (map > 5000) { continue; } var obj = new DynamicNpc { UniqueId = count, Type = reader.Load <byte>("Action"), Look = reader.Load <uint>("Look"), MapId = reader.Load <ushort>("Map"), MaximumHp = reader.Load <ushort>("HP"), CurrentHp = reader.Load <ushort>("HP"), Base = reader.Load <byte>("Base"), Sort = reader.Load <byte>("Sort"), Defense = reader.Load <ushort>("Defense"), MagicDefense = reader.Load <ushort>("MDefense") }; UniqueIdGenerator.Goto(obj.UniqueId, EntityType.DynamicNpc); obj.Location.X = reader.Load <ushort>("X"); obj.Location.Y = reader.Load <ushort>("Y"); if (obj.MapId == 0) { continue; } if (GameWorld.Maps.ContainsKey(obj.MapId)) { Collections.Npcs.Add(obj.UniqueId, obj); GameWorld.Maps[obj.MapId].LoadInEntity(obj); } count++; } } ShopDb.LoadShops(); }