Skip to content

Commit

Permalink
Merge pull request #604 from 1242509682/master
Browse files Browse the repository at this point in the history
添加插件 玩家速度(2段冲刺) 自定义武器,修复 自动钓鱼v1.3.2代码
  • Loading branch information
THEXN authored Dec 12, 2024
2 parents 474cfb4 + c1ce694 commit 9d50aa9
Show file tree
Hide file tree
Showing 26 changed files with 6,289 additions and 126 deletions.
20 changes: 20 additions & 0 deletions Plugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DwTP", "src\DwTP\DwTP.cspro
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoClear", "src\AutoClears\AutoClear.csproj", "{998A17B6-92DE-490D-8AB2-01941C729BFE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlayerSpeed", "src\PlayerSpeed\PlayerSpeed.csproj", "{7BA96C42-7623-4B07-B68F-244E4FCBAD53}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModifyWeapons", "src\ModifyWeapons\ModifyWeapons.csproj", "{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1246,6 +1250,22 @@ Global
{998A17B6-92DE-490D-8AB2-01941C729BFE}.Release|Any CPU.Build.0 = Release|Any CPU
{998A17B6-92DE-490D-8AB2-01941C729BFE}.Release|x64.ActiveCfg = Release|Any CPU
{998A17B6-92DE-490D-8AB2-01941C729BFE}.Release|x64.Build.0 = Release|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Debug|x64.ActiveCfg = Debug|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Debug|x64.Build.0 = Debug|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Release|Any CPU.Build.0 = Release|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Release|x64.ActiveCfg = Release|Any CPU
{7BA96C42-7623-4B07-B68F-244E4FCBAD53}.Release|x64.Build.0 = Release|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Debug|x64.ActiveCfg = Debug|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Debug|x64.Build.0 = Debug|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Release|Any CPU.Build.0 = Release|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Release|x64.ActiveCfg = Release|Any CPU
{76988FD0-FDEF-427F-856E-DB5F0BF8FCC5}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
| [AutoPluginManager](src/AutoPluginManager/README.md) | 一键自动更新插件 ||
| [AdditionalPylons](src/AdditionalPylons/README.md) | 放置更多晶塔 ||
| [AnnouncementBoxPlus](src/AnnouncementBoxPlus/README.md) | 广播盒功能强化 ||
| [AutoAirItem](src/AutoAirItem/README.md) | 自动垃圾桶插件 | |
| [AutoAirItem](src/AutoAirItem/README.md) | 自动垃圾桶插件 | [LazyAPI](src/LazyAPI/README.md) |
| [AutoBroadcast](src/AutoBroadcast/README.md) | 自动广播 ||
| [AutoClear](src/Autoclear/README.md) | 智能自动扫地 ||
| [AutoReset](src/AutoReset/README.md) | 完全自动重置 ||
| [AutoStoreItems](src/AutoStoreItems/README.md) | 自动储存 ||
| [AutoTeam](src/AutoTeam/README.md) | 自动队伍 ||
| [AutoFish](src/AutoFish/README.md) | 自动钓鱼 | |
| [AutoFish](src/AutoFish/README.md) | 自动钓鱼 | [LazyAPI](src/LazyAPI/README.md) |
| [Back](src/Back/README.md) | 死亡回溯 ||
| [BagPing](src/BagPing/README.md) | 地图上标记宝藏袋 ||
| [BetterWhitelist](src/BetterWhitelist/README.md) | 白名单插件 ||
Expand Down Expand Up @@ -133,13 +133,15 @@
| [LazyAPI](src/LazyAPI/README.md) | 插件基础库 | linq2db |
| [LifemaxExtra](src/LifemaxExtra/README.md) | 吃更多生命果/水晶 ||
| [ListPlugins](src/ListPlugins/README.md) | 查已装插件 ||
| [ModifyWeapons](src/ModifyWeapons/README.md) | 修改武器 | [LazyAPI](src/LazyAPI/README.md) |
| [MapTeleport](src/MapTp/README.md) | 双击大地图传送 ||
| [MiniGamesAPI](src/MiniGamesAPI/README.md) | 豆沙小游戏 API ||
| [MonsterRegen](src/MonsterRegen/README.md) | 怪物进度回血 ||
| [Musicplayer](src/MusicPlayer/README.md) | 简易音乐播放器 ||
| [Noagent](src/Noagent/README.md) | 禁止代理 ip 进入 ||
| [NormalDropsBags](src/NormalDropsBags/README.md) | 普通难度宝藏袋 ||
| [OnlineGiftPackage](src/OnlineGiftPackage/README.md) | 在线礼包 ||
| [PlayerSpeed](src/PlayerSpeed/README.md) | 玩家速度 | [LazyAPI](src/LazyAPI/README.md) |
| [PacketsStop](src/PacketsStop/README.md) | 数据包拦截 ||
| [PermaBuff](src/PermaBuff/README.md) | 永久 Buff ||
| [PerPlayerLoot](src/PerPlayerLoot/README.md) | 玩家战利品单独箱子 ||
Expand Down
2 changes: 2 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@
| [LazyAPI](src/LazyAPI/README.md) | Yes | Plugin base library | linq2db |
| [LifemaxExtra](src/LifemaxExtra/README.md) | No | Eat more life fruits/crystals | None |
| [ListPlugins](src/ListPlugins/README.md) | No | List installed plugins | None |
| [ModifyWeapons](src/ModifyWeapons/README_EN.md) | Yes | ModifyWeapons | [LazyAPI](src/LazyAPI/README.md) |
| [MapTeleport](src/MapTp/README_EN.md) | Yes | Double-click on the map to teleport | None |
| [MiniGamesAPI](src/MiniGamesAPI/README.md) | No | Bean paste mini-game API | None |
| [MonsterRegen](src/MonsterRegen/README.md) | No | Monster progress regeneration | None |
| [Musicplayer](src/MusicPlayer/README.md) | No | Simple music player | None |
| [Noagent](src/Noagent/README.md) | No | Prohibit proxy IP from entering | None |
| [NormalDropsBags](src/NormalDropsBags/README.md) | No | Drop treasure bags at normal difficulty | None |
| [OnlineGiftPackage](src/OnlineGiftPackage/README.md) | No | Online gift package | None |
| [PlayerSpeed](src/PlayerSpeed/README.md) | Yes | Enable players to achieve a two-stage sprint | [LazyAPI](src/LazyAPI/README.md) |
| [PacketsStop](src/PacketsStop/README.md) | No | Packet interception | None |
| [PermaBuff](src/PermaBuff/README.md) | No | Permanent buff | None |
| [PerPlayerLoot](src/PerPlayerLoot/README_EN.md) | Yes | Separate chest for player loot | None |
Expand Down
2 changes: 2 additions & 0 deletions README_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@
| [LazyAPI](src/LazyAPI/README.md) | No | Biblioteca base para plugins | linq2db |
| [LifemaxExtra](src/LifemaxExtra/README.md) | No | Comer más frutas/cristales de vida | Ninguna |
| [ListPlugins](src/ListPlugins/README.md) | No | Lista los plugins instalados | Ninguna |
| [ModifyWeapons](src/ModifyWeapons/README_EN.md) | No | Deje que los jugadores realicen dos Sprint | [LazyAPI](src/LazyAPI/README.md) |
| [MapTeleport](src/MapTp/README_EN.md) | No | Teletransportarse con doble clic en el mapa | Ninguna |
| [MiniGamesAPI](src/MiniGamesAPI/README.md) | No | API para el mini-juego de pasta de frijol | Ninguna |
| [MonsterRegen](src/MonsterRegen/README.md) | No | Regeneración de progreso de monstruos | Ninguna |
| [Musicplayer](src/MusicPlayer/README.md) | No | Reproductor de música simple | Ninguna |
| [Noagent](src/Noagent/README.md) | No | Prohíbe que las IPs de proxy ingresen al servidor | Ninguna |
| [NormalDropsBags](src/NormalDropsBags/README.md) | No | Suelta bolsas de tesoros en dificultad normal | Ninguna |
| [OnlineGiftPackage](src/OnlineGiftPackage/README.md) | No | Paquete de regalos en línea | Ninguna |
| [PlayerSpeed](src/PlayerSpeed/README.md) | No | Interceptación de paquetes | [LazyAPI](src/LazyAPI/README.md) |
| [PacketsStop](src/PacketsStop/README.md) | No | Interceptación de paquetes | Ninguna |
| [PermaBuff](src/PermaBuff/README.md) | No | Buff permanente | Ninguna |
| [PerPlayerLoot](src/PerPlayerLoot/README_EN.md) | No | Cofre separado para el botín del jugador | Ninguna |
Expand Down
192 changes: 77 additions & 115 deletions src/AutoFish/AutoFish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AutoFish : LazyPlugin
#region 插件信息
public override string Name => "自动钓鱼";
public override string Author => "羽学 少司命";
public override Version Version => new Version(1, 3, 3);
public override Version Version => new Version(1, 3, 4);
public override string Description => "涡轮增压不蒸鸭";
#endregion

Expand Down Expand Up @@ -101,112 +101,97 @@ private void ProjectAiUpdate(ProjectileAiUpdateEventArgs args)
return;
}

//开启消耗模式
if (Configuration.Instance.ConMod)
// 正常状态下 与消耗模式下启用自动钓鱼
if (!Configuration.Instance.ConMod || (Configuration.Instance.ConMod && list.Mod))
{
//多加一个 list.Mod 来判断玩家是否花费了【指定物品】来换取功能时长
if (list.Mod && list.Enabled)
if (args.Projectile.ai[1] < 0)
{
ControlFishing(args, plr);
}
}
else
{
//否则只要打开插件开关就能使用功能
if (list.Enabled)
{
ControlFishing(args, plr);
}
}
}
#endregion

#region 自动钓鱼核心逻辑(由少司命贡献) 我就加一下他没写完的逻辑- -
private static void ControlFishing(ProjectileAiUpdateEventArgs args, TSPlayer plr)
{
if (args.Projectile.ai[1] < 0)
{
args.Projectile.ai[0] = 1.0f;
args.Projectile.ai[0] = 1.0f;

var baitItem = new Item();
var baitItem = new Item();

// 检查并选择消耗饵料
plr.TPlayer.ItemCheck_CheckFishingBobber_PickAndConsumeBait(args.Projectile, out var pullTheBobber, out var baitTypeUsed);
if (pullTheBobber)
{
plr.TPlayer.ItemCheck_CheckFishingBobber_PullBobber(args.Projectile, baitTypeUsed);

// 更新玩家背包 使用饵料信息
for (var i = 0; i < plr.TPlayer.inventory.Length; i++)
// 检查并选择消耗饵料
plr.TPlayer.ItemCheck_CheckFishingBobber_PickAndConsumeBait(args.Projectile, out var pullTheBobber, out var baitTypeUsed);
if (pullTheBobber)
{
var inv = plr.TPlayer.inventory[i];
plr.TPlayer.ItemCheck_CheckFishingBobber_PullBobber(args.Projectile, baitTypeUsed);

//玩家饵料(指的是你手上鱼竿上的那个数字),使用的饵料是背包里的物品
if (inv.bait > 0 && baitTypeUsed == inv.type)
// 更新玩家背包 使用饵料信息
for (var i = 0; i < plr.TPlayer.inventory.Length; i++)
{
//当物品数量正常则开始进入钓鱼检查
if (inv.stack > 1)
{
//发包到对应饵料的格子内
plr.SendData(PacketTypes.PlayerSlot, "", plr.Index, i);
break;
}
var inv = plr.TPlayer.inventory[i];

//当前物品数量为1则移除(避免选中的饵不会主动消失 变成无限饵 或 卡住线程)
if (inv.stack == 1 || inv.bait == 1)
//玩家饵料(指的是你手上鱼竿上的那个数字),使用的饵料是背包里的物品
if (inv.bait > 0 && baitTypeUsed == inv.type)
{
inv.TurnToAir();
plr.SendData(PacketTypes.PlayerSlot, "", plr.Index, i);
break;
//当物品数量正常则开始进入钓鱼检查
if (inv.stack > 1)
{
//发包到对应饵料的格子内
plr.SendData(PacketTypes.PlayerSlot, "", plr.Index, i);
break;
}

//当前物品数量为1则移除(避免选中的饵不会主动消失 变成无限饵 或 卡住线程)
if (inv.stack == 1 || inv.bait == 1)
{
inv.TurnToAir();
plr.SendData(PacketTypes.PlayerSlot, "", plr.Index, i);
break;
}
}
}
}
}

//松露虫 判断一下玩家是否在海边
if (baitItem.type == 2673 && plr.X / 16 == Main.oceanBG && plr.Y / 16 == Main.oceanBG)
{
args.Projectile.ai[1] = 0;
plr.SendData(PacketTypes.ProjectileNew, "", args.Projectile.whoAmI);
return;
}

do //无限循环检查
{
// 执行钓鱼检查
args.Projectile.FishingCheck();

//随机物品
if (Configuration.Instance.Random)
//松露虫 判断一下玩家是否在海边
if (baitItem.type == 2673 && plr.X / 16 == Main.oceanBG && plr.Y / 16 == Main.oceanBG)
{
var rm = new Random();
var id = rm.Next(1, ItemID.Count - 1);
args.Projectile.localAI[1] = id;
args.Projectile.ai[1] = 0;
plr.SendData(PacketTypes.ProjectileNew, "", args.Projectile.whoAmI);
return;
}

// 将localAI[1]的值复制到ai[1]
args.Projectile.ai[1] = args.Projectile.localAI[1];

//如果额外渔获 有任何1个物品ID 则参与AI[1]
if (Configuration.Instance.DoorItems.Any())
//获得钓鱼物品方法
var flag = false;
var ActiveCount = TShock.Players.Where(plr => plr != null && plr.Active && plr.IsLoggedIn).Count();
var Limit = Tools.GetLimit(ActiveCount); //根据人数动态调整Limit
for (var count = 0; !flag && count < Limit; count++)
{
//确保浮漂正在运动,没有鱼上钩(即ai[1]小于等于0)
if (args.Projectile.ai[1] < 0)
args.Projectile.FishingCheck();

if (Configuration.Instance.Random)
{
// 从DoorItems中随机选择一个物品,并将其ID赋值给ai[1],模拟有新鱼上钩的情况
args.Projectile.ai[1] = Convert.ToSingle(Configuration.Instance.DoorItems.OrderByDescending(x => Guid.NewGuid()).First());
args.Projectile.localAI[1] = Random.Shared.Next(1, ItemID.Count);
}

args.Projectile.ai[1] = args.Projectile.localAI[1];

// 如果额外渔获有任何1个物品ID,则参与AI[1]
if (Configuration.Instance.DoorItems.Any())
{
if (args.Projectile.ai[1] <= 0)
{
args.Projectile.ai[1] = Configuration.Instance.DoorItems[Main.rand.Next(Configuration.Instance.DoorItems.Count)];
}
}

flag = args.Projectile.ai[1] > 0;
}

if (!flag)
{
return;
}
}
while (args.Projectile.ai[1] <= 0); // 循环直到有一个有效的鱼上钩(ai[1]大于0)

//这里发的是连续弹幕 避免线断 因为弹幕是不需要玩家物理点击来触发收杆的
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);
//这里发的是连续弹幕 避免线断 因为弹幕是不需要玩家物理点击来触发收杆的
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);

