Added metal monstrosity, added a function for sticky projectiles and fixed the rarity of burning strife
This commit is contained in:
1 parent
17386d6483
commit
2e276c2748
10 files changed
+339
-1
No files matched your search
@@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
item.UseSound = SoundID.Item1;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.value = Item.buyPrice(0, 36, 0, 0);
|
||||
item.rare = 4;
|
||||
item.rare = 5;
|
||||
item.autoReuse = true;
|
||||
item.noUseGraphic = true;
|
||||
item.noMelee = true;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
public class MetalMonstrosity : RogueWeapon
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Metal Monstrosity");
|
||||
Tooltip.SetDefault("Hurls a heavy metal ball that shatters on impact \n" +
|
||||
"Stealth Strikes makes the ball release spikes as it travels \n" +
|
||||
"'This has to hurt'");
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
{
|
||||
item.width = 32;
|
||||
item.height = 32;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.autoReuse = true;
|
||||
item.noUseGraphic = true;
|
||||
item.noMelee = true;
|
||||
item.UseSound = SoundID.Item1;
|
||||
item.rare = 3;
|
||||
item.value = Item.buyPrice(0, 4, 0, 0);
|
||||
|
||||
item.damage = 40;
|
||||
item.useAnimation = 40;
|
||||
item.useTime = 40;
|
||||
item.knockBack = 7f;
|
||||
item.shoot = ModContent.ProjectileType<MetalChunk>();
|
||||
item.shootSpeed = 7f;
|
||||
|
||||
item.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType<MetalChunk>(), damage, knockBack, player.whoAmI, 0f, 0f);
|
||||
if (player.Calamity().StealthStrikeAvailable())
|
||||
Main.projectile[proj].Calamity().stealthStrike = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ItemID.SpikyBall, 500);
|
||||
recipe.AddIngredient(ItemID.Spike, 80);
|
||||
recipe.AddTile(TileID.Anvils);
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 727 B |
@@ -0,0 +1,65 @@
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class MetalChunk : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Metal Chunk"); //Metal Chungus - Shucks
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 32;
|
||||
projectile.height = 32;
|
||||
projectile.friendly = true;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.ignoreWater = true; //Its hella heavy so ofc
|
||||
projectile.extraUpdates = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
//Gravity
|
||||
projectile.velocity.Y += 0.11f;
|
||||
if (projectile.velocity.Y > 16f)
|
||||
projectile.velocity.Y = 16f;
|
||||
//Rotation
|
||||
projectile.rotation += 0.14f * projectile.direction;
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
{
|
||||
projectile.ai[0]++;
|
||||
if(projectile.ai[0] >= 10f)
|
||||
{
|
||||
Vector2 speed = new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-6f, 6f));
|
||||
Projectile.NewProjectile(projectile.Center, speed, ModContent.ProjectileType<MetalShard>(), (int)(projectile.damage * 0.3f), 0f, projectile.owner, 0f, 0f);
|
||||
projectile.ai[0] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
Main.PlaySound(SoundID.NPCHit42, projectile.Center);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Vector2 S1 = new Vector2(-projectile.velocity.X, -projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-45, 46)));
|
||||
int proj = Projectile.NewProjectile(projectile.Center, S1, ProjectileID.SpikyBall, (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f);
|
||||
Main.projectile[proj].timeLeft = 600;
|
||||
Main.projectile[proj].usesLocalNPCImmunity = true;
|
||||
Main.projectile[proj].localNPCHitCooldown = 20;
|
||||
S1 = new Vector2(-projectile.velocity.X * 0.7f, -projectile.velocity.Y*0.7f).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-45, 46)));
|
||||
Projectile.NewProjectile(projectile.Center, S1, ModContent.ProjectileType<MetalShard>(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f);
|
||||
}
|
||||
//Dust
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Dust.NewDust(projectile.Center, 1, 1, DustID.Lead, 0f, 0f, 0, default, 1.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 727 B |
@@ -0,0 +1,90 @@
|
||||
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class MetalShard : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Metal Shard");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.friendly = true;
|
||||
projectile.width = 12;
|
||||
projectile.height = 12;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.penetrate = 10;
|
||||
projectile.extraUpdates = 1;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 60;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
//Rotation
|
||||
if (projectile.ai[0] == 0f)
|
||||
projectile.rotation += 0.1f;
|
||||
//Gravity
|
||||
projectile.velocity.Y += 0.1f;
|
||||
if (projectile.velocity.Y > 16f)
|
||||
projectile.velocity.Y = 16f;
|
||||
//Sticky Behaviour
|
||||
CalamityUtils.StickyProjAI(projectile);
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
CalamityUtils.ModifyHitNPCSticky(projectile, 8 , true);
|
||||
}
|
||||
|
||||
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 bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture;
|
||||
if (projectile.localAI[1] == 0f)
|
||||
projectile.localAI[1] = Main.rand.Next(1, 4);
|
||||
switch (projectile.localAI[1])
|
||||
{
|
||||
|
||||
case 2f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard2");
|
||||
break;
|
||||
case 3f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard3");
|
||||
break;
|
||||
default: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard");
|
||||
break;
|
||||
}
|
||||
Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Dust.NewDust(projectile.Center, projectile.width, projectile.height, DustID.Lead, 0f, 0f, 0, default, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Main.PlaySound(SoundID.Dig, projectile.Center);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 281 B |
Binary file not shown.
|
After Width: | Height: | Size: 319 B |
Binary file not shown.
|
After Width: | Height: | Size: 269 B |
@@ -324,6 +324,130 @@ namespace CalamityMod
|
||||
proj = x;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC
|
||||
/// </summary>
|
||||
/// <param name="projectile">The projectile you're adding sticky behaviour to</param>
|
||||
public static void StickyProjAI (Projectile projectile)
|
||||
{
|
||||
if (projectile.ai[0] == 1f)
|
||||
{
|
||||
projectile.tileCollide = false;
|
||||
int num988 = 15;
|
||||
bool flag54 = false;
|
||||
bool flag55 = false;
|
||||
projectile.localAI[0]++;
|
||||
if (projectile.localAI[0] % 30f == 0f)
|
||||
{
|
||||
flag55 = true;
|
||||
}
|
||||
int num989 = (int)projectile.ai[1];
|
||||
if (projectile.localAI[0] >= (float)(60 * num988))
|
||||
{
|
||||
flag54 = true;
|
||||
}
|
||||
else if (num989 < 0 || num989 >= 200)
|
||||
{
|
||||
flag54 = true;
|
||||
}
|
||||
else if (Main.npc[num989].active && !Main.npc[num989].dontTakeDamage)
|
||||
{
|
||||
projectile.Center = Main.npc[num989].Center - projectile.velocity * 2f;
|
||||
projectile.gfxOffY = Main.npc[num989].gfxOffY;
|
||||
if (flag55)
|
||||
{
|
||||
Main.npc[num989].HitEffect(0, 1.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag54 = true;
|
||||
}
|
||||
if (flag54)
|
||||
{
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile
|
||||
/// </summary>
|
||||
/// <param name="projectile">The projectile you're giving sticky behaviour to</param>
|
||||
/// <param name="maxStick">How many projectiles of this type can stick to one enemy</param>
|
||||
/// <param name="constantDamage">Decides if you want the projectile to deal damage while its sticked to enemies or not</param>
|
||||
public static void ModifyHitNPCSticky(Projectile projectile, int maxStick, bool constantDamage)
|
||||
{
|
||||
Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
|
||||
if (projectile.owner == Main.myPlayer)
|
||||
{
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
if (Main.npc[i].active && !Main.npc[i].dontTakeDamage &&
|
||||
((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) ||
|
||||
(projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1))
|
||||
{
|
||||
if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i]))
|
||||
{
|
||||
bool flag3;
|
||||
if (Main.npc[i].type == 414)
|
||||
{
|
||||
Rectangle rect = Main.npc[i].getRect();
|
||||
int num5 = 8;
|
||||
rect.X -= num5;
|
||||
rect.Y -= num5;
|
||||
rect.Width += num5 * 2;
|
||||
rect.Height += num5 * 2;
|
||||
flag3 = projectile.Colliding(myRect, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag3 = projectile.Colliding(myRect, Main.npc[i].getRect());
|
||||
}
|
||||
if (flag3)
|
||||
{
|
||||
if (Main.npc[i].reflectingProjectiles && projectile.CanReflect())
|
||||
{
|
||||
Main.npc[i].ReflectProjectile(projectile.whoAmI);
|
||||
return;
|
||||
}
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.ai[1] = (float)i;
|
||||
projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f;
|
||||
projectile.netUpdate = true;
|
||||
if (!constantDamage)
|
||||
projectile.damage = 0;
|
||||
Point[] array2 = new Point[maxStick];
|
||||
int num29 = 0;
|
||||
for (int l = 0; l < 1000; l++)
|
||||
{
|
||||
if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i)
|
||||
{
|
||||
array2[num29++] = new Point(l, Main.projectile[l].timeLeft);
|
||||
if (num29 >= array2.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num29 >= array2.Length)
|
||||
{
|
||||
int num30 = 0;
|
||||
for (int m = 1; m < array2.Length; m++)
|
||||
{
|
||||
if (array2[m].Y < array2[num30].Y)
|
||||
{
|
||||
num30 = m;
|
||||
}
|
||||
}
|
||||
Main.projectile[array2[num30].X].Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Tile Utilities
|
||||
|
||||
Reference in new issue
Block a user