Merge pull request #82 from UncleDanny/more-class-items

Reworked SSV and Photoviscerator. Added Gastric Belcher.
This commit is contained in:
Cameron Ewell authored and GitHub committed 2020-05-29 22:19:36 -04:00
commit dbf820c9a7
38 files changed
+1609 -142

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
using CalamityMod.CalPlayer;
using CalamityMod.Projectiles.Summon;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Summon
{
public class GastricBelcherBuff : ModBuff
{
public override void SetDefaults()
{
DisplayName.SetDefault("Gastric Aberration");
Description.SetDefault("The aquatic aberration will protect you");
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<GastricBelcher>()] > 0)
{
modPlayer.gastricBelcher = true;
}
if (!modPlayer.gastricBelcher)
{
player.DelBuff(buffIndex);
buffIndex--;
}
else
{
player.buffTime[buffIndex] = 18000;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

+2
View File
@@ -839,6 +839,7 @@ namespace CalamityMod.CalPlayer
public bool rDevil = false;
public bool aValkyrie = false;
public bool apexShark = false;
public bool gastricBelcher = false;
public bool squirrel = false;
public bool hauntedDishes = false;
public bool stormjaw = false;
@@ -1786,6 +1787,7 @@ namespace CalamityMod.CalPlayer
eAxe = false;
endoCooper = false;
apexShark = false;
gastricBelcher = false;
squirrel = false;
hauntedDishes = false;
stormjaw = false;
+7 -1
View File
@@ -121,6 +121,7 @@ namespace CalamityMod
public static Texture2D AstralSky;
public static Effect CustomShader;
public static Effect LightShader;
public static Effect TentacleShader;
// DR data structure
public static SortedDictionary<int, float> DRValues;
@@ -286,6 +287,7 @@ namespace CalamityMod
AstralSky = ModContent.GetTexture("CalamityMod/ExtraTextures/AstralSky");
CustomShader = GetEffect("Effects/CustomShader");
LightShader = GetEffect("Effects/LightBurstShader");
TentacleShader = GetEffect("Effects/TentacleShader");
Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh);
SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky();
@@ -320,6 +322,8 @@ namespace CalamityMod
Filters.Scene["CalamityMod:LightBurst"] = new Filter(new ScreenShaderData(new Ref<Effect>(LightShader), "BurstPass"), EffectPriority.VeryHigh);
Filters.Scene["CalamityMod:LightBurst"].Load();
GameShaders.Misc["CalamityMod:SubsumingTentacle"] = new MiscShaderData(new Ref<Effect>(TentacleShader), "BurstPass");
RipperUI.Reset();
AstralArcanumUI.Load(this);
@@ -638,7 +642,9 @@ namespace CalamityMod
ModContent.ProjectileType<MagnomalyBeam>(),
ModContent.ProjectileType<MagnomalyAura>(),
ModContent.ProjectileType<RainbowTrail>(),
ModContent.ProjectileType<PrismaticBeam>()
ModContent.ProjectileType<PrismaticBeam>(),
ModContent.ProjectileType<ExoLight>(),
ModContent.ProjectileType<ExoLightBomb>()
};
projectileDestroyExceptionList = new List<int>()
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+2
View File
@@ -4,6 +4,7 @@ using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.World;
using Terraria;
@@ -52,6 +53,7 @@ namespace CalamityMod.Items.TreasureBags
DropHelper.DropItemChance(player, ModContent.ItemType<Atlantis>(), 3);
DropHelper.DropItemChance(player, ModContent.ItemType<BrackishFlask>(), 3);
DropHelper.DropItemChance(player, ModContent.ItemType<LeviathanTeeth>(), 3);
DropHelper.DropItemChance(player, ModContent.ItemType<GastricBelcherStaff>(), 3);
// Equipment
DropHelper.DropItem(player, ModContent.ItemType<LeviathanAmbergris>());
+12 -14
View File
@@ -1,5 +1,4 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Ores;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Microsoft.Xna.Framework;
@@ -12,15 +11,19 @@ namespace CalamityMod.Items.Weapons.Magic
{
public class SubsumingVortex : ModItem
{
public const int MaxVortexCount = 4;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Subsuming Vortex");
Tooltip.SetDefault("Fires 3 vortexes of elemental energy");
Tooltip.SetDefault("Fires a giant slow-moving vortex\n" +
"When an enemy is nearby, the vortex releases tentacles that redirect towards the enemy.\n" +
"After some time, the vortex slows down, charges, and eventually explodes.\n" +
$"Only {MaxVortexCount} vortexes can exist at once.");
}
public override void SetDefaults()
{
item.damage = 520;
item.damage = 480;
item.magic = true;
item.mana = 20;
item.width = 38;
@@ -28,14 +31,14 @@ namespace CalamityMod.Items.Weapons.Magic
item.UseSound = SoundID.Item84;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.knockBack = 5f;
item.value = Item.buyPrice(2, 50, 0, 0);
item.rare = 10;
item.autoReuse = true;
item.shoot = ModContent.ProjectileType<Vortex>();
item.shootSpeed = 9f;
item.shoot = ModContent.ProjectileType<EnormousConsumingVortex>();
item.shootSpeed = 7f;
item.Calamity().customRarity = CalamityRarity.Violet;
}
@@ -45,16 +48,11 @@ namespace CalamityMod.Items.Weapons.Magic
spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Weapons/Magic/SubsumingVortexGlow"), item.Center - Main.screenPosition, null, Color.White, rotation, origin, 1f, SpriteEffects.None, 0f);
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] < MaxVortexCount;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
int num6 = 3;
for (int index = 0; index < num6; ++index)
{
float SpeedX = speedX + (float)Main.rand.Next(-50, 51) * 0.05f;
float SpeedY = speedY + (float)Main.rand.Next(-50, 51) * 0.05f;
float ai = Main.rand.NextFloat() + 0.5f;
Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0.0f, ai);
}
Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI);
return false;
}
+50 -9
View File
@@ -10,34 +10,53 @@ namespace CalamityMod.Items.Weapons.Ranged
{
public class Photoviscerator : ModItem
{
public const int CooldownTime = 60 * 7; // 7 second cooldown.
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Photoviscerator");
Tooltip.SetDefault("90% chance to not consume gel\n" +
"Fires a stream of exo flames that literally melts everything");
"Fires a stream of exo flames and light that explodes into homing sparks\n" +
"Right click to fire homing flares which stick to enemies and incinerate them");
}
public override void SetDefaults()
{
item.damage = 250;
item.damage = 230;
item.ranged = true;
item.width = 84;
item.height = 30;
item.useTime = 2;
item.useAnimation = 10;
item.useStyle = 5;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.knockBack = 2f;
item.UseSound = SoundID.Item34;
item.value = Item.buyPrice(2, 50, 0, 0);
item.rare = 10;
item.autoReuse = true;
item.shoot = ModContent.ProjectileType<ExoFire>();
item.shootSpeed = 6f;
item.useAmmo = 23;
item.useAmmo = AmmoID.Gel;
item.Calamity().customRarity = CalamityRarity.Violet;
}
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
item.shoot = ModContent.ProjectileType<ExoLightBurst>();
item.useTime = item.useAnimation = 27;
}
else
{
item.useTime = 2;
item.useAnimation = 10;
item.shoot = ModContent.ProjectileType<ExoFire>();
}
return base.CanUseItem(player);
}
public override Vector2? HoldoutOffset()
{
return new Vector2(-15, 0);
@@ -45,11 +64,33 @@ namespace CalamityMod.Items.Weapons.Ranged
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
for (int i = 0; i < 2; i++)
if (player.altFunctionUse == 2)
{
float SpeedX = speedX + (float)Main.rand.Next(-5, 6) * 0.05f;
float SpeedY = speedY + (float)Main.rand.Next(-5, 6) * 0.05f;
Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f);
Vector2 velocity = new Vector2(speedX, speedY);
position += velocity.ToRotation().ToRotationVector2() * 80f;
Projectile.NewProjectile(position, velocity.SafeNormalize(Vector2.Zero) * 17f, ModContent.ProjectileType<ExoLightBurst>(), damage * 3, knockBack, player.whoAmI);
}
else
{
for (int i = 0; i < 2; i++)
{
Vector2 velocity = new Vector2(speedX, speedY).RotatedByRandom(0.05f);
Projectile.NewProjectile(position, velocity, type, damage / 2, knockBack, player.whoAmI, 0f, 0f);
}
if (Main.rand.NextBool(8))
{
for (int i = 0; i < 2; i++)
{
Vector2 velocity = new Vector2(speedX, speedY) * 2f;
position += velocity.ToRotation().ToRotationVector2() * 64f;
int yDirection = (i == 0).ToDirectionInt();
velocity = velocity.RotatedBy(0.2f * yDirection);
Projectile lightBomb = Projectile.NewProjectileDirect(position, velocity, ModContent.ProjectileType<ExoLightBomb>(), damage, knockBack, player.whoAmI);
lightBomb.localAI[1] = yDirection;
lightBomb.netUpdate = true;
}
}
}
return false;
}
@@ -0,0 +1,73 @@
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Summon
{
public class GastricBelcherStaff : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Gastric Belcher Staff");
Tooltip.SetDefault("Summons aquatic aberrations to protect you\n" +
"Aberrations fire vomit at nearby enemies with every third attack firing bubbles");
}
public override void SetDefaults()
{
item.damage = 70;
item.mana = 10;
item.width = 66;
item.height = 70;
item.useTime = item.useAnimation = 20;
item.useStyle = 1;
item.noMelee = true;
item.knockBack = 1f;
item.value = CalamityGlobalItem.Rarity7BuyPrice;
item.rare = 7;
item.UseSound = SoundID.Item76;
item.shoot = ModContent.ProjectileType<GastricBelcher>();
item.shootSpeed = 10f;
item.summon = true;
item.autoReuse = true;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (player.altFunctionUse != 2)
{
player.itemTime = item.useTime;
Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true);
float directionX = Main.mouseX + Main.screenPosition.X - playerPos.X;
float directionY = Main.mouseY + Main.screenPosition.Y - playerPos.Y;
if (player.gravDir == -1f)
{
directionY = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y;
}
Vector2 spinningpoint = new Vector2(directionX, directionY);
float dist = spinningpoint.Length();
if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f))
{
spinningpoint.X = player.direction;
spinningpoint.Y = 0f;
dist = item.shootSpeed;
}
else
{
dist = item.shootSpeed / dist;
}
spinningpoint.X *= dist;
spinningpoint.Y *= dist;
playerPos.X = Main.mouseX + Main.screenPosition.X;
playerPos.Y = Main.mouseY + Main.screenPosition.Y;
spinningpoint = spinningpoint.RotatedBy(Math.PI / 2D, default);
Projectile.NewProjectile(playerPos + spinningpoint, spinningpoint, type, damage, knockBack, player.whoAmI, 0f, 1f);
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+2 -1
View File
@@ -344,7 +344,7 @@ namespace CalamityMod
{
BossDifficulty.TryGetValue("Leviathan", out float order);
List<int> bosses = new List<int>() { NPCType<Leviathan>(), NPCType<Siren>() };
List<int> loot = new List<int>() { ItemType<LeviathanBag>(), ItemType<Greentide>(), ItemType<Leviatitan>(), ItemType<SirensSong>(), ItemType<Atlantis>(), ItemType<BrackishFlask>(), ItemType<LeviathanTeeth>(), ItemType<LureofEnthrallment>(), ItemType<LeviathanAmbergris>(), ItemType<TheCommunity>(), ItemID.HotlineFishingHook, ItemID.BottomlessBucket, ItemID.SuperAbsorbantSponge, ItemID.FishingPotion, ItemID.SonarPotion, ItemID.CratePotion, ItemID.GreaterHealingPotion };
List<int> loot = new List<int>() { ItemType<LeviathanBag>(), ItemType<Greentide>(), ItemType<Leviatitan>(), ItemType<SirensSong>(), ItemType<Atlantis>(), ItemType<GastricBelcherStaff>(), ItemType<BrackishFlask>(), ItemType<LeviathanTeeth>(), ItemType<LureofEnthrallment>(), ItemType<LeviathanAmbergris>(), ItemType<TheCommunity>(), ItemID.HotlineFishingHook, ItemID.BottomlessBucket, ItemID.SuperAbsorbantSponge, ItemID.FishingPotion, ItemID.SonarPotion, ItemID.CratePotion, ItemID.GreaterHealingPotion };
List<int> collection = new List<int>() { ItemType<LeviathanTrophy>(), ItemType<LeviathanMask>(), ItemType<KnowledgeOcean>(), ItemType<KnowledgeLeviathanandSiren>() };
string instructions = "By killing an unknown entity in the Ocean Biome";
string despawn = CalamityUtils.ColorMessage("The aquatic entities sink back beneath the ocean depths.", new Color(0x7F, 0xFF, 0xD4));
@@ -844,6 +844,7 @@ namespace CalamityMod
//Entropy's Vigil is a bruh moment
sAssociation.Call("AddMinionInfo", ItemType<PlantationStaff>(), BuffType<PlantationBuff>(), ProjectileType<PlantSummon>());
sAssociation.Call("AddMinionInfo", ItemType<SandSharknadoStaff>(), BuffType<Sandnado>(), ProjectileType<SandnadoMinion>());
sAssociation.Call("AddMinionInfo", ItemType<GastricBelcherStaff>(), BuffType<GastricBelcherBuff>(), ProjectileType<GastricBelcher>());
sAssociation.Call("AddMinionInfo", ItemType<ResurrectionButterfly>(), BuffType<ResurrectionButterflyBuff>(), new List<int>() { ProjectileType<PinkButterfly>(), ProjectileType<PurpleButterfly>()});
sAssociation.Call("AddMinionInfo", ItemType<FuelCellBundle>(), BuffType<FuelCellBundleBuff>(), ProjectileType<PlaguebringerMK2>());
sAssociation.Call("AddMinionInfo", ItemType<GodspawnHelixStaff>(), BuffType<AstralProbeBuff>(), ProjectileType<AstralProbeSummon>());
+2
View File
@@ -9,6 +9,7 @@ using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -627,6 +628,7 @@ namespace CalamityMod.NPCs.Leviathan
DropHelper.DropItemChance(npc, ModContent.ItemType<Atlantis>(), 4);
DropHelper.DropItemChance(npc, ModContent.ItemType<BrackishFlask>(), 4);
DropHelper.DropItemChance(npc, ModContent.ItemType<LeviathanTeeth>(), 4);
DropHelper.DropItemChance(npc, ModContent.ItemType<GastricBelcherStaff>(), 4);
// Equipment
DropHelper.DropItemChance(npc, ModContent.ItemType<LureofEnthrallment>(), 4);
+15
View File
@@ -2264,6 +2264,21 @@ namespace CalamityMod.Projectiles
projectile.spriteDirection = projectile.direction;
projectile.rotation = projectile.velocity.X * tiltFloat;
}
public static void ExpandHitboxBy(Projectile projectile, int width, int height)
{
projectile.position = projectile.Center;
projectile.width = width;
projectile.height = height;
projectile.position -= projectile.Size * 0.5f;
}
public static void ExpandHitboxBy(Projectile projectile, int newSize)
{
ExpandHitboxBy(projectile, newSize, newSize);
}
public static void ExpandHitboxBy(Projectile projectile, float expandRatio)
{
ExpandHitboxBy(projectile, (int)(projectile.width * expandRatio), (int)(projectile.height * expandRatio));
}
#endregion
}
}
@@ -0,0 +1,204 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class EnormousConsumingVortex : ModProjectile
{
public float Time
{
get => projectile.ai[0];
set => projectile.ai[0] = value;
}
public float IdealScale
{
get => projectile.localAI[0];
set => projectile.localAI[0] = value;
}
public const int TentacleSpawnRate = 30;
public const int PulseInterval = 18;
public const float PulseHitboxExpandRatio = 2.5f;
public const float RadialOffsetVarianceFactor = 0.1f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Subsuming Vortex");
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = 2;
projectile.height = 2;
projectile.friendly = true;
projectile.alpha = 255;
projectile.penetrate = -1;
projectile.scale = 0.0004f;
projectile.timeLeft = 540;
projectile.tileCollide = false;
projectile.magic = true;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 17;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(IdealScale);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
IdealScale = reader.ReadSingle();
}
public override void AI()
{
projectile.rotation += MathHelper.ToRadians(8f); // Spin 2 win.
projectile.alpha = (int)MathHelper.Lerp(255, 0, Utils.InverseLerp(0f, 20f, Time, true)); // Fade in completely after 20 frames.
projectile.scale = MathHelper.Lerp(0.0004f, IdealScale, Utils.InverseLerp(0f, 30f, Time, true)); // Expand completely after 30 frames.
// Determine the ideal scale in the first frame.
if (IdealScale == 0f)
{
IdealScale = Main.rand.NextFloat(2.2f, 3f);
projectile.netUpdate = true;
}
// Target enemy if possible and idly spawn tentacles.
if (Time < 300)
{
TargetingMovement();
if (Time % TentacleSpawnRate == TentacleSpawnRate - 1 && Main.netMode != NetmodeID.MultiplayerClient)
{
ProduceSubsumingHentai();
}
}
// Slow down and pulse frequently.
else if (Time < 480)
{
projectile.velocity *= 0.96f;
if (Time % PulseInterval == 0f)
{
PulseEffect();
}
}
else if (Time == 520f)
{
ExplodeEffect();
projectile.Kill();
}
CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(projectile.scale * 62));
Time++;
}
public void ProduceSubsumingHentai()
{
float xStartingAcceleration = Main.rand.NextFloat(0.001f, 0.04f) * Main.rand.NextBool(2).ToDirectionInt();
float yStartingAcceleration = Main.rand.NextFloat(0.001f, 0.04f) * Main.rand.NextBool(2).ToDirectionInt();
Projectile subsumingHentai = Projectile.NewProjectileDirect(projectile.Center,
Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(9f, 13f),
ModContent.ProjectileType<SubsumingTentacle>(),
(int)(projectile.damage * 0.6),
projectile.knockBack * 0.6f,
projectile.owner,
xStartingAcceleration,
yStartingAcceleration);
subsumingHentai.tileCollide = false;
}
public void TargetingMovement()
{
NPC potentialTarget = projectile.Center.ClosestNPCAt(1500f, true);
if (potentialTarget != null)
{
projectile.velocity = (projectile.velocity * 5f + projectile.DirectionTo(potentialTarget.Center) * 7f) / 6f;
}
}
public void PulseEffect()
{
CalamityGlobalProjectile.ExpandHitboxBy(projectile, PulseHitboxExpandRatio);
projectile.Damage();
if (!Main.dedServ)
{
Main.PlaySound(SoundID.Item43, projectile.Center);
for (int i = 0; (float)i < 85; i++)
{
float angle = i / 85f * MathHelper.TwoPi;
Vector2 spawnPosition = projectile.Center + angle.ToRotationVector2() * (500f + Main.rand.NextFloat(-8f, 8f));
Vector2 velocity = (angle - (float)Math.PI).ToRotationVector2() * Main.rand.NextFloat(27f, 38.5f);
Dust dust = Dust.NewDustPerfect(spawnPosition, 264, velocity);
dust.scale = 0.9f;
dust.fadeIn = 1.25f;
dust.color = Main.hslToRgb(i / 85f, 1f, 0.8f);
dust.noGravity = true;
}
}
CalamityGlobalProjectile.ExpandHitboxBy(projectile, 1f / PulseHitboxExpandRatio);
}
public void ExplodeEffect()
{
Main.PlaySound(SoundID.Zombie, projectile.Center, 104);
if (!Main.dedServ)
{
for (int i = 0; i < 200; i++)
{
Vector2 velocity = Main.rand.NextVector2Circular(50f, 50f);
Dust dust = Dust.NewDustPerfect(projectile.Center, 264, velocity);
dust.color = Main.hslToRgb(i / 100f % 1f, 1f, 0.8f);
dust.fadeIn = 1.25f;
dust.noGravity = true;
}
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC closestTarget = projectile.Center.ClosestNPCAt(1600f, true);
for (int i = 0; i < 12; i++)
{
float rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Vector2 velocity = Vector2.UnitY.RotatedBy(rotation);
if (closestTarget != null)
velocity = projectile.DirectionTo(closestTarget.Center).RotatedByRandom(0.4f);
velocity *= Main.rand.NextFloat(3f, 5f);
Projectile.NewProjectileDirect(projectile.Center,
velocity,
ModContent.ProjectileType<Vortex>(),
(int)(projectile.damage * 0.7),
projectile.knockBack,
projectile.owner,
0f,
Main.rand.NextFloat(0.5f, 1.8f));
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
int vortexesToDraw = 27;
for (int i = 0; i < vortexesToDraw; i++)
{
float rotation = MathHelper.TwoPi / i * vortexesToDraw + projectile.rotation;
float drawScale = projectile.scale * 0.66f;
drawScale *= (float)(Math.Cos(Time / 18f + rotation * 2f) + 1f) * 0.3f + 0.7f; // Range of 0.7 to 1. Used to give variance with the scale.
float offsetFactor = (float)(Math.Sin(Time / 18f + rotation * 2f) + 1f) * 0.2f + 0.8f; // Range of 0.8 to 1.
// Due to the way RotatedBy works, the offset can be negative, giving the projectile a
// dual buzzsaw look.
Vector2 drawOffset = Vector2.UnitX.RotatedBy(rotation) * 30f * offsetFactor * drawScale;
Vector2 drawPosition = projectile.Center + drawOffset - Main.screenPosition;
Color colorToDraw = Main.hslToRgb((i / (float)vortexesToDraw + Time / 40f) % 1f, 1f, 0.75f);
spriteBatch.Draw(ModContent.GetTexture(Texture),
drawPosition,
null,
colorToDraw * 0.7f,
rotation,
ModContent.GetTexture(Texture).Size() * 0.5f,
drawScale,
SpriteEffects.None,
0f);
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

+160
View File
@@ -0,0 +1,160 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class SubsumingTentacle : ModProjectile
{
public int AlphaFade
{
get => (int)projectile.localAI[0];
set => projectile.localAI[0] = value;
}
public Vector2 OffsetAcceleration
{
get => new Vector2(projectile.ai[0], projectile.ai[1]);
set
{
projectile.ai[0] = value.X;
projectile.ai[1] = value.Y;
}
}
public const float SegmentOffset = 5f;
public const float MaxArcingSpeed = 16f;
public const float MaxHomingSpeed = 18f;
public const float MaxEnemyDistance = 1450f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Tentacle");
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 75;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 20;
projectile.friendly = true;
projectile.penetrate = 2;
projectile.MaxUpdates = 2;
projectile.magic = true;
projectile.penetrate = -1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 16;
}
public override void AI()
{
if (!projectile.tileCollide)
{
AlphaFade++;
projectile.alpha = AlphaFade;
if (projectile.alpha >= 255)
{
projectile.Kill();
return;
}
}
// Here, the old positions act more like "control points" than old postions, and will be referred as such henceforth.
// Each control point should have a set offset, to give a "chain" effect.
for (int i = 1; i < projectile.oldPos.Length; i++)
{
projectile.oldPos[i] = projectile.oldPos[i - 1] + Vector2.Normalize(projectile.oldPos[i] - projectile.oldPos[i - 1]) * SegmentOffset;
}
CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(20f * projectile.scale));
if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height) && projectile.tileCollide)
{
projectile.tileCollide = false;
}
NPC closestTarget = projectile.Center.ClosestNPCAt(MaxEnemyDistance, true);
if (closestTarget != null)
{
HomingMovement(closestTarget);
}
else
{
ArcingMovement();
}
projectile.scale -= closestTarget == null ? 0.007f : 0.004f;
if (projectile.scale <= 0.05f)
{
projectile.Kill();
}
}
public void ArcingMovement()
{
// Cause the tentacle to arc around at an increasingly fast rate.
projectile.velocity += OffsetAcceleration;
if (projectile.velocity.Length() > MaxArcingSpeed)
{
projectile.velocity.Normalize();
projectile.velocity *= MaxArcingSpeed;
}
// Accelerate the arc.
OffsetAcceleration *= 1.035f;
}
public void HomingMovement(NPC closestTarget)
{
float angleOffset = MathHelper.WrapAngle(projectile.AngleTo(closestTarget.Center) - projectile.velocity.ToRotation());
angleOffset = MathHelper.Clamp(angleOffset, -0.2f, 0.2f);
if (projectile.Distance(closestTarget.Center) > 65f)
{
projectile.velocity = projectile.velocity.RotatedBy(angleOffset);
projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * MaxHomingSpeed;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
if (projectile.scale < 1f)
{
for (int i = 10; i < projectile.oldPos.Length; i++)
{
var tentacleShader = GameShaders.Misc["CalamityMod:SubsumingTentacle"];
tentacleShader.UseImage("Images/Misc/Perlin");
Vector2 drawPos = projectile.oldPos[i] + ModContent.GetTexture(Texture).Size() / 2f - Main.screenPosition + projectile.gfxOffY * Vector2.UnitY;
float scale = MathHelper.Lerp(0.05f, 1.3f, i / (float)projectile.oldPos.Length) * projectile.scale;
scale = MathHelper.Clamp(scale, 0f, 2f);
Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length);
spriteBatch.Draw(ModContent.GetTexture(Texture), drawPos, null, color, projectile.rotation, ModContent.GetTexture(Texture).Size() / 2f, scale, SpriteEffects.None, 0f);
tentacleShader.UseSaturation(i / (float)projectile.oldPos.Length); // A "completion ratio" for the shader. Used to make the entire tentacle appear multi-colored.
tentacleShader.UseOpacity(1f / projectile.oldPos.Length); // A "step value" for the shader. Used to give variance in color at each individual segment.
tentacleShader.Apply(null);
}
}
return false;
}
public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
{
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
for (int i = 1; i < projectile.oldPos.Length; i++)
{
float scale = MathHelper.Lerp(0.05f, 1f, i / (float)projectile.oldPos.Length) * projectile.scale * 0.85f;
if (targetHitbox.Intersects(new Rectangle((int)projectile.oldPos[i].X, (int)projectile.oldPos[i].Y, (int)(projectile.width * scale), (int)(projectile.height * scale))))
return true;
}
return false;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.velocity = oldVelocity;
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+102 -105
View File
@@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -10,9 +9,28 @@ namespace CalamityMod.Projectiles.Magic
{
public class Vortex : ModProjectile
{
public float TargetCheckCooldown
{
get => projectile.localAI[0];
set => projectile.localAI[0] = value;
}
public float Time
{
get => projectile.localAI[1];
set => projectile.localAI[1] = value;
}
public int TargetIndex
{
get => (int)projectile.ai[0];
set => projectile.ai[0] = value;
}
public const float AngularMovementSpeed = 0.1f;
public const float Acceleration = 0.0025f;
public const float TargetCheckInterval = 30f;
public const float MaximumTargetDistance = 1200f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Vortex");
DisplayName.SetDefault("Subsuming Vortex");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 20;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
@@ -24,10 +42,10 @@ namespace CalamityMod.Projectiles.Magic
projectile.alpha = 255;
projectile.friendly = true;
projectile.magic = true;
projectile.penetrate = 10;
projectile.timeLeft = 300;
projectile.penetrate = 1;
projectile.tileCollide = true;
projectile.extraUpdates = 4;
projectile.timeLeft = 115 * projectile.extraUpdates;
projectile.ignoreWater = true;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 5;
@@ -35,119 +53,98 @@ namespace CalamityMod.Projectiles.Magic
public override void AI()
{
projectile.localAI[1] += 1f;
// At the very beginning, start without a target.
if (Time == 0f)
{
TargetIndex = -1;
}
Time++;
if (projectile.localAI[1] > 10f && Main.rand.NextBool(3))
{
int num713 = 5;
for (int num714 = 0; num714 < num713; num714++)
{
Vector2 vector58 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width, (float)projectile.height) / 2f;
vector58 = vector58.RotatedBy((double)(num714 - (num713 / 2 - 1)) * 3.1415926535897931 / (double)(float)num713, default) + projectile.Center;
Vector2 value25 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8);
int num715 = Dust.NewDust(vector58 + value25, 0, 0, 66, value25.X * 2f, value25.Y * 2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.7f);
Main.dust[num715].noGravity = true;
Main.dust[num715].noLight = true;
Main.dust[num715].velocity /= 4f;
Main.dust[num715].velocity -= projectile.velocity;
}
projectile.alpha -= 5;
if (projectile.alpha < 50)
{
projectile.alpha = 50;
}
projectile.rotation += projectile.velocity.X * 0.1f;
Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f);
VisualEffects();
}
int num716 = -1;
Vector2 vector59 = projectile.Center;
float num717 = 350f * projectile.ai[1];
if (projectile.localAI[0] > 0f)
{
projectile.localAI[0] -= 1f;
}
if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f)
{
for (int num718 = 0; num718 < 200; num718++)
{
NPC nPC6 = Main.npc[num718];
if (nPC6.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(num718 + 1)))
{
Vector2 center4 = nPC6.Center;
float num719 = Vector2.Distance(center4, vector59);
if (num719 < num717 && Collision.CanHit(projectile.position, projectile.width, projectile.height, nPC6.position, nPC6.width, nPC6.height))
{
num717 = num719;
vector59 = center4;
num716 = num718;
}
}
}
if (num716 >= 0)
{
projectile.ai[0] = (float)(num716 + 1);
projectile.netUpdate = true;
}
}
if (projectile.localAI[0] == 0f && projectile.ai[0] == 0f)
{
projectile.localAI[0] = 30f;
}
bool flag32 = false;
if (projectile.ai[0] != 0f)
{
int num720 = (int)(projectile.ai[0] - 1f);
if (Main.npc[num720].active && !Main.npc[num720].dontTakeDamage && Main.npc[num720].immune[projectile.owner] == 0)
{
float num721 = Main.npc[num720].position.X + (float)(Main.npc[num720].width / 2);
float num722 = Main.npc[num720].position.Y + (float)(Main.npc[num720].height / 2);
float num723 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num721) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num722);
if (num723 < 1000f)
{
flag32 = true;
vector59 = Main.npc[num720].Center;
}
}
else
{
projectile.ai[0] = 0f;
flag32 = false;
projectile.netUpdate = true;
}
}
if (flag32)
{
Vector2 v = vector59 - projectile.Center;
float num724 = projectile.velocity.ToRotation();
float num725 = v.ToRotation();
float num726 = num725 - num724;
num726 = MathHelper.WrapAngle(num726);
projectile.velocity = projectile.velocity.RotatedBy(num726 * 0.1, default);
}
float num727 = projectile.velocity.Length();
projectile.velocity.Normalize();
projectile.velocity *= num727 + 0.0025f;
Movement(HandleTargeting());
projectile.rotation += projectile.velocity.X * 0.1f;
}
public override bool OnTileCollide(Vector2 oldVelocity)
public bool HandleTargeting()
{
projectile.penetrate--;
if (projectile.penetrate <= 0)
float targetCheckDistance = 350f * projectile.ai[1];
// Reduce a cooldown. Nothing special here.
if (TargetCheckCooldown > 0f)
{
projectile.Kill();
TargetCheckCooldown--;
}
else
// Attempt to find a target if the projectile has none.
if (TargetIndex == -1 && TargetCheckCooldown <= 0f)
{
projectile.ai[0] += 0.1f;
if (projectile.velocity.X != oldVelocity.X)
NPC potentialTarget = projectile.Center.ClosestNPCAt(targetCheckDistance, true);
if (potentialTarget != null)
TargetIndex = potentialTarget.whoAmI;
projectile.netUpdate = true;
}
if (TargetCheckCooldown <= 0f && TargetIndex == -1)
{
TargetCheckCooldown = TargetCheckInterval;
}
bool stillCanReachTarget = false;
// Ensure that the target is still in reach if there is indeed a target.
if (TargetIndex != -1)
{
stillCanReachTarget = projectile.Distance(Main.npc[TargetIndex].Center) < MaximumTargetDistance;
if (!stillCanReachTarget)
{
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y)
{
projectile.velocity.Y = -oldVelocity.Y;
TargetIndex = -1;
projectile.netUpdate = true;
}
}
return false;
return stillCanReachTarget;
}
public void VisualEffects()
{
// Generate idle circular dust and light after 10 frames.
if (!Main.dedServ)
{
int dustCount = 5;
for (int i = 0; i < dustCount; i++)
{
Vector2 spawnPosition = projectile.Center + projectile.Size.RotatedBy(i / (float)dustCount * MathHelper.TwoPi) * 0.5f;
Vector2 velocity = Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * Main.rand.NextFloat(6f, 16f);
Dust dust = Dust.NewDustPerfect(spawnPosition, 66, velocity, 0, Main.DiscoColor, 0.7f);
dust.noGravity = true;
dust.noLight = true;
dust.velocity = -projectile.velocity;
}
}
// Fade in.
projectile.alpha -= 5;
if (projectile.alpha < 50)
{
projectile.alpha = 50;
}
// And make rainbow light.
Lighting.AddLight(projectile.Center / 16, Main.DiscoColor.ToVector3());
}
public void Movement(bool stillCanReachTarget)
{
// Homing sharply towards the target in a circular fashion.
// The way this type of homing is by determining the offset between the angle to the target and the velocity's angle.
// This offset can be thought of as how much, in radians, the velocity would need to rotate to move towards the target.
// Then, the velocity is rotated by that offset (which, as established, would give perfect homing) multiplied by a <1 factor.
// This causes the velocity to constantly rotate sharply towards the target.
if (stillCanReachTarget)
{
float angleOffsetToTarget = projectile.AngleTo(Main.npc[TargetIndex].Center) - projectile.velocity.ToRotation();
angleOffsetToTarget = MathHelper.WrapAngle(angleOffsetToTarget); // Ensure the offset is in the range of -pi to pi.
projectile.velocity = projectile.velocity.RotatedBy(angleOffsetToTarget * AngularMovementSpeed);
}
// Accelerate constantly with time.
float oldSpeed = projectile.velocity.Length();
projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * (oldSpeed + Acceleration);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

+8 -12
View File
@@ -1,6 +1,7 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,8 +9,7 @@ namespace CalamityMod.Projectiles.Ranged
{
public class ExoFire : ModProjectile
{
public bool speedXChoice = false;
public bool speedYChoice = false;
public bool ProducedAcceleration = false;
public override void SetStaticDefaults()
{
@@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Ranged
public override void SetDefaults()
{
projectile.width = 12;
projectile.height = 12;
projectile.width = 24;
projectile.height = 24;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.ranged = true;
@@ -27,22 +27,18 @@ namespace CalamityMod.Projectiles.Ranged
projectile.extraUpdates = 10;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 5;
projectile.timeLeft = 300;
projectile.timeLeft = 180;
}
public override void AI()
{
float speedX = 1f;
float speedY = 1f;
if (!speedXChoice)
if (!ProducedAcceleration)
{
speedX = Main.rand.NextBool(2) ? 1.03f : 0.97f;
speedXChoice = true;
}
if (!speedYChoice)
{
speedY = Main.rand.NextBool(2) ? 1.03f : 0.97f;
speedYChoice = true;
projectile.velocity *= Utils.RandomVector2(Main.rand, 0.97f, 1.03f);
ProducedAcceleration = true;
}
projectile.velocity.X *= speedX;
projectile.velocity.X *= speedY;
+100
View File
@@ -0,0 +1,100 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ExoLight : ModProjectile
{
public float OffsetSpeed
{
get => projectile.ai[0];
set => projectile.ai[0] = value;
}
public float OffsetRotation
{
get => projectile.ai[1];
set => projectile.ai[1] = value;
}
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Light");
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 20;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 16;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.ranged = true;
projectile.penetrate = -1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 5;
projectile.timeLeft = 180;
}
public override void AI()
{
if (projectile.localAI[0] == 0f)
{
OffsetRotation = Main.rand.NextFloat(MathHelper.TwoPi);
OffsetSpeed = Main.rand.NextFloat(MathHelper.ToRadians(2.5f), MathHelper.ToRadians(4f)) * Main.rand.NextBool(2).ToDirectionInt();
projectile.localAI[0] = 1f;
}
Projectile owner = Main.projectile[(int)projectile.localAI[1]];
// Ensure the owner is the correct projectile.
if (owner.type != ModContent.ProjectileType<ExoLightBurst>())
projectile.Kill();
// Movement around the owner.
projectile.Center = owner.Center + OffsetRotation.ToRotationVector2() * (float)Math.Cos(OffsetRotation * 0.3f) * owner.Size * 0.5f;
projectile.rotation = (projectile.position - projectile.oldPos[1]).ToRotation();
OffsetRotation += OffsetSpeed;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D lightTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/PhotovisceratorLight");
for (int i = 0; i < projectile.oldPos.Length; i++)
{
float colorInterpolation = (float)Math.Cos(projectile.timeLeft / 16f + Main.GlobalTime / 20f + i / (float)projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f;
Color color = Color.Lerp(Color.LightGreen, Color.LightPink, colorInterpolation) * 0.4f;
color.A = 0;
Vector2 drawPosition = projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY);
Color outerColor = color;
Color innerColor = color * 0.5f;
float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTime % 60f * MathHelper.TwoPi);
// Become smaller the futher along the old positions we are.
intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)projectile.oldPos.Length);
Vector2 outerScale = new Vector2(1.65f) * intensity;
Vector2 innerScale = new Vector2(1.65f) * intensity * 0.7f;
outerColor *= intensity;
innerColor *= intensity;
spriteBatch.Draw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0);
spriteBatch.Draw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0);
}
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<ExoFreeze>(), 60);
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
target.AddBuff(ModContent.BuffType<GlacialState>(), 180);
target.AddBuff(ModContent.BuffType<Plague>(), 180);
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
target.AddBuff(BuffID.CursedInferno, 180);
target.AddBuff(BuffID.Frostburn, 180);
target.AddBuff(BuffID.OnFire, 180);
target.AddBuff(BuffID.Ichor, 180);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

