Esempio n. 1
0
        public bool Update()
        {
            switch (nType)
            {
            case AffectedAreaType.UserSkill:
                foreach (var mob in Field.Mobs)
                {
                    if (!rcArea.PointInRect(mob.Position.CurrentXY))
                    {
                        continue;
                    }

                    mob.TryApplySkillDamageStatus
                        (Field.Users[dwOwnerId], nSkillID, nSLV, 0);
                }
                break;

            case AffectedAreaType.BlessedMist:                     // TODO fix the recovery numbers, its incorrect rn
            {
                var rate = MasterManager.SkillTemplates[nSkillID].X(nSLV) * 0.01;
                foreach (var user in Field.Users)
                {
                    if (!rcArea.PointInRect(user.Position.CurrentXY))
                    {
                        continue;
                    }

                    user.Modify.Heal(0, (int)(user.BasicStats.nMMP * rate));

                    var effect = new UserEffectPacket(UserEffect.SkillAffected)
                    {
                        nSkillID = nSkillID,
                        nSLV     = nSLV,
                    };

                    effect.BroadcastEffect(user);
                }
            }
            break;

            case AffectedAreaType.MobSkill:
                foreach (var user in Field.Users)
                {
                    if (!rcArea.PointInRect(user.Position.CurrentXY))
                    {
                        continue;
                    }

                    var toAdd = new Debuff(nSkillID, nSLV);
                    toAdd.StatType = SecondaryStatFlag.Poison;
                    toAdd.Generate();
                    user.Buffs.Remove(toAdd.nBuffID);
                    user.Buffs.Add(toAdd);
                }
                break;
            }

            return(StartTime.MillisSinceStart() >= Duration);
        }
Esempio n. 2
0
        public void OnStatChangeByMobSkill(MobSkillLevelData template, int dwMobTemplate, int tDelay)
        {
            if (!template.DoProp(Constants.Rand))
            {
                return;
            }

            if (template.Time <= 0)
            {
                if (template.nSkillID == (int)MobSkill.MobSkillID.DISPEL)
                {
                    CancelAllDebuffs();
                    // Parent.ValidateStat(); // no need to validate stat here cuz it does it when removed
                }
            }
            else
            {
                var debuff = new Debuff(template.nSkillID, template.nSLV);

                switch ((MobSkill.MobSkillID)template.nSkillID)                 // TODO determine the rest of these
                {
                case MobSkill.MobSkillID.ATTRACT:
                    debuff.StatType = SecondaryStatFlag.Attract;
                    debuff.nOption  = template.X;
                    break;

                case MobSkill.MobSkillID.BANMAP:
                    debuff.StatType = SecondaryStatFlag.BanMap;
                    debuff.dwMobId  = dwMobTemplate;
                    break;

                case MobSkill.MobSkillID.STUN:
                    debuff.StatType = SecondaryStatFlag.Stun;
                    debuff.nOption  = 1;
                    break;

                case MobSkill.MobSkillID.SEAL:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Seal;
                    debuff.nOption  = 1;
                    break;

                case MobSkill.MobSkillID.DARKNESS:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Darkness;
                    debuff.nOption  = 1;
                    break;

                case MobSkill.MobSkillID.WEAKNESS:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Weakness;
                    debuff.nOption  = 1;
                    break;

                case MobSkill.MobSkillID.CURSE:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Curse;
                    debuff.nOption  = 1;
                    break;

                case MobSkill.MobSkillID.POISON:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Poison;
                    debuff.nOption  = template.X;
                    break;

                case MobSkill.MobSkillID.SLOW:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.Slow;
                    debuff.nOption  = template.X;
                    break;

                case MobSkill.MobSkillID.REVERSE_INPUT:
                    //if (GetByType(SecondaryStatFlag.Holyshield) != null) return;
                    if (Parent.Stats.SecondaryStats.nHolyShield != 0)
                    {
                        return;
                    }
                    debuff.StatType = SecondaryStatFlag.ReverseInput;
                    debuff.nOption  = template.X;
                    break;

                default: throw new InvalidOperationException();
                }
                debuff.tDuration = template.Time * 1000 + tDelay;
                debuff.Generate(tDelay);

                Remove(debuff.nBuffID);

                Add(debuff);
            }
        }