Infernal Kris

This commit is contained in:
AlterraKira committed 2019-12-10 22:35:18 +00:00
1 parent f3164692fb
commit f7d489feb0
8 files changed
+389

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
using CalamityMod.Projectiles.Rogue;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Rogue
{
public class InfernalKris : RogueWeapon
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Infernal Kris");
Tooltip.SetDefault("Throws a burning dagger that starts spinning after travelling a short distance, inflicting additional damage while spinning\n" +
"Stealth strikes cause the dagger to be engulfed in flames, exploding on contact with walls and enemies");
}
public override void SafeSetDefaults()
{
item.width = 32;
item.damage = 18;
item.noMelee = true;
item.noUseGraphic = true;
item.consumable = true;
item.useAnimation = 18;
item.useStyle = 1;
item.useTime = 18;
item.knockBack = 1f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 30;
item.maxStack = 999;
item.value = Item.buyPrice(0, 1, 0, 0);
item.rare = 3;
item.shoot = ModContent.ProjectileType<InfernalKrisProjectile>();
item.shootSpeed = 15f;
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)
{
if (player.Calamity().StealthStrikeAvailable())
{
int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f);
Main.projectile[p].Calamity().stealthStrike = true;
return false;
}
return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HellstoneBar);
recipe.AddIngredient(ItemID.Obsidian, 2);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this, 100);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

+74
View File
@@ -0,0 +1,74 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class InfernalKrisCinder : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Infernal Cinder");
}
public override void SetDefaults()
{
projectile.width = 4;
projectile.height = 4;
projectile.friendly = true;
projectile.alpha = 0;
projectile.penetrate = 3;
projectile.tileCollide = true;
projectile.timeLeft = 120;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -1;
projectile.Calamity().rogue = true;
}
public override void AI()
{
projectile.velocity.Y += 0.1f;
projectile.rotation += 0.4f * projectile.direction;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height);
float minScale = 1.9f;
float maxScale = 2.5f;
int numDust = 2;
for (int i = 0; i < numDust; i++)
{
Dust.NewDust(projectile.position, 4, 4, 6, projectile.velocity.X, projectile.velocity.Y, 0, default, Main.rand.NextFloat(minScale, maxScale));
}
projectile.Kill();
return true;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 120);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
// If this is a stealth strike, make the blade glow orange
Color glowColour = new Color(255, 215, 100, 100);
Texture2D tex = Main.projectileTexture[projectile.type];
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, glowColour, projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
float minScale = 1.9f;
float maxScale = 2.5f;
int numDust = 2;
for (int i = 0; i < numDust; i++)
{
int dust = Dust.NewDust(projectile.position, 4, 4, 6, 0f, -2f, 0, default, Main.rand.NextFloat(minScale, maxScale));
Main.dust[dust].noGravity = true;
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

@@ -0,0 +1,78 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class InfernalKrisExplosion : ModProjectile
{
public static float radius = 64;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Infernal Explosion");
}
public override void SetDefaults()
{
projectile.width = (int)radius * 2;
projectile.height = (int)radius * 2;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.timeLeft = 9;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -1;
projectile.Calamity().rogue = true;
}
public override void AI()
{
if (projectile.timeLeft >= 5)
{
int numDust = 40;
int dustType = 6;
float minRange = 0;
float maxRange = radius / 10f;
for (int i = 0; i < numDust; i++)
{
Vector2 circleVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1));
circleVelocity.Normalize();
circleVelocity *= Main.rand.NextFloat(minRange, maxRange);
int circle = Dust.NewDust(projectile.Center, 1, 1, dustType, circleVelocity.X, circleVelocity.Y, 0, default, 2f);
Main.dust[circle].noGravity = true;
Main.dust[circle].velocity = circleVelocity;
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 120);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft());
float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight());
float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft());
float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight());
float minDist = dist1;
if (dist2 < minDist)
minDist = dist2;
if (dist3 < minDist)
minDist = dist3;
if (dist4 < minDist)
minDist = dist4;
return minDist <= radius;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

