Exemplo n.º 1
0
        /// <summary>
        /// This is raised by Player.HandleActionUseItem, and is wrapped in ActionChain.<para />
        /// The actor of the ActionChain is the item being used.<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.
        ///
        /// 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>
        public override void ActOnUse(Player player)
        {
            var actionChain = new ActionChain();

            actionChain.AddDelaySeconds(player.Rotate(this));
            if (Biota.BiotaPropertiesEmote.Count > 0)
            {
                var rng    = Physics.Common.Random.RollDice(0.0f, 1.0f);
                var result = Biota.BiotaPropertiesEmote.Where(emote => emote.Category == 7 && rng >= emote.Probability);

                if (result.Count() < 1)
                {
                    result = Biota.BiotaPropertiesEmote.Where(emote => emote.Category == 7);
                }
                if (result.Count() > 0)
                {
                    var actions = Biota.BiotaPropertiesEmoteAction.Where(action => action.EmoteSetId == result.ElementAt(result.Count() - 1).EmoteSetId&& action.EmoteCategory == result.ElementAt(result.Count() - 1).Category);

                    foreach (var action in actions)
                    {
                        EmoteManager.ExecuteEmote(result.ElementAt(result.Count() - 1), action, actionChain, this, player);
                    }
                }
                actionChain.EnqueueChain();
                //OnAutonomousMove(player.Location, this.Sequences, MovementTypes.TurnToObject, playerId);
                //GameEventUseDone sendUseDoneEvent = new GameEventUseDone(player.Session);
                //player.Session.Network.EnqueueSend(sendUseDoneEvent);
                player.SendUseDoneEvent();
            }
            else
            {
                player.SendUseDoneEvent();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is raised by Player.HandleActionUseItem, and is wrapped in ActionChain.<para />
        /// The actor of the ActionChain is the item being used.<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.
        ///
        /// 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>
        public override void ActOnUse(WorldObject worldObject)
        {
            if (worldObject is Player)
            {
                var player = worldObject as Player;

                var actionChain = new ActionChain();
                actionChain.AddDelaySeconds(player.Rotate(this));
                if (Biota.BiotaPropertiesEmote.Count > 0)
                {
                    var emoteSets = Biota.BiotaPropertiesEmote.Where(x => x.Category == (int)EmoteCategory.Use).ToList();

                    if (emoteSets.Count > 0)
                    {
                        var selectedEmoteSet = emoteSets.FirstOrDefault(x => x.Probability == 1);

                        if (selectedEmoteSet == null)
                        {
                            var rng = Physics.Common.Random.RollDice(0.0f, 1.0f);

                            selectedEmoteSet = emoteSets.FirstOrDefault(x => x.Probability >= rng);
                        }

                        if (selectedEmoteSet == null)
                        {
                            player.SendUseDoneEvent();
                            return;
                        }

                        var emoteActions = Biota.BiotaPropertiesEmoteAction.Where(x => x.EmoteCategory == selectedEmoteSet.Category && x.EmoteSetId == selectedEmoteSet.EmoteSetId).OrderBy(x => x.Order).ToList();

                        foreach (var action in emoteActions)
                        {
                            EmoteManager.ExecuteEmote(selectedEmoteSet, action, actionChain, this, player);
                        }
                        actionChain.EnqueueChain();
                    }

                    player.SendUseDoneEvent();
                }
                else
                {
                    player.SendUseDoneEvent();
                }
            }
        }