Skip to content

Commit

Permalink
v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsFabTest committed Aug 18, 2024
1 parent dbb396f commit 6a650ac
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NebulaPluginNova/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class NebulaPlugin : BasePlugin
//public const string VisualVersion = "Snapshot 24.08.17a";

public const string PluginEpochStr = "101";
public const string PluginBuildNumStr = "1101";
public const string PluginBuildNumStr = "1104";
public static readonly int PluginEpoch = int.Parse(PluginEpochStr);
public static readonly int PluginBuildNum = int.Parse(PluginBuildNumStr);
public const bool GuardVanillaLangData = false;
Expand Down
6 changes: 3 additions & 3 deletions NebulaPluginNova/Patches/SetTeamChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ private static bool hasChat()

public static void Postfix(HudManager __instance)
{
if (!GeneralConfigurations.UseBubbleChatOption) return;
if (!GeneralConfigurations.UseBubbleChatOption || !hasChat()) return;

if (hasChat() && !__instance.Chat.isActiveAndEnabled)
if (!__instance.Chat.isActiveAndEnabled)
__instance.Chat.SetVisible(true);
else if (!hasChat() && MeetingHud.Instance == null && LobbyBehaviour.Instance == null) __instance.Chat.SetVisible(false);
//else if (!hasChat() && MeetingHud.Instance == null && LobbyBehaviour.Instance == null) __instance.Chat.SetVisible(false);
}
}
3 changes: 3 additions & 0 deletions NebulaPluginNova/Resources/Achievements.dat
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ justice.common2,1,
justice.another1,0,secret,
justice.common3,1,
justice.challenge,2,
knight.common1,0,
knight.common2,1,goal-10,
knight.challenge,2,
madmate.common1,0,
madmate.another1,1,secret,
madmate.common2,0,
Expand Down
Binary file modified NebulaPluginNova/Resources/Addons/NebulaRemakeLanguage.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"options.role.judge.canJudgeLovers" : "可以处决恋人"
"options.role.judge.canCallEmergencyMeeting" : "可以发起紧急会议"

"role.knight.name" : "骑士"
"role.knight.short" : "骑"
"role.knight.blurb" : "捍卫骑士的荣耀"
"options.role.knight.detail" : "骑士拥有格挡技能。<br>在格挡期间,骑士不会因直接击杀导致死亡。"
"options.role.knight.blockCoolDown" : "格挡冷却时间"
"options.role.knight.blockDuration" : "格挡持续时间"

"role.madmateModifier.name" : "叛徒"
"role.madmateModifier.short" : "叛"
"role.madmateModifier.generalBlurb" : "帮助伪装者获得胜利"
Expand All @@ -53,6 +60,7 @@
"role.oracle.blurb" : "感受你的过往"
"options.role.oracle.detail" : "你可以获取他人的职业。<br>你获取的信息会混杂着多个错误的干扰信息。"
"options.role.oracle.oracleCoolDown" : "占卜冷却时间"
"options.role.oracle.oracleDuration" : "占卜所需时间"
"options.role.oracle.numOfInfo" : "占卜获得的职业数量"
"role.oracle.message" : "%PLAYER%的职业是%DETAIL%其中之一"

Expand Down Expand Up @@ -87,6 +95,7 @@

# Buttons

"button.label.block" : "格挡"
"button.label.repair" : "修理"
"button.label.oracle" : "占卜"

Expand Down Expand Up @@ -117,9 +126,11 @@
"chat.nac" : "/help: 查询命令<br> - /tell [玩家名] [消息内容] : 私聊<br> - /impostor [消息内容] : 伪装者频道<br> - /jackal [消息内容] : 豺狼频道<br> - /lover [消息内容] : 恋人频道"

# Input

"input.changeCannel" : "聊天框更换频道"

# Options

"options.bubbleChat" : "聊天框频道"
"options.bubbleChat.detail" : "允许玩家在游戏内随时使用聊天框与队友交流。"
"options.bubbleChat.useBubbleChat" : "队伍游戏中聊天框"
Expand Down Expand Up @@ -169,6 +180,18 @@
"achievement.judge.challenge.goal" : "成功审判三人并存活到最后取得胜利。"
"achievement.judge.challenge.cond" : "条件:游戏结束时存活且成功审判三人"

