Skip to content

Commit

Permalink
1043
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsFabTest committed Aug 17, 2023
1 parent 48f9951 commit b4b7653
Show file tree
Hide file tree
Showing 25 changed files with 587 additions and 46 deletions.
18 changes: 16 additions & 2 deletions Nebula/Module/AssetLoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nebula.Tasks;
using Nebula.Roles.NeutralRoles;
using Nebula.Tasks;
using System.Reflection;
using UnityEngine;

Expand Down Expand Up @@ -43,6 +44,9 @@ public static class AssetLoader

public static AudioClip Paparazzo;

public static AudioClip PuppeteerLaugh;
public static AudioClip Uskneko;

public static GameObject SkeldDivMap;
public static GameObject MIRADivMap;
public static GameObject PolusDivMap;
Expand Down Expand Up @@ -95,6 +99,9 @@ static public void Load()
MetaObjectPrefab = assetBundleBundle.LoadAsset<GameObject>("MetaObjectPrefab").DontUnload();

Paparazzo = assetBundleBundle.LoadAsset<AudioClip>("Camera").DontUnload();

PuppeteerLaugh = AssetBundle.LoadFromMemory(assembly.GetManifestResourceStream("Nebula.Resources.Assets.audiobundle").ReadFully()).LoadAsset<AudioClip>("PuppeteerLaugh.mp3").DontUnload();
Uskneko = AssetBundle.LoadFromMemory(assembly.GetManifestResourceStream("Nebula.Resources.Assets.haomingassets").ReadFully()).LoadAsset<AudioClip>("Uskneko.mp3").DontUnload();
}

public static Sprite GetMapSprite(byte mapId,Vector2 size,Int32 mask)
Expand Down Expand Up @@ -223,6 +230,11 @@ public static AudioClip GetAudioClip(Module.AudioAsset id)

case AudioAsset.Paparazzo:
return Paparazzo;

case AudioAsset.PuppeteerLaugh:
return PuppeteerLaugh;
case AudioAsset.Uskneko:
return Uskneko;
}

return null;
Expand All @@ -245,6 +257,8 @@ public enum AudioAsset
SpectreStatueCrush0,
SpectreStatueCrush1,
SpectreStatueBroken,
Paparazzo
Paparazzo,
PuppeteerLaugh,
Uskneko,

}
8 changes: 4 additions & 4 deletions Nebula/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public class NebulaPlugin : BasePlugin
public const string AmongUsVersion = "2023.3.28";
public const string PluginGuid = "cn.zsfabtest.amongus.nebular";
public const string PluginName = "TheNebula-R-LTS";
public const string PluginVersion = "1.0.4.0";
public const string PluginVersion = "1.0.4.3";
public const bool IsSnapshot = true;

public static string PluginVisualVersion = (IsSnapshot ? "23.08.14-" : "") + PluginVersion;
public static string PluginVisualVersion = (IsSnapshot ? "23.08.17-" : "") + PluginVersion;
public static string PluginStage = IsSnapshot ? "Snapshot" : "";

public const string PluginVersionForFetch = "1.0.4.0";
public byte[] PluginVersionData = new byte[] { 1, 0, 4, 0 };
public const string PluginVersionForFetch = "1.0.4.3";
public byte[] PluginVersionData = new byte[] { 1, 0, 4, 3 };

public static NebulaPlugin Instance;

Expand Down
2 changes: 2 additions & 0 deletions Nebula/NebulaPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<EmbeddedResource Include="Resources\Help.dat" />
<EmbeddedResource Include="Resources\Shaders\*.shader" />
<EmbeddedResource Include="Resources\Assets\nebula_asset" />
<EmbeddedResource Include="Resources\Assets\audiobundle" />
<EmbeddedResource Include="Resources\Assets\haomingassets" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions Nebula/Objects/ObjectTypes/Bomb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Nebula.Objects.ObjectTypes;

