ClearBuff() public method

public ClearBuff ( int type ) : void
type int
return void
Example #1
0
 public void Dismount(Player mountedPlayer)
 {
     if (!this._active)
     {
         return;
     }
     this._active = false;
     mountedPlayer.ClearBuff(this._data.buff);
     if (this._type == 6)
     {
         mountedPlayer.ClearBuff(this._data.extraBuff);
         mountedPlayer.cartFlip           = false;
         mountedPlayer.fullRotation       = 0f;
         mountedPlayer.fullRotationOrigin = Vector2.Zero;
         mountedPlayer.lastBoost          = Vector2.Zero;
     }
     if (Main.netMode != 2)
     {
         for (int i = 0; i < 100; i++)
         {
             if (this._type == 6)
             {
                 if (i % 10 == 0)
                 {
                     int type = Main.rand.Next(61, 64);
                     int num  = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
                     Main.gore[num].alpha    = 100;
                     Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
                 }
             }
             else
             {
                 int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
                 Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
                 if (Main.rand.Next(2) == 0)
                 {
                     Main.dust[num2].scale    *= 1.3f;
                     Main.dust[num2].noGravity = true;
                 }
                 else
                 {
                     Main.dust[num2].velocity *= 0.5f;
                 }
                 Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
             }
         }
     }
     this.Reset();
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     mountedPlayer.height     = 42;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     if (mountedPlayer.whoAmi == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmi, 0f, 0f, 0f, 0);
     }
 }
Example #2
0
        public override void AI()
        {
            Terraria.Player player = Terraria.Main.player[projectile.owner];
            if (player.dead || !player.active)
            {
                player.ClearBuff(BuffType <ScaryLookingPumpkinBuff>());
            }
            if (player.HasBuff(BuffType <ScaryLookingPumpkinBuff>()))
            {
                projectile.timeLeft = 2;
            }

            //General behavior
            Vector2 idlePosition = player.Center;

            float minionPositionOffsetX = (10 + projectile.minionPos * 40) * -player.direction;

            idlePosition.X += minionPositionOffsetX; // Go behind the player

            // Teleport to player if distance is too big
            Vector2 vectorToIdlePosition   = idlePosition - projectile.Center;
            float   distanceToIdlePosition = vectorToIdlePosition.Length();

            if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 800f)
            {
                projectile.position  = idlePosition;
                projectile.velocity *= 0.1f;
                projectile.netUpdate = true; //multiplayer related
            }
        }