+176
View File
@@ -0,0 +1,176 @@
using CalamityMod.Items.Weapons.Rogue;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class InfernalKrisProjectile : ModProjectile
{
public static int spinTime = 280;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Infernal Kris");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 8;
ProjectileID.Sets.TrailingMode[projectile.type] = 1;
}
public override void SetDefaults()
{
projectile.width = 10;
projectile.height = 10;
projectile.friendly = true;
projectile.penetrate = 5;
projectile.timeLeft = 300;
projectile.Calamity().rogue = true;
}
public override void AI()
{
if (projectile.timeLeft < spinTime)
{
projectile.rotation += 0.4f * projectile.direction;
float minScale = 1.9f;
float maxScale = 2.5f;
int dust = Dust.NewDust(projectile.position - new Vector2(10, 10), 30, 30, 6, projectile.velocity.X, projectile.velocity.Y, 0, default, Main.rand.NextFloat(minScale, maxScale));
Main.dust[dust].noGravity = true;
}
else
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f;
}
projectile.velocity.Y += 0.01f;
if (projectile.velocity.Y > 10f)
{
projectile.velocity.Y = 10f;
}
}
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (projectile.timeLeft < spinTime)
{
damage = (int)(projectile.damage * 1.75f) + Main.rand.Next(0, 6);
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 120);
if (projectile.Calamity().stealthStrike)
{
int sparkCount = Main.rand.Next(3, 7);
for (int i = 0; i < sparkCount; i++)
{
int sparkScatter = 1;
Vector2 sparkVelocity = new Vector2(Main.rand.NextFloat(-sparkScatter, sparkScatter), Main.rand.NextFloat(-sparkScatter - 2, sparkScatter + 2));
sparkVelocity.Normalize();
sparkVelocity *= 3;
Projectile.NewProjectile(projectile.Center, sparkVelocity, ModContent.ProjectileType<InfernalKrisCinder>(), 10, 0, projectile.owner, 0, 0);
}
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<InfernalKrisExplosion>(), 10, 0, projectile.owner, 0, 0);
Main.PlaySound(2, projectile.position, 74);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.Calamity().stealthStrike)
{
// If this is a stealth strike, make the blade glow orange
Color glowColour = new Color(255, 215, 100, 100);
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, glowColour, ProjectileID.Sets.TrailingMode[projectile.type], 3);
float minScale = 1.9f;
float maxScale = 2.5f;
int dust = Dust.NewDust(projectile.position, 10, 10, 6, projectile.velocity.X, projectile.velocity.Y, 0, default, Main.rand.NextFloat(minScale, maxScale));
Main.dust[dust].noGravity = true;
}
else
{
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 3);
}
return false;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height);
projectile.ai[0] = 0;
projectile.ai[1] = 0;
if (projectile.velocity.X != oldVelocity.X)
{
if (oldVelocity.X < 0)
{
projectile.ai[0] = 1;
}
if (oldVelocity.X > 0)
{
projectile.ai[0] = -1;
}
}
if (projectile.velocity.Y != oldVelocity.Y)
{
if (oldVelocity.Y < 0)
{
projectile.ai[1] = 1;
}
if (oldVelocity.Y > 0)
{
projectile.ai[1] = -1;
}
}
Main.PlaySound(0, projectile.position);
projectile.Kill();
return false;
}
public override void Kill(int timeLeft)
{
if (Main.rand.Next(4) == 0)
{
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType<InfernalKris>());
}
if (projectile.Calamity().stealthStrike)
{
int sparkCount = Main.rand.Next(3, 7);
for (int i = 0; i < sparkCount; i++)
{
int sparkScatter = 1;
Vector2 sparkVelocity = new Vector2(Main.rand.NextFloat(-sparkScatter, sparkScatter), Main.rand.NextFloat(-sparkScatter, sparkScatter));
if (projectile.ai[0] != 0)
{
sparkVelocity.X *= -1;
}
if (projectile.ai[1] != 0)
{
sparkVelocity.Y *= -1;
}
sparkVelocity.X += projectile.ai[0];
sparkVelocity.Y += projectile.ai[1];
sparkVelocity.Normalize();
sparkVelocity *= 3;
Projectile.NewProjectile(projectile.Center, sparkVelocity, ModContent.ProjectileType<InfernalKrisCinder>(), 10, 0, projectile.owner, 0, 0);
}
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<InfernalKrisExplosion>(), 10, 0, projectile.owner, 0, 0);
Main.PlaySound(2, projectile.position, 74);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B