Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
更新:生成基础建设 v1.5.4
  • Loading branch information
1242509682 committed Jul 17, 2024
commit becaebc655446aa19a8fa075135656137f767e43
15 changes: 13 additions & 2 deletions SpawnInfra/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ internal class Configuration
public string Text5 { get; set; } = "每次重置服务器前使用一遍:/rm 重置,或者直接把这个指令写进重置插件里";
[JsonProperty("使用说明6", Order = -11)]
public string Text6 { get; set; } = "以下参数仅适用于大地图,小地图需自己调试适配";
[JsonProperty("使用说明7", Order = -11)]
public string Text7 { get; set; } = "[设置刷怪率]需所有在线玩家在刷怪场中心且击败[肉山]后生效";

[JsonProperty("开服自动基建", Order = -10)]
public bool Enabled { get; set; } = true;
Expand Down Expand Up @@ -248,8 +250,15 @@ public class ItemData3
[JsonProperty("是否放飞镖", Order = 13)]
public bool Dart { get; set; } = true;

[JsonProperty("设置刷怪率", Order = 15)]
public bool SpawnRate { get; set; } = true;
[JsonProperty("刷怪间隔/帧", Order = 15)]
public int defaultSpawnRate { get; set; }
[JsonProperty("刷怪上限/个", Order = 15)]
public int defaultMaxSpawns { get; set; }

public ItemData3(ushort id, ushort id2, ushort platformID, int platformstyle, int tileX, int tileY, int width, int platformY, int width2, int height, int width3, int center)

public ItemData3(ushort id, ushort id2, ushort platformID, int platformstyle, int tileX, int tileY, int width, int platformY, int width2, int height, int width3, int center,int deSpawn,int MaxSpawn)
{
Hell_BM_TileID = id;
Cord_TileID = id2;
Expand All @@ -263,6 +272,8 @@ public ItemData3(ushort id, ushort id2, ushort platformID, int platformstyle, in
BrushMonstHeight = height;
BrushMonstWidth = width3;
BrushMonstCenter = center;
defaultSpawnRate = deSpawn;
defaultMaxSpawns = MaxSpawn;
}
}
#endregion
Expand Down Expand Up @@ -308,7 +319,7 @@ public void Ints()

HellTunnel = new List<ItemData3>
{
new ItemData3(38, 214, 19, 43, 0, 0,5,25,2,200,200,2),
new ItemData3(38, 214, 19, 43, 0, 0,5,25,2,200,200,2,60,100),
};

SpawnShimmerBiome = new List<ItemData4>
Expand Down
75 changes: 69 additions & 6 deletions SpawnInfra/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terraria;
using Terraria.Utilities;
using TerrariaApi.Server;
using TShockAPI;
using TShockAPI.Hooks;
Expand All @@ -11,7 +12,7 @@ public class Plugin : TerrariaPlugin
#region 插件信息
public override string Name => "生成基础建设";
public override string Author => "羽学";
public override Version Version => new Version(1, 5, 3);
public override Version Version => new Version(1, 5, 4);
public override string Description => "给新世界创建NPC住房、仓库、洞穴刷怪场、地狱/微光直通车、地表和地狱世界级平台(轨道)";
#endregion

