This commit is contained in:
mountaindrew10 committed 2023-06-09 21:12:56 -05:00
commit 2fbffcf8a3
30 files changed
+1127

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
using CalamityMod.CalPlayer;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Summon
{
public class KingofConstellationsBuff : ModBuff
{
public override void SetStaticDefaults()
{
Main.buffNoTimeDisplay[Type] = true;
Main.buffNoSave[Type] = true;
}
public override void Update(Player player, ref int buffIndex)
{
CalamityPlayer modPlayer = player.Calamity();
if (player.ownedProjectileCounts[ModContent.ProjectileType<BlackDragonHead>()] > 0 || player.ownedProjectileCounts[ModContent.ProjectileType<WhiteDragonHead>()] > 0)
{
modPlayer.celestialDragons = true;
}
if (!modPlayer.celestialDragons)
{
player.DelBuff(buffIndex);
buffIndex--;
}
else
{
player.buffTime[buffIndex] = 18000;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

+2
View File
@@ -971,6 +971,7 @@ namespace CalamityMod.CalPlayer
public bool perditionBeacon = false;
public bool MoonFist = false;
public bool AresCannons = false;
public bool celestialDragons = false;
public List<DeadMinionProperties> PendingProjectilesToRespawn = new List<DeadMinionProperties>();
@@ -2001,6 +2002,7 @@ namespace CalamityMod.CalPlayer
perditionBeacon = false;
MoonFist = false;
AresCannons = false;
celestialDragons = false;
disableVoodooSpawns = false;
disablePerfCystSpawns = false;
+52
View File
@@ -0,0 +1,52 @@
using Terraria.DataStructures;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class DeepcoreGK2 : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Ranged";
public override void SetDefaults()
{
Item.damage = 45;
Item.ArmorPenetration = 15;
Item.DamageType = DamageClass.Ranged;
Item.noMelee = true;
Item.width = 142;
Item.height = 64;
Item.useTime = Item.useAnimation = 16;
Item.useStyle = ItemUseStyleID.Shoot;
Item.knockBack = 7f;
Item.value = CalamityGlobalItem.Rarity5BuyPrice;
Item.rare = ItemRarityID.Pink;
Item.UseSound = SoundID.Item38;
Item.autoReuse = true;
Item.shoot = ProjectileID.Bullet;
Item.shootSpeed = 20f;
Item.useAmmo = AmmoID.Bullet;
Item.Calamity().donorItem = true;
Item.Calamity().canFirePointBlankShots = true;
}
public override Vector2? HoldoutOffset() => new Vector2(-20, 0);
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Vector2 shootDirection = velocity.SafeNormalize(Vector2.UnitX * player.direction);
Vector2 gunTip = position + shootDirection * Item.scale * 120f;
gunTip.Y -= 18f;
int p = Projectile.NewProjectile(source, gunTip, velocity, type, damage, knockback, player.whoAmI);
if (p.WithinBounds(Main.maxProjectiles))
{
Main.projectile[p].Calamity().deepcoreBullet = true;
Main.projectile[p].scale = 2;
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,77 @@
using Terraria.DataStructures;
using CalamityMod.Items.Materials;
using CalamityMod.Rarities;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Summon
{
public class KingofConstellationsTenryu : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Summon";
public override void SetDefaults()
{
Item.mana = 10;
Item.damage = 213;
Item.useStyle = ItemUseStyleID.HoldUp;
Item.shootSpeed = 10f;
Item.shoot = ModContent.ProjectileType<BlackDragonHead>();
Item.width = 44;
Item.height = 62;
Item.UseSound = Flare.FlareSound;
Item.useAnimation = Item.useTime = 25;
Item.value = CalamityGlobalItem.Rarity12BuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.Calamity().donorItem = true;
Item.noMelee = true;
Item.knockBack = 2f;
Item.DamageType = DamageClass.Summon;
Item.autoReuse = true;
}
public override Vector2? HoldoutOffset()
{
return new Vector2(-20, 0);
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 4;
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Vector2 spawnPos = new Vector2(player.position.X - 200, player.position.Y - 200);
Vector2 spawnPos2 = new Vector2(player.position.X + 200, player.position.Y - 200);
SpawnDragon(ModContent.ProjectileType<WhiteDragonHead>(), ModContent.ProjectileType<WhiteDragonBody>(), ModContent.ProjectileType<WhiteDragonTail>(), spawnPos2, player, source, damage, knockback);
SpawnDragon(ModContent.ProjectileType<BlackDragonHead>(), ModContent.ProjectileType<BlackDragonBody>(), ModContent.ProjectileType<BlackDragonTail>(), spawnPos, player, source, damage, knockback);
return false;
}
public static void SpawnDragon(int head, int body, int tail, Vector2 spawnPos, Player player, EntitySource_ItemUse_WithAmmo source, int damage, float knockback)
{
Projectile.NewProjectile(source, spawnPos, player.DirectionTo(Main.MouseWorld) * 3, head, damage, knockback, player.whoAmI);
Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, tail, damage, knockback, player.whoAmI);
for (var i = 0; i < 20; i++)
{
Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, body, damage, knockback, player.whoAmI);
}
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient(ItemID.StardustDragonStaff).
AddIngredient(ItemID.LightShard).
AddIngredient(ItemID.DarkShard).
AddIngredient(ModContent.ItemType<TwistingNether>(), 3).
AddTile(TileID.LunarCraftingStation).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -1217,6 +1217,11 @@ IgneousExaltationBuff: {
Description: A blade is orbiting you
}
KingofConstellationsBuff: {
DisplayName: Celestial Dragons
Description: The celestial dragons will protect you
}
LilPlaguebringerBuff: {
DisplayName: Lil' Plaguebringer
Description: The Plaguebringer will protect you
@@ -347,6 +347,15 @@ DarkechoGreatbow: {
'''
}
DeepcoreGK2: {
DisplayName: Deepcore GK2
Tooltip:
'''
Bullets are twice as large and ignores 15 points of enemy defense
'For rock and stone!'
'''
}
Deathwind: {
DisplayName: Deathwind
Tooltip:
@@ -449,6 +449,15 @@ InfectedRemote: {
'''
}
KingofConstellationsTenryu: {
DisplayName: King of Constellations, Tenryū
Tooltip:
'''
Uses 4 minion slots to summon a pair of celestial dragons to fight for you
'The ones who will devour the Unmoving Star'
'''
}
Metastasis: {
DisplayName: Metastasis
Tooltip:
@@ -27,6 +27,9 @@ BabyBloodCrawler.DisplayName: Baby Blood Crawler
BabyPlaguebringer.DisplayName: Baby Plaguebringer
BelladonnaPetal.DisplayName: Belladonna Petal
BelladonnaSpirit.DisplayName: Belladonna Spirit
BlackDragonBody.DisplayName: Black Celestial Dragon
BlackDragonHead.DisplayName: Black Celestial Dragon
BlackDragonTail.DisplayName: Black Celestial Dragon
BlackHawkBullet.DisplayName: Black Hawk Bullet
BlackHawkSummon.DisplayName: Black Hawk
BloodBreath.DisplayName: Fire
@@ -284,6 +287,9 @@ VolcanicFireballSummon.DisplayName: Volcanic Fireball
WaterElementalMinion.DisplayName: Anahita
WaterElementalSong.DisplayName: Siren Song
WaterSpearFriendly.DisplayName: Spear
WhiteDragonBody.DisplayName: White Celestial Dragon
WhiteDragonHead.DisplayName: White Celestial Dragon
WhiteDragonTail.DisplayName: White Celestial Dragon
WitherBlossom.DisplayName: Wither Blossom
WitherBolt.DisplayName: Wither Bolt
WulfrumDroid.DisplayName: Wulfrum Droid
+1
View File
@@ -1175,6 +1175,7 @@ namespace CalamityMod
sAssociation.Call("AddMinionInfo", ItemType<EntropysVigil>(), BuffType<EntropysVigilBuff>(), new List<int>() { ProjectileType<Calamitamini>(), ProjectileType<Cataclymini>(), ProjectileType<Catastromini>()}, new List<float>() {1-(1f/3f), 2f/3f, 2f/3f});
//Entropy's Vigil is a bruh moment
sAssociation.Call("AddMinionInfo", ItemType<ResurrectionButterfly>(), BuffType<ResurrectionButterflyBuff>(), new List<int>() { ProjectileType<PinkButterfly>(), ProjectileType<PurpleButterfly>()});
sAssociation.Call("AddMinionInfo", ItemType<KingofConstellationsTenryu>(), BuffType<KingofConstellationsBuff>(), new List<int>() { ProjectileType<BlackDragonHead>(), ProjectileType<WhiteDragonHead>() });
}
}
}
+1
View File
@@ -1592,6 +1592,7 @@ namespace CalamityMod.NPCs
.AddWithCustomValue(ItemID.SpelunkerPotion, Item.buyPrice(gold: 4), potionSells, Condition.HappyEnough, Condition.DownedEowOrBoc)
.AddWithCustomValue(ItemID.ObsidianSkinPotion, Item.buyPrice(gold: 4), potionSells, Condition.HappyEnough, Condition.DownedSkeletron);
AddScalingPotion(ref shop, ItemID.EndurancePotion, Condition.DownedSkeletron);
shop.Add(ModContent.ItemType<DeepcoreGK2>(), Condition.DownedMechBossAny);
}
if (type == NPCID.ArmsDealer)
+22
View File
@@ -7,6 +7,7 @@ using CalamityMod.EntitySources;
using CalamityMod.Events;
using CalamityMod.Items.Accessories;
using CalamityMod.NPCs;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Melee;
using CalamityMod.Projectiles.Ranged;
@@ -70,6 +71,9 @@ namespace CalamityMod.Projectiles
// If true, this projectile can apply the infinitely-stacking Shred debuff iconic to Soma Prime.
public bool appliesSomaShred = false;
// If true, this projectile creates impact sparks upon hitting enemies
public bool deepcoreBullet = false;
// Amount of extra updates that are set in SetDefaults.
public int defExtraUpdates = -1;
@@ -2532,6 +2536,24 @@ namespace CalamityMod.Projectiles
if (!WorldUtils.Find(projectile.Center.ToTileCoordinates(), Searches.Chain(new Searches.Down(12), new Conditions.IsSolid()), out _))
modifiers.SourceDamage /= 1.5f;
}
// create sparks on hit to hammer in the defense shredding
if (deepcoreBullet)
{
if (Main.netMode != NetmodeID.Server)
{
Vector2 cen = Vector2.Lerp(projectile.Center, target.Center, 0.65f);
int numSparks = Main.rand.Next(2, 5);
for (int i = 0; i < numSparks; i++)
{
Vector2 sparkVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(2f, 8f);
Color sparkColor = Color.Lerp(Color.AliceBlue, Color.DarkSlateBlue, Main.rand.NextFloat(0.7f));
sparkColor = Color.Lerp(sparkColor, Color.CornflowerBlue, Main.rand.NextFloat());
SparkParticle sparke = new(cen, -sparkVelocity, false, 10, 0.5f, sparkColor);
GeneralParticleHandler.SpawnParticle(sparke);
}
}
}
}
#endregion
+124
View File
@@ -0,0 +1,124 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class BlackDragonBody : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public int segmentIndex = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = false;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.idStaticNPCHitCooldown = 4;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minion = true;
}
public override void OnSpawn(IEntitySource source)
{
foreach (var projectile in Main.projectile)
{
if (projectile.type == ModContent.ProjectileType<BlackDragonTail>() && projectile.owner == Projectile.owner && projectile.active)
{
segmentIndex = projectile.ModProjectile<BlackDragonTail>().segmentIndex;
projectile.ModProjectile<BlackDragonTail>().segmentIndex++;
}
}
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
internal void SegmentMove()
{
Player player = Main.player[Projectile.owner];
var live = false;
Projectile nextSegment = new Projectile();
BlackDragonHead head = new BlackDragonHead();
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active)
{
if (projectile.ModProjectile<BlackDragonBody>().segmentIndex == segmentIndex - 1)
{
live = true;
nextSegment = projectile;
}
}
if (projectile.type == ModContent.ProjectileType<BlackDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
if (segmentIndex == 1)
{
live = true;
nextSegment = projectile;
}
head = projectile.ModProjectile<BlackDragonHead>();
}
}
if (!live) Projectile.Kill();
Vector2 destinationOffset = nextSegment.Center+nextSegment.velocity - Projectile.Center;
if (nextSegment.rotation != Projectile.rotation)
{
float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation);
//destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center);
destinationOffset = destinationOffset.RotatedBy(angle * 0.1f);
}
Projectile.rotation = destinationOffset.ToRotation();
if (destinationOffset != Vector2.Zero)
{
Projectile.Center = nextSegment.Center+nextSegment.velocity - destinationOffset.SafeNormalize(Vector2.Zero) * 20f;
}
}
public override bool PreDraw(ref Color lightColor)
{
return false;
}
public override void Kill(int timeLeft)
{
if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType<BlackDragonHead>()] > 0)
{
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<BlackDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
projectile.Kill();
}
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