Example #3
0
        public override void AI()
        {
            Terraria.Player player = Terraria.Main.player[projectile.owner];
            if (player.dead || !player.active)
            {
                player.ClearBuff(BuffType <FlyingFishBuff>());
            }
            if (player.HasBuff(BuffType <FlyingFishBuff>()))
            {
                projectile.timeLeft = 2;
            }

            //General behavior
            Vector2 idlePosition = player.Center;

            idlePosition.Y -= 48f;             // Go up 48 coordinates (three tiles from the center of the player)

            float minionPositionOffsetX = (10 + projectile.minionPos * 40) * -player.direction;

            idlePosition.X += minionPositionOffsetX;             // Go behind the player

            // Teleport to player if distance is too big
            Vector2 vectorToIdlePosition   = idlePosition - projectile.Center;
            float   distanceToIdlePosition = vectorToIdlePosition.Length();

            if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f)
            {
                projectile.position  = idlePosition;
                projectile.velocity *= 0.1f;
                projectile.netUpdate = true;                 //multiplayer related
            }

            //"minion chain" reorganizing
            float overlapVelocity = 0.04f;

            for (int i = 0; i < Main.maxProjectiles; i++)
            {
                Projectile other = Main.projectile[i];
                if (i != projectile.whoAmI && other.active && other.owner == projectile.owner && Math.Abs(projectile.position.X - other.position.X) + Math.Abs(projectile.position.Y - other.position.Y) < projectile.width)
                {
                    if (projectile.position.X < other.position.X)
                    {
                        projectile.velocity.X -= overlapVelocity;
                    }
                    else
                    {
                        projectile.velocity.X += overlapVelocity;
                    }

                    if (projectile.position.Y < other.position.Y)
                    {
                        projectile.velocity.Y -= overlapVelocity;
                    }
                    else
                    {
                        projectile.velocity.Y += overlapVelocity;
                    }
                }
            }

            //Find target
            // Starting search distance
            float   distanceFromTarget = 400f;
            Vector2 targetCenter       = projectile.position;
            bool    foundTarget        = false;

            // Targeting feature
            if (player.HasMinionAttackTargetNPC)
            {
                NPC   npc     = Main.npc[player.MinionAttackTargetNPC];
                float between = Vector2.Distance(npc.Center, projectile.Center);
                if (between < 1000f)                 // Targetting distance
                {
                    distanceFromTarget = between;
                    targetCenter       = npc.Center;
                    foundTarget        = true;
                }
            }
            if (!foundTarget)             //if target isn't found, then
            {
                for (int i = 0; i < Main.maxNPCs; i++)
                {
                    NPC npc = Main.npc[i];
                    if (npc.CanBeChasedBy())
                    {
                        float between     = Vector2.Distance(npc.Center, projectile.Center);
                        bool  closest     = Vector2.Distance(projectile.Center, targetCenter) > between;
                        bool  inRange     = between < distanceFromTarget;
                        bool  lineOfSight = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
                        // Additional check for this specific minion behavior, otherwise it will stop attacking once it dashed through an enemy while flying though tiles afterwards
                        // The number depends on various parameters seen in the movement code below. Test different ones out until it works alright
                        bool closeThroughWall = between < 100f;
                        if (((closest && inRange) || !foundTarget) && (lineOfSight || closeThroughWall))
                        {
                            distanceFromTarget = between;
                            targetCenter       = npc.Center;
                            foundTarget        = true;
                        }
                    }
                }
            }

            projectile.friendly = foundTarget;             // friendly needs to be set to true so the minion can deal contact damage

            //Movement

            // Default movement parameters for attacking
            float speed   = 8f;
            float inertia = 30f;

            if (foundTarget)                  //if target is found, then
            {
                if (distanceFromTarget > 40f) //if distance from enemy is less than X, then
                {
                    Vector2 direction = targetCenter - projectile.Center;
                    direction.Normalize();
                    direction          *= speed;
                    projectile.velocity = (projectile.velocity * (inertia - 1) + direction) / inertia;
                }
            }

            else
            {
                // Minion doesn't have a target: return to player and idle
                if (distanceToIdlePosition > 600f)
                {
                    // Speed up the minion if it's away from the player
                    speed   = 12f;
                    inertia = 60f;
                }

                else
                {
                    // Slow down the minion if closer to the player
                    speed   = 4f;
                    inertia = 80f;
                }
                if (distanceToIdlePosition > 20f)
                {
                    // The immediate range around the player (when it passively floats about)

                    // This is a simple movement formula using the two parameters and its desired direction to create a "homing" movement
                    vectorToIdlePosition.Normalize();
                    vectorToIdlePosition *= speed;
                    projectile.velocity   = (projectile.velocity * (inertia - 1) + vectorToIdlePosition) / inertia;
                }
                else if (projectile.velocity == Vector2.Zero)
                {
                    // If there is a case where it's not moving at all, give it a little "poke"
                    projectile.velocity.X = -0.15f;
                    projectile.velocity.Y = -0.05f;
                }
            }

            //Animation and visuals

            // So it will lean slightly towards the direction it's moving
            projectile.rotation        = projectile.velocity.X * 0.05f;
            projectile.spriteDirection = -projectile.direction;

            // Loop trough all the frames from animation
            int frameSpeed = 5;

            projectile.frameCounter++;
            if (projectile.frameCounter >= frameSpeed)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame >= Main.projFrames[projectile.type])
                {
                    projectile.frame = 0;
                }
            }

            Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 0.18f);
        }
