public static bool TeleportSavePoint(Character character, EffectInteger effect)
        {
            character.PlayEmote((byte)EmotesEnum.DrinkPotion);
            character.SpawnPoint();

            return(true);
        }
        public static bool TeleportToCity(Character character, EffectInteger effect)
        {
            character.PlayEmote((byte)EmotesEnum.DrinkPotion);

            int?mapId = null;

            switch (effect.Value)
            {
            case 104:
                mapId = 144419;     // Brackmar

                break;

            case 1436:
                mapId = 147768;     // Bonta

                break;
            }

            if (mapId.HasValue)
            {
                character.TeleportZaap(mapId.Value);

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static bool PermanentChance(Character character, EffectInteger effect)
        {
            character.Record.Stats.Chance.Additional += (short)effect.Value;
            character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 11, effect.Value);

            return(true);
        }
Example #4
0
        public override bool Apply()
        {
            EffectInteger effectInteger = this.Effect.GenerateEffect(EffectGenerationContext.Item, EffectGenerationType.Normal) as EffectInteger;
            bool          result;

            if (effectInteger == null)
            {
                result = false;
            }
            else
            {
                short num = this.AdjustBonusStat((short)((long)effectInteger.Value * (long)((ulong)base.NumberOfUses)));
                if (num == 0)
                {
                    base.Target.SendServerMessage(string.Format("Bonus limit reached : {0}", StatBonus.StatBonusLimit), Color.Red);
                    result = false;
                }
                else
                {
                    base.Target.Stats[StatBonus.GetEffectCharacteristic(this.Effect.EffectId)].Base += (int)num;
                    base.UsedItems = (uint)System.Math.Ceiling((double)num / (double)effectInteger.Value);
                    this.UpdatePermanentStatField(num);
                    base.Target.RefreshStats();
                    result = true;
                }
            }
            return(result);
        }
Example #5
0
        public override bool Apply()
        {
            bool result;

            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null)
                {
                    result = false;
                    return(result);
                }
                foreach (Buff current2 in
                         from buff in current.GetBuffs().ToArray <Buff>()
                         where buff.Dispellable
                         select buff)
                {
                    Buff expr_71 = current2;
                    expr_71.Duration -= effectInteger.Value;
                    if (current2.Duration <= 0)
                    {
                        current.RemoveAndDispellBuff(current2);
                    }
                }
                ContextHandler.SendGameActionFightModifyEffectsDurationMessage(base.Fight.Clients, base.Caster, current, Convert.ToInt16(-effectInteger.Value));
            }
            result = true;
            return(result);
        }
        public static bool AddExp(Character character, EffectInteger effect)
        {
            character.AddExperience(effect.Value);
            character.OnExperienceGained(effect.Value);

            return(true);
        }
Example #7
0
        public override bool Apply()
        {
            bool result;

            //Following code shouldn't be there.
            //If there is any reason to this code : remove commentary.
            //switch (Spell.Id)
            //{
            //    case (int)SpellIdEnum.Trance:
            //        base.Targets = SpellTargetType.ALLY_ALL;
            //        break;
            //}
            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null || this.Effect.Duration <= 0)
                {
                    return(false);
                }

                double num = (double)Caster.Stats.Health.TotalMax * ((double)effectInteger.Value / 100.0);
                base.AddStatBuff(current, (short)num, PlayerFields.Shield, true, CustomActionsEnum.Action_Shield_Buff);
            }
            result = true;
            return(result);
        }
Example #8
0
        public override bool Apply()
        {
            bool result;

            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null)
                {
                    result = false;
                    return(result);
                }
                //var entry = new TriggerBuffApplyHandler(BuffHandler);
                base.AddTriggerBuff(current, false, BuffTriggerType.TURN_BEGIN, new Fights.Buffs.TriggerBuffApplyHandler(BuffHandler));
                //Effect.Delay;
                //if (this.Effect.Duration > 0)
                //{
                //    base.AddStatBuff(current, effectInteger.Value, PlayerFields.AP, true);
                //}
                //else
                //{
                //    current.RegainAP(effectInteger.Value);
                //}
            }
            result = true;
            return(result);
        }
