Merge pull request #101 from UncleDanny/chromatic-orb-bendy-light-pet

Added Bendy's light pet, the Chromatic Orb
This commit is contained in:
Cameron Ewell authored and GitHub committed 2020-06-15 21:37:36 -04:00
commit 50858bd5a7
11 files changed
+330 -5

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
using CalamityMod.Projectiles.Pets;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Pets
{
public class BendyBuff : ModBuff
{
public override void SetDefaults()
{
DisplayName.SetDefault("Dreamfog");
Description.SetDefault("Xi believes in Yuu");
Main.buffNoTimeDisplay[Type] = true;
Main.lightPet[Type] = true;
}
public override void Update(Player player, ref int buffIndex)
{
player.buffTime[buffIndex] = 18000;
player.Calamity().bendyPet = true;
bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType<BendyPet>()] <= 0;
if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
{
Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, ModContent.ProjectileType<BendyPet>(), 0, 0f, player.whoAmI, 0f, 0f);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

+4
View File
@@ -289,6 +289,7 @@ namespace CalamityMod.CalPlayer
public bool babyGhostBell = false;
public bool radiator = false;
public bool scalPet = false;
public bool bendyPet = false;
#endregion
#region Rage
@@ -1338,6 +1339,7 @@ namespace CalamityMod.CalPlayer
babyGhostBell = false;
radiator = false;
scalPet = false;
bendyPet = false;
onyxExcavator = false;
angryDog = false;
fab = false;
@@ -11842,6 +11844,8 @@ namespace CalamityMod.CalPlayer
light += 1;
if (radiator)
light += 1;
if (bendyPet)
light += 1;
if (sparks)
light += 1;
if (fathomSwarmerVisage)
+35
View File
@@ -0,0 +1,35 @@
using CalamityMod.Buffs.Pets;
using CalamityMod.Projectiles.Pets;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Pets
{
public class ChromaticOrb : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Chromatic Orb");
Tooltip.SetDefault("It glows warmly in your hand\n" +
"Summons an ancient dragon light pet that highlights nearby enemies and danger sources\n" +
"Provides a small amount of light in the abyss");
}
public override void SetDefaults()
{
item.CloneDefaults(ItemID.WispinaBottle);
item.shoot = ModContent.ProjectileType<BendyPet>();
item.buffType = ModContent.BuffType<BendyBuff>();
item.Calamity().customRarity = CalamityRarity.Dedicated;
}
public override void UseStyle(Player player)
{
if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
{
player.AddBuff(item.buffType, 3600, true);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

+3 -4
View File
@@ -1,6 +1,7 @@
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Pets;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Magic;
@@ -33,10 +34,7 @@ namespace CalamityMod.Items.TreasureBags
item.rare = 9;
}
public override bool CanRightClick()
{
return true;
}
public override bool CanRightClick() => true;
public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item);
@@ -58,6 +56,7 @@ namespace CalamityMod.Items.TreasureBags
// Equipment
DropHelper.DropItemRIV(player, ModContent.ItemType<AstralBulwark>(), ModContent.ItemType<HideofAstrumDeus>(), 1f, DropHelper.RareVariantDropRateFloat);
DropHelper.DropItemChance(player, ModContent.ItemType<ChromaticOrb>(), 5);
// Vanity
DropHelper.DropItemChance(player, ModContent.ItemType<AstrumDeusMask>(), 7);
+1 -1
View File
@@ -397,7 +397,7 @@ namespace CalamityMod
List<int> segments = new List<int>() { NPCType<AstrumDeusHeadSpectral>(), NPCType<AstrumDeusBodySpectral>(), NPCType<AstrumDeusTailSpectral>() };
int summon = ItemType<Starcore>();
List<int> loot = new List<int>() { ItemType<AstrumDeusBag>(), ItemType<Stardust>(), ItemID.FallenStar, ItemType<TheMicrowave>(), ItemType<StarSputter>(), ItemType<Starfall>(), ItemType<GodspawnHelixStaff>(), ItemType<RegulusRiot>(), ItemType<Quasar>(), ItemType<AstralBulwark>(), ItemType<HideofAstrumDeus>(), ItemID.FragmentSolar, ItemID.FragmentVortex, ItemID.FragmentNebula, ItemID.FragmentStardust, ItemID.GreaterHealingPotion };
List<int> collection = new List<int>() { ItemType<AstrumDeusTrophy>(), ItemType<AstrumDeusMask>(), ItemType<KnowledgeAstrumDeus>(), ItemType<KnowledgeAstralInfection>() };
List<int> collection = new List<int>() { ItemType<AstrumDeusTrophy>(), ItemType<AstrumDeusMask>(), ItemType<KnowledgeAstrumDeus>(), ItemType<KnowledgeAstralInfection>(), ItemType<ChromaticOrb>() };
string instructions = $"Defeat 3 empowered astral titans or use a [i:{summon}] at Night";
string despawn = CalamityUtils.ColorMessage("The infected deity retreats to the heavens.", new Color(0xFF, 0xD7, 0x00));
string bossLogTex = "CalamityMod/NPCs/AstrumDeus/AstrumDeus_BossChecklist";
@@ -4,6 +4,7 @@ using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
using CalamityMod.Items.LoreItems;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Pets;
using CalamityMod.Items.Placeables.Furniture.Trophies;
using CalamityMod.Items.TreasureBags;
using CalamityMod.Items.Weapons.Melee;
@@ -233,6 +234,7 @@ namespace CalamityMod.NPCs.AstrumDeus
// Equipment
DropHelper.DropItemChance(npc, ModContent.ItemType<HideofAstrumDeus>(), DropHelper.RareVariantDropRateInt);
DropHelper.DropItemChance(npc, ModContent.ItemType<ChromaticOrb>(), 5);
// Vanity
DropHelper.DropItemChance(npc, ModContent.ItemType<AstrumDeusMask>(), 7);
+257
View File
@@ -0,0 +1,257 @@
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.Pets
{
public class BendyPet : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Dreamfog Dragon");
Main.projFrames[projectile.type] = 5;
Main.projPet[projectile.type] = true;
ProjectileID.Sets.LightPet[projectile.type] = true;
}
public override void SetDefaults()
{
projectile.netImportant = true;
projectile.width = 38;
projectile.height = 56;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.timeLeft *= 5;
projectile.ignoreWater = true;
projectile.tileCollide = false;
}
public override void AI()
{
//Set up namespaces
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
//If the player dies or something, kill thte projectile
if (!player.active)
{
projectile.active = false;
return;
}
if (player.dead)
{
modPlayer.bendyPet = false;
}
//Prevent the projectile from losing its timeLeft
if (modPlayer.bendyPet)
{
projectile.timeLeft = 2;
}
//Update frames
projectile.frameCounter++;
if (projectile.frameCounter > 6)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= Main.projFrames[projectile.type])
{
projectile.frame = 0;
}
//Highlight nearby danger sources
player.dangerSense = true;
player.detectCreature = true;
//Generate less light if returning to the player
if (projectile.localAI[0] == 0f)
{
Lighting.AddLight(projectile.Center, 0.8118f, 0.2529f, 1.3294f); //138, 43, 226
}
else
{
Lighting.AddLight(projectile.Center, 0.4329f, 0.1349f, 0.709f);
}
float idleMvt = 0.2f;
float projSpeed = 5f;
//Calculate where the pet should reside based on pressed controls
Vector2 projVec = player.Center - projectile.Center;
projVec.Y += player.gfxOffY;
if (player.controlLeft)
{
projVec.X -= 120f;
}
else if (player.controlRight)
{
projVec.X += 120f;
}
if (player.controlDown)
{
projVec.Y += 120f;
}
else
{
if (player.controlUp)
{
projVec.Y -= 120f;
}
projVec.Y -= 60f;
}
float playerDist = projVec.Length();
if (playerDist > 1000f)
{
projectile.position.X += projVec.X;
projectile.position.Y += projVec.Y;
}
//Returning to player AI
if (projectile.localAI[0] == 1f)
{
//If close enough, the player isn't moving too much, and isn't moving vertically, return to normal
if (playerDist < 10f && Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y) < projSpeed && player.velocity.Y == 0f)
{
projectile.localAI[0] = 0f;
}
//Go faster
projSpeed = 12f;
if (playerDist < projSpeed)
{
projectile.velocity.X = projVec.X;
projectile.velocity.Y = projVec.Y;
}
else
{
playerDist = projSpeed / playerDist;
projectile.velocity.X = projVec.X * playerDist;
projectile.velocity.Y = projVec.Y * playerDist;
}
//Set projectile direction and rotation
if (projectile.velocity.X > 0.5f)
{
projectile.direction = -1;
}
else if (projectile.velocity.X < -0.5f)
{
projectile.direction = 1;
}
projectile.spriteDirection = projectile.direction;
projectile.rotation = projectile.velocity.X * 0.05f;
return;
}
//If too far, return to the player
if (playerDist > 200f)
{
projectile.localAI[0] = 1f;
}
//Set projectile direction and rotation
if (projectile.velocity.X > 0.5f)
{
projectile.direction = -1;
}
else if (projectile.velocity.X < -0.5f)
{
projectile.direction = 1;
}
projectile.spriteDirection = projectile.direction;
if (playerDist < 10f)
{
projectile.velocity.X = projVec.X;
projectile.velocity.Y = projVec.Y;
projectile.rotation = projectile.velocity.X * 0.05f;
if (playerDist < projSpeed)
{
projectile.position += projectile.velocity;
projectile.velocity *= 0f;
idleMvt = 0f;
}
projectile.direction = -player.direction;
}
playerDist = projSpeed / playerDist;
projVec.X *= playerDist;
projVec.Y *= playerDist;
if (projectile.velocity.X < projVec.X)
{
projectile.velocity.X += idleMvt;
if (projectile.velocity.X < 0f)
{
projectile.velocity.X *= 0.99f;
}
}
if (projectile.velocity.X > projVec.X)
{
projectile.velocity.X -= idleMvt;
if (projectile.velocity.X > 0f)
{
projectile.velocity.X *= 0.99f;
}
}
if (projectile.velocity.Y < projVec.Y)
{
projectile.velocity.Y += idleMvt;
if (projectile.velocity.Y < 0f)
{
projectile.velocity.Y *= 0.99f;
}
}
if (projectile.velocity.Y > projVec.Y)
{
projectile.velocity.Y -= idleMvt;
if (projectile.velocity.Y > 0f)
{
projectile.velocity.Y *= 0.99f;
}
}
//Rotation if moving
if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f)
{
projectile.rotation = projectile.velocity.X * 0.05f;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D texture = Main.projectileTexture[projectile.type];
int height = texture.Height / Main.projFrames[projectile.type];
int frameHeight = height * projectile.frame;
SpriteEffects spriteEffects = SpriteEffects.None;
if (projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f);
return false;
}
public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/BendyPetGlow");
int height = texture.Height / Main.projFrames[projectile.type];
int frameHeight = height * projectile.frame;
SpriteEffects spriteEffects = SpriteEffects.None;
if (projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Color rainbow = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[]
{
new Color(255, 0, 0, 50), //Red
new Color(255, 255, 0, 50), //Yellow
new Color(0, 255, 0, 50), //Green
new Color(0, 255, 255, 50), //Cyan
new Color(0, 0, 255, 50), //Blue
new Color(255, 0, 255, 50), //Fuschia
});
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), rainbow, projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB