Merge branch 'master' of https://github.com/UncleDanny/CalamityMod
This commit is contained in:
commit
fe363feafe
7 files changed
+242
-11
No files matched your search
@@ -1,4 +1,6 @@
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
@@ -8,6 +10,7 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Titanium Shuriken");
|
||||
Tooltip.SetDefault("Stealth strikes act like a boomerang that spawns clones on enemy hits");
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
@@ -33,6 +36,20 @@ namespace CalamityMod.Items.Weapons.Rogue
|
||||
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()) //setting the stealth strike
|
||||
{
|
||||
int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f);
|
||||
Main.projectile[stealth].Calamity().stealthStrike = true;
|
||||
Main.projectile[stealth].usesLocalNPCImmunity = true;
|
||||
Main.projectile[stealth].aiStyle = -1;
|
||||
Main.projectile[stealth].extraUpdates = 1;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Main.rand.Next(2) == 0)
|
||||
if (Main.rand.NextBool(2))
|
||||
{
|
||||
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 5, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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 TitaniumClone : ModProjectile
|
||||
{
|
||||
private static float RotationIncrement = 0.22f;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Shuriken");
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 28;
|
||||
projectile.height = 28;
|
||||
projectile.alpha = 150;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = 1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft = 200;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.extraUpdates = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.rotation += RotationIncrement;
|
||||
projectile.ai[0] += 1f;
|
||||
if (projectile.ai[0] > 30f)
|
||||
{
|
||||
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 400f, 15f, 20f);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanDamage() => projectile.ai[0] >= 30f;
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 444 B |
@@ -1,6 +1,7 @@
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
@@ -8,9 +9,14 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class TitaniumShurikenProjectile : ModProjectile
|
||||
{
|
||||
private static float RotationIncrement = 0.22f;
|
||||
private static float ReboundTime = 26f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Shuriken");
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 6;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
@@ -23,21 +29,158 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
projectile.timeLeft = 600;
|
||||
aiType = ProjectileID.ThrowingKnife;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.localNPCHitCooldown = 20;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
{
|
||||
drawOffsetX = -11;
|
||||
drawOriginOffsetY = -10;
|
||||
drawOriginOffsetX = 0;
|
||||
|
||||
// ai[0] stores whether the knife is returning. If 0, it isn't. If 1, it is.
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if (projectile.ai[1] >= ReboundTime)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.tileCollide = false;
|
||||
float returnSpeed = 16f;
|
||||
float acceleration = 3.2f;
|
||||
Player owner = Main.player[projectile.owner];
|
||||
|
||||
// Delete the shuriken if it's excessively far away.
|
||||
Vector2 playerCenter = owner.Center;
|
||||
float xDist = playerCenter.X - projectile.Center.X;
|
||||
float yDist = playerCenter.Y - projectile.Center.Y;
|
||||
float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist));
|
||||
if (dist > 3000f)
|
||||
projectile.Kill();
|
||||
|
||||
dist = returnSpeed / dist;
|
||||
xDist *= dist;
|
||||
yDist *= dist;
|
||||
|
||||
// Home back in on the player.
|
||||
if (projectile.velocity.X < xDist)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + acceleration;
|
||||
if (projectile.velocity.X < 0f && xDist > 0f)
|
||||
projectile.velocity.X += acceleration;
|
||||
}
|
||||
else if (projectile.velocity.X > xDist)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - acceleration;
|
||||
if (projectile.velocity.X > 0f && xDist < 0f)
|
||||
projectile.velocity.X -= acceleration;
|
||||
}
|
||||
if (projectile.velocity.Y < yDist)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + acceleration;
|
||||
if (projectile.velocity.Y < 0f && yDist > 0f)
|
||||
projectile.velocity.Y += acceleration;
|
||||
}
|
||||
else if (projectile.velocity.Y > yDist)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - acceleration;
|
||||
if (projectile.velocity.Y > 0f && yDist < 0f)
|
||||
projectile.velocity.Y -= acceleration;
|
||||
}
|
||||
|
||||
// Delete the projectile if it touches its owner.
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
if (projectile.Hitbox.Intersects(owner.Hitbox))
|
||||
{
|
||||
projectile.Kill(); //boomerangs return to you so you get a refund
|
||||
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType<TitaniumShuriken>());
|
||||
}
|
||||
}
|
||||
|
||||
// Rotate the shuriken as it flies.
|
||||
projectile.rotation += RotationIncrement;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
{
|
||||
projectile.ai[0] += 0.1f;
|
||||
if (projectile.velocity.X != oldVelocity.X)
|
||||
{
|
||||
projectile.velocity.X = -oldVelocity.X;
|
||||
}
|
||||
if (projectile.velocity.Y != oldVelocity.Y)
|
||||
{
|
||||
projectile.velocity.Y = -oldVelocity.Y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 Kill(int timeLeft)
|
||||
{
|
||||
if (Main.rand.NextBool(2))
|
||||
if (Main.rand.NextBool(2) && !projectile.Calamity().stealthStrike)
|
||||
{
|
||||
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType<TitaniumShuriken>());
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike)
|
||||
{
|
||||
int projNumber = Main.rand.Next(1,3);
|
||||
for (int index2 = 0; index2 < projNumber; index2++)
|
||||
{
|
||||
float xVector = (float)Main.rand.Next(-35, 36) * 0.02f;
|
||||
float yVector = (float)Main.rand.Next(-35, 36) * 0.02f;
|
||||
xVector *= 10f;
|
||||
yVector *= 10f;
|
||||
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType<TitaniumClone>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player target, int damage, bool crit)
|
||||
{
|
||||
if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike)
|
||||
{
|
||||
int projNumber = Main.rand.Next(1,3);
|
||||
for (int index2 = 0; index2 < projNumber; index2++)
|
||||
{
|
||||
float xVector = (float)Main.rand.Next(-35, 36) * 0.02f;
|
||||
float yVector = (float)Main.rand.Next(-35, 36) * 0.02f;
|
||||
xVector *= 10f;
|
||||
yVector *= 10f;
|
||||
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType<TitaniumClone>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,12 +42,15 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num473 = projectile.Center.Y;
|
||||
float num474 = 400f;
|
||||
bool flag17 = false;
|
||||
for (int num475 = 0; num475 < Main.npc.Length; num475++)
|
||||
Player player = Main.player[projectile.owner];
|
||||
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
if (Main.npc[num475].CanBeChasedBy(projectile, false))
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
|
||||
float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
|
||||
float num476 = npc.position.X + (float)(npc.width / 2);
|
||||
float num477 = npc.position.Y + (float)(npc.height / 2);
|
||||
float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477);
|
||||
if (num478 < num474)
|
||||
{
|
||||
@@ -58,6 +61,26 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num475 = 0; num475 < Main.maxNPCs; num475++)
|
||||
{
|
||||
NPC npc = Main.npc[num475];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num476 = npc.position.X + (float)(npc.width / 2);
|
||||
float num477 = npc.position.Y + (float)(npc.height / 2);
|
||||
float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477);
|
||||
if (num478 < num474)
|
||||
{
|
||||
num474 = num478;
|
||||
num472 = num476;
|
||||
num473 = num477;
|
||||
flag17 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag17)
|
||||
{
|
||||
float num483 = 10f;
|
||||
|
||||
@@ -180,9 +180,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanDamage()
|
||||
{
|
||||
return projectile.ai[0] >= 30f;
|
||||
}
|
||||
public override bool CanDamage() => projectile.ai[0] >= 30f;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user