Example #9
0
        protected virtual void Initialize()
        {
            if ((m_moodEffect = (EffectInteger)
                                (Effects.FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LivingObjectMood))) == null)
            {
                m_moodEffect = new EffectInteger(EffectsEnum.Effect_LivingObjectMood, 0);
                Effects.Add(m_moodEffect);
            }

            if ((m_selectedLevelEffect = (EffectInteger)
                                         (Effects.FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LivingObjectSkin))) == null)
            {
                m_selectedLevelEffect = new EffectInteger(EffectsEnum.Effect_LivingObjectSkin, 1);
                Effects.Add(m_selectedLevelEffect);
            }

            if ((m_experienceEffect = (EffectInteger)
                                      (Effects.FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LivingObjectLevel))) == null)
            {
                m_experienceEffect = new EffectInteger(EffectsEnum.Effect_LivingObjectLevel, 0);
                Effects.Add(m_experienceEffect);
            }


            if ((m_categoryEffect = (EffectInteger)
                                    (Effects.FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LivingObjectCategory))) != null)
            {
                return;
            }
            m_categoryEffect = new EffectInteger(EffectsEnum.Effect_LivingObjectCategory, (short)m_record.ItemType);
            Effects.Add(m_categoryEffect);

            OnObjectModified();
        }
Example #10
0
        public override bool Apply()
        {
            bool result;

            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null)
                {
                    result = false;
                    return(result);
                }
                base.AddStatBuff(current, Convert.ToInt16(-effectInteger.Value), PlayerFields.AP, true, 168);
                if (this.Effect.Duration > 0)
                {
                    base.AddStatBuff(base.Caster, effectInteger.Value, PlayerFields.AP, true, 111);
                }
                else
                {
                    base.Caster.RegainAP(effectInteger.Value);
                }
            }
            result = true;
            return(result);
        }
Example #11
0
        public override bool Apply()
        {
            bool result;

            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null)
                {
                    result = false;
                    return(result);
                }
                FightActor          fightActor         = current;
                SpellReflectionBuff bestReflectionBuff = current.GetBestReflectionBuff();
                if (bestReflectionBuff != null && bestReflectionBuff.ReflectedLevel >= (int)base.Spell.CurrentLevel && base.Spell.Template.Id != 0)
                {
                    this.NotifySpellReflected(current);
                    current.RemoveAndDispellBuff(bestReflectionBuff);
                    fightActor = base.Caster;
                }
                if (this.Effect.Duration > 1)
                {
                    base.AddStatBuff(fightActor, Convert.ToInt16(-effectInteger.Value), PlayerFields.AP, true, 168);
                }
                else
                {
                    fightActor.LostAP(effectInteger.Value);
                }
            }
            result = true;
            return(result);
        }
        public override bool Apply()
        {
            EffectInteger effectInteger = this.Effect.GenerateEffect(EffectGenerationContext.Item, EffectGenerationType.Normal) as EffectInteger;
            bool          result;

            if (effectInteger == null)
            {
                result = false;
            }
            else
            {
                if (effectInteger.Value < 1)
                {
                    result = false;
                }
                else
                {
                    base.UsedItems = base.NumberOfUses;
                    Character expr_47 = base.Target;
                    expr_47.SpellsPoints += (ushort)((long)effectInteger.Value * (long)((ulong)base.NumberOfUses));
                    base.Target.RefreshStats();
                    result = true;
                }
            }
            return(result);
        }
