Basic function done
This commit is contained in:
1 parent
42bc6dcdc6
commit
e6ca5fee63
4 files changed
+170
-71
No files matched your search
@@ -6,6 +6,7 @@ using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using XPT.Core.Audio.MP3Sharp.Decoding;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
@@ -21,8 +22,10 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Item.useTime = Item.useAnimation = 6;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 3f;
|
||||
Item.UseSound = SoundID.Item11;
|
||||
Item.knockBack = 5f;
|
||||
Item.UseSound = null;
|
||||
Item.noUseGraphic = true;
|
||||
Item.channel = true;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ProjectileID.PurificationPowder;
|
||||
Item.shootSpeed = 16f;
|
||||
@@ -33,31 +36,15 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Item.Calamity().canFirePointBlankShots = true;
|
||||
}
|
||||
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) > 40;
|
||||
|
||||
public override Vector2? HoldoutOffset() => new Vector2(-5, 0);
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player) => false;
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
if (Main.rand.NextBool(8))
|
||||
{
|
||||
Projectile.NewProjectile(source, position, velocity * 0.8f,
|
||||
ModContent.ProjectileType<EmesisGore>(), damage, knockback, player.whoAmI);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustDirect(position, 10, 10, DustID.Shadowflame);
|
||||
dust.velocity = Vector2.Normalize(velocity).RotatedByRandom(MathHelper.ToRadians(15f));
|
||||
dust.noGravity = true;
|
||||
}
|
||||
if (player.Calamity().soundCooldown <= 0)
|
||||
{
|
||||
// WoF vomit sound.
|
||||
SoundEngine.PlaySound(SoundID.NPCDeath13 with { Volume = SoundID.NPCDeath13.Volume * 0.5f }, position);
|
||||
player.Calamity().soundCooldown = 120;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType<FetidEmesisHoldout>(), damage, knockback, player.whoAmI);
|
||||
|
||||
// We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out.
|
||||
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -10,77 +11,50 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
public class EmesisGore : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public int HurtCounter = 0;
|
||||
public const int HurtTimeIncrement = 10;
|
||||
public bool setStats = true;
|
||||
public int rotDirection = 1;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 12;
|
||||
Projectile.height = 12;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = 10;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.extraUpdates = 4;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 6;
|
||||
}
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(HurtCounter);
|
||||
}
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
HurtCounter = reader.ReadInt32();
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.StickyProjAI(15);
|
||||
|
||||
// Override the default DOT used in the method above.
|
||||
if (Projectile.ai[0] == 1f)
|
||||
if (setStats)
|
||||
{
|
||||
Projectile.localAI[0] = 5f;
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
HurtCounter++;
|
||||
if (HurtCounter % HurtTimeIncrement == 0)
|
||||
{
|
||||
Main.npc[(int)Projectile.ai[1]].HitEffect(0, 50.0);
|
||||
}
|
||||
rotDirection = (Main.rand.NextBool() ? -1 : 1);
|
||||
Projectile.scale = Main.rand.NextFloat(0.75f, 1.2f);
|
||||
setStats = false;
|
||||
}
|
||||
else
|
||||
Projectile.rotation += 0.009f * rotDirection * Projectile.scale * Utils.GetLerpValue(0, 300, Projectile.timeLeft);
|
||||
Projectile.velocity *= 0.995f;
|
||||
Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 70, 0, 0, 255, true));
|
||||
if (Projectile.timeLeft > 70)
|
||||
{
|
||||
Projectile.rotation += (Projectile.velocity.X > 0).ToDirectionInt() * MathHelper.ToRadians(8f);
|
||||
}
|
||||
if (Projectile.timeLeft % 12 == 11)
|
||||
{
|
||||
for (int i = 0; i < (Projectile.ai[0] == 1f ? 3 : 1); i++)
|
||||
if (Projectile.timeLeft % 2 == 0)
|
||||
{
|
||||
Dust dust = Dust.NewDustDirect(Projectile.position, 10, 10, DustID.Shadowflame);
|
||||
dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi);
|
||||
dust.noGravity = true;
|
||||
SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 2f, -Projectile.velocity * 0.05f, false, 7, Projectile.scale, Color.Lime * 0.135f);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(8);
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
if (targetHitbox.Width > 8 && targetHitbox.Height > 8)
|
||||
{
|
||||
targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 60);
|
||||
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 60);
|
||||
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 180);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class FetidEmesisHoldout : BaseGunHoldoutProjectile
|
||||
{
|
||||
public override int AssociatedItemID => ModContent.ItemType<FetidEmesis>();
|
||||
public override float MaxOffsetLengthFromArm => 24f;
|
||||
public override float OffsetXUpwards => -5f;
|
||||
public override float BaseOffsetY => -5f;
|
||||
public override float OffsetYDownwards => 5f;
|
||||
|
||||
public ref float revFrames => ref Projectile.ai[0];
|
||||
public ref float cooldownTimer => ref Projectile.ai[1];
|
||||
public ref float shootingTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil
|
||||
public bool isTired => cooldownTimer > 0;
|
||||
public float revSpeed = 1;
|
||||
|
||||
public override void KillHoldoutLogic()
|
||||
{
|
||||
if ( !isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type))
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
public override void HoldoutAI()
|
||||
{
|
||||
if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type))
|
||||
cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 180, true));
|
||||
if (isTired)
|
||||
{
|
||||
PostFiringCooldown();
|
||||
return;
|
||||
}
|
||||
revSpeed = Utils.Remap(revFrames, 0, 200, 1, 20, true);
|
||||
if (shootingTimer >= 60)
|
||||
{
|
||||
int bulletAMMO = ProjectileID.Bullet;
|
||||
Owner.PickAmmo(Owner.ActiveItem(), out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _, Main.rand.Next(0, 100 + 1) < 50);
|
||||
|
||||
SoundStyle fire = new("CalamityMod/Sounds/Item/StrongGunShot");
|
||||
SoundEngine.PlaySound(fire with { Volume = 0.7f }, Projectile.Center);
|
||||
|
||||
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12;
|
||||
float spread = 0.045f * Utils.GetLerpValue(0, 300, revFrames, true);
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(spread), bulletAMMO, Projectile.damage, Projectile.knockBack, Projectile.owner);
|
||||
|
||||
for (int i = 0; i <= 3; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 5, Main.rand.NextBool(5) ? 28 : 215, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f));
|
||||
dust.noGravity = true;
|
||||
}
|
||||
GenericSparkle sparker = new GenericSparkle(GunTipPosition, Vector2.Zero, Color.DarkGoldenrod, Color.Gold, Main.rand.NextFloat(1.1f, 1.8f), 2, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f);
|
||||
GeneralParticleHandler.SpawnParticle(sparker);
|
||||
|
||||
OffsetLengthFromArm -= 5f;
|
||||
shootingTimer = 0;
|
||||
}
|
||||
|
||||
shootingTimer += revSpeed;
|
||||
revFrames++;
|
||||
if (revFrames >= 300)
|
||||
{
|
||||
Owner.Calamity().GeneralScreenShakePower = 6.5f;
|
||||
OffsetLengthFromArm -= 35f;
|
||||
cooldownTimer = 180;
|
||||
SoundStyle bigShot = new("CalamityMod/Sounds/Custom/Perforator/PerfHiveIchorShoot");
|
||||
SoundStyle bigShotGun = new("CalamityMod/Sounds/Item/FlakKrakenShoot");
|
||||
SoundEngine.PlaySound(bigShot with { Pitch = -0.2f, Volume = 0.6f }, Projectile.Center);
|
||||
SoundEngine.PlaySound(bigShotGun with { Volume = 0.6f }, Projectile.Center);
|
||||
|
||||
for (int i = 0; i <= 12; i++)
|
||||
{
|
||||
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 13;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(0.02f * i) * Main.rand.NextFloat(0.7f, 1.1f), ModContent.ProjectileType<EmesisGore>(), Projectile.damage, Projectile.knockBack * 3, Projectile.owner);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PostFiringCooldown()
|
||||
{
|
||||
Owner.channel = true;
|
||||
|
||||
if (cooldownTimer > 1)
|
||||
{
|
||||
Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5;
|
||||
|
||||
if (cooldownTimer % 40 == 0)
|
||||
{
|
||||
SoundStyle tired = new("CalamityMod/Sounds/Custom/OldDukeHuff");
|
||||
SoundEngine.PlaySound(tired with { Pitch = -0.2f }, Projectile.Center);
|
||||
for (int i = 0; i <= 12; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f));
|
||||
dust.noGravity = false;
|
||||
dust.color = Color.White;
|
||||
}
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true);
|
||||
GeneralParticleHandler.SpawnParticle(smoke);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
cooldownTimer--;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (revFrames < 2)
|
||||
return false;
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = texture.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user