Shock Grenades

This commit is contained in:
AlterraKira committed 2019-12-26 16:50:10 +00:00
1 parent 6e90f4d56e
commit 0ef10ef454
16 files changed
+579 -2

No files matched your search

+7 -2
View File
@@ -59,9 +59,14 @@ namespace CalamityMod.Buffs
else if (type == BuffID.Slow)
{
if (npc.Calamity().slowed < npc.buffTime[buffIndex])
{
npc.Calamity().slowed = npc.buffTime[buffIndex];
}
npc.DelBuff(buffIndex);
buffIndex--;
}
if (type == BuffID.Electrified)
{
if (npc.Calamity().electrified < npc.buffTime[buffIndex])
npc.Calamity().electrified = npc.buffTime[buffIndex];
npc.DelBuff(buffIndex);
buffIndex--;
}
+69
View File
@@ -0,0 +1,69 @@
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Rogue;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Rogue
{
public class ShockGrenade : RogueWeapon
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Shock Grenade");
Tooltip.SetDefault("Throws a grenade that explodes into a burst of lightning\n" +
"Stealth strikes cause the grenade to leave an electrifying aura when it explodes");
}
public override void SafeSetDefaults()
{
item.width = 14;
item.damage = 100;
item.noMelee = true;
item.noUseGraphic = true;
item.consumable = true;
item.useAnimation = 18;
item.useStyle = 1;
item.useTime = 18;
item.knockBack = 1f;
item.autoReuse = true;
item.height = 30;
item.maxStack = 999;
item.value = Item.buyPrice(0, 1, 0, 0);
item.rare = 8;
item.shoot = ModContent.ProjectileType<ShockGrenadeProjectile>();
item.shootSpeed = 7.5f;
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, 0f);
Main.projectile[p].Calamity().stealthStrike = true;
return false;
}
return true;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Vector2 origin = new Vector2(item.width / 2, item.height / 2);
spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ShockGrenadeGlow"), item.Center - Main.screenPosition, null, Color.White, rotation, origin, 1f, SpriteEffects.None, 0f);
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Grenade, 10);
recipe.AddIngredient(ItemID.MartianConduitPlating, 2);
recipe.AddIngredient(ItemID.Nanites, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this, 10);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

