コード例 #1
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender         = actionInput.Controller;
            var         contextMessage = new ContextualString(sender.Thing, this.target)
            {
                ToOriginator = "You cast ThunderClap at $ActiveThing.Name!",
                ToReceiver   = "$Aggressor.Name casts ThunderClap at you, you only hear a ringing in your ears now.",
                ToOthers     = "You hear $Aggressor.Name cast ThunderClap at $ActiveThing.Name!  It was very loud.",
            };
            var sm = new SensoryMessage(SensoryType.Hearing, 100, contextMessage);

            var attackEvent = new AttackEvent(this.target, sm, sender.Thing);

            sender.Thing.Eventing.OnCombatRequest(attackEvent, EventScope.ParentsDown);
            if (!attackEvent.IsCancelled)
            {
                var deafenEffect = new AlterSenseEffect()
                {
                    SensoryType = SensoryType.Hearing,
                    AlterAmount = -1000,
                    Duration    = new TimeSpan(0, 0, 45),
                };

                this.target.Behaviors.Add(deafenEffect);
                sender.Thing.Eventing.OnCombatEvent(attackEvent, EventScope.ParentsDown);
            }
        }
コード例 #2
0
ファイル: ThunderClap.cs プロジェクト: biggsk81/WheelMUD
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var contextMessage = new ContextualString(actionInput.Actor, target)
            {
                ToOriginator = $"You cast ThunderClap at {target.Name}!",
                ToReceiver = $"{actionInput.Actor.Name} casts ThunderClap at you. You only hear a ringing in your ears now.",
                ToOthers = $"You hear {actionInput.Actor.Name} cast ThunderClap at {target.Name}! It was very loud.",
            };
            var sm = new SensoryMessage(SensoryType.Hearing, 100, contextMessage);

            var attackEvent = new AttackEvent(target, sm, actionInput.Actor);
            actionInput.Actor.Eventing.OnCombatRequest(attackEvent, EventScope.ParentsDown);
            if (!attackEvent.IsCancelled)
            {
                var deafenEffect = new AlterSenseEffect()
                {
                    SensoryType = SensoryType.Hearing,
                    AlterAmount = -1000,
                    Duration = new TimeSpan(0, 0, 45),
                };

                target.Behaviors.Add(deafenEffect);
                actionInput.Actor.Eventing.OnCombatEvent(attackEvent, EventScope.ParentsDown);
            }
        }