Upload from upload_mods.ps1
This commit is contained in:
3312
Harmony/Harmony_EntityAlive.cs
Normal file
3312
Harmony/Harmony_EntityAlive.cs
Normal file
@@ -0,0 +1,3312 @@
|
||||
using Audio;
|
||||
using GamePath;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using UAI;
|
||||
using UnityEngine;
|
||||
using static ItemActionRanged;
|
||||
using static RebirthManager;
|
||||
using static WeatherManager;
|
||||
|
||||
namespace Harmony.EntityAlive_FR
|
||||
{
|
||||
internal class EntityAlivePatches
|
||||
{
|
||||
/*private static void SetMaterials(EntityAlive __instance)
|
||||
{
|
||||
DynamicProperties properties = ((Entity)__instance).EntityClass?.Properties;
|
||||
if (!properties.Values.ContainsKey("TintColor") && !properties.Values.dic.Keys.Any<string>((Func<string, bool>)(k => k.StartsWith("TintMaterial"))))
|
||||
return;
|
||||
Renderer[] componentsInChildren = ((Component)((Entity)__instance).RootTransform)?.GetComponentsInChildren<Renderer>();
|
||||
if (componentsInChildren == null || componentsInChildren.Length == 0)
|
||||
return;
|
||||
List<Material> allMaterials = GetAllMaterials(componentsInChildren);
|
||||
string[] shaderProperties = ParseShaderProperties(properties, new char[1]);
|
||||
foreach (KeyValuePair<string, string> keyValuePair in properties.Values.dic)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(keyValuePair.Key) && keyValuePair.Key.StartsWith("TintMaterial"))
|
||||
{
|
||||
int sint32 = StringParsers.ParseSInt32(Regex.Match(keyValuePair.Key, "\\d+$").Value, 0, -1, NumberStyles.Integer);
|
||||
Color white = Color.white;
|
||||
properties.ParseColorHex(string.Format("{0}{1}", (object)"TintMaterial", (object)sint32), ref white);
|
||||
if (white != Color.white && sint32 < allMaterials.Count)
|
||||
{
|
||||
for (int index = 0; index < shaderProperties.Length; ++index)
|
||||
{
|
||||
Material material = allMaterials[sint32];
|
||||
if (material != null && material.HasColor(shaderProperties[index]))
|
||||
material.SetColor(shaderProperties[index], white);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!properties.Values.ContainsKey("TintColor"))
|
||||
return;
|
||||
Color white1 = Color.white;
|
||||
properties.ParseColorHex("TintColor", ref white1);
|
||||
foreach (Material material in allMaterials)
|
||||
{
|
||||
for (int index = 0; index < shaderProperties.Length; ++index)
|
||||
{
|
||||
if (material != null && material.HasColor(shaderProperties[index]))
|
||||
material.SetColor(shaderProperties[index], white1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Material> GetAllMaterials(Renderer[] renderers)
|
||||
{
|
||||
List<Material> allMaterials = new List<Material>();
|
||||
foreach (Material material in ((IEnumerable<Renderer>)renderers).SelectMany<Renderer, Material>((Func<Renderer, IEnumerable<Material>>)(r => (IEnumerable<Material>)r.materials)))
|
||||
allMaterials.Add(material);
|
||||
return allMaterials;
|
||||
}
|
||||
|
||||
private static string[] ParseShaderProperties(DynamicProperties props, char[] separator)
|
||||
{
|
||||
string empty = string.Empty;
|
||||
props.ParseString("TintShaderProperties", ref empty);
|
||||
return empty.Split(separator);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive))]
|
||||
[HarmonyPatch("Kill")]
|
||||
public class KillPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, DamageResponse _dmResponse)
|
||||
{
|
||||
SetMaterials(__instance);
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityAlive))]
|
||||
[HarmonyPatch("ConditionalTriggerSleeperWakeUp")]
|
||||
public class ConditionalTriggerSleeperWakeUpPatch
|
||||
{
|
||||
public static void Postfix(EntityAlive __instance)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$IsAIOff", 0f);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "SetDead")]
|
||||
public class SetDeadPatch
|
||||
{
|
||||
public static void Postfix(EntityAlive __instance)
|
||||
{
|
||||
__instance.SetMoveForwardWithModifiers(0.0f, 0.0f, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "IsAttackValid")]
|
||||
public class IsAttackValidPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, ref bool __result)
|
||||
{
|
||||
if (RebirthUtilities.HasBuffLike(__instance, "FuriousRamsayRangedStun") && !__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally")))
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "SetAttackTarget")]
|
||||
public class SetAttackTargetPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, EntityAlive _attackTarget, int _attackTargetTime)
|
||||
{
|
||||
if (_attackTarget is null)
|
||||
{
|
||||
__instance.attackTarget = null;
|
||||
__instance.attackTargetTime = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "GetLootList")]
|
||||
public class GetLootListPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, ref string __result)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge" && __instance is EntitySupplyCrate)
|
||||
{
|
||||
__result = "airDropPurge_" + RebirthUtilities.GetCurrentBiomePurgeProgression();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "CanEntityBeSeen")]
|
||||
public class CanEntityBeSeenPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, ref bool __result, Entity _other)
|
||||
{
|
||||
if (_other != null && !_other.IsAlive())
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "ClearInvestigatePosition")]
|
||||
public class ClearInvestigatePositionPatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance)
|
||||
{
|
||||
if (__instance is EntityZombieSDX zombie && zombie.wanderingHorde == 1)
|
||||
{
|
||||
Vector3 investigationPosition = RandomPositionGenerator.Calc(__instance, 50, 0);
|
||||
|
||||
float num2 = __instance.world.GetHeight((int)investigationPosition.x, (int)investigationPosition.z);
|
||||
float num3 = __instance.world.GetTerrainHeight((int)investigationPosition.x, (int)investigationPosition.z);
|
||||
investigationPosition.y = ((num2 + num3) / 2f) + 1.5f;
|
||||
|
||||
__instance.SetInvestigatePosition(investigationPosition, 6000, false);
|
||||
|
||||
////Log.Out("EntityAlivePatches-ClearInvestigatePosition set new investigation position");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityHuman), "GetMoveSpeedAggro")]
|
||||
public class GetMoveSpeedAggroPatch
|
||||
{
|
||||
public static bool Prefix(EntityHuman __instance, ref float __result,
|
||||
float ___moveSpeedRagePer
|
||||
)
|
||||
{
|
||||
EnumGamePrefs _eProperty = EnumGamePrefs.ZombieMove;
|
||||
|
||||
/*//Log.Out("EntityAlivePatches-GetMoveSpeed EnumGamePrefs.ZombieMove: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed EnumGamePrefs.ZombieMoveNight: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMoveNight)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed EnumGamePrefs.ZombieFeralMove: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieFeralMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed EnumGamePrefs.ZombieBMMove: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieBMMove)]);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed __instance.moveSpeedRagePer: " + __instance.moveSpeedRagePer);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE EnumGamePrefs.ZombieMove: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE EnumGamePrefs.ZombieMoveNight: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMoveNight)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE EnumGamePrefs.ZombieFeralMove: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieFeralMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE EnumGamePrefs.ZombieBMMove: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieBMMove)]);*/
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
_eProperty = EnumGamePrefs.ZombieBMMove;
|
||||
}
|
||||
else if (__instance.IsFeral)
|
||||
{
|
||||
_eProperty = EnumGamePrefs.ZombieFeralMove;
|
||||
}
|
||||
else if (__instance.world.IsDark())
|
||||
{
|
||||
_eProperty = EnumGamePrefs.ZombieMoveNight;
|
||||
}
|
||||
|
||||
int index = GamePrefs.GetInt(_eProperty);
|
||||
float num = EntityHuman.moveSpeeds[index];
|
||||
|
||||
float currentMovevalue = num;
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed num 1: " + num);
|
||||
|
||||
if ((double)__instance.moveSpeedRagePer > 1.0)
|
||||
{
|
||||
num = EntityHuman.moveSuperRageSpeeds[index];
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed num 2: " + num);
|
||||
}
|
||||
else if ((double)__instance.moveSpeedRagePer > 0.0)
|
||||
{
|
||||
float moveRageSpeed = EntityHuman.moveRageSpeeds[index];
|
||||
num = (float)((double)num * (1.0 - (double)___moveSpeedRagePer) + (double)moveRageSpeed * (double)___moveSpeedRagePer);
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed num 3: " + num);
|
||||
}
|
||||
|
||||
float newValue = 0;
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed FINAL num: " + num);
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed __instance.moveSpeedAggro: " + __instance.moveSpeedAggro);
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed __instance.moveSpeedAggroMax: " + __instance.moveSpeedAggroMax);
|
||||
|
||||
if (num >= 1)
|
||||
{
|
||||
newValue = __instance.moveSpeedAggroMax * num;
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed 1.0 - num: " + (1.0 - num));
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed __instance.moveSpeedAggro * (1.0 - num): " + (__instance.moveSpeedAggro * (1.0 - num)));
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed __instance.moveSpeedAggroMax * num: " + __instance.moveSpeedAggroMax * num);
|
||||
|
||||
newValue = (float)(__instance.moveSpeedAggro * (1.0 - num) + __instance.moveSpeedAggroMax * num);
|
||||
}
|
||||
|
||||
float baseSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)num >= 1.0 ? __instance.moveSpeedAggroMax * num : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)num) + (double)__instance.moveSpeedAggroMax * (double)num), _entity: (EntityAlive)__instance);
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed BASE SPEED [" + __instance.EntityClass.entityClassName + "]: " + baseSpeed);
|
||||
|
||||
float numNormalSpeed = EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMove)];
|
||||
float numNightSpeed = EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMoveNight)];
|
||||
float numFeralSpeed = EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieFeralMove)];
|
||||
float numBMSpeed = EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieBMMove)];
|
||||
|
||||
float resultingNormalSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)numNormalSpeed >= 1.0 ? __instance.moveSpeedAggroMax * numNormalSpeed : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)numNormalSpeed) + (double)__instance.moveSpeedAggroMax * (double)numNormalSpeed), _entity: (EntityAlive)__instance);
|
||||
float resultingNightSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)numNightSpeed >= 1.0 ? __instance.moveSpeedAggroMax * numNightSpeed : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)numNightSpeed) + (double)__instance.moveSpeedAggroMax * (double)numNightSpeed), _entity: (EntityAlive)__instance);
|
||||
float resultingFeralSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)numFeralSpeed >= 1.0 ? __instance.moveSpeedAggroMax * numFeralSpeed : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)numFeralSpeed) + (double)__instance.moveSpeedAggroMax * (double)numFeralSpeed), _entity: (EntityAlive)__instance);
|
||||
float resultingBMSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)numBMSpeed >= 1.0 ? __instance.moveSpeedAggroMax * numBMSpeed : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)numBMSpeed) + (double)__instance.moveSpeedAggroMax * (double)numBMSpeed), _entity: (EntityAlive)__instance);
|
||||
|
||||
float resultingSpeed = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)num >= 1.0 ? __instance.moveSpeedAggroMax * num : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)num) + (double)__instance.moveSpeedAggroMax * (double)num), _entity: (EntityAlive)__instance);
|
||||
|
||||
if (__instance is EntityZombieSDX)
|
||||
{
|
||||
/*//Log.Out("EntityAlivePatches-GetMoveSpeed night speed [" + __instance.EntityName + "]: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMoveNight)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed feral speed [" + __instance.EntityName + "]: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieFeralMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed blood moon speed [" + __instance.EntityName + "]: " + EntityHuman.moveSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieBMMove)]);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE night speed [" + __instance.EntityName + "]: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieMoveNight)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE feral speed [" + __instance.EntityName + "]: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieFeralMove)]);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed RAGE blood moon speed [" + __instance.EntityName + "]: " + EntityHuman.moveSuperRageSpeeds[GamePrefs.GetInt(EnumGamePrefs.ZombieBMMove)]);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed moveSpeedAggro [" + __instance.EntityName + "]: " + __instance.moveSpeedAggro);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed moveSpeedAggroMax [" + __instance.EntityName + "]: " + __instance.moveSpeedAggroMax);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed resultingNormalSpeed [" + __instance.EntityName + "]: " + resultingNormalSpeed);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed resultingNightSpeed [" + __instance.EntityName + "]: " + resultingNightSpeed);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed resultingFeralSpeed [" + __instance.EntityName + "]: " + resultingFeralSpeed);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeed resultingBMSpeed [" + __instance.EntityName + "]: " + resultingBMSpeed);*/
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed RESULT [" + __instance.EntityName + "]: " + resultingSpeed);
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight() && __instance.world.IsDark())
|
||||
{
|
||||
if (resultingFeralSpeed > resultingNightSpeed)
|
||||
{
|
||||
resultingSpeed = resultingFeralSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultingSpeed = resultingNightSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed PRE-END RESULT: " + resultingSpeed);
|
||||
|
||||
// Check settings and cap based on settings
|
||||
if (resultingSpeed > 1.8f)
|
||||
{
|
||||
resultingSpeed = 1.8f;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && __instance.world.IsDark() && !RebirthUtilities.IsHordeNight() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
if (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("zombie")) &&
|
||||
!(__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("feral")) ||
|
||||
__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("radiated")) ||
|
||||
__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("tainted")))
|
||||
)
|
||||
{
|
||||
resultingSpeed = EffectManager.GetValue(PassiveEffects.WalkSpeed, _originalValue: __instance.moveSpeedAggro, _entity: __instance);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
__result = resultingSpeed;
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetMoveSpeed END RESULT: " + resultingSpeed);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityHuman))]
|
||||
[HarmonyPatch("GetMoveSpeedAggro")]
|
||||
public class GetMoveSpeedAggroPatch
|
||||
{
|
||||
public static bool Prefix(EntityHuman __instance, ref float __result)
|
||||
{
|
||||
|
||||
|
||||
EnumGamePrefs _eProperty = EnumGamePrefs.ZombieMove;
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro _eProperty: " + _eProperty);
|
||||
|
||||
if (__instance.IsBloodMoon)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro BLOODMOON");
|
||||
_eProperty = EnumGamePrefs.ZombieBMMove;
|
||||
}
|
||||
else if (__instance.IsFeral)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro FERAL");
|
||||
_eProperty = EnumGamePrefs.ZombieFeralMove;
|
||||
}
|
||||
else if (__instance.world.IsDark())
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro NIGHT");
|
||||
_eProperty = EnumGamePrefs.ZombieMoveNight;
|
||||
}
|
||||
|
||||
int index = GamePrefs.GetInt(_eProperty);
|
||||
float num = EntityHuman.moveSpeeds[index];
|
||||
if ((double)__instance.moveSpeedRagePer > 1.0)
|
||||
{
|
||||
num = EntityHuman.moveSuperRageSpeeds[index];
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro num A: " + num);
|
||||
}
|
||||
else if ((double)__instance.moveSpeedRagePer > 0.0)
|
||||
{
|
||||
float moveRageSpeed = EntityHuman.moveRageSpeeds[index];
|
||||
num = (float)((double)num * (1.0 - (double)__instance.moveSpeedRagePer) + (double)moveRageSpeed * (double)__instance.moveSpeedRagePer);
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro num B: " + num);
|
||||
}
|
||||
__result = EffectManager.GetValue(PassiveEffects.RunSpeed, _originalValue: (double)num >= 1.0 ? __instance.moveSpeedAggroMax * num : (float)((double)__instance.moveSpeedAggro * (1.0 - (double)num) + (double)__instance.moveSpeedAggroMax * (double)num), _entity: (EntityAlive)__instance);
|
||||
|
||||
//Log.Out("EntityAlivePatches-GetMoveSpeedAggro __result: " + __result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "OnUpdateLive")]
|
||||
public class OnUpdateLiveLivePatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlive::OnUpdateLive Prefix 1 - this Entity: {__instance}, attackTarget: {__instance.attackTarget}");
|
||||
|
||||
RebirthUtilities.CheckSleeperActivated(__instance);
|
||||
|
||||
if (__instance is EntityZombie && __instance.emodel.IsRagdollActive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "PlayHitGroundSound")]
|
||||
public class PlayHitGroundSoundPatch
|
||||
{
|
||||
private static bool Prefix(EntityAlive __instance)
|
||||
{
|
||||
if (__instance.Buffs.GetCustomVar("onMission") == 1f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#region Code from Zilox to fix the animals animating on dedi when they do not have root motion.
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "OnUpdatePosition")]
|
||||
public class ReplicateMovementSpeedsPatch
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public class Patch
|
||||
{
|
||||
[HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(Entity), "ReplicateSpeeds")]
|
||||
public static void ReplicateSpeeds(Entity instance)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Prefix(EntityAlive __instance, float _partialTicks)
|
||||
{
|
||||
if (__instance is EntityTrader) return false; // why are we preventing traders from updating their position? Was this to fix them 'walking'?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Postfix(EntityAlive __instance)
|
||||
{
|
||||
if (__instance is EntityTrader) return; // stop if this is a trader
|
||||
|
||||
if (!__instance.RootMotion && !__instance.isEntityRemote)
|
||||
{
|
||||
Patch.ReplicateSpeeds(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Code from Zilox to fix the animals animating on dedi when they do not have root motion.
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "CanSee", new Type[] { typeof(EntityAlive) })]
|
||||
public class CanSeePatch
|
||||
{
|
||||
private static bool Prefix(ref EntityAlive __instance, ref bool __result, EntityAlive _other)
|
||||
{
|
||||
if (__instance is EntityZombieSDX && _other is EntityPlayer)
|
||||
{
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
if (isValidFeralSense)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (__instance is EntityAliveV2)
|
||||
{
|
||||
__result = __instance.CanEntityBeSeen(_other);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "CanSeeStealth")]
|
||||
public class CanSeeStealthPatch
|
||||
{
|
||||
private static void Postfix(ref EntityAlive __instance, ref bool __result, float dist, float lightLevel)
|
||||
{
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (isValidFeralSense || __instance.Buffs.GetCustomVar("$eventSpawn") == 1f || (__instance.IsSleeper && POISense))
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "DamageEntity")]
|
||||
public class DamageEntityPatch
|
||||
{
|
||||
/*private static void Postfix(EntityAlive __instance, ref int __result, DamageSource _damageSource, int _strength, bool _criticalHit, float _impulseScale, ref float ___accumulatedDamageResisted)
|
||||
{
|
||||
////Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity POSTFIX __result: " + __result);
|
||||
}*/
|
||||
|
||||
private static bool Prefix(EntityAlive __instance, ref int __result, DamageSource _damageSource, int _strength, bool _criticalHit, float _impulseScale)
|
||||
{
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity START, _damageSource.damageType: " + _damageSource.damageType);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity _damageSource.getEntityId(): " + _damageSource.getEntityId());
|
||||
//Log.Out("EntityAlivePatches-DamageEntity _damageSource.ownerEntityId: " + _damageSource.ownerEntityId);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity _strength: " + _strength);
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-DamageEntity _damageSource.getEntityId(): " + _damageSource.getEntityId());
|
||||
|
||||
// __instance is the target of the damage. the DamageSource is the attacker
|
||||
|
||||
// I'm thinking we should be checking if the damage source has the tags rather than the damage receiving player?
|
||||
|
||||
EntityAlive entityAlive = __instance.world.GetEntity(_damageSource.getEntityId()) as EntityAlive;
|
||||
if (entityAlive != null)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-DamageEntity SOURCE entityAlive.EntityName: " + entityAlive.EntityName);
|
||||
////Log.Out("EntityAlivePatches-DamageEntity TARGET __instance.EntityName: " + __instance.EntityName);
|
||||
|
||||
bool canDamage = RebirthUtilities.VerifyFactionStanding(entityAlive, __instance);
|
||||
|
||||
////Log.Out("EntityAlivePatches-DamageEntity canDamage: " + canDamage);
|
||||
|
||||
if ((__instance is EntityTurret || __instance is EntityDrone) && !canDamage)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-DamageEntity BYPASS");
|
||||
__result = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance is EntityPlayer || __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("survivor,trader,ally")))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-DamageEntity _damageSource.damageType: " + _damageSource.damageType);
|
||||
|
||||
if (_damageSource.damageType == EnumDamageTypes.Heat)
|
||||
{
|
||||
if (entityAlive != null)
|
||||
{
|
||||
if (entityAlive.EntityClass.entityClassName.ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
////Log.Out($"HarmonyPatch-EntityAlive::DamageEntity this: {__instance} - returning 0 damage false. furiousramsaykamikaze. Dmg source: {entityAlive}");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (_damageSource.ItemClass != null && _damageSource.ItemClass.GetItemName() == "auraExplosion")
|
||||
{
|
||||
////Log.Out($"HarmonyPatch-EntityAlive::DamageEntity this: {__instance} - returning 0 damage false. auraExplosion. Dmg source: {entityAlive}");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance is EntityVehicleRebirth)
|
||||
{
|
||||
if (_damageSource.damageType == EnumDamageTypes.Crushing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*//Log.Out("EntityAlivePatches-DamageEntity _damageSource.damageType: " + _damageSource.damageType);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity _damageSource.AttackingItem != null: " + (_damageSource.AttackingItem != null));
|
||||
//Log.Out("EntityAlivePatches-DamageEntity VEHICLE entityAlive.EntityName: " + __instance.EntityName);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity VEHICLE entityAlive.Health: " + __instance.Health);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity VEHICLE _strength: " + _strength);
|
||||
|
||||
//_strength = _strength * 10;
|
||||
|
||||
DamageResponse _dmResponse1 = __instance.damageEntityLocal(_damageSource, _strength, _criticalHit, _impulseScale);
|
||||
NetPackage _package1 = (NetPackage)NetPackageManager.GetPackage<NetPackageDamageEntity>().Setup(__instance.entityId, _dmResponse1);
|
||||
if (__instance.world.IsRemote())
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(_package1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int _excludePlayer = -1;
|
||||
__instance.world.entityDistributer.SendPacketToTrackedPlayersAndTrackedEntity(__instance.entityId, _excludePlayer, _package1);
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
/*if (__instance is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity IS PLAYER");
|
||||
if (__instance.AttachedToEntity)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity IS ATTACHED");
|
||||
EntityAlive vehicle = __instance.AttachedMainEntity as EntityAlive;
|
||||
|
||||
if (vehicle != null)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity vehicle: " + vehicle.EntityName);
|
||||
|
||||
bool hasProtection = !vehicle.HasAnyTags(FastTags<TagGroup.Global>.Parse("noprotection"));
|
||||
|
||||
//Log.Out("EntityAlivePatches-DamageEntity hasProtection: " + hasProtection);
|
||||
//Log.Out("EntityAlivePatches-DamageEntity vehicle.Health: " + vehicle.Health);
|
||||
|
||||
if (!hasProtection ||
|
||||
vehicle.Health == 0)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity Direct Damage to the Player");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-DamageEntity Direct Damage to the Vehicle");
|
||||
vehicle.DamageEntity(_damageSource, _strength, _criticalHit, _impulseScale);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityAlive))]
|
||||
[HarmonyPatch("CheckDismember")]
|
||||
public class CheckDismemberPatch
|
||||
{
|
||||
private static bool Prefix(EntityAlive __instance, ref DamageResponse _dmResponse, float damagePer)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember START");
|
||||
bool flag = _dmResponse.HitBodyPart.IsLeg();
|
||||
if (!flag || !__instance.IsAlive() || __instance.bodyDamage.CurrentStun == EnumEntityStunType.None && !__instance.sleepingOrWakingUp)
|
||||
{
|
||||
float dismemberChance = __instance.GetDismemberChance(ref _dmResponse, damagePer);
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember dismemberChance: " + dismemberChance);
|
||||
|
||||
double random = __instance.rand.RandomFloat;
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember random: " + random);
|
||||
|
||||
if ((double)dismemberChance > 0.0 && (double)__instance.rand.RandomFloat <= (double)dismemberChance)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 2");
|
||||
_dmResponse.Dismember = true;
|
||||
if (!flag)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 3");
|
||||
return false;
|
||||
}
|
||||
_dmResponse.TurnIntoCrawler = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!flag)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 4");
|
||||
return false;
|
||||
}
|
||||
EntityClass entityClass = EntityClass.list[__instance.entityClass];
|
||||
if ((double)entityClass.LegCrawlerThreshold > 0.0 && (double)__instance.GetDamageFraction((float)_dmResponse.Strength) >= (double)entityClass.LegCrawlerThreshold)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 5");
|
||||
_dmResponse.TurnIntoCrawler = true;
|
||||
}
|
||||
if ((__instance.bodyDamage.ShouldBeCrawler ? 1 : (_dmResponse.TurnIntoCrawler ? 1 : 0)) != 0 || (double)entityClass.LegCrippleScale <= 0.0)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 6");
|
||||
return false;
|
||||
}
|
||||
float num = __instance.GetDamageFraction((float)_dmResponse.Strength) * entityClass.LegCrippleScale;
|
||||
if ((double)num < 0.05000000074505806)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 7");
|
||||
return false;
|
||||
}
|
||||
if (((int)__instance.bodyDamage.Flags & 4096) == 0 && _dmResponse.HitBodyPart.IsLeftLeg() && (double)__instance.rand.RandomFloat < (double)num)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 8");
|
||||
_dmResponse.CrippleLegs = true;
|
||||
}
|
||||
if (((int)__instance.bodyDamage.Flags & 8192) != 0 || !_dmResponse.HitBodyPart.IsRightLeg() || (double)__instance.rand.RandomFloat >= (double)num)
|
||||
{
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember 9");
|
||||
return false;
|
||||
}
|
||||
_dmResponse.CrippleLegs = true;
|
||||
}
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePAtches-CheckDismember END");
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "GetDismemberChance")]
|
||||
public class GetDismemberChancePatch
|
||||
{
|
||||
private static void Postfix(ref EntityAlive __instance, ref float __result, ref DamageResponse _dmResponse, float damagePer)
|
||||
{
|
||||
int entityID = _dmResponse.Source.getEntityId();
|
||||
|
||||
if (entityID > 0)
|
||||
{
|
||||
Entity entity = __instance.world.GetEntity(entityID);
|
||||
|
||||
if (entity != null && (entity is EntityPlayer || entity is EntityNPCRebirth))
|
||||
{
|
||||
EntityAlive entityAlive = (EntityAlive)entity;
|
||||
|
||||
if (entityAlive != null)
|
||||
{
|
||||
bool isFeral = __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("feral"));
|
||||
bool isRadiated = __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("radiated"));
|
||||
bool isBoss = __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("boss"));
|
||||
bool isBoss2 = __instance.Buffs.GetCustomVar("$varFuriousRamsayBoss") == 1f;
|
||||
bool isSupport = __instance.Buffs.GetCustomVar("$varFuriousRamsaySupportMinion") == 1f;
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance EntityTags: " + __instance.EntityTags);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance isFeral: " + isFeral);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance isRadiated: " + isRadiated);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance isBoss: " + isBoss);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance isBoss2: " + isBoss2);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance isSupport: " + isSupport);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance entityAlive.Buffs.ActiveBuffs.Count: " + entityAlive.Buffs.ActiveBuffs.Count);
|
||||
|
||||
if (isBoss || isBoss2 || isSupport)
|
||||
{
|
||||
__result = 0;
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance A __result: " + __result);
|
||||
return;
|
||||
}
|
||||
|
||||
float currentResult = __result;
|
||||
|
||||
for (int i = 1; i < 11; i++)
|
||||
{
|
||||
if (entityAlive.Buffs.HasBuff("FuriousRamsayDismember" + i))
|
||||
{
|
||||
float chance = __result;
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance __result: " + __result);
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance chance: " + chance);
|
||||
|
||||
/*if (isBoss)
|
||||
{
|
||||
__result = 0f; // 0.5f / 100;
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance BOSS __result: " + __result);
|
||||
}
|
||||
else*/
|
||||
if (isRadiated)
|
||||
{
|
||||
__result = (i * 1.5f) / 100;
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance RADIATED __result: " + __result);
|
||||
}
|
||||
else if (isFeral)
|
||||
{
|
||||
__result = (10 + (i * 2f)) / 100;
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance FERAL __result: " + __result);
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = (20 + (i * 2.5f)) / 100;
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance NORMAL __result: " + __result);
|
||||
}
|
||||
|
||||
if (__result < chance)
|
||||
{
|
||||
__result = chance;
|
||||
}
|
||||
|
||||
if (RebirthVariables.testDismember)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance TEST DISMEMBER");
|
||||
__result = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthVariables.testDismember)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance TEST DISMEMBER");
|
||||
__result = 1;
|
||||
}
|
||||
|
||||
if (__result < currentResult)
|
||||
{
|
||||
__result = currentResult;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-GetDismemberChance B __result: " + __result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "SetSleeperSight")]
|
||||
public class SetSleeperSightPatch
|
||||
{
|
||||
private static void Postfix(ref EntityAlive __instance, float angle, float range)
|
||||
{
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (__instance.IsSleeper && POISense)
|
||||
{
|
||||
__instance.sleeperSightRange = 200f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "SetSleeperHearing")]
|
||||
public class SetSleeperHearingPatch
|
||||
{
|
||||
private static void Postfix(ref EntityAlive __instance, float percent)
|
||||
{
|
||||
string rebirthFeralSense = CustomGameOptions.GetString("CustomFeralSense");
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
((currentDay == RebirthManager.nextFeralSenseDay) && rebirthFeralSense == "random");
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (__instance.IsSleeper && POISense)
|
||||
{
|
||||
__instance.noiseGroan = 0;
|
||||
__instance.noiseWake = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "GetSeeDistance")]
|
||||
public class GetSeeDistancePatch
|
||||
{
|
||||
private static void Postfix(ref EntityAlive __instance, ref float __result)
|
||||
{
|
||||
string rebirthFeralSense = RebirthVariables.customFeralSense;
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
bool randomValid = rebirthFeralSense == "random" &&
|
||||
currentDay == RebirthManager.nextFeralSenseDay;
|
||||
|
||||
if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2)
|
||||
{
|
||||
randomValid = false;
|
||||
}
|
||||
|
||||
bool isValidFeralSense = (rebirthFeralSense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") ||
|
||||
randomValid;
|
||||
|
||||
string rebirthPOISense = RebirthVariables.customPOISense;
|
||||
bool POISense = (rebirthPOISense == "always") ||
|
||||
(GameManager.Instance.World.IsDaytime() && rebirthPOISense == "dayonly") ||
|
||||
(!GameManager.Instance.World.IsDaytime() && rebirthPOISense == "nightonly");
|
||||
|
||||
if (isValidFeralSense || __instance.Buffs.GetCustomVar("$eventSpawn") == 1f || (__instance.IsSleeper && POISense))
|
||||
{
|
||||
if (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("zombie")))
|
||||
{
|
||||
__result = 200;
|
||||
__instance.maxViewAngle = 360;
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = 50;
|
||||
__instance.maxViewAngle = 180;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "checkForTeleportOutOfTraderArea")]
|
||||
public class checkForTeleportOutOfTraderAreaPatch
|
||||
{
|
||||
private static bool Prefix(ref EntityAlive __instance)
|
||||
{
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer || GameManager.Instance.IsEditMode() || __instance.IsGodMode.Value || !(__instance is EntityPlayer) || (double)Time.time - (double)__instance.lastTimeTraderStationChecked <= 2.0)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
__instance.lastTimeTraderStationChecked = Time.time;
|
||||
Vector3 position = __instance.position;
|
||||
position.y += 0.5f;
|
||||
Vector3i blockPos = World.worldToBlockPos(position);
|
||||
TraderArea traderAreaAt = __instance.world.GetTraderAreaAt(blockPos);
|
||||
if (traderAreaAt != null)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 2");
|
||||
EntityPlayer requester = __instance as EntityPlayer;
|
||||
|
||||
if (requester == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requester.Buffs.HasBuff("FuriousRamsaySpawningDelay"))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea HAS SPAWNING DELAY");
|
||||
return false;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea requester.Spawned: " + requester.Spawned);
|
||||
|
||||
bool flag = false;
|
||||
Vector3 vector3 = (Vector3)(traderAreaAt.ProtectPosition + traderAreaAt.ProtectSize * 0.5f);
|
||||
if ((bool)(UnityEngine.Object)requester && __instance.world.IsWorldEvent(World.WorldEvent.BloodMoon))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 3");
|
||||
flag = true;
|
||||
}
|
||||
Prefab.PrefabTeleportVolume tpVolume;
|
||||
if (((bool)(UnityEngine.Object)requester || __instance is EntityHuman) && traderAreaAt.IsWithinTeleportArea(position, out tpVolume))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 4");
|
||||
flag = traderAreaAt.IsClosed;
|
||||
if (!flag && (bool)(UnityEngine.Object)requester && (double)EffectManager.GetValue(PassiveEffects.NoTrader, _entity: __instance) == 1.0)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 5");
|
||||
flag = true;
|
||||
vector3 = (Vector3)(__instance.world.GetPOIAtPosition((Vector3)blockPos).boundingBoxPosition + tpVolume.startPos + tpVolume.size * 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag && !RebirthVariables.isHordeNight)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 6");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!RebirthVariables.customProtectTraderArea && RebirthVariables.isHordeNight)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea TRADER PROTECTION IS OFF");
|
||||
return false;
|
||||
}
|
||||
|
||||
++__instance.traderTeleportStreak;
|
||||
Vector3 normalized = (__instance.GetPosition() - vector3).normalized with
|
||||
{
|
||||
y = 0.0f
|
||||
};
|
||||
Vector3 teleportPosition = __instance.GetTeleportPosition(__instance.GetPosition() + normalized * 5f * (float)__instance.traderTeleportStreak, normalized);
|
||||
if (__instance.isEntityRemote)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 7");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.Clients.ForEntityId(__instance.entityId).SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageTeleportPlayer>().Setup(teleportPosition));
|
||||
}
|
||||
else if ((bool)(UnityEngine.Object)requester)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 8");
|
||||
requester.Teleport(teleportPosition);
|
||||
}
|
||||
else if ((UnityEngine.Object)__instance.AttachedToEntity != (UnityEngine.Object)null)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 9");
|
||||
__instance.AttachedToEntity.SetPosition(teleportPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 10");
|
||||
__instance.SetPosition(teleportPosition);
|
||||
}
|
||||
if (!(bool)(UnityEngine.Object)requester)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea 11");
|
||||
return false;
|
||||
}
|
||||
GameEventManager.Current.HandleAction("game_on_trader_teleport", requester, (Entity)requester, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-checkForTeleportOutOfTraderArea __instance.traderTeleportStreak: " + __instance.traderTeleportStreak);
|
||||
__instance.traderTeleportStreak = 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive))]
|
||||
[HarmonyPatch("ClientKill")]
|
||||
public class ClientKillPatch
|
||||
{
|
||||
private static bool Prefix(ref EntityAlive __instance, DamageResponse _dmResponse)
|
||||
{
|
||||
if (__instance is EntityZombieSDX)
|
||||
{
|
||||
if (_dmResponse.Source != null && _dmResponse.Source.BuffClass != null && SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-ClientKill 1");
|
||||
EntityZombieSDX entity = (EntityZombieSDX)__instance;
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-ClientKill 2");
|
||||
foreach (BuffValue buff in entity.Buffs.ActiveBuffs)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-ClientKill BUFF NAME: " + buff.BuffName);
|
||||
|
||||
if (buff.BuffName == _dmResponse.Source.BuffClass.Name)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-ClientKill Instigator: " + buff.InstigatorId);
|
||||
entity.entityThatKilledMeID = buff.InstigatorId;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "updateTasks")]
|
||||
public class updateTasksPatch
|
||||
{
|
||||
private static bool Prefix(ref EntityAlive __instance)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks START");
|
||||
if (__instance is EntityTurret)
|
||||
{
|
||||
if (__instance.Buffs.GetCustomVar("$FR_Turret_Temp") == 2)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks SKIPPING");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthUtilities.HasBuffLike(__instance, "FuriousRamsayRangedStun") && !__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally")))
|
||||
{
|
||||
__instance.SetMoveForwardWithModifiers(0.0f, 0.0f, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (GamePrefs.GetBool(EnumGamePrefs.DebugStopEnemiesMoving))
|
||||
{
|
||||
__instance.SetMoveForwardWithModifiers(0f, 0f, false);
|
||||
if (__instance.aiManager != null)
|
||||
{
|
||||
__instance.aiManager.UpdateDebugName();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance is EntityTurret)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 1");
|
||||
EntityTurret entityTurret = (EntityTurret)__instance;
|
||||
|
||||
if (entityTurret.PickedUpWaitingToDelete)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 2");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__instance.CheckDespawn();
|
||||
|
||||
if (__instance.seeCache == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
__instance.seeCache.ClearIfExpired();
|
||||
bool useAIPackages = EntityClass.list[__instance.entityClass].UseAIPackages;
|
||||
__instance.aiActiveDelay -= __instance.aiActiveDelay;
|
||||
if (__instance.aiActiveDelay <= 0f)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 1");
|
||||
if (!useAIPackages)
|
||||
{
|
||||
__instance.aiManager.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 3");
|
||||
UAIBase.Update(__instance.utilityAIContext);
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)__instance;
|
||||
if (npc != null && npc.Buffs.HasBuff("FuriousRamsayStandStill") ||
|
||||
(
|
||||
(npc.Buffs.GetCustomVar("CurrentOrder") == (int)EntityUtilities.Orders.Stay || npc.Buffs.GetCustomVar("CurrentOrder") == (int)EntityUtilities.Orders.TempStay) && __instance.GetAttackTarget() != null)
|
||||
)
|
||||
{
|
||||
////Log.Out($"EntityAlivePatches-updateTasks CLEAR PATH this: {__instance}");
|
||||
__instance.navigator?.clearPath();
|
||||
__instance.moveHelper.Stop();
|
||||
return false;
|
||||
}
|
||||
else if (npc.Buffs.GetCustomVar("CurrentOrder") == (int)EntityUtilities.Orders.Stay &&
|
||||
npc.guardPosition == Vector3.zero
|
||||
)
|
||||
{
|
||||
npc.guardPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
PathInfo path = PathFinderThread.Instance.GetPath(__instance.entityId);
|
||||
if (path.path != null) // && (!(__instance is EntityNPCRebirth)))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 4");
|
||||
bool flag = true;
|
||||
if (!useAIPackages)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks 5");
|
||||
flag = __instance.aiManager.CheckPath(path);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlivePatches-updateTasks navigator.SetPath __instance.EntityName: {__instance.EntityName}");
|
||||
|
||||
__instance.navigator.SetPath(path, path.speed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks path == null");
|
||||
}
|
||||
|
||||
__instance.navigator.UpdateNavigation();
|
||||
if (__instance is EntityNPCRebirth)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-updateTasks noPathAndNotPlanningOne: " + __instance.navigator.noPathAndNotPlanningOne());
|
||||
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)__instance;
|
||||
|
||||
bool isRanged = false;
|
||||
int _actionIndex = 0;
|
||||
|
||||
if (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged")))
|
||||
{
|
||||
_actionIndex = 1;
|
||||
isRanged = true;
|
||||
}
|
||||
|
||||
if (isRanged && npc != null && __instance.GetAttackTarget() != null)
|
||||
{
|
||||
//////////////////// START
|
||||
////Log.Out($"isRanged and npc {npc}, attackTarget: {npc.attackTarget}");
|
||||
|
||||
bool isTargetWithinItemActionRange = false;
|
||||
float maxItemActionRange;
|
||||
|
||||
float itemActionRange = 1.095f;
|
||||
|
||||
ItemValue holdingItemItemValue = __instance.inventory.holdingItemItemValue;
|
||||
int holdingItemIdx = __instance.inventory.holdingItemIdx;
|
||||
|
||||
ItemAction itemAction = __instance.inventory.holdingItem.Actions[_actionIndex];
|
||||
if (itemAction != null)
|
||||
{
|
||||
itemActionRange = itemAction.Range;
|
||||
if (itemActionRange == 0f)
|
||||
{
|
||||
////Log.Out("EAIApproachAndAttackTargetCompanion-Update 8");
|
||||
itemActionRange = EffectManager.GetItemValue(PassiveEffects.MaxRange, holdingItemItemValue, 0f);
|
||||
}
|
||||
}
|
||||
maxItemActionRange = Utils.FastMax(0.7f, itemActionRange - 0.35f);
|
||||
|
||||
////Log.Out("EAIApproachAndAttackTargetCompanion-Update 9a, itemActionRange: " + itemActionRange);
|
||||
////Log.Out("EAIApproachAndAttackTargetCompanion-Update 9b, maxItemActionRange: " + maxItemActionRange);
|
||||
|
||||
float maxRangeSquared = maxItemActionRange * maxItemActionRange;
|
||||
float estimatedTimeInTicks = 4f;
|
||||
estimatedTimeInTicks = 0.5f * estimatedTimeInTicks;
|
||||
|
||||
|
||||
//targetXZDistanceSq = __instance.GetTargetXZDistanceSq(estimatedTimeInTicks);
|
||||
|
||||
Vector3 vector = __instance.GetAttackTarget().position;
|
||||
|
||||
Vector3 curEntTargPos = __instance.position;
|
||||
Vector3 targetDirection = __instance.position - curEntTargPos;
|
||||
|
||||
Vector3 entityTargetVel = Vector3.zero;
|
||||
|
||||
if (targetDirection.sqrMagnitude < 1f)
|
||||
{
|
||||
////Log.Out("EAIApproachAndAttackTargetCompanion-Update 7");
|
||||
entityTargetVel = entityTargetVel * 0.7f + targetDirection * 0.3f;
|
||||
}
|
||||
|
||||
vector += entityTargetVel * estimatedTimeInTicks;
|
||||
Vector3 vector2 = __instance.position + __instance.motion * estimatedTimeInTicks - vector;
|
||||
vector2.y = 0f;
|
||||
float targetXZDistanceSq = vector2.sqrMagnitude;
|
||||
|
||||
|
||||
curEntTargPos = __instance.GetAttackTarget().position;
|
||||
float yDiff = curEntTargPos.y - __instance.position.y;
|
||||
float absoluteYDiff = Utils.FastAbs(yDiff);
|
||||
float entityDistance = Vector3.Distance(__instance.position, curEntTargPos);
|
||||
isTargetWithinItemActionRange = entityDistance < maxItemActionRange;
|
||||
|
||||
if (!isTargetWithinItemActionRange)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlivePatches::updateTasksPatch - !isTargetWithinItemActionRange - UpdateMoveHelper");
|
||||
__instance.moveHelper.UpdateMoveHelper();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.Buffs.GetCustomVar("$IsBackingUp") == 1f)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlivePatches::updateTasksPatch - $IsBackingUp == 1f - UpdateMoveHelper");
|
||||
__instance.moveHelper.UpdateMoveHelper();
|
||||
}
|
||||
}
|
||||
//////////////////// END
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (npc.currentOrder != (int)EntityUtilities.Orders.Stay)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlivePatches::updateTasksPatch - else 1 this: {__instance}, moveHelper: {__instance.moveHelper.moveToPos}, IsActive: {__instance.moveHelper.IsActive}");
|
||||
|
||||
__instance.moveHelper.UpdateMoveHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlivePatches::updateTasksPatch - else 2 this: {__instance}");
|
||||
|
||||
__instance.moveHelper.UpdateMoveHelper();
|
||||
}
|
||||
__instance.lookHelper.onUpdateLook();
|
||||
if (__instance.distraction != null && (__instance.distraction.IsDead() || __instance.distraction.IsMarkedForUnload()))
|
||||
{
|
||||
__instance.distraction = null;
|
||||
}
|
||||
if (__instance.pendingDistraction != null && (__instance.pendingDistraction.IsDead() || __instance.pendingDistraction.IsMarkedForUnload()))
|
||||
{
|
||||
__instance.pendingDistraction = null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "OnUpdateLive")]
|
||||
public class OnUpdateLivePatch
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance)
|
||||
{
|
||||
//if (__instance is EntityNPCRebirth)
|
||||
////Log.Out($"EntityAlive::OnUpdateLive Prefix 2 - this Entity: {__instance}, attackTarget: {__instance.attackTarget}");
|
||||
|
||||
if (__instance.Buffs.HasBuff("FuriousRamsayRangedStunEffects") && !__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally")))
|
||||
{
|
||||
//__instance.enabled = false;
|
||||
__instance.SetRevengeTarget((EntityAlive) null);
|
||||
__instance.attackTarget = (EntityAlive) null;
|
||||
__instance.SetMoveForwardWithModifiers(0f, 0f, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(EntityAlive __instance)
|
||||
{
|
||||
if (__instance.timeStayAfterDeath > 60)
|
||||
{
|
||||
if (__instance is EntityZombie)
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
__instance.timeStayAfterDeath = 60; // 3 seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (__instance)
|
||||
{
|
||||
case EntityZombie _:
|
||||
case EntityPlayerLocal _:
|
||||
case EntityPlayer _:
|
||||
case EntityVulture _:
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.isEntityRemote)
|
||||
return;
|
||||
|
||||
if (!__instance.emodel) return;
|
||||
|
||||
var avatarController = __instance.emodel.avatarController;
|
||||
if (!avatarController) return;
|
||||
|
||||
var flag = __instance.onGround || __instance.isSwimming;
|
||||
|
||||
var canFall = !__instance.emodel.IsRagdollActive && __instance.bodyDamage.CurrentStun == EnumEntityStunType.None && !__instance.isSwimming && !__instance.IsDead();
|
||||
avatarController.SetFallAndGround(canFall, flag);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "OnEntityDeath")]
|
||||
public class OnEntityDeathPatch
|
||||
{
|
||||
private static bool isGameMessageOnDeath()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void dropItemOnDeath(ref EntityAlive __instance)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath 1");
|
||||
for (int i = 0; i < __instance.inventory.GetItemCount(); i++)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath i: " + i);
|
||||
ItemStack item = __instance.inventory.GetItem(i);
|
||||
ItemClass forId = ItemClass.GetForId(item.itemValue.type);
|
||||
if (forId != null && forId.CanDrop())
|
||||
{
|
||||
__instance.world.GetGameManager().ItemDropServer(item, __instance.position, new Vector3(0.5f, 0f, 0.5f), -1, Constants.cItemDroppedOnDeathLifetime, false);
|
||||
__instance.inventory.SetItem(i, ItemValue.None.Clone(), 0, true);
|
||||
}
|
||||
}
|
||||
__instance.inventory.SetFlashlight(false);
|
||||
__instance.equipment.DropItems();
|
||||
if (__instance.world.IsDark())
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath 2");
|
||||
__instance.lootDropProb *= 1f;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath A __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
|
||||
/*if (___entityThatKilledMe)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath 3");
|
||||
__instance.lootDropProb = EffectManager.GetValue(PassiveEffects.LootDropProb, ___entityThatKilledMe.inventory.holdingItemItemValue, __instance.lootDropProb, ___entityThatKilledMe, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
||||
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
|
||||
//Log.Out($"EntityAlivePatches-dropItemOnDeath BEFORE ({__instance.entityName}) __instance.lootDropProb: {__instance.lootDropProb}");
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
if (!__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("NoLootDropChange")))
|
||||
{
|
||||
float customHordeNightLootDropMultiplier = float.Parse(RebirthVariables.customHordeNightLootDropMultiplier) / 100;
|
||||
|
||||
//Log.Out("EntityAlivePatches-dropItemOnDeath customHordeNightLootDropMultiplier: " + customHordeNightLootDropMultiplier);
|
||||
|
||||
if (__instance.lootDropProb >= 1f)
|
||||
{
|
||||
customHordeNightLootDropMultiplier = 1f;
|
||||
//Log.Out("EntityAlivePatches-dropItemOnDeath ADJUST customHordeNightLootDropMultiplier: " + customHordeNightLootDropMultiplier);
|
||||
}
|
||||
|
||||
if (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("reducedHNloot")))
|
||||
{
|
||||
__instance.lootDropProb = __instance.lootDropProb * 0.25f * customHordeNightLootDropMultiplier;
|
||||
//Log.Out("EntityAlivePatches-dropItemOnDeath REDUCED __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.lootDropProb = __instance.lootDropProb * 1f * customHordeNightLootDropMultiplier;
|
||||
//Log.Out("EntityAlivePatches-dropItemOnDeath AFTER __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath A");
|
||||
if (!(__instance.lootDropProb >= 1f))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath B");
|
||||
__instance.lootDropProb = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.lootDropProb > __instance.rand.RandomFloat)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath 4");
|
||||
if (!RebirthVariables.customEventsLoot && __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("seeker,boss")))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.DropContentOfLootContainerServer(BlockValue.Air, new Vector3i(__instance.position), __instance.entityId);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (__instance.entityThatKilledMe)
|
||||
{
|
||||
__instance.lootDropProb = EffectManager.GetValue(PassiveEffects.LootDropProb, __instance.entityThatKilledMe.inventory.holdingItemItemValue, __instance.lootDropProb, __instance.entityThatKilledMe, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
////Log.Out($"EntityAlivePatches-dropItemOnDeath BEFORE ({__instance.entityName}) __instance.lootDropProb: {__instance.lootDropProb}");
|
||||
|
||||
if (!__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("NoLootDropChange")))
|
||||
{
|
||||
float customHordeNightLootDropMultiplier = 3 * float.Parse(RebirthVariables.customHordeNightLootDropMultiplier) / 100;
|
||||
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath customHordeNightLootDropMultiplier: " + customHordeNightLootDropMultiplier);
|
||||
|
||||
if (__instance.lootDropProb >= 1f)
|
||||
{
|
||||
customHordeNightLootDropMultiplier = 1f;
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath ADJUST customHordeNightLootDropMultiplier: " + customHordeNightLootDropMultiplier);
|
||||
}
|
||||
|
||||
if (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("reducedHNloot")))
|
||||
{
|
||||
__instance.lootDropProb = __instance.lootDropProb * 0.25f * customHordeNightLootDropMultiplier;
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath REDUCED __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.lootDropProb = __instance.lootDropProb * 1f * customHordeNightLootDropMultiplier;
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath AFTER __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.lootDropProb < 1f && !(__instance.Buffs.GetCustomVar("$herdEntity") == 1f))
|
||||
{
|
||||
__instance.lootDropProb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Buffs.GetCustomVar("$varFuriousRamsayBoss") == 1f)
|
||||
{
|
||||
__instance.lootDropProb = 1;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath __instance.lootDropProb: " + __instance.lootDropProb);
|
||||
|
||||
if (__instance.lootDropProb > __instance.rand.RandomFloat)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath __instance.EntityTags: " + __instance.EntityTags);
|
||||
if (!RebirthVariables.customEventsLoot && __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("seeker,boss")))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath A");
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-dropItemOnDeath B");
|
||||
GameManager.Instance.DropContentOfLootContainerServer(BlockValue.Air, new Vector3i(__instance.position), __instance.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Prefix(ref EntityAlive __instance)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath START");
|
||||
|
||||
if (__instance is EntityPlayer)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 0");
|
||||
return true;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 1");
|
||||
if (__instance.deathUpdateTime != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath ADDSCORE");
|
||||
__instance.AddScore(1, 0, 0, -1, 0);
|
||||
if (__instance.soundLiving != null && __instance.soundLivingID >= 0)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 2");
|
||||
Manager.Stop(__instance.entityId, __instance.soundLiving);
|
||||
__instance.soundLivingID = -1;
|
||||
}
|
||||
if (__instance.AttachedToEntity)
|
||||
{
|
||||
__instance.Detach();
|
||||
}
|
||||
if (__instance.isEntityRemote)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance.entityThatKilledMe == null && __instance is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX entityZombie = (EntityZombieSDX)__instance;
|
||||
__instance.entityThatKilledMe = (EntityAlive)__instance.world.GetEntity(entityZombie.entityThatKilledMeID);
|
||||
if (__instance.entityThatKilledMe != null)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath ___entityThatKilledMe: " + ___entityThatKilledMe.EntityClass.entityClassName);
|
||||
}
|
||||
}
|
||||
|
||||
float flLeader = 0;
|
||||
|
||||
if (__instance.entityThatKilledMe is EntityNPCRebirth)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 4");
|
||||
flLeader = RebirthUtilities.GetLeader(__instance.entityThatKilledMe);
|
||||
|
||||
if (flLeader > 0)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 6");
|
||||
var ___entityPlayerLocal = __instance.entityThatKilledMe.world.GetEntity((int)flLeader) as global::EntityPlayer;
|
||||
if (___entityPlayerLocal)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 7");
|
||||
float distanceEntity = ___entityPlayerLocal.GetDistance(__instance.entityThatKilledMe);
|
||||
|
||||
if (distanceEntity <= 50)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 7a");
|
||||
__instance.AwardKill(___entityPlayerLocal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 8");
|
||||
__instance.AwardKill(__instance.entityThatKilledMe);
|
||||
}
|
||||
|
||||
if (__instance.particleOnDeath != null && __instance.particleOnDeath.Length > 0)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 9");
|
||||
float lightBrightness = __instance.world.GetLightBrightness(__instance.GetBlockPosition());
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath 9 ___particleOnDeath: " + ___particleOnDeath + " / id: " + ___particleOnDeath.GetHashCode());
|
||||
__instance.world.GetGameManager().SpawnParticleEffectServer(new ParticleEffect(__instance.particleOnDeath, __instance.getHeadPosition(), lightBrightness, Color.white, null, null, false), __instance.entityId);
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath flLeader: " + flLeader);
|
||||
////Log.Out("EntityAlivePatches-OnEntityDeath __instance is EntityNPCRebirth: " + (__instance is EntityNPCRebirth));
|
||||
|
||||
if (isGameMessageOnDeath() && (__instance is EntityPlayer || (__instance is EntityNPCRebirth && flLeader > 0)))
|
||||
{
|
||||
GameManager.Instance.GameMessage(EnumGameMessages.EntityWasKilled, __instance, __instance.entityThatKilledMe);
|
||||
}
|
||||
if (__instance.entityThatKilledMe != null)
|
||||
{
|
||||
Log.Out("Entity {0} {1} killed by {2} {3}", new object[]
|
||||
{
|
||||
__instance.GetDebugName(),
|
||||
__instance.entityId,
|
||||
__instance.entityThatKilledMe.GetDebugName(),
|
||||
__instance.entityThatKilledMe.entityId
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("Entity {0} {1} killed", new object[]
|
||||
{
|
||||
__instance.GetDebugName(),
|
||||
__instance.entityId
|
||||
});
|
||||
}
|
||||
ModEvents.EntityKilled.Invoke(__instance, __instance.entityThatKilledMe);
|
||||
dropItemOnDeath(ref __instance);
|
||||
__instance.entityThatKilledMe = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "AwardKill")]
|
||||
public class AwardKillPatch
|
||||
{
|
||||
private static bool Prefix(ref EntityAlive __instance, EntityAlive killer)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill START");
|
||||
|
||||
////Log.Out("EntityAlivePatches-AwardKill killer != null: " + (killer != null));
|
||||
|
||||
////Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
|
||||
if (killer != null && killer != __instance)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 1");
|
||||
int num = 0;
|
||||
int num2 = 0;
|
||||
int conditions = 0;
|
||||
EntityType entityType = __instance.entityType;
|
||||
if (entityType != EntityType.Player)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 2");
|
||||
if (entityType == EntityType.Zombie)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 3");
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 4");
|
||||
num2++;
|
||||
}
|
||||
EntityPlayer entityPlayer = killer as EntityPlayer;
|
||||
if (entityPlayer)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 5");
|
||||
|
||||
if (RebirthVariables.customScenario == "purge" && __instance.IsSleeper)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill Purge 1");
|
||||
PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(__instance.SleeperSpawnPosition); //__instance.world.GetPOIAtPosition(__instance.SleeperSpawnPosition, false);
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
Vector3 vector = new Vector3(poiatPosition.boundingBoxPosition.x, poiatPosition.boundingBoxPosition.y, poiatPosition.boundingBoxPosition.z);
|
||||
|
||||
////Log.Out("EntityAlivePatches-AwardKill Purge poiatPosition.prefab.PrefabName: " + poiatPosition.prefab.PrefabName);
|
||||
////Log.Out("EntityAlivePatches-AwardKill Purge vector: " + vector);
|
||||
var result = RebirthManager.AddKill(poiatPosition.prefab.PrefabName, vector, entityPlayer.entityId);
|
||||
int numKills = result.numKills;
|
||||
int numRedeemableKills = result.numRedeemableKills;
|
||||
|
||||
entityPlayer.Buffs.SetCustomVar("$purgeRedeemKills", numKills);
|
||||
entityPlayer.Buffs.SetCustomVar("$purgeRedeemableKills", numRedeemableKills);
|
||||
}
|
||||
}
|
||||
|
||||
GameManager.Instance.AwardKill(killer, __instance);
|
||||
if (entityPlayer.inventory.IsHoldingGun() && entityPlayer.inventory.holdingItem.Name.Equals("gunHandgunT2Magnum44"))
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AwardKill 6");
|
||||
conditions = 2;
|
||||
}
|
||||
GameManager.Instance.AddScoreServer(killer.entityId, num, num2, __instance.TeamNumber, conditions);
|
||||
}
|
||||
}
|
||||
|
||||
////Log.Out("EntityAlivePatches-AwardKill END");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "AddScore")]
|
||||
public class AddScorePatch
|
||||
{
|
||||
public static void Postfix(EntityAlive __instance, int _diedMySelfTimes, int _zombieKills, int _playerKills, int _otherTeamnumber, int _conditions)
|
||||
{
|
||||
if (__instance is EntityPlayerLocal)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AddScore __instance.KilledZombies: " + __instance.KilledZombies);
|
||||
bool isNaturalSelectionCountingOn = RebirthUtilities.IsNaturalSelectionCountingOn();
|
||||
|
||||
////Log.Out("EntityAlivePatches-AddScore isNaturalSelectionCountingOn: " + isNaturalSelectionCountingOn);
|
||||
|
||||
////Log.Out("EntityAlivePatches-AddScore _zombieKills: " + _zombieKills);
|
||||
|
||||
if (isNaturalSelectionCountingOn && !GameManager.IsDedicatedServer)
|
||||
{
|
||||
int numNS = (int)__instance.Buffs.GetCustomVar("$NaturalSelection_FR") + _zombieKills;
|
||||
|
||||
////Log.Out("EntityAlivePatches-AddScore numNS: " + numNS);
|
||||
|
||||
__instance.Buffs.SetCustomVar("$NaturalSelection_FR", numNS);
|
||||
|
||||
RebirthVariables.localConstants["$varFuriousRamsayTheyGrowStrongerKills_Cst"] = numNS; // ___entityPlayerLocal.KilledZombies;
|
||||
}
|
||||
|
||||
//RebirthVariables.localConstants["$varFuriousRamsayTheyGrowStrongerKills_Cst"] = __instance.Buffs.GetCustomVar("$NaturalSelection_FR") + _zombieKills; // __instance.KilledZombies;
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-AddScore (SERVER) __instance.KilledZombies: " + __instance.KilledZombies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "FireEvent")]
|
||||
public class FireEventPatch
|
||||
{
|
||||
private static bool Prefix(EntityAlive __instance, MinEventTypes _eventType, bool useInventory = true)
|
||||
{
|
||||
if (__instance.EntityClass.entityClassName.ToLower().Contains("furiousramsaykamikaze") ||
|
||||
__instance.EntityClass.entityClassName.ToLower().Contains("fatcop")
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
MinEventParams minEventContext = __instance.MinEventContext;
|
||||
|
||||
if (__instance is EntityPlayer)
|
||||
{
|
||||
if (minEventContext.ItemValue != null && minEventContext.ItemValue.ItemClass != null && _eventType == MinEventTypes.onProjectileImpact)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onProjectileImpact Item: " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
}
|
||||
|
||||
/*if (_eventType == MinEventTypes.onSelfRespawn)
|
||||
{
|
||||
ItemValue itemValue = new ItemValue(ItemClass.GetItem("armorPreacherHelmet", false).type);
|
||||
itemValue.SetMetadata("bonus", "perkMiner69r", TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("type", "", TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("level", 1, TypedMetadataValue.TypeTag.Integer);
|
||||
itemValue.SetMetadata("active", 2, TypedMetadataValue.TypeTag.Integer);
|
||||
|
||||
RebirthUtilities.addToPlayerBag(itemValue, __instance, 1);
|
||||
}*/
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfFirstSpawn)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
RebirthUtilities.RandomizePlayerEquipment((EntityPlayerLocal)__instance);
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("vehicleBicyclePlaceable"), __instance, 1, "");
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolTorch"), __instance, 1, "");
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("FuriousRamsayClassBookGeneric"), __instance, 1, "");
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("WorkbenchToolbox001_FR"), __instance, 1, "");
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("bedrollBlockVariantHelper"), __instance, 1, "");
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolAxeT1IronFireaxe"), __instance, 1, "", 1, true, 2);
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolShovelT1IronShovel"), __instance, 1, "", 1, true, 2);
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolPickT1IronPickaxe"), __instance, 1, "", 1, true, 2);
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolSalvageT1Wrench"), __instance, 1, "", 1, true, 1);
|
||||
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("drinkJarPureMineralWater"), __instance, 4, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("drugVitamins"), __instance, 3, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("foodCanCatfood"), __instance, 5, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("foodCanDogfood"), __instance, 5, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("foodCanMiso"), __instance, 5, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("FuriousRamsayInfo_Purge2Supplies"), __instance, 1, "");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("FuriousRamsayInfo_Purge2aThreatScanner"), __instance, 1, "");
|
||||
}
|
||||
|
||||
string optionJumpstart = RebirthVariables.customJumpstart;
|
||||
|
||||
if (RebirthVariables.customScenario == "purge" || (RebirthVariables.customScenario == "none" && optionJumpstart == "classbookessentials"))
|
||||
{
|
||||
ProgressionValue progressionValue = __instance.Progression.GetProgressionValue("craftingSalvageTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 10)
|
||||
{
|
||||
progressionValue.Level = 10;
|
||||
__instance.Buffs.SetCustomVar("$varFuriousRamsaySalvageToolsPercUnit", 0.2f);
|
||||
RebirthVariables.localVariables["$varFuriousRamsaySalvageToolsPercUnit"] = 0.2f;
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsaySalvageToolsPercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = __instance.Progression.GetProgressionValue("FuriousRamsayMiningTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
__instance.Buffs.SetCustomVar("$varFuriousRamsayMinePercUnit", 1.0f);
|
||||
RebirthVariables.localVariables["$varFuriousRamsayMinePercUnit"] = 1.0f;
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsayMinePercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = __instance.Progression.GetProgressionValue("craftingChoppingTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
__instance.Buffs.SetCustomVar("$varFuriousRamsayChopPercUnit", 0.2f);
|
||||
RebirthVariables.localVariables["$varFuriousRamsayChopPercUnit"] = 0.2f;
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsayChopPercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = __instance.Progression.GetProgressionValue("FuriousRamsayDiggingTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
__instance.Buffs.SetCustomVar("$varFuriousRamsayDigPercUnit", 1.0f);
|
||||
RebirthVariables.localVariables["$varFuriousRamsayDigPercUnit"] = 1.0f;
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsayDigPercUnit");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfEnteredGame)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge" && !RebirthVariables.purgePrefabsLoaded)
|
||||
{
|
||||
RebirthVariables.purgePrefabsLoaded = true;
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent Requesting list of purged prefabs");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageGetPurgePrefabs>().Setup(__instance.entityId), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance is EntityNPCRebirth)
|
||||
{
|
||||
if (_eventType == MinEventTypes.onSelfRangedBurstShotStart)
|
||||
{
|
||||
float currentRounds = __instance.Buffs.GetCustomVar("$roundsinmag");
|
||||
|
||||
if (currentRounds > 0)
|
||||
{
|
||||
currentRounds--;
|
||||
__instance.Buffs.SetCustomVar("$roundsinmag", currentRounds);
|
||||
}
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentRounds: " + currentRounds);
|
||||
|
||||
if (currentRounds == 0)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent RELOADING");
|
||||
__instance.Buffs.AddBuff("buffReloadDelay");
|
||||
|
||||
int magazineSize = RebirthUtilities.GetNPCMagazineSize(__instance);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent magazineSize: " + magazineSize);
|
||||
|
||||
__instance.Buffs.SetCustomVar("$roundsinmag", magazineSize);
|
||||
|
||||
//__instance.Buffs.SetCustomVar("$reloading", 1f);
|
||||
}
|
||||
}
|
||||
|
||||
int leader = RebirthUtilities.GetLeader(__instance);
|
||||
|
||||
if (leader > 0)
|
||||
{
|
||||
EntityAlive myLeader = (EntityAlive)__instance.world.GetEntity(leader);
|
||||
|
||||
if (myLeader != null && myLeader.Spawned)
|
||||
{
|
||||
if (_eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"]++;
|
||||
bool isHeadShot = (minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head);
|
||||
if (isHeadShot)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNHeadShots_Cst"]++;
|
||||
}
|
||||
}
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageCheckAchievementRebirth>().Setup(minEventContext.Biome.m_Id, myLeader.entityId, minEventContext.Other.entityId), false, myLeader.entityId, -1, -1, null, 192);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthUtilities.ProcessCheckAchievements(minEventContext.Biome.m_Id, myLeader, minEventContext.Other);
|
||||
}
|
||||
}
|
||||
}
|
||||
//else if (_eventType == MinEventTypes.onSelfDamagedOther && minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("ranged") && __instance is EntityNPCRebirth npc)
|
||||
else if (_eventType == MinEventTypes.onSelfDamagedOther && __instance is EntityNPCRebirth npc)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent NPC DAMAGE");
|
||||
bool isRangedHit = __instance.inventory.holdingItemItemValue.ItemClass.Actions[1].IsActionRunning(__instance.inventory.GetItemActionDataInSlot(__instance.inventory.holdingItemIdx, 1));
|
||||
|
||||
if (isRangedHit)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent minEventContext.ItemValue.ItemClass.GetItemName(): " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
bool bShotgun = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("shotgun");
|
||||
|
||||
if (RebirthUtilities.VerifyFactionStanding(myLeader, minEventContext.Other))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent NPC Ranged 1");
|
||||
if (npc.canShotgunTrigger)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent NPC Ranged 2");
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent NPC NetPackageSetAuraChance");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageSetAuraChance>().Setup(minEventContext.ItemValue.ItemClass.GetItemName(), myLeader.entityId, (int)myLeader.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, __instance.entityId, false, false), false, myLeader.entityId, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent NPC SetAuraChance");
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), myLeader.entityId, myLeader.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, true, false, __instance.entityId);
|
||||
}
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.delayNPCShotgunTrigger(1.0f, npc));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent isMeleeHit item: " + minEventContext.ItemValue.ItemClass.Name);
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), myLeader.entityId, myLeader.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, true, true, __instance.entityId);
|
||||
}
|
||||
}
|
||||
/*else if (_eventType == MinEventTypes.onSelfDamagedOther && __instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("mercenary")))
|
||||
{
|
||||
int buffLevel = 2;
|
||||
|
||||
if (__instance.EntityClass.Properties.Values.ContainsKey("MercenaryLevel"))
|
||||
{
|
||||
buffLevel = int.Parse(__instance.EntityClass.Properties.Values["MercenaryLevel"]);
|
||||
}
|
||||
|
||||
minEventContext.Other.Buffs.AddBuff("FuriousRamsayRangedBleedDamage" + buffLevel, __instance.entityId);
|
||||
return false;
|
||||
}*/
|
||||
else if (_eventType == MinEventTypes.onOtherDamagedSelf && (__instance is EntityPlayer || __instance is EntityNPCRebirth))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended");
|
||||
List<string> tagNames = minEventContext.ItemValue.ItemClass.ItemTags.GetTagNames();
|
||||
|
||||
string optionCustomAuraDefense = RebirthVariables.customAuraDefense;
|
||||
|
||||
bool canTrigger = false;
|
||||
float triggerChance = myLeader.Buffs.GetCustomVar("$AuraOtherDamageSelfIncrease") * 100;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf NPC AURA triggerChance: " + triggerChance);
|
||||
|
||||
if (triggerChance > 0)
|
||||
{
|
||||
int random = __instance.rand.RandomRange(1, 100);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf NPC AURA random: " + random);
|
||||
|
||||
if (random <= triggerChance)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf NPC AURA CAN TRIGGER");
|
||||
canTrigger = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((optionCustomAuraDefense == "on" || optionCustomAuraDefense == "cooldown") && canTrigger)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended, GetItemName: " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended, __instance.entityId: " + __instance.entityId);
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended, minEventContext.Other.entityId: " + minEventContext.Other.entityId);
|
||||
if (minEventContext.ItemValue != null && minEventContext.Other != null)
|
||||
{
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended NetPackageSetAuraChance");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageSetAuraChance>().Setup(minEventContext.ItemValue.ItemClass.GetItemName(), myLeader.entityId, (int)myLeader.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, __instance.entityId, true, isMelee), false, myLeader.entityId, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf Extended SetAuraChance");
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), myLeader.entityId, myLeader.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, true, isMelee, __instance.entityId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (_eventType == MinEventTypes.onSelfDamagedOther && minEventContext.Other is EntityPlayer)
|
||||
{
|
||||
//Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
}*/
|
||||
|
||||
if ((_eventType == MinEventTypes.onSelfDamagedOther || _eventType == MinEventTypes.onSelfKilledOther) && SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && (minEventContext.ItemValue != null && minEventContext.ItemValue.ItemClass != null && (minEventContext.ItemValue.ItemClass.GetItemName().ToLower().StartsWith("gunbot") || minEventContext.ItemValue.ItemClass.GetItemName().ToLower().StartsWith("furiousramsayjunkturret"))))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA1a, minEventContext.ItemValue.ItemClass.GetItemName(): " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA1a, entity: " + __instance.EntityClass.entityClassName);
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA1a, __instance is EntityPlayerLocal: " + (__instance is EntityPlayerLocal));
|
||||
|
||||
if (!(__instance is EntityPlayerLocal))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA1b, entityID: " + __instance.entityId);
|
||||
|
||||
int eventType = -1;
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
eventType = 1;
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfDamagedOther)
|
||||
{
|
||||
eventType = 2;
|
||||
}
|
||||
|
||||
string heldItem = "";
|
||||
|
||||
if (minEventContext.ItemValue != null)
|
||||
{
|
||||
heldItem = minEventContext.ItemValue.ItemClass.GetItemName();
|
||||
}
|
||||
|
||||
int targetEntityID = minEventContext.Other.entityId;
|
||||
int playerEntityID = __instance.entityId;
|
||||
bool isHeadShot = (minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head);
|
||||
int biomeID = minEventContext.Biome.m_Id;
|
||||
|
||||
if (RebirthUtilities.VerifyFactionStanding(__instance, minEventContext.Other))
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageSetAuraChance>().Setup(minEventContext.ItemValue.ItemClass.GetItemName(), __instance.entityId, (int)__instance.Buffs.GetCustomVar("$ActiveClass_FR"), minEventContext.Other.entityId, -1, false, false), false, __instance.entityId, -1, -1, null, 192);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageProcessDamageXP>().Setup(heldItem, biomeID, isHeadShot, playerEntityID, targetEntityID, eventType), false, __instance.entityId, -1, -1, null, 192);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA2a, entity: " + __instance.EntityClass.entityClassName);
|
||||
//Log.Out("EntityAlivePatches-FireEvent AA2b, entityID: " + __instance.entityId);
|
||||
}
|
||||
}
|
||||
|
||||
// LEARN BY DOING
|
||||
if (__instance is EntityPlayerLocal && minEventContext.Biome != null && minEventContext.ItemValue != null && __instance.IsAlive())
|
||||
{
|
||||
if (_eventType == MinEventTypes.onSelfAction2Start)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (minEventContext.ItemValue == null || minEventContext.ItemValue.ItemClass == null)
|
||||
{
|
||||
// todo fix the problem with ItemClass. NRE from punching grass - ItemClass == null here
|
||||
//Log.Out($"minEventContext.ItemValue: {minEventContext.ItemValue}, itemClass: {minEventContext.ItemValue.ItemClass}");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent _eventType: " + _eventType);
|
||||
//Log.Out("EntityAlivePatches-FireEvent Class Name: " + minEventContext.ItemValue.ItemClass.Name);
|
||||
//Log.Out("EntityAlivePatches-FireEvent GetItemName: " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
|
||||
float activeClassID = __instance.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfDestroyedBlock ||
|
||||
_eventType == MinEventTypes.onSelfDamagedBlock
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfDestroyedBlock");
|
||||
if (_eventType == MinEventTypes.onSelfDestroyedBlock && minEventContext.BlockValue.Block.Tags.Test_AllSet(FastTags<TagGroup.Global>.Parse("FuriousRamsayFarmedCrops")))
|
||||
{
|
||||
string tag = "$varFuriousRamsayAchievementCropsExp";
|
||||
string notification = Localization.Get("GreenThumbsProgression");
|
||||
RebirthUtilities.ProcessAchievement(__instance, tag, notification);
|
||||
}
|
||||
|
||||
//float classMultiplierOption = float.Parse(RebirthVariables.customClassXPMultiplier) / 100;
|
||||
float geneticsMultiplierOption = float.Parse(RebirthVariables.customGeneticsXPMultiplier) / 100;
|
||||
|
||||
float experienceModMultiplier = __instance.Buffs.GetCustomVar("$GeneticsExpIncrease");
|
||||
if (experienceModMultiplier > 0)
|
||||
{
|
||||
geneticsMultiplierOption = geneticsMultiplierOption + (geneticsMultiplierOption * experienceModMultiplier);
|
||||
}
|
||||
|
||||
bool isVehicle = RebirthUtilities.HasFilterTag(minEventContext.BlockValue.Block, "SC_automotive");
|
||||
bool isSalvageTool = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("salvagingskill");
|
||||
bool noXP = minEventContext.BlockValue.Block.Tags.Test_AllSet(FastTags<TagGroup.Global>.Parse("MNoXP"));
|
||||
bool canSalvage = RebirthUtilities.CanHarvest(minEventContext.BlockValue.Block, "salvageHarvest");
|
||||
|
||||
bool isStone = minEventContext.BlockValue.Block.blockMaterial.SurfaceCategory == "stone";
|
||||
bool isWood = minEventContext.BlockValue.Block.blockMaterial.SurfaceCategory == "wood";
|
||||
bool isEarth = minEventContext.BlockValue.Block.blockMaterial.SurfaceCategory == "earth";
|
||||
bool isMetal = minEventContext.BlockValue.Block.blockMaterial.SurfaceCategory == "metal";
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent isStone: " + isStone);
|
||||
//Log.Out("EntityAlivePatches-FireEvent isWood: " + isWood);
|
||||
//Log.Out("EntityAlivePatches-FireEvent isEarth: " + isEarth);
|
||||
//Log.Out("EntityAlivePatches-FireEvent isMetal: " + isMetal);
|
||||
|
||||
float maxBlockDamage = minEventContext.BlockValue.Block.MaxDamage;
|
||||
float maxMaterialDamage = minEventContext.BlockValue.Block.blockMaterial.MaxDamage;
|
||||
float blockDamageDealt = RebirthVariables.damageGiven;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent maxBlockDamage: " + maxBlockDamage);
|
||||
//Log.Out("EntityAlivePatches-FireEvent maxMaterialDamage: " + maxMaterialDamage);
|
||||
//Log.Out("EntityAlivePatches-FireEvent canSalvage: " + canSalvage);
|
||||
//Log.Out("EntityAlivePatches-FireEvent SC_automotive: " + isVehicle);
|
||||
//Log.Out("EntityAlivePatches-FireEvent isSalvageTool: " + isSalvageTool);
|
||||
|
||||
if (!noXP)
|
||||
{
|
||||
int playerLevelTier = RebirthUtilities.GetPlayerLevelTier(__instance);
|
||||
string keyName = "";
|
||||
string cvarName = "";
|
||||
string categoryName = "";
|
||||
bool isValid = false;
|
||||
|
||||
bool miningTool = minEventContext.ItemValue.ItemClass.ItemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("miningTool"));
|
||||
bool diggingTool = minEventContext.ItemValue.ItemClass.ItemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("shovel"));
|
||||
bool choppingTool = minEventContext.ItemValue.ItemClass.ItemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("axe"));
|
||||
|
||||
if (maxBlockDamage >= 25)
|
||||
{
|
||||
if (miningTool && (isStone || isMetal))
|
||||
{
|
||||
keyName = "Strength";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseStrengthBreakingOreTier" + playerLevelTier;
|
||||
isValid = true;
|
||||
}
|
||||
else if (choppingTool && isWood)
|
||||
{
|
||||
keyName = "Strength";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseCutTreesTier" + playerLevelTier;
|
||||
isValid = true;
|
||||
}
|
||||
else if (diggingTool && isEarth)
|
||||
{
|
||||
keyName = "Strength";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseStrengthDiggingTier" + playerLevelTier;
|
||||
isValid = true;
|
||||
}
|
||||
else if (isSalvageTool && canSalvage)
|
||||
{
|
||||
keyName = "Intelligence";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsaySalvageTier" + playerLevelTier;
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
float num = RebirthVariables.localVariables[cvarName] + (RebirthVariables.localConstants[categoryName] * (blockDamageDealt) * geneticsMultiplierOption);
|
||||
//Log.Out("EntityAlivePatches-FireEvent cvarName: " + cvarName);
|
||||
//Log.Out("EntityAlivePatches-FireEvent categoryName: " + categoryName);
|
||||
//Log.Out("EntityAlivePatches-FireEvent RebirthVariables.localVariables[cvarName]: " + RebirthVariables.localVariables[cvarName]);
|
||||
//Log.Out("EntityAlivePatches-FireEvent RebirthVariables.localConstants[categoryName]: " + RebirthVariables.localConstants[categoryName]);
|
||||
//Log.Out("EntityAlivePatches-FireEvent num: " + num);
|
||||
RebirthUtilities.GetMaxGeneticsProgression(ref num, keyName);
|
||||
RebirthVariables.localVariables[cvarName] = num;
|
||||
RebirthUtilities.ProcessAttribute(__instance, cvarName);
|
||||
}
|
||||
|
||||
if (isSalvageTool && canSalvage)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent CAN HARVEST");
|
||||
|
||||
float increment = 0f;
|
||||
string currentCategory = "SalvageTools";
|
||||
float currentValue = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"];
|
||||
|
||||
increment = RebirthUtilities.GetCraftingIncrement(currentCategory, currentValue);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent increment BEFORE : " + increment);
|
||||
//Log.Out("EntityAlivePatches-FireEvent blockDamageDealt: " + blockDamageDealt);
|
||||
//Log.Out("EntityAlivePatches-FireEvent geneticsMultiplierOption: " + geneticsMultiplierOption);
|
||||
|
||||
increment = increment * blockDamageDealt * geneticsMultiplierOption;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent increment AFTER : " + increment);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentValue: " + currentValue);
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentCategory: " + currentCategory);
|
||||
//Log.Out("EntityAlivePatches-FireEvent increment: " + increment);
|
||||
|
||||
float num = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] + increment;
|
||||
if (num > 10)
|
||||
{
|
||||
num = 10;
|
||||
}
|
||||
RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] = num;
|
||||
//Log.Out("EntityAlivePatches-FireEvent $varFuriousRamsay" + currentCategory + "PercUnit: " + RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"]);
|
||||
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsay" + currentCategory + "PercUnit");
|
||||
}
|
||||
if (miningTool && (isStone || isMetal))
|
||||
{
|
||||
float increment = 0f;
|
||||
string currentCategory = "Mine";
|
||||
float currentValue = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"];
|
||||
|
||||
increment = RebirthUtilities.GetCraftingIncrement(currentCategory, currentValue);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentValue: " + currentValue);
|
||||
//Log.Out("EntityAlivePatches-FireEvent increment BEFORE : " + increment);
|
||||
//Log.Out("EntityAlivePatches-FireEvent blockDamageDealt: " + blockDamageDealt);
|
||||
//Log.Out("EntityAlivePatches-FireEvent geneticsMultiplierOption: " + geneticsMultiplierOption);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentCategory: " + currentCategory);
|
||||
//Log.Out("EntityAlivePatches-FireEvent BEFORE $varFuriousRamsay" + currentCategory + "PercUnit: " + RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"]);
|
||||
|
||||
increment = increment * blockDamageDealt * geneticsMultiplierOption;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent increment AFTER : " + increment);
|
||||
|
||||
float num = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] + increment;
|
||||
if (num > 10)
|
||||
{
|
||||
num = 10;
|
||||
}
|
||||
RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] = num;
|
||||
//Log.Out("EntityAlivePatches-FireEvent AFTER $varFuriousRamsay" + currentCategory + "PercUnit: " + RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"]);
|
||||
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsay" + currentCategory + "PercUnit");
|
||||
}
|
||||
if (choppingTool && isWood)
|
||||
{
|
||||
float increment = 0f;
|
||||
string currentCategory = "Chop";
|
||||
float currentValue = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"];
|
||||
|
||||
increment = RebirthUtilities.GetCraftingIncrement(currentCategory, currentValue);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent BEFORE increment: " + increment);
|
||||
|
||||
increment = increment * blockDamageDealt * geneticsMultiplierOption;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentCategory: " + currentCategory);
|
||||
//Log.Out("EntityAlivePatches-FireEvent AFTER increment: " + increment);
|
||||
|
||||
float num = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] + increment;
|
||||
if (num > 10)
|
||||
{
|
||||
num = 10;
|
||||
}
|
||||
RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] = num;
|
||||
//Log.Out("EntityAlivePatches-FireEvent $varFuriousRamsay" + currentCategory + "PercUnit: " + RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"]);
|
||||
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsay" + currentCategory + "PercUnit");
|
||||
}
|
||||
if (diggingTool && isEarth)
|
||||
{
|
||||
float increment = 0f;
|
||||
string currentCategory = "Dig";
|
||||
float currentValue = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"];
|
||||
|
||||
increment = RebirthUtilities.GetCraftingIncrement(currentCategory, currentValue);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent BEFORE increment: " + increment);
|
||||
|
||||
increment = increment * blockDamageDealt * geneticsMultiplierOption;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent currentCategory: " + currentCategory);
|
||||
//Log.Out("EntityAlivePatches-FireEvent AFTER increment: " + increment);
|
||||
|
||||
float num = RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] + increment;
|
||||
if (num > 10)
|
||||
{
|
||||
num = 10;
|
||||
}
|
||||
RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"] = num;
|
||||
//Log.Out("EntityAlivePatches-FireEvent $varFuriousRamsay" + currentCategory + "PercUnit: " + RebirthVariables.localVariables["$varFuriousRamsay" + currentCategory + "PercUnit"]);
|
||||
|
||||
RebirthUtilities.ProcessAttribute(__instance, "$varFuriousRamsay" + currentCategory + "PercUnit");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_eventType == MinEventTypes.onOtherDamagedSelf)
|
||||
{
|
||||
List<string> tagNames = minEventContext.ItemValue.ItemClass.ItemTags.GetTagNames();
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf");
|
||||
string optionCustomAuraDefense = RebirthVariables.customAuraDefense;
|
||||
|
||||
bool canTrigger = false;
|
||||
float triggerChance = __instance.Buffs.GetCustomVar("$AuraOtherDamageSelfIncrease") * 100;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf AURA triggerChance: " + triggerChance);
|
||||
|
||||
if (triggerChance > 0)
|
||||
{
|
||||
int random = __instance.rand.RandomRange(1, 100);
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf AURA random: " + random);
|
||||
|
||||
if (random <= triggerChance)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf AURA CAN TRIGGER");
|
||||
canTrigger = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((optionCustomAuraDefense == "on" || optionCustomAuraDefense == "cooldown") && canTrigger)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, GetItemName: " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, __instance.entityId: " + __instance.entityId);
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, minEventContext.Other.entityId: " + minEventContext.Other.entityId);
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, __instance.entityClassName: " + __instance.EntityClass.entityClassName);
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, Other.entityClassName: " + minEventContext.Other.EntityClass.entityClassName);
|
||||
|
||||
if (minEventContext.ItemValue != null && minEventContext.Other != null)
|
||||
{
|
||||
if (__instance.entityId != minEventContext.Other.entityId)
|
||||
{
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), __instance.entityId, activeClassID, minEventContext.Other.entityId, true, isMelee, -1, true);
|
||||
}
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, GetItemName: " + minEventContext.ItemValue.ItemClass.GetItemName());
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf, minEventContext.Other.entityId: " + minEventContext.Other.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfPrimaryActionStart)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart");
|
||||
float geneticsMultiplierOption = float.Parse(RebirthVariables.customGeneticsXPMultiplier) / 100;
|
||||
int playerLevelTier = RebirthUtilities.GetPlayerLevelTier(__instance);
|
||||
string keyName = "";
|
||||
string cvarName = "";
|
||||
string categoryName = "";
|
||||
bool isValid = false;
|
||||
|
||||
string itemName = minEventContext.ItemValue.ItemClass.GetItemName();
|
||||
FastTags<TagGroup.Global> itemTags = minEventContext.ItemValue.ItemClass.ItemTags;
|
||||
|
||||
bool hasCooldown = __instance.Buffs.HasBuff("FuriousRamsayUsedDrugsCountdown");
|
||||
|
||||
if (itemName.EndsWith("Schematic"))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart 1");
|
||||
keyName = "Intelligence";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseIntelligenceReadSchematic";
|
||||
isValid = true;
|
||||
}
|
||||
else if (!hasCooldown && itemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("medicalLow")))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart 2");
|
||||
keyName = "Constitution";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseUseDrugsLowTier" + playerLevelTier;
|
||||
__instance.Buffs.AddBuff("FuriousRamsayUsedDrugsCountdown");
|
||||
isValid = true;
|
||||
}
|
||||
else if (!hasCooldown && itemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("medicalMedium")))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart 3");
|
||||
keyName = "Constitution";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseUseDrugsMediumTier" + playerLevelTier;
|
||||
__instance.Buffs.AddBuff("FuriousRamsayUsedDrugsCountdown");
|
||||
isValid = true;
|
||||
}
|
||||
else if (!hasCooldown && itemTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("medicalHigh")))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart 4");
|
||||
keyName = "Constitution";
|
||||
cvarName = "$varFuriousRamsay" + keyName + "PercUnit";
|
||||
categoryName = "$varFuriousRamsayIncreaseUseDrugsHighTier" + playerLevelTier;
|
||||
__instance.Buffs.AddBuff("FuriousRamsayUsedDrugsCountdown");
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart geneticsMultiplierOption: " + geneticsMultiplierOption);
|
||||
//Log.Out($"EntityAlivePatches-FireEvent onSelfPrimaryActionStart RebirthVariables.localConstants[{categoryName}]: " + RebirthVariables.localConstants[categoryName]);
|
||||
//Log.Out($"EntityAlivePatches-FireEvent onSelfPrimaryActionStart RebirthVariables.localVariables[{cvarName}]: " + RebirthVariables.localVariables[cvarName]);
|
||||
|
||||
float num = RebirthVariables.localVariables[cvarName] + (RebirthVariables.localConstants[categoryName] * geneticsMultiplierOption);
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfPrimaryActionStart num: " + num);
|
||||
RebirthUtilities.GetMaxGeneticsProgression(ref num, keyName);
|
||||
|
||||
//Log.Out($"EntityAlivePatches-FireEvent onSelfPrimaryActionStart GetMaxGeneticsProgression(ref num, {keyName}): " + num);
|
||||
|
||||
RebirthVariables.localVariables[cvarName] = num;
|
||||
RebirthUtilities.ProcessAttribute(__instance, cvarName);
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfJump ||
|
||||
_eventType == MinEventTypes.onSelfRun ||
|
||||
_eventType == MinEventTypes.onReloadStart ||
|
||||
_eventType == MinEventTypes.onSelfAimingGunStart
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfJump");
|
||||
bool hasMobilityCooldown = __instance.Buffs.HasBuff("FuriousRamsayUsedMobilityCountdown");
|
||||
|
||||
if (!hasMobilityCooldown)
|
||||
{
|
||||
RebirthUtilities.ProcessGeneticsLBD(__instance, "Dexterity", "IncreaseMobility");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayUsedMobilityCountdown");
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfLootContainer)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfLootContainer");
|
||||
RebirthUtilities.ProcessGeneticsLBD(__instance, "Intelligence", "IncreaseLooted");
|
||||
//Log.Out("EntityAlivePatches-FireEvent $varFuriousRamsayIntelligencePercUnit: " + RebirthVariables.localVariables["$varFuriousRamsayIntelligencePercUnit"]);
|
||||
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onOtherDamagedSelf)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onOtherDamagedSelf");
|
||||
|
||||
bool hasBuff = __instance.Buffs.HasBuff("FuriousRamsayOtherDamagedSelfCountdown");
|
||||
|
||||
if (!hasBuff)
|
||||
{
|
||||
RebirthUtilities.ProcessGeneticsLBD(__instance, "Constitution", "IncreaseReceivedDamage");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayOtherDamagedSelfCountdown");
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfSecondaryActionRayHit && minEventContext.Other is EntityZombieSDX)
|
||||
{
|
||||
List<string> tagNames = minEventContext.ItemValue.ItemClass.ItemTags.GetTagNames();
|
||||
bool isTwoHanded = RebirthUtilities.hasTag(tagNames, "TwoHanded");
|
||||
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
bool bMindControlled = minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") || minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") || minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
||||
|
||||
ProgressionValue progressionValue = __instance.Progression.GetProgressionValue("perkMeleeDamage");
|
||||
float perkLevel = RebirthUtilities.GetCalculatedLevel(__instance, progressionValue);
|
||||
|
||||
float distance = perkLevel * 0.2f;
|
||||
|
||||
if (isTwoHanded)
|
||||
{
|
||||
distance = distance * 1.5f;
|
||||
}
|
||||
|
||||
Vector3 AoEDistance = new Vector3(distance, distance, distance);
|
||||
|
||||
int chance = (int)perkLevel * 5;
|
||||
|
||||
if (!minEventContext.Other.IsDead() && !bMindControlled && __instance.rand.RandomRange(0, 100) < chance)
|
||||
{
|
||||
if (isMelee && minEventContext.ItemActionData.hitInfo != null)
|
||||
{
|
||||
List<EntityAlive> entsInRange = GameManager.Instance.World.GetLivingEntitiesInBounds(minEventContext.Other, new Bounds(minEventContext.Other.position, AoEDistance));
|
||||
for (int index = 0; index < entsInRange.Count; ++index)
|
||||
{
|
||||
if (entsInRange[index] is EntityZombieSDX)
|
||||
{
|
||||
bool isMindControlled = entsInRange[index].Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") || entsInRange[index].Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") || entsInRange[index].Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
||||
|
||||
if (!isMindControlled)
|
||||
{
|
||||
ItemActionDynamic itemAction = (ItemActionDynamic)__instance.inventory.holdingItem.Actions[minEventContext.ItemActionData.indexInEntityOfAction];
|
||||
float damageEntity = itemAction.GetDamageEntity(minEventContext.ItemValue, __instance, minEventContext.ItemActionData.indexInEntityOfAction);
|
||||
DamageSourceEntity _damageSource = new DamageSourceEntity(EnumDamageSource.External, EnumDamageTypes.Bashing, __instance.entityId, minEventContext.ItemActionData.hitInfo.ray.direction, minEventContext.ItemActionData.hitInfo.transform.name, minEventContext.ItemActionData.hitInfo.hit.pos, Voxel.phyxRaycastHit.textureCoord);
|
||||
entsInRange[index].DamageEntity(_damageSource, (int)damageEntity, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfDamagedOther || _eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent A onSelfDamagedOther/onSelfKilledOther");
|
||||
|
||||
List<string> tagNames = minEventContext.ItemValue.ItemClass.ItemTags.GetTagNames();
|
||||
|
||||
bool bMindControlled = minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier1") || minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier2") || minEventContext.Other.Buffs.HasBuff("FuriousRamsayRangedMindControlBuffTier3");
|
||||
|
||||
if (!(minEventContext.Other.IsDead() && _eventType == MinEventTypes.onSelfDamagedOther) && !bMindControlled)
|
||||
{
|
||||
bool bShotgun = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("shotgun"); //__instance.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("shotgun");
|
||||
bool canProceed = true;
|
||||
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
|
||||
if (canProceed)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent B onSelfDamagedOther/onSelfKilledOther");
|
||||
if (_eventType == MinEventTypes.onSelfDamagedOther)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent onSelfDamagedOther");
|
||||
|
||||
bool bRanged = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("ranged"); //__instance.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("ranged");
|
||||
|
||||
bool bBow = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("furiousramsayregularbows"); //__instance.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("furiousramsayregularbows");
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent activeClassID: " + activeClassID);
|
||||
//Log.Out("EntityAlivePatches-FireEvent bBow: " + bBow);
|
||||
|
||||
bool isInside = false; // minEventContext.Other.Stats.AmountEnclosed > 0f && !minEventContext.Other.Climbing;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent Amount IsIndoors: " + isInside);
|
||||
|
||||
bool bSpear = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1spears");
|
||||
bool bClub = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1clubs");
|
||||
bool bSword = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1swords");
|
||||
bool bAxe = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1axes");
|
||||
bool bBaton = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1batons");
|
||||
bool bKnuckles = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1knuckles");
|
||||
bool bHammer = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1hammers");
|
||||
bool bKnife = minEventContext.ItemValue.ItemClass.ItemTags.ToString().ToLower().Contains("weapontier1knives");
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent bRanged:" + bRanged);
|
||||
//Log.Out("EntityAlivePatches-FireEvent bSword:" + bSword);
|
||||
//Log.Out("EntityAlivePatches-FireEvent activeClassID: " + activeClassID);
|
||||
|
||||
bool isClassActive = RebirthUtilities.IsClassActive(3);
|
||||
|
||||
bool isMeleeTrigger = (RebirthUtilities.IsClassActive(1) && bSpear) ||
|
||||
(RebirthUtilities.IsClassActive(2) && bClub) ||
|
||||
(RebirthUtilities.IsClassActive(3) && bSword) ||
|
||||
(RebirthUtilities.IsClassActive(4) && bAxe) ||
|
||||
(RebirthUtilities.IsClassActive(5) && bBaton) ||
|
||||
(RebirthUtilities.IsClassActive(6) && bKnuckles) ||
|
||||
(RebirthUtilities.IsClassActive(7) && bHammer) ||
|
||||
(RebirthUtilities.IsClassActive(8) && bKnife);
|
||||
|
||||
if ((bRanged || isMelee) && __instance.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent SET AURA CHANCE");
|
||||
|
||||
if (RebirthUtilities.VerifyFactionStanding(__instance, minEventContext.Other))
|
||||
{
|
||||
if (bShotgun)
|
||||
{
|
||||
if (RebirthVariables.canShotgunTrigger)
|
||||
{
|
||||
ItemActionAttack holdingGun = (ItemActionAttack)minEventContext.ItemValue.ItemClass.Actions[0];
|
||||
|
||||
RebirthUtilities.SetDismemberChance(__instance, minEventContext.Other, minEventContext.ItemValue.SelectedAmmoTypeIndex, minEventContext.ItemValue);
|
||||
if (!RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), __instance.entityId, activeClassID, minEventContext.Other.entityId, true, isMeleeTrigger);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SetBonusChance(minEventContext.ItemValue, __instance, minEventContext.Other, false, false);
|
||||
}
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.delayShotgunTrigger(1.0f));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool setAuraChance = true;
|
||||
bool setDismemberChance = true;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent minEventContext.ItemValue.ItemClass.Name: " + minEventContext.ItemValue.ItemClass.Name);
|
||||
|
||||
if (bRanged && __instance is EntityPlayer) // && minEventContext.ItemValue != null && minEventContext.ItemValue.ItemClass.Name.Contains("gunBot"))
|
||||
{
|
||||
ItemActionAttack holdingGun = (ItemActionAttack)minEventContext.ItemValue.ItemClass.Actions[0];
|
||||
|
||||
if (holdingGun != null)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent holdingGun.item.Name: " + holdingGun.item.Name);
|
||||
//Log.Out("EntityAlivePatches-FireEvent holdingGun.MagazineItemNames.Length: " + holdingGun.MagazineItemNames.Length);
|
||||
//Log.Out("EntityAlivePatches-FireEvent minEventContext.ItemValue.SelectedAmmoTypeIndex: " + minEventContext.ItemValue.SelectedAmmoTypeIndex);
|
||||
//Log.Out("EntityAlivePatches-FireEvent holdingGun.MagazineItemNames[minEventContext.ItemValue.SelectedAmmoTypeIndex]: " + holdingGun.MagazineItemNames[minEventContext.ItemValue.SelectedAmmoTypeIndex]);
|
||||
|
||||
ItemValue itemValue = ItemClass.GetItem(holdingGun.MagazineItemNames[minEventContext.ItemValue.SelectedAmmoTypeIndex], false);
|
||||
|
||||
if (itemValue != null)
|
||||
{
|
||||
string ammoType = ItemClass.GetItem(holdingGun.MagazineItemNames[minEventContext.ItemValue.SelectedAmmoTypeIndex], false).ItemClass.GetItemName();
|
||||
|
||||
if (ammoType.ToLower().Contains("mindcontrol"))
|
||||
{
|
||||
setAuraChance = false;
|
||||
setDismemberChance = false;
|
||||
}
|
||||
|
||||
if (setDismemberChance)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent setDismemberChance ammoType: " + ammoType);
|
||||
RebirthUtilities.SetDismemberChance(__instance, minEventContext.Other, minEventContext.ItemValue.SelectedAmmoTypeIndex, minEventContext.ItemValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (setAuraChance && minEventContext.ItemValue != null && !RebirthUtilities.hasTag(tagNames, "motorTool"))
|
||||
{
|
||||
bool isPrimaryAttack = true;
|
||||
|
||||
if (isMelee && !RebirthUtilities.hasTag(tagNames, "throwable"))
|
||||
{
|
||||
isPrimaryAttack = !minEventContext.ItemValue.ItemClass.Actions[1].IsActionRunning(__instance.inventory.GetItemActionDataInSlot(__instance.inventory.holdingItemIdx, 1));
|
||||
}
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent isPrimaryAttack: " + isPrimaryAttack);
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
RebirthUtilities.SetAuraChance(minEventContext.ItemValue, minEventContext.ItemValue.ItemClass.GetItemName(), __instance.entityId, activeClassID, minEventContext.Other.entityId, true, isMelee, -1, false, false, isPrimaryAttack);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SetBonusChance(minEventContext.ItemValue, __instance, minEventContext.Other, isMelee, isPrimaryAttack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isClassActive)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent TAGS: " + __instance.inventory.holdingItem.ItemTags.ToString());
|
||||
|
||||
if (bSword)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent IS SWORD");
|
||||
|
||||
ProgressionValue butcherProgressionValue = __instance.Progression.GetProgressionValue("furiousramsayattbutcher");
|
||||
|
||||
if (butcherProgressionValue != null)
|
||||
{
|
||||
int butcherProgressionLevel = butcherProgressionValue.Level;
|
||||
|
||||
if (minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.LeftLowerLeg ||
|
||||
minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.RightLowerLeg ||
|
||||
minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.LeftUpperLeg ||
|
||||
minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.RightUpperLeg
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent LEGS");
|
||||
minEventContext.Other.Buffs.AddBuff("FuriousRamsayBleedDamageHinderLevel" + butcherProgressionLevel);
|
||||
}
|
||||
//minEventContext.Other.Buffs.AddBuff("FuriousRamsayBleedDamageLevel" + butcherProgressionLevel, __instance.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
bool isChargedAssault = false;
|
||||
__instance.Buffs.SetCustomVar(".FuriousRamsayHPAmmo", 0);
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(2))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent IS THUG, tag: " + tagNames[i]);
|
||||
if (tagNames[i] == "WeaponTier1Clubs")
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent IS CLUB");
|
||||
if (__instance.CurrentMovementTag.Test_AllSet(FastTags<TagGroup.Global>.Parse("running")))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent IS RUNNING");
|
||||
isChargedAssault = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isChargedAssault)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("FuriousRamsayThump2", -1, 0f, false);
|
||||
string tag = "$varFuriousRamsayAchievementChargedAssaultExp";
|
||||
string notification = Localization.Get("ChargedAssaultProgression");
|
||||
RebirthUtilities.ProcessAchievement(__instance, tag, notification);
|
||||
}
|
||||
}
|
||||
|
||||
int eventType = -1;
|
||||
|
||||
bool isHeadShot = (minEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head);
|
||||
|
||||
if (_eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
eventType = 1;
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"]++;
|
||||
if (isHeadShot)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNHeadShots_Cst"]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_eventType == MinEventTypes.onSelfDamagedOther)
|
||||
{
|
||||
eventType = 2;
|
||||
}
|
||||
|
||||
string heldItem = "";
|
||||
|
||||
if (minEventContext.ItemValue != null && minEventContext.ItemValue.ItemClass != null)
|
||||
{
|
||||
heldItem = minEventContext.ItemValue.ItemClass.GetItemName();
|
||||
}
|
||||
|
||||
int targetEntityID = minEventContext.Other.entityId;
|
||||
int playerEntityID = __instance.entityId;
|
||||
int biomeID = minEventContext.Biome.m_Id;
|
||||
|
||||
RebirthUtilities.ProcessDamageXP(heldItem, biomeID, isHeadShot, playerEntityID, targetEntityID, eventType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NATURAL SELECTION
|
||||
if (__instance is EntityPlayerLocal && _eventType == MinEventTypes.onSelfKilledOther)
|
||||
{
|
||||
bool isNaturalSelectionCountingOn = RebirthUtilities.IsNaturalSelectionCountingOn();
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent isNaturalSelectionCountingOn: " + isNaturalSelectionCountingOn);
|
||||
|
||||
if (isNaturalSelectionCountingOn)
|
||||
{
|
||||
int playerKills = (int)__instance.Buffs.GetCustomVar("$NaturalSelection_FR"); //__instance.KilledZombies;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent playerKills: " + playerKills);
|
||||
|
||||
float playerKills01 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection01_Cst"];
|
||||
float playerKills02 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection02_Cst"];
|
||||
float playerKills03 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection03_Cst"];
|
||||
float playerKills04 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection04_Cst"];
|
||||
float playerKills05 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection05_Cst"];
|
||||
float playerKills06 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection06_Cst"];
|
||||
float playerKills07 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection07_Cst"];
|
||||
float playerKills08 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection08_Cst"];
|
||||
float playerKills09 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection09_Cst"];
|
||||
float playerKills10 = RebirthVariables.localConstants["$varFuriousRamsayNaturalSelection10_Cst"];
|
||||
|
||||
bool playSound = false;
|
||||
int progressionLevel = 0;
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent entityClassName: " + __instance.EntityClass.entityClassName);
|
||||
|
||||
ProgressionValue progressionValue = __instance.Progression.GetProgressionValue("FuriousRamsayNaturalSelection");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = progressionValue.Level;
|
||||
//Log.Out("EntityAlivePatches-FireEvent progressionLevel: " + progressionLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent RETURN");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (playerKills >= playerKills01 && playerKills < playerKills02)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 1");
|
||||
if (progressionLevel < 1)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 2");
|
||||
playSound = true;
|
||||
progressionLevel = 1;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills02 && playerKills < playerKills03)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 3");
|
||||
if (progressionLevel < 2)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 4");
|
||||
playSound = true;
|
||||
progressionLevel = 2;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills03 && playerKills < playerKills04)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 5");
|
||||
if (progressionLevel < 3)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 6");
|
||||
playSound = true;
|
||||
progressionLevel = 3;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills04 && playerKills < playerKills05)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 7");
|
||||
if (progressionLevel < 4)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 8");
|
||||
playSound = true;
|
||||
progressionLevel = 4;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills05 && playerKills < playerKills06)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent ");
|
||||
if (progressionLevel < 5)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent ");
|
||||
playSound = true;
|
||||
progressionLevel = 5;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills06 && playerKills < playerKills07)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 9");
|
||||
if (progressionLevel < 6)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 10");
|
||||
playSound = true;
|
||||
progressionLevel = 6;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills07 && playerKills < playerKills08)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 11");
|
||||
if (progressionLevel < 7)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 12");
|
||||
playSound = true;
|
||||
progressionLevel = 7;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills08 && playerKills < playerKills09)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 13");
|
||||
if (progressionLevel < 8)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 14");
|
||||
playSound = true;
|
||||
progressionLevel = 8;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills09 && playerKills < playerKills10)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 15");
|
||||
if (progressionLevel < 9)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 15");
|
||||
playSound = true;
|
||||
progressionLevel = 9;
|
||||
}
|
||||
}
|
||||
else if (playerKills >= playerKills10)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 17");
|
||||
if (progressionLevel < 10)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent 18");
|
||||
playSound = true;
|
||||
progressionLevel = 10;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityAlivePatches-FireEvent playSound: " + playSound);
|
||||
|
||||
if (playSound)
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-FireEvent new progressionLevel: " + progressionLevel);
|
||||
|
||||
Manager.PlayInsidePlayerHead("FuriousRamsayNaturalSelection");
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.messageHUD(__instance as EntityPlayerLocal, 3f, "miseryPlayerKill"));
|
||||
|
||||
progressionValue.Level = progressionLevel;
|
||||
__instance.Progression.bProgressionStatsChanged = !__instance.isEntityRemote;
|
||||
__instance.bPlayerStatsChanged |= !__instance.isEntityRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float flPermadeath = __instance.Buffs.GetCustomVar("$varFuriousRamsayPermadeath");
|
||||
float flLoseInventory = __instance.Buffs.GetCustomVar("$varFuriousRamsayLoseInventory");
|
||||
|
||||
if (__instance is global::EntityPlayer && (flPermadeath == 1 || flLoseInventory == 1))
|
||||
{
|
||||
//Log.Out("EntityAlivePatches-OnEntityDeath PERMADEATH IS ON");
|
||||
if (__instance.AttachedToEntity)
|
||||
{
|
||||
__instance.Detach();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// virtual method. Only EntityTurret and EntityVehicle override this method
|
||||
[HarmonyPatch(typeof(EntityAlive), "damageEntityLocal")]
|
||||
public class damageEntityLocal
|
||||
{
|
||||
private static float GetDamageFraction(float _damage, EntityAlive __instance)
|
||||
{
|
||||
return _damage / (float)__instance.GetMaxHealth();
|
||||
}
|
||||
|
||||
private static bool Prefix(ref EntityAlive __instance, ref DamageResponse __result, DamageSource _damageSource, int _strength, bool _criticalHit, float impulseScale)
|
||||
{
|
||||
DamageResponse damageResponse = new()
|
||||
{
|
||||
Source = _damageSource,
|
||||
Strength = _strength,
|
||||
Critical = _criticalHit,
|
||||
HitDirection = Utils.EnumHitDirection.None,
|
||||
MovementState = __instance.MovementState,
|
||||
Random = __instance.rand.RandomFloat,
|
||||
ImpulseScale = impulseScale,
|
||||
HitBodyPart = _damageSource.GetEntityDamageBodyPart(__instance),
|
||||
ArmorSlot = _damageSource.GetEntityDamageEquipmentSlot(__instance),
|
||||
ArmorSlotGroup = _damageSource.GetEntityDamageEquipmentSlotGroup(__instance)
|
||||
};
|
||||
|
||||
if (_strength > 0)
|
||||
{
|
||||
damageResponse.HitDirection = (_damageSource.Equals(DamageSource.fall) ? Utils.EnumHitDirection.Back : ((Utils.EnumHitDirection)Utils.Get4HitDirectionAsInt(_damageSource.getDirection(), __instance.GetLookVector())));
|
||||
}
|
||||
|
||||
if (!GameManager.IsDedicatedServer && _damageSource.damageSource != EnumDamageSource.Internal && GameManager.Instance != null)
|
||||
{
|
||||
World world = GameManager.Instance.World;
|
||||
|
||||
if (world != null && _damageSource.getEntityId() == world.GetPrimaryPlayerId())
|
||||
{
|
||||
Transform hitTransform = __instance.emodel.GetHitTransform(_damageSource);
|
||||
Vector3 position = __instance.emodel.transform.position;
|
||||
|
||||
if (hitTransform != null)
|
||||
{
|
||||
position = hitTransform.position;
|
||||
}
|
||||
|
||||
bool flag = world.GetPrimaryPlayer().inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged"));
|
||||
float magnitude = (world.GetPrimaryPlayer().GetPosition() - position).magnitude;
|
||||
|
||||
if (flag && magnitude > EntityAlive.HitSoundDistance)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("HitEntitySound", -1, 0f, false);
|
||||
}
|
||||
|
||||
if (EntityAlive.ShowDebugDisplayHit)
|
||||
{
|
||||
Transform transform = hitTransform ? hitTransform : __instance.emodel.transform;
|
||||
Vector3 position2 = Camera.main.transform.position;
|
||||
DebugLines.CreateAttached("EntityDamage", transform, position2 + Origin.position, _damageSource.getHitTransformPosition(), new Color(0.3f, 0f, 0.3f), new Color(1f, 0f, 1f), EntityAlive.DebugDisplayHitSize * 2f, EntityAlive.DebugDisplayHitSize, EntityAlive.DebugDisplayHitTime);
|
||||
DebugLines.CreateAttached("EntityDamage2", transform, _damageSource.getHitTransformPosition(), transform.position + Origin.position, new Color(0f, 0f, 0.5f), new Color(0.3f, 0.3f, 1f), EntityAlive.DebugDisplayHitSize * 2f, EntityAlive.DebugDisplayHitSize, EntityAlive.DebugDisplayHitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.MinEventContext.Other = (__instance.world.GetEntity(damageResponse.Source.getEntityId()) as EntityAlive);
|
||||
|
||||
if (_damageSource.AffectedByArmor())
|
||||
{
|
||||
__instance.equipment.CalcDamage(ref damageResponse.Strength, ref damageResponse.ArmorDamage, damageResponse.Source.DamageTypeTag, __instance.MinEventContext.Other, damageResponse.Source.AttackingItem);
|
||||
}
|
||||
|
||||
float num = GetDamageFraction((float)damageResponse.Strength, __instance);
|
||||
|
||||
if (damageResponse.Fatal || damageResponse.Strength >= __instance.Health)
|
||||
{
|
||||
|
||||
if (__instance.IsAlive() && !RebirthUtilities.IsHordeNight() && __instance is EntityPlayer && RebirthUtilities.IsClassActive(__instance, 10))
|
||||
{
|
||||
if (!__instance.Buffs.HasBuff("FuriousRamsayRageBuffDeath") && !__instance.Buffs.HasBuff("FuriousRamsayDeathRageBuffCooldown"))
|
||||
{
|
||||
damageResponse.Fatal = false;
|
||||
damageResponse.Strength = 0;
|
||||
damageResponse.Stun = EnumEntityStunType.None;
|
||||
__result = damageResponse;
|
||||
|
||||
__instance.Health = 50;
|
||||
__instance.Buffs.AddBuff("FuriousRamsayDeathRageBuff");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__instance.Buffs.RemoveBuff("FuriousRamsayDeathRageBuff");
|
||||
|
||||
if (damageResponse.HitBodyPart == EnumBodyPartHit.Head)
|
||||
{
|
||||
if (num >= 0.2f)
|
||||
{
|
||||
damageResponse.Source.DismemberChance = Utils.FastMax(damageResponse.Source.DismemberChance * 0.5f, 0.3f);
|
||||
}
|
||||
}
|
||||
else if (num >= 0.12f)
|
||||
{
|
||||
damageResponse.Source.DismemberChance = Utils.FastMax(damageResponse.Source.DismemberChance * 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
num = 1f;
|
||||
}
|
||||
|
||||
__instance.CheckDismember(ref damageResponse, num);
|
||||
int num2 = __instance.bodyDamage.StunKnee;
|
||||
int num3 = __instance.bodyDamage.StunProne;
|
||||
|
||||
if (damageResponse.HitBodyPart == EnumBodyPartHit.Head && damageResponse.Dismember)
|
||||
{
|
||||
damageResponse.Strength = __instance.Health;
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal DISMEMBER A");
|
||||
}
|
||||
else if (_damageSource.CanStun && __instance.GetWalkType() != 4 && __instance.bodyDamage.CurrentStun != EnumEntityStunType.Prone)
|
||||
{
|
||||
if (damageResponse.HitBodyPart.IsArm() || damageResponse.HitBodyPart == EnumBodyPartHit.Head || damageResponse.HitBodyPart == EnumBodyPartHit.Torso)
|
||||
{
|
||||
num3 += _strength;
|
||||
}
|
||||
else if (damageResponse.HitBodyPart.IsLeg())
|
||||
{
|
||||
num2 += _strength * (_criticalHit ? 2 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!damageResponse.HitBodyPart.IsLeg() || !damageResponse.Dismember) && __instance.GetWalkType() != 4 && !__instance.sleepingOrWakingUp)
|
||||
{
|
||||
EntityClass entityClass = EntityClass.list[__instance.entityClass];
|
||||
|
||||
if (GetDamageFraction((float)num3, __instance) >= entityClass.KnockdownProneDamageThreshold && entityClass.KnockdownProneDamageThreshold > 0f)
|
||||
{
|
||||
if (__instance.bodyDamage.CurrentStun != EnumEntityStunType.Prone)
|
||||
{
|
||||
damageResponse.Stun = EnumEntityStunType.Prone;
|
||||
damageResponse.StunDuration = __instance.rand.RandomRange(entityClass.KnockdownProneStunDuration.x, entityClass.KnockdownProneStunDuration.y);
|
||||
}
|
||||
}
|
||||
else if (GetDamageFraction((float)num2, __instance) >= entityClass.KnockdownKneelDamageThreshold && entityClass.KnockdownKneelDamageThreshold > 0f && __instance.bodyDamage.CurrentStun != EnumEntityStunType.Prone)
|
||||
{
|
||||
damageResponse.Stun = EnumEntityStunType.Kneel;
|
||||
damageResponse.StunDuration = __instance.rand.RandomRange(entityClass.KnockdownKneelStunDuration.x, entityClass.KnockdownKneelStunDuration.y);
|
||||
}
|
||||
}
|
||||
|
||||
bool flag2 = false;
|
||||
int num4 = damageResponse.Strength + damageResponse.ArmorDamage / 2;
|
||||
|
||||
if (num4 > 0 && !__instance.IsGodMode.Value && damageResponse.Stun == EnumEntityStunType.None && !__instance.sleepingOrWakingUp)
|
||||
{
|
||||
flag2 = (damageResponse.Strength < __instance.Health);
|
||||
if (flag2)
|
||||
{
|
||||
flag2 = (__instance.GetWalkType() == 4 || !damageResponse.Dismember || !damageResponse.HitBodyPart.IsLeg());
|
||||
}
|
||||
|
||||
if (flag2 && damageResponse.Source.GetDamageType() != EnumDamageTypes.Bashing)
|
||||
{
|
||||
flag2 = (num4 >= 6);
|
||||
}
|
||||
|
||||
if (damageResponse.Source.GetDamageType() == EnumDamageTypes.BarbedWire)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
damageResponse.PainHit = flag2;
|
||||
|
||||
if (damageResponse.Strength >= __instance.Health)
|
||||
{
|
||||
damageResponse.Fatal = true;
|
||||
}
|
||||
|
||||
if (damageResponse.Fatal)
|
||||
{
|
||||
damageResponse.Stun = EnumEntityStunType.None;
|
||||
}
|
||||
|
||||
if (__instance.isEntityRemote)
|
||||
{
|
||||
damageResponse.ModStrength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.Health <= damageResponse.Strength)
|
||||
{
|
||||
_strength -= __instance.Health;
|
||||
}
|
||||
|
||||
damageResponse.ModStrength = _strength;
|
||||
}
|
||||
|
||||
if (damageResponse.Source.BuffClass == null)
|
||||
{
|
||||
__instance.FireEvent(MinEventTypes.onOtherAttackedSelf, true);
|
||||
}
|
||||
|
||||
if (damageResponse.Dismember && __instance.IsAlive())
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal DISMEMBER");
|
||||
EntityAlive entityAlive = __instance.world.GetEntity(damageResponse.Source.getEntityId()) as EntityAlive;
|
||||
|
||||
if (entityAlive != null)
|
||||
{
|
||||
entityAlive.FireEvent(MinEventTypes.onDismember, true);
|
||||
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal isAlive: " + isAlive);
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal entityAlive.IsDead(): " + entityAlive.IsDead()) ;
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal entityAlive.Health: " + entityAlive.Health);
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal entityAlive.RecordedDamage.Fatal: " + entityAlive.RecordedDamage.Fatal);
|
||||
|
||||
#region Rebirth specific mod
|
||||
if (damageResponse.HitBodyPart == EnumBodyPartHit.Head)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal HEAD DISMEMBER");
|
||||
bool bRanged = entityAlive.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("ranged");
|
||||
bool bMelee = entityAlive.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("melee");
|
||||
|
||||
bool bMale = __instance.EntityTags.ToString().ToLower().Contains("male");
|
||||
bool bFemale = __instance.EntityTags.ToString().ToLower().Contains("female");
|
||||
bool bBandit = __instance.EntityTags.ToString().ToLower().Contains("bandit");
|
||||
bool bZombie = __instance.EntityTags.ToString().ToLower().Contains("zombie");
|
||||
bool bEnemyRobot = __instance.EntityTags.ToString().ToLower().Contains("enemyrobot");
|
||||
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal Item Tags: " + entityAlive.inventory.holdingItem.ItemTags.ToString());
|
||||
|
||||
if (bZombie)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE");
|
||||
if (bRanged)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE RANGED");
|
||||
/*if (bMale)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRangedMale");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE RANGED MALE");
|
||||
}
|
||||
else if (bFemale)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRangedFemale");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE RANGED FEMALE");
|
||||
}
|
||||
else
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE RANGED NON-SPECIFIC");
|
||||
}*/
|
||||
}
|
||||
if (bMelee)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE MELEE");
|
||||
/*if (bMale)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE MELEE MALE");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMeleeMale");
|
||||
}
|
||||
else if (bFemale)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE MELEE FEMALE");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMeleeFemale");
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ZOMBIE MELEE NON-SPECIFIC");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMelee");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else if (bEnemyRobot)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal ENEMY ROBOT");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadEnemyRobot");
|
||||
}
|
||||
else if (bBandit)
|
||||
{
|
||||
if (bRanged)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT RANGED");
|
||||
/*if (bMale)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRangedMale");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT RANGED MALE");
|
||||
}
|
||||
else if (bFemale)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRangedFemale");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT RANGED FEMALE");
|
||||
}
|
||||
else
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT RANGED NON-SPECIFIC");
|
||||
}*/
|
||||
}
|
||||
if (bMelee)
|
||||
{
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadRanged");
|
||||
/*////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT MELEE");
|
||||
if (bMale)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT MELEE MALE");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMeleeMale");
|
||||
}
|
||||
else if (bFemale)
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT MELEE FEMALE");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMeleeFemale");
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("EntityAlivePatches-damageEntityLocal BANDIT MELEE NON-SPECIFIC");
|
||||
entityAlive.Buffs.AddBuff("FuriousRamsayDismemberedHeadMelee");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.MinEventContext.Other != null)
|
||||
{
|
||||
__instance.MinEventContext.Other.MinEventContext.DamageResponse = damageResponse;
|
||||
float value = EffectManager.GetValue(PassiveEffects.HealthSteal, null, 0f, __instance.MinEventContext.Other, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
||||
|
||||
if (value != 0f)
|
||||
{
|
||||
int num5 = (int)((float)num4 * value);
|
||||
if (num5 + __instance.MinEventContext.Other.Health <= 0)
|
||||
{
|
||||
num5 = (__instance.MinEventContext.Other.Health - 1) * -1;
|
||||
}
|
||||
|
||||
__instance.MinEventContext.Other.AddHealth(num5);
|
||||
|
||||
if (num5 < 0 && __instance.MinEventContext.Other is EntityPlayerLocal)
|
||||
{
|
||||
((EntityPlayerLocal)__instance.MinEventContext.Other).ForceBloodSplatter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.ProcessDamageResponseLocal(damageResponse);
|
||||
__result = damageResponse;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(EntityAlive), "GetLookVector", new Type[] { })]
|
||||
public class EntityAlive_GetLookVector
|
||||
{
|
||||
public static bool Prefix(EntityAlive __instance, ref Vector3 __result)
|
||||
{
|
||||
////Log.Out($"EntityAlive::GetLookVector Prefix entity: {__instance}");
|
||||
var myTarget = __instance.GetAttackTarget();
|
||||
|
||||
if (myTarget == null) return true;
|
||||
|
||||
__result = __instance.GetAttackVector();
|
||||
////Log.Out($"EntityAlive::GetLookVector Prefix vec result: {__result}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user