ToxiTwister p1

This commit is contained in:
Xyk committed 2024-08-05 23:17:20 -07:00
1 parent 22ef3cee08
commit cfd3076ecb
5 files changed
+212 -166

No files matched your search

+26 -9
View File
@@ -5,6 +5,7 @@ using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.GameContent.Bestiary.IL_BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions;
namespace CalamityMod.Items.Weapons.Rogue
{
@@ -14,16 +15,16 @@ namespace CalamityMod.Items.Weapons.Rogue
{
Item.width = 42;
Item.height = 46;
Item.damage = 333;
Item.damage = 150;
Item.noMelee = true;
Item.noUseGraphic = true;
Item.useAnimation = Item.useTime = 20;
Item.useAnimation = Item.useTime = 50;
Item.useStyle = ItemUseStyleID.Swing;
Item.knockBack = 5f;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<ToxicantTwisterTwoPointZero>();
Item.shootSpeed = 18f;
Item.shoot = ModContent.ProjectileType<ToxicantTwisterProj>();
Item.shootSpeed = 20f;
Item.DamageType = RogueDamageClass.Instance;
Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice;
@@ -34,14 +35,30 @@ namespace CalamityMod.Items.Weapons.Rogue
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float angle1 = MathHelper.ToRadians(20f);
if (player.Calamity().StealthStrikeAvailable())
{
int boomer = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI);
if (boomer.WithinBounds(Main.maxProjectiles))
Main.projectile[boomer].Calamity().stealthStrike = true;
return false;
for (int i = 0; i < 2; i++)
{
int proj = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle1), type, damage, knockback, player.whoAmI, 0, 0, 0 + i);
int proj2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle1 * 0.5f) * 0.9f, type, damage, knockback, player.whoAmI, 0, 0, 2 + i);
angle1 *= -1;
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().stealthStrike = true;
if (proj2.WithinBounds(Main.maxProjectiles))
Main.projectile[proj2].Calamity().stealthStrike = true;
}
}
return true;
else
{
for (int i = 0; i < 2; i++)
{
int proj = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle1), type, damage, knockback, player.whoAmI, 0, 0, 0 + i);
int proj2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(angle1 * 0.5f) * 0.9f, type, damage, knockback, player.whoAmI, 0, 0, 2 + i);
angle1 *= -1;
}
}
return false;
}
}
}
@@ -312,7 +312,7 @@ TotalityFlask.DisplayName: Totality Flask
TotalityTar.DisplayName: Totality Tar
TotalMeltdown.DisplayName: Explosion
ToxicantTwisterDust.DisplayName: Toxicant Dust
ToxicantTwisterTwoPointZero.DisplayName: Toxicant Twister
ToxicantTwisterProj.DisplayName: Toxicant Twister
TurbulanceProjectile.DisplayName: Turbulance
TurbulanceWindSlash.DisplayName: Wind Slash
TwistingThunderProj.DisplayName: Twisting Thunder
+60 -5
View File
@@ -1,7 +1,14 @@
using CalamityMod.Buffs.DamageOverTime;
using System;
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Dusts;
using CalamityMod.Particles;
namespace CalamityMod.Projectiles.Rogue
{
@@ -18,20 +25,68 @@ namespace CalamityMod.Projectiles.Rogue
Projectile.tileCollide = true;
Projectile.ignoreWater = true;
Projectile.penetrate = 1;
Projectile.extraUpdates = 2;
Projectile.timeLeft = 180;
Projectile.DamageType = RogueDamageClass.Instance;
}
public override void AI()
{
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.UnusedBrown, 0f, 0f, 100, default, 1f);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 0f;
Player Owner = Main.player[Projectile.owner];
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
if (Projectile.ai[1] % 2 == 0 && targetDist < 1400)
{
Particle spark = new GlowSparkParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-2, -1), -Projectile.velocity * 0.3f, false, 5, 0.04f, Color.Lerp(Color.Green, Color.Chartreuse, 0.8f) * 0.65f, new Vector2(1, 0.3f), true, false, 1.5f);
GeneralParticleHandler.SpawnParticle(spark);
}
Projectile.rotation += 0.2f;
NPC target = (Projectile.ai[1] > 90) ? Projectile.Center.ClosestNPCAt(1200) : null;
float moveSpeed = Utils.GetLerpValue(200, 0, Projectile.timeLeft);
if (target == null)
{
Vector2 position = (Owner.Calamity().mouseWorld + ((new Vector2(0, -250).RotatedBy(Projectile.rotation * 0.2f)).RotatedBy(MathHelper.ToRadians(90f) * Projectile.ai[2])));
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 8)
Projectile.velocity += moveToMouse * (0.7f);
else
Projectile.velocity *= 0.9f;
}
else
{
Vector2 position = target.Center;
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 13 * moveSpeed)
Projectile.velocity += moveToMouse * moveSpeed;
else
Projectile.velocity *= 0.9f;
if (Projectile.ai[1] % 2 == 0)
Projectile.timeLeft++; // Lasts longer if it has a target
}
if (target != null && target.life <= 0)
target = null;
Projectile.ai[1]++;
}
public override void OnKill(int timeLeft)
{
for (int i = 0; i <= 2; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.SulphurousSeaAcid, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(1.3f, 1.8f));
dust.noGravity = true;
}
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
return true;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 120);
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 40, targetHitbox);
}
}
+125
View File
@@ -0,0 +1,125 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ToxicantTwisterProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ToxicantTwister";
private int targetIndex = -1;
public float circleRange = -150;
public float circleSpeed = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 42;
Projectile.height = 46;
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.extraUpdates = 1;
Projectile.timeLeft = 300;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates;
}
public override void AI()
{
Player Owner = Main.player[Projectile.owner];
if (Projectile.Calamity().stealthStrike)
{
Projectile.extraUpdates = 2;
if (Projectile.ai[1] == 0)
{
Projectile.timeLeft = 600;
circleRange *= 5;
circleSpeed *= 3;
}
if (Projectile.timeLeft % 30 == 0)
{
Projectile dustProjectile = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.1f) * -0.6f, ModContent.ProjectileType<ToxicantTwisterDust>(), (int)(Projectile.damage * 0.25), 0f, Projectile.owner, 0, 0, Projectile.ai[2]);
dustProjectile.timeLeft = 240;
}
}
if (Main.rand.NextBool(5) && Projectile.ai[1] > 7)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(13, 13), (int)CalamityDusts.SulphurousSeaAcid);
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.9f, 1.3f) * Utils.GetLerpValue(255, 0, Projectile.alpha);
dust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.7f);
}
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
if (Projectile.ai[1] % 2 == 0 && Projectile.ai[1] > 7 && targetDist < 1400)
{
Particle spark = new GlowSparkParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-2, -1), -Projectile.velocity * 0.3f, false, 6, 0.07f, Color.Lerp(Color.Green, Color.Chartreuse, 0.8f) * 0.65f, new Vector2(1, 0.3f), true, false, 1);
GeneralParticleHandler.SpawnParticle(spark);
}
// Boomerang rotation
Projectile.rotation += 0.5f / circleSpeed;
if (Projectile.ai[1] > 20f)
{
Vector2 position = (Owner.Calamity().mouseWorld + ((new Vector2(0, circleRange).RotatedBy(Projectile.rotation * 0.2f)).RotatedBy(MathHelper.ToRadians(90f) * Projectile.ai[2])));
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 18)
Projectile.velocity += moveToMouse * circleSpeed;
else
Projectile.velocity *= 0.9f;
}
else
{
Projectile.velocity *= 0.985f;
}
Projectile.ai[1]++;
}
public override void OnKill(int timeLeft)
{
for (int i = 0; i <= 5; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.SulphurousSeaAcid, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(1.3f, 1.8f));
dust.noGravity = true;
}
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
for (int i = 0; i < 3; i++)
{
Color auraColor = Color.Lerp(Color.Chartreuse, Color.Lime, Utils.GetLerpValue(0, 3, i)) * 0.7f;
Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 27f).ToRotationVector2();
rotationalDrawOffset *= MathHelper.Lerp(3f, 5.25f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 15f) * 0.5f + 1f);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + rotationalDrawOffset, null, auraColor with { A = 0 } * Utils.GetLerpValue(255, 0, Projectile.alpha), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None);
}
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor * 0.3f, 2);
return true;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 55, targetHitbox);
}
}
@@ -1,151 +0,0 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ToxicantTwisterTwoPointZero : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ToxicantTwister";
private int lifeTime = 300;
private int targetIndex = -1;
public override void SetDefaults()
{
Projectile.width = 42;
Projectile.height = 46;
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.timeLeft = lifeTime;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 12;
}
public override void AI()
{
if (Projectile.Calamity().stealthStrike)
{
if (Projectile.timeLeft % 20 == 0 && Main.myPlayer == Projectile.owner)
{
for (int i = 0; i < 2; i++)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.1f) * -0.6f, ModContent.ProjectileType<ToxicantTwisterDust>(), (int)(Projectile.damage * 0.25), 0f, Projectile.owner);
}
Projectile.rotation += 0.06f * (Projectile.velocity.X > 0).ToDirectionInt();
}
// Boomerang rotation
Projectile.rotation += 0.4f * Projectile.direction;
// Boomerang sound
if (Projectile.soundDelay == 0)
{
Projectile.soundDelay = 8;
SoundEngine.PlaySound(SoundID.Item7, Projectile.position);
}
Projectile.ai[1]++;
if (Projectile.ai[0] != 0f)
{
float returnSpeed = 30f;
float acceleration = 1.4f;
Player owner = Main.player[Projectile.owner];
// Delete the projectile if it's excessively far away.
Vector2 projVector = owner.Center - Projectile.Center;
float dist = projVector.Length();
if (dist > 3000f)
Projectile.Kill();
dist = returnSpeed / dist;
projVector.X *= dist;
projVector.Y *= dist;
// Home back in on the player.
if (Projectile.velocity.X < projVector.X)
{
Projectile.velocity.X += acceleration;
if (Projectile.velocity.X < 0f && projVector.X > 0f)
Projectile.velocity.X += acceleration;
}
else if (Projectile.velocity.X > projVector.X)
{
Projectile.velocity.X -= acceleration;
if (Projectile.velocity.X > 0f && projVector.X < 0f)
Projectile.velocity.X -= acceleration;
}
if (Projectile.velocity.Y < projVector.Y)
{
Projectile.velocity.Y += acceleration;
if (Projectile.velocity.Y < 0f && projVector.Y > 0f)
Projectile.velocity.Y += acceleration;
}
else if (Projectile.velocity.Y > projVector.Y)
{
Projectile.velocity.Y -= acceleration;
if (Projectile.velocity.Y > 0f && projVector.Y < 0f)
Projectile.velocity.Y -= acceleration;
}
// Delete the projectile if it touches its owner.
if (Main.myPlayer == Projectile.owner)
if (Projectile.Hitbox.Intersects(owner.Hitbox))
Projectile.Kill();
}
else if (Projectile.ai[1] > 40f)
{
NPC closestTarget = Projectile.Center.ClosestNPCAt(1769f, true, true);
if (closestTarget != null)
{
Projectile.extraUpdates = 1;
targetIndex = closestTarget.whoAmI;
float inertia = 20f;
float homingVelocity = Projectile.Calamity().stealthStrike ? 30f : 20f;
Vector2 moveDirection = Projectile.SafeDirectionTo(closestTarget.Center, Vector2.UnitY);
Projectile.velocity = (Projectile.velocity * inertia + moveDirection * homingVelocity) / (inertia + 1f);
}
}
else
{
Projectile.velocity *= 0.985f;
}
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Projectile.ai[1] <= 40f && Projectile.ai[0] != 1f)
{
modifiers.SourceDamage *= 0.3333f;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (targetIndex == target.whoAmI)
Projectile.ai[0] = 1f;
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
for (int k = 0; k < 10; k++)
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
Projectile.ai[0] = 1f;
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
for (int k = 0; k < 10; k++)
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
}
}
}