more stuff

This commit is contained in:
Altixal authored and Cameron Ewell committed 2024-11-18 11:14:07 -05:00
1 parent 5d14fbf8e4
commit d20298df14
10 files changed
+288 -39

No files matched your search

+16
View File
@@ -518,6 +518,22 @@ namespace CalamityMod.CalPlayer
DoMountDashDamage(damageHitbox, damage, knockback, NPCImmuneTime, playerImmuneTime);
}
if (Player.mount.Active && Player.mount.Type == ModContent.MountType<ExoTank>() && Math.Abs(Player.velocity.X) > Player.mount.RunSpeed)
{
Rectangle damageHitbox = Player.getRect();
if (Player.direction == 1)
damageHitbox.Offset(Player.width - 1, 0);
damageHitbox.Width = 2;
damageHitbox.Inflate(6, 12);
float damage = Player.GetTotalDamage<SummonDamageClass>().ApplyTo(ExoTank.DashDamage);
float knockback = 10f;
int NPCImmuneTime = 30;
int playerImmuneTime = 6;
DoMountDashDamage(damageHitbox, damage, knockback, NPCImmuneTime, playerImmuneTime);
}
if (Player.mount.Active && Player.mount.Type == ModContent.MountType<RimehoundMount>() && Math.Abs(Player.velocity.X) > Player.mount.RunSpeed / 2f)
{
Rectangle damageHitbox = Player.getRect();
+156 -39
View File
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using CalamityMod.Buffs.Mounts;
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
@@ -14,9 +14,33 @@ namespace CalamityMod.Items.Mounts
{
public class ExoTank : ModMount
{
public static int DashDamage = 2000;
public static int MissileDamage = 1000;
public static int MissileAttackRate = 6;
public static int MissileLauncherFrameCount = 8;
public static int MinigunDamage = 400;
public static int MinigunAttackRate = 4;
public static int MinigunFrameCount = 4;
protected class ExoTankData
{
internal int MinigunFrame;
internal int MinigunFrameCounter;
internal float MinigunRotation;
public ExoTankData()
{
MinigunFrame = 0;
MinigunFrameCounter = 0;
MinigunRotation = 0f;
}
}
public override void SetStaticDefaults()
{
MountData.spawnDust = DustID.Iron;
MountData.spawnDust = DustID.Platinum;
MountData.spawnDustNoGravity = true;
MountData.buff = ModContent.BuffType<ExoTankBuff>();
@@ -75,102 +99,195 @@ namespace CalamityMod.Items.Mounts
}
}
public override void SetMount(Player player, ref bool skipDust) => player.mount._mountSpecificData = new ExoTankData();
public override void UpdateEffects(Player player)
{
if (Main.myPlayer == player.whoAmI)
{
Mount tank = player.mount;
var data = (ExoTankData)player.mount._mountSpecificData;
ref float minigunRotation = ref data.MinigunRotation;
// Find the closest NPC targetable by the tank
float range = 960f; // 60 tiles
int targetNPC = -1;
bool canFireLasers = true;
Vector2 gunPosition = player.Center + Vector2.UnitX * 52f * player.direction - Vector2.UnitY * 10f;
foreach (NPC target in Main.ActiveNPCs)
{
if (!target.CanBeChasedBy(tank))
continue;
Vector2 targetDif = target.Center - player.Center;
Vector2 targetDif = target.Center - gunPosition;
float angle = MathF.Abs(targetDif.ToRotation());
// The tank has a sight line of 120 degrees, similar to Toy Tank
if (player.direction == 1 && MathF.Abs(targetDif.ToRotation()) > MathHelper.ToRadians(60f))
continue;
// The tank has a base sight line of 120 degrees, equal to Toy Tank
// However, the laser cannon can only pivot up to 36 degrees and any further will not fire out lasers
if (player.direction == 1)
{
if (angle > MathHelper.ToRadians(60f))
continue;
if (player.direction == -1 && MathF.Abs(targetDif.ToRotation()) < MathHelper.ToRadians(120f))
continue;
canFireLasers = angle <= MathHelper.ToRadians(18f);
}
else
{
if (angle < MathHelper.ToRadians(120f))
continue;
canFireLasers = angle >= MathHelper.ToRadians(162f);
}
float distance = targetDif.Length();
if (distance < range && Collision.CanHitLine(player.Center, 0, 0, target.position, target.width, target.height))
if (distance < range && Collision.CanHitLine(gunPosition, 0, 0, target.position, target.width, target.height))
{
range = distance;
targetNPC = target.whoAmI;
}
}
var source = new EntitySource_Mount(player, Type);
// Release 3 missiles matching the animation frames
if ((int)tank._frameExtraCounter % MissileAttackRate == 0)
{
if (tank._frameExtra > 0 && tank._frameExtra < 4)
{
for (int i = 0; i < 3; i++)
{
Vector2 rocketPos = player.Center - Vector2.UnitX * (60f - 4f * i - 6f * tank._frameExtra) * player.direction - Vector2.UnitY * (72f - 8f * i);
Vector2 rocketVel = (Vector2.UnitX * player.direction).RotatedBy(-MathHelper.PiOver4 * player.direction) * 10f;
int rocketDamage = (int)player.GetBestClassDamage().ApplyTo(MissileDamage);
float rocketKB = 1f;
Projectile.NewProjectile(source, rocketPos, rocketVel, ModContent.ProjectileType<ExoTankMissile>(), rocketDamage, rocketKB, player.whoAmI);
}
}
}
if (targetNPC != -1)
{
tank._aiming = true;
if (tank._frameExtraCounter % 5f == 0f)
if (!canFireLasers)
{
// Release 3 missiles matching the animation frames
if (tank._frameExtra > 0 && tank._frameExtra < 4)
{
for (int i = 0; i < 3; i++)
{
Vector2 rocketPos = player.Center - Vector2.UnitX * (60f - 4f * i - 6f * tank._frameExtra) * player.direction - Vector2.UnitY * (72f - 8f * i);
Vector2 rocketVel = (Vector2.UnitX * player.direction).RotatedBy(-MathHelper.PiOver4 * player.direction) * 10f;
int rocketDamage = (int)player.GetBestClassDamage().ApplyTo(800);
float rocketKB = 1f;
Projectile.NewProjectile(new EntitySource_Parent(player), rocketPos, rocketVel, ModContent.ProjectileType<ExoTankMissile>(), rocketDamage, rocketKB, player.whoAmI);
}
}
minigunRotation = 0f;
return;
}
// Fires a bullet on every frame switch
Vector2 bulletPos = player.Center + Main.rand.NextVector2Circular(3f, 3f) + Vector2.UnitX * 80f * player.direction - Vector2.UnitY * 10f;
Vector2 bulletVel = (Main.npc[targetNPC].Center - bulletPos).SafeNormalize(Vector2.UnitX * player.direction) * Main.rand.NextFloat(10f, 12f);
int bulletDamage = (int)player.GetBestClassDamage().ApplyTo(400);
float idealRotation = (Main.npc[targetNPC].Center - gunPosition).SafeNormalize(Vector2.UnitX * player.direction).ToRotation();
/*
// Cap the rotation
// EDIT: This looks jarring if you can't fire lasers and the lasers are pointless if they are shot anyway. Re-add if we wanted it to shoot something again
if (!canFireLasers)
idealRotation = (player.direction == 1 ? MathHelper.ToRadians(18f) : MathHelper.ToRadians(162f)) * MathF.Sign(idealRotation);
*/
minigunRotation = idealRotation + (player.direction == 1 ? 0f : MathHelper.Pi);
// Fires a bullet on every frame switch
if (data.MinigunFrameCounter % MinigunAttackRate == 0)
{
Vector2 bulletPos = player.Center + Vector2.UnitX * 28f * player.direction - Vector2.UnitY * 10f + (idealRotation * (player.direction == 1 ? 1.33f : 1f)).ToRotationVector2() * 38f;
Vector2 bulletVel = (Main.npc[targetNPC].Center - bulletPos).SafeNormalize(Vector2.UnitX * player.direction) * Main.rand.NextFloat(15f, 16f);
int bulletDamage = (int)player.GetBestClassDamage().ApplyTo(MinigunDamage);
float bulletKB = 1f;
Projectile laser = Projectile.NewProjectileDirect(new EntitySource_Parent(player), bulletPos, bulletVel, ModContent.ProjectileType<AtlasMunitionsLaser>(), bulletDamage, bulletKB, player.whoAmI);
if (laser.whoAmI.WithinBounds(Main.maxProjectiles))
laser.DamageType = DamageClass.Generic;
Projectile.NewProjectile(source, bulletPos, bulletVel, ModContent.ProjectileType<ExoTankLaser>(), bulletDamage, bulletKB, player.whoAmI);
Vector2 flashPos = bulletPos + bulletVel.SafeNormalize(Vector2.Zero) * 36f * (player.direction == 1 ? 1f : 1.33f);
for (int i = 0; i < 2; i++)
{
Dust dust = Dust.NewDustPerfect(flashPos, DustID.FireworksRGB);
dust.noGravity = true;
dust.noLight = true;
dust.velocity = bulletVel.RotatedByRandom(MathHelper.ToRadians(5f)) * Main.rand.NextFloat(0.5f, 1f);
dust.color = Color.Lerp(Color.OrangeRed, Color.Red, Main.rand.NextFloat(0f, 0.8f));
dust.scale = Main.rand.NextFloat(0.5f, 0.8f);
}
// Muzzle flash
// This would be attached to the gun but the frame rate is too fast for only one to exist at a time
Projectile.NewProjectile(source, flashPos, bulletVel, ModContent.ProjectileType<ExoTankMuzzleFlash>(), 0, 0f, player.whoAmI);
}
}
else
{
tank._aiming = false;
minigunRotation = 0f;
}
}
}
public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity)
{
// Locked to 2 states: moving and not moving
// Ground dust as you travel (State 1 indicates running on the ground)
if (state == 1 && Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed)
{
for (int i = 0; i < 2; i++)
{
Dust ground = Dust.NewDustDirect(mountedPlayer.BottomLeft - Vector2.UnitX * 40f, mountedPlayer.width + 80, 6, DustID.Platinum);
ground.velocity = new Vector2(velocity.X * 0.15f, Main.rand.NextFloat(-2f, 0f));
ground.noLight = true;
ground.scale = Main.rand.NextFloat(0.2f, 0.8f);
ground.fadeIn = Main.rand.NextFloat(1f, 1.5f);
ground.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer);
}
if (mountedPlayer.cMount == 0)
{
float direction = Math.Sign(velocity.X);
mountedPlayer.position += new Vector2(direction * 24f, 0f);
mountedPlayer.FloorVisuals(true);
mountedPlayer.position -= new Vector2(direction * 24f, 0f);
}
}
// Animation frames locked to 2 states: moving and not moving
if (state != 0)
state = 1;
// Advances weapon frames while attacking OR while not attacking but mid-animation
Mount tank = mountedPlayer.mount;
if (tank._aiming || tank._frameExtraCounter > 0)
if (tank._aiming || (tank._frameExtraCounter >= MissileAttackRate))
tank._frameExtraCounter++;
else if (tank._frameExtraCounter > 0f)
tank._frameExtraCounter = 0f;
if (tank._frameExtraCounter >= 40f)
if (tank._frameExtraCounter >= MissileAttackRate * MissileLauncherFrameCount)
{
tank._frameExtraCounter = 0f;
tank._frameExtra = 0;
}
tank._frameExtra = (int)tank._frameExtraCounter / 5 % 8;
tank._frameExtra = (int)tank._frameExtraCounter / MissileAttackRate;
// Minigun has a separate custom frame counter
var data = (ExoTankData)tank._mountSpecificData;
ref int minigunFrame = ref data.MinigunFrame;
ref int minigunFrameCounter = ref data.MinigunFrameCounter;
if (tank._aiming || minigunFrameCounter > 0)
minigunFrameCounter++;
if (minigunFrameCounter >= MinigunAttackRate * MinigunFrameCount)
{
minigunFrameCounter = 0;
minigunFrame = 0;
}
minigunFrame = minigunFrameCounter / MinigunAttackRate;
return true;
}
public override bool Draw(List<DrawData> playerDrawData, int drawType, Player drawPlayer, ref Texture2D texture, ref Texture2D glowTexture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, ref Color glowColor, ref float rotation, ref SpriteEffects spriteEffects, ref Vector2 drawOrigin, ref float drawScale, float shadow)
{
// Modify frames for backTextureExtra (minigun) and its glow
// Modify everything for backTextureExtra (minigun) and its glow
if (drawType == 1)
{
frame = texture.Frame(1, 4, 0, drawPlayer.mount._frameExtra % 4);
drawPosition += Vector2.UnitY * -6f * CalamityUtils.Convert01To010(drawPlayer.mount._frameExtraCounter / 39f);
var data = (ExoTankData)drawPlayer.mount._mountSpecificData;
frame = texture.Frame(1, MinigunFrameCount, 0, data.MinigunFrame);
drawPosition += new Vector2(drawPlayer.direction == 1 ? 15f : -15f, 7f);
spriteEffects = drawPlayer.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
rotation = data.MinigunRotation;
drawOrigin = new Vector2(drawPlayer.direction == 1 ? 0f : 80f, 12f);
}
// frontTexture (missile launcher) and its glow
// Frames for frontTexture (missile launcher) and its glow
if (drawType == 2)
frame = texture.Frame(1, 8, 0, drawPlayer.mount._frameExtra);
frame = texture.Frame(1, MissileLauncherFrameCount, 0, drawPlayer.mount._frameExtra);
return true;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 645 B

@@ -49,7 +49,9 @@ EmpyreanMarble.DisplayName: Empyrean Marble
EmpyreanStellarDetritus.DisplayName: Empyrean Stellar Detritus
EnergyShell.DisplayName: Energy Shell
EutrophicSandBallGun.DisplayName: Eutrophic Sand
ExoTankLaser.DisplayName: Mini Exo Pulse Laser
ExoTankMissile.DisplayName: Miracle Missile
ExoTankMuzzleFlash.DisplayName: Mini Exo Flash
FeralDoubleBobber.DisplayName: Feral Bobber
FlameLickedBarrage.DisplayName: Flame Licked Barrage
FlameLickedHellblast.DisplayName: Flame Licked Hellblast
+68
View File
@@ -0,0 +1,68 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
// Modified clone of Atlas Munitions Laser to circumvent the minion attack type tag
public class ExoTankLaser : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override string Texture => "CalamityMod/Projectiles/Summon/AtlasMunitionsLaserOverdrive";
public override void SetStaticDefaults() => Main.projFrames[Type] = 4;
public override void SetDefaults()
{
Projectile.width = Projectile.height = 18;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.MaxUpdates = 3;
Projectile.timeLeft = 240;
Projectile.Opacity = 0f;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * Projectile.Opacity * 0.5f);
Projectile.Opacity = Utils.GetLerpValue(240f, 235f, Projectile.timeLeft, true);
Projectile.rotation = Projectile.velocity.ToRotation();
Projectile.frameCounter++;
Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type];
if (Projectile.velocity.Length() < 18f)
Projectile.velocity *= 1.03f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
int dustCount = 16;
bool sideways = Main.rand.NextBool(6);
float generalAngularOffset = Main.rand.NextFloatDirection() * MathHelper.Pi / 24f;
if (sideways)
dustCount += 36;
for (int i = 0; i < dustCount; i++)
{
float offsetAngle = MathHelper.TwoPi * i / dustCount;
float unitOffsetX = MathF.Pow(MathF.Cos(offsetAngle), 3f);
float unitOffsetY = MathF.Pow(MathF.Sin(offsetAngle), 3f);
Vector2 puffDustVelocity = new Vector2(unitOffsetX, unitOffsetY) * 5f;
if (sideways)
puffDustVelocity = puffDustVelocity.RotatedBy(MathHelper.PiOver4) * 1.7f;
else
puffDustVelocity = puffDustVelocity.RotatedBy(generalAngularOffset);
Dust magic = Dust.NewDustPerfect(target.Center, 182, puffDustVelocity);
magic.scale = sideways ? 1.8f : 1f;
magic.fadeIn = 0.5f;
magic.noGravity = true;
}
}
}
}
+14
View File
@@ -1,5 +1,7 @@
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -10,6 +12,9 @@ namespace CalamityMod.Projectiles.Typeless
{
public new string LocalizationCategory => "Projectiles.Typeless";
public static Asset<Texture2D> Glow;
public override void Load() => Glow = ModContent.Request<Texture2D>(Texture + "Glow");
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 4;
@@ -38,5 +43,14 @@ namespace CalamityMod.Projectiles.Typeless
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<MiracleBlight>(), 300);
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox);
public override void PostDraw(Color lightColor)
{
if (Glow != null)
{
Rectangle frame = Glow.Value.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, frame.Size() * 0.5f, Projectile.scale, SpriteEffects.None);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,32 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class ExoTankMuzzleFlash : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override void SetStaticDefaults() => Main.projFrames[Type] = 3;
public override void SetDefaults()
{
Projectile.width = Projectile.height = 10;
Projectile.friendly = true;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter >= 3 * Main.projFrames[Type])
Projectile.Kill();
Projectile.frame = Projectile.frameCounter / 3;
Projectile.rotation = Projectile.velocity.ToRotation();
}
public override bool ShouldUpdatePosition() => false;
public override Color? GetAlpha(Color lightColor) => Color.White;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B