public TransformResult Render(string templatePath, IDictionary<string, object> parameters)
        {
            try
            {
                if (!File.Exists(templatePath)) throw new FileNotFoundException("Template file not found.", templatePath);

                var serviceProvider = _context.ServiceProvider;

                var templating = serviceProvider.GetService(typeof(STextTemplating)) as ITextTemplating;
                var sessionHost = templating as ITextTemplatingSessionHost;

                sessionHost.Session = sessionHost.CreateSession();
                foreach (var parameter in parameters) sessionHost.Session[parameter.Key] = parameter.Value;

                var transformContext = new TransformContext();

                var output = templating.ProcessTemplate(templatePath, File.ReadAllText(templatePath), transformContext);

                return new TransformResult(output, transformContext.Errors.Select(x => new Exception(x)));
            }
            catch (Exception e)
            {
                return new TransformResult(null, new [] {e});
            }
        }
Exemplo n.º 2
0
		static int SearchDownwardKill(TransformContext context, Statement st, StatementBlock block, int startIndex) {
			Variable[] usage = context.Usages[st];
			Variable[] definition = context.Definitions[st];
			for (int i = startIndex + 1; i < block.Statements.Count; i++) {
				if (context.Usages[block.Statements[i]].Intersect(definition).Count() > 0 ||
				    context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0)
					return i;
			}
			return block.Statements.Count - 1;
		}
        /// <summary>
        /// Returns a stream with the encryption bits in place to ensure proper message encryption
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="provider">The crypto stream provider</param>
        /// <param name="stream">The original stream to which the encrypted message content is written</param>
        /// <param name="context">The second context of the message</param>
        /// <returns>A stream for serializing the message which will be encrypted</returns>
        public static Stream GetEncryptStream(this ICryptoStreamProvider provider, Stream stream, TransformContext context)
        {
            if (context == null)
                throw new ArgumentNullException(nameof(context));

            object keyIdObj;
            string keyId = context.Headers.TryGetHeader(EncryptedMessageSerializer.EncryptionKeyHeader, out keyIdObj)
                ? keyIdObj.ToString()
                : default(string);

            return provider.GetEncryptStream(stream, keyId, CryptoStreamMode.Write);
        }
Exemplo n.º 4
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Instruction != IRInstruction.AddressOf)
            {
                return(false);
            }

            if (!IsParameter(context.Operand1.Definitions[0].Operand1))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand2.IsResolvedConstant)
            {
                return(false);
            }

            var previous = GetPreviousNodeUntil(context, IRInstruction.LoadR8, transformContext.Window, context.Result);

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

            if (!previous.Operand2.IsResolvedConstant)
            {
                return(false);
            }

            if (previous.Operand1 != context.Operand1)
            {
                return(false);
            }

            if (previous.Operand2.ConstantUnsigned64 != context.Operand2.ConstantUnsigned64)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsResolvedConstant)
            {
                return(false);
            }

            if (context.Operand1.ConstantUnsigned64 != 0)
            {
                return(false);
            }

            if (!IsResolvedConstant(context.Operand2))
            {
                return(false);
            }

            if (IsZero(context.Operand2))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand2.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand2.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Instruction != IRInstruction.And32)
            {
                return(false);
            }

            if (!AreSame(context.Operand1, context.Operand2.Definitions[0].Operand1))
            {
                return(false);
            }

            return(true);
        }
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!IsResolvedConstant(context.Operand2))
            {
                return(false);
            }

            if (!IsPowerOfTwo64(context.Operand2))
            {
                return(false);
            }

            if (IsZero(context.Operand2))
            {
                return(false);
            }

            if (IsOne(context.Operand2))
            {
                return(false);
            }

            return(true);
        }
        public void evaluates_equality_of_int_and_bool()
        {
            var services = new InMemoryServiceLocator();

            services.Add <IMappingVariableExpander>(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services));
            var arguments = new TransformArguments(services, new Dictionary <string, object>
            {
                { "field", "status" },
                { "value", true }
            });

            var data = new ModelData();

            var context   = new TransformContext(data, arguments, new InMemoryServiceLocator());
            var transform = new IsEqualTransform();

            data["status"] = 1;
            transform.Execute(context).ShouldEqual(true);

            data["status"] = 0;
            transform.Execute(context).ShouldEqual(false);

            arguments = new TransformArguments(services, new Dictionary <string, object>
            {
                { "field", "status" },
                { "value", 1 }
            });

            context = new TransformContext(data, arguments, new InMemoryServiceLocator());

            data["status"] = true;
            transform.Execute(context).ShouldEqual(true);

            data["status"] = false;
            transform.Execute(context).ShouldEqual(false);
        }
