Example #1
0
        public static void ActivateSpectreBolt(PvPPlayer attacker, PvPPlayer target, PvPItem weapon, int dmg)
        {
            if (!weapon.magic)
            {
                return;
            }
            int Damage = dmg / 2;

            if (dmg / 2 <= 1)
            {
                return;
            }
            int?attackingIndex = null;

            if (Collision.CanHit(attacker.TPlayer.position, attacker.TPlayer.width, attacker.TPlayer.height, target.TPlayer.position, target.TPlayer.width, target.TPlayer.height))
            {
                attackingIndex = target.Index;
            }
            if (attackingIndex == null)
            {
                return;
            }
            int    num3   = (int)attackingIndex;
            double num4   = 4.0;
            float  num5   = (float)Main.rand.Next(-100, 101);
            float  num6   = (float)Main.rand.Next(-100, 101);
            double num7   = Math.Sqrt((double)num5 * (double)num5 + (double)num6 * (double)num6);
            float  num8   = (float)(num4 / num7);
            float  SpeedX = num5 * num8;
            float  SpeedY = num6 * num8;

            ProjectileUtils.SpawnProjectile(attacker, attacker.X, attacker.Y, SpeedX, SpeedY, 356, Damage, 0.0f, attacker.Index, (float)num3, 0.0f);
        }
Example #2
0
        /// <summary>
        /// Spawns Counterweights/Additional yoyos when a person has hit with one.
        /// This normally does not work in vanilla servers, so this must be emulated on a
        /// server for accessories such as Yoyo Bag to work.
        /// </summary>
        public static void ActivateYoyoBag(PvPPlayer attacker, PvPPlayer target, int dmg, float kb)
        {
            if (!attacker.TPlayer.yoyoGlove && attacker.TPlayer.counterWeight <= 0)
            {
                return;
            }
            int index1 = -1;
            int num1   = 0;
            int num2   = 0;

            for (int index2 = 0; index2 < 1000; ++index2)
            {
                if (Main.projectile[index2].active && Main.projectile[index2].owner == attacker.TPlayer.whoAmI)
                {
                    if (Main.projectile[index2].counterweight)
                    {
                        ++num2;
                    }
                    else if (Main.projectile[index2].aiStyle == 99)
                    {
                        ++num1;
                        index1 = index2;
                    }
                }
            }
            if (attacker.TPlayer.yoyoGlove && num1 < 2)
            {
                if (index1 < 0)
                {
                    return;
                }
                Vector2 vector21 = Vector2.Subtract(target.LastNetPosition, attacker.TPlayer.Center);
                vector21.Normalize();
                Vector2 vector22 = Vector2.Multiply(vector21, 16f);
                ProjectileUtils.SpawnProjectile(attacker, attacker.TPlayer.Center.X, attacker.TPlayer.Center.Y, vector22.X, vector22.Y, Main.projectile[index1].type, Main.projectile[index1].damage, Main.projectile[index1].knockBack, attacker.TPlayer.whoAmI, 1f);
            }
            else
            {
                if (num2 >= num1)
                {
                    return;
                }
                int     index;
                Vector2 vector21 = Vector2.Subtract(target.LastNetPosition, attacker.TPlayer.Center);
                vector21.Normalize();
                Vector2 vector22  = Vector2.Multiply(vector21, 16f);
                float   knockBack = (float)((kb + 6.0) / 2.0);
                ProjectileUtils.SpawnProjectile(attacker, attacker.TPlayer.Center.X, attacker.TPlayer.Center.Y,
                                                vector22.X, vector22.Y, attacker.TPlayer.counterWeight, (int)(dmg * 0.8), knockBack,
                                                attacker.TPlayer.whoAmI, (num2 > 0).ToInt());
            }
        }