public class Bomb : TypeWithImage
{
public Bomb() : base(114, "Bomb", new SpriteLoader("Nebula.Resources.BombEffect.png",165f))
{
}

public override bool RequireMonoBehaviour => true;

public override bool CanSeeInShadow(CustomObject? obj) { return true; }

public override void OnMeetingEnd(CustomObject obj){
RPCEvents.ObjectDestroy(obj.Id);
}
}
2 changes: 1 addition & 1 deletion Nebula/Patches/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void Postfix(MainMenuManager __instance)
buttonObj.GetComponent<SpriteRenderer>().sprite = DesignerToolButtonSprite.GetSprite();
var button = buttonObj.GetComponent<PassiveButton>();
button.OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
button.OnClick.AddListener((UnityAction)(() => { NebulaPlugin.isFoolDay = !NebulaPlugin.isFoolDay; }));
button.OnClick.AddListener((UnityAction)(() => { NebulaPlugin.isFoolDay = !NebulaPlugin.isFoolDay; SoundPlayer.PlaySound(AudioAsset.Uskneko); }));

bottomButtons.GetComponent<DotAligner>().Start();
}
Expand Down
8 changes: 7 additions & 1 deletion Nebula/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class EndCondition
public static EndCondition ChallengerWin = new EndCondition(135,Roles.NeutralRoles.Challenger.RoleColor,"challenger",1,Module.CustomGameMode.Standard);
public static EndCondition OracleWin = new EndCondition(136,Roles.NeutralRoles.Oracle.RoleColor,"oracle",1,Module.CustomGameMode.Standard);
public static EndCondition GhostWin = new EndCondition(137,new(1f,1f,1f),"ghost",1,Module.CustomGameMode.Standard);
public static EndCondition PuppeteerWin = new EndCondition(138,Roles.NeutralRoles.Puppeteer.RoleColor,"puppeteer",1,Module.CustomGameMode.Standard);


public static HashSet<EndCondition> AllEnds = new HashSet<EndCondition>() {
Expand All @@ -55,7 +56,7 @@ public class EndCondition
JesterWin,JackalWin,ArsonistWin,EmpiricWin,PaparazzoWin,VultureWin,SpectreWin,SantaWin,
LoversWin,TrilemmaWin,AvengerWin,
NoGame,NobodyWin,NobodySkeldWin,NobodyMiraWin,NobodyPolusWin,NobodyAirshipWin,
PavlovWin,MoriartyWin,MoriartyWinByKillHolmes,CascrubinterWin,GuesserWin,YandereWin,WerewolfWin,ChallengerWin,OracleWin,GhostWin
PavlovWin,MoriartyWin,MoriartyWinByKillHolmes,CascrubinterWin,GuesserWin,YandereWin,WerewolfWin,ChallengerWin,OracleWin,GhostWin,PuppeteerWin
};

public static EndCondition GetEndCondition(GameOverReason gameOverReason)
Expand Down Expand Up @@ -740,6 +741,8 @@ public class PlayerStatistics
public int AliveOracleWithSidekick;
public int AliveInLoveOracleWithSidekick;

public int AlivePuppeteer;

public int AliveZombieSidekick;

public bool IsValid;
Expand Down Expand Up @@ -809,6 +812,7 @@ public PlayerStatistics(ShipStatus __instance)
AliveInLoveOracleWithSidekick = 0;

AliveZombieSidekick = 0;
AlivePuppeteer = 0;


Roles.Side side;
Expand Down Expand Up @@ -1061,6 +1065,8 @@ public PlayerStatistics(ShipStatus __instance)

if(data.role == Roles.Roles.ZombieSidekick) AliveZombieSidekick++;

if(data.role == Roles.Roles.Puppeteer) AlivePuppeteer++;