Exemplo n.º 10
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand2.IsResolvedConstant)
            {
                return(false);
            }

            var next = GetNextNodeUntil(context, IRInstruction.Store64, transformContext.Window, context.Operand1);

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

            if (!next.Operand2.IsResolvedConstant)
            {
                return(false);
            }

            if (next.Operand1 != context.Operand1)
            {
                return(false);
            }

            if (next.Operand2.ConstantUnsigned64 != context.Operand2.ConstantUnsigned64)
            {
                return(false);
            }

            return(true);
        }
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Instruction != IRInstruction.ShiftLeft64)
            {
                return(false);
            }

            if (!IsGreaterThanOrEqual(And32(To32(context.Operand1.Definitions[0].Operand2), 63u), 32u))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        public static void Run(StatementBlock block, RandomGenerator random)
        {
            var context = new TransformContext {
                Statements = block.Statements.ToArray(),
                Usages = block.Statements.ToDictionary(s => s, s => GetVariableUsage(s).ToArray()),
                Definitions = block.Statements.ToDictionary(s => s, s => GetVariableDefinition(s).ToArray())
            };
            for (int i = 0; i < ITERATION; i++) {
                foreach (Statement st in context.Statements) {
                    int index = block.Statements.IndexOf(st);
                    Variable[] vars = GetVariableUsage(st).Concat(GetVariableDefinition(st)).ToArray();

                    // Statement can move between defIndex & useIndex without side effects
                    int defIndex = SearchUpwardKill(context, st, block, index);
                    int useIndex = SearchDownwardKill(context, st, block, index);

                    // Move to a random spot in the interval
                    int newIndex = defIndex + random.NextInt32(1, useIndex - defIndex);
                    if (newIndex > index) newIndex--;
                    block.Statements.RemoveAt(index);
                    block.Statements.Insert(newIndex, st);
                }
            }
        }
Exemplo n.º 13
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsCPURegister)
            {
                return(false);
            }

            if (context.Operand1.Register != GeneralPurposeRegister.ESP)
            {
                return(false);
            }

            if (!context.Operand2.IsConstant)
            {
                return(false);
            }

            var next = GetNextNode(context);

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

            if (next.Instruction != X86.Sub32)
            {
                return(false);
            }

            if (!next.Operand2.IsConstant)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
 public override void Transform(Context context, TransformContext transformContext)
 {
     context.SetNop();
 }
Exemplo n.º 15
0
 public override void Transform(Context context, TransformContext transformContext)
 {
     transformContext.UpdatePHI(context);
 }
Exemplo n.º 16
0
 public override bool Match(Context context, TransformContext transformContext)
 {
     return(context.OperandCount != context.Block.PreviousBlocks.Count);
 }