+220
View File
@@ -0,0 +1,220 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
// HUGE credit to Dozezoze for lending his worm projectile code
public class BlackDragonHead : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
Dictionary<int, Projectile> segments = new Dictionary<int, Projectile>();
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.localNPCHitCooldown = 30;
Projectile.usesLocalNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minionSlots = 2;
Projectile.minion = true;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
player.AddBuff(ModContent.BuffType<KingofConstellationsBuff>(), 1);
if (Projectile.type == ModContent.ProjectileType<BlackDragonHead>())
{
if (player.dead)
{
player.Calamity().celestialDragons = false;
}
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
Projectile.ai[0]++;
// Hover to the left because evil is not right or something
Vector2 idealPos = new Vector2(player.Center.X - 200, player.Center.Y - 50);
float distanceFromOwner = Projectile.Distance(idealPos);
if (distanceFromOwner > 3000)
{
Projectile.Center = player.Center;
Projectile.netUpdate = true;
}
NPC target = CalamityUtils.MinionHoming(Projectile.position, 2500, player, true, true);
if (target != null && Projectile.position.Distance(player.position) <= 2500)
{
AttackTarget(target);
}
else
{
float hoverAcceleration = 0.2f;
if (distanceFromOwner < 200f)
hoverAcceleration = 0.12f;
if (distanceFromOwner < 140f)
hoverAcceleration = 0.06f;
if (distanceFromOwner > 100f)
{
if (Math.Abs(player.Center.X - Projectile.Center.X) > 20f)
Projectile.velocity.X += hoverAcceleration * Math.Sign(idealPos.X - Projectile.Center.X);
if (Math.Abs(player.Center.Y - Projectile.Center.Y) > 10f)
Projectile.velocity.Y += hoverAcceleration * Math.Sign(idealPos.Y - Projectile.Center.Y);
}
else if (Projectile.velocity.Length() > 1f)
Projectile.velocity *= 0.96f;
if (Math.Abs(Projectile.velocity.Y) < 1f)
Projectile.velocity.Y -= 0.1f;
if (Projectile.velocity.Length() > 25)
Projectile.velocity = Vector2.Normalize(Projectile.velocity) * 25;
}
Projectile.rotation = Projectile.velocity.ToRotation();
segments.Clear();
foreach (var projectile in Main.projectile)
{
if (projectile.type == ModContent.ProjectileType<BlackDragonBody>() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile<BlackDragonBody>().segmentIndex))
{
segments.Add(projectile.ModProjectile<BlackDragonBody>().segmentIndex, projectile);
}
if (projectile.type == ModContent.ProjectileType<BlackDragonTail>() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile<BlackDragonTail>().segmentIndex))
{
segments.Add(projectile.ModProjectile<BlackDragonTail>().segmentIndex, projectile);
}
}
for (var i = 1; i <= segments.Count; i++)
{
if (i < segments.Count)
{
if (segments.ContainsKey(i))
segments[i].ModProjectile<BlackDragonBody>().SegmentMove();
}
else
{
if (segments.ContainsKey(i))
segments[i].ModProjectile<BlackDragonTail>().SegmentMove();
}
}
}
internal void AttackTarget(NPC target)
{
float idealFlyAcceleration = 0.18f;
Vector2 destination = target.Center;
float distanceFromDestination = Projectile.Distance(destination);
// Get a swerve effect if somewhat far from the target.
if (Projectile.Distance(destination) > 425f)
{
Projectile.ai[2] = 0;
destination += (Projectile.ai[0] % 30f / 30f * MathHelper.TwoPi).ToRotationVector2() * 145f;
distanceFromDestination = Projectile.Distance(destination);
idealFlyAcceleration *= 2.5f;
}
// Charge if the target is far away.
if (distanceFromDestination > 1500f)
idealFlyAcceleration = MathHelper.Min(6f, Projectile.ai[1] + 1f);
Projectile.ai[1] = MathHelper.Lerp(Projectile.ai[1], idealFlyAcceleration, 0.3f);
float directionToTargetOrthogonality = Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.SafeDirectionTo(destination));
// Fly towards the target if it's far.
if (distanceFromDestination > 320f)
{
float speed = Projectile.velocity.Length();
if (speed < 23f)
speed += 0.08f;
if (speed > 32f)
speed -= 0.08f;
// Go faster if the line of sight is aiming closely at the target.
if (directionToTargetOrthogonality < 0.85f && directionToTargetOrthogonality > 0.5f)
speed += 16f;
// And go slower otherwise so that the dragon can angle towards the target more accurately.
if (directionToTargetOrthogonality < 0.5f && directionToTargetOrthogonality > -0.7f)
speed -= 16f;
speed = MathHelper.Clamp(speed, 16f, 34f);
Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.AngleTo(destination), Projectile.ai[1]).ToRotationVector2() * speed;
// failsafe to prevent orbiting
Projectile.ai[2]++;
if (Projectile.ai[2] >= 90)
{
Projectile.velocity = Projectile.DirectionTo(destination) * 30;
Projectile.ai[2] = 0;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
Texture2D texBody = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlackDragonBody").Value;
Texture2D texBody2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlackDragonBody2").Value;
Texture2D texTail = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlackDragonTail").Value;
Texture2D texTail2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlackDragonTail2").Value;
for (var i = segments.Count; i > 0; i--)
{
if (segments.ContainsKey(i))
{
SpriteEffects fx = Math.Abs(segments[i].rotation) > MathHelper.PiOver2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
if (i < segments.Count - 1)
{
Main.EntitySpriteDraw((i == 5 || i == 12) ? texBody2 : texBody, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0);
}
else if (i < segments.Count)
{
Main.EntitySpriteDraw(texTail, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0);
}
else
{
Main.EntitySpriteDraw(texTail2, segments[i].Center - Main.screenPosition - new Vector2(10, 0).RotatedBy(segments[i].rotation), null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texTail.Size() / 2f, segments[i].scale, fx, 0);
}
}
}
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation + MathHelper.Pi / 2f, tex.Size() / 2f, Projectile.scale, Projectile.velocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0);
return false;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

