Right click for Igneous + summon netcode stuff
This commit is contained in:
1 parent
461a45767c
commit
e6aa363969
10 files changed
+134
-71
No files matched your search
@@ -586,6 +586,37 @@ namespace CalamityMod.Items
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (player.HeldItem.type == ModContent.ItemType<IgneousExaltation>())
|
||||
{
|
||||
bool hasBlades = false;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
{
|
||||
hasBlades = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasBlades)
|
||||
{
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if ((Main.projectile[i].modProjectile as IgneousBlade).Firing)
|
||||
continue;
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
{
|
||||
Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4;
|
||||
Main.projectile[i].velocity = Main.projectile[i].DirectionTo(Main.MouseWorld) * 16f;
|
||||
Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation();
|
||||
Main.projectile[i].ai[0] = 180f;
|
||||
(Main.projectile[i].modProjectile as IgneousBlade).Firing = true;
|
||||
Main.projectile[i].tileCollide = true;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return base.AltFunctionUse(item, player);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
{
|
||||
DisplayName.SetDefault("Igneous Exaltation");
|
||||
Tooltip.SetDefault("Summons an orbiting blade\n" +
|
||||
"If this item is used when you have no free minion slots, all knives are launched towards the cursor");
|
||||
"Right click to launch all blades towards the cursor");
|
||||
Item.staff[item.type] = true;
|
||||
}
|
||||
|
||||
@@ -37,15 +37,25 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
}
|
||||
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.altFunctionUse != 2)
|
||||
float totalMinionSlots = 0f;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI)
|
||||
{
|
||||
totalMinionSlots += Main.projectile[i].minionSlots;
|
||||
}
|
||||
}
|
||||
if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions)
|
||||
{
|
||||
position = Main.MouseWorld;
|
||||
Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI);
|
||||
int swordCount = 0;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI)
|
||||
{
|
||||
if ((Main.projectile[i].modProjectile as IgneousBlade).Firing)
|
||||
continue;
|
||||
swordCount++;
|
||||
for (int j = 0; j < 22; j++)
|
||||
{
|
||||
@@ -61,6 +71,8 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
{
|
||||
if ((Main.projectile[i].modProjectile as IgneousBlade).Firing)
|
||||
continue;
|
||||
Main.projectile[i].ai[0] = angle;
|
||||
angle += angleVariance;
|
||||
for (int j = 0; j < 22; j++)
|
||||
@@ -71,42 +83,6 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
}
|
||||
}
|
||||
}
|
||||
float totalMinionSlots = 0f;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI)
|
||||
{
|
||||
totalMinionSlots += Main.projectile[i].minionSlots;
|
||||
}
|
||||
}
|
||||
if (totalMinionSlots >= player.maxMinions)
|
||||
{
|
||||
bool hasBlades = false;
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
{
|
||||
hasBlades = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasBlades)
|
||||
{
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<IgneousBlade>() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f)
|
||||
{
|
||||
Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4;
|
||||
Main.projectile[i].velocity = Main.projectile[i].DirectionTo(Main.MouseWorld) * 16f;
|
||||
Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation();
|
||||
Main.projectile[i].ai[0] = 180f;
|
||||
Main.projectile[i].localAI[1] = 1f;
|
||||
Main.projectile[i].tileCollide = true;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ namespace CalamityMod.Projectiles.Summon
|
||||
positionDelta = Utils.RandomVector2(Main.rand, -12f, 12f);
|
||||
|
||||
projectile.Center = potentialTarget.Center + positionDelta;
|
||||
projectile.rotation = projectile.AngleTo(potentialTarget.Center) + MathHelper.PiOver2;
|
||||
projectile.rotation += angleMax;
|
||||
projectile.rotation = projectile.AngleTo(potentialTarget.Center) + MathHelper.PiOver2 + angleMax;
|
||||
projectile.velocity = Vector2.Zero;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] % 160f > 120f)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
projectile.ai[0] = potentialTarget.whoAmI;
|
||||
Main.PlaySound(SoundID.Zombie, projectile.Center, 53); // Ethereal whisper indicating a new target has been spotted.
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CalamityMod.Buffs.Summon;
|
||||
using CalamityMod.CalPlayer;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
@@ -11,10 +12,12 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class IgneousBlade : ModProjectile
|
||||
{
|
||||
public bool Firing = false;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Igneous Blade");
|
||||
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 7;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
@@ -35,11 +38,11 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[1]);
|
||||
writer.Write(Firing);
|
||||
}
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[1] = reader.ReadSingle();
|
||||
Firing = reader.ReadBoolean();
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
@@ -73,7 +76,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
// Orbiting. 1 = Shooting
|
||||
if (projectile.localAI[1] == 0f)
|
||||
if (!Firing)
|
||||
{
|
||||
const float outwardPosition = 180f;
|
||||
projectile.Center = player.Center + projectile.ai[0].ToRotationVector2() * outwardPosition;
|
||||
@@ -85,27 +88,41 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.ai[0]--;
|
||||
if (projectile.ai[0] == 1)
|
||||
projectile.Kill();
|
||||
|
||||
if (projectile.ai[0] % 10f == 9f)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
float angle = MathHelper.TwoPi / 20f * i;
|
||||
Dust dust = Dust.NewDustPerfect(projectile.position + angle.ToRotationVector2().RotatedBy(projectile.rotation) * new Vector2(14f, 21f), DustID.Fire);
|
||||
dust.velocity = angle.ToRotationVector2().RotatedBy(projectile.rotation) * 2f;
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
if (projectile.localAI[1] == 1f)
|
||||
if (Firing)
|
||||
{
|
||||
projectile.ai[0] = 50;
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Vector2 spawnPosition = target.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.ToRadians(8f));
|
||||
Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 24f, ModContent.ProjectileType<IgneousBladeStrike>(),
|
||||
(int)(projectile.damage * 0.666), projectile.knockBack, projectile.owner);
|
||||
projectile.ai[0] = 50;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Vector2 spawnPosition = target.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.ToRadians(8f));
|
||||
Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 24f, ModContent.ProjectileType<IgneousBladeStrike>(),
|
||||
(int)(projectile.damage * 0.666), projectile.knockBack, projectile.owner);
|
||||
}
|
||||
for (int i = 0; i < Main.rand.Next(28, 41); i++)
|
||||
{
|
||||
Dust.NewDustPerfect(
|
||||
projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f),
|
||||
6,
|
||||
Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f));
|
||||
}
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
for (int i = 0; i < Main.rand.Next(28, 41); i++)
|
||||
{
|
||||
Dust.NewDustPerfect(
|
||||
projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f),
|
||||
6,
|
||||
Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f));
|
||||
}
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
public override void Kill(int timeLeft)
|
||||
@@ -117,5 +134,34 @@ namespace CalamityMod.Projectiles.Summon
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
if (Firing)
|
||||
{
|
||||
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/IgneousBlade");
|
||||
|
||||
Rectangle rectangle = new Rectangle(0, 0, texture.Width, texture.Height);
|
||||
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (projectile.spriteDirection == -1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
if (Lighting.NotRetro)
|
||||
{
|
||||
for (int i = 0; i < projectile.oldPos.Length; i++)
|
||||
{
|
||||
Vector2 drawPos = projectile.oldPos[i] + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY);
|
||||
Color color = Color.Lerp(Color.White, Color.Red, i / (float)projectile.oldPos.Length) *
|
||||
((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length);
|
||||
float scale = MathHelper.Lerp(projectile.scale * 1.35f, projectile.scale * 0.6f, i / (float)projectile.oldPos.Length);
|
||||
Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color,
|
||||
projectile.rotation,
|
||||
rectangle.Size() / 2f, scale, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,18 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < Main.rand.Next(18, 21); i++)
|
||||
if (Main.myPlayer == projectile.whoAmI)
|
||||
{
|
||||
Dust.NewDustPerfect(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f),
|
||||
(int)CalamityDusts.Plague,
|
||||
Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f));
|
||||
for (int i = 0; i < Main.rand.Next(18, 21); i++)
|
||||
{
|
||||
Dust.NewDustPerfect(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f),
|
||||
(int)CalamityDusts.Plague,
|
||||
Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f));
|
||||
}
|
||||
Main.PlaySound(SoundID.Item107, projectile.Center);
|
||||
int idx = Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType<PlaguebringerMK2>(), projectile.damage, 4f, projectile.owner);
|
||||
Main.projectile[idx].ai[1] = CalamityUtils.CountProjectiles(ModContent.ProjectileType<PlaguebringerMK2>());
|
||||
}
|
||||
Main.PlaySound(SoundID.Item107, projectile.Center);
|
||||
int idx = Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType<PlaguebringerMK2>(), projectile.damage, 4f, projectile.owner);
|
||||
Main.projectile[idx].ai[1] = CalamityUtils.CountProjectiles(ModContent.ProjectileType<PlaguebringerMK2>());
|
||||
}
|
||||
public override bool CanDamage() => false;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.velocity = velocity;
|
||||
}
|
||||
int timeNeeded = (int)MathHelper.Lerp(60f, 18f, MathHelper.Clamp(projectile.localAI[1] / 320f, 0f, 1f));
|
||||
if (projectile.ai[0] >= timeNeeded)
|
||||
if (projectile.ai[0] >= timeNeeded && Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Projectile.NewProjectile(projectile.Center,
|
||||
projectile.DirectionTo(potentialTarget.Center) * 14f,
|
||||
@@ -117,7 +117,10 @@ namespace CalamityMod.Projectiles.Summon
|
||||
Vector2 velocity = distanceToDestination.SafeNormalize(projectile.direction * Vector2.UnitX) * speed;
|
||||
projectile.velocity = (projectile.velocity * 20f + velocity) / 21f;
|
||||
if (distance > 2250f)
|
||||
{
|
||||
projectile.Center = player.Center;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,8 +140,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
projectile.frame = 0;
|
||||
}
|
||||
|
||||
Lighting.AddLight(projectile.Center - Vector2.UnitY * 21f, 0.25f, 0.865f, 0.825f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
if (projectile.Distance(potentialTarget.Center) > TeleportDistance)
|
||||
{
|
||||
projectile.Center = potentialTarget.Center + Utils.NextVector2Unit(Main.rand) * potentialTarget.Size * 1.3f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,9 +88,10 @@ namespace CalamityMod.Projectiles.Summon
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
projectile.Center = potentialTarget.Center + Utils.NextVector2Unit(Main.rand) * potentialTarget.Size * 1.3f;
|
||||
projectile.netUpdate = true;
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
float angle = MathHelper.TwoPi / 20f * i;
|
||||
float angle = MathHelper.TwoPi / 40f * i;
|
||||
float lerp = MathHelper.Lerp(0f, 1f, (float)Math.Sin(i / 8f * MathHelper.TwoPi) * 0.5f + 0.5f);
|
||||
Dust dust = Dust.NewDustPerfect(projectile.position, DustID.Fire);
|
||||
dust.velocity = Vector2.Lerp(Vector2.Zero, angle.ToRotationVector2() * 6f, lerp);
|
||||
@@ -148,6 +150,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
projectile.Center = player.Center;
|
||||
projectile.velocity = Utils.NextVector2Unit(Main.rand) * 12f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else if (projectile.Distance(player.Center) > 90f)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
projectile.ai[1]++;
|
||||
NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player);
|
||||
if (potentialTarget != null)
|
||||
if (potentialTarget != null && Main.myPlayer == projectile.whoAmI)
|
||||
{
|
||||
if (projectile.ai[1] % 35 == 34)
|
||||
{
|
||||
|
||||
@@ -124,8 +124,10 @@ namespace CalamityMod.Projectiles.Summon
|
||||
Main.projectile[i].type == ModContent.ProjectileType<SkeletalDragonChild>())
|
||||
{
|
||||
Main.projectile[i].Center = player.Center;
|
||||
Main.projectile[i].netUpdate = true;
|
||||
}
|
||||
}
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
|
||||
Reference in new issue
Block a user