Exemplo n.º 17
0
        public override void OnCast()
        {
            if (this.CheckSequence())
            {
                List <Mobile>     targets = new List <Mobile>();
                IPooledEnumerable eable   = Caster.GetMobilesInRange(8);

                foreach (Mobile m in eable)
                {
                    if (this.Caster != m && SpellHelper.ValidIndirectTarget(this.Caster, m) && this.Caster.CanBeHarmful(m, false))
                    {
                        targets.Add(m);
                    }
                }
                eable.Free();

                this.Caster.PlaySound(0xF5);
                this.Caster.PlaySound(0x299);
                this.Caster.FixedParticles(0x37C4, 1, 25, 9922, 14, 3, EffectLayer.Head);

                int dispelSkill = this.ComputePowerValue(2);

                double chiv = this.Caster.Skills.Chivalry.Value;

                for (int i = 0; i < targets.Count; ++i)
                {
                    Mobile       m  = targets[i];
                    BaseCreature bc = m as BaseCreature;

                    if (bc != null)
                    {
                        bool dispellable = bc.Summoned && !bc.IsAnimatedDead;

                        if (dispellable)
                        {
                            double dispelChance = (50.0 + ((100 * (chiv - bc.GetDispelDifficulty())) / (bc.DispelFocus * 2))) / 100;
                            dispelChance *= dispelSkill / 100.0;

                            if (dispelChance > Utility.RandomDouble())
                            {
                                Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                                Effects.PlaySound(m, m.Map, 0x201);

                                m.Delete();
                                continue;
                            }
                        }

                        bool evil = !bc.Controlled && bc.Karma < 0;

                        if (evil)
                        {
                            // TODO: Is this right?
                            double fleeChance = (100 - Math.Sqrt(m.Fame / 2)) * chiv * dispelSkill;
                            fleeChance /= 1000000;

                            if (fleeChance > Utility.RandomDouble())
                            {
                                // guide says 2 seconds, it's longer
                                bc.BeginFlee(TimeSpan.FromSeconds(30.0));
                            }
                        }
                    }

                    TransformContext context = TransformationSpellHelper.GetContext(m);
                    if (context != null && context.Spell is NecromancerSpell)   //Trees are not evil!	TODO: OSI confirm?
                    {
                        // transformed ..
                        double drainChance = 0.5 * (this.Caster.Skills.Chivalry.Value / Math.Max(m.Skills.Necromancy.Value, 1));

                        if (drainChance > Utility.RandomDouble())
                        {
                            int drain = (5 * dispelSkill) / 100;

                            m.Stam -= drain;
                            m.Mana -= drain;
                        }
                    }
                }
            }

            this.FinishSequence();
        }
Exemplo n.º 18
0
 public void Run(AstNode rootNode, TransformContext context)
 {
     rootNode.AcceptVisitor(this, null);
 }
Exemplo n.º 19
0
 protected override void CustomizeTransformation()
 {
     TransformContext.SetStageOptions(IsInSSAForm, LowerTo32 && CompilerSettings.LongExpansion && Is32BitPlatform);
 }
Exemplo n.º 20
0
 public static void AddContext(Mobile m, TransformContext context)
 {
     m_Table[m] = context;
 }
Exemplo n.º 21
0
 public override bool Match(Context context, TransformContext transformContext)
 {
     return(transformContext.LowerTo32);
 }
Exemplo n.º 22
0
        public override int GetAttackSpeedBonus()
        {
            int bonus = base.GetAttackSpeedBonus();

            if (Core.SE)
            {
                /*
                 * This is likely true for Core.AOS as well... both guides report the same
                 * formula, and both are wrong.
                 * The old formula left in for AOS for legacy & because we aren't quite 100%
                 * Sure that AOS has THIS formula
                 */
                bonus += AosAttributes.GetValue(this, AosAttribute.WeaponSpeed);

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(this))
                {
                    bonus += 10;
                }

                // Bonus granted by successful use of Honorable Execution.
                bonus += HonorableExecution.GetSwingBonus(this);

                if (DualWield.Registry.Contains(this))
                {
                    bonus += ((DualWield.DualWieldTimer)DualWield.Registry[this]).BonusSwingSpeed;
                }

                if (Feint.Registry.Contains(this))
                {
                    bonus -= ((Feint.FeintTimer)Feint.Registry[this]).SwingSpeedReduction;
                }

                TransformContext context = TransformationSpellHelper.GetContext(this);

                if (context != null && context.Spell is ReaperFormSpell reaperSpell)
                {
                    bonus += reaperSpell.SwingSpeedBonus;
                }

                int discordanceEffect = 0;

                // Discordance gives a malus of -0/-28% to swing speed.
                if (SkillHandlers.Discordance.GetEffect(this, ref discordanceEffect))
                {
                    bonus -= discordanceEffect;
                }

                if (EssenceOfWindSpell.IsDebuffed(this))
                {
                    bonus -= EssenceOfWindSpell.GetSSIMalus(this);
                }

                if (bonus > 60)
                {
                    bonus = 60;
                }
            }
            else if (Core.AOS)
            {
                bonus += AosAttributes.GetValue(this, AosAttribute.WeaponSpeed);

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(this))
                {
                    bonus += 10;
                }

                int discordanceEffect = 0;

                // Discordance gives a malus of -0/-28% to swing speed.
                if (SkillHandlers.Discordance.GetEffect(this, ref discordanceEffect))
                {
                    bonus -= discordanceEffect;
                }
            }

            return(bonus);
        }
