public override void Kill(int timeLeft) { Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y); // Play a death sound Vector2 usePos = projectile.position; // Position to use for dusts // Please note the usage of MathHelper, please use this! // We subtract 90 degrees as radians to the rotation vector to offset the sprite as its default rotation in the sprite isn't aligned properly. Vector2 rotVector = (projectile.rotation - MathHelper.ToRadians(90f)).ToRotationVector2(); // rotation vector to use for dust velocity usePos += rotVector * 16f; // Declaring a constant in-line is fine as it will be optimized by the compiler // It is however recommended to define it outside method scope if used elswhere as well // They are useful to make numbers that don't change more descriptive const int NUM_DUSTS = 5; Vector2 center; float angle; Vector2 tar; if (projectile.damage < 1) { if (Main.rand.Next(2) == 0) { if (hasSpawned == false) { hasSpawned = true; for (int i = 0; i < (Main.rand.Next(2) + 1); i++) { // Where dagger appears angle = Main.rand.Next(360) * 0.0174f; //center.X += (float)System.Math.Sin(angle) * 200; //center.Y += (float)System.Math.Cos(angle) * 200; center.X = projectile.position.X; center.Y = projectile.position.Y; tar.X = projectile.position.X; tar.Y = projectile.position.Y; tar.Normalize(); tar.X += (float)System.Math.Sin(angle) * 200; tar.Y += (float)System.Math.Cos(angle) * 200; tar.Normalize(); tar *= 3; // speed //tar.X -= (tar.X / 2) * 2 ; //Projectile.NewProjectile(center.X, center.Y, tar.X, tar.Y, mod.ProjectileType("FrostShankProjectile"), (int)(damage * 0.50f), knockback, projectile.owner, 0f, 0f); if (Main.player[projectile.owner].strongBees == true) { if (Main.rand.NextBool(4)) { int hesinthebuilding = Projectile.NewProjectile(center.X, center.Y, tar.X, tar.Y, ProjectileID.GiantBee, (int)(initialDamage * 0.80f), (projectile.knockBack + 0.4f), projectile.owner, 0f, 0f); Main.projectile[hesinthebuilding].thrown = true; Main.projectile[hesinthebuilding].usesLocalNPCImmunity = true; Main.projectile[hesinthebuilding].localNPCHitCooldown = 10; } else { int oprahbeesdotgif2 = Projectile.NewProjectile(center.X, center.Y, tar.X, tar.Y, ProjectileID.Bee, (int)(initialDamage * 0.60f), projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[oprahbeesdotgif2].thrown = true; Main.projectile[oprahbeesdotgif2].usesLocalNPCImmunity = true; Main.projectile[oprahbeesdotgif2].localNPCHitCooldown = 10; } } else { int oprahbeesdotgif = Projectile.NewProjectile(center.X, center.Y, tar.X, tar.Y, ProjectileID.Bee, (int)(initialDamage * 0.60f), projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[oprahbeesdotgif].thrown = true; Main.projectile[oprahbeesdotgif].usesLocalNPCImmunity = true; Main.projectile[oprahbeesdotgif].localNPCHitCooldown = 10; } } // last 0f,0f, this is projectile.ai[0] and projectile.ai[1] where you can put timer, angle, or the target.a } } } // Spawn some dusts upon javelin death for (int i = 0; i < NUM_DUSTS; i++) { // Create a new dust Dust dust = Dust.NewDustDirect(usePos, projectile.width, projectile.height, 215); dust.position = (dust.position + projectile.Center) / 2f; dust.velocity += rotVector * 2f; dust.velocity *= 0.5f; dust.noGravity = true; usePos -= rotVector * 8f; } }
public override bool PreAI() { //projectile.rotation = MathHelper.ToRadians(90); Player player = Main.player[projectile.owner]; Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); projectile.localAI[1] = 1; bool isChanneling = player.channel && !player.noItems && !player.CCed; if (isChanneling) { if (Main.myPlayer == projectile.owner) { float scaleFactor = 1f; if (player.inventory[player.selectedItem].shoot == projectile.type) { projectile.scale = player.inventory[player.selectedItem].scale; projectile.localAI[1] = (30f / (float)player.inventory[player.selectedItem].useTime) / player.meleeSpeed; scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; } Vector2 mouseVector = Main.MouseWorld - vector; //Vector between cursor pos and player mouseVector.Normalize(); if (mouseVector.HasNaNs()) { mouseVector = Vector2.UnitX * (float)player.direction; } mouseVector *= scaleFactor; if (mouseVector.X != projectile.velocity.X || mouseVector.Y != projectile.velocity.Y) { projectile.netUpdate = true; } projectile.velocity = mouseVector; } } else { projectile.Kill(); } if (projectile.ai[1] == 0) { projectile.ai[0] = 0; } if (player.velocity.Y == 0) { projectile.ai[0] = 1; } float speed = 12f; float accel = (speed * projectile.localAI[1]) / 30f; projectile.localNPCHitCooldown = (int)(20f / projectile.localAI[1]); projectile.ai[1] = projectile.ai[1] < 30 ? projectile.ai[1] + projectile.localAI[1] : 0; bool halt = ((player.controlLeft && player.velocity.X > 0 && projectile.velocity.X > 0) || (player.velocity.X < 0 && projectile.velocity.X < 0 && player.controlRight)); bool zip = ((player.velocity.X > 0 && projectile.velocity.X > 0 && player.controlRight) || (player.velocity.X < 0 && projectile.velocity.X < 0 && player.controlLeft)); if (projectile.ai[1] < 10) { if (!zip) { player.velocity.X *= 0.9f; } } else if (projectile.ai[1] < 20) { if (!zip) { player.velocity.X *= 0.9f; } } else { for (int i = 0; i < 3; i++) { Dust d = Dust.NewDustDirect(player.position, player.width, player.height, 229, player.velocity.X * -0.2f, player.velocity.Y * -0.2f); d.noGravity = true; } for (int i = 0; i < 5; i++) { Dust d = Dust.NewDustPerfect(player.Center, 229); d.position += player.velocity * 3f; d.velocity = 0.2f * player.velocity.RotatedBy(1f + 0.1f * i); d.position += d.velocity * 2f; d.noGravity = true; d = Dust.NewDustPerfect(player.Center, 229); d.position += player.velocity * 3f; d.velocity = 0.2f * player.velocity.RotatedBy(-(1f + 0.1f * i)); d.position += d.velocity * 2f; d.noGravity = true; } player.velocity.Y = ((projectile.ai[0] > 0 && player.velocity.Y > -speed) || projectile.velocity.Y > 0) ? player.velocity.Y + projectile.velocity.Y * accel : player.velocity.Y; player.velocity.X = Math.Abs(player.velocity.X) < speed ? player.velocity.X + projectile.velocity.X * accel : player.velocity.X; } if (halt) { player.velocity.X *= 0.9f; } projectile.position = (projectile.velocity + vector) - projectile.Size / 2f; projectile.rotation = projectile.velocity.ToRotation() + (projectile.direction == -1 ? 3.14f : 0); projectile.spriteDirection = projectile.direction; player.ChangeDir(projectile.direction); player.heldProj = projectile.whoAmI; player.itemTime = 10; player.itemAnimation = 10; player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); return(false); }
public override void AI() { // Slowly remove alpha as it is present if (projectile.alpha > 0) { projectile.alpha -= alphaReduction; } // If alpha gets lower than 0, set it to 0 if (projectile.alpha < 0) { projectile.alpha = 0; } // If ai0 is 0f, run this code. This is the 'movement' code for the javelin as long as it isn't sticking to a target if (!isStickingToTarget) { targetWhoAmI += 1f; // For a little while, the javelin will travel with the same speed, but after this, the javelin drops velocity very quickly. if (targetWhoAmI >= maxTicks) { // Change these multiplication factors to alter the javelin's movement change after reaching maxTicks float velXmult = 0.98f; // x velocity factor, every AI update the x velocity will be 98% of the original speed float velYmult = 0.35f; // y velocity factor, every AI update the y velocity will be be 0.35f bigger of the original speed, causing the javelin to drop to the ground targetWhoAmI = maxTicks; // set ai1 to maxTicks continuously projectile.velocity.X = projectile.velocity.X * velXmult; projectile.velocity.Y = projectile.velocity.Y + velYmult; } // Make sure to set the rotation accordingly to the velocity, and add some to work around the sprite's rotation projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians( 90f); // Please notice the MathHelper usage, offset the rotation by 90 degrees (to radians because rotation uses radians) because the sprite's rotation is not aligned! // Spawn some random dusts as the javelin travels if (Main.rand.Next(3) == 0) { Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, mod.DustType <Dusts.Sparkle>(), projectile.velocity.X * .2f, projectile.velocity.Y * .2f, 200, Scale: 1.2f); dust.velocity += projectile.velocity * 0.3f; dust.velocity *= 0.2f; } if (Main.rand.Next(4) == 0) { Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, mod.DustType <Dusts.Sparkle>(), 0, 0, 254, Scale: 0.3f); dust.velocity += projectile.velocity * 0.5f; dust.velocity *= 0.5f; } } // This code is ran when the javelin is sticking to a target if (isStickingToTarget) { // These 2 could probably be moved to the ModifyNPCHit hook, but in vanilla they are present in the AI projectile.ignoreWater = true; // Make sure the projectile ignores water projectile.tileCollide = false; // Make sure the projectile doesn't collide with tiles anymore int aiFactor = 15; // Change this factor to change the 'lifetime' of this sticking javelin bool killProj = false; // if true, kill projectile at the end bool hitEffect = false; // if true, perform a hit effect projectile.localAI[0] += 1f; // Every 30 ticks, the javelin will perform a hit effect hitEffect = projectile.localAI[0] % 30f == 0f; int projTargetIndex = (int)targetWhoAmI; if (projectile.localAI[0] >= (float)(60 * aiFactor) || // If it's time for this javelin to die, kill it (projTargetIndex < 0 || projTargetIndex >= 200)) // If the index is past its limits, kill it { killProj = true; } else if (Main.npc[projTargetIndex].active && !Main.npc[projTargetIndex].dontTakeDamage) // If the target is active and can take damage { // Set the projectile's position relative to the target's center projectile.Center = Main.npc[projTargetIndex].Center - projectile.velocity * 2f; projectile.gfxOffY = Main.npc[projTargetIndex].gfxOffY; if (hitEffect) // Perform a hit effect here { Main.npc[projTargetIndex].HitEffect(0, 1.0); } } else // Otherwise, kill the projectile { killProj = true; } if (killProj) // Kill the projectile { projectile.Kill(); } } }
public void explosionFX(float normalTime) { //explosion ball dust indicates size for (int i = 0; i < (ChargeLevel + 3) * 3 * normalTime; i++) { Vector2 velocity = new Vector2( Main.rand.Next(-projectile.width, projectile.width + 1), Main.rand.Next(-projectile.height, projectile.height + 1)); //make into a circle Vector2 normal = new Vector2(velocity.X * 0.5f, velocity.Y * 0.5f); normal.Normalize(); normal.X = Math.Abs(normal.X); normal.Y = Math.Abs(normal.Y); //make dust move distance of projectile size float log = (float)Math.Log((double)(velocity.X * velocity.X + velocity.Y * velocity.Y)); //make into a ring float ring = projectile.width / velocity.Length(); //explosion INNER Dust d = Dust.NewDustDirect(projectile.Center - new Vector2(16, 16), 32, 32, 262, velocity.X * normal.X / log, velocity.Y * normal.Y / log, 0, Color.White, 1f + ChargeLevel * 0.3f); d.noGravity = true; d.velocity *= 0.6f; //explosion OUTER d = Dust.NewDustDirect(projectile.Center - new Vector2(16, 16), 32, 32, 262, velocity.X * ring / log, velocity.Y * ring / log, 0, Color.White, 0.6f + ChargeLevel * 0.1f); d.noGravity = true; d.velocity *= 0.5f; if (i % 2 == 0) { //explosion shockwave horizontal d = Dust.NewDustDirect(projectile.Center - new Vector2(16, 16), 32, 32, 262, velocity.X * ring * 1.5f / log, velocity.Y * ring * 0.3f / log, 0, Color.White, 0.2f); d.noGravity = true; d.fadeIn = 0.4f + Main.rand.NextFloat() * 0.4f + ChargeLevel * 0.1f; d.velocity *= 0.5f; //explosion shockwave vertical d = Dust.NewDustDirect(projectile.Center - new Vector2(16, 16), 32, 32, 262, velocity.X * ring * 0.2f / log, velocity.Y * ring * 1.5f / log, 0, Color.White, 0.2f); d.noGravity = true; d.fadeIn = 0.4f + Main.rand.NextFloat() * 0.4f + ChargeLevel * 0.1f; d.velocity *= 0.5f; } } try { float denominator = 1 + Vector2.DistanceSquared(Main.player[Main.myPlayer].Center, projectile.Center) / 500000; WeaponOut.shakeIntensity = Math.Max(WeaponOut.shakeIntensity, (int)(2 * ChargeLevel / denominator)); //Main.NewText("shake = \n" + (int)(2 * ChargeLevel / denominator) + ": \n" + (2 * ChargeLevel) + "/\n" + denominator); } catch { //-//Main.NewText("ERROR IN SHAKING"); } }
public override void MeleeEffects(Player player, Rectangle hitbox) { Dust dust = Dust.NewDustDirect(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("LightParticle")); }
public override void Kill(int timeLeft) { for (int k = 0; k < 8; k++) { Dust dust = Dust.NewDustDirect(projectile.Center, 10, 10, 90, Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, 4f), 0, default, 1.25f);
// It appears that for this AI, only the ai0 field is used! public override void AI() { // Since we access the owner player instance so much, it's useful to create a helper local variable for this // Sadly, Projectile/ModProjectile does not have its own Player projOwner = Main.player[projectile.owner]; // Here we set some of the projectile's owner properties, such as held item and itemtime, along with projectile direction and position based on the player Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter, true); projectile.direction = projOwner.direction; projOwner.heldProj = projectile.whoAmI; projOwner.itemTime = projOwner.itemAnimation; projectile.position.X = ownerMountedCenter.X - (float)(projectile.width / 2); projectile.position.Y = ownerMountedCenter.Y - (float)(projectile.height / 2); // As long as the player isn't frozen, the spear can move if (!projOwner.frozen) { if (movementFactor == 0f) // When initially thrown out, the ai0 will be 0f { movementFactor = 2.0f; // Make sure the spear moves forward when initially thrown out projectile.netUpdate = true; // Make sure to netUpdate this spear } if (projOwner.itemAnimation < projOwner.itemAnimationMax / 3) // Somewhere along the item animation, make sure the spear moves back { movementFactor -= 1.7f; } else // Otherwise, increase the movement factor { movementFactor += 1.6f; } } // Change the spear position based off of the velocity and the movementFactor projectile.position += projectile.velocity * movementFactor; // When we reach the end of the animation, we can kill the spear projectile if (projOwner.itemAnimation == 0) { projectile.Kill(); } // Apply proper rotation, with an offset of 135 degrees due to the sprite's rotation, notice the usage of MathHelper, use this class! // MathHelper.ToRadians(xx degrees here) projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); // Offset by 90 degrees here if (projectile.spriteDirection == -1) { projectile.rotation -= MathHelper.ToRadians(90f); } //if (Main.player[projectile.owner].itemAnimation < Main.player[projectile.owner].itemAnimationMax / 3) //code to shoot projectiles when spear is extended with a clear shot, not at lower angles. //{ // projectile.ai[0] -= 1.1f; // if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) // { // projectile.localAI[0] = 1f; // if (Collision.CanHit(Main.player[projectile.owner].position, Main.player[projectile.owner].width, Main.player[projectile.owner].height, new Vector2(projectile.Center.X + projectile.velocity.X * projectile.ai[0], projectile.Center.Y + projectile.velocity.Y * projectile.ai[0]), projectile.width, projectile.height)) // { // int z = Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, projectile.velocity.X * 1.5f, projectile.velocity.Y * 1.5f, ModContent.ProjectileType("SpitProj"), projectile.damage, projectile.knockBack * 0.85f, projectile.owner, 0f, 0f); // Main.projectile[z].tileCollide = true; // Main.projectile[z].timeLeft = 240; // } // // These dusts are added later, for the 'ExampleMod' effect if (Main.rand.Next(3) == 0) { Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, 170, projectile.velocity.X * .2f, projectile.velocity.Y * .2f, 200, Scale: 1.2f); dust.velocity += projectile.velocity * 0.3f; dust.velocity *= 0.2f; } // //if (Main.rand.Next(4) == 0) // //{ // // Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, mod.DustType<Dusts.Sparkle>(), // // 0, 0, 254, Scale: 0.3f); // // dust.velocity += projectile.velocity * 0.5f; // // dust.velocity *= 0.5f; // //} // } //} }
private void MovementAI(Player player, int damagedNearlySum, bool UpgradeOutBeach) { switch ((NPCState)State) { case NPCState.Start: { oldLife = npc.life; npc.TargetClosest(true); npc.alpha = 0; SwitchState((int)NPCState.Move); break; } case NPCState.Break: { if ((float)npc.life / (float)npc.lifeMax <= 0.46f) { SwitchState((int)NPCState.Break_State2); Timer = 0; npc.ai[2] = npc.ai[3] = 0; IsState2 = true; return; } Timer++; if (Timer <= 15) { npc.alpha -= 255 / 15 + 1; } npc.dontTakeDamage = true; if (Timer > (int)(80f - (1f - (float)npc.life / (float)npc.lifeMax) * 40f)) { npc.TargetClosest(); switch (Main.rand.Next(3)) { case 0: SwitchState((int)NPCState.Move); break; case 1: SwitchState((int)NPCState.Dash); break; default: SwitchState((int)NPCState.Rotat); break; } if (damagedNearlySum >= 680 && FindWater(60, 60) && Main.rand.NextBool(2)) { SwitchState((int)NPCState.FindingWaters); } if ((NPCState)State == NPCState.Dash) // 冲刺Biss { switch (Main.rand.Next(2)) { case 0: SwitchState((int)NPCState.Move); break; default: SwitchState((int)NPCState.Rotat); break; } } Timer = 0; } break; } case NPCState.Move: { Timer++; if (Timer == 1) { npc.Center = player.Center + new Vector2(Main.rand.Next(24, 33) * 16 * (Main.rand.NextBool(2) ? 1f : -1f) , Main.rand.Next(14, 21) * 16 * (Main.rand.NextBool(2) ? 1f : -1f)); npc.netUpdate = true; } if (Timer <= 15) { npc.alpha += 255 / 15 + 1; } npc.velocity = (player.Center - npc.Center).ToRotation().ToRotationVector2() * (7.2f - (float)water / (float)waterMax * 2f); int MigrantCount = 0; foreach (NPC npc in Main.npc) { if (npc.type == NPCType <Migrant>()) { MigrantCount++; } } if (Timer % 85 == 0 && MigrantCount <= 20 && Main.netMode != NetmodeID.MultiplayerClient) { NPC migrant = Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCType <Migrant>())]; migrant.scale = 1f + (float)water / (float)waterMax * 0.4f; water -= 32; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, migrant.whoAmI, -1f, 0f, 0f, 0, 0, 0); } } if (Timer % (int)(72f - (1f - (float)npc.life / (float)npc.lifeMax) * 50f) == 0) { float shouldHeight = -12.4f; if (player.Center.Y < npc.Center.Y) { shouldHeight -= (npc.Center.Y - player.Center.Y) * 0.0625f; } if (shouldHeight < -20f) { shouldHeight = -20f; } Shooting(2, npc.Center, player.Center + player.velocity * 85f, 0.0f, Main.rand.NextFloat(9.6f, 14.9f) * 3f, shouldHeight); water -= 8; } if (Timer >= 185) { Timer = 0; SwitchState((int)NPCState.Break); } break; } case NPCState.Dash: { Timer++; if (Timer == 1) { npc.Center = player.Center + new Vector2(30 * 16 * (Main.rand.NextBool(2) ? 1f : -1f) , 20 * 16 * (Main.rand.NextBool(2) ? 1f : -1f)); npc.netUpdate = true; } if (Timer <= 15) { npc.alpha += 255 / 15 + 1; } if (Timer == 25) { npc.direction = npc.Center.X > player.Center.X ? -1 : 1; npc.spriteDirection = npc.direction; npc.velocity.X = npc.direction * 24; Main.PlaySound(SoundID.ForceRoar, (int)npc.position.X, (int)npc.position.Y, -1, 1f, 0f); } if ((Timer - 25) % 5 == 0) { Shooting(0, npc.Center, player.Center, 0f, 20f); water -= 2; } if (Timer == 40 && Main.netMode != NetmodeID.MultiplayerClient) { NPC migrant = Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCType <Migrant>())]; migrant.scale = 1f + (float)water / (float)waterMax * 0.4f; water -= 32; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, migrant.whoAmI, -1f, 0f, 0f, 0, 0, 0); } } if (Timer >= 65) { Timer = 0; npc.velocity.X = 0f; SwitchState((int)NPCState.Break); } break; } case NPCState.Rotat: { npc.velocity = Vector2.Zero; Timer++; if (Timer == 1) { npc.Center = player.Center + new Vector2(0f, 26 * 16 * (Main.rand.NextBool(2) ? 1f : -1f)); npc.netUpdate = true; int insideTiles = 0; for (int i = 0; i < npc.width / 16; i++) { for (int j = 0; j < npc.height / 16; j++) { Tile tile = Main.tile[i + (int)npc.position.X / 16, j + (int)npc.position.Y / 16]; if (Main.tileSolid[tile.type] && tile.active() && tile != null) { insideTiles++; } } } if (insideTiles >= 12) { npc.Center = new Vector2(npc.Center.X, npc.Center.Y + -(npc.Center.Y - player.Center.Y)); } } if (Timer <= 15) { npc.alpha += 255 / 15 + 1; } npc.ai[3] += 0.006f; if (npc.ai[3] >= 0.3f) { if (npc.ai[3] >= 0.55f) { npc.ai[3] = 0.55f; } npc.frameCounter += npc.ai[3]; // 发射 if (Timer % 2 == 0 && Main.rand.Next(1, 4) <= 2 && Main.netMode != NetmodeID.MultiplayerClient) { if (Main.rand.NextBool(6)) { water -= 6; Shooting(1, npc.Center, npc.Center + new Vector2(0f, -10f), Main.rand.NextFloat(0.0f, MathHelper.TwoPi), Main.rand.Next(9, 20)); } water -= 1; Shooting(0, npc.Center, player.Center, Main.rand.NextFloat(0.0f, MathHelper.TwoPi), Main.rand.Next(10, 16)); } } if (Timer >= 245) { Timer = 0; npc.ai[3] = 0f; SwitchState((int)NPCState.Break); } break; } case NPCState.FindingWaters: { Timer++; npc.velocity = Vector2.Zero; if (Timer == 1) { npc.Center = waterPos + new Vector2(50f, 50f); npc.netUpdate = true; if (water >= waterMax) { water = (int)(waterMax * 0.7f); } } if (Timer <= 15) { npc.alpha += 255 / 15 + 1; } if (Timer >= 150 || water >= waterMax || npc.life >= npc.lifeMax) { Timer = 0; SwitchState((int)NPCState.Break); } break; } case NPCState.Break_State2: { Timer++; if (Timer > 10 && Main.netMode != NetmodeID.MultiplayerClient) { switch (Main.rand.Next(2)) { case 0: SwitchState((int)NPCState.Move_State2); break; default: SwitchState((int)NPCState.Round_State2); break; } npc.netUpdate = true; Timer = 0; npc.ai[2] = npc.ai[3] = 0; IsState2 = true; } break; } case NPCState.Move_State2: { npc.velocity = ModHelper.GetFromToVector(npc.Center, player.Center) * 8.2f; Timer++; if ((Timer - 30) % 50 == 0 && Timer > 60 && Main.netMode != NetmodeID.MultiplayerClient) { int proj = Projectile.NewProjectile(npc.Center, Vector2.Zero, ProjectileType <ShootingLine>(), 0, 0f, 255, 0f, npc.whoAmI); Main.projectile[proj].ai[1] = npc.whoAmI; if (Main.dedServ) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj); } } if (Timer == 250) { if (Main.rand.NextBool(3)) { SwitchState((int)NPCState.Magic_State2); } else { SwitchState((int)NPCState.Round_State2); } npc.ai[2] = npc.ai[3] = Timer = 0; return; } break; } case NPCState.Magic_State2: { // 距离小于50,且没有成功过就进入 Vector2 targetPos = player.Center + new Vector2(0f, 320f); if (Vector2.Distance(npc.Center, targetPos) > 50f && npc.ai[2] != 1) { npc.velocity = ModHelper.GetFromToVector(npc.Center, targetPos) * 36f; return; } else if (npc.ai[2] != 1) { npc.ai[2] = 1; Timer = 20; } if (npc.ai[2] == 1) { Timer++; } if (Timer >= 20) { npc.velocity = Vector2.Zero; npc.Center = targetPos; npc.netUpdate = true; } if (Timer <= 25) { //npc.alpha -= 255 / 15 + 1; //npc.alpha = Math.Max(0, npc.alpha); } if (Timer % 40 == 0 && Timer >= 70 && Main.netMode != NetmodeID.MultiplayerClient) { int offset = Timer % 80 == 40 ? 80 : 0; for (float pos = -1600f; pos <= 1600f; pos += 320f) { int proj = Projectile.NewProjectile(player.Center - new Vector2(pos + offset, 1000f), Vector2.Zero, ProjectileType <ContimatedShark>(), 60, 3f, 255, 0f, 0f); if (Main.dedServ) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj); } } } if (Timer >= 200f) { //npc.alpha += 255 / 15 + 1; //npc.alpha = Math.Min(255, npc.alpha); } if (Timer >= 215f) { SwitchState((int)(NPCState.Move_State2)); npc.ai[2] = npc.ai[3] = Timer = 0; return; } break; } case NPCState.Round_State2: { // 规定ai2只有0,1,2两种状态 // ai3为记录中的本回合的总时长 // Timer为进入转圈状态的总时长 npc.ai[3]++; // 距离小于36,且没有成功过就进入 Vector2 targetPos = player.Center + new Vector2(0f, -500f); if (Vector2.Distance(npc.Center, targetPos) > 36f && npc.ai[2] < 1) { npc.velocity = ModHelper.GetFromToVector(npc.Center, targetPos) * 30f; return; } else if (npc.ai[2] < 1) { recordedStartRoundPos = npc.Center; npc.ai[2] = 1; } if (npc.ai[2] >= 1) { Timer++; npc.velocity = Vector2.Zero; // 缓冲时间 if (Timer >= 30 && npc.ai[2] != 2f) { npc.ai[2] = 2f; Timer = 0; } if (npc.ai[2] != 2f) { return; } float speedMultipiler = 3.4f; float radians = MathHelper.ToRadians(Timer * speedMultipiler); npc.velocity = new Vector2(16f * speedMultipiler) * radians.ToRotationVector2(); //Main.NewText($"Timer:{Timer}, Radians:{radians}, Velocity:{npc.velocity}."); // 射击(向与NPC移动方向垂直的圈内向量射击)(其实我也不知道我这注释写的什么) Vector2 shootTarget = npc.Center + npc.velocity; // 旋转90°,也就是垂直,是向圆心射击 Shooting(3, npc.Center, shootTarget, 90f, 24f); if (Main.expertMode && Timer % 5 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { Shooting(3, npc.Center, shootTarget, 90f, 10f); } // for模拟一圈,用于显示粒子特效。因为属于特效所以服务器就别掺和了 if (!Main.dedServ) { Vector2 _position = recordedStartRoundPos; for (int _Timer = 0; _Timer <= 360; _Timer += UpgradeOutBeach ? 2 : 1) { float _radians = MathHelper.ToRadians(_Timer); Vector2 _velocity = new Vector2(16f) * _radians.ToRotationVector2(); _position += _velocity; // 生成粒子 Dust d = Dust.NewDustDirect(_position, 4, 4, MyDustId.LightBlueParticle); d.noGravity = true; } } // 转了2.75圈 if (Timer >= 2.75 * (360 / speedMultipiler)) { switch (Main.rand.Next(2)) { case 0: SwitchState((int)NPCState.Move_State2); break; case 1: SwitchState((int)NPCState.Magic_State2); break; } npc.ai[2] = npc.ai[3] = Timer = 0; return; } } else { if (npc.ai[3] >= 240) { switch (Main.rand.Next(2)) { case 0: SwitchState((int)NPCState.Move_State2); break; case 1: SwitchState((int)NPCState.Magic_State2); break; } npc.ai[2] = npc.ai[3] = Timer = 0; return; } } break; } case NPCState.PlayerDead: { npc.TargetClosest(true); Timer++; if (!player.dead && player.active && player.ZoneBeach) { SwitchState((int)NPCState.Break); Timer = 0; } else if (Timer >= 180) { npc.TargetClosest(true); if (player.dead || !player.active || !player.ZoneBeach) { if (Timer <= 195) { npc.alpha -= 255 / 15 + 1; } else { npc.active = false; } } else { SwitchState((int)NPCState.Break); Timer = 0; } } break; } } }
public override bool PreAI() { Player player = Main.player[projectile.owner]; Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); int max = 30; projectile.scale = 1f - (projectile.ai[0] / max); projectile.width = (int)(32 * projectile.scale); projectile.height = (int)(32 * projectile.scale); bool channeling = player.controlUseTile && !player.noItems && !player.CCed && !player.dead; int mana = 5; if (player.inventory[player.selectedItem].type == mod.ItemType("WaterWhip")) { mana = player.inventory[player.selectedItem].mana / 2; } if (projectile.localAI[0] == 0) { projectile.localAI[0]++; } if (channeling && player.CheckMana(mana)) { if (projectile.ai[1] == -1 && projectile.localAI[0] % 40 == 0) { player.CheckMana(mana, true); } projectile.localAI[0]++; if (nextProj >= 0 && Main.projectile[nextProj].type != projectile.type && Main.projectile[nextProj].owner != projectile.owner) { projectile.localAI[0] = 5; } if (player.ownedProjectileCounts[projectile.type] < max - 1 && projectile.localAI[0] == 5) { nextProj = Projectile.NewProjectile(projectile.Center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, projectile.ai[0] + 1, projectile.identity); player.ownedProjectileCounts[projectile.type]++; } if (projectile.ai[1] != -1) { if (Main.projectile[(int)projectile.ai[1]].type == projectile.type && Main.projectile[(int)projectile.ai[1]].owner == projectile.owner) { vector = Main.projectile[(int)projectile.ai[1]].Center; } else { projectile.Kill(); } } if (Main.myPlayer == projectile.owner) { float scaleFactor = 20f * projectile.scale; /* * for (int i = 0; i < projectile.ai[0]; i++) * { * scaleFactor += 8f * (1f - (i / max)); * } */ Vector2 dir = Main.MouseWorld - vector; dir.Normalize(); if (dir.HasNaNs()) { dir = Vector2.UnitX * (float)player.direction; } dir *= scaleFactor; if (dir.X != projectile.velocity.X || dir.Y != projectile.velocity.Y) { projectile.netUpdate = true; } if (projectile.ai[1] == -1) { projectile.velocity = dir; } else { if (Collision.CanHitLine(projectile.position, projectile.width, projectile.height, projectile.Center + dir, 1, 1)) { Vector2 move = vector + dir - projectile.Center; if (move.Length() > 0) { move *= scaleFactor / move.Length(); } float home = 40f - projectile.ai[0]; projectile.velocity = ((home - 1f) * projectile.velocity + move) / home; if (projectile.velocity.Length() < scaleFactor) { projectile.velocity *= (scaleFactor / projectile.velocity.Length()); } } else { projectile.velocity = projectile.oldVelocity; } } } } else { projectile.Kill(); } for (int i = 0; i < Main.item.Length; i++) { if (Main.item[i].active) { Item I = Main.item[i]; if (projectile.Hitbox.Intersects(I.Hitbox)) { Vector2 vel = I.DirectionTo(player.Center) * 2; I.velocity = vel; I.position += I.velocity; } } } if (projectile.localAI[1] > 0) { NPC target = Main.npc[(int)projectile.localAI[1] - 1]; bool tooClose = player.Distance(target.Center) <= (target.width > target.height ? target.width / 2 : target.height / 2) + 30; if (target.active && target.life > 0 && target.knockBackResist > 0 && !target.dontTakeDamage && !target.friendly && target.type != NPCID.TargetDummy) { if (tooClose) { projectile.localAI[1] = 0; target.velocity = player.DirectionTo(target.Center) * projectile.knockBack; } else { target.position = projectile.Center - target.Size / 2; } } else { projectile.localAI[1] = 0; } if (Main.netMode != 0) { ModPacket packet = mod.GetPacket(); packet.Write((byte)JoostModMessageType.NPCpos); packet.Write(target.whoAmI); packet.WriteVector2(target.position); packet.WriteVector2(target.velocity); ModPacket netMessage = packet; netMessage.Send(); } } projectile.position = (vector) - projectile.Size / 2f; projectile.rotation = projectile.velocity.ToRotation(); //projectile.spriteDirection = projectile.direction; projectile.timeLeft = 2; if (projectile.ai[0] == 0) { player.ChangeDir(projectile.direction); player.itemTime = 10; player.itemAnimation = 10; player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } if (projectile.localAI[0] % 5 == 0) { Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 33).noGravity = true; } return(false); }
public override void AI() { Player player = Main.player[projectile.owner]; MyPlayer modPlayer = player.GetModPlayer <MyPlayer>(); if (!_isInitialized) { modPlayer.isMassiveBlastCharging = true; //modPlayer.isMassiveBlastInUse = true; HeldTime = 1; _isInitialized = true; } // cancel channeling if the projectile is maxed if (player.channel && projectile.scale > 3.0) { player.channel = false; } if (player.channel && modPlayer.isMassiveBlastCharging) { projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime; Vector2 projectileOffset = new Vector2(-projectile.width * 0.5f, -projectile.height * 0.5f); projectileOffset += new Vector2(0, -(80 + projectile.scale * 115f)); projectile.position = player.Center + projectileOffset; HeldTime++; for (int d = 0; d < 25; d++) { float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 dustPosition = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.Center + (dustPosition * (40 + 110 * projectile.scale)), projectile.width, projectile.height, 169, 0f, 0f, 213, default(Color), 1.5f); tDust.velocity = Vector2.Normalize((projectile.Center + projectile.Size / 2f) - tDust.position) * 2; tDust.noGravity = true; } //Rock effect projectile.ai[1]++; if (projectile.ai[1] % 7 == 0) { Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("StoneBlockDestruction"), projectile.damage, 0f, projectile.owner); } Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("DirtBlockDestruction"), projectile.damage, 0f, projectile.owner); if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } MyPlayer.ModPlayer(player).AddKi(-2, true, false); player.ApplyChannelingSlowdown(); // depleted check, release the ball if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } } else if (modPlayer.isMassiveBlastCharging) { modPlayer.isMassiveBlastCharging = false; float projectileWidthFactor = projectile.width * projectile.scale / TRAVEL_SPEED_COEFFICIENT; projectile.timeLeft = (int)Math.Ceiling(projectileWidthFactor) + 180; projectile.velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * TRAVEL_SPEED_COEFFICIENT; projectile.tileCollide = false; projectile.damage *= (int)Math.Ceiling(projectile.scale / 3); } projectile.netUpdate = true; projectile.netUpdate2 = true; }
public override void DrawEffects(NPC npc, ref Color drawColor) { if (gouge) { if (!Main.rand.NextBool(4)) { Dust dust = Dust.NewDustDirect(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 5, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 2.2f); Dust dust2 = Dust.NewDustDirect(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 54, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 1.6f); dust.noGravity = true; dust.velocity *= 1.2f; dust.velocity.Y -= 0.7f; dust2.noGravity = true; dust2.velocity *= 1.2f; dust2.velocity.Y -= 0.7f; if (Main.rand.NextBool(4)) { dust.noGravity = false; dust.scale *= 0.3f; dust2.noGravity = false; dust2.scale *= 0.3f; } } drawColor.G = (byte)(drawColor.G * 0.35f); drawColor.B = (byte)(drawColor.B * 0.15f); } if (honeySlow) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width, npc.height, 153, 0f, Main.rand.NextFloat(0.25f, 0.75f), 50, default(Color), 1.35f); Main.dust[dust].noGravity = true; Main.dust[dust].fadeIn = 1.1f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (frozen) { if (!Main.rand.NextBool(5)) { Dust dust = Dust.NewDustDirect(npc.position - new Vector2(2f, 2f), npc.width, npc.height, 111, 0f, 0f, 0, default(Color), 0.75f); dust.noGravity = true; dust.velocity *= 0f; dust.fadeIn = 1.75f; } Lighting.AddLight(npc.position, 0.1f, 0.2f, 0.6f); drawColor.R = (byte)(drawColor.R * 0.35f); drawColor.G = (byte)(drawColor.G * 0.65f); } if (embrittle) { if (!Main.rand.NextBool(5)) { Dust dust = Dust.NewDustDirect(npc.position - new Vector2(2f, 2f), npc.width, npc.height, 57, 0f, 0f, 255, default(Color), 0.65f); dust.shader = GameShaders.Armor.GetSecondaryShader(20, Main.LocalPlayer); dust.noGravity = true; dust.velocity *= 0f; dust.fadeIn = 1.75f; } drawColor.R = (byte)(drawColor.R * 1f); drawColor.G = (byte)(drawColor.G * 1f); drawColor.B = (byte)(drawColor.B * 1f); } }
public override void UpdateAccessory(Player player, bool hideVisual) { t++; /* * int x = Main.spawnTileX; * int y = Main.spawnTileY; * if (a) * { * * for (int chestIndex = 0; chestIndex < 1000; chestIndex++) * { * Chest chest = Main.chest[chestIndex]; * // If you look at the sprite for Chests by extracting Tiles_21.xnb, you'll see that the 12th chest is the Ice Chest. Since we are counting from 0, this is where 11 comes from. 36 comes from the width of each tile including padding. * if (chest != null && Main.tile[chest.x, chest.y].type == TileID.Containers && Main.tile[chest.x, chest.y].frameX == 11 * 36) * { * string str = string.Format("X{0:D} Y{1:D}", Main.mapMaxX/2 - chest.x/16,chest.y/16);//Main.worldSurface * Main.NewText(str); * a = false; * break; * } * } * a=false; * } */ if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 0) { fra = 16 * 36; fra2 = 16 * 36; } if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 1) { fra = 22 * 36; fra2 = 27 * 36; } if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 2) { fra = 21 * 36; fra2 = 26 * 36; } if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 3) { fra = 20 * 36; fra2 = 25 * 36; } if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 4) { fra = 19 * 36; fra2 = 24 * 36; } if (Main.LocalPlayer.GetModPlayer <MyPlayer>().baoxiang == 5) { fra = 18 * 36; fra2 = 23 * 36; } if (t > 120) { for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { Chest chest = Main.chest[chestIndex]; // If you look at the sprite for Chests by extracting Tiles_21.xnb, you'll see that the 12th chest is the Ice Chest. Since we are counting from 0, this is where 11 comes from. 36 comes from the width of each tile including padding. if (chest != null && Main.tile[chest.x, chest.y].type == TileID.Containers && (Main.tile[chest.x, chest.y].frameX == fra || Main.tile[chest.x, chest.y].frameX == fra2)) { abc = new Vector2(chest.x * 16, chest.y * 16); a = true; break; } } if (abc.X != 0 && abc.Y != 0) { Vector2 toTarget = abc - player.Center; toTarget.Normalize(); toTarget *= 3f; // toTarget = toTarget.RotatedBy(0.15f); Projectile.NewProjectile(player.Center, toTarget, mod.ProjectileType("arrwy"), 0, 0f, Main.myPlayer); t = 0; } else { Main.NewText("没有找到符合要求的箱子"); t = 0; } } if (Vector2.Distance(player.position, abc) < 700f && t <= 60) { for (int i = 0; i < 3; i++) { Dust.NewDustDirect(player.position, player.width, player.height, MyDustId.PurpleLight, -player.velocity.X * 0.5f, -player.velocity.Y * 0.5f, 100, Color.White, 1.0f); } } }
public override void AI() { Player player = Main.player[projectile.owner]; if (!isInitialized) { HeldTime = 1; isInitialized = true; } // cancel channeling if the projectile is maxed if (projectile.scale > 12 && player.channel) { player.channel = false; } if (player.channel && HeldTime > 0) { projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime; projectile.position = player.Center + new Vector2(0, -20 - (projectile.scale * 17)); HeldTime++; // reduced from 25. for (int d = 0; d < 15; d++) { // loop hitch for variance. if (Main.rand.NextFloat() < 0.3f) { continue; } float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.position + (position * (20 + 12.5f * projectile.scale)), projectile.width, projectile.height, 15, 0f, 0f, 213, default(Color), 2.0f); tDust.velocity = Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2; tDust.noGravity = true; } //Rock effect if (DBZMOD.IsTickRateElapsed(10) && rocksFloating < MAX_ROCKS) { // only some of the time, keeps it a little more varied. if (Main.rand.NextFloat() < 0.6f) { rocksFloating++; BaseFloatingDestructionProj.SpawnNewFloatingRock(player, projectile); } } projectile.netUpdate = true; if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } MyPlayer.ModPlayer(player).AddKi(-2, true, false); ProjectileUtil.ApplyChannelingSlowdown(player); projectile.netUpdate2 = true; // depleted check, release the ball if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } int soundtimer = 0; soundtimer++; if (soundtimer > 120) { SoundUtil.PlayCustomSound("Sounds/SpiritBombCharge", player, 0.5f); soundtimer = 0; } } else if (HeldTime > 0) { HeldTime = 0; projectile.timeLeft = (int)Math.Ceiling(projectile.scale * 15) + 400; projectile.velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * 3.5f; projectile.tileCollide = false; projectile.damage *= (int)projectile.scale / 2; SoundUtil.PlayCustomSound("Sounds/SpiritBombFire", player); } }
public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) { timer++; float refa = a; a = ((player.statLifeMax - player.statLife) / 100); SpriteBatch spriteBatch = Main.spriteBatch; if (visceralHeartVisual) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive); for (int i = 0; i < 8; i++) { spriteBatch.Draw(mod.GetTexture("Items/Weapons/Visceral/ClottedClump"), player.Center + new Vector2(i < 4 ? -10 : 10, 0) + new Vector2(Main.rand.Next(-10, 10), Main.rand.Next(-10, 10)) - Main.screenPosition, new Rectangle(0, 0, 14, 32), new Color(60, 10, 10, 100), 0, new Vector2(7, 16), new Vector2(2 + Main.rand.NextFloat(0.2f), 2 + Main.rand.NextFloat(0.2f)), i < 4 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); } spriteBatch.End(); spriteBatch.Begin(); } if (chilledAmuletVisual) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive); for (int i = -2; i <= 2; i += 2) { Texture2D tex = mod.GetTexture("Items/Weapons/Frostbite/ChilledAmulet"); float cos1 = MathHelper.Clamp((float)Math.Cos((timer / 10) + Math.Abs(i / 2)), 0, 1f) * 5; spriteBatch.Draw(tex, player.Center - new Vector2(0, player.height / 2) + new Vector2(0, 5) - Main.screenPosition, new Rectangle(0, 0, tex.Width, tex.Height), new Color(255, 255, 255, 255), MathHelper.ToRadians(180) + i * MathHelper.ToRadians(17), new Vector2(tex.Width / 2, -15 - cos1), 1f, SpriteEffects.None, 0f); } spriteBatch.End(); spriteBatch.Begin(); } if (player.GetModPlayer <DayriseDash>().DashTimer2 > 3) { for (int i = 0; i < 3; i++) { Dust dust; Vector2 position = player.position + new Vector2(5, 7); dust = Dust.NewDustDirect(position, player.width - 10, player.height - 14, mod.DustType("LightParticle"), 0f, 0f, 0, new Color(255, 255, 255), 0.6f); dust.noGravity = true; } float alpha = player.GetModPlayer <DayriseDash>().DashTimer2 * 9f; spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive); for (int i = 0; i < 2; i++) { spriteBatch.Draw(mod.GetTexture("Items/Weapons/Phosphor/DashTrail"), player.Center - Main.screenPosition, new Rectangle(0, 0, 50, 50), new Color(alpha, alpha, alpha, alpha), 0, new Vector2(25, 25), 1.3f, SpriteEffects.None, 0f); } for (int i = 0; i < 8; i++) { spriteBatch.Draw(mod.GetTexture("Items/Weapons/Phosphor/DashTrail"), oldPos[i] - Main.screenPosition, new Rectangle(0, 0, 50, 50), new Color(alpha, alpha, alpha, alpha), 0, new Vector2(25, 25), 1 - (0.1f * i), SpriteEffects.None, 0f); } spriteBatch.End(); spriteBatch.Begin(); } if (player.GetModPlayer <DayriseDash>().DashTimer2 == 3) { player.fallStart = (int)player.Bottom.Y; player.fallStart2 = (int)player.Bottom.Y; for (int i = 0; i < 10; i++) { Dust dust; Vector2 position = player.position; dust = Dust.NewDustDirect(position, player.width, player.height, mod.DustType("LightParticle"), 0f, 0f, 0, new Color(255, 255, 255), 1f); dust.noGravity = true; } } a = refa; }
public override void AI() { npc.GivenName = ""; Rectangle room = MWorld.TorizoRoomLocation; if (room.X > 0 && room.Y > 0) { Vector2 pos = new Vector2(room.X + 8, room.Y + room.Height - 4); npc.direction = 1; if (room.X > Main.maxTilesX / 2) { pos.X = (room.X + room.Width - 8); npc.direction = -1; } pos *= 16f; npc.spriteDirection = npc.direction; npc.position.X = pos.X - npc.width / 2; npc.position.Y = pos.Y - npc.height; } for (int i = 0; i < 255; i++) { Player player = Main.player[i]; if (player.active && !player.dead && Vector2.Distance(player.Center, npc.Center) < 200f && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && npc.ai[0] == 0) { npc.ai[0] = 1; npc.target = player.whoAmI; } } eTankFrameCounter++; if (eTankFrameCounter > 2) { eTankFrame++; eTankFrameCounter = 0; } if (eTankFrame > 1) { eTankFrame = 0; } if (npc.ai[0] == 1) { if (npc.ai[1] <= 0) { Vector2 ePos = npc.Center + new Vector2(eTankPos.X * npc.direction, eTankPos.Y); for (int i = 0; i < 10; i++) { Dust dust = Dust.NewDustDirect(ePos - new Vector2(16, 16), 32, 32, 57, 0f, 0f, 100, default(Color), 3f); dust.velocity *= 1.4f; dust.noGravity = true; dust = Dust.NewDustDirect(ePos - new Vector2(16, 16), 32, 32, 30, 0f, 0f, 100, default(Color), 3f); dust.velocity *= 1.4f; dust.noGravity = true; } for (int i = 1; i <= 4; i++) { Vector2 velocity = new Vector2(-Main.rand.Next(31), -Main.rand.Next(31)) * 0.2f * 0.4f; if (i % 2 == 0) { velocity.X *= -1; } Gore gore = Gore.NewGoreDirect(ePos, velocity, mod.GetGoreSlot("Gores/TorizoETankGore" + i)); gore.velocity.X = velocity.X; gore.timeLeft = 60; } Main.PlaySound(2, (int)ePos.X, (int)ePos.Y, 14); drawETank = false; for (int i = 0; i < 6; i++) { Vector2 velocity = new Vector2(Main.rand.Next(12) * npc.direction, -Main.rand.Next(12)); if (velocity.Length() < 6f) { velocity *= (6f / velocity.Length()); } Projectile part = Projectile.NewProjectileDirect(ePos, velocity, mod.ProjectileType("Torizo_EnergyParticle"), 0, 0f); part.ai[0] = npc.Center.X; part.ai[1] = npc.Center.Y; } npc.ai[1] = 1; } else { npc.ai[1]++; if (npc.ai[1] > 180) { npc.ai[0] = 2; npc.ai[1] = 0; } } } if (npc.ai[0] == 2) { for (int i = 9; i >= 0; i--) { Vector2 gPos = npc.Center + gorePos[i]; byte goreFrame = 0; if (npc.direction == -1) { gPos.X = npc.Center.X - gorePos[i].X; goreFrame = 1; } Vector2 velocity = new Vector2(gPos.X - npc.Center.X, gPos.Y - (npc.position.Y + npc.height)) * 0.02f; int type = mod.GetGoreSlot("Gores/TorizoStatueGore" + (1 + i)); gPos.X -= Main.goreTexture[type].Width / 2; gPos.Y -= Main.goreTexture[type].Height / 4; Gore gore = Gore.NewGorePerfect(gPos, velocity, type); gore.numFrames = 2; gore.frame = goreFrame; gore.timeLeft = 60; int stype = 0; if (i % 2 == 0) { stype = 21; } Main.PlaySound(stype, (int)gPos.X, (int)gPos.Y, 1, 1f, 0f); } for (int i = 0; i < 35; i++) { Dust dust = Main.dust[Dust.NewDust(npc.position - new Vector2(8, 8), npc.width + 16, npc.height + 16, 30, 0f, 0f, 100, default(Color), 2.5f)]; dust.velocity *= 1.4f; dust.noGravity = true; } if (!NPC.AnyNPCs(mod.NPCType("Torizo"))) { Vector2 tPos = new Vector2(npc.Center.X - 26 * npc.direction, npc.position.Y + npc.height - 117); NPC.NewNPC((int)tPos.X, (int)tPos.Y, mod.NPCType("Torizo"), npc.whoAmI, 0, 1, 0, 0, npc.target); } if (Main.netMode == 0) { Main.NewText(Language.GetTextValue("Announcement.HasAwoken", "Torizo"), 175, 75, 255, false); } if (Main.netMode == 2) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", "The Torizo"), new Color(175, 75, 255), -1); } npc.active = false; } }
public override void AI() { Player player = Main.player[npc.target]; //Target int proj; int proj2; Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.FrostHydra, 0f, 0f, 0, new Color(0, 255, 142), 0.4605263f); #region Movement Direction if (npc.velocity.X > 0f) // This is the code that makes the sprite turn. Based on the vanilla one. { npc.direction = 1; } else if (npc.velocity.X < 0f) { npc.direction = -1; } else if (npc.velocity.X == 0) { npc.direction = npc.oldDirection; } if (npc.direction == 1) { npc.spriteDirection = 1; } else if (npc.direction == -1) { npc.spriteDirection = -1; } #endregion Movement Direction #region Shooting icetimer--; if (icetimer <= 0) { Icicles(npc); } timer--; if (timer == 60) //Here the shoot bool becomes true, 60 ticks before it shoots { shoot = true; } if (timer <= 0) //If timer is 0 or less it shoots. { if (player.statLife > 0) { if (npc.direction == 1) //I did not find a better way to do this. This defines the positions the projectile based on its direction. { proj = Projectile.NewProjectile(new Vector2(npc.Center.X + 20f, npc.Center.Y), npc.DirectionTo(Main.player[npc.target].Center) * 10f, mod.ProjectileType("FrostBoneShot"), 20, 2, Main.myPlayer, 0, 1); } else if (npc.direction == -1) { proj = Projectile.NewProjectile(new Vector2(npc.Center.X - 28f, npc.Center.Y), npc.DirectionTo(Main.player[npc.target].Center) * 10f, mod.ProjectileType("FrostBoneShot"), 20, 2, Main.myPlayer, 0, 1); } } timer = 120; //Resetting the timer to 120 ticks (2 seconds). } timer2--; // Same logic as the first timer. if (timer2 <= 0) { if (player.statLife > 0) { if (npc.direction == 1) { proj2 = Projectile.NewProjectile(new Vector2(npc.Center.X + 11f, npc.Center.Y + 9f), npc.DirectionTo(Main.player[npc.target].Center) * 10f, mod.ProjectileType("FrostBoneShot"), 20, 2, Main.myPlayer, 0, 1); } else if (npc.direction == -1) { proj2 = Projectile.NewProjectile(new Vector2(npc.Center.X - 21f, npc.Center.Y + 9f), npc.DirectionTo(Main.player[npc.target].Center) * 10f, mod.ProjectileType("FrostBoneShot"), 20, 2, Main.myPlayer, 0, 1); } } timer2 = 120; } #endregion Shooting #region Logic Control if (shoot == true) //If the shoot bool is true, then redcue the shoot timer otherwise do nothing. { shootTimer--; } if (shootTimer <= 0) //If it becomes 0 or less, reset the shoot bool to false. { shoot = false; shootTimer = 60; //Resets the timer to 60 ticks (1 second) } if (shoot == true) //If the shoot bool is true, its X speed is reduced by 75% of its initial. That is to generate the effects of it stopping a little before shooting. { npc.velocity.X *= 0.9f; } #endregion Logic Control }
public override void ResetEffects() { //ResetEffects() is called not long after player.doubleTapCardinalTimer's values have been set //Check if the ExampleDashAccessory is equipped and also check against this priority: // If the Shield of Cthulhu, Master Ninja Gear, Tabi and/or Solar Armour set is equipped, prevent this accessory from doing its dash effect //The priority is used to prevent undesirable effects. //Without it, the player is able to use the ExampleDashAccessory's dash as well as the vanilla ones bool dashAccessoryEquipped = false; //This is the loop used in vanilla to update/check the not-vanity accessories for (int i = 3; i < 8 + player.extraAccessorySlots; i++) { Item item = player.armor[i]; //Set the flag for the ExampleDashAccessory being equipped if we have it equipped OR immediately return if any of the accessories are // one of the higher-priority ones if (item.type == ModContent.ItemType <PhosphorNinjaCharm>()) { dashAccessoryEquipped = true; } else if (item.type == ItemID.EoCShield || item.type == ItemID.MasterNinjaGear || item.type == ItemID.Tabi) { return; } } //If we don't have the ExampleDashAccessory equipped or the player has the Solor armor set equipped, return immediately //Also return if the player is currently on a mount, since dashes on a mount look weird, or if the dash was already activated if (!dashAccessoryEquipped || player.setSolar || player.mount.Active || DashActive) { return; } //When a directional key is pressed and released, vanilla starts a 15 tick (1/4 second) timer during which a second press activates a dash //If the timers are set to 15, then this is the first press just processed by the vanilla logic. Otherwise, it's a double-tap if (player.controlDown && player.releaseDown && player.doubleTapCardinalTimer[DashDown] < 15) { DashDir = DashDown; } else if (player.controlUp && player.releaseUp && player.doubleTapCardinalTimer[DashUp] < 15) { DashDir = DashUp; } else if (player.controlRight && player.releaseRight && player.doubleTapCardinalTimer[DashRight] < 15) { DashDir = DashRight; } else if (player.controlLeft && player.releaseLeft && player.doubleTapCardinalTimer[DashLeft] < 15) { DashDir = DashLeft; } else { return; //No dash was activated, return } DashActive = true; DashTimer2 = 13; for (int i = 0; i < 20; i++) { Dust dust; Vector2 position = player.position; dust = Dust.NewDustDirect(position, player.width, player.height, mod.DustType("LightParticle"), 0f, 0f, 0, new Color(255, 255, 255), 1.7236842f); dust.noGravity = true; } for (int i = 0; i < 8; i++) { player.GetModPlayer <DayrisePlayer>().oldPos[i] = player.Center; } Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Phosphor_Dash" + Main.rand.Next(1, 3).ToString()).WithPitchVariance(Main.rand.NextFloat(-0.1f, -0.2f)), player.Center); }
public override void AI() { Dust dust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 0, default, 0.7f);
///* Titan Shield */// public void TitanShieldDash() //Executes the dash (ramming) { int dashDirection = titanShieldDashing > 0 ? +1 : -1; //Negative is left player.vortexStealthActive = false; //Hits NPCs Rectangle playerRect = new Rectangle((int)(player.position.X + player.velocity.X * 0.5 - 4.0), (int)(player.position.Y + player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); //Expanded player hitbox foreach (NPC npc in Main.npc) { //Finds a suitable target that collides with the player if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[player.whoAmI] <= 0) { if (playerRect.Intersects(npc.getRect()) && (npc.noTileCollide || player.CanHit(npc))) { TitanShield titanShield = (TitanShield)player.inventory[player.selectedItem].modItem; //Gets the held item int damage = titanShield.GetDamage(player); float knockBack = titanShield.item.knockBack; bool crit = RandomInt(100) < (titanShield.item.crit + player.meleeCrit); //Damages the enemy player.ApplyDamageToNPC(npc, damage, knockBack, player.direction, crit); npc.immune[player.whoAmI] = 5; //Area of effect if (titanShieldLastExplosion == 0 || titanShieldLastExplosion - Math.Abs(titanShieldDashing) >= TitanShield.ExplosionDelay) //Cooldown before consecutive explosions { titanShieldLastExplosion = Math.Abs(titanShieldDashing); Main.PlaySound(SoundID.Item14, npc.Center); Projectile newProj = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, mod.ProjectileType <ProjTitanAOE>(), damage, knockBack / 2, player.whoAmI, /*ai[0]*/ crit ? 1 : 0); } //Prevents player from taking damage player.immune = true; player.immuneNoBlink = true; player.immuneTime = Math.Min(10, Math.Abs(titanShieldDashing)); //Immune time caps at the time left } } } //Dust for (int i = 0; i < 5; i++) { Color color = CoinFlip() ? new Color(255, 255, 255) : new Color(255, 255, 255, 0f); Dust newDust = Dust.NewDustDirect(player.position + new Vector2(RandomFloat(-5, +5), RandomFloat(-5, +5)), player.width, player.height, /*Type*/ 16, 0f, 0f, /*Alpha*/ 0, color, /*Scale*/ RandomFloat(1f, 2f)); newDust.velocity *= 0.2f; newDust.noGravity = true; newDust.fadeIn = 0.5f; } if (Math.Abs(titanShieldDashing) > TitanShield.DashTime - 8) //First 8 ticks { player.velocity.X = 16.0f * dashDirection; //Maintains top speed in the direction of the dash } else if (dashDirection == +1 && player.velocity.X <= 0 || dashDirection == -1 && player.velocity.X >= 0) //Player has changed direction { titanShieldDashing = 0; //Ends the dash return; } titanShieldDashing -= dashDirection; //Goes toward 0 titanShieldCoolDown = TitanShield.CoolDown; //Resets cooldown to the max until the dash is over }
public override void AI() { npc.ai[0]++; Player P = Main.player[npc.target]; if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(true); } if (npc.ai[0] == 220) { for (int d = 0; d < 20; d++) { Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(10, 10), 20, 20, 31, npc.velocity.X * 0.8f, npc.velocity.Y * 0.8f, 0, default(Color), 1.5f); Vector2 vel = npc.Center - dust.position; vel.Normalize(); dust.position -= vel * 30; dust.velocity = vel * 2 + npc.velocity; dust.noGravity = true; } } if (npc.ai[0] > 220 && npc.ai[0] % 3 == 0) { Dust.NewDustDirect(npc.Center - new Vector2(10, 10), 20, 20, 31, npc.velocity.X * 0.8f, npc.velocity.Y * 0.8f, 0, default(Color), 1f); } if (npc.ai[3] > 10) { if (Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.velocity *= 0.98f; } if (Main.expertMode) // Wind { npc.ai[1]++; if (npc.ai[1] > 1000) { if (npc.ai[1] % 2 == 0) { Dust.NewDustDirect(npc.position, npc.width, npc.height, 31, npc.velocity.X * 0.8f, npc.velocity.Y * 0.8f, 0, Color.White, 1.5f); } if (npc.velocity.Y * npc.directionY < 8) { npc.velocity.Y += 0.3f * npc.directionY; } if (Collision.CanHitLine(npc.Center, 1, 1, P.Center, 1, 1) && npc.ai[2] == 0 && Math.Abs(npc.Center.Y - P.Center.Y) < 40) { npc.ai[2]++; } } if (npc.ai[2] > 0) { npc.ai[2]++; npc.velocity *= 0.98f; Vector2 position = npc.Center; float speedX = ((7f + Main.rand.NextFloat() * 7f) * npc.direction) + (npc.direction * npc.velocity.X > 0 ? npc.velocity.X : 0); position.X -= 1000 * npc.direction; position.Y += Main.rand.Next(-8, 8) * 10; if (npc.ai[2] % 2 == 0) { Dust.NewDustPerfect(position, 31, new Vector2(speedX * 3, 0), 0, Color.White, 2f); } if (npc.ai[2] % 16 == 0) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 7, 1.8f, -0.8f); if (Main.netMode != 1) { Projectile.NewProjectile(position.X, position.Y, speedX, 0, mod.ProjectileType("HostileWind"), 25, 10f); } } if (npc.ai[2] > 200) { npc.ai[0] = 0; npc.ai[1] = 0; npc.ai[2] = 0; } } } if (npc.ai[0] >= 240 && Collision.CanHitLine(npc.Center - new Vector2(20, 20), 40, 40, P.Center, 1, 1) && npc.ai[2] == 0) { float Speed = 8f; int damage = 25; int type = mod.ProjectileType("Gust"); Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 1); Vector2 dir = npc.DirectionTo(P.Center); if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center, dir * Speed, type, damage, 10f); } for (int d = 0; d < 10; d++) { Dust.NewDust(npc.Center - new Vector2(10, 10), 20, 20, 31, dir.X * Speed, dir.Y * Speed, 0, default(Color), 2f); } npc.ai[0] = 0; npc.velocity = dir * -10; } npc.direction = npc.Center.X < P.Center.X ? 1 : -1; npc.directionY = npc.Center.Y < P.Center.Y ? 1 : -1; float speed = 10; Vector2 vel = new Vector2(speed * npc.direction, speed * npc.directionY); if (vel.Length() > speed) { vel *= speed / vel.Length(); } if (npc.Distance(P.Center) < 300 && Collision.CanHitLine(npc.Center, 1, 1, P.Center, 1, 1)) { vel *= -1; } float home = 50f; if (vel != Vector2.Zero) { npc.velocity = ((home - 1f) * npc.velocity + vel) / home; } } else { Dust.NewDust(npc.position, npc.width, npc.height, 31, 0, 0, 0, Color.White, 1.5f); } if (npc.ai[3] < (Main.expertMode ? 90 : 120)) { npc.ai[3]++; } else { if (npc.ai[0] % 2 == 0) { Dust.NewDustPerfect(new Vector2(npc.Center.X, npc.Center.Y + (npc.height / 2)), 31, Vector2.Zero, 0, Color.White, 1).noGravity = true; } for (int i = 0; i < Main.projectile.Length; i++) { Projectile proj = Main.projectile[i]; float collisionPoint = 0; if (proj.active && proj.friendly && proj.damage > 0 && proj.CanHit(npc) && Collision.CheckAABBvLineCollision(npc.position, npc.Size, proj.Center, proj.Center + proj.velocity * 10 * (proj.extraUpdates + 1), proj.width, ref collisionPoint)) { Vector2 vel = proj.velocity; vel.Normalize(); npc.velocity = vel.RotatedBy(90 * 0.0174f) * 12; npc.ai[3] = 0; Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 7); break; } } } }
public void SpawnReturnPortalDust() { if (this._gateType == PotionOfReturnGateHelper.GateType.EntryPoint) { if (Main.rand.Next(3) != 0) { return; } if (Main.rand.Next(2) == 0) { Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * new Vector2(0.5f, 1f); Dust dust = Dust.NewDustDirect(this._position - vector2 * 30f, 0, 0, Utils.SelectRandom <int>(Main.rand, 86, 88), 0.0f, 0.0f, 0, new Color(), 1f); dust.noGravity = true; dust.noLightEmittence = true; dust.position = this._position - vector2.SafeNormalize(Vector2.Zero) * (float)Main.rand.Next(10, 21); dust.velocity = vector2.RotatedBy(1.57079637050629, new Vector2()) * 2f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = (object)this; dust.position += dust.velocity * 10f; dust.velocity *= -1f; } else { Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * new Vector2(0.5f, 1f); Dust dust = Dust.NewDustDirect(this._position - vector2 * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f); dust.noGravity = true; dust.noLight = true; dust.position = this._position - vector2.SafeNormalize(Vector2.Zero) * (float)Main.rand.Next(5, 10); dust.velocity = vector2.RotatedBy(-1.57079637050629, new Vector2()) * 3f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = (object)this; dust.position += dust.velocity * 10f; dust.velocity *= -1f; } } else { if (Main.rand.Next(3) != 0) { return; } if (Main.rand.Next(2) == 0) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * new Vector2(0.5f, 1f); Dust dust = Dust.NewDustDirect(this._position - spinningpoint * 30f, 0, 0, Utils.SelectRandom <int>(Main.rand, 86, 88), 0.0f, 0.0f, 0, new Color(), 1f); dust.noGravity = true; dust.noLightEmittence = true; dust.position = this._position; dust.velocity = spinningpoint.RotatedBy(-0.785398185253143, new Vector2()) * 2f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = (object)this; dust.position += spinningpoint * new Vector2(20f); } else { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * new Vector2(0.5f, 1f); Dust dust = Dust.NewDustDirect(this._position - spinningpoint * 30f, 0, 0, Utils.SelectRandom <int>(Main.rand, 86, 88), 0.0f, 0.0f, 0, new Color(), 1f); dust.noGravity = true; dust.noLightEmittence = true; dust.position = this._position; dust.velocity = spinningpoint.RotatedBy(-0.785398185253143, new Vector2()) * 2f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = (object)this; dust.position += spinningpoint * new Vector2(20f); } } }
private void Dusting() { if (Main.rand.NextFloat(2f) < 1f) { Dust.NewDustDirect(projectile.Center, projectile.width, projectile.height, DustID.GreenTorch, 0, 0, 0, default, 1);
public override void AI() { var dust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 172, projectile.velocity.X * 0.4f, projectile.velocity.Y * 0.4f, 100, default, 1.5f);
public override void Hurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit) { if (CosmicPowers) { int amountOfProjectiles = Main.rand.Next(2, 6); /*for (int i = 0; i < amountOfProjectiles; ++i) * { * float sX = (float)Main.rand.Next(-40, 40) * 0.1f; * float pX = (float)Main.rand.Next(-120, 120) * 2; * int projectile = Projectile.NewProjectile(player.Center.X + pX, player.Center.Y - 500, sX, 5, mod.ProjectileType("CosmirockMeteor"), 45, 0f, player.whoAmI, 0f, 0f); * Main.projectile[projectile].timeLeft = 1000; * }*/ for (int index1 = 0; index1 < amountOfProjectiles; ++index1) { Vector2 position = player.Center + new Vector2(Main.rand.Next(-500, 501), -Main.rand.Next(500, 801)); Vector2 target = player.Center + new Vector2(Main.rand.Next(-150, 151), 0); Vector2 speed = target - position; speed.Normalize(); speed *= 8f; int projectile = Projectile.NewProjectile(position.X, position.Y, speed.X, speed.Y, mod.ProjectileType("CosmirockMeteor"), 60, 10f, player.whoAmI, player.Center.Y); Main.projectile[projectile].timeLeft = 1000; } } if (duneBonus) { player.AddBuff(mod.BuffType("DuneWinds"), 10 * 60); for (int i = 0; i < 8; i++) { Vector2 velocity = new Vector2(10, 0).RotatedBy((Main.rand.Next(45) + i * 45).ToRadians()); Dust newDust = Dust.NewDustDirect(player.Center, 0, 0, 32, velocity.X, velocity.Y); newDust.noGravity = true; newDust.scale = 2; } } if (jungard && Main.rand.Next(3) == 0) { Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, mod.ProjectileType("JungleGuard"), (int)(15 * (player.minionDamage * player.minionDamage * player.minionDamage)), 5f, player.whoAmI); } if (frostguard && Main.rand.Next(3) == 0) { Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, mod.ProjectileType("IceSlimeMinion"), (int)(12 * (player.minionDamage * player.minionDamage * player.minionDamage)), 5f, player.whoAmI); } if (BeeHive) { player.AddBuff(48, 60 * Main.rand.Next(3, 11)); int num = 3; if (Main.rand.Next(3) == 0) { ++num; } if (Main.rand.Next(3) == 0) { ++num; } if (Main.rand.Next(3) == 0) { ++num; } for (int index = 0; index < num; ++index) { Projectile.NewProjectile((float)player.position.X, (float)player.position.Y, (float)Main.rand.Next(-35, 36) * 0.02f, (float)Main.rand.Next(-35, 36) * 0.02f, this.beeType2(), player.beeDamage(80), player.beeKB(0.0f), Main.myPlayer, 0.0f, 0.0f); } } if (pearl && Main.rand.Next(2) == 0 && damageTaken >= 10) { //Vector2 ok = player.Center; //ok.X += Main.rand.Next(-60, 61); //ok.Y += Main.rand.Next(-60, 61); //Item.NewItem((int)ok.X, (int)ok.Y, player.width, player.height, mod.ItemType("BlueHeart")); player.statLife += 10; player.HealEffect(10); } if (pearl && player.statLife <= player.statLifeMax2 / 2) { player.statLife += damageTaken / 10; player.HealEffect(damageTaken / 10); } if (pearl2 && Main.rand.Next(2) == 0 && damageTaken >= 15) { player.statLife += 15; player.HealEffect(15); } if (pearl2 && player.statLife <= player.statLifeMax2 / 2) { player.statLife += damageTaken / 7; player.HealEffect(damageTaken / 7); } }
public override void Update(NPC npc, ref int buffIndex) { npc.GetGlobalNPC <ExpandedGlobalNPC>().michiGun = true; var dust = Dust.NewDustDirect(npc.position, 5, 5, 5, npc.velocity.X * Main.rand.Next(-5, 5), npc.velocity.Y * Main.rand.Next(-5, 5), 100, default, 1f);
public override void AI() { Lighting.AddLight(npc.position, 0.0149f, 0.0142f, 0.0207f); npc.TargetClosest(true); Player player = Main.player[npc.target]; npc.ai[2]++; if (npc.ai[0] == 0) { Location = npc.Center - Main.npc[(int)npc.ai[1]].Center; Location2 = npc.Center - Main.npc[(int)npc.ai[1]].Center; npc.ai[0]++; } else { Location2 = Location.RotatedBy((MathHelper.Pi / 180)); Location = Location2; npc.Center = Location + Main.npc[(int)npc.ai[1]].Center; } if (Main.npc[(int)npc.ai[1]].life <= 0) { npc.life = 0; } npc.rotation = npc.velocity.ToRotation(); Vector2 vector2_1 = (new Vector2(0.0f, (float)Math.Cos((double)npc.frameCounter * 6.28318548202515 / 40.0 - 1.57079637050629)) * 32f).RotatedBy((double)npc.rotation, Vector2.Zero); Vector2 vector2_2 = npc.velocity.SafeNormalize(Vector2.Zero); for (int index = 0; index < 1; ++index) { Dust dust1 = Dust.NewDustDirect(npc.Center - npc.Size / 4f, npc.width / 2, npc.height / 2, 70, 0.0f, 0.0f, 0, new Color(), 0.2f); int num1 = 1; dust1.noGravity = num1 != 0; Vector2 vector2_3 = npc.Center + vector2_1; dust1.position = vector2_3; Vector2 vector2_4 = dust1.velocity * 0.0f; dust1.velocity = vector2_4; double num2 = 0.79999997615814; dust1.fadeIn = (float)num2; double num3 = 1.14999997615814; dust1.scale = (float)0.1f; int num4 = 1; Vector2 vector2_5 = dust1.position + npc.velocity * 1.2f; dust1.position = vector2_5; Vector2 vector2_6 = dust1.velocity + vector2_2 * 2f; dust1.velocity = vector2_6; Dust dust2 = Dust.NewDustDirect((npc.Center - npc.Size / 4f), npc.width / 2, npc.height / 2, 70, 0.0f, 0.0f, 0, new Color(), 0.1f); int num5 = 1; dust2.noGravity = num5 != 0; Vector2 vector2_7 = npc.Center + vector2_1; dust2.position = vector2_7; Vector2 vector2_8 = dust2.velocity * 0.0f; dust2.velocity = vector2_8; double num6 = 0.89999997615814; dust2.fadeIn = (float)num6; double num7 = 1.14999997615814; dust2.scale = (float)0.05f; int num8 = 1; Vector2 vector2_9 = dust2.position + npc.velocity * 0.5f; dust2.position = vector2_9; Vector2 vector2_10 = dust2.position + npc.velocity * 1.2f; dust2.position = vector2_10; Vector2 vector2_11 = dust2.velocity + vector2_2 * 2f; dust2.velocity = vector2_11; } int num9 = (int)(npc.frameCounter + 1); npc.frameCounter = num9; if (num9 >= 40) { npc.frameCounter = 0; } //npc.frame = npc.frameCounter / 5; }
public override void AI() { Player player = Main.player[projectile.owner]; if (Main.myPlayer == projectile.owner) { if (!Released) { projectile.scale += 0.04f; projectile.position = player.position + new Vector2(0, -20 - (projectile.scale * 17)); for (int d = 0; d < 25; d++) { float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.position + (position * (20 + 12.5f * projectile.scale)), projectile.width, projectile.height, 15, 0f, 0f, 213, default(Color), 2.0f); tDust.velocity = Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2; tDust.noGravity = true; } if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } if (MyPlayer.ModPlayer(player).KiCurrent <= 0) { projectile.Kill(); } MyPlayer.ModPlayer(player).KiCurrent -= 2; player.velocity = new Vector2(player.velocity.X / 3, player.velocity.Y); //Rock effect projectile.ai[1]++; if (projectile.ai[1] % 7 == 0) { Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("StoneBlockDestruction"), projectile.damage, 0f, projectile.owner); } Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("DirtBlockDestruction"), projectile.damage, 0f, projectile.owner); } projectile.netUpdate = true; } //if button let go if (!player.channel) { //projectile.Kill(); if (!Released) { Released = true; projectile.velocity = Vector2.Normalize(Main.MouseWorld - projectile.position) * 6; projectile.tileCollide = false; projectile.damage *= (int)projectile.scale; } //Projectile p = Projectile.NewProjectileDirect(new Vector2(projectile.Center.X, projectile.Center.Y) - (projectile.velocity * 5), new Vector2(0, 0), mod.ProjectileType("EnergyWaveTrail"), projectile.damage / 3, 4f, projectile.owner, 0, projectile.rotation); //p.scale = projectile.scale * 1.5f; } }
public override void PostAI() { npc.netUpdate = true; npc.TargetClosest(true); Player player = Main.player[npc.target]; if (!npc.HasValidTarget) { npc.velocity *= 0f; npc.alpha += 1; despawnTimer++; npc.spriteDirection = npc.direction; Main.PlaySound(SoundID.Item24, (int)npc.position.X, (int)npc.position.Y); Dust.NewDustDirect(npc.position, npc.width, npc.height / 2, 58, 0f, -5f, 100, default(Color), 1.5f); if (despawnTimer == 255) { npc.active = false; Main.PlaySound(SoundID.Item6, (int)npc.position.X, (int)npc.position.Y); Dust.NewDustDirect(npc.position, npc.width, npc.height, 58, 0f, 0f, 0, default(Color), 1.5f); } } npc.rotation = npc.velocity.X * 0.03F; npc.spriteDirection = npc.direction; if (npc.life >= npc.lifeMax) { npc.life = npc.lifeMax; } timer++; if (state == LancerionState.Following) { npc.width = 50; if (timer == 200) { state = LancerionState.Dashing; } if (timer >= 600) { if (Main.netMode != 1) { // First time entering this AI. Determines the attack type that is used. if (timer == 600) { if (Main.rand.Next(2) == 1) { attack1 = true; } else { attack2 = true; } } npc.velocity.X = 0; npc.velocity.Y = 0; if (attack1 == true) { Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height / 2, 12, 0f, -5f, 100, default(Color), 1.5f)]; dust.position = npc.Center + Vector2.UnitY.RotatedByRandom(4.1887903213500977) * new Vector2(npc.width * 1.5f, npc.height * 1.1f) * 0.8f * (0.8f + Main.rand.NextFloat() * 0.2f); if (timer < 700) { if ((timer - 600) % 20 == 0) { Main.PlaySound(SoundID.Item82, npc.Center); } } // No longer need for an extra timer. Just use the one we already have. else if ((timer - 700) % 20 == 0) { throwingUp = true; float perturbedSpeedX = player.Center.X - npc.Center.X; float perturbedSpeedY = player.Center.Y - npc.Center.Y; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, perturbedSpeedX, perturbedSpeedY, mod.ProjectileType("LancerionSpear"), (int)(npc.damage * 0.50f), 2, Main.myPlayer); npc.netUpdate = true; Main.PlaySound(SoundID.Item19, npc.Center); } } else if (attack2 == true) { Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height / 2, 58, 0f, -5f, 100, default(Color), 1.5f)]; dust.position = npc.Center + Vector2.UnitY.RotatedByRandom(4.1887903213500977) * new Vector2(npc.width * 1.5f, npc.height * 1.1f) * 0.8f * (0.8f + Main.rand.NextFloat() * 0.2f); // No longer need for an extra timer. Just use the one we already have. if ((timer - 600) % 30 == 0) { float floatingY = 1; float acceleration = 1.3f; float SpeedY = floatingY * acceleration; Projectile.NewProjectile(player.Center.X, player.Center.Y - 125, 0, SpeedY, mod.ProjectileType("LancerionSpear"), (int)(npc.damage * 0.50f), 2, Main.myPlayer); npc.netUpdate = true; Main.PlaySound(SoundID.Item19, npc.Center); } } // If the timer reaches a certain point, start one of the other two AI states. if (timer >= 900) { if (Main.rand.Next(2) == 1) { state = LancerionState.Teleporting; } else { state = LancerionState.Stomping; } timer = 0; attack1 = attack2 = false; } } } } else if (state == LancerionState.Dashing) { if (timer < 250) { npc.velocity *= 0; } else if (timer == 250) { Main.PlaySound(SoundID.Item19, npc.Center); if (npc.direction == 1) { npc.velocity.X = 15; } if (npc.direction == -1) { npc.velocity.X = -15; } if (player.Center.Y - npc.Center.Y <= 0) { npc.velocity.Y = 1; } if (player.Center.Y - npc.Center.Y >= 0) { npc.velocity.Y = -1; } } else if (timer == 400) { state = LancerionState.Following; } } else if (state == LancerionState.Teleporting) //make this work { npc.velocity *= 0; if (++dustPortal >= 0) { Vector2 usePos = npc.position; Vector2 rotVector = (npc.rotation - MathHelper.ToRadians(90f)).ToRotationVector2(); usePos += rotVector * 16f; Dust.NewDustDirect(npc.position, npc.width, npc.height / 2, 58, 0f, -5f, 100, default(Color), 1.5f); } if (++regenTimer >= 5 && npc.life != 2000) { npc.life += 1; regenTimer = 0; } // We've already gained a new teleportation position, so we can begin processing it. if (teleporting) { if (teleportationPosition != Vector2.Zero && timer++ >= 100) { Vector2 usePos = npc.position; Vector2 rotVector = (npc.rotation - MathHelper.ToRadians(90f)).ToRotationVector2(); usePos += rotVector * 16f; npc.position = teleportationPosition; // Teleport to dust. Main.PlaySound(SoundID.Item6, (int)npc.position.X, (int)npc.position.Y); for (int i = 0; i < 50; ++i) { Dust.NewDustDirect(teleportationPosition, npc.width, npc.height, 58, 0f, 0f, 0, default(Color), 1.5f); } npc.netUpdate = true; // Reset NPC values and teleportation variables. timer = -50; teleporting = false; state = LancerionState.Following; if (timer == 0) { teleportationPosition = Vector2.Zero; } } else if (teleportationPosition == Vector2.Zero) // Teleportation did not succeed; reset everything to default. { timer = 0; teleporting = false; state = LancerionState.Following; } } else // We do not yet have a teleportation position for this teleport sequence. { bool tryTeleport = true; int teleportTries = 0; // We give the teleportation 50 tries to get a new, valid position. If this does not get a valid teleportation position before the tries are up, it won't teleport at all. while (tryTeleport && teleportTries <= 50) { // This position was done in pixel coordinates, not tile coordinate :s int randX = (int)(player.position.X / 16) + Main.rand.Next(16) - 8; int randY = (int)(player.position.Y / 16) + Main.rand.Next(16) - 8; int minTilePosX = randX; int maxTilePosX = randX + ((npc.width * 2) / 16); int minTilePosY = randY; int maxTilePosY = randY + ((npc.height * 2) / 16); for (int x = minTilePosX; x < maxTilePosX; x++) { for (int y = minTilePosY; y < maxTilePosY; y++) { if (WorldGen.InWorld(x, y)) { if (!Collision.SolidTiles(randX, randX + 2, randY, randY + 2)) { Vector2 vector2; vector2.X = (x * 16); vector2.Y = (y * 16); teleportationPosition = new Vector2(randX * 16, randY * 16); tryTeleport = false; } } } } teleportTries++; } teleporting = true; } } else if (state == LancerionState.Stomping) { int stompTry = 0; stompTry++; npc.velocity.X = 0; if (npc.velocity.Y == 0) { npc.ai[0] = 3; } if (npc.ai[0] > 0) { npc.velocity.Y -= 5f; npc.ai[0]--; } if (npc.collideY && npc.velocity.Y >= 0) { for (int k = 0; k < 8; k++) { if (Main.player[k].active) { MyPlayer modPlayer = Main.player[k].GetModPlayer <MyPlayer>(mod); modPlayer.cameraShakeDur = 20; modPlayer.cameraShakeMagnitude = 5f; } } if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 3f, -5f, mod.ProjectileType("LancerionStomp"), (int)(npc.damage * 0.50f), 2f, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -3f, -5f, mod.ProjectileType("LancerionStomp"), (int)(npc.damage * 0.50f), 2f, Main.myPlayer); } Main.PlaySound(SoundID.Item66, npc.Center); timer = 0; state = LancerionState.Following; } else if (stompTry >= 1000) { stompTry = 0; npc.width = 50; timer = 0; state = LancerionState.Following; } } else { timer = 0; state = LancerionState.Following; } }
public override void AI() { if (Main.myPlayer == projectile.owner) { if (targetNPC == null && targetPlayer == null) { if (Vector2.Distance(projectile.position, Main.MouseWorld) > 0.1) { projectile.velocity = Vector2.Normalize(Main.MouseWorld - projectile.position) * 6; } else { projectile.velocity = Vector2.Zero; } } projectile.netUpdate = true; } if (targetNPC != null) { if (targetNPC.life <= 0) { Kill(0); } else { //targetNPC.position = Main.MouseWorld; targetNPC.velocity.Y = -2.5f; targetNPC.velocity.X = 0; projectile.position = targetNPC.position; } } if (targetPlayer != null) { if (targetPlayer.statLife <= 0) { Kill(0); } else { //targetNPC.position = Main.MouseWorld; targetPlayer.velocity.Y = -2.5f; targetPlayer.velocity.X = 0; targetPlayer.lifeRegen -= 4; projectile.position = targetPlayer.position; } } //for(int i = 0; i < 10; i++) if (projectile.timeLeft % 2 == 0) { Dust tDust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 35, 0f, 0f, 213, Color.Red, 1.0f); tDust.velocity = Vector2.Zero; tDust.noGravity = true; } }
// It appears that for this AI, only the ai0 field is used! public override void AI() { // Since we access the owner player instance so much, it's useful to create a helper local variable for this // Sadly, Projectile/ModProjectile does not have its own Player projOwner = Main.player[projectile.owner]; // Here we set some of the projectile's owner properties, such as held item and itemtime, along with projectile direction and position based on the player Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter, true); projectile.direction = projOwner.direction; projOwner.heldProj = projectile.whoAmI; projOwner.itemTime = projOwner.itemAnimation; projectile.position.X = ownerMountedCenter.X - (float)(projectile.width / 2); projectile.position.Y = ownerMountedCenter.Y - (float)(projectile.height / 2); // As long as the player isn't frozen, the spear can move if (!projOwner.frozen) { if (movementFactor == 0f) // When initially thrown out, the ai0 will be 0f { movementFactor = 3f; // Make sure the spear moves forward when initially thrown out projectile.netUpdate = true; // Make sure to netUpdate this spear } if (projOwner.itemAnimation < projOwner.itemAnimationMax / 3) // Somewhere along the item animation, make sure the spear moves back { movementFactor -= 2.4f; } else // Otherwise, increase the movement factor { movementFactor += 2.1f; } } // Change the spear position based off of the velocity and the movementFactor projectile.position += projectile.velocity * movementFactor; // When we reach the end of the animation, we can kill the spear projectile if (projOwner.itemAnimation == 0) { projectile.Kill(); } // Apply proper rotation, with an offset of 135 degrees due to the sprite's rotation, notice the usage of MathHelper, use this class! // MathHelper.ToRadians(xx degrees here) projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); // Offset by 90 degrees here if (projectile.spriteDirection == -1) { projectile.rotation -= MathHelper.ToRadians(90f); } // These dusts are added later, for the 'ExampleMod' effect if (Main.rand.Next(3) == 0) { Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, 55, 0f, 0f, 161, new Color(255, 255, 255), 1f); dust.velocity += projectile.velocity * 0.3f; dust.velocity *= 0.2f; } if (Main.rand.Next(4) == 0) { Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, 55, 0f, 0f, 161, new Color(255, 255, 255), 1f); dust.velocity += projectile.velocity * 0.5f; dust.velocity *= 0.5f; } if (Main.rand.Next(20) == 0) { Projectile.NewProjectile(projectile.Center, projectile.velocity * 2, mod.ProjectileType("JimBallFriendly"), projectile.damage, 0, Main.myPlayer); } }