/// <summary> /// This method will remove a worldobject if we have consumed all of the amount in the merge. /// This checks inventory or wielded items (you could be pulling stackable ammo out of a wielded slot and into a stack in your pack /// It then creates and sends the remove object message. Lastly, if the wo has ever been saved to the db, we clean up after ourselves. /// </summary> /// <param name="session">Session is used for sequence and target</param> /// <param name="fromWo">World object of the item are we merging from that needs to be destroyed.</param> public void RemoveWorldObject(Session session, WorldObject fromWo) { if (HasInventoryItem(fromWo.Guid)) { session.Player.TryRemoveFromInventory(fromWo.Guid); } GameMessageRemoveObject msgRemoveFrom = new GameMessageRemoveObject(fromWo); CurrentLandblock.EnqueueBroadcast(Location, MaxObjectTrackingRange, msgRemoveFrom); // todo fix for EF throw new NotImplementedException(); //if (fromWo.SnapShotOfAceObject().HasEverBeenSavedToDatabase) // DatabaseManager.Shard.DeleteObject(fromWo.SnapShotOfAceObject(), null); }
/// <summary> /// This method will remove a worldobject if we have consumed all of the amount in the merge. /// This checks inventory or wielded items (you could be pulling stackable ammo out of a wielded slot and into a stack in your pack /// It then creates and sends the remove object message. Lastly, if the wo has ever been saved to the db, we clean up after ourselves. /// </summary> /// <param name="session">Session is used for sequence and target</param> /// <param name="fromWo">World object of the item are we merging from that needs to be destroyed.</param> public void RemoveWorldObject(Session session, WorldObject fromWo) { if (HasItem(fromWo.Guid)) { session.Player.RemoveWorldObjectFromInventory(fromWo.Guid); } else { session.Player.RemoveFromWieldedObjects(fromWo.Guid); } GameMessageRemoveObject msgRemoveFrom = new GameMessageRemoveObject(fromWo); CurrentLandblock.EnqueueBroadcast(Location, MaxObjectTrackingRange, msgRemoveFrom); if (fromWo.SnapShotOfAceObject().HasEverBeenSavedToDatabase) { DatabaseManager.Shard.DeleteObject(fromWo.SnapShotOfAceObject(), null); } }
public override void OnUse(Session session) { 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 (session.Player.CanReadScroll(School, Power)) { success = true; } else { success = false; failReason = "You are not skilled enough in the inscribed spell's school of magic to understand the writing on this scroll."; } break; default: // Level 1 or Level 7+ never fail success = true; break; } if (!session.Player.UnknownSpell(SpellId)) { success = false; failReason = "You already know the spell inscribed upon this scroll."; } ActionChain readScrollChain = new ActionChain(); readScrollChain.AddAction(session.Player, () => session.Player.HandleActionMotion(motionReading)); readScrollChain.AddDelaySeconds(2); if (success) { readScrollChain.AddAction(session.Player, () => session.Player.LearnSpell(SpellId)); readScrollChain.AddAction(session.Player, () => session.Player.HandleActionMotion(motionReady)); var removeObjMessage = new GameMessageRemoveObject(this); var destroyMessage = new GameMessageSystemChat("The scroll is destroyed.", ChatMessageType.Magic); readScrollChain.AddAction(session.Player, () => session.Network.EnqueueSend(destroyMessage, removeObjMessage)); readScrollChain.AddAction(session.Player, () => session.Player.RemoveWorldObjectFromInventory(Guid)); } else { readScrollChain.AddDelaySeconds(2); readScrollChain.AddAction(session.Player, () => session.Player.HandleActionMotion(motionReady)); var failMessage = new GameMessageSystemChat($"{failReason}", ChatMessageType.Magic); readScrollChain.AddAction(session.Player, () => session.Network.EnqueueSend(failMessage)); } var sendUseDoneEvent = new GameEventUseDone(session.Player.Session); readScrollChain.AddAction(session.Player, () => session.Network.EnqueueSend(sendUseDoneEvent)); readScrollChain.EnqueueChain(); }