From e2e8537a01d2713f64622ceb26b45b4ae7ce9f10 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Tue, 30 Jun 2020 14:11:05 -0400 Subject: [PATCH] Added the Timekeeper (WIP). - The double helix pattern is broken at some rotation. - The bullet sometimes get killed for no reason. --- Content/Items/Weapons/DuneWyrm/Timekeeper.cs | 41 +++++++ Content/Items/Weapons/DuneWyrm/Timekeeper.png | Bin 0 -> 3440 bytes Content/Projectiles/DuneWyrm/Timekeeper.cs | 110 ++++++++++++++++++ Content/Projectiles/DuneWyrm/Timekeeper.png | Bin 0 -> 256 bytes Lib/Items/DecimationWeapon.cs | 2 +- 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 Content/Items/Weapons/DuneWyrm/Timekeeper.cs create mode 100644 Content/Items/Weapons/DuneWyrm/Timekeeper.png create mode 100644 Content/Projectiles/DuneWyrm/Timekeeper.cs create mode 100644 Content/Projectiles/DuneWyrm/Timekeeper.png diff --git a/Content/Items/Weapons/DuneWyrm/Timekeeper.cs b/Content/Items/Weapons/DuneWyrm/Timekeeper.cs new file mode 100644 index 0000000..b8220d7 --- /dev/null +++ b/Content/Items/Weapons/DuneWyrm/Timekeeper.cs @@ -0,0 +1,41 @@ +using Decimation.Lib.Items; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content.Items.Weapons.DuneWyrm +{ + public class Timekeeper : DecimationWeapon + { + protected override string ItemName => "The Timekeeper"; + protected override int Damages => 45; + protected override DamageType DamagesType => DamageType.Ranged; + protected override int ProjectileId => ModContent.ProjectileType(); + protected override int AmmoId => AmmoID.Bullet; + + protected override void InitWeapon() + { + item.width = 58; + item.height = 22; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTime = 10; + item.useAnimation = 10; + item.crit = 6; + item.shootSpeed = 10f; + } + + public override bool ConsumeAmmo(Player player) + { + return !Main.rand.NextBool(10); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, + ref float knockBack) + { + type = ProjectileId; + + return true; + } + } +} \ No newline at end of file diff --git a/Content/Items/Weapons/DuneWyrm/Timekeeper.png b/Content/Items/Weapons/DuneWyrm/Timekeeper.png new file mode 100644 index 0000000000000000000000000000000000000000..dbf50f8c3fce2d17b32629fe84f8f7b1de5bfed3 GIT binary patch literal 3440 zcmV-$4Uh7PP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR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h8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0007;Nkl=Lp%hVOAyzaQQFIq<7~XWz z5Q@5pKoX@cf^N$6B0@?8=`RsDDi}pYq(wo07UqyBqP#d=eCLIIhqKcu>LRx1=4^Yv z@7>4yywCeRn_-$JZt(ePwFUWn&Tw1b8mM$kczf!H>%M=D1(XODdR-W5-r&fvps_j+ zz{s^R01~Mo0EPw<8q<$vef&;`{H@L@Gg<%xVD|NA6JY1=tpH4Ym;vDNy@wi;H4U4s zZHm#!%zZ5$-`-9kv&A|@uxfSC@$>6_H2`EDd<7u;d>(-Hp_mEq?(K^*qpn!~Eu$(p zsor-sWEG<<(U?P?Hb}g?YbgL7X+HohyOv>f3;>a6z3VxqZ>dg+pHrQ4=klD&XT{&A z>aC8e(mJlpXu(vJDF?uw);a*zg;hmUoCF{mY0{=`G7-@7Nc_yW(o$sN4FG|a0qeO! z)Bd5(i1UG>y#Vx|I0is&Lf7iH=oSD@UzsUu)b+lKg%>%-!)=GPX)4oIG$~9_Mg2l zr+v}Ez3RRkJ^oDP8?5x?b;UVJr-;U5sPhfnQ1|%xWQBGPJF}&u(H4J&S*S%p`qV2` z(b{QMvA(1M(6K+Q9L+`HUYYi^lF;S z=lll1=q2Sigi)^*FE*Y3^ml0a9|o_CibijakEp5jv`MSDXjQ!L|Avxb^ydJTYzAcv Sy!b-^0000 45; + protected override DecimationWeapon.DamageType DamageType => DecimationWeapon.DamageType.Ranged; + + private int Sibling + { + get => (int) projectile.localAI[0]; + set => projectile.localAI[0] = value; + } + + private float Rotation + { + get => projectile.localAI[1]; + set => projectile.localAI[1] = value; + } + + private Projectile SiblingProjectile => Main.projectile[Sibling]; + + private int Counter + { + get => (int) projectile.ai[0]; + set => projectile.ai[0] = value; + } + + private bool IsChild => projectile.ai[1] == 1f; + + private float Speed { get; set; } + private bool Initialization { get; set; } = true; + + protected override void Init() + { + projectile.width = 12; + projectile.height = 12; + projectile.penetrate = -1; + projectile.aiStyle = -1; + projectile.timeLeft = 600; + + Sibling = -1; + } + + public override bool PreKill(int timeLeft) + { + SiblingProjectile.Kill(); + + return true; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0, + 0, 100, default, 4f * projectile.scale); + } + } + + public override void AI() + { + if (!IsChild) + { + if (Sibling == -1) + { + projectile.position.Y -= 8f; + + Rotation = projectile.velocity.ToRotation(); + Speed = projectile.velocity.Length(); + + Sibling = Projectile.NewProjectile(projectile.position, new Vector2(Speed, Rotation), + projectile.type, + projectile.damage, projectile.knockBack, projectile.owner, 0, 1); + } + + // Parent + Vector2 parentVelocity = new Vector2(0, 1) * (float) (1.5f * Math.Sin(Counter * (1 / 8f))); + parentVelocity.X = Speed; + projectile.velocity = parentVelocity.RotatedBy(Rotation); + + // Sibling + Vector2 siblingVelocity = parentVelocity * new Vector2(1, -1); + SiblingProjectile.velocity = siblingVelocity.RotatedBy(Rotation); + + if (Initialization) + { + Vector2 offset = new Vector2(projectile.position.X - SiblingProjectile.position.X, -16); + projectile.velocity += offset.RotatedBy(Rotation); + + Initialization = false; + } + + Counter++; + } + else if (IsChild && Sibling == -1) + { + Sibling = projectile.owner; + } + + Lighting.AddLight(projectile.Center, 0f, 0f, 1f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, projectile.velocity.X * 0.2f, + projectile.velocity.Y * 0.2f, 100, default, 2f * projectile.scale); + } + } +} \ No newline at end of file diff --git a/Content/Projectiles/DuneWyrm/Timekeeper.png b/Content/Projectiles/DuneWyrm/Timekeeper.png new file mode 100644 index 0000000000000000000000000000000000000000..1fc5f3571dfaf3190337b860d8f95accb28a21ae GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$3?vg*uel1O5(0ceT!HleGfrv$)6&iW@&5*f z|3KW((2$Uj@E;^_=FI>93=RL!q=9%_wrp{5aA;^?U;rTq22l?lJox|rf8o@to8SHS zEojczcG0P%L*CFwMa5=|#Nqu63=E7VL4Lsu4$p3+0Xdun9+AZi417mGm~pB$pEOX= z($mE;gkxsv*`0z61{}FVdQ&MBb@032>&ZvX%Q literal 0 HcmV?d00001 diff --git a/Lib/Items/DecimationWeapon.cs b/Lib/Items/DecimationWeapon.cs index 742e278..e234fd9 100644 --- a/Lib/Items/DecimationWeapon.cs +++ b/Lib/Items/DecimationWeapon.cs @@ -63,7 +63,7 @@ namespace Decimation.Lib.Items if (AmmoName != null) item.useAmmo = ItemUtils.GetIdFromName(AmmoName, typeof(Item), VanillaAmmo); - if (AmmoId > -1) item.ammo = AmmoId; + if (AmmoId > -1) item.useAmmo = AmmoId; if (item.melee) item.noMelee = false; }