Added Scorched Earth weapon

This commit is contained in:
ben-tk committed 2022-01-06 14:29:38 -05:00
1 parent 3f08343561
commit 99cd705eb7
13 files changed
+396 -14

No files matched your search

+1
View File
@@ -1039,6 +1039,7 @@ namespace CalamityMod
ItemType<PurgeGuzzler>(),
ItemType<RedSun>(),
ItemType<SarosPossession>(),
ItemType<ScorchedEarth>(),
ItemType<ShatteredSun>(),
ItemID.SolarEruption,
ItemType<SolarFlare>(),
+1 -1
View File
@@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Ranged
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ThePack>());
recipe.AddIngredient(ModContent.ItemType<BlissfulBombardier>());
recipe.AddIngredient(ModContent.ItemType<ScorchedEarth>()); // This weapon has two donor weapons
recipe.AddIngredient(ModContent.ItemType<AethersWhisper>());
recipe.AddIngredient(ItemID.ElectrosphereLauncher);
recipe.AddIngredient(ModContent.ItemType<MiracleMatter>());
+76
View File
@@ -0,0 +1,76 @@
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class ScorchedEarth : ModItem
{
private int counter = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Scorched Earth");
Tooltip.SetDefault("Fires a burst of four fuel-air rockets which explode into cluster bombs\n" +
"Each burst consumes two rockets each\n" +
"Burns your targets to a fine crisp");
}
public override void SetDefaults()
{
item.damage = 123;
item.ranged = true;
item.useTime = 8;
item.useAnimation = 32; // 4 shots in just over half a second
item.reuseDelay = 60; // 1 second recharge
item.width = 104;
item.height = 44;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.knockBack = 8.7f;
item.value = CalamityGlobalItem.Rarity14BuyPrice;
item.rare = ItemRarityID.Purple;
item.Calamity().customRarity = CalamityRarity.DarkBlue;
item.autoReuse = true;
item.shootSpeed = 12.6f;
item.shoot = ModContent.ProjectileType<ScorchedEarthRocket>();
item.useAmmo = AmmoID.Rocket;
item.Calamity().donorItem = true;
}
// Consume two ammo per fire
public override bool ConsumeAmmo(Player player) => counter % 2 == 0;
public override Vector2? HoldoutOffset() => new Vector2(-30, 0);
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), ModContent.ProjectileType<ScorchedEarthRocket>(), damage, knockBack, player.whoAmI);
if (counter == 0)
{
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ScorchedEarthShot" + Main.rand.Next(1,4)), position);
}
counter++;
if (counter == 4)
counter = 0;
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<BlissfulBombardier>());
recipe.AddIngredient(ModContent.ItemType<DarksunFragment>(), 10);
recipe.AddIngredient(ItemID.FragmentSolar, 50);
recipe.AddRecipeGroup("AnyAdamantiteBar", 15);
recipe.AddTile(ModContent.TileType<CosmicAnvil>());
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+148
View File
@@ -0,0 +1,148 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class RocketFire : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Rogue/TotalityFire";
private bool initialized = false;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Fire");
Main.projFrames[projectile.type] = 3;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 2;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 14;
projectile.height = 14;
projectile.friendly = true;
projectile.penetrate = 3;
projectile.timeLeft = 120;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -1;
projectile.ranged = true;
projectile.ignoreWater = true;
}
public override void AI()
{
//make it face the way it's going
if (projectile.ai[1] > 0f)
{
projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2;
}
else
{
projectile.rotation = projectile.velocity.ToRotation();
}
projectile.ai[1]--;
//frames
if (!initialized)
{
initialized = true;
projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]);
}
projectile.frameCounter++;
if (projectile.frameCounter > 6)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= Main.projFrames[projectile.type])
{
projectile.frame = 0;
}
//movement
if (projectile.velocity.X != projectile.velocity.X)
{
projectile.velocity.X *= -0.1f;
}
if (projectile.velocity.X != projectile.velocity.X)
{
projectile.velocity.X *= -0.5f;
}
if (projectile.velocity.Y != projectile.velocity.Y && projectile.velocity.Y > 1f)
{
projectile.velocity.Y *= -0.5f;
}
projectile.ai[0] += 1f;
if (projectile.ai[0] > 5f)
{
projectile.ai[0] = 5f;
if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f)
{
projectile.velocity.X *= 0.97f;
if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f)
{
projectile.velocity.X = 0f;
projectile.netUpdate = true;
}
}
projectile.velocity.Y += 0.2f;
}
if (projectile.velocity.Y < 0.25f && projectile.velocity.Y > 0.15f)
{
projectile.velocity.X *= 0.8f;
}
if (projectile.velocity.Y > 16f)
{
projectile.velocity.Y = 16f;
}
//dust
if (Main.rand.NextBool(4))
{
int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[fire];
dust.position.X -= 2f;
dust.position.Y += 2f;
dust.scale += (float)Main.rand.Next(50) * 0.01f;
dust.noGravity = true;
dust.velocity.Y -= 2f;
}
if (Main.rand.NextBool(10))
{
int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[fire];
dust.position.X -= 2f;
dust.position.Y += 2f;
dust.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f;
dust.noGravity = true;
dust.velocity *= 0.1f;
}
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.ai[1] = 10f;
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 120);
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
target.AddBuff(BuffID.OnFire, 120);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
return false;
}
}
}
@@ -0,0 +1,54 @@
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ScorchedEarthClusterBomb : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Cluster Bomb");
}
public override void SetDefaults()
{
projectile.width = 14;
projectile.height = 14;
projectile.friendly = true;
projectile.ranged = true;
projectile.penetrate = -1;
projectile.timeLeft = 120;
projectile.ignoreWater = true;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -2;
}
public override void AI()
{
projectile.rotation = projectile.velocity.ToRotation();
projectile.velocity *= 0.95f;
if (projectile.velocity.Length() < 0.5f && projectile.timeLeft > 10)
projectile.timeLeft = 10;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item14, projectile.position);
for (int i = 0; i < 10; i++)
{
Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 0, default, 1f);
}
int projAmt = Main.rand.Next(2, 4);
if (projectile.owner == Main.myPlayer)
{
for (int k = 0; k < projAmt; k++)
{
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f);
Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType<RocketFire>(), projectile.damage, 0f, projectile.owner);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

+114
View File
@@ -0,0 +1,114 @@
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ScorchedEarthRocket : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Rocket");
Main.projFrames[projectile.type] = 10;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 3;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 22;
projectile.height = 22;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.penetrate = 1;
projectile.timeLeft = 300;
projectile.ranged = true;
projectile.tileCollide = false;
projectile.extraUpdates = 1;
}
public override void AI()
{
//Lighting
Lighting.AddLight(projectile.Center, 1f, 0.79f, 0.3f);
//Animation
projectile.frameCounter++;
if (projectile.frameCounter > (projectile.frame == 1 ? 10 : 7))
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= Main.projFrames[projectile.type])
{
projectile.frame = 6;
}
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 400f, 5f, 30f);
//Rotation
projectile.rotation = projectile.velocity.ToRotation();
if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f)
{
float xVel = projectile.velocity.X * 0.5f;
float yVel = projectile.velocity.Y * 0.5f;
int d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f);
Main.dust[d].scale *= 2f + (float)Main.rand.Next(10) * 0.1f;
Main.dust[d].velocity *= 0.2f;
Main.dust[d].noGravity = true;
d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f);
Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f;
Main.dust[d].velocity *= 0.05f;
}
}
public override void Kill(int timeLeft)
{
CalamityGlobalProjectile.ExpandHitboxBy(projectile, 300);
projectile.maxPenetrate = projectile.penetrate = -1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
projectile.Damage();
Main.PlaySound(SoundID.Item14, projectile.position);
for (int i = 0; i < 40; i++)
{
int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
Main.dust[d].velocity *= 3f;
if (Main.rand.NextBool(2))
{
Main.dust[d].scale = 0.5f;
Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int i = 0; i < 60; i++)
{
int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f);
Main.dust[d].noGravity = true;
Main.dust[d].velocity *= 5f;
d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
Main.dust[d].velocity *= 2f;
}
CalamityUtils.ExplosionGores(projectile.Center, 10);
if (projectile.owner == Main.myPlayer)
{
for (int j = 0; j < 5; j++)
{
Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f);
Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType<ScorchedEarthClusterBomb>(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

+2 -13
View File
@@ -112,19 +112,8 @@ namespace CalamityMod.Projectiles.Ranged
{
for (int k = 0; k < projAmt; k++)
{
Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
while (velocity.X == 0f && velocity.Y == 0f)
{
velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
}
velocity.Normalize();
velocity *= (float)Main.rand.Next(70, 101) * 0.1f;
int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType<TotalityFire>(), (int)(projectile.damage * 0.33), 0f, projectile.owner);
if (flames.WithinBounds(Main.maxProjectiles))
{
Main.projectile[flames].penetrate = 3;
Main.projectile[flames].Calamity().forceRanged = true;
}
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f);
Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType<RocketFire>(), (int)(projectile.damage * 0.33), 0f, projectile.owner);
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.