public LungLevel() { background_ = new FAnimatedSprite("Lungs_Background"); int[] breathing_frames = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; FAnimation breathing_animation = new FAnimation("breathing", "Lungs_Background", breathing_frames, 250, true); background_.addAnimation(breathing_animation); background_.play("breathing"); AddChild(background_); dust_container_size_ = new Rect(-Futile.screen.halfWidth*2.5f, -Futile.screen.halfHeight*2.5f, Futile.screen.width*2.5f, Futile.screen.height*2.5f); dust1_ = new Dust("Dust_4", dust_container_size_); AddChild(dust1_); tubes1_ = new FSprite("Lungs_Rear"); AddChild(tubes1_); tubes2_ = new FSprite("Lungs_MidBack1"); AddChild(tubes2_); dust2_ = new Dust("Dust_3", dust_container_size_); AddChild(dust2_); tubes3_ = new FSprite("Lungs_MiddleFore"); AddChild(tubes3_); tubes4_ = new FSprite("Lungs_Fore"); AddChild(tubes4_); dust3_ = new Dust("Dust_2", dust_container_size_); AddChild(dust3_); }
//in Terraria.Dust.UpdateDust after incrementing Dust.dCount call this internal static void SetupUpdateType(Dust dust) { ModDust modDust = GetDust(dust.type); if (modDust != null && modDust.updateType >= 0) { dust.realType = dust.type; dust.type = modDust.updateType; } }
//in Terraria.Dust.NewDust after initializing dust properties call ModDust.SetupDust(dust); internal static void SetupDust(Dust dust) { ModDust modDust = GetDust(dust.type); if (modDust != null) { dust.frame.X = 0; dust.frame.Y %= 30; modDust.OnSpawn(dust); } }
public override void AI() { Player P = Main.player[npc.target]; Lighting.AddLight(npc.Center, 1f, 1f, 1f); // despawn if no players if (!Main.player[npc.target].active || Main.player[npc.target].dead) { npc.TargetClosest(true); if (!Main.player[npc.target].active || Main.player[npc.target].dead) { npc.localAI[0]++; npc.velocity.Y = npc.velocity.Y + 0.11f; if (npc.localAI[0] >= 300) { npc.active = false; } } else { npc.localAI[0] = 0; } } if (npc.ai[0] < 180) { if (npc.ai[0] == 0) { originX = P.Center.X; originY = P.Center.Y; } if (npc.ai[0] < 60) { MoonlordDeathDrama.RequestLight(1f, npc.Center); npc.alpha = 255; if (npc.ai[0] == 59) { Main.PlaySound(SoundLoader.customSoundType, (int)npc.position.X, (int)npc.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/NPC/AncientMergeFall")); for (int i = 0; i < Main.projectile.Length; i++) { if (Main.projectile[i].type == mod.ProjectileType("IzarisShard") || Main.projectile[i].type == mod.ProjectileType("KirveinShard") || Main.projectile[i].type == mod.ProjectileType("KrecheusShard") || Main.projectile[i].type == mod.ProjectileType("XernonShard") || Main.projectile[i].type == mod.ProjectileType("ShardBase")) { Main.projectile[i].Kill(); } } } } else { if (!spawnedHands && Main.netMode != 1) { npc.TargetClosest(true); spawnedHands = true; int num = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, mod.NPCType("AncientAmalgamFist"), npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num].ai[0] = -1f; Main.npc[num].ai[1] = (float)npc.whoAmI; Main.npc[num].target = npc.target; Main.npc[num].netUpdate = true; num = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, mod.NPCType("AncientAmalgamFist"), npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num].ai[0] = 1f; Main.npc[num].ai[1] = (float)npc.whoAmI; Main.npc[num].ai[3] = 150f; // ai timer offset so they arent exactly the same Main.npc[num].target = npc.target; Main.npc[num].netUpdate = true; } npc.alpha = 0; Vector2 target = new Vector2(originX, originY - 250); Vector2 toTarget = new Vector2(target.X - npc.Center.X, target.Y - npc.Center.Y); toTarget.Normalize(); if (Vector2.Distance(target, npc.Center) > 5) { npc.velocity = toTarget * 6; } else { npc.velocity *= 0f; } } npc.ai[0]++; } else { if (npc.ai[1] == 0) { int attackNum = -1; while (attackNum == previousAttackNum || attackNum == -1) { if (npc.life > npc.lifeMax * 0.85f) { attackNum = Main.rand.Next(0, 6); } else if (npc.life < npc.lifeMax * 0.8f && npc.life > npc.lifeMax * 0.5f) { attackNum = Main.rand.Next(1, 6); } else if (npc.life < npc.lifeMax * 0.5f && npc.life > npc.lifeMax * 0.25f) { attackNum = Main.rand.Next(2, 9); } else if (npc.life < npc.lifeMax * 0.25f) { attackNum = Main.rand.Next(3, 11); while (attackNum == 4 || attackNum == 9) { attackNum = Main.rand.Next(3, 11); } if (attackNum == 7) { attackNum = 11; } } } if (npc.localAI[1] == 0) { npc.localAI[1]++; attackNum = 0; } npc.ai[2] = attackNum; previousAttackNum = attackNum; invertAttack = Main.rand.Next(2) == 0 ? -1 : 1; playerOrigin = P.Center; } if (npc.alpha > 0 && npc.ai[2] != 3 && npc.ai[2] != 5 && npc.ai[2] != 8) { npc.alpha -= 5; } npc.ai[1]++; // move and swing hands if (npc.ai[2] == 0) { float speed = 0.25f; float playerX = P.Center.X - npc.Center.X; float playerY = P.Center.Y - 250f - npc.Center.Y; Move(P, speed, playerX, playerY); if (npc.ai[1] > 450) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // create a circle of kunais else if (npc.ai[2] == 1) { npc.velocity = Vector2.Zero; shootTimer[0]--; shootTimer[1]--; if (shootTimer[1] <= 0) { shootTimer[1] = 80; numRadialProj = Main.rand.Next(20, 30); } if (shootTimer[0] <= 0 && shootTimer[1] <= 42) { int projDamage = Main.expertMode ? (int)(projectileBaseDamage * 0.75f) : projectileBaseDamage; float rotation = MathHelper.ToRadians(360); for (int i = 0; i < numRadialProj; i++) { Vector2 perturbedSpeed = new Vector2(2, 2).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numRadialProj - 1))) * 2.5f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, mod.ProjectileType("CrystallineKunaiHostileNG"), projDamage, 2f, 0); } shootTimer[0] = 14; } if (npc.ai[1] > 400) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // spin and block else if (npc.ai[2] == 2) { npc.velocity = Vector2.Zero; // hands spin around npc.ai[3]++; if (npc.ai[3] >= 60) { for (int i = 0; i < Main.projectile.Length; i++) { Projectile oProj = Main.projectile[i]; if (Vector2.Distance(oProj.Center, npc.Center) <= 300 && !hasInverted[i] && oProj.active) { oProj.velocity.X *= -1; oProj.velocity.Y *= -1; oProj.friendly = false; oProj.hostile = true; hasInverted[i] = true; } if (!oProj.active) { hasInverted[oProj.whoAmI] = false; } } } if (npc.ai[1] > 300) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // projections from the side else if (npc.ai[2] == 3) { if (npc.alpha == 0) { Main.PlaySound(29, (int)npc.Center.X, (int)npc.Center.Y, 105, 1f, 0f); } if (npc.alpha < 255) { npc.alpha += 5; } else { npc.Center = P.Center - new Vector2(0, 1000); } shootTimer[0]--; if (shootTimer[0] <= 0) { float speed = 6f; for (int i = 1; i < 5; i++) // start at 1 so they dont overlap { Projectile.NewProjectile(playerOrigin.X - 1000 * invertAttack, playerOrigin.Y - i * 300, speed * invertAttack, 0f, mod.ProjectileType("AncientProjection"), projectileBaseDamage, 0f, 0, Main.rand.Next(4)); Projectile.NewProjectile(playerOrigin.X - 1000 * invertAttack, playerOrigin.Y + i * 300, speed * invertAttack, 0f, mod.ProjectileType("AncientProjection"), projectileBaseDamage, 0f, 0, Main.rand.Next(4)); } Projectile.NewProjectile(playerOrigin.X - 1000 * invertAttack, playerOrigin.Y, speed * invertAttack, 0f, mod.ProjectileType("AncientProjection"), projectileBaseDamage, 0f, 0, Main.rand.Next(4)); shootTimer[0] = 45; } if (npc.ai[1] > 300) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // clusters else if (npc.ai[2] == 4) { float speed = 0.25f; float playerX = P.Center.X - npc.Center.X; float playerY = P.Center.Y - 450f - npc.Center.Y; Move(P, speed, playerX, playerY); if (Main.rand.Next(5) == 0) { int distance = 500; Projectile.NewProjectile(P.Center.X + Main.rand.NextFloat(-distance, distance), P.Center.Y + Main.rand.NextFloat(-distance, distance), 0f, 0f, mod.ProjectileType("CrystalCluster"), projectileBaseDamage, 0f, 0); } if (Main.rand.Next(30) == 0) { Projectile.NewProjectile(P.Center.X, P.Center.Y, 0f, 0f, mod.ProjectileType("CrystalCluster"), projectileBaseDamage, 0f, 0); } if (npc.ai[1] > 450) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // teleport and dash else if (npc.ai[2] == 5) { if (npc.ai[3] == 0) { int dist = 500; double angle = Main.rand.NextDouble() * 2d * Math.PI; Vector2 offset = new Vector2((float)Math.Sin(angle) * dist, (float)Math.Cos(angle) * dist); Dust dust = Main.dust[Dust.NewDust(P.Center + offset, 0, 0, 6, 0, 0, 100)]; npc.Center = P.Center + offset; toPlayerDash = P.Center - npc.Center; for (int i = 0; i < Main.npc.Length; i++) { NPC fist = Main.npc[i]; if (fist.type == mod.NPCType("AncientAmalgamFist") && fist.ai[1] == npc.whoAmI && fist.active) { int fistPos = fist.ai[0] == 1 ? 90 : -120; fist.position.X = npc.Center.X + fistPos - fist.width / 2; fist.position.Y = npc.Center.Y + 140 - fist.height / 2; } } } npc.ai[3]++; if (npc.ai[3] >= 75) { if (npc.alpha < 255) { npc.alpha += 15; } if (npc.alpha >= 255) { npc.ai[3] = 0; } } else { if (npc.alpha > 0) { npc.alpha -= 15; } toPlayerDash.Normalize(); npc.velocity = toPlayerDash * 12f; } if (npc.ai[1] > 300) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // shoot down homing projectiles else if (npc.ai[2] == 6) { if (npc.ai[3] == 0) { Vector2 target = P.Center + new Vector2(400 * invertAttack, -300); Vector2 toTarget = new Vector2(target.X - npc.Center.X, target.Y - npc.Center.Y); toTarget.Normalize(); if (Vector2.Distance(target, npc.Center) > 20) { npc.velocity = toTarget * 16; } else { npc.ai[3]++; } } if (npc.ai[3] != 0) { npc.ai[3]++; shootTimer[0]--; npc.velocity.X = -8f * invertAttack; npc.velocity.Y = 0f; if (shootTimer[0] <= 0) { Projectile kunai = Main.projectile[Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 8f, mod.ProjectileType("CrystallineKunaiHostileExplosive"), projectileBaseDamage, 2f, 0, 1)]; kunai.timeLeft = 60; shootTimer[0] = 15; } } if (npc.ai[3] >= 90) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // kunai galaxy else if (npc.ai[2] == 7) { npc.velocity *= 0f; if (npc.ai[3] == 0) { Vector2 target = P.Center; Vector2 toTarget = new Vector2(target.X - npc.Center.X, target.Y - npc.Center.Y); toTarget.Normalize(); if (Vector2.Distance(target, npc.Center) > 300) { npc.velocity = toTarget * 13; } else { npc.ai[3]++; } } // create projections else if (npc.ai[3] == 1) { int innerCount = 15; for (int l = 0; l < innerCount; l++) { float distance = 360 / innerCount; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("AncientProjectionSwirl"), projectileBaseDamage, 5f, 0, l * distance, npc.whoAmI); } int outerCount = 20; for (int l = 0; l < outerCount; l++) { float distance = 360 / outerCount; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("AncientProjectionSwirl2"), projectileBaseDamage, 5f, 0, l * distance, npc.whoAmI); } npc.ai[3]++; } if (npc.ai[3] == 2) { shootTimer[0]--; Vector2 offset = new Vector2(400, 0); float rotateSpeed = MathHelper.ToRadians(0.88f); shootTimer[1] += rotateSpeed; if (shootTimer[0] <= 0) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 20); float numProj = 5f; float projOffset = MathHelper.ToRadians(360f) / numProj; for (int i = 0; i < numProj; i++) { Vector2 shootTarget1 = npc.Center + offset.RotatedBy(shootTimer[1] + (projOffset * i)); float rotation = (float)Math.Atan2(npc.Center.Y - shootTarget1.Y, npc.Center.X - shootTarget1.X); for (int k = 0; k < 2; k++) { float Speed = k == 0 ? 7 : 4; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), mod.ProjectileType("CrystallineKunaiHostileNG"), projectileBaseDamage, 0f, 0); } } shootTimer[0] = 12; } } if (npc.ai[1] > 450) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); for (int i = 0; i < Main.projectile.Length; i++) { Projectile other = Main.projectile[i]; if ((other.type == mod.ProjectileType("AncientProjectionSwirl") || other.type == mod.ProjectileType("AncientProjectionSwirl2")) && other.ai[1] == npc.whoAmI && other.active) { other.Kill(); } } } } // teleport and shoot else if (npc.ai[2] == 8) { npc.velocity *= 0f; npc.ai[3]++; int intervalTime = 45; int alphaChangeRate = 5; int xDist = 300; if (npc.life <= npc.lifeMax / 4) { intervalTime = 30; alphaChangeRate = 15; xDist = 350; } if (npc.life <= npc.lifeMax / 10) { intervalTime = 15; alphaChangeRate = 20; xDist = 450; } if (npc.ai[3] >= intervalTime) { if (npc.alpha < 255) { npc.alpha += alphaChangeRate; } else { npc.Center = new Vector2(P.Center.X - (Main.rand.Next(2) == 0 ? -xDist : xDist), P.Center.Y + Main.rand.Next(-400, 400)); for (int i = 0; i < Main.npc.Length; i++) { NPC fist = Main.npc[i]; if (fist.type == mod.NPCType("AncientAmalgamFist") && fist.ai[1] == npc.whoAmI && fist.active) { int fistPos = fist.ai[0] == 1 ? 90 : -120; fist.position.X = npc.Center.X + fistPos - fist.width / 2; fist.position.Y = npc.Center.Y + 140 - fist.height / 2; } } npc.ai[3] = 0; } } else { if (npc.alpha > 0) { npc.alpha -= alphaChangeRate; } } if (npc.ai[3] == (int)(intervalTime / 2)) { float projSpeed = 12f; float rotation = (float)Math.Atan2(npc.Center.Y - P.Center.Y, npc.Center.X - P.Center.X); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * projSpeed) * -1), (float)((Math.Sin(rotation) * projSpeed) * -1), mod.ProjectileType("CrystallineKunaiHostileNG"), projectileBaseDamage, 5f, 0); } if (npc.ai[1] > 600) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // exploding projectiles else if (npc.ai[2] == 9) { shootTimer[0]--; if (npc.life <= npc.lifeMax * 0.35f) { if (Main.rand.Next(50) == 0) { Projectile kunai = Main.projectile[Projectile.NewProjectile(P.Center.X + Main.rand.Next(-1000, 1000), P.Center.Y - 1500, Main.rand.NextFloat(-2, 2), 9f, mod.ProjectileType("CrystallineKunaiHostileExplosive"), projectileBaseDamage, 5f, 0)]; kunai.timeLeft = 180; } } if (shootTimer[0] <= 0) { float projSpeed = 12f; float rotation = (float)Math.Atan2(npc.Center.Y - P.Center.Y, npc.Center.X - P.Center.X); Projectile kunai = Main.projectile[Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * projSpeed) * -1), (float)((Math.Sin(rotation) * projSpeed) * -1), mod.ProjectileType("CrystallineKunaiHostileExplosive"), projectileBaseDamage, 5f, 0)]; kunai.timeLeft = 60; shootTimer[0] = 60; } float speed = 0.15f; float playerX = P.Center.X - npc.Center.X; float playerY = P.Center.Y - npc.Center.Y; Move(P, speed, playerX, playerY); if (npc.ai[1] > 600) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // clusters and exploding else if (npc.ai[2] == 10) { float speed = 0.15f; float playerX = P.Center.X - npc.Center.X; float playerY = P.Center.Y - npc.Center.Y; Move(P, speed, playerX, playerY); shootTimer[0]--; if (Main.rand.Next(75) == 0) { Projectile kunai = Main.projectile[Projectile.NewProjectile(P.Center.X + Main.rand.Next(-1000, 1000), P.Center.Y - 1500, Main.rand.NextFloat(-2, 2), 9f, mod.ProjectileType("CrystallineKunaiHostileExplosive"), projectileBaseDamage, 5f, 0)]; kunai.timeLeft = 180; } if (shootTimer[0] <= 0) { float projSpeed = 12f; float rotation = (float)Math.Atan2(npc.Center.Y - P.Center.Y, npc.Center.X - P.Center.X); Projectile kunai = Main.projectile[Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * projSpeed) * -1), (float)((Math.Sin(rotation) * projSpeed) * -1), mod.ProjectileType("CrystallineKunaiHostileExplosive"), projectileBaseDamage, 5f, 0)]; kunai.timeLeft = 75; shootTimer[0] = 60; } if (Main.rand.Next(10) == 0) { int distance = 500; Projectile.NewProjectile(P.Center.X + Main.rand.NextFloat(-distance, distance), P.Center.Y + Main.rand.NextFloat(-distance, distance), 0f, 0f, mod.ProjectileType("CrystalCluster"), projectileBaseDamage, 0f, 0); } if (Main.rand.Next(32) == 0) { Projectile.NewProjectile(P.Center.X, P.Center.Y, 0f, 0f, mod.ProjectileType("CrystalCluster"), projectileBaseDamage, 0f, 0); } if (npc.ai[1] > 450) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); } } // kunai flower else if (npc.ai[2] == 11) { npc.velocity *= 0f; if (npc.ai[3] == 0) { Vector2 target = P.Center; Vector2 toTarget = new Vector2(target.X - npc.Center.X, target.Y - npc.Center.Y); toTarget.Normalize(); if (Vector2.Distance(target, npc.Center) > 300) { npc.velocity = toTarget * 13; } else { npc.ai[3]++; } } else if (npc.ai[3] == 1) { int innerCount = 15; for (int l = 0; l < innerCount; l++) { float distance = 360 / innerCount; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("AncientProjectionSwirl"), projectileBaseDamage, 5f, 0, l * distance, npc.whoAmI); } int outerCount = 20; for (int l = 0; l < outerCount; l++) { float distance = 360 / outerCount; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("AncientProjectionSwirl2"), projectileBaseDamage, 5f, 0, l * distance, npc.whoAmI); } npc.ai[3]++; } if (npc.ai[3] == 2) { shootTimer[0]--; Vector2 offset = new Vector2(400, 0); float rotateSpeed = 0.015f; shootTimer[1] += rotateSpeed; shootTimer[2] -= rotateSpeed; float Speed = 7; if (shootTimer[0] <= 0) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 20); float numProj = 5f; float projOffset = MathHelper.ToRadians(360f) / numProj; for (int i = 0; i < numProj; i++) { Vector2 shootTarget1 = npc.Center + offset.RotatedBy(shootTimer[1] + (projOffset * (float)i) * (Math.PI * 2 / 8)); float rotation = (float)Math.Atan2(npc.Center.Y - shootTarget1.Y, npc.Center.X - shootTarget1.X); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), mod.ProjectileType("CrystallineKunaiHostileNG"), projectileBaseDamage, 0f, 0); } for (int i = 0; i < numProj; i++) { Vector2 shootTarget1 = npc.Center + offset.RotatedBy(shootTimer[2] + (projOffset * (float)i) * (Math.PI * 2 / 8)); float rotation = (float)Math.Atan2(npc.Center.Y - shootTarget1.Y, npc.Center.X - shootTarget1.X); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), mod.ProjectileType("CrystallineKunaiHostileNG"), projectileBaseDamage, 0f, 0); } shootTimer[0] = 12; } } if (npc.ai[1] > 450) { npc.ai[1] = 0; npc.ai[3] = 0; ResetShootTimers(); for (int i = 0; i < Main.projectile.Length; i++) { Projectile other = Main.projectile[i]; if ((other.type == mod.ProjectileType("AncientProjectionSwirl") || other.type == mod.ProjectileType("AncientProjectionSwirl2")) && other.ai[1] == npc.whoAmI && other.active) { other.Kill(); } } } } } }
public override void AI() { if (Main.rand.Next(0) == 0) { int choice = Main.rand.Next(6); if (choice == 0) { choice = 231; } else if (choice == 1) { choice = 6; } else if (choice == 2) { choice = 162; } else if (choice == 3) { choice = 231; } else if (choice == 4) { choice = 6; } else if (choice == 5) { choice = 162; } else { choice = 271; } Dust.NewDust(projectile.position, projectile.width, projectile.height, choice, projectile.velocity.X * 0.25f, projectile.velocity.Y * -0.25f, 150, default(Color), 0.8f); Dust.NewDust(projectile.position, projectile.width, projectile.height, choice, projectile.velocity.X * 0.25f, projectile.velocity.Y * -0.25f, 150, default(Color), 0.8f); Dust.NewDust(projectile.position, projectile.width, projectile.height, 162, projectile.velocity.X * 0.25f, projectile.velocity.Y * -0.25f, 150, default(Color), 0.8f); } Dust dust; dust = Terraria.Dust.NewDustPerfect(projectile.Center, 133, new Vector2(0f, 0f), 0, new Color(255, 255, 255), 1.052632f); dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(59, Main.LocalPlayer); projectile.ai[0] += 1f; if (projectile.ai[0] > 320f) { // Fade out projectile.alpha += 300; if (projectile.alpha > 255) { projectile.alpha = 255; } } else { // Fade in projectile.alpha -= 25; if (projectile.alpha < 30) { projectile.alpha = 0; } } // Slow down projectile.velocity *= 0.99f; // Loop through the 4 animation frames, spending 5 ticks on each. if (++projectile.frameCounter >= 8) { projectile.frameCounter = 0; if (++projectile.frame >= 4) { projectile.frame = 0; } } projectile.rotation += 0.05f * (float)projectile.direction; }
public override void Kill(int timeLeft) { int dustType = 31; Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType)].velocity *= 0.25f; }
public override void AI() { projectile.velocity = new Vector2(0, 0); projectile.timeLeft -= (int)projectile.ai[0] - 1; //Player player = Main.player[projectile.owner]; for (int p = 0; p < 255; p++) { direction = (projectile.Center - Main.player[p].Center).ToRotation(); horiSpeed = (float)Math.Cos(direction) * pullSpeed / 2; vertSpeed = (float)Math.Sin(direction) * pullSpeed / 2; Main.player[p].velocity += new Vector2(horiSpeed, vertSpeed); for (int i = 0; i < 1; i++) { int dust = Dust.NewDust(Main.player[p].position, Main.player[p].width, Main.player[p].height, mod.DustType("B4PDust"), 0, 0); } } /* * for (int g = 0; g < 3; g++) * { * Dust blackEs = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("B4PDust"), 0, 0)]; * direction = (projectile.Center - blackEs.position).ToRotation(); * horiSpeed = (float)Math.Cos(direction) * pullSpeed * 50; * vertSpeed = (float)Math.Sin(direction) * pullSpeed * 50; * blackEs.velocity += new Vector2(horiSpeed, vertSpeed); * * * } */ for (int d = 0; d < 80; d++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(Main.rand.NextFloat(10, 200), theta), mod.DustType("BlackHoleMatter"), QwertyMethods.PolarVector(6, theta + (float)Math.PI / 2)); dust.scale = 1f; } for (int i = 0; i < Main.dust.Length; i++) { dust = Main.dust[i]; if (!dust.noGravity) { direction = (projectile.Center - dust.position).ToRotation(); horiSpeed = (float)Math.Cos(direction) * pullSpeed * 5; vertSpeed = (float)Math.Sin(direction) * pullSpeed * 5; dust.velocity += new Vector2(horiSpeed, vertSpeed); } if (dust.type == mod.DustType("BlackHoleMatter")) { direction = (projectile.Center - dust.position).ToRotation(); dust.velocity += QwertyMethods.PolarVector(.8f, direction); if ((dust.position - projectile.Center).Length() < 10) { dust.scale = 0f; } else { dust.scale = .35f; } } } for (int i = 0; i < 200; i++) { mass = Main.npc[i]; if (!mass.boss && mass.active && mass.knockBackResist != 0f) { direction = (projectile.Center - mass.Center).ToRotation(); horiSpeed = (float)Math.Cos(direction) * pullSpeed; vertSpeed = (float)Math.Sin(direction) * pullSpeed; mass.velocity += new Vector2(horiSpeed, vertSpeed); for (int g = 0; g < 1; g++) { int dust = Dust.NewDust(mass.position, mass.width, mass.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed); } } } for (int i = 0; i < Main.item.Length; i++) { item = Main.item[i]; if (item.position != new Vector2(0, 0)) { direction = (projectile.Center - item.Center).ToRotation(); horiSpeed = (float)Math.Cos(direction) * pullSpeed; vertSpeed = (float)Math.Sin(direction) * pullSpeed; item.velocity += new Vector2(horiSpeed, vertSpeed); for (int g = 0; g < 1; g++) { int dust = Dust.NewDust(item.position, item.width, item.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed); } } } for (int i = 0; i < Main.projectile.Length; i++) { proj = Main.projectile[i]; if (proj.active && proj.type != mod.ProjectileType("BlackHole") && proj.type != mod.ProjectileType("SideLaser")) { direction = (projectile.Center - proj.Center).ToRotation(); horiSpeed = (float)Math.Cos(direction) * pullSpeed; vertSpeed = (float)Math.Sin(direction) * pullSpeed; proj.velocity += new Vector2(horiSpeed, vertSpeed); for (int g = 0; g < 1; g++) { int dust = Dust.NewDust(proj.position, proj.width, proj.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed); } } } }
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Dust.NewDustPerfect(new Vector2(8 + i * 16, 2 + j * 16), DustType <Dusts.BlueStamina>(), new Vector2((float)Math.Sin(StarlightWorld.rottime * 2 + i * j) * 0.3f, -0.6f), 0, default, 1.5f);
//in Terraria.Main.DrawDust before universal dust drawing call // ModDust modDust = ModDust.GetDust(dust.type); // if(modDust != null) { modDust.Draw(dust, color5, scale); continue; } internal void Draw(Dust dust, Color alpha, float scale) { Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), alpha, dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f); if (dust.color != default(Microsoft.Xna.Framework.Color)) { Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), dust.GetColor(alpha), dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f); } if (alpha == Microsoft.Xna.Framework.Color.Black) { dust.active = false; } }
public override void AI() { if (npc.localAI[3] == 0) //just spawned { npc.TargetClosest(false); Movement(Main.player[npc.target].Center, 0.8f, 32f); if (npc.Distance(Main.player[npc.target].Center) < 2000) npc.localAI[3] = 1; else return; if (Main.netMode != NetmodeID.MultiplayerClient) { if (FargoSoulsWorld.MasochistMode) Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType<LifeRitual>(), npc.damage / 2, 0f, Main.myPlayer, 0f, npc.whoAmI); } } EModeGlobalNPC.championBoss = npc.whoAmI; Player player = Main.player[npc.target]; Vector2 targetPos; if (npc.HasValidTarget && npc.Distance(player.Center) < 2500) npc.timeLeft = 600; switch ((int)npc.ai[0]) { case -3: //final phase if (!Main.dayTime || !player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) npc.timeLeft = 30; npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; break; } npc.velocity = Vector2.Zero; npc.ai[1] -= (float)Math.PI * 2 / 447; npc.ai[3] += (float)Math.PI * 2 / 447; //spin deathrays both ways if (--npc.ai[2] < 0) { npc.localAI[1] = npc.localAI[1] == 0 ? 1 : 0; npc.ai[2] = npc.localAI[1] == 1 ? 90 : 30; if (npc.ai[1] < 360 && Main.netMode != NetmodeID.MultiplayerClient) { int type = npc.localAI[1] == 1 ? ModContent.ProjectileType<LifeDeathraySmall2>() : ModContent.ProjectileType<LifeDeathray2>(); int max = 3; for (int i = 0; i < max; i++) { float offset = (float)Math.PI * 2 / max * i; Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[3] + offset), type, npc.damage / 4, 0f, Main.myPlayer, (float)Math.PI * 2 / 447, npc.whoAmI); Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[1] + offset), type, npc.damage / 4, 0f, Main.myPlayer, -(float)Math.PI * 2 / 447, npc.whoAmI); } } } if (--npc.localAI[0] < 0) { npc.localAI[0] = 47; if (Main.netMode != NetmodeID.MultiplayerClient) { int max = 14; float rotation = Main.rand.NextFloat((float)Math.PI * 2); for (int i = 0; i < max; i++) { Projectile.NewProjectile(npc.Center, new Vector2(4f, 0).RotatedBy(rotation + Math.PI / max * 2 * i), ModContent.ProjectileType<ChampionBee>(), npc.damage / 4, 0f, Main.myPlayer); } } } break; case -2: //final phase transition npc.velocity *= 0.97f; if (npc.ai[1] > 180) { npc.localAI[0] = 0; npc.localAI[2] = 2; } if (++npc.ai[1] == 180) //heal up { Main.PlaySound(SoundID.Roar, npc.Center, 2); //arte scream int heal = npc.lifeMax / 3 - npc.life; npc.life += heal; CombatText.NewText(npc.Hitbox, CombatText.HealLife, heal); const int num226 = 80; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.UnitX * 40f; vector6 = vector6.RotatedBy(((num227 - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + npc.Center; Vector2 vector7 = vector6 - npc.Center; int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 174, 0f, 0f, 0, default(Color), 3f); Main.dust[num228].noGravity = true; Main.dust[num228].velocity = vector7; } } else if (npc.ai[1] > 240) { npc.ai[0] = -3; npc.ai[1] = npc.DirectionTo(player.Center).ToRotation(); npc.ai[2] = 0; npc.ai[3] = npc.DirectionTo(player.Center).ToRotation(); npc.netUpdate = true; } break; case -1: //heal npc.velocity *= 0.97f; if (npc.ai[1] > 180) npc.localAI[2] = 1; if (++npc.ai[1] == 180) //heal up { Main.PlaySound(SoundID.Roar, npc.Center, 2); //arte scream int heal = npc.lifeMax - npc.life; npc.life += heal; CombatText.NewText(npc.Hitbox, CombatText.HealLife, heal); const int num226 = 80; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.UnitX * 40f; vector6 = vector6.RotatedBy(((num227 - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + npc.Center; Vector2 vector7 = vector6 - npc.Center; int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 174, 0f, 0f, 0, default(Color), 3f); Main.dust[num228].noGravity = true; Main.dust[num228].velocity = vector7; } } else if (npc.ai[1] > 240) { npc.ai[0] = npc.ai[3]; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 0: //float over player if (!Main.dayTime || !player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) npc.timeLeft = 30; npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; break; } targetPos = player.Center; targetPos.Y -= 275; if (npc.Distance(targetPos) > 50) Movement(targetPos, 0.18f, 24f, true); if (npc.Distance(player.Center) < 200) //try to avoid contact damage Movement(targetPos, 0.24f, 24f, true); if (++npc.ai[1] > 150) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } if (npc.localAI[2] == 0 && npc.life < npc.lifeMax / 3) { float buffer = npc.ai[0]; npc.ai[0] = -1; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = buffer; npc.netUpdate = true; } if (npc.localAI[2] == 1 && npc.life < npc.lifeMax / 3 && FargoSoulsWorld.MasochistMode) { npc.ai[0] = -2; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 1: //boundary npc.velocity *= 0.95f; if (++npc.ai[1] > (npc.localAI[2] == 1 ? 2 : 3)) { Main.PlaySound(SoundID.Item12, npc.Center); npc.ai[1] = 0; npc.ai[2] -= (float)Math.PI / 4 / 457 * npc.ai[3]; if (npc.ai[2] < -(float)Math.PI) npc.ai[2] += (float)Math.PI * 2; if (Main.netMode != NetmodeID.MultiplayerClient) { int max = npc.localAI[2] == 1 ? 5 : 4; for (int i = 0; i < max; i++) { Projectile.NewProjectile(npc.Center, new Vector2(6f, 0).RotatedBy(npc.ai[2] + Math.PI / max * 2 * i), ModContent.ProjectileType<ChampionBee>(), npc.damage / 4, 0f, Main.myPlayer); } } } if (++npc.ai[3] > 300) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 2: if (npc.ai[3] == 0) { if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) npc.timeLeft = 30; npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; return; } if (npc.ai[2] == 0) npc.ai[2] = npc.Center.Y; //store arena height if (npc.Center.Y > npc.ai[2] + 1000) //now below arena, track player { targetPos = new Vector2(player.Center.X, npc.ai[2] + 1100); Movement(targetPos, 1.2f, 24f); if (Math.Abs(player.Center.X - npc.Center.X) < npc.width / 2 && ++npc.ai[1] > (npc.localAI[2] == 1 ? 30 : 60)) //in position under player { Main.PlaySound(SoundID.Item92, npc.Center); npc.ai[3]++; npc.ai[1] = 0; npc.netUpdate = true; } } else //drop below arena { npc.velocity.X *= 0.95f; npc.velocity.Y += 0.6f; } } else { npc.velocity.X = 0; npc.velocity.Y = -36f; if (++npc.ai[1] > 1) //spawn pixies { npc.ai[1] = 0; npc.localAI[0] = npc.localAI[0] == 1 ? -1 : 1; //alternate sides if (Main.netMode != NetmodeID.MultiplayerClient) { int n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType<LesserFairy>(), npc.whoAmI, Target: npc.target); if (n != Main.maxNPCs) { Main.npc[n].velocity = 5f * Vector2.UnitX.RotatedBy(Math.PI * (Main.rand.NextDouble() - 0.5)); Main.npc[n].velocity.X *= npc.localAI[0]; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n); } } } } if (npc.Center.Y < player.Center.Y - 600) //dash ended { npc.velocity.Y *= -0.25f; npc.localAI[0] = 0f; npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } } break; case 3: goto case 0; case 4: //beetle swarm npc.velocity *= 0.9f; if (npc.ai[3] == 0) npc.ai[3] = npc.Center.X < player.Center.X ? -1 : 1; if (++npc.ai[2] > (npc.localAI[2] == 1 ? 35 : 45)) { npc.ai[2] = 0; Main.PlaySound(SoundID.Item92, npc.Center); if (npc.localAI[0] > 0) npc.localAI[0] = -1; else npc.localAI[0] = 1; if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projTarget = npc.Center; projTarget.X += 1200 * npc.ai[3]; projTarget.Y += 1200 * -npc.localAI[0]; for (int i = 0; i < 20; i++) { projTarget.Y += 250 * npc.localAI[0]; Vector2 speed = (projTarget - npc.Center) / 40; float ai0 = (npc.localAI[2] == 1 ? 9 : 6) * -npc.ai[3]; //x speed of beetles float ai1 = 6 * -npc.localAI[0]; //y speed of beetles Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType<ChampionBeetle>(), npc.damage / 4, 0f, Main.myPlayer, ai0, ai1); } } } if (++npc.ai[1] > 360) { npc.localAI[0] = 0; npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 5: goto case 0; case 6: npc.velocity *= 0.98f; if (++npc.ai[2] > 60) { if (++npc.ai[3] > (npc.localAI[2] == 1 ? 4 : 7)) //spray fireballs that home down { npc.ai[3] = 0; if (Main.netMode != NetmodeID.MultiplayerClient) { //spawn anywhere above self Vector2 target = new Vector2(Main.rand.NextFloat(1000), 0).RotatedBy(Main.rand.NextDouble() * -Math.PI); Vector2 speed = 2 * target / 60; float acceleration = -speed.Length() / 60; Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType<LifeFireball>(), npc.damage / 4, 0f, Main.myPlayer, 60f, acceleration); } } if (npc.ai[2] > (npc.localAI[2] == 1 ? 120 : 100)) { npc.netUpdate = true; npc.ai[2] = 0; } } if (++npc.ai[1] > 480) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 7: goto case 0; case 8: goto case 2; case 9: //deathray spin npc.velocity *= 0.95f; npc.ai[3] += (float)Math.PI * 2 / (npc.localAI[2] == 1 ? -300 : 360); if (--npc.ai[2] < 0) { npc.ai[2] = 60; npc.localAI[1] = npc.localAI[1] == 0 ? 1 : 0; if (npc.ai[1] < 360 && Main.netMode != NetmodeID.MultiplayerClient) { int type = npc.localAI[1] == 1 ? ModContent.ProjectileType<LifeDeathraySmall>() : ModContent.ProjectileType<LifeDeathray>(); int max = npc.localAI[2] == 1 ? 6 : 4; for (int i = 0; i < max; i++) { float offset = (float)Math.PI * 2 / max * i; Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[3] + offset), type, npc.damage / 4, 0f, Main.myPlayer, offset, npc.whoAmI); } } } if (++npc.ai[1] > 390) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.localAI[1] = 0; npc.netUpdate = true; } break; case 10: goto case 0; case 11: //cactus mines npc.velocity *= 0.98f; if (++npc.ai[2] > (npc.localAI[2] == 1 ? 75 : 100)) { if (++npc.ai[3] > 5) //spray mines that home down { npc.ai[3] = 0; Main.PlaySound(SoundID.Item12, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 target = player.Center - npc.Center; target.X += Main.rand.Next(-75, 76); target.Y += Main.rand.Next(-75, 76); Vector2 speed = 2 * target / 90; float acceleration = -speed.Length() / 90; Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType<CactusMine>(), npc.damage / 4, 0f, Main.myPlayer, 0f, acceleration); } } if (npc.ai[2] > 130) { npc.netUpdate = true; npc.ai[2] = 0; } } if (++npc.ai[1] > 480) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; default: npc.ai[0] = 0; goto case 0; } for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 87, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 4f; } }
//in Terraria.Dust.UdpateDust at end of dust update code call this internal static void TakeDownUpdateType(Dust dust) { if (dust.realType >= 0) { dust.type = dust.realType; dust.realType = -1; } }
//in beginning of Terraria.Dust.GetAlpha add // ModDust modDust = ModDust.GetDust(this.type); // if(modDust != null) // { // Color? modColor = modDust.GetAlpha(this, newColor); // if(modColor.HasValue) // { // return modColor.Value; // } // } public virtual Color? GetAlpha(Dust dust, Color lightColor) { return null; }
public virtual bool MidUpdate(Dust dust) { return false; }
//in Terraria.Dust.UpdateDust after setting up update type add // ModDust modDust = ModDust.GetDust(dust.type); // if(modDust != null && !modDust.Update(dust)) { ModDust.TakeDownUpdateType(dust); continue; } public virtual bool Update(Dust dust) { return true; }
public virtual void OnSpawn(Dust dust) { }
public override void AI() { if (!spawned) { spawned = true; NPC.TargetClosest(false); if (Main.netMode != NetmodeID.MultiplayerClient) { head = FargoSoulsUtil.NPCExists(FargoSoulsUtil.NewNPCEasy(NPC.GetSource_FromThis(), NPC.Center, ModContent.NPCType <TrojanSquirrelHead>(), NPC.whoAmI, target: NPC.target)); arms = FargoSoulsUtil.NPCExists(FargoSoulsUtil.NewNPCEasy(NPC.GetSource_FromThis(), NPC.Center, ModContent.NPCType <TrojanSquirrelArms>(), NPC.whoAmI, target: NPC.target)); } //drop summon if (FargoSoulsWorld.EternityMode && !FargoSoulsWorld.downedBoss[(int)FargoSoulsWorld.Downed.TrojanSquirrel] && Main.netMode != NetmodeID.MultiplayerClient) { Item.NewItem(NPC.GetSource_Loot(), Main.player[NPC.target].Hitbox, ModContent.ItemType <SquirrelCoatofArms>()); } //start by jumping NPC.ai[0] = 1f; NPC.ai[3] = 1f; for (int i = 0; i < 80; i++) { int d = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 50, default(Color), 4f); Main.dust[d].velocity.Y -= 1.5f; Main.dust[d].velocity *= 1.5f; Main.dust[d].noGravity = true; } FargoSoulsUtil.GrossVanillaDodgeDust(NPC); SoundEngine.PlaySound(SoundID.Roar, Main.player[NPC.target].Center); } Player player = Main.player[NPC.target]; NPC.direction = NPC.spriteDirection = NPC.Center.X < player.Center.X ? 1 : -1; bool despawn = false; switch ((int)NPC.ai[0]) { case 0: //mourning wood movement { Vector2 target = player.Bottom - Vector2.UnitY; if (NPC.localAI[0] > 0) //doing running attack { NPC.localAI[0] -= 1f; float distance = NPC.Center.X - target.X; bool passedTarget = Math.Sign(distance) == NPC.localAI[1]; if (passedTarget && Math.Abs(distance) > 160) { NPC.localAI[0] = 0f; } target = new Vector2(NPC.Center.X + 256f * NPC.localAI[1], target.Y); if (NPC.localAI[0] == 0f) { NPC.TargetClosest(false); } if (FargoSoulsWorld.EternityMode && head == null && NPC.localAI[0] % 3 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Top.X, NPC.Top.Y, Main.rand.NextFloat(-5, 5), Main.rand.NextFloat(-5), Main.rand.Next(326, 329), FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer); if (p != Main.maxProjectiles) { Main.projectile[p].timeLeft = 90; } } } else if (!NPC.HasValidTarget || NPC.Distance(player.Center) > (FargoSoulsWorld.EternityMode ? 1600 : 2400)) { target = NPC.Center + new Vector2(256f * Math.Sign(NPC.Center.X - player.Center.X), -128); NPC.TargetClosest(false); despawn = true; } if (Math.Abs(NPC.velocity.Y) < 0.05f && NPC.localAI[3] >= 2) { if (NPC.localAI[3] == 2) { NPC.localAI[3] = 0f; } else { NPC.localAI[3] -= 1; NPC.ai[0] = 1f; NPC.ai[3] = 1f; } SoundEngine.PlaySound(SoundID.Item14, NPC.Center); ExplodeAttack(); } bool goFast = despawn || NPC.localAI[0] > 0; Movement(target, goFast); if (arms != null && (NPC.localAI[3] == -1 || NPC.localAI[3] == 1)) //from arms { NPC.direction = NPC.spriteDirection = (int)NPC.localAI[3]; } bool canDoAttacks = FargoSoulsWorld.EternityMode && !goFast; if (canDoAttacks) //decide next action { float increment = 1f; if (head == null) { increment += 0.5f; } if (arms == null) { increment += 0.5f; } if (FargoSoulsWorld.MasochistModeReal) { increment += 1f; } if (NPC.dontTakeDamage) { increment /= 2; } if (target.Y > NPC.Top.Y) { NPC.ai[1] += increment; } else { NPC.ai[2] += increment; } if (Math.Abs(NPC.velocity.Y) < 0.05f) { //its structured like this to ensure body picks the right attack for the situation after being delayed by head/arms bool canProceed = !(head != null && head.ai[0] != 0) && !(arms != null && arms.ai[0] != 0); int threshold = 300; if (NPC.ai[1] > threshold) { if (canProceed) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; //NPC.ai[2] = 0f; NPC.ai[3] = 0f; NPC.localAI[0] = 0f; NPC.netUpdate = true; } else { NPC.ai[1] -= 10f; } } if (NPC.ai[2] > threshold) { if (canProceed) { NPC.ai[0] = 1f; //NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 1f; NPC.localAI[0] = 0f; NPC.netUpdate = true; } else { NPC.ai[2] -= 10f; } } } } } break; case 1: //telegraph something { NPC.velocity.X *= 0.9f; TileCollision(player.Bottom.Y - 1 > NPC.Bottom.Y, Math.Abs(player.Center.X - NPC.Center.X) < NPC.width / 2 && NPC.Bottom.Y < player.Bottom.Y - 1); int threshold = 120; if (FargoSoulsWorld.EternityMode) { if (head == null) { threshold -= 20; } if (arms == null) { threshold -= 20; } if (head == null && arms == null) { threshold -= 30; } if (NPC.localAI[3] >= 2) { threshold -= 20; } } if (FargoSoulsWorld.MasochistModeReal) { threshold -= 20; } if (++NPC.localAI[0] > threshold) { NPC.localAI[0] = 0f; NPC.netUpdate = true; if (NPC.ai[3] == 0f) { NPC.ai[0] = 0f; NPC.localAI[0] = 300f; NPC.localAI[1] = Math.Sign(player.Center.X - NPC.Center.X); NPC.localAI[2] = player.Center.X; } else { NPC.ai[0] = 2f; } } } break; case 2: //jump { const float gravity = 0.4f; float time = FargoSoulsWorld.EternityMode && arms == null ? 60f : 90f; if (NPC.localAI[0]++ == 0) { Vector2 distance = player.Top - NPC.Bottom; if (FargoSoulsWorld.EternityMode && arms == null) { distance.X += NPC.width * Math.Sign(player.Center.X - NPC.Center.X); if (NPC.localAI[3] < 2) { NPC.localAI[3] = 2; //flag to stomp again on landing if (head == null) { NPC.localAI[3] += 2; //flag to do more stomps } } ExplodeAttack(); } distance.X = distance.X / time; distance.Y = distance.Y / time - 0.5f * gravity * time; NPC.velocity = distance; NPC.netUpdate = true; SoundEngine.PlaySound(SoundID.Item14, NPC.Center); } else { NPC.velocity.Y += gravity; } if (NPC.localAI[0] > time) { NPC.TargetClosest(false); NPC.velocity.X = Utils.Clamp(NPC.velocity.X, -20, 20); NPC.velocity.Y = Utils.Clamp(NPC.velocity.Y, -10, 10); NPC.ai[0] = 0f; NPC.localAI[0] = 0f; NPC.netUpdate = true; } } break; default: NPC.ai[0] = 0; goto case 0; } if (despawn) { if (NPC.timeLeft > 60) { NPC.timeLeft = 60; } } else { if (NPC.timeLeft < 600) { NPC.timeLeft = 600; } } if (head == null) { Vector2 pos = NPC.Top; pos.X += 2f * 16f * NPC.direction; pos.Y -= 8f; int width = 4 * 16; int height = 2 * 16; pos.X -= width / 2f; pos.Y -= height / 2f; for (int i = 0; i < 3; i++) { int d = Dust.NewDust(pos, width, height, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 50, default(Color), 2.5f); Main.dust[d].velocity.Y -= 1.5f; Main.dust[d].velocity *= 1.5f; Main.dust[d].noGravity = true; } if (Main.rand.NextBool(3)) { int d = Dust.NewDust(pos, width, height, DustID.Torch, NPC.velocity.X * 0.4f, NPC.velocity.Y * 0.4f, 100, default(Color), 2.5f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 3f; Main.dust[d].velocity *= 1.5f; } } else { lifeMaxHead = head.lifeMax; head = FargoSoulsUtil.NPCExists(head.whoAmI, ModContent.NPCType <TrojanSquirrelHead>()); } if (arms == null) { Vector2 pos = NPC.Center; pos.X -= 16f * NPC.direction; pos.Y -= 3f * 16f; int width = 2 * 16; int height = 2 * 16; pos.X -= width / 2f; pos.Y -= height / 2f; for (int i = 0; i < 2; i++) { int d = Dust.NewDust(pos, width, height, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 50, default(Color), 1.5f); Main.dust[d].noGravity = true; } if (Main.rand.NextBool()) { int d2 = Dust.NewDust(pos, width, height, DustID.Torch, NPC.velocity.X * 0.4f, NPC.velocity.Y * 0.4f, 100, default(Color), 3f); Main.dust[d2].noGravity = true; } } else { lifeMaxArms = arms.lifeMax; arms = FargoSoulsUtil.NPCExists(arms.whoAmI, ModContent.NPCType <TrojanSquirrelArms>()); } if (NPC.life < NPC.lifeMax / 2 && Main.rand.NextBool(3)) { int d = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 50, default(Color), 4f); Main.dust[d].velocity.Y -= 1.5f; Main.dust[d].velocity *= 1.5f; Main.dust[d].noGravity = true; } if (FargoSoulsWorld.EternityMode) { bool wasImmune = NPC.dontTakeDamage; NPC.dontTakeDamage = NPC.life < NPC.lifeMax / 2 && (head != null || arms != null); if (wasImmune != NPC.dontTakeDamage) { for (int i = 0; i < 6; i++) { ExplodeDust(NPC.position + new Vector2(Main.rand.Next(NPC.width), Main.rand.Next(NPC.height))); } } } else { NPC.dontTakeDamage = false; } }
public override void AI() { Projectile P = projectile; Player O = Main.player[P.owner]; Item I = O.inventory[O.selectedItem]; MPlayer mp = O.GetModPlayer <MPlayer>(); MGlobalItem mi = I.GetGlobalItem <MGlobalItem>(); float MY = Main.mouseY + Main.screenPosition.Y; float MX = Main.mouseX + Main.screenPosition.X; if (O.gravDir == -1f) { MY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY; } Vector2 oPos = O.RotatedRelativePoint(O.MountedCenter, true); P.scale = ((float)mi.seekerCharge / (float)MGlobalItem.seekerMaxCharge) * (0.25f + (0.75f * ((float)(mi.numSeekerTargets + 1) / 6f))); float targetrotation = (float)Math.Atan2((MY - oPos.Y), (MX - oPos.X)); P.rotation += 0.5f * P.direction; O.itemTime = 2; O.itemAnimation = 2; int range = I.width + 4; int width = (I.width / 2) - (P.width / 2); int height = (I.height / 2) - (P.height / 2); if (negateUseTime < I.useTime) { negateUseTime++; } Vector2 iPos = O.itemLocation; P.friendly = false; P.damage = 0; P.position = new Vector2(iPos.X + (float)Math.Cos(targetrotation) * range + width, iPos.Y + (float)Math.Sin(targetrotation) * range + height); P.alpha = 0; if (P.velocity.X < 0) { P.direction = -1; } else { P.direction = 1; } P.spriteDirection = P.direction; O.direction = P.direction; O.heldProj = P.whoAmI; O.itemRotation = (float)Math.Atan2((MY - oPos.Y) * O.direction, (MX - oPos.X) * O.direction) - O.fullRotation; P.position -= P.velocity; P.timeLeft = 60; if (O.whoAmI == Main.myPlayer) { if (mi.seekerCharge == 10) { soundInstance = Main.PlaySound(SoundLoader.customSoundType, (int)oPos.X, (int)oPos.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/ChargeStartup_Seeker")); } } if (mi.seekerCharge >= MGlobalItem.seekerMaxCharge) { if (dustDelay <= mi.numSeekerTargets) { int dust = Dust.NewDust(P.position + P.velocity, P.width, P.height, 63, 0, 0, 100, Color.Cyan, 2.0f); Main.dust[dust].noGravity = true; dustDelay = 5; } } dustDelay = Math.Max(dustDelay - 1, 0); Lighting.AddLight(P.Center, (LightColor.R / 255f) * P.scale, (LightColor.G / 255f) * P.scale, (LightColor.B / 255f) * P.scale); if (O.controlUseItem && !mp.ballstate && !mp.shineActive && !O.dead && !O.noItems) { if (P.owner == Main.myPlayer) { P.velocity = targetrotation.ToRotationVector2() * O.inventory[O.selectedItem].shootSpeed; } } else { if (mi.seekerCharge >= MGlobalItem.seekerMaxCharge) { O.itemTime = I.useTime; O.itemAnimation = I.useAnimation; } else { O.itemTime = I.useTime - negateUseTime; O.itemAnimation = I.useAnimation - negateUseTime; } if (O.whoAmI == Main.myPlayer) { if (soundInstance != null) { soundInstance.Stop(true); } soundPlayed = false; } P.Kill(); } }
public override void MeleeEffects(Player player, Rectangle hitbox) { int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 64); }
public override void AI() { if (!npc.HasPlayerTarget) { npc.TargetClosest(); } Player player = Main.player[npc.target]; BaseAI.AIFlier(npc, ref npc.ai, true, 0.15f, 0.08f, 8f, 7f, false, 300); if (npc.alpha > 0) { npc.alpha -= 4; } else { npc.alpha = 0; } if (npc.ai[3]++ > 30 && Main.netMode != 1) { int projType = ModContent.ProjectileType <SeraphFeather>(); float spread = 30f * 0.0174f; Vector2 dir = Vector2.Normalize(player.Center - npc.Center); dir *= 14f; float baseSpeed = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y)); double startAngle = Math.Atan2(dir.X, dir.Y) - .1d; double deltaAngle = spread / 6f; for (int i = 0; i < 3; i++) { double offsetAngle = startAngle + (deltaAngle * i); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), projType, npc.damage / 4, 2, Main.myPlayer); } npc.ai[3] = 0; npc.netUpdate = true; } if (!player.GetModPlayer <AAPlayer>().ZoneAcropolis || player.dead) { npc.TargetClosest(); if (!player.GetModPlayer <AAPlayer>().ZoneAcropolis || player.dead) { if (!player.GetModPlayer <AAPlayer>().ZoneAcropolis) { CombatText.NewText(npc.Hitbox, Color.CadetBlue, SeraphBitching(), true); } else if (player.dead) { CombatText.NewText(npc.Hitbox, Color.CadetBlue, SeraphBitchingKill(), true); } for (int a = 0; a < 8; a++) { Dust.NewDust(npc.Center, 60, 40, ModContent.DustType <Feather>(), Main.rand.Next(-1, 2), 1, 0); } BaseAI.KillNPC(npc); } } npc.spriteDirection = npc.direction; npc.rotation = npc.velocity.X * 0.05f; }
public override void AI() { NPC abomination = Main.npc[center]; if (!abomination.active || abomination.type != mod.NPCType("Abomination")) { if (change > 0 || NPC.AnyNPCs(mod.NPCType("AbominationRun"))) { if (change == 0) { npc.netUpdate = true; } change++; } else { npc.life = -1; npc.active = false; return; } } if (change > 0) { Color?color = GetColor(); if (color.HasValue) { for (int x = 0; x < 5; x++) { int dust = Dust.NewDust(npc.position, npc.width, npc.height, mod.DustType("Pixel"), 0f, 0f, 0, color.Value); double angle = Main.rand.NextDouble() * 2.0 * Math.PI; Main.dust[dust].velocity = 3f * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)); } } if (Main.netMode != 1 && change >= 100f) { int next = NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, mod.NPCType("CaptiveElement2")); Main.npc[next].ai[0] = captiveType; if (captiveType != 4) { Main.npc[next].ai[1] = 300f + (float)Main.rand.Next(100); } npc.life = -1; npc.active = false; } return; } else if (npc.timeLeft < 750) { npc.timeLeft = 750; } if (npc.localAI[0] == 0f) { if (GetDebuff() >= 0f) { npc.buffImmune[GetDebuff()] = true; } if (captiveType == 3f) { npc.buffImmune[20] = true; } if (captiveType == 0f) { npc.coldDamage = true; } npc.localAI[0] = 1f; } SetPosition(npc); attackCool -= 1f; if (Main.netMode != 1 && attackCool <= 0f) { attackCool = 200f + 200f * (float)abomination.life / (float)abomination.lifeMax + (float)Main.rand.Next(200); Vector2 delta = Main.player[abomination.target].Center - npc.Center; float magnitude = (float)Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y); if (magnitude > 0) { delta *= 5f / magnitude; } else { delta = new Vector2(0f, 5f); } int damage = (npc.damage - 30) / 2; if (Main.expertMode) { damage = (int)(damage / Main.expertDamage); } Projectile.NewProjectile(npc.Center.X, npc.Center.Y, delta.X, delta.Y, mod.ProjectileType("ElementBall"), damage, 3f, Main.myPlayer, GetDebuff(), GetDebuffTime()); npc.netUpdate = true; } }
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { Dust.NewDustPerfect(new Vector2(6 + i * 16, 2 + j * 16), DustType <Content.Dusts.GoldWithMovement>(), new Vector2((float)Math.Sin(StarlightWorld.rottime * 2 + i * j) * 0.3f, -0.4f)); Lighting.AddLight(new Vector2(i * 16, j * 16), new Vector3(245, 220, 110) * 0.004f); }
public void SpawnDustOnPlayerPostUpdate(DoTariaPlayer dotariaPlayer) { Vector2 dustPosition = new Vector2(dotariaPlayer.player.position.X + 2, dotariaPlayer.player.position.Y + 37); Dust.NewDust(dustPosition, 18, 10, mod.DustType <ShadowTrail>(), 0f, 0.8f, 0, new Color(255, 255, 255), 2.4f); }
public override void Update(NPC npc, ref int buffIndex) { npc.defense = (npc.defDefense / 100) * 92; npc.lifeRegen -= 14; int dust = Dust.NewDust(npc.position, npc.width, npc.height, 173); }
public override void MeleeEffects(Player player, Rectangle hitbox) { int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 6); Lighting.AddLight(new Vector2(player.position.X, player.position.Y), 0.9f, 0.6f, 0.2f); }
public override void AI() { if (projectile.penetrate == 1 || projectile.timeLeft <= 700) { projectile.velocity *= 0.9f; projectile.alpha += 5; } if (projectile.alpha >= 255) { projectile.Kill(); } if (projectile.localAI[0] == 0) { if (projectile.scale <= 1f) { projectile.scale += 0.05f; } if (projectile.scale >= 1f) { projectile.localAI[0] = 1; } } if (projectile.localAI[0] >= 1) { projectile.localAI[0] += 1; if (projectile.localAI[0] >= 60 && projectile.localAI[0] <= 200) { Overlayalpha += 0.005f; projectile.damage += 1; projectile.scale += 0.005f; } if (projectile.localAI[0] == 200) { for (int num2 = 0; num2 < 24; num2++) { int num = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 269, 1f, 1f, 100, default(Color), 2.2f); Main.dust[num].velocity *= 4f; Main.dust[num].noGravity = true; } Overlayalpha = 1f; } if (projectile.localAI[0] >= 260) { Overlayalpha -= 0.025f; projectile.damage -= 2; projectile.scale -= 0.01f; } if (projectile.localAI[0] >= 360) { projectile.Kill(); } } projectile.rotation += 0.04f; double deg = (double)projectile.ai[0]; double rad = deg * (Math.PI / 180); double dist = (double)projectile.ai[1]; if (projectile.localAI[1] == 0) { Player player = Main.player[projectile.owner]; MyPlayer modPlayer = (MyPlayer)player.GetModPlayer(mod, "MyPlayer"); Vector2 direction = Main.player[projectile.owner].Center - projectile.Center; projectile.rotation = direction.ToRotation(); //To make this i modified a projectile that orbits around the player, modified it and got it working. projectile.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - projectile.width / 2; projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - projectile.height / 2; projectile.ai[0] += 1; projectile.ai[0] += Main.rand.NextFloat(0.5f, 2f); if (modPlayer.UsedSpiritOrb) { projectile.localAI[1] = 1; } Vector2 value11 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY); projectile.velocity = Vector2.Normalize(value11 - projectile.Center) * 12; } if (projectile.localAI[1] == 1) { projectile.localAI[0] = -1; projectile.ai[1] = 0; projectile.ai[0] = 0; projectile.localAI[1] = 2; Vector2 value11 = Main.screenPosition + new Vector2(Main.mouseX - (int)(Math.Cos(rad) * dist) / 2 - projectile.width / 2, Main.mouseY - (int)(Math.Sin(rad) * dist) / 2 - projectile.height / 2); projectile.velocity = Vector2.Normalize(value11 - projectile.Center) * 6; } if (projectile.localAI[1] == 2) { float num372 = projectile.position.X; float num373 = projectile.position.Y; float num374 = 100000f; bool flag10 = false; projectile.ai[0] += 1; int num3; for (int num375 = 0; num375 < 200; num375 = num3 + 1) { if (Main.npc[num375].CanBeChasedBy(projectile, false)) { float num376 = Main.npc[num375].position.X + (float)(Main.npc[num375].width / 2); float num377 = Main.npc[num375].position.Y + (float)(Main.npc[num375].height / 2); float num378 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num376) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num377); if (num378 < 800f && num378 < num374 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num375].position, Main.npc[num375].width, Main.npc[num375].height)) { num374 = num378; num372 = num376; num373 = num377; flag10 = true; } } num3 = num375; } if (!flag10) { num372 = projectile.position.X + (float)(projectile.width / 2) + projectile.velocity.X * 250f; num373 = projectile.position.Y + (float)(projectile.height / 2) + projectile.velocity.Y * 250f; } float num379 = 7f; float num380 = 0.06f; Vector2 vector29 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num381 = num372 - vector29.X; float num382 = num373 - vector29.Y; float num383 = (float)Math.Sqrt((double)(num381 * num381 + num382 * num382)); num383 = num379 / num383; num381 *= num383; num382 *= num383; if (projectile.velocity.X < num381) { projectile.velocity.X = projectile.velocity.X + num380; if (projectile.velocity.X < 0f && num381 > 0f) { projectile.velocity.X = projectile.velocity.X + num380 * 2f; } } else { if (projectile.velocity.X > num381) { projectile.velocity.X = projectile.velocity.X - num380; if (projectile.velocity.X > 0f && num381 < 0f) { projectile.velocity.X = projectile.velocity.X - num380 * 2f; } } } if (projectile.velocity.Y < num382) { projectile.velocity.Y = projectile.velocity.Y + num380; if (projectile.velocity.Y < 0f && num382 > 0f) { projectile.velocity.Y = projectile.velocity.Y + num380 * 2f; return; } } else { if (projectile.velocity.Y > num382) { projectile.velocity.Y = projectile.velocity.Y - num380; if (projectile.velocity.Y > 0f && num382 < 0f) { projectile.velocity.Y = projectile.velocity.Y - num380 * 2f; return; } } } Lighting.AddLight(projectile.Center, ((255 - projectile.alpha) * 0.05f) / 255f, ((255 - projectile.alpha) * 0.5f) / 255f, ((255 - projectile.alpha) * 0.75f) / 255f); projectile.rotation += 0.08f; projectile.ai[1] += 0.5f; if (projectile.ai[1] >= 10f && projectile.ai[1] <= 25f) { projectile.velocity.X *= 1.02f; projectile.velocity.Y *= 1.02f; } if (projectile.ai[1] >= 35f) { projectile.velocity.X *= 0.96f; projectile.velocity.Y *= 0.96f; } if (projectile.ai[1] <= 35f) { if (projectile.alpha > 40) { projectile.alpha -= 2; } } if (projectile.ai[1] >= 10f) { int drust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width * (int)projectile.scale, projectile.height * (int)projectile.scale, 6, 0f, 0f, 100, default(Color), 1.5f); Main.dust[drust].velocity *= 2f; Main.dust[drust].fadeIn *= 1.8f; Main.dust[drust].noGravity = true; int drust2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width * (int)projectile.scale, projectile.height * (int)projectile.scale, 269, 0f, 0f, 100, default(Color), 1.5f); Main.dust[drust2].velocity *= 4f; Main.dust[drust2].fadeIn *= 2.8f; Main.dust[drust2].noGravity = true; projectile.rotation += 0.03f; } } }
public override bool CanUseItem(Player player) { VipixToolBoxPlayer myPlayer = player.GetModPlayer <VipixToolBoxPlayer>(mod); if (player.altFunctionUse == 2) { //sending mouse coordinates (at the moment of the click) to VipixToolBoxPlayer for UI position myPlayer.tbMouseX = Main.mouseX; myPlayer.tbMouseY = Main.mouseY; ColorUI.visible = true; } else { if (operationAllowed) { int i = 0; //need to check for resource first bool found = false; bool operationDone = false; while (i < player.inventory.Length) { if (paints.Contains(player.inventory[i].type)) { break; } i++; } if (i < player.inventory.Length) { found = true; } switch (myPlayer.paintStatus) { case 0: if (found && myPlayer.pointedTile.color() != myPlayer.colorByte) { //no painting of already painted tiles (would consume paint) myPlayer.pointedTile.color(myPlayer.colorByte); if (Main.rand.NextDouble() <= 0.2) { player.inventory[i].stack--; //80% not to consume paint } operationDone = true; } break; case 1: if (found && myPlayer.pointedTile.wallColor() != myPlayer.colorByte) { myPlayer.pointedTile.wallColor(myPlayer.colorByte); if (Main.rand.NextDouble() <= 0.2) { player.inventory[i].stack--; //80% not to consume paint } operationDone = true; } break; case 2: if (myPlayer.pointedTile.color() != 0) { myPlayer.pointedTile.color(0); operationDone = true; } break; case 3: if (myPlayer.pointedTile.wallColor() != 0) { myPlayer.pointedTile.wallColor(0); operationDone = true; } break; } if (operationDone) { if (Main.netMode == 1) { NetMessage.SendTileSquare(-1, myPlayer.pointedTileX, myPlayer.pointedTileY, 1); } Main.PlaySound(SoundID.Dig); Vector2 dustSpawn; for (int j = 0; j < 10; j++) { dustSpawn = new Vector2(myPlayer.pointerCoord.X - 4, myPlayer.pointerCoord.Y - 4); //dunno why the offset looks better int dust = Dust.NewDust(dustSpawn, 15, 15, 33); //,0f, 0f, 0, new Color(255, 255, 255),1f);//80 is the type } } } //tile.color((byte)Paints.Red); } return(false); }
public override bool PreAI() { npc.defense = Def(); Vector2 chasePosition = Main.npc[(int)npc.ai[1]].Center; Vector2 directionVector = chasePosition - npc.Center; npc.spriteDirection = (directionVector.X > 0f) ? 1 : -1; if (npc.ai[3] > 0) { npc.realLife = (int)npc.ai[3]; } if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead) { npc.TargetClosest(true); } if (Main.player[npc.target].dead && npc.timeLeft > 300) { npc.timeLeft = 300; } if (Main.netMode != 1) { if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != mod.NPCType("GreedA")) { npc.life = 0; npc.HitEffect(0, 10.0); npc.active = false; NetMessage.SendData(28, -1, -1, null, npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0); } } if (npc.ai[1] < (double)Main.npc.Length) { Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float dirX = Main.npc[(int)npc.ai[1]].position.X + Main.npc[(int)npc.ai[1]].width / 2 - npcCenter.X; float dirY = Main.npc[(int)npc.ai[1]].position.Y + Main.npc[(int)npc.ai[1]].height / 2 - npcCenter.Y; npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f; float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY); float dist = (length - npc.width) / length; float posX = dirX * dist; float posY = dirY * dist; if (dirX < 0f) { npc.spriteDirection = 1; } else { npc.spriteDirection = -1; } npc.velocity = Vector2.Zero; npc.position.X = npc.position.X + posX; npc.position.Y = npc.position.Y + posY; } int tileX = (int)(npc.position.X / 16f) - 1; int tileCenterX = (int)(npc.Center.X / 16f) + 2; int tileY = (int)(npc.position.Y / 16f) - 1; int tileCenterY = (int)(npc.Center.Y / 16f) + 2; if (tileX < 0) { tileX = 0; } if (tileCenterX > Main.maxTilesX) { tileCenterX = Main.maxTilesX; } if (tileY < 0) { tileY = 0; } if (tileCenterY > Main.maxTilesY) { tileCenterY = Main.maxTilesY; } for (int tX = tileX; tX < tileCenterX; tX++) { for (int tY = tileY; tY < tileCenterY; tY++) { Tile checkTile = BaseWorldGen.GetTileSafely(tX, tY); if (checkTile != null && ((checkTile.nactive() && (Main.tileSolid[checkTile.type] || (Main.tileSolidTop[checkTile.type] && checkTile.frameY == 0))) || checkTile.liquid > 64)) { Vector2 tPos; tPos.X = tX * 16; tPos.Y = tY * 16; if (npc.position.X + npc.width > tPos.X && npc.position.X < tPos.X + 16f && npc.position.Y + npc.height > tPos.Y && npc.position.Y < tPos.Y + 16f) { if (Main.rand.Next(100) == 0 && checkTile.nactive()) { WorldGen.KillTile(tX, tY, true, true, false); } } } } } if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(true); } if (npc.alpha <= 0) { npc.alpha = 0; return(false); } else { for (int spawnDust = 0; spawnDust < 4; spawnDust++) { int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f);
public override void AI() { Projectile.frameCounter++; if (Projectile.frameCounter > 2) { Projectile.frameCounter = 0; Projectile.frame++; if (Projectile.frame > 3) { Projectile.frame = 0; } } if (--Projectile.ai[0] < 0) { Projectile.Kill(); return; } Lighting.AddLight(Projectile.Center, 1.1f, 0.9f, 0.4f); Projectile.rotation = Projectile.velocity.ToRotation(); if (++Projectile.localAI[0] == 12) //loads of vanilla dust :echprime: { Projectile.localAI[0] = 0.0f; for (int index1 = 0; index1 < 12; ++index1) { Vector2 vector2 = (Vector2.UnitX * (float)-Projectile.width / 2f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 6.0, new Vector2()) * new Vector2(8f, 16f)).RotatedBy((double)Projectile.rotation - 1.57079637050629, new Vector2()); int index2 = Dust.NewDust(Projectile.Center, 0, 0, 6, 0.0f, 0.0f, 160, new Color(), 1f); Main.dust[index2].scale = 1.1f; Main.dust[index2].noGravity = true; Main.dust[index2].position = Projectile.Center + vector2; Main.dust[index2].velocity = Projectile.velocity * 0.1f; Main.dust[index2].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[index2].position) * 1.25f; } } if (Main.rand.NextBool(4)) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index2].velocity *= 0.1f; Main.dust[index2].position = Projectile.Center + vector2 * (float)Projectile.width / 2f; Main.dust[index2].fadeIn = 0.9f; } } if (Main.rand.NextBool(32)) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.392699092626572).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0.0f, 0.0f, 155, new Color(), 0.8f); Main.dust[index2].velocity *= 0.3f; Main.dust[index2].position = Projectile.Center + vector2 * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { Main.dust[index2].fadeIn = 1.4f; } } } if (Main.rand.NextBool()) { for (int index1 = 0; index1 < 2; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.785398185253143).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0.0f, 0.0f, 0, new Color(), 1.2f); Main.dust[index2].velocity *= 0.3f; Main.dust[index2].noGravity = true; Main.dust[index2].position = Projectile.Center + vector2 * (float)Projectile.width / 2f; if (Main.rand.NextBool()) { Main.dust[index2].fadeIn = 1.4f; } } } }
public override void AI() { base.AI(); if (_previousAngle != Angle) { projectile.netUpdate = true; } Owner.heldProj = projectile.whoAmI; if (Vector2.Distance(Center, Owner.Center) >= 16 * 100) { CurrentState = "RETURN"; } if (CurrentAnimation != null) { Width = (int)CurrentAnimation.FrameSize.X; Height = (int)CurrentAnimation.FrameSize.Y; } if (!SetVel) { if (Owner.direction == -1) { Angle = (float)MathHelper.Pi; } Opacity = 0f; Center = Owner.Center - new Vector2(120 * Owner.direction, 24); SetVel = true; } Speed = 8.0f; if (CurrentState == "TURN" && CurrentAnimation.CurrentFrame <= 8) { Speed = 9 - MathHelper.Clamp(CurrentAnimation.CurrentFrame, 0, 8); } else if (CurrentState == "TURN" && CurrentAnimation.CurrentFrame >= 8) { Speed = 0 - MathHelper.Clamp(8 - (CurrentAnimation.CurrentFrame - CurrentAnimation.FrameCount), 0, 8); } TBAPlayer tPlayer = TBAPlayer.Get(Owner); if (IsSpawning) { if (Opacity < 1f) { Opacity += 0.04f; } } if (IsDespawning || IsSpawning) { for (int i = 0; i < 5; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y) + projectile.velocity * 4.5f, 0, 0, 31, 0f, 0f, 100, default, 2f);
public override void AI() { int dustLength = 7; for (int i = 0; i < dustLength; i++) { Dust dust = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.PinkFlame)]; dust.velocity = Vector2.Zero; dust.position -= projectile.velocity / dustLength * (float)i; dust.noGravity = true; dust.scale *= 0.7f; } projectile.localAI[0] += 0.075f; if (projectile.localAI[0] > 8f) { projectile.localAI[0] = 8f; } float rotateIntensity = projectile.localAI[0]; float waveTime = 16f; projectile.ai[0]++; if (projectile.ai[1] == 0) // this part is to fix the offset (it is still slightlyyyy offset) { if (projectile.ai[0] > waveTime * 0.5f) { projectile.ai[0] = 0; projectile.ai[1] = 1; } else { Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(-rotateIntensity)); projectile.velocity = perturbedSpeed; } } else { if (projectile.ai[0] <= waveTime) { Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(rotateIntensity)); projectile.velocity = perturbedSpeed; } else { Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(-rotateIntensity)); projectile.velocity = perturbedSpeed; } if (projectile.ai[0] >= waveTime * 2) { projectile.ai[0] = 0; } } float centerY = projectile.Center.X; float centerX = projectile.Center.Y; float num = 400f; bool home = false; for (int i = 0; i < 200; i++) { if (Main.npc[i].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) { float num1 = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); float num2 = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); float num3 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num1) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num2); if (num3 < num) { num = num3; centerY = num1; centerX = num2; home = true; } } } if (home) { float speed = 25f; Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num4 = centerY - vector35.X; float num5 = centerX - vector35.Y; float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); num6 = speed / num6; num4 *= num6; num5 *= num6; projectile.velocity.X = (projectile.velocity.X * 20f + num4) / 21f; projectile.velocity.Y = (projectile.velocity.Y * 20f + num5) / 21f; return; } }
public override void AI() { Lighting.AddLight(projectile.Center, ((255 - projectile.alpha) * 0.25f) / 255f, ((255 - projectile.alpha) * 0.05f) / 255f, ((255 - projectile.alpha) * 0.05f) / 255f); if (projectile.timeLeft > 90) { projectile.timeLeft = 90; } if (projectile.ai[0] > 7f) { float num296 = 1f; if (projectile.ai[0] == 8f) { num296 = 0.25f; } else if (projectile.ai[0] == 9f) { num296 = 0.5f; } else if (projectile.ai[0] == 10f) { num296 = 0.75f; } projectile.ai[0] += 1f; int num297 = 56; if (Main.rand.NextBool(2)) { for (int num298 = 0; num298 < 1; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1f); if ((num297 == 235 && Main.rand.NextBool(3))) { Main.dust[num299].noGravity = true; Main.dust[num299].scale *= 3f; Dust expr_DBEF_cp_0 = Main.dust[num299]; expr_DBEF_cp_0.velocity.X = expr_DBEF_cp_0.velocity.X * 2f; Dust expr_DC0F_cp_0 = Main.dust[num299]; expr_DC0F_cp_0.velocity.Y = expr_DC0F_cp_0.velocity.Y * 2f; } else { Main.dust[num299].scale *= 1.5f; } Dust expr_DC74_cp_0 = Main.dust[num299]; expr_DC74_cp_0.velocity.X = expr_DC74_cp_0.velocity.X * 1.2f; Dust expr_DC94_cp_0 = Main.dust[num299]; expr_DC94_cp_0.velocity.Y = expr_DC94_cp_0.velocity.Y * 1.2f; Main.dust[num299].scale *= num296; if (num297 == 75) { Main.dust[num299].velocity += projectile.velocity; if (!Main.dust[num299].noGravity) { Main.dust[num299].velocity *= 0.5f; } } } } } else { projectile.ai[0] += 1f; } projectile.rotation += 0.3f * projectile.direction; }
public override void Kill(int timeLeft) { if (projectile.ai[1] == 0) { for (int i = 0; i < 5; i++) { Vector2 vel = new Vector2(Main.rand.NextFloat(-3, 3), Main.rand.NextFloat(-10, -8)); Projectile.NewProjectile(projectile.Center, vel, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 0, 1); } } Main.PlaySound(SoundID.Item14, projectile.position); if (projectile.type == 29) { projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 200; projectile.height = 200; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); } for (int i = 0; i < 50; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 1.4f; } for (int i = 0; i < 80; i++) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f); Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].velocity *= 5f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f); Main.dust[dustIndex].velocity *= 3f; } for (int g = 0; g < 2; g++) { int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[goreIndex].scale = 1.5f; Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f; Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f; } projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 10; projectile.height = 10; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); // 29 470 637 // TODO, tmodloader helper method { int explosionRadius = 3; //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637) { explosionRadius = 7; } int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius); int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius); int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius); int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius); if (minTileX < 0) { minTileX = 0; } if (maxTileX > Main.maxTilesX) { maxTileX = Main.maxTilesX; } if (minTileY < 0) { minTileY = 0; } if (maxTileY > Main.maxTilesY) { maxTileY = Main.maxTilesY; } bool canKillWalls = false; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { float diffX = Math.Abs((float)x - projectile.position.X / 16f); float diffY = Math.Abs((float)y - projectile.position.Y / 16f); double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0) { canKillWalls = true; break; } } } AchievementsHelper.CurrentlyMining = true; for (int i = minTileX; i <= maxTileX; i++) { for (int j = minTileY; j <= maxTileY; j++) { float diffX = Math.Abs((float)i - projectile.position.X / 16f); float diffY = Math.Abs((float)j - projectile.position.Y / 16f); double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY)); if (distanceToTile < (double)explosionRadius) { bool canKillTile = true; if (Main.tile[i, j] != null && Main.tile[i, j].active()) { canKillTile = true; if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404) { canKillTile = false; } if (!Main.hardMode && Main.tile[i, j].type == 58) { canKillTile = false; } if (!TileLoader.CanExplode(i, j)) { canKillTile = false; } if (canKillTile) { WorldGen.KillTile(i, j, false, false, false); if (!Main.tile[i, j].active() && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, "", 0, (float)i, (float)j, 0f, 0, 0, 0); } } } if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall)) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].wall == 0 && Main.netMode != 0) { NetMessage.SendData(17, -1, -1, "", 2, (float)x, (float)y, 0f, 0, 0, 0); } } } } } } } } AchievementsHelper.CurrentlyMining = false; } }
public override void Kill(int timeLeft) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType <CosmicBolt>(), 80, projectile.knockBack, projectile.owner, 0f, 0f); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType <CosmicBolt>(), 80, projectile.knockBack, projectile.owner, 0f, 0f); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType <Fire>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 50; projectile.height = 50; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 133, 0f, 0f, 100, default(Color), 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.Next(2) == 0) { Main.dust[num622].scale = 0.5f; Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 35; num623++) { int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 133, 0f, 0f, 100, default(Color), 3f); Main.dust[num624].scale = .5f; Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 133, 0f, 0f, 100, default(Color), 2f); Main.dust[num624].scale = .5f; Main.dust[num624].velocity *= 2f; } for (int num625 = 0; num625 < 3; num625++) { float scaleFactor10 = 0.33f; if (num625 == 1) { scaleFactor10 = 0.66f; } else if (num625 == 2) { scaleFactor10 = 1f; } int num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Main.gore[num626].velocity.X += 1f; Main.gore[num626].velocity.Y += 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Main.gore[num626].velocity.X -= 1f; Main.gore[num626].velocity.Y += 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Main.gore[num626].velocity.X += 1f; Main.gore[num626].velocity.Y -= 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Main.gore[num626].velocity.X -= 1f; Main.gore[num626].velocity.Y -= 1f; } projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 10; projectile.height = 10; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); }
public override void AI() { if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3) { projectile.tileCollide = false; //projectile.ai[1] = 0f; projectile.alpha = 255; //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637) { projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 250; projectile.height = 250; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); projectile.damage = 250; projectile.knockBack = 10f; } } else { if (Main.rand.Next(2) == 0) { int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1f); Main.dust[dustIndex].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[dustIndex].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default(Vector2)) * 1.1f; dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1f); Main.dust[dustIndex].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[dustIndex].noGravity = true; Main.dust[dustIndex].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default(Vector2)) * 1.1f; } } projectile.ai[0] += 1f; if (projectile.ai[0] > 5f) { projectile.ai[0] = 10f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { projectile.velocity.X = projectile.velocity.X * 0.97f; if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637) { projectile.velocity.X = projectile.velocity.X * 0.99f; } if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01) { projectile.velocity.X = 0f; projectile.netUpdate = true; } } projectile.velocity.Y = projectile.velocity.Y + 0.2f; } projectile.rotation += projectile.velocity.X * 0.1f; if (projectile.velocity.X * 0.1f > 0) { projectile.rotation += Math.Abs(projectile.velocity.Y * 0.01f); } else { projectile.rotation -= Math.Abs(projectile.velocity.Y * 0.01f); } return; }
public override void AI() { Vector2?vector78 = null; if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) { projectile.velocity = -Vector2.UnitY; } int ai1 = (int)projectile.ai[1]; if (Main.npc[ai1].active && (Main.npc[ai1].type == NPCID.MoonLordHand || Main.npc[ai1].type == NPCID.MoonLordHead)) { projectile.Center = Main.npc[ai1].Center; projectile.velocity = Main.npc[ai1].localAI[0].ToRotationVector2(); } else { projectile.Kill(); return; } if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) { projectile.velocity = -Vector2.UnitY; } /*if (projectile.localAI[0] == 0f) * { * Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 104, 1f, 0f); * }*/ float num801 = 0.3f; projectile.localAI[0] += 1f; if (projectile.localAI[0] >= maxTime) { projectile.Kill(); return; } projectile.scale = (float)Math.Sin(projectile.localAI[0] * 3.14159274f / maxTime) * 0.6f * num801; if (projectile.scale > num801) { projectile.scale = num801; } float num804 = projectile.velocity.ToRotation(); projectile.rotation = num804 - 1.57079637f; projectile.velocity = num804.ToRotationVector2(); float num805 = 3f; float num806 = (float)projectile.width; Vector2 samplingPoint = projectile.Center; if (vector78.HasValue) { samplingPoint = vector78.Value; } float[] array3 = new float[(int)num805]; //Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 3000f, array3); for (int i = 0; i < array3.Length; i++) { array3[i] = 3000f; } float num807 = 0f; int num3; for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1) { num807 += array3[num808]; num3 = num808; } num807 /= num805; float amount = 0.5f; projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); for (int num809 = 0; num809 < 2; num809 = num3 + 1) { float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811); int num812 = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default(Color), 1f); Main.dust[num812].noGravity = true; Main.dust[num812].scale = 1.7f; num3 = num809; } if (Main.rand.Next(5) == 0) { Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width; int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default(Color), 1.5f); Dust dust = Main.dust[num813]; dust.velocity *= 0.5f; Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); } //DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); //Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); }
public override void MeleeEffects(Player player, Rectangle rectangle) { int dust = Dust.NewDust(new Vector2((float)rectangle.X, (float)rectangle.Y), rectangle.Width, rectangle.Height, 6, (player.velocity.X * 0.2f) + (player.direction * 3), player.velocity.Y * 0.2f, 100, default, 1.9f);
public override bool PreAI() { projectile.spriteDirection = projectile.direction; projectile.frameCounter++; if (projectile.frameCounter >= 3) { projectile.frame++; projectile.frameCounter = 0; if (projectile.frame >= 2) { projectile.frame = 0; } } projectile.rotation = projectile.velocity.ToRotation() + 1.57F; if (projectile.ai[0] == 0 && Main.netMode != 1) { target = -1; float distance = 2000f; for (int k = 0; k < 255; k++) { if (Main.player[k].active && !Main.player[k].dead) { Vector2 center = Main.player[k].Center; float currentDistance = Vector2.Distance(center, projectile.Center); if (currentDistance < distance || target == -1) { distance = currentDistance; target = k; } } } if (target != -1) { projectile.ai[0] = 1; projectile.netUpdate = true; } } Player targetPlayer = Main.player[target]; Vector2 direction = targetPlayer.Center - projectile.Center; direction.Normalize(); projectile.velocity *= 0.98f; int dust2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6); Main.dust[dust2].noGravity = true; Main.dust[dust2].velocity *= 0f; Main.dust[dust2].velocity *= 0f; Main.dust[dust2].scale = 0.9f; if (Math.Sqrt((projectile.velocity.X * projectile.velocity.X) + (projectile.velocity.Y * projectile.velocity.Y)) < 14f) { if (Main.rand.Next(24) == 1) { direction.X = direction.X * Main.rand.Next(20, 24); direction.Y = direction.Y * Main.rand.Next(20, 24); projectile.velocity.X = direction.X; projectile.velocity.Y = direction.Y; } } return(false); }
public override void AI() { Player player = Main.player[projectile.owner]; float num = 1.57079637f; Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); projectile.ai[0] += 1f; int num2 = 0; if (projectile.ai[0] >= 30f) { num2++; } if (projectile.ai[0] >= 60f) { num2++; } if (projectile.ai[0] >= 90f) { num2++; } int num3 = 24; int num4 = 6; projectile.ai[1] += 1f; bool flag = false; if (projectile.ai[1] >= num3 - num4 * num2) { projectile.ai[1] = 0f; flag = true; } if (projectile.ai[1] == 1f && projectile.ai[0] != 1f) { Vector2 vector2 = Vector2.UnitX * 24f; vector2 = vector2.RotatedBy(projectile.rotation - 1.57079637f, default); Vector2 value = projectile.Center + vector2; for (int i = 0; i < 3; i++) { int num5 = Dust.NewDust(value - Vector2.One * 8f, 16, 16, ModContent.DustType <Dusts.VoidDust>(), projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 100); Main.dust[num5].position.Y -= 0.3f; Main.dust[num5].velocity *= 0.66f; Main.dust[num5].noGravity = true; Main.dust[num5].scale = 1.4f; } } if (flag && Main.myPlayer == projectile.owner) { if (player.channel && !player.noItems && !player.CCed) { float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; Vector2 vector3 = vector; Vector2 value2 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector3; if (player.gravDir == -1f) { value2.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - vector3.Y; } Vector2 vector4 = Vector2.Normalize(value2); if (float.IsNaN(vector4.X) || float.IsNaN(vector4.Y)) { vector4 = -Vector2.UnitY; } vector4 *= scaleFactor; if (vector4.X != projectile.velocity.X || vector4.Y != projectile.velocity.Y) { projectile.netUpdate = true; } projectile.velocity = vector4; float scaleFactor2 = 14f; int num7 = 7; vector3 = projectile.Center + new Vector2(Main.rand.Next(-num7, num7 + 1), Main.rand.Next(-num7, num7 + 1)); Vector2 vector5 = Vector2.Normalize(projectile.velocity) * scaleFactor2; vector5 = vector5.RotatedBy(Main.rand.NextDouble() * 0.19634954631328583 - 0.098174773156642914, default); if (float.IsNaN(vector5.X) || float.IsNaN(vector5.Y)) { vector5 = -Vector2.UnitY; } } } if (player.direction == 1) { projectile.Center = player.Center + new Vector2(10, 0); } if (player.direction == -1) { projectile.Center = player.Center + new Vector2(-18, 0); } projectile.rotation = projectile.velocity.ToRotation() + num; projectile.spriteDirection = projectile.direction; projectile.timeLeft = 2; player.ChangeDir(projectile.direction); player.heldProj = projectile.whoAmI; player.itemTime = 2; player.itemAnimation = 2; player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * projectile.direction, projectile.velocity.X * projectile.direction); counter++; if (counter >= 120) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 93); chargeLevel = 4; } else if (counter >= 80) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 101); chargeLevel = 3; } else if (counter >= 40) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 13); chargeLevel = 2; } else if (counter <= 40) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 13); chargeLevel = 1; } if (!player.channel) { projectile.Kill(); } }
public void loadPlans() { XmlDocument doc = new XmlDocument (); using (FileStream file = new FileStream(Application.dataPath + "/plans.xml",FileMode.Open)) { doc.Load (file); } foreach (XmlNode node in doc.DocumentElement.ChildNodes) { if(node.Name == "plan"){ Plan plan = new Plan(); plan.dif = getDificulty(node.Attributes); List<Dust> dusts = new List<Dust>(); foreach(XmlNode subNode in node.ChildNodes){ if(subNode.Name == "dust"){ Dust dust = new Dust(); dust.key = getDustType(subNode.Attributes); dust.pos = getPos(subNode.InnerText); dusts.Add(dust); } } plan.dusts = dusts.ToArray(); plans.Add(plan); } } }
public override void AI() { if (Projectile.localAI[1] == 100) { DrawColor = new Color(231, 174, 254); } int shadertype = (int)Projectile.localAI[1]; Lighting.AddLight(Projectile.Center, DrawColor.A / 255, DrawColor.G / 255, DrawColor.G / 255); colorlerp += 0.15f; Projectile.localAI[0]++; if (!playedsound) { SoundEngine.PlaySound(SoundID.Item122 with { Volume = 0.5f, Pitch = -0.5f }, Projectile.Center); playedsound = true; } if (Main.rand.NextBool(6)) { if (Main.rand.Next(Projectile.extraUpdates) != 0) { return; } for (int index1 = 0; index1 < 2; ++index1) { float num1 = Projectile.rotation + (float)((Main.rand.Next(2) == 1 ? -1.0 : 1.0) * 1.57079637050629); float num2 = (float)(Main.rand.NextDouble() * 0.800000011920929 + 1.0); Vector2 vector2 = new Vector2((float)Math.Cos((double)num1) * num2, (float)Math.Sin((double)num1) * num2); int index2 = Dust.NewDust(Projectile.Center, 0, 0, 226, vector2.X, vector2.Y, 0, DrawColor, 1f); Main.dust[index2].noGravity = true; Main.dust[index2].scale = 1.2f; Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(shadertype, Main.LocalPlayer); } if (Main.rand.Next(5) != 0) { return; } int index3 = Dust.NewDust(Projectile.Center + Projectile.velocity.RotatedBy(1.57079637050629, new Vector2()) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width - Vector2.One * 4f, 8, 8, 31, 0.0f, 0.0f, 100, DrawColor, 1.5f); Dust dust = Main.dust[index3]; dust.shader = GameShaders.Armor.GetSecondaryShader(shadertype, Main.LocalPlayer); dust.velocity = dust.velocity * 0.5f; Main.dust[index3].velocity.Y = -Math.Abs(Main.dust[index3].velocity.Y); } float num3 = Projectile.velocity.Length(); //take length of initial velocity Vector2 spinningpoint = Vector2.UnitX.RotatedBy(Projectile.ai[0]) * num3; //create a base velocity to modify for actual velocity of projectile Vector2 rotationVector2 = spinningpoint.RotatedBy(Projectile.ai[1] * (Math.Floor(Math.Sin((Projectile.localAI[0] - MathHelper.Pi / 4) * 2)) + 0.5f) * MathHelper.Pi / 4); //math thing for zigzag pattern Projectile.velocity = rotationVector2; Projectile.rotation = Projectile.velocity.ToRotation() + 1.570796f; /*for (int index1 = 1; index1 < Projectile.oldPos.Length; index1++) * { * const int max = 5; * Vector2 offset = Projectile.oldPos[index1 - 1] - Projectile.oldPos[index1]; * offset /= max; * for (int i = 0; i < 5; i++) * { * Vector2 position = Projectile.oldPos[index1] + offset * i; * int index2 = Dust.NewDust(position, Projectile.width, Projectile.height, 160, 0.0f, 0.0f, 0, new Color(), 1f); * Main.dust[index2].scale = Main.rand.Next(70, 110) * 0.013f; * Main.dust[index2].velocity *= 0.2f; * } * }*/ }