private void AdjustCooldownAndRecharge(Character target)
        {
            Dictionary <SkillId, SkillCastingRequirement> requirements = target.GetSkillCastingRequirements();
            float cooldownRatio = 1 - info.Cmc.cdReduction * powerScale;
            float rechargeRatio = 1 - info.Cmc.rcReduction * powerScale;

            foreach (KeyValuePair <SkillId, SkillCastingRequirement> pair in requirements)
            {
                foreach (Resource res in pair.Value.Resources)
                {
                    if (res is TimeCooldownResource)
                    {
                        TimeCooldownResource tcr = (TimeCooldownResource)res;
                        timeCooldownResources.Add(tcr);
                        tcr.AdjustDurationWithRatio(cooldownRatio);
                    }

                    if (res is RecoverableChargeResource)
                    {
                        RecoverableChargeResource rcr = (RecoverableChargeResource)res;
                        recoverableChargeResources.Add(rcr);
                        rcr.AdjustDurationWithRatio(rechargeRatio);
                    }
                }
            }
        }
Example #2
0
        public void GetCooldownInfo(out bool hasCooldown, out float remainingPercentage, out float duration)
        {
            hasCooldown         = false;
            remainingPercentage = 0;
            duration            = 0;
            for (int i = 0; i < resources.Length; i++)
            {
                if (resources[i].GetType() == typeof(RecoverableChargeResource))
                {
                    RecoverableChargeResource recoverable = resources[i] as RecoverableChargeResource;
                    hasCooldown         = recoverable.Duration() > 0;
                    duration            = recoverable.Duration();
                    remainingPercentage = hasCooldown ? recoverable.RemainingPercentage(): 0;
                    break;
                }

                if (resources[i].GetType() == typeof(NonRecoverableChargeResource))
                {
                    hasCooldown         = false;
                    remainingPercentage = 0;
                    duration            = 0;
                    break;
                }

                if (resources[i].GetType() == typeof(TimeCooldownResource))
                {
                    TimeCooldownResource timeCooldown = resources[i] as TimeCooldownResource;
                    hasCooldown         = timeCooldown.Duration() > 0;
                    remainingPercentage = hasCooldown ? timeCooldown.RemainingPercentage() : 0;
                    duration            = timeCooldown.Duration();
                }
            }
        }
        protected override void OnDelayedAttachAsMain(Character target)
        {
            Dictionary <SkillId, SkillCastingRequirement> requirements = target.GetSkillCastingRequirements();

            foreach (KeyValuePair <SkillId, SkillCastingRequirement> pair in requirements)
            {
                if (pair.Key.Category.ShowParentSkillCategory() == ParentSkillCategory.Passive)
                {
                    continue;
                }
                if (info.Cbsmc.ShowMode() == CooldownBySecondModifierConfig.Mode.Local)
                {
                    if (!pair.Key.Equals(parentSkillId))
                    {
                        continue;
                    }
                }
                foreach (Resource res in pair.Value.Resources)
                {
                    if (res is TimeCooldownResource)
                    {
                        TimeCooldownResource tcr = (TimeCooldownResource)res;
                        tcr.ReduceRemainingTimeBy(info.Cbsmc.cdReduction * powerScale * multiplier);
                    }

                    if (res is RecoverableChargeResource)
                    {
                        RecoverableChargeResource rcr = (RecoverableChargeResource)res;
                        rcr.ReduceRemainingTimeBy(info.Cbsmc.rcReduction * powerScale * multiplier);
                    }
                }
            }
        }
Example #4
0
        public override void OnDamageDealt(Character caster, Character target, Skill fromSkill,
                                           Modifier fromModifier, int damage)
        {
            base.OnDamageDealt(caster, target, fromSkill, fromModifier, damage);
            SkillId skillId = null;

            if (caster == modifierTarget && fromSkill != null &&
                caster.SkillId(fromSkill, ref skillId) &&
                info.Config.IsProducerInterested(skillId.Category))
            {
                Dictionary <SkillId, SkillCastingRequirement> requirements = modifierTarget.GetSkillCastingRequirements();
                foreach (KeyValuePair <SkillId, SkillCastingRequirement> pair in requirements)
                {
                    if (!info.Config.IsConsumerInterested(pair.Key.Category))
                    {
                        continue;
                    }
                    foreach (Resource res in pair.Value.Resources)
                    {
                        if (res is TimeCooldownResource)
                        {
                            TimeCooldownResource tcr = (TimeCooldownResource)res;
                            tcr.ReduceRemainingTimeBy(info.Config.cdReduction);
                        }

                        if (res is RecoverableChargeResource)
                        {
                            RecoverableChargeResource rcr = (RecoverableChargeResource)res;
                            rcr.ReduceRemainingTimeBy(info.Config.rcReduction);
                        }
                    }
                }
            }
        }