Exemplo n.º 23
0
 public override void Transform(Context context, TransformContext transformContext)
 {
     context.SetInstruction(IRInstruction.Nop);
 }
Exemplo n.º 24
0
        public override void OnCast()
        {
            if (CheckSequence())
            {
                Caster.PlaySound(0xF5);
                Caster.PlaySound(0x299);
                Caster.FixedParticles(0x37C4, 1, 25, 9922, 14, 3, EffectLayer.Head);

                int    dispelSkill = ComputePowerValue(2);
                double chiv        = Caster.Skills.Chivalry.Value;

                foreach (var m in AcquireIndirectTargets(Caster.Location, 8).OfType <Mobile>())
                {
                    if (m is BaseCreature bc)
                    {
                        bool dispellable = bc.Summoned && !bc.IsAnimatedDead;

                        if (dispellable)
                        {
                            double dispelChance = (50.0 + ((100 * (chiv - bc.GetDispelDifficulty())) / (bc.DispelFocus * 2))) / 100;
                            dispelChance *= dispelSkill / 100.0;

                            if (dispelChance > Utility.RandomDouble())
                            {
                                Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                                Effects.PlaySound(m, m.Map, 0x201);

                                m.Delete();
                                continue;
                            }
                        }

                        bool evil = !bc.Controlled && bc.Karma < 0;

                        if (evil)
                        {
                            // TODO: Is this right?
                            double fleeChance = (100 - Math.Sqrt(m.Fame / 2)) * chiv * dispelSkill;
                            fleeChance /= 1000000;

                            if (fleeChance > Utility.RandomDouble())
                            {
                                // guide says 2 seconds, it's longer
                                bc.BeginFlee(TimeSpan.FromSeconds(30.0));
                            }
                        }
                    }

                    TransformContext context = TransformationSpellHelper.GetContext(m);
                    if (context != null && context.Spell is NecromancerSpell)   //Trees are not evil!	TODO: OSI confirm?
                    {
                        // transformed ..
                        double drainChance = 0.5 * (Caster.Skills.Chivalry.Value / Math.Max(m.Skills.Necromancy.Value, 1));

                        if (drainChance > Utility.RandomDouble())
                        {
                            int drain = (5 * dispelSkill) / 100;

                            m.Stam -= drain;
                            m.Mana -= drain;
                        }
                    }
                }
            }

            FinishSequence();
        }
Exemplo n.º 25
0
 public override bool Match(Context context, TransformContext transformContext)
 {
     return(context.Result2.Uses.Count == 0);
 }
Exemplo n.º 26
0
 public override void Transform(Context context, TransformContext transformContext)
 {
     context.SetInstruction(IRInstruction.Sub64, context.Result, context.Operand1, context.Operand2);
 }
Exemplo n.º 27
0
 // Cannot go before the statements that use the variable defined at the statement
 // Cannot go further than the statements that override the variable used at the statement
 private static int SearchUpwardKill(TransformContext context, Statement st, StatementBlock block, int startIndex)
 {
     Variable[] usage = context.Usages[st];
     Variable[] definition = context.Definitions[st];
     for (int i = startIndex - 1; i >= 0; i--) {
         if (context.Usages[block.Statements[i]].Intersect(definition).Count() > 0 ||
             context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0)
             return i;
     }
     return 0;
 }