+23
View File
@@ -98,6 +98,7 @@ namespace CalamityMod.NPCs
public int silvaStun = 0;
public int webbed = 0;
public int slowed = 0;
public int electrified = 0;
public int yellowCandle = 0;
public int pearlAura = 0;
public int wCleave = 0;
@@ -544,6 +545,10 @@ namespace CalamityMod.NPCs
ApplyDPSDebuff(dFlames, 2500, 500, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(bBlood, 50, 10, ref npc.lifeRegen, ref damage);
ApplyDPSDebuff(sulphurPoison, 180, 36, ref npc.lifeRegen, ref damage);
if (npc.velocity.X == 0)
ApplyDPSDebuff(electrified, 4, 2, ref npc.lifeRegen, ref damage);
else
ApplyDPSDebuff(electrified, 16, 16, ref npc.lifeRegen, ref damage);
}
public void ApplyDPSDebuff(int debuff, int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage)
@@ -611,6 +616,7 @@ namespace CalamityMod.NPCs
npc.buffImmune[ModContent.BuffType<TimeSlow>()] = true;
npc.buffImmune[BuffID.Webbed] = true;
npc.buffImmune[BuffID.Slow] = true;
npc.buffImmune[BuffID.Electrified] = true;
}
if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.DD2EterniaCrystal || npc.townNPC)
@@ -2121,6 +2127,8 @@ namespace CalamityMod.NPCs
webbed--;
if (slowed > 0)
slowed--;
if (electrified > 0)
electrified--;
if (yellowCandle > 0)
yellowCandle--;
if (pearlAura > 0)
@@ -3189,6 +3197,21 @@ namespace CalamityMod.NPCs
}
}
}
if (electrified > 0)
{
if (Main.rand.Next(5) < 4)
{
int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 132, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 0, default, 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 1.1f;
Main.dust[dust].velocity.Y += 0.25f;
if (Main.rand.NextBool(2))
{
Main.dust[dust].noGravity = false;
Main.dust[dust].scale *= 0.5f;
}
}
}
if (gState > 0 || eFreeze > 0)
{
+12
View File
@@ -1667,6 +1667,18 @@ namespace CalamityMod.NPCs
DropHelper.DropItemCondition(npc, ModContent.ItemType<DarksunFragment>(), CalamityWorld.downedBuffedMothron, Main.expertMode ? 0.06f : 0.04f, 1, 1);
break;
case NPCID.MartianOfficer:
DropHelper.DropItemChance(npc, ModContent.ItemType<ShockGrenade>(), Main.expertMode ? 3 : 4, 3, 8);
break;
case NPCID.BrainScrambler:
case NPCID.GrayGrunt:
case NPCID.GigaZapper:
case NPCID.MartianEngineer:
case NPCID.RayGunner:
case NPCID.ScutlixRider:
DropHelper.DropItemChance(npc, ModContent.ItemType<ShockGrenade>(), Main.expertMode ? 4 : 5, 1, 4);
break;
default:
break;
}
+121
View File
@@ -0,0 +1,121 @@
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ShockGrenadeBolt : ModProjectile
{
public static int frameWidth = 12;
public static int frameHeight = 26;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Bolt");
Main.projFrames[projectile.type] = 4;
}
public override void SetDefaults()
{
projectile.width = 10;
projectile.height = 10;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.penetrate = 3;
projectile.timeLeft = 120;
projectile.Calamity().rogue = true;
}
public override void AI()
{
projectile.frameCounter++;
if (projectile.frameCounter > 6)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= Main.projFrames[projectile.type])
{
projectile.frame = 0;
}
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
if (projectile.timeLeft < 55)
{
projectile.tileCollide = true;
}
if (projectile.ai[1] == 1f)
{
float minDist = 999f;
int index = 0;
for (int i = 0; i < Main.npc.Length; i++)
{
NPC npc = Main.npc[i];
if (!npc.friendly && !npc.townNPC && npc.active && !npc.dontTakeDamage && npc.chaseable)
{
float dist = (projectile.Center - npc.Center).Length();
if (dist < minDist)
{
minDist = dist;
index = i;
}
}
}
Vector2 velocityNew;
if (minDist < 999f)
{
velocityNew = Main.npc[index].Center - projectile.Center;
velocityNew.Normalize();
velocityNew *= 2f;
projectile.velocity += velocityNew;
if (projectile.velocity.Length() > 10f)
{
projectile.velocity.Normalize();
projectile.velocity *= 10f;
}
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Electrified, 180);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D sprite;
if (projectile.ai[0] == 0f)
sprite = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/ShockGrenadeBolt");
else
sprite = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/ShockGrenadeBolt2");
Color drawColour = Color.White;
Vector2 origin = new Vector2(frameWidth / 2, frameHeight / 2);
spriteBatch.Draw(sprite, projectile.Center - Main.screenPosition, new Rectangle(0, frameHeight * projectile.frame, frameWidth, frameHeight), drawColour, projectile.rotation, origin, 1f, SpriteEffects.None, 0f);
return false;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 93, 0.25f, 0f);
for (int i = 0; i < 5; i++)
{
int dustType = 132;
int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X, projectile.velocity.Y, 0, default, 0.5f);
Main.dust[dust].noGravity = true;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

@@ -0,0 +1,77 @@
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ShockGrenadeExplosion : ModProjectile
{
private const float radius = 100f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Shock Grenade Explosion");
}
public override void SetDefaults()
{
projectile.width = 320;
projectile.height = 320;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.timeLeft = 10;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -1;
projectile.Calamity().rogue = true;
}
public override void AI()
{
if (projectile.timeLeft >= 8)
{
for (int i = 0; i < 50; i++)
{
int dustType = 132;
if (Main.rand.NextBool())
{
dustType = 264;
}
Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1));
dustVelocity.Normalize();
dustVelocity *= 8;
int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, dustVelocity.X, dustVelocity.Y, 0, default, 0.75f);
Main.dust[dust].noGravity = true;
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Electrified, 300);
}
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: 1.1 KiB

