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()); }
/// <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); }