+112
View File
@@ -0,0 +1,112 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class BlackDragonTail : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public int segmentIndex = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = false;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.localNPCHitCooldown = 30;
Projectile.usesLocalNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minion = true;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
internal void SegmentMove()
{
Player player = Main.player[Projectile.owner];
var live = false;
Projectile nextSegment = new Projectile();
BlackDragonHead head = new BlackDragonHead();
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<BlackDragonBody>() && projectile.owner == Projectile.owner && projectile.active)
{
if (projectile.ModProjectile<BlackDragonBody>().segmentIndex == segmentIndex - 1)
{
live = true;
nextSegment = projectile;
}
}
if (projectile.type == ModContent.ProjectileType<BlackDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
if (segmentIndex == 1)
{
live = true;
nextSegment = projectile;
}
head = projectile.ModProjectile<BlackDragonHead>();
}
}
if (!live) Projectile.Kill();
Vector2 destinationOffset = nextSegment.Center - Projectile.Center;
if (nextSegment.rotation != Projectile.rotation)
{
float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation);
//destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center);
destinationOffset = destinationOffset.RotatedBy(angle * 0.1f);
}
Projectile.rotation = destinationOffset.ToRotation();
if (destinationOffset != Vector2.Zero)
{
Projectile.Center = nextSegment.Center - destinationOffset.SafeNormalize(Vector2.Zero) * 20f;
}
Projectile.velocity = Vector2.Zero;
}
public override bool PreDraw(ref Color lightColor)
{
return false;
}
public override void Kill(int timeLeft)
{
if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType<BlackDragonHead>()] > 0)
{
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<BlackDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
projectile.Kill();
}
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+121
View File
@@ -0,0 +1,121 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class WhiteDragonBody : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public int segmentIndex = 1;
public override void SetStaticDefaults()
{
Main.projPet[Projectile.type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.idStaticNPCHitCooldown = 4;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minion = true;
}
public override void OnSpawn(IEntitySource source)
{
foreach (var projectile in Main.projectile)
{
if (projectile.type == ModContent.ProjectileType<WhiteDragonTail>() && projectile.owner == Projectile.owner && projectile.active)
{
segmentIndex = projectile.ModProjectile<WhiteDragonTail>().segmentIndex;
projectile.ModProjectile<WhiteDragonTail>().segmentIndex++;
}
}
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
internal void SegmentMove()
{
Player player = Main.player[Projectile.owner];
var live = false;
Projectile nextSegment = new Projectile();
WhiteDragonHead head = new WhiteDragonHead();
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active)
{
if (projectile.ModProjectile<WhiteDragonBody>().segmentIndex == segmentIndex - 1)
{
live = true;
nextSegment = projectile;
}
}
if (projectile.type == ModContent.ProjectileType<WhiteDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
if (segmentIndex == 1)
{
live = true;
nextSegment = projectile;
}
head = projectile.ModProjectile<WhiteDragonHead>();
}
}
if (!live) Projectile.Kill();
Vector2 destinationOffset = nextSegment.Center+nextSegment.velocity - Projectile.Center;
if (nextSegment.rotation != Projectile.rotation)
{
float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation);
//destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center);
destinationOffset = destinationOffset.RotatedBy(angle * 0.1f);
}
Projectile.rotation = destinationOffset.ToRotation();
if (destinationOffset != Vector2.Zero)
{
Projectile.Center = nextSegment.Center+nextSegment.velocity - destinationOffset.SafeNormalize(Vector2.Zero) * 20f;
}
}
public override bool PreDraw(ref Color lightColor)
{
return false;
}
public override void Kill(int timeLeft)
{
if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType<WhiteDragonHead>()] > 0)
{
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<WhiteDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
projectile.Kill();
}
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

