public static void ConsumePotion(PlayerMobile player, CustomAlchemyPotion potion) { if (player != null) { double cooldown = BaseCooldown; double alchemySkill = player.Skills.Alchemy.Value; cooldown -= (alchemySkill * AlchemySkillCooldownPerSkillPoint); TimeSpan cooldownDelay = TimeSpan.FromMinutes(cooldown); player.BeginAction(typeof(CustomAlchemyPotion)); Timer.DelayCall(cooldownDelay, delegate { if (player != null) { player.EndAction(typeof(CustomAlchemyPotion)); } }); } if (potion != null) { potion.Delete(); } }
public static void UsePotion(CustomAlchemyPotion potion, Mobile from) { PlayerMobile player = from as PlayerMobile; if (player == null) { return; } if (!potion.IsChildOf(from.Backpack)) { from.SendMessage("That item must be in your pack in order to use it."); return; } if (!from.CanBeginAction(typeof(CustomAlchemyPotion)) && player.AccessLevel == AccessLevel.Player) { from.SendMessage("You must wait before using another custom alchemy potion."); return; } if (potion.PositiveEffect) { from.SendMessage("Target the creature or player to use this potion on."); } else { from.SendMessage("Target the creature to use this potion on."); } from.Target = new PotionTarget(potion, player); }
public static void ResolvePotion(PlayerMobile player, Mobile mobileTarget, CustomAlchemyPotion potion) { if (!SpecialAbilities.Exists(player)) { return; } if (!SpecialAbilities.Exists(mobileTarget)) { return; } bool positiveEffect = potion.PositiveEffect; CustomAlchemy.EffectType primaryEffect = potion.PrimaryEffect; CustomAlchemy.EffectType secondaryEffect = potion.SecondaryEffect; CustomAlchemy.EffectPotencyType potencyType = potion.EffectPotency; int throwSound = 0x5D3; int itemID = potion.ItemID; int itemHue = potion.Hue; int hitSound = Utility.RandomList(0x38E, 0x38F, 0x390); int effectSound = 0x5D8; ConsumePotion(player, potion); SpecialAbilities.HinderSpecialAbility(1.0, null, player, 1.0, 0.75, true, 0, false, "", "", "-1"); Point3D location = player.Location; Map map = player.Map; Point3D targetLocation = mobileTarget.Location; Map targetMap = mobileTarget.Map; bool drinkPotion = false; if (positiveEffect && player == mobileTarget && potencyType == EffectPotencyType.Target) { drinkPotion = true; } if (drinkPotion) { player.Animate(34, 5, 1, true, false, 0); Effects.PlaySound(player.Location, player.Map, Utility.RandomList(0x4CC, 0x4CD, 0x030, 0x031)); } else { player.Animate(31, 7, 1, true, false, 0); Effects.PlaySound(player.Location, player.Map, throwSound); } Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate { if (!SpecialAbilities.Exists(player)) { return; } //Update Target Location if MobileTarget still Valid if (mobileTarget != null && !drinkPotion) { if (Utility.GetDistance(mobileTarget.Location, targetLocation) < 20 && mobileTarget.Map == targetMap) { targetLocation = mobileTarget.Location; } } double distance = Utility.GetDistance(location, targetLocation); double destinationDelay = (double)distance * .04; IEntity startLocation = new Entity(Serial.Zero, new Point3D(location.X, location.Y, location.Z + 5), map); IEntity endLocation = new Entity(Serial.Zero, new Point3D(targetLocation.X, targetLocation.Y, targetLocation.Z + 5), targetMap); if (drinkPotion) { destinationDelay = 0; } else { Effects.SendMovingEffect(startLocation, endLocation, itemID, 10, 0, false, false, itemHue, 0); } Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate { //Update Target Location if MobileTarget still Valid if (mobileTarget != null && !drinkPotion) { if (Utility.GetDistance(mobileTarget.Location, targetLocation) < 20 && mobileTarget.Map == targetMap) { targetLocation = mobileTarget.Location; } } int primaryEffectItemId = 0x3709; int primaryEffectHue = 0; int primaryEffectSound = 0x208; int secondaryEffectItemId = 0x3709; int secondaryEffectHue = 0; int secondaryEffectSound = 0x208; List <Point3D> m_EffectLocations = new List <Point3D>(); if (drinkPotion && SpecialAbilities.Exists(player)) { m_EffectLocations.Add(player.Location); } else { int radius = 0; switch (potencyType) { case EffectPotencyType.SmallAoE: radius = 2; break; case EffectPotencyType.MediumAoE: radius = 4; break; case EffectPotencyType.LargeAoE: radius = 6; break; } int minRange = -1 * radius; int maxRange = radius + 1; for (int a = minRange; a < maxRange; a++) { for (int b = minRange; b < maxRange; b++) { Point3D newLocation = new Point3D(targetLocation.X + a, targetLocation.Y + b, targetLocation.Z); if (!m_EffectLocations.Contains(newLocation)) { m_EffectLocations.Add(newLocation); } } } } foreach (Point3D point in m_EffectLocations) { Effects.SendLocationParticles(EffectItem.Create(point, map, TimeSpan.FromSeconds(0.25)), primaryEffectItemId, 10, 30, primaryEffectHue, 0, 5029, 0); //Effect } /* * //Positive * StrengthIncrease, * DexterityIncrease, * IntelligenceIncrease, * HitsRegenIncrease, * StamRegenIncrease, * ManaRegenIncrease, * MeleeDamageDealtIncrease, * MeleeDamageResistIncrease, * SpellDamageDealtIncrease, * SpellDamageResistIncrease, * AccuracyIncrease, * EvasionIncrease, * * //Negative * Entangle, * Petrify, * FireDamage, * FrostDamage, * AbyssalDamage, * ShockDamage, * EarthDamage, * BleedDamage, * Disease, * Poison, * AccuracyReduction, * EvasionReduction * * Target, * SmallAoE, * MediumAoE, * LargeAoE */ if (drinkPotion) { } }); }); }
public PotionTarget(CustomAlchemyPotion potion, PlayerMobile player) : base(25, true, TargetFlags.None, false) { m_Potion = potion; m_Player = player; }