From 4f3efec09d28a369bb5ff5ececd0e16e1e632990 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 28 Jul 2019 00:45:04 -0400 Subject: [PATCH] added afterimages to Nanoblack Reaper --- Items/Weapons/NanoblackReaperMelee.cs | 12 +- Items/Weapons/NanoblackReaperRogue.cs | 12 +- Projectiles/Rogue/NanoblackMainRogue.cs | 154 ------------- Projectiles/Rogue/NanoblackMainRogue.png | Bin 1830 -> 0 bytes Projectiles/Rogue/NanoblackSplitRogue.cs | 207 ------------------ Projectiles/Rogue/NanoblackSplitRogue.png | Bin 1088 -> 0 bytes Projectiles/Rogue/NanoblackSplitRogueGlow.png | Bin 1143 -> 0 bytes .../NanoblackMain.cs} | 29 ++- .../NanoblackMain.png} | Bin .../NanoblackSplit.cs} | 23 +- .../NanoblackSplit.png} | Bin .../NanoblackSplitGlow.png} | Bin 12 files changed, 62 insertions(+), 375 deletions(-) delete mode 100644 Projectiles/Rogue/NanoblackMainRogue.cs delete mode 100644 Projectiles/Rogue/NanoblackMainRogue.png delete mode 100644 Projectiles/Rogue/NanoblackSplitRogue.cs delete mode 100644 Projectiles/Rogue/NanoblackSplitRogue.png delete mode 100644 Projectiles/Rogue/NanoblackSplitRogueGlow.png rename Projectiles/{Melee/NanoblackMainMelee.cs => Typeless/NanoblackMain.cs} (85%) rename Projectiles/{Melee/NanoblackMainMelee.png => Typeless/NanoblackMain.png} (100%) rename Projectiles/{Melee/NanoblackSplitMelee.cs => Typeless/NanoblackSplit.cs} (90%) rename Projectiles/{Melee/NanoblackSplitMelee.png => Typeless/NanoblackSplit.png} (100%) rename Projectiles/{Melee/NanoblackSplitMeleeGlow.png => Typeless/NanoblackSplitGlow.png} (100%) diff --git a/Items/Weapons/NanoblackReaperMelee.cs b/Items/Weapons/NanoblackReaperMelee.cs index faa83604a0..b0ad5a68d2 100644 --- a/Items/Weapons/NanoblackReaperMelee.cs +++ b/Items/Weapons/NanoblackReaperMelee.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -36,11 +37,18 @@ namespace CalamityMod.Items.Weapons item.GetGlobalItem(mod).postMoonLordRarity = 16; item.value = Item.buyPrice(5, 0, 0, 0); - item.shoot = mod.ProjectileType("NanoblackMainMelee"); + item.shoot = mod.ProjectileType("NanoblackMain"); item.shootSpeed = Speed; } - public override void AddRecipes() + // ai[0] = 0f so that the projectile is melee. + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, Main.myPlayer, 0f); + return false; + } + + public override void AddRecipes() { ModRecipe r = new ModRecipe(mod); r.SetResult(this); diff --git a/Items/Weapons/NanoblackReaperRogue.cs b/Items/Weapons/NanoblackReaperRogue.cs index bff565e7ab..88bb5faf69 100644 --- a/Items/Weapons/NanoblackReaperRogue.cs +++ b/Items/Weapons/NanoblackReaperRogue.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -36,11 +37,18 @@ namespace CalamityMod.Items.Weapons item.GetGlobalItem(mod).postMoonLordRarity = 16; item.value = Item.buyPrice(5, 0, 0, 0); - item.shoot = mod.ProjectileType("NanoblackMainRogue"); + item.shoot = mod.ProjectileType("NanoblackMain"); item.shootSpeed = Speed; } - public override void AddRecipes() + // ai[0] = 1f so that the projectile is rogue. + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, Main.myPlayer, 1f); + return false; + } + + public override void AddRecipes() { ModRecipe r = new ModRecipe(mod); r.SetResult(this); diff --git a/Projectiles/Rogue/NanoblackMainRogue.cs b/Projectiles/Rogue/NanoblackMainRogue.cs deleted file mode 100644 index ffafc13fa3..0000000000 --- a/Projectiles/Rogue/NanoblackMainRogue.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using CalamityMod.Items.Weapons; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NanoblackMainRogue : ModProjectile - { - private static float RotationIncrement = 0.22f; - private static int Lifetime = 240; - private static float ReboundTime = 50f; - private static int MinBladeTimer = 13; - private static int MaxBladeTimer = 18; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Nanoblack Reaper"); - } - - public override void SetDefaults() - { - projectile.width = 56; - projectile.height = 56; - projectile.friendly = true; - projectile.GetGlobalProjectile(mod).rogue = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 2; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 2; - } - - public override void AI() - { - drawOffsetX = -11; - drawOriginOffsetY = -4; - drawOriginOffsetX = 0; - - // Initialize the frame counter and random blade delay on the very first frame. - if (projectile.timeLeft == Lifetime) - { - projectile.ai[0] = 0f; - projectile.ai[1] = GetBladeDelay(); - } - - // Produces electricity and green firework sparks constantly while in flight. - if (Main.rand.Next(3) == 0) - { - int dustType = (Main.rand.Next(5) == 0) ? 226 : 220; - float scale = 0.8f + Main.rand.NextFloat(0.3f); - float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = velocityMult * projectile.velocity; - Main.dust[idx].scale = scale; - } - - // ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade. - projectile.ai[0] += 1f; - projectile.ai[1] -= 1f; - - // On the frame the scythe begins returning, send a net update. - if (projectile.ai[0] == ReboundTime) - projectile.netUpdate = true; - - // The scythe runs its returning AI if the frame counter is greater than ReboundTime. - if (projectile.ai[0] >= ReboundTime) - { - float returnSpeed = NanoblackReaperRogue.Speed; - float acceleration = 2.4f; - Player owner = Main.player[projectile.owner]; - - // Delete the scythe if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - projectile.Kill(); - - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; - - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } - - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } - - // Create nanoblack energy blades at a somewhat-random rate while in flight. - if (projectile.ai[1] <= 0f) - { - SpawnEnergyBlade(); - projectile.ai[1] = GetBladeDelay(); - } - - // Rotate the scythe as it flies. - float spin = (projectile.direction <= 0) ? -1f : 1f; - projectile.rotation += spin * RotationIncrement; - return; - } - - private int GetBladeDelay() - { - return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1); - } - - private void SpawnEnergyBlade() - { - int bladeID = mod.ProjectileType("NanoblackSplitRogue"); - int bladeDamage = NanoblackReaperRogue.BaseDamage / 5; - float bladeKB = 3f; - float spin = (projectile.direction <= 0) ? -1f : 1f; - float d = 16f; - float velocityMult = 0.9f; - Vector2 directOffset = new Vector2(Main.rand.NextFloat(-d, d), Main.rand.NextFloat(-d, d)); - Vector2 velocityOffset = Main.rand.NextFloat(-velocityMult, velocityMult) * projectile.velocity; - Vector2 pos = projectile.Center + directOffset + velocityOffset; - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); - } - } -} diff --git a/Projectiles/Rogue/NanoblackMainRogue.png b/Projectiles/Rogue/NanoblackMainRogue.png deleted file mode 100644 index a4de09bee1982cfb6bab6d624cd708b4511b0e1a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1830 zcmV+>2if?EP){2@tQ*1Vcm=V-tPAghZkwifBUQ zLD6VH116#Yyd)+fMiWE?Noheqsa#qR(hKymZP$l6-|o(I&t7JC@xuAPEN9M~*|VJA z{^$F?nXN;CHL_wAV$TMXUCfCiHe2doa{O8*&Z`)2jah7s&9U#Huq7e5mQ>Gn|W8ENm-ymG*((JA9ZTlvIUDsLX= z1k^K#_Vh&o234!}t`ss z`7d_9p7i|g&0DnVrN79GGtFv>*ZrF$`ovkPVD&he#oA9bs<_IS6-|i;iszZ6n6sv- zyY5~I^e0uk?Sa)gp-D28l$B&tK5>@HJ8|i}ZvBZM0E3No@xXJ_^fQ&OJOMz1dpzlV zMT!t+N=Oxgy>e&qHuJp1m+59@ptKZ#o{o+vBs^KeyUh4W zG7M38&TUEGN8&y+mlaZiE|KDyA|ZOnbvFb3Gn9jMpOJXKa*Rht;S*=6yc35T4+%jg zIYL@saJd7})7qj|xm;3&2=O#?t-+Mcf?k=1jAIfl{V)9atJW@69J$YuVO0)5cXJaE zC(kF&QUxQ1k#?&#P{j;KiEP`NUbO z5X5CFjWm%NkBLl=5_!d4lAEqrpkKG+a+!L4{B5mW2o&<}uU!Mc)>W|##V0Nw%6mP| zOGzrkK>rG`%${N6`h>kETD!THP&sBi09#kBjH*}FPl%N&%Z4ov0Z9lfPk#S0uE;0O zQhD<@FL`AYW}GKPi6p*~6?&2EYLY!ABCo29yzkJ_V*xnZP^Z2B@@*Tn{z9H)IocQslD8LIp>;zzW z^I-sHe57XCeT!7(dgOxVVz&f7an{P1I3cKfu-b*u(t6s=5VWzpR`$&tF;l`swtGK> zygwR`0`bpNbNeg+>c80&1vtI^HSM|;2h_(BkEWlbDz#P3zNa*AEjdizr5 zps|Z`^ssCtRzut6E=&G)a^8KxwH)+LaiEk(?K+=0OC@?- z%F3;f=Cv|z*2{#nqF_+1Ep&7MnO9K?O{ACC1y05?9j$*Xo^y|V;w%+Nh`WF|QI9^o zMCm0O664IwRY4K?2AN%WVQP{`%3W@l}Vb&&m8ikfEnS-O8E|VZ^u3F zJPE`Jl+`1%)^DyIlxML6S{6vmEO>yV*t#r`x1bIZohNCt9G9_ zOT}hY^S4!^cOQEx>4mbwE*XJ%+kZ`FwIp=tm{uiOGf&mwYG&6s0QKLgZ=6q@rJQk7 zX9CdKcrs-imu?S-RC4#fx(I-Y%iaJqFD&R^Wyn=tI}ti&PICZCzdr!@>#8}+$sn%M zo`B4r;)$)Z#{qD(T3?Wq8olJGnPv|ElrmjQ5&6Vfs$T_I{^v`Esb9-?H#cd&d=|oD z1H8Nm=pWa4dBgujK5>@vBo5;@_ClH$VP3xn{lAeW@`(mod).rogue = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = 4; - projectile.extraUpdates = 1; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - } - - // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target - // ai[1] = Current spin speed. Negative speeds are also allowed. - public override void AI() - { - drawOffsetX = -10; - drawOriginOffsetY = 0; - drawOriginOffsetX = 0; - - // On the very first frame, clear any invalid starting target variable and create some dust. - if (projectile.timeLeft == Lifetime) - { - projectile.ai[0] = 0f; - SpawnDust(); - } - - // Spin in the specified starting direction and slow down spin over time - // Loses 1.66% of current speed every frame - // Also update current orientation to reflect current spin direction - float currentSpin = projectile.ai[1]; - projectile.direction = (currentSpin <= 0f) ? 1 : -1; - projectile.spriteDirection = projectile.direction; - projectile.rotation += currentSpin * MaxRotationSpeed; - float spinReduction = 0.0166f * currentSpin; - projectile.ai[1] -= spinReduction; - - // If about to disappear, shrink by 8% every frame - if(projectile.timeLeft < 15) - projectile.scale *= 0.92f; - - // Search for and home in on nearby targets - HomingAI(); - } - - private void HomingAI() - { - // If we don't currently have a target, go try and get one! - int targetID = (int)(projectile.ai[0]) - 1; - if (targetID < 0) - targetID = AcquireTarget(); - - // Save the target, whether we have one or not. - projectile.ai[0] = targetID + 1f; - - // If we don't have a target, then just slow down a bit. - if (targetID < 0) - { - projectile.velocity *= 0.94f; - return; - } - - // Homing behavior depends on how far the blade is from its target. - NPC target = Main.npc[targetID]; - float xDist = projectile.Center.X - target.Center.X; - float yDist = projectile.Center.Y - target.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - - // If the target is too far away, stop homing in on it. - if(dist > HomingBreakRange) - { - projectile.ai[0] = 0f; - return; - } - - // Adds a multiple of the towards-target vector to its velocity every frame. - float homingFactor = CalcHomingFactor(dist); - Vector2 posDiff = target.Center - projectile.Center; - posDiff = posDiff.SafeNormalize(Vector2.Zero); - posDiff *= homingFactor; - Vector2 newVelocity = projectile.velocity += posDiff; - - // Caps speed to make sure it doesn't go too fast. - if(newVelocity.Length() >= MaxSpeed) - { - newVelocity = newVelocity.SafeNormalize(Vector2.Zero); - newVelocity *= MaxSpeed; - } - - projectile.velocity = newVelocity; - } - - // Returns the ID of the NPC to be targeted by this energy blade. - // It chooses the closest target which can be chased, ignoring invulnerable NPCs. - // Nanoblack Blades prefer to target bosses whenever possible. - private int AcquireTarget() - { - bool bossFound = false; - int target = -1; - float minDist = HomingStartRange; - for (int i = 0; i < 200; ++i) - { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) - continue; - - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; - - if (npc.CanBeChasedBy(projectile, false)) - { - float xDist = projectile.Center.X - npc.Center.X; - float yDist = projectile.Center.Y - npc.Center.Y; - float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (distToNPC < minDist) - { - // If this target within range is a boss, set the boss found flag. - if (npc.boss) - bossFound = true; - minDist = distToNPC; - target = i; - } - } - } - return target; - } - - // Energy blades home even more aggressively if they are very close to their target. - private float CalcHomingFactor(float dist) - { - float baseFactor = BaseHomingFactor; - float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); - if (bonus < 0f) - bonus = 0f; - return baseFactor + bonus; - } - - // Draws the energy blade's glowmask. - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - float fWidthOverTwo = SpriteWidth / 2f; - float fHeightOverTwo = projectile.height / 2f; - - // Make sure the glowmask matches the blade's own orientation - SpriteEffects eff = SpriteEffects.None; - if (projectile.spriteDirection == -1) - eff = SpriteEffects.FlipHorizontally; - Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); - spriteBatch.Draw(mod.GetTexture("Projectiles/Rogue/NanoblackSplitRogueGlow"), - projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, - origin, projectile.scale, eff, 0f); - } - - // Spawns a tiny bit of dust when the energy blade vanishes. - public override void Kill(int timeLeft) - { - SpawnDust(); - } - - // Spawns a small bit of Luminite themed dust. - private void SpawnDust() - { - int dustCount = Main.rand.Next(3, 6); - Vector2 corner = projectile.position; - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.6f + Main.rand.NextFloat(0.4f); - int idx = Dust.NewDust(corner, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - } - } -} diff --git a/Projectiles/Rogue/NanoblackSplitRogue.png b/Projectiles/Rogue/NanoblackSplitRogue.png deleted file mode 100644 index 5f802a34349ca0ab3fe6ee648c155933678219a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1088 zcmV-G1i$-rIjkdOOeK>PFxtp2YEq#$WFT)+qoilU4 z^L^*+S;gJjP(J|4XbS*;7FL{VK?C%rx-9p>(GdU|zZ+Hn$x|}`{1XlVu)1_r1GLpW zZta`S{RY6cr+XDZs4fD)?BYBCBcHtM`Fi)=^#}dWO;zf6xWuw|IhVsbVT3NC7SA`!0pkvE3KzU^RZ0_q1 ztaaavd_#LqJ|%z%Idvr(5!FZ~+N_fukM9K_cI-_B@Wj7S4X)~}4E=09upAd|=B@*9 zt8n9A6o0-jl!wmA(Z_67XYR*^A<9(7v2D%x;v!+;ty>EpdqmXfR?ST8sO52 z(*TTL_{KAU;f~>03C{S{MD24Qa5=R*L%UJ#_ee0G7_rXjotA zo5%71Ow9h^8L$L*%5^QCNEw8Vj0IHXLWVoZXso1TtX@=V>AZBySN@t(0Lx!o(BP^V zd!7QIsq-bkMaqQU7I>))UQ6V zLjkltoCG}8(~7qrlw_K$NM-6sgb}E4lwp7hcrE8E%Aga`J{_+YU+{oWCr{^t|{o z0O`LM09YL!1>E{G=Wxf&I0A=|+TAbRcK3p^PWa^8uiw*yEA8R#)Gxe7|*yzl(0?1^SfdC>D>Ru2EOx6jP1`-YzoE$Atmpsj!xZ#9fPghk_V{y-L z%&47F-M#0kfc41Wa5t4`17NWB5g>pFxr*ida&6DbvM+6O>ibVW0?Kp2Z>r-r1v1Dq zJukiA$U)g}>f_nYhytiiwRy%h$QTPSLXMdU>0(|~yGUbW9McG z_~j`Jne^w!fb|pD_N=^HU)t$piYBCf7JP(^b-nTy09%@*0^iOFxi0-QSaJed-MCo+ zJW#j|z*J8HfTicUOa4325DqK3iq1`C#3Lk0000{IP)wd z6ckH!A&6-a1V1Xai?j&}u}PY*Vl!z{Gn1L5879qhapw5uzPxGEg&^<0x$|buz3rez_Zc2kKc54jJ=p}n-}zjr%{u^n-9481h2bInXaM?7{RF^DW5lwnoi8}$*LA)7 z4M2Ej6oA#j8UVA4a{vqtoc5jGwg>w+|9_dS8lL>*D*y&tWFf~BSVWXWd$P#@M60(0 zkYBqa1AP9Q{Qkp?4(R|abk+IZ@2Sp1*7e2FD*!ySr_}&7)YSuU=FL|uyWkV*TfXjV zxH3Emz@d?h18}BGNcEh(3czarK?5*aTJV`^fgls|A!DtGxj1G3&PQ_&xMXs>qXr;$D-Xcpw_p3- z$cK>ibd1h^@7wR?cRm1MJTBb^Q}(?2r)8XutPB@GLZ!TtOvp3aooaJ7*|6D%H0m^L zY&QVr_j#c5N|zC`RLS0}nJ?Z4pd%yK{WHdz=cPvRso)W6ANvJ>iS(THkGoTC23&Fn zJ`*ByQ#Sx;YTfGqTs!+C;6^J|?R){)I)SZ9ed?4_?-DcN)eJ-3|m*^xvQ?<4M+~4QwfBjPD>wvr4 z4;-P8MhD$Jr!z|cv{dMzWK@Ohg0vnVh{SgR&=x-kxKXbrEi11T>OxnYug~p#G$j+8 zwePRdEv$7Gk|(te3mhTSdrtOp-i&*AUKZ$^58t&qc%z;w9Idvlm5>tjA!gYtu>(h+ z0bp+Gh5=}5l_%ob>r%n$6Er+MX^{;+p~Lg$o)w|D0`Xj1_l6I&Wyy^f99Tn1=AANktl9Evcm{3W2LaGG*{A^gY0vT66Ts#ZRjri0C$JqE>EA!&pARc3_=HqFCr$yduR-22)I?+_P`oYY zZ_Agj`<{TRbhmur^uN3Cd%m665tZ}39nl!zR?PRye_jQS&_CxMu*;9uWWoRd002ov JPDHLkV1m6T9PI!A diff --git a/Projectiles/Melee/NanoblackMainMelee.cs b/Projectiles/Typeless/NanoblackMain.cs similarity index 85% rename from Projectiles/Melee/NanoblackMainMelee.cs rename to Projectiles/Typeless/NanoblackMain.cs index 5571a552ca..5db09d82d1 100644 --- a/Projectiles/Melee/NanoblackMainMelee.cs +++ b/Projectiles/Typeless/NanoblackMain.cs @@ -1,12 +1,14 @@ using System; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Items.Weapons; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Typeless { - public class NanoblackMainMelee : ModProjectile + public class NanoblackMain : ModProjectile { private static float RotationIncrement = 0.22f; private static int Lifetime = 240; @@ -17,7 +19,9 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Nanoblack Reaper"); - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { @@ -41,8 +45,14 @@ namespace CalamityMod.Projectiles.Melee drawOriginOffsetX = 0; // Initialize the frame counter and random blade delay on the very first frame. + // Also grab the damage type based on ai[0]. if (projectile.timeLeft == Lifetime) { + if (projectile.ai[0] > 0f) + projectile.GetGlobalProjectile(mod).rogue = true; + else + projectile.melee = true; + projectile.ai[0] = 0f; projectile.ai[1] = GetBladeDelay(); } @@ -131,6 +141,12 @@ namespace CalamityMod.Projectiles.Melee return; } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + private int GetBladeDelay() { return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1); @@ -138,7 +154,7 @@ namespace CalamityMod.Projectiles.Melee private void SpawnEnergyBlade() { - int bladeID = mod.ProjectileType("NanoblackSplitMelee"); + int bladeID = mod.ProjectileType("NanoblackSplit"); int bladeDamage = NanoblackReaperMelee.BaseDamage / 5; float bladeKB = 3f; float spin = (projectile.direction <= 0) ? -1f : 1f; @@ -148,7 +164,10 @@ namespace CalamityMod.Projectiles.Melee Vector2 velocityOffset = Main.rand.NextFloat(-velocityMult, velocityMult) * projectile.velocity; Vector2 pos = projectile.Center + directOffset + velocityOffset; if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); + { + float damageType = projectile.melee ? 0f : 1f; + Projectile.NewProjectile(pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, damageType, spin); + } } } } diff --git a/Projectiles/Melee/NanoblackMainMelee.png b/Projectiles/Typeless/NanoblackMain.png similarity index 100% rename from Projectiles/Melee/NanoblackMainMelee.png rename to Projectiles/Typeless/NanoblackMain.png diff --git a/Projectiles/Melee/NanoblackSplitMelee.cs b/Projectiles/Typeless/NanoblackSplit.cs similarity index 90% rename from Projectiles/Melee/NanoblackSplitMelee.cs rename to Projectiles/Typeless/NanoblackSplit.cs index b7f4c28900..571afb4dcb 100644 --- a/Projectiles/Melee/NanoblackSplitMelee.cs +++ b/Projectiles/Typeless/NanoblackSplit.cs @@ -5,9 +5,9 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Typeless { - public class NanoblackSplitMelee : ModProjectile + public class NanoblackSplit : ModProjectile { private static int SpriteWidth = 52; private static int Lifetime = 90; @@ -23,14 +23,15 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Nanoblack Blade"); - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 32; projectile.height = 32; projectile.friendly = true; - projectile.melee = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = 4; @@ -49,8 +50,14 @@ namespace CalamityMod.Projectiles.Melee drawOriginOffsetX = 0; // On the very first frame, clear any invalid starting target variable and create some dust. + // Also grab the damage type based on ai[0]. if (projectile.timeLeft == Lifetime) { + if (projectile.ai[0] > 0f) + projectile.GetGlobalProjectile(mod).rogue = true; + else + projectile.melee = true; + projectile.ai[0] = 0f; SpawnDust(); } @@ -166,6 +173,12 @@ namespace CalamityMod.Projectiles.Melee return baseFactor + bonus; } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + // Draws the energy blade's glowmask. public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -177,7 +190,7 @@ namespace CalamityMod.Projectiles.Melee if (projectile.spriteDirection == -1) eff = SpriteEffects.FlipHorizontally; Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); - spriteBatch.Draw(mod.GetTexture("Projectiles/Melee/NanoblackSplitMeleeGlow"), + spriteBatch.Draw(mod.GetTexture("Projectiles/Typeless/NanoblackSplitGlow"), projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, projectile.scale, eff, 0f); } diff --git a/Projectiles/Melee/NanoblackSplitMelee.png b/Projectiles/Typeless/NanoblackSplit.png similarity index 100% rename from Projectiles/Melee/NanoblackSplitMelee.png rename to Projectiles/Typeless/NanoblackSplit.png diff --git a/Projectiles/Melee/NanoblackSplitMeleeGlow.png b/Projectiles/Typeless/NanoblackSplitGlow.png similarity index 100% rename from Projectiles/Melee/NanoblackSplitMeleeGlow.png rename to Projectiles/Typeless/NanoblackSplitGlow.png