Fixed Tactical Plague engine damage bugs I think

This commit is contained in:
ben-tk committed 2020-12-19 12:42:28 -05:00
1 parent 04b4deca38
commit 212cc839a2
4 files changed
+161 -19

No files matched your search

+46 -5
View File
@@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon
{
DisplayName.SetDefault("Tactical Plague Engine");
Tooltip.SetDefault("Summons a plague jet to pummel your enemies into submission\n" +
"Consumes bullets\n" +
"Requires bullets to shoot\n" +
"Sometimes shoots a missile instead of a bullet");
}
@@ -34,17 +34,58 @@ namespace CalamityMod.Items.Weapons.Summon
item.summon = true;
item.shoot = ModContent.ProjectileType<TacticalPlagueEngineSummon>();
item.shootSpeed = 16f;
item.useAmmo = AmmoID.Bullet;
}
public override bool ConsumeAmmo(Player player) => false;
public override bool CanUseItem(Player player) => player.HasAmmo(item, false);
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (player.altFunctionUse != 2)
{
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f);
}
// Undo the vanilla addition of ammo damage
damage -= GetVanillaAmmoDamage(player);
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, item.shoot, damage, knockBack, player.whoAmI, 0f, 1f);
return false;
}
private int GetVanillaAmmoDamage(Player player)
{
Item ammo = null;
int ammoBonus = 0;
bool ammoSlots = false;
for (int index = Main.maxInventory - 4; index < Main.maxInventory; ++index)
{
if (player.inventory[index].ammo == item.useAmmo && player.inventory[index].stack > 0)
{
ammo = player.inventory[index];
ammoSlots = true;
break;
}
}
if (!ammoSlots)
{
for (int index = 0; index < Main.maxInventory - 4; ++index)
{
if (player.inventory[index].ammo == item.useAmmo && player.inventory[index].stack > 0)
{
ammo = player.inventory[index];
break;
}
}
}
if (ammo != null)
{
if (ammo.damage > 0)
{
ammoBonus = (int)(ammo.damage * player.MinionDamage());
}
}
return ammoBonus;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
+4 -1
View File
@@ -74,7 +74,10 @@ namespace CalamityMod.Projectiles.Ranged
// For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla.
int regenTimeForCalc = (int)MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f);
return (int)(regenDamageRatio * regenTimeForCalc);
int bloodFireBonus = (int)(regenDamageRatio * regenTimeForCalc);
// Main.NewText("Bloodfire Regen Bonus: " + bloodFireBonus, Color.Red);
return bloodFireBonus;
}
public override void Kill(int timeLeft)
@@ -1,7 +1,7 @@
using CalamityMod.Buffs.Summon;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Summon;
using Microsoft.Xna.Framework;
using System;
using Terraria;
@@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon
Dust dust = Dust.NewDustPerfect(projectile.Center + velocity * 2f, (int)CalamityDusts.Plague, velocity);
dust.noGravity = true;
}
FalseGun = ItemLoader.GetItem(ModContent.ItemType<P90>()).item;
FalseGun = GetItem();
projectile.localAI[0] = 1f;
}
if (projectile.frameCounter++ > 6f)
@@ -82,9 +82,19 @@ namespace CalamityMod.Projectiles.Summon
projectile.timeLeft = 2;
}
}
// Try and find a gun every 2.5 seconds if for some reason there is none
if (FalseGun is null)
{
if (player.miscCounter % 150 == 0)
{
FalseGun = GetItem();
}
}
NPC potentialTarget = projectile.Center.MinionHoming(1560f, player);
if (potentialTarget is null || !player.HasAmmo(FalseGun, false))
if (potentialTarget is null || FalseGun is null || !player.HasAmmo(FalseGun, false))
{
float acceleration = 0.1f;
Vector2 distanceVector = player.Center - projectile.Center;
@@ -145,23 +155,24 @@ namespace CalamityMod.Projectiles.Summon
if (projectile.ai[0]++ % 75f == 24f)
{
int damage = projectile.damage;
int shoot = ProjectileID.Bullet;
float shootSpeed = 0f;
bool canShoot = true;
int dmg = projectile.damage;
float kBack = projectile.knockBack * 0.5f;
player.PickAmmoSummon(FalseGun, ref shoot, ref shootSpeed, ref canShoot, ref dmg, ref kBack);
if (projectile.ai[1]++ % 20f == 0f)
{
int idx = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 18f, ModContent.ProjectileType<MK2RocketHoming>(),
(int)(damage * 1.5), 5f, projectile.owner);
(int)(dmg * 1.5), kBack * 5f, projectile.owner);
if (idx.WithinBounds(Main.maxProjectiles))
Main.projectile[idx].Calamity().forceMinion = true;
}
else
{
int shoot = 0;
float shootSpeed = 0f;
bool canShoot = true;
float knockBack = projectile.knockBack * 0.5f;
player.PickAmmo(FalseGun, ref shoot, ref shootSpeed, ref canShoot, ref damage, ref knockBack);
int idx = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * shootSpeed, shoot,
damage, knockBack, projectile.owner);
int idx = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * shootSpeed, shoot, dmg, kBack, projectile.owner);
// There's airway for a small bug in here, but the potential alterative (that has indeed been appearing), where
// the projectile simply cannot exist, is far worse than this. If you have another solution, let me know.
if (idx.WithinBounds(Main.maxProjectiles))
@@ -172,6 +183,28 @@ namespace CalamityMod.Projectiles.Summon
}
}
private Item GetItem()
{
Item item = null;
Player player = Main.player[projectile.owner];
if (!Main.mouseItem.IsAir && Main.mouseItem.type == ModContent.ItemType<TacticalPlagueEngine>())
item = Main.mouseItem;
if (item is null)
{
for (int index = 0; index < Main.maxInventory - 4; ++index)
{
if (player.inventory[index].type == ModContent.ItemType<TacticalPlagueEngine>() && player.inventory[index].stack > 0)
{
item = player.inventory[index];
break;
}
}
}
return item;
}
public override bool CanDamage() => false;
}
}
+65
View File
@@ -754,6 +754,71 @@ namespace CalamityMod
return hitbox;
}
public static void PickAmmoSummon(this Player player, Item item, ref int shoot, ref float speed, ref bool canShoot, ref int dmg, ref float kBack, bool dontConsume = false)
{
Item ammo = null;
bool ammoSlots = false;
// Check if there is ammo in the dedicated ammo slots first
for (int index = Main.maxInventory - 4; index < Main.maxInventory; ++index)
{
if (player.inventory[index].ammo == item.useAmmo && player.inventory[index].stack > 0)
{
ammo = player.inventory[index];
canShoot = true;
ammoSlots = true;
break;
}
}
if (!ammoSlots)
{
for (int index = 0; index < Main.maxInventory - 4; ++index)
{
if (player.inventory[index].ammo == item.useAmmo && player.inventory[index].stack > 0)
{
ammo = player.inventory[index];
canShoot = true;
break;
}
}
}
if (ammo is null || !canShoot)
return;
if (ammo.shoot > 0)
shoot = ammo.shoot;
speed += ammo.shootSpeed;
kBack += ammo.knockBack;
// Main.NewText("Damage before: " + dmg, Color.Green);
int ammoBonus = 0;
if (ammo.damage > 0)
{
ammoBonus = (int)(ammo.damage * player.MinionDamage());
// Main.NewText("Ammo Bonus: " + ammoBonus, Color.Red);
}
dmg += ammoBonus;
// Main.NewText("Damage after: " + dmg, Color.Red);
bool dontConsumeAmmo = dontConsume;
if (player.ammoBox && Main.rand.NextBool(5))
dontConsumeAmmo = true;
if (player.ammoPotion && Main.rand.NextBool(5))
dontConsumeAmmo = true;
if (player.ammoCost80 && Main.rand.NextBool(5))
dontConsumeAmmo = true;
if (player.ammoCost75 && Main.rand.NextBool(4))
dontConsumeAmmo = true;
if (Main.rand.NextFloat() > player.Calamity().rangedAmmoCost)
dontConsumeAmmo = true;
if (dontConsumeAmmo || !ammo.consumable)
return;
--ammo.stack;
if (ammo.stack > 0)
return;
ammo.active = false;
ammo.TurnToAir();
}
public static void ConsumeItemViaQuickBuff(Player player, Item item, int buffType, int buffTime, bool reducedPotionSickness)
{
bool showsOver = false;