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

更新:添加血月、霜月等事件强制pvp新功能,去除中文命名 #207

Merged
merged 2 commits into from
Jun 15, 2024
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
3 changes: 3 additions & 0 deletions RealTime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
- 由于夜晚不生成npc,所以老人和拜月教邪教徒每24分钟检测一次,如果不存在就召唤一个,召唤位置在地牢。
- 白天随机天气功能,15分钟更新一次
- 夜间npc入住功能
-事件发生时,使其强制开启PVP模式

## 更新日志

```
v2.4更新:更改事件发生时,使其强制开启PVP模式

v2.3更新:新增白天随机天气功能,15分钟更新一次

v2.2更新:新增夜间npc入住功能
Expand Down
53 changes: 46 additions & 7 deletions RealTime/RealTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class RealTime : TerrariaPlugin
public override string Author => "十七";
public override string Description => "同步现实时间";
public override string Name => "RealTime";
public override Version Version => new Version(2, 3, 0, 0);
public override Version Version => new Version(2, 4, 0, 0);
public RealTime(Main game) : base(game)
{
}
Expand Down Expand Up @@ -64,23 +64,32 @@ public ChangeCloud GetRandom(ChangeCloud[] arr)//自定义随机数定义
bool lastBloodMoon = false;
bool lastEclipse = false;
bool lastPumpkinMoon = false;
bool lastSnowMoon = false;
bool lastSnowMoon = false;
DateTime time = DateTime.Now;
private void OnGameUpdate(EventArgs args)
{
{
#region 血月
if (lastBloodMoon ^ Main.bloodMoon)
{
if (Main.bloodMoon)
{
//血月开启瞬间
time = DateTime.Now + TimeSpan.FromMinutes(30);
time = DateTime.Now + TimeSpan.FromMinutes(20);
}
}
lastBloodMoon = Main.bloodMoon;
if (Main.bloodMoon == true)
{

TShock.Players.Where(p => p != null).ToList().ForEach(p=>
{
if (Main.player[p.Index].hostile == false)
{
Main.player[p.Index].hostile = true;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, NetworkText.Empty, p.Index);
p.SendWarningMessage(
"血月的邪恶影响会阻止你的PvP关闭。");
}
});
if (DateTime.Now >= time)
{
Main.bloodMoon = false;
Expand All @@ -93,12 +102,22 @@ private void OnGameUpdate(EventArgs args)
if (Main.eclipse)
{
//日食开启瞬间
time = DateTime.Now + TimeSpan.FromMinutes(30);
time = DateTime.Now + TimeSpan.FromMinutes(20);
}
}
lastEclipse = Main.eclipse;
if (Main.eclipse == true)
{
TShock.Players.Where(p => p != null).ToList().ForEach(p =>
{
if (Main.player[p.Index].hostile == false)
{
Main.player[p.Index].hostile = true;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, NetworkText.Empty, p.Index);
p.SendWarningMessage(
"日食的邪恶影响会阻止你的PvP关闭。");
}
});
if (DateTime.Now >= time)
{
Main.eclipse = false;
Expand All @@ -119,6 +138,16 @@ private void OnGameUpdate(EventArgs args)
{
if (DateTime.Now >= time)
{
TShock.Players.Where(p => p != null).ToList().ForEach(p =>
{
if (Main.player[p.Index].hostile == false)
{
Main.player[p.Index].hostile = true;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, NetworkText.Empty, p.Index);
p.SendWarningMessage(
"万圣节的邪恶影响会阻止你的PvP关闭。");
}
});
Main.pumpkinMoon = false;
}
}
Expand All @@ -137,6 +166,16 @@ private void OnGameUpdate(EventArgs args)
{
if (DateTime.Now >= time)
{
TShock.Players.Where(p => p != null).ToList().ForEach(p =>
{
if (Main.player[p.Index].hostile == false)
{
Main.player[p.Index].hostile = true;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, NetworkText.Empty, p.Index);
p.SendWarningMessage(
"霜月的邪恶影响会阻止你的PvP关闭。");
}
});
Main.snowMoon = false;
}
}
Expand Down Expand Up @@ -214,7 +253,7 @@ private void OnGameUpdate(EventArgs args)
else
{
Random ran = new Random();
int num = ran.Next(1, 50); //100以内随机数
int num = ran.Next(1, 50); //1-50随机数
ChangeCloud[] arr =
{
()=>Main.cloudBGActive=num,
Expand Down
Loading