Ejemplo n.º 1
0
        private static void Curaga1(AbilityBuilder builder)
        {
            builder.Create(Feat.Curaga1, PerkType.Curaga)
            .Name("Curaga I")
            .HasRecastDelay(RecastGroup.Curaga1, 12f)
            .HasActivationDelay(4.0f)
            .RequirementMP(12)
            .UsesActivationType(AbilityActivationType.Casted)
            .DisplaysVisualEffectWhenActivating()
            .HasImpactAction((activator, target, level) =>
            {
                var bonus = GetAbilityModifier(AbilityType.Wisdom, activator);

                foreach (var member in Party.GetAllPartyMembersWithinRange(activator, 5.0f))
                {
                    var amount = Random.D6(2) + bonus;

                    ApplyEffectToObject(DurationType.Instant, GetRacialType(target) == RacialType.Undead
                            ? EffectDamage(amount)
                            : EffectHeal(amount), target);

                    ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Healing_S), member);

                    Enmity.ModifyEnmityOnAll(activator, amount);
                }

                CombatPoint.AddCombatPointToAllTagged(activator, SkillType.WhiteMagic, 3);
            });
        }
Ejemplo n.º 2
0
        private static IEnumerable <uint> SpawnLoot(uint creature, string lootTableName, int chance, int attempts)
        {
            var gilfinderLevel      = GetLocalInt(creature, "GILFINDER_LEVEL");
            var gilPercentIncrease  = gilfinderLevel * 0.2f;
            var treasureHunterLevel = GetLocalInt(creature, "TREASURE_HUNTER_LEVEL");

            var table = GetLootTableByName(lootTableName);

            for (int x = 1; x <= attempts; x++)
            {
                if (Random.D100(1) > chance)
                {
                    continue;
                }

                var item     = table.GetRandomItem(treasureHunterLevel);
                var quantity = Random.Next(item.MaxQuantity) + 1;

                // Gilfinder perk - Increase the quantity of gold found.
                if (item.Resref == "nw_it_gold001")
                {
                    quantity += (int)(quantity * gilPercentIncrease);
                }

                yield return(CreateItemOnObject(item.Resref, creature, quantity));
            }
        }
        private static void RecoveryStab3(AbilityBuilder builder)
        {
            builder.Create(Feat.RecoveryStab3, PerkType.RecoveryStab)
            .Name("Recovery Stab III")
            .HasRecastDelay(RecastGroup.RecoveryStab, 60f)
            .RequirementStamina(16)
            .UsesActivationType(AbilityActivationType.Weapon)
            .HasImpactAction((activator, target, level) =>
            {
                var bonus = GetAbilityModifier(AbilityType.Wisdom, activator);
                foreach (var member in Party.GetAllPartyMembersWithinRange(activator, 5.0f))
                {
                    var amount   = Random.D8(3) + bonus;
                    var duration = 24f;

                    if (StatusEffect.HasStatusEffect(activator, StatusEffectType.DeliberateStab))
                    {
                        duration *= 2f;
                    }

                    ApplyEffectToObject(DurationType.Instant, EffectHeal(amount), member);
                    ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Healing_S), member);
                    ApplyEffectToObject(DurationType.Temporary, EffectRegenerate(1, 6f), member, duration);


                    Enmity.ModifyEnmityOnAll(activator, amount + 6);
                }

                CombatPoint.AddCombatPointToAllTagged(activator, SkillType.RedMagic, 3);
                Enmity.ModifyEnmityOnAll(activator, 10);
            });
        }
