public Npc(NpcSpawnRecord spawnRecord) { this.SpawnRecord = spawnRecord; this.ActionsRecord = NpcActionRecord.GetActions(SpawnRecord.Id); this.Map = MapRecord.GetMap(spawnRecord.MapId); this.m_Id = this.Map.Instance.PopNextNPEntityId(); }
public static void CreateInstances() { UpdateLogger updateLogger = new UpdateLogger(); int num = 0; foreach (var record in Maps) { record.InteractiveElements = InteractiveElementRecord.GetActiveElementsOnMap(record.Id); record.Position = MapPositionRecord.GetMapPosition(record.Id); record.MonsterSpawnsSubArea = MonsterSpawnRecord.GetSpawns(record.SubAreaId).ToArray(); record.NpcsRecord = NpcSpawnRecord.GetMapNpcs(record.Id).ToArray(); record.Instance = new MapInstance(record); NpcSpawnsManager.Instance.SpawnAtStartup(record); if (record.AbleToSpawn) { MonsterSpawnManager.Instance.SpawnMonsters(record); } updateLogger.Update(num.Percentage(Maps.Count)); num++; } }
public NpcSpawnRecord Spawn(ushort npcId, MapRecord record, ushort cellId, sbyte direction) { var spawnRecord = NpcSpawnRecord.AddNpc(npcId, record.Id, cellId, direction); record.Instance.AddNpc(spawnRecord, false); return(spawnRecord); }
public static void HandleNpcGenericAction(NpcGenericActionRequestMessage message, WorldClient client) { NpcSpawnRecord record = NpcSpawnRecord.GetNpcByContextualId(message.npcId); if (record != null) { NpcsActionsProvider.Handle(client, record, message.npcActionId); } }
public static void NpcsInfo(WorldClient client, string[] args) { List <NpcSpawnRecord> spawnRecords = NpcSpawnRecord.GetMapNpcs(client.Character.Map.Id); client.Character.Reply("Npcs on map:"); foreach (NpcSpawnRecord spawnRecord in spawnRecords) { client.Character.Reply($" - {spawnRecord.Template.Name}: Id={spawnRecord.TemplateId}, SpawnId={spawnRecord.Id}"); } }
public NpcBuySellExchange(WorldClient client, NpcActionsRecord action, NpcSpawnRecord npc) { this.Action = action; this.Client = client; this.Items = Action.OptionalValue1.ToSplitedList <short>().ConvertAll <ItemRecord>( x => ItemRecord.GetItem(x)); this.Items.RemoveAll(x => x.IsNull()); this.Npc = npc; this.TokenId = ushort.Parse(action.OptionalValue2); }
public void AddNpc(NpcSpawnRecord npcRecord, bool quiet) { Npc entity = new Npc(npcRecord); if (quiet) { AddQuietEntity(entity); } else { AddEntity(entity); } }
static void Talk(WorldClient client, NpcSpawnRecord npc, NpcActionsRecord action) { if (action == null) { client.Character.Reply("Ce PNJ n'est pas apte a parler."); return; } ushort messageId = ushort.Parse(action.OptionalValue1); List <NpcReplyRecord> replies = NpcsRepliesProvider.GetPossibleReply(client, NpcReplyRecord.GetNpcReplies(messageId)); client.Character.CurrentDialogType = DialogTypeEnum.DIALOG_DIALOG; client.Send(new NpcDialogCreationMessage(npc.MapId, -npc.Id)); client.Send(new NpcDialogQuestionMessage(messageId, new string[] { "0" }, replies.ConvertAll <ushort>(x => (ushort)x.ReplyId))); }
static void Sell(WorldClient client, NpcSpawnRecord npc, NpcActionsRecord action) { if (client.Character.BidShopInstance != null) { client.Character.BidShopInstance.OpenSellPanel(); return; } var bidshop = BidShopRecord.GetBidShop(int.Parse(action.OptionalValue1)); if (bidshop != null) { client.Character.BidShopInstance = new BidShopExchange(client, bidshop.GetDescriptor(npc.Id), bidshop.Id); client.Character.BidShopInstance.OpenSellPanel(); } else { client.Character.Reply("Cet hotel de vente n'est pas encore disponible!"); } }
public static void Handle(WorldClient client, NpcSpawnRecord npc, sbyte clientnpcactionid) { var actionType = (NpcActionTypeEnum)clientnpcactionid; var handler = NpcActions.FirstOrDefault(x => x.Key == actionType); if (handler.Value != null) { var action = NpcActionsRecord.GetNpcAction(npc.Id, actionType); if (action != null) { handler.Value(client, npc, action); } else { client.Character.NotificationError("Unable to find npc action record (" + clientnpcactionid + ") for Npc " + npc.Id); } } else { client.Character.NotificationError("Unable to find npc generic action handler (" + clientnpcactionid + ") for Npc " + npc.Id); } }
public static void SpawnNpc(WorldClient client, string[] args) { if (args.Length < 2) { client.Character.Reply("Spawn an NPC on the map. The NPC will have the same direction as you."); client.Character.Reply(".npc spawn|s $NpcId [$CellId]"); client.Character.Reply(" - $NpcId ⇒ ID of the NPC you want to spawn."); client.Character.Reply(" - $CellId ⇒ (Opt) The targett cell. Default is your current cell."); return; } Character ch = client.Character; ushort npcId = ushort.Parse(args[1]); ushort cellId = args.Length > 2 ? ushort.Parse(args[2]) : ch.CellId; MapRecord mapRecord = ch.Map; sbyte recordDirection = ch.Record.Direction; NpcSpawnRecord spawnRecord = NpcSpawnsManager.Instance.Spawn(npcId, mapRecord, cellId, recordDirection); client.Character.Map.Instance.Reload(); ch.Reply($"Spawned npc {spawnRecord.Template.Name} (NpcId={spawnRecord.Template.Id}, SpawnId={spawnRecord.Id})"); }
static void BuySell(WorldClient client, NpcSpawnRecord npc, NpcActionsRecord action) { client.Character.NpcShopExchange = new NpcBuySellExchange(client, action, npc); client.Character.NpcShopExchange.OpenPanel(); }
public MapInstance(MapRecord record) { this.Record = record; this.Npcs = NpcSpawnRecord.GetMapNpcs(Record.Id); this.Interactives = InteractiveRecord.GetInteractivesOnMap(Record.Id); }