+184
View File
@@ -0,0 +1,184 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ExoLightBomb : ModProjectile
{
public Vector2 InitialCenter;
public Vector2 Destination;
public const float MaxRadius = 90f;
public float Time
{
get => projectile.ai[0];
set => projectile.ai[0] = value;
}
public int DustType
{
get => (int)projectile.ai[1];
set => projectile.ai[1] = value;
}
public float YDirection
{
get => projectile.localAI[1];
set => projectile.localAI[1] = value;
}
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Light");
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 15;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 40;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.ranged = true;
projectile.penetrate = 1;
projectile.timeLeft = 300;
projectile.alpha = 127;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(YDirection);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
YDirection = reader.ReadSingle();
}
public override void AI()
{
Lighting.AddLight(projectile.Center, Color.DarkSlateGray.ToVector3());
projectile.alpha = (int)MathHelper.Lerp(255, 127, Utils.InverseLerp(0f, 25f, Time, true));
projectile.scale = MathHelper.Lerp(0.001f, 1f, Utils.InverseLerp(0f, 25f, Time, true));
if (projectile.localAI[0] == 0f)
{
InitialCenter = projectile.Center;
Destination = Main.MouseWorld;
DustType = Main.rand.NextBool(2) ? 107 : 234;
if (Main.rand.NextBool(4))
{
DustType = 269;
}
projectile.localAI[0] = 1f;
}
if (Time <= 90f)
{
projectile.position = Vector2.Lerp(InitialCenter, Destination, Time / 90f);
projectile.position.Y += (float)Math.Sin(Time / 90f * MathHelper.TwoPi) * 75f;
}
else if (Time < 180f)
{
// For those who haven't seen this yet (namely in the 1.4 source), this allows you to achieve a
// fade-in and fade-out effect with relative ease. At 90, multiply by 0, and somewhere in-between until 115, where you multiply by 1.
// And then do the same for the fade-out effect of 180f-165. These inverse linear interpolations cannot overlap by definition because
// their ranges do not overlap. Overall a really cool trick.
float radius = MaxRadius * Utils.InverseLerp(90f, 115f, Time, true) * Utils.InverseLerp(180f, 165f, Time, true);
radius *= 1f + (float)Math.Cos(Main.GlobalTime / 24f) * 0.25f;
if (radius < 5f)
radius = 5f;
projectile.Center = Destination + ((Time - 90) / 90f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius;
}
else if (Time == 180f)
{
projectile.Kill();
}
projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
Time++;
}
public void GenerateRotationalDust()
{
for (int i = 0; i < 9; i++)
{
float angle = Time / 45f + i / 9f * MathHelper.TwoPi;
Vector2 offsetSpan = angle.ToRotationVector2() * projectile.Size * 0.65f * projectile.scale;
Vector2 edgePosition = projectile.Center + offsetSpan.RotatedBy(projectile.rotation);
Dust dust = Dust.NewDustPerfect(edgePosition + Main.rand.NextVector2Circular(4f, 4f), DustType);
dust.velocity = Vector2.Zero;
dust.noGravity = true;
dust.scale = 0.65f;
}
}
public override Color? GetAlpha(Color lightColor)
{
return CalamityUtils.MulticolorLerp(Time / 60f % 1f, new Color[]
{
Color.PaleGreen,
Color.Violet,
Color.SlateGray
}) * projectile.Opacity;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D lightTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/PhotovisceratorLight");
for (int i = 0; i < projectile.oldPos.Length; i++)
{
float colorInterpolation = (float)Math.Cos(projectile.timeLeft / 16f + Main.GlobalTime / 20f + i / (float)projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f;
Color color = CalamityUtils.MulticolorLerp(MathHelper.Clamp(colorInterpolation, 0f, 0.99f), new Color[]
{
Color.PaleGreen,
Color.Violet,
Color.SlateGray
}) * projectile.Opacity;
color.A = 0;
Vector2 drawPosition = projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY);
Color outerColor = color;
Color innerColor = color * 0.5f;
float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTime % 60f * MathHelper.TwoPi);
// Become smaller the futher along the old positions we are.
intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)projectile.oldPos.Length);
Vector2 outerScale = new Vector2(1.25f) * intensity;
Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f;
outerColor *= intensity * projectile.scale;
innerColor *= intensity * projectile.scale;
spriteBatch.Draw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0);
spriteBatch.Draw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0);
}
return false;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item14, projectile.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
for (int i = 0; i < 3; i++)
{
Projectile.NewProjectileDirect(projectile.Center,
Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 16f,
ModContent.ProjectileType<ExoSpark>(),
projectile.damage,
projectile.knockBack * 0.3f,
projectile.owner);
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<ExoFreeze>(), 30);
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
target.AddBuff(ModContent.BuffType<GlacialState>(), 180);
target.AddBuff(ModContent.BuffType<Plague>(), 180);
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
target.AddBuff(BuffID.CursedInferno, 180);
target.AddBuff(BuffID.Frostburn, 180);
target.AddBuff(BuffID.OnFire, 180);
target.AddBuff(BuffID.Ichor, 180);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

