mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Hazel;
|
|
|
|
namespace EHR.Modules;
|
|
|
|
public static class PetsHelper
|
|
{
|
|
public static void RpcRemovePet(PlayerControl pc)
|
|
{
|
|
const string petId = "";
|
|
if (!GameStates.IsInGame || !Options.RemovePetsAtDeadPlayers.GetBool() || !pc || !pc.Data.IsDead || pc.IsAlive() || pc.CurrentOutfit.PetId == petId) return;
|
|
|
|
SetPet(pc, petId);
|
|
}
|
|
|
|
public static void SetPet(PlayerControl pc, string petId)
|
|
{
|
|
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla && !string.IsNullOrWhiteSpace(petId))
|
|
{
|
|
pc.RpcChangePet(petId);
|
|
return;
|
|
}
|
|
|
|
var sender = CustomRpcSender.Create("PetsHelper.SetPet", SendOption.Reliable);
|
|
|
|
try { pc.SetPet(petId); }
|
|
catch { }
|
|
|
|
try { pc.Data.DefaultOutfit.PetSequenceId += 10; }
|
|
catch { }
|
|
|
|
sender.AutoStartRpc(pc.NetId, RpcCalls.SetPetStr)
|
|
.Write(petId)
|
|
.Write(pc.GetNextRpcSequenceId(RpcCalls.SetPetStr))
|
|
.EndRpc();
|
|
|
|
sender.SendMessage();
|
|
}
|
|
|
|
public static string GetPetId()
|
|
{
|
|
try
|
|
{
|
|
string[] pets = Options.PetToAssign;
|
|
string pet = pets[Options.PetToAssignToEveryone.GetValue()];
|
|
string petId = pet == "pet_RANDOM_FOR_EVERYONE" ? pets[IRandom.Instance.Next(0, pets.Length - 1)] : pet;
|
|
return string.IsNullOrWhiteSpace(petId) ? "pet_test" : petId;
|
|
}
|
|
catch { return "pet_test"; }
|
|
}
|
|
} |