Merge pull request #93 from UncleDanny/utilities-and-shortcuts
Refactored an enormous amount of minion AI and optimized Black Hawk and other anti-clump minions.
This commit is contained in:
87 files changed
+1020
-1914
No files matched your search
@@ -6,7 +6,6 @@ using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Melee
|
||||
{
|
||||
|
||||
@@ -2102,408 +2102,6 @@ namespace CalamityMod.Projectiles
|
||||
}
|
||||
}
|
||||
|
||||
public static void HealingProjectile(Projectile projectile, int healing, int playerToHeal, float homingVelocity, float N, bool autoHomes = true, int timeCheck = 120)
|
||||
{
|
||||
int target = playerToHeal;
|
||||
Player player = Main.player[target];
|
||||
float homingSpeed = homingVelocity;
|
||||
if (player.lifeMagnet)
|
||||
homingSpeed *= 1.5f;
|
||||
|
||||
Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y);
|
||||
float xDist = player.Center.X - projPos.X;
|
||||
float yDist = player.Center.Y - projPos.Y;
|
||||
Vector2 playerVector = new Vector2(xDist, yDist);
|
||||
float playerDist = playerVector.Length();
|
||||
if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y)
|
||||
{
|
||||
if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech)
|
||||
{
|
||||
int healAmt = healing;
|
||||
player.HealEffect(healAmt, false);
|
||||
player.statLife += healAmt;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
{
|
||||
player.statLife = player.statLifeMax2;
|
||||
}
|
||||
NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0);
|
||||
}
|
||||
projectile.Kill();
|
||||
}
|
||||
if (autoHomes)
|
||||
{
|
||||
playerDist = homingSpeed / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f);
|
||||
projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f);
|
||||
}
|
||||
else if (player.lifeMagnet && projectile.timeLeft < timeCheck)
|
||||
{
|
||||
playerDist = homingVelocity / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f);
|
||||
projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChargingMinionAI(Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging)
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
|
||||
//Anti sticky movement to prevent stacking
|
||||
float antiStickMvt = 0.05f;
|
||||
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
|
||||
{
|
||||
Projectile proj = Main.projectile[projIndex];
|
||||
bool typeCheck = proj.type == projectile.type;
|
||||
if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= antiStickMvt;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += antiStickMvt;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= antiStickMvt;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += antiStickMvt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Breather time between charges as like a reset
|
||||
bool chargeDelay = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
projectile.extraUpdates = initialUpdates + (projectile.type == ModContent.ProjectileType<CloudElementalMinion>() ? 2 : 1);
|
||||
if (projectile.ai[1] > chargeDelayTime)
|
||||
{
|
||||
projectile.ai[1] = 1f;
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.extraUpdates = initialUpdates;
|
||||
projectile.numUpdates = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
chargeDelay = true;
|
||||
}
|
||||
}
|
||||
if (chargeDelay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Find a target
|
||||
float maxDist = range;
|
||||
Vector2 targetVec = projectile.position;
|
||||
bool foundTarget = false;
|
||||
Vector2 half = new Vector2(0.5f);
|
||||
//Prioritize the targeted enemy if possible
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
//Check the size of the target to make it easier to hit fat targets like Levi
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
//Some minions will ignore tiles when choosing a target like Ice Claspers, others will not
|
||||
bool canHit = true;
|
||||
if (!tileVision)
|
||||
canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
|
||||
if (!foundTarget && targetDist < maxDist && canHit)
|
||||
{
|
||||
maxDist = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//If no npc is specifically targetted, check through the entire array
|
||||
else
|
||||
{
|
||||
for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
|
||||
{
|
||||
NPC npc = Main.npc[npcIndex];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
bool canHit = true;
|
||||
if (!tileVision)
|
||||
canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
|
||||
if (!foundTarget && targetDist < maxDist && canHit)
|
||||
{
|
||||
maxDist = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If the player is too far, return to the player. Range is increased while attacking something.
|
||||
float distBeforeForcedReturn = maxPlayerDist;
|
||||
if (foundTarget)
|
||||
{
|
||||
distBeforeForcedReturn = extraMaxPlayerDist;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
//Go to the target if you found one
|
||||
if (foundTarget && projectile.ai[0] == 0f)
|
||||
{
|
||||
//Some minions don't ignore tiles while charging like brittle stars
|
||||
projectile.tileCollide = !ignoreTilesWhenCharging;
|
||||
Vector2 targetSpot = targetVec - projectile.Center;
|
||||
float targetDist = targetSpot.Length();
|
||||
targetSpot.Normalize();
|
||||
//Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does
|
||||
if (targetDist > 200f)
|
||||
{
|
||||
float speed = goToSpeed; //8
|
||||
targetSpot *= speed;
|
||||
projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float speed = -goBackSpeed; //-4
|
||||
targetSpot *= speed;
|
||||
projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41
|
||||
}
|
||||
}
|
||||
|
||||
//Movement for idle or returning to the player
|
||||
else
|
||||
{
|
||||
//Ignore tiles so they don't get stuck everywhere like Optic Staff
|
||||
projectile.tileCollide = false;
|
||||
|
||||
bool returningToPlayer = false;
|
||||
if (!returningToPlayer)
|
||||
{
|
||||
returningToPlayer = projectile.ai[0] == 1f;
|
||||
}
|
||||
|
||||
//Player distance calculations
|
||||
Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f);
|
||||
float playerDist = playerVec.Length();
|
||||
|
||||
//If the minion is actively returning, move faster
|
||||
float playerHomeSpeed = 6f;
|
||||
if (returningToPlayer)
|
||||
{
|
||||
playerHomeSpeed = 15f;
|
||||
}
|
||||
//Move somewhat faster if the player is kinda far~ish
|
||||
if (playerDist > 200f && playerHomeSpeed < 8f)
|
||||
{
|
||||
playerHomeSpeed = 8f;
|
||||
}
|
||||
//Return to normal if close enough to the player
|
||||
if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//Teleport to the player if abnormally far
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//If more than 70 pixels away, move toward the player
|
||||
if (playerDist > 70f)
|
||||
{
|
||||
playerVec.Normalize();
|
||||
playerVec *= playerHomeSpeed;
|
||||
projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f;
|
||||
}
|
||||
//Minions never stay still
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
//Increment attack counter randomly
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
}
|
||||
//If high enough, prepare to attack
|
||||
if (projectile.ai[1] > chargeCounterMax)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
//Charge at an enemy if not on cooldown
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
projectile.ai[0] = 2f;
|
||||
Vector2 targetPos = targetVec - projectile.Center;
|
||||
targetPos.Normalize();
|
||||
projectile.velocity = targetPos * chargeSpeed; //8
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void FloatingPetAI(Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false)
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
|
||||
//anti sticking movement as a failsafe
|
||||
float SAImovement = 0.05f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
bool flag23 = Main.projPet[proj.type];
|
||||
if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAImovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float passiveMvtFloat = 0.5f;
|
||||
projectile.tileCollide = false;
|
||||
float range = 100f;
|
||||
Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y);
|
||||
float xDist = player.Center.X - projPos.X;
|
||||
float yDist = player.Center.Y - projPos.Y;
|
||||
yDist += Main.rand.NextFloat(-10, 20);
|
||||
xDist += Main.rand.NextFloat(-10, 20);
|
||||
//Light pets lead the player, normal pets trail the player
|
||||
xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction);
|
||||
yDist -= 60f;
|
||||
Vector2 playerVector = new Vector2(xDist, yDist);
|
||||
float playerDist = playerVector.Length();
|
||||
float returnSpeed = 18f;
|
||||
|
||||
//If player is close enough, resume normal
|
||||
if (playerDist < range && player.velocity.Y == 0f &&
|
||||
projectile.position.Y + projectile.height <= player.position.Y + player.height &&
|
||||
!Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
if (projectile.velocity.Y < -6f)
|
||||
{
|
||||
projectile.velocity.Y = -6f;
|
||||
}
|
||||
}
|
||||
|
||||
//Teleport to player if too far
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - projectile.width / 2;
|
||||
projectile.position.Y = player.Center.Y - projectile.height / 2;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
if (playerDist < 50f)
|
||||
{
|
||||
if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f)
|
||||
{
|
||||
projectile.velocity *= 0.99f;
|
||||
}
|
||||
passiveMvtFloat = 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerDist < 100f)
|
||||
{
|
||||
passiveMvtFloat = 0.1f;
|
||||
}
|
||||
if (playerDist > 300f)
|
||||
{
|
||||
passiveMvtFloat = 1f;
|
||||
}
|
||||
playerDist = returnSpeed / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
}
|
||||
if (projectile.velocity.X < playerVector.X)
|
||||
{
|
||||
projectile.velocity.X += passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f)
|
||||
{
|
||||
projectile.velocity.X += passiveMvtFloat;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.X > playerVector.X)
|
||||
{
|
||||
projectile.velocity.X -= passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f)
|
||||
{
|
||||
projectile.velocity.X -= passiveMvtFloat;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.Y < playerVector.Y)
|
||||
{
|
||||
projectile.velocity.Y += passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f)
|
||||
{
|
||||
projectile.velocity.Y += passiveMvtFloat * 2f;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.Y > playerVector.Y)
|
||||
{
|
||||
projectile.velocity.Y -= passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f)
|
||||
{
|
||||
projectile.velocity.Y -= passiveMvtFloat * 2f;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.X >= 0.25f)
|
||||
{
|
||||
projectile.direction = faceRight ? 1 : -1;
|
||||
}
|
||||
else if (projectile.velocity.X < -0.25f)
|
||||
{
|
||||
projectile.direction = faceRight ? -1 : 1;
|
||||
}
|
||||
//Tilting and change directions
|
||||
projectile.spriteDirection = projectile.direction;
|
||||
projectile.rotation = projectile.velocity.X * tiltFloat;
|
||||
}
|
||||
public static void ExpandHitboxBy(Projectile projectile, int width, int height)
|
||||
{
|
||||
projectile.position = projectile.Center;
|
||||
|
||||
@@ -128,19 +128,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
|
||||
|
||||
if (!target.boss)
|
||||
{
|
||||
if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 &&
|
||||
target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 &&
|
||||
target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 &&
|
||||
target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 &&
|
||||
target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 &&
|
||||
target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 &&
|
||||
target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 &&
|
||||
target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 &&
|
||||
target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 &&
|
||||
target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 &&
|
||||
target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 &&
|
||||
target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 &&
|
||||
target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57)
|
||||
if (target.Inorganic())
|
||||
{
|
||||
damage += target.lifeMax / 250;
|
||||
}
|
||||
|
||||
@@ -143,11 +143,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
|
||||
{
|
||||
if (projectile.ai[1] >= 0f)
|
||||
{
|
||||
if (target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 &&
|
||||
target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 &&
|
||||
target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 &&
|
||||
target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 &&
|
||||
target.HitSound != SoundID.NPCHit54 && target.HitSound != null)
|
||||
if (target.Organic())
|
||||
{
|
||||
target.velocity.X = 0f;
|
||||
target.velocity.Y = 0f;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
projectile.velocity.X *= 0.95f;
|
||||
projectile.velocity.Y *= 0.95f;
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, 3, (int)projectile.ai[0], 6f, 15f, false);
|
||||
projectile.HealingProjectile(3, (int)projectile.ai[0], 6f, 15f, false);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
{
|
||||
projectile.velocity.Y *= 0.98f;
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, 25, projectile.owner, 12f, 15f);
|
||||
projectile.HealingProjectile(25, projectile.owner, 12f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 200, 0), 1.5f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 74, 0f, 0f, 100, default, 1f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
projectile.frame = 0;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
projectile.localAI[0] += 1f;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f);
|
||||
float num494 = projectile.velocity.X * 0.334f;
|
||||
float num495 = -(projectile.velocity.Y * 0.334f);
|
||||
int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 56, 0f, 0f, 100, default, 0.5f);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 2f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 3f, 15f);
|
||||
int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 175, 0f, 0f, 100, default, 1.3f);
|
||||
Dust dust = Main.dust[dusty];
|
||||
dust.noGravity = true;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
{
|
||||
projectile.velocity.X *= 0.95f;
|
||||
projectile.velocity.Y *= 0.95f;
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, 10, (int)projectile.ai[0], 6f, 15f, false, 360);
|
||||
projectile.HealingProjectile(10, (int)projectile.ai[0], 6f, 15f, false, 360);
|
||||
float num498 = projectile.velocity.X * 0.2f;
|
||||
float num499 = -(projectile.velocity.Y * 0.2f);
|
||||
int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
{
|
||||
projectile.velocity.X *= 0.985f;
|
||||
projectile.velocity.Y *= 0.985f;
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, 8, projectile.owner, 12f, 15f, false);
|
||||
projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false);
|
||||
|
||||
float num498 = projectile.velocity.X * 0.2f;
|
||||
float num499 = -(projectile.velocity.Y * 0.2f);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
for (int num493 = 0; num493 < 3; num493++)
|
||||
{
|
||||
float num494 = projectile.velocity.X * 0.334f * (float)num493;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], projectile.owner, 6f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], projectile.owner, 6f, 15f);
|
||||
|
||||
for (int num468 = 0; num468 < 3; num468++)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
projectile.velocity.X *= 0.95f;
|
||||
projectile.velocity.Y *= 0.95f;
|
||||
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, 9, (int)projectile.ai[0], 8f, 15f, false, 300);
|
||||
projectile.HealingProjectile(9, (int)projectile.ai[0], 8f, 15f, false, 300);
|
||||
float num498 = projectile.velocity.X * 0.2f;
|
||||
float num499 = -(projectile.velocity.Y * 0.2f);
|
||||
int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f);
|
||||
float num494 = projectile.velocity.X * 0.334f;
|
||||
float num495 = -(projectile.velocity.Y * 0.334f);
|
||||
int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 183, 0f, 0f, 100, default, 0.7f);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f);
|
||||
float num498 = projectile.velocity.X * 0.2f;
|
||||
float num499 = -(projectile.velocity.Y * 0.2f);
|
||||
int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 58, 0f, 0f, 100, default, 2f);
|
||||
|
||||
@@ -3,7 +3,6 @@ using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.02f);
|
||||
projectile.FloatingPetAI(true, 0.02f);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
Lighting.AddLight(projectile.Center, 0.1f, 0.3f, 0.5f);
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f, true);
|
||||
projectile.FloatingPetAI(false, 0.05f, true);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f);
|
||||
projectile.FloatingPetAI(false, 0.05f);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.1f);
|
||||
projectile.FloatingPetAI(true, 0.1f);
|
||||
|
||||
//Dust
|
||||
if (Main.rand.NextBool(50))
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f);
|
||||
projectile.FloatingPetAI(false, 0.05f);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
dust += 1f;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.05f);
|
||||
projectile.FloatingPetAI(true, 0.05f);
|
||||
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f);
|
||||
projectile.FloatingPetAI(false, 0.05f);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Pets
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.1f);
|
||||
projectile.FloatingPetAI(true, 0.1f);
|
||||
//Animation
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
|
||||
@@ -4,7 +4,6 @@ using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
|
||||
@@ -51,19 +51,7 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
damageMult += 0.25;
|
||||
}
|
||||
if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 &&
|
||||
target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 &&
|
||||
target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 &&
|
||||
target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 &&
|
||||
target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 &&
|
||||
target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 &&
|
||||
target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 &&
|
||||
target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 &&
|
||||
target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 &&
|
||||
target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 &&
|
||||
target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 &&
|
||||
target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 &&
|
||||
target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57)
|
||||
if (target.Inorganic())
|
||||
{
|
||||
damageMult += 0.1;
|
||||
}
|
||||
|
||||
@@ -94,31 +94,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<ApexShark>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner &&
|
||||
flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
bool flag24 = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
projectile.rotation += projectile.velocity.X * 0.04f;
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false);
|
||||
projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false);
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
|
||||
@@ -70,32 +70,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//anti sticking movement
|
||||
float SAImovement = 0.05f;
|
||||
float width = (float) projectile.width;
|
||||
for (int indexNPC = 0; indexNPC < Main.projectile.Length; indexNPC++)
|
||||
{
|
||||
Projectile proj = Main.projectile[indexNPC];
|
||||
bool myType = proj.type == ModContent.ProjectileType<AureusBomber>();
|
||||
if (indexNPC != projectile.whoAmI && proj.active && proj.owner == projectile.owner && myType && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAImovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//get in a line
|
||||
Vector2 idlePosition = player.Center;
|
||||
|
||||
@@ -142,32 +142,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
projectile.velocity.Y = (targetPosition.Y - projectile.Center.Y + potentialTarget.spriteDirection * 75f) / 90f;
|
||||
}
|
||||
float SAImovement = 0.05f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI &&
|
||||
proj.active && proj.owner == projectile.owner &&
|
||||
proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAImovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 708 B |
@@ -1,6 +1,8 @@
|
||||
using CalamityMod.Buffs.Summon;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Projectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -9,8 +11,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class BlackHawkSummon : ModProjectile
|
||||
{
|
||||
private const float PushawayForce = 0.05f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Black Hawk");
|
||||
@@ -37,45 +37,52 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
//Set namespaces
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
CalamityGlobalProjectile modProj = projectile.Calamity();
|
||||
|
||||
//On spawn effects
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage();
|
||||
projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
||||
int num226 = 36;
|
||||
for (int num227 = 0; num227 < num226; num227++)
|
||||
//Set constants
|
||||
modProj.spawnedPlayerMinionDamageValue = player.MinionDamage();
|
||||
modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
||||
//Spawn dust
|
||||
int dustAmt = 36;
|
||||
for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++)
|
||||
{
|
||||
Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f;
|
||||
vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center;
|
||||
Vector2 vector7 = vector6 - projectile.Center;
|
||||
int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 258, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f);
|
||||
Main.dust[num228].noGravity = true;
|
||||
Main.dust[num228].velocity = vector7;
|
||||
Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f;
|
||||
direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center;
|
||||
Vector2 dustVel = direction - projectile.Center;
|
||||
int fire = Dust.NewDust(direction + dustVel, 0, 0, 258, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f);
|
||||
Main.dust[fire].noGravity = true;
|
||||
Main.dust[fire].velocity = dustVel;
|
||||
}
|
||||
projectile.localAI[0] += 1f;
|
||||
}
|
||||
if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue)
|
||||
|
||||
//Flexible minion damage update
|
||||
if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue)
|
||||
{
|
||||
int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue /
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue *
|
||||
player.MinionDamage());
|
||||
int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue /
|
||||
modProj.spawnedPlayerMinionDamageValue * player.MinionDamage());
|
||||
projectile.damage = damage2;
|
||||
}
|
||||
|
||||
//Update frames
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter >= 4)
|
||||
{
|
||||
projectile.frame++;
|
||||
projectile.frameCounter = 0;
|
||||
}
|
||||
if (projectile.frame >= 3)
|
||||
if (projectile.frame >= Main.projFrames[projectile.type])
|
||||
{
|
||||
projectile.frame = 0;
|
||||
}
|
||||
float num633 = 700f;
|
||||
float num634 = 1300f;
|
||||
float num635 = 2600f;
|
||||
float num636 = 600f;
|
||||
|
||||
//Set up buff and timeLeft
|
||||
bool flag64 = projectile.type == ModContent.ProjectileType<BlackHawkSummon>();
|
||||
player.AddBuff(ModContent.BuffType<BlackHawkBuff>(), 3600);
|
||||
if (flag64)
|
||||
@@ -89,171 +96,203 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < Main.maxProjectiles; k++)
|
||||
{
|
||||
Projectile otherProj = Main.projectile[k];
|
||||
// Short circuits to make the loop as fast as possible
|
||||
if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI)
|
||||
continue;
|
||||
|
||||
// If the other projectile is indeed a Black Hawk owned by the same player and they're too close, nudge them away.
|
||||
bool isBlackHawk = otherProj.type == projectile.type;
|
||||
float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y);
|
||||
if (isBlackHawk && taxicabDist < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < otherProj.position.X)
|
||||
projectile.velocity.X = projectile.velocity.X - PushawayForce;
|
||||
else
|
||||
projectile.velocity.X = projectile.velocity.X + PushawayForce;
|
||||
//Anti sticky movement to prevent overlapping minions
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
if (projectile.position.Y < otherProj.position.Y)
|
||||
projectile.velocity.Y = projectile.velocity.Y - PushawayForce;
|
||||
else
|
||||
projectile.velocity.Y = projectile.velocity.Y + PushawayForce;
|
||||
}
|
||||
}
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
float maxDistance = 700f;
|
||||
Vector2 targetVec = projectile.position;
|
||||
Vector2 half = new Vector2(0.5f);
|
||||
bool foundTarget = false;
|
||||
//If targeting something, prioritize that enemy
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!flag25 && num646 < num633)
|
||||
//Adding a check on the NPC's size allows it to target big things like Providence
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
//Calculate distance between target and the projectile to know if it's too far or not
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!foundTarget && targetDist < maxDistance)
|
||||
{
|
||||
vector46 = npc.Center;
|
||||
flag25 = true;
|
||||
maxDistance = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.maxNPCs; num645++)
|
||||
for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if (nPC2.CanBeChasedBy(projectile, false))
|
||||
NPC npc = Main.npc[npcIndex];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if (!flag25 && num646 < num633)
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!foundTarget && targetDist < maxDistance)
|
||||
{
|
||||
num633 = num646;
|
||||
vector46 = nPC2.Center;
|
||||
flag25 = true;
|
||||
maxDistance = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (flag25)
|
||||
|
||||
//If too far, make the minion start returning to the player.
|
||||
float separationAnxietyDist = 1300f;
|
||||
if (foundTarget)
|
||||
{
|
||||
num647 = num635;
|
||||
//Max travel distance increases if targeting something
|
||||
separationAnxietyDist = 2600f;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (flag25 && projectile.ai[0] == 0f)
|
||||
|
||||
//If a target is found, move toward it
|
||||
if (foundTarget && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
Vector2 vecToTarget = targetVec - projectile.Center;
|
||||
float targetDist = vecToTarget.Length();
|
||||
vecToTarget.Normalize();
|
||||
//If farther than 200 pixels, move toward it
|
||||
if (targetDist > 200f)
|
||||
{
|
||||
float scaleFactor2 = 18f; //12
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
float speedMult = 18f;
|
||||
vecToTarget *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
|
||||
}
|
||||
//Otherwise, back it up slowly
|
||||
else
|
||||
{
|
||||
float num649 = 9f;
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
float speedMult = -9f;
|
||||
vecToTarget *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
|
||||
}
|
||||
}
|
||||
|
||||
//If not targeting something, act passively
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
if (!flag26)
|
||||
bool returningToPlayer = false;
|
||||
if (!returningToPlayer)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
returningToPlayer = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 12f;
|
||||
if (flag26)
|
||||
//Move faster if actively returning to the player
|
||||
float speedMult = 12f;
|
||||
if (returningToPlayer)
|
||||
{
|
||||
num650 = 30f;
|
||||
speedMult = 30f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f);
|
||||
float num651 = vector48.Length();
|
||||
if (num651 > 200f && num650 < 16f)
|
||||
Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f);
|
||||
float playerDist = vecToPlayer.Length();
|
||||
//Speed up if near the player
|
||||
if (playerDist < 200f && speedMult < 16f)
|
||||
{
|
||||
num650 = 16f;
|
||||
speedMult = 16f;
|
||||
}
|
||||
if (num651 < num636 && flag26)
|
||||
//If close enough to the player, return to normal
|
||||
if (playerDist < 600f && returningToPlayer)
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 2000f)
|
||||
//If abnormally far, teleport to the player
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 70f)
|
||||
//Move toward player if more than 70 pixels away
|
||||
if (playerDist > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
vecToPlayer.Normalize();
|
||||
vecToPlayer *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f;
|
||||
}
|
||||
//Move if still
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (flag25)
|
||||
|
||||
//Update rotation
|
||||
if (foundTarget)
|
||||
{
|
||||
projectile.rotation = (vector46 - projectile.Center).ToRotation() + 3.14159274f;
|
||||
projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.rotation = projectile.velocity.ToRotation() + 3.14159274f;
|
||||
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi;
|
||||
}
|
||||
|
||||
//Increment attack cooldown
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
projectile.ai[1] += Main.rand.Next(1, 4);
|
||||
}
|
||||
//Set the minion to be ready for attack
|
||||
if (projectile.ai[1] > 90f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
|
||||
//Return if on attack cooldown, has no target, or returning to the player
|
||||
if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f)
|
||||
return;
|
||||
|
||||
//Shoot a bullet
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
float scaleFactor3 = 6f;
|
||||
int num658 = ModContent.ProjectileType<BlackHawkBullet>();
|
||||
if (flag25 && projectile.ai[1] == 0f)
|
||||
{
|
||||
Main.PlaySound(SoundID.Item20, projectile.Center);
|
||||
projectile.ai[1] += 2f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Vector2 value19 = vector46 - projectile.Center;
|
||||
value19.Normalize();
|
||||
value19 *= scaleFactor3;
|
||||
_ = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
float projSpeed = 6f;
|
||||
int projType = ModContent.ProjectileType<BlackHawkBullet>();
|
||||
Main.PlaySound(SoundID.Item20, projectile.Center);
|
||||
projectile.ai[1] += 2f;
|
||||
Vector2 velocity = targetVec - projectile.Center;
|
||||
velocity.Normalize();
|
||||
velocity *= projSpeed;
|
||||
Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack, projectile.owner);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanDamage()
|
||||
//Does no contact damage
|
||||
public override bool CanDamage() => false;
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
int frameHeight = texture.Height / Main.projFrames[projectile.type];
|
||||
int y6 = frameHeight * projectile.frame;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (projectile.spriteDirection == -1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Pretty glowmask
|
||||
public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/BlackHawkGlow");
|
||||
int frameHeight = texture.Height / Main.projFrames[projectile.type];
|
||||
int y6 = frameHeight * projectile.frame;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (projectile.spriteDirection == -1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,30 +89,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
for (int num534 = 0; num534 < Main.maxProjectiles; num534++)
|
||||
{
|
||||
if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner &&
|
||||
Main.projectile[num534].type == ModContent.ProjectileType<BloodClotMinion>() &&
|
||||
Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num534].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + 0.05f;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num534].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + 0.05f;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
float num535 = projectile.position.X;
|
||||
float num536 = projectile.position.Y;
|
||||
float num537 = 1300f;
|
||||
|
||||
@@ -102,30 +102,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
float num633 = 700f;
|
||||
float num636 = 400f; //150
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<BrimstoneElementalMinion>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (projectile.ai[0] != 1f)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
projectile.rotation += projectile.velocity.X * 0.04f;
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false);
|
||||
projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false);
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
||||
|
||||
@@ -134,32 +134,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
projectile.localAI[0] -= 1f;
|
||||
}
|
||||
int num3;
|
||||
for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1)
|
||||
{
|
||||
if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner &&
|
||||
Main.projectile[num534].type == ModContent.ProjectileType<CalamariMinion>() &&
|
||||
Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num534].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + 0.05f;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num534].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + 0.05f;
|
||||
}
|
||||
}
|
||||
num3 = num534;
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
Vector2 vector = projectile.position;
|
||||
float num10 = 3000f; //300
|
||||
bool flag = false;
|
||||
|
||||
@@ -78,30 +78,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<Calamitamini>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
bool flag24 = false;
|
||||
if (flag24)
|
||||
{
|
||||
|
||||
@@ -77,30 +77,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<Cataclymini>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
bool flag24 = false;
|
||||
if (flag24)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.frame = 0;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1100f, 2400f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true);
|
||||
projectile.ChargingMinionAI(700f, 1100f, 2400f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
|
||||
@@ -82,22 +82,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//Anti sticky movement to prevent minions from stacking
|
||||
float antiStickyFloat = 0.05f;
|
||||
for (int index = 0; index < Main.maxProjectiles; ++index)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI && proj.active && (proj.owner == projectile.owner && proj.type == projectile.type) && (double) Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
projectile.velocity.X -= antiStickyFloat;
|
||||
else
|
||||
projectile.velocity.X += antiStickyFloat;
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
projectile.velocity.Y -= antiStickyFloat;
|
||||
else
|
||||
projectile.velocity.Y += antiStickyFloat;
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//Set tile collision for only when trying to return to the player
|
||||
projectile.tileCollide = projectile.ai[0] != 1f;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.frame = 0;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true);
|
||||
projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,30 +70,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num634 = 1600f; //800
|
||||
float num635 = 2400f; //1200
|
||||
float num636 = 800f;
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<CosmicEnergySpiral>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.rotation += projectile.velocity.X * 0.1f;
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 855 B |
@@ -92,31 +92,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float colorScale = (float)projectile.alpha / 255f;
|
||||
Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 1f * colorScale, 0.1f * colorScale, 1f * colorScale);
|
||||
|
||||
float antiStickyFloat = 0.05f;
|
||||
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
|
||||
{
|
||||
Projectile proj = Main.projectile[projIndex];
|
||||
bool flag23 = proj.type == ModContent.ProjectileType<CosmicViperSummon>();
|
||||
if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= antiStickyFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += antiStickyFloat;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= antiStickyFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += antiStickyFloat;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
float detectRange = 700f;
|
||||
Vector2 targetVec = projectile.position;
|
||||
@@ -292,19 +268,31 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanDamage() => false;
|
||||
public override bool CanDamage() => false;
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
|
||||
int frameHeight = texture.Height / Main.projFrames[projectile.type];
|
||||
int y6 = frameHeight * projectile.frame;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (projectile.spriteDirection == -1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PostDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/CosmicViperGlow");
|
||||
int frameHeight = texture.Height / Main.projFrames[projectile.type];
|
||||
int y6 = frameHeight * projectile.frame;
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (projectile.spriteDirection == -1)
|
||||
spriteEffects = SpriteEffects.FlipHorizontally;
|
||||
|
||||
spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,32 +83,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
int num3;
|
||||
for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1)
|
||||
{
|
||||
if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner &&
|
||||
Main.projectile[num534].type == ModContent.ProjectileType<CosmilampMinion>() &&
|
||||
Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num534].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + 0.05f;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num534].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + 0.05f;
|
||||
}
|
||||
}
|
||||
num3 = num534;
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
float num535 = projectile.position.X;
|
||||
float num536 = projectile.position.Y;
|
||||
float num537 = 3000f;
|
||||
@@ -142,7 +117,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num542 = 0; num542 < Main.maxNPCs; num542 = num3 + 1)
|
||||
for (int num542 = 0; num542 < Main.maxNPCs; num542++)
|
||||
{
|
||||
if (Main.npc[num542].CanBeChasedBy(projectile, false))
|
||||
{
|
||||
@@ -157,7 +132,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
flag19 = true;
|
||||
}
|
||||
}
|
||||
num3 = num542;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,9 +142,9 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
num546 = 18f;
|
||||
}
|
||||
Vector2 vector42 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
|
||||
float num547 = Main.player[projectile.owner].Center.X - vector42.X;
|
||||
float num548 = Main.player[projectile.owner].Center.Y - vector42.Y - 60f;
|
||||
Vector2 vector42 = projectile.Center;
|
||||
float num547 = player.Center.X - vector42.X;
|
||||
float num548 = player.Center.Y - vector42.Y - 60f;
|
||||
float num549 = (float)Math.Sqrt((double)(num547 * num547 + num548 * num548));
|
||||
if (num549 < 400f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
@@ -240,7 +214,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
projectile.rotation = projectile.velocity.X * 0.05f;
|
||||
if ((double)Math.Abs(projectile.velocity.X) > 0.2)
|
||||
if (Math.Abs(projectile.velocity.X) > 0.2f)
|
||||
{
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
return;
|
||||
|
||||
@@ -75,32 +75,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
int num3;
|
||||
for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1)
|
||||
{
|
||||
if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner &&
|
||||
Main.projectile[num534].type == ModContent.ProjectileType<DankCreeperMinion>() &&
|
||||
Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num534].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + 0.05f;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num534].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + 0.05f;
|
||||
}
|
||||
}
|
||||
num3 = num534;
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
float num535 = projectile.position.X;
|
||||
float num536 = projectile.position.Y;
|
||||
float num537 = 1300f;
|
||||
@@ -134,7 +109,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num542 = 0; num542 < Main.maxNPCs; num542 = num3 + 1)
|
||||
for (int num542 = 0; num542 < Main.maxNPCs; num542++)
|
||||
{
|
||||
if (Main.npc[num542].CanBeChasedBy(projectile, false))
|
||||
{
|
||||
@@ -149,7 +124,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
flag19 = true;
|
||||
}
|
||||
}
|
||||
num3 = num542;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,32 +110,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.frame = (projectile.localAI[1] == 1f).ToInt() * 4;
|
||||
}
|
||||
|
||||
float acceleration = 0.1f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI &&
|
||||
proj.active && proj.owner == projectile.owner &&
|
||||
proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += acceleration;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += acceleration;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump(0.1f);
|
||||
if (projectile.Distance(player.Center) > 2700f)
|
||||
{
|
||||
projectile.Center = player.Center;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
projectile.rotation += 0.075f;
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 1600f, 1800f, 2500f, 400f, 1, 30f, 24f, -12f, 30f, 16f, true, true);
|
||||
projectile.ChargingMinionAI(1600f, 1800f, 2500f, 400f, 1, 30f, 24f, -12f, 30f, 16f, true, true);
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
|
||||
@@ -110,7 +110,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float longdistance = AttackMode != 2 ? 1300f : 1200f;
|
||||
float longestdistance = AttackMode != 2 ? 2600f : 2500f;
|
||||
float idledistance = AttackMode != 2 ? 600f : 400f;
|
||||
float SAImovement = 0.05f;
|
||||
float chasespeed1 = 30f;
|
||||
float chasespeed2 = 18f;
|
||||
float firerate = 30f;
|
||||
@@ -140,32 +139,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
if (limbs.type != ModContent.ProjectileType<EndoCooperLimbs>() || !limbs.active)
|
||||
projectile.Kill();
|
||||
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
Projectile proj = Main.projectile[num638];
|
||||
bool flag23 = proj.type == ModContent.ProjectileType<EndoCooperBody>();
|
||||
bool limbsfind = proj.type == ModContent.ProjectileType<EndoCooperBody>();
|
||||
if (num638 != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAImovement;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projectile.MinionAntiClump();
|
||||
bool flag24 = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
|
||||
@@ -95,31 +95,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//Anti-sticky movement failsafe
|
||||
float SAIMovement = 0.05f;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
Projectile proj = Main.projectile[i];
|
||||
bool typeCheck = proj.type == ModContent.ProjectileType<FungalClumpMinion>();
|
||||
if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAIMovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAIMovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAIMovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAIMovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//If summoned by Amalgam, trail poisonous seawater
|
||||
if (Math.Abs(projectile.velocity.X) > 0.1f || Math.Abs(projectile.velocity.Y) > 0.1f)
|
||||
|
||||
@@ -104,31 +104,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//Anti sticky movement to prevent overlapping minions
|
||||
float antiStickMvt = 0.05f;
|
||||
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
|
||||
{
|
||||
Projectile proj = Main.projectile[projIndex];
|
||||
bool correctMinion = proj.type == ModContent.ProjectileType<GastricBelcher>();
|
||||
if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && correctMinion && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= antiStickMvt;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += antiStickMvt;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= antiStickMvt;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += antiStickMvt;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//Find a target
|
||||
float maxDistance = 700f;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 7f, false, true);
|
||||
projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 7f, false, true);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
Lighting.AddLight(projectile.Center, 0.75f, 0.485f, 0f);
|
||||
CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.04f, true);
|
||||
projectile.FloatingPetAI(false, 0.04f, true);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
|
||||
@@ -85,22 +85,6 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//Anti sticky movement although there should only be one
|
||||
float antiStickyFloat = 0.05f;
|
||||
for (int index = 0; index < Main.maxProjectiles; ++index)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI && proj.active && (proj.owner == projectile.owner && proj.type == projectile.type) && (double)Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
projectile.velocity.X -= antiStickyFloat;
|
||||
else
|
||||
projectile.velocity.X += antiStickyFloat;
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
projectile.velocity.Y -= antiStickyFloat;
|
||||
else
|
||||
projectile.velocity.Y += antiStickyFloat;
|
||||
}
|
||||
}
|
||||
|
||||
//Set tile collision for only when trying to return to the player
|
||||
projectile.tileCollide = projectile.ai[0] != 1f;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true);
|
||||
projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true);
|
||||
|
||||
projectile.rotation = projectile.velocity.ToRotation() - 1.57f;
|
||||
}
|
||||
|
||||
@@ -22,22 +22,11 @@ namespace CalamityMod.Projectiles.Summon
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Frost Shard");
|
||||
Main.projFrames[projectile.type] = 5;
|
||||
ProjectileID.Sets.SentryShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 4)
|
||||
{
|
||||
projectile.frameCounter = 0;
|
||||
projectile.frame++;
|
||||
}
|
||||
|
||||
if (projectile.frame >= 5)
|
||||
projectile.frame = 0;
|
||||
|
||||
projectile.velocity.Y += 0.2f;
|
||||
if (projectile.localAI[0] == 0f || projectile.localAI[0] == 2f)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true);
|
||||
projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true);
|
||||
|
||||
projectile.rotation = projectile.velocity.ToRotation() + 1.57f;
|
||||
}
|
||||
|
||||
@@ -48,30 +48,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.alpha -= 50;
|
||||
float num634 = 1200f;
|
||||
float num635 = 2500f;
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicAxe>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
if (projectile.ai[1] <= 30)
|
||||
{
|
||||
projectile.ai[1]++;
|
||||
|
||||
+212
-211
@@ -7,229 +7,230 @@ using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicRifle : ModProjectile
|
||||
{
|
||||
{
|
||||
private int counter = 0;
|
||||
private bool canHome = false;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Rifle");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Rifle");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 0f;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.minion = true;
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 0f;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.minion = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicRifle>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
//Set player namespace
|
||||
Player player = Main.player[projectile.owner];
|
||||
|
||||
//Anti sticky movement to prevent overlapping minions
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//Try not to do anything at first
|
||||
if (counter <= 30)
|
||||
{
|
||||
counter++;
|
||||
canHome = true;
|
||||
}
|
||||
float homingRange = MagicHat.Range;
|
||||
float num634 = 1600f;
|
||||
float num635 = 2600f;
|
||||
float num636 = 600f;
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!flag25 && num646 < homingRange)
|
||||
{
|
||||
homingRange = num646;
|
||||
vector46 = npc.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.npc.Length; num645++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if (nPC2.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if (!flag25 && num646 < homingRange)
|
||||
{
|
||||
homingRange = num646;
|
||||
vector46 = nPC2.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (flag25)
|
||||
{
|
||||
num647 = num635;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (flag25 && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
{
|
||||
float scaleFactor2 = 18f; //12
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num649 = 9f;
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
if (!flag26)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 12f;
|
||||
if (flag26)
|
||||
{
|
||||
num650 = 30f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f);
|
||||
float num651 = vector48.Length();
|
||||
if (num651 > 200f && num650 < 16f)
|
||||
{
|
||||
num650 = 16f;
|
||||
}
|
||||
if (num651 < num636 && flag26)
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
}
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (flag25)
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = (vector46 - projectile.Center).ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135));
|
||||
}
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
}
|
||||
if (projectile.ai[1] > 90f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
float scaleFactor3 = 6f;
|
||||
int projType = ModContent.ProjectileType<MagicBullet>();
|
||||
if (flag25 && projectile.ai[1] == 0f)
|
||||
{
|
||||
if (Main.rand.NextBool(6))
|
||||
float homingRange = MagicHat.Range;
|
||||
Vector2 targetVec = projectile.position;
|
||||
Vector2 half = new Vector2(0.5f);
|
||||
bool foundTarget = false;
|
||||
//If targeting something, prioritize that enemy
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
//Adding a check on the NPC's size allows it to target big things like Providence
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
//Calculate distance between target and the projectile to know if it's too far or not
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!foundTarget && targetDist < homingRange)
|
||||
{
|
||||
Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f);
|
||||
homingRange = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Vector2 value19 = vector46 - projectile.Center;
|
||||
value19.Normalize();
|
||||
value19 *= scaleFactor3;
|
||||
Main.PlaySound(SoundID.Item40, projectile.position);
|
||||
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, projType, projectile.damage, 0f, Main.myPlayer, 0f, 0f);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
|
||||
{
|
||||
NPC npc = Main.npc[npcIndex];
|
||||
if (npc.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!foundTarget && targetDist < homingRange)
|
||||
{
|
||||
homingRange = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(148, 0, 211, projectile.alpha);
|
||||
}
|
||||
//If too far, make the minion start returning to the player.
|
||||
float separationAnxietyDist = 1600f;
|
||||
if (foundTarget)
|
||||
{
|
||||
//Max travel distance increases if targeting something
|
||||
separationAnxietyDist = 2600f;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
public override bool CanDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//If a target is found, move toward it
|
||||
if (foundTarget && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vecToTarget = targetVec - projectile.Center;
|
||||
float targetDist = vecToTarget.Length();
|
||||
vecToTarget.Normalize();
|
||||
//If farther than 200 pixels, move toward it
|
||||
if (targetDist > 200f)
|
||||
{
|
||||
float speedMult = 18f; //12
|
||||
vecToTarget *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
|
||||
}
|
||||
//Otherwise, back it up slowly
|
||||
else
|
||||
{
|
||||
float speedMult = -9f;
|
||||
vecToTarget *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//If not targeting something, act passively
|
||||
else
|
||||
{
|
||||
bool returningToPlayer = false;
|
||||
if (!returningToPlayer)
|
||||
{
|
||||
returningToPlayer = projectile.ai[0] == 1f;
|
||||
}
|
||||
//Move faster if actively returning to the player
|
||||
float speedMult = 12f;
|
||||
if (returningToPlayer)
|
||||
{
|
||||
speedMult = 30f;
|
||||
}
|
||||
Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f);
|
||||
float playerDist = vecToPlayer.Length();
|
||||
//Speed up if near the player
|
||||
if (playerDist < 200f && speedMult < 16f)
|
||||
{
|
||||
speedMult = 16f;
|
||||
}
|
||||
//If close enough to the player, return to normal
|
||||
if (playerDist < 600f && returningToPlayer)
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//If abnormally far, teleport to the player
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//Move toward player if more than 70 pixels away
|
||||
if (playerDist > 70f)
|
||||
{
|
||||
vecToPlayer.Normalize();
|
||||
vecToPlayer *= speedMult;
|
||||
projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f;
|
||||
}
|
||||
//Move if still
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
//Update rotation
|
||||
if (foundTarget)
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt();
|
||||
projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)), 0.1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135));
|
||||
}
|
||||
|
||||
//Increment attack cooldown
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += Main.rand.Next(1, 4);
|
||||
}
|
||||
//Set the minion to be ready for attack
|
||||
if (projectile.ai[1] > 90f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
//Return if on attack cooldown, has no target, or returning to the player
|
||||
if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f)
|
||||
return;
|
||||
|
||||
//Shoot a bullet
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
float projSpeed = 6f;
|
||||
int projType = ModContent.ProjectileType<MagicBullet>();
|
||||
if (Main.rand.NextBool(6))
|
||||
{
|
||||
Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f);
|
||||
}
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Vector2 velocity = targetVec - projectile.Center;
|
||||
velocity.Normalize();
|
||||
velocity *= projSpeed;
|
||||
Main.PlaySound(SoundID.Item40, projectile.position);
|
||||
Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor) => new Color(148, 0, 211, projectile.alpha);
|
||||
|
||||
public override bool CanDamage() => false;
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,31 +45,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num634 = 1600f;
|
||||
float num635 = 2200f;
|
||||
float num636 = 150f;
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicUmbrella>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner &&
|
||||
flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
if (counter <= 30)
|
||||
{
|
||||
counter++;
|
||||
|
||||
@@ -102,30 +102,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
ModContent.ProjectileType<MidnightSunLaser>(),
|
||||
projectile.damage, projectile.knockBack, projectile.owner);
|
||||
}
|
||||
float acceleration = 0.35f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += acceleration;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += acceleration;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump(0.35f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -162,30 +139,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
projectile.velocity = (projectile.velocity * 15f + projectile.DirectionTo(player.Center - new Vector2(player.direction * -80f, 160f)) * 19f) / 16f;
|
||||
|
||||
float acceleration = 0.35f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += acceleration;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= acceleration;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += acceleration;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump(0.35f);
|
||||
projectile.rotation = projectile.velocity.X * 0.03f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,16 +285,16 @@ namespace CalamityMod.Projectiles.Summon
|
||||
else
|
||||
AI(1, num535, num536, player);
|
||||
}
|
||||
if ((double)projectile.velocity.X > 0.25)
|
||||
if (projectile.velocity.X > 0.25f)
|
||||
{
|
||||
projectile.direction = -1;
|
||||
}
|
||||
else if ((double)projectile.velocity.X < -0.25)
|
||||
else if (projectile.velocity.X < -0.25f)
|
||||
{
|
||||
projectile.direction = 1;
|
||||
}
|
||||
|
||||
if ((double)Math.Abs(projectile.velocity.X) > 0.2)
|
||||
if (Math.Abs(projectile.velocity.X) > 0.2f)
|
||||
{
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
}
|
||||
|
||||
@@ -283,16 +283,16 @@ namespace CalamityMod.Projectiles.Summon
|
||||
else
|
||||
AI(1, num535, num536, player);
|
||||
}
|
||||
if ((double)projectile.velocity.X > 0.25)
|
||||
if (projectile.velocity.X > 0.25f)
|
||||
{
|
||||
projectile.direction = -1;
|
||||
}
|
||||
else if ((double)projectile.velocity.X < -0.25)
|
||||
else if (projectile.velocity.X < -0.25f)
|
||||
{
|
||||
projectile.direction = 1;
|
||||
}
|
||||
|
||||
if ((double)Math.Abs(projectile.velocity.X) > 0.2)
|
||||
if (Math.Abs(projectile.velocity.X) > 0.2f)
|
||||
{
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
}
|
||||
|
||||
@@ -72,30 +72,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<PhantomGuy>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
float num633 = 3000f;
|
||||
float num634 = 3500f;
|
||||
float num635 = 4000f;
|
||||
|
||||
@@ -92,30 +92,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<PinkButterfly>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
bool flag24 = false;
|
||||
if (flag24)
|
||||
{
|
||||
|
||||
@@ -120,47 +120,24 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
|
||||
//anti sticking movement
|
||||
float antiStickFloat = 0.05f;
|
||||
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
|
||||
{
|
||||
Projectile proj = Main.projectile[projIndex];
|
||||
bool projCheck = proj.type == ModContent.ProjectileType<PlaguePrincess>();
|
||||
if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && projCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - antiStickFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + antiStickFloat;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - antiStickFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + antiStickFloat;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
//anti-sticking also applies to the player
|
||||
float antiStickFloat = 0.05f;
|
||||
if (projectile.position.X < player.position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - antiStickFloat;
|
||||
projectile.velocity.X -= antiStickFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + antiStickFloat;
|
||||
projectile.velocity.X += antiStickFloat;
|
||||
}
|
||||
if (projectile.position.Y < player.position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - antiStickFloat;
|
||||
projectile.velocity.Y -= antiStickFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + antiStickFloat;
|
||||
projectile.velocity.Y += antiStickFloat;
|
||||
}
|
||||
|
||||
bool cancelAttack = false;
|
||||
|
||||
@@ -82,31 +82,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
if (!modPlayer.plaguebringerPatronSet)
|
||||
projectile.Kill();
|
||||
|
||||
float SAIMovement = 0.05f;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
Projectile proj = Main.projectile[i];
|
||||
bool minionTypeCheck = proj.type == ModContent.ProjectileType<PlaguebringerSummon>() || Main.projPet[proj.type];
|
||||
if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && minionTypeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAIMovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAIMovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAIMovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAIMovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
int buffType = ModContent.BuffType<Plague>();
|
||||
float range = auraRange;
|
||||
|
||||
@@ -119,32 +119,9 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num634 = 1300f;
|
||||
float num635 = 2600f;
|
||||
float num636 = 600f;
|
||||
float num637 = 0.05f;
|
||||
|
||||
//idle movement
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<PlantSummon>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
if (!enraged)
|
||||
{
|
||||
|
||||
@@ -8,281 +8,104 @@ using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class PurpleButterfly : ModProjectile
|
||||
{
|
||||
public int dust = 3;
|
||||
public class PurpleButterfly : ModProjectile
|
||||
{
|
||||
public int dust = 3;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Purple Butterfly");
|
||||
Main.projFrames[projectile.type] = 4;
|
||||
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
|
||||
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
|
||||
}
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Purple Butterfly");
|
||||
Main.projFrames[projectile.type] = 4;
|
||||
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
|
||||
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 1f;
|
||||
projectile.timeLeft = 18000;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft *= 5;
|
||||
projectile.minion = true;
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 1f;
|
||||
projectile.timeLeft = 18000;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft *= 5;
|
||||
projectile.minion = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (dust > 0)
|
||||
{
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage();
|
||||
projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
||||
int num226 = 36;
|
||||
for (int num227 = 0; num227 < num226; num227++)
|
||||
{
|
||||
Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f;
|
||||
vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center;
|
||||
Vector2 vector7 = vector6 - projectile.Center;
|
||||
int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f);
|
||||
Main.dust[num228].noGravity = true;
|
||||
}
|
||||
dust--;
|
||||
}
|
||||
if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue)
|
||||
{
|
||||
int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue /
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue *
|
||||
player.MinionDamage());
|
||||
projectile.damage = damage2;
|
||||
}
|
||||
if ((double)Math.Abs(projectile.velocity.X) > 0.2)
|
||||
{
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
}
|
||||
projectile.rotation = projectile.velocity.X * 0.02f;
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
projectile.frame++;
|
||||
projectile.frameCounter = 0;
|
||||
}
|
||||
if (projectile.frame > 3)
|
||||
{
|
||||
projectile.frame = 0;
|
||||
}
|
||||
Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f);
|
||||
float num633 = 1200f;
|
||||
float num634 = 1500f;
|
||||
float num635 = 2400f;
|
||||
float num636 = 150f;
|
||||
bool flag64 = projectile.type == ModContent.ProjectileType<PurpleButterfly>();
|
||||
player.AddBuff(ModContent.BuffType<ResurrectionButterflyBuff>(), 3600);
|
||||
if (flag64)
|
||||
{
|
||||
if (player.dead)
|
||||
{
|
||||
modPlayer.resButterfly = false;
|
||||
}
|
||||
if (modPlayer.resButterfly)
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<PurpleButterfly>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner &&
|
||||
flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool flag24 = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
projectile.extraUpdates = 1;
|
||||
if (projectile.ai[1] > 30f)
|
||||
{
|
||||
projectile.ai[1] = 1f;
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.extraUpdates = 0;
|
||||
projectile.numUpdates = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag24 = true;
|
||||
}
|
||||
}
|
||||
if (flag24)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active)
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if (!flag25 && num646 < num633)
|
||||
{
|
||||
num633 = num646;
|
||||
vector46 = npc.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.maxNPCs; num645++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if ((nPC2.CanBeChasedBy(projectile, false) || nPC2.type == NPCID.DukeFishron) && nPC2.active)
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if (!flag25 && num646 < num633)
|
||||
{
|
||||
num633 = num646;
|
||||
vector46 = nPC2.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (flag25)
|
||||
{
|
||||
num647 = num635;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (flag25 && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
{
|
||||
float scaleFactor2 = 18f;
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num649 = 9f;
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
if (!flag26)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 10f;
|
||||
if (flag26)
|
||||
{
|
||||
num650 = 24f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(40f, -40f);
|
||||
float num651 = vector48.Length();
|
||||
if (num651 > 200f && num650 < 12f)
|
||||
{
|
||||
num650 = 12f;
|
||||
}
|
||||
if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
}
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 3);
|
||||
}
|
||||
if (projectile.ai[1] > 30f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
if (projectile.ai[1] == 0f && flag25 && num633 < 300f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
projectile.ai[0] = 2f;
|
||||
Vector2 value20 = vector46 - projectile.Center;
|
||||
value20.Normalize();
|
||||
projectile.velocity = value20 * 12f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (dust > 0)
|
||||
{
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage();
|
||||
projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
||||
int num226 = 36;
|
||||
for (int num227 = 0; num227 < num226; num227++)
|
||||
{
|
||||
Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f;
|
||||
vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center;
|
||||
Vector2 vector7 = vector6 - projectile.Center;
|
||||
int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f);
|
||||
Main.dust[num228].noGravity = true;
|
||||
}
|
||||
dust--;
|
||||
}
|
||||
if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue)
|
||||
{
|
||||
int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue /
|
||||
projectile.Calamity().spawnedPlayerMinionDamageValue *
|
||||
player.MinionDamage());
|
||||
projectile.damage = damage2;
|
||||
}
|
||||
if (Math.Abs(projectile.velocity.X) > 0.2f)
|
||||
{
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
}
|
||||
projectile.rotation = projectile.velocity.X * 0.02f;
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
projectile.frame++;
|
||||
projectile.frameCounter = 0;
|
||||
}
|
||||
if (projectile.frame > 3)
|
||||
{
|
||||
projectile.frame = 0;
|
||||
}
|
||||
Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f);
|
||||
projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 30f, 18f, -9f, 30f, 12f, true, true);
|
||||
bool flag64 = projectile.type == ModContent.ProjectileType<PurpleButterfly>();
|
||||
player.AddBuff(ModContent.BuffType<ResurrectionButterflyBuff>(), 3600);
|
||||
if (flag64)
|
||||
{
|
||||
if (player.dead)
|
||||
{
|
||||
modPlayer.resButterfly = false;
|
||||
}
|
||||
if (modPlayer.resButterfly)
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Texture2D texture2D13 = Main.projectileTexture[projectile.type];
|
||||
int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
|
||||
int y6 = num214 * projectile.frame;
|
||||
Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
}
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
Texture2D texture2D13 = Main.projectileTexture[projectile.type];
|
||||
int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
|
||||
int y6 = num214 * projectile.frame;
|
||||
Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
target.immune[projectile.owner] = 6;
|
||||
}
|
||||
}
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
target.immune[projectile.owner] = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,30 +101,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num = (float)Main.rand.Next(90, 111) * 0.01f;
|
||||
num *= Main.essScale;
|
||||
Lighting.AddLight(projectile.Center, 0.7f * num, 0.6f * num, 0f * num);
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<SandElementalHealer>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > 400f)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
|
||||
@@ -93,30 +93,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float num = (float)Main.rand.Next(90, 111) * 0.01f;
|
||||
num *= Main.essScale;
|
||||
Lighting.AddLight(projectile.Center, 0.7f * num, 0.6f * num, 0f * num);
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.maxProjectiles; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<SandElementalMinion>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (projectile.ai[0] != 1f)
|
||||
|
||||
@@ -77,31 +77,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num8 = 0.1f;
|
||||
float num9 = (float)projectile.width * 2f;
|
||||
for (int j = 0; j < Main.maxProjectiles; j++)
|
||||
{
|
||||
if (j != projectile.whoAmI && Main.projectile[j].active && Main.projectile[j].owner == projectile.owner && Main.projectile[j].type == projectile.type &&
|
||||
Math.Abs(projectile.position.X - Main.projectile[j].position.X) + Math.Abs(projectile.position.Y - Main.projectile[j].position.Y) < num9)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[j].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num8;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num8;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[j].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num8;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num8;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump(0.1f);
|
||||
Vector2 vector = projectile.position;
|
||||
float num10 = 900f;
|
||||
bool flag = false;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 1000f, 2000f, 3000f, 500f, 1, 30f, 8f, -4f, 40f, 8f, true, true);
|
||||
projectile.ChargingMinionAI(1000f, 2000f, 3000f, 500f, 1, 30f, 8f, -4f, 40f, 8f, true, true);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
|
||||
@@ -168,32 +168,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
}
|
||||
}
|
||||
float SAImovement = 0.25f;
|
||||
for (int index = 0; index < Main.projectile.Length; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
if (index != projectile.whoAmI &&
|
||||
proj.active && proj.owner == projectile.owner &&
|
||||
proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X += SAImovement;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump(0.25f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.spriteDirection = -projectile.direction;
|
||||
}
|
||||
|
||||
CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true);
|
||||
projectile.ChargingMinionAI(700f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true);
|
||||
|
||||
//Give off some light
|
||||
float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f;
|
||||
|
||||
@@ -90,31 +90,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
player.MinionDamage());
|
||||
projectile.damage = damage2;
|
||||
}
|
||||
float antiStickyFloat = 0.05f;
|
||||
for (int index = 0; index < Main.maxProjectiles; index++)
|
||||
{
|
||||
Projectile proj = Main.projectile[index];
|
||||
bool flag23 = proj.type == ModContent.ProjectileType<VileFeederSummon>();
|
||||
if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < proj.position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - antiStickyFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + antiStickyFloat;
|
||||
}
|
||||
if (projectile.position.Y < proj.position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - antiStickyFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + antiStickyFloat;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 3)
|
||||
{
|
||||
|
||||
@@ -87,22 +87,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
float num6 = 0.05f;
|
||||
float width = (float) projectile.width;
|
||||
for (int index = 0; index < Main.maxProjectiles; ++index)
|
||||
{
|
||||
if (index != projectile.whoAmI && Main.projectile[index].active && (Main.projectile[index].owner == projectile.owner && Main.projectile[index].type == projectile.type) && (double) Math.Abs(projectile.position.X - Main.projectile[index].position.X) + (double) Math.Abs(projectile.position.Y - Main.projectile[index].position.Y) < (double) width)
|
||||
{
|
||||
if ((double) projectile.position.X < (double) Main.projectile[index].position.X)
|
||||
projectile.velocity.X -= num6;
|
||||
else
|
||||
projectile.velocity.X += num6;
|
||||
if ((double) projectile.position.Y < (double) Main.projectile[index].position.Y)
|
||||
projectile.velocity.Y -= num6;
|
||||
else
|
||||
projectile.velocity.Y += num6;
|
||||
}
|
||||
}
|
||||
projectile.MinionAntiClump();
|
||||
Vector2 vector2_3 = projectile.position;
|
||||
float num7 = 450f;
|
||||
bool flag = false;
|
||||
|
||||
@@ -61,19 +61,7 @@ namespace CalamityMod.Projectiles.Typeless.FiniteUse
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 &&
|
||||
target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 &&
|
||||
target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 &&
|
||||
target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 &&
|
||||
target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 &&
|
||||
target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 &&
|
||||
target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 &&
|
||||
target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 &&
|
||||
target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 &&
|
||||
target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 &&
|
||||
target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 &&
|
||||
target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 &&
|
||||
target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57)
|
||||
if (target.Inorganic())
|
||||
{
|
||||
damage += target.lifeMax / 20; //500 + 200 = 700 + (100000 / 20 = 5000) = 5700 * 2 (explosion) = 11400 = 11.4% of boss HP
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.NPCs.Providence;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
@@ -31,12 +29,7 @@ namespace CalamityMod.Projectiles.Typeless.FiniteUse
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 &&
|
||||
target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 &&
|
||||
target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 &&
|
||||
target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 &&
|
||||
target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == ModContent.NPCType<Providence>() ||
|
||||
target.type == ModContent.NPCType<Eidolist>() || target.type == ModContent.NPCType<ScornEater>())
|
||||
if (target.Organic())
|
||||
{
|
||||
damage += target.lifeMax / 25; //400 + 80 = 480 + (100000 / 25 = 4000) = 4480, if crit = 5600 = 5.6% of boss HP
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Items;
|
||||
using CalamityMod.Items.Tools.ClimateChange;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.NPCs.Providence;
|
||||
using CalamityMod.Projectiles;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using CalamityMod.Tiles;
|
||||
using CalamityMod.Tiles.Abyss;
|
||||
using CalamityMod.Tiles.Astral;
|
||||
@@ -239,6 +242,52 @@ namespace CalamityMod
|
||||
damage = 0D;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if an NPC is organic
|
||||
/// </summary>
|
||||
/// <param name="target">The NPC attacked.</param>
|
||||
/// <returns>Whether or not the NPC is organic.</returns>
|
||||
public static bool Organic(this NPC target)
|
||||
{
|
||||
if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 &&
|
||||
target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 &&
|
||||
target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 &&
|
||||
target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 &&
|
||||
target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == ModContent.NPCType<Providence>() ||
|
||||
target.type == ModContent.NPCType<ScornEater>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if an NPC is inorganic
|
||||
/// </summary>
|
||||
/// <param name="target">The NPC attacked.</param>
|
||||
/// <returns>Whether or not the NPC is inorganic.</returns>
|
||||
public static bool Inorganic(this NPC target)
|
||||
{
|
||||
if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 &&
|
||||
target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 &&
|
||||
target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 &&
|
||||
target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 &&
|
||||
target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 &&
|
||||
target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 &&
|
||||
target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 &&
|
||||
target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 &&
|
||||
target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 &&
|
||||
target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 &&
|
||||
target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 &&
|
||||
target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 &&
|
||||
target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57 && target.type != ModContent.NPCType<AngryDog>() &&
|
||||
target.type != ModContent.NPCType<Providence>() && target.type != ModContent.NPCType<ScornEater>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Item Utilities
|
||||
@@ -676,6 +725,414 @@ namespace CalamityMod
|
||||
}
|
||||
return newDamage;
|
||||
}
|
||||
|
||||
public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f)
|
||||
{
|
||||
for (int k = 0; k < Main.maxProjectiles; k++)
|
||||
{
|
||||
Projectile otherProj = Main.projectile[k];
|
||||
// Short circuits to make the loop as fast as possible
|
||||
if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI)
|
||||
continue;
|
||||
|
||||
// If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
|
||||
bool sameProjType = otherProj.type == projectile.type;
|
||||
float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y);
|
||||
if (sameProjType && taxicabDist < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < otherProj.position.X)
|
||||
projectile.velocity.X -= pushForce;
|
||||
else
|
||||
projectile.velocity.X += pushForce;
|
||||
|
||||
if (projectile.position.Y < otherProj.position.Y)
|
||||
projectile.velocity.Y -= pushForce;
|
||||
else
|
||||
projectile.velocity.Y += pushForce;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging)
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
|
||||
//Anti sticky movement to prevent stacking
|
||||
projectile.MinionAntiClump();
|
||||
|
||||
//Breather time between charges as like a reset
|
||||
bool chargeDelay = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
projectile.extraUpdates = initialUpdates + (projectile.type == ModContent.ProjectileType<CloudElementalMinion>() ? 2 : 1);
|
||||
if (projectile.ai[1] > chargeDelayTime)
|
||||
{
|
||||
projectile.ai[1] = 1f;
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.extraUpdates = initialUpdates;
|
||||
projectile.numUpdates = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
chargeDelay = true;
|
||||
}
|
||||
}
|
||||
if (chargeDelay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Find a target
|
||||
float maxDist = range;
|
||||
Vector2 targetVec = projectile.position;
|
||||
bool foundTarget = false;
|
||||
Vector2 half = new Vector2(0.5f);
|
||||
bool isButterfly = projectile.type == ModContent.ProjectileType<PurpleButterfly>();
|
||||
//Prioritize the targeted enemy if possible
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly;
|
||||
if (npc.CanBeChasedBy(projectile, false) || fishronCheck)
|
||||
{
|
||||
//Check the size of the target to make it easier to hit fat targets like Levi
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
//Some minions will ignore tiles when choosing a target like Ice Claspers, others will not
|
||||
bool canHit = true;
|
||||
if (!tileVision)
|
||||
canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
|
||||
if (!foundTarget && targetDist < maxDist && canHit)
|
||||
{
|
||||
maxDist = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//If no npc is specifically targetted, check through the entire array
|
||||
else
|
||||
{
|
||||
for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
|
||||
{
|
||||
NPC npc = Main.npc[npcIndex];
|
||||
bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly;
|
||||
if (npc.CanBeChasedBy(projectile, false) || fishronCheck)
|
||||
{
|
||||
Vector2 sizeCheck = npc.position + npc.Size * half;
|
||||
float targetDist = Vector2.Distance(npc.Center, projectile.Center);
|
||||
bool canHit = true;
|
||||
if (!tileVision)
|
||||
canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height);
|
||||
if (!foundTarget && targetDist < maxDist && canHit)
|
||||
{
|
||||
maxDist = targetDist;
|
||||
targetVec = sizeCheck;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If the player is too far, return to the player. Range is increased while attacking something.
|
||||
float distBeforeForcedReturn = maxPlayerDist;
|
||||
if (foundTarget)
|
||||
{
|
||||
distBeforeForcedReturn = extraMaxPlayerDist;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
//Go to the target if you found one
|
||||
if (foundTarget && projectile.ai[0] == 0f)
|
||||
{
|
||||
//Some minions don't ignore tiles while charging like brittle stars
|
||||
projectile.tileCollide = !ignoreTilesWhenCharging;
|
||||
Vector2 targetSpot = targetVec - projectile.Center;
|
||||
float targetDist = targetSpot.Length();
|
||||
targetSpot.Normalize();
|
||||
//Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does
|
||||
if (targetDist > 200f)
|
||||
{
|
||||
float speed = goToSpeed; //8
|
||||
targetSpot *= speed;
|
||||
projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float speed = -goBackSpeed; //-4
|
||||
targetSpot *= speed;
|
||||
projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41
|
||||
}
|
||||
}
|
||||
|
||||
//Movement for idle or returning to the player
|
||||
else
|
||||
{
|
||||
//Ignore tiles so they don't get stuck everywhere like Optic Staff
|
||||
projectile.tileCollide = false;
|
||||
|
||||
bool returningToPlayer = false;
|
||||
if (!returningToPlayer)
|
||||
{
|
||||
returningToPlayer = projectile.ai[0] == 1f;
|
||||
}
|
||||
|
||||
//Player distance calculations
|
||||
Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f);
|
||||
float playerDist = playerVec.Length();
|
||||
|
||||
//If the minion is actively returning, move faster
|
||||
float playerHomeSpeed = 6f;
|
||||
if (returningToPlayer)
|
||||
{
|
||||
playerHomeSpeed = 15f;
|
||||
}
|
||||
//Move somewhat faster if the player is kinda far~ish
|
||||
if (playerDist > 200f && playerHomeSpeed < 8f)
|
||||
{
|
||||
playerHomeSpeed = 8f;
|
||||
}
|
||||
//Return to normal if close enough to the player
|
||||
if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//Teleport to the player if abnormally far
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
//If more than 70 pixels away, move toward the player
|
||||
if (playerDist > 70f)
|
||||
{
|
||||
playerVec.Normalize();
|
||||
playerVec *= playerHomeSpeed;
|
||||
projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f;
|
||||
}
|
||||
//Minions never stay still
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
//Increment attack counter randomly
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
}
|
||||
//If high enough, prepare to attack
|
||||
if (projectile.ai[1] > chargeCounterMax)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
//Charge at an enemy if not on cooldown
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
projectile.ai[0] = 2f;
|
||||
Vector2 targetPos = targetVec - projectile.Center;
|
||||
targetPos.Normalize();
|
||||
projectile.velocity = targetPos * chargeSpeed; //8
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false)
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
|
||||
//anti sticking movement as a failsafe
|
||||
float SAImovement = 0.05f;
|
||||
for (int k = 0; k < Main.maxProjectiles; k++)
|
||||
{
|
||||
Projectile otherProj = Main.projectile[k];
|
||||
// Short circuits to make the loop as fast as possible
|
||||
if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI)
|
||||
continue;
|
||||
|
||||
// If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away.
|
||||
bool isPet = Main.projPet[otherProj.type];
|
||||
float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y);
|
||||
if (isPet && taxicabDist < projectile.width)
|
||||
{
|
||||
if (projectile.position.X < otherProj.position.X)
|
||||
projectile.velocity.X -= SAImovement;
|
||||
else
|
||||
projectile.velocity.X += SAImovement;
|
||||
|
||||
if (projectile.position.Y < otherProj.position.Y)
|
||||
projectile.velocity.Y -= SAImovement;
|
||||
else
|
||||
projectile.velocity.Y += SAImovement;
|
||||
}
|
||||
}
|
||||
|
||||
float passiveMvtFloat = 0.5f;
|
||||
projectile.tileCollide = false;
|
||||
float range = 100f;
|
||||
Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y);
|
||||
float xDist = player.Center.X - projPos.X;
|
||||
float yDist = player.Center.Y - projPos.Y;
|
||||
yDist += Main.rand.NextFloat(-10, 20);
|
||||
xDist += Main.rand.NextFloat(-10, 20);
|
||||
//Light pets lead the player, normal pets trail the player
|
||||
xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction);
|
||||
yDist -= 60f;
|
||||
Vector2 playerVector = new Vector2(xDist, yDist);
|
||||
float playerDist = playerVector.Length();
|
||||
float returnSpeed = 18f;
|
||||
|
||||
//If player is close enough, resume normal
|
||||
if (playerDist < range && player.velocity.Y == 0f &&
|
||||
projectile.position.Y + projectile.height <= player.position.Y + player.height &&
|
||||
!Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
if (projectile.velocity.Y < -6f)
|
||||
{
|
||||
projectile.velocity.Y = -6f;
|
||||
}
|
||||
}
|
||||
|
||||
//Teleport to player if too far
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - projectile.width / 2;
|
||||
projectile.position.Y = player.Center.Y - projectile.height / 2;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
if (playerDist < 50f)
|
||||
{
|
||||
if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f)
|
||||
{
|
||||
projectile.velocity *= 0.99f;
|
||||
}
|
||||
passiveMvtFloat = 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerDist < 100f)
|
||||
{
|
||||
passiveMvtFloat = 0.1f;
|
||||
}
|
||||
if (playerDist > 300f)
|
||||
{
|
||||
passiveMvtFloat = 1f;
|
||||
}
|
||||
playerDist = returnSpeed / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
}
|
||||
if (projectile.velocity.X < playerVector.X)
|
||||
{
|
||||
projectile.velocity.X += passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f)
|
||||
{
|
||||
projectile.velocity.X += passiveMvtFloat;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.X > playerVector.X)
|
||||
{
|
||||
projectile.velocity.X -= passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f)
|
||||
{
|
||||
projectile.velocity.X -= passiveMvtFloat;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.Y < playerVector.Y)
|
||||
{
|
||||
projectile.velocity.Y += passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f)
|
||||
{
|
||||
projectile.velocity.Y += passiveMvtFloat * 2f;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.Y > playerVector.Y)
|
||||
{
|
||||
projectile.velocity.Y -= passiveMvtFloat;
|
||||
if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f)
|
||||
{
|
||||
projectile.velocity.Y -= passiveMvtFloat * 2f;
|
||||
}
|
||||
}
|
||||
if (projectile.velocity.X >= 0.25f)
|
||||
{
|
||||
projectile.direction = faceRight ? 1 : -1;
|
||||
}
|
||||
else if (projectile.velocity.X < -0.25f)
|
||||
{
|
||||
projectile.direction = faceRight ? -1 : 1;
|
||||
}
|
||||
//Tilting and change directions
|
||||
projectile.spriteDirection = projectile.direction;
|
||||
projectile.rotation = projectile.velocity.X * tiltFloat;
|
||||
}
|
||||
|
||||
public static void HealingProjectile(this Projectile projectile, int healing, int playerToHeal, float homingVelocity, float N, bool autoHomes = true, int timeCheck = 120)
|
||||
{
|
||||
int target = playerToHeal;
|
||||
Player player = Main.player[target];
|
||||
float homingSpeed = homingVelocity;
|
||||
if (player.lifeMagnet)
|
||||
homingSpeed *= 1.5f;
|
||||
|
||||
Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y);
|
||||
float xDist = player.Center.X - projPos.X;
|
||||
float yDist = player.Center.Y - projPos.Y;
|
||||
Vector2 playerVector = new Vector2(xDist, yDist);
|
||||
float playerDist = playerVector.Length();
|
||||
if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y)
|
||||
{
|
||||
if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech)
|
||||
{
|
||||
int healAmt = healing;
|
||||
player.HealEffect(healAmt, false);
|
||||
player.statLife += healAmt;
|
||||
if (player.statLife > player.statLifeMax2)
|
||||
{
|
||||
player.statLife = player.statLifeMax2;
|
||||
}
|
||||
NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0);
|
||||
}
|
||||
projectile.Kill();
|
||||
}
|
||||
if (autoHomes)
|
||||
{
|
||||
playerDist = homingSpeed / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f);
|
||||
projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f);
|
||||
}
|
||||
else if (player.lifeMagnet && projectile.timeLeft < timeCheck)
|
||||
{
|
||||
playerDist = homingVelocity / playerDist;
|
||||
playerVector.X *= playerDist;
|
||||
playerVector.Y *= playerDist;
|
||||
projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f);
|
||||
projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Tile Utilities
|
||||
|
||||
Reference in new issue
Block a user