Example #13
0
        private void InitializeEffects()
        {
            // new item
            if (Effects.OfType <EffectInteger>().All(x => x.EffectId != MealCountEffect))
            {
                Effects.RemoveAll(x => x.EffectId == EffectsEnum.Effect_LifePoints ||
                                  x.EffectId == EffectsEnum.Effect_LastMeal ||
                                  x.EffectId == EffectsEnum.Effect_LastMealDate ||
                                  x.EffectId == EffectsEnum.Effect_Corpulence);

                Effects.Add(LifePointsEffect = new EffectInteger(EffectsEnum.Effect_LifePoints, (short)MaxLifePoints));
                Effects.Add(new EffectInteger(EffectsEnum.Effect_MealCount, 0));

                Corpulence = 0;

                m_monsterKilledEffects = new Dictionary <int, EffectDice>();

                foreach (var monsterEffect in Effects.Where(x => x.EffectId == EffectsEnum.Effect_MonsterKilledCount).ToArray())
                {
                    Effects.Remove(monsterEffect);
                }
            }
            else
            {
                LifePointsEffect   = Effects.OfType <EffectInteger>().First(x => x.EffectId == EffectsEnum.Effect_LifePoints);
                LastMealDateEffect = Effects.OfType <EffectDate>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LastMealDate);
                LastMealEffect     = Effects.OfType <EffectInteger>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_LastMeal);
                CorpulenceEffect   = Effects.OfType <EffectDice>().FirstOrDefault(x => x.EffectId == EffectsEnum.Effect_Corpulence);

                m_monsterKilledEffects = Effects.OfType <EffectDice>().Where(x => x.EffectId == EffectsEnum.Effect_MonsterKilledCount).DistinctBy(x => x.DiceNum).ToDictionary(x => (int)x.DiceNum);
                UpdateCorpulence();
            }
        }
 public static bool PermanentVitality(Character character, EffectInteger effect)
 {
     character.Record.Stats.Vitality.Additional += (short)effect.Value;
     character.Record.Stats.LifePoints          += effect.Value;
     character.Record.Stats.MaxLifePoints       += effect.Value;
     character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 13, effect.Value);
     return(true);
 }
Example #15
0
        public EffectBase DeserializeEffect(byte[] buffer, ref int index)
        {
            if (buffer.Length < index)
            {
                throw new System.Exception("buffer too small to contain an Effect");
            }
            byte       b = buffer[index];
            EffectBase effectBase;

            switch (b)
            {
            case 1:
                effectBase = new EffectBase();
                break;

            case 2:
                effectBase = new EffectCreature();
                break;

            case 3:
                effectBase = new EffectDate();
                break;

            case 4:
                effectBase = new EffectDice();
                break;

            case 5:
                effectBase = new EffectDuration();
                break;

            case 6:
                effectBase = new EffectInteger();
                break;

            case 7:
                effectBase = new EffectLadder();
                break;

            case 8:
                effectBase = new EffectMinMax();
                break;

            case 9:
                effectBase = new EffectMount();
                break;

            case 10:
                effectBase = new EffectString();
                break;

            default:
                throw new System.Exception(string.Format("Incorrect identifier : {0}", b));
            }
            index++;
            effectBase.DeSerialize(buffer, ref index);
            return(effectBase);
        }
Example #16
0
        private void OnBuffTriggered(TriggerBuff buff, BuffTriggerType trigger, object token)
        {
            EffectInteger effectInteger = base.GenerateEffect();

            if (!(effectInteger == null))
            {
                this.HealHpPercent(buff.Target, (int)effectInteger.Value);
            }
        }
        public static void ApplyArmorBuff(TriggerBuff buff, BuffTriggerType trigger, object token)
        {
            EffectInteger effectInteger = buff.GenerateEffect();

            if (!(effectInteger == null))
            {
                buff.Target.DamageMultiplicator = effectInteger.Value / 100;
            }
        }
Example #18
0
        private static void HealBuffTrigger(TriggerBuff buff, BuffTriggerType trigger, object token)
        {
            EffectInteger effectInteger = buff.GenerateEffect();

            if (!(effectInteger == null))
            {
                buff.Target.Heal((int)effectInteger.Value, buff.Caster, true);
            }
        }
Example #19
0
        public EffectInteger GenerateEffect()
        {
            EffectInteger effectInteger = this.Effect.GenerateEffect(EffectGenerationContext.Spell, EffectGenerationType.Normal) as EffectInteger;

            if (effectInteger != null)
            {
                effectInteger.Value = (short)((double)effectInteger.Value * this.Efficiency);
            }
            return(effectInteger);
        }
