sun spriit and vengeful sun pt1

This commit is contained in:
Doze-Zoze committed 2025-11-01 18:26:31 -05:00
1 parent e383a1e202
commit 98d075d8b1
15 files changed
+624 -314

No files matched your search

+3 -3
View File
@@ -1,12 +1,12 @@
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Summon;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Summon
{
public class SolarGodSpiritBuff : BaseSummonBuff
{
protected override int MinionProjectileType => ModContent.ProjectileType<SolarGod>();
protected override int MinionProjectileType => ModContent.ProjectileType<VengefulSunSpiritMinion>();
protected override ref bool MinionBool => ref BuffModdedOwner.SPG;
protected override ref bool MinionBool => ref BuffModdedOwner.vengefulSunMinion;
}
}
+3 -3
View File
@@ -1,12 +1,12 @@
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Summon;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Summon
{
public class SolarSpirit : BaseSummonBuff
{
protected override int MinionProjectileType => ModContent.ProjectileType<SolarPixie>();
protected override int MinionProjectileType => ModContent.ProjectileType<SunSpiritMinion>();
protected override ref bool MinionBool => ref BuffModdedOwner.SP;
protected override ref bool MinionBool => ref BuffModdedOwner.sunSpirit;
}
}
+4 -4
View File
@@ -1449,12 +1449,12 @@ namespace CalamityMod.CalPlayer
public bool brittleStar = false;
public bool aquaticStar = false;
/// <summary> Sun Spirit Staff. </summary>
public bool SP = false;
public bool sunSpirit = false;
public bool dCreeper = false;
public bool eAxe = false;
public bool endoCooper = false;
/// <summary> Vengeful Sun Staff. </summary>
public bool SPG = false;
public bool vengefulSunMinion = false;
public bool sirius = false;
/// <summary> Yharon's Kindle Staff. </summary>
public bool aChicken = false;
@@ -2626,7 +2626,7 @@ namespace CalamityMod.CalPlayer
aSlime = false;
brittleStar = false;
aquaticStar = false;
SP = false;
sunSpirit = false;
dCreeper = false;
eAxe = false;
endoCooper = false;
@@ -2634,7 +2634,7 @@ namespace CalamityMod.CalPlayer
gastricBelcher = false;
hauntedDishes = false;
stormjaw = false;
SPG = false;
vengefulSunMinion = false;
sirius = false;
aChicken = false;
cLamp = false;
+23 -9
View File
@@ -1,4 +1,5 @@
using CalamityMod.Buffs.Summon;
using System.Linq;
using CalamityMod.Buffs.Summon;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
@@ -16,9 +17,9 @@ namespace CalamityMod.Items.Weapons.Summon
{
Item.width = 44;
Item.height = 48;
Item.damage = 12;
Item.damage = 10;
Item.mana = 10;
Item.useAnimation = Item.useTime = 35;
Item.useAnimation = Item.useTime = 10;
Item.useStyle = ItemUseStyleID.Swing;
Item.noMelee = true;
Item.knockBack = 1.15f;
@@ -26,19 +27,32 @@ namespace CalamityMod.Items.Weapons.Summon
Item.rare = ItemRarityID.Blue;
Item.UseSound = SoundID.Item44;
Item.buffType = ModContent.BuffType<SolarSpirit>();
Item.shoot = ModContent.ProjectileType<SolarPixie>();
Item.shoot = ModContent.ProjectileType<SunSpiritMinion>();
Item.DamageType = DamageClass.Summon;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
public override bool CanUseItem(Player player)
{
float minionSlotsAvailable = player.maxMinions;
foreach (var item in Main.ActiveProjectiles)
{
if (item.owner == player.whoAmI)
minionSlotsAvailable -= item.minionSlots;
}
return minionSlotsAvailable >= 1;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
if (player.ownedProjectileCounts[type] > 0)
{
var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI);
p.ai[0]++;
p.netUpdate = true;
return false;
}
player.AddBuff(Item.buffType, 2);
CalamityUtils.KillShootProjectiles(true, type, player);
var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI);
minion.originalDamage = Item.damage;
return false;
return true;
}
public override void AddRecipes()
+23 -9
View File
@@ -1,4 +1,5 @@
using CalamityMod.Buffs.Summon;
using System.Linq;
using CalamityMod.Buffs.Summon;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
@@ -17,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Summon
{
Item.width = 72;
Item.height = 72;
Item.damage = 60;
Item.damage = 30;
Item.mana = 10;
Item.useAnimation = Item.useTime = 25;
Item.useAnimation = Item.useTime = 10;
Item.useStyle = ItemUseStyleID.Swing;
Item.noMelee = true;
Item.knockBack = 1.25f;
@@ -27,19 +28,32 @@ namespace CalamityMod.Items.Weapons.Summon
Item.rare = ItemRarityID.LightPurple;
Item.UseSound = SoundID.Item44;
Item.buffType = ModContent.BuffType<SolarGodSpiritBuff>();
Item.shoot = ModContent.ProjectileType<SolarGod>();
Item.shoot = ModContent.ProjectileType<VengefulSunSpiritMinion>();
Item.DamageType = DamageClass.Summon;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
public override bool CanUseItem(Player player)
{
float minionSlotsAvailable = player.maxMinions;
foreach (var item in Main.ActiveProjectiles)
{
if (item.owner == player.whoAmI)
minionSlotsAvailable -= item.minionSlots;
}
return minionSlotsAvailable >= 1;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
if (player.ownedProjectileCounts[type] > 0)
{
var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI);
p.ai[0]++;
p.netUpdate = true;
return false;
}
player.AddBuff(Item.buffType, 2);
CalamityUtils.KillShootProjectiles(true, type, player);
var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI);
minion.originalDamage = Item.damage;
return false;
return true;
}
public override void AddRecipes()
@@ -333,3 +333,7 @@ FlarebatMinion.DisplayName: Flarebat
FrostbatMinion.DisplayName: Frostbat
AmphibiansGuitarMinion.DisplayName: Amphibian's Guitars
AmphibiansGuitarProjectile.DisplayName: Note
SunSpiritBeam.DisplayName: Sun Spirit Beam
SunSpiritMinion.DisplayName: Sun Spirit Minion
VengefulSunBeam.DisplayName: Vengeful Sun Beam
VengefulSunSpiritMinion.DisplayName: Vengeful Sun Spirit Minion
+2 -2
View File
@@ -1155,7 +1155,7 @@ namespace CalamityMod
sAssociation.Call("AddMinionInfo", summonItem, summonBuff, summonProjectile);
}
RegisterSummon(ItemType<WulfrumController>(), BuffType<WulfrumDroidBuff>(), ProjectileType<WulfrumDroid>());
RegisterSummon(ItemType<SunSpiritStaff>(), BuffType<SolarSpirit>(), ProjectileType<SolarPixie>());
RegisterSummon(ItemType<SunSpiritStaff>(), BuffType<SolarSpirit>(), ProjectileType<SunSpiritMinion>());
RegisterSummon(ItemType<FrostBlossomStaff>(), BuffType<FrostBlossomBuff>(), ProjectileType<FrostBlossom>());
RegisterSummon(ItemType<BelladonnaSpiritStaff>(), BuffType<BelladonnaSpiritBuff>(), ProjectileType<BelladonnaSpirit>());
RegisterSummon(ItemType<StormjawStaff>(), BuffType<BabyStormlionBuff>(), ProjectileType<StormjawBaby>());
@@ -1183,7 +1183,7 @@ namespace CalamityMod
RegisterSummon(ItemType<GlacialEmbrace>(), BuffType<GlacialEmbraceBuff>(), ProjectileType<GlacialEmbracePointyThing>());
RegisterSummon(ItemType<MountedScanner>(), BuffType<MountedScannerBuff>(), ProjectileType<MountedScannerSummon>());
RegisterSummon(ItemType<DeepseaStaff>(), BuffType<AquaticStar>(), ProjectileType<AquaticStarMinion>());
RegisterSummon(ItemType<VengefulSunStaff>(), BuffType<SolarGodSpiritBuff>(), ProjectileType<SolarGod>());
RegisterSummon(ItemType<VengefulSunStaff>(), BuffType<SolarGodSpiritBuff>(), ProjectileType<VengefulSunSpiritMinion>());
RegisterSummon(ItemType<TundraFlameBlossomsStaff>(), BuffType<TundraFlameBlossomsBuff>(), ProjectileType<TundraFlameBlossom>());
RegisterSummon(ItemType<DormantBrimseeker>(), BuffType<BrimseekerBuff>(), ProjectileType<DormantBrimseekerBab>());
RegisterSummon(ItemType<IgneousExaltation>(), BuffType<IgneousExaltationBuff>(), ProjectileType<IgneousBlade>());
+143 -17
View File
@@ -1,46 +1,172 @@
using Microsoft.Xna.Framework;
using System;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class SolarBeam : ModProjectile, ILocalizedModType
public class VengefulSunBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 14;
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.MinionShot[Type] = true;
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = Projectile.height = 4;
Projectile.aiStyle = ProjAIStyleID.Ray;
Projectile.width = 24;
Projectile.height = 24;
Projectile.friendly = true;
Projectile.extraUpdates = 220;
Projectile.timeLeft = 200;
Projectile.timeLeft = 180;
Projectile.DamageType = DamageClass.Summon;
Projectile.MaxUpdates = 2;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 0; //has a custom iframe counter
Projectile.stopsDealingDamageAfterPenetrateHits = true;
}
public override void OnSpawn(IEntitySource source)
{
ProjectileID.Sets.TrailCacheLength[Type] = 8;
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
}
public override void AI()
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 9f)
if (Projectile.ai[0] > 1)
{
for (int i = 0; i < 4; i++)
Projectile.ai[0]--;
Projectile.timeLeft = 120;
}
if (Projectile.ai[0] > 0)
{
var target = Projectile.FindTargetWithinRange(640);
if (target != null)
{
Vector2 dustPos = Projectile.position;
dustPos -= Projectile.velocity * ((float)i * 0.25f);
Projectile.alpha = 255;
int dust = Dust.NewDust(dustPos, 1, 1, DustID.GoldCoin, 0f, 0f, 0, default, 1f);
Main.dust[dust].position = dustPos;
Main.dust[dust].scale = (float)Main.rand.Next(70, 110) * 0.013f;
Main.dust[dust].velocity *= 0.2f;
Projectile.Calamity().HomingTarget = target.whoAmI;
Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), 0.5f*(1-Projectile.ai[0]/120f)).ToRotationVector2() * Projectile.velocity.Length();
}
}
if (Projectile.damage <= 0)
{
Projectile.ai[0] = 0;
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4;
Projectile.timeLeft = (int)MathHelper.Min(8, Projectile.timeLeft);
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
for (int i = 0; i < 12; i++)
{
Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f;
float dustScale = Main.rand.NextFloat(3f, 5f);
Color dustColor = Color.Lerp(Color.OrangeRed, Color.Gold, Main.rand.NextFloat(0.5f, 1f));
Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale);
dust.noGravity = true;
dust.noLight = false;
dust.noLightEmittence = false;
}
if (Projectile.ai[0] > 0)
return;
for (var i = -1; i <= 1; i+=2)
{
var randomVel = Projectile.velocity.RotatedByRandom(MathHelper.TwoPi);
var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(),Projectile.Center- randomVel * 3, randomVel, Type,Projectile.damage,Projectile.knockBack,Projectile.owner, 120);
p.penetrate = 1;
p.scale = 0.75f;
}
Projectile.damage = 0;
Projectile.timeLeft = 10;
Projectile.netUpdate = true;
}
public override void OnKill(int timeLeft)
{
}
public override bool? CanDamage()
{
return Projectile.ai[0] <= 90;
}
public override bool PreDraw(ref Color lightColor) => false;
public float FireWidthFunction(float completion)
{
float width;
float maxBodyWidth = 38f * Projectile.scale;
float curveRatio = 0.2f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireColorFunction(float completion)
{
Color mainColor = Color.Gold * 1.3f;
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion);
}
public float FireCoreWidthFunction(float completion)
{
float width;
float maxBodyWidth = Projectile.scale * 16;
float curveRatio = 0.25f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
if (completion < curveRatio)
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireCoreColorFunction(float completion)
{
Color mainColor = Color.OrangeRed;
Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion);
return Color.Lerp(fullBodyColor, Color.White, 0.175f);
}
public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer)
{
// Render the main trail for the body for the flame.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32);
// Render a smaller, pure white trail in the same position to represent the glowing core of the flame.
Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray();
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SylvestaffStreak"));
PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24);
}
}
}
-133
View File
@@ -1,133 +0,0 @@
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class SolarGod : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override void SetStaticDefaults()
{
Main.projPet[Type] = true;
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 74;
Projectile.height = 90;
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 1f;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft *= 5;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
player.AddBuff(ModContent.BuffType<SolarGodSpiritBuff>(), 3600);
bool correctMinion = Projectile.type == ModContent.ProjectileType<SolarGod>();
if (correctMinion)
{
if (player.dead)
{
modPlayer.SPG = false;
}
if (modPlayer.SPG)
{
Projectile.timeLeft = 2;
}
}
Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f);
if (player.gravDir == -1f)
{
Projectile.position.Y += 120f;
Projectile.rotation = MathHelper.Pi;
}
else
{
Projectile.rotation = 0f;
}
Projectile.position.X = (int)Projectile.position.X;
Projectile.position.Y = (int)Projectile.position.Y;
float sizeScale = (float)Main.mouseTextColor / 200f - 0.35f;
sizeScale *= 0.2f;
Projectile.scale = sizeScale + 0.95f;
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f);
if (Projectile.localAI[0] == 0f)
{
int dustAmt = 50;
for (int d = 0; d < dustAmt; d++)
{
int fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.CopperCoin, 0f, 0f, 0, default, 1f);
Main.dust[fire].velocity *= 2f;
Main.dust[fire].scale *= 1.15f;
}
Projectile.localAI[0] += 1f;
}
if (Projectile.owner == Main.myPlayer)
{
if (Projectile.ai[0] != 0f)
{
Projectile.ai[0] -= 1f;
return;
}
Vector2 targetPos = Projectile.position;
float maxDistance = 700f;
bool foundTarget = false;
if (player.HasMinionAttackTargetNPC)
{
NPC npc = Main.npc[player.MinionAttackTargetNPC];
if (npc.CanBeChasedBy(Projectile, false))
{
float npcDist = Vector2.Distance(Projectile.Center, npc.Center);
if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height))
{
targetPos = npc.Center;
foundTarget = true;
}
}
}
if (!foundTarget)
{
foreach (NPC npc in Main.ActiveNPCs)
{
if (npc.CanBeChasedBy(Projectile, false))
{
float npcDist = Vector2.Distance(Projectile.Center, npc.Center);
if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height))
{
maxDistance = npcDist;
targetPos = npc.Center;
foundTarget = true;
}
}
}
}
if (foundTarget)
{
float shootSpeed = 15f;
Vector2 source = Projectile.Center;
Vector2 velocity = targetPos - source;
velocity.Normalize();
velocity *= shootSpeed;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, velocity, ModContent.ProjectileType<SolarBeam>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
Projectile.ai[0] = 20f;
}
}
}
public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200);
}
}
-134
View File
@@ -1,134 +0,0 @@
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class SolarPixie : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override void SetStaticDefaults()
{
Main.projPet[Type] = true;
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 50;
Projectile.height = 50;
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 1f;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft *= 5;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
player.AddBuff(ModContent.BuffType<SolarSpirit>(), 3600);
bool correctMinion = Projectile.type == ModContent.ProjectileType<SolarPixie>();
if (correctMinion)
{
if (player.dead)
{
modPlayer.SP = false;
}
if (modPlayer.SP)
{
Projectile.timeLeft = 2;
}
}
Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f);
if (player.gravDir == -1f)
{
Projectile.position.Y += 120f;
Projectile.rotation = MathHelper.Pi;
}
else
{
Projectile.rotation = 0f;
}
Projectile.position.X = (int)Projectile.position.X;
Projectile.position.Y = (int)Projectile.position.Y;
float sizeScale = (float)Main.mouseTextColor / 200f - 0.35f;
sizeScale *= 0.2f;
Projectile.scale = sizeScale + 0.95f;
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f);
if (Projectile.localAI[0] == 0f)
{
int dustAmt = 25;
for (int d = 0; d < dustAmt; d++)
{
int fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.CopperCoin, 0f, 0f, 0, default, 1f);
Main.dust[fire].velocity *= 2f;
Main.dust[fire].scale *= 1.15f;
}
Projectile.localAI[0] += 1f;
}
if (Projectile.owner == Main.myPlayer)
{
if (Projectile.ai[0] != 0f)
{
Projectile.ai[0] -= 1f;
return;
}
Vector2 targetPos = Projectile.position;
float maxDistance = 700f;
bool foundTarget = false;
if (player.HasMinionAttackTargetNPC)
{
NPC npc = Main.npc[player.MinionAttackTargetNPC];
if (npc.CanBeChasedBy(Projectile, false))
{
float npcDist = Vector2.Distance(Projectile.Center, npc.Center);
if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height))
{
targetPos = npc.Center;
foundTarget = true;
}
}
}
if (!foundTarget)
{
foreach (NPC npc in Main.ActiveNPCs)
{
if (npc.CanBeChasedBy(Projectile, false))
{
float npcDist = Vector2.Distance(Projectile.Center, npc.Center);
if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height))
{
maxDistance = npcDist;
targetPos = npc.Center;
foundTarget = true;
}
}
}
}
if (foundTarget)
{
float shootSpeed = 30f;
Vector2 source = Projectile.Center;
Vector2 velocity = targetPos - source;
velocity.Normalize();
velocity *= shootSpeed;
Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), source, velocity, ProjectileID.HeatRay, Projectile.damage, Projectile.knockBack, Projectile.owner);
beam.DamageType = DamageClass.Summon;
Projectile.ai[0] = 50f;
}
}
}
public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200);
}
}
+139
View File
@@ -0,0 +1,139 @@
using System;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class SunSpiritBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 14;
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.MinionShot[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 24;
Projectile.height = 24;
Projectile.friendly = true;
Projectile.timeLeft = 180;
Projectile.DamageType = DamageClass.Summon;
Projectile.MaxUpdates = 2;
Projectile.stopsDealingDamageAfterPenetrateHits = true;
}
public override void OnSpawn(IEntitySource source)
{
ProjectileID.Sets.TrailCacheLength[Type] = 8;
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
if (Projectile.damage <= 0)
{
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4;
Projectile.timeLeft = (int)MathHelper.Min(8,Projectile.timeLeft);
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
for (int i = 0; i < 12; i++)
{
Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f;
float dustScale = Main.rand.NextFloat(3f, 5f);
Color dustColor = Color.Lerp(Color.Yellow, Color.Gold, Main.rand.NextFloat(0.5f, 1f));
Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale);
dust.noGravity = true;
dust.noLight = false;
dust.noLightEmittence = false;
}
}
public override void OnKill(int timeLeft)
{
}
public override bool PreDraw(ref Color lightColor) => false;
public float FireWidthFunction(float completion)
{
float width;
float maxBodyWidth = 38f * Projectile.scale;
float curveRatio = 0.2f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
return (width + additionalPulseWidth ) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type] ;
}
public Color FireColorFunction(float completion)
{
Color mainColor = Color.Gold * 1.3f;
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
}
public float FireCoreWidthFunction(float completion)
{
float width;
float maxBodyWidth = Projectile.scale * 16;
float curveRatio = 0.25f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
//completion *= positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
if (completion < curveRatio)
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireCoreColorFunction(float completion)
{
Color mainColor = Color.Gold;
Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion);
return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity;
}
public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer)
{
// Render the main trail for the body for the flame.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32);
// Render a smaller, pure white trail in the same position to represent the glowing core of the flame.
Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray();
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SylvestaffStreak"));
PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24);
}
}
}
+139
View File
@@ -0,0 +1,139 @@
using System.Net.Http.Headers;
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class SunSpiritMinion : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 50;
Projectile.height = 50;
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 1f;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft *= 5;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public int MinionSlotsToAdd
{
get { return (int)Projectile.ai[0]; }
set { Projectile.ai[0] = value; }
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
player.AddBuff(ModContent.BuffType<SolarSpirit>(), 3600);
#region Add Minion Slots
if (MinionSlotsToAdd > 0)
{
float minionSlotsAvaliable = player.maxMinions;
foreach (var item in Main.ActiveProjectiles)
{
if (item.owner == Projectile.owner)
minionSlotsAvaliable -= item.minionSlots;
}
while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0)
{
Projectile.minionSlots++;
minionSlotsAvaliable--;
MinionSlotsToAdd--;
}
MinionSlotsToAdd = 0;
}
#endregion
#region Checking alive
bool correctMinion = Projectile.type == ModContent.ProjectileType<SunSpiritMinion>();
if (correctMinion)
{
if (player.dead)
{
modPlayer.sunSpirit = false;
}
if (modPlayer.sunSpirit)
{
Projectile.timeLeft = 2;
}
}
#endregion
#region Positioning
Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -16f);
#endregion
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f);
NPC target = null;
int targetID = -1;
Projectile.Minion_FindTargetInRange(800, ref targetID, false);
if (targetID < 0)
return;
target = Main.npc[targetID];
if (Projectile.owner == Main.myPlayer)
{
if (Projectile.ai[1] > 0f)
{
Projectile.ai[1] -= 1f;
return;
}
float shootSpeed = 15f;
Vector2 source = Projectile.Center;
var velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, target, shootSpeed, 2);
Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType<SunSpiritBeam>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
beam.DamageType = DamageClass.Summon;
Projectile.ai[1] += 50f / Projectile.minionSlots;
}
}
public override bool? CanDamage() => false;
public static Asset<Texture2D> circle;
public override bool PreDraw(ref Color lightColor)
{
var spTex = TextureAssets.Projectile[Type].Value;
var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value;
Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0);
Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () =>
{
for (var i = 0; i < Projectile.minionSlots && i < 5; i++)
{
var comp = (i / (Projectile.minionSlots));
var offset = ((Main.mouseTextColor - 190) / 64f);
if (i % 2 == 0)
offset = 1 - offset;
Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Lerp(Color.Gold, Color.OrangeRed, i / (4f)), Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.02f + 0.0025f * offset + 0.005f * i, SpriteEffects.None);
}
});
return false;
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 388 B

