Nighttime Prov Reward item
This commit is contained in:
1 parent
4baa2ecebb
commit
2c58eafa00
7 files changed
+154
-11
No files matched your search
@@ -9,6 +9,7 @@ using CalamityMod.Items.Accessories;
|
||||
using CalamityMod.Items.Accessories.Vanity;
|
||||
using CalamityMod.Items.Armor;
|
||||
using CalamityMod.Items.DifficultyItems;
|
||||
using CalamityMod.Items.Dyes;
|
||||
using CalamityMod.Items.Mounts;
|
||||
using CalamityMod.Items.TreasureBags;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
@@ -9535,8 +9536,53 @@ namespace CalamityMod.CalPlayer
|
||||
}
|
||||
}
|
||||
}
|
||||
public static readonly List<Color> MoonlightDyeDayColors = new List<Color>()
|
||||
{
|
||||
new Color(255, 163, 56),
|
||||
new Color(235, 30, 19),
|
||||
new Color(242, 48, 187),
|
||||
};
|
||||
public static readonly List<Color> MoonlightDyeNightColors = new List<Color>()
|
||||
{
|
||||
new Color(24, 134, 198),
|
||||
new Color(130, 40, 150),
|
||||
new Color(40, 64, 150),
|
||||
};
|
||||
|
||||
public override void PreUpdate()
|
||||
public static void DetermineMoonlightDyeColors(out Color drawColor, Color dayColor, Color nightColor)
|
||||
{
|
||||
int totalTime = Main.dayTime ? 54000 : 32400;
|
||||
float transitionTime = 5400;
|
||||
//Color dayColor = new Color(255, 163, 56);
|
||||
//Color nightColor = new Color(24, 134, 198);
|
||||
float interval = Utils.InverseLerp(0f, transitionTime, (float)Main.time, true) + Utils.InverseLerp(totalTime - transitionTime, totalTime, (float)Main.time, true);
|
||||
if (Main.dayTime)
|
||||
{
|
||||
// Dusk.
|
||||
if (Main.time >= totalTime - transitionTime)
|
||||
drawColor = Color.Lerp(dayColor, nightColor, Utils.InverseLerp(totalTime - transitionTime, totalTime, (float)Main.time, true));
|
||||
// Dawn.
|
||||
else if (Main.time <= transitionTime)
|
||||
drawColor = Color.Lerp(nightColor, dayColor, interval);
|
||||
else
|
||||
drawColor = dayColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawColor = nightColor;
|
||||
}
|
||||
}
|
||||
public static Color GetCurrentMoonlightDyeColor(float angleOffset = 0f)
|
||||
{
|
||||
float interval = (float)Math.Cos(Main.GlobalTime * 0.6f + angleOffset) * 0.5f + 0.5f;
|
||||
interval = MathHelper.Clamp(interval, 0f, 0.995f);
|
||||
Color dayColorToUse = CalamityUtils.MulticolorLerp(interval, MoonlightDyeDayColors.ToArray());
|
||||
Color nightColorToUse = CalamityUtils.MulticolorLerp(interval, MoonlightDyeNightColors.ToArray());
|
||||
DetermineMoonlightDyeColors(out Color drawColor, dayColorToUse, nightColorToUse);
|
||||
return drawColor;
|
||||
}
|
||||
|
||||
public override void PreUpdate()
|
||||
{
|
||||
tailFrameUp++;
|
||||
if (tailFrameUp == 8)
|
||||
@@ -9547,8 +9593,15 @@ namespace CalamityMod.CalPlayer
|
||||
tailFrame = 0;
|
||||
}
|
||||
tailFrameUp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < player.dye.Length; i++)
|
||||
{
|
||||
if (player.dye[i].type == ModContent.ItemType<ProfanedMoonlightDye>())
|
||||
{
|
||||
GameShaders.Armor.GetSecondaryShader(player.dye[i].dye, player)?.UseColor(GetCurrentMoonlightDyeColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly PlayerLayer Tail = new PlayerLayer("CalamityMod", "Tail", PlayerLayer.BackAcc, delegate (PlayerDrawInfo drawInfo)
|
||||
{
|
||||
@@ -9787,6 +9840,44 @@ namespace CalamityMod.CalPlayer
|
||||
}
|
||||
});
|
||||
|
||||
public static readonly PlayerLayer ProfanedMoonlightDyeEffects = new PlayerLayer("CalamityMod", "ProfanedMoonlight", PlayerLayer.Body, (drawInfo) =>
|
||||
{
|
||||
Player drawPlayer = drawInfo.drawPlayer;
|
||||
int totalMoonlightDyes = drawPlayer.dye.Count(dyeItem => dyeItem.type == ModContent.ItemType<ProfanedMoonlightDye>());
|
||||
if (totalMoonlightDyes <= 0)
|
||||
return;
|
||||
float auroraCount = 12 + (int)MathHelper.Clamp(totalMoonlightDyes, 0f, 4f) * 2;
|
||||
float opacity = MathHelper.Clamp(totalMoonlightDyes / 3f, 0f, 1f);
|
||||
|
||||
if (Main.dayTime)
|
||||
opacity *= 0.4f;
|
||||
else
|
||||
opacity *= 0.25f;
|
||||
|
||||
float time01 = Main.GlobalTime % 3f / 3f;
|
||||
Texture2D auroraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AuroraTexture");
|
||||
for (int i = 0; i < auroraCount; i++)
|
||||
{
|
||||
float incrementOffsetAngle = MathHelper.TwoPi * i / auroraCount;
|
||||
float timeOffset = (float)Math.Sin(time01 * MathHelper.TwoPi + incrementOffsetAngle * 2f);
|
||||
float rotation = (float)Math.Sin(incrementOffsetAngle) * MathHelper.Pi / 12f;
|
||||
float yOffset = (float)Math.Sin(time01 * MathHelper.TwoPi + incrementOffsetAngle * 2f + MathHelper.ToRadians(60f)) * 6f;
|
||||
Color color = GetCurrentMoonlightDyeColor(incrementOffsetAngle);
|
||||
Vector2 offset = new Vector2(20f * timeOffset, yOffset - 14f);
|
||||
DrawData drawData = new DrawData(auroraTexture,
|
||||
drawPlayer.Top + offset - Main.screenPosition,
|
||||
null,
|
||||
color * opacity,
|
||||
rotation + MathHelper.PiOver2,
|
||||
auroraTexture.Size() * 0.5f,
|
||||
0.135f,
|
||||
SpriteEffects.None,
|
||||
1);
|
||||
|
||||
Main.playerDrawData.Add(drawData);
|
||||
}
|
||||
});
|
||||
|
||||
public override void ModifyDrawLayers(List<PlayerLayer> list)
|
||||
{
|
||||
MiscEffectsBack.visible = true;
|
||||
@@ -9815,6 +9906,7 @@ namespace CalamityMod.CalPlayer
|
||||
}
|
||||
list.Add(ColdDivinityOverlay);
|
||||
list.Add(StratusSphereDrawing);
|
||||
list.Add(ProfanedMoonlightDyeEffects);
|
||||
list.Add(IbanDevRobot);
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -3919,7 +3919,12 @@ namespace CalamityMod
|
||||
Main.npc[npcIndex2].Calamity().newAI[2] = reader.ReadSingle();
|
||||
Main.npc[npcIndex2].Calamity().newAI[3] = reader.ReadSingle();
|
||||
break;
|
||||
default:
|
||||
case CalamityModMessageType.ProvidenceDyeConditionSync:
|
||||
byte npcIndex3 = reader.ReadByte();
|
||||
(Main.npc[npcIndex3].modNPC as Providence).hasTakenDaytimeDamage = reader.ReadBoolean();
|
||||
break;
|
||||
|
||||
default:
|
||||
Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}.");
|
||||
break;
|
||||
}
|
||||
@@ -4002,6 +4007,7 @@ namespace CalamityMod
|
||||
AcidRainOldDukeSummonSync,
|
||||
GaelsGreatswordSwingSync,
|
||||
SpawnSuperDummy,
|
||||
SyncCalamityNPCAIArray
|
||||
SyncCalamityNPCAIArray,
|
||||
ProvidenceDyeConditionSync // We shouldn't fucking need this. Die in a hole, Multiplayer.
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
@@ -0,0 +1,22 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace CalamityMod.Items.Dyes
|
||||
{
|
||||
public class ProfanedMoonlightDye : BaseDye
|
||||
{
|
||||
public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref<Effect>(mod.GetEffect("Effects/Dyes/ProfanedMoonlightDye")), "DyePass");
|
||||
public override void SafeSetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Profaned Moonlight Dye");
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
{
|
||||
item.rare = 10;
|
||||
item.Calamity().customRarity = CalamityRarity.Turquoise;
|
||||
item.value = Item.sellPrice(0, 10, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 363 B |
@@ -27,6 +27,7 @@ using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Items.Dyes;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
|
||||
@@ -35,7 +36,6 @@ namespace CalamityMod.NPCs.Providence
|
||||
[AutoloadBossHead]
|
||||
public class Providence : ModNPC
|
||||
{
|
||||
private bool hasTakenDaytimeDamage = false;
|
||||
private bool text = false;
|
||||
private bool useDefenseFrames = false;
|
||||
private float bossLife;
|
||||
@@ -46,8 +46,9 @@ namespace CalamityMod.NPCs.Providence
|
||||
private int frameUsed = 0;
|
||||
private int healTimer = 0;
|
||||
private bool challenge = Main.expertMode && Main.netMode == NetmodeID.SinglePlayer; //Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only.
|
||||
internal bool hasTakenDaytimeDamage = false;
|
||||
|
||||
public static float normalDR = 0.35f;
|
||||
public static float normalDR = 0.35f;
|
||||
public static float cocoonDR = 0.9f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
@@ -413,8 +414,10 @@ namespace CalamityMod.NPCs.Providence
|
||||
cocoonDR : delayAttacks ?
|
||||
MathHelper.Lerp(normalDR, cocoonDR, npc.localAI[2] / attackDelayAfterCocoon) : normalDR;
|
||||
|
||||
// Movement
|
||||
if (npc.ai[0] != 2f && npc.ai[0] != 5f)
|
||||
npc.Calamity().DR = 0f;
|
||||
|
||||
// Movement
|
||||
if (npc.ai[0] != 2f && npc.ai[0] != 5f)
|
||||
{
|
||||
// Firing holy ray or not
|
||||
bool firingLaser = npc.ai[0] == 7f;
|
||||
@@ -1334,7 +1337,7 @@ namespace CalamityMod.NPCs.Providence
|
||||
DropHelper.DropItemCondition(npc, ModContent.ItemType<ProfanedSoulCrystal>(), true, shouldDrop);
|
||||
|
||||
// Special drop for defeating her at night
|
||||
//DropHelper.DropItemCondition(npc, ModContent.ItemType<SpecialItem>(), true, !hasTakenDaytimeDamage);
|
||||
DropHelper.DropItemCondition(npc, ModContent.ItemType<ProfanedMoonlightDye>(), true, !hasTakenDaytimeDamage, 3, 4);
|
||||
|
||||
// All other drops are contained in the bag, so they only drop directly on Normal
|
||||
if (!Main.expertMode)
|
||||
@@ -1621,8 +1624,18 @@ namespace CalamityMod.NPCs.Providence
|
||||
|
||||
public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit)
|
||||
{
|
||||
bool oldDaytimeDamageCheck = hasTakenDaytimeDamage;
|
||||
hasTakenDaytimeDamage = Main.dayTime;
|
||||
|
||||
if (oldDaytimeDamageCheck != hasTakenDaytimeDamage && Main.netMode != NetmodeID.SinglePlayer)
|
||||
{
|
||||
var netMessage = mod.GetPacket();
|
||||
netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync);
|
||||
netMessage.Write((byte)npc.whoAmI);
|
||||
netMessage.Write(hasTakenDaytimeDamage);
|
||||
netMessage.Send();
|
||||
}
|
||||
|
||||
if (challenge)
|
||||
{
|
||||
bool goldenGun = projectile.type == ModContent.ProjectileType<GoldenGunProj>();
|
||||
@@ -1637,9 +1650,19 @@ namespace CalamityMod.NPCs.Providence
|
||||
}
|
||||
|
||||
public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit)
|
||||
{
|
||||
{
|
||||
bool oldDaytimeDamageCheck = hasTakenDaytimeDamage;
|
||||
hasTakenDaytimeDamage = Main.dayTime;
|
||||
|
||||
if (oldDaytimeDamageCheck != hasTakenDaytimeDamage && Main.netMode != NetmodeID.SinglePlayer)
|
||||
{
|
||||
var netMessage = mod.GetPacket();
|
||||
netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync);
|
||||
netMessage.Write((byte)npc.whoAmI);
|
||||
netMessage.Write(hasTakenDaytimeDamage);
|
||||
netMessage.Send();
|
||||
}
|
||||
|
||||
if (challenge)
|
||||
challenge = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user