Example #20
0
 public override bool Apply()
 {
     EffectInteger effectInteger = this.GenerateEffect();
     bool flag;
     if (effectInteger == null)
     {
         flag = false;
     }
     else
     {
         foreach (FightActor target in this.GetAffectedActors())
         {
             if (target.CanBeMove())
             {
                 MapPoint point1 = this.TargetedCell.Id != target.Cell.Id ? this.TargetedPoint : new MapPoint(this.CastCell);
                 if (point1.CellId != target.Position.Cell.Id)
                 {
                     DirectionsEnum direction = target.Position.Point.OrientationTo(point1, false);
                     MapPoint point2 = target.Position.Point;
                     MapPoint mapPoint1 = point2;
                     for (int index = 0; index < effectInteger.Value; ++index)
                     {
                         MapPoint nearestCellInDirection = mapPoint1.GetNearestCellInDirection(direction);
                         if (nearestCellInDirection != null)
                         {
                             if (!this.Fight.ShouldTriggerOnMove(this.Fight.Map.Cells[nearestCellInDirection.CellId]))
                             {
                                 if (this.Fight.IsCellFree(this.Map.Cells[nearestCellInDirection.CellId]))
                                 {
                                     mapPoint1 = nearestCellInDirection;
                                 }
                                 else
                                 {
                                     break;
                                 }
                             }
                             else
                             {
                                 mapPoint1 = nearestCellInDirection;
                                 break;
                             }
                         }
                         else
                             break;
                     }
                     MapPoint mapPoint2 = mapPoint1;
                     target.Position.Cell = this.Map.Cells[(int)mapPoint2.CellId];
                     ActionsHandler.SendGameActionFightSlideMessage((IPacketReceiver)this.Fight.Clients, this.Caster, target, point2.CellId, mapPoint2.CellId);
                 }
             }
         }
         flag = true;
     }
     return flag;
 }
Example #21
0
        public static void BuffHandler(TriggerBuff buff, BuffTriggerType type, object token)
        {
            EffectInteger effectInteger = buff.GenerateEffect();

            if (!(effectInteger == null))
            {
                int      id       = buff.Target.PopNextBuffId();
                StatBuff statBuff = new StatBuff(id, buff.Target, buff.Caster, buff.Effect, buff.Spell, effectInteger.Value, PlayerFields.AP, false, false);
                buff.Target.AddAndApplyBuff(statBuff, true);
            }
        }
Example #22
0
        private bool AddBonus(PetFoodRecord food)
        {
            var possibleEffect = PetTemplate.PossibleEffects.OfType <EffectDice>().FirstOrDefault(x => x.EffectId == food.BoostedEffect);
            var effect         = Effects.OfType <EffectInteger>().FirstOrDefault(x => x.EffectId == food.BoostedEffect);

            if (possibleEffect == null)
            {
                return(false);
            }

            if (effect?.Value >= possibleEffect.Max)
            {
                return(false);
            }

            if (PetTemplate.PossibleEffects.Count > 0 && EffectManager.Instance.GetItemPower(this) >= MaxPower)
            {
                return(false);
            }

            if (effect == null)
            {
                Effects.Add(effect = new EffectInteger(food.BoostedEffect, (short)food.BoostAmount));
                if (IsEquiped())
                {
                    var handler = EffectManager.Instance.GetItemEffectHandler(effect, Owner, this);
                    handler.Operation = ItemEffectHandler.HandlerOperation.APPLY;
                    handler.Apply();

                    Owner.RefreshStats();
                }
            }
            else
            {
                if (IsEquiped())
                {
                    var handler = EffectManager.Instance.GetItemEffectHandler(effect, Owner, this);
                    handler.Operation = ItemEffectHandler.HandlerOperation.UNAPPLY;
                    handler.Apply();

                    effect.Value += (short)food.BoostAmount;

                    handler.Operation = ItemEffectHandler.HandlerOperation.APPLY;
                    handler.Apply();
                    Owner.RefreshStats();
                }
                else
                {
                    effect.Value += (short)food.BoostAmount;
                }
            }

            return(true);
        }