Example #4
0
 public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
 {
     if (this._type == m || m <= -1 || m >= 14)
     {
         return;
     }
     if (m == 5 && mountedPlayer.wet)
     {
         return;
     }
     if (!this._active)
     {
         this._active = true;
     }
     else
     {
         mountedPlayer.ClearBuff(this._data.buff);
         if (this.Cart)
         {
             mountedPlayer.ClearBuff(this._data.extraBuff);
             mountedPlayer.cartFlip = false;
             mountedPlayer.lastBoost = Vector2.Zero;
         }
         mountedPlayer.fullRotation = 0f;
         mountedPlayer.fullRotationOrigin = Vector2.Zero;
         this._mountSpecificData = null;
     }
     this._flyTime = 0;
     this._type = m;
     this._data = Mount.mounts[m];
     this._fatigueMax = (float)this._data.fatigueMax;
     if (!this.Cart || faceLeft || this.Directional)
     {
         mountedPlayer.AddBuff(this._data.buff, 3600, true);
         this._flipDraw = false;
     }
     else
     {
         mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
         this._flipDraw = true;
     }
     if (this._type == 9 && this._abilityCooldown < 20)
     {
         this._abilityCooldown = 20;
     }
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     for (int i = 0; i < (int)mountedPlayer.shadowPos.Length; i++)
     {
         mountedPlayer.shadowPos[i].Y = mountedPlayer.shadowPos[i].Y + (float)mountedPlayer.height;
     }
     mountedPlayer.height = 42 + this._data.heightBoost;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     for (int j = 0; j < (int)mountedPlayer.shadowPos.Length; j++)
     {
         mountedPlayer.shadowPos[j].Y = mountedPlayer.shadowPos[j].Y - (float)mountedPlayer.height;
     }
     if (this._type == 7 || this._type == 8)
     {
         mountedPlayer.fullRotationOrigin = new Vector2((float)(mountedPlayer.width / 2), (float)(mountedPlayer.height / 2));
     }
     if (this._type == 8)
     {
         this._mountSpecificData = new Mount.DrillMountData();
     }
     if (Main.netMode != 2)
     {
     }
     if (mountedPlayer.whoAmI == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0f, 0f, 0f, 0, 0, 0);
     }
 }
Example #5
0
 public void Dismount(Player mountedPlayer)
 {
     if (!this._active)
     {
         return;
     }
     bool cart = this.Cart;
     this._active = false;
     mountedPlayer.ClearBuff(this._data.buff);
     this._mountSpecificData = null;
     if (cart)
     {
         mountedPlayer.ClearBuff(this._data.extraBuff);
         mountedPlayer.cartFlip = false;
         mountedPlayer.lastBoost = Vector2.Zero;
     }
     mountedPlayer.fullRotation = 0f;
     mountedPlayer.fullRotationOrigin = Vector2.Zero;
     if (Main.netMode != 2)
     {
         for (int i = 0; i < 100; i++)
         {
             if (this._type != 6 && this._type != 11 && this._type != 13)
             {
             }
         }
     }
     this.Reset();
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     mountedPlayer.height = 42;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     if (mountedPlayer.whoAmI == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0f, 0f, 0f, 0, 0, 0);
     }
 }
Example #6
0
		public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
		{
			if (this._type == m || m <= -1 || m >= 7)
			{
				return;
			}
			if (m == 5 && mountedPlayer.wet)
			{
				return;
			}
			if (this._active)
			{
				mountedPlayer.ClearBuff(this._data.buff);
				if (this._type == 6)
				{
					mountedPlayer.ClearBuff(this._data.extraBuff);
					mountedPlayer.cartFlip = false;
					mountedPlayer.fullRotation = 0f;
					mountedPlayer.fullRotationOrigin = Vector2.Zero;
					mountedPlayer.lastBoost = Vector2.Zero;
				}
			}
			else
			{
				this._active = true;
			}
			this._flyTime = 0;
			this._type = m;
			this._data = Mount.mounts[m];
			this._fatigueMax = (float)this._data.fatigueMax;
			if (this._type == 6 && !faceLeft)
			{
				mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
				this._flipDraw = true;
			}
			else
			{
				mountedPlayer.AddBuff(this._data.buff, 3600, true);
				this._flipDraw = false;
			}
			mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
			mountedPlayer.height = 42 + this._data.heightBoost;
			mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
			if (Main.netMode != 2)
			{
				for (int i = 0; i < 100; i++)
				{
					if (this._type == 6)
					{
						if (i % 10 == 0)
						{
							int type = Main.rand.Next(61, 64);
							int num = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
							Main.gore[num].alpha = 100;
							Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
						}
					}
					else
					{
						int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
						Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
						if (Main.rand.Next(2) == 0)
						{
							Main.dust[num2].scale *= 1.3f;
							Main.dust[num2].noGravity = true;
						}
						else
						{
							Main.dust[num2].velocity *= 0.5f;
						}
						Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
					}
				}
			}
			if (mountedPlayer.whoAmi == Main.myPlayer)
			{
				NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmi, 0f, 0f, 0f, 0);
			}
		}
