public override void PostAI() { projectile.netUpdate = true; player = Main.player[projectile.owner]; FinalChargeLimit = ChargeLimit + MyPlayer.ModPlayer(player).ChargeLimitAdd; if (!ChargeBall) { projectile.scale = projectile.scale + ChargeLevel; } if (BeamTrail && projectile.scale > 0 && SizeTimer > 0) { SizeTimer = 120; SizeTimer--; projectile.scale = (projectile.scale * SizeTimer / 120f); } if (ChargeBall) { if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } projectile.hide = true; if (projectile.timeLeft < 4) { projectile.timeLeft = 10; } projectile.position.X = player.Center.X + (player.direction * 20 + xoffset) - 5; projectile.position.Y = player.Center.Y - 3 + yoffset; projectile.netUpdate2 = true; if (!player.channel && ChargeLevel < 1) { projectile.Kill(); } // if the player is channeling, increment the timer and apply some slowdown if (player.channel && projectile.active) { ChargeTimer++; ProjectileUtil.ApplyChannelingSlowdown(player); } //ChargeTimerMax -= MyPlayer.ModPlayer(player).chargeTimerMaxAdd; if (ChargeTimer > ChargeTimerMax && ChargeLevel < FinalChargeLimit) { ChargeLevel += 1; CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), new Color(51, 204, 255), ChargeLevel, false, false); ChargeTimer = 0; } if (DBZMOD.IsTickRateElapsed(2) && !MyPlayer.ModPlayer(player).IsKiDepleted()) { MyPlayer.ModPlayer(player).AddKi(-KiDrainRate, true, false); } for (int d = 0; d < 4; d++) { float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.position + (position * (10 + 2.0f * projectile.scale)), projectile.width, projectile.height, DustType, 0f, 0f, 213, default(Color), ballscale); tDust.velocity = Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2; tDust.noGravity = true; } } }
public override void AI() { Player player = Main.player[projectile.owner]; if (!isInitialized) { HeldTime = 1; isInitialized = true; } // cancel channeling if the projectile is maxed if (player.channel && projectile.scale > 2.5) { player.channel = false; } if (player.channel && HeldTime > 0) { projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime; Vector2 projectileOffset = new Vector2(-projectile.width * 0.5f, -projectile.height * 0.5f); projectileOffset += new Vector2(0, -(80 + projectile.scale * 115f)); projectile.position = player.Center + projectileOffset; HeldTime++; projectile.netUpdate = true; //Rock effect projectile.ai[1]++; if (projectile.ai[1] % 7 == 0) { Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("StoneBlockDestruction"), projectile.damage, 0f, projectile.owner); } Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("DirtBlockDestruction"), projectile.damage, 0f, projectile.owner); if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } projectile.netUpdate2 = true; MyPlayer.ModPlayer(player).AddKi(-2, true, false); ProjectileUtil.ApplyChannelingSlowdown(player); // depleted check, release the ball if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } int soundtimer = 0; soundtimer++; if (soundtimer > 120) { SoundUtil.PlayCustomSound("Sounds/SuperNovaCharge", player, 0.6f); soundtimer = 0; } } else if (HeldTime > 0) { HeldTime = 0; projectile.timeLeft = (int)Math.Ceiling(projectile.scale * 15) + 600; projectile.velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * 6; projectile.tileCollide = false; projectile.damage *= (int)Math.Ceiling(projectile.scale * 3f); SoundUtil.PlayCustomSound("Sounds/SuperNovaThrow", player, 0.6f); } }
public override void AI() { Player player = Main.player[projectile.owner]; if (!isInitialized) { HeldTime = 1; isInitialized = true; } if (player.channel && HeldTime > 0) { projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime; projectile.position = player.Center + new Vector2(0, -40 - (projectile.scale * 17)); HeldTime++; // reduced from 25. for (int d = 0; d < 15; d++) { // loop hitch for variance. if (Main.rand.NextFloat() < 0.3f) { continue; } float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.position + (position * (20 + 12.5f * projectile.scale)), projectile.width, projectile.height, 230, 0f, 0f, 213, default(Color), 2.0f); tDust.velocity = Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2; tDust.noGravity = true; } //Rock effect if (DBZMOD.IsTickRateElapsed(10) && rocksFloating < MAX_ROCKS) { // only some of the time, keeps it a little more varied. if (Main.rand.NextFloat() < 0.6f) { rocksFloating++; BaseFloatingDestructionProj.SpawnNewFloatingRock(player, projectile); } } projectile.netUpdate = true; if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } MyPlayer.ModPlayer(player).AddKi(-5, true, false); ProjectileUtil.ApplyChannelingSlowdown(player); projectile.netUpdate2 = true; // depleted check, release the ball if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } int soundtimer = 0; soundtimer++; if (soundtimer > 120) { SoundUtil.PlayCustomSound("Sounds/SpiritBombCharge", player, 0.5f); soundtimer = 0; } } else if (HeldTime > 0) { HeldTime = 0; projectile.timeLeft = (int)Math.Ceiling(projectile.scale * 15) + 600; projectile.velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * 2.8f; projectile.tileCollide = false; projectile.damage *= (int)projectile.scale / 2; SoundUtil.PlayCustomSound("Sounds/SpiritBombFire", player); } }
public void HandleChargingKi(Player player) { bool IsCharging = false; FinalChargeLimit = ChargeLimit + MyPlayer.ModPlayer(player).ChargeLimitAdd; // stop channeling if the player is out of ki if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } // keep alive routine. if (projectile.timeLeft < 4) { projectile.timeLeft = 10; } MyPlayer modPlayer = MyPlayer.ModPlayer(player); // The energy in the projectile decays if the player stops channeling. if (!player.channel && !modPlayer.IsMouseRightHeld && !IsSustainingFire) { // kill the tracked charge sound if the player let go, immediately ChargeSoundSlotId = SoundUtil.KillTrackedSound(ChargeSoundSlotId); if (ChargeLevel > 0f) { ChargeLevel = Math.Max(0, ChargeLevel - DecayRate()); // don't draw the ball when firing. if (!IsSustainingFire) { ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, DecayDustFrequency, true, ChargeSize.ToVector2()); } } else { // the charge level zeroed out, kill the projectile. projectile.Kill(); } } // charge the ball if the proper keys are held. // increment the charge timer if channeling and apply slowdown effect if (player.channel && projectile.active && modPlayer.IsMouseRightHeld && !IsSustainingFire) { // the player can hold the charge all they like once it's fully charged up. Currently this doesn't incur a movespeed debuff either. if (ChargeLevel < FinalChargeLimit && !modPlayer.IsKiDepleted()) { IsCharging = true; // drain ki from the player when charging if (DBZMOD.IsTickRateElapsed(CHARGE_KI_DRAIN_WINDOW)) { MyPlayer.ModPlayer(player).AddKi(-ChargeKiDrainRate(), true, false); } // increase the charge ChargeLevel = Math.Min(FinalChargeLimit, ChargeRate() + ChargeLevel); // slow down the player while charging. ProjectileUtil.ApplyChannelingSlowdown(player); // shoot some dust into the ball to show it's charging, and to look cool. if (!IsSustainingFire) { ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, ChargeDustFrequency, false, ChargeSize.ToVector2()); } } } // play the sound if the player just started charging and the audio is "off cooldown" if (!WasCharging && IsCharging && ChargeSoundCooldown == 0f) { if (!Main.dedServ) { ChargeSoundSlotId = SoundUtil.PlayCustomSound(ChargeSoundKey, projectile.Center); } ChargeSoundCooldown = ChargeSoundDelay; } else { ChargeSoundCooldown = Math.Max(0f, ChargeSoundCooldown - 1); } // set the wasCharging flag for proper tracking WasCharging = IsCharging; }
public override void AI() { Player player = Main.player[projectile.owner]; if (!isInitialized) { HeldTime = 1; isInitialized = true; } // cancel channeling if the projectile is maxed if (player.channel && projectile.scale > 3.0) { player.channel = false; } if (player.channel && HeldTime > 0) { projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime; Vector2 projectileOffset = new Vector2(-projectile.width * 0.5f, -projectile.height * 0.5f); projectileOffset += new Vector2(0, -(80 + projectile.scale * 115f)); Vector2 projectileOuter = new Vector2(projectile.scale * projectile.width, projectile.scale * projectile.height) / 2f; projectile.position = player.Center + projectileOffset; HeldTime++; for (int d = 0; d < 25; d++) { float angle = Main.rand.NextFloat(360); float angleRad = MathHelper.ToRadians(angle); Vector2 dustPosition = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad)); Dust tDust = Dust.NewDustDirect(projectile.Center + (dustPosition * projectileOuter) + projectileOffset, projectile.width, projectile.height, 15, 0f, 0f, 213, default(Color), 2.0f); tDust.velocity = Vector2.Normalize((projectile.Center + projectile.Size / 2f) - tDust.position) * 2; tDust.noGravity = true; } //Rock effect projectile.ai[1]++; if (projectile.ai[1] % 7 == 0) { Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("StoneBlockDestruction"), projectile.damage, 0f, projectile.owner); } Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("DirtBlockDestruction"), projectile.damage, 0f, projectile.owner); projectile.netUpdate = true; if (projectile.timeLeft < 399) { projectile.timeLeft = 400; } MyPlayer.ModPlayer(player).AddKi(-2, true, false); ProjectileUtil.ApplyChannelingSlowdown(player); projectile.netUpdate2 = true; // depleted check, release the ball if (MyPlayer.ModPlayer(player).IsKiDepleted()) { player.channel = false; } } else if (HeldTime > 0) { HeldTime = 0; projectile.timeLeft = (int)Math.Ceiling(projectile.scale * 15) + 600; projectile.velocity = Vector2.Normalize(Main.MouseWorld - player.Center) * 6; projectile.tileCollide = false; projectile.damage *= (int)Math.Ceiling(projectile.scale * 4f); } }