public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { // TODO: to be removed once physics collisions are implemented HandleActionOnCollide(playerId); // always send useDone event var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(sendUseDoneEvent); } }); // Run on the player chain.EnqueueChain(); }
// Called by the Landblock for books that are WorldObjects (some notes pinned to the ground, statues, pedestals and tips in training academy, etc public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } // Make sure player is within the use radius of the item. if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { BookUseHandler(player.Session); } }); // Run on the player chain.EnqueueChain(); }
/// <summary> /// Fired when Client clicks on the Vendor World Object /// </summary> /// <param name="playerId"></param> public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { chain.AddAction(this, () => { LoadInventory(); ApproachVendor(player); }); } }); chain.EnqueueChain(); }
public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } ////if (playerDistanceTo >= 2500) ////{ //// var sendTooFarMsg = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0037); //// player.Session.Network.EnqueueSend(sendTooFarMsg, sendUseDoneEvent); //// return; ////} if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { ActionChain checkDoorChain = new ActionChain(); checkDoorChain.AddAction(this, () => { if (!IsLocked) { if (!IsOpen) { Open(playerId); } else { Close(playerId); } // Create Door auto close timer ActionChain autoCloseTimer = new ActionChain(); autoCloseTimer.AddDelaySeconds(ResetInterval); autoCloseTimer.AddAction(this, () => Reset()); autoCloseTimer.EnqueueChain(); } else { CurrentLandblock.EnqueueBroadcastSound(this, Sound.OpenFailDueToLock); } var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(sendUseDoneEvent); }); checkDoorChain.EnqueueChain(); } }); chain.EnqueueChain(); }
public override void HandleActionOnUse(ObjectGuid playerId) { // All data on a lifestone is constant -- therefore we just run in context of player ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; string serverMessage = null; // validate within use range, taking into account the radius of the model itself, as well SetupModel csetup = SetupModel.ReadFromDat(SetupTableId.Value); float radiusSquared = (UseRadius.Value + csetup.Radius) * (UseRadius.Value + csetup.Radius); // Run this animation... // Player Enqueue: var motionSanctuary = new UniversalMotion(MotionStance.Standing, new MotionItem(MotionCommand.Sanctuary)); var animationEvent = new GameMessageUpdateMotion(player.Guid, player.Sequences.GetCurrentSequence(Network.Sequence.SequenceType.ObjectInstance), player.Sequences, motionSanctuary); // This event was present for a pcap in the training dungeon.. Why? The sound comes with animationEvent... var soundEvent = new GameMessageSound(Guid, Sound.LifestoneOn, 1); if (player.Location.SquaredDistanceTo(Location) >= radiusSquared) { serverMessage = "You wandered too far to attune with the Lifestone!"; } else { player.SetCharacterPosition(PositionType.Sanctuary, player.Location); // create the outbound server message serverMessage = "You have attuned your spirit to this Lifestone. You will resurrect here after you die."; player.HandleActionMotion(motionSanctuary); player.Session.Network.EnqueueSend(soundEvent); } var lifestoneBindMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.Magic); // always send useDone event var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(lifestoneBindMessage, sendUseDoneEvent); }); chain.EnqueueChain(); }
public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } ////if (playerDistanceTo >= 2500) ////{ //// var sendTooFarMsg = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0037); //// player.Session.Network.EnqueueSend(sendTooFarMsg, sendUseDoneEvent); //// return; ////} if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { ActionChain useObjectChain = new ActionChain(); useObjectChain.AddAction(this, () => { if (AllowedActivator == null) { Activate(playerId); } var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(sendUseDoneEvent); }); useObjectChain.EnqueueChain(); } }); chain.EnqueueChain(); }
// FIXME(ddevec): I broke vendors -- I need to think about how to reimplement this cleanly public override void OnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } string serverMessage = null; // validate within use range, taking into account the radius of the model itself, as well SetupModel csetup = SetupModel.ReadFromDat(PhysicsData.CSetup); float radiusSquared = (GameData.UseRadius + csetup.Radius) * (GameData.UseRadius + csetup.Radius); // We're static, so this is safe -- our Location is never written if (player.Location.SquaredDistanceTo(Location) >= radiusSquared) { serverMessage = "Your way to far away to trust, come closer and buy something or leave me alone!"; } else { // create the outbound server message serverMessage = "You Break it, you bought it!"; } // give player starting money var money = new GameMessagePrivateUpdatePropertyInt(player.Session, PropertyInt.CoinValue, 5000); player.Session.Network.EnqueueSend(money); var welcomemsg = new GameMessageSystemChat(serverMessage, ChatMessageType.Tell); // always send useDone event var sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(welcomemsg, sendUseDoneEvent); player.Session.Network.EnqueueSend(new GameEventApproachVendor(player.Session, Guid)); }); chain.EnqueueChain(); }
/// <summary> /// This is the OnUse method. This is just an initial implemention. I have put in the turn to action at this point. /// If we are out of use radius, move to the object. Once in range, let's turn the creature toward us and get started. /// Note - we may need to make an NPC class vs monster as using a monster does not make them turn towrad you as I recall. Og II /// Also, once we are reading in the emotes table by weenie - this will automatically customize the behavior for creatures. /// </summary> /// <param name="playerId">Identity of the player we are interacting with</param> public override void HandleActionOnUse(ObjectGuid playerId) { ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, wo => { Player player = wo as Player; if (player == null) { return; } if (!player.IsWithinUseRadiusOf(this)) { player.DoMoveTo(this); } else { ActionChain turnToChain = new ActionChain(); turnToChain.AddAction(this, () => { OnAutonomousMove(wo.Location, this.Sequences, MovementTypes.TurnToObject, playerId); }); turnToChain.EnqueueChain(); ActionChain doneChain = new ActionChain(); doneChain.AddAction(this, () => { GameEventUseDone sendUseDoneEvent = new GameEventUseDone(player.Session); player.Session.Network.EnqueueSend(sendUseDoneEvent); }); doneChain.EnqueueChain(); } }); chain.EnqueueChain(); }
public override void HandleActionOnCollide(ObjectGuid playerId) { string serverMessage; ActionChain chain = new ActionChain(); CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) => { Player player = wo as Player; if (player == null) { return; } if (Destination != null) { #if DEBUG serverMessage = "Checking requirements for " + this.Name; var usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System); player.Session.Network.EnqueueSend(usePortalMessage); #endif // Check player level -- requires remote query to player (ugh)... if ((player.Level >= MinimumLevel) && ((player.Level <= MaximumLevel) || (MaximumLevel == 0))) { Position portalDest = Destination; switch (WeenieClassId) { /// <summary> /// Setup correct racial portal destination for the Central Courtyard in the Training Academy /// </summary> case (ushort)SpecialPortalWCID.CentralCourtyard: { uint playerLandblockId = player.Location.LandblockId.Raw; switch (playerLandblockId) { case (uint)SpecialPortalLandblockID.ShoushiCCLaunch: // Shoushi { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiCCLanding); break; } case (uint)SpecialPortalLandblockID.YaraqCCLaunch: // Yaraq { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqCCLanding); break; } case (uint)SpecialPortalLandblockID.SanamarCCLaunch: // Sanamar { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarCCLanding); break; } default: // Holtburg { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgCCLanding); break; } } portalDest.PositionX = Destination.PositionX; portalDest.PositionY = Destination.PositionY; portalDest.PositionZ = Destination.PositionZ; portalDest.RotationX = Destination.RotationX; portalDest.RotationY = Destination.RotationY; portalDest.RotationZ = Destination.RotationZ; portalDest.RotationW = Destination.RotationW; break; } /// <summary> /// Setup correct racial portal destination for the Outer Courtyard in the Training Academy /// </summary> case (ushort)SpecialPortalWCID.OuterCourtyard: { uint playerLandblockId = player.Location.LandblockId.Raw; switch (playerLandblockId) { case (uint)SpecialPortalLandblockID.ShoushiOCLaunch: // Shoushi { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiOCLanding); break; } case (uint)SpecialPortalLandblockID.YaraqOCLaunch: // Yaraq { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqOCLanding); break; } case (uint)SpecialPortalLandblockID.SanamarOCLaunch: // Sanamar { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarOCLanding); break; } default: // Holtburg { portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgOCLanding); break; } } portalDest.PositionX = Destination.PositionX; portalDest.PositionY = Destination.PositionY; portalDest.PositionZ = Destination.PositionZ; portalDest.RotationX = Destination.RotationX; portalDest.RotationY = Destination.RotationY; portalDest.RotationZ = Destination.RotationZ; portalDest.RotationW = Destination.RotationW; break; } /// <summary> /// All other portals don't need adjustments. /// </summary> default: { break; } } #if DEBUG serverMessage = "Portal sending player to destination"; usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System); player.Session.Network.EnqueueSend(usePortalMessage); #endif player.Session.Player.Teleport(portalDest); // If the portal just used is able to be recalled to, // save the destination coordinates to the LastPortal character position save table if (IsRecallable) { player.SetCharacterPosition(PositionType.LastPortal, portalDest); } } else if ((player.Level > MaximumLevel) && (MaximumLevel != 0)) { // You are too powerful to interact with that portal! var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AC); player.Session.Network.EnqueueSend(failedUsePortalMessage); } else { // You are not powerful enough to interact with that portal! var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AB); player.Session.Network.EnqueueSend(failedUsePortalMessage); } } else { serverMessage = "Portal destination for portal ID " + this.WeenieClassId + " not yet implemented!"; var failedUsePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System); player.Session.Network.EnqueueSend(failedUsePortalMessage); } }); // Run on the player chain.EnqueueChain(); }