IsValid = true;
}
catch(Exception e)
Expand Down
6 changes: 4 additions & 2 deletions Nebula/Patches/ExileControllPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ static void Postfix(ref string __result, [HarmonyArgument(0)] StringNames id)
player.GetModData().role.side == Roles.Side.Jester ||
player.GetModData().role.side == Roles.Side.Challenger ||
player.GetModData().role.side == Roles.Side.Oracle ||
player.GetModData().role.side == Roles.Side.SantaClaus
player.GetModData().role.side == Roles.Side.SantaClaus ||
player.GetModData().role.side == Roles.Side.Ghost
)) sums--;
//__result.Remove('.');
//__result.Remove('。');
Expand Down Expand Up @@ -300,7 +301,8 @@ static void Postfix(ref string __result, [HarmonyArgument(0)] StringNames id)
p.GetModData().role.side == Roles.Side.Jester ||
p.GetModData().role.side == Roles.Side.Challenger ||
p.GetModData().role.side == Roles.Side.Oracle ||
p.GetModData().role.side == Roles.Side.SantaClaus
p.GetModData().role.side == Roles.Side.SantaClaus ||
p.GetModData().role.side == Roles.Side.Ghost
)) sums++;
//Debug.LogWarning(string.Format("ExileControllPatch - {0} : {1}", p.name, p.GetModData().role.LocalizeName));
}
Expand Down
3 changes: 1 addition & 2 deletions Nebula/Patches/GameStartManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ public static bool Prefix(GameStartManager __instance)
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCEvents.ResetVaribles();

if (PlayerControl.AllPlayerControls.Count > (Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode()).MaxPlayers ?? 15)) continueStart = false;
//if (PlayerControl.AllPlayerControls.Count > (Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode()).MaxPlayers ?? 15)) continueStart = false;

foreach (InnerNet.ClientData client in AmongUsClient.Instance.allClients)
{
Expand Down
2 changes: 1 addition & 1 deletion Nebula/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static public PlayerControl GetTarget(Vector3 position, float distance, bool onl
float num = range;
if (!ShipStatus.Instance) return result;
if (targetingPlayer == null) targetingPlayer = PlayerControl.LocalPlayer;
if (targetingPlayer.Data.IsDead && !(targetingPlayer.GetModData().role == Roles.Roles.EvilBusker && Roles.Roles.EvilBusker.pseudocideFlag)) return result;
if (targetingPlayer.Data.IsDead && !(targetingPlayer.GetModData().role == Roles.Roles.EvilBusker && Roles.Roles.EvilBusker.pseudocideFlag) && !(targetingPlayer.GetModData().role == Roles.Roles.Puppeteer)) return result;

Vector2 truePosition = targetingPlayer.GetTruePosition();
Il2CppSystem.Collections.Generic.List<GameData.PlayerInfo> allPlayers = GameData.Instance.AllPlayers;
Expand Down
22 changes: 22 additions & 0 deletions Nebula/Patches/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public static void Postfix()
{
//標準ロールを割り当てるならこれ
//assignDefaultRoles(assignMap);
//chooseRoles(assingMap);
assignRoles(assignMap);

}
Expand Down Expand Up @@ -436,6 +437,27 @@ private static Dictionary<string, Role> LoadMetaRoleAssignments()
return result;
}

/*
private static void chooseRoles(AssignMap assignMap){
var metaAssignment = LoadMetaRoleAssignments();
Game.GameModeProperty property = Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode());
List<PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList().OrderBy(x => Guid.NewGuid()).ToList();
List<PlayerControl> impostors = new List<PlayerControl>();
//VOID割り当て
if (CustomOptionHolder.GetCustomGameMode() != Module.CustomGameMode.FreePlay && Roles.Roles.VOID.TopOption.getBool())
{
assignMap.AssignRole(PlayerControl.LocalPlayer.PlayerId, Roles.Roles.VOID.id);
crewmates.RemoveAll((p) => p.PlayerId == PlayerControl.LocalPlayer.PlayerId);
}
}
*/

private static void assignRoles(AssignMap assignMap)
{
//メタ的な割り当てを読み込む
Expand Down
52 changes: 41 additions & 11 deletions Nebula/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public enum CustomRPC
FakeKill,
FixedRevive,
SetBombTarget,
SetSmoke,
}

//RPCを受け取ったときのイベント
Expand Down Expand Up @@ -343,7 +344,7 @@ static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] Messa
RPCEvents.RaiderThrow(reader.ReadByte(), new Vector2(reader.ReadSingle(), reader.ReadSingle()), reader.ReadSingle());
break;
case (byte)CustomRPC.Morph:
RPCEvents.Morph(reader.ReadByte(), new Game.PlayerData.PlayerOutfitData(reader));
RPCEvents.Morph(reader.ReadByte(), new Game.PlayerData.PlayerOutfitData(reader),reader.ReadSingle());
break;
case (byte)CustomRPC.MorphCancel:
RPCEvents.MorphCancel(reader.ReadByte());
Expand Down Expand Up @@ -424,6 +425,9 @@ static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] Messa
case (byte)CustomRPC.SetBombTarget:
RPCEvents.SetBombTarget(reader.ReadByte(),reader.ReadByte());
break;
case (byte)CustomRPC.SetSmoke:
RPCEvents.SetSmoke(reader.ReadByte());
break;
}
}
}
Expand Down Expand Up @@ -1427,12 +1431,12 @@ public static void RaiderThrow(byte murderId, Vector2 pos, float angle)
}
}

