Deathstare rod

This commit is contained in:
DominicKarma committed 2020-10-15 16:48:04 -05:00
1 parent dff2f3eaa3
commit 069b0b4bbc
12 files changed
+312

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 DeathstareBuff : ModBuff
{
public override void SetDefaults()
{
DisplayName.SetDefault("Miniature Eye of Cthulhu");
Description.SetDefault("It's watching 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<DeathstareEyeball>()] > 0)
{
modPlayer.deathstareEyeball = true;
}
if (!modPlayer.deathstareEyeball)
{
player.DelBuff(buffIndex);
buffIndex--;
}
else
{
player.buffTime[buffIndex] = 18000;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

+2
View File
@@ -952,6 +952,7 @@ namespace CalamityMod.CalPlayer
public bool howlTrio = false;
public bool mountedScanner = false;
public bool viridVanguard = false;
public bool deathstareEyeball = false;
#endregion
#region Biome
@@ -1978,6 +1979,7 @@ namespace CalamityMod.CalPlayer
howlTrio = false;
mountedScanner = false;
viridVanguard = false;
deathstareEyeball = false;
abyssalDivingSuitPrevious = abyssalDivingSuit;
abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false;
+1
View File
@@ -2983,6 +2983,7 @@ Grants immunity to fire blocks, and temporary immunity to lava";
case ItemID.EyeOfCthulhuBossBag:
DropHelper.DropItem(player, ModContent.ItemType<VictoryShard>(), 3, 5);
DropHelper.DropItemChance(player, ModContent.ItemType<TeardropCleaver>(), 3);
DropHelper.DropItemChance(player, ModContent.ItemType<DeathstareRod>(), 3);
DropHelper.DropItemCondition(player, ModContent.ItemType<CounterScarf>(), CalamityWorld.revenge);
break;
+42
View File
@@ -0,0 +1,42 @@
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Summon
{
public class DeathstareRod : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Deathstare Rod");
Tooltip.SetDefault("Summons an eye above your head that watches you and shoots at enemies");
}
public override void SetDefaults()
{
item.damage = 33;
item.mana = 10;
item.width = item.height = 42;
item.useTime = item.useAnimation = 35;
item.useStyle = ItemUseStyleID.SwingThrow;
item.noMelee = true;
item.knockBack = 2f;
item.value = CalamityGlobalItem.Rarity1BuyPrice;
item.rare = ItemRarityID.Blue;
item.UseSound = SoundID.NPCHit8;
item.autoReuse = true;
item.shoot = ModContent.ProjectileType<DeathstareEyeball>();
item.shootSpeed = 10f;
item.summon = true;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
CalamityUtils.KillShootProjectiles(true, type, player);
Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

+1
View File
@@ -1471,6 +1471,7 @@ namespace CalamityMod.NPCs
case NPCID.EyeofCthulhu:
DropHelper.DropItemCondition(npc, ModContent.ItemType<VictoryShard>(), !Main.expertMode, 2, 4);
DropHelper.DropItemCondition(npc, ModContent.ItemType<DeathstareRod>(), !Main.expertMode, 5, 1, 1);
DropHelper.DropItemCondition(npc, ModContent.ItemType<TeardropCleaver>(), !Main.expertMode, 5, 1, 1);
break;
+51
View File
@@ -0,0 +1,51 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class DeathstareBeam : ModProjectile
{
public ref float OwnerUUID => ref projectile.ai[0];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Beam");
ProjectileID.Sets.MinionShot[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = 10;
projectile.height = 10;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.minion = true;
projectile.ignoreWater = true;
projectile.timeLeft = 10;
}
public override void AI()
{
if (!Main.projectile.IndexInRange((int)OwnerUUID))
{
projectile.Kill();
return;
}
projectile.Opacity = Utils.InverseLerp(1f, 0f, 1f - projectile.timeLeft / 10f, true);
projectile.Center = Main.projectile[(int)OwnerUUID].Center - projectile.velocity;
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D beamTexture = Main.projectileTexture[projectile.type];
Vector2 drawPosition = projectile.Center + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition;
Vector2 drawScale = new Vector2(0.55f, projectile.velocity.Length() / beamTexture.Height * 20f);
Color color = Color.White * 2.1f * projectile.Opacity;
spriteBatch.Draw(beamTexture, drawPosition, null, color, projectile.rotation, beamTexture.Frame().Bottom(), drawScale, SpriteEffects.None, 0f);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

+179
View File
@@ -0,0 +1,179 @@
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
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 DeathstareEyeball : ModProjectile
{
// This does not need to be synced. It is used solely for drawcode/visuals and is intended to be local.
public float PupilScale = 1f;
public const int BeamFireRate = 60;
public Player Owner => Main.player[projectile.owner];
public ref float Time => ref projectile.ai[1];
public ref float PupilAngle => ref projectile.localAI[0];
public ref float PupilOutwardness => ref projectile.localAI[1];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Eyeball");
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 16;
projectile.netImportant = true;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.minionSlots = 1f;
projectile.timeLeft = 90000;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.minion = true;
}
#region AI
public override void AI()
{
Lighting.AddLight(projectile.Center, Color.Blue.ToVector3());
bool isCorrectMinion = projectile.type == ModContent.ProjectileType<DeathstareEyeball>();
CalamityPlayer modPlayer = Owner.Calamity();
Owner.AddBuff(ModContent.BuffType<DeathstareBuff>(), 3600);
// Ensure that the projectile executing this code is a valid one.
if (isCorrectMinion)
{
if (Owner.dead)
modPlayer.deathstareEyeball = false;
if (modPlayer.deathstareEyeball)
projectile.timeLeft = 2;
}
Vector2 destination = Owner.Center + Vector2.UnitY * (Owner.gfxOffY - 110f);
if (Owner.gravDir == -1f)
destination.Y += 220f;
// Very quickly fly towards above (or below if gravity is reversed) the player.
projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.36f);
projectile.position = projectile.position.Floor();
projectile.rotation = (projectile.position.X - projectile.oldPosition.X) * 0.07f + Owner.velocity.X * 0.2f;
projectile.rotation = Utils.Clamp(projectile.rotation, -0.4f, 0.4f);
if (projectile.localAI[0] == 0f)
{
Initialize(Owner);
projectile.localAI[0] = 1f;
}
if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue)
{
int trueDamage = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue /
projectile.Calamity().spawnedPlayerMinionDamageValue *
Owner.MinionDamage());
projectile.damage = trueDamage;
}
NPC potentialTarget = projectile.Center.MinionHoming(720f, Owner);
if (potentialTarget is null)
DoHoveringAI();
else
DoAttackingAI(potentialTarget);
projectile.frame = (int)(Time / 5) % 4;
Time++;
}
public void DoHoveringAI()
{
// Roll the pupil around if there's little movement from the eye and player.
if (Time % 180f > 120f && Math.Abs(projectile.rotation) < 0.03f)
{
float idealAngle = Utils.InverseLerp(120f, 180f, Time % 180f, true) * MathHelper.TwoPi;
PupilAngle = PupilAngle.AngleTowards(idealAngle, MathHelper.ToRadians(12f));
PupilOutwardness = MathHelper.Lerp(PupilOutwardness, 4f, 0.2f);
}
else
{
float idealOutwardness = MathHelper.Clamp(Owner.velocity.Length() * 0.5f, 0f, 5f);
float idealAngle = Owner.velocity.ToRotation();
PupilOutwardness = MathHelper.Lerp(PupilOutwardness, idealOutwardness, 0.2f);
PupilAngle = PupilAngle.AngleTowards(idealAngle, MathHelper.ToRadians(12f));
}
}
public void DoAttackingAI(NPC target)
{
PupilOutwardness = MathHelper.Lerp(PupilOutwardness, 4f, 0.25f);
if (Time % BeamFireRate == BeamFireRate - 20)
{
if (Main.myPlayer == projectile.owner)
{
Vector2 velocity = (target.Center - projectile.Center) / 15f;
int beam = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType<DeathstareBeam>(), projectile.damage, projectile.knockBack, projectile.owner);
Main.projectile[beam].ai[0] = Projectile.GetByUUID(projectile.owner, projectile.whoAmI);
Main.projectile[beam].Damage();
}
PupilScale = 1.5f;
}
// After firing, have the pupil retract a bit.
if (Time % BeamFireRate > BeamFireRate - 20)
{
PupilScale = MathHelper.Lerp(PupilScale, 0.7f, 0.15f);
}
// Otherwise, have it behave like normal.
else
{
PupilScale = MathHelper.Lerp(PupilScale, 1f, 0.175f);
PupilAngle = PupilAngle.AngleTowards(projectile.AngleTo(target.Center), MathHelper.ToRadians(15f));
}
}
public void Initialize(Player player)
{
projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage();
projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage;
if (!Main.dedServ)
return;
for (int i = 0; i < 25; i++)
{
Dust dust = Dust.NewDustDirect(projectile.position, 52, 52, DustID.Blood);
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.2f, 1.5f);
}
}
#endregion
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D eyeTexture = Main.projectileTexture[projectile.type];
Rectangle frame = eyeTexture.Frame(1, 4, 0, projectile.frame);
Vector2 origin = frame.Size() * 0.5f;
SpriteEffects spriteEffects = Owner.gravDir == 1 ? SpriteEffects.None : SpriteEffects.FlipVertically;
spriteBatch.Draw(eyeTexture, projectile.Center - Main.screenPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, spriteEffects, 0f);
// Pupil drawing.
Texture2D pupilTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/DeathstareEyePupil");
Vector2 pupilDrawPosition = projectile.Center - Main.screenPosition + PupilAngle.ToRotationVector2() * PupilOutwardness;
spriteBatch.Draw(pupilTexture, pupilDrawPosition, null, projectile.GetAlpha(lightColor), PupilAngle, pupilTexture.Size() * 0.5f, PupilScale, spriteEffects, 0f);
return false;
}
public override bool CanDamage() => false;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B