basic attacks

will also add sounds and visuals later
This commit is contained in:
Altixal authored and Cameron Ewell committed 2024-11-18 11:14:07 -05:00
1 parent b6225c8a10
commit d01044fa6f
4 files changed
+109 -3

No files matched your search

+66 -3
View File
@@ -1,6 +1,8 @@
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;
@@ -18,9 +20,6 @@ namespace CalamityMod.Items.Mounts
MountData.spawnDustNoGravity = true;
MountData.buff = ModContent.BuffType<ExoTankBuff>();
// Attack (lasers; rockets are determined by extra frames)
MountData.abilityCooldown = 6;
// Horizontal movement
MountData.runSpeed = 9f;
MountData.dashSpeed = 22.5f;
@@ -73,6 +72,70 @@ namespace CalamityMod.Items.Mounts
}
}
public override void UpdateEffects(Player player)
{
if (Main.myPlayer == player.whoAmI)
{
Mount tank = player.mount;
// Find the closest NPC targetable by the tank
float range = 960f; // 60 tiles
int targetNPC = -1;
foreach (NPC target in Main.ActiveNPCs)
{
if (!target.CanBeChasedBy(tank))
continue;
Vector2 targetDif = target.Center - player.Center;
// 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;
if (player.direction == -1 && MathF.Abs(targetDif.ToRotation()) < MathHelper.ToRadians(120f))
continue;
float distance = targetDif.Length();
if (distance < range && Collision.CanHitLine(player.Center, 0, 0, target.position, target.width, target.height))
{
range = distance;
targetNPC = target.whoAmI;
}
}
if (targetNPC != -1)
{
tank._aiming = true;
if (tank._frameExtraCounter == 0f)
{
// 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);
}
}
// Fires a bullet on every frame switch
Vector2 bulletPos = player.Center + Main.rand.NextVector2Circular(3f, 3f) + Vector2.UnitX * 80f * player.direction - Vector2.UnitY * 8f;
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 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;
}
}
else
tank._aiming = false;
}
}
public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity)
{
// Locked to 2 states: moving and not moving
@@ -49,6 +49,7 @@ EmpyreanMarble.DisplayName: Empyrean Marble
EmpyreanStellarDetritus.DisplayName: Empyrean Stellar Detritus
EnergyShell.DisplayName: Energy Shell
EutrophicSandBallGun.DisplayName: Eutrophic Sand
ExoTankMissile.DisplayName: Miracle Missile
FeralDoubleBobber.DisplayName: Feral Bobber
FlameLickedBarrage.DisplayName: Flame Licked Barrage
FlameLickedHellblast.DisplayName: Flame Licked Hellblast
+42
View File
@@ -0,0 +1,42 @@
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class ExoTankMissile : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 4;
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 66;
Projectile.height = 22;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.MaxUpdates = 3;
Projectile.timeLeft = 90 * Projectile.MaxUpdates;
}
public override void AI()
{
Projectile.frameCounter++;
Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type];
CalamityUtils.HomeInOnNPC(Projectile, false, 1200f, 15f, 20f);
Projectile.rotation = Projectile.velocity.ToRotation();
}
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);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB