Merge branch '1.4' of https://github.com/CalamityTeam/CalamityMod into 1.4
This commit is contained in:
commit
0e3c9dfbbf
23 files changed
+144
-153
No files matched your search
@@ -30,7 +30,7 @@ namespace CalamityMod.BiomeManagers
|
||||
if (acidRain)
|
||||
{
|
||||
music = DownedBossSystem.downedPolterghast
|
||||
? CalamityMod.Instance.GetMusicFromMusicMod("AcidRain2") ?? MusicID.Eclipse // Acid Rain Tier 3
|
||||
? CalamityMod.Instance.GetMusicFromMusicMod("AcidRain2") ?? MusicID.Monsoon // Acid Rain Tier 3
|
||||
: CalamityMod.Instance.GetMusicFromMusicMod("AcidRain1") ?? MusicID.OldOnesArmy; // Acid Rain Tier 1 + 2
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Player.Update_NPCCollision += NerfShieldOfCthulhuBonkSafety;
|
||||
On.Terraria.WorldGen.OpenDoor += OpenDoor_LabDoorOverride;
|
||||
On.Terraria.WorldGen.CloseDoor += CloseDoor_LabDoorOverride;
|
||||
On.Terraria.Wiring.Teleport += DisableTeleporters; // only applies in boss rush
|
||||
IL.Terraria.Main.DrawInterface_40_InteractItemIcon += MakeMouseHoverItemsSupportAnimations;
|
||||
On.Terraria.Item.AffixName += IncorporateEnchantmentInAffix;
|
||||
On.Terraria.Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float += IncorporateMinionExplodingCountdown;
|
||||
@@ -155,7 +154,6 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Player.Update_NPCCollision -= NerfShieldOfCthulhuBonkSafety;
|
||||
On.Terraria.WorldGen.OpenDoor -= OpenDoor_LabDoorOverride;
|
||||
On.Terraria.WorldGen.CloseDoor -= CloseDoor_LabDoorOverride;
|
||||
On.Terraria.Wiring.Teleport -= DisableTeleporters;
|
||||
IL.Terraria.Main.DrawInterface_40_InteractItemIcon -= MakeMouseHoverItemsSupportAnimations;
|
||||
On.Terraria.Item.AffixName -= IncorporateEnchantmentInAffix;
|
||||
On.Terraria.Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float -= IncorporateMinionExplodingCountdown;
|
||||
|
||||
@@ -449,16 +449,6 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
#endregion Platform Collision Checks for Grounded Bosses
|
||||
|
||||
#region Teleporter Disabling During Boss Fights
|
||||
private static void DisableTeleporters(On.Terraria.Wiring.orig_Teleport orig)
|
||||
{
|
||||
if (CalamityPlayer.areThereAnyDamnBosses)
|
||||
return;
|
||||
|
||||
orig();
|
||||
}
|
||||
#endregion Teleporter Disabling During Boss Fights
|
||||
|
||||
#region Incorporate Enchantments in Item Names
|
||||
private static string IncorporateEnchantmentInAffix(On.Terraria.Item.orig_AffixName orig, Item self)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace CalamityMod.Items.Accessories
|
||||
AddIngredient<OrnateShield>().
|
||||
AddIngredient<ShieldoftheOcean>().
|
||||
AddIngredient<CoreofCalamity>().
|
||||
AddIngredient(ItemID.LifeFruit, 5).
|
||||
AddTile(TileID.MythrilAnvil).
|
||||
Register();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
SacrificeTotal = 1;
|
||||
DisplayName.SetDefault("Scuttler's Jewel");
|
||||
Tooltip.SetDefault("Stealth strike projectiles spawn a jewel spike when destroyed");
|
||||
Tooltip.SetDefault("Stealth strike projectiles spawn a jewel spike when destroyed\n" +
|
||||
"Can also be broken down at an extractinator");
|
||||
ItemID.Sets.ExtractinatorMode[Item.type] = Item.type;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
@@ -21,6 +23,12 @@ namespace CalamityMod.Items.Accessories
|
||||
Item.value = CalamityGlobalItem.Rarity1BuyPrice;
|
||||
Item.rare = ItemRarityID.Blue;
|
||||
Item.accessory = true;
|
||||
|
||||
Item.useStyle = ItemUseStyleID.HiddenAnimation;
|
||||
Item.useAnimation = 10;
|
||||
Item.useTime = 2;
|
||||
Item.consumable = true;
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual)
|
||||
@@ -28,5 +36,26 @@ namespace CalamityMod.Items.Accessories
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.scuttlersJewel = true;
|
||||
}
|
||||
|
||||
public override void ExtractinatorUse(ref int resultType, ref int resultStack)
|
||||
{
|
||||
float dropRand = Main.rand.Next(1, 8);
|
||||
resultStack = Main.rand.Next(1, 3);
|
||||
|
||||
if (dropRand == 1f)
|
||||
resultType = ItemID.Ruby;
|
||||
else if (dropRand == 2f)
|
||||
resultType = ItemID.Diamond;
|
||||
else if (dropRand == 3f)
|
||||
resultType = ItemID.Emerald;
|
||||
else if (dropRand == 4f)
|
||||
resultType = ItemID.Topaz;
|
||||
else if (dropRand == 5f)
|
||||
resultType = ItemID.Sapphire;
|
||||
else if (dropRand == 6f)
|
||||
resultType = ItemID.Amethyst;
|
||||
else if (dropRand >= 7f)
|
||||
resultType = ItemID.Amber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -889,10 +889,6 @@ namespace CalamityMod.Items
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion)
|
||||
{
|
||||
return !player.HasBuff(ModContent.BuffType<BossEffects>());
|
||||
}
|
||||
if (item.type == ItemID.RodofDiscord)
|
||||
{
|
||||
if (player.chaosState)
|
||||
|
||||
@@ -291,9 +291,9 @@ namespace CalamityMod.Items
|
||||
case ItemID.HallowedFishingCrate:
|
||||
case ItemID.HallowedFishingCrateHard:
|
||||
BlockCrateDrops();
|
||||
int potion = WorldGen.crimson ? ModContent.ItemType<ProfanedRagePotion>() : ModContent.ItemType<HolyWrathPotion>();
|
||||
DropHelper.DropItemCondition(s, player, ModContent.ItemType<UnholyEssence>(), DownedBossSystem.downedProvidence, 0.15f, 5, 10);
|
||||
DropHelper.DropItemCondition(s, player, potion, DownedBossSystem.downedProvidence, 0.1f, 1, 2);
|
||||
DropHelper.DropItemCondition(s, player, ModContent.ItemType<ProfanedRagePotion>(), DownedBossSystem.downedProvidence, 0.15f, 1, 2);
|
||||
DropHelper.DropItemCondition(s, player, ModContent.ItemType<HolyWrathPotion>(), DownedBossSystem.downedProvidence, 0.15f, 1, 2);
|
||||
break;
|
||||
|
||||
case ItemID.DungeonFishingCrate:
|
||||
|
||||
@@ -255,20 +255,10 @@ namespace CalamityMod.Items
|
||||
if (item.type == ItemID.GelBalloon)
|
||||
EditTooltipByNum(0, (line) => line.Text = "");
|
||||
|
||||
// Teleporters not working while a boss is alive.
|
||||
if (item.type == ItemID.Teleporter)
|
||||
EditTooltipByName("Placeable", (line) => line.Text += "\nCannot be used while a boss is alive");
|
||||
|
||||
// Flesh Knuckles giving extra max life.
|
||||
if (item.type == ItemID.FleshKnuckles || item.type == ItemID.HeroShield || item.type == ItemID.BerserkerGlove)
|
||||
EditTooltipByNum(0, (line) => line.Text += "\nMax life increased by 45");
|
||||
|
||||
// Mirrors and Recall Potions cannot be used while a boss is alive.
|
||||
if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion)
|
||||
ApplyTooltipEdits(tooltips,
|
||||
(i, l) => l.Mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"),
|
||||
(line) => line.Text += "\nCannot be used while you have the Boss Effects buff");
|
||||
|
||||
// Rod of Discord cannot be used multiple times to hurt yourself
|
||||
if (item.type == ItemID.RodofDiscord)
|
||||
EditTooltipByNum(0, (line) => line.Text += "\nTeleportation is disabled while Chaos State is active");
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
CreateRecipe().
|
||||
AddIngredient(ItemID.ConfettiCannon).
|
||||
AddIngredient<CosmicRainbow>().
|
||||
AddIngredient(ItemID.FireworksLauncher).
|
||||
AddIngredient(ItemID.Celeb2).
|
||||
AddIngredient(ItemID.FlaskofParty, 5).
|
||||
AddIngredient(ItemID.SoulofLight, 25).
|
||||
AddIngredient(ItemID.Confetti, 50).
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
AddIngredient(ItemID.Wood, 10).
|
||||
AddIngredient(ItemID.SoulofLight, 5).
|
||||
AddIngredient(ItemID.SoulofNight, 5).
|
||||
AddIngredient(ItemID.Bowl).
|
||||
AddIngredient(ItemID.FoodPlatter, 3).
|
||||
AddTile(TileID.Anvils).
|
||||
Register();
|
||||
}
|
||||
|
||||
@@ -406,15 +406,17 @@ namespace CalamityMod.NPCs
|
||||
#endregion
|
||||
|
||||
#region Blood Moon
|
||||
// Drippler
|
||||
// Bouncing Eyeball @ 2.5% Normal, 5% Expert+
|
||||
case NPCID.Drippler:
|
||||
npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType<BouncingEyeball>(), 40, 20));
|
||||
break;
|
||||
|
||||
// All Blood Moon fishing enemies
|
||||
// Drop more Blood Orbs @ 100%
|
||||
|
||||
// Wandering Eye Fish
|
||||
// Bouncing Eyeball @ 10% Normal, 16.66% Expert+
|
||||
case NPCID.EyeballFlyingFish:
|
||||
npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType<BouncingEyeball>(), 10, 6));
|
||||
npcLoot.Add(ModContent.ItemType<BloodOrb>(), 1, 3, 6);
|
||||
break;
|
||||
|
||||
case NPCID.ZombieMerman:
|
||||
npcLoot.Add(ModContent.ItemType<BloodOrb>(), 1, 3, 6);
|
||||
break;
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Amber, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Amethyst, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.CrystalShard, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Diamond, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Emerald, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Ruby, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Sapphire, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
||||
{
|
||||
npcLoot.Add(ItemID.Topaz, 1, 2, 4);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 10);
|
||||
npcLoot.Add(ModContent.ItemType<ScuttlersJewel>(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,6 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Cnidarian");
|
||||
ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 7f;
|
||||
ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 240f;
|
||||
ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 11f;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
@@ -64,8 +61,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public void SetOrigin(Vector2 position)
|
||||
{
|
||||
Projectile.Center = position;
|
||||
if ((Projectile.Center - Owner.Center).Length() > 380f)
|
||||
Projectile.Center = Owner.Center + (Projectile.Center - Owner.Center).SafeNormalize(Vector2.One) * 380f;
|
||||
if ((Projectile.Center - Owner.Center).Length() > 380f * Owner.whipRangeMultiplier)
|
||||
Projectile.Center = Owner.Center + (Projectile.Center - Owner.Center).SafeNormalize(Vector2.One) * 380f * Owner.whipRangeMultiplier;
|
||||
}
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
|
||||
@@ -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