public GameDialog(WorldClient Client, int NpcID, Npc npc, NpcQuestion nQuestion) : base(GameActionTypeEnum.DIALOG_CREATE, Client.Character) { this.NpcID = NpcID; this.Client = Client; this.Question = nQuestion; this.NPC = npc; }
public static void GiveQuestion(ActionModel action, Player perso, Player target, int itemID, int cellID) { if (action.args.Equals("DV")) { perso.GetClient().EndGameAction(GameActionTypeEnum.DIALOG_CREATE); } else { int qID = -1; try { qID = int.Parse(action.args); } catch (Exception localNumberFormatException) { } NpcQuestion quest = NpcQuestionTable.getNPCQuestion(qID); if (quest == null) { perso.GetClient().EndGameAction(GameActionTypeEnum.DIALOG_CREATE); return; } perso.Send(new NpcDialogQuestionMessage(quest, perso)); } }
public static void Load() { Cache.Clear(); var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM npc_questions"); while (reader.Read()) { var npc = new NpcQuestion() { ID = reader.GetInt32("ID"), Reponses = reader.GetString("responses"), Args = reader.GetString("params"), Conditions = reader.GetString("cond"), FalseQuestion = reader.GetInt32("ifFalse"), }; Cache.Add(npc.ID, npc); } reader.Close(); Logger.Info("Loaded @'" + Cache.Count + "'@ NPC Questions"); }
private static void DialogStart(WorldClient Client, String Packet) { try { int npcID = int.Parse(Packet.Substring(2).Split((char)0x0A)[0]); Npc npc = Client.Character.myMap.getNPC(npcID); if (npc == null) { return; } Client.Send(new NpcDialogStartMessage(npcID)); int qID = npc.get_template().InitQuestion; if (!NpcQuestionTable.Cache.ContainsKey(qID)) { Client.Send(new NpcEndDialogMessage()); } NpcQuestion quest = NpcQuestionTable.Cache[qID]; Client.AddGameAction(new GameDialog(Client, npcID, npc, quest)); } catch (Exception e) { } }
public NpcDialogQuestionMessage(NpcQuestion npc, Player charc) { this.Question = npc; this.Character = charc; }