Пример #1
0
        public static ReturnTypes spell_attack(int sn, int level, CharacterInstance ch, object vo)
        {
            var skill = RepositoryManager.Instance.SKILLS.Get(sn);
            var vch   = (CharacterInstance)vo;

            var saved = skill.CheckSave(level, ch, vch);

            if (CheckFunctions.CheckIfTrueCasting(
                    saved && Macros.SPELL_SAVE(skill) == (int)SpellSaveEffectTypes.Negate, skill, ch,
                    CastingFunctionType.Failed, vch))
            {
                return(ReturnTypes.SpellFailed);
            }

            var damage = GetBaseDamage(level, ch, skill);

            if (saved)
            {
                var spellSaveType =
                    EnumerationExtensions.GetEnum <SpellSaveEffectTypes>(Macros.SPELL_SAVE(skill));
                switch (spellSaveType)
                {
                case SpellSaveEffectTypes.ThreeQuartersDamage:
                    damage = GetThreeQuartersDamage(damage);
                    break;

                case SpellSaveEffectTypes.HalfDamage:
                    damage = GetHalfDamage(damage);
                    break;

                case SpellSaveEffectTypes.QuarterDamage:
                    damage = GetQuarterDamage(damage);
                    break;

                case SpellSaveEffectTypes.EighthDamage:
                    damage = GetEighthDamage(damage);
                    break;

                case SpellSaveEffectTypes.Absorb:
                    AbsorbDamage(ch, skill, vch, damage);
                    return(ReturnTypes.None);

                case SpellSaveEffectTypes.Reflect:
                    return(spell_attack(sn, level, vch, ch));
                }
            }

            var retcode = ch.CauseDamageTo(vch, damage, sn);

            if (retcode == ReturnTypes.None &&
                !ch.CharDied() && !vch.CharDied()
                &&
                (!vch.IsAffectedBy(sn) || skill.Flags.IsSet(SkillFlags.Accumulative) ||
                 skill.Flags.IsSet(SkillFlags.ReCastable)))
            {
                retcode = AffectCharacter.spell_affectchar(sn, level, ch, vch);
            }

            return(retcode);
        }
Пример #2
0
        private static void CastTargetSpellAtVictim(CharacterInstance ch, CharacterInstance victim, SkillData skill, TargetBooleanValues targetValues, int level)
        {
            if (targetValues.GroupSpell || targetValues.AreaSpell)
            {
                var resType = EnumerationExtensions.GetEnum <ResistanceTypes>(Macros.SPELL_DAMAGE(skill));
                if ((targetValues.GroupSpell &&
                     !victim.IsSameGroup(ch)) ||
                    victim.Immunity.IsSet(ResistanceTypes.Magic) ||
                    victim.IsImmune(resType) ||
                    skill.CheckSave(level, ch, victim) ||
                    (!skill.Flags.IsSet(SkillFlags.ReCastable) && !victim.IsAffectedBy((int)skill.ID)))
                {
                    return;
                }

                if (targetValues.HitVictim && ch != victim)
                {
                    comm.act(ATTypes.AT_MAGIC, skill.HitVictimMessage, ch, null, victim, ToTypes.Victim);
                    if (targetValues.HitRoom)
                    {
                        comm.act(ATTypes.AT_MAGIC, skill.HitRoomMessage, ch, null, victim, ToTypes.NotVictim);
                        comm.act(ATTypes.AT_MAGIC, skill.HitRoomMessage, ch, null, victim, ToTypes.Character);
                    }
                }
                else if (targetValues.HitRoom)
                {
                    comm.act(ATTypes.AT_MAGIC, skill.HitRoomMessage, ch, null, victim, ToTypes.Room);
                }

                if (ch == victim)
                {
                    if (targetValues.HitVictim)
                    {
                        comm.act(ATTypes.AT_MAGIC, skill.HitVictimMessage, ch, null, ch, ToTypes.Character);
                    }
                    else if (targetValues.HitCharacter)
                    {
                        comm.act(ATTypes.AT_MAGIC, skill.HitCharacterMessage, ch, null, ch, ToTypes.Character);
                    }
                }
                else if (targetValues.HitCharacter)
                {
                    comm.act(ATTypes.AT_MAGIC, skill.HitCharacterMessage, ch, null, victim, ToTypes.Character);
                }
            }

            var retCode = AffectCharacter.spell_affectchar((int)skill.ID, level, ch, victim);

            if (!targetValues.GroupSpell && !targetValues.AreaSpell)
            {
                if (retCode == ReturnTypes.VictimImmune)
                {
                    ch.ImmuneCast(skill, victim);
                }
                else
                {
                    ch.SuccessfulCast(skill, victim);
                }
            }
        }
Пример #3
0
        public static ReturnTypes spell_area_attack(int sn, int level, CharacterInstance ch, object vo)
        {
            var skill = RepositoryManager.Instance.SKILLS.Get(sn);

            if (CheckFunctions.CheckIfTrueCasting(ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe), skill, ch))
            {
                return(ReturnTypes.SpellFailed);
            }

            if (string.IsNullOrEmpty(skill.HitCharacterMessage))
            {
                comm.act(ATTypes.AT_MAGIC, skill.HitCharacterMessage, ch, null, null, ToTypes.Character);
            }
            if (string.IsNullOrEmpty(skill.HitRoomMessage))
            {
                comm.act(ATTypes.AT_MAGIC, skill.HitRoomMessage, ch, null, null, ToTypes.Room);
            }

            foreach (var vch in ch.CurrentRoom.Persons
                     .Where(x => x.IsNpc() || !x.Act.IsSet((int)PlayerFlags.WizardInvisibility) ||
                            ((PlayerInstance)x).PlayerData.WizardInvisible < LevelConstants.ImmortalLevel)
                     .Where(x => x != ch)
                     .Where(x => !fight.is_safe(ch, x, false))
                     .Where(x => ch.IsNpc() || x.IsNpc() || ch.IsInArena() || (ch.IsPKill() && x.IsPKill())))
            {
                var saved = skill.CheckSave(level, ch, vch);
                if (saved &&
                    CheckFunctions.CheckIfTrueCasting(Macros.SPELL_SAVE(skill) == (int)SpellSaveEffectTypes.Negate,
                                                      skill, ch, CastingFunctionType.Failed, vch))
                {
                    continue;
                }

                var damage = GetBaseDamage(level, ch, skill);

                if (saved)
                {
                    damage = GetDamageIfSaved(sn, level, ch, skill, vch, damage);
                }

                var retcode = ch.CauseDamageTo(vch, damage, sn);
                if (retcode == ReturnTypes.None &&
                    !ch.CharDied() && !vch.CharDied()
                    &&
                    (!vch.IsAffectedBy(sn) || skill.Flags.IsSet(SkillFlags.Accumulative) ||
                     skill.Flags.IsSet(SkillFlags.ReCastable)))
                {
                    retcode = AffectCharacter.spell_affectchar(sn, level, ch, vch);
                }

                if (retcode == ReturnTypes.CharacterDied || ch.CharDied())
                {
                    break;
                }
            }
            return(ReturnTypes.None);
        }