1 - Balanced Cinder Blossom Staff.
2 - Flower dust effect on hit. 3 - Restructured code.
This commit is contained in:
1 parent
b734538b5e
commit
19c19c20e8
3 files changed
+81
-57
No files matched your search
@@ -19,19 +19,22 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 25;
|
||||
Item.damage = 16;
|
||||
Item.knockBack = 2f;
|
||||
Item.mana = 10;
|
||||
|
||||
Item.shoot = ModContent.ProjectileType<CinderBlossom>();
|
||||
|
||||
Item.width = 50;
|
||||
Item.height = 56;
|
||||
Item.useTime = Item.useAnimation = 30;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 2f;
|
||||
Item.value = CalamityGlobalItem.Rarity3BuyPrice;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.UseSound = SoundID.Item34;
|
||||
Item.shoot = ModContent.ProjectileType<CinderBlossom>();
|
||||
|
||||
Item.DamageType = DamageClass.Summon;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.UseSound = SoundID.Item34;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.value = CalamityGlobalItem.Rarity3BuyPrice;
|
||||
Item.noMelee = true;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
@@ -19,16 +20,18 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 12;
|
||||
Projectile.height = 12;
|
||||
Projectile.friendly = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.idStaticNPCHitCooldown = 10;
|
||||
Projectile.penetrate = 3;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 10;
|
||||
Projectile.minion = true;
|
||||
|
||||
Projectile.width = 12;
|
||||
Projectile.height = 12;
|
||||
|
||||
Projectile.DamageType = DamageClass.Summon;
|
||||
Projectile.friendly = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.minion = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
@@ -48,6 +51,28 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.OnFire, 180);
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
int flowerPetalCount = Main.rand.Next(3, 5 + 1);
|
||||
float thetaDelta = Projectile.velocity.ToRotation();
|
||||
float weaveDistanceMin = 2f;
|
||||
float weaveDistanceOutwardMax = 3f;
|
||||
float weaveDistanceInner = 0.5f;
|
||||
for (float theta = 0f; theta < MathHelper.TwoPi; theta += 0.05f)
|
||||
{
|
||||
Vector2 velocity = theta.ToRotationVector2() *
|
||||
(weaveDistanceMin +
|
||||
// The 0.5 in here is to prevent the petal from looping back into itself. With a 0.5 addition, it is perfect, coming back to (0,0)
|
||||
// instead of weaving backwards.
|
||||
(float)(Math.Sin(thetaDelta + theta * flowerPetalCount) + 0.5f + weaveDistanceInner) *
|
||||
weaveDistanceOutwardMax);
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Torch, velocity);
|
||||
dust.noGravity = true;
|
||||
dust.scale = 1.35f;
|
||||
}
|
||||
// Makes an orange flower made out of dust when it hits a target.
|
||||
|
||||
target.AddBuff(BuffID.OnFire, 180);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,10 @@ namespace CalamityMod.Projectiles.Summon
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
public CalamityPlayer moddedOwner => Owner.Calamity();
|
||||
|
||||
public float DelayBetweenShooting
|
||||
{
|
||||
get => Projectile.ai[0];
|
||||
set => Projectile.ai[0] = value;
|
||||
}
|
||||
|
||||
public ref float DelayBetweenShooting => ref Projectile.ai[0];
|
||||
|
||||
public bool CheckForSpawning = false;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
@@ -28,70 +26,48 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.minionSlots = 1f;
|
||||
Projectile.penetrate = -1;
|
||||
|
||||
Projectile.width = 42;
|
||||
Projectile.height = 42;
|
||||
|
||||
Projectile.DamageType = DamageClass.Summon;
|
||||
Projectile.netImportant = true;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.minionSlots = 1f;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.minion = true;
|
||||
Projectile.DamageType = DamageClass.Summon;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CheckMinionExistance(); // Checks if the minion can still exist.
|
||||
EffectWhenSpawned(); // Makes a dust effect when it spawns
|
||||
|
||||
NPC potentialTarget = Projectile.Center.MinionHoming(1200f, Owner);
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
if (potentialTarget != null)
|
||||
{
|
||||
if (DelayBetweenShooting == 35f) // Shoots once every 35 frames.
|
||||
{
|
||||
Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, potentialTarget, 20f);
|
||||
int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<Cinder>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
|
||||
if (Main.projectile.IndexInRange(p))
|
||||
Main.projectile[p].originalDamage = Projectile.originalDamage;
|
||||
|
||||
DelayBetweenShooting = 0f;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
if (DelayBetweenShooting < 35f)
|
||||
DelayBetweenShooting++;
|
||||
}
|
||||
}
|
||||
CheckMinionExistince(); // Checks if the minion can still exist.
|
||||
EffectWhenSpawned(); // Makes a dust effect when it spawns
|
||||
ShootTarget(potentialTarget); // Shoots at the target if there's one.
|
||||
|
||||
Projectile.Center = Owner.Center - Vector2.UnitY * 60f;
|
||||
Projectile.rotation += MathHelper.ToRadians((potentialTarget is not null) ? 3f * (potentialTarget.Center.X - Projectile.Center.X > 0).ToDirectionInt() : 1.5f * Owner.direction);
|
||||
// The projectile normally will spin in the direction of the player.
|
||||
// If an enemy is detected, it will spin faster, in the direction of where the enemy is.
|
||||
Projectile.rotation += MathHelper.ToRadians(5f * Owner.direction); // The projectile normally will spin in the direction of the player.
|
||||
Lighting.AddLight(Projectile.Center, Color.Orange.ToVector3());
|
||||
}
|
||||
|
||||
public void CheckMinionExistance()
|
||||
public void CheckMinionExistince()
|
||||
{
|
||||
Owner.AddBuff(ModContent.BuffType<CinderBlossomBuff>(), 1);
|
||||
if (Projectile.type == ModContent.ProjectileType<CinderBlossom>())
|
||||
{
|
||||
if (Owner.dead)
|
||||
{
|
||||
moddedOwner.cinderBlossom = false;
|
||||
}
|
||||
if (moddedOwner.cinderBlossom)
|
||||
{
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EffectWhenSpawned()
|
||||
{
|
||||
if (Projectile.localAI[0] == 0f)
|
||||
if (CheckForSpawning == false)
|
||||
{
|
||||
for (int i = 0; i < 36; i++)
|
||||
{
|
||||
@@ -99,7 +75,27 @@ namespace CalamityMod.Projectiles.Summon
|
||||
dust.noGravity = true;
|
||||
dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f, 6f);
|
||||
}
|
||||
Projectile.localAI[0] = 1f;
|
||||
CheckForSpawning = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShootTarget(NPC target)
|
||||
{
|
||||
if (target != null && Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
if (DelayBetweenShooting == 35f) // Shoots once every 35 frames.
|
||||
{
|
||||
Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, target, 20f);
|
||||
int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<Cinder>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
|
||||
if (Main.projectile.IndexInRange(p))
|
||||
Main.projectile[p].originalDamage = Projectile.originalDamage;
|
||||
|
||||
DelayBetweenShooting = 0f;
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
if (DelayBetweenShooting < 35f)
|
||||
DelayBetweenShooting++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user