"achievement.knight.common1.title" : "来者何人"
"achievement.knight.common1.goal" : "成功格挡一次击杀。"
"achievement.knight.common1.cond" : ""

"achievement.knight.common2.title" : "振刀"
"achievement.knight.common2.goal" : "累计格挡十次击杀。"
"achievement.knight.common2.cond" : ""

"achievement.knight.challenge.title" : "四面楚歌"
"achievement.knight.challenge.goal" : "一次性格挡三次击杀。"
"achievement.knight.challenge.cond" : "条件:在一次技能期间避免三次击杀"

"achievement.oracle.common1.title" : "让我看看"
"achievement.oracle.common1.goal" : "使用一次占卜。"
"achievement.oracle.common1.cond" : ""
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions NebulaPluginNova/Roles/Crewmate/Knight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using Nebula.Game.Statistics;
using Virial;
using Virial.Assignable;
using Virial.Configuration;
using Virial.Events.Player;
using Virial.Game;

namespace Nebula.Roles.Crewmate;

public class Knight : DefinedRoleTemplate, DefinedRole
{
private Knight() : base("knight", new(198, 97, 97), RoleCategory.CrewmateRole, Crewmate.MyTeam, [BlockCoolDownOption, BlockDurationOption]) { }

RuntimeRole RuntimeAssignableGenerator<RuntimeRole>.CreateInstance(Virial.Game.Player player, int[] arguments) => new Instance(player);

private static FloatConfiguration BlockCoolDownOption = NebulaAPI.Configurations.Configuration("options.role.knight.blockCoolDown", (2.5f, 60f, 2.5f), 30f, FloatConfigurationDecorator.Second);
private static FloatConfiguration BlockDurationOption = NebulaAPI.Configurations.Configuration("options.role.knight.blockDuration", (1f, 10f, 0.5f), 5f, FloatConfigurationDecorator.Second);

public static Knight MyRole = new Knight();
public class Instance : RuntimeAssignableTemplate, RuntimeRole
{
DefinedRole RuntimeRole.Role => MyRole;
public Instance(Virial.Game.Player player) : base(player) { }
private static Image buttonSprite = SpriteLoader.FromResource("Nebula.Resources.Buttons.BlockButton.png", 115f);
private AchievementToken<(bool cleared, int count)>? acTokenChallenge;
private ModAbilityButton blockButton = null!;
internal static Dictionary<byte, bool> BlockMurderingTab = new();

void RuntimeAssignable.OnActivated()
{
BlockMurderingTab = new();
if (AmOwner)
{
acTokenChallenge = new("knight.challenge", (false, 0), (val, _) => val.cleared);

blockButton = Bind(new ModAbilityButton()).KeyBind(Virial.Compat.VirtualKeyInput.Ability);

blockButton.SetSprite(buttonSprite.GetSprite());
blockButton.Availability = (button) => MyPlayer.CanMove;
blockButton.Visibility = (button) => !MyPlayer.IsDead;
blockButton.OnClick = (button) =>
{
button.ActivateEffect();
};
blockButton.OnEffectStart = (button) =>
{
acTokenChallenge!.Value.count = 0;
RpcSetBlock.Invoke((MyPlayer.PlayerId, true));
};
blockButton.OnEffectEnd = (button) =>
{
RpcSetBlock.Invoke((MyPlayer.PlayerId, false));
button.StartCoolDown();
};
blockButton.CoolDownTimer = Bind(new Timer(BlockCoolDownOption).SetAsAbilityCoolDown().Start());
blockButton.EffectTimer = Bind(new Timer(BlockDurationOption));
blockButton.SetLabelType(Virial.Components.ModAbilityButton.LabelType.Standard);
blockButton.SetLabel("block");
}
}

void RuntimeAssignable.OnInactivated()
{
RpcSetBlock.Invoke((MyPlayer.PlayerId, false));
}

[OnlyMyPlayer]
void CheckKill(PlayerCheckKillEvent ev)
{
//ev.Result = KillResult.Guard;
//return;
//Debug.Log($"{ev.Killer.PlayerId} {MyPlayer.PlayerId}");
if (ev.IsMeetingKill || ev.EventDetail == EventDetail.Curse) return;
if (ev.Killer.PlayerId == MyPlayer.PlayerId) return;
bool temp;
//Debug.Log(result.ToString());
ev.Result = (BlockMurderingTab.TryGetValue(ev.Player.PlayerId, out temp) && temp) ? KillResult.Guard : KillResult.Kill;
}

[OnlyMyPlayer]
void OnGuard(PlayerGuardEvent ev)
{
if (AmOwner)
{
Debug.Log("OnGuard");
new StaticAchievementToken("knight.common1");
new StaticAchievementToken("knight.common2");
acTokenChallenge!.Value.count++;
if (acTokenChallenge!.Value.count >= 3)
{
acTokenChallenge!.Value.cleared = true;
}
}
}
}
private static readonly RemoteProcess<(byte playerId, bool status)> RpcSetBlock = new(
"SetBlock", (message, _) =>
{
Instance.BlockMurderingTab[message.playerId] = message.status;
});
}
28 changes: 23 additions & 5 deletions NebulaPluginNova/Roles/Crewmate/Oracle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ namespace Nebula.Roles.Crewmate;