Ejemplo n.º 4
0
        public Dictionary <Feat, AbilityDetail> BuildAbilities()
        {
            var builder = new AbilityBuilder()
                          .Create(Feat.Sleep, PerkType.Sleep)
                          .Name("Sleep")
                          .HasRecastDelay(RecastGroup.Sleep, 12f)
                          .HasActivationDelay(2f)
                          .RequirementMP(8)
                          .UsesActivationType(AbilityActivationType.Casted)
                          .DisplaysVisualEffectWhenActivating()
                          .HasImpactAction((activator, target, level) =>
            {
                var resistance   = Resistance.GetResistance(target, ResistanceType.Sleep);
                var baseDuration = Random.NextFloat(15.0f, 30.0f);
                var duration     = baseDuration * resistance;

                StatusEffect.Apply(activator, target, StatusEffectType.Sleep, duration);
                Resistance.ModifyResistance(target, ResistanceType.Sleep, -0.25f);

                CombatPoint.AddCombatPoint(activator, target, SkillType.BlackMagic, 3);
                Enmity.ModifyEnmity(activator, target, 18);
            });

            return(builder.Build());
        }
Ejemplo n.º 5
0
        private static void Dia2(StatusEffectBuilder builder)
        {
            builder.Create(StatusEffectType.Dia2)
            .Name("Dia II")
            .EffectIcon(154)
            .GrantAction((target, duration) =>
            {
                if (StatusEffect.HasStatusEffect(target, StatusEffectType.Dia3))
                {
                    SendMessageToPC(target, "A more powerful version of Dia is already in effect.");
                    StatusEffect.Remove(target, StatusEffectType.Dia2);
                    return;
                }

                StatusEffect.Remove(target, StatusEffectType.Dia1);
            })
            .TickAction((activator, target) =>
            {
                var damage = Random.D4(1);

                AssignCommand(activator, () =>
                {
                    ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Positive), target);
                });
            });
        }
        private static void AttemptSteal(uint activator, uint target, int baseChance)
        {
            var delta = 0.0f;

            // Players who use this ability have their Thievery skill checked against the CR
            // of the target. Other users simply have a delta of zero.
            if (GetIsPC(activator) && !GetIsDM(activator))
            {
                var playerId = GetObjectUUID(activator);
                var dbPlayer = DB.Get <Player>(playerId);
                var cr       = GetChallengeRating(target) * 3;
                var thievery = dbPlayer.Skills[SkillType.Thievery];

                delta = (thievery.Rank - cr) * 0.01f;
            }

            var chance = baseChance + (delta * baseChance);

            if (chance < 1)
            {
                chance = 1;
            }
            else if (chance > 95)
            {
                chance = 95;
            }

            if (Random.D100(1) <= chance)
            {
                for (var item = GetFirstItemInInventory(target); GetIsObjectValid(item); item = GetNextItemInInventory(target))
                {
                    // This item can be stolen. Copy it to the thief now.
                    if (GetLocalBool(item, "STEAL_ITEM"))
                    {
                        DeleteLocalBool(item, "STEAL_ITEM");
                        CopyItem(item, activator, true);

                        Messaging.SendMessageNearbyToPlayers(activator, $"{GetName(activator)} successfully steals '{GetName(item)}' from {GetName(target)}.");

                        DestroyObject(item);
                        break;
                    }
                }
            }
            else
            {
                SendMessageToPC(activator, $"You failed to steal from {GetName(target)}.");
            }

            CombatPoint.AddCombatPoint(activator, target, SkillType.Thievery, 3);
            Enmity.ModifyEnmity(activator, target, 5);
        }
 private static void Stone3(AbilityBuilder builder)
 {
     builder.Create(Feat.Stone3, PerkType.Stone)
     .Name("Stone III")
     .HasRecastDelay(RecastGroup.Stone, 4f)
     .HasActivationDelay(2.0f)
     .RequirementMP(7)
     .UsesActivationType(AbilityActivationType.Casted)
     .DisplaysVisualEffectWhenActivating()
     .HasImpactAction((activator, target, level) =>
     {
         ApplyStoneEffects(activator, target, Random.D10(2), 14);
     });
 }
 private static void Thunder3(AbilityBuilder builder)
 {
     builder.Create(Feat.Thunder3, PerkType.Thunder)
     .Name("Thunder III")
     .HasRecastDelay(RecastGroup.Thunder, 4f)
     .HasActivationDelay(4.0f)
     .RequirementMP(8)
     .UsesActivationType(AbilityActivationType.Casted)
     .DisplaysVisualEffectWhenActivating()
     .HasImpactAction((activator, target, level) =>
     {
         ApplyThunderEffects(activator, target, Random.D12(2), 15, 6f);
         ApplyAOEThunderEffects(activator, target, Random.D12(2), 15, 6f);
     });
 }
 private static void Fire3(AbilityBuilder builder)
 {
     builder.Create(Feat.Fire3, PerkType.Fire)
     .Name("Fire III")
     .HasRecastDelay(RecastGroup.Fire, 3f)
     .HasActivationDelay(3.0f)
     .RequirementMP(7)
     .UsesActivationType(AbilityActivationType.Casted)
     .DisplaysVisualEffectWhenActivating()
     .HasImpactAction((activator, target, level) =>
     {
         ApplyFireEffects(activator, target, Random.D12(2), 15, 30f);
         ApplyAOEFireEffects(activator, target, Random.D12(2), 15, 30f);
     });
 }
 private static void Blizzard3(AbilityBuilder builder)
 {
     builder.Create(Feat.Blizzard3, PerkType.Blizzard)
     .Name("Blizzard III")
     .HasRecastDelay(RecastGroup.Blizzard, 2f)
     .HasActivationDelay(2.0f)
     .RequirementMP(6)
     .UsesActivationType(AbilityActivationType.Casted)
     .DisplaysVisualEffectWhenActivating()
     .HasImpactAction((activator, target, level) =>
     {
         ApplyBlizzardEffects(activator, target, Random.D8(2), 10, 30f);
         ApplyAOEBlizzardEffects(activator, target, Random.D8(2), 10, 30f);
     });
 }
        private static void Chakra1(AbilityBuilder builder)
        {
            builder.Create(Feat.Chakra1, PerkType.Chakra)
            .Name("Chakra I")
            .HasRecastDelay(RecastGroup.Chakra, 30f)
            .HasActivationDelay(2f)
            .UsesActivationType(AbilityActivationType.Casted)
            .RequirementStamina(10)
            .HasImpactAction((activator, target, level) =>
            {
                var hpRecover = Random.D6(2);
                ApplyEffectToObject(DurationType.Instant, EffectHeal(hpRecover), target);
                ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Healing_S), target);

                CombatPoint.AddCombatPointToAllTagged(activator, SkillType.Chi, 2);
                Enmity.ModifyEnmityOnAll(activator, 6 + hpRecover);
            });
        }