+218
View File
@@ -0,0 +1,218 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
// HUGE credit to Dozezoze for lending his worm projectile code
public class WhiteDragonHead : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
Dictionary<int, Projectile> segments = new Dictionary<int, Projectile>();
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 24;
Projectile.height = 24;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.localNPCHitCooldown = 30;
Projectile.usesLocalNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minionSlots = 2;
Projectile.minion = true;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
player.AddBuff(ModContent.BuffType<KingofConstellationsBuff>(), 1);
if (Projectile.type == ModContent.ProjectileType<WhiteDragonHead>())
{
if (player.dead)
{
player.Calamity().celestialDragons = false;
}
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
Projectile.ai[0]++;
// Hover to the right because light is right or something
Vector2 idealPos = new Vector2(player.Center.X + 200, player.Center.Y - 50);
float distanceFromOwner = Projectile.Distance(idealPos);
if (distanceFromOwner > 5000)
{
Projectile.Center = player.Center;
}
NPC target = CalamityUtils.MinionHoming(Projectile.position, 2500, player, true, true);
if (target != null && Projectile.position.Distance(player.position) <= 2500)
{
AttackTarget(target);
}
else
{
float hoverAcceleration = 0.2f;
if (distanceFromOwner < 200f)
hoverAcceleration = 0.12f;
if (distanceFromOwner < 140f)
hoverAcceleration = 0.06f;
if (distanceFromOwner > 100f)
{
if (Math.Abs(player.Center.X - Projectile.Center.X) > 20f)
Projectile.velocity.X += hoverAcceleration * Math.Sign(idealPos.X - Projectile.Center.X);
if (Math.Abs(player.Center.Y - Projectile.Center.Y) > 10f)
Projectile.velocity.Y += hoverAcceleration * Math.Sign(idealPos.Y - Projectile.Center.Y);
}
else if (Projectile.velocity.Length() > 1f)
Projectile.velocity *= 0.96f;
if (Math.Abs(Projectile.velocity.Y) < 1f)
Projectile.velocity.Y -= 0.1f;
if (Projectile.velocity.Length() > 25)
Projectile.velocity = Vector2.Normalize(Projectile.velocity) * 25;
}
Projectile.rotation = Projectile.velocity.ToRotation();
segments.Clear();
foreach (var projectile in Main.projectile)
{
if (projectile.type == ModContent.ProjectileType<WhiteDragonBody>() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile<WhiteDragonBody>().segmentIndex))
{
segments.Add(projectile.ModProjectile<WhiteDragonBody>().segmentIndex, projectile);
}
if (projectile.type == ModContent.ProjectileType<WhiteDragonTail>() && projectile.owner == Projectile.owner && projectile.active)
{
segments.Add(projectile.ModProjectile<WhiteDragonTail>().segmentIndex, projectile);
}
}
for (var i = 1; i <= segments.Count; i++)
{
if (i < segments.Count)
{
if (segments.ContainsKey(i))
segments[i].ModProjectile<WhiteDragonBody>().SegmentMove();
}
else
{
if (segments.ContainsKey(i))
segments[i].ModProjectile<WhiteDragonTail>().SegmentMove();
}
}
}
internal void AttackTarget(NPC target)
{
float idealFlyAcceleration = 0.18f;
Vector2 destination = target.Center;
float distanceFromDestination = Projectile.Distance(destination);
// Get a swerve effect if somewhat far from the target.
if (Projectile.Distance(destination) > 425f)
{
Projectile.ai[2] = 0;
destination += (Projectile.ai[0] % 30f / 30f * MathHelper.TwoPi).ToRotationVector2() * 145f;
distanceFromDestination = Projectile.Distance(destination);
idealFlyAcceleration *= 2.5f;
}
// Charge if the target is far away.
if (distanceFromDestination > 1500f)
idealFlyAcceleration = MathHelper.Min(6f, Projectile.ai[1] + 1f);
Projectile.ai[1] = MathHelper.Lerp(Projectile.ai[1], idealFlyAcceleration, 0.3f);
float directionToTargetOrthogonality = Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.SafeDirectionTo(destination));
// Fly towards the target if it's far.
if (distanceFromDestination > 320f)
{
float speed = Projectile.velocity.Length();
if (speed < 23f)
speed += 0.08f;
if (speed > 32f)
speed -= 0.08f;
// Go faster if the line of sight is aiming closely at the target.
if (directionToTargetOrthogonality < 0.85f && directionToTargetOrthogonality > 0.5f)
speed += 16f;
// And go slower otherwise so that the dragon can angle towards the target more accurately.
if (directionToTargetOrthogonality < 0.5f && directionToTargetOrthogonality > -0.7f)
speed -= 16f;
speed = MathHelper.Clamp(speed, 16f, 34f);
Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.AngleTo(destination), Projectile.ai[1]).ToRotationVector2() * speed;
// failsafe to prevent orbiting
Projectile.ai[2]++;
if (Projectile.ai[2] >= 90)
{
Projectile.velocity = Projectile.DirectionTo(destination) * 30;
Projectile.ai[2] = 0;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
Texture2D texBody = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/WhiteDragonBody").Value;
Texture2D texBody2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/WhiteDragonBody2").Value;
Texture2D texTail = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/WhiteDragonTail").Value;
Texture2D texTail2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/WhiteDragonTail2").Value;
for (var i = segments.Count; i > 0; i--)
{
if (segments.ContainsKey(i))
{
SpriteEffects fx = Math.Abs(segments[i].rotation) > MathHelper.PiOver2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
if (i < segments.Count - 1)
{
Main.EntitySpriteDraw((i == 5 || i == 12) ? texBody2 : texBody, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / (2f), segments[i].scale, fx, 0);
}
else if (i < segments.Count)
{
Main.EntitySpriteDraw(texTail, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0);
}
else
{
Main.EntitySpriteDraw(texTail2, segments[i].Center - Main.screenPosition - new Vector2(10, 0).RotatedBy(segments[i].rotation), null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texTail.Size() / 2f, segments[i].scale, fx, 0);
}
}
}
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation + MathHelper.Pi / 2f, tex.Size() / 2f, Projectile.scale, Projectile.velocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0);
return false;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+113
View File
@@ -0,0 +1,113 @@
using CalamityMod.Buffs.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class WhiteDragonTail : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public int segmentIndex = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.MinionSacrificable[Type] = false;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
}
public override void SetDefaults()
{
Projectile.timeLeft = 10;
Projectile.width = 26;
Projectile.height = 26;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 180;
Projectile.localNPCHitCooldown = 30;
Projectile.usesLocalNPCImmunity = true;
Projectile.tileCollide = false;
Projectile.extraUpdates = 0;
Projectile.aiStyle = -1;
Projectile.DamageType = DamageClass.Summon;
Projectile.netImportant = true;
Projectile.minion = true;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (player.Calamity().celestialDragons)
{
Projectile.timeLeft = 2;
}
}
internal void SegmentMove()
{
Player player = Main.player[Projectile.owner];
var live = false;
Projectile nextSegment = new Projectile();
WhiteDragonHead head = new WhiteDragonHead();
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<WhiteDragonBody>() && projectile.owner == Projectile.owner && projectile.active)
{
if (projectile.ModProjectile<WhiteDragonBody>().segmentIndex == segmentIndex - 1)
{
live = true;
nextSegment = projectile;
}
}
if (projectile.type == ModContent.ProjectileType<WhiteDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
if (segmentIndex == 1)
{
live = true;
nextSegment = projectile;
}
head = projectile.ModProjectile<WhiteDragonHead>();
}
}
if (!live) Projectile.Kill();
Vector2 destinationOffset = nextSegment.Center - Projectile.Center;
if (nextSegment.rotation != Projectile.rotation)
{
float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation);
//destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center);
destinationOffset = destinationOffset.RotatedBy(angle * 0.1f);
}
Projectile.rotation = destinationOffset.ToRotation();
if (destinationOffset != Vector2.Zero)
{
Projectile.Center = nextSegment.Center - destinationOffset.SafeNormalize(Vector2.Zero) * 20f;
}
Projectile.velocity = Vector2.Zero;
}
public override bool PreDraw(ref Color lightColor)
{
return false;
}
public override void Kill(int timeLeft)
{
if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType<WhiteDragonHead>()] > 0)
{
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
if (projectile.type == ModContent.ProjectileType<WhiteDragonHead>() && projectile.owner == Projectile.owner && projectile.active)
{
projectile.Kill();
}
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB