Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(AutoFish): bobbers moving leftward #807

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions src/AutoFish/AutoFish.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutoFish.Utils;
using LazyAPI;
using Microsoft.Xna.Framework;
using System.Text;
using Terraria;
using Terraria.ID;
Expand All @@ -14,7 +15,7 @@ public class AutoFish : LazyPlugin

#region 插件信息
public override string Name => System.Reflection.Assembly.GetExecutingAssembly().GetName().Name!; public override string Author => "羽学 少司命";
public override Version Version => new Version(1, 3, 6);
public override Version Version => new (1, 3, 7);
public override string Description => GetString("自动钓鱼");
#endregion

Expand Down Expand Up @@ -185,9 +186,16 @@ private void ProjectAiUpdate(ProjectileAiUpdateEventArgs args)

//这里发的是连续弹幕 避免线断 因为弹幕是不需要玩家物理点击来触发收杆的
plr.SendData(PacketTypes.ProjectileNew, "", args.Projectile.whoAmI);

var index = SpawnProjectile.NewProjectile(Main.projectile[args.Projectile.whoAmI].GetProjectileSource_FromThis(),
args.Projectile.position, args.Projectile.velocity, args.Projectile.type, 0, 0, args.Projectile.owner, 0, 0, 0);

var index = Projectile.NewProjectile(
args.Projectile.GetProjectileSource_FromThis(),
// NewProjectile uses centred position
args.Projectile.position + new Vector2((float)args.Projectile.width / 2, (float)args.Projectile.height / 2),
args.Projectile.velocity,
args.Projectile.type,
0,
0,
args.Projectile.owner);

plr.SendData(PacketTypes.ProjectileNew, "", index);
}
Expand All @@ -199,39 +207,52 @@ private void ProjectAiUpdate(ProjectileAiUpdateEventArgs args)
public void ProjectNew(object? sender, GetDataHandlers.NewProjectileEventArgs e)
{
var plr = e.Player;
var guid = Guid.NewGuid().ToString();
var HookCount = Main.projectile.Count(p => p.active && p.owner == e.Owner && p.bobber); // 浮漂计数
var bobberCount = Main.projectile.Count(p => p.active && p.owner == e.Owner && p.bobber); // 浮漂计数

if (plr == null ||
!plr.Active ||
!plr.IsLoggedIn ||
!Configuration.Instance.Enabled ||
!Configuration.Instance.MoreHook ||
!plr.HasPermission("autofish") ||
HookCount > Configuration.Instance.HookMax - 1)
bobberCount > Configuration.Instance.HookMax - 1)
{
return;
}

// 从数据表中获取与玩家名字匹配的配置项
var list = Data.Items.FirstOrDefault(x => x.Name == plr.Name);
var playerData = Data.Items.FirstOrDefault(x => x.Name == plr.Name);
// 如果没有找到配置项,或者自动钓鱼功能或启用状态未设置,则返回
if (list == null || !list.Enabled)
if (playerData is not { Enabled: true })
{
return;
}

// 正常状态下与消耗模式下启用多线钓鱼
if (!Configuration.Instance.ConMod || (Configuration.Instance.ConMod && list.Mod))
if (!Configuration.Instance.ConMod || (Configuration.Instance.ConMod && playerData.Mod))
{
// 检查是否上钩
if (Tools.BobbersActive(e.Owner))
{
var index = SpawnProjectile.NewProjectile(Main.projectile[e.Index].GetProjectileSource_FromThis(), e.Position, e.Velocity, e.Type, e.Damage, e.Knockback, e.Owner, 0, 0, 0, -1, guid);
plr.SendData(PacketTypes.ProjectileNew, "", index);
// since there is no `ProjectileID.Sets.IsBobber`, I can only determine in this way
var dummyProjectile = new Projectile();
dummyProjectile.SetDefaults(e.Type);
if (!dummyProjectile.bobber)
{
return;
}

var index = Projectile.NewProjectile(
Main.projectile[e.Index].GetProjectileSource_FromThis(),
e.Position,
e.Velocity,
e.Type,
e.Damage,
e.Knockback,
e.Owner);


// 更新多线计数
HookCount++;
plr.SendData(PacketTypes.ProjectileNew, "", index);
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/AutoFish/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ internal class Configuration : JsonConfigBase<Configuration>
[LocalizedPropertyName(CultureType.Chinese, "额外渔获", Order = -1)]
[LocalizedPropertyName(CultureType.English, "AdditionalCatches")]
public List<int> DoorItems = new();

[LocalizedPropertyName(CultureType.Chinese, "禁止衍生弹幕", Order = 10)]
[LocalizedPropertyName(CultureType.English, "ForbidProjectiles")]
public int[] DisableProjectile { get; set; } = new int[] { 623, 625, 626, 627, 628, 831, 832, 833, 834, 835, 963, 970 };
#endregion

protected override string Filename => "AutoFish";
Expand Down
14 changes: 0 additions & 14 deletions src/AutoFish/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,6 @@
2676,
3191,
3194
],
"ForbidProjectiles": [
623, // To solve the BUG where single summon creatures spawn more numbers under multi-hook mode
625,
626,
627,
628,
831,
832,
833,
834,
835,
963,
970
]
}
```
Expand Down
18 changes: 4 additions & 14 deletions src/AutoFish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@
29,
3093,
4345
],
"禁止衍生弹幕": [
623, //用于解决在多线钓鱼的模式下,单体召唤物会衍生更多数量的BUG
625,
626,
627,
628,
831,
832,
833,
834,
835,
963,
970
]
}
```
Expand All @@ -81,6 +67,10 @@
## 更新日志

```
v1.3.7
修复浮漂往左运动的问题
精简部分代码

v1.3.5
准备更新TS 5.2.1,修正文档,初始配置内容更改

Expand Down
Loading