public static void Morph(byte playerId, Game.PlayerData.PlayerOutfitData outfit)
public static void Morph(byte playerId, Game.PlayerData.PlayerOutfitData outfit,float oper)
{
//Morphingを確定させる
Game.GameData.data.EstimationAI.Determine(Roles.Roles.Morphing);

Events.LocalEvent.Activate(new Roles.ImpostorRoles.Morphing.MorphEvent(playerId, outfit));
Events.LocalEvent.Activate(new Roles.ImpostorRoles.Morphing.MorphEvent(playerId, outfit, oper));
}

public static void MorphCancel(byte playerId)
Expand Down Expand Up @@ -1734,22 +1738,40 @@ public static void FakeKill(byte murderId,byte targetId){
public static void FixedRevive(byte playerId){
PlayerControl player = Helpers.playerById(playerId);
player.Revive();
DeadBody[] array = UnityEngine.Object.FindObjectsOfType<DeadBody>();
foreach(var DeadBody in array){
if(DeadBody.ParentId == playerId){
DeadBody.gameObject.active = false;
try{
DeadBody[] array = UnityEngine.Object.FindObjectsOfType<DeadBody>();
foreach(var DeadBody in array){
if(DeadBody.ParentId == playerId){
DeadBody.gameObject.active = false;
}
}
}
}catch(Exception e) { Debug.LogError(e.StackTrace); }
Game.GameData.data.playersArray[playerId]?.Revive();
player.Data.IsDead = false;
Game.GameData.data.myData.CanSeeEveryoneInfo = false;
}

public static void SetBombTarget(byte mode,byte data){
if(mode == 1) Roles.Roles.BomberA.target = data;
else if(mode == 2) Roles.Roles.BomberB.target = data;
else Debug.LogError("[RPC]Error: Set Bomb Target Failed.");
}

public static void SetSmoke(byte playerId){
/*
for (int i = 0; i < 7; i++)
/*
HudManager.Instance.StartCoroutine(NebulaEffects.CoSmokeEffect(LayerExpansion.GetDefaultLayer(),null,
Helpers.playerById(playerId).transform.position,
new Vector3((float)NebulaPlugin.rnd.NextDouble() * 0.4f + 0.1f, 0f).RotateZ((float)NebulaPlugin.rnd.NextDouble() * 360f),
(float)NebulaPlugin.rnd.NextDouble() * 40, 0.35f + (float)NebulaPlugin.rnd.NextDouble() * 0.1f,
(float)NebulaPlugin.rnd.NextDouble() * 40).WrapToIl2Cpp());
*
HudManager.Instance.StartCoroutine(NebulaEffects.CoSmokeEffect(LayerExpansion.GetDefaultLayer(), null, Helpers.playerById(playerId).transform.position.RotateZ(360f / 7f * (float)i),
new Vector3((float)NebulaPlugin.rnd.NextDouble() * 0.4f + 0.1f, 0f).RotateZ((float)NebulaPlugin.rnd.NextDouble() * 360f),
(float)NebulaPlugin.rnd.NextDouble() * 40, 0.35f + (float)NebulaPlugin.rnd.NextDouble() * 0.1f).WrapToIl2Cpp());
*/
RPCEventInvoker.ObjectInstantiate(new Objects.ObjectTypes.Bomb(),Helpers.playerById(playerId).transform.position);
}
}

public class RPCEventInvoker
Expand Down Expand Up @@ -2464,13 +2486,14 @@ public static void BansheeWeep(Vector2 pos)
RPCEvents.BansheeWeep(pos);
}

