示例#1
0
        public static ForceDamageResult CalculateForceDamage(
            NWCreature caster,
            NWCreature target,
            ForceAbilityType abilityType,
            int basePotency,
            float tier1Modifier,
            float tier2Modifier,
            float tier3Modifier,
            float tier4Modifier)
        {
            ForceResistanceResult resistance = CalculateResistanceRating(caster, target, abilityType);
            int itemBonus = CalculateItemPotencyBonus(caster, abilityType);

            int casterPrimary   = 0;
            int casterSecondary = 0;
            int targetPrimary   = 0;
            int targetSecondary = 0;

            switch (abilityType)
            {
            case ForceAbilityType.Electrical:
                casterPrimary   = caster.Intelligence;
                casterSecondary = caster.Wisdom;
                targetPrimary   = target.Intelligence;
                targetSecondary = target.Wisdom;
                break;

            case ForceAbilityType.Mind:
                casterPrimary   = caster.Wisdom;
                casterSecondary = caster.Intelligence;
                targetPrimary   = target.Wisdom;
                targetSecondary = target.Intelligence;
                break;

            case ForceAbilityType.Light:
                casterPrimary   = caster.Wisdom;
                casterSecondary = caster.Intelligence;
                targetPrimary   = target.Intelligence;
                targetSecondary = target.Wisdom;
                break;

            case ForceAbilityType.Dark:
                casterPrimary   = caster.Intelligence;
                casterSecondary = caster.Wisdom;
                targetPrimary   = target.Wisdom;
                targetSecondary = target.Intelligence;
                break;
            }

            // Calculate delta between caster's primary/secondary stats and target's primary and secondary stats
            int delta = (int)((casterPrimary + casterSecondary * 0.5f) - (targetPrimary + targetSecondary * 0.5f));

            float multiplier;

            // Not every ability will have tiers 2-4. Default to the next lowest one if it's missing.
            if (delta <= 49 || tier2Modifier <= 0.0f)
            {
                multiplier = tier1Modifier;
            }
            else if (delta <= 99 || tier3Modifier <= 0.0f)
            {
                multiplier = tier2Modifier;
            }
            else if (delta <= 199 || tier4Modifier <= 0.0f)
            {
                multiplier = tier3Modifier;
            }
            else
            {
                multiplier = tier4Modifier;
            }

            //caster.SendMessage("casterPrimary = " + casterPrimary + ", casterSecondary = " + casterSecondary + ", targetPrimary = " + targetPrimary + ", targetSecondary = " + targetSecondary);
            //caster.SendMessage("itemBonus = " + itemBonus + ", basePotency = " + basePotency + ", delta = " + delta + ", multiplier = " + multiplier + ", resistanceMultiplier = " + resistanceMultiplier);

            // Combine everything together to get the damage result.
            int damage = (int)((itemBonus + basePotency + (delta * multiplier)) * resistance.Amount);

            if (damage > 0)
            {
                damage += RandomService.D8(1);
            }

            if (damage <= 1)
            {
                damage = 1;
            }

            ForceDamageResult result = new ForceDamageResult
            {
                Damage     = damage,
                Resistance = resistance,
                ItemBonus  = itemBonus
            };

            // If this ability was resisted in any way, notify the caster.
            if (resistance.Type != ResistanceType.Zero)
            {
                string name = GetForceResistanceName(resistance.Type);
                caster.SendMessage("Your force ability was resisted. " + name);
            }

            return(result);
        }
示例#2
0
        public void OnImpact(NWPlayer player, NWObject target, int level, int spellFeatID)
        {
            float length;
            int   damage;

            switch (level)
            {
            case 1:
                damage = RandomService.D4(1);
                length = 3;
                break;

            case 2:
                damage = RandomService.D4(1);
                length = 6;
                break;

            case 3:
                damage = RandomService.D6(1);
                length = 6;
                break;

            case 4:
                damage = RandomService.D8(1);
                length = 6;
                break;

            case 5:
                damage = RandomService.D8(1);
                length = 9;
                break;

            default: return;
            }
            SkillService.RegisterPCToNPCForSkill(player, target, SkillType.ForceCombat);

            // Resistance affects length for this perk.
            ForceResistanceResult resistance = CombatService.CalculateResistanceRating(player, target.Object, ForceAbilityType.Mind);

            length = length * resistance.Amount;

            if (length <= 0.0f || resistance.Type != ResistanceType.Zero)
            {
                player.SendMessage("Your Force Push effect was resisted.");
                return;
            }

            var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player);
            int luck           = PerkService.GetPCPerkLevel(player, PerkType.Lucky) + effectiveStats.Luck;

            if (RandomService.Random(100) + 1 <= luck)
            {
                length = length * 2;
                player.SendMessage("Lucky force push!");
            }

            _.PlaySound("v_imp_frcpush");
            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectDamage(damage, DAMAGE_TYPE_POSITIVE), target);
            _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectKnockdown(), target, length);
            CombatService.AddTemporaryForceDefense(target.Object, ForceAbilityType.Light);
        }
示例#3
0
        public static ForceResistanceResult CalculateResistanceRating(
            NWCreature caster,
            NWCreature target,
            ForceAbilityType forceAbility)
        {
            int accuracy = CalculateForceAccuracy(caster, target, forceAbility);
            ForceResistanceResult result = new ForceResistanceResult();

            // Do four checks to see if the attacker overcomes the defender's
            // resistance.  The more checks you succeed, the lower the resistance.
            int successes = 0;

            if (RandomService.D100(1) <= accuracy)
            {
                successes++;

                if (RandomService.D100(1) <= accuracy)
                {
                    successes++;

                    if (RandomService.D100(1) <= accuracy)
                    {
                        successes++;

                        if (RandomService.D100(1) <= accuracy)
                        {
                            successes++;
                        }
                    }
                }
            }

            switch (successes)
            {
            case 0:
                result.Amount = 0f;
                result.Type   = ResistanceType.Full;
                break;

            case 1:
                result.Amount = 0.125f;
                result.Type   = ResistanceType.Eighth;
                break;

            case 2:
                result.Amount = 0.25f;
                result.Type   = ResistanceType.Fourth;
                break;

            case 3:
                result.Amount = 0.5f;
                result.Type   = ResistanceType.Half;
                break;

            case 4:
                result.Amount = 1.0f;
                result.Type   = ResistanceType.Zero;
                break;
            }

            return(result);
        }