Example #23
0
        public override bool Apply()
        {
            EffectInteger integer = base.GenerateEffect();

            if (integer == null)
            {
                return(false);
            }
            foreach (FightActor actor in base.GetAffectedActors())
            {
                if (actor.CanBeMove())
                {
                    MapPoint   startCell;
                    MapPoint   endCell;
                    FightActor actorCopy;
                    MapPoint   point = (base.TargetedCell.Id == actor.Cell.Id) ? new MapPoint(base.CastCell) : base.TargetedPoint;
                    if (point.CellId != actor.Position.Cell.Id)
                    {
                        DirectionsEnum direction = point.OrientationTo(actor.Position.Point, false);
                        startCell = actor.Position.Point;
                        MapPoint point2 = startCell;
                        for (int i = 0; i < integer.Value; i++)
                        {
                            MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction);
                            if (nearestCellInDirection == null)
                            {
                                break;
                            }
                            if (base.Fight.ShouldTriggerOnMove(base.Fight.Map.Cells[nearestCellInDirection.CellId]))
                            {
                                point2 = nearestCellInDirection;
                                break;
                            }
                            if ((nearestCellInDirection == null) || !base.Fight.IsCellFree(base.Map.Cells[nearestCellInDirection.CellId]))
                            {
                                int damage = (8 + (new AsyncRandom().Next(1, 8) * (base.Caster.Level / 50))) * (integer.Value - i);
                                actor.InflictDirectDamage(damage, base.Caster);
                                break;
                            }
                            point2 = nearestCellInDirection;
                        }
                        endCell   = point2;
                        actorCopy = actor;
                        base.Fight.ForEach(delegate(Character entry)
                        {
                            ActionsHandler.SendGameActionFightSlideMessage(entry.Client, this.Caster, actorCopy, startCell.CellId, endCell.CellId);
                        });
                        actor.Position.Cell = base.Map.Cells[endCell.CellId];
                    }
                }
            }
            return(true);
        }
Example #24
0
        public static void RemoveArmorBuff(TriggerBuff buff)
        {
            EffectInteger effectInteger = buff.GenerateEffect();

            if (!(effectInteger == null))
            {
                foreach (PlayerFields current in DamageArmor.GetAssociatedCaracteristics(buff.Spell.Id))
                {
                    buff.Target.Stats[current].Context -= buff.Target.CalculateArmorValue((int)effectInteger.Value);
                }
            }
        }
Example #25
0
        private int DeBoostEffect(EffectInteger runeEffect)
        {
            var   pwrToLose = (int)Math.Ceiling(EffectManager.Instance.GetEffectPower(runeEffect));
            short residual  = 0;

            if (ItemToImprove.PlayerItem.PowerSink > 0)
            {
                residual = (short)-Math.Min(pwrToLose, ItemToImprove.PlayerItem.PowerSink);
                ItemToImprove.PlayerItem.PowerSink += residual;
                pwrToLose += residual;
            }

            if (pwrToLose == 0)
            {
                return(residual);
            }

            while (pwrToLose > 0)
            {
                var effect = GetEffectToDown(runeEffect);

                if (effect == null)
                {
                    break;
                }

                var maxLost = (int)Math.Ceiling(EffectManager.Instance.GetEffectBasePower(runeEffect) / Math.Abs(EffectManager.Instance.GetEffectBasePower(effect)));

                var rand = new CryptoRandom();
                var lost = rand.Next(1, maxLost + 1);

                var oldValue = effect.Value;

                effect.Value -= (short)((effect.Template.BonusType == -1 ? -1 : 1) * lost);
                pwrToLose    -= (int)Math.Ceiling(lost * Math.Abs(EffectManager.Instance.GetEffectBasePower(effect)));

                if (effect.Value == 0 || (effect.Value < 0 && oldValue > 0))
                {
                    ItemToImprove.Effects.Remove(effect);
                }
                else if (effect.Value < 0 && effect.Value >= -lost && effect.Template.OppositeId > 0) // from positiv to negativ stat
                {
                    ItemToImprove.Effects.Remove(effect);
                    ItemToImprove.Effects.Add(new EffectInteger((EffectsEnum)effect.Template.OppositeId, (short)-effect.Value));
                }
            }

            residual = (short)(pwrToLose < 0 ? -pwrToLose : 0);
            ItemToImprove.PlayerItem.PowerSink += residual;

            return(residual);
        }
