public bool Run(params object[] args) { NWPlayer pc = NWPlayer.Wrap(_.GetLastUsedBy()); if (!pc.IsValid) { pc = NWPlayer.Wrap(_.GetPCSpeaker()); } string conversation = _.GetLocalString(Object.OBJECT_SELF, "CONVERSATION"); if (!string.IsNullOrWhiteSpace(conversation)) { int objectType = _.GetObjectType(Object.OBJECT_SELF); if (objectType == OBJECT_TYPE_PLACEABLE) { NWPlaceable talkTo = NWPlaceable.Wrap(Object.OBJECT_SELF); _dialog.StartConversation(pc, talkTo, conversation); } else { NWCreature talkTo = NWCreature.Wrap(Object.OBJECT_SELF); _dialog.StartConversation(pc, talkTo, conversation); } } else { _.ActionStartConversation(pc.Object, "", TRUE, FALSE); } return(true); }
public bool Run(params object[] args) { NWPlaceable placeable = (Object.OBJECT_SELF); NWPlayer user = placeable.ObjectType == OBJECT_TYPE_PLACEABLE? _.GetLastUsedBy() : _.GetClickingObject(); if (!user.IsPlayer && !user.IsDM) { return(false); } string conversation = placeable.GetLocalString("CONVERSATION"); NWObject target = placeable.GetLocalInt("TARGET_PC") == TRUE ? user.Object : placeable.Object; if (!string.IsNullOrWhiteSpace(conversation)) { _dialog.StartConversation(user, target, conversation); } else { user.AssignCommand(() => _.ActionStartConversation(target, string.Empty, TRUE, FALSE)); } return(true); }
public void StartConversation(NWPlayer player, NWObject talkTo, string @class) { if (player == null) { throw new ArgumentNullException(nameof(player)); } if (player.Object == null) { throw new ArgumentNullException(nameof(player.Object)); } if (talkTo == null) { throw new ArgumentNullException(nameof(talkTo)); } if (talkTo.Object == null) { throw new ArgumentNullException(nameof(talkTo.Object)); } if (string.IsNullOrWhiteSpace(@class)) { throw new ArgumentException(nameof(@class), nameof(@class) + " cannot be null, empty, or whitespace."); } LoadConversation(player, talkTo, @class, -1); PlayerDialog dialog = _cache.PlayerDialogs[player.GlobalID]; // NPC conversations if (_.GetObjectType(talkTo.Object) == NWScript.OBJECT_TYPE_CREATURE && !talkTo.IsPlayer && !talkTo.IsDM) { _.BeginConversation("dialog" + dialog.DialogNumber, new Object()); } // Everything else else { player.AssignCommand(() => _.ActionStartConversation(talkTo.Object, "dialog" + dialog.DialogNumber, NWScript.TRUE, NWScript.FALSE)); } }
public bool Run(params object[] args) { NWPlaceable container = Object.OBJECT_SELF; NWObject owner = container.GetLocalObject("QUEST_OWNER"); NWPlayer player = _.GetLastDisturbed(); NWItem item = _.GetInventoryDisturbItem(); int disturbType = _.GetInventoryDisturbType(); string crafterPlayerID = item.GetLocalString("CRAFTER_PLAYER_ID"); Guid? crafterPlayerGUID = null; if (!string.IsNullOrWhiteSpace(crafterPlayerID)) { crafterPlayerGUID = new Guid(crafterPlayerID); } if (disturbType == INVENTORY_DISTURB_TYPE_ADDED) { int questID = container.GetLocalInt("QUEST_ID"); PCQuestStatus status = _data.Single <PCQuestStatus>(x => x.PlayerID == player.GlobalID && x.QuestID == questID); PCQuestItemProgress progress = _data.SingleOrDefault <PCQuestItemProgress>(x => x.PCQuestStatusID == status.ID && x.Resref == item.Resref); DatabaseActionType action = DatabaseActionType.Update; if (progress == null) { _.CopyItem(item, player, TRUE); player.SendMessage(_color.Red("That item is not required for this quest.")); } else if (progress.MustBeCraftedByPlayer && crafterPlayerGUID != player.GlobalID) { _.CopyItem(item, player, TRUE); player.SendMessage(_color.Red("You may only submit items which you have personally created for this quest.")); } else { progress.Remaining--; if (progress.Remaining <= 0) { var progressCopy = progress; progress = _data.Single <PCQuestItemProgress>(x => x.ID == progressCopy.ID); action = DatabaseActionType.Delete; } _data.SubmitDataChange(progress, action); // Recalc the remaining items needed. int remainingCount = _data.GetAll <PCQuestItemProgress>().Count(x => x.PCQuestStatusID == status.ID); if (remainingCount <= 0) { _quest.AdvanceQuestState(player, owner, questID); } player.SendMessage("You need " + progress.Remaining + " " + item.Name + " for this quest."); } item.Destroy(); var questItemProgresses = _data.Where <PCQuestItemProgress>(x => x.PCQuestStatusID == status.ID); if (!questItemProgresses.Any()) { string conversation = _.GetLocalString(owner, "CONVERSATION"); if (!string.IsNullOrWhiteSpace(conversation)) { _dialog.StartConversation(player, owner, conversation); } else { player.AssignCommand(() => { _.ActionStartConversation(owner, "", TRUE, FALSE); }); } } } return(true); }