Example #7
0
		public void Dismount(Player mountedPlayer)
		{
			if (!this._active)
			{
				return;
			}
			this._active = false;
			mountedPlayer.ClearBuff(this._data.buff);
			if (this._type == 6)
			{
				mountedPlayer.ClearBuff(this._data.extraBuff);
				mountedPlayer.cartFlip = false;
				mountedPlayer.fullRotation = 0f;
				mountedPlayer.fullRotationOrigin = Vector2.Zero;
				mountedPlayer.lastBoost = Vector2.Zero;
			}
			if (Main.netMode != 2)
			{
				for (int i = 0; i < 100; i++)
				{
					if (this._type == 6)
					{
						if (i % 10 == 0)
						{
							int type = Main.rand.Next(61, 64);
							int num = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
							Main.gore[num].alpha = 100;
							Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
						}
					}
					else
					{
						int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
						Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
						if (Main.rand.Next(2) == 0)
						{
							Main.dust[num2].scale *= 1.3f;
							Main.dust[num2].noGravity = true;
						}
						else
						{
							Main.dust[num2].velocity *= 0.5f;
						}
						Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
					}
				}
			}
			this.Reset();
			mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
			mountedPlayer.height = 42;
			mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
			if (mountedPlayer.whoAmi == Main.myPlayer)
			{
				NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmi, 0f, 0f, 0f, 0);
			}
		}
Example #8
0
 public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
 {
     if (this._type == m || m <= -1 || m >= 14)
     {
         return;
     }
     if (m == 5 && mountedPlayer.wet)
     {
         return;
     }
     if (this._active)
     {
         mountedPlayer.ClearBuff(this._data.buff);
         if (this.Cart)
         {
             mountedPlayer.ClearBuff(this._data.extraBuff);
             mountedPlayer.cartFlip = false;
             mountedPlayer.lastBoost = Vector2.Zero;
         }
         mountedPlayer.fullRotation = 0f;
         mountedPlayer.fullRotationOrigin = Vector2.Zero;
         this._mountSpecificData = null;
     }
     else
     {
         this._active = true;
     }
     this._flyTime = 0;
     this._type = m;
     this._data = Mount.mounts[m];
     this._fatigueMax = (float)this._data.fatigueMax;
     if (this.Cart && !faceLeft && !this.Directional)
     {
         mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
         this._flipDraw = true;
     }
     else
     {
         mountedPlayer.AddBuff(this._data.buff, 3600, true);
         this._flipDraw = false;
     }
     if (this._type == 9 && this._abilityCooldown < 20)
     {
         this._abilityCooldown = 20;
     }
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     for (int i = 0; i < mountedPlayer.shadowPos.Length; i++)
     {
         Vector2[] expr_14D_cp_0 = mountedPlayer.shadowPos;
         int expr_14D_cp_1 = i;
         expr_14D_cp_0[expr_14D_cp_1].Y = expr_14D_cp_0[expr_14D_cp_1].Y + (float)mountedPlayer.height;
     }
     mountedPlayer.height = 42 + this._data.heightBoost;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     for (int j = 0; j < mountedPlayer.shadowPos.Length; j++)
     {
         Vector2[] expr_1AC_cp_0 = mountedPlayer.shadowPos;
         int expr_1AC_cp_1 = j;
         expr_1AC_cp_0[expr_1AC_cp_1].Y = expr_1AC_cp_0[expr_1AC_cp_1].Y - (float)mountedPlayer.height;
     }
     if (this._type == 7 || this._type == 8)
     {
         mountedPlayer.fullRotationOrigin = new Vector2((float)(mountedPlayer.width / 2), (float)(mountedPlayer.height / 2));
     }
     if (this._type == 8)
     {
         this._mountSpecificData = new Mount.DrillMountData();
     }
     if (Main.netMode != 2)
     {
         for (int k = 0; k < 100; k++)
         {
             if (this._type == 6 || this._type == 11 || this._type == 13)
             {
                 if (k % 10 == 0)
                 {
                     int type = Main.rand.Next(61, 64);
                     int num = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
                     Main.gore[num].alpha = 100;
                     Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
                 }
             }
             else
             {
                 int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
                 Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
                 if (this._data.spawnDustNoGravity)
                 {
                     Main.dust[num2].noGravity = true;
                 }
                 else if (Main.rand.Next(2) == 0)
                 {
                     Main.dust[num2].scale *= 1.3f;
                     Main.dust[num2].noGravity = true;
                 }
                 else
                 {
                     Main.dust[num2].velocity *= 0.5f;
                 }
                 Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
             }
         }
     }
     if (mountedPlayer.whoAmI == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0f, 0f, 0f, 0, 0, 0);
     }
 }
