Merge: Fishing minigames

This commit is contained in:
Cameron Ewell authored and GitHub committed 2025-09-08 18:57:20 -04:00
commit 216ee31bba
16 files changed
+1092 -61

No files matched your search

+43 -1
View File
@@ -178,7 +178,20 @@ namespace CalamityMod.CalPlayer
public int momentumCapacitorTime = 0;
/// <summary> A multiplier on the player's movement speed applied while using Momentum Capacitor. </summary>
public float momentumCapacitorBoost = 0f;
public enum FishingMinigames
{
None,
WulfrumRod,
NavyFishingRod,
HeronRod,
SlurperPole,
VerstaltiteFishingRod,
FeralDoubleRod,
RiftReeler,
EarlyBloomRod,
TheDevourerOfCods
}
public FishingMinigames SelectedFishingMinigame = FishingMinigames.None;
public bool countsAsAnyWet => (Player.armor[0].type == ItemID.FishBowl || Player.wetCount > 0 || Player.wet || Player.honeyWet || Player.lavaWet);
public StatModifier TypelessDebuffMultiplier = new();
@@ -401,6 +414,7 @@ namespace CalamityMod.CalPlayer
public bool canFireBloodflareMageProjectile = false;
public bool canFireBloodflareRangedProjectile = false;
public int consecutiveCaughtFish = 0;
public float WeakTimeFreezeUseTimer = 0;
public bool WeakTimeFreezeInUse = false;
#endregion
@@ -2571,6 +2585,8 @@ namespace CalamityMod.CalPlayer
pinkCandle = false;
yellowCandle = false;
SelectedFishingMinigame = FishingMinigames.None;
#region Minion Reset Effects
wDroid = false;
resButterfly = false;
@@ -2829,6 +2845,8 @@ namespace CalamityMod.CalPlayer
#endregion
#region Buffs, Debuffs, Counters, and Nonsense
if (Player.HeldItem.IsAir || Player.HeldItem.fishingPole == 0)
consecutiveCaughtFish = 0;
heldGaelsLastFrame = false;
gaelSwipes = 0;
whitewaterHeal = 0;
@@ -5664,5 +5682,29 @@ namespace CalamityMod.CalPlayer
}
}
#endregion
#region Controls
// These are used to entirely disable player directional inputs while being able to read them for other features
public bool ShouldHideControls = false;
public bool pressedRight = false;
public bool pressedLeft = false;
public bool pressedUp = false;
public bool pressedDown = false;
public override void SetControls()
{
pressedRight = Player.controlRight;
pressedLeft = Player.controlLeft;
pressedUp = Player.controlUp;
pressedDown = Player.controlDown;
if (ShouldHideControls)
{
Player.controlLeft = false;
Player.controlUp = false;
Player.controlDown = false;
Player.controlRight = false;
}
ShouldHideControls = false;
}
#endregion
}
}
+21
View File
@@ -10,6 +10,7 @@ using CalamityMod.Items.Fishing.BrimstoneCragCatches;
using CalamityMod.Items.Fishing.FishingRods;
using CalamityMod.Items.Fishing.SulphurCatches;
using CalamityMod.Items.Fishing.SunkenSeaCatches;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Abyss;
using CalamityMod.Items.SummonItems;
using CalamityMod.Items.Weapons.Melee;
@@ -173,6 +174,20 @@ namespace CalamityMod.CalPlayer
return;
}
if (attempt.playerFishingConditions.PoleItemType == ModContent.ItemType<WulfrumRod>())
{
if (Main.rand.NextBool(5))
{
itemDrop = ModContent.ItemType<WulfrumMetalScrap>();
return;
}
if (Main.rand.NextBool(15))
{
itemDrop = ModContent.ItemType<EnergyCore>();
return;
}
}
// Ignore catches if it's junk
if (itemDrop == ItemID.OldShoe || itemDrop == ItemID.FishingSeaweed || itemDrop == ItemID.TinCan || itemDrop == ItemID.JojaCola)
return;
@@ -352,6 +367,10 @@ namespace CalamityMod.CalPlayer
fishingLevel = fishingLevel * VerstaltiteFishingRod.FishingPowerBiomeMult;
if (Player.ZoneSkyHeight && fishingRod.type == ModContent.ItemType<HeronRod>())
fishingLevel = fishingLevel * HeronRod.FishingPowerBiomeMult;
if (fishingRod.type == ModContent.ItemType<FeralDoubleRod>())
{
fishingLevel *= 1f + (Player.statLifeMax2 - Player.statLife) * 0.002f;
}
// Prevent the player from fishing if they have the Bloodworm
if (bait.type == ModContent.ItemType<BloodwormItem>())
@@ -415,6 +434,8 @@ namespace CalamityMod.CalPlayer
if (fishList.Contains(fish.type))
fish.stack += Main.rand.Next(1, 3 + 1);
}
if (fish.type == ModContent.ItemType<WulfrumMetalScrap>())
fish.stack = Main.rand.Next(1, 6);
}
#endregion
}
-36
View File
@@ -3963,42 +3963,6 @@ namespace CalamityMod.CalPlayer
}
}
// Navy Fishing Rod's electric aura when in-use
if (Player.ActiveItem().type == ModContent.ItemType<NavyFishingRod>() && Player.ownedProjectileCounts[ModContent.ProjectileType<NavyBobber>()] != 0)
{
const int FramesPerHit = 120;
// Constantly increment the timer every frame.
navyRodAuraTimer = (navyRodAuraTimer + 1) % FramesPerHit;
// If the timer rolls over, it's time to deal damage. Only run this code for the client which is holding the fishing rod,
if (navyRodAuraTimer == 0 && Player.whoAmI == Main.myPlayer)
{
const int BaseDamage = 10;
int damage = (int)Player.GetBestClassDamage().ApplyTo(BaseDamage);
var source = Player.GetSource_ItemUse(Player.ActiveItem());
float range = 200f;
foreach (NPC npc in Main.ActiveNPCs)
{
if (npc.friendly || npc.damage <= 0 || npc.dontTakeDamage)
continue;
if (Vector2.Distance(Player.Center, npc.Center) <= range)
Projectile.NewProjectile(source, npc.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), damage, 0f, Player.whoAmI, npc.whoAmI);
// Occasionally spawn cute sparks so it looks like an electrical aura
if (Main.rand.NextBool(10))
{
Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f);
Projectile spark = Projectile.NewProjectileDirect(source, npc.Center, velocity, ModContent.ProjectileType<GenericElectricSpark>(), damage / 2, 0f, Player.whoAmI);
spark.localNPCHitCooldown = -2;
spark.timeLeft = 30;
}
}
}
}
// Inferno potion boost
if (ataxiaBlaze && Player.inferno)
{
+21 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
@@ -25,11 +26,30 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<EarlyBloomBobber>();
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
player.accFishingLine = true;
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.EarlyBloomRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.EarlyBloomRod;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
+25 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
@@ -24,6 +25,29 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<FeralDoubleBobber>();
Item.value = CalamityGlobalItem.RarityLimeBuyPrice;
Item.rare = ItemRarityID.Lime;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.FeralDoubleRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.FeralDoubleRod;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
+25 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
@@ -28,6 +29,29 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<HeronBobber>();
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
Item.rare = ItemRarityID.Orange;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.HeronRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.HeronRod;
}
public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor)
+25 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.SunkenSea;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
@@ -24,6 +25,29 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<NavyBobber>();
Item.value = CalamityGlobalItem.RarityGreenBuyPrice;
Item.rare = ItemRarityID.Green;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.NavyFishingRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.NavyFishingRod;
}
public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor)
+27 -4
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
@@ -30,13 +31,35 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<RiftReelerBobber>();
Item.value = CalamityGlobalItem.RarityYellowBuyPrice;
Item.rare = ItemRarityID.Yellow;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.RiftReeler;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.RiftReeler;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
for (int i = 0; i < Main.rand.Next(3, 6); i++) //3 to 5 bobbers
for (int i = 0; i < 4; i++) //4 bobbers
{
Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(18f)), type, 0, 0f, player.whoAmI, ai2: Main.rand.Next(2));
Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(45f)), type, 10, 1f, player.whoAmI, ai2: Main.rand.Next(2));
}
return false;
}
@@ -47,7 +70,7 @@ namespace CalamityMod.Items.Fishing.FishingRods
if (bobber.ai[2] == 0f)
lineColor = new Color(255, 165, 0, 100);
else
lineColor = new Color(0, 206, 209, 100);
lineColor = new Color(200, 206, 209, 100);
}
public override void AddRecipes()
+25 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Projectiles.Typeless;
using CalamityMod.CalPlayer;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
@@ -27,6 +28,29 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<SlurperBobber>();
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
Item.rare = ItemRarityID.Orange;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.SlurperPole;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.SlurperPole;
}
public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor)
+43 -1
View File
@@ -1,4 +1,9 @@
using CalamityMod.Items.Materials;
using System.Collections.Generic;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Fishing.AstralCatches;
using CalamityMod.Items.Fishing.BrimstoneCragCatches;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Abyss;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Rarities;
using CalamityMod.Tiles.Furniture.CraftingStations;
@@ -12,6 +17,24 @@ namespace CalamityMod.Items.Fishing.FishingRods
{
public class TheDevourerofCods : ModItem, ILocalizedModType
{
public static List<int> FishToEat = new List<int>()
{
ItemID.Bass,
ItemID.AtlanticCod,
ItemID.Flounder,
ItemID.NeonTetra,
ItemID.RedSnapper,
ItemID.RockLobster,
ItemID.Salmon,
ItemID.Shrimp,
ItemID.Trout,
ItemID.Tuna,
ModContent.ItemType<CharredLasher>(),
ModContent.ItemType<CragBullhead>(),
ModContent.ItemType<ProcyonidPrawn>(),
ModContent.ItemType<TwinklingPollox>(),
ModContent.ItemType<PlantyMush>()
};
public new string LocalizationCategory => "Items.Fishing";
public override void SetStaticDefaults()
{
@@ -31,13 +54,32 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<DevourerofCodsBobber>();
Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice;
Item.rare = ModContent.RarityType<CosmicPurple>();
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.TheDevourerOfCods;
player.accFishingLine = true;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.TheDevourerOfCods;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
for (int i = 0; i < 10; i++)
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
@@ -28,6 +29,30 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shoot = ModContent.ProjectileType<VerstaltiteBobber>();
Item.value = CalamityGlobalItem.RarityPinkBuyPrice;
Item.rare = ItemRarityID.Pink;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
player.accFishingLine = true;
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.VerstaltiteFishingRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.VerstaltiteFishingRod;
}
public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor)
+26 -2
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Materials;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
@@ -23,12 +24,35 @@ namespace CalamityMod.Items.Fishing.FishingRods
Item.shootSpeed = 10f;
Item.shoot = ModContent.ProjectileType<WulfrumBobber>();
Item.value = CalamityGlobalItem.RarityBlueBuyPrice;
Item.accessory = true;
}
public override bool AllowPrefix(int pre)
{
if (pre == 0)
return true;
return false;
}
public override bool CanReforge()
{
return false;
}
public override void HoldItem(Player player)
{
if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None)
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.WulfrumRod;
}
public override void UpdateEquip(Player player)
{
player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.WulfrumRod;
}
public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor)
{
lineOriginOffset = new Vector2(35f, -27f);
lineColor = new Color(200, 200, 200, 100);
lineColor = Color.Lerp(Color.GreenYellow, Color.DeepSkyBlue, Main.player[bobber.owner].Calamity().consecutiveCaughtFish / 5f);
}
public override void AddRecipes()
@@ -282,6 +282,7 @@ EarlyBloomRod: {
Tooltip:
'''
Fires six lines at once. Line never snaps
Equip this as an accessory to disable fishing minigames
'The early bird catches the fish'
'''
}
@@ -291,7 +292,12 @@ FeralDoubleRod: {
Tooltip:
'''
Fires two lines at once
Just as you have tamed the jungle monster, you can now tame the fish in the sea
Gains fishing power the more life you have lost
Provides a fishing minigame
Press <right> to drain life
Draining life speeds up catches
Bobbers can hook onto enemies, dealing damage when life is drained
Equip this as an accessory to use this minigame for other rods
'''
}
@@ -300,8 +306,12 @@ HeronRod: {
Tooltip:
'''
Increases fishing power by {0}x when in space
'A silent head and beak lanced down and plucked it out by the head,
and the beak swallowed the little fish while its tail waved frantically.'
Provides a fishing minigame
Moving while fishing instead moves your bobbers
Rings appear over time above the water's surface
Touching a ring hooks an item onto the bobber
Bobbers will automatically reel in hooked items upon landing back in the water
Equip this as an accessory to use this minigame for other rods
'''
}
@@ -309,9 +319,11 @@ NavyFishingRod: {
DisplayName: Navy Fishing Rod
Tooltip:
'''
While held, slowly electrifies nearby enemies
'The sea is a city.
Just below are highways, boulevards, streets and roundabouts bustling with submarine traffic.'
Fires bobbers that inflict Static Discharge on nearby enemies
Provides a fishing minigame
The bobber will float at your height underwater, allowing underwater fishing
Move in the indicated direction while fishing to catch items
Equip this as an accessory to use this minigame for other rods
'''
}
@@ -319,10 +331,13 @@ RiftReeler: {
DisplayName: Rift Reeler
Tooltip:
'''
Fires three to five lines at once
Fires four lines at once
Can fish in lava
'The battlefield is a scene of constant chaos.
The winner will be the one who controls that chaos, both the pole and the fish.'
Provides a fishing minigame
Moving while fishing instead moves your bobbers
Rifts appear over time in liquids, containing an item
When bobbers touch a rift, they automatically reel in the item within
Equip this as an accessory to use this minigame for other rods
'''
}
@@ -331,6 +346,7 @@ SlurperPole: {
Tooltip:
'''
Can fish in lava
Equip this as an accessory to disable fishing minigames
'It is the burning lava of the soul that has a furnace within--a very volcano of grief and sorrow.'
'''
}
@@ -340,6 +356,11 @@ TheDevourerofCods: {
Tooltip:
'''
Fires ten lines at once. Line never snaps and can fish from lava
Provides a fishing minigame
Hooked items stay hooked forever
Common fish are automatically consumed while fishing
Consuming fish allows a bobber to hook a new item and feeds the user
Equip this as an accessory to use this minigame for other rods
'The devourer was once just an Eater of Shoals'
'''
}
@@ -349,13 +370,22 @@ VerstaltiteFishingRod: {
Tooltip:
'''
Increases fishing power by {0}x when in the tundra
Equip this as an accessory to disable fishing minigames
The ancient alloy's prismatic qualities are perfect for attracting fish
'''
}
WulfrumRod: {
DisplayName: Wulfrum Fishing Pole
Tooltip: "'This barely works, but it's better than nothing...'"
Tooltip:
'''
Can fish up Wulfrum Metal Scrap and Wulfrum Energy Cores
Provides a fishing minigame
Move in the indicated direction while fishing to catch items
The rod empowers the longer you go without a mistake, speeding it up
Equip this as an accessory to use this minigame for other rods
'This barely works, but it's better than nothing...'
'''
}
// Bait
+720
View File
@@ -13,6 +13,7 @@ using CalamityMod.Events;
using CalamityMod.ExtraTextures;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Ammo;
using CalamityMod.Items.Fishing.FishingRods;
using CalamityMod.Items.Armor.Daedalus;
using CalamityMod.Items.Armor.Reaver;
using CalamityMod.Items.Potions.Alcohol;
@@ -364,6 +365,8 @@ namespace CalamityMod.Projectiles
#region Pre AI
public override bool PreAI(Projectile projectile)
{
if (projectile.bobber && RunFishingMinigames(projectile))
return false;
#region Vanilla Summons AI Changes
//
@@ -2849,6 +2852,723 @@ namespace CalamityMod.Projectiles
}
#endregion
#region Fishing Minigames
// All these fields are exclusively used for fishing minigames, so I declared them in this region for organization
/// <summary>
/// Reel state of bobber
/// ai[0] in bobber AI
/// </summary>
private float isReelingIn = 0;
/// <summary>
/// How long you have to catch a fish when bitten
/// ai[1] in bobber AI
/// </summary>
private float CatchTime = 0;
/// <summary>
/// How long until a fish bites
/// LocalAI[1] in bobber AI
/// </summary>
private float TimerToCatch = 0;
/// <summary>
/// Item ID of hooked item for fishing minigames
/// </summary>
public int CaughtItemID = -1;
/// <summary>
/// What this does depends on the fishing minigame. Used to store data between updates
/// </summary>
public float PersistentFishingData = -1;
/// <summary>
/// What this does depends on the fishing minigame. Used to store data between updates
/// </summary>
public Vector2 PersistentFishingDataVector2 = Vector2.Zero;
public bool RunFishingMinigames(Projectile projectile)
{
var owner = Main.player[projectile.owner];
var cplayer = owner.Calamity();
#region Utilities
void SmallSplashAtOffset(Vector2 offset)
{
int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f) + offset, projectile.width + 12, 24, Dust.dustWater());
Main.dust[num].velocity.Y -= 4f;
Main.dust[num].velocity.X *= 2.5f;
Main.dust[num].scale = 0.8f;
Main.dust[num].alpha = 100;
Main.dust[num].noGravity = true;
}
void SmallDustAtOffset(Vector2 offset, int dustID)
{
int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f) + offset, projectile.width + 12, 24, dustID);
Main.dust[num].velocity.Y -= 4f;
Main.dust[num].velocity.X *= 2.5f;
Main.dust[num].scale = 0.8f;
Main.dust[num].alpha = 100;
Main.dust[num].noGravity = true;
}
void Splash()
{
for (int i = 0; i < 100; i++)
{
int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f), projectile.width + 12, 24, Dust.dustWater());
Main.dust[num].velocity.Y -= 4f;
Main.dust[num].velocity.X *= 2.5f;
Main.dust[num].scale = 0.8f;
Main.dust[num].alpha = 100;
Main.dust[num].noGravity = true;
}
SoundEngine.PlaySound(SoundID.SplashWeak, projectile.Center);
}
void ReelTheBobberChecks()
{
if (projectile.localAI[1] == 1)
{
if (Main.netMode != 1)
{
NPC.SpawnOnPlayer(owner.whoAmI, 370);
}
projectile.ai[0] = 2f;
}
else if (projectile.localAI[1] < 1)
{
Point point = default(Point);
point = new Point((int)projectile.position.X, (int)projectile.position.Y);
int num = (int)(0f - projectile.localAI[1]);
if (num == 618)
{
point.Y += 64;
}
if (Main.netMode == 1)
{
NetMessage.SendData(130, -1, -1, null, point.X / 16, point.Y / 16, num);
}
else
{
if (num == 682)
{
NPC.unlockedSlimeRedSpawn = true;
}
NPC.NewNPC(new EntitySource_FishedOut(owner), point.X, point.Y, num);
projectile.ai[0] = 2f;
WorldGen.CheckAchievement_RealEstateAndTownSlimes();
}
}
else if (Main.rand.NextBool(7) && !owner.accFishingLine)
{
projectile.ai[0] = 2f;
projectile.ai[1] = 0;
projectile.localAI[1] = 0;
}
else
{
projectile.ai[1] = projectile.localAI[1];
}
projectile.netUpdate = true;
}
Vector2 GetWaterLine()
{
Vector2 FoundWaterline = projectile.Center;
var tilePos = projectile.Center.ToTileCoordinates();
if (Main.tile[tilePos.X, tilePos.Y].LiquidAmount > 0)
{
for (var i = 0; i < 1000; i++)
{
if (i <= 0 || i >= Main.maxTilesY || Main.tile[tilePos.X, tilePos.Y - i].LiquidAmount > 0)
continue;
FoundWaterline.Y = (tilePos.Y - i + 1) * 16f;
FoundWaterline.Y += (1 - Main.tile[tilePos.X, tilePos.Y - i + 1].LiquidAmount / 255f) * 16f;
break;
}
}
else
{
for (var i = 0; i < 1000; i++)
{
if (i <= 0 || i >= Main.maxTilesY || Main.tile[tilePos.X, tilePos.Y + i].LiquidAmount == 0)
continue;
FoundWaterline.Y = (tilePos.Y + i) * 16f;
FoundWaterline.Y += (1 - Main.tile[tilePos.X, tilePos.Y + i].LiquidAmount / 255f) * 16f;
break;
}
}
return FoundWaterline;
}
#endregion
//Doze's notes on bobber AI
//ai[0] - Bobber state. 0: thrown/idle/bitten, 1: reeling in, 2: snapped
//ai[1] - Amount of time to reel in the bobber once a bite happens. Is negative and counts up
//When reeled in, this becomes the value of localAI[1] (ID of item/NPC)
//At 0, the bobber is just floating waiting for a bite
//localAI[1] - The timer for fish to try and bite the hook. When it exceeds 660, it resets to 0.
//If ai[1] is not 0, this is set to the item ID of the hooked item/NPC
//If hooking an NPC, this is set to the NPC ID but negative. Still need to find how this gets treated upon reeling in.
switch (owner.Calamity().SelectedFishingMinigame)
{
case CalamityPlayer.FishingMinigames.WulfrumRod:
{
foreach (var item in Main.ActiveProjectiles)
{
if (item.bobber && item.owner == projectile.owner && item.whoAmI != projectile.whoAmI)
{
item.active = false;
}
}
if (CatchTime < 0 || (isReelingIn == 1 && CaughtItemID > 0))
{
owner.Calamity().ShouldHideControls = true;
}
if (isReelingIn != projectile.ai[0])
return false;
if (CatchTime < 0)
CatchTime++;
if (projectile.wet || (projectile.lavaWet && owner.accLavaFishing) || projectile.honeyWet)
TimerToCatch++;
var speedup = Math.Min(owner.Calamity().consecutiveCaughtFish * 5, 25);
var totalTime = 60 - speedup;
if (TimerToCatch + 90 >= 160 - owner.HeldItem.fishingPole && CatchTime >= 0)
{
if (PersistentFishingData == 0)
PersistentFishingData = Main.rand.NextBool() ? 1 : -1;
var timer = TimerToCatch - 160 - owner.HeldItem.fishingPole;
SmallSplashAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0));
}
if (TimerToCatch >= 160 - owner.HeldItem.fishingPole && CatchTime >= 0)
{
PersistentFishingData = 0;
projectile.FishingCheck();
if (projectile.ai[1] < 0)
{
CatchTime = -totalTime * 4;
CaughtItemID = (int)projectile.localAI[1];
}
TimerToCatch = 0;
}
if (CatchTime < 0 && CatchTime % totalTime == 0)
{
Splash();
PersistentFishingData = Main.rand.Next(0, 4);
var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(PersistentFishingData * MathHelper.PiOver2) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 45 - speedup, 0.04f, Color.Blue, new(1, 2), shrinkSpeed: -0.2f);
GeneralParticleHandler.SpawnParticle(particle);
}
if (CatchTime < 0 && CatchTime % totalTime == -15)
{
var playerDir = -1;
if (owner.Calamity().pressedUp)
{
playerDir = 3;
}
if (owner.Calamity().pressedLeft)
{
playerDir = 2;
}
if (owner.Calamity().pressedDown)
{
playerDir = 1;
}
if (owner.Calamity().pressedRight)
{
playerDir = 0;
}
if (playerDir == PersistentFishingData)
{
}
else
{
if (playerDir >= 0)
{
var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(playerDir * MathHelper.PiOver2) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 15, 0.04f, Color.Red, new(1, 2), shrinkSpeed: -0.2f);
GeneralParticleHandler.SpawnParticle(particle);
}
else
{
var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 15, 0.06f, Color.Red, Vector2.One);
GeneralParticleHandler.SpawnParticle(particle);
}
TimerToCatch = 0;
CatchTime = 0;
CaughtItemID = -1;
PersistentFishingData = 0;
owner.Calamity().consecutiveCaughtFish = 0;
}
}
if (CatchTime == -1)
{
projectile.localAI[1] = CaughtItemID;
ReelTheBobberChecks();
owner.Calamity().consecutiveCaughtFish++;
if (projectile.ai[0] == 2)
return false;
isReelingIn = 1;
CatchTime = (float)CaughtItemID;
TimerToCatch = 0;
}
if (projectile.ai[0] == 0)
{
projectile.ai[1] = CatchTime;
projectile.localAI[1] = TimerToCatch;
if (CaughtItemID != -1 && isReelingIn == 0)
{
projectile.localAI[1] = 0;
projectile.ai[1] = 0;
}
projectile.ai[0] = isReelingIn;
}
return false;
}
case CalamityPlayer.FishingMinigames.RiftReeler:
{
if (PersistentFishingData == -1)
{
PersistentFishingData = 1;
TimerToCatch = 300;
}
var Waterline = GetWaterLine();
if (Waterline.Y >= projectile.Center.Y)
{
TimerToCatch = 300;
projectile.velocity.Y += 0.4f;
}
else if (projectile.ai[0] == 0)
{
owner.Calamity().ShouldHideControls = true;
if (owner.Calamity().pressedUp)
projectile.velocity.Y -= 0.125f;
if (owner.Calamity().pressedDown)
projectile.velocity.Y += 0.125f;
if (owner.Calamity().pressedLeft)
projectile.velocity.X -= 0.125f;
if (owner.Calamity().pressedRight)
projectile.velocity.X += 0.125f;
}
projectile.velocity *= 0.975f;
if (Waterline.Y <= projectile.Center.Y && projectile.ai[0] == 0 && !(projectile.lavaWet && !owner.accLavaFishing))
{
TimerToCatch -= Main.rand.Next(1, 5);
if (TimerToCatch <= 0)
{
projectile.FishingCheck();
if (projectile.ai[1] < 0)
{
CaughtItemID = (int)projectile.localAI[1];
projectile.ai[1] = 0;
projectile.localAI[1] = 0;
for (var i = 0; i < 1000; i++)
{
var vectorToCheck = projectile.Center + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 201));
var tileCoordsToCheck = vectorToCheck.ToSafeTileCoordinates();
if (new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight).Contains((int)vectorToCheck.X, (int)vectorToCheck.Y) && !Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].IsTileSolid() && Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].LiquidAmount > 0)
{
if (projectile.localAI[2] >= 1)
{
int customSonarText = (int)(projectile.localAI[2] - 1);
if (Main.popupText[customSonarText].sonar)
{
Main.popupText[customSonarText].position = vectorToCheck - FontAssets.MouseText.Value.MeasureString(Main.popupText[customSonarText].name) / 2f;
}
}
PersistentFishingDataVector2 = vectorToCheck;
TimerToCatch = 600;
break;
}
}
}
}
if (PersistentFishingDataVector2 != Vector2.Zero)
{
Dust.NewDustPerfect(PersistentFishingDataVector2, DustID.Smoke);
if (Main.rand.NextBool(3))
{
Dust.NewDustPerfect(PersistentFishingDataVector2, DustID.Torch);
}
var particle = new HeavySmokeParticle(PersistentFishingDataVector2, Vector2.One.RotatedByRandom(6.28) * Main.rand.NextFloat(1f, 4f), Color.Lerp(Color.DarkOrange, Color.DarkGray, Main.rand.NextFloat()), 15, 0.2f, 1);
GeneralParticleHandler.SpawnParticle(particle);
}
//When in lava, give the bobber a particle over it to show its location
if (projectile.lavaWet)
{
var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 2, 0.01f, Color.DarkGray, Vector2.One);
GeneralParticleHandler.SpawnParticle(particle);
}
List<(Vector2, int)> validRifts = new();
foreach (var item in Main.ActiveProjectiles)
{
if (item.bobber && item.owner == projectile.owner && item.ai[0] == 0 && item.Calamity().PersistentFishingDataVector2 != Vector2.Zero)
{
validRifts.Add((item.Calamity().PersistentFishingDataVector2, item.whoAmI));
}
}
foreach (var item in validRifts)
{
if (projectile.Distance(item.Item1) < 16)
{
projectile.localAI[1] = Main.projectile[item.Item2].Calamity().CaughtItemID;
ReelTheBobberChecks();
if (projectile.ai[0] < 2)
projectile.ai[0] = 1;
Main.projectile[item.Item2].Calamity().PersistentFishingDataVector2 = PersistentFishingDataVector2;
Main.projectile[item.Item2].Calamity().CaughtItemID = CaughtItemID;
break;
}
}
}
if (projectile.ai[0] == 0)
return true;
break;
}
case CalamityPlayer.FishingMinigames.FeralDoubleRod:
if (projectile.ai[0] == 0)
{
if (projectile.wet) //Fishing in water
{
if (cplayer.mouseRight && projectile.ai[1] == 0)
{
projectile.localAI[1] += 2;
owner.lifeRegenCount -= 60; // -0.5 health per tick
}
}
else //Attached to an enemy
{
if (PersistentFishingData >= 0 && Main.npc[(int)PersistentFishingData].active && projectile.Distance(Main.npc[(int)PersistentFishingData].Center + PersistentFishingDataVector2) < 128)
{
projectile.Center = Main.npc[(int)PersistentFishingData].Center + PersistentFishingDataVector2;
projectile.velocity = Vector2.Zero;
if (cplayer.mouseRight && projectile.ai[1] == 0 && owner.miscCounter % 10 == 0)
{
owner.lifeRegenCount -= 600; // -5 health per 10 ticks
var projID = Projectile.NewProjectile(projectile.GetSource_FromThis(), Main.npc[(int)PersistentFishingData].Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), (int)owner.GetBestClassDamage().ApplyTo(owner.HeldItem.fishingPole + owner.fishingSkill + owner.ChooseAmmo(owner.HeldItem).bait), 0f, owner.whoAmI, Main.npc[(int)PersistentFishingData].whoAmI);
if (Main.projectile.IndexInRange(projID))
{
Main.projectile[projID].ArmorPenetration = 100; //This should ignore almost all armor
}
}
projectile.timeLeft++;
return true;
}
else if (PersistentFishingData >= 0)
{
PersistentFishingData = -1;
projectile.velocity.Y -= 3;
}
foreach (var item in Main.ActiveNPCs)
{
if (item.friendly || item.dontTakeDamage)
continue;
if (projectile.Colliding(projectile.Hitbox, item.Hitbox))
{
PersistentFishingDataVector2 = projectile.Center - item.Center;
PersistentFishingData = item.whoAmI;
break;
}
}
}
}
break;
case CalamityPlayer.FishingMinigames.NavyFishingRod:
{
if (isReelingIn != projectile.ai[0])
return false;
var waterline = GetWaterLine();
var AdjustedOwnerWaterline = waterline;
if (AdjustedOwnerWaterline.Y < owner.Center.Y)
AdjustedOwnerWaterline.Y = owner.Center.Y;
if (AdjustedOwnerWaterline.Y >= projectile.Center.Y)
{
projectile.velocity.Y += 0.4f;
}
else
{
projectile.velocity.Y -= 0.1f;
}
projectile.velocity *= 0.975f;
if (CatchTime < 0)
CatchTime++;
if (projectile.wet || (projectile.lavaWet && owner.accLavaFishing) || projectile.honeyWet)
TimerToCatch++;
var speedup = 15;
var totalTime = 60 - speedup;
if (TimerToCatch + 90 >= 300 && CatchTime >= 0)
{
if (PersistentFishingData == 0)
PersistentFishingData = Main.rand.NextBool() ? 1 : -1;
var timer = TimerToCatch - 300;
SmallSplashAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0));
SmallDustAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0), DustID.BlueCrystalShard);
}
if (TimerToCatch >= 300 && CatchTime >= 0)
{
PersistentFishingData = 0;
projectile.FishingCheck();
if (projectile.ai[1] < 0)
{
CatchTime = -totalTime * 4;
CaughtItemID = (int)projectile.localAI[1];
}
TimerToCatch = 0;
}
if (CatchTime < 0 && CatchTime % totalTime == 0)
{
Splash();
PersistentFishingData = Main.rand.Next(0, 2);
var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(PersistentFishingData * MathHelper.Pi) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 45 - speedup, 0.04f, Color.Blue, new(1, 2), shrinkSpeed: -0.2f);
GeneralParticleHandler.SpawnParticle(particle);
}
if (CatchTime < 0 && CatchTime % totalTime == -15)
{
var playerDir = -1;
if (owner.Calamity().pressedLeft)
{
playerDir = 1;
}
if (owner.Calamity().pressedRight)
{
playerDir = 0;
}
if (playerDir == PersistentFishingData)
{
}
else
{
if (playerDir >= 0)
{
var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(playerDir * MathHelper.Pi) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 15, 0.04f, Color.Red, new(1, 2), shrinkSpeed: -0.2f);
GeneralParticleHandler.SpawnParticle(particle);
}
else
{
var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 15, 0.06f, Color.Red, Vector2.One);
GeneralParticleHandler.SpawnParticle(particle);
}
TimerToCatch = 0;
CatchTime = 0;
CaughtItemID = -1;
PersistentFishingData = 0;
owner.Calamity().consecutiveCaughtFish = 0;
}
}
if (CatchTime == -1)
{
projectile.localAI[1] = CaughtItemID;
ReelTheBobberChecks();
owner.Calamity().consecutiveCaughtFish++;
if (projectile.ai[0] == 2)
return false;
isReelingIn = 1;
CatchTime = (float)CaughtItemID;
TimerToCatch = 0;
}
if (projectile.ai[0] == 0)
{
projectile.ai[1] = CatchTime;
projectile.localAI[1] = TimerToCatch;
if (CaughtItemID != -1 && isReelingIn == 0)
{
projectile.localAI[1] = 0;
projectile.ai[1] = 0;
}
projectile.ai[0] = isReelingIn;
}
if (projectile.ai[0] == 0)
return true;
break;
}
case CalamityPlayer.FishingMinigames.TheDevourerOfCods:
var fishToEat = TheDevourerofCods.FishToEat;
if (projectile.ai[1] < -1)
{
//Coonsuming a fish provides/increases the player's food buffs.
if (fishToEat.Contains((int)projectile.localAI[1]))
{
projectile.ai[1] = 0;
projectile.localAI[1] = 0;
SoundEngine.PlaySound(SoundID.Item2, projectile.Center);
//If the player doesn't have Ex. Stuffed, either give them Plenty Satisfied or inrease existing Plenty Satisfied duration
if (!owner.HasBuff(BuffID.WellFed3))
{
if (owner.HasBuff(BuffID.WellFed2))
{
var bIndex = owner.FindBuffIndex(BuffID.WellFed2);
if (owner.buffTime[bIndex] < CalamityUtils.MinutesToFrames(24))
{
owner.buffTime[bIndex] += 300;
}
}
else
{
owner.AddBuff(BuffID.WellFed2, 300);
}
}
else //If the player DOES have Ex. Stuffed, increase the duration of it
{
var bIndex = owner.FindBuffIndex(BuffID.WellFed3);
if (owner.buffTime[bIndex] < CalamityUtils.MinutesToFrames(24)) //Requires fishing once per day if you'd like to keep free ExStuffed forever
{
owner.buffTime[bIndex] += 300;
}
}
}
else //If the hooked item isn't consumable, make it stay hooked forever.
{
projectile.ai[1] = -30;
}
}
return false;
case CalamityPlayer.FishingMinigames.HeronRod:
{
if (CatchTime < 0 || (isReelingIn == 1 && CaughtItemID > 0))
{
owner.Calamity().ShouldHideControls = true;
}
if (PersistentFishingData == -1)
{
PersistentFishingData = 1;
TimerToCatch = 300;
}
var Waterline = GetWaterLine();
if (Waterline.Y >= projectile.Center.Y)
{
projectile.velocity.Y += 0.4f;
}
else if (projectile.ai[0] <= 0)
{
projectile.velocity.Y -= 0.1f;
}
if (projectile.ai[0] <= 1)
{
owner.Calamity().ShouldHideControls = true;
}
projectile.velocity *= 0.975f;
if (projectile.wet)
projectile.velocity *= 0.99f;
//When in lava, give the bobber a particle over it to show its location
if (projectile.lavaWet)
{
var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 2, 0.01f, Color.DarkGray, Vector2.One);
GeneralParticleHandler.SpawnParticle(particle);
}
if (projectile.ai[0] == 0)
{
if (owner.Calamity().pressedUp && projectile.velocity.Y < 0)
projectile.velocity.Y -= 0.3f;
if (owner.Calamity().pressedUp && Waterline.Y < projectile.Center.Y)
projectile.velocity.Y -= 0.3f;
if (owner.Calamity().pressedDown)
projectile.velocity.Y += 0.25f;
if (owner.Calamity().pressedLeft)
projectile.velocity.X -= 0.25f;
if (owner.Calamity().pressedRight)
projectile.velocity.X += 0.25f;
if (Waterline.Y <= projectile.Center.Y - 8)
TimerToCatch -= Main.rand.Next(1, 5);
if (TimerToCatch <= 0)
{
projectile.FishingCheck();
if (projectile.ai[1] < 0 && !(projectile.lavaWet && !owner.accLavaFishing))
{
CaughtItemID = (int)projectile.localAI[1];
projectile.ai[1] = 0;
projectile.localAI[1] = 0;
for (var i = 0; i < 1000; i++)
{
var vectorToCheck = Waterline + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 32));
var tileCoordsToCheck = vectorToCheck.ToSafeTileCoordinates();
if (new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight).Contains((int)vectorToCheck.X, (int)vectorToCheck.Y) && !Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].IsTileSolid() && Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].LiquidAmount == 0)
{
if (projectile.localAI[2] >= 1)
{
int customSonarText = (int)(projectile.localAI[2] - 1);
if (Main.popupText[customSonarText].sonar)
{
Main.popupText[customSonarText].position = vectorToCheck - FontAssets.MouseText.Value.MeasureString(Main.popupText[customSonarText].name) / 2f;
}
}
PersistentFishingDataVector2 = vectorToCheck;
TimerToCatch = 600;
break;
}
}
}
}
if (PersistentFishingDataVector2 != Vector2.Zero && owner.miscCounter % 15 == 0)
{
var particle = new CustomSpark(PersistentFishingDataVector2, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 25, 0.02f, Color.Green, Vector2.One);
GeneralParticleHandler.SpawnParticle(particle);
}
List<(Vector2, int)> validRifts = new();
foreach (var item in Main.ActiveProjectiles)
{
if (item.bobber && item.owner == projectile.owner && item.ai[0] == 0 && item.Calamity().PersistentFishingDataVector2 != Vector2.Zero)
{
validRifts.Add((item.Calamity().PersistentFishingDataVector2, item.whoAmI));
}
}
foreach (var item in validRifts)
{
if (projectile.Distance(item.Item1) < 16)
{
projectile.localAI[1] = Main.projectile[item.Item2].Calamity().CaughtItemID;
projectile.ai[0] = -1;
Main.projectile[item.Item2].Calamity().PersistentFishingDataVector2 = PersistentFishingDataVector2;
Main.projectile[item.Item2].Calamity().CaughtItemID = CaughtItemID;
break;
}
}
}
if (projectile.ai[0] == -1 && (Waterline.Y <= projectile.Center.Y || projectile.velocity.Length() < 0.5f))
{
ReelTheBobberChecks();
if (projectile.ai[0] < 2)
projectile.ai[0] = 1;
}
if (projectile.ai[0] == 0)
return true;
break;
}
}
return false;
}
#endregion
#region AI
public override void AI(Projectile projectile)
{
+20 -1
View File
@@ -1,4 +1,6 @@
using Terraria;
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
@@ -14,6 +16,23 @@ namespace CalamityMod.Projectiles.Typeless
Projectile.bobber = true;
}
public override void PostAI()
{
foreach (var item in Main.ActiveNPCs)
{
if (!item.friendly && item.Distance(Projectile.Center) < 160)
{
item.AddBuff(ModContent.BuffType<StaticDischarge>(), 180);
if (Main.rand.NextBool(10))
{
Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f);
Projectile spark = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), item.Center, velocity, ModContent.ProjectileType<GenericElectricSpark>(), 0, 0f, Projectile.owner);
spark.localNPCHitCooldown = -2;
spark.timeLeft = 30;
}
}
}
}
public override bool PreDrawExtras()
{
Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0.25f);
+5
View File
@@ -13,6 +13,11 @@ namespace CalamityMod.Projectiles.Typeless
Projectile.height = 14;
Projectile.aiStyle = ProjAIStyleID.Bobber;
Projectile.bobber = true;
Projectile.friendly = true;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.penetrate = -1;
Projectile.ArmorPenetration = 100;
}
public override bool PreDrawExtras()