changed prismatic laser collision logic
This commit is contained in:
1 parent
1c6c2a7013
commit
0826e0243b
2 files changed
+16
-35
No files matched your search
@@ -98,7 +98,8 @@ namespace CalamityMod.Projectiles.Magic
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
// We can only collide if we are at max charge, which is when the laser is actually fired
|
||||
if (!IsAtMaxCharge) return false;
|
||||
if (!IsAtMaxCharge)
|
||||
return false;
|
||||
|
||||
Player player = Main.player[projectile.owner];
|
||||
Vector2 unit = projectile.velocity;
|
||||
@@ -146,27 +147,11 @@ namespace CalamityMod.Projectiles.Magic
|
||||
ChargeLaser(player);
|
||||
|
||||
// If laser is not charged yet, stop the AI here.
|
||||
if (Charge < MAX_CHARGE) return;
|
||||
|
||||
/*//Repeatedly drain mana once fully charged. Unaffected by modifiers.
|
||||
//commented out because I think it's a HERO's conflict
|
||||
if (!Main.expertMode)
|
||||
{
|
||||
manaDrain++;
|
||||
if (manaDrain == 15)
|
||||
{
|
||||
player.statMana -= 5;
|
||||
if (player.statMana <= 0)
|
||||
{
|
||||
player.statMana = 0;
|
||||
projectile.Kill();
|
||||
}
|
||||
manaDrain = 0;
|
||||
}
|
||||
}*/
|
||||
if (Charge < MAX_CHARGE)
|
||||
return;
|
||||
|
||||
//Play cool sound when fully charged
|
||||
if (playedSound == false)
|
||||
if (!playedSound)
|
||||
{
|
||||
Main.PlaySound(SoundID.Item68, projectile.position);
|
||||
playedSound = true;
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 6;
|
||||
projectile.height = 6;
|
||||
projectile.width = 10;
|
||||
projectile.height = 10;
|
||||
projectile.friendly = true;
|
||||
projectile.ranged = true;
|
||||
projectile.melee = true;
|
||||
@@ -136,7 +136,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
// We can only collide if we are at max charge, which is when the laser is actually fired
|
||||
if (!IsAtMaxCharge) return false;
|
||||
if (!IsAtMaxCharge)
|
||||
return false;
|
||||
|
||||
Player player = Main.player[projectile.owner];
|
||||
Vector2 unit = projectile.velocity;
|
||||
@@ -164,12 +165,13 @@ namespace CalamityMod.Projectiles.Melee
|
||||
ChargeLaser(player);
|
||||
|
||||
// If laser is not charged yet, stop the AI here.
|
||||
if (Charge < MAX_CHARGE) return;
|
||||
if (Charge < MAX_CHARGE)
|
||||
return;
|
||||
|
||||
//Play cool sound when fully charged
|
||||
if (playedSound == false)
|
||||
if (!playedSound)
|
||||
{
|
||||
Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 68);
|
||||
Main.PlaySound(SoundID.Item68, projectile.position);
|
||||
playedSound = true;
|
||||
}
|
||||
|
||||
@@ -183,15 +185,9 @@ namespace CalamityMod.Projectiles.Melee
|
||||
*/
|
||||
private void SetLaserPosition(Player player)
|
||||
{
|
||||
for (Distance = MOVE_DISTANCE; Distance <= 2200f; Distance += 5f)
|
||||
{
|
||||
var start = player.Center + projectile.velocity * Distance;
|
||||
if (!Collision.CanHit(player.Center, 1, 1, start, 1, 1))
|
||||
{
|
||||
Distance -= 5f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
float[] samplingPoints = new float[12];
|
||||
Collision.LaserScan(player.Center + projectile.velocity * MOVE_DISTANCE, projectile.velocity, projectile.width * 0.5f, 2200f, samplingPoints);
|
||||
Distance = MathHelper.Max(samplingPoints.Average() + projectile.height * 2f, 40f);
|
||||
}
|
||||
|
||||
private void ChargeLaser(Player player)
|
||||
|
||||
Reference in new issue
Block a user