Example #9
0
 public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
 {
     if (this._type == m || m <= -1 || m >= 14 || m == 5 && mountedPlayer.wet)
         return;
     if (this._active)
     {
         mountedPlayer.ClearBuff(this._data.buff);
         if (this.Cart)
         {
             mountedPlayer.ClearBuff(this._data.extraBuff);
             mountedPlayer.cartFlip = false;
             mountedPlayer.lastBoost = Vector2.Zero;
         }
         mountedPlayer.fullRotation = 0.0f;
         mountedPlayer.fullRotationOrigin = Vector2.Zero;
         this._mountSpecificData = (object)null;
     }
     else
         this._active = true;
     this._flyTime = 0;
     this._type = m;
     this._data = Mount.mounts[m];
     this._fatigueMax = (float)this._data.fatigueMax;
     if (this.Cart && !faceLeft && !this.Directional)
     {
         mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
         this._flipDraw = true;
     }
     else
     {
         mountedPlayer.AddBuff(this._data.buff, 3600, true);
         this._flipDraw = false;
     }
     if (this._type == 9 && this._abilityCooldown < 20)
         this._abilityCooldown = 20;
     mountedPlayer.position.Y += (float)mountedPlayer.height;
     for (int index = 0; index < mountedPlayer.shadowPos.Length; ++index)
         mountedPlayer.shadowPos[index].Y += (float)mountedPlayer.height;
     mountedPlayer.height = 42 + this._data.heightBoost;
     mountedPlayer.position.Y -= (float)mountedPlayer.height;
     for (int index = 0; index < mountedPlayer.shadowPos.Length; ++index)
         mountedPlayer.shadowPos[index].Y -= (float)mountedPlayer.height;
     if (this._type == 7 || this._type == 8)
         mountedPlayer.fullRotationOrigin = new Vector2((float)(mountedPlayer.width / 2), (float)(mountedPlayer.height / 2));
     if (this._type == 8)
         this._mountSpecificData = (object)new Mount.DrillMountData();
     if (Main.netMode != 2)
     {
         for (int index1 = 0; index1 < 100; ++index1)
         {
             if (this._type == 6 || this._type == 11 || this._type == 13)
             {
                 if (index1 % 10 == 0)
                 {
                     int Type = Main.rand.Next(61, 64);
                     int index2 = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, Type, 1f);
                     Main.gore[index2].alpha = 100;
                     Main.gore[index2].velocity = Vector2.Transform(new Vector2(1f, 0.0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.28318548202515)));
                 }
             }
             else
             {
                 int index2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0.0f, 0.0f, 0, new Color(), 1f);
                 Main.dust[index2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
                 if (this._data.spawnDustNoGravity)
                     Main.dust[index2].noGravity = true;
                 else if (Main.rand.Next(2) == 0)
                 {
                     Main.dust[index2].scale *= 1.3f;
                     Main.dust[index2].noGravity = true;
                 }
                 else
                     Main.dust[index2].velocity *= 0.5f;
                 Main.dust[index2].velocity += mountedPlayer.velocity * 0.8f;
             }
         }
     }
     if (mountedPlayer.whoAmI != Main.myPlayer)
         return;
     NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
 }