plr.SendData(PacketTypes.ProjectileNew, "", index);
plr.SendData(PacketTypes.ProjectileNew, "", index);
}
}
}
#endregion
Expand Down Expand Up @@ -237,40 +222,17 @@ public void ProjectNew(object? sender, GetDataHandlers.NewProjectileEventArgs e)
return;
}

//开启消耗模式
if (Configuration.Instance.ConMod)
// 正常状态下与消耗模式下启用多线钓鱼
if (!Configuration.Instance.ConMod || (Configuration.Instance.ConMod && list.Mod))
{
//玩家的自动钓鱼开关
if (list.Mod && list.Enabled)
{
// 检查是否上钩
if (Tools.BobbersActive(e.Owner))
{
//构建新弹幕
var index = SpawnProjectile.NewProjectile(Main.projectile[e.Index].GetProjectileSource_FromThis(),
e.Position, e.Velocity, e.Type, (int)e.Damage, e.Knockback, e.Owner, 0, 0, 0, -1, guid);

plr.SendData(PacketTypes.ProjectileNew, "", index);

// 更新多线计数
HookCount++;
}
}
}

else //正常模式下多线
{
if (list.Enabled)
// 检查是否上钩
if (Tools.BobbersActive(e.Owner))
{
if (Tools.BobbersActive(e.Owner))
{
var index = SpawnProjectile.NewProjectile(Main.projectile[e.Index].GetProjectileSource_FromThis(),
e.Position, e.Velocity, e.Type, (int)e.Damage, e.Knockback, e.Owner, 0, 0, 0, -1, guid);

plr.SendData(PacketTypes.ProjectileNew, "", index);
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);

HookCount++;
}
// 更新多线计数
HookCount++;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/AutoFish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
## 更新日志

```
v1.3.4
补充v1.3.2遗漏的代码
v1.3.3
引用LazyAPI
v1.3.2
尝试修复鱼饵数量为1时崩服BUG
Expand Down
6 changes: 6 additions & 0 deletions src/AutoFish/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
## Update Log

```
v1.3.4
Supplement the code omitted in v1.3.2
v1.3.3
using LazyAPI
v1.3.2
- Attempted to fix the server crash bug that occurred when the bait quantity was 1.
Expand Down
Loading

0 comments on commit 9d50aa9

Please sign in to comment.