/// <summary> /// This is raised by Player.HandleActionUseItem, and is wrapped in ActionChain.<para /> /// The actor of the ActionChain is the player using the item.<para /> /// The item should be in the players possession. /// </summary> public override void UseItem(Player player, ActionChain actionChain) { bool success = true; string failReason = "You are unable to read the scroll."; switch (Power) { // research: http://asheron.wikia.com/wiki/Announcements_-_2002/06_-_Castling case spellLevel2: // Level 2 case spellLevel3: // Level 3 case spellLevel4: // Level 4 case spellLevel5: // Level 5 case spellLevel6: // Level 6 if (!player.CanReadScroll(School, Power)) { success = false; failReason = "You are not skilled enough in the inscribed spell's school of magic to understand the writing on this scroll."; } break; } if (player.SpellIsKnown(SpellId)) { success = false; failReason = "You already know the spell inscribed upon this scroll."; } actionChain .AddAction(player, () => player.HandleActionMotion(motionReading)) .AddDelaySeconds(2); if (success) { actionChain.AddAction(player, () => { player.LearnSpellWithNetworking(SpellId); player.HandleActionMotion(motionReady); if (player.TryRemoveFromInventoryWithNetworking(this)) { player.Session.Network.EnqueueSend(new GameMessageSystemChat("The scroll is destroyed.", ChatMessageType.Magic)); } }); } else { actionChain .AddDelaySeconds(2) .AddAction(player, () => { player.HandleActionMotion(motionReady); player.Session.Network.EnqueueSend(new GameMessageSystemChat($"{failReason}", ChatMessageType.Magic)); }); } actionChain .AddAction(player, () => player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session))); }