public override void OnUse(Player player) { 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); 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, this.Guid.Full)); }
public override void OnUse(Player player) { string serverMessage = null; // validate within use range, taking into account the radius of the model itself, as well SetupModel csetup = SetupModel.ReadFromDat(this.PhysicsData.CSetup); float radiusSquared = (this.GameData.UseRadius + csetup.Radius) * (this.GameData.UseRadius + csetup.Radius); var motionSanctuary = new UniversalMotion(MotionStance.Standing, new MotionItem(MotionCommand.Sanctuary)); var animationEvent = new GameMessageUpdateMotion(player, player.Session, motionSanctuary); // This event was present for a pcap in the training dungeon.. Why? The sound comes with animationEvent... var soundEvent = new GameMessageSound(this.Guid, Sound.LifestoneOn, 1); if (player.Location.SquaredDistanceTo(this.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.EnqueueMovementEvent(motionSanctuary, player.Guid); 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); }
public float GetWorldObjectEffectiveUseRadius(ObjectGuid objectId) { WorldObject wo; Log($"Getting WorldObject Effective Use Radius {objectId.Full:X}"); lock (objectCacheLocker) { wo = worldObjects.ContainsKey(objectId) ? worldObjects[objectId] : null; } if (wo != null) { var csetup = SetupModel.ReadFromDat(wo.PhysicsData.CSetup); return((float)Math.Pow((wo.GameData.UseRadius + csetup.Radius + 1.5), 2)); } return(0.00f); }
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 float GetWorldObjectEffectiveUseRadius(ObjectGuid objectId) { Log($"Getting WorldObject Effective Use Radius {objectId.Full:X}"); WorldObject wo = worldObjects.ContainsKey(objectId) ? worldObjects[objectId] : null; if (wo?.SetupTableId == null) { return(0.00f); } SetupModel csetup = SetupModel.ReadFromDat(wo.SetupTableId.Value); if (wo.UseRadius != null) { return((float)Math.Pow(wo.UseRadius.Value + csetup.Radius + 1.5, 2)); } return((float)Math.Pow(0.25 + csetup.Radius + 1.5, 2)); }
// 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(); }