diff --git a/Fonts/Wingdings.xnb b/Fonts/Wingdings.xnb new file mode 100644 index 0000000000..a487f2746c Binary files /dev/null and b/Fonts/Wingdings.xnb differ diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index ced3d50ced..a6dd9b024c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -56,6 +56,7 @@ DoGDeathBoom.DisplayName: Cosmic Explosion DoGFire.DisplayName: Death Fire DoGP1EndPortal.DisplayName: Portal DoGTeleportRift.DisplayName: Rift +DoGWingdings.DisplayName: Ramblings of Wing DoGster DraedonSummonLaser.DisplayName: Giant Fuck-off Deathray of Doom DyingSun.DisplayName: Dying Sun EssenceDust.DisplayName: Cosmic Dust diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 3532c04d4d..0644504a31 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -2921,7 +2921,31 @@ namespace CalamityMod.NPCs.DevourerofGods }); Color messageColor = Color.Cyan; Rectangle location = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + + // Speak in Wingdings if the Punch Card is equipped + if (target.Calamity().punchCard && DoGWingdings.Wingdings != null && System.Environment.OSVersion.Platform == PlatformID.Win32NT && !GameCulture.FromCultureName(GameCulture.CultureName.Chinese).IsActive && !GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive) + { + Vector2 vector = DoGWingdings.Wingdings.MeasureString(Language.GetTextValue(text)); + // This is how normal combat text spawn positioning is handled + float positionX = (float)location.X + (float)location.Width * 0.5f - vector.X * 0.5f + Main.rand.Next(-(int)((double)location.Width * 0.5), (int)((double)location.Width * 0.5) + 1); + float positionY = (float)location.Y + (float)location.Height * 0.25f - vector.Y * 0.5f + Main.rand.Next(-(int)((double)location.Height * 0.5), (int)((double)location.Height * 0.5) + 1); + if (target.gravDir == -1f) + { + positionY = (float)location.Y + (float)location.Height * 0.75f + vector.Y * 0.5f; + } + // Spawn a projectile that mimmicks combat text behaviour + int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), new Vector2(positionX, positionY), new Vector2((float)Main.rand.Next(-25, 26) * 0.05f , - 14f * target.gravDir), ModContent.ProjectileType(), 0, 0, -1, -1); + Projectile proj = Main.projectile[p]; + proj.rotation = proj.velocity.X < 0 ? -0.06f : 0.06f; + + // Pass the spoken dialogue into it + DoGWingdings wingdings = Main.projectile[p].ModProjectile(); + wingdings.dialogue = Language.GetTextValue(text); + } + else + { + CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + } target.Calamity().dogTextCooldown = 60; } } diff --git a/Projectiles/Boss/DoGWingdings.cs b/Projectiles/Boss/DoGWingdings.cs new file mode 100644 index 0000000000..00b1290f0c --- /dev/null +++ b/Projectiles/Boss/DoGWingdings.cs @@ -0,0 +1,159 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGWingdings : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static DynamicSpriteFont Wingdings = null; + + public string dialogue; + + public override void SetStaticDefaults() + { + if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) + { + Wingdings = CalamityMod.Instance.Assets.Request("Fonts/Wingdings", AssetRequestMode.ImmediateLoad).Value; + } + } + + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.penetrate = -1; + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 180; + Projectile.scale = 0; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(dialogue); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + dialogue = reader.ReadString(); + } + + public override void AI() + { + // Replicae CombatText behaviour + float targetScale = 1f; + Projectile.Opacity += (float)Projectile.ai[0] * 0.05f; + if ((double)Projectile.Opacity <= 0.6) + { + Projectile.ai[0] = 1; + } + if (Projectile.Opacity >= 1f) + { + Projectile.Opacity = 1f; + Projectile.ai[0] = -1; + } + Projectile.velocity.Y *= 0.8464f; + + Projectile.velocity.X *= 0.93f; + + if (Projectile.timeLeft <= 60) + { + Projectile.scale -= 0.1f * targetScale; + if ((double)Projectile.scale < 0.1) + { + Projectile.active = false; + } + Projectile.timeLeft = 60; + Projectile.ai[0] = -1; + Projectile.scale += 0.07f * targetScale; + return; + } + if (Projectile.velocity.X < 0f) + { + Projectile.rotation += 0.001f; + } + else + { + Projectile.rotation -= 0.001f; + } + if (Projectile.scale < targetScale) + { + Projectile.scale += 0.1f * targetScale; + } + if (Projectile.scale > targetScale) + { + Projectile.scale = targetScale; + } + } + + public override bool PreDraw(ref Color lightColor) + { + // Do not draw if the font isn't loaded or text is Cyrillic or Chinese + if (Wingdings == null || System.Environment.OSVersion.Platform != PlatformID.Win32NT || GameCulture.FromCultureName(GameCulture.CultureName.Chinese).IsActive || GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive) + return false; + // Otherwise identical drawcode to CombatText + Vector2 stringSize = Wingdings.MeasureString(dialogue); + Vector2 origin = new Vector2(stringSize.X * 0.5f, stringSize.Y * 0.5f); + Color cyan = Color.Cyan; + float scale = Projectile.scale; + float red = (int)cyan.R; + float green = (int)cyan.G; + float blue = (int)cyan.B; + float alpha = (int)cyan.A; + red *= scale * Projectile.Opacity * 0.3f; + blue *= scale * Projectile.Opacity * 0.3f; + green *= scale * Projectile.Opacity * 0.3f; + alpha *= scale * Projectile.Opacity; + Color color = new Color((int)red, (int)green, (int)blue, (int)alpha); + for (int l = 0; l < 5; l++) + { + float xOffset = 0f; + float yOffset = 0f; + switch (l) + { + case 0: + xOffset -= 1f; + break; + case 1: + xOffset += 1f; + break; + case 2: + yOffset -= 1f; + break; + case 3: + yOffset += 1f; + break; + default: + red = (float)(int)cyan.R * scale * Projectile.Opacity; + blue = (float)(int)cyan.B * scale * Projectile.Opacity; + green = (float)(int)cyan.G * scale * Projectile.Opacity; + alpha = (float)(int)cyan.A * scale * Projectile.Opacity; + color = new Color((int)red, (int)green, (int)blue, (int)alpha); + break; + } + if (Main.player[Main.myPlayer].gravDir != 1f) + { + float finalYPos = Projectile.position.Y - Main.screenPosition.Y; + finalYPos = (float)Main.screenHeight - finalYPos; + Main.spriteBatch.DrawString(Wingdings, dialogue.ToUpper(), new Vector2(Projectile.position.X - Main.screenPosition.X + xOffset + origin.X, finalYPos + yOffset + origin.Y), color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); + } + else + { + Main.spriteBatch.DrawString(Wingdings, dialogue.ToUpper(), new Vector2(Projectile.position.X - Main.screenPosition.X + xOffset + origin.X, Projectile.position.Y - Main.screenPosition.Y + yOffset + origin.Y), color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); + } + } + return false; + } + } +}