Added King of Constellations, Tenryu

This commit is contained in:
GinYuH authored and Cameron Ewell committed 2023-06-09 20:34:54 -04:00
1 parent b2cc1cf1f2
commit befe0f2e46
25 files changed
+933

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;
@@ -0,0 +1,108 @@
using Terraria.DataStructures;
using CalamityMod.Buffs.Summon;
using CalamityMod.Items.Materials;
using CalamityMod.Rarities;
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 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 = NPCs.Yharon.Yharon.HitSound;
Item.useAnimation = Item.useTime = 25;
Item.value = CalamityGlobalItem.Rarity14BuyPrice;
Item.rare = ModContent.RarityType<DarkBlue>();
Item.Calamity().donorItem = true;
Item.noMelee = true;
Item.knockBack = 2f;
Item.DamageType = DamageClass.Summon;
Item.autoReuse = true;
}
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)
{
bool Exists = false;
int tailID = 0;
foreach (var projectile in Main.projectile)
{
if (projectile.type == head && projectile.owner == player.whoAmI && projectile.active)
{
Exists = true;
}
if (projectile.type == tail && projectile.owner == player.whoAmI && projectile.active)
{
tailID = projectile.whoAmI;
}
}
float foundSlotsCount = 0f;
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile p = Main.projectile[i];
if (p.active && p.minion && p.owner == player.whoAmI)
{
foundSlotsCount += p.minionSlots;
}
}
if (Exists)
{
if (!(foundSlotsCount + 0.5f > (float)player.maxMinions))
{
//Projectile.NewProjectile(source, Main.projectile[tailID].Center, Vector2.Zero, body, damage, knockback, player.whoAmI);
}
}
else
{
if (!(foundSlotsCount + 1f > (float)player.maxMinions))
{
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<ArmoredShell>(), 7).
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
@@ -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>() });
}
}
}
+123
View File
@@ -0,0 +1,123 @@
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 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;
}
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: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

+151
View File
@@ -0,0 +1,151 @@
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 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;
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.ChargingMinionAI(2000f, 2500f, 3200f, 300f, 0, 45f, 36f, 8f, new Vector2(0f, -60f), 12f, 12f, true, true, 1);
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();
}
}
// Fly away from the white dragon
float pushForce = 0.1f;
for (int k = 0; k < Main.maxProjectiles; k++)
{
Projectile otherProj = Main.projectile[k];
// Short circuits to make the loop as fast as possible
if (!otherProj.active || k == Projectile.whoAmI)
continue;
// If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
bool sameProjType = otherProj.type == ModContent.ProjectileType<WhiteDragonHead>();
float taxicabDist = Vector2.Distance(Projectile.Center, otherProj.Center);
float distancegate = 80f;
if (sameProjType && taxicabDist < distancegate)
{
if (Projectile.position.X < otherProj.position.X)
Projectile.velocity.X -= pushForce;
else
Projectile.velocity.X += pushForce;
if (Projectile.position.Y < otherProj.position.Y)
Projectile.velocity.Y -= pushForce;
else
Projectile.velocity.Y += pushForce;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
lightColor = Color.White;
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 == 16) ? 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.6 KiB

+111
View File
@@ -0,0 +1,111 @@
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 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;
}
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: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

+120
View File
@@ -0,0 +1,120 @@
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 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;
}
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: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

+150
View File
@@ -0,0 +1,150 @@
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 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;
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.ChargingMinionAI(2000f, 2500f, 3200f, 300f, 0, 45f, 36f, 8f, new Vector2(0f, -60f), 12f, 12f, true, true, 1);
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();
}
}
// Fly away from the black dragon
float pushForce = 0.1f;
for (int k = 0; k < Main.maxProjectiles; k++)
{
Projectile otherProj = Main.projectile[k];
// Short circuits to make the loop as fast as possible
if (!otherProj.active || k == Projectile.whoAmI)
continue;
// If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
bool sameProjType = otherProj.type == ModContent.ProjectileType<BlackDragonHead>();
float taxicabDist = Vector2.Distance(Projectile.Center, otherProj.Center);
float distancegate = 80f;
if (sameProjType && taxicabDist < distancegate)
{
if (Projectile.position.X < otherProj.position.X)
Projectile.velocity.X -= pushForce;
else
Projectile.velocity.X += pushForce;
if (Projectile.position.Y < otherProj.position.Y)
Projectile.velocity.Y -= pushForce;
else
Projectile.velocity.Y += pushForce;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
lightColor = Color.White;
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 == 16) ? 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: 2.2 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 WhiteDragonTail : ModProjectile, ILocalizedModType
{
public 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;
}
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: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B