public class Oracle : DefinedRoleTemplate, HasCitation, DefinedRole
{
private Oracle() : base("oracle", new(254, 156, 45), RoleCategory.CrewmateRole, Crewmate.MyTeam, [OracleCoolDownOption, NumOfInfoOption]) { }
private Oracle() : base("oracle", new(254, 156, 45), RoleCategory.CrewmateRole, Crewmate.MyTeam, [OracleCoolDownOption, OracleDurationOption, NumOfInfoOption]) { }
Citation? HasCitation.Citaion => Citations.NebulaOnTheShip_Old;

RuntimeRole RuntimeAssignableGenerator<RuntimeRole>.CreateInstance(Virial.Game.Player player, int[] arguments) => new Instance(player);

private static FloatConfiguration OracleCoolDownOption = NebulaAPI.Configurations.Configuration("options.role.oracle.oracleCoolDown", (5f, 60f, 2.5f), 20f, FloatConfigurationDecorator.Second);
private static FloatConfiguration OracleDurationOption = NebulaAPI.Configurations.Configuration("options.role.oracle.oracleDuration", (0f, 5f, 0.5f), 1.5f, FloatConfigurationDecorator.Second);
private static IntegerConfiguration NumOfInfoOption = NebulaAPI.Configurations.Configuration("options.role.oracle.numOfInfo", (3, 10), 4);

public static Oracle MyRole = new Oracle();
Expand All @@ -30,6 +31,7 @@ public Instance(Virial.Game.Player player) : base(player)
private Dictionary<byte, string> oracleResults = new();
private TMPro.TextMeshPro message = null!;
private float duration = 0f;
private byte targetId = byte.MaxValue;

void RuntimeAssignable.OnActivated()
{
Expand All @@ -42,6 +44,7 @@ void RuntimeAssignable.OnActivated()
this.message.gameObject.SetActive(false);
duration = 0f;
Bind(new GameObjectBinding(message.gameObject));
targetId = byte.MaxValue;

var myTracker = Bind(ObjectTrackers.ForPlayer(null, MyPlayer, (p) => ObjectTrackers.StandardPredicate(p)));
var oracleButton = Bind(new ModAbilityButton()).KeyBind(Virial.Compat.VirtualKeyInput.Ability);
Expand All @@ -51,15 +54,29 @@ void RuntimeAssignable.OnActivated()
oracleButton.Visibility = (button) => !MyPlayer.IsDead;
oracleButton.OnClick = (button) =>
{
button.ActivateEffect();
};
oracleButton.OnEffectStart = (button) =>
{
targetId = myTracker.CurrentTarget!.PlayerId;
};
oracleButton.OnEffectEnd = (button) =>
{
if ((myTracker.CurrentTarget?.PlayerId ?? byte.MaxValue) != targetId)
{
targetId = byte.MaxValue;
return;
}
string info;
if(!oracleResults.TryGetValue(myTracker.CurrentTarget!.PlayerId, out info!))
if (!oracleResults.TryGetValue(myTracker.CurrentTarget!.PlayerId, out info!))
{
info = GetInfomation(myTracker.CurrentTarget!, NumOfInfoOption).TrimEnd(' ').TrimEnd(',');
oracleResults.Add(myTracker.CurrentTarget!.PlayerId, info);
new StaticAchievementToken("oracle.common2");
}else info = oracleResults[myTracker.CurrentTarget!.PlayerId];
}
else info = oracleResults[myTracker.CurrentTarget!.PlayerId];
string message = Language.Translate("role.oracle.message").Replace("%PLAYER%",myTracker.CurrentTarget.Name).Replace("%DETAIL%",info);
string message = Language.Translate("role.oracle.message").Replace("%PLAYER%", myTracker.CurrentTarget.Name).Replace("%DETAIL%", info);
this.message.text = message;
this.message.gameObject.SetActive(true);
Debug.LogWarning($"Message: {message}\nMessage.IsActive: {this.message.gameObject.active}");
Expand All @@ -68,7 +85,8 @@ void RuntimeAssignable.OnActivated()
new StaticAchievementToken("oracle.common1");
button.StartCoolDown();
};
oracleButton.CoolDownTimer = Bind(new Timer(OracleCoolDownOption).Start());
oracleButton.CoolDownTimer = Bind(new Timer(OracleCoolDownOption).SetAsAbilityCoolDown().Start());
oracleButton.EffectTimer = Bind(new Timer(OracleDurationOption));
oracleButton.SetLabelType(Virial.Components.ModAbilityButton.LabelType.Standard);
oracleButton.SetLabel("oracle");
}
Expand Down
4 changes: 4 additions & 0 deletions NebulaPluginNova/Roles/Impostor/Camouflager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ void OnPlayerMurdered(PlayerMurderedEvent ev)
if (AmOwner && acTokenChallenge != null) acTokenChallenge.Value.killed++;
}