Expand All @@ -23,6 +24,7 @@ public override void Initialize()
GeneralHooks.ReloadEvent += (_) => LoadConfig();
//提高优先级避免覆盖CreateSpawn插件
ServerApi.Hooks.GamePostInitialize.Register(this, OnGamePostInitialize, 20);
GetDataHandlers.PlayerUpdate.Register(PlayerUpdate);
Commands.ChatCommands.Add(new Command("room.use", Comds.Comd, "rm", "基建")
{
HelpText = "生成基础建设"
Expand All @@ -35,6 +37,7 @@ protected override void Dispose(bool disposing)
{
GeneralHooks.ReloadEvent -= (_) => LoadConfig();
ServerApi.Hooks.GamePostInitialize.Deregister(this, OnGamePostInitialize);
GetDataHandlers.PlayerUpdate.UnRegister(PlayerUpdate);
Commands.ChatCommands.Remove(new Command("room.use", Comds.Comd, "rm", "基建"));
}
base.Dispose(disposing);
Expand Down Expand Up @@ -93,8 +96,6 @@ private static void OnGamePostInitialize(EventArgs args)
WorldGen.ShimmerMakeBiome(Main.spawnTileX + item.TileX, Main.spawnTileY + item.TileY); //坐标为出生点
}



//地狱直通车与刷怪场
foreach (var item in Config.HellTunnel)
{
Expand Down Expand Up @@ -178,6 +179,65 @@ private static void OnGamePostInitialize(EventArgs args)
}
#endregion

#region 提高刷怪场中的刷怪率方法
private void PlayerUpdate(object? sender, GetDataHandlers.PlayerUpdateEventArgs e)
{
if (e == null || !Config.Enabled || !Config.HellTunnel[0].SpawnRate ||
!Config.HellTunnel[0].BrushMonstEnabled || !Main.hardMode) return;

if (Main.zenithWorld || Main.remixWorld)//颠倒种子
MonsterRegion(Main.rockLayer / 2 + Config.HellTunnel[0].BrushMonstHeight,
Config.HellTunnel[0].BrushMonstHeight, Config.HellTunnel[0].BrushMonstWidth, Config.HellTunnel[0].BrushMonstCenter);

else //普通世界
MonsterRegion(Main.rockLayer, Config.HellTunnel[0].BrushMonstHeight,
Config.HellTunnel[0].BrushMonstWidth, Config.HellTunnel[0].BrushMonstCenter);
}

private static void MonsterRegion(double posY, int height, int width, int centerVal)
{
if (InRegion(posY, height, width, centerVal))
{
NPC.defaultSpawnRate = Config.HellTunnel[0].defaultSpawnRate;
NPC.defaultMaxSpawns = Config.HellTunnel[0].defaultMaxSpawns;
}
else
{
NPC.defaultSpawnRate = TShock.Config.Settings.DefaultSpawnRate;
NPC.defaultMaxSpawns = TShock.Config.Settings.DefaultMaximumSpawns;
}
}
#endregion

#region 判断所有玩家在刷怪区方法
public static bool InRegion(double posY, int height, int width, int centerVal)
{
int region = (int)posY - height;
int top = region + height * 2;
int bottom = (int)posY + height * 2;
int middle = (top + bottom) / 2 + centerVal;

int centerTop = middle + 8 + centerVal - 11;
int centerBottom = middle + 8 + centerVal + 3;
int centerLeft = Main.spawnTileX - 8 - centerVal;
int centerRight = Main.spawnTileX + 8 + centerVal;

for (int i = 0; i < Main.maxPlayers; i++) //所有在线玩家
{
Player plr = Main.player[i];
if (plr.active)
{
int plrX = (int)(plr.position.X / 16);
int plrY = (int)(plr.position.Y / 16);
if (!(plrX >= centerLeft && plrX <= centerRight
&& plrY >= centerTop && plrY <= centerBottom))
return false;
}
}
return true;
}
#endregion

#region 刷怪场
private static void RockTrialField(double posY, int Height, int Width, int CenterVal)
{
Expand Down Expand Up @@ -285,9 +345,9 @@ private static void RockTrialField(double posY, int Height, int Width, int Cente
//尖球
WorldGen.PlaceTile(x - j, wallY - j, 137, true, false, -1, 3);
WorldGen.PlaceTile(x + j, wallY - j, 137, true, false, -1, 3);
//给尖球加制动器
WorldGen.PlaceActuator(x - j, wallY - j);
WorldGen.PlaceActuator(x + j, wallY - j);
//给尖球虚化
Main.tile[x - j, wallY - j].inActive(true);
Main.tile[x + j, wallY - j].inActive(true);
}
//给尖球加电线
for (int j = 2; j <= 10 + CenterVal; j++)
Expand All @@ -309,11 +369,14 @@ private static void RockTrialField(double posY, int Height, int Width, int Cente
if (x < Main.spawnTileX)
{
Main.tile[x, middle - 1].slope(3); // 设置为右斜坡
WorldGen.PlaceTile(x, middle, 421, false, true, -1, 0); //刷怪场中间左边放1层传送带(刷怪取物品用)
}
else
{
Main.tile[x, middle - 1].slope(4); // 设置为左斜坡
WorldGen.PlaceTile(x, middle, 422, false, true, -1, 0); //刷怪场中间右边放1层传送带(刷怪取物品用)
}

// 把半砖替换成推怪平台
WorldGen.PlaceTile(x, middle - 1, Config.HellTunnel[0].PlatformID, false, true, -1, Config.HellTunnel[0].PlatformStyle);
//平台加电线+制动器
Expand Down
15 changes: 12 additions & 3 deletions SpawnInfra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

## 更新日志
```
v1.5.4
给刷怪场加入提高刷怪率方法
需击败肉山后所有在线玩家在刷怪场中心才会生效
把刷怪层改成传送带,尖球机关改成虚化(取消制动器)

v1.5.3
左海平台不会再建到太空层
优化天顶颠倒种子的世界平台与十周年种子的微光直通车
Expand Down Expand Up @@ -90,11 +95,12 @@ v1.0.0
```json
{
"使用说明": "[微光直通车]的高度是从[世界平台]到湖中心,[自建微光湖]天顶从地狱往上算,其他以出生点往下算,开启则关闭[微光直通]",
"使用说明2": "[世界平台]与[左海…]判断高度为太空层往下的距离,[刷怪场比例缩放]为倍数放大,建议不要调太高",
"使用说明2": "[世界平台]普通世界从出生点往上算,天顶从太空层往下算,[刷怪场比例缩放]为倍数放大,建议不要调太高",
"使用说明3": "改[箱子数量]要同时改[出生点偏移X],改[箱子层数]要同时改[出生点偏移Y],[层数间隔]和[箱子宽度]不建议动",
"使用说明4": "给玩家用的建晶塔房指令:/rm 数量 权限名:room.use (千万别在出生点用,有炸图风险)",
"使用说明5": "每次重置服务器前使用一遍:/rm 重置,或者直接把这个指令写进重置插件里",
"使用说明6": "以下参数仅适用于大地图,小地图需自己调试适配",
"使用说明7": "[设置刷怪率]需所有在线玩家在刷怪场中心且击败[肉山]后生效",
"开服自动基建": true,
"自建微光湖": [
{
Expand Down Expand Up @@ -176,12 +182,15 @@ v1.0.0
"刷怪场比例缩放": 2,
"是否放岩浆": true,
"是否放尖球": true,
"是否放飞镖": true
"是否放飞镖": true,
"设置刷怪率": true,
"刷怪间隔/帧": 60,
"刷怪上限/个": 100
}
]
}
```
## 反馈
- 优先发issued -> 共同维护的插件库:https://github.com/Controllerdestiny/TShockPlugin
- 次优先:TShock官方群:816771079
- 大概率看不到但是也可以:国内社区trhub.cn ,bbstr.net , tr.monika.love
- 大概率看不到但是也可以:国内社区trhub.cn ,bbstr.net , tr.monika.love