Closed Nahkranoth0 closed 2 years ago
Managed to fix this somewhat in a hacky way... So far it seems to works correctly for me now, except the immunity is re-applied on server rejoin / respawn. Not sure how to fix that part yet...
namespace ChatCommands.Commands
{
[Command("sunimmunity, sun", Usage = "sunimmunity", Description = "Makes you immune to the sun")]
public static class SunImmunity
{
public static void Initialize(Context ctx)
{
var component = ctx.EntityManager.GetComponentData<TakeDamageInSun>(ctx.Event.SenderCharacterEntity);
//if (component.SunDamageDisabled) component.ImmuneToSun.Value = false;
//else component.SunDamageDisabled = true;
if (component.SunDamageDisabled)
{
component.SunDamageDisabled = false;
component.ImmuneToSun.Value = false;
component.AlwaysInSun.Value = false;
}
else
{
component.SunDamageDisabled = true;
component.ImmuneToSun.Value = true;
}
ctx.EntityManager.SetComponentData(ctx.Event.SenderCharacterEntity, component);
string s = component.ImmuneToSun.Value ? "Activated" : "Deactivated";
ctx.Event.User.SendSystemMessage($"Sun Immunity <color=#ffff00ff>{s}</color>");
}
}
}
My newest version uses the temporary fix at the moment. Will have to see what I can do about it.
I was testing on my dedicated server the commands and tested the sunimmunity one. As soon as it did, i've had immunity to the sun, regardless if i logout or not.
Steps to reproduce:
Also, i've tried taking off the commands of the disabled section and running them again but it just disables for that session.
Even with the mod disabled, this stayed permanent.
I don't know how to revert this change...
Tested another situation: disabled the sunimmunity, got killed, then when respawning i got sunimmunity issue once again..