Ejemplo n.º 12
0
        private static void ElectricFist1(AbilityBuilder builder)
        {
            builder.Create(Feat.ElectricFist1, PerkType.ElectricFist)
            .Name("Electric Fist I")
            .HasRecastDelay(RecastGroup.ElectricFist, 60f)
            .UsesActivationType(AbilityActivationType.Weapon)
            .RequirementStamina(3)
            .HasImpactAction((activator, target, level) =>
            {
                var modifier = GetAbilityModifier(AbilityType.Wisdom, activator);
                modifier     = modifier > 0 ? modifier : 0;
                var damage   = Random.D4(2) + modifier;
                ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Electrical), target);
                ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Com_Hit_Electrical), target);

                CombatPoint.AddCombatPoint(activator, target, SkillType.Chi, 3);
                Enmity.ModifyEnmityOnAll(activator, 6 + damage);
            });
        }
        private static void Jolt3(AbilityBuilder builder)
        {
            builder.Create(Feat.Jolt3, PerkType.Jolt)
            .Name("Jolt III")
            .HasRecastDelay(RecastGroup.Jolt, 4f)
            .RequirementMP(12)
            .UsesActivationType(AbilityActivationType.Casted)
            .HasActivationDelay(2f)
            .HasImpactAction((activator, target, level) =>
            {
                var damage = Random.D10(2);

                ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Com_Hit_Electrical), target);
                ApplyEffectToObject(DurationType.Instant, EffectDamage(damage), target);

                Enmity.ModifyEnmity(activator, target, damage + 8);
                CombatPoint.AddCombatPoint(activator, target, SkillType.RedMagic, 3);
            });
        }