Exemplo n.º 28
0
        public void CheckCancelMorph(Mobile m)
        {
            if (m == null)
            {
                return;
            }

            double minSkill, maxSkill;

            AnimalFormContext acontext = AnimalForm.GetContext(m);
            TransformContext  context  = TransformationSpellHelper.GetContext(m);

            if (context != null)
            {
                Spell spell = context.Spell as Spell;
                spell.GetCastSkills(out minSkill, out maxSkill);
                if (m.Skills[spell.CastSkill].Value < minSkill)
                {
                    TransformationSpellHelper.RemoveContext(m, context, true);
                }
            }
            if (acontext != null)
            {
                int i;
                for (i = 0; i < AnimalForm.Entries.Length; ++i)
                {
                    if (AnimalForm.Entries[i].Type == acontext.Type)
                    {
                        break;
                    }
                }
                if (m.Skills[SkillName.Ninjitsu].Value < AnimalForm.Entries[i].ReqSkill)
                {
                    AnimalForm.RemoveContext(m, true);
                }
            }
            if (!m.CanBeginAction(typeof(PolymorphSpell)) && m.Skills[SkillName.Magery].Value < 66.1)
            {
                m.BodyMod = 0;
                m.HueMod  = -1;
                m.NameMod = null;
                m.EndAction(typeof(PolymorphSpell));
                BaseArmor.ValidateMobile(m);
                BaseClothing.ValidateMobile(m);
            }
            if (!m.CanBeginAction(typeof(IncognitoSpell)) && m.Skills[SkillName.Magery].Value < 38.1)
            {
                if (m is PlayerMobile)
                {
                    ((PlayerMobile)m).SetHairMods(-1, -1);
                }
                m.BodyMod = 0;
                m.HueMod  = -1;
                m.NameMod = null;
                m.EndAction(typeof(IncognitoSpell));
                BaseArmor.ValidateMobile(m);
                BaseClothing.ValidateMobile(m);
                BuffInfo.RemoveBuff(m, BuffIcon.Incognito);
            }
            return;
        }
Exemplo n.º 29
0
        public BuffType GetRandomBuff(Mobile target)
        {
            List <BuffType> buffs = new List <BuffType>();

            if (MagicReflectSpell.HasReflect(target))
            {
                buffs.Add(BuffType.MagicReflect);
            }

            if (ReactiveArmorSpell.HasArmor(target))
            {
                buffs.Add(BuffType.ReactiveArmor);
            }

            if (ProtectionSpell.HasProtection(target))
            {
                buffs.Add(BuffType.Protection);
            }

            TransformContext context = TransformationSpellHelper.GetContext(target);

            if (context != null && context.Type != typeof(AnimalForm))
            {
                buffs.Add(BuffType.Transformation);
            }

            StatMod mod = target.GetStatMod("[Magic] Str Buff");

            if (mod != null)
            {
                buffs.Add(BuffType.StrBonus);
            }

            mod = target.GetStatMod("[Magic] Dex Buff");
            if (mod != null)
            {
                buffs.Add(BuffType.DexBonus);
            }

            mod = target.GetStatMod("[Magic] Int Buff");
            if (mod != null)
            {
                buffs.Add(BuffType.IntBonus);
            }

            if (EodonianPotion.IsUnderEffects(target, PotionEffect.Barrab))
            {
                buffs.Add(BuffType.BarrabHemolymph);
            }

            if (EodonianPotion.IsUnderEffects(target, PotionEffect.Urali))
            {
                buffs.Add(BuffType.UraliTrance);
            }

            if (buffs.Count == 0)
            {
                return(BuffType.None);
            }

            BuffType type = buffs[Utility.Random(buffs.Count)];

            buffs.Clear();

            return(type);
        }
        public override void Transform(Context context, TransformContext transformContext)
        {
            var previous = GetPreviousNodeUntil(context, IRInstruction.Store32, transformContext.Window, context.Operand1);

            context.SetInstruction(IRInstruction.SignExtend32x64, context.Result, previous.Operand3);
        }
