Ejemplo n.º 1
0
        public void Apply()
        {
            if (this.Target.World != null)
            {
                this.Target.World.BuffManager.SendTargetPayload(this.Target, this);
            }

            // if attack does damage and payload target is a player, run through and activate all the desctructibles
            if (this.Target is Player && this.DamageEntries.Count > 0)
            {
                Player player = (Player)this.Target;
                foreach (Actor extra in this.Targets.ExtraActors)
                {
                    if (extra is Mooege.Core.GS.Actors.Implementations.DesctructibleLootContainer)
                    {
                        extra.OnTargeted(player, null);
                    }
                }
            }

            // main targets
            if (this.Targets == null)
            {
                Logger.Warn("FIXME: Tried to Apply AttackPayload with null targets.");
                return;
            }

            foreach (Actor target in this.Targets.Actors)
            {
                //TODO: In a proper threaded workflow there should be no null targets selected.
                //Taken the check out so flags will be raised when this happens

                // filter null and killed targets
                //if (target == null)
                //    continue;

                // TODO: calculate hit chance for monsters instead of always hitting

                var payload = new HitPayload(this, _DoCriticalHit(this.Context.User, target), target);
                payload.AutomaticHitEffects = this.AutomaticHitEffects;
                payload.OnDeath             = OnDeath;

                foreach (Func <Buff> buffFactory in _hitBuffs)
                {
                    this.Context.AddBuff(target, buffFactory());
                }

                if (OnHit != null)
                {
                    OnHit(payload);
                }

                payload.Apply();
            }
        }
Ejemplo n.º 2
0
        public void Apply()
        {
            if (this.Targets == null)
            {
                this.Targets = new TargetList();
            }

            if (this.Target.World != null)
            {
                this.Target.World.BuffManager.SendTargetPayload(this.Target, this);
            }

            // if attack does damage and payload target is a player, run through and activate all the desctructibles
            if (this.Target is Player && this.DamageEntries.Count > 0)
            {
                Player player = (Player)this.Target;
                foreach (Actor extra in this.Targets.ExtraActors)
                {
                    if (extra is Mooege.Core.GS.Actors.Implementations.DesctructibleLootContainer)
                    {
                        extra.OnTargeted(player, null);
                    }
                }
            }

            // main targets
            foreach (Actor target in this.Targets.Actors)
            {
                // filter null and killed targets
                if (target == null || target.World != null && target.World.PowerManager.IsDeletingActor(target))
                {
                    continue;
                }

                // TODO: calculate hit chance for monsters instead of always hitting

                var payload = new HitPayload(this, _DoCriticalHit(this.Context.User, target), target);
                payload.AutomaticHitEffects = this.AutomaticHitEffects;
                payload.OnDeath             = OnDeath;

                foreach (Func <Buff> buffFactory in _hitBuffs)
                {
                    this.Context.AddBuff(target, buffFactory());
                }

                if (OnHit != null)
                {
                    OnHit(payload);
                }

                payload.Apply();
            }
        }