public void ReadBook(uint bookGuid) { // This appears to have been sent in response 0x00AA (not pcapped) // When a book is blank, client automatically adds a "blank" page after opening, gets a GameEventBookAddPageResponse success and then sends 0x00AA, expecting this response or the page/book is not writable or usable, unless it is closed and opened again // TODO: Do we want to throttle this request, like appraisals? var book = FindObject(new ObjectGuid(bookGuid), SearchLocations.MyInventory | SearchLocations.LastUsedHook, out var container, out var rootOwner, out var wasEquipped) as Book; if (book == null) { return; } // found book if (book != null) { int maxChars = book.Biota.PropertiesBook.MaxNumCharsPerPage; int maxPages = book.Biota.PropertiesBook.MaxNumPages; string authorName; if (book.ScribeName != null) { authorName = book.ScribeName; } else { authorName = ""; } //string authorAccount; //if (book.ScribeAccount != null) // authorAccount = ScribeAccount; //else // authorAccount = ""; //uint authorID = ScribeIID ?? 0xFFFFFFFF; uint authorID = (book.ScribeIID.HasValue) ? (uint)book.ScribeIID : 0xFFFFFFFF; var pages = book.Biota.PropertiesBookPageData.Clone(book.BiotaDatabaseLock); bool ignoreAuthor = book.IgnoreAuthor ?? false; string inscription; if (book.Inscription != null) { inscription = book.Inscription; } else { inscription = ""; } var bookDataResponse = new GameEventBookDataResponse(Session, book.Guid.Full, maxChars, maxPages, pages, inscription, authorID, authorName, ignoreAuthor); Session.Network.EnqueueSend(bookDataResponse); } }
/// <summary> /// This is raised by Player.HandleActionUseItem.<para /> /// The item does not exist in the players possession.<para /> /// If the item was outside of range, the player will have been commanded to move using DoMoveTo before ActOnUse is called.<para /> /// When this is called, it should be assumed that the player is within range. /// </summary> public override void ActOnUse(WorldObject worldObject) { var player = worldObject as Player; if (player == null) { return; } int maxChars = Biota.PropertiesBook.MaxNumCharsPerPage; int maxPages = Biota.PropertiesBook.MaxNumPages; string authorName; if (ScribeName != null) { authorName = ScribeName; } else { authorName = ""; } string authorAccount; if (ScribeAccount != null) { authorAccount = ScribeAccount; } else { authorAccount = ""; } //uint authorID = ScribeIID ?? 0xFFFFFFFF; uint authorID = (ScribeIID.HasValue) ? (uint)ScribeIID : 0xFFFFFFFF; var pages = Biota.PropertiesBookPageData.Clone(BiotaDatabaseLock); bool ignoreAuthor = IgnoreAuthor ?? false; string inscription; if (Inscription != null) { inscription = Inscription; } else { inscription = ""; } var bookDataResponse = new GameEventBookDataResponse(player.Session, Guid.Full, maxChars, maxPages, pages, inscription, authorID, authorName, ignoreAuthor); player.Session.Network.EnqueueSend(bookDataResponse); }
/// <summary> /// One function to handle both Player.OnUse and Landblock.HandleACtionOnUse functions /// </summary> /// <param name="session"></param> private void BookUseHandler(Session session) { uint maxChars = MaxCharactersPerPage ?? 1000; uint maxPages = MaxPages ?? 1; string authorName; if (ScribeName != null) { authorName = ScribeName; } else { authorName = ""; } string authorAccount; if (ScribeAccount != null) { authorAccount = ScribeAccount; } else { authorAccount = ""; } uint authorID = Scribe ?? 0xFFFFFFFF; List <PageData> pageData = new List <PageData>(); foreach (KeyValuePair <uint, AceObjectPropertiesBook> p in PropertiesBook) { PageData newPage = new PageData(); newPage.AuthorID = p.Value.AuthorId; newPage.AuthorName = p.Value.AuthorName; newPage.AuthorAccount = p.Value.AuthorAccount; pageData.Add(newPage); } bool ignoreAuthor = IgnoreAuthor ?? false; string inscription; if (Inscription != null) { inscription = Inscription; } else { inscription = ""; } var bookDataResponse = new GameEventBookDataResponse(session, Guid.Full, maxChars, maxPages, pageData, inscription, authorID, authorName, ignoreAuthor); session.Network.EnqueueSend(bookDataResponse); var sendUseDoneEvent = new GameEventUseDone(session); session.Network.EnqueueSend(sendUseDoneEvent); }
/// <summary> /// One function to handle both Player.OnUse and Landblock.HandleACtionOnUse functions /// </summary> /// <param name="session"></param> private void BookUseHandler(Session session) { int maxChars = Biota.BiotaPropertiesBook.MaxNumCharsPerPage; int maxPages = Biota.BiotaPropertiesBook.MaxNumPages; string authorName; if (ScribeName != null) { authorName = ScribeName; } else { authorName = ""; } string authorAccount; if (ScribeAccount != null) { authorAccount = ScribeAccount; } else { authorAccount = ""; } //uint authorID = ScribeIID ?? 0xFFFFFFFF; uint authorID = (ScribeIID.HasValue) ? (uint)ScribeIID : 0xFFFFFFFF; List <PageData> pageData = new List <PageData>(); foreach (var p in Biota.BiotaPropertiesBookPageData) { PageData newPage = new PageData(); newPage.AuthorID = p.AuthorId; newPage.AuthorName = p.AuthorName; newPage.AuthorAccount = p.AuthorAccount; newPage.PageText = p.PageText; newPage.IgnoreAuthor = p.IgnoreAuthor; pageData.Add(newPage); } bool ignoreAuthor = IgnoreAuthor ?? false; string inscription; if (Inscription != null) { inscription = Inscription; } else { inscription = ""; } var bookDataResponse = new GameEventBookDataResponse(session, Guid.Full, maxChars, maxPages, pageData, inscription, authorID, authorName, ignoreAuthor); session.Network.EnqueueSend(bookDataResponse); var sendUseDoneEvent = new GameEventUseDone(session); session.Network.EnqueueSend(sendUseDoneEvent); }
/// <summary> /// This is raised by Player.HandleActionUseItem.<para /> /// The item does not exist in the players possession.<para /> /// If the item was outside of range, the player will have been commanded to move using DoMoveTo before ActOnUse is called.<para /> /// When this is called, it should be assumed that the player is within range. /// </summary> public override void ActOnUse(WorldObject worldObject) { var player = worldObject as Player; if (player == null) { return; } int maxChars = Biota.BiotaPropertiesBook.MaxNumCharsPerPage; int maxPages = Biota.BiotaPropertiesBook.MaxNumPages; string authorName; if (ScribeName != null) { authorName = ScribeName; } else { authorName = ""; } string authorAccount; if (ScribeAccount != null) { authorAccount = ScribeAccount; } else { authorAccount = ""; } //uint authorID = ScribeIID ?? 0xFFFFFFFF; uint authorID = (ScribeIID.HasValue) ? (uint)ScribeIID : 0xFFFFFFFF; List <PageData> pageData = new List <PageData>(); foreach (var p in Biota.BiotaPropertiesBookPageData) { PageData newPage = new PageData(); newPage.AuthorID = p.AuthorId; newPage.AuthorName = p.AuthorName; newPage.AuthorAccount = p.AuthorAccount; newPage.PageText = p.PageText; newPage.IgnoreAuthor = p.IgnoreAuthor; pageData.Add(newPage); } bool ignoreAuthor = IgnoreAuthor ?? false; string inscription; if (Inscription != null) { inscription = Inscription; } else { inscription = ""; } var bookDataResponse = new GameEventBookDataResponse(player.Session, Guid.Full, maxChars, maxPages, pageData, inscription, authorID, authorName, ignoreAuthor); player.Session.Network.EnqueueSend(bookDataResponse); }