Example #10
0
 public void Dismount(Player mountedPlayer)
 {
     if (!this._active)
         return;
     bool cart = this.Cart;
     this._active = false;
     mountedPlayer.ClearBuff(this._data.buff);
     this._mountSpecificData = (object)null;
     if (cart)
     {
         mountedPlayer.ClearBuff(this._data.extraBuff);
         mountedPlayer.cartFlip = false;
         mountedPlayer.lastBoost = Vector2.Zero;
     }
     mountedPlayer.fullRotation = 0.0f;
     mountedPlayer.fullRotationOrigin = Vector2.Zero;
     if (Main.netMode != 2)
     {
         for (int index1 = 0; index1 < 100; ++index1)
         {
             if (this._type == 6 || this._type == 11 || this._type == 13)
             {
                 if (index1 % 10 == 0)
                 {
                     int Type = Main.rand.Next(61, 64);
                     int index2 = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, Type, 1f);
                     Main.gore[index2].alpha = 100;
                     Main.gore[index2].velocity = Vector2.Transform(new Vector2(1f, 0.0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.28318548202515)));
                 }
             }
             else
             {
                 int index2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0.0f, 0.0f, 0, new Color(), 1f);
                 Main.dust[index2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
                 if (this._data.spawnDustNoGravity)
                     Main.dust[index2].noGravity = true;
                 else if (Main.rand.Next(2) == 0)
                 {
                     Main.dust[index2].scale *= 1.3f;
                     Main.dust[index2].noGravity = true;
                 }
                 else
                     Main.dust[index2].velocity *= 0.5f;
                 Main.dust[index2].velocity += mountedPlayer.velocity * 0.8f;
             }
         }
     }
     this.Reset();
     mountedPlayer.position.Y += (float)mountedPlayer.height;
     mountedPlayer.height = 42;
     mountedPlayer.position.Y -= (float)mountedPlayer.height;
     if (mountedPlayer.whoAmI != Main.myPlayer)
         return;
     NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0);
 }
Example #11
0
 public void SetMount(int m, Player mountedPlayer, bool faceLeft = false)
 {
     if (this._type == m || m <= -1 || m >= 7)
     {
         return;
     }
     if (m == 5 && mountedPlayer.wet)
     {
         return;
     }
     if (this._active)
     {
         mountedPlayer.ClearBuff(this._data.buff);
         if (this._type == 6)
         {
             mountedPlayer.ClearBuff(this._data.extraBuff);
         }
     }
     else
     {
         this._active = true;
     }
     this._flyTime    = 0;
     this._type       = m;
     this._data       = Mount.mounts[m];
     this._fatigueMax = (float)this._data.fatigueMax;
     if (this._type == 6 && !faceLeft)
     {
         mountedPlayer.AddBuff(this._data.extraBuff, 3600, true);
         this._flipDraw = true;
     }
     else
     {
         mountedPlayer.AddBuff(this._data.buff, 3600, true);
         this._flipDraw = false;
     }
     mountedPlayer.position.Y = mountedPlayer.position.Y + (float)mountedPlayer.height;
     mountedPlayer.height     = 42 + this._data.heightBoost;
     mountedPlayer.position.Y = mountedPlayer.position.Y - (float)mountedPlayer.height;
     if (Main.netMode != 2)
     {
         for (int i = 0; i < 100; i++)
         {
             if (this._type == 6)
             {
                 if (i % 10 == 0)
                 {
                     int type = Main.rand.Next(61, 64);
                     int num  = Gore.NewGore(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), Vector2.Zero, type, 1f);
                     Main.gore[num].alpha    = 100;
                     Main.gore[num].velocity = Vector2.Transform(new Vector2(1f, 0f), Matrix.CreateRotationZ((float)(Main.rand.NextDouble() * 6.2831854820251465)));
                 }
             }
             else
             {
                 int num2 = Dust.NewDust(new Vector2(mountedPlayer.position.X - 20f, mountedPlayer.position.Y), mountedPlayer.width + 40, mountedPlayer.height, this._data.spawnDust, 0f, 0f, 0, default(Color), 1f);
                 Main.dust[num2].scale += (float)Main.rand.Next(-10, 21) * 0.01f;
                 if (Main.rand.Next(2) == 0)
                 {
                     Main.dust[num2].scale    *= 1.3f;
                     Main.dust[num2].noGravity = true;
                 }
                 else
                 {
                     Main.dust[num2].velocity *= 0.5f;
                 }
                 Main.dust[num2].velocity += mountedPlayer.velocity * 0.8f;
             }
         }
     }
     if (mountedPlayer.whoAmi == Main.myPlayer)
     {
         NetMessage.SendData(13, -1, -1, "", mountedPlayer.whoAmi, 0f, 0f, 0f, 0);
     }
 }