Ejemplo n.º 14
0
        private static void Cure3(AbilityBuilder builder)
        {
            builder.Create(Feat.Cure3, PerkType.Cure)
            .Name("Cure III")
            .HasRecastDelay(RecastGroup.Cure3, 5f)
            .HasActivationDelay(2.0f)
            .RequirementMP(15)
            .UsesActivationType(AbilityActivationType.Casted)
            .DisplaysVisualEffectWhenActivating()
            .HasImpactAction((activator, target, level) =>
            {
                var amount = Random.D8(3) + GetAbilityModifier(AbilityType.Wisdom, activator);

                ApplyEffectToObject(DurationType.Instant, EffectHeal(amount), target);
                ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Healing_M), target);

                Enmity.ModifyEnmityOnAll(activator, amount);
                CombatPoint.AddCombatPointToAllTagged(activator, SkillType.WhiteMagic, 3);
            });
        }
Ejemplo n.º 15
0
        private static void Bash(AbilityBuilder builder)
        {
            builder.Create(Feat.Bash, PerkType.Bash)
            .Name("Bash")
            .HasRecastDelay(RecastGroup.Bash, 12f)
            .RequirementStamina(5)
            .UsesActivationType(AbilityActivationType.Weapon)
            .HasImpactAction((activator, target, level) =>
            {
                var damage = Random.D4(1);
                var length = 1f + GetAbilityModifier(AbilityType.Constitution, activator) * 0.5f;

                ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Confusion_S), target);
                ApplyEffectToObject(DurationType.Temporary, EffectStunned(), target, length);
                ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Bludgeoning), target);

                Enmity.ModifyEnmity(activator, target, 4);
                CombatPoint.AddCombatPoint(activator, target, SkillType.Chivalry, 2);
            });
        }
        private static void Bleed3(StatusEffectBuilder builder)
        {
            builder.Create(StatusEffectType.Bleed3)
            .Name("Bleed III")
            .EffectIcon(159)
            .GrantAction((target, duration) =>
            {
                StatusEffect.Remove(target, StatusEffectType.Bleed1);
                StatusEffect.Remove(target, StatusEffectType.Bleed3);
            })
            .TickAction((activator, target) =>
            {
                var damage = Random.D6(2);

                AssignCommand(activator, () =>
                {
                    ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Piercing), target);
                });
            });
        }