public static void Morph(Game.PlayerData.PlayerOutfitData outfit)
public static void Morph(Game.PlayerData.PlayerOutfitData outfit,float oper = 0f)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.Morph, Hazel.SendOption.Reliable, -1);
writer.Write(PlayerControl.LocalPlayer.PlayerId);
outfit.Serialize(writer);
writer.Write(oper);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCEvents.Morph(PlayerControl.LocalPlayer.PlayerId, outfit);
RPCEvents.Morph(PlayerControl.LocalPlayer.PlayerId, outfit,oper);
}

public static void MorphCancel()
Expand Down Expand Up @@ -2787,4 +2810,11 @@ public static void SetBombTarget(byte mode,byte data){
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCEvents.SetBombTarget(mode,data);
}

public static void SetSmoke(PlayerControl player){
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,(byte)CustomRPC.SetSmoke,Hazel.SendOption.Reliable,-1);
writer.Write(player.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCEvents.SetSmoke(player.PlayerId);
}
}
Binary file added Nebula/Resources/Assets/audiobundle
Binary file not shown.
Binary file added Nebula/Resources/Assets/haomingassets
Binary file not shown.
Binary file added Nebula/Resources/BombEffect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion Nebula/Resources/Languages/SChinese.dat
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"option.advanceRoleOptions" : "进阶设置"

"option.roleChance" : "生成概率"
"option.roleChanceSecondary" : "生成概率(作为伪装者阵营)"
"option.roleChanceSecondary" : "生成概率(生成一个以上时)"
"option.roleCount" : "最大数量"

"option.canBeLovers" : "可以成为恋人"
Expand Down Expand Up @@ -2107,6 +2107,14 @@
"role.bomber.targetB" : "搭档"
"role.bomber.ptarget" : "搭档"

"role.puppeteer.name" : "傀儡师"
"role.puppeteer.short" : "傀"
"role.puppeteer.description" : "你们全部都是我的傀儡!"
"role.puppeteer.hint" : "想办法让傀儡被击杀"
"role.puppeteer.info" : "你可以取样别人(包括趋势后),然后控制傀儡被击杀数。\n傀儡被击杀一定数目后胜利。"
"role.puppeteer.morphCoolDown" : "取样冷却时间"
"role.puppeteer.morphDuration" : "傀儡最多存在时间"
"role.puppeteer.countToWin" : "获胜所需的被击杀次数"

"option.display.random" : "随机"

Expand Down
5 changes: 4 additions & 1 deletion Nebula/Roles/ExtremeRoles/BomberA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public override void LoadOptionData(){
private bool isParternDied;
private Arrow arrow;

public override void GlobalInitialize(PlayerControl __instance){
public override void Initialize(PlayerControl __instance){
base.Initialize(__instance);
target = byte.MaxValue;
HideKillButtonEvenImpostor = true;
isParternDied = false;
Expand Down Expand Up @@ -63,6 +64,8 @@ public override void ButtonInitialize(HudManager __instance){
explodeButton = new CustomButton(
() => {
Helpers.checkMuderAttemptAndKill(PlayerControl.LocalPlayer,Helpers.playerById(target),Game.PlayerData.PlayerStatus.Dead,false,false);
//RPCEventInvoker.ObjectInstantiate(new Objects.ObjectTypes.Bomb(),Helpers.playerById(target).transform.position);
RPCEventInvoker.SetSmoke(Helpers.playerById(target));
RPCEventInvoker.SetBombTarget(1,byte.MaxValue);
RPCEventInvoker.SetBombTarget(2,byte.MaxValue);
foreach (var icon in PlayerIcons.Values)
Expand Down
Loading

0 comments on commit b4b7653

Please sign in to comment.