public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 3, 11);
            if (player == null || spell == null)
            {
                return(null);
            }
            string               effectName               = Expressions.GetStr(args[0]);
            ProjectileKind       projectileKind           = ProjectileKind.EachTarget;
            int                  projectileCount          = 1;
            float                speed                    = 20;
            FireCollisionEventOn fireCollisionEventOn     = FireCollisionEventOn.EachImpact;
            float                launchTimeVariance       = 0;
            float                targetVariance           = 0;
            ProjectileSizeOption projectileSize           = ProjectileSizeOption.ConstantSize;
            float                projectileSizeMultiplier = 1;
            float                bezierPathMultiplier     = 1;

            if (args.Count > 1)
            {
                projectileKind = Expressions.Get <ProjectileKind>(args[1]);
                if (args.Count > 2)
                {
                    int.TryParse(args[2], out projectileCount);
                    if (args.Count > 3)
                    {
                        float.TryParse(args[3], out speed);

                        if (args.Count > 4)
                        {
                            fireCollisionEventOn = Expressions.Get <FireCollisionEventOn>(args[4]);
                            if (args.Count > 5)
                            {
                                float.TryParse(args[5], out launchTimeVariance);
                                if (args.Count > 6)
                                {
                                    float.TryParse(args[6], out targetVariance);
                                    if (args.Count > 7)
                                    {
                                        projectileSize = Expressions.Get <ProjectileSizeOption>(args[7]);
                                        if (args.Count > 8)
                                        {
                                            float.TryParse(args[8], out projectileSizeMultiplier);
                                            if (args.Count > 9)
                                            {
                                                float.TryParse(args[9], out bezierPathMultiplier);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            ProjectileEffectEventArgs ea = new ProjectileEffectEventArgs(effectName, spell.ID, player.taleSpireId, speed, projectileCount, projectileKind, fireCollisionEventOn, launchTimeVariance, targetVariance, target, projectileSize, projectileSizeMultiplier, bezierPathMultiplier);

            LaunchProjectile?.Invoke(null, ea);

            return(null);
        }
예제 #2
0
        public static void GetWindupParameters(List <string> args, Character player, Target target, CastedSpell spell,
                                               out string effectName, out int hue, out int saturation, out int brightness, out double scale,
                                               out double rotation, out double autoRotation, out double degreesOffset, out bool flipHorizontal,
                                               out int xOffset, out int yOffset, out double velocityX, out double velocityY, out double forceX, out double forceY,
                                               out int fadeIn, out int lifespan, out int fadeOut)
        {
            effectName = Expressions.GetStr(args[0], player, target, spell);
            hue        = 0;
            if (args.Count > 1)
            {
                if (args[1].Trim() == "player")
                {
                    hue = player.hueShift;
                }
                else
                {
                    hue = Expressions.GetInt(args[1], player, target, spell);
                }
            }

            saturation = 100;
            if (args.Count > 2)
            {
                saturation = Expressions.GetInt(args[2], player, target, spell);
            }

            brightness = 100;
            if (args.Count > 3)
            {
                brightness = Expressions.GetInt(args[3], player, target, spell);
            }

            scale = 1;
            if (args.Count > 4)
            {
                scale = Expressions.GetDouble(args[4], player, target, spell);
            }

            rotation = 0;
            if (args.Count > 5)
            {
                rotation = Expressions.GetDouble(args[5], player, target, spell);
            }

            autoRotation = 0;
            if (args.Count > 6)
            {
                autoRotation = Expressions.GetDouble(args[6], player, target, spell);
            }

            degreesOffset = 0;
            if (args.Count > 7)
            {
                degreesOffset = Expressions.GetDouble(args[7], player, target, spell);
            }

            flipHorizontal = false;
            if (args.Count > 8)
            {
                flipHorizontal = Expressions.GetBool(args[8], player, target, spell);
            }

            xOffset = 0;
            if (args.Count > 9)
            {
                xOffset = Expressions.GetInt(args[9], player, target, spell);
            }

            yOffset = 0;
            if (args.Count > 10)
            {
                yOffset = Expressions.GetInt(args[10], player, target, spell);
            }

            velocityX = 0;
            if (args.Count > 11)
            {
                velocityX = Expressions.GetDouble(args[11], player, target, spell);
            }

            velocityY = 0;
            if (args.Count > 12)
            {
                velocityY = Expressions.GetDouble(args[12], player, target, spell);
            }

            forceX = 0;
            if (args.Count > 13)
            {
                forceX = Expressions.GetDouble(args[13], player, target, spell);
            }

            forceY = 0;
            if (args.Count > 14)
            {
                forceY = Expressions.GetDouble(args[14], player, target, spell);
            }

            fadeIn = 0;
            if (args.Count > 15)
            {
                fadeIn = Expressions.GetInt(args[15], player, target, spell);
            }

            lifespan = 0;
            if (args.Count > 16)
            {
                lifespan = Expressions.GetInt(args[16], player, target, spell);
            }

            fadeOut = 0;
            if (args.Count > 17)
            {
                fadeOut = Expressions.GetInt(args[17], player, target, spell);
            }
        }
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 1, 9);
            if (player == null)
            {
                return(null);
            }

            string spellId;

            if (spell == null)
            {
                spellId = Guid.NewGuid().ToString();
            }
            else
            {
                spellId = spell.ID;
            }

            string         effectName        = Expressions.GetStr(args[0]);
            float          lifeTime          = 0;
            float          secondsDelayStart = 0;
            float          enlargeTime       = 0;
            float          shrinkTime        = 0;
            float          rotation          = 0;
            float          wallLength        = 0;
            float          distanceBetweenWallEffectsFeet = 2.5f;
            EffectLocation effectLocation = EffectLocation.CreatureBase;

            if (args.Count > 1)
            {
                lifeTime = (float)Expressions.GetDouble(args[1]);
                if (args.Count > 2)
                {
                    effectLocation = Expressions.Get <EffectLocation>(args[2]);
                    if (args.Count > 3)
                    {
                        secondsDelayStart = Expressions.GetFloat(args[3]);
                        if (args.Count > 4)
                        {
                            enlargeTime = Expressions.GetFloat(args[4]);
                            if (args.Count > 5)
                            {
                                shrinkTime = Expressions.GetFloat(args[5]);
                                if (args.Count > 6)
                                {
                                    rotation = Expressions.GetFloat(args[6]);
                                    if (args.Count > 7)
                                    {
                                        wallLength = Expressions.GetFloat(args[7]);
                                        if (args.Count > 8)
                                        {
                                            distanceBetweenWallEffectsFeet = Expressions.GetFloat(args[8]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            OnPlayKnownEffect(effectName, spellId, player.taleSpireId, lifeTime, effectLocation, secondsDelayStart, enlargeTime, shrinkTime, rotation, wallLength, distanceBetweenWallEffectsFeet);

            return(null);
        }
예제 #4
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Creature target, CastedSpell spell)
        {
            if (player == null)
            {
                return(null);
            }

            ExpectingArguments(args, 2);

            string variableName = args[0];
            double valueDouble  = MathUtils.GetDouble(Expressions.Get <object>(args[1], player, target, spell).ToString());
            int    valueInt     = (int)Math.Round(valueDouble);

            // TODO: Wil says Convert.ConvertTo() can simplify this.

            FieldInfo field = typeof(Character).GetField(variableName);

            if (field != null)
            {
                if (field.FieldType.FullName == "System.Int32")
                {
                    field.SetValue(player, MathUtils.GetInt(field.GetValue(player).ToString()) + valueInt);
                }
                else
                {
                    field.SetValue(player, MathUtils.GetDouble(field.GetValue(player).ToString()) + valueDouble);
                }
                return(null);
            }

            PropertyInfo property = typeof(Character).GetProperty(variableName);

            if (property != null)
            {
                if (property.PropertyType.FullName == "System.Int32")
                {
                    property.SetValue(player, MathUtils.GetInt(property.GetValue(player).ToString()) + valueInt);
                }
                else
                {
                    property.SetValue(player, MathUtils.GetDouble(property.GetValue(player).ToString()) + valueDouble);
                }
                return(null);
            }

            object existingValueRaw = player.GetState(variableName);

            if (existingValueRaw != null)
            {
                if (existingValueRaw is int)
                {
                    player.SetState(variableName, MathUtils.GetInt(existingValueRaw.ToString()) + valueInt);
                }
                else
                {
                    player.SetState(variableName, MathUtils.GetDouble(existingValueRaw.ToString()) + valueDouble);
                }
                return(null);
            }

            throw new Exception($"Variable \"{variableName}\" not found.");
        }
예제 #5
0
 void ExecuteCommand(string command, Character player)
 {
     Expressions.Do(command, player);
 }
예제 #6
0
        public static void GetVisualEffectParameters(List <string> args, Character player, Target target, CastedSpell spell, out string effectName, out int hue, out int saturation, out int brightness, out double scale, out double rotation, out double autoRotation, out int timeOffset, out int secondaryHue, out int secondarySaturation, out int secondaryBrightness, out int xOffset, out int yOffset, out double velocityX, out double velocityY)
        {
            effectName = Expressions.GetStr(args[0], player, target, spell);
            hue        = 0;
            if (args.Count > 1)
            {
                if (args[1].Trim() == "player")
                {
                    hue = player.hueShift;
                }
                else
                {
                    hue = Expressions.GetInt(args[1], player, target, spell);
                }
            }

            saturation = 100;
            if (args.Count > 2)
            {
                saturation = Expressions.GetInt(args[2], player, target, spell);
            }

            brightness = 100;
            if (args.Count > 3)
            {
                brightness = Expressions.GetInt(args[3], player, target, spell);
            }

            scale = 1;
            if (args.Count > 4)
            {
                scale = Expressions.GetDouble(args[4], player, target, spell);
            }

            rotation = 0;
            if (args.Count > 5)
            {
                rotation = Expressions.GetDouble(args[5], player, target, spell);
            }


            autoRotation = 0;
            if (args.Count > 6)
            {
                autoRotation = Expressions.GetDouble(args[6], player, target, spell);
            }

            timeOffset = int.MinValue;
            if (args.Count > 7)
            {
                timeOffset = Expressions.GetInt(args[7], player, target, spell);
            }

            secondaryHue = 0;
            if (args.Count > 8)
            {
                if (args[8].Trim() == "player")
                {
                    secondaryHue = player.hueShift;
                }
                else
                {
                    secondaryHue = Expressions.GetInt(args[8], player, target, spell);
                }
            }

            secondarySaturation = 100;
            if (args.Count > 9)
            {
                secondarySaturation = Expressions.GetInt(args[9], player, target, spell);
            }

            secondaryBrightness = 100;
            if (args.Count > 10)
            {
                secondaryBrightness = Expressions.GetInt(args[10], player, target, spell);
            }

            xOffset = 0;
            if (args.Count > 11)
            {
                xOffset = Expressions.GetInt(args[11], player, target, spell);
            }

            yOffset = 0;
            if (args.Count > 12)
            {
                yOffset = Expressions.GetInt(args[12], player, target, spell);
            }

            velocityX = 0;
            if (args.Count > 13)
            {
                velocityX = Expressions.GetDouble(args[13], player, target, spell);
            }

            velocityY = 0;
            if (args.Count > 14)
            {
                velocityY = Expressions.GetDouble(args[14], player, target, spell);
            }
        }
예제 #7
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Creature target = null, CastedSpell spell = null)
        {
            AddReminderEventArgs ea = new AddReminderEventArgs(Expressions.GetStr(args[0], player, target, spell), Expressions.GetStr(args[1], player, target, spell));

            AddReminder(player, ea);
            return(null);
        }
예제 #8
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target = null, CastedSpell spell = null, RollResults dice = null)
        {
            ExpectingArguments(args, 2, 10);
            if (player != null)
            {
                if (target == null)
                {
                    target = Expressions.Get <Target>(args[0]);
                }

                string magicItemName = Expressions.GetStr(args[1]);

                object data1 = null;
                object data2 = null;
                object data3 = null;
                object data4 = null;
                object data5 = null;
                object data6 = null;
                object data7 = null;
                object data8 = null;

                if (args.Count > 2)
                {
                    data1 = GetData(args[2], player, target, spell);
                }
                if (args.Count > 3)
                {
                    data2 = GetData(args[3], player, target, spell);
                }
                if (args.Count > 4)
                {
                    data3 = GetData(args[4], player, target, spell);
                }
                if (args.Count > 5)
                {
                    data4 = GetData(args[5], player, target, spell);
                }
                if (args.Count > 6)
                {
                    data5 = GetData(args[6], player, target, spell);
                }
                if (args.Count > 7)
                {
                    data6 = GetData(args[7], player, target, spell);
                }
                if (args.Count > 8)
                {
                    data7 = GetData(args[8], player, target, spell);
                }
                if (args.Count > 9)
                {
                    data8 = GetData(args[9], player, target, spell);
                }

                //if (target == null)
                //	target = player.ActiveTarget;
                // TODO: consider passing in the spell name as well for unique id (if castedSpell is valid).
                player.GiveMagic(magicItemName, spell, target, data1, data2, data3, data4, data5, data6, data7, data8);
            }

            return(null);
        }
예제 #9
0
        private void DndAlarm_AlarmFired(object sender, DndTimeEventArgs ea)
        {
            string functionToCall = (string)ea.Alarm.Data;

            Expressions.Do(functionToCall, ea.Alarm.Creature);
        }