Ejemplo n.º 17
0
        private static void Dia3(StatusEffectBuilder builder)
        {
            builder.Create(StatusEffectType.Dia3)
            .Name("Dia III")
            .EffectIcon(155)
            .GrantAction((target, duration) =>
            {
                StatusEffect.Remove(target, StatusEffectType.Dia1);
                StatusEffect.Remove(target, StatusEffectType.Dia2);
            })
            .TickAction((activator, target) =>
            {
                var damage = Random.D6(1);

                AssignCommand(activator, () =>
                {
                    ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Positive), target);
                });
            });
        }
        private static void RecoveryStab1(AbilityBuilder builder)
        {
            builder.Create(Feat.RecoveryStab1, PerkType.RecoveryStab)
            .Name("Recovery Stab I")
            .HasRecastDelay(RecastGroup.RecoveryStab, 60f)
            .RequirementStamina(8)
            .UsesActivationType(AbilityActivationType.Weapon)
            .HasImpactAction((activator, target, level) =>
            {
                var bonus = GetAbilityModifier(AbilityType.Wisdom, activator);
                foreach (var member in Party.GetAllPartyMembersWithinRange(activator, 5.0f))
                {
                    var amount = Random.D6(2) + bonus;

                    ApplyEffectToObject(DurationType.Instant, EffectHeal(amount), member);
                    ApplyEffectToObject(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Imp_Healing_S), member);

                    Enmity.ModifyEnmityOnAll(activator, amount + 2);
                }

                CombatPoint.AddCombatPointToAllTagged(activator, SkillType.RedMagic, 3);
                Enmity.ModifyEnmityOnAll(activator, 6);
            });
        }
        private static void Bleed1(StatusEffectBuilder builder)
        {
            builder.Create(StatusEffectType.Bleed1)
            .Name("Bleed I")
            .EffectIcon(157)
            .GrantAction((target, duration) =>
            {
                if (StatusEffect.HasStatusEffect(target, StatusEffectType.Bleed2) ||
                    StatusEffect.HasStatusEffect(target, StatusEffectType.Bleed3))
                {
                    SendMessageToPC(target, "A more powerful version of Bleed is already in effect.");
                    StatusEffect.Remove(target, StatusEffectType.Bleed1);
                }
            })
            .TickAction((activator, target) =>
            {
                var damage = Random.D4(1);

                AssignCommand(activator, () =>
                {
                    ApplyEffectToObject(DurationType.Instant, EffectDamage(damage, DamageType.Piercing), target);
                });
            });
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Handles the auto-craft procedure. This is an automatic (no mini-game) form of crafting
        /// where success is determined by a player's stats. This simply creates the item on a successful crafting attempt.
        /// </summary>
        /// <param name="player">The player performing the auto-craft.</param>
        private static void AutoCraftItem(uint player)
        {
            var state  = Craft.GetPlayerCraftingState(player);
            var device = OBJECT_SELF;

            float CalculateAutoCraftingDelay()
            {
                var baseDelay = 20f;
                var perk      = _autoCraftPerk[state.DeviceSkillType];

                switch (Perk.GetEffectivePerkLevel(player, perk))
                {
                case 2: baseDelay -= 4; break;

                case 3: baseDelay -= 8; break;

                case 4: baseDelay -= 12; break;

                case 5: baseDelay -= 16; break;
                }

                return(baseDelay);
            }

            void CraftItem(bool isSuccessful)
            {
                var recipe = Craft.GetRecipe(state.SelectedRecipe);

                var playerComponents    = GetComponents(player, device);
                var remainingComponents = recipe.Components.ToDictionary(x => x.Key, y => y.Value);

                for (var index = playerComponents.Count - 1; index >= 0; index--)
                {
                    var component = playerComponents[index];
                    var resref    = GetResRef(component);

                    // Item does not need any more of this component type.
                    if (!remainingComponents.ContainsKey(resref))
                    {
                        continue;
                    }

                    var quantity = GetItemStackSize(component);

                    // Player's component stack size is greater than the amount required.
                    if (quantity > remainingComponents[resref])
                    {
                        SetItemStackSize(component, quantity - remainingComponents[resref]);
                        remainingComponents[resref] = 0;
                    }
                    // Player's component stack size is less than or equal to the amount required.
                    else if (quantity <= remainingComponents[resref])
                    {
                        remainingComponents[resref] -= quantity;
                        DestroyObject(component);
                    }

                    if (remainingComponents[resref] <= 0)
                    {
                        remainingComponents.Remove(resref);
                    }
                }

                if (isSuccessful)
                {
                    CreateItemOnObject(recipe.Resref, player, recipe.Quantity);
                }
            }

            if (!HasAllComponents(player, device))
            {
                SendMessageToPC(player, ColorToken.Red("You are missing some necessary components..."));
                return;
            }

            var craftingDelay = CalculateAutoCraftingDelay();

            state.IsAutoCrafting = true;
            Player.StartGuiTimingBar(player, craftingDelay);
            AssignCommand(player, () => ActionPlayAnimation(Animation.LoopingGetMid, 1f, craftingDelay));
            DelayCommand(craftingDelay, () =>
            {
                // Player logged out.
                if (!GetIsObjectValid(player))
                {
                    Craft.ClearPlayerCraftingState(player);
                    return;
                }

                var chanceToCraft = Craft.CalculateChanceToCraft(player, state.SelectedRecipe);
                var roll          = Random.NextFloat(0f, 100f);

                if (roll <= chanceToCraft)
                {
                    CraftItem(true);
                }
                else
                {
                    CraftItem(false);
                    SendMessageToPC(player, ColorToken.Red("You failed to craft the item..."));
                }

                state.IsAutoCrafting = false;
            });
            ApplyEffectToObject(DurationType.Temporary, EffectCutsceneParalyze(), player, craftingDelay);
        }