void RuntimeAssignable.OnInactivated()
{
RpcCamouflage.Invoke(new(MyPlayer.PlayerId, false));
}
}

private static NetworkedPlayerInfo.PlayerOutfit CamouflagerOutfit = new() { PlayerName = "", ColorId = 16, HatId = "hat_NoHat", SkinId = "skin_None", VisorId = "visor_EmptyVisor", PetId= "pet_EmptyPet" };
Expand Down
2 changes: 1 addition & 1 deletion NebulaPluginNova/Roles/Impostor/EvilAce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class EvilAce : DefinedRoleTemplate, HasCitation, DefinedRole

RuntimeRole RuntimeAssignableGenerator<RuntimeRole>.CreateInstance(GamePlayer player, int[] arguments) => new Instance(player);

private static FloatConfiguration killCoolDownOption = NebulaAPI.Configurations.Configuration("options.role.evilAce.killCoolDown", (0.125f, 1f, 0.125f), 0.75f);
private static FloatConfiguration killCoolDownOption = NebulaAPI.Configurations.Configuration("options.role.evilAce.killCoolDown", (0.125f, 1f, 0.125f), 0.75f, FloatConfigurationDecorator.Ratio);

public static EvilAce MyRole = new EvilAce();

Expand Down
1 change: 1 addition & 0 deletions NebulaPluginNova/Roles/Neutral/SchrödingersCat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private SchrödingersCat(int categoryId) : base("schrödingersCat" + adds.Get(ca
bool AssignableFilterHolder.CanLoadDefault(DefinedAssignable assignable) => CanLoadDefaultTemplate(assignable) && categoryId == 0;

bool IGuessed.CanBeGuessDefault => categoryId == 0;
bool DefinedAssignable.ShowOnHelpScreen => categoryId == 0;

RuntimeRole CheckAndCreateInstance(Virial.Game.Player player)
{
Expand Down

0 comments on commit 6a650ac

Please sign in to comment.