After

Width:  |  Height:  |  Size: 388 B

@@ -0,0 +1,141 @@
using System;
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class VengefulSunSpiritMinion : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 50;
Projectile.height = 50;
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 1f;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft *= 5;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public int MinionSlotsToAdd
{
get { return (int)Projectile.ai[0]; }
set { Projectile.ai[0] = value; }
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
player.AddBuff(ModContent.BuffType<SolarGodSpiritBuff>(), 3600);
#region Add Minion Slots
if (MinionSlotsToAdd > 0)
{
float minionSlotsAvaliable = player.maxMinions;
foreach (var item in Main.ActiveProjectiles)
{
if (item.owner == Projectile.owner)
minionSlotsAvaliable -= item.minionSlots;
}
while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0)
{
Projectile.minionSlots++;
minionSlotsAvaliable--;
MinionSlotsToAdd--;
}
MinionSlotsToAdd = 0;
}
#endregion
#region Checking alive
bool correctMinion = Projectile.type == ModContent.ProjectileType<VengefulSunSpiritMinion>();
if (correctMinion)
{
if (player.dead)
{
modPlayer.vengefulSunMinion = false;
}
if (modPlayer.vengefulSunMinion)
{
Projectile.timeLeft = 2;
}
}
#endregion
#region Positioning
Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -16f);
#endregion
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f);
NPC target = null;
int targetID = -1;
Projectile.Minion_FindTargetInRange(1600, ref targetID, false);
if (targetID < 0)
return;
target = Main.npc[targetID];
if (Projectile.owner == Main.myPlayer)
{
if (Projectile.ai[1] > 0f)
{
Projectile.ai[1] -= 1f;
return;
}
float shootSpeed = 15f;
Vector2 source = Projectile.Center;
var velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, target, shootSpeed, 2);
Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType<VengefulSunBeam>(), (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)), Projectile.knockBack, Projectile.owner);
beam.DamageType = DamageClass.Summon;
Projectile.ai[1] += 60f / (0.75f + Projectile.minionSlots * 0.25f);
}
}
public override bool? CanDamage() => false;
public static Asset<Texture2D> circle;
public override bool PreDraw(ref Color lightColor)
{
var spTex = TextureAssets.Projectile[Type].Value;
var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/ExtraTextures/GreyscaleOpenCircleButBigger").Value;
Main.spriteBatch.Draw(spTex,Projectile.Center-Main.screenPosition,null,Color.White,Main.GlobalTimeWrappedHourly,spTex.Size()*0.5f, 0.75f,SpriteEffects.None,0);
Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () =>
{
Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Gold, Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.075f, SpriteEffects.None);
float count = MathHelper.Min(Projectile.minionSlots * 2, 20);
for (var i = 0; i < count; i++)
{
var comp = (i / count);
var offset = ((Main.mouseTextColor - 190) / 64f) * 8;
if (i % 2 == 0)
offset = 8 - offset;
CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center + new Vector2(26 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), Projectile.Center + new Vector2(40 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), i % 2 == 0 ? Color.OrangeRed : Color.Gold, 2f);
}
});
return false;
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 945 B

After

Width:  |  Height:  |  Size: 945 B