+91
View File
@@ -0,0 +1,91 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ExoLightBurst : ModProjectile
{
public const float MinDistanceFromTarget = 45f;
public const float MaxDistanceFromTarget = 1350f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Flare");
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 190;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.ranged = true;
projectile.penetrate = -1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 5;
projectile.timeLeft = 180;
}
public override void AI()
{
// localAI[0] is used by the sticky AI method.
if (projectile.localAI[1] == 0f)
{
if (Main.netMode != NetmodeID.Server)
{
for (int i = 0; i < 5; i++)
{
Projectile.NewProjectileDirect(projectile.Center,
Vector2.Zero,
ModContent.ProjectileType<ExoLight>(),
projectile.damage,
projectile.knockBack,
projectile.owner).localAI[1] = Projectile.GetByUUID(projectile.owner, projectile.whoAmI);
}
}
projectile.localAI[1] = 1f;
}
if (projectile.ai[0] == 0f)
{
NPC potentialTarget = projectile.Center.ClosestNPCAt(MaxDistanceFromTarget, true);
if (potentialTarget != null)
{
if (projectile.Distance(potentialTarget.Center) > MinDistanceFromTarget)
{
float angleOffset = projectile.AngleTo(potentialTarget.Center) - projectile.velocity.ToRotation();
angleOffset = MathHelper.WrapAngle(angleOffset);
projectile.velocity = projectile.velocity.RotatedBy(MathHelper.Clamp(angleOffset, -0.1f, 0.1f));
}
}
}
CalamityUtils.StickyProjAI(projectile, 5);
}
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
CalamityUtils.ModifyHitNPCSticky(projectile, 4, false);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
int width = (int)MathHelper.Max(targetHitbox.Width, 150);
int height = (int)MathHelper.Max(targetHitbox.Height, 150);
CalamityGlobalProjectile.ExpandHitboxBy(projectile, width, height);
return null;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<ExoFreeze>(), 60);
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
target.AddBuff(ModContent.BuffType<GlacialState>(), 180);
target.AddBuff(ModContent.BuffType<Plague>(), 180);
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
target.AddBuff(BuffID.CursedInferno, 180);
target.AddBuff(BuffID.Frostburn, 180);
target.AddBuff(BuffID.OnFire, 180);
target.AddBuff(BuffID.Ichor, 180);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

