Pumpler nerf & unscuff
This commit is contained in:
1 parent
156385ca71
commit
ddc46b316d
3 files changed
+92
-102
No files matched your search
@@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 27;
|
||||
Item.damage = 18;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.width = 72;
|
||||
Item.height = 34;
|
||||
|
||||
@@ -3,11 +3,16 @@ using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using Terraria.Audio;
|
||||
using CalamityMod.Particles;
|
||||
using System;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class PumplerGrenade : ModProjectile
|
||||
{
|
||||
public ref float State => ref Projectile.ai[0];
|
||||
public static int MaxTime => 180;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Squash Shell");
|
||||
@@ -15,63 +20,123 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 16;
|
||||
Projectile.height = 22;
|
||||
Projectile.width = 26;
|
||||
Projectile.height = 26;
|
||||
Projectile.friendly = true;
|
||||
Projectile.timeLeft = 180;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = MaxTime;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
|
||||
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 20;
|
||||
|
||||
}
|
||||
public override string Texture => "CalamityMod/Projectiles/Ranged/PumplerGrenade";
|
||||
|
||||
private void Explode(bool NPCHit = false)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
|
||||
if (Main.myPlayer == Projectile.owner)
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<PumplerGrenadeExplosion>(), (int)(Projectile.damage), Projectile.knockBack, Projectile.owner, NPCHit ? 1 : 0);
|
||||
}
|
||||
Projectile.Kill();
|
||||
|
||||
int size = NPCHit ? 50 : 70; //Bigger explosion if no npc is hit
|
||||
Projectile.scale = (size / (float)Projectile.height) * Projectile.scale;
|
||||
|
||||
Projectile.position -= Vector2.One * (size - Projectile.width) * 0.5f;
|
||||
Projectile.height = Projectile.width = size;
|
||||
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 6;
|
||||
Projectile.hide = true;
|
||||
Projectile.velocity = Vector2.Zero;
|
||||
State = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.timeLeft == 1)
|
||||
Explode();
|
||||
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
Point tileCoords = Projectile.Bottom.ToTileCoordinates();
|
||||
if (Main.tile[tileCoords.X, tileCoords.Y + 1].HasUnactuatedTile &&
|
||||
WorldGen.SolidTile(Main.tile[tileCoords.X, tileCoords.Y + 1]) && Projectile.timeLeft < 165)
|
||||
//Behave like a grenade
|
||||
if (State == 0)
|
||||
{
|
||||
Explode();
|
||||
Projectile.Kill();
|
||||
if (Projectile.timeLeft == 1)
|
||||
{
|
||||
Explode();
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
Point tileCoords = Projectile.Bottom.ToTileCoordinates();
|
||||
if (Main.tile[tileCoords.X, tileCoords.Y + 1].HasUnactuatedTile &&
|
||||
WorldGen.SolidTile(Main.tile[tileCoords.X, tileCoords.Y + 1]) && Projectile.timeLeft < 165)
|
||||
{
|
||||
Explode();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (Projectile.timeLeft < MaxTime - 8)
|
||||
{
|
||||
Projectile.velocity.Y += 0.4f;
|
||||
if (Projectile.velocity.Y > 16f)
|
||||
Projectile.velocity.Y = 16f;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Projectile.velocity.Y += 0.4f;
|
||||
if (Projectile.velocity.Y > 16f)
|
||||
Projectile.velocity.Y = 16f;
|
||||
if (Projectile.timeLeft == 5)
|
||||
SmokeBoom();
|
||||
}
|
||||
}
|
||||
|
||||
private void SmokeBoom()
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
Particle smoke = new SmallSmokeParticle(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30));
|
||||
smoke.Velocity = (smoke.Position - Projectile.Center) * 0.2f + Projectile.velocity;
|
||||
GeneralParticleHandler.SpawnParticle(smoke);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Projectile.velocity *= -1f;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
|
||||
Explode(true);
|
||||
if (State == 0)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
|
||||
Explode(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
public override bool? CanHitNPC(NPC target)
|
||||
{
|
||||
//Damage gets lowered for the main hit, most of the damage comes from the explosion itself.
|
||||
damage = (int)(damage * 0.1f);
|
||||
if (State == 0)
|
||||
return null;
|
||||
|
||||
float blastRadius = Projectile.height / 2f;
|
||||
|
||||
//Get the absolute value of the distance between the target's hitbox center & the explosion's center
|
||||
float distanceX = Math.Abs(Projectile.Center.X - target.Hitbox.Center.X);
|
||||
float distanceY = Math.Abs(Projectile.Center.Y - target.Hitbox.Center.Y);
|
||||
|
||||
//If the distance is just too big for the two to intersect, return false
|
||||
if (distanceX > (target.Hitbox.Width / 2f + blastRadius) || distanceY > (target.Hitbox.Height / 2f + blastRadius))
|
||||
return false;
|
||||
|
||||
//If either distance is too small (aka if the projectile's center is inside of the target's hitbox, return true
|
||||
if (distanceX <= (target.Hitbox.Width / 2f) || distanceY <= (target.Hitbox.Height / 2f))
|
||||
return null;
|
||||
|
||||
//Pythagorean theorem stuff to determine the litteral edge cases
|
||||
float squaredCornerDisance = (float)(Math.Pow(distanceX - target.Hitbox.Width / 2f, 2) + Math.Pow(distanceY - target.Hitbox.Height / 2f, 2));
|
||||
if (squaredCornerDisance <= Math.Pow(blastRadius, 2))
|
||||
return null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Particles;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class PumplerGrenadeExplosion : ModProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
private bool NPCHit => Projectile.ai[0] == 1;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Cucurbitace Blast");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 70;
|
||||
Projectile.height = 70;
|
||||
Projectile.friendly = true;
|
||||
Projectile.timeLeft = 5;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
private void SmokeBoom()
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
Particle smoke = new SmallSmokeParticle(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30));
|
||||
smoke.Velocity = (smoke.Position - Projectile.Center) * 0.2f + Projectile.velocity;
|
||||
GeneralParticleHandler.SpawnParticle(smoke);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? CanHitNPC(NPC target)
|
||||
{
|
||||
float blastRadius = Projectile.height / 2f;
|
||||
|
||||
//Get the absolute value of the distance between the target's hitbox center & the explosion's center
|
||||
float distanceX = Math.Abs(Projectile.Center.X - target.Hitbox.Center.X);
|
||||
float distanceY = Math.Abs(Projectile.Center.Y - target.Hitbox.Center.Y);
|
||||
|
||||
//If the distance is just too big for the two to intersect, return false
|
||||
if (distanceX > (target.Hitbox.Width / 2f + blastRadius) || distanceY > (target.Hitbox.Height / 2f + blastRadius))
|
||||
return false;
|
||||
|
||||
//If either distance is too small (aka if the projectile's center is inside of the target's hitbox, return true
|
||||
if (distanceX <= (target.Hitbox.Width / 2f) || distanceY <= (target.Hitbox.Height / 2f))
|
||||
return true;
|
||||
|
||||
//Pythagorean theorem stuff to determine the litteral edge cases
|
||||
float squaredCornerDisance = (float)(Math.Pow(distanceX - target.Hitbox.Width / 2f, 2) + Math.Pow(distanceY - target.Hitbox.Height / 2f, 2));
|
||||
return (squaredCornerDisance <= Math.Pow(blastRadius, 2));
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
//Bigger explosion if no npc gets hit
|
||||
if (!NPCHit)
|
||||
{
|
||||
Projectile.width = 120;
|
||||
Projectile.height = 120;
|
||||
}
|
||||
|
||||
if (Projectile.timeLeft == 5)
|
||||
SmokeBoom();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user