+133
View File
@@ -0,0 +1,133 @@
using CalamityMod.Buffs.StatDebuffs;
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.Rogue
{
public class ShockGrenadeProjectile : ModProjectile
{
public static int spriteWidth = 14;
public static int spriteHeight = 30;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Shock Grenade");
}
public override void SetDefaults()
{
projectile.width = 10;
projectile.height = 10;
projectile.friendly = true;
projectile.penetrate = 1;
projectile.timeLeft = 180;
projectile.Calamity().rogue = true;
}
public override void AI()
{
projectile.velocity.Y += 0.1f;
if (projectile.velocity.Y >= 16f)
{
projectile.velocity.Y = 16f;
}
projectile.rotation += projectile.direction * 0.2f;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height);
projectile.localAI[0] = 0;
projectile.localAI[1] = 0;
if (projectile.velocity.X != oldVelocity.X)
{
if (oldVelocity.X < 0)
{
projectile.localAI[0] = 1;
}
if (oldVelocity.X > 0)
{
projectile.localAI[0] = -1;
}
}
if (projectile.velocity.Y != oldVelocity.Y)
{
if (oldVelocity.Y < 0)
{
projectile.localAI[1] = 1;
}
if (oldVelocity.Y > 0)
{
projectile.localAI[1] = -1;
}
}
projectile.Kill();
return false;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D tex = Main.projectileTexture[projectile.type];
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
return false;
}
public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 origin = new Vector2(spriteWidth / 2, spriteHeight / 2);
spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Rogue/ShockGrenadeProjectileGlow"), projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, 1f, SpriteEffects.None, 0f);
}
public override void Kill(int timeLeft)
{
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 94, 0.75f, 0f);
int boltCount = Main.rand.Next(5, 11);
for (int i = 0; i < boltCount; i++)
{
int boltScatter = 1;
Vector2 boltVelocity = new Vector2(Main.rand.NextFloat(-boltScatter, boltScatter), Main.rand.NextFloat(-boltScatter * 2, boltScatter * 2));
if (projectile.localAI[0] != 0)
{
boltVelocity.X *= -1;
}
if (projectile.localAI[1] != 0)
{
boltVelocity.Y *= -1;
}
boltVelocity.X += projectile.localAI[0];
boltVelocity.Y += projectile.localAI[1] * 2;
boltVelocity.Normalize();
boltVelocity *= 10;
int boltType = Main.rand.Next(0, 2);
int boltDamage = projectile.damage / 2;
int boltAI = 0;
if (projectile.Calamity().stealthStrike)
{
boltAI = 1;
}
Projectile.NewProjectile(projectile.Center, boltVelocity, ModContent.ProjectileType<ShockGrenadeBolt>(), boltDamage, 0, projectile.owner, boltType, boltAI);
}
if (projectile.Calamity().stealthStrike)
{
int auraDamage = projectile.damage / 4;
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<ShockTeslaAura>(), auraDamage, 1, projectile.owner, 0, 0);
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 93, 0.5f, 0f);
}
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<ShockGrenadeExplosion>(), projectile.damage, 3, projectile.owner, 0, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

+137
View File
@@ -0,0 +1,137 @@

using CalamityMod.NPCs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ShockTeslaAura : ModProjectile
{
private const float radius = 98f;
private const int lifetime = 240;
private const int framesX = 3;
private const int framesY = 6;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Electrifying Aura");
}
public override void SetDefaults()
{
projectile.width = 218;
projectile.height = 218;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.penetrate = -1;
projectile.timeLeft = lifetime;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 20;
projectile.Calamity().rogue = true;
}
public override void AI()
{
projectile.frameCounter++;
if (projectile.frameCounter > 3)
{
projectile.localAI[0]++;
projectile.frameCounter = 0;
}
if (projectile.localAI[0] >= framesY)
{
projectile.localAI[0] = 0;
projectile.localAI[1]++;
}
if (projectile.localAI[1] >= framesX)
{
projectile.localAI[1] = 0;
}
Player player = Main.player[Main.myPlayer];
Vector2 posDiff = player.Center - projectile.Center;
if (posDiff.Length() <= radius)
{
player.statDefense += 6;
player.lifeRegen += 2;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D sprite = Main.projectileTexture[projectile.type];
Color drawColour = Color.White;
Rectangle sourceRect = new Rectangle(projectile.width * (int)projectile.localAI[1], projectile.height * (int)projectile.localAI[0], projectile.width, projectile.height);
Vector2 origin = new Vector2(projectile.width / 2, projectile.height / 2);
float opacity = 1f;
int sparkCount = 0;
int fadeTime = 20;
if (projectile.timeLeft < fadeTime)
{
opacity = projectile.timeLeft * (1f / fadeTime);
sparkCount = fadeTime - projectile.timeLeft;
}
for (int i = 0; i < sparkCount * 2; i++)
{
int dustType = 132;
if (Main.rand.NextBool())
{
dustType = 264;
}
float rangeDiff = 2f;
Vector2 dustPos = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1));
dustPos.Normalize();
dustPos *= radius + Main.rand.NextFloat(-rangeDiff, rangeDiff);
int dust = Dust.NewDust(projectile.Center + dustPos, 1, 1, dustType, 0, 0, 0, default, 0.75f);
Main.dust[dust].noGravity = true;
}
spriteBatch.Draw(sprite, projectile.Center - Main.screenPosition, sourceRect, drawColour * opacity, projectile.rotation, origin, 1f, SpriteEffects.None, 0f);
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
if (CalamityGlobalNPC.ShouldAffectNPC(target))
{
float knockbackMultiplier = knockback - target.knockBackResist;
if (knockbackMultiplier < 0)
{
knockbackMultiplier = 0;
}
Vector2 trueKnockback = target.Center - projectile.Center;
trueKnockback.Normalize();
target.velocity = trueKnockback * knockbackMultiplier;
}
target.AddBuff(BuffID.Electrified, 300);
}
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: 48 KiB