Example #26
0
        public virtual void AddEffectInteger(EffectsEnum effect, ushort value)
        {
            EffectInteger current = FirstEffect <EffectInteger>(effect);

            if (current == null)
            {
                Effects.Add(new EffectInteger((ushort)effect, value));
            }
            else
            {
                current.Value += value;
            }
        }
Example #27
0
        public BoundLivingObjectItem(Character owner, PlayerItemRecord record) : base(owner, record)
        {
            EffectInteger effectInteger = (EffectInteger)this.Effects.First((EffectBase x) => x.EffectId == EffectsEnum.Effect_LivingObjectId);

            this.m_livingObjectTemplate = Singleton <ItemManager> .Instance.TryGetTemplate((int)effectInteger.Value);

            base.LivingObjectRecord = Singleton <ItemManager> .Instance.TryGetLivingObjectRecord((int)effectInteger.Value);

            if (base.LivingObjectRecord == null || this.m_livingObjectTemplate == null)
            {
                BoundLivingObjectItem.logger.Error("Living Object {0} has no template", this.Template.Id);
            }
            this.Initialize();
        }
Example #28
0
        public override bool Apply()
        {
            bool result;

            foreach (FightActor current in base.GetAffectedActors())
            {
                EffectInteger effectInteger = base.GenerateEffect();
                if (effectInteger == null)
                {
                    result = false;
                    return(result);
                }
                short num = effectInteger.Value;
                if (this.Effect.EffectId != EffectsEnum.Effect_LosingMP)
                {
                    num = 0;
                    int num2 = 0;
                    while (num2 < (int)effectInteger.Value && (int)num < current.MP)
                    {
                        if (current.RollMPLose(base.Caster))
                        {
                            num += 1;
                        }
                        num2++;
                    }
                    short num3 = Convert.ToInt16(effectInteger.Value - num);
                    if (num3 > 0)
                    {
                        ActionsHandler.SendGameActionFightDodgePointLossMessage(base.Fight.Clients, ActionsEnum.ACTION_FIGHT_SPELL_DODGED_PM, base.Caster, current, num3);
                    }
                }
                if (num <= 0)
                {
                    result = false;
                    return(result);
                }
                if (this.Effect.Duration > 1)
                {
                    base.AddStatBuff(current, Convert.ToInt16(-num), PlayerFields.MP, true);
                }
                else
                {
                    current.LostMP(num);
                }
            }
            result = true;
            return(result);
        }
        private static void DamageBuffTrigger(TriggerBuff buff, BuffTriggerType trigger, object token)
        {
            EffectInteger left = buff.GenerateEffect();

            if (!(left == null))
            {
                Fights.Damage damage = new Fights.Damage(buff.Dice, DamagePercent.GetEffectSchool(buff.Dice.EffectId), buff.Caster, buff.Spell)
                {
                    Buff = buff
                };
                damage.GenerateDamages();
                damage.Amount            = (int)((double)buff.Target.MaxLifePoints * ((double)damage.Amount / 100.0));
                damage.IgnoreDamageBoost = true;
                buff.Target.InflictDamage(damage);
            }
        }
Example #30
0
        public override bool Apply()
        {
            EffectInteger effectInteger = this.Effect.GenerateEffect(EffectGenerationContext.Item, EffectGenerationType.Normal) as EffectInteger;
            bool          result;

            if (effectInteger == null)
            {
                result = false;
            }
            else
            {
                base.UsedItems = base.NumberOfUses;
                base.Target.Spells.LearnSpell((int)effectInteger.Value);
                result = true;
            }
            return(result);
        }