Exemplo n.º 31
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand2.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand2.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
            {
                return(false);
            }

            if (!context.Operand2.Definitions[0].Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand2.Definitions[0].Operand2.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand1.Definitions[0].Instruction != IRInstruction.MulSigned64)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand2.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand2.Definitions[0].Instruction != IRInstruction.MulSigned64)
            {
                return(false);
            }

            if (!AreSame(context.Operand2.Definitions[0].Operand1.Definitions[0].Operand1, context.Operand2.Definitions[0].Operand2.Definitions[0].Operand1))
            {
                return(false);
            }

            if (!AreSame(context.Operand2.Definitions[0].Operand1.Definitions[0].Operand1, context.Operand2.Definitions[0].Operand2.Definitions[0].Operand2))
            {
                return(false);
            }

            if (!IsResolvedConstant(context.Operand1))
            {
                return(false);
            }

            if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand1.Definitions[0].Operand2))
            {
                return(false);
            }

            if (!IsEvenInteger(context.Operand2.Definitions[0].Operand1.Definitions[0].Operand2))
            {
                return(false);
            }

            if (!IsEqual(To64(context.Operand1), Square64(DivUnsigned64(To64(context.Operand2.Definitions[0].Operand1.Definitions[0].Operand2), 2))))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 32
0
        public LoadMessageData(Uri address, IMessageDataRepository repository, IMessageDataConverter <T> converter, TransformContext transformContext)
        {
            _address          = address;
            _repository       = repository;
            _converter        = converter;
            _transformContext = transformContext;

            _value = new Lazy <Task <T> >(GetValue);
        }
Exemplo n.º 33
0
        private void ExplodePunch(Mobile target)
        {
            double alchemyBonus = 0;
            double sdi          = 0;
            int    dmgInc       = 0;
            int    exploDamage  = 20;

            if ((Controlled || Summoned) && ControlMaster != null)
            {
                Mobile master = ControlMaster;
                alchemyBonus = AosAttributes.GetValue(master, AosAttribute.EnhancePotions);
                sdi          = AosAttributes.GetValue(master, AosAttribute.SpellDamage);
                //if (alchemyBonus > 50)
                //    alchemyBonus = 50;
                sdi          += (int)(master.Skills.Inscribe.Fixed + (1000 * (int)(master.Skills.Inscribe.Fixed / 100))) / 100;
                alchemyBonus += master.Skills.Alchemy.Fixed / 330 * 10;
                sdi          += master.Int / 10;
                sdi          += ArcaneEmpowermentSpell.GetSpellBonus(master, false);

                TransformContext context = TransformationSpellHelper.GetContext(master);

                if (context != null && context.Spell is ReaperFormSpell)
                {
                    sdi += ((ReaperFormSpell)context.Spell).SpellDamageBonus;
                }
                exploDamage = (int)(((master.Skills[SkillName.Alchemy].Value / 2.5)) * (1 + (alchemyBonus + sdi) / 100));
            }


            if (target == null)
            {
                return;
            }

            Point3D m_loc = target.Location;
            Map     map   = target.Map;

            int ExpRange = 0;

            if (ControlMaster != null)
            {
                ExpRange += (int)(ControlMaster.Skills[SkillName.Tinkering].Value + ControlMaster.Skills[SkillName.Alchemy].Value) / 50;
                if (Utility.RandomDouble() > AosAttributes.GetValue(ControlMaster, AosAttribute.EnhancePotions))
                {
                    ExpRange += 1;
                }
                if (Utility.RandomDouble() > AosAttributes.GetValue(ControlMaster, AosAttribute.SpellDamage))
                {
                    ExpRange += 1;
                }
            }
            target.PlaySound(0x11D);

            if ((Map)map != null)
            {
                IPooledEnumerable eable = (IPooledEnumerable)map.GetMobilesInRange(m_loc, ExpRange);

                foreach (object o in eable)
                {
                    if ((o is Mobile) && (o != this) && (target == null || (SpellHelper.ValidIndirectTarget(this, (Mobile)o) && CanBeHarmful((Mobile)o, false))) &&
                        ((Mobile)o).InLOS(target))
                    {
                        if (o is PlayerMobile)
                        {
                            AOS.Damage((Mobile)o, this, Utility.RandomMinMax(0, exploDamage / 4), 0, 100, 0, 0, 0);
                        }
                        else if (o is BaseCreature && Controlled)
                        {
                            if (ControlMaster != ((BaseCreature)o).ControlMaster)
                            {
                                AOS.Damage((Mobile)o, this, Utility.RandomMinMax(0, exploDamage), 0, 100, 0, 0, 0);
                            }
                            else if (o is BaseCreature)
                            {
                                AOS.Damage((Mobile)o, this, Utility.RandomMinMax(0, exploDamage), 0, 100, 0, 0, 0);
                            }
                        }
                        DoHarmful((Mobile)o);
                    }
                }
            }
        }
