Ejemplo n.º 1
0
        public override void Cast(IAvatar caster, IActor target, CastResults results)
        {
            IAvatar defender = target as IAvatar;

            // TODO: Defense against spells?
            int power = this.Foci.Power + results.CastSuccessCount;

            target.SetBody(target.Body - power);

            caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                    String.Format(Resources.SpellDamagedTarget, target.A(), power)));
            if (defender != null)
            {
                defender.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Negative,
                                                          String.Format(Resources.SpellDamagedByTarget, power, caster.A())));
            }
            if (defender != null)
            {
                defender.Context.AddRange(defender.GetRdlProperties(Avatar.BodyProperty));
            }

            if (target.IsDead)
            {
                results.TargetDied = true;
                if (defender != null)
                {
                    // Killed an Avatar.
                    caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                            String.Format(Resources.SpellKilledTarget, target.A())));
                    defender.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Negative,
                                                              String.Format(Resources.SpellKilledByTarget, caster.A())));
                }
                else
                {
                    // Destroyed an object.
                    caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                            String.Format(Resources.SpellDestroyedTraget, target.A())));
                }
            }
            else if (defender != null && defender.IsUnconscious)
            {
                results.TargetUnconscious = true;
                caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                        String.Format(Resources.SpellUnconsciousTarget, target.A())));
                if (defender != null)
                {
                    defender.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Negative,
                                                              String.Format(Resources.SpellUnconsciousByTarget, caster.A())));
                }
            }
        }
Ejemplo n.º 2
0
        public override void Cast(IAvatar caster, IActor target, CastResults results)
        {
            IAvatar defender = target as IAvatar;

            // Increase the protection value of the target.
            if (defender != null)
            {
                if (defender is PerenthiaMobile)
                {
                    defender = caster;
                }

                int power = this.Foci.Power + results.CastSuccessCount;
                this.AffectPower = power;
                this.Save();

                // If a protection spell already exists using the same skill then remove it
                // and add the current one.
                // Search the list of spells with the same skill and try to find those spells in the
                // affects collection.
                var spellNames = defender.GetAllChildren().Where(c => c is ISpell && (c as ISpell).Skill == this.Skill).Select(c => c.Name);
                foreach (var spellName in spellNames)
                {
                    // If this protection already exists then remove it and add the new one.
                    if (defender.Affects.ContainsKey(spellName))
                    {
                        this.RemoveAffect(defender, false);
                    }
                }

                defender.Protection += power;
                defender.Affects.Add(this, this.Foci.Duration);
                defender.Context.AddRange(defender.Affects.ToRdl());
                if (Object.ReferenceEquals(caster, defender))
                {
                    caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                            String.Format(Resources.SpellProtectionGained, power)));
                }
                else
                {
                    caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                            String.Format(Resources.SpellProtectionGainedTarget, target.A(), power)));
                    defender.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                              String.Format(Resources.SpellProtectionGainedByTarget, power, caster.A())));
                    if (defender != null)
                    {
                        defender.Context.AddRange(defender.GetRdlProperties(Avatar.ProtectionProperty));
                    }
                }
            }
            else
            {
                this.NoAffect(caster);
            }
        }