+84
View File
@@ -0,0 +1,84 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ExoSpark : ModProjectile
{
public static readonly int[] FrameToDustIDTable = new int[]
{
107,
234,
269,
};
public const float HomingInertia = 10f;
public const float MaxTargetDistance = 750f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Spark");
Main.projFrames[projectile.type] = 3;
}
public override void SetDefaults()
{
projectile.width = 28;
projectile.height = 14;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.ranged = true;
projectile.penetrate = 1;
projectile.timeLeft = 600;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 4;
}
public override void AI()
{
if (projectile.localAI[0] == 0f)
{
projectile.frame = Main.rand.Next(3);
projectile.localAI[0] = 1f;
projectile.netUpdate = true;
}
NPC potentialTarget = projectile.Center.ClosestNPCAt(MaxTargetDistance);
if (potentialTarget != null)
{
projectile.velocity = (projectile.velocity * (HomingInertia - 1) + projectile.DirectionTo(potentialTarget.Center) * 16f) / HomingInertia;
}
projectile.rotation = projectile.velocity.ToRotation();
if (!Main.dedServ)
{
GenerateCircularDust();
}
}
public void GenerateCircularDust()
{
for (int i = 0; i < 12; i++)
{
float angle = i / 12f * MathHelper.TwoPi;
Vector2 spawnPosition = projectile.Center + angle.ToRotationVector2().RotatedBy(projectile.rotation) * new Vector2(10f, 6f);
Dust dust = Dust.NewDustPerfect(spawnPosition, FrameToDustIDTable[projectile.frame]);
dust.velocity = Vector2.Zero;
dust.scale = 0.5f;
dust.noGravity = true;
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 60);
target.AddBuff(ModContent.BuffType<GlacialState>(), 60);
target.AddBuff(ModContent.BuffType<Plague>(), 60);
target.AddBuff(ModContent.BuffType<HolyFlames>(), 60);
target.AddBuff(BuffID.CursedInferno, 120);
target.AddBuff(BuffID.Frostburn, 120);
target.AddBuff(BuffID.OnFire, 120);
target.AddBuff(BuffID.Ichor, 120);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

+352
View File
@@ -0,0 +1,352 @@
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using CalamityMod.Projectiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class GastricBelcher : ModProjectile
{
private bool initialized = false;
private int bubbleCounter = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Gastric Belcher");
Main.projFrames[projectile.type] = 4;
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = 40;
projectile.height = 40;
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;
}
public override void AI()
{
//Set namespaces
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
CalamityGlobalProjectile modProj = projectile.Calamity();
//On spawn effects
if (!initialized)
{
//Set constants
modProj.spawnedPlayerMinionDamageValue = player.MinionDamage();
modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage;
//Spawn dust
int dustAmt = 36;
for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++)
{
int randomDust = Utils.SelectRandom(Main.rand, new int[]
{
33,
89
});
Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f;
direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center;
Vector2 dustVel = direction - projectile.Center;
int water = Dust.NewDust(direction + dustVel, 0, 0, randomDust, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f);
Main.dust[water].noGravity = true;
Main.dust[water].velocity = dustVel;
}
initialized = true;
}
//Flexible minion damage update
if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue)
{
int damage2 = (int)(modProj.spawnedPlayerMinionProjectileDamageValue /
modProj.spawnedPlayerMinionDamageValue * player.MinionDamage());
projectile.damage = damage2;
}
//Update frames
if (projectile.frameCounter++ % 6 == 0)
{
projectile.frame++;
}
if (projectile.frame >= Main.projFrames[projectile.type])
{
projectile.frame = 0;
}
//Set up buff and timeLeft
bool typeCheck = projectile.type == ModContent.ProjectileType<GastricBelcher>();
player.AddBuff(ModContent.BuffType<GastricBelcherBuff>(), 3600);
if (typeCheck)
{
if (player.dead)
{
modPlayer.gastricBelcher = false;
}
if (modPlayer.gastricBelcher)
{
projectile.timeLeft = 2;
}
}
//Anti sticky movement to prevent overlapping minions
float antiStickMvt = 0.05f;
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
{
Projectile proj = Main.projectile[projIndex];
bool correctMinion = proj.type == ModContent.ProjectileType<GastricBelcher>();
if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && correctMinion && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
{
if (projectile.position.X < proj.position.X)
{
projectile.velocity.X -= antiStickMvt;
}
else
{
projectile.velocity.X += antiStickMvt;
}
if (projectile.position.Y < proj.position.Y)
{
projectile.velocity.Y -= antiStickMvt;
}
else
{
projectile.velocity.Y += antiStickMvt;
}
}
}
//Find a target
float maxDistance = 700f;
Vector2 targetVec = projectile.position;
Vector2 half = new Vector2(0.5f);
bool foundTarget = false;
//If targeting something, prioritize that enemy
if (player.HasMinionAttackTargetNPC)
{
NPC npc = Main.npc[player.MinionAttackTargetNPC];
if (npc.CanBeChasedBy(projectile, false))
{
//Adding a check on the NPC's size allows it to target big things like Providence
Vector2 sizeCheck = npc.position + npc.Size * half;
//Check if blocks are in the way
bool collisionCheck = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
//Calculate distance between target and the projectile to know if it's too far or not
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
if (!foundTarget && targetDist < maxDistance && collisionCheck)
{
maxDistance = targetDist;
targetVec = sizeCheck;
foundTarget = true;
}
}
}
else
{
for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
{
NPC npc = Main.npc[npcIndex];
if (npc.CanBeChasedBy(projectile, false))
{
Vector2 sizeCheck = npc.position + npc.Size * half;
bool collisionCheck = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
if (!foundTarget && targetDist < maxDistance && collisionCheck)
{
maxDistance = targetDist;
targetVec = sizeCheck;
foundTarget = true;
}
}
}
}
//If too far, make the minion start returning to the player.
float returnDist = 1000f;
if (foundTarget)
{
//Max travel distance increases if targeting something
returnDist = 2200f;
}
if (Vector2.Distance(player.Center, projectile.Center) > returnDist)
{
projectile.ai[0] = 1f;
projectile.netUpdate = true;
}
//If a target is found, move toward it
if (foundTarget && projectile.ai[0] == 0f)
{
Vector2 vecToTarget = targetVec - projectile.Center;
float targetDist = vecToTarget.Length();
vecToTarget.Normalize();
//If farther than 200 pixels, move toward it
if (targetDist > 200f)
{
float speedMult = (targetDist > 400f) ? 12f : (targetDist > 250) ? 6f : 3f;
vecToTarget *= speedMult;
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
}
//Otherwise, back it up slowly
else
{
float speedMult = -3f;
vecToTarget *= speedMult;
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
}
}
//If not targeting something, act passively
else
{
bool returningToPlayer = false;
if (!returningToPlayer)
{
returningToPlayer = projectile.ai[0] == 1f;
}
//Move faster if actively returning to the player
float speedMult = 10f;
if (returningToPlayer)
{
speedMult = 21f;
}
Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -60f);
float playerDist = vecToPlayer.Length();
//Slow down if near the player
if (playerDist < 200f && speedMult > 8f)
{
speedMult = 1f;
}
//If close enough to the player, return to normal
if (playerDist < 150f && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
{
projectile.ai[0] = 0f;
projectile.netUpdate = true;
}
//If abnormally far, teleport to the player
if (playerDist > 2000f)
{
projectile.position.X = player.Center.X - (projectile.width / 2f);
projectile.position.Y = player.Center.Y - (projectile.height / 2f);
projectile.netUpdate = true;
}
//Move toward player if more than 70 pixels away
if (playerDist > 70f)
{
vecToPlayer.Normalize();
vecToPlayer *= speedMult;
projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f;
}
//Move if still
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
{
projectile.velocity.X = -0.15f;
projectile.velocity.Y = -0.05f;
}
}
//Update sprite direction and rotation
if (foundTarget)
{
projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt();
projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi), 0.1f);
}
else
{
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi);
}
//Increment attack cooldown
if (projectile.ai[1] > 0f)
{
projectile.ai[1] += Main.rand.Next(1, 4);
}
//Set the minion to be ready for attack
if (projectile.ai[1] > 90f)
{
projectile.ai[1] = 0f;
projectile.netUpdate = true;
}
//Return if on attack cooldown, has no target, or returning to the player
if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f)
return;
if (Main.myPlayer == projectile.owner)
{
//Play vomit sound
if (modPlayer.soundCooldown <= 0)
{
Main.PlaySound(SoundID.NPCKilled, (int)projectile.Center.X, (int)projectile.Center.Y, 13, 0.5f, 0f);
modPlayer.soundCooldown = Main.rand.Next(120, 180);
}
//Increment the attack counter
projectile.ai[1]++;
int projType = ModContent.ProjectileType<GastricBelcherVomit>();
//Calculate the general velocity
Vector2 velocity = targetVec - projectile.Center;
velocity.Normalize();
//Add some inaccuracy for the vomit projectiles
float vomitSpeedMult = 16f;
Vector2 vomitVel = velocity * vomitSpeedMult;
vomitVel.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f;
vomitVel.X += Main.rand.NextFloat(-30f, 30f) * 0.05f;
//Fire the vomit projectile
Projectile.NewProjectile(projectile.Center, vomitVel, projType, projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0f);
//Fire 5 bubbles for every three attacks
if (bubbleCounter++ % 3 == 2)
{
for (int projCount = 0; projCount < 5; projCount++)
{
//Add a shotgun spread to the bubbles
float bubbleSpeedMult = 14f;
Vector2 bubbleVel = velocity * bubbleSpeedMult;
bubbleVel.Y += Main.rand.NextFloat(-50f, 50f) * 0.05f;
bubbleVel.X += Main.rand.NextFloat(-50f, 50f) * 0.05f;
Projectile.NewProjectile(projectile.Center, bubbleVel, ModContent.ProjectileType<GastricBelcherBubble>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
}
}
projectile.netUpdate = true;
}
}
//This minion does no contact damage
public override bool CanDamage() => false;
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D texture = Main.projectileTexture[projectile.type];
int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
int y6 = frameHeight * projectile.frame;
SpriteEffects spriteEffects = SpriteEffects.None;
if (projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

@@ -0,0 +1,44 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class GastricBelcherBubble : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Gastric Bubble");
ProjectileID.Sets.MinionShot[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.friendly = true;
projectile.width = projectile.height = 18;
projectile.minion = true;
projectile.timeLeft = 180;
projectile.aiStyle = 72;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item54, projectile.position);
Vector2 center = projectile.Center;
for (int dustIndex = 0; dustIndex < 10; ++dustIndex)
{
int scalar = (int)(10 * projectile.ai[1]);
int bubble = Dust.NewDust(projectile.Center - Vector2.One * scalar, scalar * 2, scalar * 2, 212, 0.0f, 0.0f, 0, new Color(), 1f);
Dust dust = Main.dust[bubble];
Vector2 dustVec = Vector2.Normalize(dust.position - projectile.Center);
dust.position = projectile.Center + dustVec * scalar * projectile.scale;
dust.velocity = dustIndex >= 30 ? dustVec * Main.rand.Next(45, 91) / 10f : dustVec * dust.velocity.Length();
dust.color = Main.hslToRgb(0.4f + Main.rand.NextFloat() * 0.2f, 0.9f, 0.5f);
dust.color = Color.Lerp(dust.color, Color.White, 0.3f);
dust.noGravity = true;
dust.scale = 0.7f;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

+66
View File
@@ -0,0 +1,66 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class GastricBelcherVomit : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Gastric Vomit");
ProjectileID.Sets.MinionShot[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.friendly = true;
projectile.width = projectile.height = 18;
projectile.minion = true;
projectile.timeLeft = 300;
projectile.penetrate = 3;
projectile.usesIDStaticNPCImmunity = true;
projectile.idStaticNPCHitCooldown = 10;
}
public override void AI()
{
//Rotation and gravity
projectile.rotation += 0.6f * projectile.direction;
projectile.velocity.Y += 0.27f;
if (projectile.velocity.Y > 16f)
{
projectile.velocity.Y = 16f;
}
}
public override void Kill(int timeLeft)
{
Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y);
//Dust effect
int splash = 0;
while (splash < 4)
{
Dust.NewDust(projectile.position, projectile.width, projectile.height, 233, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.9f);
splash += 1;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D texture;
switch (projectile.ai[0])
{
case 1f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit2");
break;
case 2f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit3");
break;
default: texture = Main.projectileTexture[projectile.type];
break;
}
Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

+13
View File
@@ -2419,6 +2419,19 @@ namespace CalamityMod
float colorMePurple = (float)((Math.Sin(timeMult * Main.GlobalTime) + 1) * 0.5f);
return Color.Lerp(firstColor, secondColor, colorMePurple);
}
/// <summary>
/// Returns a color lerp that supports multiple colors.
/// </summary>
/// <param name="increment">The 0-1 incremental value used when interpolating.</param>
/// <param name="colors">The various colors to interpolate across.</param>
/// <returns></returns>
public static Color MulticolorLerp(float increment, params Color[] colors)
{
int currentColorIndex = (int)(increment * colors.Length);
Color currentColor = colors[currentColorIndex];
Color nextColor = colors[(currentColorIndex + 1) % colors.Length];
return Color.Lerp(currentColor, nextColor, increment * colors.Length % 1f);
}
#endregion
#region Miscellaneous Utilities