-
Notifications
You must be signed in to change notification settings - Fork 176
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
Fixed Event StartingRecallEventArgs's IsAllowed issue. #2226
Conversation
* Added ChaosTargetCount * a * Updated * Fix build errors --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>
Grammar fixes. This includes fixing multiple it's to its, removal of unnecessary commas, and removal of redundancies.
Now the IsAllowed will work as what it should be.
The part of
currently will lead into crash , dont merge before if i can fix this bug.Another option is to give up acquiring Target players, although I know this is not realistic, lol |
this will also be call for Scp0492 'RagdollAbilityBase' |
yes , that is what the arg used for.Actually it will be call by Scp3114, but to doing limits on the Player , then it can be avoided. |
The problem about previous patch's By using using System;
using Exiled.API.Features;
using PlayerRoles;
using System.Linq;
using Exiled.Events.EventArgs.Scp049;
using LimitZombie.Events.EventArgs.Scp049;
using static PlayerRoles.PlayableScps.Scp049.Zombies.ZombieAudioPlayer;
namespace LimitZombie
{
public class ResurrectHandler
{
public static void ShowMessageOnConsole(int playerCount, int zombieCount, bool IsAllowed, bool IsMaxed)
{
int Limit;
if (IsMaxed)
{
CalcLimit(playerCount, out Limit);
Log.Info($"SCP-049-2 count is {zombieCount}.Max {Limit} Event blocked.");
Log.Info("Executed branch 2.");
Log.Info($"Current Flag: {IsAllowed}");
}
else
{
CalcLimit(playerCount, out Limit);
Log.Info($"SCP-049-2 count is {zombieCount}.Max {Limit} Event is not blocked.");
Log.Info("Executed branch 1.");
Log.Info($"Current Flag: {IsAllowed}");
}
}
public static void CalcLimit(int count, out int limit)
{
limit = (int)Math.Round(count * 2.0 / 3.0);
}
public static void OnResurrect(StartingRecallEventArgsMod ev)
{
Log.Info($"ev type: {ev.GetType().FullName}");
Log.Info($"ev.IsAllowed: {ev?.IsAllowed}");
Log.Info($"ev.Player: {ev?.Player}");
Log.Info($"ev.Ragdoll: {ev?.Ragdoll}");
Player player = ev.Player;
Player target = ev.Ragdoll.Owner ?? null;
Log.Info($"Executed Player: {player}");
Log.Info($"Target Player: {target}");
Log.Info($"Entering OnResurrect. Initial IsAllowed: {ev.IsAllowed}");
if (player.Role.Type == RoleTypeId.Scp049)
{
bool Test = true;
if (Test)
{
int scp0492Count = Player.List.Count(player => player.Role == RoleTypeId.Scp0492);
int playerList = Player.List.Count;
int scpList = Player.List.Count(player => player.Role.Type == RoleTypeId.Scp049 || player.Role.Type == RoleTypeId.Scp096 || player.Role.Type == RoleTypeId.Scp106 || player.Role.Type == RoleTypeId.Scp3114 || player.Role.Type == RoleTypeId.Scp173 || player.Role.Type == RoleTypeId.Scp939 || player.Role.Type == RoleTypeId.Scp096);
int playerCount = playerList - scpList;
int Limit;
CalcLimit(playerCount, out Limit);
string msg = $"本局非SCP人数:{playerCount},本局最多可同时存在{Limit}个小僵尸。目前小僵尸数量:{scp0492Count}。";
Log.Info($"Entering Method OnResurrect");
if (scp0492Count == Limit)
{
Log.Info("Event is now Blocked.");
player.Broadcast(5, msg, Broadcast.BroadcastFlags.Normal, true);
ShowMessageOnConsole(playerCount, scp0492Count, ev.IsAllowed, true);
ev.IsAllowed = false;
}
else
{
Log.Info("Event is not Blocked.");
player.Broadcast(5, msg, Broadcast.BroadcastFlags.Normal, true);
ShowMessageOnConsole(playerCount, scp0492Count, ev.IsAllowed, false);
ev.IsAllowed = true;
}
}
else
{
int scp0492Count = Player.List.Count(player => player.Role == RoleTypeId.Scp0492);
int playerList = Player.List.Count;
int scpList = Player.List.Count(player => player.Role.Type == RoleTypeId.Scp049 || player.Role.Type == RoleTypeId.Scp096 || player.Role.Type == RoleTypeId.Scp106 || player.Role.Type == RoleTypeId.Scp3114 || player.Role.Type == RoleTypeId.Scp173 || player.Role.Type == RoleTypeId.Scp939 || player.Role.Type == RoleTypeId.Scp096);
int playerCount = playerList - scpList;
int Limit;
CalcLimit(playerCount, out Limit);
string msg = $"本局非SCP人数:{playerCount},本局最多可同时存在{Limit}个小僵尸。目前小僵尸数量:{scp0492Count}。";
player.Broadcast(5, msg, Broadcast.BroadcastFlags.Normal, true);
ShowMessageOnConsole(playerCount, scp0492Count, ev.IsAllowed, false);
ev.IsAllowed = true;
}
}
Log.Info($"Exiting OnResurrect. Final IsAllowed: {ev.IsAllowed}");
}
}
} The event written by myself.I can get such info:
|
Transpiler can modify return value ??? |
uh , letme try that lol , forget its just stack |
Alright. now i've rewritten as Transpiler.And tested. |
Please target dev branch. |
/// <param name="isAllowed"> | ||
/// <inheritdoc cref="IsAllowed" /> | ||
/// </param> | ||
public StartingRecallEventArgsMod(Player player, Ragdoll ragdoll, bool isAllowed = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public StartingRecallEventArgsMod(Player player, Ragdoll ragdoll, bool isAllowed = true) | |
public StartingRecallEventArgs(Player player, Ragdoll ragdoll, bool isAllowed = true) |
OK I'll do it after i get up |
You will need to create a separate PR to prevent conflicts. |
StartingRecallEventArgs's IsAllowed won't stop the event. Patch at RagdollAbilityBase could solve this.