Exemplo n.º 34
0
 public override void Transform(Context context, TransformContext transformContext)
 {
     context.SetInstruction(IRInstruction.Compare64x64, context.ConditionCode.GetReverse(), context.Result, context.Operand2, context.Operand1);
 }
Exemplo n.º 35
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result = context.Result;

            context.SetInstruction(X86.Inc32, result, result);
        }
Exemplo n.º 36
0
        public static void RemoveContext(Mobile m, TransformContext context, bool resetGraphics)
        {
            if (m_Table.ContainsKey(m))
            {
                m_Table.Remove(m);

                List<ResistanceMod> mods = context.Mods;

                for (int i = 0; i < mods.Count; ++i)
                    m.RemoveResistanceMod(mods[i]);

                if (resetGraphics)
                {
                    m.HueMod = -1;
                    m.BodyMod = 0;
                }

                context.Timer.Stop();
                context.Spell.RemoveEffect(m);
            }
        }
Exemplo n.º 37
0
        public override bool Match(Context context, TransformContext transformContext)
        {
            if (!context.Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand2.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Instruction != IRInstruction.ShiftLeft64)
            {
                return(false);
            }

            if (!context.Operand1.Definitions[0].Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand1.Definitions[0].Operand2.IsResolvedConstant)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Operand2.ConstantUnsigned64 != 1)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand1.Definitions[0].Operand1.Definitions[0].Instruction != IRInstruction.MulSigned64)
            {
                return(false);
            }

            if (context.Operand2.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
            {
                return(false);
            }

            if (!context.Operand2.Definitions[0].Operand1.IsVirtualRegister)
            {
                return(false);
            }

            if (!context.Operand2.Definitions[0].Operand2.IsVirtualRegister)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand1.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand1.Definitions[0].Instruction != IRInstruction.MulSigned64)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand2.Definitions.Count != 1)
            {
                return(false);
            }

            if (context.Operand2.Definitions[0].Operand2.Definitions[0].Instruction != IRInstruction.MulSigned64)
            {
                return(false);
            }

            if (!AreSame(context.Operand1.Definitions[0].Operand1.Definitions[0].Operand1, context.Operand2.Definitions[0].Operand1.Definitions[0].Operand1))
            {
                return(false);
            }

            if (!AreSame(context.Operand1.Definitions[0].Operand1.Definitions[0].Operand1, context.Operand2.Definitions[0].Operand1.Definitions[0].Operand2))
            {
                return(false);
            }

            if (!AreSame(context.Operand1.Definitions[0].Operand1.Definitions[0].Operand2, context.Operand2.Definitions[0].Operand2.Definitions[0].Operand1))
            {
                return(false);
            }

            if (!AreSame(context.Operand1.Definitions[0].Operand1.Definitions[0].Operand2, context.Operand2.Definitions[0].Operand2.Definitions[0].Operand2))
            {
                return(false);
            }

            return(true);
        }