Upload from upload_mods.ps1
This commit is contained in:
@@ -0,0 +1,387 @@
|
||||
using System.Globalization;
|
||||
|
||||
public class CustomGameOptionsHarmony
|
||||
{
|
||||
private const string CustomAttrGamePrefSelectorId = "CustomAttrGamePrefSelectorId";
|
||||
private const string CustomAttrDefaultValue = "CustomAttrDefaultValue";
|
||||
private const string CustomNamePrefix = "Custom";
|
||||
public static int GamePrefValue = 500;
|
||||
|
||||
private const string SCoreAssemblyName = "SCore,";
|
||||
private const string SCoreConfigurationClass = "Configuration";
|
||||
private const string SCoreCheckFeatureStatusMethod = "CheckFeatureStatus";
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("Init")]
|
||||
[HarmonyPatch(new Type[] { })]
|
||||
public class PatchXUiC_GamePrefSelectorInit
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance)
|
||||
{
|
||||
if (__instance.ViewComponent.ID.StartsWith(CustomNamePrefix))
|
||||
{
|
||||
// Store the ViewComonponent.ID in temp storage for use in Postfix and other Harmony methods below
|
||||
__instance.CustomAttributes.Set(CustomAttrGamePrefSelectorId, __instance.ViewComponent.ID);
|
||||
|
||||
// Temporarily use enum 'Last'
|
||||
AccessTools.Field(typeof(XUiView), "id").SetValue(__instance.ViewComponent, "Last");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Postfix(XUiC_GamePrefSelector __instance,
|
||||
ref EnumGamePrefs ___gamePref,
|
||||
ref GamePrefs.EnumType ___valueType)
|
||||
{
|
||||
// If we are a Custom GameOption then get the correct ViewComponent ID from temp storage, then set the correct ViewComponent.ID and the GamePref to a new custom Enum value
|
||||
var id = __instance.CustomAttributes.GetString(CustomAttrGamePrefSelectorId);
|
||||
if (id.StartsWith(CustomNamePrefix))
|
||||
{
|
||||
GamePrefValue++;
|
||||
___gamePref = (EnumGamePrefs)GamePrefValue;
|
||||
|
||||
AccessTools.Field(typeof(XUiView), "id").SetValue(__instance.ViewComponent, id);
|
||||
|
||||
// Set DefaultValue if nothing was loaded from configs
|
||||
if (!CustomGameOptions.HasValue(id))
|
||||
{
|
||||
switch (___valueType)
|
||||
{
|
||||
case GamePrefs.EnumType.Int:
|
||||
CustomGameOptions.SetValue(id, __instance.CustomAttributes.GetInt(CustomAttrDefaultValue));
|
||||
break;
|
||||
case GamePrefs.EnumType.String:
|
||||
CustomGameOptions.SetValue(id, __instance.CustomAttributes.GetString(CustomAttrDefaultValue));
|
||||
break;
|
||||
case GamePrefs.EnumType.Bool:
|
||||
CustomGameOptions.SetValue(id, __instance.CustomAttributes.GetBool(CustomAttrDefaultValue));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("SetVisible")]
|
||||
[HarmonyPatch(new Type[] { typeof(bool) })]
|
||||
public class PatchXUiC_GamePrefSelectorSetVisible
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance)
|
||||
{
|
||||
if (IsCustomGameOption(__instance))
|
||||
{
|
||||
__instance.ViewComponent.IsVisible = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("ControlCombo_OnValueChanged")]
|
||||
[HarmonyPatch(new Type[] { typeof(XUiController), typeof(XUiC_GamePrefSelector.GameOptionValue), typeof(XUiC_GamePrefSelector.GameOptionValue) })]
|
||||
public class PatchXUiC_GamePrefSelectorControlCombo_OnValueChanged
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance,
|
||||
XUiC_GamePrefSelector.GameOptionValue _newValue,
|
||||
ref GamePrefs.EnumType ___valueType)
|
||||
{
|
||||
if (IsCustomGameOption(__instance))
|
||||
{
|
||||
var id = __instance.CustomAttributes.GetString(CustomAttrGamePrefSelectorId);
|
||||
|
||||
//Log.Out("CustomGameOptionsHarmony-ControlCombo_OnValueChanged id: " + id);
|
||||
//Log.Out("CustomGameOptionsHarmony-ControlCombo_OnValueChanged _newValue: " + _newValue);
|
||||
|
||||
switch (___valueType)
|
||||
{
|
||||
case GamePrefs.EnumType.Int:
|
||||
CustomGameOptions.SetValue(id, _newValue.IntValue);
|
||||
break;
|
||||
case GamePrefs.EnumType.String:
|
||||
//Log.Out("CustomGameOptionsHarmony-ControlCombo_OnValueChanged _newValue.StringValue: " + _newValue.StringValue);
|
||||
//Log.Out("CustomGameOptionsHarmony-ControlCombo_OnValueChanged LOCALIZED _newValue.StringValue: " + Localization.Get(_newValue.StringValue));
|
||||
CustomGameOptions.SetValue(id, _newValue.StringValue);
|
||||
|
||||
if (id == "CustomScenario" && _newValue.StringValue == "purge")
|
||||
{
|
||||
}
|
||||
|
||||
break;
|
||||
case GamePrefs.EnumType.Bool:
|
||||
CustomGameOptions.SetValue(id, _newValue.IntValue == 1);
|
||||
break;
|
||||
}
|
||||
|
||||
AccessTools.Method(typeof(XUiC_GamePrefSelector), "CheckDefaultValue").Invoke(__instance, new object[] { });
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("ControlText_OnChangeHandler")]
|
||||
[HarmonyPatch(new Type[] { typeof(XUiController), typeof(string), typeof(bool) })]
|
||||
public class PatchXUiC_GamePrefSelectorControlText_OnChangeHandler
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance,
|
||||
string _text,
|
||||
ref GamePrefs.EnumType ___valueType)
|
||||
{
|
||||
if (IsCustomGameOption(__instance))
|
||||
{
|
||||
var id = __instance.CustomAttributes.GetString(CustomAttrGamePrefSelectorId);
|
||||
|
||||
switch (___valueType)
|
||||
{
|
||||
case GamePrefs.EnumType.Int:
|
||||
{
|
||||
if (int.TryParse(_text, out int value))
|
||||
{
|
||||
CustomGameOptions.SetValue(id, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GamePrefs.EnumType.String:
|
||||
CustomGameOptions.SetValue(id, _text);
|
||||
break;
|
||||
}
|
||||
|
||||
AccessTools.Method(typeof(XUiC_GamePrefSelector), "CheckDefaultValue").Invoke(__instance, new object[] { });
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("SetCurrentValue")]
|
||||
[HarmonyPatch(new Type[] { })]
|
||||
public class PatchXUiC_GamePrefSelectorSetCurrentValue
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance,
|
||||
ref string[] ___valuesFromXml,
|
||||
ref GamePrefs.EnumType ___valueType,
|
||||
ref bool ___isTextInput,
|
||||
ref XUiC_ComboBoxList<XUiC_GamePrefSelector.GameOptionValue> ___controlCombo,
|
||||
ref XUiC_TextInput ___controlText,
|
||||
string ___valueLocalizationPrefixFromXml)
|
||||
{
|
||||
if (IsCustomGameOption(__instance))
|
||||
{
|
||||
var id = __instance.CustomAttributes.GetString(CustomAttrGamePrefSelectorId);
|
||||
|
||||
switch (___valueType)
|
||||
{
|
||||
case GamePrefs.EnumType.Int:
|
||||
{
|
||||
/*if (!string.IsNullOrEmpty(___valueLocalizationPrefixFromXml))
|
||||
{
|
||||
Log.Out("PatchXUiC_GamePrefSelectorSetCurrentValue-SetCurrentValue ___valueLocalizationPrefixFromXml: " + ___valueLocalizationPrefixFromXml);
|
||||
}*/
|
||||
|
||||
if (___isTextInput)
|
||||
{
|
||||
___controlText.Text = CustomGameOptions.GetInt(id).ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i < ___controlCombo.Elements.Count; i++)
|
||||
{
|
||||
if (___controlCombo.Elements[i].IntValue == CustomGameOptions.GetInt(id))
|
||||
{
|
||||
___controlCombo.SelectedIndex = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GamePrefs.EnumType.String:
|
||||
{
|
||||
if (___isTextInput)
|
||||
{
|
||||
___controlText.Text = CustomGameOptions.GetString(id);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i < ___controlCombo.Elements.Count; i++)
|
||||
{
|
||||
if (___controlCombo.Elements[i].StringValue == CustomGameOptions.GetString(id))
|
||||
{
|
||||
___controlCombo.SelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GamePrefs.EnumType.Bool:
|
||||
___controlCombo.SelectedIndex = CustomGameOptions.GetBool(id) ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
AccessTools.Method(typeof(XUiC_GamePrefSelector), "CheckDefaultValue").Invoke(__instance, new object[] { });
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("IsDefaultValueForGameMode")]
|
||||
[HarmonyPatch(new Type[] { })]
|
||||
public class PatchXUiC_GamePrefSelectorIsDefaultValueForGameMode
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance,
|
||||
ref bool __result,
|
||||
ref GamePrefs.EnumType ___valueType,
|
||||
ref XUiC_ComboBoxList<XUiC_GamePrefSelector.GameOptionValue> ___controlCombo,
|
||||
ref XUiC_TextInput ___controlText,
|
||||
ref bool ___isTextInput)
|
||||
{
|
||||
if (IsCustomGameOption(__instance))
|
||||
{
|
||||
switch (___valueType)
|
||||
{
|
||||
case GamePrefs.EnumType.Int:
|
||||
{
|
||||
int intValue;
|
||||
if (___isTextInput)
|
||||
{
|
||||
StringParsers.TryParseSInt32(___controlText.Text, out intValue, 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
else
|
||||
{
|
||||
intValue = ___controlCombo.Value.IntValue;
|
||||
}
|
||||
__result = intValue == __instance.CustomAttributes.GetInt(CustomAttrDefaultValue);
|
||||
break;
|
||||
}
|
||||
case GamePrefs.EnumType.String:
|
||||
{
|
||||
if (___isTextInput)
|
||||
{
|
||||
__result = ___controlText.Text == __instance.CustomAttributes.GetString(CustomAttrDefaultValue);
|
||||
break;
|
||||
}
|
||||
__result = ___controlCombo.Value.StringValue == __instance.CustomAttributes.GetString(CustomAttrDefaultValue);
|
||||
break;
|
||||
}
|
||||
case GamePrefs.EnumType.Bool:
|
||||
__result = ___controlCombo.Value.IntValue == 1 == __instance.CustomAttributes.GetBool(CustomAttrDefaultValue);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_NewContinueGame))]
|
||||
[HarmonyPatch("SaveGameOptions")]
|
||||
[HarmonyPatch(new Type[] { })]
|
||||
public class PatchXUiC_NewContinueGameSaveGameOptions
|
||||
{
|
||||
static void Postfix(XUiC_NewContinueGame __instance)
|
||||
{
|
||||
Log.Out("SaveGameOptions");
|
||||
CustomGameOptions.SaveGameOptions();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_GamePrefSelector))]
|
||||
[HarmonyPatch("ParseAttribute")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(string), typeof(XUiController) })]
|
||||
public class PatchXUiC_GamePrefSelectorParseAttribute
|
||||
{
|
||||
static bool Prefix(XUiC_GamePrefSelector __instance,
|
||||
ref string _name,
|
||||
ref string _value,
|
||||
ref XUiController _parent,
|
||||
ref GamePrefs.EnumType ___valueType)
|
||||
{
|
||||
// Load default values from windows.xml and save in CustomAttributes
|
||||
if (_name == "default_value"
|
||||
&& _value != "default_value")
|
||||
{
|
||||
__instance.CustomAttributes.Set(CustomAttrDefaultValue, _value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsCustomGameOption(XUiC_GamePrefSelector __instance)
|
||||
{
|
||||
var id = __instance.CustomAttributes.GetString(CustomAttrGamePrefSelectorId);
|
||||
|
||||
return !string.IsNullOrEmpty(id) && id.StartsWith(CustomNamePrefix);
|
||||
}
|
||||
|
||||
[HarmonyPatch()]
|
||||
public class PatchScoreConfigurationCheckFeatureStatus
|
||||
{
|
||||
[HarmonyPrepare]
|
||||
public static bool Prepare(MethodBase original)
|
||||
{
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (assembly?.FullName.StartsWith(SCoreAssemblyName) != true) continue;
|
||||
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
if (type.FullName != SCoreConfigurationClass) continue;
|
||||
|
||||
return type.GetMethod(SCoreCheckFeatureStatusMethod, new Type[] { typeof(string), typeof(string) }) != null;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyTargetMethod]
|
||||
static MethodBase TargetMethod()
|
||||
{
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (assembly?.FullName.StartsWith(SCoreAssemblyName) != true) continue;
|
||||
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
if (type?.FullName != SCoreConfigurationClass) continue;
|
||||
|
||||
return type.GetMethod(SCoreCheckFeatureStatusMethod, new Type[] { typeof(string), typeof(string) });
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool Prefix(ref bool __result, string strClass, string strFeature)
|
||||
{
|
||||
var variableName = $"{CustomNamePrefix}{strClass}{strFeature}";
|
||||
|
||||
if (CustomGameOptions.HasValue(variableName))
|
||||
{
|
||||
__result = CustomGameOptions.GetBool(variableName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.AIAirDropPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIAirDrop))]
|
||||
[HarmonyPatch("SelectCrateCount")]
|
||||
public class SelectCrateCountPatch
|
||||
{
|
||||
public static bool Prefix(AIAirDrop __instance, int _numPlayers, out int _min, out int _max)
|
||||
{
|
||||
_min = 1;
|
||||
_max = 1;
|
||||
|
||||
if (RebirthVariables.customScenario != "purge")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIAirDrop))]
|
||||
[HarmonyPatch("CreateFlightPaths")]
|
||||
public class CreateFlightPathsPatch
|
||||
{
|
||||
// Helper function to ensure positions stay within a given radius
|
||||
private static Vector2 ClampToRadius(Vector2 center, Vector2 point, float maxRadius)
|
||||
{
|
||||
Vector2 direction = point - center;
|
||||
float distance = direction.magnitude;
|
||||
if (distance > maxRadius)
|
||||
{
|
||||
direction = direction.normalized * maxRadius;
|
||||
point = center + direction;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
public static bool Prefix(AIAirDrop __instance)
|
||||
{
|
||||
if (RebirthVariables.customScenario != "purge")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
float MaxDropDistanceFromPlayer = 100f; // Set your desired maximum distance here
|
||||
|
||||
__instance.flightPaths = new List<AIAirDrop.FlightPath>();
|
||||
int _numCrates;
|
||||
int _numPlanes;
|
||||
__instance.CalcSupplyDropMetrics(__instance.numPlayers, __instance.clusters.Count, out _numCrates, out _numPlanes);
|
||||
int num1 = Math.Max(1, _numCrates / _numPlanes);
|
||||
int num2 = _numCrates - _numPlanes * num1;
|
||||
HashSet<int> intSet = new HashSet<int>();
|
||||
GameRandom random = AIAirDrop.controller.Random;
|
||||
|
||||
while (_numCrates > 0)
|
||||
{
|
||||
int num3 = Mathf.Min(_numCrates, num1 + num2);
|
||||
_numCrates -= num3;
|
||||
num2 = 0;
|
||||
int index1;
|
||||
do
|
||||
{
|
||||
index1 = random.RandomRange(0, __instance.clusters.Count);
|
||||
}
|
||||
while (intSet.Contains(index1));
|
||||
|
||||
AIAirDrop.PlayerCluster cluster = __instance.clusters[index1];
|
||||
intSet.Add(index1);
|
||||
if (intSet.Count == __instance.clusters.Count)
|
||||
intSet.Clear();
|
||||
|
||||
// Get the player's position and adjust the center within the allowed radius
|
||||
Vector2 playerPosition = new Vector2(cluster.Players[0].position.x, cluster.Players[0].position.z);//new Vector2(cluster.XZCenter.x, cluster.XZCenter.y);
|
||||
float PlayerY = cluster.Players[0].position.y;
|
||||
if (RebirthVariables.playerAirDrops.Count > 0)
|
||||
{
|
||||
//Log.Out("===================== USE PLAYER AIRDROPS ======================");
|
||||
Vector3 removedItem = RebirthVariables.playerAirDrops[0];
|
||||
RebirthVariables.playerAirDrops.RemoveAt(0);
|
||||
PlayerY = removedItem.y;
|
||||
playerPosition = new Vector2(removedItem.x, removedItem.z);
|
||||
}
|
||||
|
||||
Vector2 randomDirection = random.RandomOnUnitCircle * random.RandomRange(0f, MaxDropDistanceFromPlayer);
|
||||
Vector2 dropCenter = playerPosition + randomDirection;
|
||||
|
||||
// Adjust crate spawn points based on the constrained center
|
||||
//float num4 = 50f; // random.RandomRange(150f, 700f);
|
||||
float num4 = random.RandomRange(100f, 200f);
|
||||
float num5 = num4 / 2f;
|
||||
Vector2 tangentDir = random.RandomOnUnitCircle.normalized;
|
||||
|
||||
Vector2 safePoint1 = dropCenter - tangentDir * num5;
|
||||
Vector2 safePoint2 = dropCenter + tangentDir * num5;
|
||||
|
||||
safePoint1 = ClampToRadius(playerPosition, safePoint1, MaxDropDistanceFromPlayer);
|
||||
safePoint2 = ClampToRadius(playerPosition, safePoint2, MaxDropDistanceFromPlayer);
|
||||
|
||||
// Create flight path
|
||||
AIAirDrop.FlightPath flightPath = new AIAirDrop.FlightPath
|
||||
{
|
||||
Start = new Vector3(safePoint1.x, PlayerY + 180f, safePoint1.y),
|
||||
End = new Vector3(safePoint2.x, PlayerY + 180f, safePoint2.y)
|
||||
};
|
||||
|
||||
float crateSpacing = num4 / num3;
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
Vector2 cratePos = dropCenter + tangentDir * (crateSpacing * i - (crateSpacing * num3) / 2);
|
||||
cratePos = ClampToRadius(playerPosition, cratePos, MaxDropDistanceFromPlayer);
|
||||
|
||||
AIAirDrop.SupplyCrateSpawn crate = new AIAirDrop.SupplyCrateSpawn
|
||||
{
|
||||
SpawnPos = new Vector3(cratePos.x, PlayerY + 180f - 10f, cratePos.y),
|
||||
Delay = (safePoint1 - cratePos).magnitude / 120f
|
||||
};
|
||||
flightPath.Crates.Add(crate);
|
||||
}
|
||||
|
||||
flightPath.Delay = cluster.Delay + random.RandomRange(0f, 15f);
|
||||
cluster.Delay += random.RandomRange(25f, 120f);
|
||||
__instance.flightPaths.Add(flightPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
namespace Harmony.AIDirectorPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirector))]
|
||||
[HarmonyPatch("NotifyNoise")]
|
||||
public class NotifyNoisePatch
|
||||
{
|
||||
public static bool Prefix(AIDirector __instance, Entity instigator, Vector3 position, string clipName, float volumeScale)
|
||||
{
|
||||
AIDirectorData.Noise noise;
|
||||
if (!AIDirectorData.FindNoise(clipName, out noise) || instigator is EntityEnemy)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 1");
|
||||
return false;
|
||||
}
|
||||
AIDirectorPlayerState directorPlayerState = (AIDirectorPlayerState)null;
|
||||
if ((bool)instigator)
|
||||
{
|
||||
if (instigator.IsIgnoredByAI())
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 2");
|
||||
return false;
|
||||
}
|
||||
__instance.playerManagementComponent.trackedPlayers.dict.TryGetValue(instigator.entityId, out directorPlayerState);
|
||||
}
|
||||
if (instigator is EntityItem entityItem && ItemClass.GetForId(entityItem.itemStack.itemValue.type).ThrowableDecoy.Value)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise clipName: " + clipName);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise noise.heatMapStrength: " + noise.heatMapStrength);
|
||||
|
||||
if (directorPlayerState != null)
|
||||
{
|
||||
if (directorPlayerState.Player.IsCrouching)
|
||||
volumeScale *= noise.muffledWhenCrouched;
|
||||
float volume = noise.volume * volumeScale;
|
||||
if (directorPlayerState.Player.Stealth.NotifyNoise(volume, noise.duration))
|
||||
instigator.world.CheckSleeperVolumeNoise(position);
|
||||
}
|
||||
if ((double)noise.heatMapStrength <= 0.0)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise 4");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool canProceed = true;
|
||||
|
||||
if (instigator is EntityAliveV2)
|
||||
{
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM NPC");
|
||||
canProceed = false;
|
||||
}
|
||||
|
||||
/*if (instigator is EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer)instigator;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
string heldItem = player.inventory.holdingItem.GetItemName();
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM PLAYER, held item: " + heldItem);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise IS FROM PLAYER, tags: " + player.inventory.holdingItem.ItemTags);
|
||||
|
||||
if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged")) && !player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ammo")))
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItem(heldItem, false).ItemClass;
|
||||
|
||||
ItemActionRanged myAction = (ItemActionRanged)itemClass.Actions[0];
|
||||
ItemActionData _actionData = player.inventory.holdingItemData.actionData[0];
|
||||
ItemActionRanged.ItemActionDataRanged itemActionDataRanged = (ItemActionRanged.ItemActionDataRanged)_actionData;
|
||||
|
||||
float myDelay = 60f / EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemActionDataRanged.invData.itemValue, 60f / itemActionDataRanged.OriginalDelay, player);
|
||||
int roundsPerMinute = (int)(60 / myDelay);
|
||||
|
||||
float divisor = RebirthUtilities.CalculateHeatMapDivisor(roundsPerMinute);
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise roundsPerMinute: " + roundsPerMinute);
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise divisor: " + divisor);
|
||||
|
||||
if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponLongRangeRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 1))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponShotguns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 2))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponAssaultRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 3))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponMachineGuns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 4))
|
||||
{
|
||||
if (heldItem != "MachineGun01_FR")
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponRevolvers")) ||
|
||||
player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("WeaponTier3DeployableTurrets")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 5))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponSubmachineGuns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 6))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponPistols")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 7))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponHeavyHandguns")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 8))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
else if (player.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("CurrentWeaponTacticalRifles")))
|
||||
{
|
||||
if (RebirthUtilities.IsClassActive(player, 9))
|
||||
{
|
||||
noise.heatMapStrength = noise.heatMapStrength * divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Log.Out("AIDirectorPatches-NotifyNoise AFTER noise.heatMapStrength: " + noise.heatMapStrength);
|
||||
|
||||
if (canProceed)
|
||||
{
|
||||
__instance.NotifyActivity(EnumAIDirectorChunkEvent.Sound, World.worldToBlockPos(position), noise.heatMapStrength * volumeScale, 240f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Harmony.AIDirectorAirDropComponentPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirectorAirDropComponent))]
|
||||
[HarmonyPatch("SpawnAirDrop")]
|
||||
public class SpawnAirDropPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorAirDropComponent __instance, ref bool __result)
|
||||
{
|
||||
if (RebirthVariables.skipSupplyDrops)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
namespace Harmony.AIDirectorBloodMoonComponentPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirectorBloodMoonComponent))]
|
||||
[HarmonyPatch("CalcNextDay")]
|
||||
public class CalcNextDayPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorBloodMoonComponent __instance, bool isSeek = false)
|
||||
{
|
||||
//Log.Out("AIDirectorBloodMoonComponentPatches-CalcNextDay START");
|
||||
if (RebirthVariables.skipHordeNight)
|
||||
{
|
||||
//Log.Out("AIDirectorBloodMoonComponentPatches-CalcNextDay SKIP HORDE NIGHT");
|
||||
__instance.SetDay(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIDirectorBloodMoonComponent))]
|
||||
[HarmonyPatch("StartBloodMoon")]
|
||||
public class StartBloodMoonPatch
|
||||
{
|
||||
public static void Postfix()
|
||||
{
|
||||
RebirthVariables.isHordeNight = true;
|
||||
RebirthVariables.wasHordeNight = true;
|
||||
RebirthUtilities.setHordeNightActiveValue(RebirthVariables.isHordeNight);
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"] = 0;
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNHeadShots_Cst"] = 0;
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageResetHNStats>().Setup());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIDirectorBloodMoonComponent))]
|
||||
[HarmonyPatch("EndBloodMoon")]
|
||||
public class EndBloodMoonPatch
|
||||
{
|
||||
public static void Postfix()
|
||||
{
|
||||
RebirthVariables.isHordeNight = false;
|
||||
RebirthUtilities.setHordeNightActiveValue(RebirthVariables.isHordeNight);
|
||||
|
||||
RebirthVariables.forceHerd = true;
|
||||
|
||||
bool runHerd = false;
|
||||
|
||||
if (RebirthVariables.customWanderingHordeHerdHN == "100")
|
||||
{
|
||||
runHerd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameRandom gameRandom = GameManager.Instance.World.GetGameRandom();
|
||||
int random = gameRandom.RandomRange(1, RebirthVariables.maxWanderingHordeFrequency + 1);
|
||||
|
||||
if (random <= int.Parse(RebirthVariables.customWanderingHordeHerdHN))
|
||||
{
|
||||
runHerd = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (runHerd)
|
||||
{
|
||||
GameManager.Instance.World.aiDirector.GetComponent<AIDirectorWanderingHordeComponent>().StartSpawning(AIWanderingHordeSpawner.SpawnType.Horde);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.AIDirectorChunkEventComponentPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirectorChunkEventComponent))]
|
||||
[HarmonyPatch("SpawnScouts")]
|
||||
public class SpawnScoutsPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorChunkEventComponent __instance, Vector3 targetPos)
|
||||
{
|
||||
if (!RebirthVariables.stopWHSpawns && RebirthVariables.isWHSpawned)
|
||||
{
|
||||
Log.Out("AIDirectorChunkEventComponentPatches-SpawnScouts CAN'T SPAWN SCREAMERS DURING AN OUTBREAK");
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 startPos;
|
||||
if (__instance.FindScoutStartPos(targetPos, out startPos))
|
||||
{
|
||||
EntityPlayer closestPlayer = __instance.Director.World.GetClosestPlayer(targetPos, 120f, false);
|
||||
if (!(bool)closestPlayer)
|
||||
return false;
|
||||
int num = GameStageDefinition.CalcGameStageAround(closestPlayer);
|
||||
string _esClassname = "Scouts";
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-SpawnScouts num: " + num);
|
||||
if (num >= RebirthVariables.spawnThresholdFeral)
|
||||
_esClassname = "ScoutsFeral";
|
||||
if (num >= RebirthVariables.spawnThresholdRadiated)
|
||||
_esClassname = "ScoutsRadiated";
|
||||
if (num >= RebirthVariables.spawnThresholdTainted)
|
||||
_esClassname = "ScoutsTainted";
|
||||
|
||||
__instance.scoutSpawnList.Add(new AIScoutHordeSpawner(new EntitySpawner(_esClassname, Vector3i.zero, Vector3i.zero, 0), startPos, targetPos, false));
|
||||
AIDirector.LogAI("Spawning {0} at {1}, to {2}", (object)_esClassname, (object)startPos.ToCultureInvariantString(), (object)targetPos.ToCultureInvariantString());
|
||||
}
|
||||
else
|
||||
AIDirector.LogAI("Scout spawning failed");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIDirectorChunkEventComponent))]
|
||||
[HarmonyPatch("CheckToSpawn")]
|
||||
[HarmonyPatch(new[] { typeof(AIDirectorChunkData) })]
|
||||
public class CheckToSpawnPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorChunkEventComponent __instance, AIDirectorChunkData _chunkData)
|
||||
{
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn START");
|
||||
|
||||
if (!GameStats.GetBool(EnumGameStats.ZombieHordeMeter) || !GameStats.GetBool(EnumGameStats.IsSpawnEnemies) || (double)_chunkData.ActivityLevel < 100.0)
|
||||
return false;
|
||||
AIDirectorChunkEvent bestEventAndReset = _chunkData.FindBestEventAndReset();
|
||||
if (bestEventAndReset != null)
|
||||
{
|
||||
int searchDistance = 150;
|
||||
|
||||
List<Entity> entitiesInBounds = __instance.Director.World.GetEntitiesInBounds(typeof(EntityZombieScreamerRebirth), BoundsUtils.BoundsForMinMax(bestEventAndReset.Position.x - searchDistance, bestEventAndReset.Position.y - 50, bestEventAndReset.Position.z - searchDistance, bestEventAndReset.Position.x + searchDistance, bestEventAndReset.Position.y + 50, bestEventAndReset.Position.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn NUM Screamers: " + entitiesInBounds.Count);
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.customScreamerMax: " + RebirthVariables.customScreamerMax);
|
||||
|
||||
int numActiveScreamers = 0;
|
||||
|
||||
for (int index = 0; index < entitiesInBounds.Count; ++index)
|
||||
{
|
||||
EntityZombieScreamerRebirth screamer = (EntityZombieScreamerRebirth)entitiesInBounds[index];
|
||||
|
||||
if (!screamer.IsDead())
|
||||
{
|
||||
numActiveScreamers++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numActiveScreamers < RebirthVariables.customScreamerMax)
|
||||
{
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.stopWHSpawns: " + RebirthVariables.stopWHSpawns);
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.isWHSpawned: " + RebirthVariables.isWHSpawned);
|
||||
|
||||
if (!RebirthVariables.stopWHSpawns && RebirthVariables.isWHSpawned)
|
||||
{
|
||||
Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn CAN'T SPAWN SCREAMERS DURING AN OUTBREAK");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn SPAWNING SCREAMERS");
|
||||
__instance.StartCooldownOnNeighbors(bestEventAndReset.Position);
|
||||
__instance.SpawnScouts(bestEventAndReset.Position.ToVector3());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn TOO MANY SCREAMERS");
|
||||
}
|
||||
}
|
||||
else
|
||||
AIDirector.LogAI("Chunk event not found!");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,568 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Harmony.AIWanderingHordeSpawnerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AIDirectorWanderingHordeComponent))]
|
||||
[HarmonyPatch("StartSpawning")]
|
||||
public class StartSpawningPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorWanderingHordeComponent __instance, AIWanderingHordeSpawner.SpawnType _spawnType)
|
||||
{
|
||||
RebirthVariables.isWHSpawned = false;
|
||||
RebirthVariables.stopWHSpawns = false;
|
||||
|
||||
RebirthVariables.herdStartTime = Time.time;
|
||||
float optionWanderingHordeHerdProb = float.Parse(RebirthVariables.customWanderingHordeHerdProb);
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-StartSpawning optionWanderingHordeHerdProb: " + optionWanderingHordeHerdProb);
|
||||
|
||||
int random = UnityEngine.Random.Range(1, 100);
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-StartSpawning random: " + random);
|
||||
|
||||
RebirthVariables.isHerd = random <= optionWanderingHordeHerdProb;
|
||||
|
||||
if (RebirthVariables.forceHerd)
|
||||
{
|
||||
RebirthVariables.isHerd = true;
|
||||
RebirthVariables.forceHerd = false;
|
||||
}
|
||||
|
||||
int optionWanderingHordeHerdDur = RebirthVariables.customWanderingHordeHerdDur;
|
||||
|
||||
RebirthVariables.herdDuration = UnityEngine.Random.Range((optionWanderingHordeHerdDur * 60) - 30, (optionWanderingHordeHerdDur * 60) + 30);
|
||||
|
||||
// START OF VANILLA CODE
|
||||
|
||||
AIDirector.LogAI("Wandering StartSpawning {0}", (object)_spawnType);
|
||||
__instance.CleanupType(_spawnType);
|
||||
bool flag = false;
|
||||
DictionaryList<int, AIDirectorPlayerState> trackedPlayers = __instance.Director.GetComponent<AIDirectorPlayerManagementComponent>().trackedPlayers;
|
||||
for (int index = 0; index < trackedPlayers.list.Count; ++index)
|
||||
{
|
||||
if (!trackedPlayers.list[index].Dead)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
AIDirector.LogAI("Spawn {0}, no living players, wait 4 hours", (object)_spawnType);
|
||||
__instance.SetNextTime(_spawnType, __instance.Director.World.worldTime + 4000UL);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<AIDirectorPlayerState> directorPlayerStateList = new List<AIDirectorPlayerState>();
|
||||
Vector3 startPos;
|
||||
Vector3 pitStop;
|
||||
Vector3 endPos;
|
||||
uint targets = __instance.FindTargets(out startPos, out pitStop, out endPos, directorPlayerStateList);
|
||||
if (targets > 0U)
|
||||
{
|
||||
AIDirector.LogAI("Spawn {0}, find targets, wait {1} hours", (object)_spawnType, (object)targets);
|
||||
__instance.SetNextTime(_spawnType, __instance.Director.World.worldTime + (ulong)(1000U * targets));
|
||||
}
|
||||
else
|
||||
{
|
||||
int searchDistance = 150;
|
||||
|
||||
List<Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityZombieScreamerRebirth), BoundsUtils.BoundsForMinMax(startPos.x - searchDistance, startPos.y - 50, startPos.z - searchDistance, startPos.x + searchDistance, startPos.y + 50, startPos.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn NUM Screamers: " + entitiesInBounds.Count);
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn RebirthVariables.customScreamerMax: " + RebirthVariables.customScreamerMax);
|
||||
|
||||
int numActiveScreamers = 0;
|
||||
|
||||
if (entitiesInBounds.Count >= 1)
|
||||
{
|
||||
for (int index = 0; index < entitiesInBounds.Count; ++index)
|
||||
{
|
||||
EntityZombieScreamerRebirth screamer = (EntityZombieScreamerRebirth)entitiesInBounds[index];
|
||||
|
||||
if (!screamer.IsDead())
|
||||
{
|
||||
numActiveScreamers++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numActiveScreamers > 0 && RebirthVariables.isHerd)
|
||||
{
|
||||
Log.Out("AIDirectorChunkEventComponentPatches-SpawnScouts CAN'T START AN OUTBREAK WHILE SCREAMERS ARE STILL ACTIVE");
|
||||
RebirthVariables.isHerd = false;
|
||||
RebirthVariables.stopWHSpawns = true;
|
||||
RebirthVariables.herdDuration = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.ChooseNextTime(_spawnType);
|
||||
__instance.spawners.Add(new AIWanderingHordeSpawner(__instance.Director, _spawnType, (AIWanderingHordeSpawner.HordeArrivedDelegate)null, directorPlayerStateList, __instance.Director.World.worldTime + 12000UL, startPos, pitStop, endPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameStageDefinition))]
|
||||
[HarmonyPatch("GetStage")]
|
||||
public class GetStagePatch
|
||||
{
|
||||
public static bool Prefix(GameStageDefinition __instance, ref GameStageDefinition.Stage __result, int stage)
|
||||
{
|
||||
if (new StackTrace().FrameCount > 5)
|
||||
{
|
||||
MethodBase caller = new StackTrace().GetFrame(5).GetMethod();
|
||||
string callerClassName = caller.ReflectedType.Name;
|
||||
|
||||
if (callerClassName != "AIWanderingHordeSpawner")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("AIDirectorGameStagePartySpawnerPatches-GetStage stage: " + stage);
|
||||
|
||||
//Log.Out("AIDirectorGameStagePartySpawnerPatches-GetStage callerClassName: " + callerClassName);
|
||||
|
||||
if (__instance.stages.Count < 1)
|
||||
{
|
||||
//Log.Out("AIDirectorGameStagePartySpawnerPatches-GetStage NO STAGES");
|
||||
__result = (GameStageDefinition.Stage)null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("AIDirectorGameStagePartySpawnerPatches-GetStage __instance.stages[0].stageNum: " + __instance.stages[0].stageNum);
|
||||
|
||||
// Set the result to the same value to keep the spawning consistent
|
||||
__result = __instance.stages[0];
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIDirectorGameStagePartySpawner))]
|
||||
[HarmonyPatch("Tick")]
|
||||
public class TickPatch
|
||||
{
|
||||
public static bool Prefix(AIDirectorGameStagePartySpawner __instance, ref bool __result, double _deltaTime
|
||||
)
|
||||
{
|
||||
if (__instance.spawnGroup != null)
|
||||
{
|
||||
bool flag = true;
|
||||
if (__instance.spawnCount >= __instance.numToSpawn)
|
||||
{
|
||||
__instance.interval -= _deltaTime;
|
||||
flag = __instance.interval <= 0.0;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("AIDirectorGameStagePartySpawner-Tick: " + __instance.ToString());
|
||||
__instance.SetupGroup();
|
||||
}
|
||||
}
|
||||
__result = __instance.spawnGroup != null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIWanderingHordeSpawner))]
|
||||
[HarmonyPatch("UpdateHorde")]
|
||||
public class UpdateHordePatch
|
||||
{
|
||||
public static bool Prefix(AIWanderingHordeSpawner __instance, float dt)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while (index < __instance.commandList.Count)
|
||||
{
|
||||
AIWanderingHordeSpawner.ZombieCommand command = __instance.commandList[index];
|
||||
|
||||
bool hasAttackTaget = false; // command.Enemy.GetAttackTarget() != null;
|
||||
bool hasOther = false;
|
||||
|
||||
bool flag = command.Enemy.IsDead() || hasAttackTaget;
|
||||
if (!flag)
|
||||
{
|
||||
if (command.Command == AIWanderingHordeSpawner.ECommand.PitStop || command.Command == AIWanderingHordeSpawner.ECommand.EndPos)
|
||||
{
|
||||
if (command.Enemy.HasInvestigatePosition)
|
||||
{
|
||||
/*if (command.Enemy.InvestigatePosition != command.TargetPos)
|
||||
{
|
||||
flag = true;
|
||||
AIDirector.LogAIExtra("Wandering horde zombie '" + command.Enemy?.ToString() + "' removed from horde control. Was killed or investigating");
|
||||
}
|
||||
else*/
|
||||
{
|
||||
command.Enemy.SetInvestigatePosition(command.TargetPos, 6000, false);
|
||||
}
|
||||
}
|
||||
else if (command.Command == AIWanderingHordeSpawner.ECommand.PitStop)
|
||||
{
|
||||
AIDirector.LogAIExtra("Wandering horde zombie '" + command.Enemy?.ToString() + "' reached pitstop. Wander around for awhile");
|
||||
command.WanderTime = (float)(90.0 + (double)__instance.director.random.RandomFloat * 4.0);
|
||||
command.Command = AIWanderingHordeSpawner.ECommand.Wander;
|
||||
}
|
||||
else
|
||||
{
|
||||
//command.Enemy.SetInvestigatePosition(command.TargetPos, 6000, false);
|
||||
/*Log.Out("AIWanderingHordeSpawner-UpdateHorde command.Command: " + command.Command + " / " + command.Enemy?.ToString());
|
||||
|
||||
hasOther = true;
|
||||
flag = true;*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command.WanderTime -= dt;
|
||||
command.Enemy.ResetDespawnTime();
|
||||
if ((double)command.WanderTime <= 0.0 && command.Enemy.GetAttackTarget() == null)
|
||||
{
|
||||
AIDirector.LogAIExtra("Wandering horde zombie '" + command.Enemy?.ToString() + "' wandered long enough. Going to endstop");
|
||||
command.Command = AIWanderingHordeSpawner.ECommand.EndPos;
|
||||
command.TargetPos = AIWanderingHordeSpawner.RandomPos(__instance.director, __instance.endPos, 6f);
|
||||
command.Enemy.SetInvestigatePosition(command.TargetPos, 6000, false);
|
||||
command.Enemy.IsHordeZombie = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
string additionalInfo = "";
|
||||
if (hasOther)
|
||||
{
|
||||
additionalInfo = " / HAS OTHER";
|
||||
}
|
||||
if (hasAttackTaget)
|
||||
{
|
||||
additionalInfo = " / HAS ATTACK TARGET";
|
||||
}
|
||||
|
||||
AIDirector.LogAIExtra("Wandering horde zombie '" + command.Enemy?.ToString() + "' removed from control" + additionalInfo);
|
||||
command.Enemy.IsHordeZombie = false;
|
||||
command.Enemy.bIsChunkObserver = false;
|
||||
__instance.commandList.RemoveAt(index);
|
||||
}
|
||||
else
|
||||
++index;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(AIWanderingHordeSpawner))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static bool Prefix(AIWanderingHordeSpawner __instance, ref bool __result, World world, float _deltaTime)
|
||||
{
|
||||
if (world.GetPlayers().Count == 0)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update NO PLAYERS");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (world.worldTime >= __instance.endTime)
|
||||
{
|
||||
if (__instance.arrivedCallback != null)
|
||||
__instance.arrivedCallback();
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update OVER END TIME: " + __instance.endTime);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
bool flag = __instance.UpdateSpawn(world, _deltaTime);
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update Wandering Horde size: " + __instance.commandList.Count);
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update Wandering Horde Total Size: " + RebirthVariables.wanderingHordeCount);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update CANNOT SPAWN");
|
||||
if (!RebirthVariables.isHerd)
|
||||
{
|
||||
if (__instance.commandList.Count == 0 || __instance.commandList.Count == RebirthVariables.wanderingHordeCount)
|
||||
{
|
||||
if (__instance.arrivedCallback != null)
|
||||
__instance.arrivedCallback();
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update __instance.commandList.Count: " + __instance.commandList.Count);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-Update CAN SPAWN");
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
AstarManager.Instance.AddLocationLine(__instance.startPos, __instance.endPos, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 zero = Vector3.zero;
|
||||
int num = 0;
|
||||
for (int index = 0; index < __instance.commandList.Count; ++index)
|
||||
{
|
||||
Entity enemy = (Entity)__instance.commandList[index].Enemy;
|
||||
if (!enemy.IsDead())
|
||||
{
|
||||
zero += enemy.position;
|
||||
++num;
|
||||
}
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
Vector3 pos3d = zero * (1f / (float)num);
|
||||
AstarManager.Instance.AddLocation(pos3d, 64);
|
||||
}
|
||||
}
|
||||
__instance.UpdateHorde(_deltaTime);
|
||||
__result = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AIWanderingHordeSpawner))]
|
||||
[HarmonyPatch("UpdateSpawn")]
|
||||
public class UpdateSpawnPatch
|
||||
{
|
||||
public static bool Prefix(AIWanderingHordeSpawner __instance, ref bool __result, World _world, float _deltaTime)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn RebirthVariables.isWHSpawned: " + RebirthVariables.isWHSpawned);
|
||||
|
||||
EntityPlayer closestPlayer = _world.GetClosestPlayer(__instance.startPos, 100, false);
|
||||
|
||||
if (closestPlayer != null)
|
||||
{
|
||||
int searchDistance = 150;
|
||||
|
||||
List<Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityZombieScreamerRebirth), BoundsUtils.BoundsForMinMax(closestPlayer.position.x - searchDistance, closestPlayer.position.y - 50, closestPlayer.position.z - searchDistance, closestPlayer.position.x + searchDistance, closestPlayer.position.y + 50, closestPlayer.position.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn NUM Screamers: " + entitiesInBounds.Count);
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn RebirthVariables.customScreamerMax: " + RebirthVariables.customScreamerMax);
|
||||
|
||||
if (entitiesInBounds.Count >= 1)
|
||||
{
|
||||
int numActiveScreamers = 0;
|
||||
|
||||
for (int index = 0; index < entitiesInBounds.Count; ++index)
|
||||
{
|
||||
EntityZombieScreamerRebirth screamer = (EntityZombieScreamerRebirth)entitiesInBounds[index];
|
||||
|
||||
if (!screamer.IsDead())
|
||||
{
|
||||
numActiveScreamers++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numActiveScreamers >= RebirthVariables.customScreamerMax)
|
||||
{
|
||||
Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn STOPPING WANDERING HORDE, TOO MANY SCREAMERS FOUND");
|
||||
RebirthVariables.isHerd = false;
|
||||
RebirthVariables.stopWHSpawns = true;
|
||||
RebirthVariables.herdDuration = 0f;
|
||||
__instance.Cleanup();
|
||||
|
||||
AIDirectorWanderingHordeComponent director = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorWanderingHordeComponent>();
|
||||
|
||||
if (director != null && director.spawners.Count > 0)
|
||||
{
|
||||
AIWanderingHordeSpawner spawner = director.spawners[director.spawners.Count - 1];
|
||||
if (spawner != null)
|
||||
{
|
||||
director.spawners.RemoveAt(director.spawners.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthVariables.isWHSpawned)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn ATTEMPTING TO FIND A PLAYER");
|
||||
|
||||
if (closestPlayer != null)
|
||||
{
|
||||
RebirthVariables.wanderingHordeGameStage = closestPlayer.gameStage;
|
||||
|
||||
string optionWanderingHordeHerdRestriction = RebirthVariables.customWanderingHordeHerdRestriction;
|
||||
|
||||
if (optionWanderingHordeHerdRestriction == "low")
|
||||
{
|
||||
if (RebirthVariables.wanderingHordeGameStage >= RebirthVariables.spawnThresholdFeral)
|
||||
{
|
||||
RebirthVariables.wanderingHordeGameStage = RebirthVariables.spawnThresholdFeral;
|
||||
}
|
||||
}
|
||||
else if (optionWanderingHordeHerdRestriction == "medium")
|
||||
{
|
||||
if (RebirthVariables.wanderingHordeGameStage >= RebirthVariables.spawnThresholdRadiated)
|
||||
{
|
||||
RebirthVariables.wanderingHordeGameStage = RebirthVariables.spawnThresholdRadiated;
|
||||
}
|
||||
}
|
||||
else if (optionWanderingHordeHerdRestriction == "high")
|
||||
{
|
||||
if (RebirthVariables.wanderingHordeGameStage >= RebirthVariables.spawnThresholdTainted)
|
||||
{
|
||||
RebirthVariables.wanderingHordeGameStage = RebirthVariables.spawnThresholdTainted;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn FOUND CLOSE MEMBER: " + closestPlayer.EntityName + " / gamestage: " + closestPlayer.gameStage);
|
||||
}
|
||||
|
||||
RebirthVariables.stopWHSpawns = false;
|
||||
RebirthVariables.isWHSpawned = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.isHerd)
|
||||
{
|
||||
float diff = Time.time - RebirthVariables.herdStartTime;
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn diff: " + diff + " / " + RebirthVariables.herdDuration);
|
||||
|
||||
if (diff >= RebirthVariables.herdDuration || RebirthUtilities.IsHordeNight()) // 1 in-game hour (170)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn OVER TIME LIMIT");
|
||||
RebirthVariables.isHerd = false;
|
||||
RebirthVariables.stopWHSpawns = true;
|
||||
RebirthVariables.herdDuration = 0f;
|
||||
__instance.Cleanup();
|
||||
|
||||
AIDirectorWanderingHordeComponent director = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorWanderingHordeComponent>();
|
||||
|
||||
if (director != null && director.spawners.Count > 0)
|
||||
{
|
||||
AIWanderingHordeSpawner spawner = director.spawners[director.spawners.Count - 1];
|
||||
if (spawner != null)
|
||||
{
|
||||
director.spawners.RemoveAt(director.spawners.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool canSpawnDirector = GameStats.GetInt(EnumGameStats.EnemyCount) < GamePrefs.GetInt(EnumGamePrefs.MaxSpawnedZombies);
|
||||
|
||||
int whSizeMultiplier = RebirthVariables.wanderingHordeMultiplier;
|
||||
|
||||
if (canSpawnDirector)
|
||||
{
|
||||
if (__instance.commandList.Count >= whSizeMultiplier * RebirthVariables.wanderingHordeSize)
|
||||
{
|
||||
canSpawnDirector = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canSpawnDirector && !RebirthVariables.stopWHSpawns)
|
||||
{
|
||||
if (!RebirthVariables.isHerd)
|
||||
{
|
||||
//Log.Out("Reached wandering horde size: " + __instance.commandList.Count);
|
||||
RebirthVariables.stopWHSpawns = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool tick = __instance.spawner.Tick((double)_deltaTime);
|
||||
|
||||
if (!canSpawnDirector || !tick || RebirthVariables.stopWHSpawns)
|
||||
{
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn CANNOT SPAWN canSpawnDirector: " + canSpawnDirector + " / tick: " + tick);
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn GameStats.GetInt(EnumGameStats.EnemyCount): " + GameStats.GetInt(EnumGameStats.EnemyCount));
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn GamePrefs.GetInt(EnumGamePrefs.MaxSpawnedZombies): " + (double)GamePrefs.GetInt(EnumGamePrefs.MaxSpawnedZombies));
|
||||
//Log.Out("AIWanderingHordeSpawnerPatches-UpdateSpawn RebirthVariables.stopWHSpawns: " + RebirthVariables.stopWHSpawns);
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
__instance.spawnDelay -= _deltaTime;
|
||||
if ((double)__instance.spawnDelay >= 0.0)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
__instance.spawnDelay = 1f;
|
||||
Vector3 _position;
|
||||
|
||||
bool canSpawn = __instance.spawner.canSpawn;
|
||||
bool spawnPosition = _world.GetMobRandomSpawnPosWithWater(__instance.startPos, 1, 6, 15, true, out _position);
|
||||
|
||||
if (!canSpawn || !spawnPosition)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
RebirthVariables.wanderingHordeCount = whSizeMultiplier * RebirthVariables.wanderingHordeSize;
|
||||
|
||||
if (__instance.commandList.Count >= whSizeMultiplier * RebirthVariables.wanderingHordeSize)
|
||||
{
|
||||
if (!RebirthVariables.isHerd)
|
||||
{
|
||||
RebirthVariables.stopWHSpawns = true;
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
string biomeName = RebirthUtilities.GetBiomeName(__instance.startPos);
|
||||
if (biomeName == "desert")
|
||||
{
|
||||
biomeName = "pine_forest";
|
||||
}
|
||||
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
|
||||
EntityEnemy entity = (EntityEnemy)EntityFactory.CreateEntity(EntityGroups.GetRandomFromGroup(__instance.spawner.spawnGroupName, ref __instance.lastClassId), _position);
|
||||
|
||||
if (entity is EntityZombieSDX zombie)
|
||||
{
|
||||
zombie.wanderingHorde = 1;
|
||||
}
|
||||
|
||||
if (RebirthVariables.isHerd)
|
||||
{
|
||||
entity.Buffs.SetCustomVar("$herdEntity", 1f);
|
||||
}
|
||||
|
||||
_world.SpawnEntityInWorld((Entity)entity);
|
||||
|
||||
entity.SetSpawnerSource(EnumSpawnerSource.Dynamic);
|
||||
entity.IsHordeZombie = true;
|
||||
entity.bIsChunkObserver = true;
|
||||
entity.IsHordeZombie = true;
|
||||
entity.bIsChunkObserver = true;
|
||||
if (++__instance.bonusLootSpawnCount >= GameStageDefinition.LootWanderingBonusEvery)
|
||||
{
|
||||
__instance.bonusLootSpawnCount = 0;
|
||||
entity.lootDropProb *= GameStageDefinition.LootWanderingBonusScale;
|
||||
}
|
||||
AIWanderingHordeSpawner.ZombieCommand zombieCommand = new AIWanderingHordeSpawner.ZombieCommand();
|
||||
zombieCommand.Enemy = entity;
|
||||
zombieCommand.TargetPos = AIWanderingHordeSpawner.RandomPos(__instance.director, __instance.endPos, 6f);
|
||||
zombieCommand.Command = AIWanderingHordeSpawner.ECommand.EndPos;
|
||||
__instance.commandList.Add(zombieCommand);
|
||||
entity.SetInvestigatePosition(zombieCommand.TargetPos, 6000, false);
|
||||
AIDirector.LogAI("Spawned wandering horde (group {0}, zombie {1})", (object)__instance.spawner.spawnGroupName, (object)entity);
|
||||
__instance.spawner.IncSpawnCount();
|
||||
__result = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using Audio;
|
||||
using System.Linq;
|
||||
using static UIBasicSprite;
|
||||
|
||||
namespace Harmony.AudioObjectPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(EnvironmentAudioManager))]
|
||||
[HarmonyPatch("InitSounds")]
|
||||
public class InitSoundsPatch
|
||||
{
|
||||
public static bool Prefix(EnvironmentAudioManager __instance)
|
||||
{
|
||||
AudioObject[] audioObjectArray = new AudioObject[0 + __instance.mixedBiomeSounds.Length + __instance.forestOnlyBiomeSounds.Length + __instance.snowOnlyBiomeSounds.Length + __instance.desertOnlyBiomeSounds.Length + __instance.wastelandOnlyBiomeSounds.Length + __instance.waterOnlyBiomeSounds.Length + __instance.burnt_forestOnlyBiomeSounds.Length];
|
||||
int num1 = 0;
|
||||
foreach (AudioObject mixedBiomeSound in __instance.mixedBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds mixedBiomeSound.name: " + mixedBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds mixedBiomeSound.audioClips.Length: " + mixedBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = mixedBiomeSound;
|
||||
}
|
||||
foreach (AudioObject forestOnlyBiomeSound in __instance.forestOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds forestOnlyBiomeSound.name: " + forestOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds forestOnlyBiomeSound.audioClips.Length: " + forestOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = forestOnlyBiomeSound;
|
||||
}
|
||||
foreach (AudioObject snowOnlyBiomeSound in __instance.snowOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds snowOnlyBiomeSound.name: " + snowOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds snowOnlyBiomeSound.audioClips.Length: " + snowOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = snowOnlyBiomeSound;
|
||||
}
|
||||
foreach (AudioObject desertOnlyBiomeSound in __instance.desertOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds desertOnlyBiomeSound.name: " + desertOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds desertOnlyBiomeSound.audioClips.Length: " + desertOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = desertOnlyBiomeSound;
|
||||
}
|
||||
foreach (AudioObject wastelandOnlyBiomeSound in __instance.wastelandOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds wastelandOnlyBiomeSound.name: " + wastelandOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds wastelandOnlyBiomeSound.audioClips.Length: " + wastelandOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = wastelandOnlyBiomeSound;
|
||||
}
|
||||
foreach (AudioObject waterOnlyBiomeSound in __instance.waterOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds waterOnlyBiomeSound.name: " + waterOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds waterOnlyBiomeSound.audioClips.Length: " + waterOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = waterOnlyBiomeSound;
|
||||
}
|
||||
foreach (AudioObject forestOnlyBiomeSound in __instance.burnt_forestOnlyBiomeSounds)
|
||||
{
|
||||
//Log.Out("AudioObjectPatches-InitSounds forestOnlyBiomeSound.name: " + forestOnlyBiomeSound.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds forestOnlyBiomeSound.audioClips.Length: " + forestOnlyBiomeSound.audioClips.Length);
|
||||
audioObjectArray[num1++] = forestOnlyBiomeSound;
|
||||
}
|
||||
int num2 = 0;
|
||||
foreach (AudioObject _audioObject in audioObjectArray)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip() && _audioObject.name == "Birds_Loops")
|
||||
continue;
|
||||
|
||||
//Log.Out("AudioObjectPatches-InitSounds _audioObject NAME: " + _audioObject.name);
|
||||
//Log.Out("AudioObjectPatches-InitSounds validBiomes.Length: " + _audioObject.validBiomes.Length);
|
||||
foreach (int validBiome in _audioObject.validBiomes)
|
||||
{
|
||||
__instance.audioBiomes[validBiome].Add(_audioObject);
|
||||
if (_audioObject.trigger == AudioObject.Trigger.Day7Times || _audioObject.trigger == AudioObject.Trigger.TimeOfDay)
|
||||
++num2;
|
||||
}
|
||||
_audioObject.Init();
|
||||
}
|
||||
__instance.fromBiomeLoops = __instance.audioBiomes[(int)__instance.fromBiome];
|
||||
__instance.toBiomeLoops = __instance.audioBiomes[(int)__instance.toBiome];
|
||||
__instance.soundsInitDone = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AudioObject))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static bool Prefix(AudioObject __instance)
|
||||
{
|
||||
foreach (AudioClip audioClip in __instance.audioClips)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip() && (audioClip.name == "a_daybreak_oneshot" ||
|
||||
audioClip.name == "a_nightfall_oneshot" ||
|
||||
audioClip.name == "a_bloodmoon_oneshot")
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((UnityEngine.Object)audioClip != (UnityEngine.Object)null)
|
||||
{
|
||||
AudioSource audioSource = UnityEngine.Object.Instantiate<AudioSource>(__instance.masterAudioSource);
|
||||
if (__instance.playOrder == AudioObject.PlayOrder.ByValue)
|
||||
{
|
||||
audioSource.transform.parent = EnvironmentAudioManager.Instance.transform;
|
||||
audioSource.loop = true;
|
||||
audioSource.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
audioSource.transform.parent = EnvironmentAudioManager.sourceSounds.transform;
|
||||
audioSource.clip = audioClip;
|
||||
audioSource.name = audioClip.name;
|
||||
//Log.Out("AudioObjectPatches-Init audioSource.name: " + audioSource.name);
|
||||
audioSource.volume = 0.0f;
|
||||
audioSource.outputAudioMixerGroup = __instance.audioMixerGroup;
|
||||
__instance.runtimeAudioSrcs.Add(audioSource);
|
||||
}
|
||||
}
|
||||
__instance.audioClips = (AudioClip[])null;
|
||||
if (__instance.trigger != AudioObject.Trigger.Random)
|
||||
return false;
|
||||
__instance.repeatTime = Time.time + Manager.random.RandomRange(__instance.repeatFreqRange.x, __instance.repeatFreqRange.y);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
namespace Harmony.AutoTurretFireControllerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(AutoTurretFireController))]
|
||||
[HarmonyPatch("shouldIgnoreTarget")]
|
||||
public class shouldIgnoreTargetPatch
|
||||
{
|
||||
public static bool Prefix(AutoTurretFireController __instance, ref bool __result, Entity _target,
|
||||
ref EntityAlive ___currentEntityTarget
|
||||
)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget START _target: " + _target.EntityClass.entityClassName);
|
||||
__result = false;
|
||||
|
||||
if (Vector3.Dot(_target.position - __instance.TileEntity.ToWorldPos().ToVector3(), __instance.Cone.transform.forward) > 0f)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 1");
|
||||
if (_target == ___currentEntityTarget)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 2");
|
||||
___currentEntityTarget = null;
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (!_target.IsAlive())
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 3");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (_target is EntitySupplyCrate || _target is EntityTurret || _target is EntityDrone)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 4");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (_target is EntityVehicle)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 5");
|
||||
Entity attachedMainEntity = (_target as EntityVehicle).AttachedMainEntity;
|
||||
if (attachedMainEntity == null)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 6");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
_target = attachedMainEntity;
|
||||
}
|
||||
if (_target is EntityZombieSDX && !__instance.TileEntity.TargetZombies)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 7");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
PersistentPlayerList persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
|
||||
PersistentPlayerData playerData = persistentPlayerList.GetPlayerData(__instance.TileEntity.GetOwner());
|
||||
|
||||
if (_target is EntityPlayer)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 8");
|
||||
bool flag = false;
|
||||
bool flag2 = false;
|
||||
EnumPlayerKillingMode @int = (EnumPlayerKillingMode)GamePrefs.GetInt(EnumGamePrefs.PlayerKillingMode);
|
||||
if (persistentPlayerList != null && persistentPlayerList.EntityToPlayerMap.ContainsKey(_target.entityId) && __instance.TileEntity.IsOwner(persistentPlayerList.EntityToPlayerMap[_target.entityId].PrimaryId))
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 9");
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 10");
|
||||
if (playerData != null && persistentPlayerList.EntityToPlayerMap.ContainsKey(_target.entityId))
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 11");
|
||||
PersistentPlayerData persistentPlayerData = persistentPlayerList.EntityToPlayerMap[_target.entityId];
|
||||
if (playerData.ACL != null && persistentPlayerData != null && playerData.ACL.Contains(persistentPlayerData.PrimaryId))
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 12");
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (@int == EnumPlayerKillingMode.NoKilling)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 13");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (flag && !__instance.TileEntity.TargetSelf)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 14");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (flag2 && (!__instance.TileEntity.TargetAllies || (@int != EnumPlayerKillingMode.KillEveryone && @int != EnumPlayerKillingMode.KillAlliesOnly)))
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 15");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (!flag && !flag2 && (!__instance.TileEntity.TargetStrangers || (@int != EnumPlayerKillingMode.KillStrangersOnly && @int != EnumPlayerKillingMode.KillEveryone)))
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 16");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData != null)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 17");
|
||||
EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(playerData.EntityId);
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 18");
|
||||
__result = !RebirthUtilities.VerifyFactionStanding(entityPlayer, (EntityAlive)_target);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Owner is not online
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget 18");
|
||||
string sourceFaction = "";
|
||||
string targetFaction = "";
|
||||
|
||||
if (__instance.TileEntity.blockValue.Block.Properties.Values.ContainsKey("Faction"))
|
||||
{
|
||||
sourceFaction = __instance.TileEntity.blockValue.Block.Properties.Values["Faction"];
|
||||
}
|
||||
if (_target.EntityClass.Properties.Values.ContainsKey("Faction"))
|
||||
{
|
||||
targetFaction = _target.EntityClass.Properties.Values["Faction"];
|
||||
}
|
||||
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget sourceFaction: " + sourceFaction);
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget targetFaction: " + targetFaction);
|
||||
|
||||
__result = !RebirthUtilities.VerifyFactionStandingDetails(sourceFaction, targetFaction);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("AutoTurretFireControllerPatches-shouldIgnoreTarget __result: " + __result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,471 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.BackgroundMusicPatches
|
||||
{
|
||||
public class MenuMusic
|
||||
{
|
||||
public static AudioType MyMusicType = AudioType.OGGVORBIS;
|
||||
public static List<int> musicLeft = new List<int>();
|
||||
|
||||
[HarmonyPatch(typeof(BackgroundMusicMono))]
|
||||
[HarmonyPatch("Start")]
|
||||
public class StartPatch
|
||||
{
|
||||
public static bool Prefix(BackgroundMusicMono __instance
|
||||
)
|
||||
{
|
||||
AudioListener[] objectsOfType = UnityEngine.Object.FindObjectsOfType<AudioListener>();
|
||||
for (int index = 0; index < objectsOfType.Length; ++index)
|
||||
{
|
||||
if (objectsOfType[index].enabled)
|
||||
{
|
||||
__instance.transform.position = objectsOfType[index].transform.position;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AudioListener.volume = Mathf.Min(GamePrefs.GetFloat(EnumGamePrefs.OptionsOverallAudioVolumeLevel), 1f);
|
||||
RebirthVariables.audioSource = __instance.gameObject.AddComponent<AudioSource>();
|
||||
RebirthVariables.audioSource.volume = RebirthVariables.currentVolume = 0.01f;
|
||||
RebirthVariables.audioSource.clip = GameManager.Instance.BackgroundMusicClip;
|
||||
RebirthVariables.audioSource.loop = true;
|
||||
RebirthVariables.audioSource.Play();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BackgroundMusicMono), "Update")]
|
||||
public class Update
|
||||
{
|
||||
private static bool Prefix(BackgroundMusicMono __instance)
|
||||
{
|
||||
if (GameManager.Instance == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.audioSource.clip.name: " + RebirthVariables.audioSource.clip.name);
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.audioSource.isPlaying: " + RebirthVariables.audioSource.isPlaying);
|
||||
|
||||
if (RebirthVariables.audioSource.clip.name == "menu_music_long_lp")
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 1");
|
||||
string strMusicPath = "";
|
||||
|
||||
RebirthVariables.audioClip = new AudioClip[23];
|
||||
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 1a, i: " + i);
|
||||
musicLeft.Add(i);
|
||||
strMusicPath = "#@modfolder(zzz_REBIRTH__Utils):Resources/FR_Music.unity3d?Menu" + i;
|
||||
RebirthVariables.audioClip[i - 1] = DataLoader.LoadAsset<AudioClip>(strMusicPath);
|
||||
}
|
||||
|
||||
strMusicPath = "#@modfolder(zzz_REBIRTH__Utils):Resources/FR_Music.unity3d?Scratch";
|
||||
|
||||
AudioClip audioClip = DataLoader.LoadAsset<AudioClip>(strMusicPath);
|
||||
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
|
||||
if (audioClip != null)
|
||||
{
|
||||
RebirthVariables.audioSource.Stop();
|
||||
RebirthVariables.audioSource.clip = audioClip;
|
||||
RebirthVariables.audioSource.PlayOneShot(audioClip);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (RebirthVariables.audioSource.clip.name == "Scratch" && RebirthVariables.audioSource.isPlaying == false)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 2");
|
||||
int num = UnityEngine.Random.Range(1, 10);
|
||||
|
||||
string strMusicPath = "#@modfolder(zzz_REBIRTH__Utils):Resources/FR_Music.unity3d?Rekt" + num;
|
||||
|
||||
AudioClip audioClip = DataLoader.LoadAsset<AudioClip>(strMusicPath);
|
||||
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
if (audioClip != null)
|
||||
{
|
||||
RebirthVariables.audioSource.clip = audioClip;
|
||||
RebirthVariables.audioSource.PlayOneShot(audioClip);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (RebirthVariables.audioSource.clip.name.Contains("Rekt") && RebirthVariables.audioSource.isPlaying == false && !RebirthVariables.audioClipLoaded)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 3a, musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
//RebirthVariables.audioClip = new AudioClip[23];
|
||||
|
||||
if (musicLeft.Count == 0)
|
||||
{
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 3a, i: " + i);
|
||||
musicLeft.Add(i);
|
||||
string strMusicPath = "#@modfolder(zzz_REBIRTH__Utils):Resources/FR_Music.unity3d?Menu" + i;
|
||||
RebirthVariables.audioClip[i - 1] = DataLoader.LoadAsset<AudioClip>(strMusicPath);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update 3b, musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
int num = UnityEngine.Random.Range(1, musicLeft.Count);
|
||||
RebirthVariables.songIndex = musicLeft[num];
|
||||
|
||||
musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 3c");
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
RebirthVariables.audioSource.Play();
|
||||
|
||||
}
|
||||
|
||||
RebirthVariables.audioClipLoaded = true;
|
||||
}
|
||||
else if (RebirthVariables.audioSource.clip.name.Contains("Menu") && RebirthVariables.audioSource.volume > 0 && RebirthVariables.audioSource.isPlaying == false && RebirthVariables.musicMode == -1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 4, musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
if (musicLeft.Count == 0)
|
||||
{
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
musicLeft.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
int num = UnityEngine.Random.Range(0, musicLeft.Count - 1);
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update num: " + num);
|
||||
|
||||
RebirthVariables.songIndex = musicLeft[num];
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.audioSource.clip.name.Contains("Menu") && RebirthVariables.audioSource.volume > 0 && RebirthVariables.audioSource.isPlaying == false && RebirthVariables.musicMode == 1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 5, musicLeft.Count: " + musicLeft.Count);
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (musicLeft.Count == 0)
|
||||
{
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("FuriousRamsayAchievementCassette" + i);
|
||||
|
||||
if (progressionValue != null && progressionValue.Level > 0)
|
||||
{
|
||||
musicLeft.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.songIndex = -1;
|
||||
|
||||
if (musicLeft.Count > 0)
|
||||
{
|
||||
int num = UnityEngine.Random.Range(0, musicLeft.Count - 1);
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update num: " + num);
|
||||
|
||||
RebirthVariables.songIndex = musicLeft[num];
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.musicMode: " + RebirthVariables.musicMode);
|
||||
|
||||
if (GameStats.GetInt(EnumGameStats.GameState) == 1 && !GameManager.Instance.IsPaused())
|
||||
{
|
||||
if (RebirthVariables.musicMode == 3 && RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 6");
|
||||
RebirthVariables.audioSource.Stop();
|
||||
RebirthVariables.musicMode = -1;
|
||||
musicLeft.Clear();
|
||||
}
|
||||
else if (RebirthVariables.musicMode == 4 && RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 7, BEFORE RebirthVariables.musicVolume: " + RebirthVariables.musicVolume);
|
||||
RebirthVariables.musicVolume += 0.02f;
|
||||
if (RebirthVariables.musicVolume > 1f)
|
||||
{
|
||||
RebirthVariables.musicVolume = 1f;
|
||||
}
|
||||
//Log.Out("BackgroundMusicPatches-Update 7, AFTER RebirthVariables.musicVolume: " + RebirthVariables.musicVolume);
|
||||
RebirthVariables.musicMode = 1;
|
||||
}
|
||||
else if (RebirthVariables.musicMode == 5 && RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 8, BEFORE RebirthVariables.musicVolume: " + RebirthVariables.musicVolume);
|
||||
RebirthVariables.musicVolume -= 0.02f;
|
||||
if (RebirthVariables.musicVolume < 0f)
|
||||
{
|
||||
RebirthVariables.musicVolume = 0f;
|
||||
}
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update 8, AFTER RebirthVariables.musicVolume: " + RebirthVariables.musicVolume);
|
||||
RebirthVariables.musicMode = 1;
|
||||
}
|
||||
else if (RebirthVariables.musicMode == 2 && RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 9");
|
||||
|
||||
RebirthVariables.audioSource.Stop();
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (musicLeft.Count == 0)
|
||||
{
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("FuriousRamsayAchievementCassette" + i);
|
||||
|
||||
if (progressionValue != null && progressionValue.Level > 0)
|
||||
{
|
||||
musicLeft.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.songIndex = -1;
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
if (musicLeft.Count > 0)
|
||||
{
|
||||
/*for (int i = 0; i <= musicLeft.Count - 1; i++)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update BEFORE musicLeft[" + i + "]: " + musicLeft[i]);
|
||||
}*/
|
||||
|
||||
int num = UnityEngine.Random.Range(0, musicLeft.Count - 1);
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update num: " + num);
|
||||
|
||||
RebirthVariables.songIndex = musicLeft[num];
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
/*if (musicLeft.Count > 0)
|
||||
{
|
||||
for (int i = 0; i <= musicLeft.Count - 1; i++)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update AFTER musicLeft[" + i + "]: " + musicLeft[i]);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.audioSource.clip.name: " + RebirthVariables.audioSource.clip.name);
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.musicMode = 1;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.musicMode == 1 && !RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 10");
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update BEFORE musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
musicLeft.Clear();
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update AFTER musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 10a");
|
||||
|
||||
if (musicLeft.Count == 0)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 10b");
|
||||
|
||||
for (int i = 1; i <= 23; i++)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("FuriousRamsayAchievementCassette" + i);
|
||||
|
||||
if (progressionValue != null && progressionValue.Level > 0)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 10c, i: " + i);
|
||||
musicLeft.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.songIndex = -1;
|
||||
|
||||
if (musicLeft.Count > 0)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 10d, musicLeft.Count: " + musicLeft.Count);
|
||||
|
||||
int num = UnityEngine.Random.Range(0, musicLeft.Count - 1);
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update num: " + num);
|
||||
|
||||
RebirthVariables.songIndex = musicLeft[num];
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update 6a, RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 6b, SONG FOUND");
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.musicMode == 0 && RebirthVariables.audioSource.isPlaying)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 11");
|
||||
RebirthVariables.secondsToFadeOut = 1f;
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeOut;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.audioSource.isPlaying && RebirthVariables.musicMode == -1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 12");
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthVariables.controlOption == MusicControlOption.FadeIn)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 13, RebirthVariables.currentVolume: " + RebirthVariables.currentVolume);
|
||||
//Log.Out("BackgroundMusicPatches-Update 13, musicLeft: " + musicLeft.Count);
|
||||
if (RebirthVariables.currentVolume < 1f)
|
||||
{
|
||||
RebirthVariables.currentVolume += Time.deltaTime / RebirthVariables.secondsToFadeIn;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.controlOption == MusicControlOption.FadeOut && RebirthVariables.currentVolume > 0f)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 14");
|
||||
RebirthVariables.currentVolume -= Time.deltaTime / RebirthVariables.secondsToFadeOut;
|
||||
}
|
||||
RebirthVariables.currentVolume = Mathf.Clamp01(RebirthVariables.currentVolume);
|
||||
|
||||
float volume = Mathf.Clamp01(GamePrefs.GetFloat(EnumGamePrefs.OptionsMenuMusicVolumeLevel) * RebirthVariables.currentVolume);
|
||||
|
||||
//if (volume == 0f && RebirthVariables.musicMode == 1)
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
volume = Mathf.Clamp01(RebirthVariables.musicVolume) * RebirthVariables.currentVolume;
|
||||
}
|
||||
|
||||
//Log.Out("BackgroundMusicPatches-Update volume: " + volume);
|
||||
|
||||
RebirthVariables.audioSource.volume = volume; // Mathf.Clamp01(GamePrefs.GetFloat(EnumGamePrefs.OptionsMenuMusicVolumeLevel) * RebirthVariables.currentVolume);
|
||||
if (RebirthVariables.audioSource.isPlaying && RebirthVariables.audioSource.volume <= 0f && RebirthVariables.musicMode != 1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update STOP");
|
||||
RebirthVariables.audioSource.Stop();
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!RebirthVariables.audioSource.isPlaying && RebirthVariables.audioSource.volume > 0f)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 15, RebirthVariables.musicMode: " + RebirthVariables.musicMode);
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 15a");
|
||||
if (RebirthVariables.songIndex > -1)
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 15b");
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 15c");
|
||||
RebirthVariables.musicMode = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BackgroundMusicPatches-Update 15d");
|
||||
|
||||
if (RebirthVariables.musicMode == 3)
|
||||
{
|
||||
RebirthVariables.musicMode = -1;
|
||||
RebirthVariables.songIndex = -1;
|
||||
musicLeft.Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
RebirthVariables.audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<int> musicLeft = new List<int>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace Harmony.EntityPlayerRebirth
|
||||
{
|
||||
internal class BagPatches
|
||||
{
|
||||
public static int numSlots = 50;
|
||||
|
||||
public static MethodInfo checkBagAssigned = AccessTools.Method(typeof(Bag), "checkBagAssigned", new Type[] { typeof(int) });
|
||||
public static MethodInfo onBackpackChanged = AccessTools.Method(typeof(Bag), "onBackpackChanged", new Type[] { });
|
||||
|
||||
[HarmonyPatch(typeof(Bag))]
|
||||
[HarmonyPatch("GetSlots")]
|
||||
public class GetSlots
|
||||
{
|
||||
private static bool Prefix(Bag __instance, ref ItemStack[] __result, ref global::EntityAlive ___entity, ref ItemStack[] ___items)
|
||||
{
|
||||
if (___entity.Spawned)
|
||||
{
|
||||
float additionalRows = ___entity.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
||||
if (additionalRows > 0)
|
||||
{
|
||||
numSlots = numSlots + (int)additionalRows;
|
||||
}
|
||||
}
|
||||
|
||||
checkBagAssigned.Invoke(__instance, new object[] { numSlots });
|
||||
|
||||
__result = ___items;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Bag))]
|
||||
[HarmonyPatch("SetSlots")]
|
||||
public class SetSlots
|
||||
{
|
||||
private static bool Prefix(Bag __instance, ItemStack[] _slots, ref global::EntityAlive ___entity, ref ItemStack[] ___items, ref XUiEvent_BackpackItemsChangedInternal ___OnBackpackItemsChangedInternal)
|
||||
{
|
||||
if (___entity.Spawned)
|
||||
{
|
||||
float additionalRows = ___entity.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
||||
if (additionalRows > 0)
|
||||
{
|
||||
numSlots = numSlots + (int)additionalRows;
|
||||
}
|
||||
}
|
||||
|
||||
checkBagAssigned.Invoke(__instance, new object[] { numSlots });
|
||||
___items = _slots;
|
||||
onBackpackChanged.Invoke(__instance, new object[] { });
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
namespace Harmony.BindingItemPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BindingItem))]
|
||||
[HarmonyPatch("ParseCVars")]
|
||||
public class ParseCVarsPatch
|
||||
{
|
||||
public static bool Prefix(BindingItem __instance, ref string __result, string _fullText,
|
||||
char ___cvarFormatSplitChar,
|
||||
char[] ___cvarFormatSplitCharArray
|
||||
)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars _fullText: " + _fullText);
|
||||
|
||||
for (int num = _fullText.IndexOf("{cvar(", StringComparison.Ordinal); num != -1; num = _fullText.IndexOf("{cvar(", num, StringComparison.Ordinal))
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars num: " + num);
|
||||
string text = _fullText.Substring(num, _fullText.IndexOf('}', num) + 1 - num);
|
||||
string format = "";
|
||||
int num2 = text.IndexOf('(') + 1;
|
||||
string text2 = text.Substring(num2, text.IndexOf(')') - num2);
|
||||
if (text2.IndexOf(___cvarFormatSplitChar) >= 0)
|
||||
{
|
||||
string[] array = text2.Split(___cvarFormatSplitCharArray);
|
||||
text2 = array[0];
|
||||
format = array[1];
|
||||
}
|
||||
|
||||
bool foundEntry = text2.Contains("$varFuriousRamsay");
|
||||
|
||||
if (!foundEntry)
|
||||
{
|
||||
_fullText = _fullText.Replace(text, XUiM_Player.GetPlayer().GetCVar(text2).ToString(format));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (text2.EndsWith("Perc") && !text2.EndsWith("Unit"))
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars RebirthVariables.localVariables[" + text2 + "Unit]: " + RebirthVariables.localVariables[text2 + "Unit"].ToString(format));
|
||||
|
||||
string level = text2.Replace("$varFuriousRamsay", "").Replace("Perc", "");
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars level: " + level);
|
||||
|
||||
bool found = false;
|
||||
|
||||
string foundKey = "";
|
||||
|
||||
foreach (var key in RebirthVariables.localClasses.Keys)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars CLASS key: " + key);
|
||||
if (level.Contains(key))
|
||||
{
|
||||
level = level.Replace(key, "");
|
||||
found = true;
|
||||
foundKey = key;
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars CLASS level: " + level);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
foreach (var key in RebirthVariables.localExpertise.Keys)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars EXPERTISE key: " + key);
|
||||
if (level.Contains(key))
|
||||
{
|
||||
level = level.Replace(key, "");
|
||||
foundKey = key;
|
||||
found = true;
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars EXPERTISE level: " + level);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float total = 0;
|
||||
|
||||
if (found)
|
||||
{
|
||||
total = RebirthVariables.localVariables[text2.Replace(level, "") + "Unit"];
|
||||
}
|
||||
else
|
||||
{
|
||||
total = RebirthVariables.localVariables[text2 + "Unit"];
|
||||
}
|
||||
|
||||
float unit = total % 1;
|
||||
|
||||
float percentage = (float)(Math.Truncate(unit * 100 * 100) / 100);
|
||||
|
||||
if (percentage > 100)
|
||||
{
|
||||
percentage = 100.00f;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars level: " + level);
|
||||
//Log.Out("BindingItemPatches-ParseCVars unit: " + unit);
|
||||
//Log.Out("BindingItemPatches-ParseCVars BEFORE percentage: " + percentage);
|
||||
|
||||
int foundLevel = int.Parse(level);
|
||||
|
||||
int currentLevel = (int)total + 1;
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars currentLevel: " + currentLevel);
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars foundLevel: " + foundLevel);
|
||||
//Log.Out("BindingItemPatches-ParseCVars currentLevel: " + currentLevel);
|
||||
if (foundLevel < currentLevel)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars foundLevel < currentLevel");
|
||||
percentage = 100.00f;
|
||||
}
|
||||
else if (foundLevel > currentLevel)
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars foundLevel > currentLevel");
|
||||
percentage = 0.00f;
|
||||
}
|
||||
|
||||
//Log.Out("BindingItemPatches-ParseCVars AFTER percentage: " + percentage);
|
||||
}
|
||||
|
||||
_fullText = _fullText.Replace(text, percentage.ToString());
|
||||
}
|
||||
else if (text2.EndsWith("Lvl"))
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars RebirthVariables.localConstants[" + text2 + "]: " + RebirthVariables.localConstants[text2].ToString(format));
|
||||
_fullText = _fullText.Replace(text, RebirthVariables.localConstants[text2].ToString(format));
|
||||
}
|
||||
else if (text2.EndsWith("_Cst"))
|
||||
{
|
||||
//Log.Out("BindingItemPatches-ParseCVars RebirthVariables.localConstants[" + text2 + "]: " + RebirthVariables.localConstants[text2].ToString(format));
|
||||
_fullText = _fullText.Replace(text, RebirthVariables.localConstants[text2].ToString(format));
|
||||
}
|
||||
else
|
||||
{
|
||||
_fullText = _fullText.Replace(text, XUiM_Player.GetPlayer().GetCVar(text2).ToString(format));
|
||||
}
|
||||
}
|
||||
}
|
||||
__result = _fullText;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
namespace Harmony.BiomeDefinitionPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(BiomeDefinition))]
|
||||
[HarmonyPatch("AddDecoBlock")]
|
||||
public class AddDecoBlockPatch
|
||||
{
|
||||
public static bool Prefix(BiomeDefinition __instance, BiomeBlockDecoration _deco)
|
||||
{
|
||||
if (Block.BlocksLoaded && _deco.blockValue.Block != null)
|
||||
{
|
||||
string name = _deco.blockName;
|
||||
float multiplier = float.Parse(RebirthVariables.customTreeDensityMultiplier) / 100;
|
||||
|
||||
if (name == "treeJuniper4m" ||
|
||||
name == "treeMountainPine12m" ||
|
||||
name == "treeMountainPine19m" ||
|
||||
name == "treeMountainPineDry21m" ||
|
||||
name == "treeMountainPine27m" ||
|
||||
name == "treeMountainPine31m" ||
|
||||
name == "treeMountainPine41m" ||
|
||||
name == "treeMountainPine48m" ||
|
||||
name == "treeOakSml01" ||
|
||||
name == "treeOakLrg01" ||
|
||||
name == "treeOakMed01" ||
|
||||
name == "treeOakMed02" ||
|
||||
name == "treeFirLrg01"
|
||||
)
|
||||
{
|
||||
_deco.prob = _deco.prob * multiplier * 0.8f;
|
||||
}
|
||||
|
||||
if (name == "treeWinterEverGreen" ||
|
||||
name == "treeWinterPine13m" ||
|
||||
name == "treeWinterPine19m" ||
|
||||
name == "treeWinterPine28m"
|
||||
)
|
||||
{
|
||||
_deco.prob = _deco.prob * multiplier;
|
||||
}
|
||||
|
||||
if (name == "treeJuniper4m" ||
|
||||
name == "treeDeadPineLeaf" ||
|
||||
name == "treePineBurntLrg" ||
|
||||
name == "treePineBurntMed" ||
|
||||
name == "treePineBurntFullMed" ||
|
||||
name == "treeBurntMaple01" ||
|
||||
name == "treeBurntMaple02" ||
|
||||
name == "treeBurntMaple03" ||
|
||||
name == "treeDeadTree01" ||
|
||||
name == "treeDeadTree02"
|
||||
)
|
||||
{
|
||||
_deco.prob = _deco.prob * multiplier * 1.67f;
|
||||
if (__instance.m_sBiomeName == "burnt_forest")
|
||||
{
|
||||
_deco.prob = _deco.prob * 2f;
|
||||
}
|
||||
else if (__instance.m_sBiomeName == "wasteland")
|
||||
{
|
||||
_deco.prob = _deco.prob / 250f;
|
||||
}
|
||||
}
|
||||
|
||||
/*if (name == "deco_remnant_wood_01" ||
|
||||
name == "deco_remnant_wood_02" ||
|
||||
name == "deco_remnant_stone_01" ||
|
||||
name == "deco_remnant_stone_02" ||
|
||||
name == "deco_remnant_stone_03" ||
|
||||
name == "deco_remnant_stone_04" ||
|
||||
name == "deco_remnant_stone_05"
|
||||
)
|
||||
{
|
||||
if (__instance.m_sBiomeName == "wasteland")
|
||||
{
|
||||
//_deco.prob = _deco.prob * 100f;
|
||||
_deco.prob = 1f; ;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == "deco_rubble_stone_01" ||
|
||||
name == "deco_rubble_stone_02" ||
|
||||
name == "deco_rubble_stone_03" ||
|
||||
name == "deco_rubble_stone_04" ||
|
||||
name == "deco_rubble_stone_05" ||
|
||||
name == "deco_rubble_stone_06" ||
|
||||
name == "deco_rubble_stone_07" ||
|
||||
name == "deco_rubble_stone_08" ||
|
||||
name == "deco_rubble_stone_09" ||
|
||||
name == "deco_rubble_stone_10"
|
||||
)
|
||||
{
|
||||
if (__instance.m_sBiomeName == "wasteland")
|
||||
{
|
||||
_deco.prob = _deco.prob * 15f;
|
||||
}
|
||||
}
|
||||
|
||||
if (name.Contains("zztong_rubble"))
|
||||
{
|
||||
_deco.prob = 0f;
|
||||
}*/
|
||||
|
||||
multiplier = float.Parse(RebirthVariables.customVehicleDensityMultiplier) / 100;
|
||||
|
||||
if (name == "carsRandomHelperBiome")
|
||||
{
|
||||
//Log.Out("BiomeDefinitionPatches-AddDecoBlock BIOME: " + __instance.m_sBiomeName);
|
||||
//Log.Out("BiomeDefinitionPatches-AddDecoBlock multiplier: " + multiplier);
|
||||
//Log.Out("BiomeDefinitionPatches-AddDecoBlock BEFORE prob: " + _deco.prob);
|
||||
_deco.prob = _deco.prob * multiplier;
|
||||
if (__instance.m_sBiomeName == "wasteland")
|
||||
{
|
||||
_deco.prob = _deco.prob * 3;
|
||||
}
|
||||
//Log.Out("BiomeDefinitionPatches-AddDecoBlock AFTER prob: " + _deco.prob);
|
||||
}
|
||||
}
|
||||
|
||||
if (Block.BlocksLoaded && _deco.blockValue.Block != null && _deco.blockValue.Block.IsDistantDecoration)
|
||||
__instance.m_DistantDecoBlocks.Add(_deco);
|
||||
__instance.m_DecoBlocks.Add(_deco);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace Harmony.BiomeSpawningFromXmlPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BiomeSpawningFromXml))]
|
||||
[HarmonyPatch("Load")]
|
||||
public class LoadPatch
|
||||
{
|
||||
private static bool Prefix(BiomeSpawningFromXml __instance, XmlFile _xmlFile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private static IEnumerator Postfix(IEnumerator __result, XmlFile _xmlFile)
|
||||
{
|
||||
yield return (object)RebirthUtilities.LoadSpawningXML(_xmlFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,825 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.BlockPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockLoaded")]
|
||||
public class OnBlockLoadedPatch
|
||||
{
|
||||
public static IEnumerator UpdateBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public static void Postfix(Block __instance, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
if (_world.IsEditor() || GameUtils.IsWorldEditor() || GameUtils.IsPlaytesting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (_blockValue.Block is BlockPoweredLight || _blockValue.Block is BlockLight)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockLoaded IsServer: " + SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer);
|
||||
|
||||
bool _isOn = ((uint)_blockValue.meta & 2U) > 0U;
|
||||
|
||||
if (_isOn)
|
||||
{
|
||||
bool isWithinTraderArea = ((World)_world).GetTraderAreaAt(_blockPos) != null;
|
||||
if (!isWithinTraderArea)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockLoaded IS ON blockLight: " + blockLight.blockName);
|
||||
_blockValue.meta = 0;
|
||||
|
||||
//RebirthVariables.blockChanges.Add(new BlockChangeInfo(_clrIdx, _blockPos, _blockValue));
|
||||
//_world.SetBlockRPC(_clrIdx, _blockPos, _blockValue);
|
||||
GameManager.Instance.StartCoroutine(UpdateBlock(_world, _clrIdx, _blockPos, _blockValue));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*else if (_blockValue.Block is BlockLight blockLight)
|
||||
{
|
||||
List<BlockChangeInfo> blockChanges = new List<BlockChangeInfo>();
|
||||
|
||||
_blockValue = blockLight.SetLightState((WorldBase)_world, _clrIdx, _blockPos, _blockValue, false);
|
||||
blockChanges.Add(new BlockChangeInfo(_clrIdx, _blockPos, _blockValue));
|
||||
|
||||
if (blockChanges.Count > 0)
|
||||
GameManager.Instance.StartCoroutine(UpdateBlocks(blockChanges));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockAdded")]
|
||||
public class OnBlockAddedPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
Log.Out("BlockPatches-OnBlockAdded START");
|
||||
if (_blockValue.Block.Properties.Contains("BedrollRebirth"))
|
||||
{
|
||||
Log.Out("BlockPatches-OnBlockAdded 1");
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
Log.Out("BlockPatches-OnBlockAdded 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong tickRate = 20UL;
|
||||
|
||||
if (_blockValue.Block.Properties.Contains("TickRate"))
|
||||
{
|
||||
tickRate = (ulong)StringParsers.ParseFloat(__instance.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20UL;
|
||||
|
||||
Log.Out("BlockPatches-OnBlockAdded tickRate: " + tickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Out("BlockPatches-OnBlockAdded Schedule Update");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, __instance.blockID, tickRate);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("UpdateTick")]
|
||||
public class UpdateTickPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
Log.Out("BlockPatches-UpdateTick START");
|
||||
if (_blockValue.Block.Properties.Contains("BedrollRebirth"))
|
||||
{
|
||||
Log.Out("BlockPatches-UpdateTick 1");
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
Log.Out("BlockPatches-UpdateTick 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
int minMax = 10;
|
||||
int minHeight = 2;
|
||||
|
||||
List<Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityNPCRebirth), BoundsUtils.BoundsForMinMax(_blockPos.x - minMax, _blockPos.y - minHeight, _blockPos.z - minMax, _blockPos.x + minMax, _blockPos.y + minHeight, _blockPos.z + minMax), new List<Entity>());
|
||||
|
||||
Log.Out("BlockPatches-UpdateTick entitiesInBounds: " + entitiesInBounds.Count);
|
||||
|
||||
if (entitiesInBounds.Count > 0)
|
||||
{
|
||||
for (int x = 0; x < entitiesInBounds.Count; x++)
|
||||
{
|
||||
EntityNPCRebirth entity = (EntityNPCRebirth)entitiesInBounds[x];
|
||||
if (entity != null)
|
||||
{
|
||||
Log.Out("BlockPatches-UpdateTick ADD BUFF TO entity: " + entity.EntityClass.entityClassName);
|
||||
entity.Buffs.AddBuff("buffBedrollAOEEffect");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ulong tickRate = 20UL;
|
||||
|
||||
if (_blockValue.Block.Properties.Contains("TickRate"))
|
||||
{
|
||||
tickRate = (ulong)StringParsers.ParseFloat(__instance.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20UL;
|
||||
|
||||
Log.Out("BlockPatches-UpdateTick tickRate: " + tickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Out("BlockPatches-UpdateTick Schedule Update");
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, __instance.blockID, tickRate);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("GetBlockByName")]
|
||||
public class GetBlockByNamePatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref Block __result, string _blockname, bool _caseInsensitive)
|
||||
{
|
||||
if (_blockname == "cntWoodBurningStove_PickedUp")
|
||||
{
|
||||
_blockname = "campfire";
|
||||
}
|
||||
|
||||
if (Block.nameToBlock == null)
|
||||
{
|
||||
__result = (Block)null;
|
||||
return false;
|
||||
}
|
||||
Block blockByName;
|
||||
if (_caseInsensitive)
|
||||
Block.nameToBlockCaseInsensitive.TryGetValue(_blockname, out blockByName);
|
||||
else
|
||||
Block.nameToBlock.TryGetValue(_blockname, out blockByName);
|
||||
|
||||
__result = blockByName;
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockDestroyedByExplosion")]
|
||||
public class OnBlockDestroyedByExplosionPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref Block.DestroyedResult __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _playerThatStartedExpl)
|
||||
{
|
||||
Log.Out("BlockPatches-OnBlockDestroyedByExplosion START");
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("IsMovementBlocked")]
|
||||
[HarmonyPatch(new[] { typeof(IBlockAccess), typeof(Vector3i), typeof(BlockValue), typeof(BlockFace) })]
|
||||
public class IsMovementBlockedPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result, IBlockAccess _world, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
Log.Out("IsMovementBlocked A");
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnEntityCollidedWithBlock")]
|
||||
public class OnEntityCollidedWithBlockPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Entity _entity)
|
||||
{
|
||||
Log.Out("BlockPatches-OnEntityCollidedWithBlock _entity: " + _entity.EntityClass.entityClassName);
|
||||
|
||||
if (_entity is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX entity = (EntityZombieSDX) _entity;
|
||||
if (entity != null)
|
||||
{
|
||||
Log.Out("BlockPatches-OnEntityCollidedWithBlock Jumping: " + entity.Jumping);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("CanPlaceBlockAt")]
|
||||
public class CanPlaceBlockAtPatch
|
||||
{
|
||||
public static MethodInfo overlapsWithOtherBlock = AccessTools.Method(typeof(Block), "overlapsWithOtherBlock", new Type[] { typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue) });
|
||||
|
||||
public static bool Prefix(Block __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
bool isWithinTraderArea = ((World)_world).GetTraderAreaAt(_blockPos) != null;
|
||||
|
||||
string blockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
bool cannotPlace = isWithinTraderArea && optionProtectTrader && !(blockName == "keystoneBlock");
|
||||
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 1, optionProtectTrader: " + optionProtectTrader);
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 1, isWithinTraderArea: " + isWithinTraderArea);
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 1, blockName: " + blockName);
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 1, cannotPlace: " + cannotPlace);
|
||||
|
||||
if (_blockPos.y > 253)
|
||||
{
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 2");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isAllowedBlock = RebirthUtilities.IsBlockTraderAllowed(blockName);
|
||||
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt 1, isAllowedBlock: " + isAllowedBlock);
|
||||
|
||||
if (!GameManager.Instance.IsEditMode() && cannotPlace)
|
||||
{
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt CANNOT PLACE");
|
||||
|
||||
if (isAllowedBlock)
|
||||
{
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt IS ALLOWED");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPatches-CanPlaceBlockAt IS NOT ALLOWED");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Block block = _blockValue.Block;
|
||||
__result = (!block.isMultiBlock || _blockPos.y + block.multiBlockPos.dim.y < 254) && (GameManager.Instance.IsEditMode() || !block.bRestrictSubmergedPlacement || !__instance.IsUnderwater(_world, _blockPos, _blockValue)) && (GameManager.Instance.IsEditMode() || _bOmitCollideCheck || !(bool)overlapsWithOtherBlock.Invoke(__instance, new object[] { _world, _clrIdx, _blockPos, _blockValue }));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("GetMapColor")]
|
||||
public class GetMapColorPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref Color __result, BlockValue _blockValue, Vector3 _normal, int _yPos)
|
||||
{
|
||||
if (!GameManager.Instance.World.IsEditor() && !GameUtils.IsPlaytesting() && __instance.Properties.Values.ContainsKey("IgnoreMapColor"))
|
||||
{
|
||||
//Log.Out("BlockPatches-GetMapColor Block Name: " + __instance.GetBlockName());
|
||||
|
||||
string biomeName = RebirthUtilities.GetBiomeName(_normal);
|
||||
|
||||
//Log.Out("BlockPatches-GetMapColor Player Position: " + entityPlayerLocal.position);
|
||||
//Log.Out("BlockPatches-GetMapColor _normalX: " + _normal.x);
|
||||
//Log.Out("BlockPatches-GetMapColor _yPos: " + _yPos);
|
||||
//Log.Out("BlockPatches-GetMapColor _normalZ: " + _normal.z);
|
||||
//Log.Out("BlockPatches-GetMapColor _blockValue.parent: " + _blockValue.parent);
|
||||
|
||||
string mapColor = "";
|
||||
|
||||
//Log.Out("BlockPatches-GetMapColor biomeName: " + biomeName);
|
||||
|
||||
if (biomeName == "wasteland")
|
||||
{
|
||||
BlockValue ground = Block.GetBlockValue("terrDestroyedStone");
|
||||
if (ground.Block.Properties.Values.ContainsKey("Map.Color"))
|
||||
{
|
||||
mapColor = ground.Block.Properties.Values["Map.Color"];
|
||||
}
|
||||
}
|
||||
else if (biomeName == "desert")
|
||||
{
|
||||
BlockValue ground = Block.GetBlockValue("terrDesertGround");
|
||||
if (ground.Block.Properties.Values.ContainsKey("Map.Color"))
|
||||
{
|
||||
mapColor = ground.Block.Properties.Values["Map.Color"];
|
||||
}
|
||||
}
|
||||
else if (biomeName == "forest" || biomeName == "pine_forest")
|
||||
{
|
||||
BlockValue ground = Block.GetBlockValue("terrForestGround");
|
||||
if (ground.Block.Properties.Values.ContainsKey("Map.Color"))
|
||||
{
|
||||
mapColor = ground.Block.Properties.Values["Map.Color"];
|
||||
}
|
||||
}
|
||||
else if (biomeName == "burnt_forest")
|
||||
{
|
||||
BlockValue ground = Block.GetBlockValue("terrBurntForestGround");
|
||||
if (ground.Block.Properties.Values.ContainsKey("Map.Color"))
|
||||
{
|
||||
mapColor = ground.Block.Properties.Values["Map.Color"];
|
||||
}
|
||||
}
|
||||
else if (biomeName == "snow")
|
||||
{
|
||||
BlockValue ground = Block.GetBlockValue("terrSnow");
|
||||
if (ground.Block.Properties.Values.ContainsKey("Map.Color"))
|
||||
{
|
||||
mapColor = ground.Block.Properties.Values["Map.Color"];
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-GetMapColor mapColor: " + mapColor);
|
||||
|
||||
if (mapColor.Trim().Length > 0)
|
||||
{
|
||||
__result = StringParsers.ParseColor32(mapColor);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("DamageBlock")]
|
||||
public class DamageBlockPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref int __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _damagePoints, int _entityIdThatDamaged, ItemActionAttack.AttackHitInfo _attackHitInfo, bool _bUseHarvestTool, bool _bBypassMaxDamage)
|
||||
{
|
||||
PlatformUserIdentifierAbs getContainerOwner = null;
|
||||
bool isOwner = false;
|
||||
|
||||
if (__instance.GetBlockName().Contains("farmPlotBlock"))
|
||||
{
|
||||
EntityPlayer player = _world.GetEntity(_entityIdThatDamaged) as EntityPlayer;
|
||||
if (player != null)
|
||||
{
|
||||
if (player.inventory.holdingItem.GetItemName() == "meleeHandPlayer")
|
||||
{
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
bool isWithinTraderArea = ((World)_world).GetTraderAreaAt(_blockPos) != null;
|
||||
|
||||
if (!optionProtectTrader && isWithinTraderArea)
|
||||
{
|
||||
if (__instance is BlockWorkstation)
|
||||
{
|
||||
TileEntityWorkstation tileEntityWorkstation = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityWorkstation;
|
||||
|
||||
if (tileEntityWorkstation != null && tileEntityWorkstation.isPlayerPlaced)
|
||||
{
|
||||
return true;
|
||||
//Log.Out("BlockPatches-DamageBlock tileEntityWorkstation.entityId: " + tileEntityWorkstation.entityId);
|
||||
}
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance is BlockSecureLootSigned)
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 1");
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerSigned;
|
||||
getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
||||
isOwner = tileEntitySecureLootContainer.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
}
|
||||
if (__instance is BlockSecureLoot)
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 2");
|
||||
|
||||
TileEntitySecureLootContainer tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainer;
|
||||
getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
||||
isOwner = tileEntitySecureLootContainer.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
}
|
||||
|
||||
if (getContainerOwner == null)
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 3");
|
||||
__result = __instance.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 4");
|
||||
if (!isOwner)
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 5");
|
||||
global::EntityAlive entityAlive = _world.GetEntity(_entityIdThatDamaged) as global::EntityAlive;
|
||||
if (entityAlive != null)
|
||||
{
|
||||
string entityClassName = entityAlive.EntityClass.entityClassName;
|
||||
//Log.Out("DamageBlock:entityClassName: " + entityClassName);
|
||||
if (entityClassName == "playerMale" || entityClassName == "playerFemale")
|
||||
{
|
||||
int @playerKillingMode = GameStats.GetInt(EnumGameStats.PlayerKillingMode);
|
||||
//Log.Out("DamageBlock:EnumPlayerKillingMode-@playerKillingMode: " + @playerKillingMode);
|
||||
if (@playerKillingMode == 0)
|
||||
{
|
||||
//Log.Out("DamageBlock:EnumPlayerKillingMode: No Killing");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DamageBlock:EnumPlayerKillingMode: Killing Allowed");
|
||||
__result = __instance.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 5");
|
||||
__result = __instance.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 6");
|
||||
__result = __instance.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPatches-DamageBlock 7");
|
||||
__result = __instance.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockDamaged")]
|
||||
public class OnBlockDamagedPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref int __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _damagePoints, int _entityIdThatDamaged, bool _bUseHarvestTool, bool _bBypassMaxDamage, int _recDepth,
|
||||
int ___Stage2Health
|
||||
)
|
||||
{
|
||||
if (__instance.GetBlockName() == "radioHam")
|
||||
{
|
||||
bool isWithinTraderArea = ((World)_world).GetTraderAreaAt(_blockPos) != null;
|
||||
|
||||
if (isWithinTraderArea)
|
||||
{
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.GetBlockName().Contains("farmPlotBlock"))
|
||||
{
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster == null)
|
||||
{
|
||||
__result = 0;
|
||||
}
|
||||
if (__instance.isMultiBlock && _blockValue.ischild)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block2 = _blockValue.Block;
|
||||
int damage = _blockValue.damage;
|
||||
bool flag = damage >= block2.MaxDamage;
|
||||
int num = damage + _damagePoints;
|
||||
|
||||
//Log.Out("BlockPatches-OnBlockDamaged damage: " + damage);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged num: " + num);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged _damagePoints: " + _damagePoints);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged block2.MaxDamage: " + block2.MaxDamage);
|
||||
|
||||
if (num > block2.MaxDamage)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged B");
|
||||
EntityPlayer player = _world.GetEntity(_entityIdThatDamaged) as EntityPlayer;
|
||||
|
||||
if (player)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged C");
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("farmPlotBlockVariantHelper"), player, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 1");
|
||||
if (!GameManager.IsDedicatedServer)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 2");
|
||||
|
||||
//Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
Entity entity = _world.GetEntity(_entityIdThatDamaged);
|
||||
if (entity is EntityPlayerLocal)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 3");
|
||||
EntityPlayerLocal playerLocal = (EntityPlayerLocal)entity;
|
||||
if (playerLocal.inventory.holdingItem.GetItemName() == "meleeHandPlayer")
|
||||
{
|
||||
Log.Out("BlockPatches-OnBlockDamaged block: " + __instance.GetBlockName() + " / position: " + _blockPos);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged _blockPos: " + _blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("BlockPatches-OnBlockDamaged SurfaceCategory: " + __instance.blockMaterial.SurfaceCategory);
|
||||
}
|
||||
|
||||
bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
|
||||
//Log.Out("BlockPatches-OnBlockDamaged isDedicated: " + isDedicated);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged isClient: " + isClient);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged isSinglePlayer: " + isSinglePlayer);
|
||||
//Log.Out("BlockPatches-OnBlockDamaged GetBlockName: " + __instance.GetBlockName());
|
||||
|
||||
/*if (__instance.GetBlockName() == "cntGasPumpFull" && (isDedicated || (isClient && !isSinglePlayer)))
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 1");
|
||||
|
||||
Entity entity = _world.GetEntity(_entityIdThatDamaged);
|
||||
if (entity is EntityPlayerLocal)
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 2");
|
||||
|
||||
EntityPlayerLocal playerLocal = (EntityPlayerLocal)entity;
|
||||
if (playerLocal.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("salvagingSkill")))
|
||||
{
|
||||
//Log.Out("BlockPatches-OnBlockDamaged 3");
|
||||
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(Block __instance, ref BlockActivationCommand[] ___cmds)
|
||||
{
|
||||
bool isEditor = GameModeEditWorld.TypeName.Equals(GamePrefs.GetString(EnumGamePrefs.GameMode));
|
||||
|
||||
if (isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Resize<BlockActivationCommand>(ref ___cmds, 1);
|
||||
//___cmds[0] = new BlockActivationCommand("cancel", "x", false, false);
|
||||
___cmds[0] = new BlockActivationCommand("take", "hand", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
bool ___CanPickup
|
||||
)
|
||||
{
|
||||
__result = false;
|
||||
|
||||
bool preventPickup = false;
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("PreventPickUp"))
|
||||
{
|
||||
StringParsers.TryParseBool(__instance.Properties.Values["PreventPickUp"], out preventPickup);
|
||||
}
|
||||
|
||||
if (preventPickup)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//bool flag = _world.GetTileEntity(_clrIdx, _blockPos) is TileEntityLootContainer;
|
||||
bool flag2 = ___CanPickup;
|
||||
bool flag3 = __instance.Properties.Contains("TakeDelay");
|
||||
|
||||
if (EffectManager.GetValue(PassiveEffects.BlockPickup, null, 0f, _entityFocusing, null, _blockValue.Block.Tags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
__result = flag2 || flag3;
|
||||
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
bool cantLoot = !optionProtectTrader && ((World)_world).IsWithinTraderArea(_blockPos);
|
||||
|
||||
string blockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (RebirthUtilities.IsBlockTraderAllowed(blockName))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cantLoot)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-HasBlockActivationCommands ___CanPickup: " + flag2);
|
||||
//Log.Out("BlockPatches-HasBlockActivationCommands TakeDelay: " + flag3);
|
||||
//Log.Out("BlockPatches-HasBlockActivationCommands __result: " + __result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("GetActivationText")]
|
||||
public class GetActivationTextPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
bool ___CanPickup
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockPatches-GetActivationText START");
|
||||
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Block block = _blockValue.Block;
|
||||
|
||||
if (!___CanPickup && EffectManager.GetValue(PassiveEffects.BlockPickup, null, 0f, _entityFocusing, null, _blockValue.Block.Tags, true, true, true, true, true, 1, false) <= 0f)
|
||||
{
|
||||
//Log.Out("BlockPatches-GetActivationText 1");
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
if (!_world.CanPickupBlockAt(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer()))
|
||||
{
|
||||
//Log.Out("BlockPatches-GetActivationText 2");
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
string key = block.GetBlockName();
|
||||
if (!string.IsNullOrEmpty(block.PickedUpItemValue))
|
||||
{
|
||||
//Log.Out("BlockPatches-GetActivationText 3");
|
||||
key = block.PickedUpItemValue;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(block.PickupTarget))
|
||||
{
|
||||
//Log.Out("BlockPatches-GetActivationText 4");
|
||||
key = block.PickupTarget;
|
||||
}
|
||||
__result = string.Format(Localization.Get("pickupPrompt"), Localization.Get(key));
|
||||
|
||||
//Log.Out("BlockPatches-GetActivationText 5");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
BlockActivationCommand[] ___cmds,
|
||||
bool ___CanPickup
|
||||
)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
___cmds[0].enabled = false;
|
||||
//___cmds[1].enabled = false;
|
||||
bool flag3 = ___CanPickup;
|
||||
if (EffectManager.GetValue(PassiveEffects.BlockPickup, null, 0f, _entityFocusing, null, _blockValue.Block.Tags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands 1");
|
||||
flag3 = true;
|
||||
}
|
||||
if (flag3)
|
||||
{
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands 2");
|
||||
//___cmds[0].enabled = false;
|
||||
___cmds[0].enabled = true;
|
||||
}
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands 3");
|
||||
___cmds[0].enabled = true;
|
||||
//___cmds[1].enabled = true;
|
||||
}
|
||||
__result = ___cmds;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static void Postfix(Block __instance, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
string blockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
bool isAllowed = false;
|
||||
|
||||
if (RebirthUtilities.IsBlockTraderAllowed(blockName))
|
||||
{
|
||||
isAllowed = true;
|
||||
}
|
||||
|
||||
if (!isAllowed && optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
|
||||
bool preventTimer = false;
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("PreventTimer"))
|
||||
{
|
||||
StringParsers.TryParseBool(__instance.Properties.Values["PreventTimer"], out preventTimer);
|
||||
}
|
||||
|
||||
if (_commandName == "take" && __instance.Properties.Contains("TakeDelay") && !preventTimer)
|
||||
{
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands takeDelay: " + takeDelay);
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands replacementBlockName: " + replacementBlockName);
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands numBlocks: " + numBlocks);
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands isReplacementItem: " + isReplacementItem);
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Harmony.BlockCompositeTileEntityPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockCompositeTileEntity))]
|
||||
[HarmonyPatch("GetActivationText")]
|
||||
public class GetActivationTextPatch
|
||||
{
|
||||
public static bool Prefix(BlockCompositeTileEntity __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (__instance.GetParentPos(_world, _clrIdx, ref _blockPos, ref _blockValue))
|
||||
__result = _blockValue.Block.GetActivationText(_world, _blockValue, _clrIdx, _blockPos, _entityFocusing);
|
||||
|
||||
TileEntityComposite tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityComposite;
|
||||
|
||||
if (tileEntity == null)
|
||||
__result = "";
|
||||
if (__instance.commands == null)
|
||||
__instance.commands = tileEntity.InitBlockActivationCommands();
|
||||
if (__instance.commands.Length == 0)
|
||||
__result = (string)null;
|
||||
PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput;
|
||||
string _activateHotkeyMarkup = playerInput.Activate.GetBindingXuiMarkupString() + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
string localizedBlockName = _blockValue.Block.GetLocalizedBlockName();
|
||||
|
||||
string ownerText = "";
|
||||
|
||||
if (tileEntity.TryGetSelfOrFeature(out ILockable lockable))
|
||||
{
|
||||
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(lockable.GetOwner());
|
||||
ownerText = "\n" + Localization.Get("ttowner") + ": [94bd91]" + playerData.PlayerName.DisplayName + "[-]";
|
||||
}
|
||||
|
||||
__result = tileEntity.GetActivationText(_world, _blockPos, _blockValue, _entityFocusing, _activateHotkeyMarkup, localizedBlockName) + ownerText;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Harmony.BlockDamagePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockDamage))]
|
||||
[HarmonyPatch("OnEntityCollidedWithBlock")]
|
||||
public class OnEntityCollidedWithBlockPatch
|
||||
{
|
||||
public static bool Prefix(BlockDamage __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Entity _targetEntity)
|
||||
{
|
||||
if (_targetEntity is EntityNPCRebirth)
|
||||
{
|
||||
if (_targetEntity.EntityClass.Properties.Values.ContainsKey("PreventTrapDamage"))
|
||||
{
|
||||
string preventTrapDamage = _targetEntity.EntityClass.Properties.Values["PreventTrapDamage"];
|
||||
|
||||
if (preventTrapDamage == "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.BlockDoorSecurePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockDoorSecure))]
|
||||
[HarmonyPatch("GetActivationText")]
|
||||
public class GetActivationTextPatch
|
||||
{
|
||||
public static bool Prefix(BlockDoorSecure __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
__result = __instance.GetActivationText(_world, block, _clrIdx, parentPos, _entityFocusing);
|
||||
return false;
|
||||
}
|
||||
TileEntitySecureDoor tileEntitySecureDoor = (TileEntitySecureDoor)_world.GetTileEntity(_clrIdx, _blockPos);
|
||||
if (tileEntitySecureDoor == null && !_world.IsEditor())
|
||||
{
|
||||
__result = "";
|
||||
return false;
|
||||
}
|
||||
bool flag = (!_world.IsEditor()) ? tileEntitySecureDoor.IsLocked() : ((_blockValue.meta & 4) > 0);
|
||||
PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput;
|
||||
string arg = playerInput.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain, null) + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain, null);
|
||||
string arg2 = Localization.Get("door");
|
||||
|
||||
bool hasOwner = (tileEntitySecureDoor.GetOwner() != null);
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
__result = string.Format(Localization.Get("tooltipUnlocked"), arg, arg2);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isOpen = BlockDoor.IsDoorOpen(_blockValue.meta);
|
||||
|
||||
if (isOpen && !hasOwner)
|
||||
{
|
||||
__result = string.Format(Localization.Get("tooltipUnlocked"), arg, arg2);
|
||||
return false;
|
||||
}
|
||||
|
||||
__result = string.Format(Localization.Get("tooltipLocked"), arg, arg2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockDoorSecure))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static bool Prefix(BlockDoorSecure __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, global::EntityAlive _player,
|
||||
string ___lockedSound,
|
||||
string ___lockingSound,
|
||||
string ___unlockingSound
|
||||
)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated START");
|
||||
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 1");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
__result = __instance.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, (EntityPlayerLocal)_player);
|
||||
return false;
|
||||
}
|
||||
TileEntitySecureDoor tileEntitySecureDoor = (TileEntitySecureDoor)_world.GetTileEntity(_cIdx, _blockPos);
|
||||
if (tileEntitySecureDoor == null && !_world.IsEditor())
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 2");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasOwner = (tileEntitySecureDoor.GetOwner() != null);
|
||||
|
||||
bool flag = (!_world.IsEditor()) ? tileEntitySecureDoor.IsLocked() : ((_blockValue.meta & 4) > 0);
|
||||
bool flag2 = !_world.IsEditor() && tileEntitySecureDoor.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier);
|
||||
if (!(_commandName == "close"))
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 3");
|
||||
if (!(_commandName == "open"))
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 4");
|
||||
if (_commandName == "lock")
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 5");
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 6");
|
||||
_blockValue.meta |= 4;
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, _blockValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 7");
|
||||
tileEntitySecureDoor.SetLocked(true);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, ___lockingSound);
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, "doorLocked");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (_commandName == "unlock")
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 8");
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 9");
|
||||
_blockValue.meta = (byte)((int)_blockValue.meta & -5);
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, _blockValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 10");
|
||||
tileEntitySecureDoor.SetLocked(false);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, ___unlockingSound);
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, "doorUnlocked");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (!(_commandName == "keypad"))
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 11");
|
||||
if (_commandName == "trigger")
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 12");
|
||||
XUiC_TriggerProperties.Show(((EntityPlayerLocal)_player).PlayerUI.xui, _cIdx, _blockPos, true, true);
|
||||
}
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);
|
||||
if (uiforPlayer != null && tileEntitySecureDoor != null)
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 13");
|
||||
XUiC_KeypadWindow.Open(uiforPlayer, tileEntitySecureDoor);
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 14");
|
||||
if (_world.IsEditor() || !flag || flag2)
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 15");
|
||||
__instance.HandleTrigger((EntityPlayer)_player, (World)_world, _cIdx, _blockPos, _blockValue);
|
||||
__result = __instance.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, (EntityPlayerLocal)_player);
|
||||
return false;
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, ___lockedSound);
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 16");
|
||||
if (_world.IsEditor() || !flag || flag2 || !hasOwner)
|
||||
{
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated 17");
|
||||
__instance.HandleTrigger((EntityPlayer)_player, (World)_world, _cIdx, _blockPos, _blockValue);
|
||||
__result = __instance.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, (EntityPlayerLocal)_player);
|
||||
if (!hasOwner)
|
||||
{
|
||||
tileEntitySecureDoor.SetLocked(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, ___lockedSound);
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDoorSecurePatches-OnBlockActivated END");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.BlockLightPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockLight))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(BlockLight __instance)
|
||||
{
|
||||
bool isEditor = GameModeEditWorld.TypeName.Equals(GamePrefs.GetString(EnumGamePrefs.GameMode));
|
||||
|
||||
if (isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Resize<BlockActivationCommand>(ref __instance.cmds, 4);
|
||||
__instance.cmds[0] = new BlockActivationCommand("light", "electric_switch", true, false);
|
||||
__instance.cmds[1] = new BlockActivationCommand("edit", "tool", true, false);
|
||||
__instance.cmds[2] = new BlockActivationCommand("trigger", "wrench", true, false);
|
||||
__instance.cmds[3] = new BlockActivationCommand("take", "hand", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLight))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockLight __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing
|
||||
)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//__instance.cmds[0].enabled = true;
|
||||
__instance.cmds[3].enabled = true;
|
||||
__instance.cmds[4].enabled = true;
|
||||
__result = __instance.cmds;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLight))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(BlockLight __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing,
|
||||
bool ___CanPickup
|
||||
)
|
||||
{
|
||||
__result = true;
|
||||
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
bool cantLoot = !optionProtectTrader && ((World)_world).IsWithinTraderArea(_blockPos);
|
||||
|
||||
if (cantLoot)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLight))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static void Postfix(BlockLight __instance, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
if (optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
if (_commandName == "take")
|
||||
{
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.BlockLootPatches
|
||||
{
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(BlockLoot))]
|
||||
[HarmonyPatch("PlaceBlock")]
|
||||
public class PlaceBlockPatch
|
||||
{
|
||||
public static void Postfix(BlockLoot __instance, WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
TileEntityLootContainer tileEntityLootContainer = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntityLootContainer;
|
||||
if (tileEntityLootContainer != null)
|
||||
{
|
||||
tileEntityLootContainer.bPlayerStorage = true;
|
||||
tileEntityLootContainer.SetModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLoot))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(BlockLoot __instance, ref BlockActivationCommand[] ___cmds)
|
||||
{
|
||||
Array.Resize<BlockActivationCommand>(ref ___cmds, 2);
|
||||
___cmds[0] = new BlockActivationCommand("Search", "search", false, false);
|
||||
___cmds[1] = new BlockActivationCommand("take", "hand", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLoot))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockLoot __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLoot))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockLoot __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
BlockActivationCommand[] ___cmds
|
||||
)
|
||||
{
|
||||
TileEntityLootContainer tileEntityLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityLootContainer;
|
||||
bool flag = tileEntityLootContainer == null;
|
||||
BlockActivationCommand[] result;
|
||||
if (flag)
|
||||
{
|
||||
result = new BlockActivationCommand[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isEmpty = tileEntityLootContainer.IsEmpty();
|
||||
bool bTouched = tileEntityLootContainer.bTouched;
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands isEmpty: " + isEmpty);
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands bTouched: " + bTouched);
|
||||
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands _blockValue.Block.GetBlockName(): " + _blockValue.Block.GetBlockName());
|
||||
|
||||
___cmds[0].enabled = true;
|
||||
___cmds[1].enabled = isEmpty && bTouched && !_blockValue.Block.GetBlockName().ToLower().Contains("repairable") && !(_blockValue.Block.GetBlockName().ToLower() == "cntfetchquestsatchel");
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands HAS TAKE DELAY");
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands END");
|
||||
__result = ___cmds;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockLoot))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static bool Prefix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_commandName == "Search" && !RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _cIdx))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, global::EntityAlive _player)
|
||||
{
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-OnBlockActivated _commandName: " + _commandName);
|
||||
|
||||
if (_commandName == "take" && !_blockValue.Block.GetBlockName().ToLower().Contains("repairable"))
|
||||
{
|
||||
/*Log.Out("BlockPatches-OnBlockActivated takeDelay: " + takeDelay);
|
||||
Log.Out("BlockPatches-OnBlockActivated replacementBlockName: " + replacementBlockName);
|
||||
Log.Out("BlockPatches-OnBlockActivated numBlocks: " + numBlocks);
|
||||
Log.Out("BlockPatches-OnBlockActivated isReplacementItem: " + isReplacementItem);*/
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
if (optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Harmony.BlockMinePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockMine))]
|
||||
[HarmonyPatch("OnEntityWalking")]
|
||||
public class OnEntityWalkingPatch
|
||||
{
|
||||
public static bool Prefix(BlockMine __instance, WorldBase _world, int _x, int _y, int _z, BlockValue _blockValue, Entity entity)
|
||||
{
|
||||
if (entity is EntityNPCRebirth)
|
||||
{
|
||||
if (entity.EntityClass.Properties.Values.ContainsKey("PreventTrapDamage"))
|
||||
{
|
||||
string preventTrapDamage = entity.EntityClass.Properties.Values["PreventTrapDamage"];
|
||||
|
||||
if (preventTrapDamage == "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.BlockPoweredLightPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockPoweredLight))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(BlockPoweredLight __instance, ref BlockActivationCommand[] ___cmds)
|
||||
{
|
||||
bool isEditor = GameModeEditWorld.TypeName.Equals(GamePrefs.GetString(EnumGamePrefs.GameMode));
|
||||
|
||||
if (isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Resize<BlockActivationCommand>(ref ___cmds, 2);
|
||||
___cmds[0] = new BlockActivationCommand("light", "electric_switch", true, false);
|
||||
___cmds[1] = new BlockActivationCommand("take", "hand", true, false);
|
||||
//___cmds[2] = new BlockActivationCommand("edit", "tool", true, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockPoweredLight))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(BlockPoweredLight __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing,
|
||||
bool ___CanPickup
|
||||
)
|
||||
{
|
||||
__result = true;
|
||||
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
bool cantLoot = !optionProtectTrader && ((World)_world).IsWithinTraderArea(_blockPos);
|
||||
|
||||
if (cantLoot)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockPoweredLight))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockPoweredLight __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
BlockActivationCommand[] ___cmds
|
||||
)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//___cmds[0].enabled = true;
|
||||
___cmds[1].enabled = true;
|
||||
//___cmds[2].enabled = true;
|
||||
__result = ___cmds;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockPoweredLight))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static void Postfix(BlockPoweredLight __instance, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
if (optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
if (_commandName == "take")
|
||||
{
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
}
|
||||
/*else if (_commandName == "edit")
|
||||
{
|
||||
TileEntityLight tileEntity = (TileEntityLight)_world.GetTileEntity(_cIdx, _blockPos);
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
XUiC_LightEditor.Open(_player.PlayerUI, tileEntity, _blockPos, _world as World, _cIdx, __instance);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.BlockSecureLootPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockSecureLoot))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(BlockSecureLoot __instance, ref BlockActivationCommand[] ___cmds)
|
||||
{
|
||||
Array.Resize<BlockActivationCommand>(ref ___cmds, 7);
|
||||
___cmds[0] = new BlockActivationCommand("Search", "search", false, false);
|
||||
___cmds[1] = new BlockActivationCommand("lock", "lock", false, false);
|
||||
___cmds[2] = new BlockActivationCommand("unlock", "unlock", false, false);
|
||||
___cmds[3] = new BlockActivationCommand("keypad", "keypad", false, false);
|
||||
___cmds[4] = new BlockActivationCommand("pick", "unlock", false, false);
|
||||
___cmds[5] = new BlockActivationCommand("trigger", "wrench", true, false);
|
||||
___cmds[6] = new BlockActivationCommand("take", "hand", false, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockSecureLoot))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockSecureLoot __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockSecureLoot))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockSecureLoot __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
BlockActivationCommand[] ___cmds,
|
||||
string ___lockPickItem
|
||||
)
|
||||
{
|
||||
TileEntitySecureLootContainer tileEntityLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainer;
|
||||
BlockActivationCommand[] result;
|
||||
if (tileEntityLootContainer == null)
|
||||
{
|
||||
result = new BlockActivationCommand[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformUserIdentifierAbs internalLocalUserIdentifier = PlatformManager.InternalLocalUserIdentifier;
|
||||
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntityLootContainer.GetOwner());
|
||||
bool flag = tileEntityLootContainer.LocalPlayerIsOwner();
|
||||
bool flag2 = !flag && (playerData != null && playerData.ACL != null) && playerData.ACL.Contains(internalLocalUserIdentifier);
|
||||
___cmds[0].enabled = true;
|
||||
___cmds[1].enabled = (!tileEntityLootContainer.IsLocked() && (flag || flag2));
|
||||
___cmds[2].enabled = (tileEntityLootContainer.IsLocked() && flag);
|
||||
___cmds[3].enabled = ((!tileEntityLootContainer.IsUserAllowed(internalLocalUserIdentifier) && tileEntityLootContainer.HasPassword() && tileEntityLootContainer.IsLocked()) || flag);
|
||||
___cmds[4].enabled = (___lockPickItem != null && tileEntityLootContainer.IsLocked() && !flag);
|
||||
___cmds[5].enabled = (_world.IsEditor() && !GameUtils.IsWorldEditor());
|
||||
___cmds[6].enabled = tileEntityLootContainer.IsEmpty() && tileEntityLootContainer.bTouched;
|
||||
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands HAS TAKE DELAY");
|
||||
}
|
||||
|
||||
__result = ___cmds;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockSecureLoot))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static bool Prefix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if ((_commandName == "Search" || _commandName == "pick") && !RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _cIdx))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(BlockSecureLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
if (optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-OnBlockActivated _commandName: " + _commandName);
|
||||
|
||||
if (_commandName == "take")
|
||||
{
|
||||
/*Log.Out("BlockPatches-OnBlockActivated takeDelay: " + takeDelay);
|
||||
Log.Out("BlockPatches-OnBlockActivated replacementBlockName: " + replacementBlockName);
|
||||
Log.Out("BlockPatches-OnBlockActivated numBlocks: " + numBlocks);
|
||||
Log.Out("BlockPatches-OnBlockActivated isReplacementItem: " + isReplacementItem);*/
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Harmony.BlockSiblingRemovePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockSiblingRemove))]
|
||||
[HarmonyPatch("OnBlockRemoved")]
|
||||
public class OnBlockRemovedPatch
|
||||
{
|
||||
public static void Postfix(BlockSiblingRemove __instance, WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
if (RebirthVariables.chunkObserver != null)
|
||||
{
|
||||
GameManager.Instance.RemoveChunkObserver(RebirthVariables.chunkObserver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using static SleeperVolume;
|
||||
|
||||
namespace Harmony.BlockSleepingBagPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockSleepingBag))]
|
||||
[HarmonyPatch("PlaceBlock")]
|
||||
public class PlaceBlockPatch
|
||||
{
|
||||
public static void Postfix(BlockSleepingBag __instance, WorldBase _world, BlockPlacement.Result _bpResult, EntityAlive _ea)
|
||||
{
|
||||
Vector3i position = _bpResult.blockPos + __instance.rotationToAddVector((int)_bpResult.blockValue.rotation);
|
||||
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageAddChunkObserver>().Setup(position), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChunkManager.ChunkObserver observerRef = GameManager.Instance.AddChunkObserver(position, false, 3, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
|
||||
namespace Harmony.BlockSpawnEntityPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockSpawnEntity), "UpdateTick")]
|
||||
public class UpdateTickPatch
|
||||
{
|
||||
const float _maxDist = 2f;
|
||||
|
||||
public static bool Prefix(BlockSpawnEntity __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
//Log.Out($"BlockSpawnEntity::UpdateTick Prefix _blockValue: {_blockValue.Block.GetBlockName()}, pos: {_blockPos}, spawnClasses len: {__instance.spawnClasses.Length}");
|
||||
|
||||
__result = false;
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return false;
|
||||
|
||||
if (__instance.spawnClasses.Length == 0)
|
||||
{
|
||||
Log.Error($"Harmony-BlockSpawnEntity:Block definition '{_blockValue.Block.GetBlockName()}' missing property SpawnClass values in entityclasses.xml");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GameManager.Instance.IsEditMode())
|
||||
{
|
||||
string className = __instance.spawnClasses[_blockValue.meta % __instance.spawnClasses.Length];
|
||||
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick className: " + className);
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick Contains: " + className.ToLower().Contains("tradermercenary_poi"));
|
||||
|
||||
bool flag1 = _blockValue.Block.blockName == "spawnTraderRebirth" && (className.ToLower() != "briston_poi_fr" && !className.ToLower().Contains("tradermercenary_poi"));
|
||||
bool flag2 = _blockValue.Block.blockName == "spawnCustomTraderRebirth" && !className.ToLower().Contains("poppy_poi_");
|
||||
bool flag3 = _blockValue.Block.blockName == "spawnCustomTraderRebirth" && className.ToLower().Contains("poppy_poi_");
|
||||
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick flag1: " + flag1);
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick flag2: " + flag2);
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick flag3: " + flag3);
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && (flag1 || flag2) ||
|
||||
!RebirthUtilities.ScenarioSkip() && (flag3)
|
||||
)
|
||||
{
|
||||
//Log.Warning($"BlockSpawnEntityPatches-UpdateTick SKIP");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(0, _blockPos, __instance.blockID, 320uL);
|
||||
return false;
|
||||
}
|
||||
|
||||
var entities = GameManager.Instance.World.GetEntitiesInBounds(null, new Bounds(_blockPos.ToVector3(), Vector3.one * 25f));
|
||||
int eClassID = EntityClass.FromString(className);
|
||||
var matchedIDs = entities.FindAll(e => e.entityClass == eClassID);
|
||||
|
||||
if (matchedIDs.Count == 0)
|
||||
{
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster == null || (Chunk)chunkCluster.GetChunkFromWorldPos(_blockPos) == null) return false;
|
||||
|
||||
Vector3 transformPos = _blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f);
|
||||
Vector3 rotation = new Vector3(0f, 90 * (_blockValue.rotation & 3), 0f);
|
||||
Entity entity = EntityFactory.CreateEntity(eClassID, transformPos, rotation);
|
||||
entity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
|
||||
GameManager.Instance.World.SpawnEntityInWorld(entity);
|
||||
|
||||
//Log.Warning($"Harmony-BlockSpawnEntity:Spawn New Trader entity: {entity}");
|
||||
}
|
||||
else if (matchedIDs.Count == 1)
|
||||
{
|
||||
var trader = matchedIDs[0];
|
||||
if (Vector3.Distance(_blockPos.ToVector3(), trader.position) > _maxDist)
|
||||
{
|
||||
//Log.Warning($"Harmony-BlockSpawnEntity:Repositioning Trader {_blockValue.Block.GetBlockName()}");
|
||||
trader.SetPosition(_blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f));
|
||||
trader.SetRotation(new Vector3(0f, 90 * (_blockValue.rotation & 3), 0f));
|
||||
}
|
||||
}
|
||||
else if (matchedIDs.Count >= 2)
|
||||
{
|
||||
//Log.Warning($"Harmony-BlockSpawnEntity:Found extra traders: {className} {matchedIDs.Count}");
|
||||
for (int i = matchedIDs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var trader = matchedIDs[i];
|
||||
var dist = Vector3.Distance(_blockPos.ToVector3(), trader.position);
|
||||
//Log.Warning($" Trader: {trader}, pos: {trader.position}, distance: {dist}");
|
||||
|
||||
if (dist > _maxDist)
|
||||
{
|
||||
//Log.Warning($"Harmony-BlockSpawnEntity:Unloading extra EntityTrader: {trader}, distance from post: {dist}");
|
||||
trader.MarkToUnload();
|
||||
matchedIDs.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedIDs.Count > 1)
|
||||
{
|
||||
//Log.Error($"Harmony-BlockSpawnEntity:Found an extra trader within the max distance."); // hope it doesn't happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(0, _blockPos, __instance.blockID, 320uL);
|
||||
|
||||
// the base Block class simply returns false
|
||||
return false; // base.UpdateTick(_world, _clrIdx, _blockPos, _blockValue, _bRandomTick, _ticksIfLoaded, _rnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Harmony.BlockSpeakerTraderPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockSpeakerTrader))]
|
||||
[HarmonyPatch("PlayOpen")]
|
||||
public class PlayOpenPatch
|
||||
{
|
||||
private static bool Prefix(Vector3i _blockPos)
|
||||
{
|
||||
//Log.Out("BlockSpeakerTraderPatches-PlayOpen START");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockSpeakerTrader))]
|
||||
[HarmonyPatch("PlayClose")]
|
||||
public class PlayClosePatch
|
||||
{
|
||||
private static bool Prefix(Vector3i _blockPos)
|
||||
{
|
||||
//Log.Out("BlockSpeakerTraderPatches-PlayClose START");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
namespace Harmony.BlockWorkstationPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("PlaceBlock")]
|
||||
public class PlaceBlockPatch
|
||||
{
|
||||
public static void Postfix(BlockWorkstation __instance, WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
TileEntityWorkstation tileEntity = (TileEntityWorkstation)_world.GetTileEntity(_result.blockPos);
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.entityId = _ea.entityId;
|
||||
tileEntity.setModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(BlockWorkstation __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag1 = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer());
|
||||
TileEntityWorkstation tileEntity = (TileEntityWorkstation)_world.GetTileEntity(_blockPos);
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
flag2 = tileEntity.IsPlayerPlaced;
|
||||
flag3 = tileEntity.entityId == _entityFocusing.entityId;
|
||||
}
|
||||
|
||||
__instance.cmds[1].enabled = ((flag1 & flag2) || flag3) && (double)__instance.TakeDelay > 0.0;
|
||||
__result = __instance.cmds;
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(Block))]
|
||||
[HarmonyPatch("OnBlockEntityTransformAfterActivated")]
|
||||
public class OnBlockEntityTransformAfterActivatedPatch
|
||||
{
|
||||
public static bool Prefix(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated START");
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated HAS ANIM");
|
||||
|
||||
if (_ebcd != null)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated GetBlockName(): " + _ebcd.blockValue.Block.GetBlockName());
|
||||
if (_ebcd.bHasTransform)
|
||||
{
|
||||
Animator[] componentsInChildren = _ebcd.transform.GetComponentsInChildren<Animator>();
|
||||
if (componentsInChildren != null)
|
||||
{
|
||||
for (int i = componentsInChildren.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Animator animator = componentsInChildren[i];
|
||||
animator.enabled = true;
|
||||
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN ON");
|
||||
animator.enabled = true;
|
||||
animator.SetBool("isOn", true);
|
||||
}
|
||||
else if (_blockValue.meta == 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN OFF");
|
||||
animator.SetBool("isOn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform transform2 = GameUtils.FindDeepChild(_ebcd.transform, "Audio");
|
||||
if (transform2 != null)
|
||||
{
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
transform2.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform2.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated NO TRANSFORM");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated NO BLOCK INFO, _blockValue: " + _blockValue.Block.GetBlockName());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockWorkstation))]
|
||||
[HarmonyPatch("checkParticles")]
|
||||
public class checkParticlesPatch
|
||||
{
|
||||
public static bool Prefix(BlockWorkstation __instance, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles START");
|
||||
|
||||
if (_blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles HAS ANIM");
|
||||
|
||||
BlockEntityData _ebcd = ((World)_world).ChunkClusters[_clrIdx].GetBlockEntity(_blockPos);
|
||||
|
||||
if (_ebcd != null)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles GetBlockName(): " + _ebcd.blockValue.Block.GetBlockName());
|
||||
if (_ebcd.bHasTransform)
|
||||
{
|
||||
Animator[] componentsInChildren = _ebcd.transform.GetComponentsInChildren<Animator>();
|
||||
if (componentsInChildren != null)
|
||||
{
|
||||
for (int i = componentsInChildren.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Animator animator = componentsInChildren[i];
|
||||
animator.enabled = true;
|
||||
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN ON");
|
||||
animator.enabled = true;
|
||||
animator.SetBool("isOn", true);
|
||||
}
|
||||
else if (_blockValue.meta == 0)
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-OnBlockEntityTransformAfterActivated TURN OFF");
|
||||
animator.SetBool("isOn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transform transform2 = GameUtils.FindDeepChild(_ebcd.transform, "Audio");
|
||||
if (transform2 != null)
|
||||
{
|
||||
if (_blockValue.meta != 0)
|
||||
{
|
||||
transform2.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform2.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles NO TRANSFORM");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockWorkstationPatches-checkParticles NO BLOCK INFO, _blockValue: " + _blockValue.Block.GetBlockName());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.BlockCarExplodeLootPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockCarExplodeLoot))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(BlockCarExplodeLoot __instance, ref BlockActivationCommand[] ___cmds)
|
||||
{
|
||||
Array.Resize<BlockActivationCommand>(ref ___cmds, 2);
|
||||
___cmds[0] = new BlockActivationCommand("Search", "search", false, false);
|
||||
___cmds[1] = new BlockActivationCommand("take", "hand", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCarExplodeLoot))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockCarExplodeLoot __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCarExplodeLoot))]
|
||||
[HarmonyPatch("GetBlockActivationCommands")]
|
||||
public class GetBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockCarExplodeLoot __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
|
||||
BlockActivationCommand[] ___cmds
|
||||
)
|
||||
{
|
||||
TileEntityLootContainer tileEntityLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityLootContainer;
|
||||
bool flag = tileEntityLootContainer == null;
|
||||
BlockActivationCommand[] result;
|
||||
if (flag)
|
||||
{
|
||||
result = new BlockActivationCommand[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//___cmds[0].enabled = true;
|
||||
bool isEmpty = tileEntityLootContainer.IsEmpty();
|
||||
bool bTouched = tileEntityLootContainer.bTouched;
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands isEmpty: " + isEmpty);
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands bTouched: " + bTouched);
|
||||
|
||||
___cmds[0].enabled = true;
|
||||
___cmds[1].enabled = false;
|
||||
|
||||
if (__instance.Properties.Contains("FilterTags"))
|
||||
{
|
||||
string filterTags = "";
|
||||
__instance.Properties.ParseString("FilterTags", ref filterTags);
|
||||
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands filterTags: " + filterTags);
|
||||
|
||||
if (!filterTags.Contains("SC_automotive"))
|
||||
{
|
||||
___cmds[1].enabled = isEmpty && bTouched;
|
||||
}
|
||||
}
|
||||
//Log.Out("BlockPatches-GetBlockActivationCommands HAS TAKE DELAY");
|
||||
}
|
||||
__result = ___cmds;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCarExplodeLoot))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static bool Prefix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
bool canBeLooted = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _cIdx);
|
||||
|
||||
if (_commandName == "Search" && !RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _cIdx))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(BlockCarExplodeLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
float takeDelay = RebirthVariables.takeDelay;
|
||||
string replacementBlockName = "";
|
||||
int numBlocks = 1;
|
||||
bool isReplacementItem = false;
|
||||
|
||||
if (__instance.Properties.Contains("TakeDelay"))
|
||||
{
|
||||
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
|
||||
}
|
||||
if (__instance.Properties.Contains("ReplacementBlockName"))
|
||||
{
|
||||
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
|
||||
}
|
||||
if (__instance.Properties.Contains("numBlocks"))
|
||||
{
|
||||
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
|
||||
}
|
||||
if (__instance.Properties.Contains("isReplacementItem"))
|
||||
{
|
||||
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
|
||||
}
|
||||
|
||||
//Log.Out("BlockPatches-OnBlockActivated _commandName: " + _commandName);
|
||||
|
||||
if (_commandName == "take")
|
||||
{
|
||||
/*Log.Out("BlockPatches-OnBlockActivated takeDelay: " + takeDelay);
|
||||
Log.Out("BlockPatches-OnBlockActivated replacementBlockName: " + replacementBlockName);
|
||||
Log.Out("BlockPatches-OnBlockActivated numBlocks: " + numBlocks);
|
||||
Log.Out("BlockPatches-OnBlockActivated isReplacementItem: " + isReplacementItem);*/
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
if (optionProtectTrader)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Challenges;
|
||||
|
||||
namespace Harmony.ChallengeJournalPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ChallengeJournal))]
|
||||
[HarmonyPatch("FireEvent")]
|
||||
public class FireEventPatch
|
||||
{
|
||||
public static void Postfix(ChallengeJournal __instance, MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
foreach (Challenge challenge in _params.Self.challengeJournal.Challenges)
|
||||
{
|
||||
if (!challenge.ReadyToComplete || !challenge.ChallengeClass.Tags.Test_AnySet(FastTags<TagGroup.Global>.Parse("autoredeem")))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
challenge.ChallengeState = Challenge.ChallengeStates.Redeemed;
|
||||
challenge.Redeem();
|
||||
QuestEventManager.Current.ChallengeCompleted(challenge.ChallengeClass, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Harmony.ChunkPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Chunk))]
|
||||
[HarmonyPatch("updateFullMap")]
|
||||
public class updateFullMapPatch
|
||||
{
|
||||
public static bool Prefix(Chunk __instance,
|
||||
ref ushort[] ___mapColors,
|
||||
byte[] ___m_HeightMap,
|
||||
ChunkBlockLayer[] ___m_BlockLayers,
|
||||
ref bool ___bMapDirty,
|
||||
byte[] ___m_NormalX,
|
||||
byte[] ___m_NormalY,
|
||||
byte[] ___m_NormalZ
|
||||
)
|
||||
{
|
||||
if (___mapColors == null)
|
||||
{
|
||||
___mapColors = new ushort[256];
|
||||
}
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
int num = i + j * 16;
|
||||
int num2 = (int)___m_HeightMap[num];
|
||||
int num3 = num2 >> 2;
|
||||
BlockValue blockValue = (___m_BlockLayers[num3] != null) ? ___m_BlockLayers[num3].GetAt(i, num2, j) : BlockValue.Air;
|
||||
WaterValue water = __instance.GetWater(i, num2, j);
|
||||
while (num2 > 0 && (blockValue.isair || blockValue.Block.IsTerrainDecoration) && !water.HasMass())
|
||||
{
|
||||
num2--;
|
||||
blockValue = ((___m_BlockLayers[num3] != null) ? ___m_BlockLayers[num3].GetAt(i, num2, j) : BlockValue.Air);
|
||||
water = __instance.GetWater(i, num2, j);
|
||||
}
|
||||
Color col = BlockLiquidv2.Color;
|
||||
if (!water.HasMass())
|
||||
{
|
||||
float x = (float)((sbyte)___m_NormalX[num]) / 127f;
|
||||
float y = (float)((sbyte)___m_NormalY[num]) / 127f;
|
||||
float z = (float)((sbyte)___m_NormalZ[num]) / 127f;
|
||||
|
||||
//Log.Out("ChunkPatches-updateFullMap block: " + blockValue.Block.GetBlockName());
|
||||
|
||||
Vector3i pos = __instance.ToWorldPos(new Vector3i(i, num2, j));
|
||||
|
||||
//Log.Out("ChunkPatches-updateFullMap x: " + pos.x);
|
||||
//Log.Out("ChunkPatches-updateFullMap y: " + pos.y);
|
||||
//Log.Out("ChunkPatches-updateFullMap z: " + pos.z);
|
||||
|
||||
if (blockValue.Block.Properties.Values.ContainsKey("IgnoreMapColor"))
|
||||
{
|
||||
col = blockValue.Block.GetMapColor(blockValue, new Vector3(pos.x, pos.y, pos.z), pos.y);
|
||||
//Log.Out("ChunkPatches-updateFullMap 1, col: " + col.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
col = blockValue.Block.GetMapColor(blockValue, new Vector3(x, y, z), num2);
|
||||
//Log.Out("ChunkPatches-updateFullMap 3, col: " + col.ToString());
|
||||
}
|
||||
}
|
||||
___mapColors[num] = Utils.ToColor5(col);
|
||||
}
|
||||
}
|
||||
___bMapDirty = false;
|
||||
ModEvents.CalcChunkColorsDone.Invoke(__instance);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Harmony prefix to override entire method to potentially fix NRE
|
||||
|
||||
[HarmonyPatch(typeof(ChunkManager), nameof(ChunkManager.GetNextChunkToProvide))]
|
||||
public class ChunkManagerPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix(ChunkManager __instance, ref long __result)
|
||||
{
|
||||
int chunkPositionsCount = 0;
|
||||
|
||||
lock (__instance.lockObject)
|
||||
{
|
||||
__instance.m_AllChunkPositions.list.CopyTo(__instance.allChunkPositionsCopy);
|
||||
chunkPositionsCount = __instance.m_AllChunkPositions.list.Count;
|
||||
}
|
||||
|
||||
ChunkCluster chunkCache = __instance.m_World.ChunkCache;
|
||||
|
||||
// added th== null check to preempt going through while loops and a stack trace to see where it possibly originates from
|
||||
if (chunkCache == null)
|
||||
{
|
||||
Log.Error($"ChunkManager::GetNextChunkToProvide - chunkCache == null here - why?? - Stacktrace: {System.Environment.StackTrace}"); // todo - find out why chunkCache would be null here, only seldomly
|
||||
__result = long.MaxValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
int num2 = 0;
|
||||
|
||||
while (chunkCache != null && num2 < chunkPositionsCount)
|
||||
{
|
||||
long num3 = __instance.allChunkPositionsCopy[num2];
|
||||
|
||||
if (WorldChunkCache.extractClrIdx(num3) == 0 && !chunkCache.ContainsChunkSync(num3))
|
||||
{
|
||||
__result = num3;
|
||||
return false;
|
||||
}
|
||||
|
||||
num2++;
|
||||
}
|
||||
|
||||
// chunkCache could be null here randomly - This line is where the NRE occurs. Extra null check added here
|
||||
if (chunkCache != null && chunkCache.ChunkProvider != null && chunkCache.ChunkProvider.GetRequestedChunks() != null)
|
||||
{
|
||||
HashSetList<long> requestedChunks = chunkCache.ChunkProvider.GetRequestedChunks();
|
||||
lock (requestedChunks.list)
|
||||
{
|
||||
if (requestedChunks.list.Count > 0)
|
||||
{
|
||||
long num4 = chunkCache.ChunkProvider.GetRequestedChunks().list[requestedChunks.list.Count - 1];
|
||||
requestedChunks.Remove(num4);
|
||||
|
||||
__result = num4;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__result = long.MaxValue;
|
||||
|
||||
// Don't process the original method
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
namespace Harmony.CompanionGroupPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(CompanionGroup))]
|
||||
[HarmonyPatch("Remove")]
|
||||
public class RemovePatch
|
||||
{
|
||||
public static bool Prefix(CompanionGroup __instance, EntityAlive entity)
|
||||
{
|
||||
//Log.Out("CompanionGroupPatches-Remove START, entity.entityId: " + entity.entityId);
|
||||
//__instance.MemberList.Remove(entity);
|
||||
|
||||
for (int i = 0; i < __instance.MemberList.Count; i++)
|
||||
{
|
||||
//Log.Out("CompanionGroupPatches-Remove i: " + i);
|
||||
//Log.Out("CompanionGroupPatches-Remove __instance.MemberList[" + i + "].entityId: " + __instance.MemberList[i].entityId);
|
||||
if (__instance.MemberList[i].entityId == entity.entityId)
|
||||
{
|
||||
//Log.Out("CompanionGroupPatches-Remove REMOVE");
|
||||
__instance.MemberList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OnCompanionGroupChanged onGroupChanged = __instance.OnGroupChanged;
|
||||
if (onGroupChanged == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
onGroupChanged();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using static RebirthManager;
|
||||
|
||||
namespace Harmony.ConnectionManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ConnectionManager))]
|
||||
[HarmonyPatch("SendToServer")]
|
||||
public class SendToServerPatch
|
||||
{
|
||||
public static bool Prefix(ConnectionManager __instance, NetPackage _package, bool _flush,
|
||||
ref INetConnection[] ___connectionToServer
|
||||
)
|
||||
{
|
||||
int channel = _package.Channel;
|
||||
if (___connectionToServer[channel] == null)
|
||||
{
|
||||
if (__instance.IsConnected)
|
||||
{
|
||||
Log.Error("Can not queue package for server: NetConnection null");
|
||||
Log.Error("Can not queue package for server: Package ID: " + _package.PackageId);
|
||||
//Log.Error("Can not queue package for server: Player: " + _package.Sender.playerName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
___connectionToServer[channel].AddToSendQueue(_package);
|
||||
if (_flush)
|
||||
{
|
||||
___connectionToServer[channel].FlushSendQueue();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ConnectionManager))]
|
||||
[HarmonyPatch("DisconnectClient")]
|
||||
public class DisconnectClientPatch
|
||||
{
|
||||
public static bool Prefix(ConnectionManager __instance, ClientInfo _cInfo, bool _bShutdown = false, bool _clientDisconnect = false)
|
||||
{
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient START, _cInfo.entityId: " + _cInfo.entityId);
|
||||
RebirthUtilities.removeTileEntityAccess(_cInfo.entityId);
|
||||
|
||||
RebirthVariables.purgePrefabsLoaded = false;
|
||||
|
||||
World world = GameManager.Instance.World;
|
||||
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient hire.playerID: " + hire.playerID);
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient hire.hireID: " + hire.hireID);
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient hire.order: " + hire.order);
|
||||
|
||||
if (hire.playerID == _cInfo.entityId && hire.order == (int)EntityUtilities.Orders.Follow)
|
||||
{
|
||||
EntityNPCRebirth entity = GameManager.Instance.World.GetEntity(hire.hireID) as EntityNPCRebirth;
|
||||
if (entity)
|
||||
{
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient entityPlayer [" + _cInfo.playerName + "] Disconnected, hire [" + entity.EntityName + "] set to STAY");
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient [" + entityPlayer.EntityName + "] entity.position + entity.GetLookVector(): " + entity.position + entity.GetLookVector());
|
||||
|
||||
entity.guardPosition = Vector3.zero;
|
||||
entity.HideNPC(false);
|
||||
entity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.TempStay);
|
||||
entity.Buffs.SetCustomVar("$Leader", _cInfo.entityId);
|
||||
}
|
||||
}
|
||||
if (hire.playerID == _cInfo.entityId && (hire.order == 1 || hire.order == 2))
|
||||
{
|
||||
for (int i = 0; i < observers.Count; i++)
|
||||
{
|
||||
if (observers[i].entityID == hire.hireID)
|
||||
{
|
||||
//Log.Out("ConnectionManagerPatches-DisconnectClient REMOVED OBSERVER, hire: " + hire.hireID);
|
||||
GameManager.Instance.RemoveChunkObserver(observers[i].observerRef);
|
||||
observers.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hire.playerID == _cInfo.entityId)
|
||||
{
|
||||
hire.playerSpawned = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.ConsoleCmdKillAllPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ConsoleCmdKillAll))]
|
||||
[HarmonyPatch("Execute")]
|
||||
public class ExecutePatch
|
||||
{
|
||||
public static void Kill(Entity entity)
|
||||
{
|
||||
entity.DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false);
|
||||
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("Gave " + 99999.ToString() + " damage to entity " + entity.GetDebugName());
|
||||
}
|
||||
|
||||
public static bool Prefix(ConsoleCmdKillAll __instance, List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
bool flag1 = _params.Count > 0 && RebirthUtilities.ConvertStringToInt(_params[0]) != -1;
|
||||
|
||||
int distanceParameter = -1;
|
||||
if (flag1)
|
||||
{
|
||||
distanceParameter = RebirthUtilities.ConvertStringToInt(_params[0]);
|
||||
}
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute distanceParameter: " + distanceParameter);
|
||||
|
||||
bool flag2 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("all");
|
||||
bool flag3 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("vehicles");
|
||||
bool flag4 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("turrets");
|
||||
bool flag5 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("whiteriver");
|
||||
bool flag6 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("bandits");
|
||||
bool flag7 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("loot");
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag1: " + flag1);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag2: " + flag2);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag3: " + flag3);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag4: " + flag4);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag5: " + flag5);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag6: " + flag6);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag7: " + flag7);
|
||||
|
||||
List<Entity> entityList = new List<Entity>((IEnumerable<Entity>)GameManager.Instance.World.Entities.list);
|
||||
for (int index = 0; index < entityList.Count; ++index)
|
||||
{
|
||||
Entity entity = entityList[index];
|
||||
if (entity != null && !(entity is EntityPlayer))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute entity: " + entity.EntityClass.entityClassName);
|
||||
if (entity is EntityAlive && !flag7)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS ENTITYALIVE");
|
||||
switch (entity)
|
||||
{
|
||||
case EntityVehicle _:
|
||||
if (flag3)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS VEHICLE");
|
||||
Kill(entity);
|
||||
}
|
||||
break;
|
||||
case EntityTurret _:
|
||||
if (flag4)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS TURRET");
|
||||
Kill(entity);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute DEFAULT");
|
||||
if (EntityClass.list[entity.entityClass].bIsEnemyEntity)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS ENEMY");
|
||||
if (flag1)
|
||||
{
|
||||
int playerId = GameManager.Instance.World.GetPrimaryPlayerId();
|
||||
if (_senderInfo.RemoteClientInfo != null)
|
||||
playerId = _senderInfo.RemoteClientInfo.entityId;
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute playerId: " + playerId);
|
||||
if (playerId == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3i playerPosition = new Vector3i(GameManager.Instance.World.Players.list.FirstOrDefault<EntityPlayer>((Func<EntityPlayer, bool>)(d => d.entityId == playerId)).GetPosition());
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute playerPosition: " + playerPosition);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute entity.position: " + entity.position);
|
||||
|
||||
float distance = Vector3.Distance(entity.position, playerPosition);
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute distance: " + distance);
|
||||
|
||||
if (distance <= distanceParameter)
|
||||
{
|
||||
Kill(entity);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Kill(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 1");
|
||||
if (flag2)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 2");
|
||||
Kill(entity);
|
||||
}
|
||||
|
||||
string faction = "";
|
||||
|
||||
if (entity.EntityClass.Properties.Values.TryGetValue("Faction", out faction))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 3");
|
||||
if (flag5 && faction.ToLower() == "whiteriver")
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 4");
|
||||
Kill(entity);
|
||||
}
|
||||
else if (flag6 && faction.ToLower() == "bandits")
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 5");
|
||||
Kill(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (entity is EntityLootContainer && flag7 && !(entity is EntityAlive))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 6");
|
||||
Kill(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.CropsGrownPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(BlockCropsGrown))]
|
||||
[HarmonyPatch("HasBlockActivationCommands")]
|
||||
public class HasBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(BlockCropsGrown __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCropsGrown), "OnBlockActivated", new Type[] { typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
//public static MethodInfo setPlantBackToBaby = AccessTools.Method(typeof(BlockCropsGrown), "setPlantBackToBaby", new Type[] { typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue) });
|
||||
|
||||
public static bool Prefix(BlockCropsGrown __instance, ref bool __result, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated START");
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 1");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Block.SItemDropProb> list = null;
|
||||
int num = 0;
|
||||
|
||||
if (__instance.itemsToDrop.TryGetValue(EnumDropEvent.Harvest, out list) && (num = Utils.FastMax(0, list[0].minCount)) > 0)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated A num: " + num);
|
||||
|
||||
if (_blockPos.y > 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 2");
|
||||
int num2 = (int)(_world.GetBlock(_blockPos - Vector3i.up).Block.blockMaterial.FertileLevel / __instance.bonusHarvestDivisor);
|
||||
num += num2;
|
||||
}
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated B num: " + num);
|
||||
|
||||
int numType = 0;
|
||||
int numAdd = 0;
|
||||
string strBlockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "mushroom01" ||
|
||||
strBlockName == "mushroom02" ||
|
||||
strBlockName == "plantedYucca3Harvest" ||
|
||||
strBlockName == "plantedCotton3Harvest" ||
|
||||
strBlockName == "plantedCoffee3Harvest" ||
|
||||
strBlockName == "plantedGoldenrod3Harvest" ||
|
||||
strBlockName == "plantedAloe3Harvest" ||
|
||||
strBlockName == "plantedBlueberry3Harvest" ||
|
||||
strBlockName == "plantedPotato3Harvest" ||
|
||||
strBlockName == "plantedChrysanthemum3Harvest" ||
|
||||
strBlockName == "plantedCorn3Harvest" ||
|
||||
strBlockName == "plantedGraceCorn3Harvest" ||
|
||||
strBlockName == "plantedHop3Harvest" ||
|
||||
strBlockName == "plantedSnowberry3Harvest" ||
|
||||
strBlockName == "plantedPumpkin3Harvest" ||
|
||||
strBlockName == "plantedCorn2Deco"
|
||||
)
|
||||
{
|
||||
numType = 1;
|
||||
//Log.Out("TYPE 1");
|
||||
}
|
||||
else if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "plantedMushroom3HarvestPlayer" ||
|
||||
strBlockName == "plantedYucca3HarvestPlayer" ||
|
||||
strBlockName == "plantedCotton3HarvestPlayer" ||
|
||||
strBlockName == "plantedCoffee3HarvestPlayer" ||
|
||||
strBlockName == "plantedGoldenrod3HarvestPlayer" ||
|
||||
strBlockName == "plantedAloe3HarvestPlayer" ||
|
||||
strBlockName == "plantedBlueberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPotato3HarvestPlayer" ||
|
||||
strBlockName == "plantedChrysanthemum3HarvestPlayer" ||
|
||||
strBlockName == "plantedCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedGraceCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedHop3HarvestPlayer" ||
|
||||
strBlockName == "plantedSnowberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPumpkin3HarvestPlayer"
|
||||
)
|
||||
{
|
||||
numType = 2;
|
||||
//Log.Out("TYPE 2");
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//Log.Out("NO TYPE");
|
||||
//}
|
||||
|
||||
ProgressionValue progressionValue1 = _player.Progression.GetProgressionValue("perkLivingOffTheLand");
|
||||
ProgressionValue progressionValue2 = _player.Progression.GetProgressionValue("FuriousRamsayAchievementCrops");
|
||||
|
||||
if (progressionValue1 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3, progressionValue1: " + progressionValue1.Level);
|
||||
if (progressionValue1.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3a");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3b");
|
||||
numAdd++;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3c");
|
||||
numAdd += 0; // 0 ?? Are you sure? ^^
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3d");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3e");
|
||||
numAdd++;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3f");
|
||||
numAdd++;
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3g");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3h");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3i");
|
||||
numAdd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progressionValue2 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4, progressionValue2: " + progressionValue2.Level);
|
||||
if (progressionValue2.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4a");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4b");
|
||||
numAdd = numAdd + 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4c");
|
||||
numAdd = numAdd + 0;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4d");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4e");
|
||||
numAdd = numAdd + 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4f");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4g");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4h");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4i");
|
||||
numAdd += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num += numAdd;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated C num: " + num);
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated numType: " + numType + ", numAdd: " + numAdd + ", Index: " + _cIdx);
|
||||
|
||||
if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 5");
|
||||
if (!__instance.DowngradeBlock.isair)
|
||||
{
|
||||
////Log.Out("BlockCropsGrownRebirth-OnBlockActivated DOWNGRADE: " + this.DowngradeBlock.Block.GetBlockName());
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated POSITION X: " + _blockPos.x + ", Y: " + _blockPos.y + ", Z: " + _blockPos.z);
|
||||
|
||||
BlockValue blockValue2 = __instance.DowngradeBlock;
|
||||
blockValue2 = BlockPlaceholderMap.Instance.Replace(blockValue2, _world.GetGameRandom(), _blockPos.x, _blockPos.z);
|
||||
blockValue2.rotation = _blockValue.rotation;
|
||||
blockValue2.meta = _blockValue.meta;
|
||||
Block block4 = blockValue2.Block;
|
||||
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_cIdx];
|
||||
chunkCluster.InvokeOnBlockDamagedDelegates(_blockPos, _blockValue, 9999, _player.entityId);
|
||||
|
||||
if (!block4.shape.IsTerrain())
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 1");
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue2);
|
||||
|
||||
if (chunkCluster.GetTextureFull(_blockPos) != 0L)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 2");
|
||||
if (__instance.RemovePaintOnDowngrade == null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 3");
|
||||
GameManager.Instance.SetBlockTextureServer(_blockPos, BlockFace.None, 0, _player.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 4");
|
||||
for (int i = 0; i < __instance.RemovePaintOnDowngrade.Count; i++)
|
||||
{
|
||||
GameManager.Instance.SetBlockTextureServer(_blockPos, __instance.RemovePaintOnDowngrade[i], 0, _player.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 5");
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue2, block4.Density);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-OnBlockActivated 6, num: " + num);
|
||||
|
||||
ItemStack itemStack = new ItemStack(ItemClass.GetItem(list[0].name, false), num);
|
||||
ItemStack @is = itemStack.Clone();
|
||||
|
||||
if ((_player.inventory.CanStackNoEmpty(itemStack) && _player.inventory.AddItem(itemStack)) || _player.bag.AddItem(itemStack) || _player.inventory.AddItem(itemStack))
|
||||
{
|
||||
_player.PlayOneShot("item_plant_pickup", false);
|
||||
|
||||
if (numType == 1)
|
||||
{
|
||||
__instance.setPlantBackToBaby(_world, _cIdx, _blockPos, _blockValue);
|
||||
QuestEventManager.Current.BlockPickedUp(_blockValue.Block.GetBlockName(), _blockPos);
|
||||
}
|
||||
|
||||
if (_player is EntityPlayerLocal)
|
||||
{
|
||||
_player.AddUIHarvestingItem(@is, false);
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Manager.PlayInsidePlayerHead("ui_denied", -1, 0f, false);
|
||||
}
|
||||
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(BlockCropsGrown), "GetActivationText")]
|
||||
public class GetActivationTextPatch
|
||||
{
|
||||
public static bool Prefix(BlockCropsGrown __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (_world.IsEditor()) return true;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText START");
|
||||
List<Block.SItemDropProb> list = null;
|
||||
int num;
|
||||
|
||||
if (__instance.itemsToDrop.TryGetValue(EnumDropEvent.Harvest, out list) && (num = Utils.FastMax(0, list[0].minCount)) > 0)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 1");
|
||||
if (_blockPos.y > 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 2");
|
||||
int num2 = (int)(_world.GetBlock(_blockPos - Vector3i.up).Block.blockMaterial.FertileLevel / __instance.bonusHarvestDivisor);
|
||||
num += num2;
|
||||
}
|
||||
|
||||
int numType = 0;
|
||||
int numAdd = 0;
|
||||
string strBlockName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "mushroom01" ||
|
||||
strBlockName == "mushroom02" ||
|
||||
strBlockName == "plantedYucca3Harvest" ||
|
||||
strBlockName == "plantedCotton3Harvest" ||
|
||||
strBlockName == "plantedCoffee3Harvest" ||
|
||||
strBlockName == "plantedGoldenrod3Harvest" ||
|
||||
strBlockName == "plantedAloe3Harvest" ||
|
||||
strBlockName == "plantedBlueberry3Harvest" ||
|
||||
strBlockName == "plantedPotato3Harvest" ||
|
||||
strBlockName == "plantedChrysanthemum3Harvest" ||
|
||||
strBlockName == "plantedCorn3Harvest" ||
|
||||
strBlockName == "plantedGraceCorn3Harvest" ||
|
||||
strBlockName == "plantedHop3Harvest" ||
|
||||
strBlockName == "plantedSnowberry3Harvest" ||
|
||||
strBlockName == "plantedPumpkin3Harvest" ||
|
||||
strBlockName == "plantedCorn2Deco"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 3");
|
||||
numType = 1;
|
||||
}
|
||||
else if (strBlockName == "plantedMushroom3Harvest" ||
|
||||
strBlockName == "plantedMushroom3HarvestPlayer" ||
|
||||
strBlockName == "plantedYucca3HarvestPlayer" ||
|
||||
strBlockName == "plantedCotton3HarvestPlayer" ||
|
||||
strBlockName == "plantedCoffee3HarvestPlayer" ||
|
||||
strBlockName == "plantedGoldenrod3HarvestPlayer" ||
|
||||
strBlockName == "plantedAloe3HarvestPlayer" ||
|
||||
strBlockName == "plantedBlueberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPotato3HarvestPlayer" ||
|
||||
strBlockName == "plantedChrysanthemum3HarvestPlayer" ||
|
||||
strBlockName == "plantedCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedGraceCorn3HarvestPlayer" ||
|
||||
strBlockName == "plantedHop3HarvestPlayer" ||
|
||||
strBlockName == "plantedSnowberry3HarvestPlayer" ||
|
||||
strBlockName == "plantedPumpkin3HarvestPlayer"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 4");
|
||||
numType = 2;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 5");
|
||||
//}
|
||||
|
||||
ProgressionValue progressionValue1 = _entityFocusing.Progression.GetProgressionValue("perkLivingOffTheLand");
|
||||
ProgressionValue progressionValue2 = _entityFocusing.Progression.GetProgressionValue("FuriousRamsayAchievementCrops");
|
||||
|
||||
if (progressionValue1 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 6");
|
||||
if (progressionValue1.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 7");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 8");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 9");
|
||||
numAdd += 0; // 0 again ??
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 10");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 11");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 12");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue1.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 13");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 14");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 15");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progressionValue2 != null)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 16");
|
||||
if (progressionValue2.Level == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 17");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 18");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 19");
|
||||
numAdd += 0;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 20");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 21");
|
||||
numAdd += 1;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 22");
|
||||
numAdd += 1;
|
||||
}
|
||||
}
|
||||
else if (progressionValue2.Level == 3)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 23");
|
||||
if (numType == 1)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 24");
|
||||
numAdd += 2;
|
||||
}
|
||||
else if (numType == 2)
|
||||
{
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText 25");
|
||||
numAdd += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num += numAdd;
|
||||
|
||||
//Log.Out("BlockCropsGrownRebirth-GetActivationText END 1");
|
||||
|
||||
__result = string.Format(Localization.Get("pickupCrops"), num, Localization.Get(list[0].name));
|
||||
return false;
|
||||
}
|
||||
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.DroneManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(DroneManager), "RemoveAllDronesFromMap")]
|
||||
public class RemoveAllVehiclesFromMapPatch
|
||||
{
|
||||
public static bool Prefix(DroneManager __instance)
|
||||
{
|
||||
GameManager instance = GameManager.Instance;
|
||||
PersistentPlayerList persistentPlayerList = instance.GetPersistentPlayerList();
|
||||
World world = instance.World;
|
||||
|
||||
foreach (KeyValuePair<PlatformUserIdentifierAbs, PersistentPlayerData> player in persistentPlayerList.Players)
|
||||
{
|
||||
EntityPlayer entity = world.GetEntity(player.Value.EntityId) as EntityPlayer;
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
OwnedEntityData[] ownedEntities = entity.GetOwnedEntities();
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ownedEntities.Length: " + ownedEntities.Length);
|
||||
|
||||
for (int i = 0; i < ownedEntities.Length; ++i)
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ___dronesActive.Count: " + ___dronesActive.Count);
|
||||
EntityDrone entityDrone = __instance.dronesActive.Find(v => v.entityId == ownedEntities[i].Id);
|
||||
|
||||
if (entityDrone != null && entity.HasOwnedEntity(entityDrone.entityId))
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap entityDrone.entityId: " + entityDrone.entityId);
|
||||
GameManager.Instance.World.RemoveEntityFromMap(entityDrone, EnumRemoveEntityReason.Unloaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
namespace Harmony.EAIManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EAIManager))]
|
||||
[HarmonyPatch("GetType")]
|
||||
public class GetTypePatch
|
||||
{
|
||||
public static bool Prefix(EAIManager __instance, ref System.Type __result, string _className)
|
||||
{
|
||||
switch (_className)
|
||||
{
|
||||
case "ApproachAndAttackTarget":
|
||||
__result = typeof(EAIApproachAndAttackTarget);
|
||||
return false;
|
||||
case "ApproachDistraction":
|
||||
__result = typeof(EAIApproachDistraction);
|
||||
return false;
|
||||
case "ApproachSpot":
|
||||
__result = typeof(EAIApproachSpot);
|
||||
return false;
|
||||
case "BlockIf":
|
||||
__result = typeof(EAIBlockIf);
|
||||
return false;
|
||||
case "BlockingTargetTask":
|
||||
__result = typeof(EAIBlockingTargetTask);
|
||||
return false;
|
||||
case "BreakBlock":
|
||||
__result = typeof(EAIBreakBlock);
|
||||
return false;
|
||||
case "DestroyArea":
|
||||
__result = typeof(EAIDestroyArea);
|
||||
return false;
|
||||
case "Dodge":
|
||||
__result = typeof(EAIDodge);
|
||||
return false;
|
||||
case "Leap":
|
||||
__result = typeof(EAILeap);
|
||||
return false;
|
||||
case "Look":
|
||||
__result = typeof(EAILook);
|
||||
return false;
|
||||
case "RangedAttackTarget":
|
||||
__result = typeof(EAIRangedAttackTarget);
|
||||
return false;
|
||||
case "RangedAttackTarget2":
|
||||
__result = typeof(EAIRangedAttackTarget2);
|
||||
return false;
|
||||
case "RunawayFromEntity":
|
||||
__result = typeof(EAIRunawayFromEntity);
|
||||
return false;
|
||||
case "RunawayWhenHurt":
|
||||
__result = typeof(EAIRunawayWhenHurt);
|
||||
return false;
|
||||
case "SetAsTargetIfHurt":
|
||||
__result = typeof(EAISetAsTargetIfHurt);
|
||||
return false;
|
||||
case "SetNearestCorpseAsTarget":
|
||||
__result = typeof(EAISetNearestCorpseAsTarget);
|
||||
return false;
|
||||
case "SetNearestEntityAsTarget":
|
||||
__result = typeof(EAISetNearestEntityAsTarget);
|
||||
return false;
|
||||
case "TakeCover":
|
||||
__result = typeof(EAITakeCover);
|
||||
return false;
|
||||
case "Territorial":
|
||||
__result = typeof(EAITerritorial);
|
||||
return false;
|
||||
case "Wander":
|
||||
__result = typeof(EAIWander);
|
||||
return false;
|
||||
default:
|
||||
//Log.Warning("EAIManager GetType slow lookup for {0}", (object)_className);
|
||||
__result = System.Type.GetType("EAI" + _className);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EAIManager))]
|
||||
[HarmonyPatch("CalcSenseScale")]
|
||||
public class CalcSenseScalePatch
|
||||
{
|
||||
public static bool Prefix(EAIManager __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;
|
||||
|
||||
if (isValidFeralSense)
|
||||
{
|
||||
__result = 1f;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (GamePrefs.GetInt(EnumGamePrefs.ZombieFeralSense))
|
||||
{
|
||||
case 1:
|
||||
if (GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
__result = 1f;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (GameManager.Instance.World.IsDark())
|
||||
{
|
||||
__result = 1f;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
__result = 1f;
|
||||
return false;
|
||||
}
|
||||
__result = 0f;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.EAISetNearestCorpseAsTargetPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EAISetNearestCorpseAsTarget))]
|
||||
[HarmonyPatch("Continue")]
|
||||
public class ContinuePatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result,
|
||||
global::EntityAlive ___targetEntity,
|
||||
global::EntityAlive ___theEntity
|
||||
)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-Continue ___targetEntity != null: " + (___targetEntity != null));
|
||||
|
||||
if (___targetEntity != null)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-Continue ___targetEntity.IsDead(): " + (___targetEntity.IsDead()));
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-Continue !(___targetEntity is EntityZombie): " + (!(___targetEntity is EntityZombie)));
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-Continue !(___targetEntity != ___theEntity.GetAttackTarget()): " + (!(___targetEntity != ___theEntity.GetAttackTarget())));
|
||||
}
|
||||
|
||||
__result = ___targetEntity && ___targetEntity.IsDead() && !(___targetEntity is EntityZombie) && !(___targetEntity != ___theEntity.GetAttackTarget());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EAISetNearestCorpseAsTarget))]
|
||||
[HarmonyPatch("CanExecute")]
|
||||
public class CanExecutePatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, ref bool __result,
|
||||
ref global::EntityAlive ___targetEntity,
|
||||
global::EntityAlive ___theEntity,
|
||||
ref int ___rndTimeout,
|
||||
float ___maxXZDistance,
|
||||
EntityFlags ___targetFlags,
|
||||
ref List<Entity> ___entityList,
|
||||
EAISetNearestEntityAsTargetSorter ___sorter,
|
||||
EAIManager ___manager
|
||||
)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute START");
|
||||
|
||||
if (___theEntity.HasInvestigatePosition)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 1");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
if (___theEntity.IsSleeping)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 2");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
if (___rndTimeout > 0 && ___manager.random.RandomRange(___rndTimeout) != 0)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 3");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
global::EntityAlive attackTarget = ___theEntity.GetAttackTarget();
|
||||
if (attackTarget is EntityPlayer && attackTarget.IsAlive() && ___manager.random.RandomFloat < 0.95f)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 4");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
float radius = ___theEntity.IsSleeper ? 7f : ___maxXZDistance;
|
||||
___theEntity.world.GetEntitiesAround(___targetFlags, ___targetFlags, ___theEntity.position, radius, ___entityList);
|
||||
___entityList.Sort(___sorter);
|
||||
global::EntityAlive entityAlive = null;
|
||||
for (int i = 0; i < ___entityList.Count; i++)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute i: " + i);
|
||||
global::EntityAlive entityAlive2 = ___entityList[i] as global::EntityAlive;
|
||||
|
||||
if (entityAlive2)
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 5");
|
||||
if (entityAlive2.IsDead())
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute 6");
|
||||
if (!(___targetEntity is EntityZombie))
|
||||
{
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute entityAlive: " + entityAlive2.EntityClass.entityClassName);
|
||||
entityAlive = entityAlive2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
___entityList.Clear();
|
||||
___targetEntity = entityAlive;
|
||||
__result = ___targetEntity != null;
|
||||
|
||||
//Log.Out("EAISetNearestCorpseAsTargetPatches-CanExecute __result: " + __result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
|
||||
namespace Harmony.EAITargetPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EAITarget))]
|
||||
[HarmonyPatch("check")]
|
||||
public class EAITarget_checkPatch
|
||||
{
|
||||
public static bool Prefix(EAITarget __instance, ref bool __result, EntityAlive _e, bool ___bNeedToSee)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check START");
|
||||
|
||||
if (_e == null || _e == __instance.theEntity)
|
||||
{
|
||||
|
||||
/*//Log.Out($"EAITargetPatches-check _e == null: " + (_e == null));
|
||||
//Log.Out($"EAITargetPatches-check _e == __instance.theEntity: " + (_e == __instance.theEntity));*/
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out($"EAITargetPatches-check _e: " + _e.EntityClass.entityClassName);
|
||||
//Log.Out($"EAITargetPatches-check __instance.theEntity: " + __instance.theEntity.EntityClass.entityClassName);
|
||||
//Log.Out($"EAITargetPatches-check !_e.IsAlive(): " + (!_e.IsAlive()));
|
||||
//Log.Out($"EAITargetPatches-check _e.IsIgnoredByAI(): " + (_e.IsIgnoredByAI()));
|
||||
|
||||
if (!_e.IsAlive() || _e.IsIgnoredByAI())
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 1");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_e is EntitySupplyCrate)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 2a");
|
||||
if (!__instance.theEntity.Buffs.HasBuff("buffSupplyCrateSpawn"))
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 2b");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3i blockPos = World.worldToBlockPos(_e.position);
|
||||
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check NO HIT source: {__instance.theEntity.EntityName} target: {_e.EntityName}");
|
||||
//Log.Out($"EAITargetPatches-check NO HIT CanSee: {__instance.theEntity.CanSee(_e)}");
|
||||
}
|
||||
|
||||
if (!__instance.theEntity.isWithinHomeDistance(blockPos.x, blockPos.y, blockPos.z) || __instance.bNeedToSee && !__instance.theEntity.CanSee(_e))
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 3");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityPlayer _other = _e as EntityPlayer;
|
||||
|
||||
if (_other != null && RebirthVariables.noHit)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check NO HIT CanSeeStealth: {__instance.theEntity.CanSeeStealth(__instance.theEntity.GetDistance((Entity)_other), _other.Stealth.lightLevel)}");
|
||||
}
|
||||
|
||||
__result = !(_other != null) || __instance.theEntity.CanSeeStealth(__instance.theEntity.GetDistance((Entity)_other), _other.Stealth.lightLevel);
|
||||
|
||||
if (RebirthUtilities.IsCurrentRevengeTarget(__instance.theEntity, _e))
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 4");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__result)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check 5");
|
||||
bool shouldAttack = RebirthUtilities.VerifyFactionStanding(__instance.theEntity, _e);
|
||||
|
||||
//Log.Out($"EAITargetPatches-check 6, shouldAttack: " + shouldAttack);
|
||||
|
||||
if (!shouldAttack) RebirthUtilities.TeLog($"EAITarget::check - this: {__instance.theEntity}, shouldAttack {shouldAttack}");
|
||||
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
//Log.Out($"EAITargetPatches-check NO HIT shouldAttack: {shouldAttack}");
|
||||
}
|
||||
|
||||
__result = shouldAttack;
|
||||
}
|
||||
|
||||
/*if (__result == false)
|
||||
{
|
||||
bool canSeeStealth = true;
|
||||
|
||||
if (_other != null)
|
||||
{
|
||||
canSeeStealth = __instance.theEntity.CanSeeStealth(__instance.theEntity.GetDistance((Entity)_other), _other.Stealth.lightLevel);
|
||||
}
|
||||
|
||||
// player is stealthy so the entity cannot see them at this time
|
||||
//RebirthUtilities.TeLog($"EAITarget::check - this: {__instance.theEntity}, entityPlayer: {_other}, canSeeStealth: {canSeeStealth}, player's stealth light level: {_other.Stealth.lightLevel}");
|
||||
}*/
|
||||
|
||||
//Log.Out($"EAITargetPatches-check 7, __result: " + __result);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
namespace Harmony.EModelBasePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EModelBase))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
private static void Postfix(EModelBase __instance, Entity ___entity)
|
||||
{
|
||||
if (__instance.GetModelTransform() == null)
|
||||
return;
|
||||
|
||||
// Add the animation Bridge to all entities that do not have it.
|
||||
__instance.GetModelTransform().gameObject.GetOrAddComponent<AnimationEventBridge>();
|
||||
|
||||
// Add any missing Root TransformRef Entity scripts where a CollisionCallForward exists.
|
||||
foreach (var collisionCallForward in __instance.GetComponentsInChildren<CollisionCallForward>())
|
||||
{
|
||||
collisionCallForward.transform.gameObject.GetOrAddComponent<RootTransformRefEntity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EModelBase))]
|
||||
[HarmonyPatch("DoRagdoll")]
|
||||
[HarmonyPatch(new Type[] { typeof(DamageResponse), typeof(float) })]
|
||||
public class DoRagdollPatch
|
||||
{
|
||||
public static bool Prefix(ref EModelBase __instance, DamageResponse dr, float stunTime, Entity ___entity
|
||||
)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll START");
|
||||
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll dr.HitBodyPart: " + dr.HitBodyPart);
|
||||
|
||||
float num = (float)dr.Strength;
|
||||
DamageSource source = dr.Source;
|
||||
if (num > 0f && source != null)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll stunTime: " + stunTime);
|
||||
Vector3 vector = source.getDirection();
|
||||
EnumDamageTypes damageType = source.GetDamageType();
|
||||
if (damageType != EnumDamageTypes.Falling && damageType != EnumDamageTypes.Crushing)
|
||||
{
|
||||
float num2;
|
||||
if (dr.HitBodyPart == EnumBodyPartHit.None)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 2");
|
||||
num2 = ___entity.rand.RandomRange(5f, 25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 3");
|
||||
float min = -20f;
|
||||
if (stunTime == 0f)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 4");
|
||||
min = 5f;
|
||||
}
|
||||
num2 = ___entity.rand.RandomRange(min, 40f);
|
||||
num *= 0.5f;
|
||||
if (source.damageType == EnumDamageTypes.Bashing)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 5");
|
||||
num *= 2.5f;
|
||||
}
|
||||
if (dr.Critical)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 6");
|
||||
num2 += 25f;
|
||||
num *= 2f;
|
||||
}
|
||||
if ((dr.HitBodyPart & EnumBodyPartHit.Head) > EnumBodyPartHit.None)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 7");
|
||||
num *= 0.45f;
|
||||
}
|
||||
num = Utils.FastMin(20f + num, 500f);
|
||||
vector *= num;
|
||||
}
|
||||
Vector3 vector2 = Vector3.Cross(vector.normalized, Vector3.up);
|
||||
vector = Quaternion.AngleAxis(num2, vector2) * vector;
|
||||
|
||||
if (___entity.EntityClass.HasRagdoll)
|
||||
{
|
||||
__instance.DoRagdoll(stunTime, dr.HitBodyPart, vector, source.getHitTransformPosition(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 10, dr.HitBodyPart: " + dr.HitBodyPart);
|
||||
bool isRemote = false;
|
||||
EnumBodyPartHit bodyPart = dr.HitBodyPart;
|
||||
Vector3 forceVec = vector;
|
||||
Vector3 forceWorldPos = source.getHitTransformPosition();
|
||||
|
||||
if (!isRemote && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && ___entity.isEntityRemote)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 11");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageEntityRagdoll>().Setup(___entity, stunTime, bodyPart, forceVec, forceWorldPos), false);
|
||||
return false;
|
||||
}
|
||||
bool flag = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && ___entity.isEntityRemote;
|
||||
if (stunTime == 0f)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 12");
|
||||
if (!flag)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 13");
|
||||
___entity.PhysicsPush(forceVec, forceWorldPos);
|
||||
}
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 14");
|
||||
___entity.world.entityDistributer.SendPacketToTrackedPlayersAndTrackedEntity(___entity.entityId, -1, NetPackageManager.GetPackage<NetPackageEntityRagdoll>().Setup(___entity, 0f, EnumBodyPartHit.Torso, forceVec, forceWorldPos));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 15");
|
||||
if (forceVec.sqrMagnitude > 0f)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 16");
|
||||
|
||||
___entity.PhysicsPush(forceVec, dr.Source.getHitTransformPosition());
|
||||
}
|
||||
}
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 17");
|
||||
___entity.world.entityDistributer.SendPacketToTrackedPlayersAndTrackedEntity(___entity.entityId, -1, NetPackageManager.GetPackage<NetPackageEntityRagdoll>().Setup(___entity, stunTime, bodyPart, forceVec, forceWorldPos));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Log.Out("DoRagdollPatch1-DoRagdoll 18");
|
||||
|
||||
__instance.DoRagdoll(stunTime, dr.HitBodyPart, Vector3.zero, Vector3.zero, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Harmony.ElectricWireControllerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ElectricWireController))]
|
||||
[HarmonyPatch("touched")]
|
||||
public class touchedPatches
|
||||
{
|
||||
public static bool Prefix(ElectricWireController __instance, Collider collider)
|
||||
{
|
||||
if (__instance.TileEntityParent == null || __instance.TileEntityChild == null || __instance.WireNode == null || collider == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (__instance.TileEntityParent.IsPowered && __instance.TileEntityChild.IsPowered && collider.transform != null)
|
||||
{
|
||||
global::EntityAlive entityAlive = collider.transform.GetComponent<global::EntityAlive>();
|
||||
if (entityAlive == null)
|
||||
{
|
||||
entityAlive = collider.transform.GetComponentInParent<global::EntityAlive>();
|
||||
}
|
||||
if (entityAlive == null && collider.transform.parent != null)
|
||||
{
|
||||
entityAlive = collider.transform.parent.GetComponentInChildren<global::EntityAlive>();
|
||||
}
|
||||
if (entityAlive == null)
|
||||
{
|
||||
entityAlive = collider.transform.GetComponentInChildren<global::EntityAlive>();
|
||||
}
|
||||
if (entityAlive != null && entityAlive.IsAlive())
|
||||
{
|
||||
if (entityAlive.Buffs.HasBuff("FuriousRamsayResistShock"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
namespace Harmony.EntityPatches
|
||||
{
|
||||
internal class EntityPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Entity))]
|
||||
[HarmonyPatch("OnEntityActivated")]
|
||||
public class OnEntityActivatedPatch
|
||||
{
|
||||
private static bool Prefix(Entity __instance, ref bool __result, int _indexInBlockActivationCommands, Vector3i _tePos, global::EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnEntityActivated _indexInBlockActivationCommands: " + _indexInBlockActivationCommands);
|
||||
if (_indexInBlockActivationCommands == 0)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnEntityActivated 1");
|
||||
if (__instance is EntitySupplyCrate)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnEntityActivated 1");
|
||||
EntitySupplyCrate entitySupplyCrate = (EntitySupplyCrate)__instance;
|
||||
if (entitySupplyCrate != null)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnEntityActivated 1");
|
||||
if (!entitySupplyCrate.onGround)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnEntityActivated 1");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(global::Entity))]
|
||||
[HarmonyPatch("HasAnyTags")]
|
||||
public class HasAnyTagsPatch
|
||||
{
|
||||
private static bool Prefix(global::Entity __instance, ref bool __result, FastTags<TagGroup.Global> tags)
|
||||
{
|
||||
__result = __instance.EntityTags.Test_AnySet(tags);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(global::Entity))]
|
||||
[HarmonyPatch("HasAllTags")]
|
||||
public class HasAllTagsPatch
|
||||
{
|
||||
private static bool Prefix(global::Entity __instance, ref bool __result, FastTags<TagGroup.Global> tags)
|
||||
{
|
||||
__result = __instance.EntityTags.Test_AllSet(tags);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Entity))]
|
||||
[HarmonyPatch("EntityTags")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class EntityTagsPatch
|
||||
{
|
||||
public static void Postfix(Entity __instance, ref FastTags<TagGroup.Global> __result, ref FastTags<TagGroup.Global> ___cachedTags)
|
||||
{
|
||||
if (__instance is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX entity = (EntityZombieSDX)__instance;
|
||||
__result = FastTags<TagGroup.Global>.Parse(___cachedTags.ToString() + entity.otherTags);
|
||||
//Log.Out("====================================== TAGS ======================================");
|
||||
//Log.Out(__result.ToString());
|
||||
}
|
||||
else if (__instance is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth entity = (EntityNPCRebirth)__instance;
|
||||
__result = FastTags<TagGroup.Global>.Parse(___cachedTags.ToString() + entity.otherTags);
|
||||
}
|
||||
/*else if (__instance is EntityMeleeCyborgRebirth)
|
||||
{
|
||||
EntityMeleeCyborgRebirth entity = (EntityMeleeCyborgRebirth)__instance;
|
||||
__result = FastTags<TagGroup.Global>.Parse(___cachedTags.ToString() + entity.otherTags);
|
||||
}
|
||||
else if (__instance is EntityMeleeRangedBanditSDX)
|
||||
{
|
||||
EntityMeleeRangedBanditSDX entity = (EntityMeleeRangedBanditSDX)__instance;
|
||||
__result = FastTags<TagGroup.Global>.Parse(___cachedTags.ToString() + entity.otherTags);
|
||||
}
|
||||
else if (__instance is EntityMeleeWerewolfSDX)
|
||||
{
|
||||
EntityMeleeWerewolfSDX entity = (EntityMeleeWerewolfSDX)__instance;
|
||||
__result = FastTags<TagGroup.Global>.Parse(___cachedTags.ToString() + entity.otherTags);
|
||||
}*/
|
||||
else
|
||||
{
|
||||
__result = ___cachedTags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(global::Entity))]
|
||||
[HarmonyPatch("OnPushEntity")]
|
||||
public class OnPushEntityPatch
|
||||
{
|
||||
private static bool Prefix(global::Entity __instance, Entity _entity)
|
||||
{
|
||||
if (__instance is EntityAnimalChickenRebirth)
|
||||
{
|
||||
//Log.Out("EntityPatches-OnPushEntity START");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
using System.Collections.Generic;
|
||||
using Twitch;
|
||||
|
||||
namespace Harmony.EntityBuffsPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityBuffs))]
|
||||
[HarmonyPatch("OnDeath")]
|
||||
public class OnDeathPatch
|
||||
{
|
||||
public static bool Prefix(EntityBuffs __instance, global::EntityAlive _entityThatKilledMe, bool _blockKilledMe, FastTags<TagGroup.Global> _damageTypeTags,
|
||||
FastTags<TagGroup.Global> ___physicalDamageTypes
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath START, parent: " + __instance.parent.EntityName);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath __instance.ActiveBuffs.Count: " + __instance.ActiveBuffs.Count);
|
||||
|
||||
if (_entityThatKilledMe != null)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 1");
|
||||
if (_entityThatKilledMe.entityId == __instance.parent.entityId)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 2");
|
||||
__instance.parent.FireEvent(MinEventTypes.onSelfKilledSelf, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 3");
|
||||
__instance.parent.MinEventContext.Other = _entityThatKilledMe;
|
||||
__instance.parent.FireEvent(MinEventTypes.onOtherKilledSelf, true);
|
||||
}
|
||||
}
|
||||
else if (_blockKilledMe)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 4");
|
||||
__instance.parent.FireEvent(MinEventTypes.onBlockKilledSelf, true);
|
||||
}
|
||||
__instance.parent.FireEvent(MinEventTypes.onSelfDied, true);
|
||||
List<int> list = new List<int>();
|
||||
|
||||
for (int i = 0; i < __instance.ActiveBuffs.Count; i++)
|
||||
{
|
||||
BuffValue buffValue = __instance.ActiveBuffs[i];
|
||||
if (buffValue != null && buffValue.BuffClass != null)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 5");
|
||||
if (buffValue.BuffClass.RemoveOnDeath && !buffValue.Paused)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 6");
|
||||
buffValue.Remove = true;
|
||||
}
|
||||
//Log.Out("EntityBuffsPatches-OnDeath buffValue.InstigatorId: " + buffValue.InstigatorId);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath buffValue.BuffName: " + buffValue.BuffName);
|
||||
if (buffValue.BuffClass.DamageType != EnumDamageTypes.None && !buffValue.Invalid && buffValue.Started && buffValue.InstigatorId != -1 && buffValue.InstigatorId != __instance.parent.entityId && (!(_entityThatKilledMe != null) || buffValue.InstigatorId != _entityThatKilledMe.entityId) && !list.Contains(buffValue.InstigatorId))
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 7");
|
||||
if (__instance.parent is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 8");
|
||||
global::EntityAlive killer;
|
||||
if (_entityThatKilledMe != null)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 9");
|
||||
killer = _entityThatKilledMe;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 10");
|
||||
killer = (GameManager.Instance.World.GetEntity(buffValue.InstigatorId) as global::EntityAlive);
|
||||
}
|
||||
if (buffValue.BuffClass.DamageType == EnumDamageTypes.BloodLoss || buffValue.BuffClass.DamageType == EnumDamageTypes.Electrical || buffValue.BuffClass.DamageType == EnumDamageTypes.Radiation || buffValue.BuffClass.DamageType == EnumDamageTypes.Heat || buffValue.BuffClass.DamageType == EnumDamageTypes.Cold)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 11");
|
||||
TwitchManager.Current.CheckKiller(__instance.parent as EntityPlayer, killer, __instance.parent.GetBlockPosition());
|
||||
}
|
||||
}
|
||||
EntityPlayerLocal entityPlayerLocal = GameManager.Instance.World.GetEntity(buffValue.InstigatorId) as EntityPlayerLocal;
|
||||
if (!(entityPlayerLocal == null) && entityPlayerLocal.Spawned)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 12");
|
||||
if (!_damageTypeTags.Test_AnySet(___physicalDamageTypes))
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 13");
|
||||
if (__instance.parent.Buffs.GetCustomVar("ETrapHit", 0f) == 1f)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 14");
|
||||
float value = EffectManager.GetValue(PassiveEffects.ElectricalTrapXP, entityPlayerLocal.inventory.holdingItemItemValue, 0f, entityPlayerLocal, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false);
|
||||
if (value > 0f)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 15");
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"]++;
|
||||
}
|
||||
// There should be no player experience gained from traps. Eventually, expertise for the Builder
|
||||
//entityPlayerLocal.AddKillXP(__instance.parent, value);
|
||||
__instance.parent.AwardKill(entityPlayerLocal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath 16");
|
||||
//entityPlayerLocal.AddKillXP(__instance.parent, 1f);
|
||||
//__instance.parent.AwardKill(entityPlayerLocal);
|
||||
|
||||
global::EntityAlive killer = (GameManager.Instance.World.GetEntity(buffValue.InstigatorId) as global::EntityAlive);
|
||||
|
||||
if (killer is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath B killer: " + killer.EntityClass.entityClassName);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath B killer: " + killer.EntityClass.entityClassName);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath buffValue.BuffName: " + buffValue.BuffName);
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"]++;
|
||||
}
|
||||
|
||||
string heldItem = "";
|
||||
|
||||
/*if (__instance.parent.MinEventContext.ItemValue != null)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath ItemValue: " + __instance.parent.MinEventContext.ItemValue);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath ItemClass: " + __instance.parent.MinEventContext.ItemValue.ItemClass);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath ItemClass Name: " + __instance.parent.MinEventContext.ItemValue.ItemClass.Name);
|
||||
heldItem = __instance.parent.MinEventContext.ItemValue.ItemClass.GetItemName();
|
||||
//Log.Out("EntityBuffsPatches-OnDeath ItemClass __instance.parent.MinEventContext.ItemValue.ItemClass.GetItemName(): " + __instance.parent.MinEventContext.ItemValue.ItemClass.GetItemName());
|
||||
}*/
|
||||
|
||||
try
|
||||
{
|
||||
if (buffValue.BuffName.ToLower().Contains("furiousramsaybleeddamagelevel"))
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath BLED OUT BUTCHER DEBUFF");
|
||||
|
||||
RebirthUtilities.ProcessDamageXP(heldItem, __instance.parent.MinEventContext.Biome.m_Id, __instance.parent.MinEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head, killer.entityId, __instance.parent.entityId, 1, true, "meleeWpnBladeT3Machete");
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthUtilities.ProcessCheckAchievements(__instance.parent.MinEventContext.Biome.m_Id, killer, __instance.parent);
|
||||
}
|
||||
}
|
||||
else if (buffValue.BuffName.ToLower() == "buffinjurybleeding")
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath BLED OUT buffInjuryBleeding");
|
||||
|
||||
RebirthUtilities.ProcessDamageXP(heldItem, __instance.parent.MinEventContext.Biome.m_Id, __instance.parent.MinEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head, killer.entityId, __instance.parent.entityId, 1, true);
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthUtilities.ProcessCheckAchievements(__instance.parent.MinEventContext.Biome.m_Id, killer, __instance.parent);
|
||||
}
|
||||
}
|
||||
else if (buffValue.BuffName.ToLower() == "buffburningflamingarrow")
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath buffburningflamingarrow");
|
||||
|
||||
RebirthUtilities.ProcessDamageXP(heldItem, __instance.parent.MinEventContext.Biome.m_Id, __instance.parent.MinEventContext.DamageResponse.HitBodyPart == EnumBodyPartHit.Head, killer.entityId, __instance.parent.entityId, 1, true);
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
RebirthUtilities.ProcessCheckAchievements(__instance.parent.MinEventContext.Biome.m_Id, killer, __instance.parent);
|
||||
}
|
||||
}
|
||||
else if (buffValue.BuffName.ToLower().Contains("furiousramsayarrowrainparticle") ||
|
||||
buffValue.BuffName.ToLower().Contains("furiousramsayknifeslashesparticle") ||
|
||||
buffValue.BuffName.ToLower().Contains("furiousramsayaddshockauradamage") ||
|
||||
buffValue.BuffName.ToLower().Contains("furiousramsayrangedbleeddamage")
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-OnDeath furiousramsayarrowrainparticle");
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
// possible bug here - NRE caught here
|
||||
// NullReferenceException: Object reference not set to an instance of an object
|
||||
// at Harmony.EntityBuffsPatches.OnDeathPatch.Prefix(EntityBuffs __instance,
|
||||
// EntityAlive _entityThatKilledMe, System.Boolean _blockKilledMe, FastTags`1[TTagGroup] _damageTypeTags, FastTags`1[TTagGroup]
|
||||
// ___physicalDamageTypes)[0x005f3] in < f0a14dac58264c04bd895edfddfc3b3a >:0
|
||||
// The offset led to this statement being the source of this NRE, possibly the __instance variable == null here
|
||||
RebirthUtilities.ProcessCheckAchievements(__instance.parent.MinEventContext.Biome.m_Id, killer, __instance.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Out($"Caught exception: {ex.Message}");
|
||||
Log.Out($"__instance: {__instance}, killer: {killer}");
|
||||
}
|
||||
|
||||
if (__instance.parent is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX zombie = (EntityZombieSDX)__instance.parent;
|
||||
zombie.entityThatKilledMeID = killer.entityId;
|
||||
entityPlayerLocal.AddKillXP(__instance.parent);
|
||||
|
||||
//Log.Out("EntityBuffsPatches-OnDeath zombie.entityThatKilledMeID: " + zombie.entityThatKilledMeID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(entityPlayerLocal.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
__instance.Update(Time.deltaTime);
|
||||
//Log.Out("EntityBuffsPatches-OnDeath END");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityBuffs))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static bool Prefix(EntityBuffs __instance, float _deltaTime)
|
||||
{
|
||||
int num = __instance.ActiveBuffs.Count;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
BuffValue buffValue = new BuffValue();
|
||||
try
|
||||
{
|
||||
buffValue = __instance.ActiveBuffs[i];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buffValue.Invalid)
|
||||
{
|
||||
__instance.ActiveBuffs.RemoveAt(i);
|
||||
i--;
|
||||
num--;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.parent.MinEventContext.Buff = buffValue;
|
||||
if (__instance.parent.MinEventContext.Other == null)
|
||||
{
|
||||
__instance.parent.MinEventContext.Other = __instance.parent.GetAttackTarget();
|
||||
}
|
||||
if (buffValue.Finished)
|
||||
{
|
||||
__instance.FireEvent(MinEventTypes.onSelfBuffFinish, buffValue.BuffClass, __instance.parent.MinEventContext);
|
||||
buffValue.Remove = true;
|
||||
}
|
||||
if (buffValue.Remove)
|
||||
{
|
||||
if (buffValue.BuffClass != null)
|
||||
{
|
||||
__instance.FireEvent(MinEventTypes.onSelfBuffRemove, buffValue.BuffClass, __instance.parent.MinEventContext);
|
||||
if (!buffValue.BuffClass.Hidden)
|
||||
{
|
||||
__instance.parent.Stats.EntityBuffRemoved(buffValue);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
__instance.ActiveBuffs.RemoveAt(i);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Log.Out("EntityBuffsPatches-Update CANNOT REMOVE BUFF entityClassName: " + __instance.parent.EntityClass.entityClassName);
|
||||
}
|
||||
i--;
|
||||
num--;
|
||||
}
|
||||
else if (!buffValue.Paused && !__instance.parent.bDead)
|
||||
{
|
||||
if (!buffValue.Started)
|
||||
{
|
||||
__instance.FireEvent(MinEventTypes.onSelfBuffStart, buffValue.BuffClass, __instance.parent.MinEventContext);
|
||||
buffValue.Started = true;
|
||||
if (!buffValue.BuffClass.Hidden)
|
||||
{
|
||||
__instance.parent.Stats.EntityBuffAdded(buffValue);
|
||||
}
|
||||
__instance.parent.BuffAdded(buffValue);
|
||||
}
|
||||
BuffManager.UpdateBuffTimers(buffValue, _deltaTime);
|
||||
if (buffValue.Update)
|
||||
{
|
||||
try
|
||||
{
|
||||
__instance.FireEvent(MinEventTypes.onSelfBuffUpdate, buffValue.BuffClass, __instance.parent.MinEventContext);
|
||||
buffValue.Update = false;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Harmony.EntityDronePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityDrone), "isAlly")]
|
||||
public class isAllyPatch
|
||||
{
|
||||
public static bool Prefix(EntityDrone __instance, ref bool __result, EntityAlive _target)
|
||||
{
|
||||
if (_target == null)
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-isAlly target == null");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
namespace Harmony.EntityFactoryPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityFactory))]
|
||||
[HarmonyPatch("GetEntityType")]
|
||||
public class GetEntityTypePatch
|
||||
{
|
||||
public static bool Prefix(EntityFactory __instance, ref System.Type __result, string _className)
|
||||
{
|
||||
switch (_className)
|
||||
{
|
||||
case "EntityAnimal":
|
||||
__result = typeof(EntityAnimal);
|
||||
return false;
|
||||
case "EntityAnimalRabbit":
|
||||
__result = typeof(EntityAnimalRabbit);
|
||||
return false;
|
||||
case "EntityAnimalStag":
|
||||
__result = typeof(EntityAnimalStag);
|
||||
return false;
|
||||
case "EntityBandit":
|
||||
__result = typeof(EntityBandit);
|
||||
return false;
|
||||
case "EntityEnemyAnimal":
|
||||
__result = typeof(EntityEnemyAnimal);
|
||||
return false;
|
||||
case "EntityHuman":
|
||||
__result = typeof(EntityHuman);
|
||||
return false;
|
||||
case "EntityNPC":
|
||||
__result = typeof(EntityNPC);
|
||||
return false;
|
||||
case "EntityPlayer":
|
||||
__result = typeof(EntityPlayer);
|
||||
return false;
|
||||
case "EntityZombie":
|
||||
__result = typeof(EntityZombie);
|
||||
return false;
|
||||
case "EntityAlive":
|
||||
__result = typeof(EntityAlive);
|
||||
return false;
|
||||
default:
|
||||
Log.Warning("GetEntityType slow lookup for {0}", (object)_className);
|
||||
__result = System.Type.GetType(_className);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,873 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Harmony.EntityGroupsPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityGroups))]
|
||||
[HarmonyPatch("IsEnemyGroup")]
|
||||
public class IsEnemyGroupPatch
|
||||
{
|
||||
public static bool Prefix(EntityGroups __instance, ref bool __result, string _sEntityGroupName)
|
||||
{
|
||||
List<SEntityClassAndProb> list = EntityGroups.list[_sEntityGroupName];
|
||||
try
|
||||
{
|
||||
__result = list != null && list.Count >= 1 && EntityClass.list[list[0].entityClassId].bIsEnemyEntity;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Out("=====================================================================================");
|
||||
Log.Out("EntityGroupsPatches-IsEnemyGroup _sEntityGroupName: " + _sEntityGroupName);
|
||||
Log.Out("=====================================================================================");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityGroups))]
|
||||
[HarmonyPatch("GetRandomFromGroupList")]
|
||||
public class GetRandomFromGroupListPatch
|
||||
{
|
||||
public static bool Prefix(EntityGroups __instance, ref int __result, List<SEntityClassAndProb> grpList, GameRandom random)
|
||||
{
|
||||
float randomFloat = random.RandomFloat;
|
||||
float num = 0f;
|
||||
for (int i = 0; i < grpList.Count; i++)
|
||||
{
|
||||
SEntityClassAndProb sentityClassAndProb = grpList[i];
|
||||
|
||||
num += sentityClassAndProb.prob;
|
||||
if (randomFloat <= num && sentityClassAndProb.prob > 0f)
|
||||
{
|
||||
if (sentityClassAndProb.entityClassId != 0)
|
||||
{
|
||||
string optionDemos = RebirthVariables.customDemos;
|
||||
string optionKamikaze = RebirthVariables.customKamikaze;
|
||||
string optionSeekers = RebirthVariables.customSeekers;
|
||||
bool isHordeNight = RebirthUtilities.IsHordeNight();
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroupList entityClassId: " + sentityClassAndProb.entityClassId);
|
||||
|
||||
if (EntityClass.list[sentityClassAndProb.entityClassId].entityClassName.ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (isHordeNight && optionDemos == "nothordenight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = sentityClassAndProb.entityClassId;
|
||||
return false;
|
||||
}
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroupList B entityClassName: " + EntityClass.list[sentityClassAndProb.entityClassId].entityClassName);
|
||||
}
|
||||
else if (EntityClass.list[sentityClassAndProb.entityClassId].entityClassName.ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (isHordeNight && optionDemos == "nothordenight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionKamikaze == "nothordenightpoi")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.list[sentityClassAndProb.entityClassId].entityClassName.ToLower().Contains("furiousramsayseeker"))
|
||||
{
|
||||
if (isHordeNight && optionSeekers == "nothordenight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionSeekers == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroupList A entityClassName: " + EntityClass.list[sentityClassAndProb.entityClassId].entityClassName);
|
||||
__result = sentityClassAndProb.entityClassId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = sentityClassAndProb.entityClassId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
__result = -1;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityGroups))]
|
||||
[HarmonyPatch("GetRandomFromGroup")]
|
||||
public class GetRandomFromGroupPatch
|
||||
{
|
||||
public static bool Prefix(EntityGroups __instance, ref int __result, string _sEntityGroupName, ref int lastClassId, GameRandom random = null)
|
||||
{
|
||||
MethodBase caller = new StackTrace().GetFrame(4).GetMethod();
|
||||
string callerMethodName = caller.Name;
|
||||
string callerClassName = caller.ReflectedType.Name;
|
||||
string calledMethodName = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
MethodBase caller2 = new StackTrace().GetFrame(3).GetMethod();
|
||||
string callerMethodName2 = caller2.Name;
|
||||
string callerClassName2 = caller2.ReflectedType.Name;
|
||||
|
||||
var reflectedType = caller2.ReflectedType;
|
||||
string callerClassName3 = "";
|
||||
|
||||
if (reflectedType.Name.Contains(">d__"))
|
||||
{
|
||||
// Get the parent type (likely the actual class containing the method)
|
||||
var declaringType = reflectedType.DeclaringType;
|
||||
callerClassName3 = declaringType.Name;
|
||||
}
|
||||
|
||||
string optionDemos = RebirthVariables.customDemos;
|
||||
string optionKamikaze = RebirthVariables.customKamikaze;
|
||||
string optionSeekers = RebirthVariables.customSeekers;
|
||||
string optionTornado = RebirthVariables.customTornados;
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup callerClassName: " + callerClassName);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup callerMethodName: " + callerMethodName);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup calledMethodName: " + calledMethodName);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup _sEntityGroupName: " + _sEntityGroupName);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup callerClassName2: " + callerClassName2);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup callerMethodName2: " + callerMethodName2);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup callerClassName3: " + callerClassName3);
|
||||
|
||||
//Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
|
||||
string _name = _sEntityGroupName.ToLower();
|
||||
|
||||
bool isSleeper = (callerClassName.ToLower().Contains("sleepervolume") || callerClassName.ToLower().Contains("updatespawnpatch") || callerMethodName.ToLower().Contains("sleepervolume") || callerMethodName.ToLower().Contains("updatespawnpatch") ||
|
||||
callerClassName2.ToLower().Contains("sleepervolume") || callerClassName2.ToLower().Contains("updatespawnpatch") || callerMethodName2.ToLower().Contains("sleepervolume") || callerMethodName2.ToLower().Contains("updatespawnpatch"));
|
||||
|
||||
|
||||
if (_name.Contains("animal") ||
|
||||
_name.Contains("vulture") ||
|
||||
_name.Contains("dog") ||
|
||||
_name.Contains("bear") ||
|
||||
_name.Contains("wolf") ||
|
||||
_name.Contains("snake") ||
|
||||
_name.Contains("boar") ||
|
||||
_name.Contains("grace") ||
|
||||
_name.Contains("wildgame") ||
|
||||
_name.Contains("zombiedemolition")
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup NOT VALID, _sEntityGroupName: " + _sEntityGroupName);
|
||||
|
||||
if (isSleeper && (_name.Contains("snake") || _name.Contains("boar") || _name.Contains("chicken")))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int gameStage = 0;
|
||||
float multiplierGamestage = float.Parse(RebirthVariables.customGamestageMultiplier) / 100;
|
||||
|
||||
if (callerClassName.ToLower().Contains("spawnmanagerbiomes") || callerMethodName.ToLower().Contains("spawnmanagerbiomes") ||
|
||||
callerClassName2.ToLower().Contains("spawnmanagerbiomes") || callerMethodName2.ToLower().Contains("spawnmanagerbiomes")
|
||||
)
|
||||
{
|
||||
gameStage = (int)(RebirthVariables.biomeGameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BIOME gameStage: " + gameStage);
|
||||
|
||||
__result = 0;
|
||||
|
||||
//System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
//watch.Start();
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.biomeGroups);
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup key.min: " + key.min);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup key.max: " + key.max);
|
||||
|
||||
if (RebirthUtilities.biomeGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BIOME Entity: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
int foundAt = -1;
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
if (!(optionTornado == "biomesonly" ||
|
||||
optionTornado == "always")
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BIOME SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
foundAt = i;
|
||||
break;
|
||||
}
|
||||
|
||||
//watch.Stop();
|
||||
////Log.Out("EntityGroupsPatches-GetRandomFromGroup time to process: " + watch.ElapsedMilliseconds + " ms");
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup foundAt: " + foundAt);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (callerClassName.ToLower().Contains("baseaction") && callerClassName2.ToLower().Contains("actionbasespawn")
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
gameStage = RebirthUtilities.GetIntegerFromString(_sEntityGroupName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Out("EntityGroupsPatches-GetRandomFromGroup BASEACTION CANNOT GET GAMESTAGE _sEntityGroupName: " + _sEntityGroupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
gameStage = (int)(gameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BASEACTION multiplierGamestage: " + multiplierGamestage);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BASEACTION gameStage: " + gameStage);
|
||||
|
||||
__result = 0;
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.generalGroups);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.generalGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BASEACTION entities.Count: " + entities.Count);
|
||||
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup Entity: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("zombiestevecrawler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClass(entities[randomValue]).Tags.Test_AllSet(FastTags<TagGroup.Global>.Parse("animal")))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup IS ANIMAL, SKIPPING");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BASEACTION SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (callerClassName3.ToLower() == "questactionspawngsenemy"
|
||||
)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
//gameStage = RebirthUtilities.GetIntegerFromString(_sEntityGroupName);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup QUESTACTION CANNOT GET GAMESTAGE _sEntityGroupName: " + _sEntityGroupName);
|
||||
//return true;
|
||||
//}
|
||||
|
||||
gameStage = (int)(RebirthVariables.gameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup QUESTACTION multiplierGamestage: " + multiplierGamestage);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup QUESTACTION gameStage: " + gameStage);
|
||||
|
||||
__result = 0;
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.generalGroups);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.generalGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup QUESTACTION entities.Count: " + entities.Count);
|
||||
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup Entity: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("zombiestevecrawler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClass(entities[randomValue]).Tags.Test_AllSet(FastTags<TagGroup.Global>.Parse("animal")))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup IS ANIMAL, SKIPPING");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup QUESTACTION SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (callerClassName.ToLower().Contains("aiwanderinghordespawner") || callerMethodName.ToLower().Contains("aiwanderinghordespawner") ||
|
||||
callerClassName2.ToLower().Contains("aiwanderinghordespawner") || callerMethodName2.ToLower().Contains("aiwanderinghordespawner")
|
||||
)
|
||||
{
|
||||
gameStage = (int)(RebirthVariables.wanderingHordeGameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup WANDERING RebirthVariables.wanderingHordeGameStage: " + RebirthVariables.wanderingHordeGameStage);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup WANDERING multiplierGamestage: " + multiplierGamestage);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup WANDERING gameStage: " + gameStage);
|
||||
|
||||
__result = 0;
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.generalGroups);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.generalGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup WANDERING entities.Count: " + entities.Count);
|
||||
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup Entity: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("zombiestevecrawler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClass(entities[randomValue]).Tags.Test_AllSet(FastTags<TagGroup.Global>.Parse("animal")))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup IS ANIMAL, SKIPPING");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup WANDERING HORDE SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (callerClassName.ToLower().Contains("aidirectorbloodmoonparty") || callerMethodName.ToLower().Contains("aidirectorbloodmoonparty") ||
|
||||
callerClassName2.ToLower().Contains("aidirectorbloodmoonparty") || callerMethodName2.ToLower().Contains("aidirectorbloodmoonparty")
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BLOOD MOON: " + _sEntityGroupName);
|
||||
|
||||
if (_sEntityGroupName.ToLower().Contains("feralhordestagegs"))
|
||||
{
|
||||
try
|
||||
{
|
||||
gameStage = int.Parse(_sEntityGroupName.Replace("feralHordeStageGS", ""));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Out("EntityGroupsPatches-GetRandomFromGroup CANNOT GET GAMESTAGE _sEntityGroupName: " + _sEntityGroupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = 0;
|
||||
|
||||
gameStage = (int)(gameStage * multiplierGamestage);
|
||||
|
||||
(int min, int max) key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.bloodMoonGroups);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup B key.min: " + key.min);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup B key.max: " + key.max);
|
||||
|
||||
bool isHordeNight = RebirthUtilities.IsHordeNight();
|
||||
|
||||
if (RebirthUtilities.bloodMoonGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup B entities.Count: " + entities.Count);
|
||||
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[" + i + "]: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("zombiestevecrawler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "ttnothordenight" ||
|
||||
optionKamikaze == "ttnothordenightpoi" ||
|
||||
optionKamikaze == "never"
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsayseeker"))
|
||||
{
|
||||
if (optionSeekers == "ttnothordenight" ||
|
||||
optionSeekers == "never"
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
if (!(optionTornado == "hordenightonly" ||
|
||||
optionTornado == "always"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup BLOOD MOON SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (callerClassName.ToLower().Contains("aihordespawner") || callerMethodName.ToLower().Contains("aihordespawner") ||
|
||||
callerClassName2.ToLower().Contains("aihordespawner") || callerMethodName2.ToLower().Contains("aihordespawner")
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup _sEntityGroupName:" + _sEntityGroupName);
|
||||
|
||||
if (_sEntityGroupName.ToLower().Contains("scouthordestagegs"))
|
||||
{
|
||||
try
|
||||
{
|
||||
gameStage = int.Parse(_sEntityGroupName.Replace("scoutHordeStageGS", ""));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup CANNOT GET GAMESTAGE _sEntityGroupName: " + _sEntityGroupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = 0;
|
||||
gameStage = (int)(gameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SCREAMER gameStage: " + gameStage);
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.generalGroups);
|
||||
}
|
||||
|
||||
bool isHordeNight = RebirthUtilities.IsHordeNight();
|
||||
|
||||
if (RebirthUtilities.generalGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[" + i + "]: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("zombiestevecrawler"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SCOUT SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (callerClassName.ToLower().Contains("sleepervolume") || callerClassName.ToLower().Contains("updatespawnpatch") || callerMethodName.ToLower().Contains("sleepervolume") || callerMethodName.ToLower().Contains("updatespawnpatch") ||
|
||||
callerClassName2.ToLower().Contains("sleepervolume") || callerClassName2.ToLower().Contains("updatespawnpatch") || callerMethodName2.ToLower().Contains("sleepervolume") || callerMethodName2.ToLower().Contains("updatespawnpatch")
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup IS FROM SLEEPERVOLUME");
|
||||
|
||||
gameStage = RebirthVariables.gameStage;
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup gameStage BEFORE MULTIPLIER: " + gameStage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup IS VALID, _sEntityGroupName: " + _sEntityGroupName);
|
||||
|
||||
__result = 0;
|
||||
gameStage = (int)(gameStage * multiplierGamestage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup gameStage AFTER MULTIPLIER: " + gameStage);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SLEEPER gameStage: " + gameStage);
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SLEEPER RebirthVariables.prefabDifficulty: " + RebirthVariables.prefabDifficulty);
|
||||
|
||||
(int min, int max) key;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
key = (1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = RebirthUtilities.GetGamestageFloorAndCeiling(gameStage, RebirthUtilities.generalGroups);
|
||||
}
|
||||
|
||||
bool isHordeNight = RebirthUtilities.IsHordeNight();
|
||||
|
||||
if (RebirthUtilities.generalGroups.TryGetValue(key, out List<int> entities))
|
||||
{
|
||||
//for (int i = 0; i < entities.Count; i++)
|
||||
//{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[" + i + "]: " + EntityClass.GetEntityClassName(entities[i]));
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 250; i++)
|
||||
{
|
||||
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
||||
|
||||
if (entities[randomValue] == lastClassId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup lastClassId: " + lastClassId);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup entities[randomValue]: " + entities[randomValue]);
|
||||
|
||||
if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower().Contains("furiousramsaykamikaze"))
|
||||
{
|
||||
if (isHordeNight && optionDemos == "nothordenight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionKamikaze == "notpoi")
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SKIPPED KAMIKAZE");
|
||||
continue;
|
||||
}
|
||||
else if (optionKamikaze == "nothordenightpoi")
|
||||
{
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SKIPPED KAMIKAZE");
|
||||
continue;
|
||||
}
|
||||
else if (optionKamikaze == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "zombiedemolition")
|
||||
{
|
||||
if (isHordeNight && optionDemos == "nothordenight")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (optionDemos == "never")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (EntityClass.GetEntityClassName(entities[randomValue]).ToLower() == "furiousramsaywindtornado")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup randomValue: " + randomValue);
|
||||
//Log.Out("EntityGroupsPatches-GetRandomFromGroup SLEEPER SPAWNED GetEntityClassName: " + EntityClass.GetEntityClassName(entities[randomValue]));
|
||||
|
||||
lastClassId = entities[randomValue];
|
||||
__result = entities[randomValue];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
namespace Harmony.EntityItemPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityItem))]
|
||||
[HarmonyPatch("createMesh")]
|
||||
public class createMeshPatch
|
||||
{
|
||||
public static bool Prefix(EntityItem __instance)
|
||||
{
|
||||
if (__instance.itemStack.itemValue.type == 0 || __instance.itemClass == null)
|
||||
{
|
||||
Log.Error(string.Format("Could not create item with id {0}", (object)__instance.itemStack.itemValue.type));
|
||||
__instance.SetDead();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((UnityEngine.Object)__instance.meshGameObject != (UnityEngine.Object)null && __instance.lastCachedItemStack.itemValue.type != 0)
|
||||
{
|
||||
UnityEngine.Object.Destroy((UnityEngine.Object)__instance.meshGameObject);
|
||||
__instance.meshGameObject = (GameObject)null;
|
||||
}
|
||||
__instance.itemTransform = (Transform)null;
|
||||
float num = 0.0f;
|
||||
Vector3 zero = Vector3.zero;
|
||||
if (__instance.itemClass.IsBlock())
|
||||
{
|
||||
BlockValue blockValue = __instance.itemStack.itemValue.ToBlockValue();
|
||||
if ((UnityEngine.Object)__instance.itemTransform == (UnityEngine.Object)null)
|
||||
__instance.itemTransform = __instance.itemClass.CloneModel(__instance.meshGameObject, __instance.world, blockValue, (Vector3[])null, Vector3.zero, __instance.transform, BlockShape.MeshPurpose.Drop);
|
||||
Block block = blockValue.Block;
|
||||
if (block.Properties.Values.ContainsKey("DropScale"))
|
||||
num = StringParsers.ParseFloat(block.Properties.Values["DropScale"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((UnityEngine.Object)__instance.itemTransform == (UnityEngine.Object)null)
|
||||
{
|
||||
__instance.itemTransform = __instance.itemClass.CloneModel(__instance.world, __instance.itemStack.itemValue, Vector3.zero, __instance.transform, BlockShape.MeshPurpose.Drop);
|
||||
}
|
||||
|
||||
bool isArrow = __instance.itemStack.itemValue.ItemClass.GetItemName().ToLower().Contains("ammoarrow") ||
|
||||
__instance.itemStack.itemValue.ItemClass.GetItemName().ToLower().Contains("ammocrossbowbolt");
|
||||
|
||||
if (isArrow)
|
||||
{
|
||||
//Log.Out("EntityItemPatches-createMesh __instance.itemStack.count: " + __instance.itemStack.count);
|
||||
//Log.Out("EntityItemPatches-createMesh __instance.itemStack.itemValue: " + __instance.itemStack.itemValue.ItemClass.GetItemName());
|
||||
//Log.Out("EntityItemPatches-createMesh OwnerId: " + __instance.OwnerId);
|
||||
if (__instance.OwnerId != -1)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer)__instance.world.GetEntity(__instance.OwnerId);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
//Log.Out("EntityItemPatches-createMesh player != null");
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageAddPlayerItem>().Setup(__instance.itemStack.itemValue.ItemClass.GetItemName(), player.entityId, 1, "item_pickup"), false, player.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.addToPlayerBag(__instance.itemStack.itemValue, player, __instance.itemStack.count, "item_pickup");
|
||||
}
|
||||
__instance.SetDead();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.itemClass.Properties.Values.ContainsKey("DropScale"))
|
||||
num = StringParsers.ParseFloat(__instance.itemClass.Properties.Values["DropScale"]);
|
||||
}
|
||||
if ((double)num != 0.0)
|
||||
__instance.itemTransform.localScale = new Vector3(num, num, num);
|
||||
__instance.itemTransform.localEulerAngles = __instance.itemClass.GetDroppedCorrectionRotation();
|
||||
__instance.itemTransform.localPosition = zero;
|
||||
bool flag = true;
|
||||
Collider[] componentsInChildren = __instance.itemTransform.GetComponentsInChildren<Collider>();
|
||||
for (int index = 0; componentsInChildren != null && index < componentsInChildren.Length; ++index)
|
||||
{
|
||||
Collider collider = componentsInChildren[index];
|
||||
Rigidbody component = collider.gameObject.GetComponent<Rigidbody>();
|
||||
if ((bool)(UnityEngine.Object)component && component.isKinematic || collider is MeshCollider && !((MeshCollider)collider).convex)
|
||||
{
|
||||
collider.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
collider.gameObject.layer = 13;
|
||||
collider.enabled = true;
|
||||
flag = false;
|
||||
collider.gameObject.AddMissingComponent<RootTransformRefEntity>();
|
||||
}
|
||||
}
|
||||
__instance.transform.GetComponent<Collider>().enabled = flag;
|
||||
__instance.meshGameObject = __instance.itemTransform.gameObject;
|
||||
__instance.meshGameObject.SetActive(true);
|
||||
if (__instance.itemWorldData != null)
|
||||
__instance.itemClass.OnMeshCreated(__instance.itemWorldData);
|
||||
__instance.bMeshCreated = true;
|
||||
__instance.meshRenderers = __instance.itemTransform.GetComponentsInChildren<Renderer>(true);
|
||||
__instance.VisiblityCheck(0.0f, false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,1424 @@
|
||||
using GamePath;
|
||||
|
||||
namespace Harmony.EntityMoveHelperPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("StartJump")]
|
||||
public class StartJumpPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance, bool calcYaw, float distance = 0.0f, float heightDiff = 0.0f)
|
||||
{
|
||||
//if (__instance.entity.Jumping || !__instance.entity.onGround && !__instance.entity.IsInElevator() || __instance.entity.Electrocuted)
|
||||
if (__instance.entity.Jumping || __instance.entity.Climbing || __instance.entity.Electrocuted)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.Jumping: " + __instance.entity.Jumping);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.onGround: " + __instance.entity.onGround);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.fallDistance: " + __instance.entity.fallDistance);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.IsInElevator(): " + __instance.entity.IsInElevator());
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.Climbing: " + __instance.entity.Climbing);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.Electrocuted: " + __instance.entity.Electrocuted);
|
||||
return false;
|
||||
}
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.entity.position: " + __instance.entity.position);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.moveToPos: " + __instance.moveToPos);
|
||||
__instance.JumpToPos = __instance.moveToPos;
|
||||
if (__instance.entity.GetAttackTarget() != null && __instance.entity.CanSee(__instance.entity.GetAttackTarget()))
|
||||
{
|
||||
__instance.JumpToPos = __instance.entity.GetAttackTarget().position;
|
||||
}
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.JumpToPos: " + __instance.JumpToPos);
|
||||
__instance.jumpYaw = calcYaw ? Mathf.Atan2(__instance.JumpToPos.x - __instance.entity.position.x, __instance.JumpToPos.z - __instance.entity.position.z) * 57.29578f : __instance.entity.rotation.y;
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump __instance.jumpYaw: " + __instance.jumpYaw);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump distance: " + distance);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump heightDiff: " + heightDiff);
|
||||
|
||||
__instance.entity.Jumping = true;
|
||||
__instance.entity.SetJumpDistance(distance, heightDiff);
|
||||
//Log.Out("EntityMoveHelperPatches-StartJump CLEAR BLOCKED");
|
||||
__instance.IsBlocked = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("CheckBlocked")]
|
||||
public class CheckBlockedPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance, Vector3 pos, Vector3 endPos, int baseY)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlocked START");
|
||||
__instance.IsBlocked = false;
|
||||
Vector3 vector3_1 = pos;
|
||||
endPos.y -= 0.01f;
|
||||
Vector3 vector3_2 = endPos - vector3_1;
|
||||
float num1 = vector3_2.magnitude + 1f / 1000f;
|
||||
Vector3 direction = vector3_2 * (1f / num1);
|
||||
Ray ray = new Ray(vector3_1 - direction * 0.375f, direction);
|
||||
if ((double)num1 > (double)__instance.ccRadius + 0.34999999403953552)
|
||||
{
|
||||
num1 = __instance.ccRadius + 0.35f;
|
||||
if (__instance.isTempMove)
|
||||
num1 += 0.4f;
|
||||
}
|
||||
if (baseY >= 2)
|
||||
num1 += 0.21f;
|
||||
if (!Voxel.Raycast(__instance.entity.world, ray, (float)((double)num1 - 0.125 + 0.375), 1082195968, 128, 0.125f))
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlocked 1");
|
||||
return false;
|
||||
}
|
||||
if (baseY == 0 && (double)Voxel.phyxRaycastHit.normal.y > 0.64300000667572021)
|
||||
{
|
||||
Vector2 vector2_1;
|
||||
vector2_1.x = Voxel.phyxRaycastHit.normal.x;
|
||||
vector2_1.y = Voxel.phyxRaycastHit.normal.z;
|
||||
vector2_1.Normalize();
|
||||
Vector2 vector2_2;
|
||||
vector2_2.x = direction.x;
|
||||
vector2_2.y = direction.z;
|
||||
vector2_2.Normalize();
|
||||
if ((double)vector2_2.x * (double)vector2_1.x + (double)vector2_2.y * (double)vector2_1.y < -0.699999988079071)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlocked 2");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Voxel.voxelRayHitInfo.hit.blockValue.Block is BlockDamage)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlocked 3");
|
||||
return false;
|
||||
}
|
||||
__instance.HitInfo = Voxel.voxelRayHitInfo.Clone();
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlocked SET BLOCKED");
|
||||
__instance.IsBlocked = true;
|
||||
__instance.blockedHeight = __instance.HitInfo.hit.pos.y - __instance.entity.position.y;
|
||||
Vector3 vector3_3 = pos - __instance.HitInfo.hit.pos;
|
||||
float sqrMagnitude = vector3_3.sqrMagnitude;
|
||||
if ((double)sqrMagnitude >= (double)__instance.blockedDistSq)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.blockedDistSq = sqrMagnitude;
|
||||
float num2 = 1f / Mathf.Sqrt(sqrMagnitude);
|
||||
float num3 = __instance.ccRadius + 0.4f;
|
||||
__instance.tempMoveToPos = vector3_3 * (num2 * num3) + __instance.HitInfo.hit.pos;
|
||||
__instance.tempMoveToPos.y = Mathf.MoveTowards(__instance.tempMoveToPos.y, __instance.moveToPos.y, 1f);
|
||||
__instance.isTempMove = true;
|
||||
__instance.obstacleCheckTickDelay = 12;
|
||||
__instance.ResetStuckCheck();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("CheckEntityBlocked")]
|
||||
public class CheckEntityBlockedPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance, Vector3 pos, Vector3 endPos)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckEntityBlocked START");
|
||||
Vector3 direction = endPos - pos;
|
||||
pos.y += 0.7f;
|
||||
RaycastHit hitInfo;
|
||||
if (!Physics.SphereCast(pos - Origin.position, 0.15f, direction, out hitInfo, 0.8f, 524288))
|
||||
return false;
|
||||
Transform transform1 = hitInfo.transform;
|
||||
if (!(bool)(UnityEngine.Object)transform1)
|
||||
return false;
|
||||
Transform transform2 = transform1.parent.Find("GameObject");
|
||||
if (!(bool)(UnityEngine.Object)transform2)
|
||||
return false;
|
||||
EntityAlive component = transform2.GetComponent<EntityAlive>();
|
||||
if (!(bool)(UnityEngine.Object)component || !((UnityEngine.Object)component != (UnityEngine.Object)__instance.entity))
|
||||
return false;
|
||||
float sqrMagnitude = (__instance.entity.position - component.position).sqrMagnitude;
|
||||
float num = (float)((double)__instance.ccRadius + (double)component.m_characterController.GetRadius() + 0.15999999642372131 + 0.25);
|
||||
if ((double)sqrMagnitude >= (double)num * (double)num)
|
||||
return false;
|
||||
__instance.BlockedEntity = component;
|
||||
__instance.blockedEntityDistSq = sqrMagnitude;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("CheckAreaBlocked")]
|
||||
public class CheckAreaBlockedPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckAreaBlocked START");
|
||||
Vector3 headPosition = __instance.entity.getHeadPosition() with
|
||||
{
|
||||
y = __instance.entity.position.y
|
||||
};
|
||||
Vector3 vector3_1 = __instance.moveToPos - headPosition;
|
||||
double f = (double)Mathf.Atan2(vector3_1.x, vector3_1.z);
|
||||
float num1 = Mathf.Sin((float)f);
|
||||
float num2 = Mathf.Cos((float)f);
|
||||
vector3_1.Normalize();
|
||||
Vector3 vector3_2 = headPosition + vector3_1 * 0.575f;
|
||||
for (float num3 = __instance.ccHeight - 0.125f; (double)num3 > 0.22499999403953552; num3 -= 0.25f)
|
||||
{
|
||||
for (int index = 0; index < 3; ++index)
|
||||
{
|
||||
double checkEdgeX = (double)EntityMoveHelper.checkEdgeXs[index];
|
||||
float num4 = (float)checkEdgeX * num2;
|
||||
float num5 = (float)(checkEdgeX * -(double)num1);
|
||||
Vector3 pos = headPosition;
|
||||
pos.x += num4;
|
||||
pos.y += num3;
|
||||
pos.z += num5;
|
||||
Vector3 endPos = vector3_2;
|
||||
endPos.x += num4;
|
||||
endPos.y += num3;
|
||||
endPos.z += num5;
|
||||
__instance.CheckBlocked(pos, endPos, 1);
|
||||
if (__instance.IsBlocked)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("CheckBlockedUp")]
|
||||
public class CheckBlockedUpPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance, Vector3 pos)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlockedUp START");
|
||||
__instance.IsBlocked = false;
|
||||
Vector3 headPosition = __instance.entity.getHeadPosition() with
|
||||
{
|
||||
x = pos.x,
|
||||
z = pos.z
|
||||
};
|
||||
headPosition.y -= 0.625f;
|
||||
if (!Voxel.Raycast(__instance.entity.world, new Ray(headPosition, Vector3.up), 1f, 1082195968, 128, 0.125f) || Voxel.voxelRayHitInfo.hit.blockValue.Block is BlockDamage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.HitInfo = Voxel.voxelRayHitInfo.Clone();
|
||||
Log.Out("EntityMoveHelperPatches-CheckBlockedUp SET BLOCKED");
|
||||
__instance.IsBlocked = true;
|
||||
float sqrMagnitude = (pos - __instance.HitInfo.hit.pos).sqrMagnitude;
|
||||
if ((double)sqrMagnitude >= (double)__instance.blockedDistSq)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.blockedDistSq = sqrMagnitude;
|
||||
__instance.obstacleCheckTickDelay = 12;
|
||||
__instance.ResetStuckCheck();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("StopMove")]
|
||||
public class StopMovePatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance)
|
||||
{
|
||||
__instance.IsActive = false;
|
||||
if (!__instance.entity.Jumping || __instance.entity.isSwimming)
|
||||
{
|
||||
__instance.entity.SetMoveForward(0.0f);
|
||||
__instance.entity.SetRotationAndStopTurning(__instance.entity.rotation);
|
||||
}
|
||||
__instance.expiryTicks = 0;
|
||||
__instance.IsBlocked = false;
|
||||
__instance.BlockedTime = 0.0f;
|
||||
__instance.BlockedEntity = (EntityAlive)null;
|
||||
|
||||
Log.Out("EntityMoveHelperPatches-StopMove CLEAR BLOCKED");
|
||||
Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("CheckWorldBlocked")]
|
||||
public class CheckWorldBlockedPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance)
|
||||
{
|
||||
Log.Out("EntityMoveHelperPatches-CheckWorldBlocked START");
|
||||
__instance.DamageScale = 1f;
|
||||
Vector3 headPosition = __instance.entity.getHeadPosition();
|
||||
headPosition.x = (float)((double)__instance.entity.position.x * 0.40000000596046448 + (double)headPosition.x * 0.60000002384185791);
|
||||
headPosition.z = (float)((double)__instance.entity.position.z * 0.40000000596046448 + (double)headPosition.z * 0.60000002384185791);
|
||||
headPosition.y = __instance.entity.position.y;
|
||||
float num1 = Utils.FastClamp(__instance.ccHeight - 0.125f, 0.7f, 1.5f);
|
||||
headPosition.y += num1;
|
||||
Vector3 moveToPos = __instance.moveToPos with
|
||||
{
|
||||
y = headPosition.y
|
||||
};
|
||||
__instance.CheckBlocked(headPosition, moveToPos, (double)num1 >= 1.0 ? 1 : 0);
|
||||
if ((double)num1 >= 1.0)
|
||||
{
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Vector3 pos = headPosition with
|
||||
{
|
||||
y = (float)((double)__instance.entity.position.y + (double)__instance.entity.stepHeight + 0.125)
|
||||
};
|
||||
moveToPos.y = pos.y;
|
||||
__instance.CheckBlocked(pos, moveToPos, 0);
|
||||
if (!__instance.IsBlocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!__instance.IsBlocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
WorldRayHitInfo hitInfo = __instance.HitInfo;
|
||||
moveToPos.y = headPosition.y + 1f;
|
||||
if ((double)num1 < 1.0)
|
||||
headPosition.y += 0.3f;
|
||||
__instance.CheckBlocked(headPosition, moveToPos, 2);
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
BlockValue blockValue1 = hitInfo.hit.blockValue;
|
||||
float num2 = (float)(blockValue1.Block.MaxDamage - blockValue1.damage);
|
||||
if (__instance.HitInfo.hit.blockPos.x != Utils.Fastfloor(__instance.moveToPos.x) || __instance.HitInfo.hit.blockPos.z != Utils.Fastfloor(__instance.moveToPos.z))
|
||||
{
|
||||
__instance.HitInfo = hitInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue blockValue2 = __instance.HitInfo.hit.blockValue;
|
||||
float num3 = (float)(blockValue2.Block.MaxDamage - blockValue2.damage);
|
||||
if ((double)num2 * 0.699999988079071 < (double)num3)
|
||||
__instance.HitInfo = hitInfo;
|
||||
}
|
||||
}
|
||||
Log.Out("EntityMoveHelperPatches-CheckWorldBlocked SET BLOCKED");
|
||||
__instance.IsBlocked = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityMoveHelper))]
|
||||
[HarmonyPatch("UpdateMoveHelper")]
|
||||
|
||||
public class UpdateMoveHelperPatch
|
||||
{
|
||||
public static bool Prefix(EntityMoveHelper __instance)
|
||||
{
|
||||
if (!__instance.IsActive)
|
||||
{
|
||||
//if (__instance.entity is EntityNPCRebirth)
|
||||
//Log.Out($"UpdateMoveHelper-Prefix this: {__instance.entity}, !__instance.IsActive return false, moveToPos: {__instance.moveToPos}");
|
||||
return false;
|
||||
}
|
||||
if (--__instance.expiryTicks <= 0)
|
||||
{
|
||||
//if (__instance.entity is EntityNPCRebirth)
|
||||
//Log.Out($"UpdateMoveHelper-Prefix this: {__instance.entity}, StopMove()");
|
||||
__instance.StopMove();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.ccHeight = __instance.entity.m_characterController.GetHeight();
|
||||
__instance.ccRadius = __instance.entity.m_characterController.GetRadius();
|
||||
Vector3 position = __instance.entity.position;
|
||||
Vector3 vector3_1 = __instance.moveToPos;
|
||||
|
||||
//if (__instance.entity is EntityNPCRebirth)
|
||||
//{
|
||||
//Log.Out($"EntityMoveHelperPatches::Prefix entity: {__instance.entity}, position: {__instance.entity.position}, moveToPos: {__instance.moveToPos}, IsActive: {__instance.IsActive}");
|
||||
//Log.Out($"Stacktrace: {System.Environment.StackTrace}");
|
||||
//}
|
||||
|
||||
if (__instance.isTempMove)
|
||||
{
|
||||
if (!__instance.IsBlocked)
|
||||
{
|
||||
__instance.isTempMove = false;
|
||||
__instance.ResetStuckCheck();
|
||||
}
|
||||
else
|
||||
vector3_1 = __instance.tempMoveToPos;
|
||||
}
|
||||
bool jumping = __instance.entity.Jumping;
|
||||
bool flag1 = jumping || __instance.entity.isSwimming;
|
||||
bool flag2 = jumping && !__instance.entity.isSwimming;
|
||||
float x1 = vector3_1.x - position.x;
|
||||
float z1 = vector3_1.z - position.z;
|
||||
float f1 = (float)((double)x1 * (double)x1 + (double)z1 * (double)z1);
|
||||
float num1 = vector3_1.y - (position.y + 0.05f);
|
||||
bool flag3 = __instance.entity.IsInElevator();
|
||||
__instance.isClimb = false;
|
||||
if (flag3 && __instance.entity.bCanClimbLadders && (double)f1 < 0.10890001058578491 && (double)num1 > 0.10000000149011612 && !jumping)
|
||||
__instance.isClimb = true;
|
||||
else if ((double)f1 <= 0.00039999998989515007 && (double)Utils.FastAbs(num1) < 0.25 && !__instance.isTempMove)
|
||||
{
|
||||
__instance.StopMove();
|
||||
return false;
|
||||
}
|
||||
AvatarController avatarController = __instance.entity.emodel.avatarController;
|
||||
if (avatarController.IsRootMotionForced())
|
||||
{
|
||||
__instance.entity.SetMoveForwardWithModifiers(__instance.moveSpeed, 1f, false);
|
||||
__instance.ResetStuckCheck();
|
||||
__instance.ClearTempMove();
|
||||
__instance.ClearBlocked();
|
||||
}
|
||||
else if (!flag1 && !__instance.isDigging && !avatarController.IsAnimationWithMotionRunning() || __instance.entity.sleepingOrWakingUp || !__instance.entity.bodyDamage.HasLimbs || !__instance.entity.bodyDamage.CurrentStun.CanMove() || __instance.entity.emodel.IsRagdollActive || avatarController.IsLocomotionPreempted())
|
||||
{
|
||||
__instance.entity.SetMoveForward(0.0f);
|
||||
__instance.ResetStuckCheck();
|
||||
__instance.ClearBlocked();
|
||||
}
|
||||
else
|
||||
{
|
||||
float y1 = __instance.moveToPos.x - position.x;
|
||||
float x2 = __instance.moveToPos.z - position.z;
|
||||
float f2 = (float)((double)y1 * (double)y1 + (double)x2 * (double)x2);
|
||||
float num2 = __instance.moveToPos.y - (position.y + 0.05f);
|
||||
if ((double)num2 < -1.1000000238418579 && (double)f2 <= 0.010000000707805157 && !flag2 && __instance.entity.onGround)
|
||||
__instance.DigStart(20);
|
||||
if (__instance.isDigging)
|
||||
{
|
||||
__instance.DigUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
float num3 = Mathf.Atan2(y1, x2) * 57.29578f;
|
||||
__instance.moveToDir = !flag2 ? Mathf.MoveTowardsAngle(__instance.moveToDir, num3, 13f) : num3;
|
||||
__instance.entity.emodel.ClearLookAt();
|
||||
if (__instance.hasNextPos || (double)f2 >= 0.022500000894069672)
|
||||
{
|
||||
float yaw = 9999f;
|
||||
if (flag2)
|
||||
{
|
||||
yaw = __instance.jumpYaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
float y2 = y1;
|
||||
float x3 = x2;
|
||||
if (__instance.hasNextPos && (double)f2 <= 2.25)
|
||||
{
|
||||
float t = Mathf.Sqrt(f2) / 1.5f;
|
||||
y2 = Mathf.Lerp(__instance.nextMoveToPos.x, __instance.moveToPos.x, t) - position.x;
|
||||
x3 = Mathf.Lerp(__instance.nextMoveToPos.z, __instance.moveToPos.z, t) - position.z;
|
||||
}
|
||||
if (__instance.focusTicks > 0)
|
||||
{
|
||||
--__instance.focusTicks;
|
||||
y2 = __instance.focusPos.x - position.x;
|
||||
x3 = __instance.focusPos.z - position.z;
|
||||
}
|
||||
if ((double)y2 * (double)y2 + (double)x3 * (double)x3 > 9.9999997473787516E-05)
|
||||
yaw = Mathf.Atan2(y2, x3) * 57.29578f;
|
||||
}
|
||||
if ((double)yaw < 9000.0)
|
||||
{
|
||||
double num4 = (double)__instance.entity.SeekYaw(yaw, 0.0f, 30f);
|
||||
}
|
||||
}
|
||||
float num5 = Mathf.Abs(Mathf.DeltaAngle(num3, __instance.moveToDir));
|
||||
float _speedScale = 1f;
|
||||
if (__instance.IsUnreachableAbove && !__instance.entity.IsRunning)
|
||||
_speedScale = 1.3f;
|
||||
float num6 = num5 - 15f;
|
||||
if ((double)num6 > 0.0)
|
||||
_speedScale *= 1f - Utils.FastMin(num6 / 30f, 0.8f);
|
||||
if ((double)_speedScale > 0.5)
|
||||
{
|
||||
if ((double)__instance.BlockedTime > 0.10000000149011612)
|
||||
_speedScale = 0.5f;
|
||||
if (__instance.focusTicks > 0)
|
||||
_speedScale = 0.45f;
|
||||
}
|
||||
if (flag3 && !__instance.entity.onGround)
|
||||
_speedScale = 0.5f;
|
||||
if (__instance.entity.hasBeenAttackedTime > 0 && (double)__instance.entity.painResistPercent < 1.0)
|
||||
_speedScale = 0.1f;
|
||||
if (!__instance.hasNextPos && !__instance.isTempMove && !jumping && (double)f1 < 0.36000001430511475 && (double)_speedScale > 0.10000000149011612)
|
||||
{
|
||||
float num7 = (float)((double)_speedScale * (double)Mathf.Sqrt(f1) / 0.60000002384185791);
|
||||
if ((double)num7 < 0.10000000149011612)
|
||||
num7 = 0.1f;
|
||||
_speedScale = num7;
|
||||
}
|
||||
bool isBreakingBlocks = __instance.entity.IsBreakingBlocks;
|
||||
if (isBreakingBlocks)
|
||||
_speedScale = 0.03f;
|
||||
|
||||
//if (__instance.entity is EntityNPCRebirth)
|
||||
//Log.Out($"EntityMoveHelper::UpdateMoveHelper - this: {__instance.entity}, SetMoveForwardWithModifiers moveSpeed: {__instance.moveSpeed}");
|
||||
|
||||
__instance.entity.SetMoveForwardWithModifiers(__instance.moveSpeed, _speedScale, __instance.isClimb);
|
||||
if ((double)_speedScale > 0.0)
|
||||
{
|
||||
float x4 = x1;
|
||||
float z2 = z1;
|
||||
float minMotion = 0.02f * _speedScale;
|
||||
float maxMotion = 1f;
|
||||
if (!__instance.isTempMove)
|
||||
{
|
||||
if (__instance.entity.entityType == EntityType.Bandit)
|
||||
__instance.entity.AddMotion(__instance.moveToDir, (float)((double)__instance.entity.speedForward * (double)_speedScale * 40.0 * 0.019999999552965164));
|
||||
if ((double)__instance.SideStepAngle != 0.0)
|
||||
{
|
||||
double f3 = ((double)__instance.moveToDir + (double)__instance.SideStepAngle) * (Math.PI / 180.0);
|
||||
x4 = Mathf.Sin((float)f3);
|
||||
z2 = Mathf.Cos((float)f3);
|
||||
minMotion = 0.025f;
|
||||
maxMotion = 0.06f;
|
||||
__instance.moveToPos = Vector3.MoveTowards(__instance.moveToPos, position, 0.0100000007f);
|
||||
}
|
||||
else if ((double)f1 > 0.42249995470046997)
|
||||
{
|
||||
double f4 = (double)__instance.moveToDir * (Math.PI / 180.0);
|
||||
x4 = Mathf.Sin((float)f4);
|
||||
z2 = Mathf.Cos((float)f4);
|
||||
}
|
||||
}
|
||||
__instance.entity.MakeMotionMoveToward(x4, z2, minMotion, maxMotion);
|
||||
if (flag3)
|
||||
{
|
||||
Vector3 normalized = new Vector3(x1, num1, z1).normalized;
|
||||
float num8 = Mathf.Pow(__instance.moveSpeed, 0.4f);
|
||||
if ((double)num1 > 0.10000000149011612)
|
||||
num8 *= 0.7f;
|
||||
else if ((double)num1 < -0.10000000149011612)
|
||||
num8 *= 1.4f;
|
||||
__instance.entity.motion = normalized * (num8 * 0.1f);
|
||||
}
|
||||
}
|
||||
if (flag2)
|
||||
return false;
|
||||
if (__instance.entity.isSwimming && (double)__instance.entity.swimStrokeRate.x > 0.0)
|
||||
{
|
||||
--__instance.swimStrokeDelayTicks;
|
||||
if (__instance.swimStrokeDelayTicks <= 0)
|
||||
{
|
||||
__instance.swimStrokeDelayTicks = (int)(20.0 / (double)__instance.random.RandomRange(__instance.entity.swimStrokeRate.x, __instance.entity.swimStrokeRate.y));
|
||||
__instance.StartSwimStroke();
|
||||
__instance.swimStrokeDelayTicks += 3;
|
||||
}
|
||||
}
|
||||
if (isBreakingBlocks || (double)num5 > 60.0 || (double)_speedScale == 0.0)
|
||||
__instance.moveToTicks = 0;
|
||||
else if (++__instance.moveToTicks > 6)
|
||||
{
|
||||
__instance.moveToTicks = 0;
|
||||
float num9 = Mathf.Sqrt((float)((double)x1 * (double)x1 + (double)num1 * (double)num1 + (double)z1 * (double)z1));
|
||||
float num10 = __instance.moveToDistance - num9;
|
||||
if ((double)num10 < 0.020999999716877937)
|
||||
{
|
||||
if ((double)num10 < -0.0099999997764825821)
|
||||
__instance.moveToDistance = num9;
|
||||
if (++__instance.moveToFailCnt >= 3)
|
||||
{
|
||||
bool flag4 = (double)num2 < -1.1000000238418579 && (double)f2 <= 0.64000004529953;
|
||||
if (flag4 && __instance.entity.onGround && (double)__instance.random.RandomFloat < 0.60000002384185791)
|
||||
{
|
||||
__instance.DigStart(80);
|
||||
return false;
|
||||
}
|
||||
__instance.CheckAreaBlocked();
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
if ((double)__instance.random.RandomFloat < 0.699999988079071)
|
||||
{
|
||||
__instance.DamageScale = 6f;
|
||||
__instance.obstacleCheckTickDelay = 40;
|
||||
return false;
|
||||
}
|
||||
__instance.StartJump(false, (float)(0.5 + (double)__instance.random.RandomFloat * 0.40000000596046448), 1.3f);
|
||||
return false;
|
||||
}
|
||||
if (flag4)
|
||||
return false;
|
||||
if ((double)__instance.random.RandomFloat > 0.5)
|
||||
{
|
||||
if (!__instance.entity.Attack(false))
|
||||
return false;
|
||||
__instance.entity.Attack(true);
|
||||
return false;
|
||||
}
|
||||
__instance.StartJump(false, (float)(0.699999988079071 + (double)__instance.random.RandomFloat * 0.800000011920929), 1.4f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.moveToDistance = num9;
|
||||
if ((double)num10 >= 0.070000000298023224)
|
||||
__instance.moveToFailCnt = 0;
|
||||
}
|
||||
}
|
||||
if (!__instance.entity.onGround && !__instance.entity.isSwimming && !flag3 && !__instance.isClimb && ((double)num2 < -0.5 || (double)num2 > 0.5))
|
||||
{
|
||||
__instance.BlockedTime = 0.0f;
|
||||
__instance.BlockedEntity = (EntityAlive)null;
|
||||
}
|
||||
else if (--__instance.obstacleCheckTickDelay <= 0)
|
||||
{
|
||||
__instance.obstacleCheckTickDelay = 4;
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper CLEAR BLOCKED A");
|
||||
__instance.IsBlocked = false;
|
||||
__instance.BlockedEntity = (EntityAlive)null;
|
||||
__instance.blockedDistSq = float.MaxValue;
|
||||
if (__instance.isClimb)
|
||||
__instance.CheckBlockedUp(position);
|
||||
else if ((double)num5 < 10.0)
|
||||
{
|
||||
__instance.CheckEntityBlocked(position, __instance.moveToPos);
|
||||
__instance.CheckWorldBlocked();
|
||||
__instance.SideStepAngle = 0.0f;
|
||||
if (!__instance.IsUnreachableAbove && __instance.hasNextPos && (__instance.IsBlocked || (bool)(UnityEngine.Object)__instance.BlockedEntity))
|
||||
{
|
||||
__instance.SideStepAngle = __instance.CalcObstacleSideStep();
|
||||
if ((double)__instance.SideStepAngle != 0.0)
|
||||
{
|
||||
__instance.isTempMove = false;
|
||||
__instance.BlockedEntity = (EntityAlive)null;
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper CLEAR BLOCKED B");
|
||||
__instance.IsBlocked = false;
|
||||
}
|
||||
}
|
||||
if ((bool)(UnityEngine.Object)__instance.BlockedEntity)
|
||||
{
|
||||
if (!__instance.IsBlocked || (double)__instance.blockedEntityDistSq < (double)__instance.blockedDistSq)
|
||||
{
|
||||
__instance.moveToTicks = 0;
|
||||
if ((double)__instance.random.RandomFloat < 0.10000000149011612)
|
||||
{
|
||||
if (__instance.BlockedEntity.moveHelper != null && __instance.BlockedEntity.moveHelper.IsBlocked)
|
||||
__instance.StartJump(false, 0.7f, __instance.BlockedEntity.height * 0.8f);
|
||||
}
|
||||
else
|
||||
__instance.Push(__instance.BlockedEntity);
|
||||
}
|
||||
}
|
||||
else if ((__instance.IsBlocked || !__instance.hasNextPos) && (double)num2 < -1.5 && (double)f2 >= 2.25 && __instance.entity.onGround)
|
||||
{
|
||||
float num11 = Mathf.Sqrt(f2 + num2 * num2) + 1f / 1000f;
|
||||
if ((double)num2 / (double)num11 < -0.86000001430511475)
|
||||
__instance.DigStart(160);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
__instance.BlockedTime += 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.BlockedTime = 0.0f;
|
||||
}
|
||||
if (!__instance.entity.CanEntityJump() || __instance.isClimb || flag1)
|
||||
return false;
|
||||
|
||||
float distance = 0.0f;
|
||||
float heightDiff = 0.9f;
|
||||
|
||||
// NEW CODE _START
|
||||
float numHeight = 0f;
|
||||
|
||||
if (__instance.entity is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX myEntity = (EntityZombieSDX)__instance.entity;
|
||||
|
||||
if (myEntity.flMaxJumpHeight > 1)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper __instance.BlockedTime: " + __instance.BlockedTime);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ___blockedHeight: " + ___blockedHeight);
|
||||
|
||||
bool bIsAir = false;
|
||||
|
||||
if (__instance.HitInfo != null)
|
||||
{
|
||||
int numAir = 0;
|
||||
for (int i = 0; i < (int)myEntity.flMaxJumpHeight + (int)myEntity.flMaxJumpSize; i++)
|
||||
{
|
||||
Vector3i blockPos = __instance.HitInfo.hit.blockPos;
|
||||
Vector3i EntityPos = Vector3i.zero;
|
||||
|
||||
EntityPos.x = (int)myEntity.position.x;
|
||||
EntityPos.z = (int)myEntity.position.z;
|
||||
EntityPos.y = (int)myEntity.position.y + i;
|
||||
|
||||
blockPos.y = (int)myEntity.position.y + i;
|
||||
|
||||
BlockValue block1 = __instance.entity.world.GetBlock(blockPos);
|
||||
BlockValue block2 = __instance.entity.world.GetBlock(EntityPos);
|
||||
|
||||
if (!block2.isair)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (block1.isair)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper IS AIR");
|
||||
numAir++;
|
||||
if (numAir == (int)myEntity.flMaxJumpSize)
|
||||
{
|
||||
numHeight = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper GetBlockName: " + block.Block.GetBlockName());
|
||||
numAir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper numAir: " + numAir);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper myEntity.flMaxJumpSize: " + myEntity.flMaxJumpSize);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper myEntity.flMaxJumpHeight: " + myEntity.flMaxJumpHeight);
|
||||
|
||||
if (numAir >= (int)myEntity.flMaxJumpSize)
|
||||
{
|
||||
bIsAir = true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, X: " + myEntity.position.x);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, Y: " + myEntity.position.y);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, Z: " + myEntity.position.z);
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , X: " + blockPos.x);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , Y: " + blockPos.y);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , Z: " + blockPos.z);
|
||||
|
||||
if (!bIsAir)
|
||||
{
|
||||
distance = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper IS AIR");
|
||||
if (__instance.BlockedTime > 0.15f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 2a");
|
||||
distance = 0.55f + __instance.random.RandomFloat * 0.3f;
|
||||
}
|
||||
else if (num2 > 1.5f && f2 <= 0.040000003f && __instance.random.RandomFloat < 0.1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 3a");
|
||||
distance = 0.02f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.BlockedTime > 0.15f && __instance.blockedHeight < myEntity.flMaxJumpHeight)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 2b");
|
||||
distance = 0.55f + __instance.random.RandomFloat * 0.3f;
|
||||
}
|
||||
else if (num2 > 1.5f && f2 <= 0.040000003f && __instance.random.RandomFloat < 0.1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 3b");
|
||||
distance = 0.02f;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NEW CODE - END
|
||||
else if ((double)__instance.BlockedTime > 0.15000000596046448 && (double)__instance.blockedHeight < 1.0)
|
||||
distance = (float)(0.550000011920929 + (double)__instance.random.RandomFloat * 0.30000001192092896);
|
||||
else if ((double)num2 > 1.5 && (double)f2 <= 0.040000002831220627 && (double)__instance.random.RandomFloat < 0.10000000149011612)
|
||||
distance = 0.02f;
|
||||
|
||||
if (__instance.IsUnreachableSideJump && (double)num5 < 25.0)
|
||||
{
|
||||
PathEntity path = __instance.entity.navigator.getPath();
|
||||
if (path == null || path.NodeCountRemaining() <= 1)
|
||||
{
|
||||
Vector3 vector3_2 = __instance.entity.position + __instance.entity.GetForwardVector() * 0.2f;
|
||||
vector3_2.y += 0.4f;
|
||||
RaycastHit hitInfo;
|
||||
if (!Physics.Raycast(vector3_2 - Origin.position, Vector3.down, out hitInfo, 3.4f, 1082195968) || (double)hitInfo.distance > 2.2000000476837158)
|
||||
{
|
||||
distance = __instance.entity.jumpMaxDistance;
|
||||
heightDiff = __instance.UnreachablePos.y - __instance.entity.position.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((double)distance <= 0.0)
|
||||
return false;
|
||||
Vector3i vector3i = new Vector3i(Utils.Fastfloor(position.x), Utils.Fastfloor(position.y + 2.35f), Utils.Fastfloor(position.z));
|
||||
BlockValue block = __instance.entity.world.GetBlock(vector3i);
|
||||
if (!block.Block.IsMovementBlocked((IBlockAccess)__instance.entity.world, vector3i, block, BlockFace.None))
|
||||
{
|
||||
//NEW CODE - START
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED block: " + block.Block.GetBlockName());
|
||||
if (__instance.entity is EntityNPCRebirth && block.Block.GetBlockName() == "air" && !__instance.IsBlocked)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED block: " + block.Block.GetBlockName());
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED num22: " + num22);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED heightDiff: " + heightDiff);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED ___blockedHeight: " + ___blockedHeight);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED numHeight: " + numHeight);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED ___jumpYaw: " + ___jumpYaw);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED __instance.IsBlocked: " + __instance.IsBlocked);
|
||||
__instance.IsUnreachableSideJump = false;
|
||||
return false;
|
||||
}
|
||||
//NEW CODE - END
|
||||
__instance.StartJump(true, distance, heightDiff);
|
||||
if (__instance.IsUnreachableSideJump)
|
||||
{
|
||||
__instance.UnreachablePercent += 0.1f;
|
||||
__instance.IsDestroyAreaTryUnreachable = true;
|
||||
}
|
||||
}
|
||||
__instance.IsUnreachableSideJump = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public static MethodInfo ResetStuckCheck = AccessTools.Method(typeof(global::EntityMoveHelper), "ResetStuckCheck", new Type[] { });
|
||||
public static MethodInfo DigStart = AccessTools.Method(typeof(global::EntityMoveHelper), "DigStart", new Type[] { typeof(int) });
|
||||
public static MethodInfo DigUpdate = AccessTools.Method(typeof(global::EntityMoveHelper), "DigUpdate", new Type[] { });
|
||||
public static MethodInfo StartSwimStroke = AccessTools.Method(typeof(global::EntityMoveHelper), "StartSwimStroke", new Type[] { });
|
||||
public static MethodInfo CheckAreaBlocked = AccessTools.Method(typeof(global::EntityMoveHelper), "CheckAreaBlocked", new Type[] { });
|
||||
public static MethodInfo Push = AccessTools.Method(typeof(global::EntityMoveHelper), "Push", new Type[] { typeof(global::EntityAlive) });
|
||||
public static MethodInfo CheckBlockedUp = AccessTools.Method(typeof(global::EntityMoveHelper), "CheckBlockedUp", new Type[] { typeof(Vector3) });
|
||||
public static MethodInfo CheckEntityBlocked = AccessTools.Method(typeof(global::EntityMoveHelper), "CheckEntityBlocked", new Type[] { typeof(Vector3), typeof(Vector3) });
|
||||
public static MethodInfo CheckWorldBlocked = AccessTools.Method(typeof(global::EntityMoveHelper), "CheckWorldBlocked", new Type[] { });
|
||||
public static MethodInfo CalcObstacleSideStep = AccessTools.Method(typeof(global::EntityMoveHelper), "CalcObstacleSideStep", new Type[] { });
|
||||
public static MethodInfo StartJump = AccessTools.Method(typeof(global::EntityMoveHelper), "StartJump", new Type[] { typeof(bool), typeof(float), typeof(float) });
|
||||
|
||||
public static bool Prefix(ref global::EntityMoveHelper __instance,
|
||||
ref global::EntityAlive __instance.entity,
|
||||
ref int ___moveToFailCnt,
|
||||
ref int ___moveToTicks,
|
||||
ref int ___expiryTicks,
|
||||
ref float ___ccHeight,
|
||||
ref float ___ccRadius,
|
||||
ref bool ___isTempMove,
|
||||
ref Vector3 ___moveToPos,
|
||||
ref Vector3 ___tempMoveToPos,
|
||||
ref bool ___isClimb,
|
||||
float ___moveSpeed,
|
||||
bool ___hasNextPos,
|
||||
ref bool ___isDigging,
|
||||
ref float ___moveToDir,
|
||||
ref float ___jumpYaw,
|
||||
Vector3 ___nextMoveToPos,
|
||||
ref int ___focusTicks,
|
||||
Vector3 ___focusPos,
|
||||
ref int ___swimStrokeDelayTicks,
|
||||
ref float ___moveToDistance,
|
||||
ref int ___obstacleCheckTickDelay,
|
||||
ref float ___blockedDistSq,
|
||||
ref float ___blockedEntityDistSq,
|
||||
ref float ___blockedHeight,
|
||||
GameRandom ___random,
|
||||
ref float ___SideStepAngle,
|
||||
ref Vector3 ___digStartPos,
|
||||
ref float ___digForTicks,
|
||||
bool ___CanBreakBlocks,
|
||||
ref float ___digTicks,
|
||||
ref float ___digActionTicks,
|
||||
ref bool ___digAttacked,
|
||||
ref float ___digForwardCount,
|
||||
ref Vector3 ___JumpToPos,
|
||||
ref WorldRayHitInfo ___HitInfo,
|
||||
ref DamageResponse ___damageResponse
|
||||
)
|
||||
{
|
||||
if (!__instance.IsActive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = ___expiryTicks - 1;
|
||||
___expiryTicks = num;
|
||||
if (num <= 0)
|
||||
{
|
||||
__instance.Stop();
|
||||
return false;
|
||||
}
|
||||
___ccHeight = __instance.entity.m_characterController.GetHeight();
|
||||
___ccRadius = __instance.entity.m_characterController.GetRadius();
|
||||
Vector3 position = __instance.entity.position;
|
||||
Vector3 vector = ___moveToPos;
|
||||
if (___isTempMove)
|
||||
{
|
||||
if (!__instance.IsBlocked)
|
||||
{
|
||||
___isTempMove = false;
|
||||
ResetStuckCheck.Invoke(__instance, new object[] { });
|
||||
}
|
||||
else
|
||||
{
|
||||
vector = ___tempMoveToPos;
|
||||
}
|
||||
}
|
||||
bool jumping = __instance.entity.Jumping;
|
||||
bool flag = jumping || __instance.entity.isSwimming;
|
||||
bool flag2 = jumping && !__instance.entity.isSwimming;
|
||||
float num2 = vector.x - position.x;
|
||||
float num3 = vector.z - position.z;
|
||||
float num4 = num2 * num2 + num3 * num3;
|
||||
float num5 = vector.y - (position.y + 0.05f);
|
||||
bool flag3 = __instance.entity.IsInElevator();
|
||||
|
||||
___isClimb = false;
|
||||
if (flag3 && __instance.entity.bCanClimbLadders && num4 < 0.10890001f && num5 > 0.1f && !jumping)
|
||||
{
|
||||
___isClimb = true;
|
||||
}
|
||||
else if (num4 <= 0.0004f && Utils.FastAbs(num5) < 0.25f && !___isTempMove)
|
||||
{
|
||||
__instance.Stop();
|
||||
return false;
|
||||
}
|
||||
AvatarController avatarController = __instance.entity.emodel.avatarController;
|
||||
if (avatarController.IsRootMotionForced())
|
||||
{
|
||||
__instance.entity.SetMoveForwardWithModifiers(___moveSpeed, 1f, false);
|
||||
ResetStuckCheck.Invoke(__instance, new object[] { });
|
||||
__instance.ClearTempMove();
|
||||
__instance.ClearBlocked();
|
||||
return false;
|
||||
}
|
||||
if ((!flag && !___isDigging && !avatarController.IsAnimationWithMotionRunning()) || __instance.entity.sleepingOrWakingUp || !__instance.entity.bodyDamage.HasLimbs || !__instance.entity.bodyDamage.CurrentStun.CanMove() || __instance.entity.emodel.IsRagdollActive || avatarController.IsLocomotionPreempted())
|
||||
{
|
||||
__instance.entity.SetMoveForward(0f);
|
||||
ResetStuckCheck.Invoke(__instance, new object[] { });
|
||||
__instance.ClearBlocked();
|
||||
return false;
|
||||
}
|
||||
float num6 = ___moveToPos.x - position.x;
|
||||
float num7 = ___moveToPos.z - position.z;
|
||||
float num8 = num6 * num6 + num7 * num7;
|
||||
float num9 = ___moveToPos.y - (position.y + 0.05f);
|
||||
if (num9 < -1.1f && num8 <= 0.010000001f && !flag2 && __instance.entity.onGround)
|
||||
{
|
||||
DigStart.Invoke(__instance, new object[] { 20 });
|
||||
}
|
||||
if (___isDigging)
|
||||
{
|
||||
DigUpdate.Invoke(__instance, new object[] { });
|
||||
return false;
|
||||
}
|
||||
float num10 = Mathf.Atan2(num6, num7) * 57.29578f;
|
||||
if (flag2)
|
||||
{
|
||||
___moveToDir = num10;
|
||||
}
|
||||
else
|
||||
{
|
||||
___moveToDir = Mathf.MoveTowardsAngle(___moveToDir, num10, 13f);
|
||||
}
|
||||
__instance.entity.emodel.ClearLookAt();
|
||||
if (___hasNextPos || num8 >= 0.0225f)
|
||||
{
|
||||
float num11 = 9999f;
|
||||
if (flag2)
|
||||
{
|
||||
num11 = ___jumpYaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num12 = num6;
|
||||
float num13 = num7;
|
||||
if (___hasNextPos && num8 <= 2.25f)
|
||||
{
|
||||
float t = Mathf.Sqrt(num8) / 1.5f;
|
||||
num12 = Mathf.Lerp(___nextMoveToPos.x, ___moveToPos.x, t) - position.x;
|
||||
num13 = Mathf.Lerp(___nextMoveToPos.z, ___moveToPos.z, t) - position.z;
|
||||
}
|
||||
if (___focusTicks > 0)
|
||||
{
|
||||
___focusTicks--;
|
||||
num12 = ___focusPos.x - position.x;
|
||||
num13 = ___focusPos.z - position.z;
|
||||
}
|
||||
if (num12 * num12 + num13 * num13 > 0.0001f)
|
||||
{
|
||||
num11 = Mathf.Atan2(num12, num13) * 57.29578f;
|
||||
}
|
||||
}
|
||||
if (num11 < 9000f)
|
||||
{
|
||||
__instance.entity.SeekYaw(num11, 0f, 30f);
|
||||
}
|
||||
}
|
||||
float num14 = Mathf.Abs(Mathf.DeltaAngle(num10, ___moveToDir));
|
||||
float num15 = 1f;
|
||||
if (__instance.IsUnreachableAbove && !__instance.entity.IsRunning)
|
||||
{
|
||||
num15 = 1.3f;
|
||||
}
|
||||
float num16 = num14 - 15f;
|
||||
if (num16 > 0f)
|
||||
{
|
||||
num15 *= 1f - Utils.FastMin(num16 / 30f, 0.8f);
|
||||
}
|
||||
if (num15 > 0.5f)
|
||||
{
|
||||
if (__instance.BlockedTime > 0.1f)
|
||||
{
|
||||
num15 = 0.5f;
|
||||
}
|
||||
if (___focusTicks > 0)
|
||||
{
|
||||
num15 = 0.45f;
|
||||
}
|
||||
}
|
||||
if (flag3 && !__instance.entity.onGround)
|
||||
{
|
||||
num15 = 0.5f;
|
||||
}
|
||||
if (__instance.entity.hasBeenAttackedTime > 0 && __instance.entity.painResistPercent < 1f)
|
||||
{
|
||||
num15 = 0.1f;
|
||||
}
|
||||
if (!___hasNextPos && !___isTempMove && !jumping && num4 < 0.36f && num15 > 0.1f)
|
||||
{
|
||||
float num17 = num15 * Mathf.Sqrt(num4) / 0.6f;
|
||||
if (num17 < 0.1f)
|
||||
{
|
||||
num17 = 0.1f;
|
||||
}
|
||||
num15 = num17;
|
||||
}
|
||||
bool isBreakingBlocks = __instance.entity.IsBreakingBlocks;
|
||||
if (isBreakingBlocks)
|
||||
{
|
||||
num15 = 0.03f;
|
||||
}
|
||||
__instance.entity.SetMoveForwardWithModifiers(___moveSpeed, num15, ___isClimb);
|
||||
if (num15 > 0f)
|
||||
{
|
||||
float x = num2;
|
||||
float z = num3;
|
||||
float minMotion = 0.02f * num15;
|
||||
float maxMotion = 1f;
|
||||
if (!___isTempMove)
|
||||
{
|
||||
if (__instance.entity.entityType == EntityType.Bandit)
|
||||
{
|
||||
__instance.entity.AddMotion(___moveToDir, __instance.entity.speedForward * num15 * 40f * 0.02f);
|
||||
}
|
||||
if (__instance.SideStepAngle != 0f)
|
||||
{
|
||||
float f = (___moveToDir + __instance.SideStepAngle) * 0.017453292f;
|
||||
x = Mathf.Sin(f);
|
||||
z = Mathf.Cos(f);
|
||||
minMotion = 0.025f;
|
||||
maxMotion = 0.06f;
|
||||
___moveToPos = Vector3.MoveTowards(___moveToPos, position, 0.010000001f);
|
||||
}
|
||||
else if (num4 > 0.42249995f)
|
||||
{
|
||||
float f2 = ___moveToDir * 0.017453292f;
|
||||
x = Mathf.Sin(f2);
|
||||
z = Mathf.Cos(f2);
|
||||
}
|
||||
}
|
||||
__instance.entity.MakeMotionMoveToward(x, z, minMotion, maxMotion);
|
||||
if (flag3)
|
||||
{
|
||||
Vector3 vector2 = new Vector3(num2, num5, num3).normalized;
|
||||
float num18 = Mathf.Pow(___moveSpeed, 0.4f);
|
||||
if (num5 > 0.1f)
|
||||
{
|
||||
num18 *= 0.7f;
|
||||
}
|
||||
else if (num5 < -0.1f)
|
||||
{
|
||||
num18 *= 1.4f;
|
||||
}
|
||||
vector2 *= num18 * 0.1f;
|
||||
__instance.entity.motion = vector2;
|
||||
}
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (__instance.entity.isSwimming && __instance.entity.swimStrokeRate.x > 0f)
|
||||
{
|
||||
___swimStrokeDelayTicks--;
|
||||
if (___swimStrokeDelayTicks <= 0)
|
||||
{
|
||||
___swimStrokeDelayTicks = (int)(20f / ___random.RandomRange(__instance.entity.swimStrokeRate.x, __instance.entity.swimStrokeRate.y));
|
||||
StartSwimStroke.Invoke(__instance, new object[] { });
|
||||
|
||||
___swimStrokeDelayTicks += 3;
|
||||
}
|
||||
}
|
||||
if (isBreakingBlocks || num14 > 60f || num15 == 0f)
|
||||
{
|
||||
___moveToTicks = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = ___moveToTicks + 1;
|
||||
___moveToTicks = num;
|
||||
if (num > 6)
|
||||
{
|
||||
___moveToTicks = 0;
|
||||
float num19 = Mathf.Sqrt(num2 * num2 + num5 * num5 + num3 * num3);
|
||||
float num20 = ___moveToDistance - num19;
|
||||
if (num20 < 0.021f)
|
||||
{
|
||||
if (num20 < -0.01f)
|
||||
{
|
||||
___moveToDistance = num19;
|
||||
}
|
||||
num = ___moveToFailCnt + 1;
|
||||
___moveToFailCnt = num;
|
||||
if (num >= 3)
|
||||
{
|
||||
bool flag4 = num9 < -1.1f && num8 <= 0.64000005f;
|
||||
if (flag4 && __instance.entity.onGround && ___random.RandomFloat < 0.6f)
|
||||
{
|
||||
DigStart.Invoke(__instance, new object[] { 80 });
|
||||
return false;
|
||||
}
|
||||
CheckAreaBlocked.Invoke(__instance, new object[] { });
|
||||
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED A");
|
||||
if (___random.RandomFloat < 0.7f)
|
||||
{
|
||||
__instance.DamageScale = 6f;
|
||||
___obstacleCheckTickDelay = 40;
|
||||
return false;
|
||||
}
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper StartJump A");
|
||||
StartJump.Invoke(__instance, new object[] { false, 0.5f + ___random.RandomFloat * 0.4f, 1.3f });
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (___random.RandomFloat > 0.5f)
|
||||
{
|
||||
if (__instance.entity.Attack(false))
|
||||
{
|
||||
__instance.entity.Attack(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED B");
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper StartJump B");
|
||||
StartJump.Invoke(__instance, new object[] { false, 0.7f + ___random.RandomFloat * 0.8f, 1.4f });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
___moveToDistance = num19;
|
||||
if (num20 >= 0.07f)
|
||||
{
|
||||
___moveToFailCnt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!__instance.entity.onGround && !__instance.entity.isSwimming && !flag3 && !___isClimb && (num9 < -0.5f || num9 > 0.5f))
|
||||
{
|
||||
__instance.BlockedTime = 0f;
|
||||
__instance.BlockedEntity = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = ___obstacleCheckTickDelay - 1;
|
||||
___obstacleCheckTickDelay = num;
|
||||
if (num <= 0)
|
||||
{
|
||||
___obstacleCheckTickDelay = 4;
|
||||
__instance.IsBlocked = false;
|
||||
__instance.BlockedEntity = null;
|
||||
___blockedDistSq = float.MaxValue;
|
||||
if (___isClimb)
|
||||
{
|
||||
CheckBlockedUp.Invoke(__instance, new object[] { position });
|
||||
|
||||
}
|
||||
else if (num14 < 10f)
|
||||
{
|
||||
CheckEntityBlocked.Invoke(__instance, new object[] { position, ___moveToPos });
|
||||
CheckWorldBlocked.Invoke(__instance, new object[] { });
|
||||
|
||||
__instance.SideStepAngle = 0f;
|
||||
if (!__instance.IsUnreachableAbove && ___hasNextPos && (__instance.IsBlocked || __instance.BlockedEntity))
|
||||
{
|
||||
CalcObstacleSideStep.Invoke(__instance, new object[] { });
|
||||
|
||||
if (__instance.SideStepAngle != 0f)
|
||||
{
|
||||
___isTempMove = false;
|
||||
__instance.BlockedEntity = null;
|
||||
__instance.IsBlocked = false;
|
||||
}
|
||||
}
|
||||
if (__instance.BlockedEntity)
|
||||
{
|
||||
if (!__instance.IsBlocked || ___blockedEntityDistSq < ___blockedDistSq)
|
||||
{
|
||||
___moveToTicks = 0;
|
||||
if (___random.RandomFloat < 0.1f)
|
||||
{
|
||||
if (__instance.BlockedEntity.moveHelper != null && __instance.BlockedEntity.moveHelper.IsBlocked)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED C");
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper StartJump C");
|
||||
StartJump.Invoke(__instance, new object[] { false, 0.7f, __instance.BlockedEntity.height * 0.8f });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Push.Invoke(__instance, new object[] { __instance.BlockedEntity });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((__instance.IsBlocked || !___hasNextPos) && num9 < -1.5f && num8 >= 2.25f && __instance.entity.onGround)
|
||||
{
|
||||
float num21 = Mathf.Sqrt(num8 + num9 * num9) + 0.001f;
|
||||
if (num9 / num21 < -0.86f)
|
||||
{
|
||||
DigStart.Invoke(__instance, new object[] { 160 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (__instance.IsBlocked)
|
||||
{
|
||||
__instance.BlockedTime += 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper 4");
|
||||
__instance.BlockedTime = 0f;
|
||||
}
|
||||
if (__instance.entity.CanEntityJump() && !___isClimb && !flag)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 1");
|
||||
|
||||
float num22 = 0f;
|
||||
float heightDiff = 0.9f;
|
||||
int numHeight = 0;
|
||||
|
||||
if (__instance.entity is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX myEntity = (EntityZombieSDX)__instance.entity;
|
||||
|
||||
if (myEntity.flMaxJumpHeight > 1)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper __instance.BlockedTime: " + __instance.BlockedTime);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ___blockedHeight: " + ___blockedHeight);
|
||||
|
||||
bool bIsAir = false;
|
||||
|
||||
if (__instance.HitInfo != null)
|
||||
{
|
||||
int numAir = 0;
|
||||
for (int i = 0; i < (int)myEntity.flMaxJumpHeight + (int)myEntity.flMaxJumpSize; i++)
|
||||
{
|
||||
Vector3i blockPos = __instance.HitInfo.hit.blockPos;
|
||||
Vector3i EntityPos = Vector3i.zero;
|
||||
|
||||
EntityPos.x = (int)myEntity.position.x;
|
||||
EntityPos.z = (int)myEntity.position.z;
|
||||
EntityPos.y = (int)myEntity.position.y + i;
|
||||
|
||||
blockPos.y = (int)myEntity.position.y + i;
|
||||
|
||||
BlockValue block = __instance.entity.world.GetBlock(blockPos);
|
||||
BlockValue block2 = __instance.entity.world.GetBlock(EntityPos);
|
||||
|
||||
if (!block2.isair)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (block.isair)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper IS AIR");
|
||||
numAir++;
|
||||
if (numAir == (int)myEntity.flMaxJumpSize)
|
||||
{
|
||||
numHeight = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper GetBlockName: " + block.Block.GetBlockName());
|
||||
numAir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper numAir: " + numAir);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper myEntity.flMaxJumpSize: " + myEntity.flMaxJumpSize);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper myEntity.flMaxJumpHeight: " + myEntity.flMaxJumpHeight);
|
||||
|
||||
if (numAir >= (int)myEntity.flMaxJumpSize)
|
||||
{
|
||||
bIsAir = true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, X: " + myEntity.position.x);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, Y: " + myEntity.position.y);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper ENTITY, Z: " + myEntity.position.z);
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , X: " + blockPos.x);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , Y: " + blockPos.y);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper BLOCK , Z: " + blockPos.z);
|
||||
|
||||
if (!bIsAir)
|
||||
{
|
||||
num22 = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper IS AIR");
|
||||
if (__instance.BlockedTime > 0.15f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 2a");
|
||||
num22 = 0.55f + ___random.RandomFloat * 0.3f;
|
||||
}
|
||||
else if (num9 > 1.5f && num8 <= 0.040000003f && ___random.RandomFloat < 0.1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 3a");
|
||||
num22 = 0.02f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num22 = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.BlockedTime > 0.15f && ___blockedHeight < myEntity.flMaxJumpHeight)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 2b");
|
||||
num22 = 0.55f + ___random.RandomFloat * 0.3f;
|
||||
}
|
||||
else if (num9 > 1.5f && num8 <= 0.040000003f && ___random.RandomFloat < 0.1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 3b");
|
||||
num22 = 0.02f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.BlockedTime > 0.15f && ___blockedHeight < 1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 2c");
|
||||
num22 = 0.55f + ___random.RandomFloat * 0.3f;
|
||||
}
|
||||
else if (num9 > 1.5f && num8 <= 0.040000003f && ___random.RandomFloat < 0.1f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 3c");
|
||||
num22 = 0.02f;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper __instance.IsUnreachableSideJump: " + __instance.IsUnreachableSideJump);
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper num14: " + num14);
|
||||
if (__instance.IsUnreachableSideJump && num14 < 25f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 4");
|
||||
PathEntity path = __instance.entity.navigator.getPath();
|
||||
if (path == null || path.NodeCountRemaining() <= 1)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 5");
|
||||
Vector3 a = __instance.entity.position + __instance.entity.GetForwardVector() * 0.2f;
|
||||
a.y += 0.4f;
|
||||
RaycastHit raycastHit;
|
||||
if (!Physics.Raycast(a - Origin.position, Vector3.down, out raycastHit, 3.4f, 1082195968) || raycastHit.distance > 2.2f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 6");
|
||||
num22 = __instance.entity.jumpMaxDistance;
|
||||
heightDiff = __instance.UnreachablePos.y - __instance.entity.position.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper num22: " + num22);
|
||||
|
||||
if (num22 > 0f)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 7");
|
||||
Vector3i vector3i = new Vector3i(Utils.Fastfloor(position.x), Utils.Fastfloor(position.y + 2.35f), Utils.Fastfloor(position.z));
|
||||
BlockValue block = __instance.entity.world.GetBlock(vector3i);
|
||||
if (!block.Block.IsMovementBlocked(__instance.entity.world, vector3i, block, BlockFace.None))
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 8");
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED block: " + block.Block.GetBlockName());
|
||||
|
||||
if (__instance.entity is EntityNPCRebirth && block.Block.GetBlockName() == "air" && !__instance.IsBlocked)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED block: " + block.Block.GetBlockName());
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED num22: " + num22);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED heightDiff: " + heightDiff);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED ___blockedHeight: " + ___blockedHeight);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED numHeight: " + numHeight);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED ___jumpYaw: " + ___jumpYaw);
|
||||
//Log.Out("EntityMoveHelperPatches-UpdateMoveHelper IS BLOCKED __instance.IsBlocked: " + __instance.IsBlocked);
|
||||
__instance.IsUnreachableSideJump = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper StartJump D");
|
||||
StartJump.Invoke(__instance, new object[] { true, num22, heightDiff });
|
||||
|
||||
if (__instance.IsUnreachableSideJump)
|
||||
{
|
||||
//Log.Out("EntityMoveHelperRebirth-UpdateMoveHelper Jump 9");
|
||||
__instance.UnreachablePercent += 0.1f;
|
||||
__instance.IsDestroyAreaTryUnreachable = true;
|
||||
}
|
||||
}
|
||||
__instance.IsUnreachableSideJump = false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.EntityPlayerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityPlayer))]
|
||||
[HarmonyPatch("Teleport")]
|
||||
public static class TeleportPatch
|
||||
{
|
||||
public static bool Prefix(EntityPlayer __instance, Vector3 _pos, float _dir)
|
||||
{
|
||||
__instance.Buffs.AddBuff("FuriousRamsayDelay-5");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayer))]
|
||||
[HarmonyPatch("unModifiedGameStage")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class unModifiedGameStagePatch
|
||||
{
|
||||
public static void Postfix(EntityPlayer __instance, ref int __result,
|
||||
QuestJournal ___QuestJournal,
|
||||
ulong ___gameStageBornAtWorldTime
|
||||
)
|
||||
{
|
||||
float modifiedGamestage = __instance.Progression.Level * RebirthVariables.playerLevelGamestageMultiplier * GameStats.GetFloat(EnumGameStats.GameDifficultyBonus);
|
||||
|
||||
float adjustedGamestage = __instance.Buffs.GetCustomVar("$GamestageDecrease");
|
||||
|
||||
if (adjustedGamestage > 0)
|
||||
{
|
||||
modifiedGamestage = modifiedGamestage - (modifiedGamestage * adjustedGamestage);
|
||||
}
|
||||
|
||||
__result = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.GameStage, null, modifiedGamestage, __instance, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayer))]
|
||||
[HarmonyPatch("gameStage")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class gameStagePatch
|
||||
{
|
||||
public static void Postfix(EntityPlayer __instance, ref int __result,
|
||||
QuestJournal ___QuestJournal,
|
||||
ulong ___gameStageBornAtWorldTime
|
||||
)
|
||||
{
|
||||
float modifiedGamestage = __instance.Progression.Level * RebirthVariables.playerLevelGamestageMultiplier * GameStats.GetFloat(EnumGameStats.GameDifficultyBonus);
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage __instance.Progression.Level: " + __instance.Progression.Level);
|
||||
//Log.Out("EntityPlayerPatches-gameStage modifiedGamestage BEFORE: " + modifiedGamestage);
|
||||
//Log.Out("EntityPlayerPatches-gameStage RebirthVariables.playerLevelGamestageMultiplier: " + RebirthVariables.playerLevelGamestageMultiplier);
|
||||
//Log.Out("EntityPlayerPatches-gameStage GameStats.GetFloat(EnumGameStats.GameDifficultyBonus): " + GameStats.GetFloat(EnumGameStats.GameDifficultyBonus));
|
||||
|
||||
float adjustedGamestage = __instance.Buffs.GetCustomVar("$GamestageDecrease");
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage adjustedGamestage: " + adjustedGamestage);
|
||||
|
||||
/*PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(__instance.position); //__instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
|
||||
int prefabGamestage = 0;
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
int tier = poiatPosition.prefab.DifficultyTier;
|
||||
|
||||
if (tier > 0)
|
||||
{
|
||||
prefabGamestage = RebirthUtilities.AdjustGamestage((int)modifiedGamestage, tier);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage prefabGamestage: " + prefabGamestage);
|
||||
|
||||
modifiedGamestage = modifiedGamestage + prefabGamestage;*/
|
||||
|
||||
if (adjustedGamestage > 0)
|
||||
{
|
||||
modifiedGamestage = modifiedGamestage - (modifiedGamestage * adjustedGamestage);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
modifiedGamestage = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.GameStage, null, modifiedGamestage, __instance, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false));
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage modifiedGamestage HORDE NIGHT: " + modifiedGamestage);
|
||||
|
||||
__result = (int)modifiedGamestage;
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage modifiedGamestage AFTER: " + modifiedGamestage);
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage __instance.Progression.Level: " + __instance.Progression.Level);
|
||||
//Log.Out("EntityPlayerPatches-gameStage playerLevelGamestageMultiplier: " + RebirthVariables.playerLevelGamestageMultiplier);
|
||||
|
||||
float questGameStageMod = 0f;
|
||||
float questGameStageBonus = 0f;
|
||||
if (___QuestJournal.ActiveQuest != null)
|
||||
{
|
||||
questGameStageMod = ___QuestJournal.ActiveQuest.QuestClass.GameStageMod;
|
||||
questGameStageBonus = ___QuestJournal.ActiveQuest.QuestClass.GameStageBonus;
|
||||
}
|
||||
|
||||
float gamestageMod = 0f;
|
||||
float gamestageBonus = 0f;
|
||||
|
||||
string biomeName = "";
|
||||
|
||||
if (__instance.biomeStandingOn != null)
|
||||
{
|
||||
gamestageMod = __instance.biomeStandingOn.GameStageMod;
|
||||
gamestageBonus = __instance.biomeStandingOn.GameStageBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
BiomeDefinition biomeAt = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)__instance.position.x, (int)__instance.position.z);
|
||||
|
||||
if (biomeAt != null)
|
||||
{
|
||||
gamestageMod = biomeAt.GameStageMod;
|
||||
gamestageBonus = biomeAt.GameStageBonus;
|
||||
}
|
||||
}
|
||||
|
||||
//if (__instance.biomeStandingOn != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-gameStage questGameStageMod: " + questGameStageMod);
|
||||
//Log.Out("EntityPlayerPatches-gameStage questGameStageBonus: " + questGameStageBonus);
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage GameStageMod: " + gamestageMod);
|
||||
//Log.Out("EntityPlayerPatches-gameStage GameStageBonus: " + gamestageBonus);
|
||||
|
||||
modifiedGamestage = modifiedGamestage * (1f + questGameStageMod + gamestageMod) + (questGameStageBonus + gamestageBonus);
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage modifiedGamestage: " + modifiedGamestage);
|
||||
|
||||
__result = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.GameStage, null, modifiedGamestage, __instance, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false));
|
||||
//Log.Out("EntityPlayerPatches-gameStage A __result: " + __result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*modifiedGamestage = modifiedGamestage * (1f + questGameStageMod) + (questGameStageBonus);
|
||||
|
||||
//Log.Out("EntityPlayerPatches-gameStage modifiedGamestage: " + modifiedGamestage);
|
||||
|
||||
__result = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.GameStage, null, modifiedGamestage, __instance, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false));
|
||||
//Log.Out("EntityPlayerPatches-gameStage B __result: " + __result);*/
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayer))]
|
||||
[HarmonyPatch("DamageEntity")]
|
||||
public class DamageEntityPatch
|
||||
{
|
||||
private static bool Prefix(EntityPlayer __instance, ref int __result, DamageSource _damageSource, int _strength, bool _criticalHit, float _impulseScale,
|
||||
ref float ___accumulatedDamageResisted
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity __instance.EntityName: " + __instance.EntityName);
|
||||
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity IsPlayerDamageEnabled: " + GameStats.GetBool(EnumGameStats.IsPlayerDamageEnabled));
|
||||
}
|
||||
|
||||
if (_damageSource.AttackingItem != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity _damageSource.AttackingItem.ItemClass.GetItemName(): " + _damageSource.AttackingItem.ItemClass.GetItemName());
|
||||
}
|
||||
if (_damageSource.BuffClass != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity _damageSource.BuffClass.Name: " + _damageSource.BuffClass.Name);
|
||||
}
|
||||
if (_damageSource.ItemClass != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity _damageSource.ItemClass.Name: " + _damageSource.ItemClass.Name);
|
||||
}
|
||||
|
||||
EntityAlive entityAlive = __instance.world.GetEntity(_damageSource.getEntityId()) as EntityAlive;
|
||||
|
||||
if (entityAlive != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity entityAlive.EntityName: " + entityAlive.EntityName);
|
||||
}
|
||||
|
||||
bool canDamage = RebirthUtilities.VerifyFactionStanding(entityAlive, __instance);
|
||||
|
||||
if (__instance.Buffs.HasBuff("FuriousRamsayProcessRespawnDebuffs"))
|
||||
{
|
||||
canDamage = false;
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity canDamage: " + canDamage);
|
||||
|
||||
if (__instance.AttachedToEntity)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity IS ATTACHED");
|
||||
if (canDamage)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity CAN DAMAGE");
|
||||
EntityAlive vehicle = __instance.AttachedToEntity as EntityAlive;
|
||||
|
||||
if (vehicle != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity vehicle: " + vehicle.EntityName);
|
||||
|
||||
bool hasProtection = !vehicle.HasAnyTags(FastTags<TagGroup.Global>.Parse("noprotection"));
|
||||
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity hasProtection: " + hasProtection);
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity BEFORE vehicle.Health: " + vehicle.Health);
|
||||
|
||||
if (!hasProtection ||
|
||||
vehicle.Health <= 1)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity Direct Damage to the Player");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity Direct Damage to the Vehicle, _strength: " + _strength);
|
||||
vehicle.DamageEntity(_damageSource, _strength * 10, _criticalHit, _impulseScale);
|
||||
//Log.Out("EntityPlayerPatches-DamageEntity AFTER vehicle.Health: " + vehicle.Health);
|
||||
|
||||
//if (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("animal")))
|
||||
{
|
||||
}
|
||||
|
||||
if (entityAlive is EntityAliveV2)
|
||||
{
|
||||
if (entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("ranged")))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("bullethitmetal", __instance.entityId);
|
||||
}
|
||||
else if (entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("organic")))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("organichitmetal", __instance.entityId);
|
||||
}
|
||||
else if (entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("metal")))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("metalhitmetal", __instance.entityId);
|
||||
}
|
||||
else if (entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("wood")))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("woodhitmetal", __instance.entityId);
|
||||
}
|
||||
else if (entityAlive.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("wood")))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("woodhitmetal", __instance.entityId);
|
||||
}
|
||||
//Manager.PlayInsidePlayerHead("stonehitmetal", __instance.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("organichitmetal", __instance.entityId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_damageSource.ItemClass != null && (_damageSource.ItemClass.GetItemName() == "auraExplosion" || _damageSource.ItemClass.GetItemName() == "otherExplosion"))
|
||||
{
|
||||
//Log.Out($"HarmonyPatch-EntityPlayer::DamageEntity this: {__instance} - returning 0 damage false. Dmg type Heat, auraExplosion - Dmg source: {entityAlive}, faction: {entityAlive.Buffs.GetCustomVar("$faction")}");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityAlive != null && entityAlive is EntityAliveV2)
|
||||
{
|
||||
if (!canDamage)
|
||||
{
|
||||
//Log.Out($"HarmonyPatch-EntityPlayer::DamageEntity this: {__instance} - returning 0 damage false. !canDamage - Dmg source: {entityAlive}, faction: {entityAlive.Buffs.GetCustomVar("$faction")}");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE WHEN NO HIT IS FIXED - VANILLA CODE - SIMPLY RETURN TRUE
|
||||
EnumDamageSource source = _damageSource.GetSource();
|
||||
if (_damageSource.IsIgnoreConsecutiveDamages() && source != EnumDamageSource.Internal)
|
||||
{
|
||||
if (__instance.damageSourceTimeouts.ContainsKey(source) && GameTimer.Instance.ticks - __instance.damageSourceTimeouts[source] < 30UL)
|
||||
{
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
Log.Out("EntityPlayerPatches-DamageEntity NO HIT, damageSourceTimeouts");
|
||||
}
|
||||
__result = -1;
|
||||
return false;
|
||||
}
|
||||
__instance.damageSourceTimeouts[source] = GameTimer.Instance.ticks;
|
||||
}
|
||||
EntityAlive entity1 = __instance.world.GetEntity(_damageSource.getEntityId()) as EntityAlive;
|
||||
if (!__instance.FriendlyFireCheck(entity1))
|
||||
{
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
Log.Out("EntityPlayerPatches-DamageEntity NO HIT, FriendlyFireCheck: " + __instance.FriendlyFireCheck(entity1));
|
||||
}
|
||||
__result = -1;
|
||||
return false;
|
||||
}
|
||||
bool flag = _damageSource.GetDamageType() == EnumDamageTypes.Heat;
|
||||
if (!flag && (bool)(UnityEngine.Object)entity1 && (__instance.entityFlags & entity1.entityFlags & EntityFlags.Zombie) > EntityFlags.None || __instance.IsGodMode.Value)
|
||||
{
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
Log.Out("EntityPlayerPatches-DamageEntity NO HIT, entityFlags: " + __instance.entityFlags);
|
||||
}
|
||||
__result = -1;
|
||||
return false;
|
||||
}
|
||||
if (!__instance.IsDead() && (bool)(UnityEngine.Object)entity1)
|
||||
{
|
||||
float num = EffectManager.GetValue(PassiveEffects.DamageBonus, _entity: entity1);
|
||||
if ((double)num > 0.0)
|
||||
{
|
||||
_damageSource.DamageMultiplier = num;
|
||||
_damageSource.BonusDamageType = EnumDamageBonusType.Sneak;
|
||||
}
|
||||
}
|
||||
float num1 = EffectManager.GetValue(PassiveEffects.GeneralDamageResist, _entity: __instance);
|
||||
float num2 = (float)_strength * num1 + __instance.accumulatedDamageResisted;
|
||||
int num3 = (int)num2;
|
||||
__instance.accumulatedDamageResisted = num2 - (float)num3;
|
||||
_strength -= num3;
|
||||
DamageResponse _dmResponse = __instance.damageEntityLocal(_damageSource, _strength, _criticalHit, _impulseScale);
|
||||
NetPackage _package = (NetPackage)NetPackageManager.GetPackage<NetPackageDamageEntity>().Setup(__instance.entityId, _dmResponse);
|
||||
if (__instance.world.IsRemote())
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(_package);
|
||||
}
|
||||
else
|
||||
{
|
||||
int _excludePlayer = -1;
|
||||
if (!flag && _damageSource.CreatorEntityId != -2)
|
||||
{
|
||||
_excludePlayer = _damageSource.getEntityId();
|
||||
if (_damageSource.CreatorEntityId != -1)
|
||||
{
|
||||
Entity entity2 = __instance.world.GetEntity(_damageSource.CreatorEntityId);
|
||||
if ((bool)(UnityEngine.Object)entity2 && !entity2.isEntityRemote)
|
||||
_excludePlayer = -1;
|
||||
}
|
||||
}
|
||||
__instance.world.entityDistributer.SendPacketToTrackedPlayersAndTrackedEntity(__instance.entityId, _excludePlayer, _package);
|
||||
}
|
||||
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
Log.Out("EntityPlayerPatches-DamageEntity NO HIT, __result: " + __result);
|
||||
}
|
||||
__result = _dmResponse.ModStrength;
|
||||
// REMOVE WHEN NO HIT IS FIXED - VANILLA CODE - SIMPLY RETURN TRUE
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void Postfix(EntityPlayer __instance, ref int __result, DamageSource _damageSource, int _strength, bool _criticalHit, float _impulseScale)
|
||||
{
|
||||
if (__instance.Health == 0)
|
||||
{
|
||||
EntityAlive entityAlive = __instance.world.GetEntity(_damageSource.getEntityId()) as EntityAlive;
|
||||
|
||||
if (entityAlive != null && entityAlive is EntityZombie)
|
||||
{
|
||||
if (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("radiated")))
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$ZombieKilledMe", 3f);
|
||||
}
|
||||
else if (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse("feral")))
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$ZombieKilledMe", 2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$ZombieKilledMe", 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayer))]
|
||||
[HarmonyPatch("AddKillXP")]
|
||||
public class AddKillXPPatch
|
||||
{
|
||||
private static bool Prefix(EntityPlayer __instance, global::EntityAlive killedEntity, float xpModifier = 1f)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP START, xpModifier: " + xpModifier);
|
||||
int num = EntityClass.list[killedEntity.entityClass].ExperienceValue;
|
||||
num = (int)EffectManager.GetValue(PassiveEffects.ExperienceGain, killedEntity.inventory.holdingItemItemValue, (float)num, killedEntity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false);
|
||||
if (xpModifier != 1f)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP BEFORE 1, num: " + num);
|
||||
num = (int)((float)num * xpModifier);
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP AFTER 1, num: " + num);
|
||||
}
|
||||
if (__instance.IsInParty())
|
||||
{
|
||||
num = __instance.Party.GetPartyXP(__instance, num);
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP 2 IN PARTY, num: " + num);
|
||||
}
|
||||
|
||||
/*if (SkyManager.IsBloodMoonVisible())
|
||||
{
|
||||
ulong worldTime = GameManager.Instance.World.worldTime;
|
||||
ValueTuple<int, int, int> valueTuple = GameUtils.WorldTimeToElements(worldTime);
|
||||
|
||||
int num1 = valueTuple.Item2;
|
||||
int num2 = valueTuple.Item3;
|
||||
|
||||
int numDaylength = GamePrefs.GetInt(EnumGamePrefs.DayLightLength);
|
||||
|
||||
int numOpenTime = 22 - numDaylength;
|
||||
|
||||
if ((num1 == 22 && num2 >= 0) || (num1 >= 22) || num1 < numOpenTime)
|
||||
{
|
||||
num = (int)(num * 0.1);
|
||||
Log.Out("EntityPlayerPatches-AddKillXP 2 HORDE NIGHT, num: " + num);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP IS HORDE NIGHT, BEFORE num: " + num);
|
||||
num = (int)(num * RebirthVariables.hordeNightXPMultiplier);
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP AFTER, num: " + num);
|
||||
|
||||
if (!__instance.isEntityRemote)
|
||||
{
|
||||
__instance.Progression.AddLevelExp(num, "_xpFromKill", global::Progression.XPTypes.Kill, true);
|
||||
__instance.bPlayerStatsChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP 4");
|
||||
NetPackageEntityAddExpClient package = NetPackageManager.GetPackage<NetPackageEntityAddExpClient>().Setup(__instance.entityId, num, global::Progression.XPTypes.Kill);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(package, false, __instance.entityId, -1, -1, null, 192);
|
||||
}
|
||||
if (xpModifier == 1f)
|
||||
{
|
||||
//Log.Out("EntityPlayerPatches-AddKillXP 5");
|
||||
GameManager.Instance.SharedKillServer(killedEntity.entityId, __instance.entityId, xpModifier);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2272 @@
|
||||
using Audio;
|
||||
using Microsoft.SqlServer.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.EntityPlayerLocalPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("SetupStartingItems")]
|
||||
public class SetupStartingItemsPatch
|
||||
{
|
||||
private static bool Prefix(EntityPlayerLocal __instance)
|
||||
{
|
||||
__instance.inventory.Clear();
|
||||
__instance.bag.Clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("MoveByInput")]
|
||||
public class MoveByInputPatch
|
||||
{
|
||||
private static void Postfix(EntityPlayerLocal __instance)
|
||||
{
|
||||
if (__instance.MovementRunning)
|
||||
{
|
||||
if (__instance.MovementState != 3)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-MoveByInput PLAYER IS NOT RUNNING NORMALLY");
|
||||
__instance.CurrentMovementTag = EntityAlive.MovementTagIdle;
|
||||
}
|
||||
/*else
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-MoveByInput PLAYER IS RUNNING");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("DamageEntity")]
|
||||
public class DamageEntityPatch
|
||||
{
|
||||
private static bool Prefix(EntityPlayerLocal __instance, ref int __result, DamageSource _damageSource, int _strength, bool _criticalHit, float impulseScale)
|
||||
{
|
||||
if (_damageSource.AttackingItem != null && _damageSource.AttackingItem.ItemClass != null && _damageSource.AttackingItem.ItemClass.GetItemName().ToLower().Contains("wraith"))
|
||||
{
|
||||
Entity sourceEntity = __instance.world.GetEntity(_damageSource.getEntityId());
|
||||
|
||||
if (sourceEntity is EntityWraith wraith)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity REMOVE SHIELD");
|
||||
|
||||
/*var parent = wraith.gameObject.transform.parent;
|
||||
if (parent != null)
|
||||
{
|
||||
Component[] componentsInChildren = wraith.GetComponentsInChildren<Component>();
|
||||
|
||||
Log.Out($"Parent: {parent.name} [" + wraith.EntityClass.entityClassName + "]" + " / particles: " + componentsInChildren.Length);
|
||||
|
||||
for (int i = 0; i < componentsInChildren.Length; i++)
|
||||
{
|
||||
var c = componentsInChildren[i];
|
||||
Log.Out($" C: {c} - Layer: {c.gameObject.layer} - Tag: {c.tag} - Active: {c.gameObject.activeSelf} - Position: {c.gameObject.transform.position}");
|
||||
if (c.name.StartsWith("Ptl_") || c.name.StartsWith("tempPrefab_"))
|
||||
{
|
||||
//Log.Out("RebirthUtilities-RemoveCommonParticles HAS PREFAB: " + c.name);
|
||||
//entity.RemoveParticle(c.name);
|
||||
UnityEngine.Object.Destroy(c.gameObject);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//wraith.Buffs.AddBuff("FuriousRamsayWraithProtection");
|
||||
//wraith.Buffs.SetCustomVar("$FuriousRamsayAttacked", 0f);
|
||||
}
|
||||
}
|
||||
|
||||
bool flag = _damageSource.GetDamageType() == EnumDamageTypes.Heat;
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity flag: " + flag);
|
||||
if (flag && _damageSource.AttackingItem != null && _damageSource.AttackingItem.ItemClass != null && _damageSource.AttackingItem.ItemClass.GetItemName() == "otherExplosion")
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity 1");
|
||||
for (int i = 0; i < __instance.Buffs.ActiveBuffs.Count; i++)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity i: " + i);
|
||||
BuffValue buffValue = __instance.Buffs.ActiveBuffs[i];
|
||||
if (buffValue != null && buffValue.BuffClass != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity 2");
|
||||
if (buffValue.BuffName.ToLower().Contains("offensiveragebuff") && !buffValue.BuffName.ToLower().Contains("cooldown"))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity 3");
|
||||
var dmgSrcEnt = __instance.world.GetEntity(_damageSource.getEntityId()) as EntityAlive;
|
||||
//Log.Out($"HarmonyPatch-EntityPlayerLocal::DamageEntity this: {__instance} - returning 0 damage false. offensiveragebuff, Dmg source: {dmgSrcEnt}");
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-DamageEntity 4");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("AfterPlayerRespawn")]
|
||||
public class AfterPlayerRespawnPatch
|
||||
{
|
||||
private static void Postfix(EntityPlayerLocal __instance, RespawnType _type)
|
||||
{
|
||||
if (_type == RespawnType.Died)
|
||||
{
|
||||
if (__instance.Progression.Level >= 5)
|
||||
{
|
||||
int random = UnityEngine.Random.Range(60, 75);
|
||||
|
||||
__instance.Stats.Health.Value = __instance.Stats.Health.Max * random / 100;
|
||||
|
||||
random = UnityEngine.Random.Range(40, 60);
|
||||
|
||||
__instance.Stats.Water.Value = __instance.Stats.Water.Max * random / 100;
|
||||
|
||||
random = UnityEngine.Random.Range(40, 60);
|
||||
|
||||
__instance.Stats.Food.Value = __instance.Stats.Food.Max * random / 100;
|
||||
|
||||
random = UnityEngine.Random.Range(0, 1);
|
||||
|
||||
random = UnityEngine.Random.Range(0, 1);
|
||||
|
||||
Log.Out("random (Fatigue): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerFatigued");
|
||||
}
|
||||
|
||||
Log.Out("random (Sprained Arm): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerSprainedArm");
|
||||
}
|
||||
|
||||
Log.Out("random (Sprained Leg): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerSprainedLeg");
|
||||
}
|
||||
|
||||
Log.Out("random (Abrasion): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerAbrasion");
|
||||
}
|
||||
|
||||
Log.Out("random (laceration): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerLaceration");
|
||||
}
|
||||
|
||||
Log.Out("random (Infection): " + random);
|
||||
|
||||
if (random == 1)
|
||||
{
|
||||
__instance.Buffs.AddBuff("triggerInfection");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("AttachToEntity")]
|
||||
public class AttachToEntityPatch
|
||||
{
|
||||
private static bool Prefix(EntityPlayerLocal __instance, Entity _other, int slot = -1)
|
||||
{
|
||||
for (int j = 0; j < __instance.Companions.Count; j++)
|
||||
{
|
||||
EntityNPCRebirth entity = __instance.Companions[j] as EntityNPCRebirth;
|
||||
if (entity != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-AttachToEntity entity: " + entity.EntityName);
|
||||
if (!entity.IsOnMission() && !(entity.Buffs.GetCustomVar("CurrentOrder") == (int)EntityUtilities.Orders.Stay))
|
||||
{
|
||||
entity.Buffs.SetCustomVar("$traveling", 1f);
|
||||
entity.HideNPC(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("Detach")]
|
||||
public class DetachPatch
|
||||
{
|
||||
private static void Postfix(EntityPlayerLocal __instance)
|
||||
{
|
||||
for (int j = 0; j < __instance.Companions.Count; j++)
|
||||
{
|
||||
EntityNPCRebirth entity = __instance.Companions[j] as EntityNPCRebirth;
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity.IsOnMission())
|
||||
{
|
||||
entity.HideNPC(false);
|
||||
entity.Buffs.SetCustomVar("$traveling", 0f);
|
||||
entity.SetPosition(__instance.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Prefix(EntityPlayerLocal __instance)
|
||||
{
|
||||
if (__instance.AttachedToEntity)
|
||||
{
|
||||
__instance.Buffs.AddBuff("FuriousRamsayDelay-10");
|
||||
|
||||
RebirthVariables.autoRun = 0;
|
||||
|
||||
if (RebirthVariables.musicMode == 1 && !RebirthVariables.walkman)
|
||||
{
|
||||
RebirthVariables.musicMode = 0;
|
||||
}
|
||||
|
||||
if (__instance.AttachedToEntity.HasAnyTags(FastTags<TagGroup.Global>.Parse("flying")))
|
||||
{
|
||||
BlockValue block = __instance.world.GetBlock(new Vector3i(__instance.AttachedToEntity.position.x, __instance.AttachedToEntity.position.y - 1, __instance.AttachedToEntity.position.z));
|
||||
|
||||
if (block.isair)
|
||||
{
|
||||
block = __instance.world.GetBlock(new Vector3i(__instance.AttachedToEntity.position.x, __instance.AttachedToEntity.position.y - 2, __instance.AttachedToEntity.position.z));
|
||||
if (block.isair)
|
||||
{
|
||||
block = __instance.world.GetBlock(new Vector3i(__instance.AttachedToEntity.position.x, __instance.AttachedToEntity.position.y - 3, __instance.AttachedToEntity.position.z));
|
||||
if (block.isair)
|
||||
{
|
||||
block = __instance.world.GetBlock(new Vector3i(__instance.AttachedToEntity.position.x, __instance.AttachedToEntity.position.y - 4, __instance.AttachedToEntity.position.z));
|
||||
if (block.isair)
|
||||
{
|
||||
block = __instance.world.GetBlock(new Vector3i(__instance.AttachedToEntity.position.x, __instance.AttachedToEntity.position.y - 5, __instance.AttachedToEntity.position.z));
|
||||
if (block.isair)
|
||||
{
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttGetCloseToGround"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.AttachedToEntity is global::EntityVehicleRebirth)
|
||||
{
|
||||
// UPDATE SERVER INO FOR VEHICLE PART DURABILITY AND OTHER STATS
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityPlayerLocal))]
|
||||
[HarmonyPatch("OnUpdateLive")]
|
||||
public class OnUpdateLivePatch
|
||||
{
|
||||
public static bool Prefix(EntityPlayerLocal __instance)
|
||||
{
|
||||
if (__instance.IsSpawned() && __instance.IsAlive())
|
||||
{
|
||||
if (__instance.IsSpectator)
|
||||
{
|
||||
//Log.Out("SPECTATOR MODE TURNED ON");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!GameStats.GetBool(EnumGameStats.EnemySpawnMode))
|
||||
{
|
||||
//Log.Out("ENEMY SPAWNING TURNED OFF");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive class level total:" + RebirthUtilities.ClassLevels(__instance));
|
||||
|
||||
bool isAttached = false;
|
||||
if (__instance.AttachedToEntity != null)
|
||||
{
|
||||
isAttached = true;
|
||||
}
|
||||
|
||||
float auraTick = 30f;
|
||||
float variablesTick = 60f;
|
||||
float biomeTick = 3f;
|
||||
float forestTick = 50f;
|
||||
float desertTick = 50f;
|
||||
float snowTick = 50f;
|
||||
float wastelandTick = 50f;
|
||||
|
||||
float heatMapTick = 1f;
|
||||
|
||||
float berserkerTick = 3f;
|
||||
|
||||
float companionsTick = 5f;
|
||||
|
||||
float hiresTick = 10f;
|
||||
|
||||
float craftingTick = 2f;
|
||||
|
||||
float walkmanTick = 10f;
|
||||
|
||||
float modelLayerTick = 15f;
|
||||
|
||||
float gamestageTick = 1.25f;
|
||||
|
||||
float scenarioTick = 1f;
|
||||
|
||||
float purgeProgressTick = 3f;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && ((Time.time - RebirthVariables.randomWeaponUpdateCheck) > RebirthVariables.randomWeaponUpdateTick || !RebirthVariables.randomWeaponInitiated))
|
||||
{
|
||||
RebirthVariables.randomWeaponUpdateCheck = Time.time;
|
||||
RebirthUtilities.RefreshRandomWeapons(__instance);
|
||||
RebirthVariables.refreshRandomWeapons = true;
|
||||
}
|
||||
|
||||
if (RebirthVariables.purgeDisplay)
|
||||
{
|
||||
scenarioTick = 1f;
|
||||
}
|
||||
|
||||
if (RebirthVariables.customScenario == "purge" && (Time.time - RebirthVariables.purgeProgressCheck) > purgeProgressTick)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive __instance.AttachedToEntity: " + __instance.AttachedToEntity);
|
||||
|
||||
RebirthVariables.purgeProgressCheck = Time.time;
|
||||
|
||||
if (!isAttached && !__instance.IsFlyMode.Value)
|
||||
{
|
||||
float numSupplyDrops = __instance.Buffs.GetCustomVar("$numSupplyDrops");
|
||||
|
||||
if (numSupplyDrops > 0)
|
||||
{
|
||||
if ((SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !GameManager.IsDedicatedServer) || SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
// Reset skipSupplyDrops before calling SpawnAirDrop()
|
||||
RebirthVariables.skipSupplyDrops = false;
|
||||
|
||||
// Spawn the air drop
|
||||
bool canSpawn = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorAirDropComponent>().SpawnAirDrop();
|
||||
|
||||
// Restore skipSupplyDrops to true after the air drop logic
|
||||
RebirthVariables.skipSupplyDrops = true;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive canSpawn: " + canSpawn);
|
||||
|
||||
if (canSpawn)
|
||||
{
|
||||
RebirthVariables.playerAirDrops.Add(new Vector3(__instance.position.x, __instance.position.y, __instance.position.z));
|
||||
numSupplyDrops--;
|
||||
|
||||
if (numSupplyDrops < 0)
|
||||
{
|
||||
numSupplyDrops = 0;
|
||||
}
|
||||
|
||||
float numTotalSupplyDrops = __instance.Buffs.GetCustomVar("$numTotalSupplyDrops");
|
||||
if (numTotalSupplyDrops == 0f)
|
||||
{
|
||||
if (RebirthUtilities.EnnemiesAround(__instance) > 0)
|
||||
{
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("FuriousRamsayInfo_Purge3SuppliesUpdate"), __instance, 1, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameEventManager.Current.HandleAction("info_purge_suppliesupdate", __instance, __instance, false, sequenceLink: "");
|
||||
}
|
||||
__instance.Buffs.SetCustomVar("FuriousRamsayInfo_Purge3SuppliesUpdate", 1f);
|
||||
}
|
||||
numTotalSupplyDrops++;
|
||||
__instance.Buffs.SetCustomVar("$numTotalSupplyDrops", numTotalSupplyDrops);
|
||||
|
||||
__instance.Buffs.SetCustomVar("$numSupplyDrops", numSupplyDrops);
|
||||
|
||||
// Play the sound and show the tooltip
|
||||
Manager.PlayInsidePlayerHead("purge_airdrop");
|
||||
GameManager.ShowTooltip(__instance, "[936fbf]PURGE[-] OBJECTIVE REACHED. ADDITIONAL [bfbc7a]SUPPLIES[-] ARE ON THE WAY", string.Empty);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageCheckPurgeSupplyDrops>().Setup(__instance.entityId));
|
||||
}
|
||||
}
|
||||
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.CheckPurgeProgress(__instance));
|
||||
}
|
||||
}
|
||||
|
||||
if ((Time.time - RebirthVariables.scenarioCheck) > scenarioTick && __instance.biomeStandingOn != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive __instance.AttachedToEntity: " + __instance.AttachedToEntity);
|
||||
|
||||
RebirthVariables.scenarioCheck = Time.time;
|
||||
|
||||
RebirthUtilities.MoveToSpawnPoint(__instance, true);
|
||||
|
||||
if (RebirthVariables.customScenario == "none")
|
||||
{
|
||||
RebirthVariables.purgeDisplay = false;
|
||||
}
|
||||
else if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE");
|
||||
if (!isAttached && !__instance.IsFlyMode.Value)
|
||||
{
|
||||
if (!__instance.world.IsEditor() && ((SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !GameManager.IsDedicatedServer) || SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer))
|
||||
{
|
||||
string biome = __instance.biomeStandingOn.m_sBiomeName;
|
||||
|
||||
int clearedPrefabs = RebirthManager.GetTotalClearedPrefabCount(biome);
|
||||
int totalPrefabs = RebirthUtilities.GetTotalSpawnedPrefab(biome);
|
||||
|
||||
int currentClearedPrefabs = RebirthUtilities.GetPurgeBiome(biome);
|
||||
|
||||
RebirthUtilities.ChangePurgeBiome(biome, clearedPrefabs);
|
||||
|
||||
float percentage = ((float)currentClearedPrefabs / totalPrefabs) * 100;
|
||||
|
||||
RebirthVariables.purgeDisplayPercentage = ((float)clearedPrefabs / totalPrefabs) * 100;
|
||||
|
||||
int numPrefabs = clearedPrefabs;
|
||||
|
||||
if (clearedPrefabs > totalPrefabs)
|
||||
{
|
||||
numPrefabs = totalPrefabs;
|
||||
}
|
||||
|
||||
RebirthVariables.purgeLabel = numPrefabs + "/" + totalPrefabs;
|
||||
|
||||
if (RebirthVariables.testPurge)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive percentage: " + percentage);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive currentClearedPrefabs: " + currentClearedPrefabs);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive clearedPrefabs: " + clearedPrefabs);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive totalPrefabs: " + totalPrefabs);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.purgeDisplayPercentage: " + RebirthVariables.purgeDisplayPercentage);
|
||||
}
|
||||
}
|
||||
else if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IS CLIENT");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageCheckPurgeProgress>().Setup(__instance.entityId));
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE 1");
|
||||
PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(__instance.position); // __instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE POI EXISTS");
|
||||
RebirthVariables.purgePrefabName = poiatPosition.prefab.PrefabName;
|
||||
RebirthVariables.purgePrefabPosition = new Vector3(poiatPosition.boundingBoxPosition.x, poiatPosition.boundingBoxPosition.y, poiatPosition.boundingBoxPosition.z);
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
if (RebirthVariables.testPurge)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.name: " + poiatPosition.name);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.boundingBoxPosition: " + poiatPosition.boundingBoxPosition);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.prefab.PrefabName: " + poiatPosition.prefab.PrefabName);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.prefab.Tags: " + poiatPosition.prefab.Tags);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.prefab.DifficultyTier: " + poiatPosition.prefab.DifficultyTier);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive poiatPosition.prefab.SleeperVolumes.Count: " + poiatPosition.prefab.SleeperVolumes.Count);
|
||||
}
|
||||
|
||||
//if ((poiatPosition.prefab.PrefabName.ToLower().Contains("_tile_") || poiatPosition.prefab.Tags.Test_AnySet(FastTags<TagGroup.Poi>.Parse("rwgonly,streettile"))) && poiatPosition.prefab.SleeperVolumes.Count == 0)
|
||||
if (poiatPosition.prefab.SleeperVolumes.Count == 0)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IS NOT VALID");
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
if ((SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !GameManager.IsDedicatedServer) || SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
int totalKills = RebirthManager.GetTotalKills(__instance.entityId);
|
||||
__instance.Buffs.SetCustomVar("$totalPurgeKills", totalKills);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive totalKills: " + totalKills);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive $purgeKills: " + __instance.Buffs.GetCustomVar("$purgeKills"));
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive $ModPurge: " + __instance.Buffs.GetCustomVar("$ModPurge"));
|
||||
int numKills = RebirthManager.AutoRedeemKills(__instance.entityId);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numKills: " + numKills);
|
||||
|
||||
int purgeAirDropNumKills = RebirthVariables.purgeAirDropNumKills - (int)__instance.Buffs.GetCustomVar("$ModPurge") * 10;
|
||||
|
||||
if (numKills > 0)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$purgeKills", __instance.Buffs.GetCustomVar("$purgeKills") + numKills);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A $purgeKills: " + __instance.Buffs.GetCustomVar("$purgeKills"));
|
||||
|
||||
int numInterations = 0;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.purgeAirDropNumKills: " + purgeAirDropNumKills);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.purgeAirDropNumKillsIncrement: " + RebirthVariables.purgeAirDropNumKillsIncrement);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A $purgeKillsIncrement: " + __instance.Buffs.GetCustomVar("$purgeKillsIncrement"));
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive compared to: " + purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)__instance.Buffs.GetCustomVar("$purgeKillsIncrement"));
|
||||
|
||||
// Enter the while loop as long as the condition holds true
|
||||
while (__instance.Buffs.GetCustomVar("$purgeKills") >= (purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)__instance.Buffs.GetCustomVar("$purgeKillsIncrement")))
|
||||
{
|
||||
// Recalculate target kills for each iteration
|
||||
int numTargetKills = purgeAirDropNumKills + RebirthVariables.purgeAirDropNumKillsIncrement * (int)__instance.Buffs.GetCustomVar("$purgeKillsIncrement");
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numTargetKills: " + numTargetKills);
|
||||
|
||||
numInterations++;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numInterations: " + numInterations);
|
||||
|
||||
float purgeKillsIncrement = __instance.Buffs.GetCustomVar("$purgeKillsIncrement");
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive purgeKillsIncrement: " + purgeKillsIncrement);
|
||||
|
||||
// Reduce $purgeKills by the number of target kills
|
||||
__instance.Buffs.SetCustomVar("$purgeKills", __instance.Buffs.GetCustomVar("$purgeKills") - numTargetKills);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B $purgeKills: " + __instance.Buffs.GetCustomVar("$purgeKills"));
|
||||
|
||||
// Check if the incremented kills are below the max and increase accordingly
|
||||
if ((RebirthVariables.purgeAirDropNumKillsIncrement * purgeKillsIncrement) < RebirthVariables.purgeAirDropNumKillsMax)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$purgeKillsIncrement", purgeKillsIncrement + 1);
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B $purgeKillsIncrement: " + __instance.Buffs.GetCustomVar("$purgeKillsIncrement"));
|
||||
}
|
||||
|
||||
if (numInterations > 0)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numInterations: " + numInterations);
|
||||
__instance.Buffs.SetCustomVar("$numSupplyDrops", numInterations);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.checkSleeperVolumes: " + RebirthVariables.checkSleeperVolumes);
|
||||
|
||||
if (!RebirthVariables.checkSleeperVolumes)
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.checkSleeperVolumes(poiatPosition, __instance, RebirthVariables.maxSleeperVolumeCount));
|
||||
}
|
||||
}
|
||||
else if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IS CLIENT");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageCheckSleeperVolumes>().Setup(__instance.entityId, RebirthVariables.maxSleeperVolumeCount));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE REMOVE DISPLAY 1");
|
||||
RebirthVariables.purgeDisplay = false;
|
||||
RebirthVariables.purgePrefabName = "";
|
||||
RebirthVariables.purgePrefabPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE REMOVE DISPLAY 2");
|
||||
RebirthVariables.purgeDisplay = false;
|
||||
RebirthVariables.purgePrefabName = "";
|
||||
RebirthVariables.purgePrefabPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PURGE REMOVE DISPLAY 3");
|
||||
RebirthVariables.purgeDisplay = false;
|
||||
RebirthVariables.purgePrefabName = "";
|
||||
RebirthVariables.purgePrefabPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((Time.time - RebirthVariables.gamestageCheck) > gamestageTick && __instance.biomeStandingOn != null)
|
||||
{
|
||||
RebirthVariables.gamestageCheck = Time.time;
|
||||
{
|
||||
int gamestage = __instance.gameStage;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive gamestage: " + gamestage);
|
||||
|
||||
int prefabGamestage = 0;
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight() && !__instance.world.IsEditor())
|
||||
{
|
||||
//PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(__instance.position); // __instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
//PrefabInstance poiatPosition = __instance.enteredPrefab;
|
||||
PrefabInstance poiatPosition = __instance.prefab;
|
||||
//PrefabInstance poiatPosition3 = __instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
|
||||
/*if (poiatPosition != null)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive enteredPrefab: " + __instance.enteredPrefab.prefab.PrefabName);
|
||||
}*/
|
||||
if (poiatPosition == null)
|
||||
{
|
||||
poiatPosition = __instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive prefab: " + __instance.prefab.prefab.PrefabName);
|
||||
}
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive PREFAB: " + poiatPosition.prefab.PrefabName);
|
||||
int tier = poiatPosition.prefab.DifficultyTier;
|
||||
|
||||
if (tier > 0)
|
||||
{
|
||||
int biomeID = RebirthUtilities.GetCurrentBiomeID(__instance.biomeStandingOn.m_sBiomeName);
|
||||
|
||||
prefabGamestage = RebirthUtilities.AdjustGamestage((int)gamestage, tier, biomeID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive NO PREFAB");
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive prefabGamestage: " + prefabGamestage);
|
||||
|
||||
RebirthVariables.displayGamestage = gamestage + prefabGamestage;
|
||||
|
||||
string gamestageValue = RebirthVariables.displayGamestage.ToString();
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive gamestageValue: " + gamestageValue);
|
||||
|
||||
if (RebirthVariables.customInfested == "hidesurprise"
|
||||
)
|
||||
{
|
||||
List<Quest> listCurrentQuests = __instance.QuestJournal.quests;
|
||||
|
||||
for (int index = 0; index < listCurrentQuests.Count; ++index)
|
||||
{
|
||||
if (listCurrentQuests[index].CurrentState == Quest.QuestState.InProgress && listCurrentQuests[index].RallyMarkerActivated)
|
||||
{
|
||||
gamestageValue = "N/A";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.displayGamestageLabel = gamestageValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Time.time - RebirthVariables.modelLayerCheck) > heatMapTick && !isAttached)
|
||||
{
|
||||
RebirthVariables.modelLayerCheck = Time.time;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive __instance.entityId:" + __instance.entityId);
|
||||
|
||||
if (__instance.Buffs.GetCustomVar("$ModHeatMapDetection") == 1f)
|
||||
{
|
||||
if ((SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !GameManager.IsDedicatedServer) || SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
if (GameManager.Instance.World.aiDirector != null)
|
||||
{
|
||||
AIDirectorChunkEventComponent component = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorChunkEventComponent>();
|
||||
|
||||
AIDirectorChunkData dataFromPosition = component.GetChunkDataFromPosition(new Vector3i(__instance.position.x, __instance.position.y, __instance.position.z), false);
|
||||
|
||||
float percentage = 0f;
|
||||
float cooldown = 0f;
|
||||
|
||||
if (dataFromPosition != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive dataFromPosition != null");
|
||||
percentage = dataFromPosition.ActivityLevel;
|
||||
if (dataFromPosition.cooldownDelay > 0.0)
|
||||
{
|
||||
cooldown = dataFromPosition.cooldownDelay;
|
||||
}
|
||||
}
|
||||
|
||||
__instance.Buffs.SetCustomVar("$ModHeatMapDetectionValue", percentage);
|
||||
__instance.Buffs.SetCustomVar("$ModHeatMapDetectionCooldown", cooldown);
|
||||
}
|
||||
}
|
||||
else if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IS CLIENT");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageGetHeatMapValue>().Setup(__instance.entityId));
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthVariables.noHit)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive NO HIT, modelLayer: " + __instance.GetModelLayer());
|
||||
}
|
||||
|
||||
/*Log.Out("EntityPlayerLocalPatches-OnUpdateLive LOCAL PLAYER CHECK TICK, modelLayer: " + modelLayer);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive LOCAL PLAYER CHECK TICK, RebirthVariables.modelLayerCheck == 1: " + (RebirthVariables.modelLayerCheck == 1));
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive LOCAL PLAYER CHECK TICK, modelLayer != 24: " + (modelLayer != 24));
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive LOCAL PLAYER CHECK TICK, modelLayer != 10: " + (modelLayer != 10));*/
|
||||
|
||||
if (RebirthVariables.logModelLayerCheck)
|
||||
{
|
||||
List<Transform> setLayerRecursivelyList = new List<Transform>();
|
||||
__instance.emodel.GetModelTransform().gameObject.GetComponentsInChildren<Transform>(true, setLayerRecursivelyList);
|
||||
List<Transform> list = setLayerRecursivelyList;
|
||||
|
||||
bool foundLayer = false;
|
||||
|
||||
for (int i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (list[i].gameObject.layer == 2)
|
||||
{
|
||||
ulong worldTime = GameManager.Instance.World.worldTime;
|
||||
ValueTuple<int, int, int> valueTuple = GameUtils.WorldTimeToElements(worldTime);
|
||||
|
||||
int numDays = valueTuple.Item1;
|
||||
int numHours = valueTuple.Item2;
|
||||
int numMinutes = valueTuple.Item3;
|
||||
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive gameObject: " + list[i].gameObject.name + " / Layer: " + list[i].gameObject.layer + " / Game Time: " + numDays + "D: " + numHours + "H: " + numMinutes + "M");
|
||||
|
||||
foundLayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundLayer)
|
||||
{
|
||||
GameManager.ShowTooltip(__instance, "Your Model Layer is set to 2, preventing hits");
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive modelLayer: " + modelLayer + " / Game Time: " + numDays + "D:" + numHours + "H:" + numMinutes + "M");
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip() && (Time.time - RebirthVariables.walkmanCheck) > walkmanTick && !isAttached)
|
||||
{
|
||||
RebirthVariables.walkmanCheck = Time.time;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive walkmanCheck START");
|
||||
|
||||
if (RebirthUtilities.HasMod(__instance, "FuriousRamsayWalkmanMod"))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive has Walkman Mod");
|
||||
|
||||
__instance.Buffs.SetCustomVar("$walkman_FR", 1f);
|
||||
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
float volume = __instance.Buffs.GetCustomVar("$volume" + i + "_FR");
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive volume: " + volume);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthVariables.musicMode: " + RebirthVariables.musicMode);
|
||||
|
||||
if (volume == 0)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive SET VOLUME");
|
||||
|
||||
List<ProgressionValue> skills = new List<ProgressionValue>();
|
||||
__instance.Progression.GetDict().CopyValuesTo(skills);
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive skills.Count: " + skills.Count);
|
||||
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
if (skills.Count > 0)
|
||||
{
|
||||
foreach (ProgressionValue progressionValue in skills)
|
||||
{
|
||||
if (progressionValue.ProgressionClass.ParentName == "furiousramsayskillsynthwavevolume" + i)
|
||||
{
|
||||
if (progressionValue.Level == 0)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive Name: " + progressionValue.Name + ", Level: " + progressionValue.Level + ", Parent: " + progressionValue.ProgressionClass.ParentName);
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive TURN SKILL ON");
|
||||
__instance.Buffs.SetCustomVar("$volume" + i + "_FR", 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive TURN SKILL OFF");
|
||||
__instance.Buffs.SetCustomVar("$volume" + i + "_FR", 0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.musicMode != 1)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive TURN SKILL OFF");
|
||||
__instance.Buffs.SetCustomVar("$volume" + i + "_FR", 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive des not have Walkman Mod");
|
||||
|
||||
__instance.Buffs.SetCustomVar("$walkman_FR", 0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip() && (Time.time - RebirthVariables.craftingCheck) > craftingTick && !isAttached)
|
||||
{
|
||||
RebirthVariables.craftingCheck = Time.time;
|
||||
RebirthUtilities.checkCraftingProgression(__instance.inventory, __instance);
|
||||
|
||||
if (RebirthVariables.cycleArea1 == 0)
|
||||
{
|
||||
RebirthVariables.cycleArea1 = 1;
|
||||
}
|
||||
else if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
RebirthVariables.cycleArea1 = 0;
|
||||
}
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CRAFTING CHECK, RebirthVariables.cycleArea1: " + RebirthVariables.cycleArea1);
|
||||
}
|
||||
|
||||
if ((Time.time - RebirthVariables.companionsCheck) > companionsTick && !isAttached)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive HIRES CHECK");
|
||||
RebirthVariables.companionsCheck = Time.time;
|
||||
|
||||
/*for (int j = 0; j < playerHires.Count; j++)
|
||||
{
|
||||
hireInfo hire = playerHires[j];
|
||||
|
||||
if (hire.playerID == __instance.entityId)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECKING HIRE: " + hire.hireID + " / entity: " + hire.className + " / order: " + hire.order + " / reSpawnPosition: " + hire.reSpawnPosition + " / spawnPosition: " + hire.spawnPosition);
|
||||
EntityNPCRebirth hiredNPC = GameManager.Instance.World.GetEntity(hire.hireID) as EntityNPCRebirth;
|
||||
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CANNOT FIND THE ENTITY");
|
||||
}
|
||||
else if (hire.order == 1)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive hiredNPC.position: " + hiredNPC.position);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (int i = 0; i < __instance.companions.MemberList.Count; i++)
|
||||
{
|
||||
//Log.Out("CompanionGroupPatches-Remove i: " + i);
|
||||
//Log.Out("CompanionGroupPatches-Remove __instance.MemberList[" + i + "].entityId: " + __instance.companions.MemberList[i].entityId);
|
||||
|
||||
if (__instance.companions.MemberList[i] != null)
|
||||
{
|
||||
var myEntity = GameManager.Instance.World.GetEntity(__instance.companions.MemberList[i].entityId) as EntityNPCRebirth;
|
||||
if (myEntity == null)
|
||||
{
|
||||
//Log.Out("CompanionGroupPatches-Remove CANNOT FIND ENTITY");
|
||||
__instance.companions.MemberList.RemoveAt(i);
|
||||
__instance.companions.OnGroupChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if ((Time.time - RebirthVariables.hiresCheck) > hiresTick && !isAttached)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive HIRES CHECK");
|
||||
RebirthVariables.hiresCheck = Time.time;
|
||||
|
||||
SpawnPosition spawnPoint = RebirthUtilities.GetSpawnPoint(__instance);
|
||||
|
||||
if (!spawnPoint.IsUndef())
|
||||
{
|
||||
float distance = Vector3.Distance(__instance.position, spawnPoint.position);
|
||||
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive distance: " + distance);
|
||||
|
||||
if (distance < 20)
|
||||
{
|
||||
for (int j = 0; j < playerHires.Count; j++)
|
||||
{
|
||||
hireInfo hire = playerHires[j];
|
||||
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECKING HIRE: " + hire.hireID + " / entity: " + hire.className + " / resSpawnPosition: " + spawnPoint.position);
|
||||
|
||||
if (hire.playerID == __instance.entityId && hire.order == (int)EntityUtilities.Orders.Follow)
|
||||
{
|
||||
EntityNPCRebirth hiredNPC = GameManager.Instance.World.GetEntity(hire.hireID) as EntityNPCRebirth;
|
||||
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive Entity Not Found, Spawn it");
|
||||
|
||||
// SEND SPAWN NEW ENTITY TO SERVER
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRespawnHireRebirth>().Setup(hire.hireID,
|
||||
spawnPoint.position
|
||||
), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnHire(hire.hireID, spawnPoint.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RebirthManager.loadedHires: " + RebirthManager.loadedHires);
|
||||
}*/
|
||||
|
||||
if ((Time.time - RebirthVariables.biomeCheck) > biomeTick && !__instance.world.IsEditor() && RebirthVariables.customRebirthWeather && !GameUtils.IsPlaytesting() && __instance.biomeStandingOn != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive BIOME TICK");
|
||||
RebirthVariables.biomeCheck = Time.time;
|
||||
|
||||
RebirthVariables.currentBiome = __instance.biomeStandingOn.m_sBiomeName;
|
||||
|
||||
/*if (biomeAt != null && biomeAt.m_sBiomeName == "wasteland")
|
||||
{
|
||||
//SkyManager.SetFogDebugColor(new Color(0.015f, 0, 0.025f));
|
||||
|
||||
if (!RebirthVariables.inWasteland)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IN WASTELAND");
|
||||
//WeatherManager.Instance.ForceWeather("rebirth_wasteland", 60f);
|
||||
RebirthVariables.inWasteland = true;
|
||||
RebirthVariables.inForest = false;
|
||||
RebirthVariables.inSnow = false;
|
||||
RebirthVariables.inDesert = false;
|
||||
RebirthVariables.inBurntForest = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Time.time - RebirthVariables.wastelandCheck) > wastelandTick)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RESET WASTELAND WEATHER");
|
||||
RebirthVariables.wastelandCheck = Time.time;
|
||||
//WeatherManager.Instance.ForceWeather("rebirth_wasteland", 60f);
|
||||
}
|
||||
}
|
||||
|
||||
//SkyManager.SetFogDensity(0);
|
||||
}
|
||||
else if (biomeAt != null && biomeAt.m_sBiomeName == "snow")
|
||||
{
|
||||
if (!RebirthVariables.inSnow)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IN SNOW");
|
||||
//WeatherManager.Instance.ForceWeather("rebirth_snow", 60f);
|
||||
RebirthVariables.inForest = false;
|
||||
RebirthVariables.inDesert = false;
|
||||
RebirthVariables.inWasteland = false;
|
||||
RebirthVariables.inSnow = true;
|
||||
RebirthVariables.inBurntForest = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Time.time - RebirthVariables.snowCheck) > snowTick)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RESET SNOW WEATHER");
|
||||
RebirthVariables.snowCheck = Time.time;
|
||||
//WeatherManager.Instance.ForceWeather("rebirth_snow", 60f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (biomeAt != null && biomeAt.m_sBiomeName == "desert")
|
||||
{
|
||||
if (!RebirthVariables.inDesert)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IN DESERT");
|
||||
//WeatherManager.Instance.ForceWeather("default", 60f);
|
||||
RebirthVariables.inForest = false;
|
||||
RebirthVariables.inSnow = false;
|
||||
RebirthVariables.inWasteland = false;
|
||||
RebirthVariables.inDesert = true;
|
||||
RebirthVariables.inBurntForest = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Time.time - RebirthVariables.desertCheck) > desertTick)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive RESET DESERT WEATHER");
|
||||
RebirthVariables.desertCheck = Time.time;
|
||||
//WeatherManager.Instance.ForceWeather("default", 60f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RebirthVariables.inForest)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IN FOREST");
|
||||
//WeatherManager.Instance.ForceWeather("default", 5f);
|
||||
RebirthVariables.inForest = true;
|
||||
RebirthVariables.inDesert = false;
|
||||
RebirthVariables.inSnow = false;
|
||||
RebirthVariables.inWasteland = false;
|
||||
RebirthVariables.inBurntForest = false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if ((Time.time - RebirthVariables.variablesCheck) > variablesTick)
|
||||
{
|
||||
RebirthVariables.variablesCheck = Time.time;
|
||||
if (__instance.Spawned)
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(RebirthVariables.UpdateLocalVariables(__instance, 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip() && (Time.time - RebirthVariables.auraCheck) > auraTick)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive AURA TICK");
|
||||
RebirthVariables.auraCheck = Time.time;
|
||||
string optionAuraRange = RebirthVariables.customAuraRange;
|
||||
|
||||
// AURAS ======================================================================================================================
|
||||
foreach (string key in RebirthVariables.localAuras.Keys)
|
||||
{
|
||||
if (__instance.Buffs.HasBuff("FuriousRamsayBuff" + key + "Aura"))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive aura: " + key);
|
||||
|
||||
ProgressionValue progressionValue = __instance.Progression.GetProgressionValue(RebirthVariables.localAuras[key].progressionName);
|
||||
int progressionLevel = progressionValue.Level;
|
||||
|
||||
if (progressionLevel > 0 && RebirthUtilities.HasMod(__instance, RebirthVariables.localAuras[key].modName))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 1");
|
||||
// PARTY MEMBERS
|
||||
if (__instance.Party != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 2");
|
||||
if (__instance.Party.MemberList != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 3, HAS PARTY MEMBERS");
|
||||
for (int j = 0; j < __instance.Party.MemberList.Count; j++)
|
||||
{
|
||||
EntityPlayer partyMember = __instance.Party.MemberList[j] as EntityPlayer;
|
||||
|
||||
bool isWithinRange = Vector3.Distance(partyMember.position, __instance.position) < (float)GameStats.GetInt(EnumGameStats.PartySharedKillRange);
|
||||
|
||||
if (optionAuraRange == "always")
|
||||
{
|
||||
isWithinRange = true;
|
||||
}
|
||||
else if (optionAuraRange == "never")
|
||||
{
|
||||
isWithinRange = false;
|
||||
}
|
||||
|
||||
if (partyMember.entityId != __instance.entityId && isWithinRange)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 4, j: " + j + ", partyMember: " + partyMember.EntityName);
|
||||
|
||||
if (!partyMember.Buffs.HasBuff(RebirthVariables.localAuras[key].allyAura + progressionLevel))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 5, member doesn't have buff: " + key);
|
||||
bool addBuff = true;
|
||||
foreach (BuffValue buffValue in partyMember.Buffs.ActiveBuffs)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 6");
|
||||
if (buffValue != null && buffValue.BuffClass != null)
|
||||
{
|
||||
BuffClass buffClass = buffValue.BuffClass;
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 7, buffClass: " + buffClass.Name);
|
||||
|
||||
if (buffClass.Name.Contains(RebirthVariables.localAuras[key].allyAura))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 8, FOUND MATCHING BUFF");
|
||||
if (int.Parse(buffClass.Name.Replace(RebirthVariables.localAuras[key].allyAura, "")) < progressionLevel)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 10");
|
||||
partyMember.Buffs.RemoveBuff(buffClass.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addBuff)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive 11");
|
||||
partyMember.Buffs.AddBuff(RebirthVariables.localAuras[key].allyAura + progressionLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < __instance.Companions.Count; j++)
|
||||
{
|
||||
EntityNPCRebirth companion = __instance.Companions[j] as EntityNPCRebirth;
|
||||
|
||||
if (companion.HasAllTags(FastTags<TagGroup.Global>.Parse("ranged")))
|
||||
{
|
||||
if (!companion.Buffs.HasBuff(RebirthVariables.localAuras[key].allyAura + progressionLevel))
|
||||
{
|
||||
bool addBuff = true;
|
||||
foreach (BuffValue buffValue in companion.Buffs.ActiveBuffs)
|
||||
{
|
||||
if (buffValue != null && buffValue.BuffClass != null)
|
||||
{
|
||||
BuffClass buffClass = buffValue.BuffClass;
|
||||
if (buffClass.Name.Contains(RebirthVariables.localAuras[key].allyAura))
|
||||
{
|
||||
if (int.Parse(buffClass.Name.Replace(RebirthVariables.localAuras[key].allyAura, "")) < progressionLevel)
|
||||
{
|
||||
companion.Buffs.RemoveBuff(buffClass.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addBuff)
|
||||
{
|
||||
companion.Buffs.AddBuff(RebirthVariables.localAuras[key].allyAura + progressionLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EVENTS ======================================================================================================================
|
||||
float eventCheck = __instance.Buffs.GetCustomVar("$FuriousRamsayEventCheck");
|
||||
float eventCheckEntity = __instance.Buffs.GetCustomVar("$FuriousRamsayEventCheckEntity");
|
||||
float eventCheckEntityBloodMoon = __instance.Buffs.GetCustomVar("$FuriousRamsayEventCheckEntityBloodMoon");
|
||||
float eventCheckCooldown = __instance.Buffs.GetCustomVar("$FuriousRamsayEventCheckCooldown");
|
||||
float numEvents = __instance.Buffs.GetCustomVar("$FuriousRamsayNumEvents");
|
||||
float eventTick = 60f;
|
||||
float eventTickEntityBloodMoon = 30f;
|
||||
float eventTickCooldown = 10f;
|
||||
int eventCooldown = 0;
|
||||
|
||||
if (eventCheck > Time.time)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheck", 0f);
|
||||
eventCheck = 0f;
|
||||
}
|
||||
if (eventCheckEntity > Time.time)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckEntity", 0f);
|
||||
eventCheckEntity = 0f;
|
||||
}
|
||||
if (eventCheckEntityBloodMoon > Time.time)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckEntityBloodMoon", 0f);
|
||||
eventCheckEntityBloodMoon = 0f;
|
||||
}
|
||||
|
||||
if (eventCheckCooldown > Time.time)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckCooldown", 0f);
|
||||
eventCheckCooldown = 0f;
|
||||
}
|
||||
|
||||
// EVENT COOLDOWN
|
||||
if ((Time.time - eventCheckCooldown) > eventTickCooldown)
|
||||
{
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckCooldown", Time.time);
|
||||
eventCooldown = (int)__instance.Buffs.GetCustomVar("$FuriousRamsayEventTotalCooldown") - 10;
|
||||
if (eventCooldown < 0)
|
||||
{
|
||||
eventCooldown = 0;
|
||||
}
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive eventCooldown: " + eventCooldown);
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventTotalCooldown", eventCooldown);
|
||||
}
|
||||
|
||||
// ENTITY EVENTS - HORDE NIGHT
|
||||
if (!RebirthUtilities.ScenarioSkip() && (Time.time - eventCheckEntityBloodMoon) > eventTickEntityBloodMoon && !isAttached)
|
||||
{
|
||||
int randomInt = 0;
|
||||
|
||||
if (RebirthVariables.customHordeNight && RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive ENTITY - IS HORDE NIGHT");
|
||||
|
||||
randomInt = __instance.rand.RandomRange(1, 50);
|
||||
int playerLevel = __instance.Progression.GetLevel();
|
||||
|
||||
// SEEKERS
|
||||
if (randomInt == 1)
|
||||
{
|
||||
if (playerLevel >= 30 && playerLevel < 50)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker001", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 50 && playerLevel < 70)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker002", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 70 && playerLevel < 90)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker003", 2, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 90 && playerLevel < 110)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker004", 2, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 110 && playerLevel < 130)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker005", 3, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 130 && playerLevel < 150)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker006", 3, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 150)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker007", 4, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
}
|
||||
// WRAITHS
|
||||
/*if (randomInt == 2)
|
||||
{
|
||||
if (playerLevel >= 60 && playerLevel < 80)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith001", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 80 && playerLevel < 100)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith002", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 100 && playerLevel < 120)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith003", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 120 && playerLevel < 140)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith004", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 140)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith005", 3, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckEntityBloodMoon", Time.time);
|
||||
}
|
||||
|
||||
string frequency = RebirthVariables.customEventsFrequency;
|
||||
|
||||
if (frequency == "less")
|
||||
{
|
||||
frequency = "50";
|
||||
}
|
||||
else if (frequency == "normal")
|
||||
{
|
||||
frequency = "100";
|
||||
}
|
||||
else if (frequency == "more")
|
||||
{
|
||||
frequency = "150";
|
||||
}
|
||||
|
||||
float optionEventsFrequency = float.Parse(frequency) / 100;
|
||||
|
||||
if (optionEventsFrequency == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
float eventTickEntity = 30f / optionEventsFrequency;
|
||||
|
||||
// ENTITY EVENTS - NOT HORDE NIGHT
|
||||
if (!RebirthUtilities.ScenarioSkip() && ((Time.time - eventCheckEntity) > eventTickEntity) || (RebirthVariables.testEvents && RebirthVariables.testEventsCategory == 2) && !isAttached)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive ENTITY EVENT TICK");
|
||||
|
||||
int randomInt = 0;
|
||||
|
||||
float daringAdventurer = __instance.Progression.GetProgressionValue("perkDaringAdventurer").calculatedLevel + 1;
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive ENTITY - IS NOT HORDE NIGHT");
|
||||
|
||||
bool isIndoors = RebirthUtilities.IsIndoors(__instance);
|
||||
bool IsQuestingInPOI = RebirthUtilities.IsQuestingInPOI(__instance);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive isIndoors: " + isIndoors);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive IsQuestingInPOI: " + IsQuestingInPOI);
|
||||
|
||||
randomInt = __instance.rand.RandomRange(0, 500);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive randomInt: " + randomInt);
|
||||
|
||||
int playerLevel = __instance.Progression.Level;
|
||||
|
||||
if (RebirthVariables.testEvents)
|
||||
{
|
||||
randomInt = RebirthVariables.testEventsType;
|
||||
playerLevel = RebirthVariables.testEventsPlayerLevel;
|
||||
__instance.Buffs.RemoveBuff("FuriousRamsayBanditEvent");
|
||||
__instance.Buffs.RemoveBuff("FuriousRamsayBanditEventInProgress");
|
||||
eventCooldown = 0;
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive randomInt: " + randomInt);
|
||||
}
|
||||
|
||||
bool skipEvent = false;
|
||||
|
||||
string optionEntityEvents = RebirthVariables.customEntityEvents;
|
||||
bool customEventsBandits = RebirthVariables.customEventsBandits;
|
||||
|
||||
if (optionEntityEvents == "never")
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK ENTITY EVENTS 1");
|
||||
skipEvent = true;
|
||||
}
|
||||
else if (optionEntityEvents == "notquesting" && RebirthUtilities.IsQuesting(__instance))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK ENTITY EVENTS 2");
|
||||
skipEvent = true;
|
||||
}
|
||||
|
||||
if (RebirthVariables.testEvents)
|
||||
{
|
||||
isIndoors = true;
|
||||
skipEvent = false;
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive isIndoors: " + isIndoors);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK ENTITY EVENTS, optionEntityEvents: " + optionEntityEvents);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK ENTITY EVENTS, RebirthUtilities.IsQuesting(__instance): " + RebirthUtilities.IsQuesting(__instance));
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive skipEvent: " + skipEvent);
|
||||
}
|
||||
|
||||
if ((isIndoors || IsQuestingInPOI) && !skipEvent && customEventsBandits)
|
||||
{
|
||||
string navIconBoss = RebirthVariables.navIconBossEventNoHealth;
|
||||
string navIconSupport = RebirthVariables.navIconSupportEventNoHealth;
|
||||
|
||||
if (RebirthVariables.customTargetBarVisibility == "always")
|
||||
{
|
||||
navIconBoss = RebirthVariables.navIconBossEvent;
|
||||
navIconSupport = RebirthVariables.navIconSupportEvent;
|
||||
}
|
||||
if (!RebirthVariables.customEventsNotification)
|
||||
{
|
||||
navIconBoss = "";
|
||||
navIconSupport = "";
|
||||
}
|
||||
|
||||
navIconSupport = "";
|
||||
navIconBoss = "";
|
||||
|
||||
float classLevels = RebirthUtilities.ClassLevels(__instance);
|
||||
|
||||
if (RebirthVariables.testEvents)
|
||||
{
|
||||
RebirthVariables.testEvents = false;
|
||||
RebirthVariables.testEventsCategory = 0;
|
||||
classLevels = RebirthVariables.testEventsClassLevel;
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive PLAYER TEST EVENT TURNED OFF");
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive navIconBoss: " + navIconBoss);
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive classLevels: " + classLevels);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive FuriousRamsayBanditEventInProgress: " + __instance.Buffs.HasBuff("FuriousRamsayBanditEventInProgress"));
|
||||
|
||||
// BANDITS
|
||||
if (playerLevel >= 10 && !__instance.Buffs.HasBuff("FuriousRamsayBanditEventInProgress"))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive BANDIT EVENT 1");
|
||||
|
||||
bool forceEvent = false;
|
||||
|
||||
if (IsQuestingInPOI)
|
||||
{
|
||||
PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(__instance.position); // __instance.world.GetPOIAtPosition(__instance.position, false);
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
int tier = poiatPosition.prefab.DifficultyTier;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive tier: " + tier);
|
||||
|
||||
forceEvent = RebirthUtilities.WillPOIBanditEventTrigger(tier);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive forceEvent: " + forceEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if ((randomInt >= 6 && randomInt <= 8) || forceEvent)
|
||||
{
|
||||
bool hasBanditEvent = __instance.Buffs.HasBuff("FuriousRamsayBanditEvent");
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive hasBanditEvent: " + hasBanditEvent);
|
||||
|
||||
if (__instance.Party != null && __instance.Party.MemberList != null)
|
||||
{
|
||||
for (int j = 0; j < __instance.Party.MemberList.Count; j++)
|
||||
{
|
||||
EntityPlayer partyMember = __instance.Party.MemberList[j] as EntityPlayer;
|
||||
|
||||
float distance = partyMember.GetDistance(__instance);
|
||||
|
||||
if (distance < 100 && partyMember.Buffs.HasBuff("FuriousRamsayBanditEventInProgress"))
|
||||
{
|
||||
hasBanditEvent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBanditEvent)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive BANDIT EVENT 2");
|
||||
|
||||
string minionBuff = "FuriousRamsayNPCMinionBuffTier1";
|
||||
string supportBuff = "FuriousRamsayNPCSupportBuffTier1";
|
||||
string buffBoss = "FuriousRamsayNPCBossBuffTier1";
|
||||
string bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
|
||||
if (classLevels >= 2.3f && classLevels < 3.4f)
|
||||
{
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEvent");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEventInProgress");
|
||||
RebirthUtilities.PlayCompanionSpawnSound(__instance);
|
||||
|
||||
// Minions
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001cBat", 1, "", "", "40", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002hSpear", 1, "", "", "41", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002fKnife", 1, "", "", "42", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
// Support
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001gMachete", 1, "", "", "43", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002bBat", 1, "", "", "44", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
// Boss
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002dAxe", 1, "", "", "45", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 2, -1, "", bossCrate, 1, navIconBoss, buffBoss);
|
||||
}
|
||||
else if (classLevels >= 3.4f && classLevels < 4.7f)
|
||||
{
|
||||
minionBuff = "FuriousRamsayNPCMinionBuffTier2";
|
||||
supportBuff = "FuriousRamsayNPCSupportBuffTier2";
|
||||
buffBoss = "FuriousRamsayNPCBossBuffTier2";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEvent");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEventInProgress");
|
||||
RebirthUtilities.PlayCompanionSpawnSound(__instance);
|
||||
|
||||
// Minions
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001cBat", 1, "", "", "40", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001bAxe", 1, "", "", "41", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001gMachete", 1, "", "", "42", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002bBat", 1, "", "", "43", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002fKnife", 1, "", "", "44", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
// Support
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002dAxe", 1, "", "", "45", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002hSpear", 1, "", "", "46", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
// Boss
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001hPipeRifle", 1, "", "", "47", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 2, -1, "", bossCrate, 1, navIconBoss, buffBoss);
|
||||
}
|
||||
else if (classLevels >= 4.7f && classLevels < 6.2f)
|
||||
{
|
||||
minionBuff = "FuriousRamsayNPCMinionBuffTier3";
|
||||
supportBuff = "FuriousRamsayNPCSupportBuffTier3";
|
||||
buffBoss = "FuriousRamsayNPCBossBuffTier3";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEvent");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEventInProgress");
|
||||
RebirthUtilities.PlayCompanionSpawnSound(__instance);
|
||||
|
||||
// Minions
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001cBat", 1, "", "", "40", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001bAxe", 1, "", "", "41", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001gMachete", 1, "", "", "42", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002bBat", 1, "", "", "43", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002dAxe", 1, "", "", "44", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002fKnife", 1, "", "", "45", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002hSpear", 1, "", "", "46", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
// Support
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditWoman001bMachete", 1, "", "", "47", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001fPipeRifle", 1, "", "", "48", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
// Boss
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001aPipePistol", 1, "", "", "49", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 2, -1, "", bossCrate, 1, navIconBoss, buffBoss);
|
||||
}
|
||||
else if (classLevels >= 6.2f)
|
||||
{
|
||||
minionBuff = "FuriousRamsayNPCMinionBuffTier4";
|
||||
supportBuff = "FuriousRamsayNPCSupportBuffTier4";
|
||||
buffBoss = "FuriousRamsayNPCBossBuffTier4";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEvent");
|
||||
__instance.Buffs.AddBuff("FuriousRamsayBanditEventInProgress");
|
||||
RebirthUtilities.PlayCompanionSpawnSound(__instance);
|
||||
|
||||
// Minions
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001cBat", 1, "", "", "40", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001bAxe", 1, "", "", "41", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001gMachete", 1, "", "", "42", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002bBat", 1, "", "", "43", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002dAxe", 1, "", "", "44", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002fKnife", 1, "", "", "45", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan002hSpear", 1, "", "", "46", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditWoman001bMachete", 1, "", "", "47", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//birthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditWoman001dBat", 1, "", "", "48", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditWoman001eSpear", 1, "", "", "49", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditWoman001gAxe", 1, "", "", "50", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001aPipePistol", 1, "", "", "51", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, -1, -1, "", "", 0, "", minionBuff);
|
||||
// Support
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001fPipeRifle", 1, "", "", "52", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001hPipeRifle", 1, "", "", "53", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 99, -1, "", "", 0, navIconSupport, supportBuff);
|
||||
// Boss
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditMan001cPipeMachineGun", 1, "", "", "54", "static", "", "", 1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 1, 1, 2, -1, "", bossCrate, 1, navIconBoss, buffBoss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// SEEKERS
|
||||
if (randomInt >= 0 && randomInt <= 1)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive playerLevel: " + playerLevel);
|
||||
if (playerLevel >= 30 && playerLevel < 40)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker001", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 40 && playerLevel < 50)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker002", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 50 && playerLevel < 60)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker003", 2, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 60 && playerLevel < 70)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker004", 2, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 70 && playerLevel < 80)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker005", 3, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 80 && playerLevel < 90)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker006", 3, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
else if (playerLevel >= 90)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive playerLevel: " + playerLevel);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsaySeeker007", 4, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
if (RebirthVariables.customEventsNotification)
|
||||
GameManager.ShowTooltip(__instance, Localization.Get("ttSeeker"));
|
||||
}
|
||||
}
|
||||
// WRAITHS
|
||||
/*if (randomInt == 2)
|
||||
{
|
||||
if (playerLevel >= 50 && playerLevel < 70)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith001", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 70 && playerLevel < 90)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith002", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 90 && playerLevel < 110)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith003", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 110 && playerLevel < 130)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith004", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 130)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith005", 3, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isAttached)
|
||||
{
|
||||
// PAIRED DOWN, NPCs
|
||||
/*randomInt = __instance.rand.RandomRange(1, 100);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive randomInt: " + randomInt);
|
||||
|
||||
// ROBOT
|
||||
if (randomInt >= 1 && randomInt <= 2)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive ROBOT");
|
||||
if (playerLevel >= 15 && playerLevel < 30)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditHumanoidRobot001", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 30 && playerLevel < 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive SPAWN ROBOT 2");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditHumanoidRobot002", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 60)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditHumanoidRobot003", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}
|
||||
// CYBORG
|
||||
if (randomInt >= 3 && randomInt <= 4)
|
||||
{
|
||||
if (playerLevel >= 10 && playerLevel < 25)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg003a", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 25 && playerLevel < 45)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg003b", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 45 && playerLevel < 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg003c", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg003d", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}
|
||||
// CYBORG 2
|
||||
if (randomInt >= 5 && randomInt <= 6)
|
||||
{
|
||||
if (playerLevel >= 45 && playerLevel < 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg002a", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg002a", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}
|
||||
// BLACK SHIELD CYBORG
|
||||
if (randomInt >= 7 && randomInt <= 8)
|
||||
{
|
||||
if (playerLevel >= 25 && playerLevel < 45)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg001b", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 45 && playerLevel < 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg001c", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 65)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayBanditCyborg001a", 1, "", "", "50", "static", "1", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}*/
|
||||
// WRAITHS
|
||||
/*if (randomInt == 8)
|
||||
{
|
||||
if (playerLevel >= 50 && playerLevel < 70)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith001", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 70 && playerLevel < 90)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith002", 1, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 90 && playerLevel < 110)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith003", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 110 && playerLevel < 130)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith004", 2, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
else if (playerLevel >= 130)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayWraith005", 3, "", "", "30", "static", "100", "", 1, -1, true, false, true, __instance.entityId);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheckEntity", Time.time);
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive Time.time: " + Time.time);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive eventCheck: " + eventCheck);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive eventTick: " + eventTick);
|
||||
|
||||
float tempEventTick = eventTick / optionEventsFrequency;
|
||||
|
||||
// NORMAL EVENTS
|
||||
if (!RebirthUtilities.ScenarioSkip() && ((Time.time - eventCheck) > tempEventTick) || (RebirthVariables.testEvents && RebirthVariables.testEventsCategory == 1) && !isAttached)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive NORMAL EVENTS");
|
||||
|
||||
bool isHoldingTool = __instance.inventory.holdingItem.HasAnyTags(FastTags<TagGroup.Global>.Parse("shovel,auger"));
|
||||
|
||||
float daringAdventurer = __instance.Progression.GetProgressionValue("perkDaringAdventurer").calculatedLevel + 1;
|
||||
|
||||
int randomInt = 0;
|
||||
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive ISN'T HORDE NIGHT");
|
||||
|
||||
ulong worldTime = GameManager.Instance.World.worldTime;
|
||||
ValueTuple<int, int, int> valueTuple = GameUtils.WorldTimeToElements(worldTime);
|
||||
|
||||
int numDays = valueTuple.Item1;
|
||||
int numHours = valueTuple.Item2;
|
||||
int numMinutes = valueTuple.Item3;
|
||||
|
||||
int playerLevel = __instance.Progression.GetLevel();
|
||||
float numEventsFrequency = 0.75f / optionEventsFrequency;
|
||||
|
||||
int numEventsMax = 1;
|
||||
|
||||
bool isActive = (numHours >= 4 && numHours < 22);
|
||||
|
||||
bool optionEventsNight = RebirthVariables.customEventsNight;
|
||||
|
||||
if (optionEventsNight)
|
||||
{
|
||||
isActive = (numHours >= 0 && numHours < 23);
|
||||
}
|
||||
|
||||
if (optionEventsFrequency <= .5f)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive LESS: " + optionEventsFrequency);
|
||||
if (playerLevel >= 20 && playerLevel < 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive LESS 1");
|
||||
numEventsMax = 1;
|
||||
}
|
||||
else if (playerLevel >= 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive LESS 2");
|
||||
numEventsMax = 1;
|
||||
}
|
||||
}
|
||||
else if (optionEventsFrequency >= 1.5f)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive MORE: " + optionEventsFrequency);
|
||||
numEventsMax = 1;
|
||||
|
||||
if (playerLevel >= 20 && playerLevel < 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive MORE 1");
|
||||
numEventsMax = 2;
|
||||
}
|
||||
else if (playerLevel >= 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive MORE 2");
|
||||
numEventsMax = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive NORMAL: " + optionEventsFrequency);
|
||||
if (playerLevel >= 20 && playerLevel < 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive NORMAL 1");
|
||||
numEventsMax = 1;
|
||||
}
|
||||
else if (playerLevel >= 60)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive NORMAL 2");
|
||||
numEventsMax = 2;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("=========================================================================");
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numEvents: " + numEvents);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numEventsMax: " + numEventsMax);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive isActive: " + isActive);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numEventsFrequency: " + numEventsFrequency);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numHours >= 8 && numHours < 20: " + (numHours >= 8 && numHours < 20));
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive numEvents < numEventsMax: " + (numEvents < numEventsMax));
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive isHoldingTool: " + isHoldingTool);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive isAttached: " + isAttached);
|
||||
|
||||
bool isBelowEventMax = numEvents < numEventsMax;
|
||||
|
||||
if (RebirthVariables.testEvents)
|
||||
{
|
||||
isActive = true;
|
||||
isBelowEventMax = true;
|
||||
playerLevel = RebirthVariables.testEventsPlayerLevel;
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive playerLevel: " + playerLevel);
|
||||
}
|
||||
|
||||
if (isActive && isBelowEventMax && !isHoldingTool && !isAttached)
|
||||
{
|
||||
if (playerLevel >= 8 && playerLevel < 15)
|
||||
{
|
||||
randomInt = (int)(__instance.rand.RandomRange(0, 1000 * numEventsFrequency));
|
||||
}
|
||||
else if (playerLevel >= 15 && playerLevel < 25)
|
||||
{
|
||||
randomInt = (int)(__instance.rand.RandomRange(0, 950 * numEventsFrequency));
|
||||
}
|
||||
else if (playerLevel >= 25 && playerLevel < 35)
|
||||
{
|
||||
randomInt = (int)(__instance.rand.RandomRange(0, 900 * numEventsFrequency));
|
||||
}
|
||||
else
|
||||
{
|
||||
randomInt = (int)(__instance.rand.RandomRange(0, 850 * numEventsFrequency));
|
||||
}
|
||||
|
||||
string optionEventRestriction = RebirthVariables.customEventRestrictions;
|
||||
|
||||
bool skipEvent = false;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, optionEventRestriction: " + optionEventRestriction);
|
||||
|
||||
if (optionEventRestriction == "off")
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 1");
|
||||
skipEvent = true;
|
||||
}
|
||||
else if (optionEventRestriction == "onlyquesting" && !RebirthUtilities.IsQuesting(__instance))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 2");
|
||||
skipEvent = true;
|
||||
}
|
||||
else if (optionEventRestriction == "notquesting" && RebirthUtilities.IsQuesting(__instance))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 3");
|
||||
skipEvent = true;
|
||||
}
|
||||
else if (optionEventRestriction == "notinside" && RebirthUtilities.IsIndoors(__instance))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 4");
|
||||
skipEvent = true;
|
||||
}
|
||||
else if (optionEventRestriction == "notquestinginside")
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 5");
|
||||
if (RebirthUtilities.IsQuesting(__instance) || RebirthUtilities.IsIndoors(__instance))
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS 6");
|
||||
skipEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, skipEvent: " + skipEvent);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, eventCooldown: " + eventCooldown);
|
||||
|
||||
if (RebirthVariables.testEvents && RebirthVariables.testEventsCategory == 1)
|
||||
{
|
||||
randomInt = RebirthVariables.testEventsType;
|
||||
eventCooldown = 0;
|
||||
skipEvent = false;
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive randomInt: " + randomInt);
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive randomInt: " + randomInt);
|
||||
|
||||
if (eventCooldown <= 0 && !skipEvent)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A");
|
||||
|
||||
bool canSpawn = false;
|
||||
bool hasSupport = true;
|
||||
|
||||
string buffMinion = "";
|
||||
string buffSupport = "";
|
||||
string buffBoss = "";
|
||||
string bossCrate = "";
|
||||
SpawnType spawnType = SpawnType.None;
|
||||
int numSpawns = 10;
|
||||
int numSupportSpawns = 2;
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive playerLevel: " + playerLevel);
|
||||
|
||||
if (playerLevel >= 8 && playerLevel < 20)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A1");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A1a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier1";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1B";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
hasSupport = false;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
}
|
||||
if (playerLevel >= 20 && playerLevel < 35)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A1");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A1a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier1";
|
||||
buffSupport = "FuriousRamsaySupportBuffTier1";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1B";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
}
|
||||
else if (playerLevel >= 35 && playerLevel < 50)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A2");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A2a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier2";
|
||||
buffSupport = "FuriousRamsaySupportBuffTier2";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1C";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
else if (randomInt >= 6 && randomInt <= 7 && RebirthVariables.customEventsZombieAnimals)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A2b");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier2NoSpeed";
|
||||
buffSupport = "";
|
||||
buffBoss = "FuriousRamsayBossBuffTier2Animal";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
numSupportSpawns = 1;
|
||||
spawnType = SpawnType.ZombieAnimals;
|
||||
}
|
||||
}
|
||||
else if (playerLevel >= 50 && playerLevel < 80)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A3");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A3a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier3";
|
||||
buffSupport = "FuriousRamsaySupportBuffTier3";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1D";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
else if (randomInt >= 6 && randomInt <= 7 && RebirthVariables.customEventsZombieAnimals)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A3b");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier3NoSpeed";
|
||||
buffSupport = "";
|
||||
buffBoss = "FuriousRamsayBossBuffTier3Animal";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
numSupportSpawns = 1;
|
||||
spawnType = SpawnType.ZombieAnimals;
|
||||
}
|
||||
}
|
||||
else if (playerLevel >= 80 && playerLevel < 110)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A4");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A4a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier4";
|
||||
buffSupport = "FuriousRamsaySupportBuffTier4";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1E";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
else if (randomInt >= 6 && randomInt <= 7 && RebirthVariables.customEventsZombieAnimals)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A4b");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier4NoSpeed";
|
||||
buffSupport = "";
|
||||
buffBoss = "FuriousRamsayBossBuffTier4Animal";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.ZombieAnimals;
|
||||
}
|
||||
}
|
||||
else if (playerLevel >= 110)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A5");
|
||||
if (randomInt >= 0 && randomInt <= 5)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A5a");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier5";
|
||||
buffSupport = "FuriousRamsaySupportBuffTier5";
|
||||
buffBoss = "FuriousRamsayBossBuffTier1F";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.Zombies;
|
||||
}
|
||||
else if (randomInt >= 6 && randomInt <= 7 && RebirthVariables.customEventsZombieAnimals)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive A5b");
|
||||
buffMinion = "FuriousRamsayMinionBuffTier5NoSpeed";
|
||||
buffSupport = "";
|
||||
buffBoss = "FuriousRamsayBossBuffTier5Animal";
|
||||
bossCrate = "FuriousRamsayEventLootContainerEntityTier" + daringAdventurer;
|
||||
canSpawn = true;
|
||||
spawnType = SpawnType.ZombieAnimals;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive canSpawn: " + canSpawn);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive spawnType: " + spawnType);
|
||||
|
||||
if (canSpawn)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B");
|
||||
string navIconBoss = RebirthVariables.navIconBossEventNoHealth;
|
||||
string navIconSupport = RebirthVariables.navIconSupportEventNoHealth;
|
||||
string navIconMinion = "";
|
||||
|
||||
if (RebirthVariables.customTargetBarVisibility == "always")
|
||||
{
|
||||
navIconBoss = RebirthVariables.navIconBossEvent;
|
||||
navIconSupport = RebirthVariables.navIconSupportEvent;
|
||||
}
|
||||
if (!RebirthVariables.customEventsNotification)
|
||||
{
|
||||
navIconBoss = "";
|
||||
navIconSupport = "";
|
||||
}
|
||||
|
||||
List<int> entitiesMinions = null;
|
||||
List<int> entitiesSupport = null;
|
||||
List<int> entitiesBosses = null;
|
||||
int gamestage = __instance.gameStage;
|
||||
|
||||
if (RebirthVariables.customEventsDifficulty.ToLower() == "less")
|
||||
{
|
||||
gamestage = __instance.gameStage - 30;
|
||||
if (gamestage < 0)
|
||||
{
|
||||
gamestage = 10;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.customEventsDifficulty.ToLower() == "more")
|
||||
{
|
||||
gamestage = __instance.gameStage + 50;
|
||||
}
|
||||
else if (RebirthVariables.customEventsDifficulty.ToLower() == "random")
|
||||
{
|
||||
int randomIncrease = GameManager.Instance.World.GetGameRandom().RandomRange(15, 75);
|
||||
gamestage = __instance.gameStage + randomIncrease;
|
||||
}
|
||||
|
||||
bool useDuplicates = false;
|
||||
|
||||
if (spawnType == SpawnType.Zombies)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B1");
|
||||
entitiesBosses = RebirthUtilities.BuildEntityGroup(gamestage);
|
||||
entitiesSupport = RebirthUtilities.BuildZombieSupportGroup(gamestage);
|
||||
entitiesMinions = RebirthUtilities.BuildEntityGroup(gamestage);
|
||||
}
|
||||
else if (spawnType == SpawnType.ZombieAnimals)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B2");
|
||||
entitiesBosses = RebirthUtilities.BuildZombieAnimalBossGroup(gamestage);
|
||||
entitiesSupport = RebirthUtilities.BuildZombieAnimalSupportGroup(gamestage);
|
||||
entitiesMinions = RebirthUtilities.BuildZombieAnimalGroup(gamestage);
|
||||
useDuplicates = true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive entitiesMinions != null: " + (entitiesMinions != null));
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive entitiesBosses != null: " + (entitiesBosses != null));
|
||||
|
||||
if (entitiesMinions != null && entitiesBosses != null)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive entitiesMinions: " + entitiesMinions.Count);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive entitiesBosses: " + entitiesBosses.Count);
|
||||
|
||||
// Remove Support entities from Boss Groups
|
||||
entitiesBosses = RebirthUtilities.RemoveZombieSupportEntries(entitiesBosses);
|
||||
|
||||
if (entitiesMinions.Count > 0 && entitiesMinions.Count > 0)
|
||||
{
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B3");
|
||||
int random = GameManager.Instance.World.GetGameRandom().RandomRange(0, entitiesBosses.Count);
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B3 random: " + random);
|
||||
|
||||
if (spawnType == SpawnType.ZombieAnimals)
|
||||
{
|
||||
numSpawns = numSpawns / 2;
|
||||
}
|
||||
|
||||
if (RebirthVariables.customEventsDifficulty.ToLower() == "random")
|
||||
{
|
||||
int numAdditionalSpawns = numSpawns;
|
||||
|
||||
if (spawnType == SpawnType.ZombieAnimals)
|
||||
{
|
||||
numAdditionalSpawns = numAdditionalSpawns / 2;
|
||||
}
|
||||
|
||||
int randomCount = GameManager.Instance.World.GetGameRandom().RandomRange(numSpawns, numSpawns + numAdditionalSpawns);
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B3 randomCount: " + randomCount);
|
||||
numSpawns = randomCount;
|
||||
}
|
||||
|
||||
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive B3 numSpawns: " + numSpawns);
|
||||
|
||||
string bossClass = EntityClass.GetEntityClassName(entitiesBosses[random]);
|
||||
|
||||
while (bossClass.ToLower().Contains("stevecrawler") ||
|
||||
bossClass.ToLower().Contains("fatcop") ||
|
||||
bossClass.ToLower().Contains("zombie016") ||
|
||||
bossClass.ToLower().Contains("kamikaze")
|
||||
)
|
||||
{
|
||||
random = GameManager.Instance.World.GetGameRandom().RandomRange(0, entitiesBosses.Count);
|
||||
bossClass = EntityClass.GetEntityClassName(entitiesBosses[random]);
|
||||
}
|
||||
|
||||
string supportClasses = "";
|
||||
|
||||
List<int> excludeEntities = new List<int>();
|
||||
|
||||
excludeEntities.Add(entitiesBosses[random]);
|
||||
|
||||
if (entitiesSupport.Count > 0)
|
||||
{
|
||||
List<int> supportEntities = RebirthUtilities.GetEntityListInt(entitiesSupport, numSupportSpawns, excludeEntities, useDuplicates);
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (int entityId in supportEntities)
|
||||
{
|
||||
string className = EntityClass.GetEntityClassName(entityId);
|
||||
if (!className.ToLower().Contains("stevecrawler") &&
|
||||
!className.ToLower().Contains("fatcop") &&
|
||||
!className.ToLower().Contains("zombie016") &&
|
||||
!className.ToLower().Contains("kamikaze")
|
||||
)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
supportClasses = supportClasses + "," + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
supportClasses = className;
|
||||
}
|
||||
count++;
|
||||
excludeEntities.Add(entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string minionClasses = RebirthUtilities.GetEntityList(entitiesMinions, numSpawns, excludeEntities);
|
||||
|
||||
if (RebirthVariables.testEvents)
|
||||
{
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, bossClass: " + bossClass);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, supportClasses: " + supportClasses);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, numSupportSpawns: " + numSupportSpawns);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, minionClasses: " + minionClasses);
|
||||
Log.Out("EntityPlayerLocalPatches-OnUpdateLive CHECK EVENTS, numSpawns: " + numSpawns);
|
||||
RebirthVariables.testEvents = false;
|
||||
RebirthVariables.testEventsCategory = 0;
|
||||
}
|
||||
|
||||
// Boss
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, bossClass, 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 2, -1, "", bossCrate, 1, navIconBoss, buffBoss);
|
||||
// Support
|
||||
if (hasSupport && supportClasses != "")
|
||||
{
|
||||
if (spawnType == SpawnType.Zombies)
|
||||
{
|
||||
numSupportSpawns = 1; // Only one cycle, but all names
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, supportClasses, 1, "", "", "40", "static", "1", "", 1.25f, -1, true, false, true, __instance.entityId, -1, "", -1, 0, 40, numSupportSpawns, 1, 99, -1, "", "ZombieLeaderTier1EntityLootContainer", 1, navIconSupport, buffSupport);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, supportClasses, 1, "", "", "40", "static", "1", "", 1.25f, -1, true, false, true, __instance.entityId, -1, "", -1, 0, 40, numSupportSpawns, 0, 99, -1, "", "ZombieLeaderTier1EntityLootContainer", 1, navIconSupport, buffSupport);
|
||||
}
|
||||
}
|
||||
// Minions
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, minionClasses, 1, "", "", "40", "static", "1", "", 1f, -1, true, false, true, __instance.entityId, -1, "", -1, 0, 40, numSpawns, 0, -1, -1, "", "", 1, navIconMinion, buffMinion);
|
||||
|
||||
numEvents++;
|
||||
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayNumEvents", numEvents);
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventTotalCooldown", RebirthUtilities.GetEventCooldown(playerLevel, numEventsFrequency));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!isActive)
|
||||
{
|
||||
//Log.Out("=========================================RESETTING EVENTS=========================================================");
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayNumEvents", 0f);
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventTotalCooldown", 0f);
|
||||
}
|
||||
}
|
||||
|
||||
__instance.Buffs.SetCustomVar("$FuriousRamsayEventCheck", Time.time);
|
||||
//Log.Out("NUM EVENTS: " + __instance.Buffs.GetCustomVar("$FuriousRamsayNumEvents"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
|
||||
namespace Harmony.EntitySupplyCratePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntitySupplyCrate))]
|
||||
[HarmonyPatch("OnUpdateEntity")]
|
||||
public class OnUpdateEntityPatch
|
||||
{
|
||||
public static bool Prefix(ref EntitySupplyCrate __instance,
|
||||
ref bool ___bPlayerStatsChanged)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
bool optionProtectCrate = RebirthVariables.customProtectCrate;
|
||||
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity A");
|
||||
if (optionProtectCrate && __instance.EntityName == "sc_General")
|
||||
{
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity B");
|
||||
if (__instance.onGround)
|
||||
{
|
||||
__instance.bIsChunkObserver = true;
|
||||
float spawnEntities = __instance.Buffs.GetCustomVar("$spawnEntities");
|
||||
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity spawnZombies: " + spawnZombies);
|
||||
if (spawnEntities == 1f)
|
||||
{
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity 2");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity 3");
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayer player = __instance.world.GetClosestPlayer(__instance, RebirthVariables.supplyCrateHostileSpawnDistance, false);
|
||||
|
||||
if (player != null && player.AttachedToEntity == null && !RebirthUtilities.IsQuesting(player))
|
||||
{
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity 4");
|
||||
int playerLevel = player.Progression.Level;
|
||||
|
||||
int entityID = __instance.entityId;
|
||||
int entityPlayerID = player.entityId;
|
||||
string strSound = "";
|
||||
string strDistance = "15";
|
||||
int minion = 0;
|
||||
int allNames = 1;
|
||||
string strEntity = "zombieBoe";
|
||||
int numEntities = 1;
|
||||
string strHeight = "";
|
||||
string strSpawner = "static";
|
||||
string strDirection = "";
|
||||
float numStartScale = 1;
|
||||
bool attackPlayer = false;
|
||||
int checkMaxEntities = 0;
|
||||
int minMax = 40;
|
||||
int maxEntities = 20;
|
||||
int repeat = 1;
|
||||
bool atPlayerLevel = false;
|
||||
bool randomRotation = true;
|
||||
int numRotation = -1;
|
||||
int isBoss = -1;
|
||||
int handParticle = -1;
|
||||
string lootListName = "";
|
||||
string lootDropClass = "";
|
||||
int lootDropChance = 1;
|
||||
string navIcon = "";
|
||||
string buffList = "buffSupplyCrateSpawn";
|
||||
int numEntitiesTotal = 8;
|
||||
int randomInt = 0;
|
||||
|
||||
string biomeName = RebirthUtilities.GetBiomeName(__instance);
|
||||
|
||||
if (biomeName == "wasteland")
|
||||
{
|
||||
handParticle = 11;
|
||||
}
|
||||
else if (biomeName == "desert")
|
||||
{
|
||||
handParticle = 1;
|
||||
}
|
||||
else if (biomeName == "forest" || biomeName == "pine_forest")
|
||||
{
|
||||
handParticle = 10;
|
||||
}
|
||||
else if (biomeName == "burnt_forest")
|
||||
{
|
||||
handParticle = 1;
|
||||
}
|
||||
else if (biomeName == "snow")
|
||||
{
|
||||
handParticle = 2;
|
||||
}
|
||||
|
||||
if (playerLevel <= 10)
|
||||
{
|
||||
handParticle = -1;
|
||||
}
|
||||
|
||||
randomInt = __instance.rand.RandomRange(0, 4);
|
||||
|
||||
if (playerLevel <= 20)
|
||||
{
|
||||
randomInt = __instance.rand.RandomRange(0, 3);
|
||||
}
|
||||
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity __instance.lootListAlive: " + __instance.lootListAlive);
|
||||
|
||||
//Log.Out("EntitySupplyCratePatches-OnUpdateEntity randomInt: " + randomInt);
|
||||
|
||||
if (randomInt == 1 & playerLevel <= 50)
|
||||
{
|
||||
randomInt = 0;
|
||||
}
|
||||
|
||||
if (randomInt == 0)
|
||||
{
|
||||
// ZOMBIES
|
||||
if (playerLevel <= 5)
|
||||
{
|
||||
__instance.Health = 2000;
|
||||
//__instance.Stats.Health.BaseMax = 1000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2000);
|
||||
allNames = 0;
|
||||
strEntity = "zombieBoe,zombieJoe,zombieArlene,zombieDarlene,zombieMarlene,zombieYo,zombieSteve,zombieBusinessMan";
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 5 && playerLevel <= 15)
|
||||
{
|
||||
__instance.Health = 2400;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2400);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007";
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 15 && playerLevel <= 25)
|
||||
{
|
||||
__instance.Health = 2800;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2800);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral";
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
strEntity = "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007,zombieFatCop,animalZombieDog";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 25 && playerLevel <= 35)
|
||||
{
|
||||
__instance.Health = 3500;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 3500);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieFatCopFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a,animalZombieDog";
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 35 && playerLevel <= 45)
|
||||
{
|
||||
__instance.Health = 4000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4000);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYoRadiated,zombieTomClarkRadiated,zombieArleneRadiated,zombieDarleneRadiated,zombieMarleneRadiated,zombieNurseRadiated,zombiePartyGirlRadiated,zombieSteveRadiated,zombieJoeRadiated,zombieLabRadiated,zombieBusinessManRadiated,zombieBurntRadiated,zombieMaleHazmatRadiated,zombieUtilityWorkerRadiated,zombieSpiderRadiated,zombieBoeRadiated,zombieJanitorRadiated";
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
strEntity = "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieFatCopFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a,animalZombieDog";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 45 && playerLevel <= 55)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYoRadiated,zombieTomClarkRadiated,zombieArleneRadiated,zombieDarleneRadiated,zombieMarleneRadiated,zombieNurseRadiated,zombiePartyGirlRadiated,zombieSteveRadiated,zombieJoeRadiated,zombieLabRadiated,zombieBusinessManRadiated,zombieBurntRadiated,zombieMaleHazmatRadiated,zombieUtilityWorkerRadiated,zombieSpiderRadiated,zombieBoeRadiated,zombieJanitorRadiated";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 55 && playerLevel <= 65)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
allNames = 0;
|
||||
strEntity = "zombieYoRadiated,zombieTomClarkRadiated,zombieArleneRadiated,zombieDarleneRadiated,zombieMarleneRadiated,zombieNurseRadiated,zombiePartyGirlRadiated,zombieSteveRadiated,zombieJoeRadiated,zombieLabRadiated,zombieBusinessManRadiated,zombieBurntRadiated,zombieMaleHazmatRadiated,zombieUtilityWorkerRadiated,zombieSpiderRadiated,zombieBoeRadiated,zombieJanitorRadiated,zombieSkateboarderRadiated,zombieMoeRadiated,zombieFatHawaiianRadiated,zombieFemaleFatRadiated,zombieLumberjackRadiated,zombieBikerRadiated,zombieSoldierRadiated,zombieMutatedRadiated,zombieWightRadiated";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 65)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
allNames = 0;
|
||||
strEntity = "zombieSkateboarderRadiated,zombieMoeRadiated,zombieFatHawaiianRadiated,zombieFemaleFatRadiated,zombieLumberjackRadiated,zombieBikerRadiated,zombieSoldierRadiated,zombieMutatedRadiated,zombieWightRadiated";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (randomInt == 1)
|
||||
{
|
||||
/*// ANIMALS
|
||||
if (playerLevel <= 5)
|
||||
{
|
||||
__instance.Health = 2000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2000);
|
||||
allNames = 0;
|
||||
strEntity = "animalSnake";
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 5 && playerLevel <= 15)
|
||||
{
|
||||
__instance.Health = 2500;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2500);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayAnimalFoxMale001,FuriousRamsayAnimalFoxMale002,FuriousRamsayAnimalFoxMale003";
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 15 && playerLevel <= 30)
|
||||
{
|
||||
__instance.Health = 3000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 3000);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayAnimalWolfMaleForest,FuriousRamsayAnimalWolfMaleDesert2";
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 35 && playerLevel <= 50)
|
||||
{
|
||||
__instance.Health = 4000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4000);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayAnimalWolfMaleDesert,FuriousRamsayAnimalWolfMaleForest2,FuriousRamsayAnimalWolfMaleSnow";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else*/
|
||||
if (playerLevel > 50 && playerLevel <= 65)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
allNames = 0;
|
||||
strEntity = "animalMountainLion";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 65)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
allNames = 0;
|
||||
strEntity = "animalBear";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (randomInt == 2)
|
||||
{
|
||||
if (playerLevel <= 5)
|
||||
{
|
||||
__instance.Health = 1600;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 1600);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 5 && playerLevel <= 15)
|
||||
{
|
||||
__instance.Health = 2000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2000);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 15 && playerLevel <= 25)
|
||||
{
|
||||
__instance.Health = 2400;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2400);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 25 && playerLevel <= 35)
|
||||
{
|
||||
__instance.Health = 2800;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 2800);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan002cPipeShotgun,FuriousRamsayBanditMan002dPipeRifle,FuriousRamsayBanditWoman001hPipeRifle,FuriousRamsayBanditWoman001gPipeShotgun,FuriousRamsayBanditWoman001aPipeShotgun,FuriousRamsayBanditWoman001bPipeRifle";
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 35 && playerLevel <= 45)
|
||||
{
|
||||
__instance.Health = 3200;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 3200);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan002cPipeShotgun,FuriousRamsayBanditMan002dPipeRifle,FuriousRamsayBanditWoman001hPipeRifle,FuriousRamsayBanditWoman001gPipeShotgun,FuriousRamsayBanditWoman001aPipeShotgun,FuriousRamsayBanditWoman001bPipeRifle,FuriousRamsayBanditMan002gPipePistol,FuriousRamsayBanditMan002aPipePistol,FuriousRamsayBanditMan002hPipeMachineGun,FuriousRamsayBanditWoman001cWoodenBow,FuriousRamsayBanditWoman001ePipePistol,FuriousRamsayBanditWoman001fPipeMachineGun,FuriousRamsayBanditMan002eWoodenBow,FuriousRamsayBanditMan002bPipeMachineGun";
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 45 && playerLevel <= 55)
|
||||
{
|
||||
__instance.Health = 3600;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 3600);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan002cPipeShotgun,FuriousRamsayBanditMan002dPipeRifle,FuriousRamsayBanditWoman001aPipeShotgun,FuriousRamsayBanditWoman001bPipeRifle,FuriousRamsayBanditWoman001gPipeShotgun,FuriousRamsayBanditWoman001hPipeRifle";
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
strEntity = "FuriousRamsayBanditMan005aClub,FuriousRamsayBanditMan005bBat,FuriousRamsayBanditMan005cAxe,FuriousRamsayBanditMan005dKnife,FuriousRamsayBanditMan005eSpear,FuriousRamsayBanditMan005fMachete,FuriousRamsayBanditMan002aClub,FuriousRamsayBanditMan002bBat,FuriousRamsayBanditMan002cAxe,FuriousRamsayBanditMan002dSpear,FuriousRamsayBanditMan002eMachete,FuriousRamsayBanditMan002gClub,FuriousRamsayBanditMan002hBat,FuriousRamsayBanditWoman001aAxe,FuriousRamsayBanditWoman001bKnife,FuriousRamsayBanditWoman001cSpear,FuriousRamsayBanditWoman001dMachete,FuriousRamsayBanditWoman001fClub,FuriousRamsayBanditWoman001gBat,FuriousRamsayBanditWoman001hAxe";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 55 && playerLevel <= 65)
|
||||
{
|
||||
__instance.Health = 4000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4000);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan002cPipeShotgun,FuriousRamsayBanditMan002dPipeRifle,FuriousRamsayBanditWoman001aPipeShotgun,FuriousRamsayBanditWoman001bPipeRifle,FuriousRamsayBanditWoman001gPipeShotgun,FuriousRamsayBanditWoman001hPipeRifle,FuriousRamsayBanditMan002aPipePistol,FuriousRamsayBanditMan002bPipeMachineGun,FuriousRamsayBanditMan002eWoodenBow,FuriousRamsayBanditMan002gPipePistol,FuriousRamsayBanditMan002hPipeMachineGun,FuriousRamsayBanditWoman001cWoodenBow,FuriousRamsayBanditWoman001ePipePistol,FuriousRamsayBanditWoman001fPipeMachineGun,FuriousRamsayBanditMan005bPipeMachineGun,FuriousRamsayBanditMan001ePipeMachineGun";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 65 && playerLevel <= 80)
|
||||
{
|
||||
__instance.Health = 4400;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4400);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan005eCrossBow,FuriousRamsayBanditMan005dPumpShotgun,FuriousRamsayBanditMan005fHuntingRifle,FuriousRamsayBanditMan005gPistol,FuriousRamsayBanditMan001aPumpShotgun,FuriousRamsayBanditMan001fPistol,FuriousRamsayBanditMan001hPumpShotgun,FuriousRamsayBanditMan001aPistol,FuriousRamsayBanditMan001bPumpShotgun,FuriousRamsayBanditMan005cPistol,FuriousRamsayBanditMan005dPumpShotgun";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
else if (playerLevel > 80)
|
||||
{
|
||||
__instance.Health = 4800;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4800);
|
||||
allNames = 0;
|
||||
strEntity = "FuriousRamsayBanditMan005cAK47,FuriousRamsayBanditMan001bAK47,FuriousRamsayBanditMan001gAK47,FuriousRamsayBanditMan001cAK47,FuriousRamsayBanditMan001dSMG5,FuriousRamsayBanditMan001eM60,FuriousRamsayBanditMan001fAssaultRifle,FuriousRamsayBanditMan001gSniperRifle,FuriousRamsayBanditMan005aAutoShotgun,FuriousRamsayBanditMan005eDesertVulture,FuriousRamsayBanditMan005fM60,FuriousRamsayBanditMan005gAssaultRifle";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, "", "", strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (randomInt == 3)
|
||||
{
|
||||
// EVENTS
|
||||
if (playerLevel < 35)
|
||||
{
|
||||
allNames = 1;
|
||||
__instance.Health = 3000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 3000);
|
||||
randomInt = __instance.rand.RandomRange(0, 3);
|
||||
if (randomInt == 0)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1B");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 12, 0, -1, -1, "", "", 1, "", "FuriousRamsayMinionBuffTier1");
|
||||
}
|
||||
else if (randomInt == 1)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieMutated", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1B");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieFatCop,zombieMutated", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 12, 0, -1, -1, "", "", 1, "", "FuriousRamsayMinionBuffTier1");
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1B");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieFatCop,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 12, 0, -1, -1, "", "", 1, "", "FuriousRamsayMinionBuffTier1");
|
||||
}
|
||||
}
|
||||
else if (playerLevel >= 35 && playerLevel < 50)
|
||||
{
|
||||
__instance.Health = 4000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 4000);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1C");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYo,zombieTomClark,zombieArlene,zombieDarlene,zombieMarlene,zombieNurse,zombiePartyGirl,zombieSteve,zombieJoe,zombieLab,zombieBusinessMan,zombieBurnt,zombieMaleHazmat,zombieUtilityWorker,zombieSpider,zombieBoe,zombieJanitor,zombieSkateboarder,zombieMoe,zombieFatHawaiian,zombieFemaleFat,zombieLumberjack,zombieBiker,zombieSoldier,zombieFatCop,zombieMutated,FuriousRamsayZombie001,FuriousRamsayZombie002,FuriousRamsayZombie003,FuriousRamsayZombie004,FuriousRamsayZombie005,FuriousRamsayZombie006,FuriousRamsayZombie007", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 8, 0, -1, -1, "", "", 1, "", "FuriousRamsayMinionBuffTier2");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieFatCopFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 5, 0, -1, -1, "", "", 1, "", "");
|
||||
}
|
||||
else if (playerLevel >= 50 && playerLevel < 80)
|
||||
{
|
||||
__instance.Health = 5000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 5000);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1D");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieFatCopFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a,zombieDemolition", 1, "", "", "40", "static", "1", "", 1.1f, -1, true, false, true, __instance.entityId, -1, "", 20, 0, 40, 10, 0, -1, -1, "", "", 1, "", "");
|
||||
}
|
||||
else if (playerLevel >= 80)
|
||||
{
|
||||
__instance.Health = 6000;
|
||||
__instance.Buffs.SetCustomVar("$healthMax", 6000);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYoRadiated,zombieTomClarkRadiated,zombieArleneRadiated,zombieDarleneRadiated,zombieMarleneRadiated,zombieNurseRadiated,zombiePartyGirlRadiated,zombieSteveRadiated,zombieJoeRadiated,zombieLabRadiated,zombieBusinessManRadiated,zombieBurntRadiated,zombieMaleHazmatRadiated,zombieUtilityWorkerRadiated,zombieSpiderRadiated,zombieBoeRadiated,zombieJanitorRadiated,zombieSkateboarderRadiated,zombieMoeRadiated,zombieFatHawaiianRadiated,zombieFemaleFatRadiated,zombieLumberjackRadiated,zombieBikerRadiated,zombieSoldierRadiated,zombieMutatedRadiated,zombieWightRadiated", 1, "", "", "40", "static", "1", "", 1.5f, -1, true, false, true, __instance.entityId, -1, "", 1, 0, 40, 1, 0, 1, -1, "", "", 1, "", "FuriousRamsayBossBuffTier1E");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityId, "zombieYoFeral,zombieTomClarkFeral,zombieArleneFeral,zombieDarleneFeral,zombieMarleneFeral,zombieNurseFeral,zombiePartyGirlFeral,zombieSteveFeral,zombieJoeFeral,zombieLabFeral,zombieBusinessManFeral,zombieBurntFeral,zombieMaleHazmatFeral,zombieUtilityWorkerFeral,zombieSpiderFeral,zombieBoeFeral,zombieJanitorFeral,zombieSkateboarderFeral,zombieMoeFeral,zombieFatHawaiianFeral,zombieFemaleFatFeral,zombieLumberjackFeral,zombieBikerFeral,zombieSoldierFeral,zombieFatCopFeral,zombieMutatedFeral,zombieWightFeral,FuriousRamsayZombie008a,FuriousRamsayZombie009a,FuriousRamsayZombie010a,FuriousRamsayZombie011a,FuriousRamsayZombie012a,FuriousRamsayZombie013a,zombieDemolition", 1, "", "", "40", "static", "1", "", 1.25f, -1, true, false, true, __instance.entityId, -1, "", 14, 0, 40, 12, 0, -1, -1, "", "", 1, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
__instance.Buffs.AddBuff("FuriousRamsayExplodeCrateAfterTime");
|
||||
__instance.Buffs.SetCustomVar("$spawnEntities", 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,820 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.EntityTraderPatches
|
||||
{
|
||||
/*
|
||||
[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("OnEntityActivated")]
|
||||
public class OnEntityActivatedPatch
|
||||
{
|
||||
public static void Postfix(EntityTrader __instance, int _indexInBlockActivationCommands, Vector3i _tePos, EntityAlive _entityFocusing)
|
||||
{
|
||||
_entityFocusing.Buffs.SetCustomVar("CurrentNPC", __instance.entityId);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("GetActivationCommands")]
|
||||
public class GetActivationCommandsPatch
|
||||
{
|
||||
public static bool Prefix(EntityTrader __instance, ref EntityActivationCommand[] __result, Vector3i _tePos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (__instance.IsDead() || __instance.NPCInfo == null)
|
||||
{
|
||||
__result = new EntityActivationCommand[0];
|
||||
return false;
|
||||
}
|
||||
|
||||
bool canTrade = true;
|
||||
|
||||
if (__instance.EntityClass.entityClassName == "TraderFarmer_POI_FR")
|
||||
{
|
||||
canTrade = _entityFocusing.Progression.GetProgressionValue("FuriousRamsayAchievementFarmerTrader").calculatedLevel == 1;
|
||||
}
|
||||
if (__instance.EntityClass.entityClassName == "TraderHandyman_POI_FR")
|
||||
{
|
||||
canTrade = _entityFocusing.Progression.GetProgressionValue("FuriousRamsayAchievementHandymanTrader").calculatedLevel == 1;
|
||||
}
|
||||
if (__instance.EntityClass.entityClassName == "TraderBlackShield_POI_FR")
|
||||
{
|
||||
canTrade = _entityFocusing.Progression.GetProgressionValue("FuriousRamsayAchievementBlackShieldTrader").calculatedLevel == 1;
|
||||
}
|
||||
|
||||
__result = new EntityActivationCommand[3]
|
||||
{
|
||||
new EntityActivationCommand("talk", "talk", true),
|
||||
new EntityActivationCommand("trade", "map_trader", canTrade),
|
||||
new EntityActivationCommand("remove", "x", GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled) && !GameUtils.IsPlaytesting())
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("OnUpdateLive")]
|
||||
public class OnUpdateLivePatch
|
||||
{
|
||||
private static float traderTick = 5f;
|
||||
private static float traderCheck = 0f;
|
||||
|
||||
public static void Postfix(EntityTrader __instance)
|
||||
{
|
||||
//Log.Out("EntityTrader-OnUpdateLive Trader: " + __instance.EntityClass.entityClassName + " / visible: " + __instance.emodel.visible + " / active: " + __instance.emodel.isActiveAndEnabled + " / avatar: " + (__instance.emodel.avatarController != null));
|
||||
|
||||
if ((Time.time - traderCheck) > traderTick)
|
||||
{
|
||||
traderCheck = Time.time;
|
||||
|
||||
if (__instance.TraderData.TraderID > 100)
|
||||
{
|
||||
Log.Out("EntityTrader-OnUpdateLive TraderID: " + __instance.TraderData.TraderID + " / entity: " + __instance.EntityClass.entityClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_CharacterFrameWindow))]
|
||||
[HarmonyPatch("OnClose")]
|
||||
public class OnClosePatch2
|
||||
{
|
||||
public static bool Prefix(XUiC_CharacterFrameWindow __instance)
|
||||
{
|
||||
EntityPlayerLocal player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
int traderId = (int)player.Buffs.GetCustomVar("$CurrentTrader_FR");
|
||||
//Log.Out("EntityTrader-OnClose traderId: " + traderId);
|
||||
|
||||
EntityTrader entityTrader = GameManager.Instance.World.GetEntity(traderId) as EntityTrader;
|
||||
|
||||
if (entityTrader != null)
|
||||
{
|
||||
if (RebirthUtilities.IsVanillaTrader(traderId))
|
||||
{
|
||||
entityTrader.ClearActiveQuests(player.entityId);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("HandleClientQuests")]
|
||||
public class HandleClientQuestsPatch
|
||||
{
|
||||
public static bool Prefix(EntityTrader __instance, EntityPlayer player)
|
||||
{
|
||||
player.Buffs.SetCustomVar("$CurrentTrader_FR", __instance.entityId);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("ActivateTrader")]
|
||||
public class ActivateTraderPatch
|
||||
{
|
||||
private static bool Prefix(EntityTrader __instance, bool traderIsOpen,
|
||||
int ___outstandingIndexInBlockActivationCommands,
|
||||
Vector3i ___outstandingTePos,
|
||||
global::EntityAlive ___outstandingEntityFocusing
|
||||
)
|
||||
{
|
||||
if (traderIsOpen)
|
||||
{
|
||||
int num = ___outstandingIndexInBlockActivationCommands;
|
||||
Vector3i blockPos = ___outstandingTePos;
|
||||
global::EntityAlive entityAlive = ___outstandingEntityFocusing;
|
||||
EntityPlayerLocal entityPlayerLocal = entityAlive as EntityPlayerLocal;
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
QuestEventManager.Current.NPCInteracted(__instance);
|
||||
QuestEventManager.Current.NPCMet((EntityNPC)__instance);
|
||||
Quest nextCompletedQuest = (entityAlive as EntityPlayerLocal).QuestJournal.GetNextCompletedQuest(null, __instance.entityId);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
__instance.activeQuests = QuestEventManager.Current.GetQuestList(GameManager.Instance.World, __instance.entityId, entityAlive.entityId);
|
||||
|
||||
if (__instance.activeQuests == null)
|
||||
{
|
||||
// OLD CODE
|
||||
//__instance.activeQuests = __instance.PopulateActiveQuests(entityPlayerLocal, -1);
|
||||
//QuestEventManager.Current.SetupQuestList(__instance.entityId, entityAlive.entityId, __instance.activeQuests);
|
||||
__instance.SetupActiveQuestsForPlayer((EntityPlayer)entityPlayerLocal);
|
||||
}
|
||||
}
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
uiforPlayer.xui.Dialog.Respondent = __instance;
|
||||
|
||||
if (nextCompletedQuest == null)
|
||||
{
|
||||
if (uiforPlayer.windowManager.IsWindowOpen("dialog"))
|
||||
break;
|
||||
uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
|
||||
uiforPlayer.windowManager.Open("dialog", true, false, true);
|
||||
QuestEventManager.Current.NPCInteracted(__instance);
|
||||
|
||||
return false;
|
||||
}
|
||||
uiforPlayer.xui.Dialog.QuestTurnIn = nextCompletedQuest;
|
||||
uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
|
||||
__instance.PlayVoiceSetEntry("quest_complete", (EntityPlayer)entityPlayerLocal, true, true);
|
||||
uiforPlayer.windowManager.Open("questTurnIn", true, false, true);
|
||||
return false;
|
||||
case 1:
|
||||
uiforPlayer.xui.Trader.TraderEntity = __instance;
|
||||
if (nextCompletedQuest == null)
|
||||
{
|
||||
GameManager.Instance.TELockServer(0, blockPos, __instance.TileEntityTrader.entityId, entityAlive.entityId, null);
|
||||
__instance.PlayVoiceSetEntry("trade", (EntityPlayer)entityPlayerLocal, true, true);
|
||||
return false;
|
||||
}
|
||||
uiforPlayer.xui.Dialog.QuestTurnIn = nextCompletedQuest;
|
||||
uiforPlayer.windowManager.CloseAllOpenWindows(null, false);
|
||||
__instance.PlayVoiceSetEntry("quest_complete", (EntityPlayer)entityPlayerLocal, true, true);
|
||||
uiforPlayer.windowManager.Open("questTurnIn", true, false, true);
|
||||
return false;
|
||||
case 2:
|
||||
{
|
||||
Waypoint entityVehicleWaypoint = entityPlayerLocal.Waypoints.GetEntityVehicleWaypoint(__instance.entityId);
|
||||
if (entityVehicleWaypoint != null)
|
||||
{
|
||||
entityPlayerLocal.Waypoints.Collection.Remove(entityVehicleWaypoint);
|
||||
NavObjectManager.Instance.UnRegisterNavObjectByPosition(entityVehicleWaypoint.pos, "waypoint");
|
||||
}
|
||||
GameEventManager.Current.HandleAction("game_remove_entity", entityPlayerLocal, __instance, false, "", "", false, true, "", null);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityTrader))]
|
||||
[HarmonyPatch("PopulateActiveQuests")]
|
||||
public class PopulateActiveQuestsPatch
|
||||
{
|
||||
private static bool Prefix(global::EntityPlayer player, int currentTier, EntityTrader __instance, ref List<Quest> __result, ref Dictionary<int, List<QuestEntry>> ___questDictionary, ref List<int> ___tempTopTierQuests, ref List<int> ___tempSpecialQuests, ref List<string> ___uniqueKeysUsed, ref TraderArea ___traderArea, ref Vector3 ___position, ref List<Vector2> ___usedPOILocations, ref GameRandom ___rand, ref int ___entityId, ref List<QuestEntry> ___specialQuestList)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests START");
|
||||
if (___questDictionary.Count == 0)
|
||||
{
|
||||
__instance.PopulateQuestList();
|
||||
if (___questDictionary.Count == 0)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int maxJobs = RebirthVariables.customMaxJobs;
|
||||
|
||||
if (maxJobs == 0)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool @bool = GameStats.GetBool(EnumGameStats.EnemySpawnMode);
|
||||
List<Quest> list = new List<Quest>();
|
||||
List<Quest> listCurrentQuests = player.QuestJournal.quests;
|
||||
|
||||
___tempTopTierQuests.Clear();
|
||||
___tempSpecialQuests.Clear();
|
||||
___uniqueKeysUsed.Clear();
|
||||
Vector2 vector;
|
||||
if (___traderArea != null)
|
||||
{
|
||||
vector = new Vector2((float)___traderArea.Position.x, (float)___traderArea.Position.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
vector = new Vector2(___position.x, ___position.z);
|
||||
}
|
||||
if (currentTier == -1)
|
||||
{
|
||||
currentTier = player.QuestJournal.GetCurrentFactionTier(__instance.NPCInfo.QuestFaction, 0, false);
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests currentTier: " + currentTier);
|
||||
|
||||
int questFactionPoints = player.QuestJournal.GetQuestFactionPoints(__instance.NPCInfo.QuestFaction);
|
||||
QuestTraderData traderData = player.QuestJournal.GetTraderData(vector);
|
||||
if (traderData != null)
|
||||
{
|
||||
traderData.CheckReset(player);
|
||||
}
|
||||
//___usedPOILocations.Clear();
|
||||
|
||||
bool playerHasFetchQuest = false;
|
||||
|
||||
for (int i = 0; i < listCurrentQuests.Count; i++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[i].CurrentState: " + listCurrentQuests[i].CurrentState);
|
||||
bool isOpen = RebirthUtilities.IsVanillaTrader(listCurrentQuests[i].QuestGiverID) && (listCurrentQuests[i].CurrentState == Quest.QuestState.NotStarted ||
|
||||
listCurrentQuests[i].CurrentState == Quest.QuestState.InProgress ||
|
||||
listCurrentQuests[i].CurrentState == Quest.QuestState.ReadyForTurnIn)
|
||||
;
|
||||
|
||||
int questOwnerId = listCurrentQuests[i].SharedOwnerID;
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests isOpen: " + isOpen);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests questOwnerId: " + questOwnerId);
|
||||
|
||||
/*if (listCurrentQuests[i].QuestPrefab != null)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[i].GetPOIName(): " + listCurrentQuests[i].GetPOIName());
|
||||
}*/
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
if (questOwnerId == -1)
|
||||
{
|
||||
for (int k = 0; k < listCurrentQuests[i].QuestClass.Objectives.Count; k++)
|
||||
{
|
||||
if (listCurrentQuests[i].QuestClass.Objectives[k] is ObjectiveFetchFromContainer)
|
||||
{
|
||||
playerHasFetchQuest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (playerHasFetchQuest)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests playerHasFetchQuest: " + playerHasFetchQuest);
|
||||
|
||||
List<Quest> listRestrictedQuests = new List<Quest>();
|
||||
List<string> listFoundQuests = new List<string>();
|
||||
|
||||
int num = 0;
|
||||
int buriedSupplies = 0;
|
||||
int restorePower = 0;
|
||||
int fetchContainer = 0;
|
||||
int numCustomQuests = 0;
|
||||
int maxCustomQuests = (int)maxJobs / 4;
|
||||
int maxBuriedSupplies = (int)maxJobs / 5;
|
||||
int numJobs = 0;
|
||||
|
||||
for (int k = 0; k < listCurrentQuests.Count; k++)
|
||||
{
|
||||
/*if (listCurrentQuests[k].QuestPrefab != null)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests list[" + k + "].GetPOIName(): " + listCurrentQuests[k].GetPOIName());
|
||||
}*/
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "].QuestGiverID: " + listCurrentQuests[k].QuestGiverID);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "].NPCInfo.QuestFaction: " + listCurrentQuests[k].QuestFaction);
|
||||
|
||||
if (listCurrentQuests[k].SharedOwnerID == -1 &&
|
||||
listCurrentQuests[k].QuestClass.DifficultyTier == currentTier &&
|
||||
RebirthUtilities.IsVanillaTrader(listCurrentQuests[k].QuestGiverID)
|
||||
)
|
||||
{
|
||||
numJobs++;
|
||||
listRestrictedQuests.Add(listCurrentQuests[k]);
|
||||
}
|
||||
|
||||
if (currentTier == 1 && numJobs == 8) break;
|
||||
if (currentTier == 2 && numJobs == 6) break;
|
||||
if (currentTier == 3 && numJobs == 5) break;
|
||||
if (currentTier == 4 && numJobs == 4) break;
|
||||
if (currentTier == 5 && numJobs == 3) break;
|
||||
if (currentTier == 6 && numJobs == 2) break;
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests numJobs: " + numJobs);
|
||||
|
||||
/*for (int k = 0; k < listRestrictedQuests.Count; k++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listRestrictedQuests[" + k + "].GetPOIName(): " + listRestrictedQuests[k].GetPOIName());
|
||||
}*/
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests maxCustomQuests: " + maxCustomQuests);
|
||||
|
||||
int startTier = 1;
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests BEFORE currentTier: " + currentTier);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests BEFORE startTier: " + startTier);
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (__instance.EntityClass.entityClassName == "npcTraderRekt")
|
||||
{
|
||||
startTier = 1;
|
||||
currentTier = 1;
|
||||
}
|
||||
else if (__instance.EntityClass.entityClassName == "npcTraderBob")
|
||||
{
|
||||
if (currentTier < 2)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
startTier = 1;
|
||||
currentTier = 2;
|
||||
}
|
||||
else if (__instance.EntityClass.entityClassName == "npcTraderHugh")
|
||||
{
|
||||
if (currentTier < 3)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
startTier = 1;
|
||||
currentTier = 3;
|
||||
}
|
||||
else if (__instance.EntityClass.entityClassName == "npcTraderJoel")
|
||||
{
|
||||
if (currentTier < 4)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
startTier = 1;
|
||||
currentTier = 4;
|
||||
}
|
||||
else if (__instance.EntityClass.entityClassName == "npcTraderJen")
|
||||
{
|
||||
if (currentTier < 5)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
startTier = 1;
|
||||
currentTier = 5;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests AFTER currentTier: " + currentTier);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests AFTER startTier: " + startTier);
|
||||
|
||||
for (int i = startTier; i <= currentTier; i++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ___usedPOILocations.Count: " + ___usedPOILocations.Count);
|
||||
|
||||
num = 0;
|
||||
|
||||
for (int j = 0; j < 1000; j++)
|
||||
{
|
||||
int index = ___rand.RandomRange(___questDictionary[i].Count);
|
||||
QuestEntry questEntry = ___questDictionary[i][index];
|
||||
if (___rand.RandomFloat < questEntry.Prob)
|
||||
{
|
||||
QuestClass questClass = questEntry.QuestClass;
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests questClass: " + questClass.ID);
|
||||
|
||||
bool optionCustomQuests = RebirthVariables.customCustomQuests;
|
||||
|
||||
bool skipQuest = false;
|
||||
|
||||
bool customQuest = questClass.Properties.Values.ContainsKey("CustomQuest");
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests customQuest: " + customQuest);
|
||||
|
||||
if (!optionCustomQuests && customQuest)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests A");
|
||||
skipQuest = true;
|
||||
}
|
||||
|
||||
if (optionCustomQuests && customQuest)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests B");
|
||||
if (numCustomQuests >= maxCustomQuests)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests C");
|
||||
skipQuest = true;
|
||||
}
|
||||
else if (num < (numCustomQuests / 3))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests D");
|
||||
skipQuest = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (questClass.Properties.Values.ContainsKey("SkipQuest") && player.IsInParty())
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests E1");
|
||||
skipQuest = true;
|
||||
}
|
||||
|
||||
if (questClass.Properties.Values.ContainsKey("SkipJobList"))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests E2");
|
||||
skipQuest = true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests num: " + num);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests numCustomQuests: " + numCustomQuests);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests skipQuest: " + skipQuest);
|
||||
|
||||
if (!skipQuest) // QuestStage removed - Do we need an alternative? // && (questClass.QuestStage == -1 || questFactionPoints >= questClass.QuestStage))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests F");
|
||||
Quest quest = questEntry.QuestClass.CreateQuest();
|
||||
quest.QuestGiverID = ___entityId;
|
||||
quest.QuestFaction = __instance.NPCInfo.QuestFaction;
|
||||
quest.SetPositionData(Quest.PositionDataTypes.QuestGiver, ___position);
|
||||
quest.SetPositionData(Quest.PositionDataTypes.TraderPosition, (___traderArea != null) ? ___traderArea.Position : ___position);
|
||||
quest.SetupTags();
|
||||
|
||||
if (@bool || !quest.QuestTags.Test_AnySet(QuestEventManager.clearTag))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests F1");
|
||||
___usedPOILocations.Clear();
|
||||
|
||||
if (quest.SetupPosition(__instance, player, ___usedPOILocations, player.entityId))
|
||||
{
|
||||
string POIName = quest.GetPOIName().ToLower();
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Quest POIName: " + POIName);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests quest.QuestClass.DifficultyTier: " + quest.QuestClass.DifficultyTier);
|
||||
|
||||
int distance = (int)Vector3.Distance(quest.Position, ___position) / 50 * 50;
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests distance: " + distance);
|
||||
|
||||
int maxDistance = 2500;
|
||||
|
||||
if (currentTier == 2)
|
||||
{
|
||||
maxDistance = 3500;
|
||||
}
|
||||
else if (currentTier == 3)
|
||||
{
|
||||
maxDistance = 4500;
|
||||
}
|
||||
else if (currentTier == 4)
|
||||
{
|
||||
maxDistance = 7000;
|
||||
}
|
||||
else if (currentTier == 5)
|
||||
{
|
||||
maxDistance = 10000;
|
||||
}
|
||||
else if (currentTier == 6)
|
||||
{
|
||||
maxDistance = 15000;
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests maxDistance: " + maxDistance);
|
||||
|
||||
if (distance <= maxDistance)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests IS WITHIN MAX DISTANCE");
|
||||
bool bypassPOI = false;
|
||||
bool foundBuriedSupplies = false;
|
||||
bool foundRestorePower = false;
|
||||
bool foundFetchContainer = false;
|
||||
int numDuplicates = 0;
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listFoundQuests.Count: " + listFoundQuests.Count);
|
||||
|
||||
for (int k = 0; k < listFoundQuests.Count; k++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listFoundQuests[" + k + "]: " + listFoundQuests[k]);
|
||||
|
||||
if (POIName.Trim() != "" && POIName == listFoundQuests[k].ToLower()
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests 00a");
|
||||
bypassPOI = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!RebirthVariables.customRepeatPOI)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests.Count: " + listCurrentQuests.Count);
|
||||
for (int k = 0; k < listCurrentQuests.Count; k++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "].GetPOIName(): " + listCurrentQuests[k].GetPOIName());
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "] IS VANILLA TRADER: " + RebirthUtilities.IsVanillaTrader(listCurrentQuests[k].QuestGiverID));
|
||||
if (RebirthUtilities.IsVanillaTrader(listCurrentQuests[k].QuestGiverID))
|
||||
{
|
||||
bool isOpen = (listCurrentQuests[k].CurrentState == Quest.QuestState.NotStarted ||
|
||||
listCurrentQuests[k].CurrentState == Quest.QuestState.InProgress ||
|
||||
listCurrentQuests[k].CurrentState == Quest.QuestState.ReadyForTurnIn ||
|
||||
listCurrentQuests[k].CurrentState == Quest.QuestState.Completed);
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "].CurrentState: " + listCurrentQuests[k].CurrentState);
|
||||
|
||||
/*//Log.Out("EntityTraderPatches-PopulateActiveQuests listCurrentQuests[" + k + "].Position: " + listCurrentQuests[k].Position);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests quest.position: " + quest.position);
|
||||
|
||||
BiomeDefinition biomeAt1 = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)listCurrentQuests[k].Position.x, (int)listCurrentQuests[k].Position.z);
|
||||
BiomeDefinition biomeAt2 = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)quest.position.x, (int)quest.position.z);
|
||||
|
||||
bool sameBiome = false;
|
||||
|
||||
if (biomeAt1 != null && biomeAt2 != null && biomeAt1.m_sBiomeName == biomeAt2.m_sBiomeName)
|
||||
{
|
||||
sameBiome = true;
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests sameBiome: " + sameBiome);*/
|
||||
|
||||
if (POIName.Trim() != "" && POIName == listCurrentQuests[k].GetPOIName().ToLower() && isOpen
|
||||
)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ALREADY DID POI POIName: " + POIName);
|
||||
bypassPOI = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests A bypassPOI: " + bypassPOI);
|
||||
|
||||
if (!bypassPOI)
|
||||
{
|
||||
/*if (quest.QuestPrefab != null)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests FOUND quest.GetPOIName(): " + quest.GetPOIName());
|
||||
}*/
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests listRestrictedQuests.Count: " + listRestrictedQuests.Count);
|
||||
|
||||
for (int k = 0; k < listRestrictedQuests.Count; k++)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests list[" + k + "].GetPOIName(): " + listRestrictedQuests[k].GetPOIName());
|
||||
if (POIName.Trim() != "" && listRestrictedQuests[k].SharedOwnerID == -1 &&
|
||||
POIName == listRestrictedQuests[k].GetPOIName().ToLower()
|
||||
)
|
||||
{
|
||||
numDuplicates++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numDuplicates >= RebirthVariables.customMaxSamePOI)
|
||||
{
|
||||
Log.Out("EntityTraderPatches-PopulateActiveQuests numDuplicates: " + numDuplicates);
|
||||
Log.Out("EntityTraderPatches-PopulateActiveQuests RebirthVariables.customMaxSamePOI: " + RebirthVariables.customMaxSamePOI);
|
||||
bypassPOI = true;
|
||||
}
|
||||
|
||||
for (int k = 0; k < quest.QuestClass.Objectives.Count; k++)
|
||||
{
|
||||
if (quest.QuestClass.Objectives[k] is ObjectiveFetchFromContainer)
|
||||
{
|
||||
if (quest.QuestClass.Objectives[k].Properties.Values.ContainsKey("default_container"))
|
||||
{
|
||||
if (quest.QuestClass.Objectives[k].Properties.Values["default_container"] == "cntFetchQuestSatchel")
|
||||
{
|
||||
foundFetchContainer = true;
|
||||
fetchContainer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests foundFetchContainer: " + foundFetchContainer);
|
||||
|
||||
for (int k = 0; k < quest.QuestClass.Objectives.Count; k++)
|
||||
{
|
||||
//Log.Out("quest.QuestClass.Objectives[" + k + "].ToString(): " + quest.QuestClass.Objectives[k].ToString());
|
||||
//Log.Out("quest.QuestClass.Objectives[" + k + "].ObjectiveValueType: " + quest.QuestClass.Objectives[k].ObjectiveValueType);
|
||||
if (quest.QuestClass.Objectives[k] is ObjectiveTreasureChest)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests FOUND TREASURE CHEST OBJECTIVE");
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests UniqueKey: " + quest.QuestClass.UniqueKey);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ID: " + quest.QuestClass.ID);
|
||||
if (quest.QuestClass.ID.ToLower().Contains("buried_supplies"))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests FOUND BURIED SUPPLIES");
|
||||
foundBuriedSupplies = true;
|
||||
buriedSupplies++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < quest.QuestClass.Objectives.Count; k++)
|
||||
{
|
||||
//Log.Out("quest.QuestClass.Objectives[" + k + "].ToString(): " + quest.QuestClass.Objectives[k].ToString());
|
||||
//Log.Out("quest.QuestClass.Objectives[" + k + "].ObjectiveValueType: " + quest.QuestClass.Objectives[k].ObjectiveValueType);
|
||||
if (quest.QuestClass.Objectives[k] is ObjectivePOIBlockActivate)
|
||||
{
|
||||
foundRestorePower = true;
|
||||
restorePower++;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests foundBuriedSupplies: " + foundBuriedSupplies);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests buriedSupplies: " + buriedSupplies);
|
||||
|
||||
if (POIName == "" && foundBuriedSupplies && buriedSupplies > maxBuriedSupplies)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests BYPASS POI");
|
||||
bypassPOI = true;
|
||||
}
|
||||
else if (customQuest && numCustomQuests > 3)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests DO NOT BYPASS POI");
|
||||
bypassPOI = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests B bypassPOI: " + bypassPOI);
|
||||
|
||||
if (!bypassPOI)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests quest.QuestClass.Name: " + quest.QuestClass.Name);
|
||||
if (foundRestorePower)
|
||||
{
|
||||
//Log.Out("FOUND RESTORE POWER, restorePower: " + restorePower);
|
||||
if (restorePower < 4)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests CC ADD QUEST");
|
||||
//if (quest.QuestPrefab != null)
|
||||
{
|
||||
//Log.Out("QUEST NAME: " + POIName + " / DISTANCE: " + ((int)Vector3.Distance(quest.Position, ___position) / 50 * 50));
|
||||
}
|
||||
|
||||
if (customQuest)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests CC CUSTOM QUEST");
|
||||
numCustomQuests++;
|
||||
}
|
||||
list.Add(quest);
|
||||
listFoundQuests.Add(POIName);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests NOT RESTORE POWER");
|
||||
if (!playerHasFetchQuest || (playerHasFetchQuest && !foundFetchContainer))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests EE ADD QUEST");
|
||||
if (customQuest && quest.QuestClass.DifficultyTier == player.QuestJournal.GetCurrentFactionTier((byte)1))
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests FF SUTOM QUEST");
|
||||
numCustomQuests++;
|
||||
}
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ADDED quest.GetPOIName(): " + POIName);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ADDED DifficultyTier: " + quest.QuestClass.DifficultyTier);
|
||||
|
||||
/*//Log.Out("EntityTraderPatches-PopulateActiveQuests ID: " + quest.QuestClass.ID);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Name: " + quest.QuestClass.Name);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests SubTitle: " + quest.QuestClass.SubTitle);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests StatementText: " + quest.QuestClass.StatementText);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests ResponseText: " + quest.QuestClass.ResponseText);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Description: " + quest.QuestClass.Description);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests POIName: " + POIName);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Difficulty: " + quest.QuestClass.Difficulty);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests DifficultyTier: " + quest.QuestClass.DifficultyTier);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Offer: " + quest.QuestClass.Offer);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests StatementText: " + quest.QuestClass.StatementText);*/
|
||||
list.Add(quest);
|
||||
listFoundQuests.Add(POIName);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (quest.QuestTags.Test_AnySet(QuestEventManager.treasureTag) && GameSparksCollector.CollectGamePlayData)
|
||||
{
|
||||
GameSparksCollector.IncrementCounter(GameSparksCollector.GSDataKey.QuestOfferedDistance, ((int)Vector3.Distance(quest.Position, ___position) / 50 * 50).ToString(), 1, true, GameSparksCollector.GSDataCollection.SessionUpdates);
|
||||
}
|
||||
if (num == maxJobs)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests REACHED MAX JOBS num: " + num);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests maxJobs: " + maxJobs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests NumQuests: " + list.Count);
|
||||
|
||||
List<Quest> listSort = new List<Quest>();
|
||||
int iteration = 0;
|
||||
|
||||
while (list.Count > 0)
|
||||
{
|
||||
int position = -1;
|
||||
int distance = 999999;
|
||||
iteration++;
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests Iteration: " + iteration);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests distance: " + distance);
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
int distanceQuest = (int)Vector3.Distance(list[i].Position, ___position);
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests i: " + i + " distanceQuest: " + distanceQuest);
|
||||
if (distanceQuest < distance)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests distanceQuest < distance");
|
||||
distance = distanceQuest;
|
||||
position = i;
|
||||
}
|
||||
}
|
||||
if (position >= 0)
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests position >= 0: " + position);
|
||||
listSort.Add(list[position]);
|
||||
list.RemoveAt(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests position < 0: " + position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("EntityTraderPatches-PopulateActiveQuests NumQuests (Sorted): " + listSort.Count);
|
||||
|
||||
list = listSort;
|
||||
|
||||
for (int k = 0; k < ___specialQuestList.Count; k++)
|
||||
{
|
||||
if (___specialQuestList[k].QuestClass.UniqueKey == "" || !___uniqueKeysUsed.Contains(___specialQuestList[k].QuestClass.UniqueKey))
|
||||
{
|
||||
QuestClass questClass = ___specialQuestList[k].QuestClass;
|
||||
if ((int)(questClass.DifficultyTier - 1) <= currentTier && player.QuestJournal.FindQuest(questClass.ID, (int)__instance.NPCInfo.QuestFaction) == null)
|
||||
{
|
||||
Quest quest2 = questClass.CreateQuest();
|
||||
quest2.QuestGiverID = ___entityId;
|
||||
quest2.QuestFaction = __instance.NPCInfo.QuestFaction;
|
||||
quest2.SetPositionData(Quest.PositionDataTypes.QuestGiver, ___position);
|
||||
quest2.SetPositionData(Quest.PositionDataTypes.TraderPosition, (___traderArea != null) ? ___traderArea.Position : ___position);
|
||||
quest2.SetupTags();
|
||||
___usedPOILocations.Clear();
|
||||
if (!quest2.NeedsNPCSetPosition || quest2.SetupPosition(__instance, player, ___usedPOILocations, player.entityId))
|
||||
{
|
||||
list.Add(quest2);
|
||||
if (questClass.UniqueKey != "")
|
||||
{
|
||||
___uniqueKeysUsed.Add(questClass.UniqueKey);
|
||||
}
|
||||
if (GameSparksCollector.CollectGamePlayData)
|
||||
{
|
||||
GameSparksCollector.IncrementCounter(GameSparksCollector.GSDataKey.QuestTraderToTraderDistance, ((int)Vector3.Distance(quest2.Position, ___position) / 50 * 50).ToString(), 1, true, GameSparksCollector.GSDataCollection.SessionUpdates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__result = list;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace Harmony.EntityTurretPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(EntityTurret))]
|
||||
[HarmonyPatch("OnUpdateEntity")]
|
||||
public class OnUpdateEntityPatch
|
||||
{
|
||||
public static void Postfix(EntityTurret __instance,
|
||||
global::EntityAlive ___Owner
|
||||
)
|
||||
{
|
||||
if (__instance.EntityClass.entityClassName.Contains("FuriousRamsayJunkTurret"))
|
||||
{
|
||||
//Log.Out("__instance.belongsPlayerId: " + __instance.belongsPlayerId);
|
||||
__instance.ForceOn = true;
|
||||
__instance.IsOn = true;
|
||||
__instance.Laser.gameObject.SetActive(__instance.IsOn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityTurret))]
|
||||
[HarmonyPatch("CanInteract")]
|
||||
public class CanInteractPatch
|
||||
{
|
||||
private static bool Prefix(EntityTurret __instance,
|
||||
ref bool __result,
|
||||
int _interactingEntityId,
|
||||
bool ___isFalling
|
||||
)
|
||||
{
|
||||
bool canInteract = !___isFalling &&
|
||||
!__instance.PickedUpWaitingToDelete &&
|
||||
__instance.OriginalItemValue.type != 0 &&
|
||||
(__instance.belongsPlayerId == _interactingEntityId || __instance.Health <= 1);
|
||||
|
||||
|
||||
if (__instance.Buffs.GetCustomVar("$FR_Turret_Temp") == 1)
|
||||
{
|
||||
canInteract = false;
|
||||
}
|
||||
|
||||
__result = canInteract;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,685 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.EntityVehiclePatches
|
||||
{
|
||||
internal class EntityVehiclePatches
|
||||
{
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("OnCollisionForward")]
|
||||
public class OnCollisionForwardPatch
|
||||
{
|
||||
private static bool Prefix(EntityVehicle __instance, Transform t, Collision collision, bool isStay)
|
||||
{
|
||||
if (__instance.isEntityRemote)
|
||||
return false;
|
||||
if (!__instance.RBActive)
|
||||
{
|
||||
if ((double)__instance.vehicleRB.velocity.magnitude > 0.0099999997764825821 && (double)__instance.vehicleRB.angularVelocity.magnitude > 0.05000000074505806)
|
||||
__instance.RBActive = true;
|
||||
if (__instance.vehicleRB.isKinematic && (!(bool)(UnityEngine.Object)collision.rigidbody || (double)collision.rigidbody.velocity.magnitude > 0.05000000074505806))
|
||||
__instance.RBActive = true;
|
||||
}
|
||||
Entity entity = (Entity)null;
|
||||
int layer = collision.gameObject.layer;
|
||||
if (layer != 16)
|
||||
{
|
||||
ColliderHitCallForward component = collision.gameObject.GetComponent<ColliderHitCallForward>();
|
||||
if ((bool)(UnityEngine.Object)component)
|
||||
entity = component.Entity;
|
||||
if (!(bool)(UnityEngine.Object)entity)
|
||||
entity = __instance.FindEntity(collision.transform.parent);
|
||||
if (!(bool)(UnityEngine.Object)entity)
|
||||
{
|
||||
Rigidbody rigidbody = collision.rigidbody;
|
||||
if ((bool)(UnityEngine.Object)rigidbody)
|
||||
entity = __instance.FindEntity(rigidbody.transform);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity is EntityPlayer || (entity is EntityNPCRebirth npc && npc.Buffs.GetCustomVar("$Leader") > 0))
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-OnCollisionForward entity: " + entity.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("UseHorn")]
|
||||
public class UseHornPatch
|
||||
{
|
||||
private static void Postfix(EntityVehicle __instance)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-UseHorn START");
|
||||
if (__instance.AttachedMainEntity is EntityPlayer)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-UseHorn IS PLAYER");
|
||||
EntityPlayer player = __instance.AttachedMainEntity as EntityPlayer;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-UseHorn player: " + player.EntityName);
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkBetterBarter");
|
||||
|
||||
if (progressionValue != null && RebirthUtilities.GetCalculatedLevel(player, progressionValue) >= 1)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-UseHorn progressionValue: " + progressionValue.level);
|
||||
RebirthUtilities.CheckForTraderDoor(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("MoveByAttachedEntity")]
|
||||
public class MoveByAttachedEntityPatch
|
||||
{
|
||||
private static void Postfix(EntityVehicle __instance, EntityPlayerLocal _player, ref MovementInput ___movementInput)
|
||||
{
|
||||
LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(_player);
|
||||
PlayerActionsVehicle vehicleActions = uiForPlayer.playerInput.VehicleActions;
|
||||
|
||||
bool flag = _player.PlayerUI.windowManager.IsInputActive();
|
||||
|
||||
if (!flag && _player.AttachedToEntity != null)
|
||||
{
|
||||
bool isBicycle = _player.AttachedToEntity.EntityTags.Test_AllSet(FastTags<TagGroup.Global>.Parse("bicycle"));
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-MoveByAttachedEntity PRESSED Q");
|
||||
if (RebirthVariables.autoRun == 0)
|
||||
{
|
||||
RebirthVariables.autoRun = 1;
|
||||
}
|
||||
else if (RebirthVariables.autoRun == 1)
|
||||
{
|
||||
RebirthVariables.autoRun = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthVariables.autoRun = 0;
|
||||
}
|
||||
}
|
||||
else if ((double)vehicleActions.Move.Y > 0.0 ||
|
||||
vehicleActions.MoveBack.IsPressed ||
|
||||
vehicleActions.Brake.IsPressed &&
|
||||
__instance as EntityVHelicopter == null &&
|
||||
__instance as EntityVGyroCopter == null)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-MoveByAttachedEntity CANCEL");
|
||||
RebirthVariables.autoRun = 0;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Backspace) && !isBicycle)
|
||||
{
|
||||
if (RebirthVariables.musicMode == 0 || RebirthVariables.musicMode == -1)
|
||||
{
|
||||
RebirthVariables.musicMode = 1;
|
||||
RebirthVariables.walkman = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthVariables.musicMode = 0;
|
||||
RebirthVariables.walkman = false;
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 2;
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Equals))
|
||||
{
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 4;
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Minus))
|
||||
{
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthVariables.autoRun == 1)
|
||||
{
|
||||
//Log.Out("RebirthVariables.autoRun: " + RebirthVariables.autoRun);
|
||||
___movementInput.moveForward = 1;
|
||||
___movementInput.running = false;
|
||||
}
|
||||
else if (RebirthVariables.autoRun == 2)
|
||||
{
|
||||
//Log.Out("RebirthVariables.autoRun: " + RebirthVariables.autoRun);
|
||||
___movementInput.moveForward = 1;
|
||||
___movementInput.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("StartInteraction")]
|
||||
public class StartInteractionPatch
|
||||
{
|
||||
private static void SendSyncData(ushort syncFlags, EntityVehicle __instance)
|
||||
{
|
||||
NetPackageVehicleDataSync package = NetPackageManager.GetPackage<NetPackageVehicleDataSync>().Setup(__instance, GameManager.Instance.World.GetPrimaryPlayerId(), syncFlags);
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
return;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(package, false, -1, -1, -1, null, 192);
|
||||
}
|
||||
|
||||
//public static MethodInfo StopInteraction = AccessTools.Method(typeof(EntityVehicle), "StopInteraction", new Type[] { typeof(ushort) });
|
||||
|
||||
private static void StopInteraction(ushort syncFlags, ref int ___interactingPlayerId, EntityVehicle __instance)
|
||||
{
|
||||
___interactingPlayerId = -1;
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
syncFlags |= 4096;
|
||||
}
|
||||
if (syncFlags != 0)
|
||||
{
|
||||
SendSyncData(syncFlags, __instance);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Prefix(EntityVehicle __instance, int _playerId, int _requestId, ref int ___interactingPlayerId, int ___interactionRequestType, bool ___hasDriver)
|
||||
{
|
||||
EntityPlayerLocal localPlayerFromID = GameManager.Instance.World.GetLocalPlayerFromID(_playerId);
|
||||
if (!localPlayerFromID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_requestId != _playerId)
|
||||
{
|
||||
GameManager.ShowTooltip(localPlayerFromID, Localization.Get("ttVehicleInUse"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
___interactingPlayerId = _playerId;
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(localPlayerFromID);
|
||||
GUIWindowManager windowManager = uiforPlayer.windowManager;
|
||||
ushort num = 0;
|
||||
switch (___interactionRequestType)
|
||||
{
|
||||
case 1:
|
||||
string vehicleType = "V6CarRepair";
|
||||
|
||||
if (__instance.EntityClass.Properties.Values.ContainsKey("VehicleType"))
|
||||
{
|
||||
vehicleType = __instance.EntityClass.Properties.Values["VehicleType"];
|
||||
}
|
||||
|
||||
vehicleType = vehicleType + "Entity";
|
||||
|
||||
((XUiC_VehicleWindowGroupRebirth)((XUiWindowGroup)windowManager.GetWindow(vehicleType)).Controller).CurrentVehicleEntity = __instance;
|
||||
|
||||
windowManager.Open(vehicleType, true, false, true);
|
||||
|
||||
Manager.BroadcastPlayByLocalPlayer(__instance.position, "UseActions/service_vehicle");
|
||||
return false;
|
||||
case 2:
|
||||
if (XUiM_Vehicle.RepairVehicle(uiforPlayer.xui, __instance.vehicle))
|
||||
{
|
||||
num |= 4;
|
||||
__instance.PlayOneShot("crafting/craft_repair_item", true);
|
||||
}
|
||||
StopInteraction(num, ref ___interactingPlayerId, __instance);
|
||||
//StopInteraction.Invoke(__instance, new object[] { num });
|
||||
return false;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 8:
|
||||
break;
|
||||
case 6:
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch 6");
|
||||
if (__instance.AddFuelFromInventory(localPlayerFromID))
|
||||
{
|
||||
num |= 4;
|
||||
}
|
||||
StopInteraction(num, ref ___interactingPlayerId, __instance);
|
||||
//StopInteraction.Invoke(__instance, new object[] { num });
|
||||
return false;
|
||||
case 7:
|
||||
if (!__instance.bag.IsEmpty())
|
||||
{
|
||||
GameManager.ShowTooltip(localPlayerFromID, Localization.Get("ttEmptyVehicleBeforePickup"), string.Empty, "ui_denied", null);
|
||||
StopInteraction(0, ref ___interactingPlayerId, __instance);
|
||||
//StopInteraction.Invoke(__instance, new object[] { 0 });
|
||||
return false;
|
||||
}
|
||||
if (!___hasDriver)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch __instance.Health: " + __instance.Health);
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch UseTimes: " + (float)((int)__instance.Stats.Health.BaseMax - __instance.Health));
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch Meta: " + (int)(__instance.vehicle.GetFuelLevel() * 50f));
|
||||
|
||||
ItemValue itemValue = __instance.vehicle.GetUpdatedItemValue();
|
||||
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch itemValue.Meta: " + itemValue.Meta);
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch itemValue.UseTimes: " + itemValue.UseTimes);
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch itemValue.MaxUseTimes: " + itemValue.MaxUseTimes);
|
||||
|
||||
ItemStack itemStack = new ItemStack(itemValue, 1);
|
||||
//Log.Out("EntityVehiclePatches-StartInteractionPatch Item: " + __instance.vehicle.GetUpdatedItemValue().ItemClass.GetItemName());
|
||||
|
||||
if (localPlayerFromID.inventory.CanTakeItem(itemStack) || localPlayerFromID.bag.CanTakeItem(itemStack))
|
||||
{
|
||||
GameManager.Instance.CollectEntityServer(__instance.entityId, localPlayerFromID.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.ShowTooltip(localPlayerFromID, Localization.Get("xuiInventoryFullForPickup"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
}
|
||||
StopInteraction(0, ref ___interactingPlayerId, __instance);
|
||||
//StopInteraction.Invoke(__instance, new object[] { 0 });
|
||||
return false;
|
||||
case 9:
|
||||
((XUiC_VehicleStorageWindowGroup)((XUiWindowGroup)windowManager.GetWindow("vehicleStorage")).Controller).CurrentVehicleEntity = __instance;
|
||||
windowManager.Open("vehicleStorage", true, false, true);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("ApplyCollisionDamageToAttached")]
|
||||
public class ApplyCollisionDamageToAttachedPatch
|
||||
{
|
||||
private static bool Prefix(EntityVehicle __instance, int damage)
|
||||
{
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("ApplyDamage")]
|
||||
public class ApplyDamagePatch
|
||||
{
|
||||
private static bool Prefix(EntityVehicle __instance, int damage, ref float ___explodeHealth)
|
||||
{
|
||||
if (!RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
damage = damage / 10;
|
||||
}
|
||||
|
||||
if (__instance is global::EntityVehicleRebirth)
|
||||
{
|
||||
int MinDamage = 1;
|
||||
|
||||
/*Log.Out("EntityVehicleRebirth-ApplyDamage damage: " + damage);
|
||||
|
||||
if (__instance.EntityClass.Properties.Values.ContainsKey("VehicleType"))
|
||||
{
|
||||
string vehicleType = __instance.EntityClass.Properties.Values["VehicleType"];
|
||||
|
||||
if (vehicleType == "BicycleRepair")
|
||||
{
|
||||
MinDamage = 5;
|
||||
}
|
||||
else if (vehicleType == "MinibikeRepair" ||
|
||||
vehicleType == "GyroRepair"
|
||||
)
|
||||
{
|
||||
MinDamage = 10;
|
||||
}
|
||||
else if (vehicleType == "MotorcycleRepair" ||
|
||||
vehicleType == "QuadRepair"
|
||||
)
|
||||
{
|
||||
MinDamage = 10;
|
||||
}
|
||||
else if (vehicleType == "V6CarRepair" ||
|
||||
vehicleType == "V8CarRepair"
|
||||
)
|
||||
{
|
||||
MinDamage = 15;
|
||||
}
|
||||
else if (vehicleType == "V6TruckRepair" ||
|
||||
vehicleType == "V8TruckRepair"
|
||||
)
|
||||
{
|
||||
MinDamage = 15;
|
||||
}
|
||||
else if (vehicleType == "RVRepair" ||
|
||||
vehicleType == "6WheelerRepair"
|
||||
)
|
||||
{
|
||||
MinDamage = 20;
|
||||
}
|
||||
else if (vehicleType == "8WheelerRepair")
|
||||
{
|
||||
MinDamage = 20;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (damage >= MinDamage)
|
||||
{
|
||||
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)__instance;
|
||||
|
||||
int slotNumber = 0;
|
||||
|
||||
GameRandom rng = new GameRandom();
|
||||
|
||||
foreach (ItemValue item in entityVehicle.itemValues)
|
||||
{
|
||||
int random = rng.RandomRange(1, 3);
|
||||
|
||||
//Log.Out("EntityVehicleRebirth-ApplyDamage item.ItemClass.GetItemName(): " + item.ItemClass.GetItemName());
|
||||
//Log.Out("EntityVehicleRebirth-ApplyDamage random: " + random);
|
||||
if (random == 2)
|
||||
{
|
||||
if (item.type == ItemValue.None.type)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((item.UseTimes + 3) < item.MaxUseTimes)
|
||||
{
|
||||
item.UseTimes += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.UseTimes = item.MaxUseTimes;
|
||||
}
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("EntityVehicleRebirth-ApplyDamage slotNumber: " + slotNumber);
|
||||
//Log.Out("EntityVehicleRebirth-ApplyDamage Degradation: " + item.UseTimes + "/" + item.MaxUseTimes);
|
||||
//Log.Out("EntityVehicleRebirth-ApplyDamage Quality: " + item.Quality + "/" + item.Quality);
|
||||
NetPackageVehicleUpdatePartRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdatePartRebirth>().Setup(__instance.GetAttachedPlayerLocal().entityId, entityVehicle.entityId, slotNumber, item.UseTimes, item.Quality, item.ItemClass.GetItemName());
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slotNumber++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int num = __instance.Health;
|
||||
if (num <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag = damage >= 99999;
|
||||
if (num == 1 || flag)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
___explodeHealth -= (float)damage;
|
||||
if (___explodeHealth <= 0f && (flag || __instance.rand.RandomFloat < 0.2f))
|
||||
{
|
||||
__instance.Kill();
|
||||
GameManager.Instance.ExplosionServer(0, __instance.GetPosition(), World.worldToBlockPos(__instance.GetPosition()), __instance.transform.rotation, EntityClass.list[__instance.entityClass].explosionData, __instance.entityId, 0f, false, null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num -= damage;
|
||||
if (num <= 1)
|
||||
{
|
||||
num = 1;
|
||||
___explodeHealth = (float)__instance.vehicle.GetMaxHealth() * 0.03f;
|
||||
}
|
||||
__instance.Health = num;
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
NetPackageUpdateVehicleHealthRebirth package = NetPackageManager.GetPackage<NetPackageUpdateVehicleHealthRebirth>().Setup(__instance.entityId, num);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("GetActivationCommands")]
|
||||
public class EntityVehicleGetActivationCommandsPatch
|
||||
{
|
||||
public static MethodInfo isDriveable = AccessTools.Method(typeof(EntityVehicle), "isDriveable", new Type[] { });
|
||||
public static MethodInfo isAllowedUser = AccessTools.Method(typeof(EntityVehicle), "isAllowedUser", new Type[] { typeof(PlatformUserIdentifierAbs) });
|
||||
|
||||
private static bool Prefix(EntityVehicle __instance, ref EntityActivationCommand[] __result, Vector3i _tePos, EntityAlive _entityFocusing, Vehicle ___vehicle, bool ___hasDriver)
|
||||
{
|
||||
if (__instance.IsDead())
|
||||
{
|
||||
__result = new EntityActivationCommand[0];
|
||||
}
|
||||
bool isAdmin = _entityFocusing.Buffs.HasBuff("god");
|
||||
|
||||
bool optionVehicleSecurity = RebirthVariables.customVehicleSecurity;
|
||||
|
||||
bool optionVehiclePickup = RebirthVariables.customVehiclePickUp;
|
||||
|
||||
bool isOwner = __instance.LocalPlayerIsOwner();
|
||||
|
||||
bool isOwnerOrAdmin = isOwner || isAdmin;
|
||||
|
||||
bool isAllowed = (bool)isAllowedUser.Invoke(__instance, new object[] { PlatformManager.InternalLocalUserIdentifier });
|
||||
bool noSecurityUnlocked = !optionVehicleSecurity && !__instance.isLocked;
|
||||
bool canAccess = isOwnerOrAdmin || isAllowed || noSecurityUnlocked;
|
||||
bool isVehicle = __instance.CanAttach(_entityFocusing) && (bool)isDriveable.Invoke(__instance, new object[] { });
|
||||
bool isDriven = __instance.IsDriven();
|
||||
|
||||
/*Log.Out("EntityVehiclePatches-GetActivationCommands isVehicle: " + isVehicle);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands isDriven: " + isDriven);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands isOwner: " + isOwner);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands isOwnerOrAdmin: " + isOwnerOrAdmin);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands isAllowed: " + isAllowed);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands optionVehicleSecurity: " + optionVehicleSecurity);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands isLocked: " + __instance.isLocked);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands noSecurityUnlocked: " + noSecurityUnlocked);
|
||||
Log.Out("EntityVehiclePatches-GetActivationCommands canAccess: " + canAccess);*/
|
||||
|
||||
EntityActivationCommand entityActivationCommand;
|
||||
if (!isDriven)
|
||||
{
|
||||
entityActivationCommand = new EntityActivationCommand("drive", "drive", isVehicle && canAccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityActivationCommand = new EntityActivationCommand("ride", "drive", isVehicle && canAccess);
|
||||
}
|
||||
|
||||
bool optionPickUp = RebirthVariables.customVehiclePickUp;
|
||||
|
||||
__result = new EntityActivationCommand[]
|
||||
{
|
||||
entityActivationCommand,
|
||||
new EntityActivationCommand("service", "service", canAccess),
|
||||
new EntityActivationCommand("repair", "wrench", false), //___vehicle.GetRepairAmountNeeded() > 0),
|
||||
new EntityActivationCommand("lock", "lock", isOwnerOrAdmin && !__instance.isLocked && !isDriven),
|
||||
new EntityActivationCommand("unlock", "unlock", __instance.isLocked && isOwnerOrAdmin),
|
||||
new EntityActivationCommand("keypad", "keypad", __instance.isLocked && (isOwnerOrAdmin || ___vehicle.PasswordHash != 0)),
|
||||
new EntityActivationCommand("refuel", "gas", false), //hasGasCan(_entityFocusing, ___vehicle) && needsFuel(___vehicle)),
|
||||
new EntityActivationCommand("take", "hand", !___hasDriver && isOwnerOrAdmin && (__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("canPickUp")) || optionPickUp)),
|
||||
new EntityActivationCommand("horn", "horn", false), //flag2 && ___vehicle.HasHorn()),
|
||||
new EntityActivationCommand("storage", "loot_sack", canAccess),
|
||||
new EntityActivationCommand("remove", "trash", !___hasDriver && !__instance.isLocked && isOwnerOrAdmin && !optionVehiclePickup)
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("OnEntityActivated")]
|
||||
public class OnEntityActivatedPatch
|
||||
{
|
||||
private static bool Prefix(EntityVehicle __instance, int _indexInBlockActivationCommands, Vector3i _tePos, EntityAlive _entityFocusing, bool ___hasDriver)
|
||||
{
|
||||
//Log.Out("EntityVehiclePatches-OnEntityActivated _indexInBlockActivationCommands: " + _indexInBlockActivationCommands);
|
||||
|
||||
EntityPlayerLocal entityPlayerLocal = _entityFocusing as EntityPlayerLocal;
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
if (entityPlayerLocal.inventory.IsHoldingItemActionRunning() || uiforPlayer.xui.isUsingItemActionEntryUse)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityActivationCommand[] myActivationCommands = __instance.GetActivationCommands(Vector3i.zero, _entityFocusing);
|
||||
|
||||
bool optionPickUp = RebirthVariables.customVehiclePickUp;
|
||||
|
||||
if (!__instance.HasAnyTags(FastTags<TagGroup.Global>.Parse("canPickUp")) && !optionPickUp)
|
||||
{
|
||||
if (myActivationCommands[_indexInBlockActivationCommands].text == "take")
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupVehicle"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myActivationCommands[_indexInBlockActivationCommands].text == "take")
|
||||
{
|
||||
if (__instance is global::EntityVehicleRebirth)
|
||||
{
|
||||
if (!__instance.bag.IsEmpty())
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttEmptyVehicleBeforePickup"), string.Empty, "ui_denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)__instance;
|
||||
|
||||
if (!entityVehicle.EntityClass.entityClassName.ToLower().Contains("bicycle"))
|
||||
{
|
||||
int numParts = 0;
|
||||
|
||||
foreach (ItemValue item in entityVehicle.itemValues)
|
||||
{
|
||||
if (item.type != ItemValue.None.type)
|
||||
{
|
||||
//numParts++;
|
||||
entityPlayerLocal.bag.AddItem(new ItemStack(item, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (numParts > 0 && !entityVehicle.EntityClass.entityClassName.ToLower().Contains("bicycle"))
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttEmptyVehiclePartsBeforePickup"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (myActivationCommands[_indexInBlockActivationCommands].text == "remove")
|
||||
{
|
||||
if (uiforPlayer != null)
|
||||
{
|
||||
if (!__instance.bag.IsEmpty())
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttEmptyVehicleBeforeRemove"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance is global::EntityVehicleRebirth)
|
||||
{
|
||||
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)__instance;
|
||||
|
||||
int numParts = 0;
|
||||
|
||||
foreach (ItemValue item in entityVehicle.itemValues)
|
||||
{
|
||||
if (item.type != ItemValue.None.type)
|
||||
{
|
||||
numParts++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numParts > 0)
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttEmptyVehiclePartsBeforeRemove"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!___hasDriver)
|
||||
{
|
||||
((XUiC_ConfirmWindowGroupRebirth)((XUiWindowGroup)uiforPlayer.windowManager.GetWindow("Confirm")).Controller).currentVehicleEntity = __instance;
|
||||
uiforPlayer.windowManager.Open("Confirm", true, false, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (myActivationCommands[_indexInBlockActivationCommands].text == "refuel")
|
||||
{
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("ammoGasCan"), entityPlayerLocal))
|
||||
{
|
||||
RebirthUtilities.notifyMissingItem(ItemClass.GetItem("ammoGasCan"), entityPlayerLocal);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((__instance != null && !__instance.GetVehicle().HasEnginePart()) || !__instance.AddFuelFromInventory(entityPlayerLocal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("Awake")]
|
||||
public class AwakePatch
|
||||
{
|
||||
public static void Postfix(EntityVehicle __instance)
|
||||
{
|
||||
__instance.isLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(EntityVehicle))]
|
||||
[HarmonyPatch("EnterVehicle")]
|
||||
public class EnterVehiclePatch
|
||||
{
|
||||
private static bool Prefix(EntityVehicle __instance, EntityAlive _entity)
|
||||
{
|
||||
float flActionInProgress = RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"];
|
||||
|
||||
if (flActionInProgress == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.Buffs.SetCustomVar("$autoRunToggle", 0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Harmony.EquipmentPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Equipment))]
|
||||
[HarmonyPatch("ModifyValue")]
|
||||
public class ModifyValuePatch
|
||||
{
|
||||
public static bool Prefix(Equipment __instance, ItemValue _originalItemValue, PassiveEffects _passiveEffect, ref float _base_val, ref float _perc_val, FastTags<TagGroup.Global> tags, bool _useDurability)
|
||||
{
|
||||
for (int index = 0; index < __instance.m_slots.Length; ++index)
|
||||
{
|
||||
ItemValue slot = __instance.m_slots[index];
|
||||
if (slot != null && !slot.Equals(_originalItemValue) && slot.ItemClass != null)
|
||||
{
|
||||
//Log.Out("EquipmentPatches-ModifyValue slot: " + slot.ItemClass.Name);
|
||||
//Log.Out("EquipmentPatches-ModifyValue PercentUsesLeft: " + slot.PercentUsesLeft);
|
||||
|
||||
if (slot.PercentUsesLeft > 0)
|
||||
{
|
||||
//Log.Out("EquipmentPatches-ModifyValue OVER ZERO");
|
||||
slot.ModifyValue(__instance.m_entity, _originalItemValue, _passiveEffect, ref _base_val, ref _perc_val, tags, _useDurability: !RebirthUtilities.ScenarioSkip());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.GUIWindowManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GUIWindowManager))]
|
||||
[HarmonyPatch("CloseAllOpenWindows")]
|
||||
[HarmonyPatch(new Type[] { typeof(GUIWindow), typeof(bool) })]
|
||||
public class CloseAllOpenWindowsPatch
|
||||
{
|
||||
public static bool Prefix(GUIWindowManager __instance, ref bool __result, GUIWindow _exceptThis, bool _fromEsc,
|
||||
List<GUIWindow> ___windows
|
||||
)
|
||||
{
|
||||
bool result = false;
|
||||
for (int i = 0; i < ___windows.Count; i++)
|
||||
{
|
||||
GUIWindow guiwindow = ___windows[i];
|
||||
|
||||
if (guiwindow.Id == "InformationPreview" || guiwindow.Id == "SelectClass")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (guiwindow.isModal && (_exceptThis == null || _exceptThis != guiwindow))
|
||||
{
|
||||
__instance.Close(guiwindow, _fromEsc);
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
__result = result;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GUIWindowManager))]
|
||||
[HarmonyPatch("Open")]
|
||||
[HarmonyPatch(new Type[] { typeof(GUIWindow), typeof(bool), typeof(bool), typeof(bool) })]
|
||||
public class OpenPatch
|
||||
{
|
||||
public static bool Prefix(GUIWindowManager __instance, GUIWindow _w, bool _bModal, bool _bIsNotEscClosable, bool _bCloseAllOpenWindows,
|
||||
Dictionary<string, GUIWindow> ___nameToWindowMap
|
||||
)
|
||||
{
|
||||
if (__instance.IsWindowOpen("InformationPreview") ||
|
||||
__instance.IsWindowOpen("SelectClass")
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("GUIWindowManagerPatches-Open START");
|
||||
|
||||
/*foreach (string key in ___nameToWindowMap.Keys)
|
||||
{
|
||||
Log.Out("GUIWindowManagerPatches-Open window: " + key);
|
||||
}*/
|
||||
|
||||
if (___nameToWindowMap.ContainsKey("backpack") && _w == ___nameToWindowMap["backpack"])
|
||||
{
|
||||
EntityPlayerLocal ___entityPlayerLocal = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
bool isValid = false;
|
||||
|
||||
if (___entityPlayerLocal.inventory.holdingItem != null)
|
||||
{
|
||||
bool bRanged = ___entityPlayerLocal.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("ranged");
|
||||
bool bMelee = ___entityPlayerLocal.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("melee");
|
||||
bool bAmmo = ___entityPlayerLocal.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("ammo");
|
||||
bool bDrone = ___entityPlayerLocal.inventory.holdingItem.ItemTags.ToString().ToLower().Contains("drone");
|
||||
|
||||
if ((bRanged || bMelee) && !bAmmo && !bDrone)
|
||||
{
|
||||
List<string> tagNames = ___entityPlayerLocal.inventory.holdingItem.ItemTags.GetTagNames();
|
||||
|
||||
float activeClassID = ___entityPlayerLocal.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
|
||||
//Log.Out("GUIWindowManagerPatches-Open item: " + ___entityPlayerLocal.inventory.holdingItem.GetItemName());
|
||||
|
||||
//Log.Out("GUIWindowManagerPatches-Open bMelee: " + bMelee);
|
||||
//Log.Out("GUIWindowManagerPatches-Open bRanged: " + bRanged);
|
||||
|
||||
if (bRanged)
|
||||
{
|
||||
bMelee = false;
|
||||
}
|
||||
|
||||
RebirthUtilities.SetAuraChance(ItemClass.GetItem(___entityPlayerLocal.inventory.holdingItem.GetItemName(), false), ___entityPlayerLocal.inventory.holdingItem.GetItemName(), ___entityPlayerLocal.entityId, activeClassID, -1, false, bMelee);
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("GUIWindowManagerPatches-Open isValid: " + isValid);
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
for (int i = 0; i < RebirthVariables.localAuraChances.Count; i++)
|
||||
{
|
||||
string auraKey = RebirthVariables.localAuraChances.ElementAt(i).Key;
|
||||
float baseChance = 0;
|
||||
int auraProgressionLevel = 0;
|
||||
bool isOwner = false;
|
||||
|
||||
foreach (BuffValue buffValue in ___entityPlayerLocal.Buffs.ActiveBuffs)
|
||||
{
|
||||
if (buffValue != null && buffValue.BuffClass != null)
|
||||
{
|
||||
BuffClass buffClass = buffValue.BuffClass;
|
||||
|
||||
if (buffClass.Name.ToLower().Contains(("FuriousRamsayBuff" + auraKey + "Aura").ToLower()))
|
||||
{
|
||||
if (buffClass.Name.ToLower() == ("FuriousRamsayBuff" + auraKey + "Aura").ToLower())
|
||||
{
|
||||
string progression = RebirthVariables.localAuras[auraKey].progressionName;
|
||||
|
||||
ProgressionValue auraProgressionValue = ___entityPlayerLocal.Progression.GetProgressionValue(progression);
|
||||
auraProgressionLevel = auraProgressionValue.Level;
|
||||
isOwner = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auraProgressionLevel = int.Parse(buffClass.Name.ToLower().Replace(("FuriousRamsayBuff" + auraKey + "Aura").ToLower(), ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float chance = 10;
|
||||
|
||||
if (!isOwner)
|
||||
{
|
||||
chance *= 0.5f;
|
||||
}
|
||||
|
||||
baseChance = auraProgressionLevel * RebirthVariables.localAuras[auraKey].baseChancePerLevel;
|
||||
|
||||
if (RebirthVariables.localAuras[auraKey].overrideChance)
|
||||
{
|
||||
baseChance = chance * RebirthVariables.localAuras[auraKey].baseChancePerLevel;
|
||||
}
|
||||
|
||||
RebirthVariables.localConstants["$varFuriousRamsay" + auraKey + "Aura_Cst"] = 0f;
|
||||
RebirthVariables.localConstants["$varFuriousRamsay" + auraKey + "AuraBase_Cst"] = baseChance;
|
||||
RebirthVariables.localConstants["$varFuriousRamsay" + auraKey + "AuraBase2_Cst"] = baseChance * 2;
|
||||
|
||||
//Log.Out("GUIWindowManagerPatches-Open baseChance: " + baseChance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
namespace Harmony.GameEventManagerPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(GameEventManager))]
|
||||
[HarmonyPatch("HandleAction")]
|
||||
[HarmonyPatch(new Type[] { typeof(string), typeof(EntityPlayer), typeof(Entity), typeof(bool), typeof(Vector3), typeof(string), typeof(string), typeof(bool), typeof(bool), typeof(string), typeof(GameEventActionSequence) })]
|
||||
public class HandleActionPatch
|
||||
{
|
||||
private static bool Prefix(GameEventManager __instance, ref bool __result, string name, EntityPlayer requester, Entity entity, bool twitchActivated, Vector3 targetPosition, string extraData, string tag, bool crateShare, bool allowRefunds, string sequenceLink, GameEventActionSequence ownerSeq
|
||||
)
|
||||
{
|
||||
//Log.Out("GameEventManagerPatches-HandleAction START, name: " + name);
|
||||
|
||||
if (name == "game_first_spawn")
|
||||
{
|
||||
if (GameUtils.IsPlaytesting())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int playerLevel = requester.Progression.GetLevel();
|
||||
int xpToNextLevel = requester.Progression.ExpToNextLevel;
|
||||
|
||||
//Log.Out("GameEventManagerPatches-HandleAction playerLevel: " + playerLevel);
|
||||
//Log.Out("GameEventManagerPatches-HandleAction xpToNextLevel: " + xpToNextLevel);
|
||||
|
||||
if (playerLevel == 1 && xpToNextLevel == 11024)
|
||||
{
|
||||
string optionJumpstart = RebirthVariables.customJumpstart;
|
||||
//Log.Out("GameEventManagerPatches-HandleAction optionJumpstart: " + optionJumpstart);
|
||||
|
||||
if (RebirthVariables.customBiomeSpawn != "random" && RebirthVariables.customScenario == "none")
|
||||
{
|
||||
if (optionJumpstart != "none")
|
||||
{
|
||||
//Log.Out("GameEventManagerPatches-HandleAction JUMPSTART");
|
||||
name = "game_first_spawn_jumpstart";
|
||||
}
|
||||
else if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("GameEventManagerPatches-HandleAction NORMAL");
|
||||
name = "game_first_spawn_fr";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//name = "intro_purge";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "game_first_spawn_scenario_fr";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
__result = __instance.HandleActionClient(name, entity, twitchActivated, targetPosition, extraData, tag, crateShare, allowRefunds, sequenceLink);
|
||||
return false;
|
||||
}
|
||||
if (GameEventManager.GameEventSequences.ContainsKey(name))
|
||||
{
|
||||
GameEventActionSequence gameEventActionSequence = GameEventManager.GameEventSequences[name];
|
||||
if (gameEventActionSequence.CanPerform(entity))
|
||||
{
|
||||
if (gameEventActionSequence.SingleInstance)
|
||||
{
|
||||
for (int i = 0; i < __instance.ActionSequenceUpdates.Count; i++)
|
||||
{
|
||||
if (__instance.ActionSequenceUpdates[i].Name == name)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
GameEventActionSequence gameEventActionSequence2 = gameEventActionSequence.Clone();
|
||||
gameEventActionSequence2.Target = entity;
|
||||
gameEventActionSequence2.TargetPosition = targetPosition;
|
||||
if (ownerSeq == null && sequenceLink != "" && requester != null)
|
||||
{
|
||||
ownerSeq = __instance.GetSequenceLink(requester, sequenceLink);
|
||||
}
|
||||
if (ownerSeq != null)
|
||||
{
|
||||
gameEventActionSequence2.Requester = ownerSeq.Requester;
|
||||
gameEventActionSequence2.ExtraData = ownerSeq.ExtraData;
|
||||
gameEventActionSequence2.CrateShare = ownerSeq.CrateShare;
|
||||
gameEventActionSequence2.Tag = ownerSeq.Tag;
|
||||
gameEventActionSequence2.AllowRefunds = ownerSeq.AllowRefunds;
|
||||
gameEventActionSequence2.TwitchActivated = ownerSeq.TwitchActivated;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameEventActionSequence2.Requester = requester;
|
||||
gameEventActionSequence2.ExtraData = extraData;
|
||||
gameEventActionSequence2.CrateShare = crateShare;
|
||||
gameEventActionSequence2.Tag = tag;
|
||||
gameEventActionSequence2.AllowRefunds = allowRefunds;
|
||||
gameEventActionSequence2.TwitchActivated = twitchActivated;
|
||||
}
|
||||
gameEventActionSequence2.OwnerSequence = ownerSeq;
|
||||
if (gameEventActionSequence2.TargetType != GameEventActionSequence.TargetTypes.Entity)
|
||||
{
|
||||
gameEventActionSequence2.POIPosition = new Vector3i(targetPosition);
|
||||
}
|
||||
gameEventActionSequence2.SetupTarget();
|
||||
__instance.ActionSequenceUpdates.Add(gameEventActionSequence2);
|
||||
__result = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,723 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
using Twitch;
|
||||
using static RebirthManager;
|
||||
using static SharedChunkObserverCache.SharedChunkObserver;
|
||||
|
||||
namespace Harmony.GameManagerPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(ApplyExplosionForce))]
|
||||
[HarmonyPatch("Explode")]
|
||||
public class ExplodePatch
|
||||
{
|
||||
private static bool Prefix(ApplyExplosionForce __instance, Vector3 explosionPos, float power, float radius)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-Explode explosionPos: " + explosionPos);
|
||||
explosionPos -= Origin.position;
|
||||
power *= 20f;
|
||||
radius *= 1.75f;
|
||||
int num = Physics.OverlapSphereNonAlloc(explosionPos, radius, ApplyExplosionForce.colliderList);
|
||||
if (num > 1024)
|
||||
num = 1024;
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
Rigidbody component = ApplyExplosionForce.colliderList[index].GetComponent<Rigidbody>();
|
||||
if ((bool)(UnityEngine.Object)component)
|
||||
component.AddExplosionForce(power, explosionPos, radius, 3f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("ExplosionClient")]
|
||||
public class ExplosionClientPatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, ref GameObject __result, int _clrIdx,
|
||||
Vector3 _center,
|
||||
Quaternion _rotation,
|
||||
int _index,
|
||||
int _blastPower,
|
||||
float _blastRadius,
|
||||
float _blockDamage,
|
||||
int _entityId,
|
||||
List<BlockChangeInfo> _explosionChanges)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ExplosionClient START");
|
||||
if (__instance.m_World == null)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ExplosionClient 1");
|
||||
__result = (GameObject)null;
|
||||
return false;
|
||||
}
|
||||
GameObject gameObject = (GameObject)null;
|
||||
if (_index > 0 && _index < WorldStaticData.prefabExplosions.Length && (UnityEngine.Object)WorldStaticData.prefabExplosions[_index] != (UnityEngine.Object)null)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ExplosionClient 2");
|
||||
gameObject = UnityEngine.Object.Instantiate<GameObject>(WorldStaticData.prefabExplosions[_index].gameObject, _center - Origin.position, _rotation);
|
||||
ApplyExplosionForce.Explode(_center, (float)_blastPower, _blastRadius);
|
||||
}
|
||||
if (_index == 0 && _blastPower == 201)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ExplosionClient 3");
|
||||
ApplyExplosionForce.Explode(_center, (float)_blastPower, _blastRadius);
|
||||
}
|
||||
if (_explosionChanges.Count > 0)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ExplosionClient 4");
|
||||
__instance.ChangeBlocks((PlatformUserIdentifierAbs)null, _explosionChanges);
|
||||
}
|
||||
QuestEventManager.Current.DetectedExplosion(_center, _entityId, _blockDamage);
|
||||
__result = gameObject;
|
||||
//Log.Out("GameManagerPatches-ExplosionClient END");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("SharedKillClient")]
|
||||
public class SharedKillClientPatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, int _entityTypeID, int _xp, EntityPlayerLocal _player = null, int _entityID = -1)
|
||||
{
|
||||
if ((UnityEngine.Object)_player == (UnityEngine.Object)null)
|
||||
_player = __instance.myEntityPlayerLocal;
|
||||
if ((UnityEngine.Object)_player == (UnityEngine.Object)null)
|
||||
return false;
|
||||
string entityClassName = EntityClass.list[_entityTypeID].entityClassName;
|
||||
|
||||
float partyMultiplierOption = float.Parse(RebirthVariables.customPartyXPMultiplier) / 100;
|
||||
|
||||
//Log.Out("GameManagerPatches-SharedKillClient 1, _xp: " + _xp);
|
||||
//Log.Out("GameManagerPatches-SharedKillClient 1, partyMultiplierOption: " + partyMultiplierOption);
|
||||
_xp = (int)(_xp * partyMultiplierOption);
|
||||
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
//Log.Out("GameManagerPatches-SharedKillClient IS HORDE NIGHT, BEFORE: " + _xp);
|
||||
_xp = (int)(_xp * RebirthVariables.hordeNightXPMultiplier);
|
||||
}
|
||||
|
||||
//Log.Out("GameManagerPatches-SharedKillClient XP AFTER: " + _xp);
|
||||
|
||||
_xp = _player.Progression.AddLevelExp(_xp, "_xpFromParty", Progression.XPTypes.Kill);
|
||||
//Log.Out("GameManagerPatches-SharedKillClient AddLevelExp, _xp: " + _xp);
|
||||
|
||||
_player.bPlayerStatsChanged = true;
|
||||
if (_xp > 0)
|
||||
GameManager.ShowTooltip(_player, string.Format(Localization.Get("ttPartySharedXPReceived"), (object)_xp));
|
||||
QuestEventManager.Current.EntityKilled((EntityAlive)_player, _entityID == -1 ? (EntityAlive)null : __instance.m_World.GetEntity(_entityID) as EntityAlive);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("PlayerSpawnedInWorld")]
|
||||
public class PlayerSpawnedInWorldPatch
|
||||
{
|
||||
private static void Postfix(GameManager __instance, ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos, int _entityId)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld START, _respawnReason: " + _respawnReason);
|
||||
|
||||
RebirthUtilities.LoadRebirthXMLOptions();
|
||||
|
||||
Entity entity;
|
||||
if (_entityId == -1 || !__instance.m_World.Entities.dict.TryGetValue(_entityId, out entity))
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld 0, _entityId: " + _entityId);
|
||||
return;
|
||||
}
|
||||
|
||||
bool isPlayer = entity is EntityPlayer;
|
||||
bool isLoadedGame = _respawnReason == RespawnType.LoadedGame || (_respawnReason == RespawnType.JoinMultiplayer && SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer);
|
||||
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld isPlayer: " + isPlayer);
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld isLoadedGame: " + isLoadedGame);
|
||||
|
||||
if (isPlayer && isLoadedGame)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld 1");
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
player.Buffs.AddBuff("FuriousRamsaySpawningDelay");
|
||||
|
||||
SpawnPosition spawnPoint = RebirthUtilities.GetSpawnPoint(player);
|
||||
|
||||
if (!spawnPoint.IsUndef())
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld ADD CHUNK OBSERVER");
|
||||
RebirthVariables.chunkObserver = GameManager.Instance.AddChunkObserver(spawnPoint.position, false, 3, -1);
|
||||
}
|
||||
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld 2");
|
||||
if (hire.playerID == player.entityId)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld hire.name: " + hire.name);
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld hire.order: " + hire.order);
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld hire.spawnPosition: " + hire.spawnPosition);
|
||||
if (hire.order == 1)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld 3");
|
||||
bool foundObserver = false;
|
||||
|
||||
foreach (chunkObservers observer in observers)
|
||||
{
|
||||
if (observer.entityID == hire.hireID)
|
||||
{
|
||||
foundObserver = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("GameManagerPatches-PlayerSpawnedInWorld foundObserver: " + foundObserver);
|
||||
|
||||
if (!foundObserver)
|
||||
{
|
||||
float height1 = GameManager.Instance.World.GetTerrainHeight((int)hire.spawnPosition.x, (int)hire.spawnPosition.z);
|
||||
float height2 = GameManager.Instance.World.GetHeight((int)hire.spawnPosition.x, (int)hire.spawnPosition.z);
|
||||
|
||||
float height = ((height1 + height2) / 2f) + 1.5f;
|
||||
|
||||
ChunkManager.ChunkObserver observerRef = GameManager.Instance.AddChunkObserver(new Vector3(hire.spawnPosition.x, height, hire.spawnPosition.z), false, 3, -1);
|
||||
observers.Add(new chunkObservers(hire.hireID, observerRef));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("ItemDropServer")]
|
||||
[HarmonyPatch(new[] { typeof(ItemStack), typeof(Vector3), typeof(Vector3), typeof(Vector3), typeof(int), typeof(float), typeof(bool), typeof(int) })]
|
||||
public class ItemDropServerPatch
|
||||
{
|
||||
public static bool Prefix(GameManager __instance, ItemStack _itemStack, Vector3 _dropPos, Vector3 _randomPosAdd, Vector3 _initialMotion, int _entityId, float _lifetime, bool _bDropPosIsRelativeToHead, int _clientEntityId)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-ItemDropServer _itemStack.itemValue.ItemClass.Name: " + _itemStack.itemValue.ItemClass.Name);
|
||||
|
||||
Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
|
||||
if (__instance.m_World == null)
|
||||
return false;
|
||||
bool flag = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer;
|
||||
Entity entity1 = __instance.m_World.GetEntity(_entityId);
|
||||
if (_clientEntityId != 0)
|
||||
{
|
||||
if (!(bool)(UnityEngine.Object)entity1)
|
||||
return false;
|
||||
flag = !entity1.isEntityRemote;
|
||||
}
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
if (_clientEntityId == -1)
|
||||
_clientEntityId = --__instance.m_World.clientLastEntityId;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageItemDrop>().Setup(_itemStack, _dropPos, _initialMotion, _randomPosAdd, _lifetime, _entityId, _bDropPosIsRelativeToHead, _clientEntityId));
|
||||
if (!flag)
|
||||
return false;
|
||||
}
|
||||
if (_bDropPosIsRelativeToHead)
|
||||
{
|
||||
if ((UnityEngine.Object)entity1 == (UnityEngine.Object)null)
|
||||
return false;
|
||||
_dropPos += entity1.getHeadPosition();
|
||||
}
|
||||
if (!_randomPosAdd.Equals(Vector3.zero))
|
||||
_dropPos += new Vector3(__instance.m_World.RandomRange(-_randomPosAdd.x, _randomPosAdd.x), __instance.m_World.RandomRange(-_randomPosAdd.y, _randomPosAdd.y), __instance.m_World.RandomRange(-_randomPosAdd.z, _randomPosAdd.z));
|
||||
EntityCreationData _ecd = new EntityCreationData();
|
||||
_ecd.entityClass = EntityClass.FromString("item");
|
||||
_ecd.id = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer || _clientEntityId >= -1 ? EntityFactory.nextEntityID++ : _clientEntityId;
|
||||
_ecd.itemStack = _itemStack.Clone();
|
||||
_ecd.pos = _dropPos;
|
||||
_ecd.rot = new Vector3(20f, 0.0f, 20f);
|
||||
_ecd.lifetime = _lifetime;
|
||||
_ecd.belongsPlayerId = _entityId;
|
||||
if (_clientEntityId != -1)
|
||||
_ecd.clientEntityId = _clientEntityId;
|
||||
EntityItem entity2 = (EntityItem)EntityFactory.CreateEntity(_ecd);
|
||||
|
||||
entity2.isPhysicsMaster = flag;
|
||||
if ((double)_initialMotion.sqrMagnitude > 0.0099999997764825821)
|
||||
entity2.AddVelocity(_initialMotion);
|
||||
__instance.m_World.SpawnEntityInWorld((Entity)entity2);
|
||||
Chunk chunkSync = (Chunk)__instance.m_World.GetChunkSync(World.toChunkXZ((int)_dropPos.x), World.toChunkXZ((int)_dropPos.z));
|
||||
if (chunkSync == null)
|
||||
return false;
|
||||
List<EntityItem> entityItemList = new List<EntityItem>();
|
||||
for (int index1 = 0; index1 < chunkSync.entityLists.Length; ++index1)
|
||||
{
|
||||
if (chunkSync.entityLists[index1] != null)
|
||||
{
|
||||
for (int index2 = 0; index2 < chunkSync.entityLists[index1].Count; ++index2)
|
||||
{
|
||||
if (chunkSync.entityLists[index1][index2] is EntityItem)
|
||||
entityItemList.Add(chunkSync.entityLists[index1][index2] as EntityItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
int num = entityItemList.Count - 50;
|
||||
if (num <= 0)
|
||||
return false;
|
||||
entityItemList.Sort((IComparer<EntityItem>)new GameManager.EntityItemLifetimeComparer());
|
||||
for (int index = entityItemList.Count - 1; index >= 0 && num > 0; --index)
|
||||
{
|
||||
entityItemList[index].MarkToUnload();
|
||||
--num;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("DestroyLootOnClose")]
|
||||
public class DestroyLootOnClosePatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, TileEntity _te, Vector3i _blockPos, int _lootEntityId)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-DestroyLootOnClose START, _te: " + _te);
|
||||
if (_te is TileEntitySecureLootContainer)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-DestroyLootOnClose IS SECURE LOOT");
|
||||
|
||||
TileEntitySecureLootContainer tileEntity = (TileEntitySecureLootContainer)_te;
|
||||
|
||||
//Log.Out("GameManagerPatches-DestroyLootOnClose tileEntity.bPlayerStorage: " + tileEntity.bPlayerStorage);
|
||||
|
||||
if (tileEntity.bPlayerStorage)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-DestroyLootOnClose PLAYER PLACED");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("Disconnect")]
|
||||
public class DisconnectPatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-Disconnect START");
|
||||
|
||||
if (!GameManager.IsDedicatedServer)
|
||||
{
|
||||
RebirthVariables.musicMode = -1;
|
||||
RebirthVariables.purgePrefabsLoaded = false;
|
||||
|
||||
float volume = Mathf.Clamp01(GamePrefs.GetFloat(EnumGamePrefs.OptionsMenuMusicVolumeLevel));
|
||||
|
||||
//Log.Out("GameManagerPatches-Disconnect volume: " + volume);
|
||||
|
||||
if (volume > 0f)
|
||||
{
|
||||
//Log.Out("GameManagerPatches-Disconnect RebirthVariables.musicMode: " + RebirthVariables.musicMode);
|
||||
RebirthVariables.audioSource.Stop();
|
||||
RebirthVariables.audioSource.volume = volume;
|
||||
RebirthVariables.musicMode = -1;
|
||||
/*Log.Out("GameManagerPatches-Disconnect MenuMusic.musicLeft.Count: " + MenuMusic.musicLeft.Count);
|
||||
|
||||
if (MenuMusic.musicLeft.Count > 0)
|
||||
{
|
||||
int num = UnityEngine.Random.Range(0, MenuMusic.musicLeft.Count - 1);
|
||||
|
||||
Log.Out("GameManagerPatches-Disconnect BEFORE RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
Log.Out("GameManagerPatches-Disconnect num: " + num);
|
||||
|
||||
RebirthVariables.songIndex = MenuMusic.musicLeft[num];
|
||||
|
||||
Log.Out("GameManagerPatches-Disconnect AFTER RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
|
||||
MenuMusic.musicLeft.Remove(RebirthVariables.songIndex);
|
||||
|
||||
if (RebirthVariables.audioClip[RebirthVariables.songIndex - 1] != null)
|
||||
{
|
||||
Log.Out("GameManagerPatches-Disconnect NEW CLIP");
|
||||
RebirthVariables.audioSource.clip = RebirthVariables.audioClip[RebirthVariables.songIndex - 1];
|
||||
}
|
||||
}
|
||||
|
||||
RebirthVariables.audioSource.loop = false;
|
||||
RebirthVariables.secondsToFadeIn = 1f;
|
||||
RebirthVariables.secondsToFadeOut = 10f;
|
||||
RebirthVariables.controlOption = MusicControlOption.FadeIn;
|
||||
RebirthVariables.audioSource.Play();*/
|
||||
}
|
||||
|
||||
EntityPlayerLocal ___entityPlayerLocal = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
GameManager.Instance.StartCoroutine(RebirthVariables.UpdateLocalVariables(___entityPlayerLocal, 1));
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
if (hire.playerID == ___entityPlayerLocal.entityId)
|
||||
{
|
||||
hire.playerSpawned = false;
|
||||
//Log.Out("GameManagerPatches-Disconnect hire.playerSpawned: " + hire.playerSpawned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("DropContentOfLootContainerServer")]
|
||||
[HarmonyPatch(new Type[] { typeof(BlockValue), typeof(Vector3i), typeof(int), typeof(ITileEntityLootable) })]
|
||||
public class DropContentOfLootContainerServerPatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, BlockValue _bvOld, Vector3i _worldPos, int _lootEntityId, ITileEntityLootable _teOld = null)
|
||||
{
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer START");
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Warning("DropContentOfLootContainerServer can not be called on clients! From:\n" + StackTraceUtility.ExtractStackTrace());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 1");
|
||||
string str = "DroppedLootContainer";
|
||||
FastTags<TagGroup.Global> none = FastTags<TagGroup.Global>.none;
|
||||
ITileEntityLootable tileEntityLootable;
|
||||
Vector3 vector3;
|
||||
if (_lootEntityId == -1)
|
||||
{
|
||||
tileEntityLootable = _teOld ?? __instance.m_World.GetTileEntity(_worldPos).GetSelfOrFeature<ITileEntityLootable>();
|
||||
if (tileEntityLootable == null || __instance.lockedTileEntities.ContainsKey((ITileEntity)tileEntityLootable))
|
||||
return false;
|
||||
vector3 = tileEntityLootable.ToWorldPos().ToVector3() + new Vector3(0.5f, 0.75f, 0.5f);
|
||||
if (_bvOld.Block.Properties.Values.ContainsKey("DroppedEntityClass"))
|
||||
{
|
||||
FastTags<TagGroup.Global> tags = _bvOld.Block.Tags;
|
||||
str = _bvOld.Block.Properties.Values["DroppedEntityClass"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 2");
|
||||
Entity entity1 = __instance.m_World.GetEntity(_lootEntityId);
|
||||
if (!(bool)entity1)
|
||||
return false;
|
||||
FastTags<TagGroup.Global> entityTags = entity1.EntityTags;
|
||||
vector3 = entity1.GetPosition();
|
||||
vector3.y += 0.9f;
|
||||
if ((double)entity1.lootDropProb != 0.0)
|
||||
{
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 3");
|
||||
int lootDropClass = EntityClass.list[entity1.entityClass].lootDropEntityClass;
|
||||
|
||||
if (entity1 is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX entityClone = (EntityZombieSDX)entity1;
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer entityClone.lootDropEntityClass: " + entityClone.lootDropEntityClass);
|
||||
if (entityClone.lootDropEntityClass != "")
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
else if (entity1 is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)entity1;
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer npc.lootDropEntityClass: " + npc.lootDropEntityClass);
|
||||
|
||||
if (npc.lootDropEntityClass != "")
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(npc.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("Gamemanagerpatches-DropContentOfLootContainerServer entity1: " + entity1.EntityClass.entityClassName);
|
||||
//Log.Out("Gamemanagerpatches-DropContentOfLootContainerServer lootDropClass: " + lootDropClass);
|
||||
EntityLootContainer entity2 = EntityFactory.CreateEntity(lootDropClass, vector3, Vector3.zero) as EntityLootContainer;
|
||||
__instance.m_World.SpawnEntityInWorld((Entity)entity2);
|
||||
entity2.transform.localScale = new Vector3(1.25f, 1.25f, 1.25f);
|
||||
Manager.BroadcastPlay(vector3, "zpack_spawn");
|
||||
return false;
|
||||
|
||||
}
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 4");
|
||||
tileEntityLootable = __instance.m_World.GetTileEntity(_lootEntityId).GetSelfOrFeature<ITileEntityLootable>();
|
||||
if (tileEntityLootable == null)
|
||||
return false;
|
||||
}
|
||||
if (!tileEntityLootable.bTouched)
|
||||
__instance.lootManager.LootContainerOpened(tileEntityLootable, -1, _bvOld.Block.Tags);
|
||||
if (!tileEntityLootable.IsEmpty())
|
||||
{
|
||||
Entity entity1 = __instance.m_World.GetEntity(_lootEntityId);
|
||||
if (!(bool)entity1)
|
||||
return false;
|
||||
|
||||
if (entity1 is EntityNPCRebirth)
|
||||
{
|
||||
str = "BackpackNPC";
|
||||
}
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 5, str: " + str);
|
||||
|
||||
EntityLootContainer entity = EntityFactory.CreateEntity(str.GetHashCode(), vector3, Vector3.zero) as EntityLootContainer;
|
||||
if (entity != null)
|
||||
{
|
||||
//Log.Warning("GameManagerPatches-DropContentOfLootContainerServer 5, str: " + str);
|
||||
entity.SetContent(ItemStack.Clone((IList<ItemStack>)tileEntityLootable.items));
|
||||
}
|
||||
__instance.m_World.SpawnEntityInWorld((Entity)entity);
|
||||
}
|
||||
tileEntityLootable.SetEmpty();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
/*
|
||||
|
||||
todo fix Needs updating to 1.0 code
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageLootContainerDropContent>().Setup(_worldPos, _entityId), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
string text = "DroppedLootContainer";
|
||||
FastTags<TagGroup.Global> none = FastTags<TagGroup.Global>.none;
|
||||
TileEntityLootContainer tileEntityLootContainer;
|
||||
Vector3 vector;
|
||||
|
||||
if (_entityId == -1)
|
||||
{
|
||||
tileEntityLootContainer = (TileEntityLootContainer)__instance.m_World.GetTileEntity(0, _worldPos);
|
||||
if (tileEntityLootContainer == null || __instance.lockedTileEntities.ContainsKey(tileEntityLootContainer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vector = tileEntityLootContainer.ToWorldPos().ToVector3() + new Vector3(0.5f, 0.75f, 0.5f);
|
||||
|
||||
if (_bvOld.Block.Properties.Values.ContainsKey("DroppedEntityClass"))
|
||||
{
|
||||
FastTags<TagGroup.Global> tags = _bvOld.Block.Tags;
|
||||
text = _bvOld.Block.Properties.Values["DroppedEntityClass"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Entity entity = __instance.m_World.GetEntity(_entityId);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FastTags<TagGroup.Global> entityTags = entity.EntityTags;
|
||||
vector = entity.GetPosition();
|
||||
vector.y += 0.9f;
|
||||
|
||||
if (entity.lootDropProb != 0f)
|
||||
{
|
||||
int lootDropClass = EntityClass.list[entity.entityClass].lootDropEntityClass;
|
||||
//Log.Out("GameManagerPatches-DropContentOfLootContainerServer BEFORE lootDropClass: " + lootDropClass);
|
||||
|
||||
if (entity is EntityZombieSDX)
|
||||
{
|
||||
EntityZombieSDX entityClone = (EntityZombieSDX)entity;
|
||||
if (entityClone.lootDropEntityClass.Trim().Length > 0)
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
else if (entity is EntityMeleeBanditSDX)
|
||||
{
|
||||
EntityMeleeBanditSDX entityClone = (EntityMeleeBanditSDX)entity;
|
||||
|
||||
if (entityClone.lootDropEntityClass.Trim().Length > 0)
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
else if (entity is EntityMeleeCyborgRebirth)
|
||||
{
|
||||
EntityMeleeCyborgRebirth entityClone = (EntityMeleeCyborgRebirth)entity;
|
||||
|
||||
if (entityClone.lootDropEntityClass.Trim().Length > 0)
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
else if (entity is EntityMeleeRangedBanditSDX)
|
||||
{
|
||||
EntityMeleeRangedBanditSDX entityClone = (EntityMeleeRangedBanditSDX)entity;
|
||||
|
||||
if (entityClone.lootDropEntityClass.Trim().Length > 0)
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
else if (entity is EntityMeleeWerewolfSDX)
|
||||
{
|
||||
EntityMeleeWerewolfSDX entityClone = (EntityMeleeWerewolfSDX)entity;
|
||||
|
||||
if (entityClone.lootDropEntityClass.Trim().Length > 0)
|
||||
{
|
||||
lootDropClass = EntityClass.FromString(entityClone.lootDropEntityClass);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("GameManagerPatches-DropContentOfLootContainerServer AFTER lootDropClass: " + lootDropClass);
|
||||
|
||||
EntityLootContainer entityLootContainer = EntityFactory.CreateEntity(lootDropClass, vector, Vector3.zero) as EntityLootContainer;
|
||||
__instance.m_World.SpawnEntityInWorld(entityLootContainer);
|
||||
entityLootContainer.transform.localScale = new Vector3(1.25f, 1.25f, 1.25f);
|
||||
Manager.BroadcastPlay(vector, "zpack_spawn", 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
tileEntityLootContainer = (TileEntityLootContainer)__instance.m_World.GetTileEntity(_entityId);
|
||||
|
||||
if (tileEntityLootContainer == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tileEntityLootContainer.bTouched)
|
||||
{
|
||||
__instance.lootManager.LootContainerOpened(tileEntityLootContainer, -1, _bvOld.Block.Tags);
|
||||
}
|
||||
|
||||
bool flag = true;
|
||||
int num = 0;
|
||||
|
||||
while (flag && num < tileEntityLootContainer.items.Length)
|
||||
{
|
||||
flag &= tileEntityLootContainer.items[num].IsEmpty();
|
||||
num++;
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
EntityLootContainer entityLootContainer2 = EntityFactory.CreateEntity(text.GetHashCode(), vector, Vector3.zero) as EntityLootContainer;
|
||||
|
||||
if (entityLootContainer2 != null)
|
||||
{
|
||||
entityLootContainer2.SetContent(ItemStack.Clone(tileEntityLootContainer.items));
|
||||
}
|
||||
|
||||
__instance.m_World.SpawnEntityInWorld(entityLootContainer2);
|
||||
}
|
||||
|
||||
tileEntityLootContainer.SetEmpty();
|
||||
|
||||
return false;*/
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("gmUpdate")]
|
||||
public class gmUpdatePatch
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, ref float ___gcCountdownTimer)
|
||||
{
|
||||
___gcCountdownTimer = 120f;
|
||||
|
||||
if (GameManager.IsDedicatedServer)
|
||||
{
|
||||
Application.targetFrameRate = 20;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(GameManager __instance, ref float ___unloadAssetsDuration, ref bool ___isUnloadAssetsReady)
|
||||
{
|
||||
___unloadAssetsDuration = 0f;
|
||||
___isUnloadAssetsReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("isAnyModalWindowOpen")]
|
||||
public class isAnyModalWindowOpen
|
||||
{
|
||||
private static bool Prefix(ref bool __result)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameManager))]
|
||||
[HarmonyPatch("lootContainerOpened")]
|
||||
public class lootContainerOpened
|
||||
{
|
||||
private static bool Prefix(GameManager __instance, TileEntityLootContainer _te, LocalPlayerUI _playerUI, int _entityIdThatOpenedIt)
|
||||
{
|
||||
ITileEntityLootable selfOrFeature = _te.GetSelfOrFeature<ITileEntityLootable>();
|
||||
if (selfOrFeature == null)
|
||||
{
|
||||
Log.Error(string.Format("Can not open container UI for TE {0}", (object)_te));
|
||||
}
|
||||
else
|
||||
{
|
||||
FastTags<TagGroup.Global> _containerTags = FastTags<TagGroup.Global>.none;
|
||||
if (_playerUI != null)
|
||||
{
|
||||
bool flag = true;
|
||||
string _lootContainerName = string.Empty;
|
||||
if (selfOrFeature.EntityId != -1)
|
||||
{
|
||||
Entity entity = __instance.m_World.GetEntity(selfOrFeature.EntityId);
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity.spawnById > 0 && entity.spawnById != _playerUI.entityPlayer.entityId && TwitchManager.Current.StealingCrateEvent != "")
|
||||
GameEventManager.Current.HandleAction(TwitchManager.Current.StealingCrateEvent, (EntityPlayer)_playerUI.entityPlayer, (Entity)_playerUI.entityPlayer, false);
|
||||
_containerTags = entity.EntityTags;
|
||||
_lootContainerName = Localization.Get(EntityClass.list[entity.entityClass].entityClassName);
|
||||
|
||||
if (entity.EntityClass.entityClassName == "BackpackNPC")
|
||||
{
|
||||
_te.lootListName = EntityClass.list[entity.entityClass].Properties.GetString(EntityClass.PropLootListOnDeath);
|
||||
}
|
||||
|
||||
if (entity is EntityVehicle)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue block = __instance.m_World.GetBlock(selfOrFeature.ToWorldPos());
|
||||
_containerTags = block.Block.Tags;
|
||||
_lootContainerName = block.Block.GetLocalizedBlockName();
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
((XUiC_LootWindowGroup)((XUiWindowGroup)_playerUI.windowManager.GetWindow("looting")).Controller).SetTileEntityChest(_lootContainerName, selfOrFeature);
|
||||
_playerUI.windowManager.Open("looting", true);
|
||||
}
|
||||
LootContainer lootContainer = LootContainer.GetLootContainer(selfOrFeature.lootListName);
|
||||
if (lootContainer != null && _playerUI.entityPlayer != null)
|
||||
lootContainer.ExecuteBuffActions(selfOrFeature.EntityId, (EntityAlive)_playerUI.entityPlayer);
|
||||
}
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
return false;
|
||||
__instance.lootManager.LootContainerOpened(selfOrFeature, _entityIdThatOpenedIt, _containerTags);
|
||||
selfOrFeature.bTouched = true;
|
||||
selfOrFeature.SetModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Harmony.GamePrefsPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GamePrefs))]
|
||||
[HarmonyPatch("SetObjectInternal")]
|
||||
public class SetObjectInternalPatch
|
||||
{
|
||||
public static bool Prefix(GamePrefs __instance, EnumGamePrefs _eProperty, object _value,
|
||||
object[] ___propertyValues
|
||||
)
|
||||
{
|
||||
int num = (int)_eProperty;
|
||||
|
||||
if (num >= ___propertyValues.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
namespace Harmony.GameStateManagerPatches
|
||||
{
|
||||
internal class GameStateManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GameStateManager))]
|
||||
[HarmonyPatch("StartGame")]
|
||||
public class StartGamePatch
|
||||
{
|
||||
public static void Postfix()
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame POST START");
|
||||
|
||||
bool optionFireManager = CustomGameOptions.GetBool("CustomFireManager");
|
||||
|
||||
if (GamePrefs.GetString(EnumGamePrefs.GameWorld) == "Empty"
|
||||
|| GamePrefs.GetString(EnumGamePrefs.GameWorld) == "Playtesting"
|
||||
|| GamePrefs.GetString(EnumGamePrefs.GameMode) == "GameModeEditWorld"
|
||||
|| !optionFireManager)
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 1A");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 1B");
|
||||
FireManager.Init();
|
||||
}
|
||||
|
||||
Broadcastmanager.Init();
|
||||
//GamestageManagerRebirth.Init();
|
||||
|
||||
RebirthManager.Init();
|
||||
|
||||
EntityPlayerLocal localPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 2");
|
||||
if (!GameManager.Instance.isEditMode)
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.BuildGamestageSpawnGroups());
|
||||
//HiresManagerRebirth.Init();
|
||||
//OutbreakManagerRebirth.Init();
|
||||
//OutbreakManagerRebirth.Init();
|
||||
//ScenarioManagerRebirth.Init();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 3");
|
||||
if (localPlayer != null)
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 4");
|
||||
//Log.Out("GameStateManagerPatches-StartGame ASKING FOR HIRES");
|
||||
//ModEvents.GameUpdate.RegisterHandler(RebirthManager.Update);
|
||||
RebirthManager.playerHires.Clear();
|
||||
RebirthManager.observers.Clear();
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageGetHiresRebirth>().Setup(localPlayer.entityId), false);
|
||||
RebirthUtilities.HasSelectedClass(localPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("GameStateManagerPatches-StartGame 5");
|
||||
//Log.Out("GameStateManagerPatches-StartGame COULD NOT FIND LOCAL PLAYER");
|
||||
}
|
||||
}
|
||||
|
||||
if (localPlayer != null)
|
||||
{
|
||||
RebirthUtilities.HasSelectedClass(localPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Harmony.GameUtilsPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GameUtils))]
|
||||
[HarmonyPatch("collectHarvestedItem")]
|
||||
public class collectHarvestedItem
|
||||
{
|
||||
private static bool Prefix(GameUtils __instance, ItemActionData _actionData, ItemValue _iv, int _count, float _prob, bool _bScaleCountOnDamage,
|
||||
ref GameRandom ___random
|
||||
)
|
||||
{
|
||||
//Log.Out("GameUtilsHarmony-collectHarvestedItem itemName: " + _iv.ItemClass.GetItemName());
|
||||
bool downgradeBlock = RebirthVariables.customReplantTrees;
|
||||
|
||||
if (downgradeBlock && _iv.ItemClass.GetItemName().Contains("treePlanted"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (___random == null)
|
||||
{
|
||||
___random = GameRandomManager.Instance.CreateGameRandom();
|
||||
___random.SetSeed((int)Stopwatch.GetTimestamp());
|
||||
}
|
||||
if (_bScaleCountOnDamage)
|
||||
{
|
||||
float num = (float)_actionData.attackDetails.damageMax / (float)_count;
|
||||
int num2 = (int)((Utils.FastMin(_actionData.attackDetails.damageTotalOfTarget, (float)_actionData.attackDetails.damageMax) - (float)_actionData.attackDetails.damageGiven) / num + 0.5f);
|
||||
int num3 = Mathf.Min((int)(_actionData.attackDetails.damageTotalOfTarget / num + 0.5f), _count);
|
||||
int b = _count;
|
||||
_count = num3 - num2;
|
||||
if (_actionData.attackDetails.damageTotalOfTarget > (float)_actionData.attackDetails.damageMax)
|
||||
{
|
||||
_count = Mathf.Min(_count, b);
|
||||
}
|
||||
}
|
||||
if (___random.RandomFloat <= _prob && _count > 0)
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(_iv, _count);
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_actionData.invData.holdingEntity as EntityPlayerLocal);
|
||||
|
||||
EntityPlayerLocal player = (EntityPlayerLocal)_actionData.invData.holdingEntity;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
int randomInt = RebirthUtilities.GetQualityFromLootstage(player);
|
||||
itemStack.itemValue.Quality = (ushort)randomInt;
|
||||
}
|
||||
|
||||
if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack))
|
||||
{
|
||||
GameManager.Instance.ItemDropServer(new ItemStack(_iv, itemStack.count), GameManager.Instance.World.GetPrimaryPlayer().GetDropPosition(), new Vector3(0.5f, 0.5f, 0.5f), GameManager.Instance.World.GetPrimaryPlayerId(), 60f, false);
|
||||
}
|
||||
uiforPlayer.entityPlayer.Progression.AddLevelExp((int)(itemStack.itemValue.ItemClass.MadeOfMaterial.Experience * (float)_count), "_xpFromHarvesting", global::Progression.XPTypes.Harvesting, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Harmony.InventoryRebirth
|
||||
{
|
||||
internal class InventoryPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Inventory))]
|
||||
[HarmonyPatch("PUBLIC_SLOTS")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class PUBLIC_SLOTSPatch
|
||||
{
|
||||
public static void Postfix(Inventory __instance, ref int __result
|
||||
)
|
||||
{
|
||||
__result = 20;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Inventory))]
|
||||
[HarmonyPatch("updateHoldingItem")]
|
||||
public class updateHoldingItem
|
||||
{
|
||||
public static bool Prefix(Inventory __instance,
|
||||
global::EntityAlive ___entity
|
||||
)
|
||||
{
|
||||
//Log.Out("InventoryPatches-updateHoldingItem START");
|
||||
|
||||
if (___entity is EntityPlayer)
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null && primaryPlayer.entityId == ___entity.entityId)
|
||||
{
|
||||
//Log.Out("InventoryPatches-updateHoldingItem ___entity: " + ___entity.EntityName);
|
||||
RebirthUtilities.checkCraftingProgression(__instance, ___entity);
|
||||
RebirthVariables.isCraftableItem = RebirthUtilities.IsCraftableItem();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.EntityPlayerPatches
|
||||
{
|
||||
internal class ItemActionAttackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemActionAttack), "Hit")]
|
||||
public class HitPatchEx
|
||||
{
|
||||
// 22 args, wow
|
||||
public static bool Prefix(
|
||||
WorldRayHitInfo hitInfo,
|
||||
int _attackerEntityId,
|
||||
EnumDamageTypes _damageType,
|
||||
float _blockDamage,
|
||||
float _entityDamage,
|
||||
float _staminaDamageMultiplier,
|
||||
float _weaponCondition,
|
||||
float _criticalHitChanceOLD,
|
||||
float _dismemberChance,
|
||||
string _attackingDeviceMadeOf,
|
||||
DamageMultiplier _damageMultiplier,
|
||||
List<string> _buffActions,
|
||||
ItemActionAttack.AttackHitInfo _attackDetails,
|
||||
int _flags = 1,
|
||||
int _actionExp = 0,
|
||||
float _actionExpBonus = 0f,
|
||||
ItemActionAttack rangeCheckedAction = null,
|
||||
Dictionary<string, ItemActionAttack.Bonuses> _toolBonuses = null,
|
||||
ItemActionAttack.EnumAttackMode _attackMode = ItemActionAttack.EnumAttackMode.RealNoHarvesting,
|
||||
Dictionary<string, string> _hitSoundOverrides = null,
|
||||
int ownedEntityId = -1,
|
||||
ItemValue damagingItemValue = null)
|
||||
{
|
||||
// our hook will simply call our replacement method
|
||||
//Log.Out($"HitPatchEx - Attacker id: {_attackerEntityId}, dmg type: {_damageType}, blk dmg: {_blockDamage}, ent dmg: {_entityDamage}");
|
||||
|
||||
ItemActionAttackRebirth.Hit(
|
||||
hitInfo,
|
||||
_attackerEntityId,
|
||||
_damageType,
|
||||
_blockDamage,
|
||||
_entityDamage,
|
||||
_staminaDamageMultiplier,
|
||||
_weaponCondition,
|
||||
_criticalHitChanceOLD,
|
||||
_dismemberChance,
|
||||
_attackingDeviceMadeOf,
|
||||
_damageMultiplier,
|
||||
_buffActions,
|
||||
_attackDetails,
|
||||
_flags,
|
||||
_actionExp,
|
||||
_actionExpBonus,
|
||||
rangeCheckedAction,
|
||||
_toolBonuses,
|
||||
_attackMode,
|
||||
_hitSoundOverrides,
|
||||
ownedEntityId,
|
||||
damagingItemValue);
|
||||
|
||||
return false; // don't process the original method
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
using Audio;
|
||||
|
||||
public class Harmony_ItemActionConnectPower_Init
|
||||
{
|
||||
public Harmony_ItemActionConnectPower_Init()
|
||||
{
|
||||
}
|
||||
|
||||
[HarmonyPatch("OnHoldingUpdate")]
|
||||
[HarmonyPatch(typeof(ItemActionConnectPower))]
|
||||
public class OnHoldingUpdatePatch
|
||||
{
|
||||
public static MethodInfo HandleItemBreak = AccessTools.Method(typeof(ItemActionConnectPower), "HandleItemBreak", new Type[] { typeof(ItemActionData) });
|
||||
public static MethodInfo GetPoweredBlockVector3i = AccessTools.Method(typeof(ItemActionConnectPower), "GetPoweredBlock", new Type[] { typeof(Vector3i) });
|
||||
public static MethodInfo GetPoweredBlock = AccessTools.Method(typeof(ItemActionConnectPower), "GetPoweredBlock", new Type[] { typeof(ItemInventoryData) });
|
||||
public static MethodInfo GetHandTransform = AccessTools.Method(typeof(ItemActionConnectPower), "GetHandTransform", new Type[] { typeof(EntityAlive) });
|
||||
public static MethodInfo DecreaseDurability = AccessTools.Method(typeof(ItemActionConnectPower), "DecreaseDurability", new Type[] { typeof(ItemActionConnectPower.ConnectPowerData) });
|
||||
|
||||
private static bool Prefix(ItemActionConnectPower __instance, ItemActionData _actionData,
|
||||
Vector3 ___wireOffset
|
||||
)
|
||||
{
|
||||
ItemActionConnectPower.ConnectPowerData connectPowerData = (ItemActionConnectPower.ConnectPowerData)_actionData;
|
||||
Vector3i blockPos = _actionData.invData.hitInfo.hit.blockPos;
|
||||
bool flag = true;
|
||||
if (connectPowerData.invData.holdingEntity is EntityPlayerLocal && connectPowerData.playerUI == null)
|
||||
{
|
||||
connectPowerData.playerUI = LocalPlayerUI.GetUIForPlayer(connectPowerData.invData.holdingEntity as EntityPlayerLocal);
|
||||
}
|
||||
if (connectPowerData.playerUI != null && !connectPowerData.invData.world.CanPlaceBlockAt(blockPos, connectPowerData.invData.world.gameManager.GetPersistentLocalPlayer(), false))
|
||||
{
|
||||
connectPowerData.isFriendly = false;
|
||||
connectPowerData.playerUI.nguiWindowManager.SetLabelText(EnumNGUIWindow.PowerInfo, null);
|
||||
return false;
|
||||
}
|
||||
connectPowerData.isFriendly = true;
|
||||
if (_actionData.invData.hitInfo.bHitValid)
|
||||
{
|
||||
int num = (int)(Constants.cDigAndBuildDistance * Constants.cDigAndBuildDistance);
|
||||
if (_actionData.invData.hitInfo.hit.distanceSq <= (float)num)
|
||||
{
|
||||
BlockValue block = _actionData.invData.world.GetBlock(blockPos);
|
||||
BlockPowered blockPowered = block.Block as BlockPowered;
|
||||
if (blockPowered != null)
|
||||
{
|
||||
if (connectPowerData.playerUI != null)
|
||||
{
|
||||
int num2 = blockPowered.RequiredPower;
|
||||
Color col = Color.grey;
|
||||
|
||||
if (blockPowered.isMultiBlock && block.ischild)
|
||||
{
|
||||
connectPowerData.playerUI.nguiWindowManager.SetLabelText(EnumNGUIWindow.PowerInfo, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3i vector3i = blockPos;
|
||||
ChunkCluster chunkCluster = _actionData.invData.world.ChunkClusters[_actionData.invData.hitInfo.hit.clrIdx];
|
||||
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
Chunk chunk = (Chunk)chunkCluster.GetChunkSync(World.toChunkXZ(vector3i.x), vector3i.y, World.toChunkXZ(vector3i.z));
|
||||
if (chunk != null)
|
||||
{
|
||||
TileEntityPowered tileEntityPowered = chunk.GetTileEntity(World.toBlock(vector3i)) as TileEntityPowered;
|
||||
if (tileEntityPowered != null)
|
||||
{
|
||||
col = (tileEntityPowered.IsPowered ? Color.yellow : Color.grey);
|
||||
num2 = tileEntityPowered.PowerUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
col = Color.grey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connectPowerData.playerUI.nguiWindowManager.SetLabel(EnumNGUIWindow.PowerInfo, string.Format("{0}W", num2), col);
|
||||
}
|
||||
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag && connectPowerData.playerUI != null)
|
||||
{
|
||||
connectPowerData.playerUI.nguiWindowManager.SetLabelText(EnumNGUIWindow.PowerInfo, null);
|
||||
}
|
||||
|
||||
if (connectPowerData.HasStartPoint)
|
||||
{
|
||||
if (connectPowerData.wireNode == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float num3 = Vector3.Distance(connectPowerData.startPoint.ToVector3(), _actionData.invData.holdingEntity.position);
|
||||
|
||||
if (num3 < 20f)
|
||||
{
|
||||
connectPowerData.inRange = true;
|
||||
connectPowerData.wireNode.wireColor = new Color(0f, 0f, 0f, 0f);
|
||||
}
|
||||
|
||||
if (num3 > 20f)
|
||||
{
|
||||
connectPowerData.inRange = false;
|
||||
connectPowerData.wireNode.wireColor = Color.red;
|
||||
}
|
||||
|
||||
if (num3 > 25f)
|
||||
{
|
||||
connectPowerData.HasStartPoint = false;
|
||||
|
||||
if (connectPowerData.wireNode != null)
|
||||
{
|
||||
WireManager.Instance.RemoveActiveWire(connectPowerData.wireNode);
|
||||
UnityEngine.Object.Destroy(connectPowerData.wireNode.gameObject);
|
||||
connectPowerData.wireNode = null;
|
||||
}
|
||||
|
||||
Chunk chunk2 = connectPowerData.invData.world.GetChunkFromWorldPos(connectPowerData.startPoint) as Chunk;
|
||||
|
||||
if (chunk2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (connectPowerData.invData.world.GetTileEntity(chunk2.ClrIdx, connectPowerData.startPoint) is TileEntityPowered)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.RemoveWire, Vector3i.zero, _actionData.invData.holdingEntity.entityId), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.RemoveWire, Vector3i.zero, _actionData.invData.holdingEntity.entityId), false);
|
||||
}
|
||||
}
|
||||
|
||||
_actionData.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
connectPowerData.invData.holdingEntity.PlayOneShot("ui_denied", false);
|
||||
}
|
||||
}
|
||||
if (!connectPowerData.StartLink || Time.time - connectPowerData.lastUseTime < AnimationDelayData.AnimationDelay[connectPowerData.invData.item.HoldType.Value].RayCast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
connectPowerData.StartLink = false;
|
||||
ItemActionConnectPower.ConnectPowerData connectPowerData2 = (ItemActionConnectPower.ConnectPowerData)_actionData;
|
||||
ItemInventoryData invData = _actionData.invData;
|
||||
Vector3i lastBlockPos = invData.hitInfo.lastBlockPos;
|
||||
if (!invData.hitInfo.bHitValid || invData.hitInfo.tag.StartsWith("E_"))
|
||||
{
|
||||
connectPowerData2.HasStartPoint = false;
|
||||
return false;
|
||||
}
|
||||
if (connectPowerData.invData.itemValue.MaxUseTimes > 0 && connectPowerData.invData.itemValue.UseTimes >= (float)connectPowerData.invData.itemValue.MaxUseTimes)
|
||||
{
|
||||
EntityPlayerLocal player = _actionData.invData.holdingEntity as EntityPlayerLocal;
|
||||
if (__instance.item.Properties.Values.ContainsKey(ItemClass.PropSoundJammed))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead(__instance.item.Properties.Values[ItemClass.PropSoundJammed], -1, 0f, false);
|
||||
}
|
||||
GameManager.ShowTooltip(player, "ttItemNeedsRepair");
|
||||
return false;
|
||||
}
|
||||
if (connectPowerData.invData.itemValue.MaxUseTimes > 0)
|
||||
{
|
||||
_actionData.invData.itemValue.UseTimes += EffectManager.GetValue(PassiveEffects.DegradationPerUse, _actionData.invData.itemValue, 1f, invData.holdingEntity, null, (_actionData.invData.itemValue.ItemClass != null) ? _actionData.invData.itemValue.ItemClass.ItemTags : FastTags<TagGroup.Global>.none, true, true, true, true, true, 1);
|
||||
HandleItemBreak.Invoke(__instance, new object[] { _actionData });
|
||||
|
||||
}
|
||||
if (connectPowerData2.HasStartPoint)
|
||||
{
|
||||
if (connectPowerData2.startPoint == invData.hitInfo.hit.blockPos || !connectPowerData2.inRange)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Vector3.Distance(connectPowerData.startPoint.ToVector3(), invData.hitInfo.hit.blockPos.ToVector3()) > 25f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TileEntityPowered poweredBlock = (TileEntityPowered)GetPoweredBlock.Invoke(__instance, new object[] { invData });
|
||||
if (poweredBlock != null)
|
||||
{
|
||||
TileEntityPowered poweredBlock2 = (TileEntityPowered)GetPoweredBlockVector3i.Invoke(__instance, new object[] { connectPowerData2.startPoint });
|
||||
|
||||
if (poweredBlock2 != null)
|
||||
{
|
||||
if (!poweredBlock.CanHaveParent(poweredBlock2))
|
||||
{
|
||||
GameManager.ShowTooltip(_actionData.invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttCantHaveParent"));
|
||||
invData.holdingEntity.PlayOneShot("ui_denied", false);
|
||||
return false;
|
||||
}
|
||||
if (poweredBlock2.ChildCount > 8)
|
||||
{
|
||||
GameManager.ShowTooltip(_actionData.invData.holdingEntity as EntityPlayerLocal, Localization.Get("ttWireLimit"));
|
||||
invData.holdingEntity.PlayOneShot("ui_denied", false);
|
||||
return false;
|
||||
}
|
||||
poweredBlock.SetParentWithWireTool(poweredBlock2, invData.holdingEntity.entityId);
|
||||
_actionData.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
connectPowerData2.HasStartPoint = false;
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.RemoveWire, Vector3i.zero, _actionData.invData.holdingEntity.entityId), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.RemoveWire, Vector3i.zero, _actionData.invData.holdingEntity.entityId), false);
|
||||
}
|
||||
EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
||||
string name = "wire_tool_" + (poweredBlock2.IsPowered ? "sparks" : "dust");
|
||||
Transform handTransform = (Transform)GetHandTransform.Invoke(__instance, new object[] { holdingEntity });
|
||||
|
||||
GameManager.Instance.SpawnParticleEffectServer(new ParticleEffect(name, handTransform.position + Origin.position, handTransform.rotation, holdingEntity.GetLightBrightness(), Color.white), invData.holdingEntity.entityId);
|
||||
if (connectPowerData.wireNode != null)
|
||||
{
|
||||
WireManager.Instance.RemoveActiveWire(connectPowerData.wireNode);
|
||||
UnityEngine.Object.Destroy(connectPowerData.wireNode.gameObject);
|
||||
connectPowerData.wireNode = null;
|
||||
}
|
||||
DecreaseDurability.Invoke(__instance, new object[] { connectPowerData });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityPowered poweredBlock3 = (TileEntityPowered)GetPoweredBlock.Invoke(__instance, new object[] { invData }); ;
|
||||
|
||||
if (poweredBlock3 != null)
|
||||
{
|
||||
_actionData.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
connectPowerData2.startPoint = invData.hitInfo.hit.blockPos;
|
||||
connectPowerData2.HasStartPoint = true;
|
||||
EntityAlive holdingEntity2 = _actionData.invData.holdingEntity;
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.AddWire, connectPowerData2.startPoint, holdingEntity2.entityId), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageWireToolActions>().Setup(NetPackageWireToolActions.WireActions.AddWire, connectPowerData2.startPoint, holdingEntity2.entityId), false);
|
||||
}
|
||||
Manager.BroadcastPlay(poweredBlock3.ToWorldPos().ToVector3(), poweredBlock3.IsPowered ? "wire_live_connect" : "wire_dead_connect", 0f);
|
||||
Transform handTransform2 = (Transform)GetHandTransform.Invoke(__instance, new object[] { holdingEntity2 });
|
||||
|
||||
if (handTransform2 != null)
|
||||
{
|
||||
Transform transform = handTransform2.FindInChilds("wire_mesh", false);
|
||||
if (transform == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (connectPowerData2.wireNode != null)
|
||||
{
|
||||
WireManager.Instance.RemoveActiveWire(connectPowerData.wireNode);
|
||||
UnityEngine.Object.Destroy(connectPowerData2.wireNode.gameObject);
|
||||
connectPowerData2.wireNode = null;
|
||||
}
|
||||
WireNode component = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/WireNode"))).GetComponent<WireNode>();
|
||||
component.LocalPosition = invData.hitInfo.hit.blockPos.ToVector3() - Origin.position;
|
||||
component.localOffset = poweredBlock3.GetWireOffset();
|
||||
WireNode wireNode = component;
|
||||
wireNode.localOffset.x = wireNode.localOffset.x + 0.5f;
|
||||
WireNode wireNode2 = component;
|
||||
wireNode2.localOffset.y = wireNode2.localOffset.y + 0.5f;
|
||||
WireNode wireNode3 = component;
|
||||
wireNode3.localOffset.z = wireNode3.localOffset.z + 0.5f;
|
||||
component.Source = transform.gameObject;
|
||||
component.sourceOffset = ___wireOffset;
|
||||
component.TogglePulse(false);
|
||||
component.SetPulseSpeed(360f);
|
||||
connectPowerData2.wireNode = component;
|
||||
WireManager.Instance.AddActiveWire(component);
|
||||
string name2 = "wire_tool_" + (poweredBlock3.IsPowered ? "sparks" : "dust");
|
||||
GameManager.Instance.SpawnParticleEffectServer(new ParticleEffect(name2, handTransform2.position + Origin.position, handTransform2.rotation, holdingEntity2.GetLightBrightness(), Color.white), invData.holdingEntity.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.ItemActionEntryUsePatches
|
||||
{
|
||||
internal class ItemActionEntryUsePatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(ItemActionEntryUse))]
|
||||
[HarmonyPatch("OnActivated")]
|
||||
public class OnActivatedPatch
|
||||
{
|
||||
public static bool Prefix(ItemActionEntryUse __instance,
|
||||
ItemActionEntryUse.ConsumeType ___consumeType,
|
||||
int ___oldToolbeltFocusID
|
||||
)
|
||||
{
|
||||
//Log.Out("ItemActionEntryUsePatches-OnActivated START");
|
||||
|
||||
if (__instance.ItemController.xui.isUsingItemActionEntryUse)
|
||||
return false;
|
||||
XUiC_ItemStack stackControl = (XUiC_ItemStack)__instance.ItemController;
|
||||
|
||||
if (!stackControl.ItemStack.itemValue.ItemClass.CanExecuteAction(0, (global::EntityAlive)__instance.ItemController.xui.playerUI.entityPlayer, stackControl.ItemStack.itemValue) || !stackControl.ItemStack.itemValue.ItemClass.CanExecuteAction(1, (global::EntityAlive)__instance.ItemController.xui.playerUI.entityPlayer, stackControl.ItemStack.itemValue))
|
||||
{
|
||||
string strRequirement = "";
|
||||
EntityAlive player = __instance.ItemController.xui.playerUI.entityPlayer;
|
||||
|
||||
//Log.Out("ItemActionEntryUsePatches-OnActivated entityPlayer.name: " + player.name);
|
||||
//Log.Out("ItemActionEntryUsePatches-OnActivated Item: " + stackControl.ItemStack.itemValue.ItemClass.Name);
|
||||
|
||||
//Log.Out("ItemActionEntryUsePatches-OnActivated CanExecuteAction: " + stackControl.ItemStack.itemValue.ItemClass.CanExecuteAction(1, (global::EntityAlive)__instance.ItemController.xui.playerUI.entityPlayer, stackControl.ItemStack.itemValue));
|
||||
|
||||
bool flag2 = true;
|
||||
|
||||
player.MinEventContext.ItemValue = stackControl.ItemStack.itemValue;
|
||||
if (stackControl.ItemStack.itemValue.ItemClass.Actions[0].ExecutionRequirements != null)
|
||||
{
|
||||
List<IRequirement> executionRequirements2 = stackControl.ItemStack.itemValue.ItemClass.Actions[0].ExecutionRequirements;
|
||||
for (int j = 0; j < executionRequirements2.Count; j++)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
executionRequirements2[j].GetInfoStrings(ref list);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
strRequirement = list[0];
|
||||
//Log.Out("ItemActionEntryUsePatches-OnActivated strRequirement: " + strRequirement);
|
||||
}
|
||||
|
||||
bool isValid = executionRequirements2[j].IsValid(player.MinEventContext);
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
flag2 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
RebirthUtilities.DisplayRequirementCaption(__instance.ItemController.xui.playerUI.entityPlayer, strRequirement);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using static ItemActionMelee;
|
||||
|
||||
namespace Harmony.ItemActionMeleePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemActionMelee))]
|
||||
[HarmonyPatch("hitTheTarget")]
|
||||
public class hitTheTargetPatch
|
||||
{
|
||||
public static bool Prefix(ItemActionMelee __instance, ItemActionMelee.InventoryDataMelee _actionData, WorldRayHitInfo hitInfo, float damageScale)
|
||||
{
|
||||
EntityAlive entityAlive = ItemActionAttack.GetEntityFromHit(hitInfo) as EntityAlive;
|
||||
|
||||
if (entityAlive is EntityPlayer)
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget EntityName: " + entityAlive.EntityName);
|
||||
|
||||
ProgressionValue progressionValue = entityAlive.Progression.GetProgressionValue("perkDodge");
|
||||
|
||||
bool hitTarget = true;
|
||||
|
||||
if (progressionValue != null)
|
||||
{
|
||||
float chance = progressionValue.level * 5f;
|
||||
int random = GameManager.Instance.World.GetGameRandom().RandomRange(0, 101);
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget progressionValue.level: " + progressionValue.level);
|
||||
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget chance: " + chance);
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget random: " + random);
|
||||
|
||||
if (random < chance)
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-hitTheTarget EXIT");
|
||||
hitTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ItemActionMelee))]
|
||||
[HarmonyPatch("OnHoldingUpdate")]
|
||||
public class OnHoldingUpdatePatch
|
||||
{
|
||||
public static bool Prefix(ItemActionMelee __instance, ItemActionData _actionData)
|
||||
{
|
||||
EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
||||
|
||||
if (holdingEntity.IsDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.EntityClass.entityClassName: " + holdingEntity.EntityClass.entityClassName);
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.IsRagdollActive: " + holdingEntity.emodel.IsRagdollActive);
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.IsAnimationStunRunning(): " + holdingEntity.emodel.avatarController.IsAnimationStunRunning());
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.IsEating: " + holdingEntity.IsEating);
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate RebirthUtilities.HasBuffLike(holdingEntity, \"FuriousRamsayRangedStun\"): " + RebirthUtilities.HasBuffLike(holdingEntity, "FuriousRamsayRangedStun"));
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.HasAnyTags(FastTags<TagGroup.Global>.Parse(\"ally\")): " + holdingEntity.HasAnyTags(FastTags<TagGroup.Global>.Parse("ally")));
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel != null: " + (holdingEntity.emodel != null));
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController != null: " + (holdingEntity.emodel.avatarController != null));
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.anim != null: " + (holdingEntity.emodel.avatarController.anim != null));
|
||||
Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.anim.IsInTransition(0): " + holdingEntity.emodel.avatarController.anim.IsInTransition(0));*/
|
||||
|
||||
if (RebirthUtilities.canAttack2(holdingEntity))
|
||||
{
|
||||
//Log.Out("ItemActionMeleePatches-OnHoldingUpdate CANNOT ATTACK");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.ItemActionUseOtherPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemActionUseOther))]
|
||||
[HarmonyPatch("ExecuteAction")]
|
||||
public class ExecuteActionPatch
|
||||
{
|
||||
public static bool Prefix(ItemActionUseOther __instance, ItemActionData _actionData, bool _bReleased,
|
||||
float ___Delay,
|
||||
FastTags<TagGroup.Global> ___medicalItemTag,
|
||||
FastTags<TagGroup.Global> ___stopBleed,
|
||||
FastTags<TagGroup.Global> ___noMedBuffsTag,
|
||||
string ___soundStart,
|
||||
string ___CreateItem,
|
||||
int ___CreateItemCount,
|
||||
ref List<string> ___BuffActions,
|
||||
float ___SphereRadius
|
||||
)
|
||||
{
|
||||
if (!_bReleased)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Time.time - _actionData.lastUseTime < ___Delay)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ItemActionUseOther.FeedInventoryData feedInventoryData = (ItemActionUseOther.FeedInventoryData)_actionData;
|
||||
EntityAlive holdingEntity = feedInventoryData.invData.holdingEntity;
|
||||
if (EffectManager.GetValue(PassiveEffects.DisableItem, holdingEntity.inventory.holdingItemItemValue, 0f, holdingEntity, null, _actionData.invData.item.ItemTags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
_actionData.lastUseTime = Time.time + 1f;
|
||||
Manager.PlayInsidePlayerHead("twitch_no_attack", -1, 0f, false);
|
||||
return false;
|
||||
}
|
||||
_actionData.lastUseTime = Time.time;
|
||||
feedInventoryData.bFeedingStarted = true;
|
||||
float distance = 4f;
|
||||
feedInventoryData.ray = holdingEntity.GetLookRay();
|
||||
int modelLayer = holdingEntity.GetModelLayer();
|
||||
holdingEntity.SetModelLayer(2, false, null);
|
||||
EntityAlive entityAlive = null;
|
||||
if (Voxel.Raycast(feedInventoryData.invData.world, feedInventoryData.ray, distance, -538750981, 128, ___SphereRadius))
|
||||
{
|
||||
entityAlive = (ItemActionUseOther.GetEntityFromHit(Voxel.voxelRayHitInfo) as EntityAlive);
|
||||
}
|
||||
if (entityAlive == null || !entityAlive.IsAlive() || !(entityAlive is EntityPlayer))
|
||||
{
|
||||
Voxel.Raycast(feedInventoryData.invData.world, feedInventoryData.ray, distance, -538488837, 128, ___SphereRadius);
|
||||
}
|
||||
if (entityAlive == null && _actionData.invData.holdingEntity is EntityPlayerLocal)
|
||||
{
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_actionData.invData.holdingEntity as EntityPlayerLocal);
|
||||
NGUIWindowManager nguiWindowManager = uiforPlayer.nguiWindowManager;
|
||||
XUiC_FocusedBlockHealth.SetData(uiforPlayer, null, 0f);
|
||||
}
|
||||
holdingEntity.SetModelLayer(modelLayer, false, null);
|
||||
if (feedInventoryData.TargetEntity == null)
|
||||
{
|
||||
feedInventoryData.TargetEntity = entityAlive;
|
||||
}
|
||||
if (feedInventoryData.TargetEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
List<string> buffActions = new List<string>();
|
||||
|
||||
if (___BuffActions != null)
|
||||
{
|
||||
buffActions = ___BuffActions;
|
||||
}
|
||||
|
||||
if (feedInventoryData.TargetEntity != null)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 6c");
|
||||
string itemName = _actionData.invData.itemValue.ItemClass.GetItemName();
|
||||
|
||||
if (feedInventoryData.invData.item.HasAnyTags(___medicalItemTag))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 6d");
|
||||
if (!RebirthUtilities.CanHeal(itemName, feedInventoryData.TargetEntity, _actionData.invData.holdingEntity))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 6e");
|
||||
return false;
|
||||
}
|
||||
|
||||
feedInventoryData.TargetEntity.Buffs.AddBuff("FuriousRamsayHealParticle");
|
||||
}
|
||||
}
|
||||
|
||||
if (feedInventoryData.invData.item.HasAnyTags(___medicalItemTag) && !(feedInventoryData.TargetEntity is EntityPlayer || feedInventoryData.TargetEntity is EntityNPCRebirth))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 7");
|
||||
feedInventoryData.bFeedingStarted = false;
|
||||
feedInventoryData.TargetEntity = null;
|
||||
return false;
|
||||
}
|
||||
if (feedInventoryData.invData.item.HasAnyTags(___medicalItemTag) && feedInventoryData.TargetEntity.HasAnyTags(___noMedBuffsTag))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 8");
|
||||
feedInventoryData.bFeedingStarted = false;
|
||||
feedInventoryData.TargetEntity = null;
|
||||
return false;
|
||||
}
|
||||
_actionData.invData.holdingEntity.RightArmAnimationUse = true;
|
||||
if (___soundStart != null)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 9");
|
||||
_actionData.invData.holdingEntity.PlayOneShot(___soundStart, false);
|
||||
}
|
||||
_actionData.invData.holdingEntity.MinEventContext.Other = feedInventoryData.TargetEntity;
|
||||
_actionData.invData.holdingEntity.MinEventContext.ItemValue = _actionData.invData.itemValue;
|
||||
_actionData.invData.holdingEntity.FireEvent(MinEventTypes.onSelfHealedOther, true);
|
||||
_actionData.invData.holdingEntity.FireEvent((_actionData.indexInEntityOfAction == 0) ? MinEventTypes.onSelfPrimaryActionEnd : MinEventTypes.onSelfSecondaryActionEnd, true);
|
||||
if (_actionData.invData.itemValue.ItemClass.HasAnyTags(___stopBleed) && feedInventoryData.TargetEntity.entityType == EntityType.Player && feedInventoryData.TargetEntity.Buffs.HasBuff("buffInjuryBleeding"))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 10");
|
||||
IAchievementManager achievementManager = PlatformManager.NativePlatform.AchievementManager;
|
||||
if (achievementManager != null)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 11");
|
||||
achievementManager.SetAchievementStat(EnumAchievementDataStat.BleedOutStopped, 1);
|
||||
}
|
||||
}
|
||||
|
||||
ItemAction.ExecuteBuffActions(buffActions, feedInventoryData.TargetEntity.entityId, feedInventoryData.TargetEntity, false, EnumBodyPartHit.None, null);
|
||||
EntityPlayer entityPlayer = _actionData.invData.holdingEntity as EntityPlayer;
|
||||
if (__instance.Consume)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 12");
|
||||
if (_actionData.invData.itemValue.MaxUseTimes > 0 && _actionData.invData.itemValue.UseTimes + 1f < (float)_actionData.invData.itemValue.MaxUseTimes)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 13");
|
||||
ItemValue itemValue = _actionData.invData.itemValue;
|
||||
itemValue.UseTimes += EffectManager.GetValue(PassiveEffects.DegradationPerUse, feedInventoryData.invData.itemValue, 1f, _actionData.invData.holdingEntity, null, _actionData.invData.itemValue.ItemClass.ItemTags, true, true, true, true, true, 1, false);
|
||||
feedInventoryData.invData.itemValue = itemValue;
|
||||
return false;
|
||||
}
|
||||
_actionData.invData.holdingEntity.inventory.DecHoldingItem(1);
|
||||
}
|
||||
if (___CreateItem != null && ___CreateItemCount > 0)
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 14");
|
||||
ItemStack itemStack = new ItemStack(ItemClass.GetItem(___CreateItem, false), ___CreateItemCount);
|
||||
LocalPlayerUI uiforPlayer2 = LocalPlayerUI.GetUIForPlayer(entityPlayer as EntityPlayerLocal);
|
||||
if (null != uiforPlayer2 && !uiforPlayer2.xui.PlayerInventory.AddItem(itemStack))
|
||||
{
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction 15");
|
||||
_actionData.invData.holdingEntity.world.gameManager.ItemDropServer(itemStack, _actionData.invData.holdingEntity.GetPosition(), Vector3.zero, -1, 60f, false);
|
||||
}
|
||||
}
|
||||
feedInventoryData.bFeedingStarted = false;
|
||||
feedInventoryData.TargetEntity = null;
|
||||
|
||||
//Log.Out("ItemActionUseOtherPatches-ExecuteAction END");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.ItemClassRebirth
|
||||
{
|
||||
internal class ItemClassPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemClass))]
|
||||
[HarmonyPatch("ExecuteAction")]
|
||||
public class ExecuteActionPatch
|
||||
{
|
||||
public static bool Prefix(ItemClass __instance, int _actionIdx, ItemInventoryData _data, bool _bReleased, PlayerActionsLocal _playerActions, FastTags<TagGroup.Global> ___stopBleed)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction START");
|
||||
ItemAction curAction = __instance.Actions[_actionIdx];
|
||||
if (curAction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(curAction is ItemActionDynamicMelee))
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction 1");
|
||||
global::ItemActionData actionData = _data.actionData[_actionIdx];
|
||||
bool flag2 = _bReleased || !curAction.IsActionRunning(actionData);
|
||||
if (!flag2)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth A flag2: " + flag2);
|
||||
return false;
|
||||
}
|
||||
|
||||
string strRequirement = "";
|
||||
|
||||
List<IRequirement> executionRequirements2 = curAction.ExecutionRequirements;
|
||||
if (executionRequirements2 != null && !_bReleased)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction executionRequirements2.Count: " + executionRequirements2.Count);
|
||||
|
||||
_data.holdingEntity.MinEventContext.ItemValue = _data.itemValue;
|
||||
for (int j = 0; j < executionRequirements2.Count; j++)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction j: " + j);
|
||||
|
||||
List<string> list = new List<string>();
|
||||
executionRequirements2[j].GetInfoStrings(ref list);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
strRequirement = list[0];
|
||||
//Log.Out("itemClassPatches-ExecuteAction strRequirement: " + strRequirement);
|
||||
}
|
||||
|
||||
bool isValid = executionRequirements2[j].IsValid(_data.holdingEntity.MinEventContext);
|
||||
|
||||
//Log.Out("itemClassPatches-ExecuteAction isValid: " + isValid);
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
flag2 = false;
|
||||
|
||||
//Log.Out("itemClassPatches-ExecuteAction executionRequirements2: " + executionRequirements2[j]);
|
||||
|
||||
if (executionRequirements2[j] is IsWeaponAvailableRebirth)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth");
|
||||
strRequirement = ".FuriousRamsayCantUse";
|
||||
}
|
||||
else if (executionRequirements2[j] is CanConsume)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction GetItemName: " + __instance.GetItemName());
|
||||
|
||||
if (!RebirthUtilities.CanHeal(__instance.GetItemName(), _data.holdingEntity, _data.holdingEntity))
|
||||
{
|
||||
strRequirement = "stat 'Health'% LT 1";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth B flag2: " + flag2);
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
//Log.Out("itemClassPatches-ExecuteAction 2");
|
||||
RebirthUtilities.DisplayRequirementCaption(_data.holdingEntity, strRequirement);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("itemClassPatches-ExecuteAction 3");
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace Harmony.ItemValuePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemValue))]
|
||||
[HarmonyPatch("ModifyValue")]
|
||||
public class ModifyValuePatch
|
||||
{
|
||||
public static bool Prefix(ItemValue __instance, EntityAlive _entity, ItemValue _originalItemValue, PassiveEffects _passiveEffect, ref float _originalValue, ref float _perc_value, FastTags<TagGroup.Global> _tags, bool _useMods, bool _useDurability)
|
||||
{
|
||||
if (_originalItemValue != null && _originalItemValue.Equals(__instance))
|
||||
return false;
|
||||
int seed = MinEventParams.CachedEventParam.Seed;
|
||||
if ((UnityEngine.Object)_entity != (UnityEngine.Object)null)
|
||||
seed = _entity.MinEventContext.Seed;
|
||||
ItemClass itemClass1 = __instance.ItemClass;
|
||||
if (itemClass1 != null)
|
||||
{
|
||||
if (itemClass1.Actions != null && itemClass1.Actions.Length != 0 && itemClass1.Actions[0] is ItemActionRanged)
|
||||
{
|
||||
string[] magazineItemNames = (itemClass1.Actions[0] as ItemActionRanged).MagazineItemNames;
|
||||
if (magazineItemNames != null)
|
||||
{
|
||||
ItemClass itemClass2 = ItemClass.GetItemClass(magazineItemNames[(int)__instance.SelectedAmmoTypeIndex]);
|
||||
if (itemClass2 != null && itemClass2.Effects != null)
|
||||
itemClass2.Effects.ModifyValue(_entity, _passiveEffect, ref _originalValue, ref _perc_value, _tags: _tags);
|
||||
}
|
||||
}
|
||||
if (itemClass1.Effects != null)
|
||||
{
|
||||
ItemValue itemValue1 = MinEventParams.CachedEventParam.ItemValue;
|
||||
ItemValue itemValue2 = (UnityEngine.Object)_entity != (UnityEngine.Object)null ? _entity.MinEventContext.ItemValue : (ItemValue)null;
|
||||
MinEventParams.CachedEventParam.Seed = (int)__instance.Seed + (__instance.Seed != (ushort)0 ? (int)_passiveEffect : 0);
|
||||
MinEventParams.CachedEventParam.ItemValue = __instance;
|
||||
if ((UnityEngine.Object)_entity != (UnityEngine.Object)null)
|
||||
{
|
||||
_entity.MinEventContext.Seed = MinEventParams.CachedEventParam.Seed;
|
||||
_entity.MinEventContext.ItemValue = __instance;
|
||||
}
|
||||
float num1 = _originalValue;
|
||||
itemClass1.Effects.ModifyValue(_entity, _passiveEffect, ref _originalValue, ref _perc_value, (float)__instance.Quality, _tags);
|
||||
if (_useDurability)
|
||||
{
|
||||
switch (_passiveEffect)
|
||||
{
|
||||
case PassiveEffects.PhysicalDamageResist:
|
||||
if ((double)__instance.PercentUsesLeft < 0.5)
|
||||
{
|
||||
float num2 = _originalValue - num1;
|
||||
_originalValue = num1 + (float)((double)num2 * (double)__instance.PercentUsesLeft * 2.0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PassiveEffects.ElementalDamageResist:
|
||||
if ((double)__instance.PercentUsesLeft < 0.5)
|
||||
{
|
||||
float num3 = _originalValue - num1;
|
||||
_originalValue = num1 + (float)((double)num3 * (double)__instance.PercentUsesLeft * 2.0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PassiveEffects.BuffResistance:
|
||||
if ((double)__instance.PercentUsesLeft < 0.5)
|
||||
{
|
||||
float num4 = _originalValue - num1;
|
||||
_originalValue = num1 + (float)((double)num4 * (double)__instance.PercentUsesLeft * 2.0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
MinEventParams.CachedEventParam.ItemValue = itemValue1;
|
||||
if ((UnityEngine.Object)_entity != (UnityEngine.Object)null)
|
||||
_entity.MinEventContext.ItemValue = itemValue2;
|
||||
}
|
||||
}
|
||||
if (_useMods)
|
||||
{
|
||||
for (int index = 0; index < __instance.CosmeticMods.Length; ++index)
|
||||
{
|
||||
if (__instance.CosmeticMods[index] != null && __instance.CosmeticMods[index].ItemClass is ItemClassModifier)
|
||||
__instance.CosmeticMods[index].ModifyValue(_entity, _originalItemValue, _passiveEffect, ref _originalValue, ref _perc_value, _tags);
|
||||
}
|
||||
for (int index = 0; index < __instance.Modifications.Length; ++index)
|
||||
{
|
||||
if (__instance.Modifications[index] != null && __instance.Modifications[index].ItemClass is ItemClassModifier)
|
||||
__instance.Modifications[index].ModifyValue(_entity, _originalItemValue, _passiveEffect, ref _originalValue, ref _perc_value, _tags);
|
||||
}
|
||||
}
|
||||
MinEventParams.CachedEventParam.Seed = seed;
|
||||
if (!((UnityEngine.Object)_entity != (UnityEngine.Object)null))
|
||||
return false;
|
||||
_entity.MinEventContext.Seed = seed;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
namespace Harmony.JunkSledgeFireControllerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(JunkSledgeFireController))]
|
||||
[HarmonyPatch("hitTarget")]
|
||||
public class hitTargetPatch
|
||||
{
|
||||
public static bool Prefix(ref JunkSledgeFireController __instance,
|
||||
DamageMultiplier ___damageMultiplier
|
||||
)
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-hitTarget START");
|
||||
|
||||
Vector3 position = __instance.Cone.transform.position;
|
||||
global::EntityAlive holdingEntity = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
|
||||
float maxDistance = __instance.MaxDistance;
|
||||
Vector3 vector = __instance.Cone.transform.forward;
|
||||
vector *= -1f;
|
||||
Ray ray = new Ray(position + Origin.position, vector);
|
||||
Voxel.Raycast(GameManager.Instance.World, ray, maxDistance, -538750981, 128, 0.15f);
|
||||
|
||||
ItemValue itemValue = __instance.entityTurret.OriginalItemValue;
|
||||
|
||||
//Log.Out("JunkSledgeFireControllerPatches-hitTarget itemValue (BEFORE): " + itemValue.ItemClass.GetItemName());
|
||||
|
||||
global::EntityAlive myOwner = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
|
||||
|
||||
ItemValue getItemValue = null;
|
||||
|
||||
if (myOwner != null)
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-hitTarget myOwner: " + myOwner.EntityClass.entityClassName);
|
||||
getItemValue = RebirthUtilities.GetItemValue(myOwner, "JunkTurret", __instance.entityTurret.EntityClass.entityClassName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-hitTarget myOwner == null");
|
||||
}
|
||||
|
||||
if (getItemValue != null)
|
||||
{
|
||||
itemValue = getItemValue;
|
||||
}
|
||||
|
||||
//Log.Out("JunkSledgeFireControllerPatches-hitTarget itemValue (AFTER): " + itemValue.ItemClass.GetItemName());
|
||||
|
||||
ItemActionAttack.Hit(Voxel.voxelRayHitInfo.Clone(),
|
||||
__instance.entityTurret.belongsPlayerId,
|
||||
EnumDamageTypes.Bashing,
|
||||
__instance.GetDamageBlock(
|
||||
itemValue,
|
||||
BlockValue.Air,
|
||||
holdingEntity,
|
||||
1),
|
||||
__instance.GetDamageEntity(
|
||||
itemValue,
|
||||
holdingEntity,
|
||||
1),
|
||||
1f,
|
||||
itemValue.PercentUsesLeft,
|
||||
0f,
|
||||
0f,
|
||||
"metal",
|
||||
___damageMultiplier,
|
||||
__instance.buffActions,
|
||||
new ItemActionAttack.AttackHitInfo(),
|
||||
1,
|
||||
0,
|
||||
0f,
|
||||
null,
|
||||
null,
|
||||
ItemActionAttack.EnumAttackMode.RealNoHarvesting,
|
||||
null,
|
||||
__instance.entityTurret.entityId,
|
||||
itemValue
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
namespace Harmony.LocalizationPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Localization))]
|
||||
[HarmonyPatch("Get")]
|
||||
[HarmonyPatch(new[] { typeof(string), typeof(bool) })]
|
||||
public class GetPatch
|
||||
{
|
||||
public static bool Prefix(ref string __result, string _key, bool _caseInsensitive)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (_key == "perkDaringAdventurerRank1LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank2LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank3LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank4LongDesc"
|
||||
)
|
||||
{
|
||||
__result = Localization.Get(_key + "_hive", _caseInsensitive);
|
||||
return false;
|
||||
}
|
||||
else if (_key == "AmmoBundle9mmTier1" ||
|
||||
_key == "AmmoBundle9mmTier2" ||
|
||||
_key == "AmmoBundle9mmTier3" ||
|
||||
_key == "AmmoBundle9mmTier4" ||
|
||||
_key == "AmmoBundle9mmTier5" ||
|
||||
_key == "AmmoBundle44Tier1" ||
|
||||
_key == "AmmoBundle44Tier2" ||
|
||||
_key == "AmmoBundle44Tier3" ||
|
||||
_key == "AmmoBundle44Tier4" ||
|
||||
_key == "AmmoBundle44Tier5" ||
|
||||
_key == "AmmoBundle762Tier1" ||
|
||||
_key == "AmmoBundle762Tier2" ||
|
||||
_key == "AmmoBundle762Tier3" ||
|
||||
_key == "AmmoBundle762Tier4" ||
|
||||
_key == "AmmoBundle762Tier5" ||
|
||||
_key == "AmmoBundleShellTier1" ||
|
||||
_key == "AmmoBundleShellTier2" ||
|
||||
_key == "AmmoBundleShellTier3" ||
|
||||
_key == "AmmoBundleShellTier4" ||
|
||||
_key == "AmmoBundleShellTier5" ||
|
||||
_key == "AmmoBundleTurretTier1" ||
|
||||
_key == "AmmoBundleTurretTier2" ||
|
||||
_key == "AmmoBundleTurretTier3" ||
|
||||
_key == "AmmoBundleTurretTier4" ||
|
||||
_key == "AmmoBundleTurretTier5" ||
|
||||
_key == "AmmoBundleArrowTier1" ||
|
||||
_key == "AmmoBundleArrowTier2" ||
|
||||
_key == "AmmoBundleArrowTier3" ||
|
||||
_key == "AmmoBundleArrowTier4" ||
|
||||
_key == "AmmoBundleArrowTier5"
|
||||
)
|
||||
{
|
||||
__result = Localization.Get(_key + "_hive", _caseInsensitive);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Localization))]
|
||||
[HarmonyPatch("Get")]
|
||||
[HarmonyPatch(new[] { typeof(string), typeof(string), typeof(bool) })]
|
||||
public class GetPatch2
|
||||
{
|
||||
public static bool Prefix(ref string __result, string _key, string _languageName, bool _caseInsensitive)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (_key == "perkDaringAdventurerRank1LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank2LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank3LongDesc" ||
|
||||
_key == "perkDaringAdventurerRank4LongDesc"
|
||||
)
|
||||
{
|
||||
__result = Localization.Get(_key + "_hive", _languageName, _caseInsensitive);
|
||||
return false;
|
||||
}
|
||||
else if (_key == "AmmoBundle9mmTier1" ||
|
||||
_key == "AmmoBundle9mmTier2" ||
|
||||
_key == "AmmoBundle9mmTier3" ||
|
||||
_key == "AmmoBundle9mmTier4" ||
|
||||
_key == "AmmoBundle9mmTier5" ||
|
||||
_key == "AmmoBundle44Tier1" ||
|
||||
_key == "AmmoBundle44Tier2" ||
|
||||
_key == "AmmoBundle44Tier3" ||
|
||||
_key == "AmmoBundle44Tier4" ||
|
||||
_key == "AmmoBundle44Tier5" ||
|
||||
_key == "AmmoBundle762Tier1" ||
|
||||
_key == "AmmoBundle762Tier2" ||
|
||||
_key == "AmmoBundle762Tier3" ||
|
||||
_key == "AmmoBundle762Tier4" ||
|
||||
_key == "AmmoBundle762Tier5" ||
|
||||
_key == "AmmoBundleShellTier1" ||
|
||||
_key == "AmmoBundleShellTier2" ||
|
||||
_key == "AmmoBundleShellTier3" ||
|
||||
_key == "AmmoBundleShellTier4" ||
|
||||
_key == "AmmoBundleShellTier5" ||
|
||||
_key == "AmmoBundleTurretTier1" ||
|
||||
_key == "AmmoBundleTurretTier2" ||
|
||||
_key == "AmmoBundleTurretTier3" ||
|
||||
_key == "AmmoBundleTurretTier4" ||
|
||||
_key == "AmmoBundleTurretTier5" ||
|
||||
_key == "AmmoBundleArrowTier1" ||
|
||||
_key == "AmmoBundleArrowTier2" ||
|
||||
_key == "AmmoBundleArrowTier3" ||
|
||||
_key == "AmmoBundleArrowTier4" ||
|
||||
_key == "AmmoBundleArrowTier5"
|
||||
)
|
||||
{
|
||||
__result = Localization.Get(_key + "_hive", _caseInsensitive);
|
||||
Log.Out("LocalizationPatches-Get B __result: " + __result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RebirthUtils.Harmony
|
||||
{
|
||||
internal class LootManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(LootManager))]
|
||||
[HarmonyPatch("LootContainerOpened")]
|
||||
public class LootContainerOpened
|
||||
{
|
||||
private static bool Prefix(LootManager __instance, ref TileEntityLootContainer _tileEntity, int _entityIdThatOpenedIt, FastTags<TagGroup.Global> _containerTags)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_entityIdThatOpenedIt);
|
||||
if (entityPlayer == null)
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened Player == null");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened START, _tileEntity.lootListName: " + _tileEntity.lootListName);
|
||||
if (GameManager.Instance.World.IsEditor())
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened 1");
|
||||
return false;
|
||||
}
|
||||
if (_tileEntity.bTouched)
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened Touched");
|
||||
return false;
|
||||
}
|
||||
_tileEntity.bTouched = true;
|
||||
_tileEntity.worldTimeTouched = GameManager.Instance.World.GetWorldTime();
|
||||
|
||||
LootContainer lootContainer = LootContainer.GetLootContainer(_tileEntity.lootListName);
|
||||
if (lootContainer == null)
|
||||
return false;
|
||||
|
||||
string lootList = _tileEntity.lootListName;
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened lootList: " + lootList);
|
||||
|
||||
if (lootList.ToLower().Contains("randomloot"))
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened BEFORE lootList: " + lootList);
|
||||
|
||||
string subString = lootList.Split('-').Last();
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened subString: " + subString);
|
||||
|
||||
int maxRange = int.Parse(Regex.Match(subString, @"\d+").Value);
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened maxRange: " + maxRange);
|
||||
|
||||
float random = GameManager.Instance.World.GetGameRandom().RandomRange(1, maxRange + 1);
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened random: " + random);
|
||||
|
||||
lootList = lootList.Substring(0, lootList.IndexOf("-")) + random;
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened AFTER lootList: " + lootList);
|
||||
lootContainer = LootContainer.GetLootContainer(lootList, true);
|
||||
|
||||
if (lootContainer == null)
|
||||
{
|
||||
Log.Out("LootManager-LootContainerOpened COULD NOT FIND lootList: " + lootList);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool flag = _tileEntity.IsEmpty();
|
||||
_tileEntity.bTouched = true;
|
||||
_tileEntity.worldTimeTouched = GameManager.Instance.World.GetWorldTime();
|
||||
if (!flag)
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened is EMPTY");
|
||||
return false;
|
||||
}
|
||||
|
||||
entityPlayer.MinEventContext.TileEntity = _tileEntity;
|
||||
entityPlayer.FireEvent(MinEventTypes.onSelfOpenLootContainer, true);
|
||||
float containerMod = 0f;
|
||||
float containerBonus = 0f;
|
||||
if (_tileEntity.EntityId == -1)
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened 6");
|
||||
try
|
||||
{
|
||||
BlockLoot blockLoot = _tileEntity.blockValue.Block as BlockLoot;
|
||||
containerMod = blockLoot.LootStageMod;
|
||||
containerBonus = blockLoot.LootStageBonus;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Log.Out("LootManager-LootContainerOpened Error while attempting to get BlockLoot");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int num = lootContainer.useUnmodifiedLootstage ? entityPlayer.unModifiedGameStage : entityPlayer.GetHighestPartyLootStage(containerMod, containerBonus);
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened Loot Stage: " + num);
|
||||
|
||||
IList<ItemStack> list = lootContainer.Spawn(__instance.Random, _tileEntity.items.Length, (float)num, 0f, entityPlayer, _containerTags, lootContainer.UniqueItems, lootContainer.IgnoreLootProb);
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened list.Count: " + list.Count);
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
_tileEntity.items[i] = list[i].Clone();
|
||||
}
|
||||
entityPlayer.FireEvent(MinEventTypes.onSelfLootContainer, true);
|
||||
|
||||
//Log.Out("LootManager-LootContainerOpened END");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.MiniTurretFireControllerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(MiniTurretFireController))]
|
||||
[HarmonyPatch("shouldIgnoreTarget")]
|
||||
public class shouldIgnoreTargetPatch
|
||||
{
|
||||
public static bool Prefix(MiniTurretFireController __instance, ref bool __result, Entity _target)
|
||||
{
|
||||
if (_target == null)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_target.IsAlive())
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (_target.entityId == __instance.entityTurret.entityId)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool shouldAttack = RebirthUtilities.VerifyFactionStanding(__instance.entityTurret, (EntityAlive)_target);
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-shouldIgnoreTarget shouldAttack: " + shouldAttack);
|
||||
|
||||
if (!shouldAttack)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MiniTurretFireController))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
//public static MethodInfo trackTarget = AccessTools.Method(typeof(MiniTurretFireController), "trackTarget", new Type[] { typeof(Entity), typeof(float), typeof(float), typeof(Vector3) });
|
||||
private static bool trackTarget(Entity _target, ref float _yaw, ref float _pitch, out Vector3 _targetPos,
|
||||
MiniTurretFireController __instance,
|
||||
Vector2 ___pitchRange,
|
||||
Vector2 ___yawRange,
|
||||
float ___targetChestHeadPercent
|
||||
)
|
||||
{
|
||||
_targetPos = Vector3.Lerp(_target.getChestPosition(), _target.getHeadPosition(), ___targetChestHeadPercent) - Origin.position;
|
||||
Vector3 position = __instance.transform.position;
|
||||
if (__instance.Laser != null)
|
||||
{
|
||||
position = __instance.Laser.transform.position;
|
||||
}
|
||||
Vector3 eulerAngles = Quaternion.LookRotation((_targetPos - position).normalized).eulerAngles;
|
||||
float num = Mathf.DeltaAngle(__instance.entityTurret.transform.rotation.eulerAngles.y, eulerAngles.y);
|
||||
float num2 = eulerAngles.x;
|
||||
if (num2 > 180f)
|
||||
{
|
||||
num2 -= 360f;
|
||||
}
|
||||
float num3 = __instance.CenteredYaw % 360f;
|
||||
float num4 = __instance.CenteredPitch % 360f;
|
||||
if (num3 > 180f)
|
||||
{
|
||||
num3 -= 360f;
|
||||
}
|
||||
if (num4 > 180f)
|
||||
{
|
||||
num4 -= 360f;
|
||||
}
|
||||
if (num < num3 + ___yawRange.x || num > num3 + ___yawRange.y || num2 < num4 + ___pitchRange.x || num2 > num4 + ___pitchRange.y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_yaw = num;
|
||||
_pitch = num2;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static MethodInfo shouldIgnoreTarget = AccessTools.Method(typeof(MiniTurretFireController), "shouldIgnoreTarget", new Type[] { typeof(Entity) });
|
||||
public static MethodInfo findTarget = AccessTools.Method(typeof(MiniTurretFireController), "findTarget", new Type[] { });
|
||||
public static MethodInfo updateLaser = AccessTools.Method(typeof(MiniTurretFireController), "updateLaser", new Type[] { });
|
||||
|
||||
private static bool Prefix(MiniTurretFireController __instance,
|
||||
ref Handle ___turretSpinAudioHandle,
|
||||
ref global::EntityAlive ___currentEntityTarget,
|
||||
ref float ___targetChestHeadDelay,
|
||||
ref float ___targetChestHeadPercent,
|
||||
ref float ___burstFireRate,
|
||||
ref float ___burstFireRateMax,
|
||||
ref Vector2 ___yawRange,
|
||||
float ___maxDistance,
|
||||
MiniTurretFireController.TurretEntitySorter ___sorter,
|
||||
string ___targetingSound,
|
||||
Vector2 ___pitchRange
|
||||
)
|
||||
{
|
||||
if (__instance.entityTurret == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!__instance.entityTurret.IsOn)
|
||||
{
|
||||
if (__instance.entityTurret.YawController.Yaw != __instance.CenteredYaw)
|
||||
{
|
||||
__instance.entityTurret.YawController.Yaw = __instance.CenteredYaw;
|
||||
}
|
||||
if (__instance.entityTurret.PitchController.Pitch != __instance.CenteredPitch + 35f)
|
||||
{
|
||||
__instance.entityTurret.PitchController.Pitch = __instance.CenteredPitch + 35f;
|
||||
}
|
||||
if (___turretSpinAudioHandle != null)
|
||||
{
|
||||
___turretSpinAudioHandle.Stop(__instance.entityTurret.entityId);
|
||||
___turretSpinAudioHandle = null;
|
||||
}
|
||||
__instance.entityTurret.YawController.UpdateYaw();
|
||||
__instance.entityTurret.PitchController.UpdatePitch();
|
||||
return false;
|
||||
}
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
if (!__instance.hasTarget)
|
||||
{
|
||||
findTarget.Invoke(__instance, new object[] { });
|
||||
}
|
||||
else if ((bool)shouldIgnoreTarget.Invoke(__instance, new object[] { ___currentEntityTarget }))
|
||||
{
|
||||
___currentEntityTarget = null;
|
||||
__instance.entityTurret.TargetEntityId = -1;
|
||||
}
|
||||
}
|
||||
else if (__instance.entityTurret.TargetEntityId != -1)
|
||||
{
|
||||
___currentEntityTarget = (GameManager.Instance.World.GetEntity(__instance.entityTurret.TargetEntityId) as global::EntityAlive);
|
||||
if (___currentEntityTarget == null || ___currentEntityTarget.IsDead())
|
||||
{
|
||||
___currentEntityTarget = null;
|
||||
__instance.entityTurret.TargetEntityId = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
___currentEntityTarget = null;
|
||||
__instance.entityTurret.TargetEntityId = -1;
|
||||
}
|
||||
if (__instance.entityTurret.IsTurning)
|
||||
{
|
||||
if (___turretSpinAudioHandle == null)
|
||||
{
|
||||
___turretSpinAudioHandle = Manager.Play(__instance.entityTurret, ___targetingSound, 1f, true);
|
||||
}
|
||||
}
|
||||
else if (___turretSpinAudioHandle != null)
|
||||
{
|
||||
___turretSpinAudioHandle.Stop(__instance.entityTurret.entityId);
|
||||
___turretSpinAudioHandle = null;
|
||||
}
|
||||
___targetChestHeadDelay -= Time.deltaTime;
|
||||
if (___targetChestHeadDelay <= 0f)
|
||||
{
|
||||
___targetChestHeadDelay = 1f;
|
||||
___targetChestHeadPercent = __instance.entityTurret.rand.RandomFloat;
|
||||
}
|
||||
___burstFireRate += Time.deltaTime;
|
||||
if (__instance.hasTarget)
|
||||
{
|
||||
__instance.entityTurret.YawController.IdleScan = false;
|
||||
float yaw = __instance.entityTurret.YawController.Yaw;
|
||||
float pitch = __instance.entityTurret.PitchController.Pitch;
|
||||
Vector3 vector;
|
||||
if (trackTarget(___currentEntityTarget, ref yaw, ref pitch, out vector,
|
||||
__instance,
|
||||
___pitchRange,
|
||||
___yawRange,
|
||||
___targetChestHeadPercent
|
||||
))
|
||||
{
|
||||
__instance.entityTurret.YawController.Yaw = yaw;
|
||||
__instance.entityTurret.PitchController.Pitch = pitch;
|
||||
global::EntityAlive entity = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
|
||||
FastTags<TagGroup.Global> tags = __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags | __instance.entityTurret.EntityClass.Tags;
|
||||
|
||||
ItemValue itemValue = __instance.entityTurret.OriginalItemValue;
|
||||
|
||||
global::EntityAlive myOwner = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Update entityClassName: " + __instance.entityTurret.EntityClass.entityClassName);
|
||||
|
||||
if (__instance.entityTurret.EntityClass.entityClassName != "junkTurretGun" && __instance.entityTurret.EntityClass.entityClassName != "junkTurretSledge")
|
||||
{
|
||||
|
||||
ItemValue getItemValue = null;
|
||||
|
||||
if (myOwner != null)
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-Update A myOwner: " + myOwner.EntityClass.entityClassName);
|
||||
getItemValue = RebirthUtilities.GetItemValue(myOwner, "JunkTurret", __instance.entityTurret.EntityClass.entityClassName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-Update A myOwner == null");
|
||||
}
|
||||
|
||||
if (getItemValue != null)
|
||||
{
|
||||
itemValue = getItemValue;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Update ___burstFireRateMax (BEFORE): " + ___burstFireRateMax);
|
||||
//___burstFireRateMax = 60f / (EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemValue, ___burstFireRateMax, entity, null, tags, true, false, true, true, true, 1) + 1E-05f);
|
||||
___burstFireRateMax = 60f / EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemValue, ___burstFireRateMax, entity);
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Update ___burstFireRateMax (AFTER): " + ___burstFireRateMax);
|
||||
|
||||
if (___burstFireRate >= ___burstFireRateMax)
|
||||
{
|
||||
__instance.Fire();
|
||||
___burstFireRate = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!__instance.entityTurret.YawController.IdleScan || (__instance.entityTurret.YawController.Yaw != ___yawRange.y && __instance.entityTurret.YawController.Yaw != ___yawRange.x))
|
||||
{
|
||||
__instance.entityTurret.YawController.IdleScan = true;
|
||||
__instance.entityTurret.YawController.Yaw = ___yawRange.y;
|
||||
}
|
||||
float num = (___yawRange.y > 0f) ? ___yawRange.y : (360f + ___yawRange.y);
|
||||
float num2 = (___yawRange.x > 0f) ? ___yawRange.x : (360f + ___yawRange.x);
|
||||
if (Mathf.Abs(__instance.entityTurret.YawController.CurrentYaw - num) < 1f || Mathf.Abs(__instance.entityTurret.YawController.CurrentYaw - ___yawRange.y) < 1f)
|
||||
{
|
||||
__instance.entityTurret.YawController.Yaw = ___yawRange.x;
|
||||
}
|
||||
else if (Mathf.Abs(__instance.entityTurret.YawController.CurrentYaw - num2) < 1f || Mathf.Abs(__instance.entityTurret.YawController.CurrentYaw - ___yawRange.x) < 1f)
|
||||
{
|
||||
__instance.entityTurret.YawController.Yaw = ___yawRange.y;
|
||||
}
|
||||
__instance.entityTurret.PitchController.Pitch = __instance.CenteredPitch;
|
||||
}
|
||||
__instance.entityTurret.YawController.UpdateYaw();
|
||||
__instance.entityTurret.PitchController.UpdatePitch();
|
||||
if (__instance.Laser != null)
|
||||
{
|
||||
updateLaser.Invoke(__instance, new object[] { });
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MiniTurretFireController))]
|
||||
[HarmonyPatch("Fire")]
|
||||
public class FirePatch
|
||||
{
|
||||
private static bool Prefix(MiniTurretFireController __instance)
|
||||
{
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire __instance.ammoItemName: " + ___ammoItemName);
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire START");
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire EntityName: " + __instance.entityTurret.EntityName);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer || (UnityEngine.Object)__instance.entityTurret == (UnityEngine.Object)null || !__instance.entityTurret.IsOn)
|
||||
{
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire 1");
|
||||
return false;
|
||||
}
|
||||
Vector3 position = __instance.Laser.transform.position;
|
||||
EntityAlive entity = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as EntityAlive;
|
||||
GameRandom gameRandom = GameManager.Instance.World.GetGameRandom();
|
||||
FastTags<TagGroup.Global> itemTags = __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags;
|
||||
int num1 = (int)EffectManager.GetValue(PassiveEffects.RoundRayCount, __instance.entityTurret.OriginalItemValue, (float)__instance.rayCount, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false);
|
||||
__instance.maxDistance = EffectManager.GetValue(PassiveEffects.MaxRange, __instance.entityTurret.OriginalItemValue, __instance.MaxDistance, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false);
|
||||
for (int index1 = 0; index1 < num1; ++index1)
|
||||
{
|
||||
Vector3 forward = __instance.Muzzle.transform.forward;
|
||||
__instance.spreadHorizontal.x = (float)-((double)EffectManager.GetValue(PassiveEffects.SpreadDegreesHorizontal, __instance.entityTurret.OriginalItemValue, 22f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false) * 0.5);
|
||||
__instance.spreadHorizontal.y = EffectManager.GetValue(PassiveEffects.SpreadDegreesHorizontal, __instance.entityTurret.OriginalItemValue, 22f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false) * 0.5f;
|
||||
__instance.spreadVertical.x = (float)-((double)EffectManager.GetValue(PassiveEffects.SpreadDegreesVertical, __instance.entityTurret.OriginalItemValue, 22f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false) * 0.5);
|
||||
__instance.spreadVertical.y = EffectManager.GetValue(PassiveEffects.SpreadDegreesVertical, __instance.entityTurret.OriginalItemValue, 22f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false) * 0.5f;
|
||||
Vector3 direction = Quaternion.Euler(gameRandom.RandomRange(__instance.spreadHorizontal.x, __instance.spreadHorizontal.y), gameRandom.RandomRange(__instance.spreadVertical.x, __instance.spreadVertical.y), 0.0f) * forward;
|
||||
Ray ray = new Ray(position + Origin.position, direction);
|
||||
__instance.waterCollisionParticles.Reset();
|
||||
__instance.waterCollisionParticles.CheckCollision(ray.origin, ray.direction, __instance.maxDistance);
|
||||
int num2 = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.EntityPenetrationCount, __instance.entityTurret.OriginalItemValue, _entity: entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false)) + 1;
|
||||
int num3 = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.BlockPenetrationFactor, __instance.entityTurret.OriginalItemValue, 1f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false));
|
||||
EntityAlive entityAlive = (EntityAlive)null;
|
||||
for (int index2 = 0; index2 < num2; ++index2)
|
||||
{
|
||||
if (Voxel.Raycast(GameManager.Instance.World, ray, __instance.maxDistance, -538750981, 8, 0.0f))
|
||||
{
|
||||
WorldRayHitInfo hitInfo = Voxel.voxelRayHitInfo.Clone();
|
||||
if (hitInfo.tag.StartsWith("E_"))
|
||||
{
|
||||
EntityAlive entityNoTagCheck = ItemActionAttack.FindHitEntityNoTagCheck(hitInfo, out string _) as EntityAlive;
|
||||
if ((UnityEngine.Object)entityAlive == (UnityEngine.Object)entityNoTagCheck)
|
||||
{
|
||||
ray.origin = hitInfo.hit.pos + ray.direction * 0.1f;
|
||||
--index2;
|
||||
continue;
|
||||
}
|
||||
entityAlive = entityNoTagCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue blockHit = ItemActionAttack.GetBlockHit(GameManager.Instance.World, hitInfo);
|
||||
index2 += Mathf.FloorToInt((float)blockHit.Block.MaxDamage / (float)num3);
|
||||
}
|
||||
|
||||
ItemValue itemValue = __instance.entityTurret.OriginalItemValue;
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire itemValue (BEFORE): " + itemValue.ItemClass.GetItemName());
|
||||
|
||||
global::EntityAlive myOwner = GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as global::EntityAlive;
|
||||
|
||||
ItemValue getItemValue = null;
|
||||
|
||||
if (myOwner != null)
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-Update B myOwner: " + myOwner.EntityClass.entityClassName);
|
||||
getItemValue = RebirthUtilities.GetItemValue(myOwner, "JunkTurret", __instance.entityTurret.EntityClass.entityClassName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("JunkSledgeFireControllerPatches-Update B myOwner == null");
|
||||
}
|
||||
|
||||
if (getItemValue != null)
|
||||
{
|
||||
itemValue = getItemValue;
|
||||
}
|
||||
|
||||
//Log.Out("MiniTurretFireControllerPatches-Fire itemValue (AFTER): " + itemValue.ItemClass.GetItemName());
|
||||
|
||||
ItemActionAttack.Hit(hitInfo, __instance.entityTurret.belongsPlayerId, EnumDamageTypes.Piercing, __instance.GetDamageBlock(__instance.entityTurret.OriginalItemValue, BlockValue.Air, GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as EntityAlive, 1), __instance.GetDamageEntity(__instance.entityTurret.OriginalItemValue, GameManager.Instance.World.GetEntity(__instance.entityTurret.belongsPlayerId) as EntityAlive, 1), 1f, __instance.entityTurret.OriginalItemValue.PercentUsesLeft, 0.0f, 0.0f, "bullet", __instance.damageMultiplier, __instance.buffActions, new ItemActionAttack.AttackHitInfo(), ownedEntityId: __instance.entityTurret.entityId, damagingItemValue: __instance.entityTurret.OriginalItemValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(__instance.muzzleFireParticle))
|
||||
FireControllerUtils.SpawnParticleEffect(new ParticleEffect(__instance.muzzleFireParticle, __instance.Muzzle.position + Origin.position, __instance.Muzzle.rotation, 1f, Color.white, __instance.fireSound, (Transform)null), -1);
|
||||
if (!string.IsNullOrEmpty(__instance.muzzleSmokeParticle))
|
||||
{
|
||||
float _lightValue = GameManager.Instance.World.GetLightBrightness(World.worldToBlockPos(__instance.TurretPosition)) / 2f;
|
||||
FireControllerUtils.SpawnParticleEffect(new ParticleEffect(__instance.muzzleSmokeParticle, __instance.Muzzle.position + Origin.position, __instance.Muzzle.rotation, _lightValue, new Color(1f, 1f, 1f, 0.3f), (string)null, (Transform)null), -1);
|
||||
}
|
||||
++__instance.burstRoundCount;
|
||||
if ((int)EffectManager.GetValue(PassiveEffects.MagazineSize, __instance.entityTurret.OriginalItemValue) > 0)
|
||||
--__instance.entityTurret.AmmoCount;
|
||||
__instance.entityTurret.OriginalItemValue.UseTimes += EffectManager.GetValue(PassiveEffects.DegradationPerUse, __instance.entityTurret.OriginalItemValue, 1f, entity, tags: __instance.entityTurret.OriginalItemValue.ItemClass.ItemTags, calcHoldingItem: false);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
namespace Harmony.NavObjectPatches
|
||||
{
|
||||
internal class NavObjectPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(NetEntityDistributionEntry))]
|
||||
[HarmonyPatch("updatePlayerEntity")]
|
||||
public class updatePlayerEntityPatch
|
||||
{
|
||||
public static bool Prefix(NetEntityDistributionEntry __instance, EntityPlayer _ep,
|
||||
Entity ___trackedEntity,
|
||||
bool ___shouldSendMotionUpdates
|
||||
)
|
||||
{
|
||||
if (__instance.trackedPlayers.Contains(_ep) && __instance.trackedEntity is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)__instance.trackedEntity;
|
||||
|
||||
if (npc.LeaderUtils.Owner != null && npc.bIsChunkObserver)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-updatePlayerEntity 9, entity: " + __instance.trackedEntity.EntityClass.entityClassName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(NavObject))]
|
||||
[HarmonyPatch("IsValidEntity")]
|
||||
public class IsValidEntityPatch
|
||||
{
|
||||
public static bool Prefix(ref NavObject __instance, ref bool __result, EntityPlayerLocal player, Entity entity, NavObjectClass navObjectClass)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 1");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 2");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entity is global::EntityAlive)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 3");
|
||||
global::EntityAlive entityAlive = entity as global::EntityAlive;
|
||||
|
||||
bool purge = RebirthVariables.customScenario == "purge" && navObjectClass.NavObjectClassName == "purge_sleeper";
|
||||
|
||||
bool canSee = false;
|
||||
|
||||
if (purge)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 4");
|
||||
|
||||
if (!(entity is EntityPlayer || entity is EntityTrader))
|
||||
{
|
||||
__result = false;
|
||||
|
||||
//Log.Out("NavObjectPatches-IsValidEntity player.EntityName: " + player.EntityName);
|
||||
|
||||
//Log.Out("NavObjectPatches-IsValidEntity =====================");
|
||||
//Log.Out("NavObjectPatches-IsValidEntity navObjectClass.NavObjectClassName: " + navObjectClass.NavObjectClassName);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity navObjectClass.RequirementName: " + navObjectClass.RequirementName);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity navObjectClass.RequirementType: " + navObjectClass.RequirementType);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entity: " + entity.EntityClass.entityClassName);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeper: " + entityAlive.IsSleeper);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.sleepingOrWakingUp: " + entityAlive.sleepingOrWakingUp);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeperPassive: " + entityAlive.IsSleeperPassive);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeping: " + entityAlive.IsSleeping);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.pendingSleepTrigger: " + entityAlive.pendingSleepTrigger);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.EntityTags: " + entityAlive.EntityTags);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.bSpawned: " + entityAlive.bSpawned);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsAlive(): " + entityAlive.IsAlive());
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.hasHome(): " + entityAlive.hasHome());
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.isSnore: " + entityAlive.isSnore);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.sleepingOrWakingUp: " + entityAlive.sleepingOrWakingUp);
|
||||
|
||||
//Log.Out("NavObjectPatches-IsValidEntity RebirthVariables.maxSleeperVolumeCount: " + RebirthVariables.maxSleeperVolumeCount);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity RebirthVariables.currentSleeperVolumeCount: " + RebirthVariables.currentSleeperVolumeCount);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity RebirthVariables.currentSleeperVolumePerc: " + RebirthVariables.currentSleeperVolumePerc);
|
||||
|
||||
//float currentSleeperEntityCount = player.Buffs.GetCustomVar("$currentSleeperEntityCount");
|
||||
float currentSleeperVolumeCount = RebirthVariables.currentSleeperVolumeCount;
|
||||
float maxSleeperVolumeCount = RebirthVariables.maxSleeperVolumeCount;
|
||||
float currentSleeperVolumePerc = RebirthVariables.currentSleeperVolumePerc;
|
||||
float clearedSleeperVolumeCount = RebirthVariables.clearedSleeperVolumeCount;
|
||||
float totalSleeperVolumeCount = RebirthVariables.totalSleeperVolumeCount;
|
||||
|
||||
float ratio = 0;
|
||||
bool canProceed = false;
|
||||
|
||||
if (totalSleeperVolumeCount > 0)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 1");
|
||||
/*ratio = (clearedSleeperVolumeCount / totalSleeperVolumeCount) * 100;
|
||||
canProceed = ratio >= 50 && clearedSleeperVolumeCount > 0;
|
||||
|
||||
if (totalSleeperVolumeCount >= 10)
|
||||
{
|
||||
if (canProceed && currentSleeperVolumePerc > 0 && currentSleeperVolumePerc <= 20)
|
||||
{
|
||||
canSee = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (canProceed && currentSleeperVolumeCount <= 1)
|
||||
{
|
||||
canSee = true;
|
||||
}
|
||||
}*/
|
||||
if (RebirthVariables.currentPOITier < 4)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 1");
|
||||
if ((RebirthVariables.totalSleeperVolumeCount > 2) && (RebirthVariables.totalSleeperVolumeCount - RebirthVariables.clearedSleeperVolumeCount) <= 1)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 2");
|
||||
canSee = true;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.currentPOITier == 4)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 3");
|
||||
if ((RebirthVariables.totalSleeperVolumeCount - RebirthVariables.clearedSleeperVolumeCount) <= 2)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 4");
|
||||
canSee = true;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.currentPOITier == 5)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 5");
|
||||
if ((RebirthVariables.totalSleeperVolumeCount - RebirthVariables.clearedSleeperVolumeCount) <= 3)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 6");
|
||||
canSee = true;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.currentPOITier >= 6)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 7");
|
||||
if ((RebirthVariables.totalSleeperVolumeCount - RebirthVariables.clearedSleeperVolumeCount) <= 4)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 8");
|
||||
canSee = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool flag1 = canSee && maxSleeperVolumeCount > 1 && entityAlive.IsSleeper;
|
||||
bool flag2 = currentSleeperVolumeCount > 0 && entityAlive.IsSleeper && !entityAlive.IsSleeperPassive;
|
||||
|
||||
if (false && entityAlive.IsSleeper && entityAlive.IsAlive())
|
||||
{
|
||||
Log.Out("===============================================================================");
|
||||
Log.Out("NavObjectPatches-IsValidEntity RebirthVariables.currentPOITier: " + RebirthVariables.currentPOITier);
|
||||
Log.Out("NavObjectPatches-IsValidEntity entity: " + entity.EntityClass.entityClassName);
|
||||
Log.Out("NavObjectPatches-IsValidEntity maxSleeperVolumeCount: " + maxSleeperVolumeCount);
|
||||
Log.Out("NavObjectPatches-IsValidEntity currentSleeperVolumeCount: " + currentSleeperVolumeCount);
|
||||
Log.Out("NavObjectPatches-IsValidEntity currentSleeperVolumePerc: " + currentSleeperVolumePerc);
|
||||
Log.Out("NavObjectPatches-IsValidEntity clearedSleeperVolumeCount: " + clearedSleeperVolumeCount);
|
||||
Log.Out("NavObjectPatches-IsValidEntity totalSleeperVolumeCount: " + totalSleeperVolumeCount);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity RebirthVariables.currentPrefab: " + RebirthVariables.currentPrefab);
|
||||
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeper: " + entityAlive.IsSleeper);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.sleepingOrWakingUp: " + entityAlive.sleepingOrWakingUp);
|
||||
Log.Out("NavObjectPatches-IsValidEntity sleeperActivated: " + entityAlive.Buffs.GetCustomVar("$sleeperActivated"));
|
||||
Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeperPassive: " + entityAlive.IsSleeperPassive);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsSleeping: " + entityAlive.IsSleeping);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.pendingSleepTrigger: " + entityAlive.pendingSleepTrigger);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.EntityTags: " + entityAlive.EntityTags);
|
||||
//Log.Out("NavObjectPatches-IsValidEntity entityAlive.bSpawned: " + entityAlive.bSpawned);
|
||||
|
||||
Log.Out("NavObjectPatches-IsValidEntity ratio: " + ratio);
|
||||
Log.Out("NavObjectPatches-IsValidEntity canProceed: " + canProceed);
|
||||
Log.Out("NavObjectPatches-IsValidEntity canSee: " + canSee);
|
||||
Log.Out("NavObjectPatches-IsValidEntity flag1: " + flag1);
|
||||
Log.Out("NavObjectPatches-IsValidEntity flag2: " + flag2);
|
||||
|
||||
Log.Out("NavObjectPatches-IsValidEntity maxSleeperVolumeCount > 0: " + (maxSleeperVolumeCount > 0));
|
||||
Log.Out("NavObjectPatches-IsValidEntity !player.IsFlyMode.Value: " + !player.IsFlyMode.Value);
|
||||
Log.Out("NavObjectPatches-IsValidEntity navObjectClass.RequirementType == NavObjectClass.RequirementTypes.QuestBounds: " + (navObjectClass.RequirementType == NavObjectClass.RequirementTypes.QuestBounds));
|
||||
Log.Out("NavObjectPatches-IsValidEntity entityAlive.IsAlive(): " + entityAlive.IsAlive());
|
||||
Log.Out("NavObjectPatches-IsValidEntity flag2: " + flag2);
|
||||
|
||||
}
|
||||
|
||||
if (maxSleeperVolumeCount > 0 &&
|
||||
!player.IsFlyMode.Value && navObjectClass.RequirementType == NavObjectClass.RequirementTypes.QuestBounds &&
|
||||
entityAlive.IsAlive())
|
||||
{
|
||||
if (canSee && maxSleeperVolumeCount > 1 && entityAlive.IsSleeper)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A");
|
||||
float sleeperActivated = entityAlive.Buffs.GetCustomVar("$sleeperActivated");
|
||||
|
||||
if (sleeperActivated == 0f)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A1");
|
||||
entityAlive.Buffs.SetCustomVar("$sleeperActivated", 1f);
|
||||
return false;
|
||||
}
|
||||
else if (sleeperActivated == 2f)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A2");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A3");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentSleeperVolumeCount > 0 && entityAlive.IsSleeper && canSee) //) && !entityAlive.IsSleeperPassive)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity B");
|
||||
float sleeperActivated = entityAlive.Buffs.GetCustomVar("$sleeperActivated");
|
||||
if (sleeperActivated == 0f)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A1");
|
||||
entityAlive.Buffs.SetCustomVar("$sleeperActivated", 1f);
|
||||
return false;
|
||||
}
|
||||
else if (sleeperActivated == 2f)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity A2");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*else
|
||||
{
|
||||
Log.Out("NavObjectPatches-IsValidEntity C");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (navObjectClass.RequirementType == NavObjectClass.RequirementTypes.None)
|
||||
{
|
||||
__result = entityAlive.IsAlive() && !entityAlive.IsSleeperPassive;
|
||||
return false;
|
||||
}
|
||||
if (!entityAlive.IsAlive() || entityAlive.IsSleeperPassive)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
switch (navObjectClass.RequirementType)
|
||||
{
|
||||
case NavObjectClass.RequirementTypes.CVar:
|
||||
__result = entityAlive.GetCVar(navObjectClass.RequirementName) > 0f;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.QuestBounds:
|
||||
if (player.QuestJournal.ActiveQuest != null && entityAlive.IsSleeper)
|
||||
{
|
||||
|
||||
Vector3 position = entity.position;
|
||||
position.y = position.z;
|
||||
if (player.ZombieCompassBounds.Contains(position))
|
||||
{
|
||||
if (purge)
|
||||
{
|
||||
if (canSee)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
//Log.Out("NavObjectPatches-IsValidEntity QuestBounds __result: " + __result);
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = false;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.Tracking:
|
||||
__result = EffectManager.GetValue(PassiveEffects.Tracking, null, 0f, player, null, entity.EntityTags, true, true, true, true, true, 1, false) > 0f;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.InParty:
|
||||
bool inParty = player.Party != null && player.Party.MemberList.Contains(entity as EntityPlayer) && entity != player && !(entity as EntityPlayer).IsSpectator;
|
||||
bool isHire = false;
|
||||
|
||||
if (entity is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)entity;
|
||||
|
||||
if (npc.LeaderUtils.Owner != null)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 9");
|
||||
|
||||
if (npc.LeaderUtils.Owner.entityId == player.entityId)
|
||||
{
|
||||
//Log.Out("NavObjectPatches-IsValidEntity 10");
|
||||
isHire = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
__result = inParty || isHire;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.IsAlly:
|
||||
__result = entity as EntityPlayer != null && (entity as EntityPlayer).IsFriendOfLocalPlayer && entity != player && !(entity as EntityPlayer).IsSpectator;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.IsPlayer:
|
||||
__result = entity == player;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.IsVehicleOwner:
|
||||
__result = (entity as EntityVehicle != null && (entity as EntityVehicle).HasOwnedEntity(player.entityId)) || (entity as EntityTurret != null && (entity as EntityTurret).belongsPlayerId == player.entityId);
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.NoActiveQuests:
|
||||
__result = entity as EntityNPC == null || player.QuestJournal.FindReadyForTurnInQuestByGiver(entity.entityId) == null;
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.IsTwitchSpawnedSelf:
|
||||
__result = entity.spawnById == player.entityId && !string.IsNullOrEmpty(entity.spawnByName);
|
||||
return false;
|
||||
case NavObjectClass.RequirementTypes.IsTwitchSpawnedOther:
|
||||
__result = entity.spawnById > 0 && entity.spawnById != player.entityId && !string.IsNullOrEmpty(entity.spawnByName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NavObjectClass.RequirementTypes requirementType = navObjectClass.RequirementType;
|
||||
if (requirementType == NavObjectClass.RequirementTypes.IsTwitchSpawnedSelf)
|
||||
{
|
||||
__result = entity.spawnById == player.entityId;
|
||||
return false;
|
||||
}
|
||||
if (requirementType == NavObjectClass.RequirementTypes.IsTwitchSpawnedOther)
|
||||
{
|
||||
__result = entity.spawnById > 0 && entity.spawnById != player.entityId;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Harmony.NetPackageEntityRagdollPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(NetPackageEntityRagdoll))]
|
||||
[HarmonyPatch("ProcessPackage")]
|
||||
public class ProcessPackagePatches
|
||||
{
|
||||
public static bool Prefix(NetPackageEntityRagdoll __instance, World _world, GameManager _callbacks,
|
||||
int ___entityId,
|
||||
float ___duration,
|
||||
sbyte ___state,
|
||||
Vector3 ___hipPos,
|
||||
Vector3 ___forceWorldPos,
|
||||
Vector3 ___forceVec,
|
||||
EnumBodyPartHit ___bodyPart
|
||||
)
|
||||
{
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage START");
|
||||
|
||||
if (_world == null)
|
||||
{
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 1");
|
||||
return false;
|
||||
}
|
||||
global::EntityAlive entityAlive = _world.GetEntity(___entityId) as global::EntityAlive;
|
||||
if (entityAlive == null)
|
||||
{
|
||||
Log.Out("Discarding " + __instance.GetType().Name + " for entity Id=" + ___entityId.ToString());
|
||||
return false;
|
||||
}
|
||||
if (___state < 0)
|
||||
{
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 2");
|
||||
if (entityAlive.EntityClass.HasRagdoll)
|
||||
{
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 4");
|
||||
entityAlive.emodel.DoRagdoll(___duration, ___bodyPart, ___forceVec, ___forceWorldPos, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 5");
|
||||
entityAlive.PhysicsPush(___forceVec, ___forceWorldPos);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
entityAlive.emodel.SetRagdollState((int)___state);
|
||||
|
||||
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 6");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace Harmony.NetPackageQuestEntitySpawnPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(NetPackageQuestEntitySpawn))]
|
||||
[HarmonyPatch("ProcessPackage")]
|
||||
public class ProcessPackagePatch
|
||||
{
|
||||
public static bool Prefix(NetPackageQuestEntitySpawn __instance, World _world, GameManager _callbacks)
|
||||
{
|
||||
if (_world == null)
|
||||
return false;
|
||||
if (__instance.entityType == -1)
|
||||
{
|
||||
EntityPlayer entity = GameManager.Instance.World.GetEntity(__instance.entityIDQuestHolder) as EntityPlayer;
|
||||
|
||||
RebirthVariables.gameStage = entity.gameStage;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("NetPackageQuestEntitySpawnPatches-ProcessPackage START: " + entity.biomeStandingOn.m_sBiomeName + $" ({entity.position})");
|
||||
string biomeName = RebirthUtilities.GetBiomeName(entity);
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
|
||||
__instance.entityType = EntityGroups.GetRandomFromGroup(GameStageDefinition.GetGameStage(__instance.gamestageGroup).GetStage(entity.PartyGameStage).GetSpawnGroup(0).groupName, ref NetPackageQuestEntitySpawn.lastClassId);
|
||||
}
|
||||
QuestActionSpawnEnemy.SpawnQuestEntity(__instance.entityType, __instance.entityIDQuestHolder);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
namespace Harmony.ObjectiveFetchKeepPatches
|
||||
{
|
||||
public class SetupObjectivePatchClass
|
||||
{
|
||||
[HarmonyPatch(typeof(ObjectiveFetch))]
|
||||
[HarmonyPatch("SetupDisplay")]
|
||||
public class SetupDisplayPatch
|
||||
{
|
||||
|
||||
public static bool Prefix(ObjectiveFetch __instance)
|
||||
{
|
||||
//Log.Out("ObjectiveFetchKeepPatches-SetupDisplay __instance.keyword: " + __instance.keyword);
|
||||
|
||||
string localizedName = "";
|
||||
|
||||
if (__instance.expectedItemClass != null)
|
||||
{
|
||||
localizedName = __instance.expectedItemClass.GetLocalizedItemName();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Seems necessary when using the Contrband Collection Custom job is you exit before completing the job
|
||||
//Log.Out("ObjectiveFetchKeepPatches-SetupDisplay expectedItemClass == null");
|
||||
}
|
||||
|
||||
//Log.Out("ObjectiveFetchKeepPatches-SetupDisplay __instance.expectedItemClass.GetLocalizedItemName(): " + localizedName);
|
||||
//Log.Out("ObjectiveFetchKeepPatches-SetupDisplay __instance.currentCount: " + __instance.currentCount);
|
||||
//Log.Out("ObjectiveFetchKeepPatches-SetupDisplay __instance.itemCount: " + __instance.itemCount);
|
||||
|
||||
__instance.Description = string.Format(__instance.keyword, localizedName);
|
||||
__instance.StatusText = string.Format("{0}/{1}", __instance.currentCount, __instance.itemCount);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ObjectiveFetch))]
|
||||
[HarmonyPatch("Refresh")]
|
||||
public class RefreshPatch
|
||||
{
|
||||
|
||||
public static bool Prefix(ObjectiveFetch __instance,
|
||||
int ___itemCount,
|
||||
ref int ___currentCount,
|
||||
ItemValue ___expectedItem
|
||||
)
|
||||
{
|
||||
if (__instance.Complete)
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (___expectedItem.ItemClass == null)
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh ___expectedItem.ItemClass == null");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh ___expectedItem: " + ___expectedItem.ItemClass.GetItemName());
|
||||
|
||||
XUiM_PlayerInventory playerInventory = LocalPlayerUI.GetUIForPlayer(__instance.OwnerQuest.OwnerJournal.OwnerPlayer).xui.PlayerInventory;
|
||||
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh A ___currentCount: " + ___currentCount);
|
||||
|
||||
if (___expectedItem.ItemClass.GetItemName() == "FuriousRamsayAnimalChicken001Spawn")
|
||||
{
|
||||
int backpackCount = 0;
|
||||
|
||||
backpackCount = playerInventory.Backpack.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken001Spawn", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken002Spawn", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken003Spawn", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken004Spawn", false), -1, -1, false);
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh B backpackCount: " + backpackCount);
|
||||
|
||||
int toolbeltCount = 0;
|
||||
|
||||
toolbeltCount = playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken001Spawn", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken002Spawn", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken003Spawn", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("FuriousRamsayAnimalChicken004Spawn", false), false, -1, -1);
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh B toolbeltCount: " + toolbeltCount);
|
||||
|
||||
___currentCount = backpackCount + toolbeltCount;
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh B ___currentCount: " + ___currentCount);
|
||||
}
|
||||
else if (___expectedItem.ItemClass.GetItemName() == "FuriousRamsayCardboardBox")
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 2");
|
||||
int backpackCount = 0;
|
||||
|
||||
backpackCount = playerInventory.Backpack.GetItemCount(ItemClass.GetItem("FuriousRamsayCardboardBox", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("palletBrownBoxesTile_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("palletBrownBoxesBase_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("palletBrownBoxesTop_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("palletBrownBoxesLoose_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateMoPowerElectronics_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateCarParts_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntStorageGenericPOI_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateLabEquipment_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateSavageCountry_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateShamway_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateShotgunMessiah_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateWorkingStiffs_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateConstructionSupplies_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateBookstore_PickedUp", false), -1, -1, false);
|
||||
backpackCount += playerInventory.Backpack.GetItemCount(ItemClass.GetItem("cntLootCrateHero_PickedUp", false), -1, -1, false);
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh C backpackCount: " + backpackCount);
|
||||
|
||||
int toolbeltCount = 0;
|
||||
|
||||
toolbeltCount = playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("FuriousRamsayCardboardBox", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("palletBrownBoxesTile_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("palletBrownBoxesBase_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("palletBrownBoxesTop_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("palletBrownBoxesLoose_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateMoPowerElectronics_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateCarParts_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntStorageGenericPOI_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateLabEquipment_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateSavageCountry_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateShamway_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateShotgunMessiah_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateWorkingStiffs_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateConstructionSupplies_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateBookstore_PickedUp", false), false, -1, -1);
|
||||
toolbeltCount += playerInventory.Toolbelt.GetItemCount(ItemClass.GetItem("cntLootCrateHero_PickedUp", false), false, -1, -1);
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh C toolbeltCount: " + toolbeltCount);
|
||||
|
||||
___currentCount = backpackCount + toolbeltCount;
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh C ___currentCount: " + ___currentCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 3");
|
||||
___currentCount = playerInventory.Backpack.GetItemCount(___expectedItem, -1, -1, false);
|
||||
___currentCount += playerInventory.Toolbelt.GetItemCount(___expectedItem, false, -1, -1);
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh D ___currentCount: " + ___currentCount);
|
||||
}
|
||||
|
||||
if (___currentCount > ___itemCount)
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 4");
|
||||
___currentCount = ___itemCount;
|
||||
}
|
||||
__instance.SetupDisplay();
|
||||
if (___currentCount != (int)__instance.CurrentValue)
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 5");
|
||||
__instance.CurrentValue = (byte)___currentCount;
|
||||
}
|
||||
__instance.Complete = (___currentCount >= ___itemCount && __instance.OwnerQuest.CheckRequirements());
|
||||
if (__instance.Complete)
|
||||
{
|
||||
//Log.Out("SetupObjectivePatchClass-Refresh 6");
|
||||
__instance.OwnerQuest.RefreshQuestCompletion(QuestClass.CompletionTypes.AutoComplete, null, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Harmony.BlockPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Party))]
|
||||
[HarmonyPatch("GetPartyXP")]
|
||||
public class GetPartyXPPatch
|
||||
{
|
||||
public static bool Prefix(Party __instance, ref int __result, EntityPlayer player, int startingXP)
|
||||
{
|
||||
int num = __instance.MemberCountInRange(player);
|
||||
|
||||
// Parse the party multiplier option
|
||||
float partyMultiplierOption = float.Parse(RebirthVariables.customPartyXPMultiplier) / 100;
|
||||
|
||||
// Calculate the result based on the multiplier
|
||||
if (partyMultiplierOption == 0)
|
||||
{
|
||||
__result = startingXP;
|
||||
}
|
||||
else
|
||||
{
|
||||
float baseMultiplier = 1.0f - 0.1f * num; // Original multiplier logic
|
||||
float adjustedMultiplier = partyMultiplierOption + (1 - partyMultiplierOption) * baseMultiplier;
|
||||
Log.Out("GetPartyXP baseMultiplier: " + baseMultiplier);
|
||||
Log.Out("GetPartyXP adjustedMultiplier: " + adjustedMultiplier);
|
||||
__result = (int)(startingXP * adjustedMultiplier);
|
||||
}
|
||||
|
||||
Log.Out("GetPartyXP startingXP: " + startingXP);
|
||||
|
||||
Log.Out("GetPartyXP XP: " + __result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3911 @@
|
||||
using Audio;
|
||||
using GUI_2;
|
||||
using InControl;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
using static RebirthManager;
|
||||
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
|
||||
|
||||
namespace Harmony.PlayerMoveControllerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(PlayerMoveController), "updateRespawn")]
|
||||
public class updateRespawnPatch
|
||||
{
|
||||
private static bool Prefix(ref PlayerMoveController __instance)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.Spawned)
|
||||
{
|
||||
if (__instance.unstuckCoState != ERoutineState.Running || !__instance.playerInput.GUIActions.Cancel.WasPressed && !__instance.windowManager.IsWindowOpen(XUiC_InGameMenuWindow.ID))
|
||||
return false;
|
||||
__instance.unstuckCoState = ERoutineState.Cancelled;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameManager.IsVideoPlaying())
|
||||
return false;
|
||||
if (!__instance.bLastRespawnActive)
|
||||
{
|
||||
__instance.spawnWindowOpened = false;
|
||||
__instance.spawnPosition = SpawnPosition.Undef;
|
||||
__instance.entityPlayerLocal.BeforePlayerRespawn(__instance.respawnReason);
|
||||
__instance.bLastRespawnActive = true;
|
||||
__instance.waitingForSpawnPointSelection = false;
|
||||
}
|
||||
__instance.entityPlayerLocal.ResetLastTickPos(__instance.entityPlayerLocal.GetPosition());
|
||||
__instance.respawnTime -= Time.deltaTime;
|
||||
if ((double)__instance.respawnTime > 0.0)
|
||||
return false;
|
||||
__instance.respawnTime = 0.0f;
|
||||
if (__instance.spawnWindowOpened && XUiC_SpawnSelectionWindow.IsOpenInUI(LocalPlayerUI.primaryUI))
|
||||
{
|
||||
if ((double)Mathf.Abs(__instance.entityPlayerLocal.GetPosition().y - Constants.cStartPositionPlayerInLevel.y) < 0.0099999997764825821)
|
||||
{
|
||||
Vector3 position = __instance.entityPlayerLocal.GetPosition();
|
||||
Vector3i blockPosition = __instance.entityPlayerLocal.GetBlockPosition();
|
||||
if (__instance.gameManager.World.GetChunkFromWorldPos(blockPosition) != null)
|
||||
{
|
||||
float y = (float)((int)__instance.gameManager.World.GetHeight(blockPosition.x, blockPosition.z) + 1);
|
||||
if ((double)position.y < 0.0 || (double)y < (double)position.y || (double)y > (double)position.y && (double)y - 2.5 < (double)position.y)
|
||||
__instance.entityPlayerLocal.SetPosition(new Vector3(__instance.entityPlayerLocal.GetPosition().x, y, __instance.entityPlayerLocal.GetPosition().z), true);
|
||||
}
|
||||
}
|
||||
if (__instance.playerAutoPilotControllor == null || !__instance.playerAutoPilotControllor.IsEnabled())
|
||||
return false;
|
||||
XUiC_SpawnSelectionWindow.Close(LocalPlayerUI.primaryUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag = __instance.respawnReason == RespawnType.NewGame || __instance.respawnReason == RespawnType.EnterMultiplayer || __instance.respawnReason == RespawnType.JoinMultiplayer || __instance.respawnReason == RespawnType.LoadedGame;
|
||||
Entity entity = (bool)(UnityEngine.Object)__instance.entityPlayerLocal.AttachedToEntity ? __instance.entityPlayerLocal.AttachedToEntity : (Entity)__instance.entityPlayerLocal;
|
||||
switch (__instance.respawnReason)
|
||||
{
|
||||
case RespawnType.NewGame:
|
||||
if (!__instance.spawnWindowOpened)
|
||||
{
|
||||
__instance.openSpawnWindow(__instance.respawnReason);
|
||||
return false;
|
||||
}
|
||||
__instance.spawnPosition = new SpawnPosition(__instance.entityPlayerLocal.GetPosition(), __instance.entityPlayerLocal.rotation.y);
|
||||
break;
|
||||
case RespawnType.LoadedGame:
|
||||
if (!__instance.spawnWindowOpened)
|
||||
{
|
||||
__instance.spawnPosition = new SpawnPosition(__instance.entityPlayerLocal.GetPosition(), __instance.entityPlayerLocal.rotation.y);
|
||||
__instance.entityPlayerLocal.SetPosition(__instance.spawnPosition.position, true);
|
||||
__instance.openSpawnWindow(__instance.respawnReason);
|
||||
return false;
|
||||
}
|
||||
__instance.spawnPosition = new SpawnPosition(__instance.entityPlayerLocal.GetPosition(), __instance.entityPlayerLocal.rotation.y);
|
||||
break;
|
||||
case RespawnType.Teleport:
|
||||
__instance.spawnPosition = new SpawnPosition(entity.GetPosition(), entity.rotation.y);
|
||||
__instance.spawnPosition.position.y = -1f;
|
||||
break;
|
||||
case RespawnType.EnterMultiplayer:
|
||||
case RespawnType.JoinMultiplayer:
|
||||
if (!__instance.spawnWindowOpened)
|
||||
{
|
||||
__instance.spawnPosition = new SpawnPosition(__instance.entityPlayerLocal.GetPosition(), __instance.entityPlayerLocal.rotation.y);
|
||||
if ((__instance.spawnPosition.IsUndef() || __instance.spawnPosition.position.Equals(Constants.cStartPositionPlayerInLevel)) && !__instance.entityPlayerLocal.lastSpawnPosition.IsUndef())
|
||||
__instance.spawnPosition = __instance.entityPlayerLocal.lastSpawnPosition;
|
||||
if (__instance.spawnPosition.IsUndef() || __instance.spawnPosition.position.Equals(Constants.cStartPositionPlayerInLevel))
|
||||
__instance.spawnPosition = __instance.gameManager.GetSpawnPointList().GetRandomSpawnPosition(__instance.entityPlayerLocal.world);
|
||||
__instance.entityPlayerLocal.SetPosition(new Vector3(__instance.spawnPosition.position.x, (double)__instance.spawnPosition.position.y == 0.0 ? Constants.cStartPositionPlayerInLevel.y : __instance.spawnPosition.position.y, __instance.spawnPosition.position.z), true);
|
||||
__instance.openSpawnWindow(__instance.respawnReason);
|
||||
return false;
|
||||
}
|
||||
__instance.spawnPosition = new SpawnPosition(__instance.entityPlayerLocal.GetPosition(), __instance.entityPlayerLocal.rotation.y);
|
||||
break;
|
||||
default:
|
||||
if (!__instance.gameManager.IsEditMode() && !__instance.spawnWindowOpened)
|
||||
{
|
||||
__instance.openSpawnWindow(__instance.respawnReason);
|
||||
return false;
|
||||
}
|
||||
XUiC_SpawnSelectionWindow window = XUiC_SpawnSelectionWindow.GetWindow(LocalPlayerUI.primaryUI);
|
||||
if (!__instance.waitingForSpawnPointSelection && !__instance.gameManager.IsEditMode() && __instance.spawnWindowOpened && window.spawnMethod != SpawnMethod.Invalid)
|
||||
{
|
||||
__instance.StartCoroutine(__instance.FindRespawnSpawnPointRoutine(window.spawnMethod, window.spawnTarget));
|
||||
window.spawnMethod = SpawnMethod.Invalid;
|
||||
window.spawnTarget = SpawnPosition.Undef;
|
||||
}
|
||||
if (__instance.waitingForSpawnPointSelection)
|
||||
return false;
|
||||
if (__instance.entityPlayerLocal.position != __instance.spawnPosition.position)
|
||||
{
|
||||
Vector3 position = __instance.spawnPosition.position;
|
||||
if (__instance.spawnPosition.IsUndef())
|
||||
position = __instance.entityPlayerLocal.GetPosition();
|
||||
__instance.spawnPosition = new SpawnPosition(position + new Vector3(0.0f, 5f, 0.0f), __instance.entityPlayerLocal.rotation.y);
|
||||
__instance.entityPlayerLocal.SetPosition(__instance.spawnPosition.position, true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (GameUtils.IsPlaytesting() || GameManager.Instance.IsEditMode() && GamePrefs.GetString(EnumGamePrefs.GameWorld) == "Empty")
|
||||
{
|
||||
SpawnPointList spawnPointList = GameManager.Instance.GetSpawnPointList();
|
||||
if (__instance.respawnReason != RespawnType.Teleport && spawnPointList.Count > 0)
|
||||
{
|
||||
__instance.spawnPosition.position = spawnPointList[0].spawnPosition.position;
|
||||
__instance.spawnPosition.heading = spawnPointList[0].spawnPosition.heading;
|
||||
__instance.entityPlayerLocal.SetPosition(__instance.spawnPosition.position, true);
|
||||
}
|
||||
}
|
||||
if (!__instance.spawnPosition.IsUndef())
|
||||
{
|
||||
if (!PrefabEditModeManager.Instance.IsActive() && !__instance.gameManager.World.IsPositionAvailable(__instance.spawnPosition.ClrIdx, __instance.spawnPosition.position))
|
||||
{
|
||||
__instance.spawnPosition.position = __instance.gameManager.World.ClampToValidWorldPos(__instance.spawnPosition.position);
|
||||
if (!(__instance.entityPlayerLocal.position != __instance.spawnPosition.position))
|
||||
return false;
|
||||
__instance.entityPlayerLocal.SetPosition(__instance.spawnPosition.position, true);
|
||||
return false;
|
||||
}
|
||||
if (!__instance.entityPlayerLocal.CheckSpawnPointStillThere())
|
||||
{
|
||||
__instance.entityPlayerLocal.RemoveSpawnPoints();
|
||||
if (flag)
|
||||
{
|
||||
__instance.entityPlayerLocal.QuestJournal.RemoveAllSharedQuests();
|
||||
__instance.entityPlayerLocal.QuestJournal.StartQuests();
|
||||
}
|
||||
}
|
||||
Vector3i blockPos = World.worldToBlockPos(__instance.spawnPosition.position);
|
||||
float num = (float)((int)__instance.gameManager.World.GetHeight(blockPos.x, blockPos.z) + 1);
|
||||
if ((double)__instance.spawnPosition.position.y < 0.0 || (double)__instance.spawnPosition.position.y > (double)num)
|
||||
__instance.spawnPosition.position.y = num;
|
||||
else if ((double)__instance.spawnPosition.position.y < (double)num && !__instance.gameManager.World.CanPlayersSpawnAtPos(__instance.spawnPosition.position, true))
|
||||
{
|
||||
++__instance.spawnPosition.position.y;
|
||||
if (!__instance.gameManager.World.CanPlayersSpawnAtPos(__instance.spawnPosition.position, true))
|
||||
__instance.spawnPosition.position.y = num;
|
||||
}
|
||||
}
|
||||
Log.Out("Respawn almost done");
|
||||
|
||||
if (__instance.spawnPosition.IsUndef())
|
||||
{
|
||||
__instance.entityPlayerLocal.Respawn(__instance.respawnReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
RaycastHit hitInfo;
|
||||
float num = !Physics.Raycast(new Ray(__instance.spawnPosition.position + Vector3.up - Origin.position, Vector3.down), out hitInfo, 3f, 1342242816) ? __instance.gameManager.World.GetTerrainOffset(0, World.worldToBlockPos(__instance.spawnPosition.position)) + 0.05f : hitInfo.point.y - __instance.spawnPosition.position.y + Origin.position.y;
|
||||
__instance.gameManager.ClearTooltips(__instance.nguiWindowManager);
|
||||
__instance.spawnPosition.position.y += num;
|
||||
__instance.entityPlayerLocal.onGround = true;
|
||||
__instance.entityPlayerLocal.lastSpawnPosition = __instance.spawnPosition;
|
||||
__instance.entityPlayerLocal.Spawned = true;
|
||||
GameManager.Instance.PlayerSpawnedInWorld((ClientInfo)null, __instance.respawnReason, new Vector3i(__instance.spawnPosition.position), __instance.entityPlayerLocal.entityId);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToClientsOrServer((NetPackage)NetPackageManager.GetPackage<NetPackagePlayerSpawnedInWorld>().Setup(__instance.respawnReason, new Vector3i(__instance.spawnPosition.position), __instance.entityPlayerLocal.entityId));
|
||||
if (__instance.respawnReason == RespawnType.Died || __instance.respawnReason == RespawnType.EnterMultiplayer || __instance.respawnReason == RespawnType.NewGame)
|
||||
__instance.entityPlayerLocal.SetAlive();
|
||||
else
|
||||
__instance.entityPlayerLocal.bDead = false;
|
||||
if (__instance.respawnReason == RespawnType.NewGame || __instance.respawnReason == RespawnType.LoadedGame || __instance.respawnReason == RespawnType.EnterMultiplayer || __instance.respawnReason == RespawnType.JoinMultiplayer)
|
||||
__instance.entityPlayerLocal.TryAddRecoveryPosition(Vector3i.FromVector3Rounded(__instance.spawnPosition.position));
|
||||
__instance.entityPlayerLocal.ResetLastTickPos(__instance.spawnPosition.position);
|
||||
if (!(bool)(UnityEngine.Object)__instance.entityPlayerLocal.AttachedToEntity)
|
||||
__instance.entityPlayerLocal.transform.position = __instance.spawnPosition.position - Origin.position;
|
||||
else
|
||||
__instance.spawnPosition.position.y += 2f;
|
||||
entity.SetPosition(__instance.spawnPosition.position);
|
||||
entity.SetRotation(new Vector3(0.0f, __instance.spawnPosition.heading, 0.0f));
|
||||
|
||||
__instance.entityPlayerLocal.JetpackWearing = false;
|
||||
__instance.entityPlayerLocal.ParachuteWearing = false;
|
||||
__instance.entityPlayerLocal.AfterPlayerRespawn(__instance.respawnReason);
|
||||
if (flag)
|
||||
{
|
||||
__instance.entityPlayerLocal.QuestJournal.RemoveAllSharedQuests();
|
||||
__instance.entityPlayerLocal.QuestJournal.StartQuests();
|
||||
}
|
||||
if ((__instance.respawnReason == RespawnType.NewGame || __instance.respawnReason == RespawnType.EnterMultiplayer) && !GameManager.Instance.World.IsEditor() && !(GameMode.GetGameModeForId(GameStats.GetInt(EnumGameStats.GameModeId)) is GameModeCreative) && !GameUtils.IsPlaytesting() && !GameManager.bRecordNextSession && !GameManager.bPlayRecordedSession)
|
||||
GameEventManager.Current.HandleAction("game_first_spawn", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
if (__instance.respawnReason != RespawnType.Died && __instance.respawnReason != RespawnType.Teleport && GameStats.GetBool(EnumGameStats.AutoParty) && __instance.entityPlayerLocal.Party == null)
|
||||
{
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackagePartyActions>().Setup(NetPackagePartyActions.PartyActions.JoinAutoParty, __instance.entityPlayerLocal.entityId, __instance.entityPlayerLocal.entityId));
|
||||
else
|
||||
Party.ServerHandleAutoJoinParty((EntityPlayer)__instance.entityPlayerLocal);
|
||||
}
|
||||
if (__instance.respawnReason == RespawnType.JoinMultiplayer || __instance.respawnReason == RespawnType.LoadedGame)
|
||||
{
|
||||
__instance.entityPlayerLocal.ReassignEquipmentTransforms();
|
||||
GameEventManager.Current.HandleAction("game_on_spawn", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
}
|
||||
|
||||
#region Rebirth
|
||||
float spawnedIn = __instance.entityPlayerLocal.Buffs.GetCustomVar("$spawnedIn");
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-updateRespawn $spawnedIn: " + spawnedIn);
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && !(__instance.entityPlayerLocal.world.IsEditor() || GameUtils.IsWorldEditor() || GameUtils.IsPlaytesting() || spawnedIn == 1f))
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-updateRespawn TURN CAMERA OFF");
|
||||
__instance.entityPlayerLocal.EnableCamera(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-updateRespawn TURN CAMERA ON");
|
||||
__instance.entityPlayerLocal.EnableCamera(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
LocalPlayerUI.primaryUI.windowManager.Close(XUiC_LoadingScreen.ID);
|
||||
LocalPlayerUI.primaryUI.windowManager.Close("eacWarning");
|
||||
LocalPlayerUI.primaryUI.windowManager.Close("crossplayWarning");
|
||||
if (flag && PlatformManager.NativePlatform.GameplayNotifier != null)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
PlatformManager.NativePlatform.GameplayNotifier.GameplayStart(SingletonMonoBehaviour<ConnectionManager>.Instance.CurrentMode == ProtocolManager.NetworkType.Server, SingletonMonoBehaviour<ConnectionManager>.Instance.LocalServerInfo.AllowsCrossplay);
|
||||
else if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
PlatformManager.NativePlatform.GameplayNotifier.GameplayStart(true, SingletonMonoBehaviour<ConnectionManager>.Instance.LastGameServerInfo.AllowsCrossplay);
|
||||
}
|
||||
if (__instance.respawnReason == RespawnType.Died)
|
||||
{
|
||||
__instance.entityPlayerLocal.QuestJournal.FailAllActivatedQuests();
|
||||
__instance.entityPlayerLocal.Progression.OnRespawnFromDeath();
|
||||
switch (GameStats.GetInt(EnumGameStats.DeathPenalty))
|
||||
{
|
||||
case 0:
|
||||
GameEventManager.Current.HandleAction("game_on_respawn_none", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
break;
|
||||
case 1:
|
||||
GameEventManager.Current.HandleAction("game_on_respawn_default", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
break;
|
||||
case 2:
|
||||
GameEventManager.Current.HandleAction("game_on_respawn_injured", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
break;
|
||||
case 3:
|
||||
GameEventManager.Current.HandleAction("game_on_respawn_permanent", (EntityPlayer)__instance.entityPlayerLocal, (Entity)__instance.entityPlayerLocal, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!__instance.gameManager.IsEditMode() && (__instance.respawnReason == RespawnType.NewGame || __instance.respawnReason == RespawnType.EnterMultiplayer))
|
||||
{
|
||||
#region Rebirth
|
||||
if (RebirthUtilities.ScenarioSkip() && !GameUtils.IsPlaytesting())
|
||||
{
|
||||
if (__instance.entityPlayerLocal.Buffs.GetCustomVar("$spawnedIn") == 0f)
|
||||
{
|
||||
__instance.windowManager.TempHUDDisable();
|
||||
__instance.entityPlayerLocal.SetControllable(false);
|
||||
__instance.entityPlayerLocal.bIntroAnimActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.entityPlayerLocal != null && __instance.entityPlayerLocal.inventory != null)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.ForceHoldingItemUpdate();
|
||||
}
|
||||
if (__instance.entityPlayerLocal != null && __instance.entityPlayerLocal.transform != null)
|
||||
{
|
||||
__instance.entityPlayerLocal.bIntroAnimActive = false;
|
||||
__instance.entityPlayerLocal.SetControllable(true);
|
||||
}
|
||||
if (__instance.windowManager != null)
|
||||
{
|
||||
__instance.windowManager.ReEnableHUD();
|
||||
}
|
||||
__instance.entityPlayerLocal.EnableCamera(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
else
|
||||
{
|
||||
__instance.windowManager.TempHUDDisable();
|
||||
__instance.entityPlayerLocal.SetControllable(false);
|
||||
__instance.entityPlayerLocal.bIntroAnimActive = true;
|
||||
GameManager.Instance.StartCoroutine(__instance.showUILater());
|
||||
if (!GameUtils.IsPlaytesting())
|
||||
GameManager.Instance.StartCoroutine(__instance.initializeHoldingItemLater(4f));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.SetControllable(true);
|
||||
if (!__instance.gameManager.IsEditMode() && !GameUtils.IsPlaytesting() && (__instance.respawnReason == RespawnType.LoadedGame || __instance.respawnReason == RespawnType.JoinMultiplayer))
|
||||
GameManager.Instance.StartCoroutine(__instance.initializeHoldingItemLater(0.1f));
|
||||
}
|
||||
__instance.bLastRespawnActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerMoveController), "Update")]
|
||||
public class PlayerMoveControllerUpdatePatch
|
||||
{
|
||||
private static bool Prefix(ref PlayerMoveController __instance)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.world.IsEditor())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bCheckPlayerActions = CheckPlayerActions(__instance, __instance.playerUI, __instance.entityPlayerLocal);
|
||||
bool flag1 = !__instance.playerUI.windowManager.IsCursorWindowOpen() && !__instance.playerUI.windowManager.IsModalWindowOpen() && (__instance.playerInput.Enabled || __instance.playerInput.VehicleActions.Enabled);
|
||||
|
||||
if (DroneManager.Debug_LocalControl)
|
||||
flag1 = false;
|
||||
|
||||
if (__instance.playerAutoPilotControllor != null && __instance.playerAutoPilotControllor.IsEnabled())
|
||||
__instance.playerAutoPilotControllor.Update();
|
||||
|
||||
if (!(__instance.bCanControlOverride & flag1) && GamePrefs.GetInt(EnumGamePrefs.SelectionOperationMode) == 0)
|
||||
{
|
||||
XUiC_InteractionPrompt.SetText(__instance.playerUI, string.Empty);
|
||||
__instance.strTextLabelPointingTo = string.Empty;
|
||||
}
|
||||
|
||||
if (!__instance.gameManager.gameStateManager.IsGameStarted() || GameStats.GetInt(EnumGameStats.GameState) != 1)
|
||||
{
|
||||
__instance.stopMoving();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.entityPlayerLocal.PlayerUI.windowManager.IsModalWindowOpen())
|
||||
{
|
||||
if (!__instance.IsGUICancelPressed && __instance.playerInput.PermanentActions.Cancel.WasPressed)
|
||||
__instance.IsGUICancelPressed = true;
|
||||
}
|
||||
else if (__instance.IsGUICancelPressed)
|
||||
__instance.IsGUICancelPressed = __instance.playerInput.PermanentActions.Cancel.GetBindingOfType(__instance.playerInput.ActiveDevice.DeviceClass == InputDeviceClass.Controller).GetState(__instance.playerInput.ActiveDevice);
|
||||
|
||||
__instance.updateRespawn();
|
||||
__instance.updateDebugKeys();
|
||||
|
||||
if (__instance.drawChunkMode > 0)
|
||||
{
|
||||
__instance.DrawChunkBoundary();
|
||||
if (__instance.drawChunkMode == 2)
|
||||
__instance.DrawChunkDensities();
|
||||
}
|
||||
|
||||
if (__instance.entityPlayerLocal.emodel.IsRagdollActive)
|
||||
__instance.stopMoving();
|
||||
else if (__instance.entityPlayerLocal.IsDead())
|
||||
{
|
||||
XUiC_InteractionPrompt.SetText(__instance.playerUI, (string)null);
|
||||
__instance.strTextLabelPointingTo = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag2 = false;
|
||||
float num1 = __instance.playerInput.Scroll.Value;
|
||||
if (__instance.playerInput.LastInputType == BindingSourceType.DeviceBindingSource)
|
||||
|
||||
{
|
||||
if (!__instance.entityPlayerLocal.AimingGun)
|
||||
num1 = 0.0f;
|
||||
else
|
||||
num1 *= 0.25f;
|
||||
}
|
||||
|
||||
float num2 = num1 * 0.25f;
|
||||
|
||||
if ((double)Mathf.Abs(num2) < 1.0 / 1000.0)
|
||||
num2 = 0.0f;
|
||||
|
||||
__instance.gameManager.GetActiveBlockTool().CheckKeys(__instance.entityPlayerLocal.inventory.holdingItemData, __instance.entityPlayerLocal.HitInfo, __instance.playerInput);
|
||||
|
||||
if (__instance.gameManager.IsEditMode() || BlockToolSelection.Instance.SelectionActive)
|
||||
{
|
||||
SelectionBoxManager.Instance.CheckKeys(__instance.gameManager, __instance.playerInput, __instance.entityPlayerLocal.HitInfo);
|
||||
|
||||
if (!flag2)
|
||||
SelectionBoxManager.Instance.ConsumeScrollWheel(num2, __instance.playerInput);
|
||||
flag2 = __instance.gameManager.GetActiveBlockTool().ConsumeScrollWheel(__instance.entityPlayerLocal.inventory.holdingItemData, num2, __instance.playerInput);
|
||||
}
|
||||
|
||||
if (!(__instance.bCanControlOverride & flag1) && GamePrefs.GetInt(EnumGamePrefs.SelectionOperationMode) == 0)
|
||||
{
|
||||
__instance.stopMoving();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.movementInput.lastInputController = __instance.playerInput.LastInputType == BindingSourceType.DeviceBindingSource;
|
||||
|
||||
if (!__instance.IsGUICancelPressed && (!__instance.gameManager.IsEditMode() || GamePrefs.GetInt(EnumGamePrefs.SelectionOperationMode) == 0))
|
||||
{
|
||||
bool controlKeyPressed = InputUtils.ControlKeyPressed;
|
||||
PlayerAction playerAction1 = __instance.playerInput.VehicleActions.Enabled ? __instance.playerInput.VehicleActions.Turbo : __instance.playerInput.Run;
|
||||
PlayerAction playerAction2 = __instance.playerInput.VehicleActions.Enabled ? __instance.playerInput.VehicleActions.MoveForward : __instance.playerInput.MoveForward;
|
||||
|
||||
if (playerAction1.WasPressed)
|
||||
{
|
||||
__instance.runInputTime = 0.0f;
|
||||
__instance.entityPlayerLocal.movementInput.running = true;
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
__instance.runPressedWhileActive = true;
|
||||
}
|
||||
else if (playerAction1.WasReleased && __instance.runPressedWhileActive)
|
||||
{
|
||||
if ((double)__instance.runInputTime > 0.20000000298023224)
|
||||
{
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
__instance.runToggleActive = false;
|
||||
}
|
||||
else if (__instance.runToggleActive)
|
||||
{
|
||||
__instance.runToggleActive = false;
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
}
|
||||
else if (playerAction2.IsPressed || __instance.sprintLockEnabled)
|
||||
{
|
||||
__instance.runToggleActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.runToggleActive = false;
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
}
|
||||
|
||||
__instance.runPressedWhileActive = false;
|
||||
}
|
||||
|
||||
if (playerAction1.IsPressed)
|
||||
__instance.runInputTime += Time.deltaTime;
|
||||
|
||||
if (__instance.runToggleActive)
|
||||
{
|
||||
bool sprintLockEnabled = GamePrefs.GetBool(EnumGamePrefs.OptionsControlsSprintLock);
|
||||
|
||||
if ((double)__instance.entityPlayerLocal.Stamina <= 0.0 && !__instance.sprintLockEnabled)
|
||||
{
|
||||
__instance.runToggleActive = false;
|
||||
__instance.runPressedWhileActive = false;
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
}
|
||||
else if (playerAction2.WasReleased && !__instance.sprintLockEnabled)
|
||||
{
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
__instance.runToggleActive = false;
|
||||
__instance.runPressedWhileActive = false;
|
||||
}
|
||||
//else if (!sprintLockEnabled && playerAction1.WasReleased && !__instance.sprintLockEnabled)
|
||||
else if (playerAction1.WasReleased && !__instance.sprintLockEnabled && !RebirthVariables.customRunToggle)
|
||||
{
|
||||
__instance.entityPlayerLocal.movementInput.running = false;
|
||||
__instance.runToggleActive = false;
|
||||
__instance.runPressedWhileActive = false;
|
||||
}
|
||||
else
|
||||
__instance.entityPlayerLocal.movementInput.running = true;
|
||||
}
|
||||
|
||||
__instance.entityPlayerLocal.movementInput.down = __instance.playerInput.Crouch.IsPressed && !(__instance.gameManager.IsEditMode() & controlKeyPressed);
|
||||
__instance.entityPlayerLocal.movementInput.jump = __instance.playerInput.Jump.IsPressed;
|
||||
|
||||
if (__instance.entityPlayerLocal.movementInput.running && __instance.entityPlayerLocal.AimingGun)
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
}
|
||||
|
||||
__instance.entityPlayerLocal.movementInput.downToggle = !__instance.gameManager.IsEditMode() && !__instance.entityPlayerLocal.IsFlyMode.Value && __instance.playerInput.ToggleCrouch.WasPressed;
|
||||
|
||||
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled) && __instance.playerInput.PermanentActions.DebugControllerLeft.IsPressed && __instance.playerInput.PermanentActions.DebugControllerRight.IsPressed)
|
||||
|
||||
{
|
||||
if (__instance.playerInput.GodAlternate.WasPressed)
|
||||
__instance.toggleGodMode();
|
||||
|
||||
if (__instance.playerInput.TeleportAlternate.WasPressed)
|
||||
__instance.teleportPlayer();
|
||||
}
|
||||
|
||||
if (__instance.playerInput.DecSpeed.WasPressed)
|
||||
__instance.entityPlayerLocal.GodModeSpeedModifier = Utils.FastMax(0.1f, __instance.entityPlayerLocal.GodModeSpeedModifier - 0.1f);
|
||||
|
||||
if (__instance.playerInput.IncSpeed.WasPressed)
|
||||
__instance.entityPlayerLocal.GodModeSpeedModifier = Utils.FastMin(3f, __instance.entityPlayerLocal.GodModeSpeedModifier + 0.1f);
|
||||
|
||||
Vector2 vector2_1;
|
||||
Vector2 vector2_2;
|
||||
|
||||
if (__instance.playerInput.Look.LastInputType != BindingSourceType.MouseBindingSource)
|
||||
{
|
||||
__instance.entityPlayerLocal.movementInput.down = __instance.entityPlayerLocal.IsFlyMode.Value && __instance.playerInput.ToggleCrouch.IsPressed;
|
||||
float magnitude;
|
||||
|
||||
if (__instance.playerInput.VehicleActions.Enabled)
|
||||
{
|
||||
vector2_1.x = __instance.playerInput.VehicleActions.Look.X;
|
||||
vector2_1.y = __instance.playerInput.VehicleActions.Look.Y * (float)__instance.invertController;
|
||||
magnitude = __instance.playerInput.VehicleActions.Look.Vector.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector2_1.x = __instance.playerInput.Look.X;
|
||||
vector2_1.y = __instance.playerInput.Look.Y * (float)__instance.invertController;
|
||||
magnitude = __instance.playerInput.Look.Vector.magnitude;
|
||||
}
|
||||
|
||||
__instance.currentLookAcceleration = (double)__instance.lookAccelerationRate > 0.0 ? ((double)magnitude <= 0.0 ? 0.0f : Mathf.Clamp(__instance.currentLookAcceleration + __instance.lookAccelerationRate * magnitude * Time.unscaledDeltaTime, 0.0f, magnitude)) : 1f;
|
||||
Vector2 controllerLookSensitivity = __instance.controllerLookSensitivity;
|
||||
|
||||
if (__instance.entityPlayerLocal.AimingGun)
|
||||
controllerLookSensitivity *= __instance.controllerZoomSensitivity;
|
||||
else if (__instance.playerInput.VehicleActions.Enabled)
|
||||
controllerLookSensitivity *= __instance.controllerVehicleSensitivity;
|
||||
|
||||
vector2_2 = controllerLookSensitivity * __instance.lookAccelerationCurve.Evaluate(__instance.currentLookAcceleration);
|
||||
|
||||
if (__instance.entityPlayerLocal.AimingGun)
|
||||
{
|
||||
float num3 = Mathf.Lerp(0.2f, 1f, (float)(((double)__instance.entityPlayerLocal.playerCamera.fieldOfView - 10.0) / ((double)Constants.cDefaultCameraFieldOfView - 10.0)));
|
||||
vector2_2 *= num3;
|
||||
}
|
||||
|
||||
if (__instance.entityPlayerLocal.AttachedToEntity != null)
|
||||
{
|
||||
__instance.aimAssistSlowAmount = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag3 = false;
|
||||
WorldRayHitInfo hitInfo = __instance.entityPlayerLocal.HitInfo;
|
||||
|
||||
if (hitInfo.bHitValid)
|
||||
{
|
||||
if ((bool)hitInfo.transform)
|
||||
{
|
||||
Transform hitRootTransform = GameUtils.GetHitRootTransform(hitInfo.tag, hitInfo.transform);
|
||||
|
||||
if (hitRootTransform != null)
|
||||
{
|
||||
EntityAlive component;
|
||||
|
||||
if (hitRootTransform.TryGetComponent<EntityAlive>(out component) && component.IsAlive() && component.IsValidAimAssistSlowdownTarget && (double)hitInfo.hit.distanceSq <= 50.0 && (__instance.entityPlayerLocal.inventory.holdingItem.Actions[0] is ItemActionAttack || __instance.entityPlayerLocal.inventory.holdingItem.Actions[0] is ItemActionDynamicMelee))
|
||||
{
|
||||
__instance.bAimAssistTargetingItem = false;
|
||||
flag3 = true;
|
||||
}
|
||||
else if ((hitInfo.tag.StartsWith("Item", StringComparison.Ordinal) || hitRootTransform.TryGetComponent<EntityItem>(out EntityItem _)) && (double)hitInfo.hit.distanceSq <= 10.0)
|
||||
{
|
||||
__instance.bAimAssistTargetingItem = true;
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((double)__instance.entityPlayerLocal.ThreatLevel.Numeric < 0.75 && GameUtils.IsBlockOrTerrain(hitInfo.tag) && __instance.entityPlayerLocal.PlayerUI.windowManager.IsWindowOpen("interactionPrompt"))
|
||||
{
|
||||
BlockValue blockValue = hitInfo.hit.blockValue;
|
||||
|
||||
if (!blockValue.Block.isMultiBlock && !blockValue.Block.isOversized && blockValue.Block.shape is BlockShapeModelEntity)
|
||||
{
|
||||
__instance.bAimAssistTargetingItem = true;
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.aimAssistSlowAmount = !flag3 ? Mathf.MoveTowards(__instance.aimAssistSlowAmount, 1f, Time.unscaledDeltaTime * 5f) : (__instance.bAimAssistTargetingItem ? 0.6f : 0.5f);
|
||||
vector2_2 *= __instance.aimAssistSlowAmount;
|
||||
|
||||
if (__instance.controllerAimAssistsEnabled && __instance.cameraSnapTargetEntity != null && __instance.cameraSnapTargetEntity.IsAlive() && (double)Time.time - (double)__instance.cameraSnapTime < 0.30000001192092896)
|
||||
{
|
||||
Vector2 vector2_3 = Vector2.one * 0.5f;
|
||||
Vector2 vector2_4 = (Vector2)(__instance.snapTargetingHead ? __instance.entityPlayerLocal.playerCamera.WorldToViewportPoint(__instance.cameraSnapTargetEntity.emodel.GetHeadTransform().position) : __instance.entityPlayerLocal.playerCamera.WorldToViewportPoint(__instance.cameraSnapTargetEntity.GetChestTransformPosition())) - vector2_3;
|
||||
float num4 = __instance.cameraSnapMode == eCameraSnapMode.MeleeAttack ? 1.5f : 1f;
|
||||
vector2_1 += vector2_4.normalized * num4 * vector2_4.magnitude / 0.15f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vector2_2 = __instance.mouseLookSensitivity;
|
||||
Vector2 vector2_5 = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y") * (float)__instance.invertMouse);
|
||||
vector2_1 = (vector2_5 + __instance.previousMouseInput) / 2f;
|
||||
__instance.previousMouseInput = vector2_5;
|
||||
|
||||
if (__instance.playerInput.VehicleActions.Enabled)
|
||||
{
|
||||
vector2_2 *= __instance.vehicleLookSensitivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
float magnitude = vector2_1.magnitude;
|
||||
float num5 = 1f;
|
||||
|
||||
if (__instance.entityPlayerLocal.AimingGun && (double)magnitude > 0.0)
|
||||
{
|
||||
Vector2 vector2_6 = vector2_2 * __instance.mouseZoomSensitivity;
|
||||
float num6 = Mathf.Pow(magnitude * 0.4f, 2.5f) / magnitude;
|
||||
float num7 = (num5 + num6 * __instance.zoomAccel) * Mathf.Lerp(0.2f, 1f, (float)(((double)__instance.entityPlayerLocal.playerCamera.fieldOfView - 10.0) / ((double)Constants.cDefaultCameraFieldOfView - 10.0)));
|
||||
vector2_2 = vector2_6 * num7;
|
||||
|
||||
if ((double)vector2_2.magnitude > (double)__instance.mouseLookSensitivity.magnitude)
|
||||
vector2_2 = __instance.mouseLookSensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.skipMouseLookNextFrame > 0 && ((double)vector2_1.x <= -1.0 || (double)vector2_1.x >= 1.0 || (double)vector2_1.y <= -1.0 || (double)vector2_1.y >= 1.0))
|
||||
{
|
||||
--__instance.skipMouseLookNextFrame;
|
||||
vector2_1 = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
MovementInput movementInput = __instance.entityPlayerLocal.movementInput;
|
||||
|
||||
if (!movementInput.bDetachedCameraMove)
|
||||
{
|
||||
PlayerActionsLocal playerInput = __instance.playerInput;
|
||||
movementInput.moveForward = __instance.playerAutoPilotControllor == null || !__instance.playerAutoPilotControllor.IsEnabled() ? playerInput.Move.Y : __instance.playerAutoPilotControllor.GetForwardMovement();
|
||||
movementInput.moveStrafe = playerInput.Move.X;
|
||||
|
||||
if (movementInput.bCameraPositionLocked)
|
||||
vector2_1 = Vector2.zero;
|
||||
|
||||
if (PlayerMoveController.useScaledMouseLook && !__instance.entityPlayerLocal.movementInput.lastInputController)
|
||||
{
|
||||
movementInput.rotation.x += vector2_1.y * vector2_2.y * Time.unscaledDeltaTime * PlayerMoveController.mouseDeltaTimeScale;
|
||||
movementInput.rotation.y += vector2_1.x * vector2_2.x * Time.unscaledDeltaTime * PlayerMoveController.mouseDeltaTimeScale;
|
||||
}
|
||||
else if (__instance.entityPlayerLocal.movementInput.lastInputController)
|
||||
{
|
||||
movementInput.rotation.x += vector2_1.y * vector2_2.y * Time.unscaledDeltaTime * PlayerMoveController.lookDeltaTimeScale;
|
||||
movementInput.rotation.y += vector2_1.x * vector2_2.x * Time.unscaledDeltaTime * PlayerMoveController.lookDeltaTimeScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
movementInput.rotation.x += vector2_1.y * vector2_2.y;
|
||||
movementInput.rotation.y += vector2_1.x * vector2_2.x;
|
||||
}
|
||||
|
||||
bool flag4 = __instance.entityPlayerLocal.IsGodMode.Value;
|
||||
movementInput.bCameraChange = playerInput.CameraChange.IsPressed && !flag4 && !playerInput.Primary.IsPressed && !playerInput.Secondary.IsPressed;
|
||||
|
||||
if (movementInput.bCameraChange)
|
||||
{
|
||||
flag2 = true;
|
||||
|
||||
if (__instance.entityPlayerLocal.bFirstPersonView)
|
||||
{
|
||||
if ((double)num2 < 0.0)
|
||||
{
|
||||
__instance.entityPlayerLocal.SwitchFirstPersonViewFromInput();
|
||||
__instance.wasCameraChangeUsedWithWheel = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movementInput.cameraDistance = Utils.FastMin(movementInput.cameraDistance - 2f * num2, 3f);
|
||||
|
||||
if ((double)movementInput.cameraDistance < -0.20000000298023224)
|
||||
{
|
||||
movementInput.cameraDistance = -0.2f;
|
||||
__instance.entityPlayerLocal.SwitchFirstPersonViewFromInput();
|
||||
}
|
||||
|
||||
if ((double)num2 != 0.0)
|
||||
__instance.wasCameraChangeUsedWithWheel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerInput.CameraChange.WasReleased && !flag4)
|
||||
{
|
||||
if (!__instance.wasCameraChangeUsedWithWheel && !playerInput.Primary.IsPressed && !playerInput.Secondary.IsPressed)
|
||||
__instance.entityPlayerLocal.SwitchFirstPersonViewFromInput();
|
||||
|
||||
__instance.wasCameraChangeUsedWithWheel = false;
|
||||
}
|
||||
|
||||
if ((__instance.gameManager.IsEditMode() || BlockToolSelection.Instance.SelectionActive) && (Input.GetKey(KeyCode.LeftControl) || GamePrefs.GetInt(EnumGamePrefs.SelectionOperationMode) != 0))
|
||||
movementInput.Clear();
|
||||
|
||||
__instance.entityPlayerLocal.MoveByInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
float num8 = 0.15f;
|
||||
float num9 = !__instance.entityPlayerLocal.movementInput.running ? num8 * __instance.entityPlayerLocal.GodModeSpeedModifier : num8 * 3f;
|
||||
|
||||
if (__instance.playerInput.MoveForward.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position += __instance.entityPlayerLocal.cameraTransform.forward * num9;
|
||||
|
||||
if (__instance.playerInput.MoveBack.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position -= __instance.entityPlayerLocal.cameraTransform.forward * num9;
|
||||
|
||||
if (__instance.playerInput.MoveLeft.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position -= __instance.entityPlayerLocal.cameraTransform.right * num9;
|
||||
|
||||
if (__instance.playerInput.MoveRight.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position += __instance.entityPlayerLocal.cameraTransform.right * num9;
|
||||
|
||||
if (__instance.playerInput.Jump.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position += Vector3.up * num9;
|
||||
|
||||
if (__instance.playerInput.Crouch.IsPressed)
|
||||
__instance.entityPlayerLocal.cameraTransform.position -= Vector3.up * num9;
|
||||
|
||||
if (!movementInput.bCameraPositionLocked)
|
||||
{
|
||||
Vector3 localEulerAngles = __instance.entityPlayerLocal.cameraTransform.localEulerAngles;
|
||||
__instance.entityPlayerLocal.cameraTransform.localEulerAngles = new Vector3(localEulerAngles.x - vector2_1.y, localEulerAngles.y + vector2_1.x, localEulerAngles.z);
|
||||
}
|
||||
}
|
||||
|
||||
bool _bAlternativeBlockPos = __instance.gameManager.IsEditMode() && __instance.playerInput.Run.IsPressed;
|
||||
Ray ray = __instance.entityPlayerLocal.GetLookRay();
|
||||
|
||||
if (__instance.gameManager.IsEditMode() && GamePrefs.GetInt(EnumGamePrefs.SelectionOperationMode) == 4)
|
||||
{
|
||||
ray = __instance.entityPlayerLocal.cameraTransform.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
|
||||
ray.origin += Origin.position;
|
||||
}
|
||||
|
||||
ray.origin += ray.direction.normalized * 0.1f;
|
||||
float num10 = Utils.FastMax(Utils.FastMax(Constants.cDigAndBuildDistance, Constants.cCollectItemDistance), 30f);
|
||||
RaycastHit hitInfo1;
|
||||
bool flag5 = Physics.Raycast(new Ray(ray.origin - Origin.position, ray.direction), out hitInfo1, num10, 73728);
|
||||
bool flag6 = false;
|
||||
|
||||
if (flag5 && hitInfo1.transform.CompareTag("E_BP_Body"))
|
||||
flag6 = true;
|
||||
|
||||
if (flag5)
|
||||
flag5 &= hitInfo1.transform.CompareTag("Item");
|
||||
|
||||
int _hitMask1 = 69;
|
||||
bool flag7;
|
||||
|
||||
if (!__instance.gameManager.IsEditMode())
|
||||
{
|
||||
flag7 = Voxel.Raycast(__instance.gameManager.World, ray, num10, -555528213, _hitMask1, 0.0f);
|
||||
|
||||
if (flag7)
|
||||
{
|
||||
Transform hitRootTransform = GameUtils.GetHitRootTransform(Voxel.voxelRayHitInfo.tag, Voxel.voxelRayHitInfo.transform);
|
||||
Entity component;
|
||||
EntityAlive entityAlive = !(hitRootTransform != null) || !hitRootTransform.TryGetComponent<Entity>(out component) ? (EntityAlive)null : component as EntityAlive;
|
||||
|
||||
if (entityAlive == null || !entityAlive.IsDead())
|
||||
flag7 = Voxel.Raycast(__instance.gameManager.World, ray, num10, -555266069, _hitMask1, 0.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int _hitMask2 = _hitMask1 | 256;
|
||||
int _layerMask = -555266069 | 268435456;
|
||||
|
||||
if (!GameManager.bVolumeBlocksEditing)
|
||||
_layerMask = int.MinValue;
|
||||
|
||||
flag7 = Voxel.RaycastOnVoxels(__instance.gameManager.World, ray, num10, _layerMask, _hitMask2, 0.0f);
|
||||
|
||||
if (flag7 && !GameManager.bVolumeBlocksEditing)
|
||||
{
|
||||
Voxel.voxelRayHitInfo.lastBlockPos = Vector3i.zero;
|
||||
Voxel.voxelRayHitInfo.hit.voxelData.Clear();
|
||||
Voxel.voxelRayHitInfo.hit.blockPos = Vector3i.zero;
|
||||
}
|
||||
}
|
||||
|
||||
WorldRayHitInfo hitInfo2 = __instance.entityPlayerLocal.HitInfo;
|
||||
Vector3i zero = Vector3i.zero;
|
||||
Vector3i _blockPos = Vector3i.zero;
|
||||
|
||||
if (flag7)
|
||||
{
|
||||
hitInfo2.CopyFrom(Voxel.voxelRayHitInfo);
|
||||
_blockPos = hitInfo2.hit.blockPos;
|
||||
Vector3i lastBlockPos = hitInfo2.lastBlockPos;
|
||||
hitInfo2.bHitValid = true;
|
||||
}
|
||||
else
|
||||
hitInfo2.bHitValid = false;
|
||||
BlockValue blockValue1 = hitInfo2.hit.blockValue;
|
||||
|
||||
if (!blockValue1.isair)
|
||||
{
|
||||
blockValue1 = hitInfo2.hit.blockValue;
|
||||
Block block = blockValue1.Block;
|
||||
if (!block.IsCollideMovement || block.CanBlocksReplace)
|
||||
hitInfo2.lastBlockPos = _blockPos;
|
||||
}
|
||||
|
||||
float num11 = flag5 ? hitInfo1.distance : 1000f;
|
||||
|
||||
if (flag7 && GameUtils.IsBlockOrTerrain(hitInfo2.tag))
|
||||
{
|
||||
num11 -= 1.2f;
|
||||
if ((double)num11 < 0.0)
|
||||
num11 = 0.1f;
|
||||
}
|
||||
|
||||
if (flag5 && (!flag7 || flag7 && (double)num11 * (double)num11 <= (double)hitInfo2.hit.distanceSq))
|
||||
{
|
||||
hitInfo2.bHitValid = true;
|
||||
hitInfo2.tag = "Item";
|
||||
hitInfo2.transform = hitInfo1.collider.transform;
|
||||
hitInfo2.hit.pos = hitInfo1.point;
|
||||
hitInfo2.hit.blockPos = World.worldToBlockPos(hitInfo2.hit.pos);
|
||||
hitInfo2.hit.distanceSq = hitInfo1.distance * hitInfo1.distance;
|
||||
}
|
||||
|
||||
if (flag6 && (double)hitInfo1.distance * (double)hitInfo1.distance <= (double)hitInfo2.hit.distanceSq)
|
||||
{
|
||||
hitInfo2.bHitValid = true;
|
||||
hitInfo2.tag = "E_BP_Body";
|
||||
hitInfo2.transform = hitInfo1.collider.transform;
|
||||
hitInfo2.hit.pos = hitInfo1.point;
|
||||
hitInfo2.hit.blockPos = World.worldToBlockPos(hitInfo2.hit.pos);
|
||||
hitInfo2.hit.distanceSq = hitInfo1.distance * hitInfo1.distance;
|
||||
}
|
||||
|
||||
bool flag8 = true;
|
||||
EntityCollisionRules component1;
|
||||
|
||||
if ((bool)hitInfo2.hitCollider && hitInfo2.hitCollider.TryGetComponent<EntityCollisionRules>(out component1) && !component1.IsInteractable)
|
||||
flag8 = false;
|
||||
|
||||
if (__instance.entityPlayerLocal.inventory != null && __instance.entityPlayerLocal.inventory.holdingItemData != null)
|
||||
__instance.entityPlayerLocal.inventory.holdingItemData.hitInfo = __instance.entityPlayerLocal.HitInfo;
|
||||
|
||||
TileEntity _te1 = (TileEntity)null;
|
||||
EntityTurret entityTurret = (EntityTurret)null;
|
||||
bool flag9 = true;
|
||||
bool flag10 = true;
|
||||
bool flag11 = __instance.playerInput.Primary.IsPressed && __instance.bAllowPlayerInput && !__instance.IsGUICancelPressed;
|
||||
bool flag12 = __instance.playerInput.Secondary.IsPressed && __instance.bAllowPlayerInput && !__instance.IsGUICancelPressed;
|
||||
|
||||
if (flag11 && GameManager.Instance.World.IsEditor())
|
||||
{
|
||||
if (__instance.bIgnoreLeftMouseUntilReleased)
|
||||
flag11 = false;
|
||||
}
|
||||
else
|
||||
__instance.bIgnoreLeftMouseUntilReleased = false;
|
||||
|
||||
bool flag13 = false;
|
||||
ITileEntityLootable _te2 = (ITileEntityLootable)null;
|
||||
EntityItem focusedItem = (EntityItem)null;
|
||||
BlockValue _bv = BlockValue.Air;
|
||||
ProjectileMoveScript projectileMoveScript = (ProjectileMoveScript)null;
|
||||
ThrownWeaponMoveScript weaponMoveScript = (ThrownWeaponMoveScript)null;
|
||||
string str1 = (string)null;
|
||||
bool _bMeshSelected = GameManager.Instance.IsEditMode() && __instance.entityPlayerLocal.HitInfo.transform != null && __instance.entityPlayerLocal.HitInfo.transform.gameObject.layer == 28;
|
||||
Entity _entity = (Entity)null;
|
||||
|
||||
if (__instance.entityPlayerLocal.AttachedToEntity == null & flag8)
|
||||
{
|
||||
if (hitInfo2.bHitValid && (_bMeshSelected |= GameUtils.IsBlockOrTerrain(hitInfo2.tag)))
|
||||
{
|
||||
blockValue1 = hitInfo2.hit.blockValue;
|
||||
int activationDistanceSq = blockValue1.Block.GetActivationDistanceSq();
|
||||
|
||||
if ((double)hitInfo2.hit.distanceSq < (double)activationDistanceSq)
|
||||
{
|
||||
_bv = hitInfo2.hit.blockValue;
|
||||
Block block = _bv.Block;
|
||||
BlockValue _blockValue = _bv;
|
||||
Vector3i vector3i = _blockPos;
|
||||
|
||||
if (_blockValue.ischild && block != null && block.multiBlockPos != null)
|
||||
{
|
||||
vector3i = block.multiBlockPos.GetParentPos(vector3i, _blockValue);
|
||||
_blockValue = __instance.gameManager.World.GetBlock(hitInfo2.hit.clrIdx, vector3i);
|
||||
}
|
||||
|
||||
if (block.HasBlockActivationCommands((WorldBase)__instance.gameManager.World, _blockValue, hitInfo2.hit.clrIdx, vector3i, (EntityAlive)__instance.entityPlayerLocal))
|
||||
{
|
||||
str1 = block.GetActivationText((WorldBase)__instance.gameManager.World, _blockValue, hitInfo2.hit.clrIdx, vector3i, (EntityAlive)__instance.entityPlayerLocal);
|
||||
|
||||
if (str1 != null)
|
||||
{
|
||||
string str2 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(str1, (object)str2);
|
||||
}
|
||||
|
||||
_te1 = __instance.gameManager.World.GetTileEntity(hitInfo2.hit.clrIdx, _blockPos);
|
||||
}
|
||||
else if (block.DisplayInfo == Block.EnumDisplayInfo.Name)
|
||||
str1 = block.GetLocalizedBlockName();
|
||||
else if (block.DisplayInfo == Block.EnumDisplayInfo.Description)
|
||||
str1 = Localization.Get(block.DescriptionKey);
|
||||
else if (block.DisplayInfo == Block.EnumDisplayInfo.Custom)
|
||||
str1 = block.GetCustomDescription(vector3i, _bv);
|
||||
|
||||
if (flag12 && InputUtils.ShiftKeyPressed && InputUtils.AltKeyPressed && __instance.gameManager.IsEditMode())
|
||||
{
|
||||
GUIWindowEditBlockValue window = (GUIWindowEditBlockValue)__instance.windowManager.GetWindow(GUIWindowEditBlockValue.ID);
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
window.SetBlock(hitInfo2.hit.blockPos, hitInfo2.hit.blockFace);
|
||||
__instance.windowManager.Open(GUIWindowEditBlockValue.ID, true);
|
||||
flag9 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag12 && InputUtils.ShiftKeyPressed && InputUtils.AltKeyPressed && __instance.gameManager.IsEditMode() && _bv.Block is BlockSpawnEntity)
|
||||
{
|
||||
__instance.windowManager.GetWindow<GUIWindowEditBlockSpawnEntity>(GUIWindowEditBlockSpawnEntity.ID).SetBlockValue(hitInfo2.hit.blockPos, _bv);
|
||||
__instance.windowManager.Open(GUIWindowEditBlockSpawnEntity.ID, true);
|
||||
flag9 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hitInfo2.bHitValid && hitInfo2.tag.Equals("Item") && (double)hitInfo2.hit.distanceSq < (double)Constants.cCollectItemDistance * (double)Constants.cCollectItemDistance)
|
||||
{
|
||||
focusedItem = hitInfo2.transform.GetComponent<EntityItem>();
|
||||
RootTransformRefEntity component2;
|
||||
|
||||
if (focusedItem == null && (component2 = hitInfo2.transform.GetComponent<RootTransformRefEntity>()) != null && component2.RootTransform != null)
|
||||
focusedItem = component2.RootTransform.GetComponent<EntityItem>();
|
||||
|
||||
if (focusedItem != null)
|
||||
{
|
||||
if (focusedItem.onGround && focusedItem.CanCollect())
|
||||
{
|
||||
string localizedItemName = ItemClass.GetForId(focusedItem.itemStack.itemValue.type).GetLocalizedItemName();
|
||||
string str3 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = focusedItem.itemStack.count <= 1 ? string.Format(Localization.Get("itemTooltipFocusedOne"), (object)str3, (object)localizedItemName) : string.Format(Localization.Get("itemTooltipFocusedSeveral"), (object)str3, (object)localizedItemName, (object)focusedItem.itemStack.count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
projectileMoveScript = hitInfo2.transform.GetComponent<ProjectileMoveScript>();
|
||||
|
||||
if (projectileMoveScript != null)
|
||||
{
|
||||
string localizedItemName = ItemClass.GetForId(projectileMoveScript.itemValueProjectile.type).GetLocalizedItemName();
|
||||
string str4 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(Localization.Get("itemTooltipFocusedOne"), (object)str4, (object)localizedItemName);
|
||||
}
|
||||
|
||||
weaponMoveScript = hitInfo2.transform.GetComponent<ThrownWeaponMoveScript>();
|
||||
|
||||
if (weaponMoveScript != null)
|
||||
{
|
||||
string localizedItemName = ItemClass.GetForId(weaponMoveScript.itemValueWeapon.type).GetLocalizedItemName();
|
||||
string str5 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(Localization.Get("itemTooltipFocusedOne"), (object)str5, (object)localizedItemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (hitInfo2.bHitValid && hitInfo2.tag.StartsWith("E_") && (double)hitInfo2.hit.distanceSq < (double)Constants.cCollectItemDistance * (double)Constants.cCollectItemDistance)
|
||||
{
|
||||
Transform hitRootTransform = GameUtils.GetHitRootTransform(hitInfo2.tag, hitInfo2.transform);
|
||||
|
||||
if (hitRootTransform != null && (_entity = hitRootTransform.GetComponent<Entity>()) != null)
|
||||
{
|
||||
if ((projectileMoveScript = hitRootTransform.GetComponentInChildren<ProjectileMoveScript>()) != null)
|
||||
{
|
||||
if (!_entity.IsDead() && (_entity as EntityPlayer) != null && (_entity as EntityPlayer).inventory != null && (_entity as EntityPlayer).inventory.holdingItem != null && (_entity as EntityPlayer).inventory.holdingItem.HasAnyTags(PlayerMoveController.BowTag))
|
||||
projectileMoveScript = (ProjectileMoveScript)null;
|
||||
|
||||
if (_entity.IsDead())
|
||||
{
|
||||
string localizedItemName = ItemClass.GetForId(projectileMoveScript.itemValueProjectile.type).GetLocalizedItemName();
|
||||
string str6 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(Localization.Get("itemTooltipFocusedOne"), (object)str6, (object)localizedItemName);
|
||||
}
|
||||
}
|
||||
else if ((weaponMoveScript = hitRootTransform.GetComponentInChildren<ThrownWeaponMoveScript>()) != null)
|
||||
{
|
||||
if (!_entity.IsDead() && (_entity as EntityPlayer) != null && (_entity as EntityPlayer).inventory != null && (_entity as EntityPlayer).inventory.holdingItem != null && (_entity as EntityPlayer).inventory.holdingItem.HasAnyTags(PlayerMoveController.BowTag))
|
||||
weaponMoveScript = (ThrownWeaponMoveScript)null;
|
||||
|
||||
if (_entity.IsDead())
|
||||
{
|
||||
string localizedItemName = ItemClass.GetForId(weaponMoveScript.itemValueWeapon.type).GetLocalizedItemName();
|
||||
string str7 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(Localization.Get("itemTooltipFocusedOne"), (object)str7, (object)localizedItemName);
|
||||
}
|
||||
}
|
||||
// ADDED - START
|
||||
else if (_entity is EntityAnimalChickenRebirth && _entity.IsAlive())
|
||||
{
|
||||
EntityAnimalChickenRebirth EntityAnimalChickenRebirth = (EntityAnimalChickenRebirth)_entity;
|
||||
Transform hitRootTransform2 = GameUtils.GetHitRootTransform(hitInfo2.tag, hitInfo2.transform);
|
||||
Entity entityChicken = null;
|
||||
TileEntity tileEntityFocus = __instance.gameManager.World.GetTileEntity(_entity.entityId);
|
||||
|
||||
if (tileEntityFocus != null && hitRootTransform2 != null && (entityChicken = hitRootTransform2.GetComponent<Entity>()) != null)
|
||||
{
|
||||
float distanceFocus = __instance.entityPlayerLocal.GetDistance(entityChicken);
|
||||
|
||||
if (distanceFocus <= EntityAnimalChickenRebirth.flCaptureDistance)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdate-UpdatePostFix holdingItem: " + __instance.entityPlayerLocal.inventory.holdingItem.GetItemName().ToLower());
|
||||
if (EntityAnimalChickenRebirth.GetActivationCommands(tileEntityFocus.ToWorldPos(), __instance.entityPlayerLocal).Length != 0)
|
||||
{
|
||||
if (__instance.playerInput.PermanentActions.Activate.WasPressed || __instance.playerInput.Activate.IsPressed)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.inventory.holdingItem.GetItemName().ToLower() == "meleehandplayer")
|
||||
{
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetCurrentEntityData(__instance.gameManager.World, EntityAnimalChickenRebirth, tileEntityFocus, __instance.entityPlayerLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal as global::EntityPlayerLocal, Localization.Get("ttBareHands"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
//Log.Out("PlayerMoveControllerUpdate-UpdatePostFix 6");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ADDED - END
|
||||
else if (_entity is EntityNPC && _entity.IsAlive())
|
||||
{
|
||||
_te1 = (TileEntity)(__instance.gameManager.World.GetTileEntity(_entity.entityId) as TileEntityTrader);
|
||||
|
||||
if (_te1 != null)
|
||||
{
|
||||
EntityTrader entityTrader = (EntityTrader)_entity;
|
||||
string str8 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
string str9 = Localization.Get(entityTrader.EntityName);
|
||||
str1 = string.Format(Localization.Get("npcTooltipTalk"), (object)str8, (object)str9);
|
||||
entityTrader.HandleClientQuests((EntityPlayer)__instance.entityPlayerLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
_te1 = __instance.gameManager.World.GetTileEntity(_entity.entityId);
|
||||
|
||||
if (_te1 != null)
|
||||
{
|
||||
string str10 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
string str11 = Localization.Get(((EntityAlive)_entity).EntityName);
|
||||
str1 = string.Format(Localization.Get("npcTooltipTalk"), (object)str10, (object)str11);
|
||||
|
||||
// ADDITION - START Should not show the interaction prompt if the entity is hostile
|
||||
if (_entity is EntityAliveV2)
|
||||
{
|
||||
if (EntityTargetingUtilities.CanTakeDamage(__instance.entityPlayerLocal, (EntityAlive)_entity))
|
||||
{
|
||||
str1 = "";
|
||||
}
|
||||
}
|
||||
|
||||
// ADDITION - END
|
||||
if (_entity is EntityDrone)
|
||||
{
|
||||
EntityDrone entityDrone = _entity as EntityDrone;
|
||||
|
||||
if ((bool)entityDrone && entityDrone.IsLocked() && !entityDrone.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier))
|
||||
str1 = Localization.Get("ttLocked") + "\n" + str1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((_entity as EntityTurret) != null)
|
||||
{
|
||||
entityTurret = _entity as EntityTurret;
|
||||
|
||||
if (entityTurret.CanInteract(__instance.entityPlayerLocal.entityId))
|
||||
{
|
||||
string str12 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
string str13 = Localization.Get(((EntityAlive)_entity).EntityName);
|
||||
str1 = string.Format(Localization.Get("turretPickUp"), (object)str12, (object)str13);
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_entity.GetLootList()))
|
||||
{
|
||||
_te2 = __instance.gameManager.World.GetTileEntity(_entity.entityId).GetSelfOrFeature<ITileEntityLootable>();
|
||||
|
||||
if (_te2 != null)
|
||||
{
|
||||
string str14 = Localization.Get(EntityClass.list[_entity.entityClass].entityClassName);
|
||||
string str15 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
string str16 = str14;
|
||||
|
||||
switch (_entity)
|
||||
{
|
||||
case EntityNPC _ when _entity.IsAlive():
|
||||
str1 = string.Format(Localization.Get("npcTooltipTalk"), (object)str15, (object)str16);
|
||||
EntityDrone entityDrone = _entity as EntityDrone;
|
||||
|
||||
if ((bool)entityDrone && entityDrone.IsLocked() && !entityDrone.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier))
|
||||
{
|
||||
str1 = Localization.Get("ttLocked") + "\n" + str1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EntityDriveable _ when _entity.IsAlive():
|
||||
str1 = string.Format(Localization.Get("tooltipInteract"), (object)str15, (object)str16);
|
||||
if (((EntityVehicle)_entity).IsLockedForLocalPlayer((EntityAlive)__instance.entityPlayerLocal))
|
||||
{
|
||||
str1 = Localization.Get("ttLocked") + "\n" + str1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// ADDITION - START
|
||||
//Log.Out("_entity.GetLootList(): " + _entity.GetLootList());
|
||||
//Log.Out("_te2.bTouched: " + _te2.bTouched);
|
||||
//Log.Out("_te2.IsEmpty(): " + _te2.IsEmpty());
|
||||
//Log.Out("Localization.Get(lootTooltipTouched): " + Localization.Get("lootTooltipTouched"));
|
||||
//Log.Out("Localization.Get(lootTooltipEmpty): " + Localization.Get("lootTooltipEmpty"));
|
||||
//Log.Out("Localization.Get(lootTooltipNew): " + Localization.Get("lootTooltipNew"));
|
||||
//Log.Out("str15: " + str15);
|
||||
//Log.Out("str16: " + str16);
|
||||
|
||||
if (_te2.bTouched)
|
||||
{
|
||||
if (!_te2.IsEmpty())
|
||||
{
|
||||
str1 = string.Format(Localization.Get("lootTooltipTouched"), str15, str16);
|
||||
}
|
||||
else
|
||||
{
|
||||
str1 = string.Format(Localization.Get("lootTooltipEmpty"), str15, str16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_entity.IsAlive() || (!string.IsNullOrEmpty(_entity.lootListOnDeath) && _entity.IsDead()))
|
||||
{
|
||||
if (!(_entity is EntityAliveV2 && _entity.GetLootList().ToLower() == "traderNPC"))
|
||||
{
|
||||
str1 = string.Format(Localization.Get("lootTooltipNew"), str15, str16);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ADDITION - END
|
||||
|
||||
// VANILLA VALUE
|
||||
//str1 = _te2.bTouched ? (!_te2.IsEmpty() ? string.Format(Localization.Get("lootTooltipTouched"), (object)str15, (object)str16) : string.Format(Localization.Get("lootTooltipEmpty"), (object)str15, (object)str16)) : string.Format(Localization.Get("lootTooltipNew"), (object)str15, (object)str16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (str1 == null)
|
||||
{
|
||||
__instance.InteractName = (string)null;
|
||||
|
||||
if (__instance.entityPlayerLocal.IsMoveStateStill() && (!__instance.entityPlayerLocal.IsSwimming() || (double)__instance.entityPlayerLocal.cameraTransform.up.y < 0.699999988079071))
|
||||
{
|
||||
__instance.InteractName = __instance.entityPlayerLocal.inventory.CanInteract();
|
||||
|
||||
if (__instance.InteractName != null && (double)__instance.InteractWaitTime == 0.0)
|
||||
__instance.InteractWaitTime = Time.time + 0.3f;
|
||||
}
|
||||
|
||||
if (__instance.InteractName != null)
|
||||
{
|
||||
if ((double)Time.time >= (double)__instance.InteractWaitTime)
|
||||
{
|
||||
flag13 = true;
|
||||
string str17 = __instance.playerInput.Activate.GetBindingXuiMarkupString() + __instance.playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
||||
str1 = string.Format(Localization.Get("ttPressTo"), (object)str17, (object)Localization.Get(__instance.InteractName));
|
||||
}
|
||||
}
|
||||
else
|
||||
__instance.InteractWaitTime = 0.0f;
|
||||
}
|
||||
else
|
||||
__instance.InteractWaitTime = 0.0f;
|
||||
}
|
||||
|
||||
if (__instance.entityPlayerLocal.IsAlive())
|
||||
{
|
||||
if (!string.Equals(str1, __instance.strTextLabelPointingTo) && ((double)Time.time - (double)__instance.timeActivatePressed > 0.5 || string.IsNullOrEmpty(str1)))
|
||||
{
|
||||
XUiC_InteractionPrompt.SetText(__instance.playerUI, str1);
|
||||
__instance.strTextLabelPointingTo = str1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.strTextLabelPointingTo = "";
|
||||
XUiC_InteractionPrompt.SetText(__instance.playerUI, (string)null);
|
||||
}
|
||||
|
||||
__instance.FocusBoxPosition = hitInfo2.lastBlockPos;
|
||||
|
||||
if (_bAlternativeBlockPos || __instance.entityPlayerLocal.inventory != null && __instance.entityPlayerLocal.inventory.holdingItem.IsFocusBlockInside())
|
||||
__instance.FocusBoxPosition = _blockPos;
|
||||
|
||||
__instance.focusBoxScript.Update(_bMeshSelected, __instance.gameManager.World, hitInfo2, __instance.FocusBoxPosition, (EntityAlive)__instance.entityPlayerLocal, __instance.gameManager.persistentLocalPlayer, _bAlternativeBlockPos);
|
||||
|
||||
if (!__instance.windowManager.IsInputActive() && !__instance.windowManager.IsFullHUDDisabled() && (__instance.playerInput.Activate.IsPressed || __instance.playerInput.VehicleActions.Activate.IsPressed || __instance.playerInput.PermanentActions.Activate.IsPressed))
|
||||
{
|
||||
if (__instance.playerInput.Activate.WasPressed || __instance.playerInput.VehicleActions.Activate.WasPressed || __instance.playerInput.PermanentActions.Activate.WasPressed)
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
|
||||
if (flag13 && hitInfo2.bHitValid && GameUtils.IsBlockOrTerrain(hitInfo2.tag))
|
||||
_bv = BlockValue.Air;
|
||||
|
||||
if (__instance.entityPlayerLocal.AttachedToEntity != null)
|
||||
__instance.entityPlayerLocal.SendDetach();
|
||||
else if (entityTurret != null || projectileMoveScript != null || weaponMoveScript != null || focusedItem != null || !_bv.isair || _te2 != null || _te1 != null)
|
||||
{
|
||||
BlockValue _blockValue = _bv;
|
||||
Vector3i vector3i = _blockPos;
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
vector3i = _blockValue.Block.multiBlockPos.GetParentPos(vector3i, _blockValue);
|
||||
_blockValue = __instance.gameManager.World.GetBlock(hitInfo2.hit.clrIdx, vector3i);
|
||||
}
|
||||
|
||||
if (!_blockValue.Equals(BlockValue.Air) && _blockValue.Block.HasBlockActivationCommands((WorldBase)__instance.gameManager.World, _blockValue, hitInfo2.hit.clrIdx, vector3i, (EntityAlive)__instance.entityPlayerLocal))
|
||||
{
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetCurrentBlockData((WorldBase)__instance.gameManager.World, vector3i, hitInfo2.hit.clrIdx, _blockValue, __instance.entityPlayerLocal);
|
||||
flag9 = true;
|
||||
}
|
||||
else if (_te2 != null && _entity.GetActivationCommands(_te2.ToWorldPos(), (EntityAlive)__instance.entityPlayerLocal).Length != 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
_te2.bWasTouched = _te2.bTouched;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetCurrentEntityData((WorldBase)__instance.gameManager.World, _entity, (ITileEntity)_te2, (EntityAlive)__instance.entityPlayerLocal);
|
||||
flag9 = true;
|
||||
}
|
||||
else if (_te1 != null && _entity.GetActivationCommands(_te1.ToWorldPos(), (EntityAlive)__instance.entityPlayerLocal).Length != 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetCurrentEntityData((WorldBase)__instance.gameManager.World, _entity, (ITileEntity)_te1, (EntityAlive)__instance.entityPlayerLocal);
|
||||
flag9 = true;
|
||||
}
|
||||
else if (entityTurret != null)
|
||||
{
|
||||
if (entityTurret.CanInteract(__instance.entityPlayerLocal.entityId))
|
||||
{
|
||||
ItemStack _itemStack = new ItemStack(entityTurret.OriginalItemValue, 1);
|
||||
if (__instance.entityPlayerLocal.inventory.CanTakeItem(_itemStack) || __instance.entityPlayerLocal.bag.CanTakeItem(_itemStack))
|
||||
__instance.gameManager.CollectEntityServer(entityTurret.entityId, __instance.playerUI.entityPlayer.entityId);
|
||||
else
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal, Localization.Get("xuiInventoryFullForPickup"), string.Empty, "ui_denied");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.windowManager.Close("radial");
|
||||
if (focusedItem != null)
|
||||
{
|
||||
EntityItem entityItem = focusedItem;
|
||||
if (entityItem != null && entityItem.CanCollect() && entityItem.onGround)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.inventory.CanTakeItem(entityItem.itemStack) || __instance.entityPlayerLocal.bag.CanTakeItem(entityItem.itemStack))
|
||||
__instance.gameManager.CollectEntityServer(focusedItem.entityId, __instance.entityPlayerLocal.entityId);
|
||||
else
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal, Localization.Get("xuiInventoryFullForPickup"), string.Empty, "ui_denied");
|
||||
}
|
||||
}
|
||||
else if (projectileMoveScript != null)
|
||||
{
|
||||
if (projectileMoveScript.itemProjectile.IsSticky)
|
||||
{
|
||||
ItemStack _itemStack = new ItemStack(projectileMoveScript.itemValueProjectile, 1);
|
||||
if (__instance.entityPlayerLocal.inventory.CanTakeItem(_itemStack) || __instance.entityPlayerLocal.bag.CanTakeItem(_itemStack))
|
||||
{
|
||||
__instance.playerUI.xui.PlayerInventory.AddItem(_itemStack);
|
||||
projectileMoveScript.ProjectileID = -1;
|
||||
UnityEngine.Object.Destroy(projectileMoveScript.gameObject);
|
||||
}
|
||||
else
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal, Localization.Get("xuiInventoryFullForPickup"), string.Empty, "ui_denied");
|
||||
}
|
||||
}
|
||||
else if (weaponMoveScript != null)
|
||||
{
|
||||
if (weaponMoveScript.itemWeapon.IsSticky)
|
||||
{
|
||||
ItemStack _itemStack = new ItemStack(weaponMoveScript.itemValueWeapon, 1);
|
||||
if (__instance.entityPlayerLocal.inventory.CanTakeItem(_itemStack) || __instance.entityPlayerLocal.bag.CanTakeItem(_itemStack))
|
||||
{
|
||||
__instance.playerUI.xui.PlayerInventory.AddItem(_itemStack);
|
||||
weaponMoveScript.ProjectileID = -1;
|
||||
UnityEngine.Object.Destroy(weaponMoveScript.gameObject);
|
||||
}
|
||||
else
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal, Localization.Get("xuiInventoryFullForPickup"), string.Empty, "ui_denied");
|
||||
}
|
||||
}
|
||||
else
|
||||
__instance.suckItemsNearby(focusedItem);
|
||||
}
|
||||
}
|
||||
else if (flag13)
|
||||
__instance.entityPlayerLocal.inventory.Interact();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.windowManager.Close("radial");
|
||||
__instance.suckItemsNearby(focusedItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.gameManager.IsEditMode() & flag11 & flag10 && !__instance.playerInput.Drop.IsPressed)
|
||||
{
|
||||
WorldRayHitInfo _other = Voxel.voxelRayHitInfo.Clone();
|
||||
int _hitMask3 = 325;
|
||||
int minValue = int.MinValue;
|
||||
|
||||
if (Voxel.RaycastOnVoxels(__instance.gameManager.World, ray, 250f, minValue, _hitMask3, 0.0f) && SelectionBoxManager.Instance.Select(Voxel.voxelRayHitInfo))
|
||||
{
|
||||
flag10 = false;
|
||||
__instance.bIgnoreLeftMouseUntilReleased = true;
|
||||
}
|
||||
|
||||
Voxel.voxelRayHitInfo.CopyFrom(_other);
|
||||
}
|
||||
|
||||
if (flag11 && (GameManager.Instance.World.IsEditor() || BlockToolSelection.Instance.SelectionActive))
|
||||
flag11 &= !__instance.playerInput.Drop.IsPressed;
|
||||
|
||||
int _idx = __instance.playerInput.InventorySlotWasPressed;
|
||||
|
||||
if (_idx >= 0)
|
||||
{
|
||||
if (__instance.playerInput.LastInputType == BindingSourceType.DeviceBindingSource)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.AimingGun)
|
||||
_idx = -1;
|
||||
}
|
||||
else if (InputUtils.ShiftKeyPressed && __instance.entityPlayerLocal.inventory.PUBLIC_SLOTS > __instance.entityPlayerLocal.inventory.SHIFT_KEY_SLOT_OFFSET)
|
||||
{
|
||||
if (RebirthVariables.customShiftToolbelt)
|
||||
{
|
||||
_idx += __instance.entityPlayerLocal.inventory.SHIFT_KEY_SLOT_OFFSET;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.inventoryScrollPressed && __instance.inventoryScrollIdxToSelect != -1)
|
||||
_idx = __instance.inventoryScrollIdxToSelect;
|
||||
|
||||
if (!flag2)
|
||||
flag2 = __instance.entityPlayerLocal.inventory.holdingItem.ConsumeScrollWheel(__instance.entityPlayerLocal.inventory.holdingItemData, num2, __instance.playerInput);
|
||||
|
||||
__instance.entityPlayerLocal.inventory.holdingItem.CheckKeys(__instance.entityPlayerLocal.inventory.holdingItemData, hitInfo2);
|
||||
ItemClass holdingItem = __instance.entityPlayerLocal.inventory.holdingItem;
|
||||
bool flag14 = holdingItem.Actions[0] != null && holdingItem.Actions[0].AllowConcurrentActions() || holdingItem.Actions[1] != null && holdingItem.Actions[1].AllowConcurrentActions();
|
||||
bool flag15 = holdingItem.Actions[1] != null && holdingItem.Actions[1].IsActionRunning(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[1]);
|
||||
|
||||
if (flag10 & flag11 && (flag14 || !flag15))
|
||||
{
|
||||
if (__instance.gameManager.IsEditMode())
|
||||
flag10 = !__instance.gameManager.GetActiveBlockTool().ExecuteAttackAction(__instance.entityPlayerLocal.inventory.holdingItemData, false, __instance.playerInput);
|
||||
|
||||
if (flag10)
|
||||
__instance.entityPlayerLocal.inventory.Execute(0, false, __instance.playerInput);
|
||||
}
|
||||
|
||||
if (flag10 && __instance.playerInput.Primary.WasReleased)
|
||||
{
|
||||
if (__instance.gameManager.IsEditMode() && !__instance.entityPlayerLocal.inventory.holdingItem.IsGun())
|
||||
flag10 = !__instance.gameManager.GetActiveBlockTool().ExecuteAttackAction(__instance.entityPlayerLocal.inventory.holdingItemData, true, __instance.playerInput);
|
||||
|
||||
if (flag10)
|
||||
__instance.entityPlayerLocal.inventory.Execute(0, true, __instance.playerInput);
|
||||
}
|
||||
|
||||
ItemAction action1 = __instance.entityPlayerLocal.inventory.holdingItem.Actions[0];
|
||||
bool flag16 = action1 != null && action1.IsActionRunning(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[0]);
|
||||
|
||||
if (flag9 & flag12 && (flag14 || !flag16))
|
||||
{
|
||||
if (__instance.gameManager.IsEditMode())
|
||||
flag9 = !__instance.gameManager.GetActiveBlockTool().ExecuteUseAction(__instance.entityPlayerLocal.inventory.holdingItemData, false, __instance.playerInput);
|
||||
|
||||
if (flag9)
|
||||
__instance.entityPlayerLocal.inventory.Execute(1, false, __instance.playerInput);
|
||||
}
|
||||
|
||||
if (flag9 && __instance.playerInput.Secondary.WasReleased && __instance.entityPlayerLocal.inventory != null)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.Execute(1, true, __instance.playerInput);
|
||||
|
||||
if (__instance.gameManager.IsEditMode() && !__instance.entityPlayerLocal.inventory.holdingItem.IsGun())
|
||||
__instance.gameManager.GetActiveBlockTool().ExecuteUseAction(__instance.entityPlayerLocal.inventory.holdingItemData, true, __instance.playerInput);
|
||||
}
|
||||
|
||||
if (__instance.playerInput.Drop.WasPressed && !__instance.gameManager.IsEditMode() && !BlockToolSelection.Instance.SelectionActive && __instance.entityPlayerLocal.inventory != null && !__instance.entityPlayerLocal.inventory.IsHoldingItemActionRunning() && !__instance.entityPlayerLocal.inventory.IsHolsterDelayActive() && !__instance.entityPlayerLocal.inventory.IsUnholsterDelayActive() && __instance.entityPlayerLocal.inventory.holdingItemIdx != __instance.entityPlayerLocal.inventory.DUMMY_SLOT_IDX && !__instance.entityPlayerLocal.AimingGun && _idx == -1 && !flag2)
|
||||
{
|
||||
Vector3 dropPosition = __instance.entityPlayerLocal.GetDropPosition();
|
||||
ItemValue holdingItemItemValue = __instance.entityPlayerLocal.inventory.holdingItemItemValue;
|
||||
|
||||
if (ItemClass.GetForId(holdingItemItemValue.type).CanDrop(holdingItemItemValue) && __instance.entityPlayerLocal.inventory.holdingCount > 0 && (double)__instance.entityPlayerLocal.DropTimeDelay <= 0.0)
|
||||
{
|
||||
__instance.entityPlayerLocal.DropTimeDelay = 0.5f;
|
||||
int count = __instance.entityPlayerLocal.inventory.holdingItemStack.count;
|
||||
__instance.gameManager.ItemDropServer(__instance.entityPlayerLocal.inventory.holdingItemStack.Clone(), dropPosition, Vector3.zero, __instance.entityPlayerLocal.entityId, ItemClass.GetForId(holdingItemItemValue.type).GetLifetimeOnDrop(), false);
|
||||
__instance.entityPlayerLocal.AddUIHarvestingItem(new ItemStack(holdingItemItemValue, -count), false);
|
||||
Manager.BroadcastPlay((Entity)__instance.entityPlayerLocal, "itemdropped");
|
||||
__instance.entityPlayerLocal.inventory.DecHoldingItem(count);
|
||||
}
|
||||
}
|
||||
|
||||
bool flag17 = __instance.playerInput.InventorySlotLeft.WasPressed || __instance.playerInput.InventorySlotRight.WasPressed || __instance.inventoryScrollPressed;
|
||||
__instance.inventoryScrollPressed = false;
|
||||
|
||||
if (__instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
if (_idx != -1 && _idx != __instance.entityPlayerLocal.inventory.GetFocusedItemIdx() && _idx < __instance.entityPlayerLocal.inventory.PUBLIC_SLOTS && __instance.entityPlayerLocal.inventory != null)
|
||||
{
|
||||
if (__instance.entityPlayerLocal.inventory.GetHoldingGun() is ItemActionRanged holdingGun)
|
||||
holdingGun.CancelReload(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[0]);
|
||||
else if (__instance.entityPlayerLocal.inventory.holdingItem.Actions[1] is ItemActionActivate action2)
|
||||
action2.CancelAction(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[1]);
|
||||
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
__instance.inventoryItemToSetAfterTimeout = __instance.entityPlayerLocal.inventory.SetFocusedItemIdx(_idx);
|
||||
__instance.inventoryItemSwitchTimeout = flag17 ? 0.3f : 0.0f;
|
||||
}
|
||||
|
||||
if ((double)__instance.inventoryItemSwitchTimeout > 0.0)
|
||||
__instance.inventoryItemSwitchTimeout -= Time.deltaTime;
|
||||
|
||||
Inventory inventory = __instance.entityPlayerLocal.inventory;
|
||||
|
||||
if (__instance.inventoryItemToSetAfterTimeout != int.MinValue && (double)__instance.inventoryItemSwitchTimeout <= 0.0 && inventory != null)
|
||||
{
|
||||
if (inventory.IsHoldingItemActionRunning())
|
||||
{
|
||||
if (inventory.GetHoldingGun() is ItemActionRanged holdingGun1)
|
||||
holdingGun1.CancelReload(inventory.holdingItemData.actionData[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.AimingGun = false;
|
||||
inventory.SetHoldingItemIdx(__instance.inventoryItemToSetAfterTimeout);
|
||||
__instance.inventoryItemToSetAfterTimeout = int.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((__instance.playerInput.Reload.WasPressed || __instance.playerInput.PermanentActions.Reload.WasPressed) && __instance.entityPlayerLocal.inventory != null)
|
||||
{
|
||||
int num12 = __instance.entityPlayerLocal.inventory.IsHoldingGun() ? 1 : (__instance.entityPlayerLocal.inventory.IsHoldingDynamicMelee() ? 1 : 0);
|
||||
ItemAction holdingPrimary = __instance.entityPlayerLocal.inventory.GetHoldingPrimary();
|
||||
ItemAction holdingSecondary = __instance.entityPlayerLocal.inventory.GetHoldingSecondary();
|
||||
|
||||
if (num12 != 0 && holdingPrimary != null)
|
||||
{
|
||||
if (holdingPrimary.HasRadial())
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
holdingPrimary.SetupRadial(__instance.playerUI.xui.RadialWindow, __instance.entityPlayerLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
holdingPrimary.CancelAction(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[0]);
|
||||
|
||||
switch (holdingSecondary)
|
||||
{
|
||||
case null:
|
||||
case ItemActionSpawnTurret _:
|
||||
break;
|
||||
|
||||
default:
|
||||
holdingSecondary.CancelAction(__instance.entityPlayerLocal.inventory.holdingItemData.actionData[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (__instance.entityPlayerLocal.inventory.GetHoldingBlock() != null)
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetupBlockShapeData();
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.playerInput.ToggleFlashlight.WasPressed || __instance.playerInput.PermanentActions.ToggleFlashlight.WasPressed)
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetActivatableItemData(__instance.entityPlayerLocal);
|
||||
}
|
||||
|
||||
if (__instance.playerInput.Swap.WasPressed || __instance.playerInput.PermanentActions.Swap.WasPressed)
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetupToolbeltMenu(0);
|
||||
}
|
||||
|
||||
if (!flag2 && __instance.playerInput.InventorySlotRight.WasPressed)
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetupToolbeltMenu(1);
|
||||
}
|
||||
|
||||
if (flag2 || !__instance.playerInput.InventorySlotLeft.WasPressed)
|
||||
return false;
|
||||
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetupToolbeltMenu(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(__instance.entityPlayerLocal.AttachedToEntity is EntityVehicle attachedToEntity))
|
||||
return false;
|
||||
|
||||
if (__instance.playerInput.PermanentActions.ToggleFlashlight.WasPressed || __instance.playerInput.VehicleActions.ToggleFlashlight.WasPressed)
|
||||
{
|
||||
if (attachedToEntity.HasHeadlight())
|
||||
{
|
||||
attachedToEntity.ToggleHeadlight();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.timeActivatePressed = Time.time;
|
||||
__instance.playerUI.xui.RadialWindow.Open();
|
||||
__instance.playerUI.xui.RadialWindow.SetActivatableItemData(__instance.entityPlayerLocal);
|
||||
}
|
||||
}
|
||||
|
||||
if (!__instance.playerInput.VehicleActions.HonkHorn.WasPressed)
|
||||
return false;
|
||||
|
||||
attachedToEntity.UseHorn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CheckPlayerActions(PlayerMoveController __instance, LocalPlayerUI ___playerUI, EntityPlayerLocal ___entityPlayerLocal)
|
||||
{
|
||||
if (!RebirthVariables.loaded)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions START");
|
||||
float flActionInProgress = RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"];
|
||||
|
||||
if (__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() || flActionInProgress == 1)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 1");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isReloading = false;
|
||||
if (__instance.entityPlayerLocal.inventory.holdingItem.Actions[0] is ItemActionRanged)
|
||||
{
|
||||
if (((ItemActionRanged.ItemActionDataRanged)__instance.entityPlayerLocal.inventory.holdingItemData.actionData[0]).isReloading)
|
||||
{
|
||||
isReloading = true;
|
||||
}
|
||||
}
|
||||
|
||||
//if (__instance.playerInput.Run.IsPressed && Input.GetKeyDown(KeyCode.H))
|
||||
if (Input.GetKeyDown(KeyCode.End) && __instance.entityPlayerLocal.AttachedToEntity == null && !isReloading)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 2");
|
||||
RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"] = 1;
|
||||
|
||||
float useQuickHeal = 1;
|
||||
|
||||
if (useQuickHeal == 0)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal as global::EntityPlayerLocal, Localization.Get("ttNoQuickHeal"), string.Empty, "ui_denied", null);
|
||||
RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"] = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ProgressionValue healingProgressionValue = __instance.entityPlayerLocal.Progression.GetProgressionValue("perkHealingFactor");
|
||||
float perkHealingFactor = RebirthUtilities.GetCalculatedLevel(__instance.entityPlayerLocal, healingProgressionValue);
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions perkHealingFactor: " + perkHealingFactor);
|
||||
|
||||
if (perkHealingFactor == 0)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions healing factor == null");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal as global::EntityPlayerLocal, Localization.Get("ttNoHealingFactor"), string.Empty, "ui_denied", null);
|
||||
RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"] = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int healedAmount = 0;
|
||||
int playerMaxHealth = __instance.entityPlayerLocal.GetMaxHealth();
|
||||
int playerHealth = __instance.entityPlayerLocal.Health;
|
||||
int playerHealthModifier = (int)Math.Floor(__instance.entityPlayerLocal.Stats.Health.MaxModifier);
|
||||
|
||||
int missingHealth = playerMaxHealth - playerHealth - healedAmount + playerHealthModifier;
|
||||
|
||||
bool bHealing = __instance.entityPlayerLocal.Buffs.HasBuff("buffHealHealth");
|
||||
float numHealing = __instance.entityPlayerLocal.Buffs.GetCustomVar("medicalRegHealthAmount");
|
||||
|
||||
float numHealingLeft = missingHealth - numHealing;
|
||||
|
||||
bool bBandageSound = false;
|
||||
bool bPillSound = false;
|
||||
bool bEatSound = false;
|
||||
bool bDrinkSound = false;
|
||||
bool foundHealingMeds = false;
|
||||
|
||||
bool bInfected = __instance.entityPlayerLocal.Buffs.HasBuff("buffInfectionMain");
|
||||
|
||||
float percInfection = __instance.entityPlayerLocal.Buffs.GetCustomVar(".infectionDisplayPerc");
|
||||
float percInfectionCure = __instance.entityPlayerLocal.Buffs.GetCustomVar(".infectionCureDisplayPerc");
|
||||
float perTotalInfection = percInfection - percInfectionCure;
|
||||
|
||||
float counterInfectionCure = __instance.entityPlayerLocal.Buffs.GetCustomVar("$infectionCureCounter");
|
||||
|
||||
float healingLeft = __instance.entityPlayerLocal.Buffs.GetCustomVar("medicalRegHealthAmount");
|
||||
|
||||
bool restrictiveHealing = RebirthVariables.customRestrictiveHealing && healingLeft > 10 && !__instance.entityPlayerLocal.Buffs.HasBuff("buffInjuryBleeding");
|
||||
bool restritedHealing = false;
|
||||
|
||||
bool isOnFire = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayFireZombieDamage") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("buffBurningFlamingArrow") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("buffBurningMolotov") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("buffBurningElement") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("buffIsOnFire") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayFireZombieAoEDamage") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayAddBurningEnemyBoss") ||
|
||||
__instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayBurningTrapDamage")
|
||||
;
|
||||
|
||||
if (isOnFire && perkHealingFactor > 0)
|
||||
{
|
||||
ItemValue itemMurkyWater = ItemClass.GetItem("drinkJarRiverWater", false);
|
||||
ItemClass itemClassMurkyWater = itemMurkyWater.ItemClass;
|
||||
int itemCountMurkyWater = __instance.entityPlayerLocal.bag.GetItemCount(itemMurkyWater, -1, -1, false);
|
||||
int itemCount2MurkyWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemMurkyWater, false, -1, -1);
|
||||
if (itemClassMurkyWater != null)
|
||||
{
|
||||
itemCountMurkyWater = __instance.entityPlayerLocal.bag.GetItemCount(itemMurkyWater, -1, -1, false);
|
||||
itemCount2MurkyWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemMurkyWater, false, -1, -1);
|
||||
}
|
||||
|
||||
ItemValue itemBoiledWater = ItemClass.GetItem("drinkJarBoiledWater", false);
|
||||
ItemClass itemClassBoiledWater = itemBoiledWater.ItemClass;
|
||||
int itemCountBoiledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemBoiledWater, -1, -1, false);
|
||||
int itemCount2BoiledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemBoiledWater, false, -1, -1);
|
||||
if (itemClassBoiledWater != null)
|
||||
{
|
||||
itemCountBoiledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemBoiledWater, -1, -1, false);
|
||||
itemCount2BoiledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemBoiledWater, false, -1, -1);
|
||||
}
|
||||
|
||||
ItemValue itemDistilledWater = ItemClass.GetItem("drinkJarPureMineralWater", false);
|
||||
ItemClass itemClassDistilledWater = itemDistilledWater.ItemClass;
|
||||
int itemCountDistilledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemDistilledWater, -1, -1, false);
|
||||
int itemCount2DistilledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemDistilledWater, false, -1, -1);
|
||||
if (itemClassDistilledWater != null)
|
||||
{
|
||||
itemCountDistilledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemDistilledWater, -1, -1, false);
|
||||
itemCount2DistilledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemDistilledWater, false, -1, -1);
|
||||
}
|
||||
|
||||
if ((itemCountMurkyWater + itemCount2MurkyWater) > 0)
|
||||
{
|
||||
if (itemCount2MurkyWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMurkyWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMurkyWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMurkyWater, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("buffExtinguishFire");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
|
||||
bDrinkSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((itemCountBoiledWater + itemCount2BoiledWater) > 0)
|
||||
{
|
||||
if (itemCount2BoiledWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemBoiledWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemBoiledWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemBoiledWater, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("buffExtinguishFire");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
|
||||
bDrinkSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((itemCountDistilledWater + itemCount2DistilledWater) > 0)
|
||||
{
|
||||
if (itemCount2DistilledWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemDistilledWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemDistilledWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemDistilledWater, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("buffExtinguishFire");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
|
||||
bDrinkSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("Percentage Infection: " + percInfection);
|
||||
//Log.Out("Percentage Infection Cure: " + percInfectionCure);
|
||||
//Log.Out("Percentage Total Infection: " + perTotalInfection);
|
||||
//Log.Out("HEALING FACTOR: " + perkHealingFactor);
|
||||
|
||||
if (perTotalInfection > 0 && perkHealingFactor > 0)
|
||||
{
|
||||
//Log.Out("INFECTED");
|
||||
|
||||
ItemValue itemHoney = ItemClass.GetItem("foodHoney", false);
|
||||
ItemClass itemClassHoney = itemHoney.ItemClass;
|
||||
int itemCountHoney = __instance.entityPlayerLocal.bag.GetItemCount(itemHoney, -1, -1, false);
|
||||
int itemCount2Honey = __instance.entityPlayerLocal.inventory.GetItemCount(itemHoney, false, -1, -1);
|
||||
if (itemClassHoney != null)
|
||||
{
|
||||
itemCountHoney = __instance.entityPlayerLocal.bag.GetItemCount(itemHoney, -1, -1, false);
|
||||
itemCount2Honey = __instance.entityPlayerLocal.inventory.GetItemCount(itemHoney, false, -1, -1);
|
||||
}
|
||||
ItemValue itemHerbalAntibiotics = ItemClass.GetItem("drugHerbalAntibiotics", false);
|
||||
ItemClass itemClassHerbalAntibiotics = itemHerbalAntibiotics.ItemClass;
|
||||
int itemCountHerbalAntibiotics = __instance.entityPlayerLocal.bag.GetItemCount(itemHerbalAntibiotics, -1, -1, false);
|
||||
int itemCount2HerbalAntibiotics = __instance.entityPlayerLocal.inventory.GetItemCount(itemHerbalAntibiotics, false, -1, -1);
|
||||
if (itemClassHerbalAntibiotics != null)
|
||||
{
|
||||
itemCountHerbalAntibiotics = __instance.entityPlayerLocal.bag.GetItemCount(itemHerbalAntibiotics, -1, -1, false);
|
||||
itemCount2HerbalAntibiotics = __instance.entityPlayerLocal.inventory.GetItemCount(itemHerbalAntibiotics, false, -1, -1);
|
||||
}
|
||||
ItemValue itemAntibiotics = ItemClass.GetItem("drugAntibiotics", false);
|
||||
ItemClass itemClassAntibiotics = itemAntibiotics.ItemClass;
|
||||
int itemCountAntibiotics = __instance.entityPlayerLocal.bag.GetItemCount(itemAntibiotics, -1, -1, false);
|
||||
int itemCount2Antibiotics = __instance.entityPlayerLocal.inventory.GetItemCount(itemAntibiotics, false, -1, -1);
|
||||
if (itemClassAntibiotics != null)
|
||||
{
|
||||
itemCountAntibiotics = __instance.entityPlayerLocal.bag.GetItemCount(itemAntibiotics, -1, -1, false);
|
||||
itemCount2Antibiotics = __instance.entityPlayerLocal.inventory.GetItemCount(itemAntibiotics, false, -1, -1);
|
||||
}
|
||||
|
||||
//Log.Out("Honey: " + (itemCountHoney+ itemCount2Honey));
|
||||
//Log.Out("Herbal Antibiotics: " + (itemCountHerbalAntibiotics + itemCount2HerbalAntibiotics));
|
||||
//Log.Out("Antibiotics: " + (itemCountAntibiotics + itemCount2Antibiotics));
|
||||
|
||||
if ((percInfection < 5) && ((itemCountHoney + itemCount2Honey) > 0) && perkHealingFactor > 0)
|
||||
{
|
||||
if (itemCount2Honey > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemHoney, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemHoney, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemHoney, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayFoodHoneyTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassHoney.ItemTags);
|
||||
bInfected = false;
|
||||
bEatSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((percInfection >= 5 && percInfection < 10) && ((itemCountHerbalAntibiotics + itemCount2HerbalAntibiotics) > 0) && perkHealingFactor >= 2)
|
||||
{
|
||||
if (itemCount2HerbalAntibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemHerbalAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugHerbalAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassHerbalAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((percInfection >= 10) && ((itemCountAntibiotics + itemCount2Antibiotics) > 0) && perkHealingFactor >= 3)
|
||||
{
|
||||
if (itemCount2Antibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((percInfection < 5) && ((itemCountHerbalAntibiotics + itemCount2HerbalAntibiotics) > 0) && perkHealingFactor >= 2)
|
||||
{
|
||||
if (itemCount2HerbalAntibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemHerbalAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugHerbalAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassHerbalAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((percInfection >= 5 && percInfection < 10) && ((itemCountAntibiotics + itemCount2Antibiotics) > 0) && perkHealingFactor >= 3)
|
||||
{
|
||||
if (itemCount2Antibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((percInfection < 5) && ((itemCountAntibiotics + itemCount2Antibiotics) > 0) && perkHealingFactor >= 3)
|
||||
{
|
||||
if (itemCount2Antibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if (percInfection >= 5 && ((itemCountHerbalAntibiotics + itemCount2HerbalAntibiotics) > 0) && ((itemCountAntibiotics + itemCount2Antibiotics) == 0) && ((itemCountHoney + itemCount2Honey) == 0) && perkHealingFactor >= 2)
|
||||
{
|
||||
if (itemCount2HerbalAntibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemHerbalAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemHerbalAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugHerbalAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassHerbalAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if (percInfection >= 5 && ((itemCountHerbalAntibiotics + itemCount2HerbalAntibiotics) == 0) && ((itemCountAntibiotics + itemCount2Antibiotics) > 0) && ((itemCountHoney + itemCount2Honey) == 0) && perkHealingFactor >= 3)
|
||||
{
|
||||
if (itemCount2Antibiotics > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemAntibiotics, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemAntibiotics, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugAntibioticsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassAntibiotics.ItemTags);
|
||||
bInfected = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
else if ((itemCountHoney + itemCount2Honey) > 0 && perkHealingFactor > 0)
|
||||
{
|
||||
if (itemCount2Honey > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemHoney, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemHoney, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemHoney, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayFoodHoneyTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassHoney.ItemTags);
|
||||
bInfected = false;
|
||||
bEatSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
bool bFatigued = __instance.entityPlayerLocal.Buffs.HasBuff("buffFatigued");
|
||||
if (bFatigued && perkHealingFactor >= 3)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("drugVitamins", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugVitaminsTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
bFatigued = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool bRadiated = __instance.entityPlayerLocal.Buffs.HasBuff("buffRadiationMain");
|
||||
bool bHasRadiationCure = __instance.entityPlayerLocal.Buffs.HasBuff("buffRadiationCureDisplay");
|
||||
|
||||
if (bRadiated && !bHasRadiationCure && perkHealingFactor >= 3)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("FuriousRamsayDrinkPrussianBlue", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugPrussianBlueTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
bRadiated = false;
|
||||
bDrinkSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool bArmBroken = __instance.entityPlayerLocal.Buffs.HasBuff("buffArmBroken");
|
||||
bool bLegBroken = __instance.entityPlayerLocal.Buffs.HasBuff("buffLegBroken");
|
||||
if ((bArmBroken || bLegBroken) && perkHealingFactor >= 3)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("medicalPlasterCast", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalPlasterCastTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
bArmBroken = false;
|
||||
bLegBroken = false;
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((bArmBroken || bLegBroken) && perkHealingFactor >= 2)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("medicalSplint", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalSplintTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
bArmBroken = false;
|
||||
bLegBroken = false;
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bLaceration = __instance.entityPlayerLocal.Buffs.HasBuff("buffLaceration");
|
||||
bool bBleeding = __instance.entityPlayerLocal.Buffs.HasBuff("buffInjuryBleeding");
|
||||
if (bLaceration && perkHealingFactor >= 2)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("resourceSewingKit", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsaySewingKitTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
bLaceration = false;
|
||||
bBleeding = false;
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool bAbrasion = __instance.entityPlayerLocal.Buffs.HasBuff("buffInjuryAbrasion");
|
||||
bool MedicalBandage = false;
|
||||
if ((bBleeding & bAbrasion) && perkHealingFactor > 0)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("medicalFirstAidBandage", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
healedAmount = healedAmount + 20;
|
||||
bAbrasion = false;
|
||||
bBleeding = false;
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
MedicalBandage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool AloeCream = false;
|
||||
if (bAbrasion && perkHealingFactor > 0)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("medicalAloeCream", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayAloeCreamTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
healedAmount = healedAmount + 5;
|
||||
bAbrasion = false;
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
AloeCream = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bConcussion = __instance.entityPlayerLocal.Buffs.HasBuff("buffInjuryConcussion");
|
||||
bool bPainKillers = __instance.entityPlayerLocal.Buffs.HasBuff("buffDrugPainkillers");
|
||||
bool bUserPainkillers = false;
|
||||
if ((bConcussion && !bPainKillers) && perkHealingFactor >= 2 && !bBleeding)
|
||||
{
|
||||
//Log.Out("HEALING C");
|
||||
ItemValue item = ItemClass.GetItem("drugPainkillers", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugPainkillersTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
healedAmount = healedAmount + 40;
|
||||
bConcussion = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
bUserPainkillers = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int numAloeCream = 0; // 10 health
|
||||
int numMedicalBandages = 0; // 6 health
|
||||
int numMedicalFirstAidBandages = 0; // 25 health
|
||||
int numPainkillers = 0; // 40 health
|
||||
int numMedicalFirstAidKit = 0; // 70 health
|
||||
|
||||
ItemValue itemMedicalBandage = ItemClass.GetItem("medicalBandage", false);
|
||||
ItemClass itemClassMedicalBandage = itemMedicalBandage.ItemClass;
|
||||
int itemCountMedicalBandage = 0;
|
||||
int itemCount2MedicalBandage = 0;
|
||||
if (itemClassMedicalBandage != null)
|
||||
{
|
||||
itemCountMedicalBandage = __instance.entityPlayerLocal.bag.GetItemCount(itemMedicalBandage, -1, -1, false);
|
||||
itemCount2MedicalBandage = __instance.entityPlayerLocal.inventory.GetItemCount(itemMedicalBandage, false, -1, -1);
|
||||
numMedicalBandages = itemCountMedicalBandage + itemCount2MedicalBandage;
|
||||
}
|
||||
|
||||
ItemValue itemMedicalFirstAidBandage = ItemClass.GetItem("medicalFirstAidBandage", false);
|
||||
ItemClass itemClassMedicalFirstAidBandage = itemMedicalFirstAidBandage.ItemClass;
|
||||
int itemCountMedicalFirstAidBandage = 0;
|
||||
int itemCount2MedicalFirstAidBandage = 0;
|
||||
if (itemClassMedicalFirstAidBandage != null)
|
||||
{
|
||||
itemCountMedicalFirstAidBandage = __instance.entityPlayerLocal.bag.GetItemCount(itemMedicalFirstAidBandage, -1, -1, false);
|
||||
itemCount2MedicalFirstAidBandage = __instance.entityPlayerLocal.inventory.GetItemCount(itemMedicalFirstAidBandage, false, -1, -1);
|
||||
numMedicalFirstAidBandages = itemCountMedicalFirstAidBandage + itemCount2MedicalFirstAidBandage;
|
||||
}
|
||||
|
||||
ItemValue itemMedicalFirstAidKit = ItemClass.GetItem("medicalFirstAidKit", false);
|
||||
ItemClass itemClassMedicalFirstAidKit = itemMedicalFirstAidKit.ItemClass;
|
||||
int itemCountMedicalFirstAidKit = 0;
|
||||
int itemCount2MedicalFirstAidKit = 0;
|
||||
if (itemClassMedicalFirstAidKit != null)
|
||||
{
|
||||
itemCountMedicalFirstAidKit = __instance.entityPlayerLocal.bag.GetItemCount(itemMedicalFirstAidKit, -1, -1, false);
|
||||
itemCount2MedicalFirstAidKit = __instance.entityPlayerLocal.inventory.GetItemCount(itemMedicalFirstAidKit, false, -1, -1);
|
||||
numMedicalFirstAidKit = itemCountMedicalFirstAidKit + itemCount2MedicalFirstAidKit;
|
||||
}
|
||||
|
||||
ItemValue itemPainkillers = ItemClass.GetItem("drugPainkillers", false);
|
||||
ItemClass itemClassPainkillers = itemPainkillers.ItemClass;
|
||||
int itemCountPainkillers = 0;
|
||||
int itemCount2Painkillers = 0;
|
||||
if (itemClassPainkillers != null)
|
||||
{
|
||||
itemCountPainkillers = __instance.entityPlayerLocal.bag.GetItemCount(itemPainkillers, -1, -1, false);
|
||||
itemCount2Painkillers = __instance.entityPlayerLocal.inventory.GetItemCount(itemPainkillers, false, -1, -1);
|
||||
numPainkillers = itemCountPainkillers + itemCount2Painkillers;
|
||||
}
|
||||
|
||||
ItemValue itemAloeCream = ItemClass.GetItem("medicalAloeCream", false);
|
||||
ItemClass itemClassAloeCream = itemAloeCream.ItemClass;
|
||||
int itemCountAloeCream = 0;
|
||||
int itemCount2AloeCream = 0;
|
||||
if (itemClassAloeCream != null)
|
||||
{
|
||||
itemCountAloeCream = __instance.entityPlayerLocal.bag.GetItemCount(itemAloeCream, -1, -1, false);
|
||||
itemCount2AloeCream = __instance.entityPlayerLocal.inventory.GetItemCount(itemAloeCream, false, -1, -1);
|
||||
numAloeCream = itemCountAloeCream + itemCount2AloeCream;
|
||||
}
|
||||
|
||||
if (numHealingLeft > 0)
|
||||
{
|
||||
//Log.Out("INSIDE HEALING");
|
||||
if (numHealingLeft >= 70 && numMedicalFirstAidKit > 0 && perkHealingFactor >= 3)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 1");
|
||||
if (itemCount2MedicalFirstAidKit > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalFirstAidKit, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalFirstAidKit, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalFirstAidKit, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidKitTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalFirstAidKit.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if ((numHealingLeft >= 25 && numHealingLeft < 70) && numMedicalFirstAidBandages > 0 && perkHealingFactor > 0 && !MedicalBandage)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 2");
|
||||
if (itemCount2MedicalFirstAidBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalFirstAidBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalFirstAidBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
/*else if ((numHealingLeft >= 25 && numHealingLeft < 70) && !bUserPainkillers && numPainkillers > 0 && !bPainKillers && perkHealingFactor >= 2)
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 3");
|
||||
if (itemCount2Painkillers > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemPainkillers, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemPainkillers, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemPainkillers, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugPainkillersTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassPainkillers.ItemTags);
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
}*/
|
||||
else if ((numHealingLeft >= 6 && numHealingLeft < 25) && numMedicalBandages > 0 && perkHealingFactor > 0)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 4");
|
||||
if (itemCount2MedicalBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numHealingLeft >= 70 && numMedicalFirstAidBandages > 0 && perkHealingFactor > 0 && !MedicalBandage)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 5");
|
||||
if (itemCount2MedicalFirstAidBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalFirstAidBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalFirstAidBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numHealingLeft >= 25 && numMedicalBandages > 0 && perkHealingFactor > 0)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 6");
|
||||
if (itemCount2MedicalBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numMedicalFirstAidBandages > 0 && numMedicalBandages == 0 && perkHealingFactor > 0 && !MedicalBandage)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 7");
|
||||
if (itemCount2MedicalFirstAidBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalFirstAidBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalFirstAidBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalFirstAidBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numMedicalBandages > 0 && perkHealingFactor > 0)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 8");
|
||||
if (itemCount2MedicalBandage > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalBandage, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalBandage, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalBandageTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalBandage.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numAloeCream > 0 && perkHealingFactor > 0 && !AloeCream)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 9");
|
||||
if (itemCount2AloeCream > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemAloeCream, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemAloeCream, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemAloeCream, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayAloeCreamTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassAloeCream.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
else if (numHealingLeft >= 50 && numMedicalFirstAidKit > 0 && perkHealingFactor >= 3)
|
||||
{
|
||||
if (restrictiveHealing)
|
||||
{
|
||||
restritedHealing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("INSIDE HEALING: 10");
|
||||
if (itemCount2MedicalFirstAidKit > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMedicalFirstAidKit, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMedicalFirstAidKit, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMedicalFirstAidKit, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMedicalFirstAidKitTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClassMedicalFirstAidKit.ItemTags);
|
||||
bBandageSound = true;
|
||||
foundHealingMeds = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*if (!bPainKillers && perkHealingFactor >= 2 && !foundHealingMeds && restritedHealing)
|
||||
{
|
||||
//Log.Out("HEALING D");
|
||||
ItemValue item = ItemClass.GetItem("drugPainkillers", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayDrugPainkillersTrigger");
|
||||
RebirthUtilities.ProcessItem(__instance.entityPlayerLocal, itemClass.ItemTags);
|
||||
healedAmount = healedAmount + 40;
|
||||
bConcussion = false;
|
||||
bPillSound = true;
|
||||
foundHealingMeds = true;
|
||||
bUserPainkillers = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//Log.Out("perkHealingFactor: " + perkHealingFactor);
|
||||
//Log.Out("Total Health: " + playerMaxHealth);
|
||||
//Log.Out("Healed Amount: " + healedAmount);
|
||||
//Log.Out("Current Health: " + playerHealth);
|
||||
//Log.Out("Missing Health: " + missingHealth);
|
||||
//Log.Out("Health Modifier: " + playerHealthModifier);
|
||||
//Log.Out("Healing Num: " + numHealing);
|
||||
//Log.Out("Healing Left: " + numHealingLeft);
|
||||
|
||||
string itemQuickHealName = "FuriousRamsayQuickHealBandage";
|
||||
if (bBandageSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("player_bandage");
|
||||
itemQuickHealName = "FuriousRamsayQuickHealBandage";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bPillSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("player_painkillers");
|
||||
itemQuickHealName = "FuriousRamsayQuickHealPill";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bEatSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("player_eating");
|
||||
itemQuickHealName = "FuriousRamsayQuickHealEat";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bDrinkSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("player_drinking");
|
||||
itemQuickHealName = "FuriousRamsayQuickHealDrink";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int itemIndex = __instance.entityPlayerLocal.inventory.GetFocusedItemIdx();
|
||||
int emptyItemIndex = -1;
|
||||
bool foundEmptySpot = false;
|
||||
|
||||
ItemValue itemQuickHeal = ItemClass.GetItem(itemQuickHealName, false);
|
||||
ItemStack[] slots = __instance.entityPlayerLocal.inventory.GetSlots();
|
||||
|
||||
int numSlots = __instance.entityPlayerLocal.inventory.GetSlotCount();
|
||||
//Log.Out("NUM SLOTS: " + numSlots);
|
||||
|
||||
if (foundHealingMeds)
|
||||
{
|
||||
for (int i = 0; i < slots.Length - 1; i++)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
if (!itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("Item: " + itemStack.itemValue.ItemClass.GetItemName());
|
||||
//Log.Out("Item Num: " + itemStack.count);
|
||||
}
|
||||
else
|
||||
{
|
||||
emptyItemIndex = i;
|
||||
ItemClass itemClass = itemQuickHeal.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 1);
|
||||
__instance.entityPlayerLocal.inventory.AddItem(@is);
|
||||
__instance.entityPlayerLocal.inventory.SetFocusedItemIdx(i);
|
||||
__instance.entityPlayerLocal.inventory.SetHoldingItemIdxNoHolsterTime(i);
|
||||
__instance.entityPlayerLocal.RightArmAnimationUse = true;
|
||||
foundEmptySpot = true;
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.ProcessItemEmptySpot(1.5f, __instance.entityPlayerLocal, itemIndex, emptyItemIndex));
|
||||
//Log.Out("FOUND EMPTY SPOT");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("Item: " + itemStack.itemValue.ItemClass.GetItemName());
|
||||
|
||||
//Log.Out("BEFORE NO EMPTY SPOT-EmptyItemIndex: " + emptyItemIndex);
|
||||
if (!foundEmptySpot)
|
||||
{
|
||||
//__instance.entityPlayerLocal.inventory.SetHoldingItemIdxNoHolsterTime(numSlots-1);
|
||||
ItemValue newItem = ItemClass.GetItem(itemQuickHealName, false);
|
||||
ItemStack[] currentSlots = __instance.entityPlayerLocal.inventory.GetSlots();
|
||||
currentSlots[numSlots - 1] = ItemStack.Empty.Clone();
|
||||
__instance.entityPlayerLocal.inventory.SetSlots(currentSlots);
|
||||
|
||||
//ItemClass itemClass = newItem.ItemClass;
|
||||
//ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 1);
|
||||
//__instance.entityPlayerLocal.inventory.AddItem(@is);
|
||||
|
||||
__instance.entityPlayerLocal.inventory.SetItem(numSlots - 1, newItem, 1);
|
||||
__instance.entityPlayerLocal.inventory.SetFocusedItemIdx(numSlots - 1);
|
||||
__instance.entityPlayerLocal.inventory.SetHoldingItemIdxNoHolsterTime(numSlots - 1);
|
||||
__instance.entityPlayerLocal.RightArmAnimationUse = true;
|
||||
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.ProcessItemEmptySpot(1.5f, __instance.entityPlayerLocal, itemIndex, numSlots - 1));
|
||||
//Log.Out("Previous Item: " + @currentHoldingItem.itemValue.ItemClass.GetItemName());
|
||||
}
|
||||
//Log.Out("AFTER NO EMPTY SPOT");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (restritedHealing)
|
||||
{
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal, Localization.Get("ttNotDoneHealing"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
RebirthVariables.localConstants["$varFuriousRamsayActionInProgress"] = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Input.GetKeyDown(KeyCode.Return) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive())
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 3");
|
||||
bool flag = false;
|
||||
ItemStack[] slots = __instance.entityPlayerLocal.bag.GetSlots();
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
if (!slots[i].itemValue.type.Equals(ItemValue.None.type))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityBackpack entityBackpack = EntityFactory.CreateEntity("Backpack".GetHashCode(), __instance.entityPlayerLocal.position + __instance.entityPlayerLocal.transform.up * 2f) as EntityBackpack;
|
||||
TileEntityLootContainer tileEntityLootContainer = new TileEntityLootContainer((Chunk)null);
|
||||
string lootList = entityBackpack.GetLootList();
|
||||
tileEntityLootContainer.lootListName = lootList;
|
||||
tileEntityLootContainer.SetUserAccessing(true);
|
||||
tileEntityLootContainer.SetEmpty();
|
||||
tileEntityLootContainer.SetContainerSize(LootContainer.GetLootContainer(lootList, true).size, true);
|
||||
|
||||
bool[] lockedSlots = __instance.entityPlayerLocal.bag.LockedSlots;
|
||||
|
||||
ItemStack[] slots3 = __instance.entityPlayerLocal.bag.GetSlots();
|
||||
|
||||
int numItems = 0;
|
||||
|
||||
for (int n = 0; n < slots3.Length; n++)
|
||||
{
|
||||
bool skipSlot = false;
|
||||
|
||||
if (lockedSlots != null)
|
||||
{
|
||||
skipSlot = lockedSlots[n];
|
||||
}
|
||||
|
||||
//Log.Out("skipSlot[" + n + "]: " + skipSlot);
|
||||
|
||||
if (!slots3[n].IsEmpty() && !slots3[n].itemValue.ItemClass.KeepOnDeath() && !skipSlot)
|
||||
{
|
||||
tileEntityLootContainer.AddItem(slots3[n]);
|
||||
slots3[n] = ItemStack.Empty.Clone();
|
||||
numItems++;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("numItems: " + numItems);
|
||||
|
||||
if (numItems == 0)
|
||||
{
|
||||
tileEntityLootContainer.SetUserAccessing(false);
|
||||
tileEntityLootContainer.SetModified();
|
||||
entityBackpack.OnEntityUnload();
|
||||
return false;
|
||||
}
|
||||
|
||||
tileEntityLootContainer.bPlayerBackpack = true;
|
||||
__instance.entityPlayerLocal.bag.SetSlots(slots3);
|
||||
|
||||
tileEntityLootContainer.SetUserAccessing(false);
|
||||
tileEntityLootContainer.SetModified();
|
||||
entityBackpack.RefPlayerId = __instance.entityPlayerLocal.entityId;
|
||||
EntityCreationData entityCreationData = new EntityCreationData(entityBackpack);
|
||||
entityCreationData.entityName = string.Format(Localization.Get("playersBackpack"), __instance.entityPlayerLocal.EntityName);
|
||||
entityCreationData.id = -1;
|
||||
entityCreationData.lootContainer = tileEntityLootContainer;
|
||||
GameManager.Instance.RequestToSpawnEntityServer(entityCreationData);
|
||||
entityBackpack.OnEntityUnload();
|
||||
//__instance.entityPlayerLocal.SetDroppedBackpackPosition(new Vector3i(__instance.entityPlayerLocal.position));
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
__instance.entityPlayerLocal.SetDroppedBackpackPositions(GameManager.Instance.persistentLocalPlayer.GetDroppedBackpackPositions());
|
||||
}
|
||||
Manager.BroadcastPlay(__instance.entityPlayerLocal.position, "close_backpack", 0f);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (__instance.entityPlayerLocal.playerInput.MoveBack.IsPressed && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive())
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.SetCustomVar("$autoRunToggle", 0f);
|
||||
return true;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.LeftAlt) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive())
|
||||
{
|
||||
float currentToggle = __instance.entityPlayerLocal.Buffs.GetCustomVar("$autoRunToggle");
|
||||
if (currentToggle == 0f)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.SetCustomVar("$autoRunToggle", 1f);
|
||||
}
|
||||
else if (currentToggle == 1f)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.SetCustomVar("$autoRunToggle", 2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.SetCustomVar("$autoRunToggle", 0f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Backspace) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && RebirthUtilities.HasMod(__instance.entityPlayerLocal, "FuriousRamsayWalkmanMod"))
|
||||
{
|
||||
/*
|
||||
if (RebirthVariables.forceNoHit)
|
||||
{
|
||||
int layerId = __instance.entityPlayerLocal.GetModelLayer();
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update: layerId: " + layerId);
|
||||
__instance.entityPlayerLocal.SetModelLayer(2, true, null);
|
||||
}
|
||||
*/
|
||||
|
||||
if (RebirthVariables.musicMode == 0 || RebirthVariables.musicMode == -1)
|
||||
{
|
||||
RebirthVariables.musicMode = 1;
|
||||
RebirthVariables.walkman = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthVariables.musicMode = 0;
|
||||
RebirthVariables.walkman = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Return) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && RebirthUtilities.HasMod(__instance.entityPlayerLocal, "FuriousRamsayWalkmanMod"))
|
||||
{
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Equals) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && RebirthUtilities.HasMod(__instance.entityPlayerLocal, "FuriousRamsayWalkmanMod"))
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions EQUALS");
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 4;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Minus) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && RebirthUtilities.HasMod(__instance.entityPlayerLocal, "FuriousRamsayWalkmanMod"))
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions MINUS");
|
||||
if (RebirthVariables.musicMode == 1)
|
||||
{
|
||||
RebirthVariables.musicMode = 5;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (__instance.entityPlayerLocal.inventory.holdingItemItemValue != null && __instance.entityPlayerLocal.inventory.holdingItemItemValue.ItemClass is ItemClassBlock && __instance.entityPlayerLocal.inventory.holdingItemItemValue.ItemClass.GetItemName() .ToLower().Contains("shapes:") && Input.GetKeyDown(KeyCode.F) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && !__instance.playerUI.windowManager.IsModalWindowOpen())
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions COPY SHAPE AND ROTATION ");
|
||||
EntityPlayerLocal _epl = __instance.entityPlayerLocal;
|
||||
ItemClassBlock.ItemBlockInventoryData _ibid;
|
||||
Block _blockHolding;
|
||||
Block _blockSelectedShape;
|
||||
bool _hasAutoRotation;
|
||||
bool _onlySimpleRotations;
|
||||
bool _hasCopyRotation;
|
||||
bool _allowShapes;
|
||||
bool _hasCopyAutoShape;
|
||||
bool _hasCopyShapeLegacy;
|
||||
|
||||
if (!RebirthUtilities.getBasicBlockInfo(_epl, out _ibid, out _blockHolding, out _blockSelectedShape, out _hasAutoRotation, out _onlySimpleRotations, out _hasCopyRotation, out _allowShapes, out _hasCopyAutoShape, out _hasCopyShapeLegacy, out bool _))
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions EXIT");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions HOLDING Shape: " + _blockHolding.shape.GetName());
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions HOLDING Rotation: " + _ibid.rotation);
|
||||
|
||||
BlockValue blockValue2 = __instance.entityPlayerLocal.HitInfo.hit.blockValue;
|
||||
if (blockValue2.ischild)
|
||||
{
|
||||
blockValue2 = __instance.entityPlayerLocal.world.GetBlock(blockValue2.Block.multiBlockPos.GetParentPos(__instance.entityPlayerLocal.HitInfo.hit.blockPos, blockValue2));
|
||||
}
|
||||
|
||||
if (blockValue2.Block.shape != null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions TARGET Shape: " + blockValue2.Block.shape.GetName());
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions BEFORE _ibid.itemValue.Meta: " + _ibid.itemValue.Meta);
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions _hasCopyAutoShape: " + _hasCopyAutoShape);
|
||||
|
||||
int num = 0;
|
||||
|
||||
if (_hasCopyAutoShape)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions blockValue2.Block.GetAutoShapeShapeName(): " + blockValue2.Block.GetAutoShapeShapeName());
|
||||
num = _blockHolding.AutoShapeAlternateShapeNameIndex(blockValue2.Block.GetAutoShapeShapeName());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions blockValue2.Block.GetBlockName(): " + blockValue2.Block.GetBlockName());
|
||||
num = _blockHolding.GetAlternateBlockIndex(blockValue2.Block.GetBlockName());
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions num: " + num);
|
||||
|
||||
if (num < 0)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions EXIT 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions AFTER _ibid.itemValue.Meta: " + num);
|
||||
|
||||
_ibid.itemValue.Meta = num;
|
||||
XUiC_Toolbelt childByType = ((XUiWindowGroup)__instance.entityPlayerLocal.playerUI.windowManager.GetWindow("toolbelt")).Controller.GetChildByType<XUiC_Toolbelt>();
|
||||
if (childByType == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions EXIT 2");
|
||||
return false;
|
||||
}
|
||||
int holdingItemIdx = _epl.inventory.holdingItemIdx;
|
||||
XUiC_ItemStack slotControl = childByType.GetSlotControl(holdingItemIdx);
|
||||
slotControl.ItemStack = new ItemStack(_ibid.itemValue, _ibid.itemStack.count);
|
||||
slotControl.ForceRefreshItemStack();
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions BEFORE _ibid.rotation: " + _ibid.rotation);
|
||||
|
||||
_ibid.rotation = blockValue2.rotation;
|
||||
_ibid.mode = BlockPlacement.EnumRotationMode.Advanced;
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions HOLDING AFTER Shape: " + _blockHolding.shape.GetName());
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions AFTER _ibid.rotation: " + _ibid.rotation);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Q) && __instance.entityPlayerLocal.AttachedToEntity == null && !__instance.entityPlayerLocal.PlayerUI.windowManager.IsInputActive() && !__instance.playerUI.windowManager.IsModalWindowOpen())
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 4");
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update: Q, hires: " + playerHires.Count);
|
||||
int numTeleport = 0;
|
||||
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update A hire.hireID: " + hire.hireID);
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update A hire.order: " + hire.order);
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update A hire.playerID: " + hire.playerID);
|
||||
|
||||
if (hire.playerID == __instance.entityPlayerLocal.entityId && hire.order == 0)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update B hire.hireID: " + hire.hireID);
|
||||
EntityNPCRebirth entity = GameManager.Instance.World.GetEntity(hire.hireID) as EntityNPCRebirth;
|
||||
if (entity)
|
||||
{
|
||||
float flNPCRespawned = entity.Buffs.GetCustomVar("$FR_NPC_Respawn");
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update flNPCRespawned: " + flNPCRespawned);
|
||||
if (entity.IsDead() || flNPCRespawned == 1 || entity.LeaderUtils.IsTeleporting)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update SKIP");
|
||||
continue;
|
||||
}
|
||||
|
||||
var target2i = new Vector2(__instance.entityPlayerLocal.position.x, __instance.entityPlayerLocal.position.z);
|
||||
var mine2i = new Vector2(entity.position.x, entity.position.z);
|
||||
var distance = Vector2.Distance(target2i, mine2i);
|
||||
|
||||
//if (!(distance < 8 && (Math.Abs(__instance.entityPlayerLocal.position.y - entity.position.y) < 3)))
|
||||
//{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update IS SERVER");
|
||||
bool hasFireBuff = entity.Buffs.HasBuff("FuriousRamsayFireZombieDamage") ||
|
||||
entity.Buffs.HasBuff("buffBurningFlamingArrow") ||
|
||||
entity.Buffs.HasBuff("buffBurningMolotov") ||
|
||||
entity.Buffs.HasBuff("buffBurningEnvironmentHack") ||
|
||||
entity.Buffs.HasBuff("buffBurningEnvironment") ||
|
||||
entity.Buffs.HasBuff("buffBurningElement") ||
|
||||
entity.Buffs.HasBuff("buffIsOnFire") ||
|
||||
entity.Buffs.HasBuff("FuriousRamsayFireZombieAoEDamage") ||
|
||||
entity.Buffs.HasBuff("FuriousRamsayFireZombieAoEDamageDisplay") ||
|
||||
entity.Buffs.HasBuff("FuriousRamsayAddBurningEnemyBoss") ||
|
||||
entity.Buffs.HasBuff("FuriousRamsayBurningTrapDamage");
|
||||
// On Fire
|
||||
if (hasFireBuff && entity.Buffs.GetCustomVar("CurrentOrder") == (int)EntityUtilities.Orders.Follow)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update NPC IS ON FIRE");
|
||||
|
||||
ItemValue itemMurkyWater = ItemClass.GetItem("drinkJarRiverWater", false);
|
||||
ItemClass itemClassMurkyWater = itemMurkyWater.ItemClass;
|
||||
int itemCountMurkyWater = __instance.entityPlayerLocal.bag.GetItemCount(itemMurkyWater, -1, -1, false);
|
||||
int itemCount2MurkyWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemMurkyWater, false, -1, -1);
|
||||
if (itemClassMurkyWater != null)
|
||||
{
|
||||
itemCountMurkyWater = __instance.entityPlayerLocal.bag.GetItemCount(itemMurkyWater, -1, -1, false);
|
||||
itemCount2MurkyWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemMurkyWater, false, -1, -1);
|
||||
}
|
||||
|
||||
ItemValue itemBoiledWater = ItemClass.GetItem("drinkJarBoiledWater", false);
|
||||
ItemClass itemClassBoiledWater = itemBoiledWater.ItemClass;
|
||||
int itemCountBoiledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemBoiledWater, -1, -1, false);
|
||||
int itemCount2BoiledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemBoiledWater, false, -1, -1);
|
||||
if (itemClassBoiledWater != null)
|
||||
{
|
||||
itemCountBoiledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemBoiledWater, -1, -1, false);
|
||||
itemCount2BoiledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemBoiledWater, false, -1, -1);
|
||||
}
|
||||
|
||||
ItemValue itemDistilledWater = ItemClass.GetItem("drinkJarPureMineralWater", false);
|
||||
ItemClass itemClassDistilledWater = itemDistilledWater.ItemClass;
|
||||
int itemCountDistilledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemDistilledWater, -1, -1, false);
|
||||
int itemCount2DistilledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemDistilledWater, false, -1, -1);
|
||||
if (itemClassDistilledWater != null)
|
||||
{
|
||||
itemCountDistilledWater = __instance.entityPlayerLocal.bag.GetItemCount(itemDistilledWater, -1, -1, false);
|
||||
itemCount2DistilledWater = __instance.entityPlayerLocal.inventory.GetItemCount(itemDistilledWater, false, -1, -1);
|
||||
}
|
||||
|
||||
if ((itemCountMurkyWater + itemCount2MurkyWater) > 0)
|
||||
{
|
||||
if (itemCount2MurkyWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMurkyWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMurkyWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMurkyWater, 1));
|
||||
entity.Buffs.AddBuff("buffExtinguishFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieDamage");
|
||||
entity.Buffs.RemoveBuff("buffBurningFlamingArrow");
|
||||
entity.Buffs.RemoveBuff("buffBurningMolotov");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironmentHack");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironment");
|
||||
entity.Buffs.RemoveBuff("buffBurningElement");
|
||||
entity.Buffs.RemoveBuff("buffIsOnFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamage");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamageDisplay");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayAddBurningEnemyBoss");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayBurningTrapDamage");
|
||||
entity.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
}
|
||||
else if ((itemCountBoiledWater + itemCount2BoiledWater) > 0)
|
||||
{
|
||||
if (itemCount2BoiledWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemBoiledWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemBoiledWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemBoiledWater, 1));
|
||||
entity.Buffs.AddBuff("buffExtinguishFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieDamage");
|
||||
entity.Buffs.RemoveBuff("buffBurningFlamingArrow");
|
||||
entity.Buffs.RemoveBuff("buffBurningMolotov");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironmentHack");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironment");
|
||||
entity.Buffs.RemoveBuff("buffBurningElement");
|
||||
entity.Buffs.RemoveBuff("buffIsOnFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamage");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamageDisplay");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayAddBurningEnemyBoss");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayBurningTrapDamage");
|
||||
entity.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
}
|
||||
else if ((itemCountDistilledWater + itemCount2DistilledWater) > 0)
|
||||
{
|
||||
if (itemCount2DistilledWater > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemDistilledWater, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemDistilledWater, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemDistilledWater, 1));
|
||||
entity.Buffs.AddBuff("buffExtinguishFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieDamage");
|
||||
entity.Buffs.RemoveBuff("buffBurningFlamingArrow");
|
||||
entity.Buffs.RemoveBuff("buffBurningMolotov");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironmentHack");
|
||||
entity.Buffs.RemoveBuff("buffBurningEnvironment");
|
||||
entity.Buffs.RemoveBuff("buffBurningElement");
|
||||
entity.Buffs.RemoveBuff("buffIsOnFire");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamage");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayFireZombieAoEDamageDisplay");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayAddBurningEnemyBoss");
|
||||
entity.Buffs.RemoveBuff("FuriousRamsayBurningTrapDamage");
|
||||
entity.Buffs.AddBuff("FuriousRamsayTempResistFire");
|
||||
}
|
||||
}
|
||||
|
||||
if (!__instance.entityPlayerLocal.IsInElevator())
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update NOT IN ELEVATOR TELEPORT");
|
||||
entity.Buffs.SetCustomVar("$FR_NPC_ForceTeleport", 1f);
|
||||
entity.Buffs.AddBuff("FuriousRamsayStandStill");
|
||||
//entity.SetMoveForwardWithModifiers(0f, 0f, false);
|
||||
//entity.ChaseReturnLocation = entity.position;
|
||||
entity.TeleportToPlayer(__instance.entityPlayerLocal, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update IS NOT SERVER");
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageForceTeleportRebirth>().Setup(entity.entityId), false);
|
||||
}
|
||||
numTeleport++;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerUpdatePatches-Update NPC DOES NOT EXIST");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numTeleport > 0)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("FuriousRamsayWhistle");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Input.GetKeyDown(KeyCode.Comma) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
RebirthUtilities.SwitchNPCOrder(__instance.entityPlayerLocal);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Input.GetKeyDown(KeyCode.Period) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 6");
|
||||
RebirthUtilities.SwitchNPCMode(__instance.entityPlayerLocal);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Home) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 9");
|
||||
bool bProtectionShield = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayProtectionShieldTrigger");
|
||||
|
||||
if (!bProtectionShield)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("FuriousRamsayProtectionShield", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayProtectionShieldTrigger");
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttProtectionShieldMissing"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttProtectionShieldOn"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Insert) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 10");
|
||||
float manualMercenaries = 1;
|
||||
if (manualMercenaries == 1)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 10a");
|
||||
bool bMercenariesBuffTier1 = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMercenariesBuffTier1");
|
||||
bool bMercenariesBuffTier2 = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMercenariesBuffTier2");
|
||||
bool bMercenariesBuffTier3 = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMercenariesBuffTier3");
|
||||
bool bMercenariesBuffTier4 = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMercenariesBuffTier4");
|
||||
bool bMercenariesBuffTier5 = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMercenariesBuffTier5");
|
||||
|
||||
bool isHordeNight = RebirthUtilities.IsHordeNight();
|
||||
|
||||
if (bMercenariesBuffTier1)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 10b");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMercenariesBuffTier1Cooldown");
|
||||
__instance.entityPlayerLocal.Buffs.RemoveBuff("FuriousRamsayMercenariesBuffTier1");
|
||||
|
||||
if (isHordeNight)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 10c");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier1_FR", 5, "", "", "8888", "dynamic", "", "", 1, -1, false, false, false, __instance.entityPlayerLocal.entityId, 0, "FuriousRamsayWarHorn");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 10d");
|
||||
//RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier1_FR", 1, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier1_FR", 1, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else if (bMercenariesBuffTier2)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMercenariesBuffTier2Cooldown");
|
||||
__instance.entityPlayerLocal.Buffs.RemoveBuff("FuriousRamsayMercenariesBuffTier2");
|
||||
|
||||
if (isHordeNight)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier2_FR", 6, "", "", "8888", "dynamic", "", "", 1, -1, false, false, false, __instance.entityPlayerLocal.entityId, 0, "FuriousRamsayWarHorn");
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier2_FR", 2, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else if (bMercenariesBuffTier3)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMercenariesBuffTier3Cooldown");
|
||||
__instance.entityPlayerLocal.Buffs.RemoveBuff("FuriousRamsayMercenariesBuffTier3");
|
||||
|
||||
if (isHordeNight)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier3_FR", 7, "", "", "8888", "dynamic", "", "", 1, -1, false, false, false, __instance.entityPlayerLocal.entityId, 0, "FuriousRamsayWarHorn");
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier3_FR", 3, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else if (bMercenariesBuffTier4)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMercenariesBuffTier4Cooldown");
|
||||
__instance.entityPlayerLocal.Buffs.RemoveBuff("FuriousRamsayMercenariesBuffTier4");
|
||||
|
||||
if (isHordeNight)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier4_FR", 8, "", "", "8888", "dynamic", "", "", 1, -1, false, false, false, __instance.entityPlayerLocal.entityId, 0, "FuriousRamsayWarHorn");
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier4_FR", 4, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else if (bMercenariesBuffTier5)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMercenariesBuffTier5Cooldown");
|
||||
__instance.entityPlayerLocal.Buffs.RemoveBuff("FuriousRamsayMercenariesBuffTier5");
|
||||
|
||||
if (isHordeNight)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier5_FR", 9, "", "", "8888", "dynamic", "", "", 1, -1, false, false, false, __instance.entityPlayerLocal.entityId, 0, "FuriousRamsayWarHorn");
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayMercenaryTier5_FR", 5, "", "", "9999", "dynamic", "", "", 1, -1, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttMercenaryContractMissing"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.PageDown) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11");
|
||||
bool canTurretSkill = false;
|
||||
bool hasJunkTurretSkillCooldown = false;
|
||||
|
||||
//float flClass = __instance.entityPlayerLocal.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
float levelDeployableTurrets = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "FuriousRamsayPerkDeployableTurrets");
|
||||
|
||||
bool hasJunkTurretCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayTurretSledgeSkillCooldown");
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions hasJunkTurretCooldown: " + hasJunkTurretCooldown);
|
||||
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 5))
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11A");
|
||||
if (levelDeployableTurrets >= 3)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11B");
|
||||
canTurretSkill = true;
|
||||
if (!hasJunkTurretCooldown)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11C");
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions levelDeployableTurrets: " + levelDeployableTurrets);
|
||||
|
||||
if (levelDeployableTurrets == 3)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11D 3");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 4)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11D 4");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 35, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 325, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 5)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 11D 5");
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 35, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 325, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 6)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 35, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 325, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 145, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 215, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 7)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 70, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 290, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 145, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 215, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 8)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 60, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 120, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 240, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 300, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 9)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 52, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 103, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 154, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 206, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 257, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 309, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 10)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 45, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 90, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 135, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 225, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 270, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretSledgeGun", 1, "", "", "2", "dynamic", "1", "", 1, 315, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int classID = 5; // Technogeek
|
||||
if (levelDeployableTurrets == 3)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 3, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 4)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 4, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 5)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 5, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 6)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 6, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 7)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 7, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 8)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 8, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 9)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 9, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 10)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 10, classID));
|
||||
}
|
||||
}
|
||||
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTurretSledgeSkillCooldown");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions HAS TURRET COOLDOWN");
|
||||
hasJunkTurretSkillCooldown = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (canTurretSkill && hasJunkTurretSkillCooldown)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttHasJunkTurretSledgeSkillCooldown"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.PageDown) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 12");
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 9))
|
||||
{
|
||||
string itemMindControlBrewName = "FuriousRamsayQuickMindControlDrink";
|
||||
ItemValue itemMindControlBrew = ItemClass.GetItem("FuriousRamsayMindControlDrink", false);
|
||||
ItemClass itemClassMindControlBrew = itemMindControlBrew.ItemClass;
|
||||
int itemCountMindControlBrew = __instance.entityPlayerLocal.bag.GetItemCount(itemMindControlBrew, -1, -1, false);
|
||||
int itemCount2MindControlBrew = __instance.entityPlayerLocal.inventory.GetItemCount(itemMindControlBrew, false, -1, -1);
|
||||
if (itemClassMindControlBrew != null)
|
||||
{
|
||||
itemCountMindControlBrew = __instance.entityPlayerLocal.bag.GetItemCount(itemMindControlBrew, -1, -1, false);
|
||||
itemCount2MindControlBrew = __instance.entityPlayerLocal.inventory.GetItemCount(itemMindControlBrew, false, -1, -1);
|
||||
}
|
||||
|
||||
if ((itemCountMindControlBrew + itemCount2MindControlBrew) > 0)
|
||||
{
|
||||
if (itemCount2MindControlBrew > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemMindControlBrew, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemMindControlBrew, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemMindControlBrew, 1));
|
||||
|
||||
Manager.PlayInsidePlayerHead("player_drinking");
|
||||
|
||||
int itemIndex = __instance.entityPlayerLocal.inventory.GetFocusedItemIdx();
|
||||
int emptyItemIndex = -1;
|
||||
bool foundEmptySpot = false;
|
||||
|
||||
ItemValue itemQuickHeal = ItemClass.GetItem(itemMindControlBrewName, false);
|
||||
ItemStack[] slots = __instance.entityPlayerLocal.inventory.GetSlots();
|
||||
|
||||
for (int i = 0; i < slots.Length - 1; i++)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
if (!itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("Item: " + itemStack.itemValue.ItemClass.GetItemName());
|
||||
//Log.Out("Item Num: " + itemStack.count);
|
||||
}
|
||||
else
|
||||
{
|
||||
emptyItemIndex = i;
|
||||
ItemClass itemClass = itemQuickHeal.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 1);
|
||||
__instance.entityPlayerLocal.inventory.AddItem(@is);
|
||||
__instance.entityPlayerLocal.inventory.SetFocusedItemIdx(i);
|
||||
__instance.entityPlayerLocal.inventory.SetHoldingItemIdxNoHolsterTime(i);
|
||||
__instance.entityPlayerLocal.RightArmAnimationUse = true;
|
||||
foundEmptySpot = true;
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.ProcessItemEmptySpot(1.5f, __instance.entityPlayerLocal, itemIndex, emptyItemIndex));
|
||||
//Log.Out("FOUND EMPTY SPOT");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundEmptySpot)
|
||||
{
|
||||
ItemStack @currentHoldingItem = new ItemStack(__instance.entityPlayerLocal.inventory.GetItem(itemIndex).itemValue.Clone(), 1);
|
||||
int numInventoryItems = __instance.entityPlayerLocal.inventory.GetItemCount();
|
||||
int numItems = __instance.entityPlayerLocal.inventory.GetItem(itemIndex).count;
|
||||
|
||||
//Log.Out("CURRENT ITEM: " + itemIndex);
|
||||
//Log.Out("NUM ITEMS: " + __instance.entityPlayerLocal.inventory.GetItem(itemIndex).count);
|
||||
|
||||
ItemValue newItem = ItemClass.GetItem(itemMindControlBrewName, false);
|
||||
ItemStack[] currentSlots = __instance.entityPlayerLocal.inventory.GetSlots();
|
||||
//Log.Out("ADDING MEDICAL BANDAGE");
|
||||
currentSlots[itemIndex] = ItemStack.Empty.Clone();
|
||||
__instance.entityPlayerLocal.inventory.SetSlots(currentSlots);
|
||||
|
||||
ItemClass itemClass = newItem.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 1);
|
||||
__instance.entityPlayerLocal.inventory.AddItem(@is);
|
||||
__instance.entityPlayerLocal.inventory.SetFocusedItemIdx(itemIndex);
|
||||
__instance.entityPlayerLocal.inventory.SetHoldingItemIdxNoHolsterTime(itemIndex);
|
||||
__instance.entityPlayerLocal.RightArmAnimationUse = true;
|
||||
|
||||
//Log.Out("Previous Item: " + @currentHoldingItem.itemValue.ItemClass.GetItemName());
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.ProcessItemUsedSpot(3.5f, __instance.entityPlayerLocal, itemIndex, @currentHoldingItem, numItems));
|
||||
}
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMindControlBrewBuff");
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttMindControlBrewMissing"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClassMindControlBrew.Id, false), 0);
|
||||
__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
else if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 10))
|
||||
{
|
||||
bool hasDensiveRageBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayRageBuffTier");
|
||||
bool hasOffensiveRageBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayOffensiveRageBuffTier");
|
||||
bool hasBloodMoonBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "BloodMoonRageBuffTier");
|
||||
bool hasDefensiveRageCooldownBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayRageBuffCooldown");
|
||||
bool hasOffensiveRageCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffCooldown");
|
||||
bool hasBloodMoonRageCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayBloodMoonRageBuffCooldown");
|
||||
bool hasOtherRageCapsuleCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayRageBuffOther");
|
||||
|
||||
bool bBerserker = !hasOtherRageCapsuleCooldownBuff && !hasDensiveRageBuff && !hasOffensiveRageBuff & !hasDefensiveRageCooldownBuff && !hasOffensiveRageCooldownBuff && !hasBloodMoonRageCooldownBuff;
|
||||
|
||||
//Log.Out("BACKSLASH-bBerserker: " + bBerserker);
|
||||
|
||||
//Log.Out("BACKSLASH-hasDensiveRageBuff: " + hasDensiveRageBuff);
|
||||
//Log.Out("BACKSLASH-hasOffensiveRageBuff: " + hasOffensiveRageBuff);
|
||||
//Log.Out("BACKSLASH-hasBloodMoonBuff: " + hasBloodMoonBuff);
|
||||
//Log.Out("BACKSLASH-hasDefensiveRageCooldownBuff: " + hasDefensiveRageCooldownBuff);
|
||||
//Log.Out("BACKSLASH-hasOffensiveRageCooldownBuff: " + hasOffensiveRageCooldownBuff);
|
||||
|
||||
if (bBerserker)
|
||||
{
|
||||
//Log.Out("DEFENSIVE RAGE TRIGGER");
|
||||
RebirthUtilities.TriggerDefensiveRage(__instance.entityPlayerLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DEFENSIVE RAGE TRIGGER CANNOT");
|
||||
if (hasDefensiveRageCooldownBuff ||
|
||||
hasOffensiveRageCooldownBuff ||
|
||||
hasBloodMoonRageCooldownBuff)
|
||||
{
|
||||
//Log.Out("DEFENSIVE RAGE TRIGGER CANNOT 0");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageCooldownActive"));
|
||||
}
|
||||
else if (hasDensiveRageBuff)
|
||||
{
|
||||
//Log.Out("DENIED 1");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageDefensiveActive"));
|
||||
}
|
||||
else if (hasBloodMoonRageCooldownBuff)
|
||||
{
|
||||
//Log.Out("DENIED 2");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageBloodmoonActive"));
|
||||
}
|
||||
else if (hasOffensiveRageCooldownBuff)
|
||||
{
|
||||
//Log.Out("DENIED 3");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageOffensiveActive"));
|
||||
}
|
||||
else if (hasOtherRageCapsuleCooldownBuff)
|
||||
{
|
||||
//Log.Out("DENIED 4");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageOffensiveOther"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DENIED 5");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttCannotUseAtThisTime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool canRageCapsuleOther = false;
|
||||
bool canTurretSkill = false;
|
||||
bool hasJunkTurretSkillCooldown = false;
|
||||
|
||||
bool hasRageBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayRageBuffOther");
|
||||
bool hasRageBuffCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayRageBuffOtherCooldown");
|
||||
|
||||
bool hasJunkTurretCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayTurretSkillCooldown");
|
||||
|
||||
float levelDeployableTurrets = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "FuriousRamsayPerkDeployableTurrets");
|
||||
|
||||
bool isClassActive = RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 5);
|
||||
|
||||
if (isClassActive)
|
||||
{
|
||||
if (levelDeployableTurrets >= 3)
|
||||
{
|
||||
canTurretSkill = true;
|
||||
if (!hasJunkTurretCooldown)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
bool canSpawn = true;
|
||||
|
||||
if (levelDeployableTurrets == 3)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunRegular", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 4)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunRegular", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 5)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunRegular", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 120, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunRegular", 1, "", "", "0", "dynamic", "1", "", 1, 240, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 6)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunRegular", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 90, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 270, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 7)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 72, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 144, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 216, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 288, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 8)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 60, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 120, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 240, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 300, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 9)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 52, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 103, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 154, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 206, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 257, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 309, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
else if (levelDeployableTurrets == 10)
|
||||
{
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 0, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 45, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 90, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShell", 1, "", "", "0", "dynamic", "1", "", 1, 135, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 180, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 225, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunAP", 1, "", "", "0", "dynamic", "1", "", 1, 270, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
RebirthUtilities.SpawnEntity(__instance.entityPlayerLocal.entityId, "FuriousRamsayJunkTurretGunShock", 1, "", "", "0", "dynamic", "1", "", 1, 315, false, true, false, __instance.entityPlayerLocal.entityId, 1);
|
||||
}
|
||||
|
||||
if (!canSpawn)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttCantUseSkill"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int classID = 5; // Technogeek
|
||||
if (levelDeployableTurrets == 3)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 13, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 4)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 14, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 5)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 15, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 6)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 16, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 7)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 17, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 8)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 18, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 9)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 19, classID));
|
||||
}
|
||||
else if (levelDeployableTurrets == 10)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRebirthUtilitiesSpawnEntity>().Setup(__instance.entityPlayerLocal.entityId, 20, classID));
|
||||
}
|
||||
}
|
||||
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTurretSkillCooldown");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasJunkTurretSkillCooldown = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (canTurretSkill && hasJunkTurretSkillCooldown)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttHasJunkTurretSkillCooldown"));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemValue itemRageCapsuleOther = ItemClass.GetItem("FuriousRamsayRageCapsuleOther", false);
|
||||
ItemClass itemClassRageCapsuleOther = itemRageCapsuleOther.ItemClass;
|
||||
|
||||
if (!(hasRageBuff || hasRageBuffCooldown))
|
||||
{
|
||||
int itemCountRageCapsuleOther = __instance.entityPlayerLocal.bag.GetItemCount(itemRageCapsuleOther, -1, -1, false);
|
||||
int itemCount2RageCapsuleOther = __instance.entityPlayerLocal.inventory.GetItemCount(itemRageCapsuleOther, false, -1, -1);
|
||||
if (itemClassRageCapsuleOther != null)
|
||||
{
|
||||
itemCountRageCapsuleOther = __instance.entityPlayerLocal.bag.GetItemCount(itemRageCapsuleOther, -1, -1, false);
|
||||
itemCount2RageCapsuleOther = __instance.entityPlayerLocal.inventory.GetItemCount(itemRageCapsuleOther, false, -1, -1);
|
||||
}
|
||||
|
||||
if ((itemCountRageCapsuleOther + itemCount2RageCapsuleOther) > 0)
|
||||
{
|
||||
if (itemCount2RageCapsuleOther > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(itemRageCapsuleOther, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(itemRageCapsuleOther, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(itemRageCapsuleOther, 1));
|
||||
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayRageBuffOther");
|
||||
canRageCapsuleOther = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-Update hasRageBuff: " + hasRageBuff);
|
||||
//Log.Out("PlayerMoveControllerPatches-Update hasRageBuffCooldown: " + hasRageBuffCooldown);
|
||||
|
||||
if (hasRageBuffCooldown)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttHasRageCapsuleOtherCooldown"));
|
||||
}
|
||||
else if (!canRageCapsuleOther && !hasRageBuff)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageCapsuleMissing"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClassRageCapsuleOther.Id, false), 0);
|
||||
__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.PageUp) && __instance.entityPlayerLocal.AttachedToEntity == null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 13");
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-Update PAGE UP");
|
||||
|
||||
//float flClass = __instance.entityPlayerLocal.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
float levelTechnogeekClass = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "furiousramsayatttechnogeek");
|
||||
float levelThugClass = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "furiousramsayattthug");
|
||||
float levelMadmanClass = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "furiousramsayattmadman");
|
||||
|
||||
//Log.Out("PlayerMoveControllerPatches-Update levelTechnogeekClass: " + levelTechnogeekClass);
|
||||
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 2) && levelThugClass >= 3)
|
||||
{
|
||||
bool bBuffCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayThugStunAoECooldown");
|
||||
|
||||
if (!bBuffCooldown)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayThugStunAoECooldown");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayRangedStunAoETrigger", __instance.entityPlayerLocal.entityId);
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 6) && levelMadmanClass >= 3)
|
||||
{
|
||||
bool bBuffCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayMadmanExplosionAoECooldown");
|
||||
|
||||
if (!bBuffCooldown)
|
||||
{
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayMadmanExplosionAoECooldown");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayAddAuraMadmanExplosionDamage" + levelMadmanClass, __instance.entityPlayerLocal.entityId);
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 5) && levelTechnogeekClass >= 5)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-Update IS TECHNOGEEK");
|
||||
|
||||
bool bBuffCooldown = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayTechnogeekShockAoECooldown");
|
||||
|
||||
if (!bBuffCooldown)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-Update NO TECHNOGEEK SHOCK AOE COOLDOWN");
|
||||
|
||||
ItemValue item = ItemClass.GetItem("FuriousRamsayShockwaveGrenade", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-Update GRENADE ITEM EXISTS");
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-Update I DO HAVE GRENADES");
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTechnogeekShockAoE");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTempResistShock");
|
||||
__instance.entityPlayerLocal.Buffs.AddBuff("FuriousRamsayTechnogeekShockAoECooldown");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-Update I DON'T HAVE GRENADES");
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttShockwaveGrenadeMissing"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttShockwaveCooldown"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 5) && levelTechnogeekClass < 5)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttShockwaveNotReached"));
|
||||
}
|
||||
}
|
||||
|
||||
if (RebirthUtilities.IsPrimaryClass(__instance.entityPlayerLocal, 10))
|
||||
{
|
||||
float levelRage = RebirthUtilities.GetPerkLevel(__instance.entityPlayerLocal, "FuriousRamsayPerkRage");
|
||||
|
||||
bool hasDensiveRageBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayRageBuffTier");
|
||||
bool hasOffensiveRageBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayOffensiveRageBuffTier");
|
||||
bool hasBloodMoonBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "BloodMoonRageBuffTier");
|
||||
|
||||
Log.Out("DEFENSIVE RAGE TRIGGER 1 ");
|
||||
|
||||
bool hasDefensiveRageCooldownBuff = RebirthUtilities.HasBuffLike(__instance.entityPlayerLocal, "FuriousRamsayRageBuffCooldown");
|
||||
|
||||
bool hasOffensiveRageCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffCooldown");
|
||||
|
||||
bool hasBloodMoonRageCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayBloodMoonRageBuffCooldown");
|
||||
|
||||
bool hasOtherRageCapsuleCooldownBuff = __instance.entityPlayerLocal.Buffs.HasBuff("FuriousRamsayRageBuffOther");
|
||||
|
||||
bool bBerserker = !hasOtherRageCapsuleCooldownBuff && !hasDensiveRageBuff && !hasOffensiveRageBuff & !hasDefensiveRageCooldownBuff && !hasOffensiveRageCooldownBuff && !hasBloodMoonRageCooldownBuff;
|
||||
|
||||
if (bBerserker)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("FuriousRamsayRageCapsule", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
int itemCount = __instance.entityPlayerLocal.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = __instance.entityPlayerLocal.inventory.GetItemCount(item, false, -1, -1);
|
||||
if (itemCount + itemCount2 > 0)
|
||||
{
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
__instance.entityPlayerLocal.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.entityPlayerLocal.bag.DecItem(item, 1, false);
|
||||
}
|
||||
LocalPlayerUI.GetUIForPlayer(__instance.entityPlayerLocal).xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
RebirthUtilities.TriggerOffensiveRage(__instance.entityPlayerLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageCapsuleMissing"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasDefensiveRageCooldownBuff ||
|
||||
hasOffensiveRageCooldownBuff ||
|
||||
hasBloodMoonRageCooldownBuff)
|
||||
{
|
||||
//Log.Out("DENIED B 1");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageCooldownActive"));
|
||||
}
|
||||
else if (hasDensiveRageBuff)
|
||||
{
|
||||
//Log.Out("DENIED B 2");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageDefensiveActive"));
|
||||
}
|
||||
else if (hasBloodMoonBuff)
|
||||
{
|
||||
//Log.Out("DENIED B 3");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageBloodmoonActive"));
|
||||
}
|
||||
else if (hasOffensiveRageBuff)
|
||||
{
|
||||
//Log.Out("DENIED B 4");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttRageOffensiveActive"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("DENIED B 5");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(__instance.entityPlayerLocal.PlayerUI.xui.playerUI.entityPlayer, Localization.Get("ttCannotUseAtThisTime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("PlayerMoveControllerPatches-CheckPlayerActions 14");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using DynamicMusic;
|
||||
using MusicUtils.Enums;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.PlayerTrackerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(PlayerTracker))]
|
||||
[HarmonyPatch("determineTrader")]
|
||||
public class determineTraderPatch
|
||||
{
|
||||
public static bool Prefix(PlayerTracker __instance, ref SectionType __result,
|
||||
List<Entity> ___npcs,
|
||||
Vector3 ___boundingBoxRange
|
||||
)
|
||||
{
|
||||
___npcs.Clear();
|
||||
GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityTrader), new Bounds(GameManager.Instance.World.GetPrimaryPlayer().position, ___boundingBoxRange), ___npcs);
|
||||
if (___npcs.Count > 0)
|
||||
{
|
||||
EntityTrader entityTrader = ___npcs[0] as EntityTrader;
|
||||
if (entityTrader != null)
|
||||
{
|
||||
string npcID = entityTrader.npcID;
|
||||
if (npcID == "traitorjoel")
|
||||
{
|
||||
__result = SectionType.TraderJoel;
|
||||
}
|
||||
if (npcID == "traderjen")
|
||||
{
|
||||
__result = SectionType.TraderJen;
|
||||
}
|
||||
if (npcID == "traderbob")
|
||||
{
|
||||
__result = SectionType.TraderBob;
|
||||
}
|
||||
if (npcID == "traderhugh")
|
||||
{
|
||||
__result = SectionType.TraderHugh;
|
||||
}
|
||||
if (npcID == "traderrekt")
|
||||
{
|
||||
__result = SectionType.TraderRekt;
|
||||
}
|
||||
//Log.Warning(entityTrader.npcID + " is not a known trader name to DMS");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = SectionType.None;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Harmony.PrefabDataPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(PrefabData))]
|
||||
[HarmonyPatch("LoadPrefabData")]
|
||||
public class LoadPrefabDataPatch
|
||||
{
|
||||
public static bool Prefix(PrefabData __instance, ref PrefabData __result, PathAbstractions.AbstractedLocation _location)
|
||||
{
|
||||
if (RebirthUtilities.IsPrefabIgnored(_location.FullPathNoExtension))
|
||||
{
|
||||
//Log.Out("PrefabManagerDataPatches-LoadPrefabData skipping ignore prefab: " + _location.FullPathNoExtension);
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
namespace Harmony.ProgressionPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(global::Progression))]
|
||||
[HarmonyPatch("AddLevelExp")]
|
||||
public class AddLevelExpPatches
|
||||
{
|
||||
static void Postfix(global::Progression __instance, int _exp, string _cvarXPName, global::Progression.XPTypes _xpType, bool useBonus,
|
||||
global::EntityAlive ___parent)
|
||||
{
|
||||
//Log.Out("AddLevelExpPatches-AddLevelExp POSTFIX START");
|
||||
|
||||
bool isAscensionOn = RebirthVariables.customAscension;
|
||||
|
||||
if (isAscensionOn && ___parent as EntityPlayerLocal != null)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal = ___parent as EntityPlayerLocal;
|
||||
|
||||
float miseryPlayerLevel01 = RebirthVariables.localConstants["$varFuriousRamsayAscension01_Cst"];
|
||||
float miseryPlayerLevel02 = RebirthVariables.localConstants["$varFuriousRamsayAscension02_Cst"];
|
||||
float miseryPlayerLevel03 = RebirthVariables.localConstants["$varFuriousRamsayAscension03_Cst"];
|
||||
float miseryPlayerLevel04 = RebirthVariables.localConstants["$varFuriousRamsayAscension04_Cst"];
|
||||
float miseryPlayerLevel05 = RebirthVariables.localConstants["$varFuriousRamsayAscension05_Cst"];
|
||||
float miseryPlayerLevel06 = RebirthVariables.localConstants["$varFuriousRamsayAscension06_Cst"];
|
||||
float miseryPlayerLevel07 = RebirthVariables.localConstants["$varFuriousRamsayAscension07_Cst"];
|
||||
float miseryPlayerLevel08 = RebirthVariables.localConstants["$varFuriousRamsayAscension08_Cst"];
|
||||
float miseryPlayerLevel09 = RebirthVariables.localConstants["$varFuriousRamsayAscension09_Cst"];
|
||||
float miseryPlayerLevel10 = RebirthVariables.localConstants["$varFuriousRamsayAscension10_Cst"];
|
||||
|
||||
int playerlevel = entityPlayerLocal.Progression.GetLevel();
|
||||
|
||||
bool playSound = false;
|
||||
int progressionLevel = 0;
|
||||
|
||||
ProgressionValue progressionValue = entityPlayerLocal.Progression.GetProgressionValue("FuriousRamsayAscension");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = progressionValue.Level;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.Level >= miseryPlayerLevel01 && __instance.Level < miseryPlayerLevel02)
|
||||
{
|
||||
if (progressionLevel < 1)
|
||||
{
|
||||
progressionLevel = 1;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel02 && __instance.Level < miseryPlayerLevel03)
|
||||
{
|
||||
if (progressionLevel < 2)
|
||||
{
|
||||
progressionLevel = 2;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel03 && __instance.Level < miseryPlayerLevel04)
|
||||
{
|
||||
if (progressionLevel < 3)
|
||||
{
|
||||
progressionLevel = 3;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel04 && __instance.Level < miseryPlayerLevel05)
|
||||
{
|
||||
if (progressionLevel < 4)
|
||||
{
|
||||
progressionLevel = 4;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel05 && __instance.Level < miseryPlayerLevel06)
|
||||
{
|
||||
if (progressionLevel < 5)
|
||||
{
|
||||
progressionLevel = 5;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel06 && __instance.Level < miseryPlayerLevel07)
|
||||
{
|
||||
if (progressionLevel < 6)
|
||||
{
|
||||
progressionLevel = 6;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel07 && __instance.Level < miseryPlayerLevel08)
|
||||
{
|
||||
if (progressionLevel < 7)
|
||||
{
|
||||
progressionLevel = 7;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel08 && __instance.Level < miseryPlayerLevel09)
|
||||
{
|
||||
if (progressionLevel < 8)
|
||||
{
|
||||
progressionLevel = 8;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel09 && __instance.Level < miseryPlayerLevel10)
|
||||
{
|
||||
if (progressionLevel < 9)
|
||||
{
|
||||
progressionLevel = 9;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel10)
|
||||
{
|
||||
if (progressionLevel < 10)
|
||||
{
|
||||
progressionLevel = 10;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("AddLevelExpPatches-AddLevelExp progressionLevel: " + progressionLevel);
|
||||
|
||||
if (playSound)
|
||||
{
|
||||
//Log.Out("AddLevelExpPatches-AddLevelExp playSound: " + playSound);
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.messageHUD(entityPlayerLocal as EntityPlayerLocal, 2f, "miseryPlayerLevel"));
|
||||
|
||||
progressionValue.Level = progressionLevel;
|
||||
entityPlayerLocal.Progression.bProgressionStatsChanged = true;
|
||||
entityPlayerLocal.bPlayerStatsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isRebirthOn = RebirthVariables.customRebirth;
|
||||
|
||||
if (isRebirthOn && ___parent as EntityPlayerLocal != null)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal = ___parent as EntityPlayerLocal;
|
||||
|
||||
float miseryPlayerLevel01 = RebirthVariables.localConstants["$varFuriousRamsayRebirth01_Cst"];
|
||||
float miseryPlayerLevel02 = RebirthVariables.localConstants["$varFuriousRamsayRebirth02_Cst"];
|
||||
float miseryPlayerLevel03 = RebirthVariables.localConstants["$varFuriousRamsayRebirth03_Cst"];
|
||||
float miseryPlayerLevel04 = RebirthVariables.localConstants["$varFuriousRamsayRebirth04_Cst"];
|
||||
float miseryPlayerLevel05 = RebirthVariables.localConstants["$varFuriousRamsayRebirth05_Cst"];
|
||||
float miseryPlayerLevel06 = RebirthVariables.localConstants["$varFuriousRamsayRebirth06_Cst"];
|
||||
float miseryPlayerLevel07 = RebirthVariables.localConstants["$varFuriousRamsayRebirth07_Cst"];
|
||||
float miseryPlayerLevel08 = RebirthVariables.localConstants["$varFuriousRamsayRebirth08_Cst"];
|
||||
float miseryPlayerLevel09 = RebirthVariables.localConstants["$varFuriousRamsayRebirth09_Cst"];
|
||||
float miseryPlayerLevel10 = RebirthVariables.localConstants["$varFuriousRamsayRebirth10_Cst"];
|
||||
|
||||
int playerlevel = entityPlayerLocal.Progression.GetLevel();
|
||||
|
||||
bool playSound = false;
|
||||
int progressionLevel = 0;
|
||||
|
||||
ProgressionValue progressionValue = entityPlayerLocal.Progression.GetProgressionValue("FuriousRamsayRebirth");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = progressionValue.Level;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.Level >= miseryPlayerLevel01 && __instance.Level < miseryPlayerLevel02)
|
||||
{
|
||||
if (progressionLevel < 1)
|
||||
{
|
||||
progressionLevel = 1;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel02 && __instance.Level < miseryPlayerLevel03)
|
||||
{
|
||||
if (progressionLevel < 2)
|
||||
{
|
||||
progressionLevel = 2;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel03 && __instance.Level < miseryPlayerLevel04)
|
||||
{
|
||||
if (progressionLevel < 3)
|
||||
{
|
||||
progressionLevel = 3;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel04 && __instance.Level < miseryPlayerLevel05)
|
||||
{
|
||||
if (progressionLevel < 4)
|
||||
{
|
||||
progressionLevel = 4;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel05 && __instance.Level < miseryPlayerLevel06)
|
||||
{
|
||||
if (progressionLevel < 5)
|
||||
{
|
||||
progressionLevel = 5;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel06 && __instance.Level < miseryPlayerLevel07)
|
||||
{
|
||||
if (progressionLevel < 6)
|
||||
{
|
||||
progressionLevel = 6;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel07 && __instance.Level < miseryPlayerLevel08)
|
||||
{
|
||||
if (progressionLevel < 7)
|
||||
{
|
||||
progressionLevel = 7;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel08 && __instance.Level < miseryPlayerLevel09)
|
||||
{
|
||||
if (progressionLevel < 8)
|
||||
{
|
||||
progressionLevel = 8;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel09 && __instance.Level < miseryPlayerLevel10)
|
||||
{
|
||||
if (progressionLevel < 9)
|
||||
{
|
||||
progressionLevel = 9;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
else if (__instance.Level >= miseryPlayerLevel10)
|
||||
{
|
||||
if (progressionLevel < 10)
|
||||
{
|
||||
progressionLevel = 10;
|
||||
playSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("AddLevelExpPatches-AddLevelExp progressionLevel: " + progressionLevel);
|
||||
|
||||
if (playSound)
|
||||
{
|
||||
//Log.Out("AddLevelExpPatches-AddLevelExp playSound: " + playSound);
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.messageHUD(entityPlayerLocal as EntityPlayerLocal, 2f, "miseryRebirth"));
|
||||
|
||||
progressionValue.Level = progressionLevel;
|
||||
entityPlayerLocal.Progression.bProgressionStatsChanged = true;
|
||||
entityPlayerLocal.bPlayerStatsChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
namespace Harmony.ProjectileMoveScriptPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ProjectileMoveScript))]
|
||||
[HarmonyPatch("checkCollision")]
|
||||
public class checkCollisionPatch
|
||||
{
|
||||
public static bool Prefix(ProjectileMoveScript __instance)
|
||||
{
|
||||
if (__instance.state != ProjectileMoveScript.State.Active || (UnityEngine.Object)ProjectileMoveScript.gameManager == (UnityEngine.Object)null)
|
||||
return false;
|
||||
World world = ProjectileMoveScript.gameManager.World;
|
||||
if (world == null)
|
||||
return false;
|
||||
Vector3 vector3_1 = !__instance.bOnIdealPos ? __instance.idealPosition : __instance.transform.position + Origin.position;
|
||||
Vector3 vector3_2 = vector3_1 - __instance.previousPosition;
|
||||
float magnitude = vector3_2.magnitude;
|
||||
if ((double)magnitude < 0.039999999105930328)
|
||||
return false;
|
||||
EntityAlive firingEntity = (EntityAlive)__instance.firingEntity;
|
||||
Ray ray = new Ray(__instance.previousPosition, vector3_2.normalized);
|
||||
__instance.waterCollisionParticles.CheckCollision(ray.origin, ray.direction, magnitude, (UnityEngine.Object)firingEntity != (UnityEngine.Object)null ? firingEntity.entityId : -1);
|
||||
int _layerId = -1;
|
||||
if ((UnityEngine.Object)firingEntity != (UnityEngine.Object)null && (UnityEngine.Object)firingEntity.emodel != (UnityEngine.Object)null)
|
||||
{
|
||||
_layerId = firingEntity.GetModelLayer();
|
||||
firingEntity.SetModelLayer(2);
|
||||
}
|
||||
int _hitMask = __instance.hmOverride == 0 ? 80 : __instance.hmOverride;
|
||||
int num1 = Voxel.Raycast(world, ray, magnitude, -538750997, _hitMask, __instance.radius) ? 1 : 0;
|
||||
if (_layerId >= 0)
|
||||
firingEntity.SetModelLayer(_layerId);
|
||||
if (num1 != 0 && (GameUtils.IsBlockOrTerrain(Voxel.voxelRayHitInfo.tag) || Voxel.voxelRayHitInfo.tag.StartsWith("E_")))
|
||||
{
|
||||
if ((UnityEngine.Object)__instance.firingEntity != (UnityEngine.Object)null && !__instance.firingEntity.isEntityRemote)
|
||||
{
|
||||
firingEntity.MinEventContext.Other = ItemActionAttack.FindHitEntity(Voxel.voxelRayHitInfo) as EntityAlive;
|
||||
ItemActionAttack.AttackHitInfo _attackDetails = new ItemActionAttack.AttackHitInfo()
|
||||
{
|
||||
WeaponTypeTag = ItemActionAttack.RangedTag
|
||||
};
|
||||
ItemActionAttack.Hit(Voxel.voxelRayHitInfo, __instance.ProjectileOwnerID, EnumDamageTypes.Piercing, Mathf.Lerp(1f, __instance.itemActionProjectile.GetDamageBlock(__instance.itemValueLauncher, ItemActionAttack.GetBlockHit(world, Voxel.voxelRayHitInfo), firingEntity), __instance.actionData.strainPercent), Mathf.Lerp(1f, __instance.itemActionProjectile.GetDamageEntity(__instance.itemValueLauncher, firingEntity), __instance.actionData.strainPercent), 1f, 1f, EffectManager.GetValue(PassiveEffects.CriticalChance, __instance.itemValueLauncher, __instance.itemProjectile.CritChance.Value, firingEntity, tags: __instance.itemProjectile.ItemTags), ItemAction.GetDismemberChance((ItemActionData)__instance.actionData, Voxel.voxelRayHitInfo), __instance.itemProjectile.MadeOfMaterial.SurfaceCategory, __instance.itemActionProjectile.GetDamageMultiplier(), __instance.getBuffActions(), _attackDetails, _actionExp: __instance.itemActionProjectile.ActionExp, _actionExpBonus: __instance.itemActionProjectile.ActionExpBonusMultiplier, damagingItemValue: __instance.itemValueLauncher);
|
||||
if ((UnityEngine.Object)firingEntity.MinEventContext.Other == (UnityEngine.Object)null)
|
||||
firingEntity.FireEvent(MinEventTypes.onSelfPrimaryActionMissEntity);
|
||||
firingEntity.FireEvent(MinEventTypes.onProjectileImpact, false);
|
||||
MinEventParams.CachedEventParam.Self = firingEntity;
|
||||
MinEventParams.CachedEventParam.Position = Voxel.voxelRayHitInfo.hit.pos;
|
||||
MinEventParams.CachedEventParam.ItemValue = __instance.itemValueProjectile;
|
||||
MinEventParams.CachedEventParam.Other = firingEntity.MinEventContext.Other;
|
||||
__instance.itemProjectile.FireEvent(MinEventTypes.onProjectileImpact, MinEventParams.CachedEventParam);
|
||||
if (__instance.itemActionProjectile.Explosion.ParticleIndex > 0)
|
||||
{
|
||||
Vector3 hitPos = Voxel.voxelRayHitInfo.hit.pos - vector3_2.normalized * 0.1f;
|
||||
Vector3i vector3i = World.worldToBlockPos(hitPos);
|
||||
if (!world.GetBlock(vector3i).isair)
|
||||
vector3i = Voxel.OneVoxelStep(vector3i, hitPos, -vector3_2.normalized, out hitPos, out BlockFace _);
|
||||
ProjectileMoveScript.gameManager.ExplosionServer(Voxel.voxelRayHitInfo.hit.clrIdx, hitPos, vector3i, Quaternion.identity, __instance.itemActionProjectile.Explosion, __instance.ProjectileOwnerID, 0.0f, false, __instance.itemValueLauncher);
|
||||
__instance.SetState(ProjectileMoveScript.State.Dead);
|
||||
return false;
|
||||
}
|
||||
if (__instance.itemProjectile.IsSticky)
|
||||
{
|
||||
GameRandom gameRandom = world.GetGameRandom();
|
||||
|
||||
ProgressionValue progressionValue = firingEntity.Progression.GetProgressionValue("FuriousRamsayPerkBows");
|
||||
int progressionLevel = 1;
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip() && progressionValue != null)
|
||||
{
|
||||
progressionLevel = progressionValue.Level;
|
||||
}
|
||||
|
||||
float baseStickChance = 0f;
|
||||
float addedChance = 0f;
|
||||
float stickChance;
|
||||
bool isArrow = __instance.itemProjectile.Name.ToLower().Contains("ammoarrow") ||
|
||||
__instance.itemProjectile.Name.ToLower().Contains("ammocrossbowbolt");
|
||||
|
||||
if (!isArrow)
|
||||
{
|
||||
stickChance = EffectManager.GetValue(PassiveEffects.ProjectileStickChance, __instance.itemValueLauncher, 0.5f, firingEntity, tags: __instance.itemProjectile.ItemTags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.itemProjectile.Name.ToLower().Contains("stone"))
|
||||
{
|
||||
baseStickChance = 0.3f;
|
||||
addedChance = progressionLevel / 25f;
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision STONE, addedChance: " + addedChance);
|
||||
stickChance = baseStickChance + addedChance;
|
||||
}
|
||||
else if (__instance.itemProjectile.Name.ToLower().Contains("iron"))
|
||||
{
|
||||
baseStickChance = 0.4f;
|
||||
addedChance = progressionLevel / 25f;
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision IRON, addedChance: " + addedChance);
|
||||
stickChance = baseStickChance + addedChance;
|
||||
}
|
||||
else if (__instance.itemProjectile.Name.ToLower().Contains("steelap"))
|
||||
{
|
||||
baseStickChance = 0.5f;
|
||||
addedChance = progressionLevel / 25f;
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision STEEL, addedChance: " + addedChance);
|
||||
stickChance = baseStickChance + addedChance;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision OTHER");
|
||||
stickChance = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
float random = gameRandom.RandomFloat;
|
||||
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision baseStickChance: " + baseStickChance);
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision addedChance: " + addedChance);
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision progressionLevel: " + progressionLevel);
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision stickChance: " + stickChance);
|
||||
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision ItemClass.Name: " + __instance.itemValueLauncher.ItemClass.Name);
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision itemProjectile.Name: " + __instance.itemProjectile.Name);
|
||||
|
||||
//Log.Out("ProjectileMoveScriptPatches-checkCollision random: " + random);
|
||||
|
||||
if (GameUtils.IsBlockOrTerrain(Voxel.voxelRayHitInfo.tag))
|
||||
{
|
||||
double randomFloat = (double)gameRandom.RandomFloat;
|
||||
ItemValue itemValueLauncher = __instance.itemValueLauncher;
|
||||
EntityAlive _entity = firingEntity;
|
||||
FastTags<TagGroup.Global> itemTags = __instance.itemProjectile.ItemTags;
|
||||
BlockValue blockValue = Voxel.voxelRayHitInfo.fmcHit.blockValue;
|
||||
FastTags<TagGroup.Global> fastTags = FastTags<TagGroup.Global>.Parse(blockValue.Block.blockMaterial.SurfaceCategory);
|
||||
FastTags<TagGroup.Global> tags = itemTags | fastTags;
|
||||
double num2 = (double)EffectManager.GetValue(PassiveEffects.ProjectileStickChance, itemValueLauncher, 0.5f, _entity, tags: tags);
|
||||
if (randomFloat < num2)
|
||||
{
|
||||
__instance.ProjectileID = ProjectileManager.AddProjectileItem(__instance.transform, _position: Voxel.voxelRayHitInfo.hit.pos, _movementLastFrame: vector3_2.normalized, _itemValueType: __instance.itemValueProjectile.type);
|
||||
__instance.SetState(ProjectileMoveScript.State.Sticky);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager gameManager = ProjectileMoveScript.gameManager;
|
||||
Vector3 pos = Voxel.voxelRayHitInfo.hit.pos;
|
||||
Quaternion rotation = Utils.BlockFaceToRotation(Voxel.voxelRayHitInfo.fmcHit.blockFace);
|
||||
Color white = Color.white;
|
||||
blockValue = Voxel.voxelRayHitInfo.fmcHit.blockValue;
|
||||
string _soundName = string.Format("{0}hit{1}", (object)blockValue.Block.blockMaterial.SurfaceCategory, (object)__instance.itemProjectile.MadeOfMaterial.SurfaceCategory);
|
||||
ParticleEffect _pe = new ParticleEffect("impact_metal_on_wood", pos, rotation, 1f, white, _soundName, (Transform)null);
|
||||
int entityId = __instance.firingEntity.entityId;
|
||||
gameManager.SpawnParticleEffectServer(_pe, entityId, false, false);
|
||||
__instance.SetState(ProjectileMoveScript.State.Dead);
|
||||
}
|
||||
}
|
||||
else if (random < stickChance)
|
||||
{
|
||||
__instance.ProjectileID = ProjectileManager.AddProjectileItem(__instance.transform, _position: Voxel.voxelRayHitInfo.hit.pos, _movementLastFrame: vector3_2.normalized, _itemValueType: __instance.itemValueProjectile.type);
|
||||
Utils.SetLayerRecursively(ProjectileManager.GetProjectile(__instance.ProjectileID).gameObject, 14);
|
||||
__instance.SetState(ProjectileMoveScript.State.Sticky);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProjectileMoveScript.gameManager.SpawnParticleEffectServer(new ParticleEffect("impact_metal_on_wood", Voxel.voxelRayHitInfo.hit.pos, Utils.BlockFaceToRotation(Voxel.voxelRayHitInfo.fmcHit.blockFace), 1f, Color.white, "bullethitwood", (Transform)null), __instance.firingEntity.entityId, false, false);
|
||||
__instance.SetState(ProjectileMoveScript.State.Dead);
|
||||
}
|
||||
}
|
||||
else
|
||||
__instance.SetState(ProjectileMoveScript.State.Dead);
|
||||
}
|
||||
else
|
||||
__instance.SetState(ProjectileMoveScript.State.Dead);
|
||||
}
|
||||
__instance.previousPosition = vector3_1;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Harmony.QuestActionSpawnGSEnemyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(QuestActionSpawnGSEnemy))]
|
||||
[HarmonyPatch("SpawnEnemies")]
|
||||
public class SpawnEnemiesPatch
|
||||
{
|
||||
public static bool Prefix(QuestActionSpawnGSEnemy __instance, Quest ownerQuest)
|
||||
{
|
||||
EntityPlayerLocal player = ownerQuest.OwnerJournal.OwnerPlayer;
|
||||
|
||||
RebirthVariables.gameStage = player.gameStage;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("QuestActionSpawnGSEnemyPatches-SpawnEnemies START: " + player.biomeStandingOn.m_sBiomeName + $" ({player.position})");
|
||||
string biomeName = RebirthUtilities.GetBiomeName(player);
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Harmony.QuestClassPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(QuestClass))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(QuestClass __instance)
|
||||
{
|
||||
if (__instance.ID.ToLower().Contains("_infested"))
|
||||
{
|
||||
string option = RebirthVariables.customInfested;
|
||||
|
||||
if (option.ToLower().Contains("hide"))
|
||||
{
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropStatementKey))
|
||||
{
|
||||
__instance.StatementText = Localization.Get("quest_clear_statement");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropResponseKey))
|
||||
{
|
||||
__instance.ResponseText = Localization.Get("quest_clear_response");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropSubtitleKey))
|
||||
{
|
||||
__instance.SubTitle = Localization.Get("quest_clear_subtitle");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropDescriptionKey))
|
||||
{
|
||||
__instance.Description = Localization.Get("quest_clear_description");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropGroupNameKey))
|
||||
{
|
||||
__instance.GroupName = Localization.Get("quest_tier2_clear");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropOfferKey))
|
||||
{
|
||||
__instance.Offer = Localization.Get("quest_tier2_clear_offer");
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropNameKey))
|
||||
{
|
||||
string NameKey = __instance.Properties.Values[QuestClass.PropNameKey].Replace("_infested", "");
|
||||
|
||||
//Log.Out("QuestClassPatches-Init BEFORE NameKey: " + NameKey);
|
||||
|
||||
string resultString = Regex.Match(__instance.Name, @"\d+").Value;
|
||||
|
||||
//Log.Out("QuestClassPatches-Init resultString: " + resultString);
|
||||
|
||||
if (!NameKey.ToLower().Contains("test") && resultString != null)
|
||||
{
|
||||
int num = Int32.Parse(resultString) - 1;
|
||||
|
||||
//Log.Out("QuestClassPatches-Init num: " + num);
|
||||
|
||||
NameKey = NameKey.Replace(resultString, num.ToString());
|
||||
//Log.Out("QuestClassPatches-Init AFTER NameKey: " + NameKey);
|
||||
}
|
||||
|
||||
__instance.Name = Localization.Get(NameKey);
|
||||
//Log.Out("QuestClassPatches-Init __instance.Name: " + __instance.Name);
|
||||
}
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropOffer))
|
||||
{
|
||||
__instance.Offer = __instance.Properties.Values[QuestClass.PropOffer].Replace("_infested", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (option == "hidesurprise")
|
||||
{
|
||||
if (__instance.Properties.Values.ContainsKey(QuestClass.PropDifficultyTier))
|
||||
{
|
||||
int difficulty = int.Parse(__instance.Properties.Values[QuestClass.PropDifficultyTier]);
|
||||
__instance.DifficultyTier = Convert.ToByte(difficulty - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.QuestEventManagerPatchesRebirth
|
||||
{
|
||||
internal class QuestEventManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(QuestEventManager))]
|
||||
[HarmonyPatch("GetPrefabsForTrader")]
|
||||
public class GetPrefabsForTraderPatch
|
||||
{
|
||||
private static bool Prefix(QuestEventManager __instance, ref List<PrefabInstance> __result, TraderArea traderArea, int difficulty, int index, GameRandom gameRandom)
|
||||
{
|
||||
if (traderArea == null)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
|
||||
}
|
||||
if (!__instance.TraderPrefabList.ContainsKey(traderArea))
|
||||
{
|
||||
RebirthUtilities.SetupTraderPrefabList(traderArea, difficulty, ref __instance.TraderPrefabList);
|
||||
}
|
||||
QuestEventManager.PrefabListData prefabListData = __instance.TraderPrefabList[traderArea][index];
|
||||
prefabListData.ShuffleDifficulty(difficulty, gameRandom);
|
||||
if (prefabListData.TierData.ContainsKey(difficulty))
|
||||
{
|
||||
__result = prefabListData.TierData[difficulty];
|
||||
return false;
|
||||
}
|
||||
__result = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(QuestEventManager))]
|
||||
[HarmonyPatch("HandleNewCompletedQuest")]
|
||||
public class HandleNewCompletedQuest
|
||||
{
|
||||
|
||||
private static bool Prefix(QuestEventManager __instance, global::EntityPlayer player, byte questFaction, int completedQuestTier, bool addsToTierComplete)
|
||||
{
|
||||
if (addsToTierComplete)
|
||||
{
|
||||
float numQuestCompletionTier = 0;
|
||||
if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier"))
|
||||
{
|
||||
numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier");
|
||||
}
|
||||
|
||||
int currentFactionTier = player.QuestJournal.GetCurrentFactionTier(questFaction, 0, true);
|
||||
int currentFactionTier2 = player.QuestJournal.GetCurrentFactionTier(questFaction, completedQuestTier, true);
|
||||
if (currentFactionTier != currentFactionTier2)
|
||||
{
|
||||
for (int i = 0; i < __instance.questTierRewards.Count; i++)
|
||||
{
|
||||
if (__instance.questTierRewards[i].Tier == currentFactionTier2)
|
||||
{
|
||||
numQuestCompletionTier++;
|
||||
player.Buffs.SetCustomVar("$varFuriousRamsayQuestCompletionTier", numQuestCompletionTier);
|
||||
//Log.Out("QuestEventManager-HandleNewCompletedQuest $varFuriousRamsayQuestCompletionTier: " + numQuestCompletionTier);
|
||||
__instance.questTierRewards[i].GiveRewards(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.QuestJournalPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(QuestJournal))]
|
||||
[HarmonyPatch("Read")]
|
||||
public class ReadPatch
|
||||
{
|
||||
public static bool Prefix(ref QuestJournal __instance, PooledBinaryReader _br)
|
||||
{
|
||||
__instance.quests.Clear();
|
||||
byte version = _br.ReadByte();
|
||||
if (version >= (byte)2)
|
||||
{
|
||||
int num = (int)_br.ReadByte();
|
||||
__instance.TraderPOIs.Clear();
|
||||
for (int index = 0; index < num; ++index)
|
||||
__instance.TraderPOIs.Add(StreamUtils.ReadVector2((BinaryReader)_br));
|
||||
}
|
||||
if (version > (byte)2)
|
||||
{
|
||||
int num1 = (int)_br.ReadByte();
|
||||
__instance.TradersByFaction.Clear();
|
||||
for (int index1 = 0; index1 < num1; ++index1)
|
||||
{
|
||||
int key = _br.ReadInt32();
|
||||
List<Vector2> vector2List = new List<Vector2>();
|
||||
int num2 = _br.ReadInt32();
|
||||
for (int index2 = 0; index2 < num2; ++index2)
|
||||
vector2List.Add(StreamUtils.ReadVector2((BinaryReader)_br));
|
||||
__instance.TradersByFaction.Add(key, vector2List);
|
||||
}
|
||||
}
|
||||
int num3 = (int)_br.ReadInt16();
|
||||
for (int index = 0; index < num3; ++index)
|
||||
{
|
||||
PooledBinaryReader.StreamReadSizeMarker _sizeMarker = new PooledBinaryReader.StreamReadSizeMarker();
|
||||
if (version >= (byte)5)
|
||||
_sizeMarker = _br.ReadSizeMarker(PooledBinaryWriter.EMarkerSize.UInt16);
|
||||
string str = _br.ReadString();
|
||||
uint _bytesReceived;
|
||||
try
|
||||
{
|
||||
byte num4 = _br.ReadByte();
|
||||
if (QuestClass.GetQuest(str) == null)
|
||||
{
|
||||
Log.Error("Loading player quests: Quest with ID " + str + " not found, ignoring");
|
||||
_br.ValidateSizeMarker(ref _sizeMarker, out _bytesReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
Quest quest1 = QuestClass.CreateQuest(str);
|
||||
Quest quest2 = quest1.Clone();
|
||||
quest2.CurrentQuestVersion = num4;
|
||||
quest2.Read(_br);
|
||||
if ((int)quest1.CurrentQuestVersion != (int)num4)
|
||||
quest2 = quest1.Clone();
|
||||
quest2.OwnerJournal = __instance;
|
||||
__instance.quests.Add(quest2);
|
||||
|
||||
//Log.Out("QuestJournalPatches-Read quest2.ID: " + quest2.ID);
|
||||
//Log.Out("QuestJournalPatches-Read quest2.CurrentState: " + quest2.CurrentState);
|
||||
//Log.Out("QuestJournalPatches-Read quest2.QuestGiverID: " + quest2.QuestGiverID);
|
||||
//Log.Out("QuestJournalPatches-Read RebirthUtilities.IsVanillaTrader(quest2.QuestGiverID): " + RebirthUtilities.IsVanillaTrader(quest2.QuestGiverID));
|
||||
|
||||
if (quest2.CurrentState == Quest.QuestState.Completed)
|
||||
{
|
||||
//Log.Out("QuestJournalPatches-Read COMPLETED");
|
||||
if (quest2.QuestClass.AddsToTierComplete)
|
||||
{
|
||||
//Log.Out("QuestJournalPatches-Read ADDS TO TIER COMPLETE");
|
||||
//Log.Out("QuestJournalPatches-Read quest2.QuestGiverID: " + quest2.QuestGiverID);
|
||||
//Log.Out("QuestJournalPatches-Read IsVanillaTrader: " + RebirthUtilities.IsVanillaTrader(quest2.QuestGiverID));
|
||||
//if (RebirthUtilities.IsVanillaTrader(quest2.QuestGiverID))
|
||||
{
|
||||
//Log.Out("QuestJournalPatches-Read IS FROM VANILLA TRADER");
|
||||
__instance.AddQuestFactionPoint(quest2.QuestFaction, (int)quest2.QuestClass.DifficultyTier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (version >= (byte)5 && !_br.ValidateSizeMarker(ref _sizeMarker, out _bytesReceived))
|
||||
Log.Error("Loading player quests: Error loading quest " + str + ", ignoring");
|
||||
}
|
||||
}
|
||||
if (version <= (byte)3)
|
||||
return false;
|
||||
__instance.TraderData.Clear();
|
||||
int num5 = (int)_br.ReadByte();
|
||||
for (int index = 0; index < num5; ++index)
|
||||
{
|
||||
QuestTraderData questTraderData = new QuestTraderData()
|
||||
{
|
||||
Owner = __instance
|
||||
};
|
||||
questTraderData.Read((BinaryReader)_br, version);
|
||||
__instance.TraderData.Add(questTraderData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(QuestJournal))]
|
||||
[HarmonyPatch("CompleteQuest")]
|
||||
public class CompleteQuestPatch
|
||||
{
|
||||
public static bool Prefix(ref QuestJournal __instance, Quest q)
|
||||
{
|
||||
q.CurrentState = Quest.QuestState.Completed;
|
||||
q.FinishTime = GameManager.Instance.World.worldTime;
|
||||
__instance.OwnerPlayer.TriggerQuestChangedEvent(q);
|
||||
|
||||
bool includeParty = RebirthVariables.customShareParty;
|
||||
|
||||
if (!includeParty)
|
||||
{
|
||||
if (q.SharedOwnerID == -1)
|
||||
{
|
||||
includeParty = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (q.QuestClass.AddsToTierComplete && includeParty)
|
||||
{
|
||||
/*if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
int currentTier = __instance.GetCurrentFactionTier((byte)1);
|
||||
int questTier = q.QuestClass.DifficultyTier;
|
||||
|
||||
Log.Out("QuestJournalPatches-CompleteQuest currentTier: " + currentTier);
|
||||
Log.Out("QuestJournalPatches-CompleteQuest BEFORE questTier: " + questTier);
|
||||
|
||||
if (q.QuestClass.ExtraTags.Test_AnySet(FastTags<TagGroup.Global>.Parse("infested")))
|
||||
{
|
||||
Log.Out("QuestJournalPatches-CompleteQuest AFTERIS INFESTED");
|
||||
questTier--;
|
||||
}
|
||||
|
||||
Log.Out("QuestJournalPatches-CompleteQuest AFTER questTier: " + questTier);
|
||||
|
||||
if (currentTier != questTier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
__instance.AddQuestFactionPoint(q.QuestFaction, (int)q.QuestClass.DifficultyTier);
|
||||
if (q.SharedOwnerID == -1 && q.PositionData.ContainsKey(Quest.PositionDataTypes.TraderPosition) && q.PositionData.ContainsKey(Quest.PositionDataTypes.POIPosition) && SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
Vector3 vector3_1 = q.PositionData[Quest.PositionDataTypes.TraderPosition];
|
||||
Vector3 vector3_2 = q.PositionData[Quest.PositionDataTypes.POIPosition];
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer((NetPackage)NetPackageManager.GetPackage<NetPackageNPCQuestList>().Setup(__instance.OwnerPlayer.entityId, new Vector2(vector3_1.x, vector3_1.z), (int)q.QuestClass.DifficultyTier, new Vector2(vector3_2.x, vector3_2.z)));
|
||||
}
|
||||
}
|
||||
if (__instance.ActiveQuest == q)
|
||||
{
|
||||
__instance.ActiveQuest = (Quest)null;
|
||||
__instance.RefreshRallyMarkerPositions();
|
||||
}
|
||||
|
||||
GameManager.Instance.persistentPlayers.GetPlayerDataFromEntityID(__instance.OwnerPlayer.entityId).RemovePositionsForQuest(q.QuestCode);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(QuestJournal))]
|
||||
[HarmonyPatch("RemoveQuest")]
|
||||
public class RemoveQuestPatch
|
||||
{
|
||||
public static bool Prefix(ref QuestJournal __instance, Quest q)
|
||||
{
|
||||
bool staticQuest = q.QuestClass.Properties.Values.ContainsKey("StaticQuest");
|
||||
|
||||
if (staticQuest)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(QuestJournal))]
|
||||
[HarmonyPatch("GetCurrentFactionTier")]
|
||||
public class GetCurrentFactionTierPatch
|
||||
{
|
||||
public static bool Prefix(ref QuestJournal __instance, ref int __result, byte id, int offset = 0, bool allowExtraTierOverMax = false)
|
||||
{
|
||||
int jobsToNextTier = RebirthVariables.customJobsToNextTier;
|
||||
|
||||
//Log.Out("QuestJournalPatches-GetCurrentFactionTier jobsToNextTier: " + jobsToNextTier);
|
||||
|
||||
int num = __instance.GetQuestFactionPoints(id) + offset;
|
||||
|
||||
//Log.Out("QuestJournalPatches-GetCurrentFactionTier A num: " + num);
|
||||
|
||||
for (int i = 1; i < 100; i++)
|
||||
{
|
||||
num -= i * jobsToNextTier;
|
||||
|
||||
//Log.Out("QuestJournalPatches-GetCurrentFactionTier i: " + i + ", num: " + num);
|
||||
|
||||
if (num < 0)
|
||||
{
|
||||
//Log.Out("QuestJournalPatches-GetCurrentFactionTier Quest.MaxQuestTier: " + Quest.MaxQuestTier);
|
||||
|
||||
//Log.Out("QuestJournalPatches-GetCurrentFactionTier allowExtraTierOverMax: " + allowExtraTierOverMax);
|
||||
|
||||
__result = Math.Min(i, Quest.MaxQuestTier + (allowExtraTierOverMax ? 1 : 0));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = 1;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(QuestJournal))]
|
||||
[HarmonyPatch("AddQuestFactionPoint")]
|
||||
public class AddQuestFactionPointPatch
|
||||
{
|
||||
public static bool Prefix(ref QuestJournal __instance, byte id, int difficultyTier)
|
||||
{
|
||||
if (difficultyTier == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
int currentTier = __instance.GetCurrentFactionTier((byte)1);
|
||||
|
||||
//Log.Out("QuestJournalPatches-CompleteQuest currentTier: " + currentTier);
|
||||
//Log.Out("QuestJournalPatches-CompleteQuest difficultyTier: " + difficultyTier);
|
||||
|
||||
if (currentTier > difficultyTier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
if (!__instance.QuestFactionPoints.ContainsKey((byte)i))
|
||||
{
|
||||
__instance.QuestFactionPoints.Add((byte)i, 0);
|
||||
}
|
||||
int points = __instance.GetQuestFactionPoints((byte)i);
|
||||
|
||||
if (points > max)
|
||||
{
|
||||
max = points;
|
||||
}
|
||||
}
|
||||
|
||||
max = max + difficultyTier;
|
||||
|
||||
Dictionary<byte, int> questFactionPoints = __instance.QuestFactionPoints;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
questFactionPoints[(byte)i] = max;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Harmony.RecipePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Recipe))]
|
||||
[HarmonyPatch("IsUnlocked")]
|
||||
public class IsUnlockedPatch
|
||||
{
|
||||
public static void Postfix(Recipe __instance, ref bool __result, EntityPlayer _ep)
|
||||
{
|
||||
string recipeName = __instance.GetName();
|
||||
|
||||
//Log.Out("RecipePatches-IsUnlocked itemClassName: " + recipeName);
|
||||
if (_ep.Buffs.GetCustomVar(recipeName) == 1f)
|
||||
{
|
||||
//Log.Out("RecipePatches-IsUnlocked KNOWN itemClassName: " + recipeName);
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Recipe))]
|
||||
[HarmonyPatch("GetCraftingTier")]
|
||||
public class GetCraftingTierPatch
|
||||
{
|
||||
public static bool Prefix(Recipe __instance, ref int __result, EntityPlayer _ep)
|
||||
{
|
||||
__result = (int)EffectManager.GetValue(PassiveEffects.CraftingTier, _originalValue: 1f, _entity: (EntityAlive)_ep, _recipe: __instance, tags: __instance.tags);
|
||||
|
||||
if (__result > 5)
|
||||
{
|
||||
__result = 5;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.RecipesFromXmlPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(RecipesFromXml))]
|
||||
[HarmonyPatch("LoadRecipies")]
|
||||
public class LoadRecipiesPatches
|
||||
{
|
||||
public static bool Prefix(RecipesFromXml __instance, XmlFile _xmlFile)
|
||||
{
|
||||
//Log.Out("RecipesFromXml-LoadRecipies START");
|
||||
|
||||
XElement root = _xmlFile.XmlDoc.Root;
|
||||
if (!root.HasElements)
|
||||
{
|
||||
throw new Exception("No element <recipes> found!");
|
||||
}
|
||||
foreach (XElement xelement in root.Elements("recipe"))
|
||||
{
|
||||
Recipe recipe = new Recipe();
|
||||
string recipeName = "";
|
||||
string craftArea = "";
|
||||
|
||||
foreach (XAttribute xattribute in xelement.Attributes())
|
||||
{
|
||||
if (xattribute.Name == "name")
|
||||
{
|
||||
recipeName = xattribute.Value;
|
||||
}
|
||||
else if (xattribute.Name == "craft_area")
|
||||
{
|
||||
craftArea = xattribute.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeName.Trim().Length > 0)
|
||||
{
|
||||
recipe.itemValueType = ItemClass.GetItem(recipeName, false).type;
|
||||
|
||||
bool hasOutput = false;
|
||||
RecipeOutputRebirth output = new RecipeOutputRebirth();
|
||||
|
||||
foreach (XElement xelement2 in xelement.Elements())
|
||||
{
|
||||
if (xelement2.Name == "output")
|
||||
{
|
||||
if (!xelement2.HasAttribute("name"))
|
||||
{
|
||||
throw new Exception("Attribute 'name' missing on ingredient in recipe '" + recipeName + "'");
|
||||
}
|
||||
string name = xelement2.GetAttribute("name");
|
||||
ItemValue item = ItemClass.GetItem(name, false);
|
||||
if (item.IsEmpty())
|
||||
{
|
||||
throw new Exception("No item/block/material with name '" + name + "' existing");
|
||||
}
|
||||
int count = 1;
|
||||
if (xelement2.HasAttribute("count"))
|
||||
{
|
||||
count = int.Parse(xelement2.GetAttribute("count"));
|
||||
}
|
||||
|
||||
hasOutput = true;
|
||||
output.recipeName = recipeName;
|
||||
output.craftingArea = craftArea;
|
||||
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies craftArea: " + craftArea);
|
||||
|
||||
ItemValue itemValue = ItemClass.GetItem(name, false);
|
||||
ItemStack itemStack = new ItemStack(itemValue, count);
|
||||
|
||||
output.OutputItems.Add(itemStack);
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies output.recipeName: " + output.recipeName + " [" + name + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOutput)
|
||||
{
|
||||
RebirthUtilities.recipeOutputs.Add(output);
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies RebirthUtilities.recipeOutputs.Count: " + RebirthUtilities.recipeOutputs.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Base Game Code
|
||||
MicroStopwatch msw = new MicroStopwatch(true);
|
||||
foreach (XElement element1 in root.Elements((XName)"recipe"))
|
||||
{
|
||||
Recipe _recipe = new Recipe();
|
||||
|
||||
string _itemName1 = element1.HasAttribute((XName)"name") ? element1.GetAttribute((XName)"name") : throw new Exception("Attribute 'name' missing on recipe");
|
||||
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies _itemName1: " + _itemName1);
|
||||
|
||||
bool shouldSkip = false;
|
||||
|
||||
foreach (XElement element2 in element1.Elements())
|
||||
{
|
||||
if (element2.Name == (XName)"scenario")
|
||||
{
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies FOUND SCENARIO ELEMENT: " + _itemName1);
|
||||
if (element2.HasAttribute((XName)"name"))
|
||||
{
|
||||
string name = element2.GetAttribute((XName)"name");
|
||||
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies FOUND SCENARIO NAME: " + name);
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies RebirthVariables.customScenario: " + RebirthVariables.customScenario);
|
||||
|
||||
if (RebirthVariables.customScenario != name)
|
||||
{
|
||||
shouldSkip = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSkip)
|
||||
{
|
||||
//Log.Out("RecipesFromXmlPatches-LoadRecipies SKIP");
|
||||
continue;
|
||||
}
|
||||
|
||||
_recipe.itemValueType = ItemClass.GetItem(_itemName1).type;
|
||||
if (_recipe.itemValueType == 0)
|
||||
throw new Exception("No item/block with name '" + _itemName1 + "' existing");
|
||||
_recipe.count = 1;
|
||||
if (element1.HasAttribute((XName)"count"))
|
||||
_recipe.count = int.Parse(element1.GetAttribute((XName)"count"));
|
||||
_recipe.scrapable = false;
|
||||
if (element1.HasAttribute((XName)"scrapable"))
|
||||
_recipe.scrapable = StringParsers.ParseBool(element1.GetAttribute((XName)"scrapable"));
|
||||
_recipe.materialBasedRecipe = false;
|
||||
if (element1.HasAttribute((XName)"material_based"))
|
||||
_recipe.materialBasedRecipe = StringParsers.ParseBool(element1.GetAttribute((XName)"material_based"));
|
||||
if (element1.HasAttribute((XName)"tags"))
|
||||
_recipe.tags = FastTags<TagGroup.Global>.Parse(element1.GetAttribute((XName)"tags") + "," + _itemName1);
|
||||
else if (element1.HasAttribute((XName)"tag"))
|
||||
_recipe.tags = FastTags<TagGroup.Global>.Parse(element1.GetAttribute((XName)"tag") + "," + _itemName1);
|
||||
if (element1.HasAttribute((XName)"tooltip"))
|
||||
_recipe.tooltip = element1.GetAttribute((XName)"tooltip");
|
||||
if (element1.HasAttribute((XName)"craft_area"))
|
||||
{
|
||||
string attribute = element1.GetAttribute((XName)"craft_area");
|
||||
_recipe.craftingArea = attribute;
|
||||
}
|
||||
else
|
||||
_recipe.craftingArea = "";
|
||||
if (element1.HasAttribute((XName)"craft_tool"))
|
||||
{
|
||||
_recipe.craftingToolType = ItemClass.GetItem(element1.GetAttribute((XName)"craft_tool")).type;
|
||||
ItemClass.list[ItemClass.GetItem(element1.GetAttribute((XName)"craft_tool")).type].bCraftingTool = true;
|
||||
}
|
||||
else
|
||||
_recipe.craftingToolType = 0;
|
||||
if (element1.HasAttribute((XName)"craft_time"))
|
||||
{
|
||||
float _result = 0.0f;
|
||||
StringParsers.TryParseFloat(element1.GetAttribute((XName)"craft_time"), out _result);
|
||||
_recipe.craftingTime = _result;
|
||||
}
|
||||
else
|
||||
_recipe.craftingTime = -1f;
|
||||
if (element1.HasAttribute((XName)"learn_exp_gain"))
|
||||
{
|
||||
float _result = 0.0f;
|
||||
_recipe.unlockExpGain = !StringParsers.TryParseFloat(element1.GetAttribute((XName)"learn_exp_gain"), out _result) ? 20 : (int)_result;
|
||||
}
|
||||
else
|
||||
_recipe.unlockExpGain = -1;
|
||||
if (element1.HasAttribute((XName)"craft_exp_gain"))
|
||||
{
|
||||
float _result = 0.0f;
|
||||
_recipe.craftExpGain = !StringParsers.TryParseFloat(element1.GetAttribute((XName)"craft_exp_gain"), out _result) ? 1 : (int)_result;
|
||||
}
|
||||
else
|
||||
_recipe.craftExpGain = -1;
|
||||
_recipe.IsTrackable = !element1.HasAttribute((XName)"is_trackable") || StringParsers.ParseBool(element1.GetAttribute((XName)"is_trackable"));
|
||||
_recipe.UseIngredientModifier = true;
|
||||
if (element1.HasAttribute((XName)"use_ingredient_modifier"))
|
||||
_recipe.UseIngredientModifier = StringParsers.ParseBool(element1.GetAttribute((XName)"use_ingredient_modifier"));
|
||||
_recipe.Effects = MinEffectController.ParseXml(element1);
|
||||
foreach (XElement element2 in element1.Elements())
|
||||
{
|
||||
if (element2.Name == (XName)"ingredient")
|
||||
{
|
||||
XElement _element = element2;
|
||||
string _itemName2 = _element.HasAttribute((XName)"name") ? _element.GetAttribute((XName)"name") : throw new Exception("Attribute 'name' missing on ingredient in recipe '" + _itemName1 + "'");
|
||||
ItemValue _itemValue = ItemClass.GetItem(_itemName2);
|
||||
if (_itemValue.IsEmpty())
|
||||
throw new Exception("No item/block/material with name '" + _itemName2 + "' existing");
|
||||
int _count = 1;
|
||||
if (_element.HasAttribute((XName)"count"))
|
||||
_count = int.Parse(_element.GetAttribute((XName)"count"));
|
||||
_recipe.AddIngredient(_itemValue, _count);
|
||||
}
|
||||
else if (element2.Name == (XName)"wildcard_forge_category")
|
||||
_recipe.wildcardForgeCategory = true;
|
||||
}
|
||||
_recipe.Init();
|
||||
CraftingManager.AddRecipe(_recipe);
|
||||
/*if (msw.ElapsedMilliseconds > (long)Constants.cMaxLoadTimePerFrameMillis)
|
||||
{
|
||||
yield return (object)null;
|
||||
msw.ResetAndRestart();
|
||||
}*/
|
||||
}
|
||||
CraftingManager.PostInit();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.RewardLootItemPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(RewardLootItem))]
|
||||
[HarmonyPatch("SetupReward")]
|
||||
public class SetupRewardPatch
|
||||
{
|
||||
public static bool Prefix(RewardLootItem __instance)
|
||||
{
|
||||
//Log.Out("RewardLootItem-SetupReward item: " + __instance.Item.itemValue.ItemClass.Name);
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
string name = __instance.Item.itemValue.ItemClass.Name.ToLower();
|
||||
if (name.StartsWith("armor") &&
|
||||
(name.Contains("helmet") ||
|
||||
name.Contains("outfit") ||
|
||||
name.Contains("gloves") ||
|
||||
name.Contains("boots")
|
||||
)
|
||||
)
|
||||
{
|
||||
//int questTier = __instance.OwnerQuest.OwnerJournal.GetCurrentFactionTier((byte)1);
|
||||
|
||||
int questTier = __instance.OwnerQuest.QuestClass.DifficultyTier;
|
||||
|
||||
//Log.Out("RewardLootItem-SetupReward questTier: " + questTier);
|
||||
|
||||
Dictionary<string, int> perks = new Dictionary<string, int>();
|
||||
|
||||
if (questTier > 1 && questTier <= 2)
|
||||
{
|
||||
perks = new Dictionary<string, int>
|
||||
{
|
||||
{ "perkMeleeDamage", 1 },
|
||||
{ "perkSexualTrex", 1 },
|
||||
{ "perkMiner69r", 1 },
|
||||
{ "perkMotherLode", 1 },
|
||||
{ "perkRuleOneCardio", 1 },
|
||||
{ "perkParkour", 1 },
|
||||
{ "perkDodge", 1 },
|
||||
{ "perkPackMule", 1 }
|
||||
};
|
||||
}
|
||||
else if (questTier > 2 && questTier <= 3)
|
||||
{
|
||||
perks = new Dictionary<string, int>
|
||||
{
|
||||
{ "perkMeleeDamage", 2 },
|
||||
{ "perkSexualTrex", 2 },
|
||||
{ "perkMiner69r", 2 },
|
||||
{ "perkMotherLode", 2 },
|
||||
{ "perkRuleOneCardio", 2 },
|
||||
{ "perkParkour", 2 },
|
||||
{ "perkDodge", 2 },
|
||||
{ "perkPackMule", 2 },
|
||||
{ "perkHealingFactor", 1 },
|
||||
{ "perkSlowMetabolism", 1 },
|
||||
{ "perkDeepCuts", 1 },
|
||||
{ "perkLuckyLooter", 1 },
|
||||
{ "perkPhysician", 1 },
|
||||
{ "perkTreasureHunter", 1 },
|
||||
{ "perkDaringAdventurer", 1 },
|
||||
{ "perkBetterBarter", 1 },
|
||||
{ "perkCharismaticNature", 1 }
|
||||
};
|
||||
}
|
||||
else if (questTier > 3 && questTier <= 4)
|
||||
{
|
||||
perks = new Dictionary<string, int>
|
||||
{
|
||||
{ "perkMeleeDamage", 3 },
|
||||
{ "perkSexualTrex", 3 },
|
||||
{ "perkMiner69r", 3 },
|
||||
{ "perkMotherLode", 3 },
|
||||
{ "perkRuleOneCardio", 3 },
|
||||
{ "perkParkour", 3 },
|
||||
{ "perkDodge", 3 },
|
||||
{ "perkPackMule", 3 },
|
||||
{ "perkHealingFactor", 2 },
|
||||
{ "perkSlowMetabolism", 2 },
|
||||
{ "perkDeepCuts", 2 },
|
||||
{ "perkLuckyLooter", 2 },
|
||||
{ "perkPhysician", 2 },
|
||||
{ "perkTreasureHunter", 2 },
|
||||
{ "perkDaringAdventurer", 2 },
|
||||
{ "perkBetterBarter", 2 },
|
||||
{ "perkCharismaticNature", 2 }
|
||||
};
|
||||
}
|
||||
else if (questTier > 4)
|
||||
{
|
||||
perks = new Dictionary<string, int>
|
||||
{
|
||||
{ "perkMeleeDamage", 4 },
|
||||
{ "perkSexualTrex", 4 },
|
||||
{ "perkMiner69r", 4 },
|
||||
{ "perkMotherLode", 4 },
|
||||
{ "perkRuleOneCardio", 4 },
|
||||
{ "perkParkour", 4 },
|
||||
{ "perkDodge", 4 },
|
||||
{ "perkPackMule", 4 },
|
||||
{ "perkHealingFactor", 2 },
|
||||
{ "perkSlowMetabolism", 2 },
|
||||
{ "perkDeepCuts", 2 },
|
||||
{ "perkLuckyLooter", 2 },
|
||||
{ "perkPhysician", 2 },
|
||||
{ "perkTreasureHunter", 2 },
|
||||
{ "perkDaringAdventurer", 2 },
|
||||
{ "perkBetterBarter", 2 },
|
||||
{ "perkCharismaticNature", 2 }
|
||||
};
|
||||
}
|
||||
|
||||
int chance = Manager.random.RandomRange(0, 101);
|
||||
|
||||
EntityPlayer player = __instance.OwnerQuest.OwnerJournal.OwnerPlayer;
|
||||
|
||||
float threshold = 60;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkDaringAdventurer");
|
||||
float perkDaringAdventurer = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
|
||||
threshold = threshold + perkDaringAdventurer * 5;
|
||||
}
|
||||
|
||||
if (questTier > 1 && chance <= threshold)
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
KeyValuePair<string, int> randomPerk = perks.ElementAt(random.Next(perks.Count));
|
||||
|
||||
ItemValue itemValue = new ItemValue(ItemClass.GetItem(__instance.Item.itemValue.ItemClass.Name, false).type);
|
||||
itemValue.SetMetadata("bonus", randomPerk.Key, TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("type", "", TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("level", randomPerk.Value, TypedMetadataValue.TypeTag.Integer);
|
||||
itemValue.SetMetadata("active", 2, TypedMetadataValue.TypeTag.Integer);
|
||||
|
||||
__instance.Item.itemValue = itemValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> tagNames = __instance.Item.itemValue.ItemClass.ItemTags.GetTagNames();
|
||||
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
bool isRanged = RebirthUtilities.hasTag(tagNames, "ranged");
|
||||
bool isTool = RebirthUtilities.hasTag(tagNames, "tool");
|
||||
bool isAxe = RebirthUtilities.hasTag(tagNames, "axe");
|
||||
bool isRepairTool = RebirthUtilities.hasTag(tagNames, "repairTool");
|
||||
bool isAmmo = RebirthUtilities.hasTag(tagNames, "ammo");
|
||||
|
||||
if ((isRanged && !isAmmo) ||
|
||||
(isMelee && !(isTool || isRepairTool)) ||
|
||||
(isAxe && !isRepairTool)
|
||||
)
|
||||
{
|
||||
int questTier = __instance.OwnerQuest.QuestClass.DifficultyTier;
|
||||
|
||||
int chance = Manager.random.RandomRange(0, 101);
|
||||
|
||||
EntityPlayer player = __instance.OwnerQuest.OwnerJournal.OwnerPlayer;
|
||||
|
||||
float threshold = 25;
|
||||
|
||||
if (player != null )
|
||||
{
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkDaringAdventurer");
|
||||
float perkDaringAdventurer = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
|
||||
threshold = threshold + perkDaringAdventurer * 5;
|
||||
}
|
||||
|
||||
if (questTier > 1 && chance <= threshold)
|
||||
{
|
||||
string bonusName = RebirthVariables.weaponAura[Manager.random.RandomRange(0, RebirthVariables.weaponAura.Count)];
|
||||
string bonusType = "aura";
|
||||
int bonusLevel = Manager.random.RandomRange(questTier, questTier + 1) - 1;
|
||||
|
||||
ItemValue itemValue = new ItemValue(ItemClass.GetItem(__instance.Item.itemValue.ItemClass.Name, false).type);
|
||||
itemValue.SetMetadata("bonus", bonusName, TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("type", bonusType, TypedMetadataValue.TypeTag.String);
|
||||
itemValue.SetMetadata("level", bonusLevel, TypedMetadataValue.TypeTag.Integer);
|
||||
itemValue.SetMetadata("active", 1, TypedMetadataValue.TypeTag.Integer);
|
||||
|
||||
__instance.Item.itemValue = itemValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.LootGameStage = Convert.ToInt32(__instance.Value);
|
||||
ItemClass itemClass = __instance.Item.itemValue.ItemClass;
|
||||
__instance.Description = itemClass.GetLocalizedItemName();
|
||||
__instance.ValueText = __instance.Value;
|
||||
switch (itemClass.Groups[0].ToLower())
|
||||
{
|
||||
case "ammo/weapons":
|
||||
__instance.Icon = "ui_game_symbol_knife";
|
||||
break;
|
||||
case "basics":
|
||||
__instance.Icon = "ui_game_symbol_shopping_cart";
|
||||
break;
|
||||
case "books":
|
||||
__instance.Icon = "ui_game_symbol_book";
|
||||
break;
|
||||
case "building":
|
||||
__instance.Icon = "ui_game_symbol_map_house";
|
||||
break;
|
||||
case "chemicals":
|
||||
__instance.Icon = "ui_game_symbol_water";
|
||||
break;
|
||||
case "clothing":
|
||||
__instance.Icon = "ui_game_symbol_shirt";
|
||||
break;
|
||||
case "decor/miscellaneous":
|
||||
__instance.Icon = "ui_game_symbol_chair";
|
||||
break;
|
||||
case "food/cooking":
|
||||
__instance.Icon = "ui_game_symbol_fork";
|
||||
break;
|
||||
case "mods":
|
||||
__instance.Icon = "ui_game_symbol_assemble";
|
||||
break;
|
||||
case "resources":
|
||||
__instance.Icon = "ui_game_symbol_resource";
|
||||
break;
|
||||
case "science":
|
||||
__instance.Icon = "ui_game_symbol_science";
|
||||
break;
|
||||
case "special items":
|
||||
__instance.Icon = "ui_game_symbol_book";
|
||||
break;
|
||||
case "tools/traps":
|
||||
__instance.Icon = "ui_game_symbol_tool";
|
||||
break;
|
||||
}
|
||||
__instance.IconAtlas = "ItemIconAtlas";
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
using PI.NGSS;
|
||||
|
||||
namespace Harmony.SkyManagerPatches
|
||||
{
|
||||
internal class SkyManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SkyManager))]
|
||||
[HarmonyPatch("UpdateSunMoonAngles")]
|
||||
public class UpdateSunMoonAnglesPatch
|
||||
{
|
||||
public static bool Prefix(SkyManager __instance)
|
||||
{
|
||||
if (!(bool)(UnityEngine.Object)SkyManager.sunLight || !(bool)(UnityEngine.Object)SkyManager.moonLight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num1 = GameStats.GetInt(EnumGameStats.DayLightLength);
|
||||
SkyManager.duskTime = 22f;
|
||||
if (num1 > 22)
|
||||
{
|
||||
SkyManager.duskTime = Mathf.Clamp((float)num1, 0.0f, 23.999f);
|
||||
}
|
||||
SkyManager.dawnTime = Mathf.Clamp(SkyManager.duskTime - (float)num1, 0.0f, 23.999f);
|
||||
|
||||
if ((double)Time.time - (double)SkyManager.worldRotationTime >= 0.20000000298023224 || SkyManager.bUpdateSunMoonNow)
|
||||
{
|
||||
SkyManager.worldRotationTime = Time.time;
|
||||
#region rebirth
|
||||
if (RebirthUtilities.ScenarioSkip() && !GameManager.Instance.World.IsEditor() && !GameUtils.IsPlaytesting() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
SkyManager.worldRotationTime = 0f;
|
||||
}
|
||||
#endregion
|
||||
|
||||
SkyManager.bUpdateSunMoonNow = false;
|
||||
float num2 = SkyManager.TimeOfDay();
|
||||
#region rebirth
|
||||
if (RebirthUtilities.ScenarioSkip() && !GameManager.Instance.World.IsEditor() && !GameUtils.IsPlaytesting() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
num2 = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if ((double)num2 >= (double)SkyManager.dawnTime && (double)num2 < (double)SkyManager.duskTime)
|
||||
{
|
||||
SkyManager.worldRotationTarget = (float)(((double)num2 - (double)SkyManager.dawnTime) / ((double)SkyManager.duskTime - (double)SkyManager.dawnTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
float num3 = 24f - SkyManager.duskTime;
|
||||
float num4 = num3 + SkyManager.dawnTime;
|
||||
SkyManager.worldRotationTarget = (double)num2 >= (double)SkyManager.dawnTime ? (num2 - SkyManager.duskTime) / num4 : (num3 + num2) / num4;
|
||||
++SkyManager.worldRotationTarget;
|
||||
}
|
||||
SkyManager.worldRotationTarget *= 0.5f;
|
||||
SkyManager.worldRotationTarget = Mathf.Clamp01(SkyManager.worldRotationTarget);
|
||||
}
|
||||
float num5 = SkyManager.worldRotationTarget - SkyManager.worldRotation;
|
||||
float worldRotationTarget = SkyManager.worldRotationTarget;
|
||||
if ((double)num5 < -0.5)
|
||||
{
|
||||
++worldRotationTarget;
|
||||
}
|
||||
else if ((double)num5 > 0.5)
|
||||
{
|
||||
--worldRotationTarget;
|
||||
}
|
||||
SkyManager.worldRotation = Mathf.Lerp(SkyManager.worldRotation, worldRotationTarget, 0.05f);
|
||||
if ((double)SkyManager.worldRotation < 0.0)
|
||||
{
|
||||
++SkyManager.worldRotation;
|
||||
}
|
||||
else if ((double)SkyManager.worldRotation >= 1.0)
|
||||
{
|
||||
--SkyManager.worldRotation;
|
||||
}
|
||||
SkyManager.dayPercent = SkyManager.CalcDayPercent();
|
||||
double angle1 = (double)SkyManager.worldRotation * 360.0;
|
||||
SkyManager.sunDirV = Quaternion.AngleAxis((float)angle1, __instance.sunAxis) * __instance.sunStartV;
|
||||
SkyManager.moonLightRot = Quaternion.LookRotation(Quaternion.AngleAxis((float)angle1, __instance.sunAxis) * __instance.moonStartV);
|
||||
float angle2 = SkyManager.worldRotation * 360f;
|
||||
if ((double)SkyManager.sunIntensity >= 1.0 / 1000.0)
|
||||
{
|
||||
if ((double)angle2 < 14.0)
|
||||
{
|
||||
angle2 = 14f;
|
||||
}
|
||||
if ((double)angle2 > 166.0)
|
||||
{
|
||||
angle2 = 166f;
|
||||
}
|
||||
Vector3 eulerAngles = Quaternion.LookRotation(Quaternion.AngleAxis(angle2, __instance.sunAxis) * __instance.sunStartV).eulerAngles;
|
||||
SkyManager.sunLightT.localEulerAngles = eulerAngles;
|
||||
SkyManager.sunLight.shadowStrength = 1f;
|
||||
SkyManager.sunLight.shadows = (double)SkyManager.sunIntensity > 0.0 ? LightShadows.Soft : LightShadows.None;
|
||||
SkyManager.moonLight.enabled = false;
|
||||
}
|
||||
else if ((double)SkyManager.moonLightColor.grayscale > 0.0)
|
||||
{
|
||||
if ((double)angle2 < 166.0)
|
||||
{
|
||||
angle2 = 166f;
|
||||
}
|
||||
if ((double)angle2 > 346.0)
|
||||
{
|
||||
angle2 = 346f;
|
||||
}
|
||||
Vector3 eulerAngles = Quaternion.LookRotation(Quaternion.AngleAxis(angle2, __instance.sunAxis) * __instance.moonStartV).eulerAngles;
|
||||
SkyManager.moonLightT.localEulerAngles = eulerAngles;
|
||||
float num6 = SkyManager.fogLightScale * SkyManager.moonBright * Utils.FastLerp(0.2f, 1f, GamePrefs.GetFloat(EnumGamePrefs.OptionsGfxBrightness) * 2f);
|
||||
SkyManager.moonLight.intensity = num6;
|
||||
SkyManager.moonLight.color = SkyManager.moonLightColor;
|
||||
SkyManager.moonLight.shadowStrength = 1f;
|
||||
SkyManager.moonLight.shadows = (double)num6 > 0.0 ? LightShadows.Soft : LightShadows.None;
|
||||
SkyManager.moonLight.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.moonLight.enabled = false;
|
||||
}
|
||||
SkyManager.sunMoonDirV = SkyManager.sunDirV;
|
||||
if ((double)SkyManager.sunIntensity < 1.0 / 1000.0)
|
||||
{
|
||||
SkyManager.sunMoonDirV = SkyManager.moonLightRot * Vector3.forward;
|
||||
}
|
||||
if (!GameManager.IsDedicatedServer && (bool)(UnityEngine.Object)SkyManager.mainCamera)
|
||||
{
|
||||
Vector3 position = SkyManager.mainCamera.transform.position;
|
||||
if ((bool)(UnityEngine.Object)SkyManager.moonSpriteT)
|
||||
{
|
||||
SkyManager.moonSpriteT.position = SkyManager.moonLightRot * Vector3.forward * -45000f;
|
||||
SkyManager.moonSpriteT.rotation = Quaternion.LookRotation(SkyManager.moonSpriteT.position, Vector3.up);
|
||||
SkyManager.moonSpriteT.position += position;
|
||||
float num7 = 6857.143f;
|
||||
if (SkyManager.IsBloodMoonVisible())
|
||||
{
|
||||
num7 *= 1.3f;
|
||||
}
|
||||
SkyManager.moonSpriteT.localScale = new Vector3(num7, num7, num7);
|
||||
}
|
||||
__instance.UpdateSunShaftSettings();
|
||||
}
|
||||
SkyManager.atmosphereSphere.Rotate(__instance.starAxis, SkyManager.worldRotation * 0.004f);
|
||||
if (!__instance.bUpdateShaders || !(bool)(UnityEngine.Object)SkyManager.cloudsSphereMtrl)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SkyManager.cloudsSphereMtrl.SetVector("_SunDir", (Vector4)SkyManager.sunDirV);
|
||||
SkyManager.cloudsSphereMtrl.SetVector("_SunMoonDir", (Vector4)SkyManager.sunMoonDirV);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SkyManager))]
|
||||
[HarmonyPatch("IsBloodMoonVisible")]
|
||||
public class IsBloodMoonVisiblePatch
|
||||
{
|
||||
public static void Postfix(ref bool __result)
|
||||
{
|
||||
if (WeatherManager.forceRain > 0.5f && (WeatherManager.forceClouds * 100f) >= 70f)
|
||||
{
|
||||
//Log.Out("SkyManagerPatches-IsBloodMoonVisible 1");
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,557 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.SleeperVolumePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("CheckTrigger")]
|
||||
public class CheckTriggerPatch
|
||||
{
|
||||
public static bool Prefix(SleeperVolume __instance, ref bool __result, World _world, Vector3 playerPos)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
if (__instance.wasCleared)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("Touch")]
|
||||
public class TouchPatch
|
||||
{
|
||||
public static bool Prefix(SleeperVolume __instance, World _world, EntityPlayer _player, bool setActive, SleeperVolume.ETriggerType trigger)
|
||||
{
|
||||
/*Log.Out("SleeperVolumePatches-Touch START");
|
||||
|
||||
if (__instance.prefabInstance != null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch __instance.prefabInstance.name: " + __instance.prefabInstance.name);
|
||||
Log.Out("SleeperVolumePatches-Touch __instance.prefabInstance.name: " + __instance.prefabInstance.name);
|
||||
}*/
|
||||
/*if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-Touch setActive: " + setActive);
|
||||
if (setActive)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-Touch SET ACTIVE");
|
||||
bool flag = (trigger == SleeperVolume.ETriggerType.Attack || trigger == SleeperVolume.ETriggerType.Trigger) && (bool)(UnityEngine.Object)_player;
|
||||
foreach (KeyValuePair<int, SleeperVolume.RespawnData> respawn in __instance.respawnMap)
|
||||
{
|
||||
int key = respawn.Key;
|
||||
//Log.Out("SleeperVolumePatches-Touch __instance.PrefabInstance.name: " + __instance.PrefabInstance.name);
|
||||
//Log.Out("SleeperVolumePatches-Touch key: " + key);
|
||||
EntityAlive entity = (EntityAlive)_world.GetEntity(key);
|
||||
if ((bool)(UnityEngine.Object)entity)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch WAKE UP entity: " + entity.EntityName);
|
||||
entity.Buffs.SetCustomVar("$IsAIOff", 0f);
|
||||
if (flag && _player.Stealth.CanSleeperAttackDetect(entity))
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch 1");
|
||||
entity.ConditionalTriggerSleeperWakeUp();
|
||||
entity.SetAttackTarget((EntityAlive)_player, 400);
|
||||
}
|
||||
else if (trigger == SleeperVolume.ETriggerType.Wander)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch 2");
|
||||
entity.ConditionalTriggerSleeperWakeUp();
|
||||
}
|
||||
else if (--SleeperVolume.wanderingCountdown <= 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch 3");
|
||||
SleeperVolume.wanderingCountdown = 10;
|
||||
entity.ConditionalTriggerSleeperWakeUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Touch 4");
|
||||
entity.SetSleeperActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
__instance.hasPassives = false;
|
||||
__instance.triggerState = trigger;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.playerTouchedToUpdate = _player;
|
||||
__instance.ticksUntilDespawn = 900;
|
||||
//Log.Out("SleeperVolumePatches-Touch __instance.hasPassives: " + __instance.hasPassives);
|
||||
if (__instance.hasPassives)
|
||||
{
|
||||
__instance.ticksUntilDespawn = 200;
|
||||
}
|
||||
if (!__instance.wasCleared || _world.worldTime >= __instance.respawnTime)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-Touch 5");
|
||||
return false;
|
||||
}
|
||||
__instance.respawnTime = Math.Max(__instance.respawnTime, _world.worldTime + 1000UL);
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("Spawn")]
|
||||
public class SpawnPatch
|
||||
{
|
||||
public static void Postfix(SleeperVolume __instance, ref EntityAlive __result, World _world, int entityClass, int spawnIndex, BlockSleeper block)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-Spawn entity: " + __result.EntityName);
|
||||
__result.Buffs.SetCustomVar("$IsAIOff", 1f);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("UpdatePlayerTouched")]
|
||||
public class UpdatePlayerTouchedPatch
|
||||
{
|
||||
public static bool Prefix(SleeperVolume __instance, World _world, EntityPlayer _playerTouched,
|
||||
int ___gameStage
|
||||
)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched START");
|
||||
if (__instance.isSpawned || _world.worldTime < __instance.respawnTime && __instance.wasCleared)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched IS SPAWNED");
|
||||
return false;
|
||||
}
|
||||
if (_world.worldTime >= __instance.respawnTime)
|
||||
{
|
||||
// NEW - Prevent respawns in Purge
|
||||
if (RebirthVariables.customScenario != "purge")
|
||||
{
|
||||
__instance.Reset();
|
||||
}
|
||||
}
|
||||
__instance.isSpawning = true;
|
||||
__instance.isSpawned = true;
|
||||
bool flag = false;
|
||||
float _countScale = 1f;
|
||||
if (__instance.prefabInstance != null)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched __instance.prefabInstance.name: " + __instance.prefabInstance.name);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched __instance.prefabInstance.prefab.PrefabName: " + __instance.prefabInstance.prefab.PrefabName);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched __instance.prefabInstance.sleeperVolumes.Count: " + __instance.prefabInstance.sleeperVolumes.Count);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched __instance.prefabInstance.prefab.SleeperVolumes.Count: " + __instance.prefabInstance.prefab.SleeperVolumes.Count);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched __instance.prefabInstance.boundingBoxPosition: " + __instance.prefabInstance.boundingBoxPosition);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched _playerTouched.position: " + _playerTouched.position);
|
||||
|
||||
/*PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(_playerTouched.position); // _playerTouched.world.GetPOIAtPosition(_playerTouched.position, false);
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched poiatPosition.name: " + poiatPosition.name);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched poiatPosition.prefab.PrefabName: " + poiatPosition.prefab.PrefabName);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched poiatPosition.prefab.SleeperVolumes.Count: " + poiatPosition.prefab.SleeperVolumes.Count);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched poiatPosition.boundingBoxPosition: " + poiatPosition.boundingBoxPosition);
|
||||
}*/
|
||||
|
||||
if (__instance.prefabInstance.LastRefreshType.Test_AnySet(QuestEventManager.infestedTag))
|
||||
flag = true;
|
||||
float num = __instance.prefabInstance.LastQuestClass == null ? 1f : __instance.prefabInstance.LastQuestClass.SpawnMultiplier;
|
||||
byte difficultyTier = __instance.prefabInstance.prefab.DifficultyTier;
|
||||
_countScale = num * ((int)difficultyTier < SleeperVolume.difficultyTierScale.Length ? SleeperVolume.difficultyTierScale[(int)difficultyTier] : SleeperVolume.difficultyTierScale[SleeperVolume.difficultyTierScale.Length - 1]);
|
||||
if (__instance.prefabInstance.LastRefreshType.Test_AnySet(QuestEventManager.banditTag))
|
||||
_countScale = 0.2f;
|
||||
|
||||
/*// NEW - Double spawns
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
flag = true;
|
||||
}*/
|
||||
|
||||
if (RebirthVariables.customScenario == "purge" && !RebirthVariables.activatingSleeperVolumes)
|
||||
{
|
||||
if (_playerTouched.AttachedToEntity == null && !_playerTouched.IsFlyMode.Value)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched activateSleeperVolumes");
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.activateSleeperVolumes(__instance.prefabInstance.sleeperVolumes, _playerTouched, __instance.prefabInstance.prefab.PrefabName, new Vector3(__instance.prefabInstance.boundingBoxPosition.x, __instance.prefabInstance.boundingBoxPosition.y, __instance.prefabInstance.boundingBoxPosition.z), __instance.prefabInstance.prefab.DifficultyTier));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (__instance.spawnPointList.Count > 0)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 1");
|
||||
if (__instance.respawnMap.Count > 0)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 2, __instance.respawnMap.Count: " + __instance.respawnMap.Count);
|
||||
__instance.respawnList = new List<int>(__instance.respawnMap.Count);
|
||||
foreach (KeyValuePair<int, SleeperVolume.RespawnData> respawn in __instance.respawnMap)
|
||||
__instance.respawnList.Add(respawn.Key);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 3, __instance.respawnList.Count: " + __instance.respawnList.Count);
|
||||
}
|
||||
int num = 0;
|
||||
__instance.gameStage = Mathf.Max(0, __instance.GetGameStageAround(_playerTouched) + num);
|
||||
__instance.spawnsAvailable = new List<int>(__instance.spawnPointList.Count);
|
||||
for (int index = 0; index < __instance.spawnPointList.Count; ++index)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 4, index: " + index);
|
||||
if (flag || __instance.spawnPointList[index].GetBlock().spawnMode != BlockSleeper.eMode.Infested)
|
||||
__instance.spawnsAvailable.Add(index);
|
||||
}
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 5, __instance.spawnsAvailable.Count: " + __instance.spawnsAvailable.Count);
|
||||
if (__instance.groupCountList != null)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 6");
|
||||
__instance.groupCountList.Clear();
|
||||
}
|
||||
if (__instance.spawnCountMin < (short)0 || __instance.spawnCountMax < (short)0)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched 7");
|
||||
__instance.spawnCountMin = (short)5;
|
||||
__instance.spawnCountMax = (short)6;
|
||||
}
|
||||
__instance.AddSpawnCount(__instance.groupName, (float)__instance.spawnCountMin * _countScale, (float)__instance.spawnCountMax * _countScale);
|
||||
__instance.spawnDelay = 0;
|
||||
}
|
||||
|
||||
// NEW - START - Gamestage calculation
|
||||
string biomeName = RebirthUtilities.GetBiomeName(_playerTouched);
|
||||
|
||||
if (__instance.prefabInstance != null)
|
||||
{
|
||||
int tier = __instance.prefabInstance.prefab.DifficultyTier;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched A START: " + _playerTouched.biomeStandingOn.m_sBiomeName + $" ({_playerTouched.position})");
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
|
||||
int biomeID = RebirthUtilities.GetCurrentBiomeID(biomeName);
|
||||
|
||||
int adjustGamestage = RebirthUtilities.AdjustGamestage(_playerTouched.gameStage, tier, biomeID);
|
||||
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched CURRENT GAMESTAGE: " + _playerTouched.gameStage);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched GAMESTAGE ADJUSTMENT: " + adjustGamestage);
|
||||
|
||||
RebirthVariables.gameStage = _playerTouched.gameStage + adjustGamestage;
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched AJUSTED GAMESTAGE: " + RebirthVariables.gameStage);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthVariables.gameStage = _playerTouched.gameStage;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched B START: " + _playerTouched.biomeStandingOn.m_sBiomeName + $" ({_playerTouched.position})");
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
}
|
||||
// NEW - END
|
||||
|
||||
if (__instance.minScript == null)
|
||||
return false;
|
||||
__instance.minScript.Run(__instance, _playerTouched, _countScale);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public static void Postfix(SleeperVolume __instance, World _world, EntityPlayer _playerTouched,
|
||||
int ___gameStage
|
||||
)
|
||||
{
|
||||
PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(_playerTouched.position); // _playerTouched.world.GetPOIAtPosition(_playerTouched.position, false);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched ___gameStage: " + ___gameStage);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched _playerTouched.gameStage: " + _playerTouched.gameStage);
|
||||
|
||||
if (poiatPosition != null)
|
||||
{
|
||||
int tier = poiatPosition.prefab.DifficultyTier;
|
||||
|
||||
int adjustGamestage = RebirthUtilities.AdjustGamestage(_playerTouched.gameStage, tier);
|
||||
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched CURRENT GAMESTAGE: " + _playerTouched.gameStage);
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched GAMESTAGE ADJUSTMENT: " + adjustGamestage);
|
||||
|
||||
RebirthVariables.gameStage = _playerTouched.gameStage + adjustGamestage;
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched AJUSTED GAMESTAGE: " + RebirthVariables.gameStage);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthVariables.gameStage = _playerTouched.gameStage;
|
||||
}
|
||||
|
||||
//Log.Out("SleeperVolumePatches-UpdatePlayerTouched START, RebirthVariables.gameStage: " + RebirthVariables.gameStage);
|
||||
}*/
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("CheckTouching")]
|
||||
public class CheckTouchingPatch
|
||||
{
|
||||
public static MethodInfo TouchGroup = AccessTools.Method(typeof(SleeperVolume), "TouchGroup", new Type[] { typeof(World), typeof(EntityPlayer), typeof(bool) });
|
||||
public static MethodInfo CheckTrigger = AccessTools.Method(typeof(SleeperVolume), "CheckTrigger", new Type[] { typeof(World), typeof(Vector3) });
|
||||
|
||||
public struct RespawnData
|
||||
{
|
||||
public string className;
|
||||
public int spawnPointIndex;
|
||||
}
|
||||
|
||||
public static void Postfix(SleeperVolume __instance, World _world, EntityPlayer _player,
|
||||
int ___flags,
|
||||
List<byte> ___TriggeredByIndices,
|
||||
Dictionary<int, RespawnData> ___respawnMap,
|
||||
bool ___hasPassives,
|
||||
EntityPlayer ___playerTouchedToUpdate,
|
||||
SleeperVolume.ETriggerType ___triggerState,
|
||||
short ___groupId,
|
||||
PrefabInstance ___prefabInstance
|
||||
)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching START");
|
||||
|
||||
if ((___TriggeredByIndices.Count > 0 && ___respawnMap.Count == 0) || _player.IsSpectator)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching RETURN");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < _player.Companions.Count; j++)
|
||||
{
|
||||
EntityNPCRebirth companion = _player.Companions[j] as EntityNPCRebirth;
|
||||
if (companion != null)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching companion: " + companion.EntityClass.entityClassName);
|
||||
|
||||
Vector3 position = companion.position;
|
||||
position.y += 0.8f;
|
||||
SleeperVolume.ETriggerType etriggerType = (SleeperVolume.ETriggerType)(___flags & 7);
|
||||
if (___hasPassives)
|
||||
{
|
||||
if (position.x >= (float)__instance.BoxMin.x - -0.3f && position.x < (float)__instance.BoxMax.x + -0.3f && position.y >= (float)__instance.BoxMin.y && position.y < (float)__instance.BoxMax.y && position.z >= (float)__instance.BoxMin.z - -0.3f && position.z < (float)__instance.BoxMax.z + -0.3f && etriggerType != SleeperVolume.ETriggerType.Passive)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching 1");
|
||||
TouchGroup.Invoke(__instance, new object[] { _world, _player, true });
|
||||
}
|
||||
}
|
||||
else if ((etriggerType == SleeperVolume.ETriggerType.Attack || etriggerType == SleeperVolume.ETriggerType.Trigger) && ___triggerState != etriggerType && position.x >= (float)__instance.BoxMin.x - -0.1f && position.x < (float)__instance.BoxMax.x + -0.1f && position.y >= (float)__instance.BoxMin.y && position.y < (float)__instance.BoxMax.y && position.z >= (float)__instance.BoxMin.z - -0.1f && position.z < (float)__instance.BoxMax.z + -0.1f)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching 2");
|
||||
TouchGroup.Invoke(__instance, new object[] { _world, _player, true });
|
||||
}
|
||||
|
||||
object[] pCheckTrigger = new object[] { _world, position };
|
||||
|
||||
bool triggerChecked = (bool)CheckTrigger.Invoke(__instance, new object[] { _world, position });
|
||||
|
||||
if (___playerTouchedToUpdate == null && triggerChecked)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-CheckTouching 3");
|
||||
TouchGroup.Invoke(__instance, new object[] { _world, _player, false });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SleeperVolume))]
|
||||
[HarmonyPatch("UpdateSpawn")]
|
||||
public class UpdateSpawnPatch
|
||||
{
|
||||
public static bool Prefix(SleeperVolume __instance, World _world,
|
||||
PrefabInstance ___prefabInstance
|
||||
)
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdateSpawn START");
|
||||
if (___prefabInstance != null && ___prefabInstance.prefab != null)
|
||||
{
|
||||
RebirthVariables.prefabDifficulty = ___prefabInstance.prefab.DifficultyTier;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
string biomeName = RebirthUtilities.GetBiomeName(___prefabInstance.boundingBoxPosition);
|
||||
|
||||
if (biomeName != "")
|
||||
{
|
||||
//Log.Out("SleeperVolumePatches-UpdateSpawn START: " + biomeAt.m_sBiomeName + $" ({___prefabInstance.boundingBoxPosition})");
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//EXISTING CODE
|
||||
/*if (--__instance.spawnDelay > 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 1");
|
||||
return false;
|
||||
}
|
||||
__instance.spawnDelay = 2;
|
||||
bool flag1 = AIDirector.CanSpawn(2.1f);
|
||||
int num1 = GameStats.GetInt(EnumGameStats.EnemyCount);
|
||||
bool flag2 = false;
|
||||
if (__instance.minScript != null && __instance.minScript.IsRunning())
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 2");
|
||||
flag2 = true;
|
||||
}
|
||||
if (__instance.spawnsAvailable != null && __instance.spawnsAvailable.Count > 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 3");
|
||||
string cultureInvariantString = Time.time.ToCultureInvariantString();
|
||||
if (__instance.respawnList != null && __instance.respawnList.Count > 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 4");
|
||||
int respawn = __instance.respawnList[__instance.respawnList.Count - 1];
|
||||
__instance.respawnList.RemoveAt(__instance.respawnList.Count - 1);
|
||||
Entity entity = _world.GetEntity(respawn);
|
||||
if ((bool)(UnityEngine.Object)entity)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 5");
|
||||
__instance.hasPassives = true;
|
||||
flag2 = true;
|
||||
Log.Out("{0} SleeperVolume {1}: Still alive '{2}'", (object)cultureInvariantString, (object)__instance.BoxMin, (object)entity.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 6");
|
||||
int num2 = __instance.respawnMap[respawn].spawnPointIndex;
|
||||
if (num2 >= 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 7");
|
||||
__instance.RemoveSpawnAvailable(num2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 8");
|
||||
num2 = __instance.FindSpawnIndex(_world);
|
||||
}
|
||||
if (num2 >= 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 9");
|
||||
SleeperVolume.SpawnPoint spawnPoint = __instance.spawnPointList[num2];
|
||||
if (!__instance.CheckSpawnPos(_world, spawnPoint.pos))
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 10");
|
||||
__instance.respawnList.Add(respawn);
|
||||
__instance.spawnsAvailable.Add(num2);
|
||||
return false;
|
||||
}
|
||||
string className = __instance.respawnMap[respawn].className;
|
||||
Log.Out("{0} SleeperVolume {1}: Restoring {2} ({3}) '{4}', count {5}", (object)cultureInvariantString, (object)__instance.BoxMin, (object)spawnPoint.pos, (object)World.toChunkXZ(spawnPoint.pos), (object)className, (object)num1);
|
||||
int entityClass = EntityClass.FromString(className);
|
||||
BlockSleeper block = spawnPoint.GetBlock();
|
||||
if ((bool)(UnityEngine.Object)__instance.Spawn(_world, entityClass, num2, block))
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 11");
|
||||
__instance.respawnMap.Remove(respawn);
|
||||
}
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flag1)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 12");
|
||||
GameStageDefinition gameStageDefinition = (GameStageDefinition)null;
|
||||
if (__instance.groupCountList != null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 13");
|
||||
int num3 = 0;
|
||||
for (int index = 0; index < __instance.groupCountList.Count; ++index)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 14, index: " + index);
|
||||
num3 += __instance.groupCountList[index].count;
|
||||
if (num3 > __instance.numSpawned)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 15");
|
||||
GameStageGroup gameStageGroup = GameStageGroup.TryGet(__instance.groupCountList[index].groupName);
|
||||
if (gameStageGroup != null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 16");
|
||||
gameStageDefinition = gameStageGroup.spawner;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gameStageDefinition != null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 17");
|
||||
GameStageDefinition.Stage stage = gameStageDefinition.GetStage(__instance.gameStage);
|
||||
if (stage != null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 18");
|
||||
int spawnIndex = __instance.FindSpawnIndex(_world);
|
||||
if (spawnIndex >= 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 19");
|
||||
SleeperVolume.SpawnPoint spawnPoint = __instance.spawnPointList[spawnIndex];
|
||||
if (!__instance.CheckSpawnPos(_world, spawnPoint.pos))
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 20");
|
||||
__instance.spawnsAvailable.Add(spawnIndex);
|
||||
return false;
|
||||
}
|
||||
BlockSleeper block = spawnPoint.GetBlock();
|
||||
if (block == null)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 21");
|
||||
Log.Error("{0} BlockSleeper {1} null, type {2}", (object)cultureInvariantString, (object)spawnPoint.pos, (object)spawnPoint.blockType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 22");
|
||||
string _sEntityGroupName = block.spawnGroup;
|
||||
if (string.IsNullOrEmpty(_sEntityGroupName))
|
||||
{
|
||||
_sEntityGroupName = stage.GetSpawnGroup(0).groupName;
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 23");
|
||||
}
|
||||
int randomFromGroup = EntityGroups.GetRandomFromGroup(_sEntityGroupName, ref __instance.lastClassId, SleeperVolume.sleeperRandom);
|
||||
EntityClass entityClass;
|
||||
EntityClass.list.TryGetValue(randomFromGroup, out entityClass);
|
||||
Log.Out("{0} SleeperVolume {1}: Spawning {2} ({3}), group '{4}', class {5}, count {6}", (object)cultureInvariantString, (object)__instance.BoxMin, (object)spawnPoint.pos, (object)World.toChunkXZ(spawnPoint.pos), (object)_sEntityGroupName, entityClass != null ? (object)entityClass.entityClassName : (object)"?", (object)num1);
|
||||
if ((bool)(UnityEngine.Object)__instance.Spawn(_world, randomFromGroup, spawnIndex, block))
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 24");
|
||||
++__instance.numSpawned;
|
||||
}
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 25");
|
||||
return false;
|
||||
}
|
||||
__instance.isSpawning = false;
|
||||
__instance.respawnList = (List<int>)null;
|
||||
if (__instance.numSpawned != 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 26");
|
||||
return false;
|
||||
}
|
||||
if (__instance.respawnMap.Count == 0)
|
||||
{
|
||||
Log.Out("SleeperVolumePatches-UpdateSpawn 27");
|
||||
__instance.wasCleared = true;
|
||||
}
|
||||
Log.Out("{0} SleeperVolume {1}: None spawned, canSpawn {2}, respawnCnt {3}", (object)Time.time.ToCultureInvariantString(), (object)__instance.BoxMin, (object)flag1, (object)__instance.respawnMap.Count);
|
||||
|
||||
return false;*/
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Harmony.SpawnManagerBiomesPatches
|
||||
{
|
||||
/*public struct SCountAndRespawnDelay
|
||||
{
|
||||
public SCountAndRespawnDelay(int _count, ulong _delayWorldTime)
|
||||
{
|
||||
__instance.count = _count;
|
||||
__instance.delayWorldTime = _delayWorldTime;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("cnt={0} wtime={1}", __instance.count, __instance.delayWorldTime);
|
||||
}
|
||||
|
||||
public int count;
|
||||
public ulong delayWorldTime;
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(ChunkAreaBiomeSpawnData))]
|
||||
[HarmonyPatch("ResetRespawn")]
|
||||
public class ResetRespawnPatch
|
||||
{
|
||||
public static bool Prefix(ChunkAreaBiomeSpawnData __instance, int _idHash, World _world, int _maxCount)
|
||||
{
|
||||
//Log.Out("SpawnManagerBiomesPatches-ResetRespawn START");
|
||||
|
||||
BiomeDefinition biome = _world.Biomes.GetBiome(__instance.biomeId);
|
||||
if (biome == null)
|
||||
return false;
|
||||
BiomeSpawnEntityGroupList spawnEntityGroupList = BiomeSpawningClass.list[biome.m_sBiomeName];
|
||||
if (spawnEntityGroupList == null)
|
||||
return false;
|
||||
BiomeSpawnEntityGroupData spawnEntityGroupData = spawnEntityGroupList.Find(_idHash);
|
||||
if (spawnEntityGroupData == null)
|
||||
return false;
|
||||
ChunkAreaBiomeSpawnData.CountsAndTime countsAndTime;
|
||||
__instance.entitesSpawned.TryGetValue(_idHash, out countsAndTime);
|
||||
|
||||
float multiplier = 1f;
|
||||
|
||||
bool optionFeelingLucky = RebirthVariables.customFeelingLucky;
|
||||
|
||||
if (GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
optionFeelingLucky = false;
|
||||
}
|
||||
|
||||
if (optionFeelingLucky)
|
||||
{
|
||||
if (multiplier < 1f)
|
||||
{
|
||||
multiplier = multiplier * 0.9f;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier = multiplier * 0.8f;
|
||||
}
|
||||
}
|
||||
|
||||
countsAndTime.delayWorldTime = _world.worldTime + (ulong)((double)spawnEntityGroupData.respawnDelayInWorldTime * multiplier * (double)_world.RandomRange(0.9f, 1.1f));
|
||||
|
||||
//Log.Out("SpawnManagerBiomesPatches-ResetRespawn multiplier: " + multiplier);
|
||||
//Log.Out("SpawnManagerBiomesPatches-ResetRespawn countsAndTime.delayWorldTime: " + countsAndTime.delayWorldTime);
|
||||
|
||||
countsAndTime.maxCount = _maxCount;
|
||||
__instance.entitesSpawned[_idHash] = countsAndTime;
|
||||
__instance.chunk.isModified = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(ChunkAreaBiomeSpawnData))]
|
||||
[HarmonyPatch("SetRespawnDelay")]
|
||||
public class SetRespawnDelayPatch
|
||||
{
|
||||
public static bool Prefix(ChunkAreaBiomeSpawnData __instance, string _entityGroupName, ulong _currentWorldTime, WorldBiomes _worldBiomes,
|
||||
ref Dictionary<string, SCountAndRespawnDelay> ___entitesSpawned
|
||||
)
|
||||
{
|
||||
if (_entityGroupName == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BiomeDefinition biome = _worldBiomes.GetBiome(__instance.biomeId);
|
||||
if (biome == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BiomeSpawnEntityGroupList biomeSpawnEntityGroupList = BiomeSpawningClass.list[biome.m_sBiomeName];
|
||||
if (biomeSpawnEntityGroupList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BiomeSpawnEntityGroupData biomeSpawnEntityGroupData = biomeSpawnEntityGroupList.Find(_entityGroupName);
|
||||
if (biomeSpawnEntityGroupData == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int count = ___entitesSpawned.ContainsKey(_entityGroupName) ? ___entitesSpawned[_entityGroupName].count : 0;
|
||||
if (_entityGroupName.ToLower().StartsWith("zombies"))
|
||||
{
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay respawnDelayInWorldTime: " + biomeSpawnEntityGroupData.respawnDelayInWorldTime);
|
||||
string spawnMultiplierOption = RebirthVariables.customFreqZombieSpawns;
|
||||
float multiplier = 1f;
|
||||
|
||||
if (spawnMultiplierOption == "slowest")
|
||||
{
|
||||
multiplier = 4f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "slow")
|
||||
{
|
||||
multiplier = 2f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "fast")
|
||||
{
|
||||
multiplier = 0.8f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "faster")
|
||||
{
|
||||
multiplier = 0.6f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "fastest")
|
||||
{
|
||||
multiplier = 0.4f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "relentless")
|
||||
{
|
||||
multiplier = 0.2f;
|
||||
}
|
||||
else if (spawnMultiplierOption == "gradualslower")
|
||||
{
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
if (currentDay <= 14)
|
||||
{
|
||||
multiplier = 4f;
|
||||
}
|
||||
else if (currentDay > 15 && currentDay <= 28)
|
||||
{
|
||||
multiplier = 2f;
|
||||
}
|
||||
else if (currentDay > 29 && currentDay <= 49)
|
||||
{
|
||||
multiplier = 1f;
|
||||
}
|
||||
else if (currentDay > 50 && currentDay <= 70)
|
||||
{
|
||||
multiplier = 0.8f;
|
||||
}
|
||||
else if (currentDay > 71)
|
||||
{
|
||||
multiplier = 0.6f;
|
||||
}
|
||||
}
|
||||
else if (spawnMultiplierOption == "gradual")
|
||||
{
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
if (currentDay <= 7)
|
||||
{
|
||||
multiplier = 4f;
|
||||
}
|
||||
else if (currentDay > 7 && currentDay <= 14)
|
||||
{
|
||||
multiplier = 2f;
|
||||
}
|
||||
else if (currentDay > 15 && currentDay <= 28)
|
||||
{
|
||||
multiplier = 1f;
|
||||
}
|
||||
else if (currentDay > 29 && currentDay <= 42)
|
||||
{
|
||||
multiplier = 0.8f;
|
||||
}
|
||||
else if (currentDay > 43)
|
||||
{
|
||||
multiplier = 0.6f;
|
||||
}
|
||||
}
|
||||
else if (spawnMultiplierOption == "gradualfaster")
|
||||
{
|
||||
int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime);
|
||||
|
||||
if (currentDay <= 7)
|
||||
{
|
||||
multiplier = 4f;
|
||||
}
|
||||
else if (currentDay > 8 && currentDay <= 14)
|
||||
{
|
||||
multiplier = 2f;
|
||||
}
|
||||
else if (currentDay > 15 && currentDay <= 21)
|
||||
{
|
||||
multiplier = 1f;
|
||||
}
|
||||
else if (currentDay > 22 && currentDay <= 28)
|
||||
{
|
||||
multiplier = 0.8f;
|
||||
}
|
||||
else if (currentDay > 29)
|
||||
{
|
||||
multiplier = 0.6f;
|
||||
}
|
||||
}
|
||||
|
||||
bool optionFeelingLucky = RebirthVariables.customFeelingLucky;
|
||||
if (GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
optionFeelingLucky = false;
|
||||
}
|
||||
|
||||
if (optionFeelingLucky)
|
||||
{
|
||||
if (multiplier < 1f)
|
||||
{
|
||||
multiplier = multiplier * 0.9f;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier = multiplier * 0.8f;
|
||||
}
|
||||
}
|
||||
|
||||
ulong respawnDelay = (ulong)((long)biomeSpawnEntityGroupData.respawnDelayInWorldTime);
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay respawnDelay: " + respawnDelay);
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay multiplier: " + multiplier);
|
||||
|
||||
if (respawnDelay > 0)
|
||||
{
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay BEFORE respawnDelay: " + respawnDelay);
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay multiplier: " + multiplier);
|
||||
respawnDelay = (ulong)(respawnDelay * multiplier);
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay MULTIPLIER respawnDelay: " + respawnDelay);
|
||||
//Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay AFTER respawnDelay: " + respawnDelay);
|
||||
}
|
||||
|
||||
respawnDelay = _currentWorldTime + respawnDelay;
|
||||
|
||||
try
|
||||
{
|
||||
___entitesSpawned[_entityGroupName] = new SCountAndRespawnDelay(count, respawnDelay);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Out("SpawnManagerBiomesPatches-SetRespawnDelay error accessing array for group: " + _entityGroupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
__instance.chunk.isModified = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(SpawnManagerBiomes))]
|
||||
[HarmonyPatch("SpawnUpdate")]
|
||||
public class SpawnUpdatePatch
|
||||
{
|
||||
public static bool Prefix(SpawnManagerBiomes __instance, string _spawnerName, bool _isSpawnEnemy, ChunkAreaBiomeSpawnData _spawnData,
|
||||
World ___world
|
||||
)
|
||||
{
|
||||
List<EntityPlayer> players = ___world.GetPlayers();
|
||||
for (int i = 0; i < players.Count; i++)
|
||||
{
|
||||
EntityPlayer entityPlayer = players[i];
|
||||
if (entityPlayer.Spawned)
|
||||
{
|
||||
//Log.Out("SpawnManagerBiomesPatches-SpawnUpdate entityPlayer: " + entityPlayer.EntityName);
|
||||
Rect rect = new Rect(entityPlayer.position.x - 40f, entityPlayer.position.z - 40f, 80f, 80f);
|
||||
if (rect.Overlaps(_spawnData.area))
|
||||
{
|
||||
RebirthVariables.playerLevel = entityPlayer.Progression.Level;
|
||||
|
||||
//Log.Out("SpawnManagerBiomesPatches-SpawnUpdate RebirthVariables.playerLevel: " + RebirthVariables.playerLevel);
|
||||
|
||||
RebirthVariables.biomeGameStage = entityPlayer.gameStage;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
string biomeName = RebirthUtilities.GetBiomeName(entityPlayer);
|
||||
|
||||
//Log.Out("SpawnManagerBiomesPatches-SpawnUpdate START: " + entityPlayer.biomeStandingOn.m_sBiomeName + $" ({entityPlayer.position})");
|
||||
if (biomeName != "")
|
||||
{
|
||||
RebirthUtilities.SetHiveSpawnGroup(biomeName);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("SpawnManagerBiomesPatches-SpawnUpdate Player [" + entityPlayer.EntityName + "] gameStage: " + entityPlayer.gameStage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
using XMLEditing;
|
||||
using static EntityDrone;
|
||||
|
||||
namespace Harmony.SpawnPointListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SpawnPointList))]
|
||||
[HarmonyPatch("GetRandomSpawnPosition")]
|
||||
public class GetRandomSpawnPositionPatch
|
||||
{
|
||||
public static bool Prefix(SpawnPointList __instance, ref SpawnPosition __result, World _world, Vector3? _refPosition = null, int _minDistance = 0, int _maxDistance = 0)
|
||||
{
|
||||
//Log.Out("===================================================================");
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition START");
|
||||
//Log.Out("===================================================================");
|
||||
|
||||
if (_world.IsEditor() || GameUtils.IsWorldEditor() || GameUtils.IsPlaytesting())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (__instance.Count > 0)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition 1, __instance.Count: " + __instance.Count);
|
||||
bool bFound = false;
|
||||
|
||||
string biome = RebirthVariables.customBiomeSpawn;
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition biome: " + biome);
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition HIVE");
|
||||
|
||||
List<PrefabInstance> prefabInstances = new List<PrefabInstance> ();
|
||||
|
||||
foreach (string prefabName in RebirthVariables.hivePrefab)
|
||||
{
|
||||
var matchingInstances = GameManager.Instance.World.ChunkClusters[0].ChunkProvider
|
||||
.GetDynamicPrefabDecorator()
|
||||
.GetDynamicPrefabs()
|
||||
.FindAll(instance => instance.name.Contains(prefabName));
|
||||
|
||||
prefabInstances.AddRange(matchingInstances);
|
||||
}
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition prefabInstances.Count: " + prefabInstances.Count);
|
||||
|
||||
if (prefabInstances.Count > 0)
|
||||
{
|
||||
List<PrefabInstance> validPrefabs = new List<PrefabInstance>();
|
||||
|
||||
foreach (PrefabInstance prefab in prefabInstances)
|
||||
{
|
||||
Vector2 prefabPosition = new Vector2((float)prefab.boundingBoxPosition.x + (float)prefab.boundingBoxSize.x / 2f, (float)prefab.boundingBoxPosition.z + (float)prefab.boundingBoxSize.z / 2f);
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition prefabPosition: " + prefabPosition);
|
||||
|
||||
BiomeDefinition biomeAt = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)prefabPosition.x, (int)prefabPosition.y);
|
||||
|
||||
if (biomeAt != null && biomeAt.m_sBiomeName == "pine_forest")
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition biomeAt.m_sBiomeName: " + biomeAt.m_sBiomeName);
|
||||
validPrefabs.Add(prefab);
|
||||
}
|
||||
}
|
||||
|
||||
if (validPrefabs.Count > 0)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition PARSING VALID PREFABS: " + validPrefabs.Count);
|
||||
int random = Manager.random.RandomRange(0, validPrefabs.Count);
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition random: " + random);
|
||||
PrefabInstance selectedPrefab = validPrefabs[random];
|
||||
|
||||
Vector3 prefabPosition = selectedPrefab.boundingBoxPosition;
|
||||
|
||||
if (selectedPrefab != null)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition selectedPrefab.boundingBoxPosition: " + selectedPrefab.boundingBoxPosition);
|
||||
__result = new SpawnPosition(selectedPrefab.boundingBoxPosition, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (biome == "random")
|
||||
{
|
||||
GameRandom gameRandom = _world.GetGameRandom();
|
||||
if (_refPosition == null)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition RANDOM BIOME 1");
|
||||
__result = __instance[gameRandom.RandomRange(__instance.Count)].spawnPosition;
|
||||
return false;
|
||||
|
||||
}
|
||||
Vector3 value = _refPosition.Value;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int index = gameRandom.RandomRange(__instance.Count);
|
||||
SpawnPosition spawnPosition = __instance[index].spawnPosition;
|
||||
float magnitude = (spawnPosition.position - value).magnitude;
|
||||
if (magnitude >= (float)_minDistance && magnitude <= (float)_maxDistance)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition RANDOM BIOME 2");
|
||||
__result = spawnPosition;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
float num = float.MaxValue;
|
||||
int num2 = -1;
|
||||
for (int j = 0; j < __instance.Count; j++)
|
||||
{
|
||||
float sqrMagnitude = (__instance[j].spawnPosition.position - value).sqrMagnitude;
|
||||
if (sqrMagnitude < num)
|
||||
{
|
||||
num = sqrMagnitude;
|
||||
num2 = j;
|
||||
}
|
||||
}
|
||||
if (num2 != -1)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition RANDOM BIOME 3");
|
||||
__result = __instance[num2].spawnPosition;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition RANDOM BIOME 4");
|
||||
__result = SpawnPosition.Undef;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GameUtils.IsPlaytesting() && biome != "randomtrader")
|
||||
{
|
||||
for (int j = 0; j < __instance.Count; j++)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition 2, j: " + j + " / position: " + __instance[j].spawnPosition);
|
||||
|
||||
string biomeName = RebirthUtilities.GetBiomeName(__instance[j].spawnPosition.ToBlockPos());
|
||||
|
||||
if (biomeName != "")
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition A, biomeAt.m_Id: " + biomeAt.m_Id);
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition A, biomeName: " + biomeName);
|
||||
|
||||
bool isValidBiome = false;
|
||||
|
||||
if (biomeName == biome)
|
||||
{
|
||||
isValidBiome = true;
|
||||
}
|
||||
else if (biomeName == "pine_forest" && biome == "forest")
|
||||
{
|
||||
isValidBiome = true;
|
||||
}
|
||||
else if (biomeName == "burnt_forest" && biome == "burnt")
|
||||
{
|
||||
isValidBiome = true;
|
||||
}
|
||||
|
||||
if (isValidBiome)
|
||||
{
|
||||
__result = __instance[j].spawnPosition;
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition B, __result.position: " + __result.position);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFound)
|
||||
{
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition 5");
|
||||
|
||||
int index = UnityEngine.Random.Range(0, __instance.Count - 1);
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition 6, index: " + index);
|
||||
|
||||
__result = __instance[index].spawnPosition;
|
||||
|
||||
int height = (int)GameManager.Instance.World.GetHeightAt(__result.position.x, __result.position.y);
|
||||
|
||||
__result.position.y = height;
|
||||
|
||||
//Log.Out("SpawnPointListPatches-GetRandomSpawnPosition 7, __result.position: " + __result.position);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = SpawnPosition.Undef;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.SpawnPointManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SpawnPointManager))]
|
||||
[HarmonyPatch("Load")]
|
||||
public class LoadPatch
|
||||
{
|
||||
public static bool Prefix(SpawnPointManager __instance, bool __result, string _path)
|
||||
{
|
||||
//Log.Out("===================================================================");
|
||||
//Log.Out("SpawnPointManagerPatches-Load START");
|
||||
//Log.Out("===================================================================");
|
||||
|
||||
int numFound = 0;
|
||||
|
||||
string biome = RebirthVariables.customBiomeSpawn;
|
||||
|
||||
if (biome == "random")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
List<PrefabInstance> prefabInstances = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetDynamicPrefabs().FindAll(instance => instance.name.Contains("trader_"));
|
||||
|
||||
if (prefabInstances.Count > 0)
|
||||
{
|
||||
//Log.Out("SpawnPointManagerPatches-Load 1, prefabInstances.Count: " + prefabInstances.Count);
|
||||
|
||||
Vector3 vector = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < prefabInstances.Count; i++)
|
||||
{
|
||||
//Log.Out("SpawnPointManagerPatches-Load 2, i: " + i);
|
||||
|
||||
//Log.Out("SpawnPointManagerPatches-Load 2, prefabInstances[i].name: " + prefabInstances[i].name);
|
||||
|
||||
Vector2 position = new Vector2((float)prefabInstances[i].boundingBoxPosition.x, (float)prefabInstances[i].boundingBoxPosition.z);
|
||||
|
||||
if (position.x == -0.1f && position.y == -0.1f)
|
||||
{
|
||||
//Log.Out("SpawnPointManagerPatches-Load 3");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("SpawnPointManagerPatches-Load 4");
|
||||
int num = (int)position.x;
|
||||
int num2 = (int)position.y;
|
||||
int num3 = (int)GameManager.Instance.World.GetHeightAt(position.x, position.y);
|
||||
|
||||
//Log.Out("SpawnPointManagerPatches-Load num3: " + num3);
|
||||
|
||||
Vector3 positionTrader = new Vector3((float)num, (float)num3, (float)num2);
|
||||
numFound++;
|
||||
__instance.spawnPointList.Add(new SpawnPoint(positionTrader, vector.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numFound == 0)
|
||||
{
|
||||
//Log.Out("SpawnPointManagerPatches-Load 7");
|
||||
if (!SdFile.Exists(_path + "/spawnpoints.xml"))
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (XElement element in new XmlFile(_path, "spawnpoints", false, false).XmlDoc.Root.Elements("spawnpoint"))
|
||||
{
|
||||
Vector3 position = StringParsers.ParseVector3(element.GetAttribute("position"), 0, -1);
|
||||
Vector3 vector = Vector3.zero;
|
||||
if (element.HasAttribute("rotation"))
|
||||
{
|
||||
vector = StringParsers.ParseVector3(element.GetAttribute("rotation"), 0, -1);
|
||||
}
|
||||
__instance.spawnPointList.Add(new SpawnPoint(position, vector.y));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Loading spawnpoints xml file for level '" + Path.GetFileName(_path) + "': " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Harmony.StatRebirth
|
||||
{
|
||||
public class StatPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(Stat))]
|
||||
[HarmonyPatch("Tick")]
|
||||
public class Tick
|
||||
{
|
||||
public static MethodInfo SetChangedFlag = AccessTools.Method(typeof(Stat), "SetChangedFlag", new Type[] { typeof(float), typeof(float) });
|
||||
|
||||
private static bool Prefix(Stat __instance, float dt, ulong worldTime, bool godMode,
|
||||
ref float ___m_originalBaseMax,
|
||||
ref float ___m_lastValue,
|
||||
ref float ___m_value,
|
||||
ref bool ___m_isEntityAlive,
|
||||
ref bool ___m_isEntityPlayer,
|
||||
ref float ___m_baseMax,
|
||||
ref bool ___m_changed
|
||||
)
|
||||
{
|
||||
if (__instance.Entity is EntitySupplyCrate)
|
||||
{
|
||||
float healthMax = __instance.Entity.Buffs.GetCustomVar("$healthMax");
|
||||
|
||||
if (healthMax > 0)
|
||||
{
|
||||
__instance.Entity.Stats.Health.BaseMax = healthMax;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.MaxPassive != PassiveEffects.None)
|
||||
{
|
||||
__instance.BaseMax = EffectManager.GetValue(__instance.MaxPassive, null, ___m_originalBaseMax, __instance.Entity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
||||
}
|
||||
___m_isEntityAlive = (__instance.Entity != null);
|
||||
___m_isEntityPlayer = (__instance.Entity as global::EntityPlayer != null);
|
||||
if ((__instance.StatType == Stat.StatTypes.Stamina || __instance.StatType == Stat.StatTypes.Health) && Mathf.Abs(___m_lastValue - ___m_value) >= 1f)
|
||||
{
|
||||
if (___m_value > ___m_lastValue && __instance.GainPassive != PassiveEffects.None)
|
||||
{
|
||||
___m_value = Mathf.Clamp(___m_lastValue + EffectManager.GetValue(__instance.GainPassive, null, ___m_value - ___m_lastValue, __instance.Entity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1), 0f, ___m_baseMax);
|
||||
}
|
||||
else if (___m_value < ___m_lastValue && __instance.LossPassive != PassiveEffects.None)
|
||||
{
|
||||
___m_value = Mathf.Clamp(___m_lastValue - EffectManager.GetValue(__instance.LossPassive, null, ___m_lastValue - ___m_value, __instance.Entity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1), 0f, ___m_baseMax);
|
||||
}
|
||||
}
|
||||
if (___m_value + __instance.RegenerationAmount > __instance.ModifiedMax)
|
||||
{
|
||||
__instance.RegenerationAmount = __instance.ModifiedMax - ___m_value;
|
||||
}
|
||||
___m_value += __instance.RegenerationAmount;
|
||||
if (__instance.RegenerationAmount > 0f)
|
||||
{
|
||||
if (__instance.StatType == Stat.StatTypes.Stamina)
|
||||
{
|
||||
__instance.Entity.Stats.Water.RegenerationAmount -= __instance.RegenerationAmount * EffectManager.GetValue(PassiveEffects.WaterLossPerStaminaPointGained, null, 1f, __instance.Entity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
||||
__instance.Entity.Stats.Food.RegenerationAmount -= __instance.RegenerationAmount * EffectManager.GetValue(PassiveEffects.FoodLossPerStaminaPointGained, null, 1f, __instance.Entity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
||||
}
|
||||
}
|
||||
__instance.RegenerationAmount = ___m_value - ___m_lastValue;
|
||||
SetChangedFlag.Invoke(__instance, new object[] { ___m_value, ___m_lastValue });
|
||||
___m_lastValue = ___m_value;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.TEFeatureSignablePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TEFeatureSignable))]
|
||||
[HarmonyPatch("InitBlockActivationCommands")]
|
||||
public class InitBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(TEFeatureSignable __instance, Action<BlockActivationCommand, TileEntityComposite.EBlockCommandOrder, TileEntityFeatureData> _addCallback)
|
||||
{
|
||||
_addCallback(new BlockActivationCommand("take", "hand", false), TileEntityComposite.EBlockCommandOrder.Normal, __instance.FeatureData);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TEFeatureSignable))]
|
||||
[HarmonyPatch("UpdateBlockActivationCommands")]
|
||||
public class UpdateBlockActivationCommandsPatch
|
||||
{
|
||||
public static void Postfix(TEFeatureSignable __instance, ref BlockActivationCommand _command, ReadOnlySpan<char> _commandName, WorldBase _world, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (__instance.CommandIs(_commandName, "take"))
|
||||
{
|
||||
if (__instance.lockFeature != null && __instance.TryGetSelfOrFeature(out ITileEntityLootable storage))
|
||||
{
|
||||
_command.enabled = storage.IsEmpty() && __instance.lockFeature.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TEFeatureSignable))]
|
||||
[HarmonyPatch("OnBlockActivated")]
|
||||
public class OnBlockActivatedPatch
|
||||
{
|
||||
public static void Postfix(TEFeatureSignable __instance, ReadOnlySpan<char> _commandName, WorldBase _world, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (__instance.CommandIs(_commandName, "take"))
|
||||
{
|
||||
RebirthUtilities.TakeItemWithTimer(_world, 0, _blockPos, _blockValue, _player, 2f, null, "", 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
namespace Harmony.TileEntityAdditionRebirth
|
||||
{
|
||||
public class TileEntityAddition
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(TileEntity))]
|
||||
[HarmonyPatch("Instantiate")]
|
||||
public class TileEntityIsActive
|
||||
{
|
||||
public static bool Prefix(ref TileEntity __result, TileEntityType type, Chunk _chunk)
|
||||
{
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntitySpawnPoint)
|
||||
{
|
||||
__result = new TileEntitySpawnPoint(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntitySpawnPOIEntityRebirth)
|
||||
{
|
||||
__result = new TileEntitySpawnPOIEntityRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntitySecureBlockRebirth)
|
||||
{
|
||||
__result = new TileEntitySecureBlockRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntitySecureLootContainerRebirth)
|
||||
{
|
||||
__result = new TileEntitySecureLootContainerRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityAoE)
|
||||
{
|
||||
__result = new TileEntityAoE(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityAnimalChickenRebirth)
|
||||
{
|
||||
__result = new TileEntityAnimalChickenRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntitySurvivorRebirth)
|
||||
{
|
||||
__result = new TileEntitySurvivorRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityChickenCoopRebirth)
|
||||
{
|
||||
__result = new TileEntityChickenCoopRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityPlantGrowingRebirth)
|
||||
{
|
||||
__result = new TileEntityPlantGrowingRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityWaterTankRebirth)
|
||||
{
|
||||
__result = new TileEntityWaterTankRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityResourceFeederRebirth)
|
||||
{
|
||||
__result = new TileEntityResourceFeederRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityFarmPlotRebirth)
|
||||
{
|
||||
__result = new TileEntityFarmPlotRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityTimedBlockRebirth)
|
||||
{
|
||||
__result = new TileEntityTimedBlockRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityManualLightRebirth)
|
||||
{
|
||||
__result = new TileEntityManualLightRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityDriveableLootContainer)
|
||||
{
|
||||
__result = new TileEntityDriveableLootContainer(_chunk);
|
||||
return false;
|
||||
}
|
||||
if (type == (TileEntityType)RebirthUtilities.TileEntityRebirth.TileEntityWorkstationRebirth)
|
||||
{
|
||||
__result = new TileEntityWorkstationRebirth(_chunk);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
namespace Harmony.TileEntityLootContainerAdditionRebirth
|
||||
{
|
||||
public class TileEntityLootContainerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntityLootContainer))]
|
||||
[HarmonyPatch("UpdateTick")]
|
||||
public class UpdateTickPatch
|
||||
{
|
||||
public static bool Prefix(TileEntityLootContainer __instance, World world)
|
||||
{
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TileEntityLootContainer))]
|
||||
[HarmonyPatch("write")]
|
||||
public class WritePatch
|
||||
{
|
||||
public static bool Prefix(TileEntityLootContainer __instance, PooledBinaryWriter stream, TileEntity.StreamModeWrite _eStreamMode)
|
||||
{
|
||||
if (__instance.lootListName == "traderNPC")
|
||||
{
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("TileEntityLootContainerPatches-write __instance.EntityId: " + __instance.EntityId);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageEntityLootContainerWriteRebirth>().Setup(__instance.EntityId, __instance.items), false);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TileEntityLootContainer))]
|
||||
[HarmonyPatch("read")]
|
||||
public class ReadPatch
|
||||
{
|
||||
public static bool Prefix(TileEntityLootContainer __instance, PooledBinaryReader _br, TileEntity.StreamModeRead _eStreamMode)
|
||||
{
|
||||
if (_eStreamMode == TileEntity.StreamModeRead.Persistency)
|
||||
{
|
||||
__instance.readVersion = (int)_br.ReadUInt16();
|
||||
__instance.localChunkPos = StreamUtils.ReadVector3i((BinaryReader)_br);
|
||||
__instance.entityId = _br.ReadInt32();
|
||||
if (__instance.readVersion <= 1)
|
||||
return false;
|
||||
__instance.heapMapUpdateTime = _br.ReadUInt64();
|
||||
__instance.heapMapLastTime = __instance.heapMapUpdateTime - AIDirector.GetActivityWorldTimeDelay();
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.localChunkPos = StreamUtils.ReadVector3i((BinaryReader)_br);
|
||||
__instance.entityId = _br.ReadInt32();
|
||||
}
|
||||
if (_eStreamMode == TileEntity.StreamModeRead.Persistency && __instance.readVersion <= 8)
|
||||
throw new Exception("Outdated loot data");
|
||||
if (_br.ReadBoolean())
|
||||
__instance.lootListName = _br.ReadString();
|
||||
__instance.containerSize = new Vector2i();
|
||||
__instance.containerSize.x = (int)_br.ReadUInt16();
|
||||
__instance.containerSize.y = (int)_br.ReadUInt16();
|
||||
__instance.bTouched = _br.ReadBoolean();
|
||||
__instance.worldTimeTouched = (ulong)_br.ReadUInt32();
|
||||
__instance.bPlayerBackpack = _br.ReadBoolean();
|
||||
int num = Math.Min((int)_br.ReadInt16(), __instance.containerSize.x * __instance.containerSize.y);
|
||||
if (__instance.bUserAccessing)
|
||||
{
|
||||
ItemStack itemStack = ItemStack.Empty.Clone();
|
||||
if (_eStreamMode == TileEntity.StreamModeRead.Persistency && __instance.readVersion < 3)
|
||||
{
|
||||
for (int index = 0; index < num; ++index)
|
||||
itemStack.ReadOld((BinaryReader)_br);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < num; ++index)
|
||||
itemStack.Read((BinaryReader)_br);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.containerSize.x * __instance.containerSize.y != __instance.items.Length)
|
||||
__instance.items = ItemStack.CreateArray(__instance.containerSize.x * __instance.containerSize.y);
|
||||
if (_eStreamMode == TileEntity.StreamModeRead.Persistency && __instance.readVersion < 3)
|
||||
{
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
__instance.items[index].Clear();
|
||||
__instance.items[index].ReadOld((BinaryReader)_br);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
__instance.items[index].Clear();
|
||||
__instance.items[index].Read((BinaryReader)_br);
|
||||
}
|
||||
}
|
||||
}
|
||||
__instance.bPlayerStorage = _br.ReadBoolean();
|
||||
if (_eStreamMode == TileEntity.StreamModeRead.Persistency && __instance.readVersion <= 9 || !_br.ReadBoolean())
|
||||
return false;
|
||||
__instance.preferences = new PreferenceTracker(-1);
|
||||
__instance.preferences.Read(_br);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.TileEntitySignPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntitySign))]
|
||||
[HarmonyPatch("SetText")]
|
||||
[HarmonyPatch(new[] { typeof(string), typeof(bool), typeof(PlatformUserIdentifierAbs) })]
|
||||
public class SetTextPatch
|
||||
{
|
||||
public static bool Prefix(TileEntitySign __instance, string _text, bool _syncData, PlatformUserIdentifierAbs _signingPlayer)
|
||||
{
|
||||
if (_signingPlayer == null)
|
||||
{
|
||||
_signingPlayer = PlatformManager.MultiPlatform.User.PlatformUserId;
|
||||
}
|
||||
|
||||
// Check for null as Vanilla code generates an error if still null
|
||||
if (_signingPlayer != null && GameManager.Instance.persistentPlayers != null)
|
||||
{
|
||||
if (GameManager.Instance.persistentPlayers.GetPlayerData(_signingPlayer) == null)
|
||||
{
|
||||
_signingPlayer = (PlatformUserIdentifierAbs)null;
|
||||
_text = "";
|
||||
}
|
||||
if (_text == __instance.signText.Text)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.signText.Update(_text, _signingPlayer);
|
||||
GeneratedTextManager.GetDisplayText(__instance.signText, new Action<string>(__instance.RefreshTextMesh), true, true, GeneratedTextManager.TextFilteringMode.FilterWithSafeString, GeneratedTextManager.BbCodeSupportMode.NotSupported);
|
||||
if (!_syncData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance.setModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.TileEntityWorkstationPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation))]
|
||||
[HarmonyPatch(MethodType.Constructor)]
|
||||
[HarmonyPatch(new Type[] { typeof(Chunk) })]
|
||||
public static class TileEntityWorkstationConstructor
|
||||
{
|
||||
public static void Postfix(ref ItemStack[] ___output)
|
||||
{
|
||||
___output = ItemStack.CreateArray(16);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation))]
|
||||
[HarmonyPatch("UpdateTick")]
|
||||
public class UpdateTickPatch
|
||||
{
|
||||
public static void Postfix(TileEntityWorkstation __instance, World world
|
||||
)
|
||||
{
|
||||
if (__instance.IsBurning)
|
||||
{
|
||||
if (__instance.blockValue.Block.GetBlockName().Contains("FuriousRamsayScreamerSignalTier"))
|
||||
{
|
||||
if ((Time.time - RebirthVariables.screamerCheck) > 10f)
|
||||
{
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update BlockName: " + __instance.blockValue.Block.GetBlockName());
|
||||
RebirthVariables.screamerCheck = Time.time;
|
||||
|
||||
RebirthUtilities.SpawnScreamer(__instance.ToWorldPos());
|
||||
|
||||
Vector3i position = __instance.ToWorldPos();
|
||||
|
||||
int searchDistance = 150;
|
||||
|
||||
List<Entity> entitiesInBounds = world.GetEntitiesInBounds(typeof(EntityPlayer), BoundsUtils.BoundsForMinMax(position.x - searchDistance, position.y - 50, position.z - searchDistance, position.x + searchDistance, position.y + 50, position.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update entitiesInBounds: " + entitiesInBounds.Count);
|
||||
|
||||
for (int i = 0; i < entitiesInBounds.Count; i++)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)entitiesInBounds[i];
|
||||
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update entityPlayer: " + entityPlayer.EntityName);
|
||||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update ADDE BUFF");
|
||||
entityPlayer.Buffs.AddBuff("FuriousRamsayScreamerSignalActive");
|
||||
}
|
||||
}
|
||||
|
||||
entitiesInBounds = world.GetEntitiesInBounds(typeof(EntityNPCRebirth), BoundsUtils.BoundsForMinMax(position.x - searchDistance, position.y - 50, position.z - searchDistance, position.x + searchDistance, position.y + 50, position.z + searchDistance), new List<Entity>());
|
||||
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update entitiesInBounds: " + entitiesInBounds.Count);
|
||||
|
||||
for (int i = 0; i < entitiesInBounds.Count; i++)
|
||||
{
|
||||
EntityNPCRebirth npc = (EntityNPCRebirth)entitiesInBounds[i];
|
||||
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update entityPlayer: " + entityPlayer.EntityName);
|
||||
|
||||
if (npc != null)
|
||||
{
|
||||
//Log.Out("XUiC_ScreamerSignalWindowGroup-Update ADDE BUFF");
|
||||
npc.Buffs.AddBuff("FuriousRamsayScreamerSignalActive");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
namespace Harmony.TraderDataPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TraderData))]
|
||||
[HarmonyPatch("Read")]
|
||||
public class ReadPatch
|
||||
{
|
||||
public static bool Prefix(TraderData __instance, byte _version, BinaryReader _br
|
||||
)
|
||||
{
|
||||
__instance.TraderID = _br.ReadInt32();
|
||||
|
||||
if (__instance.TraderID == 1919247457 || __instance.TraderID == 0)
|
||||
{
|
||||
__instance.TraderID = 100;
|
||||
}
|
||||
|
||||
__instance.lastInventoryUpdate = _br.ReadUInt64();
|
||||
_br.ReadByte();
|
||||
|
||||
//Log.Out("TraderDataPatches-Read __instance.TraderID: " + __instance.TraderID);
|
||||
|
||||
if (__instance.TraderID != 100)
|
||||
{
|
||||
__instance.ReadInventoryData(_br);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TraderData))]
|
||||
[HarmonyPatch("Write")]
|
||||
public class WritePatch
|
||||
{
|
||||
public static bool Prefix(TraderData __instance, BinaryWriter _bw
|
||||
)
|
||||
{
|
||||
if (__instance.TraderID == 1919247457 || __instance.TraderID == 0)
|
||||
{
|
||||
__instance.TraderID = 100;
|
||||
}
|
||||
|
||||
_bw.Write(__instance.TraderID);
|
||||
_bw.Write(__instance.lastInventoryUpdate);
|
||||
_bw.Write(TraderData.FileVersion);
|
||||
|
||||
//Log.Out("TraderDataPatches-Write __instance.TraderID: " + __instance.TraderID);
|
||||
|
||||
if (__instance.TraderID != 100)
|
||||
{
|
||||
__instance.WriteInventoryData(_bw);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.VPHeadlightPatches
|
||||
{
|
||||
public class Headlights
|
||||
{
|
||||
public float durability;
|
||||
public int quality;
|
||||
public int side;
|
||||
|
||||
public Headlights()
|
||||
{
|
||||
}
|
||||
|
||||
public Headlights(float _durability, int _quality, int _side)
|
||||
{
|
||||
durability = _durability;
|
||||
quality = _quality;
|
||||
side = _side;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(VPHeadlight), "Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static bool Prefix(VPHeadlight __instance, float _dt)
|
||||
{
|
||||
if (__instance.IsBroken())
|
||||
{
|
||||
__instance.SetOn(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int numLights = 0;
|
||||
float durability = 0f;
|
||||
int side = 0;
|
||||
float quality = 0;
|
||||
int index = 0;
|
||||
|
||||
List<Headlights> headlights = new List<Headlights>();
|
||||
var entityVehicle = __instance.vehicle.entity as EntityVehicleRebirth;
|
||||
|
||||
if (entityVehicle == null) return false;
|
||||
|
||||
foreach (ItemValue item in entityVehicle.itemValues)
|
||||
{
|
||||
if (item.type == ItemValue.None.type || (item.MaxUseTimes - item.UseTimes <= 0) || item.ItemClass == null)
|
||||
{
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Log.Out("entityVehicle.itemValues[" + index + "]: " + entityVehicle.itemValues[index].ItemClass.Name);
|
||||
|
||||
if (item.ItemClass.GetItemName() == "resourceHeadlight")
|
||||
{
|
||||
durability += item.PercentUsesLeft;
|
||||
quality += item.Quality;
|
||||
numLights++;
|
||||
side = index % 2;
|
||||
headlights.Add(new Headlights() { quality = item.Quality, durability = item.PercentUsesLeft, side = side });
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
if (numLights == 0)
|
||||
{
|
||||
__instance.SetOn(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance.lights != null && entityVehicle.itemValues != null && entityVehicle.itemValues.Length >= __instance.lights.Count)
|
||||
{
|
||||
//Log.Out("VPHeadlightPatches-Update __instance.lights.Count: " + __instance.lights.Count);
|
||||
|
||||
for (int i = 0; i < __instance.lights.Count; i++)
|
||||
{
|
||||
Light light = __instance.lights[i];
|
||||
//Log.Out("VPHeadlightPatches-Update light.name[" + i + "]: " + light.name);
|
||||
|
||||
ItemValue item = entityVehicle.itemValues[i];
|
||||
|
||||
float brightness = 0;
|
||||
float range = 0;
|
||||
|
||||
if (__instance.lights.Count == 1)
|
||||
{
|
||||
quality = headlights[i].quality;
|
||||
float num = 0.2f + (0.3f * __instance.vehicle.EffectLightIntensity * headlights[i].durability);
|
||||
float num2 = 0.5f * quality / 6;
|
||||
|
||||
range = 35f + 0.5f * (50f * num);
|
||||
|
||||
if (numLights == 1)
|
||||
{
|
||||
num *= 0.85f;
|
||||
}
|
||||
|
||||
brightness = 0.25f + num + num2;
|
||||
}
|
||||
else
|
||||
{
|
||||
side = -1;
|
||||
|
||||
if (light.name.ToLower().Contains("left"))
|
||||
{
|
||||
side = 0;
|
||||
}
|
||||
else if (light.name.ToLower().Contains("right"))
|
||||
{
|
||||
side = 1;
|
||||
}
|
||||
|
||||
//Log.Out("VPHeadlightPatches-Update side: " + side);
|
||||
|
||||
for (int j = 0; j < headlights.Count; j++)
|
||||
{
|
||||
//Log.Out("VPHeadlightPatches-Update headlights[" + j + "].quality: " + headlights[j].quality);
|
||||
//Log.Out("VPHeadlightPatches-Update headlights[" + j + "].durability: " + headlights[j].durability);
|
||||
//Log.Out("VPHeadlightPatches-Update headlights[" + j + "].side: " + headlights[j].side);
|
||||
|
||||
if (headlights[j].side == side || (side == -1 && headlights.Count > 0))
|
||||
{
|
||||
quality = headlights[j].quality;
|
||||
float num = 0.2f + (0.3f * __instance.vehicle.EffectLightIntensity * headlights[j].durability);
|
||||
float num2 = 0.5f * quality / 6;
|
||||
|
||||
range = 35f + 0.5f * (50f * num);
|
||||
|
||||
if (numLights == 1)
|
||||
{
|
||||
num *= 0.85f;
|
||||
}
|
||||
|
||||
brightness = 0.25f + num + num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
light.intensity = brightness;
|
||||
light.range = range;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.VehiclePartPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(VehiclePart))]
|
||||
[HarmonyPatch("IsBroken")]
|
||||
public class DamageVehiclePartPatch
|
||||
{
|
||||
public static bool Prefix(VehiclePart __instance, ref bool __result,
|
||||
Vehicle ___vehicle
|
||||
)
|
||||
{
|
||||
__result = false;
|
||||
|
||||
//Log.Out("VehiclePartPatches-IsBroken START");
|
||||
|
||||
if (___vehicle.GetHealth() <= 0)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken 1");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken 2");
|
||||
|
||||
if (___vehicle.entity.HasDriver && ___vehicle.entity is global::EntityVehicleRebirth)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken 3");
|
||||
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)___vehicle.entity;
|
||||
|
||||
if (___vehicle.entity.EntityClass.Properties.Values.ContainsKey("VehicleType"))
|
||||
{
|
||||
string vehicleType = ___vehicle.entity.EntityClass.Properties.Values["VehicleType"];
|
||||
|
||||
//Log.Out("VehiclePartPatches-IsBroken 4, vehicleType: " + vehicleType);
|
||||
|
||||
int currentPart = 0;
|
||||
|
||||
foreach (string vehicleTypeKey in RebirthVariables.localVehicleTypes.Keys)
|
||||
{
|
||||
if (vehicleType == vehicleTypeKey)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken 5");
|
||||
|
||||
List<RepairableVehicleSlotsEnum> partsList = RebirthVariables.localVehicleTypes[vehicleTypeKey];
|
||||
|
||||
//Log.Out("VehiclePartPatches-IsBroken 6, partsList.Count: " + partsList.Count);
|
||||
|
||||
for (int i = 0; i < partsList.Count; i++)
|
||||
{
|
||||
RepairableVehicleSlotsEnum partName = partsList[i];
|
||||
|
||||
//Log.Out("VehiclePartPatches-IsBroken 7, partName: " + partName);
|
||||
|
||||
foreach (RepairableVehicleSlotsEnum key in RebirthVariables.localVehicleParts.Keys)
|
||||
{
|
||||
if (key == partName && RebirthVariables.localVehicleParts[key].requiredToOperate)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken 6");
|
||||
if (entityVehicle.itemValues[i].type == ItemValue.None.type)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken MISSING OR BROKEN: " + partName);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int maxUSerTimes = entityVehicle.itemValues[i].MaxUseTimes;
|
||||
int useTimes = (int)entityVehicle.itemValues[i].UseTimes;
|
||||
|
||||
bool flag = entityVehicle.itemValues[i].MaxUseTimes - entityVehicle.itemValues[i].UseTimes == 0;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("VehiclePartPatches-IsBroken MISSING OR BROKEN: " + partName);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
namespace Harmony.WorldRebirth
|
||||
{
|
||||
public class WorldPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("unloadEntity")]
|
||||
public class unloadEntityPatch
|
||||
{
|
||||
public static bool Prefix(World __instance, Entity _e, EnumRemoveEntityReason _reason)
|
||||
{
|
||||
Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("CanPlaceBlockAt")]
|
||||
public class CanPlaceBlockAtPatch
|
||||
{
|
||||
public static bool Prefix(World __instance, ref bool __result, Vector3i blockPos, PersistentPlayerData lpRelative, bool traderAllowed = false)
|
||||
{
|
||||
if (__instance == null || lpRelative == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer)__instance.GetEntity(lpRelative.EntityId);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
bool isWithinTraderArea = ((World)__instance).GetTraderAreaAt(blockPos) != null;
|
||||
|
||||
string blockName = player.inventory.holdingItem.GetItemName();
|
||||
bool isAllowedBlock = false;
|
||||
|
||||
bool cannotPlace = isWithinTraderArea && optionProtectTrader;
|
||||
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt blockName: " + blockName);
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt optionProtectTrader: " + optionProtectTrader);
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt isWithinTraderArea: " + isWithinTraderArea);
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt cannotPlace: " + cannotPlace);
|
||||
|
||||
if (cannotPlace && RebirthUtilities.IsBlockTraderAllowed(blockName))
|
||||
{
|
||||
isAllowedBlock = true;
|
||||
}
|
||||
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt isAllowedBlock: " + isAllowedBlock);
|
||||
|
||||
//Log.Out("WorldPatches-CanPlaceBlockAt isAllowedBlock: " + isAllowedBlock);
|
||||
|
||||
if (isAllowedBlock)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("CanPickupBlockAt")]
|
||||
public class CanPickupBlockAtPatch
|
||||
{
|
||||
public static bool Prefix(World __instance, ref bool __result, Vector3i blockPos, PersistentPlayerData lpRelative)
|
||||
{
|
||||
if (__instance == null || lpRelative == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer)__instance.GetEntity(lpRelative.EntityId);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
|
||||
bool isWithinTraderArea = ((World)__instance).GetTraderAreaAt(blockPos) != null;
|
||||
|
||||
BlockValue block = __instance.GetBlock(blockPos);
|
||||
|
||||
string blockName = block.Block.GetBlockName();
|
||||
bool isAllowedBlock = RebirthUtilities.IsBlockTraderAllowed(blockName);
|
||||
|
||||
bool cannotPickUp = isWithinTraderArea && optionProtectTrader;
|
||||
|
||||
//Log.Out("WorldPatches-CanPickupBlockAt blockName: " + blockName);
|
||||
//Log.Out("WorldPatches-CanPickupBlockAt isAllowedBlock: " + isAllowedBlock);
|
||||
|
||||
if (isAllowedBlock)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("UnloadWorld")]
|
||||
public class WorldUnloadWorld
|
||||
{
|
||||
static void Postfix()
|
||||
{
|
||||
if (RebirthManager.HasInstance)
|
||||
{
|
||||
RebirthManager.Cleanup();
|
||||
}
|
||||
/*if (RebirthManager.HasInstance)
|
||||
{
|
||||
RebirthManager.Cleanup();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("IsWithinTraderArea")]
|
||||
[HarmonyPatch(new Type[] { typeof(Vector3i) })]
|
||||
public class IsWithinTraderAreaPatch
|
||||
{
|
||||
private static bool Prefix(World __instance, ref bool __result, Vector3i _worldBlockPos)
|
||||
{
|
||||
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
|
||||
if (!optionProtectTrader)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isWithinTraderArea = ((World)__instance).GetTraderAreaAt(_worldBlockPos) != null;
|
||||
|
||||
BlockValue block = __instance.GetBlock(_worldBlockPos);
|
||||
|
||||
string blockName = block.Block.GetBlockName();
|
||||
bool canDamageBlock = RebirthUtilities.IsBlockTraderAllowed(blockName);
|
||||
|
||||
if (canDamageBlock)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(World))]
|
||||
[HarmonyPatch("GetTileEntity")]
|
||||
[HarmonyPatch(new Type[] { typeof(int) })]
|
||||
public class GetTileEntityPatch
|
||||
{
|
||||
private static bool Prefix(World __instance, ref TileEntity __result, int _entityId)
|
||||
{
|
||||
Entity entity = __instance.GetEntity(_entityId);
|
||||
if (entity == null)
|
||||
{
|
||||
__result = null;
|
||||
return false;
|
||||
}
|
||||
if (entity is EntityAnimalChickenRebirth && entity.IsAlive())
|
||||
{
|
||||
//Log.Out("WorldPatches-GetTileEntity EntityAnimalChickenRebirth");
|
||||
__result = ((EntityAnimalChickenRebirth)entity).tileEntityAnimalChickenRebirth;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.WorldBiomesPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(WorldBiomes))]
|
||||
[HarmonyPatch("readXML")]
|
||||
public class readXMLPatch
|
||||
{
|
||||
public static bool Prefix(WorldBiomes __instance, XDocument _xml, bool _instantiateReferences)
|
||||
{
|
||||
Array.Clear((Array)__instance.m_Id2BiomeArr, 0, __instance.m_Id2BiomeArr.Length);
|
||||
__instance.m_Color2BiomeMap.Clear();
|
||||
__instance.m_Name2BiomeMap.Clear();
|
||||
if (BiomeDefinition.nameToId == null)
|
||||
BiomeDefinition.nameToId = new Dictionary<string, byte>();
|
||||
foreach (XElement descendant in _xml.Descendants((XName)"biomemap"))
|
||||
{
|
||||
string attribute = descendant.GetAttribute((XName)"name");
|
||||
if (!BiomeDefinition.nameToId.ContainsKey(attribute))
|
||||
BiomeDefinition.nameToId.Add(attribute, byte.Parse(descendant.GetAttribute((XName)"id")));
|
||||
}
|
||||
foreach (XElement descendant in _xml.Descendants((XName)"biome"))
|
||||
{
|
||||
string attribute = descendant.GetAttribute((XName)"name");
|
||||
if (!BiomeDefinition.nameToId.ContainsKey(attribute))
|
||||
throw new Exception("Parsing biomes. Biome with name '" + attribute + "' also needs an entry in the biomemap");
|
||||
BiomeDefinition biome = __instance.parseBiome(BiomeDefinition.nameToId[attribute], (byte)0, attribute, descendant, _instantiateReferences);
|
||||
__instance.m_Id2BiomeArr[(int)biome.m_Id] = biome;
|
||||
__instance.m_Color2BiomeMap.Add(biome.m_uiColor, biome);
|
||||
__instance.m_Name2BiomeMap.Add(biome.m_sBiomeName, biome);
|
||||
}
|
||||
BiomeParticleManager.RegistrationCompleted = true;
|
||||
foreach (XContainer descendant1 in _xml.Descendants((XName)"pois"))
|
||||
{
|
||||
foreach (XElement descendant2 in descendant1.Descendants((XName)"poi"))
|
||||
{
|
||||
uint uint32 = Convert.ToUInt32(descendant2.GetAttribute((XName)"poimapcolor").Substring(1), 16);
|
||||
int _iSO = 0;
|
||||
int num = 0;
|
||||
int _iST = 0;
|
||||
if (descendant2.HasAttribute((XName)"surfaceoffset"))
|
||||
_iSO = Convert.ToInt32(descendant2.GetAttribute((XName)"surfaceoffset"));
|
||||
if (descendant2.HasAttribute((XName)"smoothness"))
|
||||
{
|
||||
int int32 = Convert.ToInt32(descendant2.GetAttribute((XName)"smoothness"));
|
||||
num = int32 < 0 ? 0 : int32;
|
||||
}
|
||||
if (descendant2.HasAttribute((XName)"starttunnel"))
|
||||
{
|
||||
int int32 = Convert.ToInt32(descendant2.GetAttribute((XName)"starttunnel"));
|
||||
_iST = int32 < 0 ? 0 : int32;
|
||||
}
|
||||
BlockValue _blockValue1 = BlockValue.Air;
|
||||
if (descendant2.HasAttribute((XName)"blockname"))
|
||||
_blockValue1 = _instantiateReferences ? __instance.getBlockValueForName(descendant2.GetAttribute((XName)"blockname")) : BlockValue.Air;
|
||||
BlockValue _blockBelow = BlockValue.Air;
|
||||
if (descendant2.HasAttribute((XName)"blockbelow"))
|
||||
_blockBelow = _instantiateReferences ? __instance.getBlockValueForName(descendant2.GetAttribute((XName)"blockbelow")) : BlockValue.Air;
|
||||
int _ypos = -1;
|
||||
if (descendant2.HasAttribute((XName)"ypos"))
|
||||
_ypos = int.Parse(descendant2.GetAttribute((XName)"ypos"));
|
||||
int _yposFill = -1;
|
||||
if (descendant2.HasAttribute((XName)"yposfill"))
|
||||
_yposFill = int.Parse(descendant2.GetAttribute((XName)"yposfill"));
|
||||
PoiMapElement poiMapElement = new PoiMapElement(uint32, descendant2.GetAttribute((XName)"prefab"), _blockValue1, _blockBelow, _iSO, _ypos, _yposFill, _iST);
|
||||
__instance.m_PoiMap.Add(uint32, poiMapElement);
|
||||
foreach (XElement element in descendant2.Elements())
|
||||
{
|
||||
if (element.Name == (XName)"decal")
|
||||
{
|
||||
int int32_1 = Convert.ToInt32(element.GetAttribute((XName)"texture"));
|
||||
BlockFace int32_2 = (BlockFace)Convert.ToInt32(element.GetAttribute((XName)"face"));
|
||||
float _prob = StringParsers.ParseFloat(element.GetAttribute((XName)"prob"));
|
||||
poiMapElement.decals.Add(new PoiMapDecal(int32_1, int32_2, _prob));
|
||||
}
|
||||
if (element.Name == (XName)"blockontop")
|
||||
{
|
||||
BlockValue _blockValue2 = _instantiateReferences ? __instance.getBlockValueForName(element.GetAttribute((XName)"blockname")) : BlockValue.Air;
|
||||
float _prob = StringParsers.ParseFloat(element.GetAttribute((XName)"prob"));
|
||||
|
||||
if (element.GetAttribute((XName)"blockname") == "carsRandomHelperBiome")
|
||||
{
|
||||
string name = descendant2.GetAttribute((XName)"name");
|
||||
float multiplier = 1;
|
||||
|
||||
if (name == "City Asphalt")
|
||||
{
|
||||
multiplier = 2.67f;
|
||||
}
|
||||
else if (name == "Country Road Asphalt")
|
||||
{
|
||||
multiplier = 1.335f;
|
||||
}
|
||||
else if (name == "Road Gravel")
|
||||
{
|
||||
multiplier = 1f;
|
||||
}
|
||||
|
||||
//Log.Out("WorldBiomesPatches-readXML name: " + name);
|
||||
//Log.Out("WorldBiomesPatches-readXML BEFORE _prob: " + _prob);
|
||||
//Log.Out("WorldBiomesPatches-readXML multiplier: " + multiplier);
|
||||
_prob = _prob * multiplier * (float.Parse(RebirthVariables.customVehicleDensityMultiplier) / 100);
|
||||
//Log.Out("WorldBiomesPatches-readXML AFTER _prob: " + _prob);
|
||||
}
|
||||
|
||||
int _offset = element.HasAttribute((XName)"offset") ? int.Parse(element.GetAttribute((XName)"offset")) : 0;
|
||||
poiMapElement.blocksOnTop.Add(new PoiMapBlock(_blockValue2, _prob, _offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
namespace Harmony.WorldEnvironmentPatches
|
||||
{
|
||||
internal class WorldEnvironmentPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(WorldEnvironment))]
|
||||
[HarmonyPatch("SpectrumsFrameUpdate")]
|
||||
public class SpectrumsFrameUpdatePatch
|
||||
{
|
||||
public static bool Prefix(WorldEnvironment __instance,
|
||||
World ___world,
|
||||
EntityPlayerLocal ___localPlayer,
|
||||
float ___dayTimeScalar,
|
||||
Vector2 ___dataFogPow,
|
||||
float ___fogDensityOverride,
|
||||
Color ___fogColorOverride,
|
||||
ref bool ___isUnderWater,
|
||||
Vector2 ___dataFogWater,
|
||||
Vector3 ___dataFogWaterColor
|
||||
)
|
||||
{
|
||||
if (___world == null || !___localPlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BiomeAtmosphereEffects biomeAtmosphereEffects = ___world.BiomeAtmosphereEffects;
|
||||
if (biomeAtmosphereEffects == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate current time of day
|
||||
//float currentTime = SkyManager.dayPercent * 24f;
|
||||
float currentTimeOfDayHours = GameUtils.WorldTimeToHours(GameManager.Instance.World.worldTime);
|
||||
float currentTimeOfDayMinutes = GameUtils.WorldTimeToMinutes(GameManager.Instance.World.worldTime);
|
||||
|
||||
// Combine hours and minutes into a single float
|
||||
float currentTime = currentTimeOfDayHours + (currentTimeOfDayMinutes / 60f);
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && !___world.IsEditor() && !GameUtils.IsPlaytesting() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate currentTimeOfDayHours: " + currentTimeOfDayHours);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate currentTimeOfDayMinutes: " + currentTimeOfDayMinutes);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate currentTime: " + currentTime);
|
||||
currentTime = 0f;
|
||||
}
|
||||
|
||||
// Get the midnight color values for sky, sun, and moon
|
||||
Color midnightSkyColor = biomeAtmosphereEffects.GetSkyColorSpectrum(0f);
|
||||
midnightSkyColor = WeatherManager.Instance.GetWeatherSpectrum(midnightSkyColor, AtmosphereEffect.ESpecIdx.Sky, 0f);
|
||||
|
||||
Color midnightSunColor = biomeAtmosphereEffects.GetSunColorSpectrum(0f);
|
||||
midnightSunColor = WeatherManager.Instance.GetWeatherSpectrum(midnightSunColor, AtmosphereEffect.ESpecIdx.Sun, 0f);
|
||||
|
||||
Color midnightMoonColor = biomeAtmosphereEffects.GetMoonColorSpectrum(0f);
|
||||
midnightMoonColor = WeatherManager.Instance.GetWeatherSpectrum(midnightMoonColor, AtmosphereEffect.ESpecIdx.Moon, 0f);
|
||||
|
||||
Color fogColor = Color.black;
|
||||
|
||||
// Calculate the darkness factor based on time of day
|
||||
float darknessFactor = 0f;
|
||||
|
||||
if (currentTime >= 18f || currentTime < 6f)
|
||||
{
|
||||
// Gradual darkening from 20h to midnight (and looping midnight as 0h)
|
||||
if (currentTime >= 18f && currentTime < 22f)
|
||||
{
|
||||
darknessFactor = (currentTime - 18f) / 4f;
|
||||
}
|
||||
// Fully dark between midnight (0h) and 6h
|
||||
else if (currentTime >= 22f && currentTime <= 24f)
|
||||
{
|
||||
darknessFactor = 1f;
|
||||
}
|
||||
else if (currentTime >= 0f && currentTime < 6f)
|
||||
{
|
||||
darknessFactor = 1f;
|
||||
}
|
||||
}
|
||||
else if (currentTime >= 6f && currentTime < 9f)
|
||||
{
|
||||
// Gradual brightening from 6h to 9h
|
||||
darknessFactor = 1f - ((currentTime - 6f) / 3f);
|
||||
}
|
||||
// Darkness factor remains 0 between 9h and 20h
|
||||
else
|
||||
{
|
||||
darknessFactor = 0f;
|
||||
}
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate SkyManager.dayPercent:" + SkyManager.dayPercent);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate currentTime:" + currentTime);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate darknessFactor:" + darknessFactor);
|
||||
|
||||
Color color = biomeAtmosphereEffects.GetSkyColorSpectrum(___dayTimeScalar);
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Sky, ___dayTimeScalar);
|
||||
|
||||
bool darkerNights = RebirthVariables.customDarkerNights;
|
||||
|
||||
//if (darkerNights && !GameManager.Instance.World.IsDaytime())
|
||||
if (darkerNights)
|
||||
{
|
||||
if (currentTime >= 0f && currentTime < 6f)
|
||||
{
|
||||
color = midnightSkyColor;
|
||||
}
|
||||
|
||||
Color sunColor = Color.black;
|
||||
|
||||
if (!RebirthUtilities.ScenarioSkip() && RebirthVariables.currentBiome == "burnt_forest")
|
||||
{
|
||||
sunColor = new Color(150f / 255, 0f / 255, 255f / 255);
|
||||
}
|
||||
|
||||
color = Color.Lerp(color, sunColor, darknessFactor);
|
||||
SkyManager.SetSkyColor(color);
|
||||
/*if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
Color sky = new Color(0f, 0f, 0f, 1f);
|
||||
SkyManager.SetSkyColor(sky);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.inWasteland)
|
||||
{
|
||||
Color sky = new Color(0f, 0f, 0f, 1f);
|
||||
SkyManager.SetSkyColor(sky);
|
||||
}
|
||||
else
|
||||
{
|
||||
Color sky = new Color(0f, 0f, 0f, 1f);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate sky:" + sky);
|
||||
SkyManager.SetSkyColor(sky);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.SetSkyColor(color);
|
||||
}
|
||||
|
||||
color = biomeAtmosphereEffects.GetSunColorSpectrum(___dayTimeScalar);
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Sun, ___dayTimeScalar);
|
||||
|
||||
if (darkerNights)
|
||||
{
|
||||
/*if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
Color sun = new Color(0f, 0f, 0f, 1f);
|
||||
SkyManager.SetSunColor(sun);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.inWasteland)
|
||||
{
|
||||
Color sun = new Color(color.r, color.g, color.b, 1f);
|
||||
SkyManager.SetSunColor(sun);
|
||||
}
|
||||
else
|
||||
{
|
||||
Color sun = new Color(0f, 0f, 0f, 1f);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate sun:" + sun);
|
||||
SkyManager.SetSunColor(sun);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (currentTime >= 0f && currentTime < 6f)
|
||||
{
|
||||
color = midnightSunColor;
|
||||
}
|
||||
|
||||
color = Color.Lerp(color, Color.black, darknessFactor);
|
||||
SkyManager.SetSunColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.SetSunColor(color);
|
||||
}
|
||||
|
||||
if (darkerNights)
|
||||
{
|
||||
/*if (RebirthVariables.inWasteland)
|
||||
{
|
||||
//SkyManager.SetSunIntensity(color.a / 2f);
|
||||
SkyManager.SetSunIntensity(0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//SkyManager.SetSunIntensity(color.a / 2f);
|
||||
SkyManager.SetSunIntensity(0f);
|
||||
}*/
|
||||
SkyManager.SetSunIntensity(Mathf.Lerp(color.a * 2f, 0f, darknessFactor));
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.SetSunIntensity(color.a * 2f);
|
||||
}
|
||||
|
||||
color = biomeAtmosphereEffects.GetMoonColorSpectrum(___dayTimeScalar);
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Moon, ___dayTimeScalar);
|
||||
|
||||
Color moon = new Color(0.125f, 0.125f, 0.125f, 1f);
|
||||
|
||||
/*if (RebirthVariables.currentBiome == "wasteland")
|
||||
{
|
||||
moon = new Color(0.030f, 0.255f, 0);
|
||||
}
|
||||
else if (RebirthVariables.currentBiome == "burnt_forest")
|
||||
{
|
||||
moon = new Color(0.119f, 0.003f, 0.252f);
|
||||
}*/
|
||||
|
||||
if (darkerNights)
|
||||
{
|
||||
/*if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
Color moon = new Color(0.175f, 0.175f, 0.175f, 1f);
|
||||
SkyManager.SetMoonLightColor(moon);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.inWasteland)
|
||||
{
|
||||
Color moon = new Color(0.125f, 0.125f, 0.125f, 1f);
|
||||
SkyManager.SetMoonLightColor(moon);
|
||||
}
|
||||
else
|
||||
{
|
||||
Color moon = new Color(0.125f, 0.125f, 0.125f, 1f);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate color:" + color);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate moon:" + moon);
|
||||
SkyManager.SetMoonLightColor(moon);
|
||||
}
|
||||
}*/
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Moon, ___dayTimeScalar);
|
||||
|
||||
if (currentTime >= 0f && currentTime < 6f)
|
||||
{
|
||||
color = midnightMoonColor;
|
||||
}
|
||||
|
||||
color = Color.Lerp(color, moon, darknessFactor);
|
||||
SkyManager.SetMoonLightColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate moon:" + color);
|
||||
SkyManager.SetMoonLightColor(color);
|
||||
}
|
||||
|
||||
color = biomeAtmosphereEffects.GetFogColorSpectrum(___dayTimeScalar);
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Fog, ___dayTimeScalar);
|
||||
Color color2 = biomeAtmosphereEffects.GetFogFadeColorSpectrum(___dayTimeScalar);
|
||||
color2 = WeatherManager.Instance.GetWeatherSpectrum(color2, AtmosphereEffect.ESpecIdx.FogFade, ___dayTimeScalar);
|
||||
SkyManager.SetFogFade(1f - color2.r - 0.5f, 1f - color2.a);
|
||||
Color b = new Color(color.r, color.g, color.b, 1f);
|
||||
float dayPercent = SkyManager.dayPercent;
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate ___dataFogPow:" + ___dataFogPow);
|
||||
|
||||
float num = Mathf.Pow(color.a, Mathf.LerpUnclamped(___dataFogPow.y, ___dataFogPow.x, dayPercent));
|
||||
num += WeatherManager.currentWeather.FogPercent();
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate BEFORE num" + num);
|
||||
|
||||
if (num > 1f)
|
||||
{
|
||||
num = 1f;
|
||||
}
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate ___fogDensityOverride" + ___fogDensityOverride);
|
||||
|
||||
if (___fogDensityOverride >= 0f)
|
||||
{
|
||||
num = ___fogDensityOverride;
|
||||
b = ___fogColorOverride;
|
||||
}
|
||||
float t = 0.01f;
|
||||
if (___localPlayer.IsUnderwaterCamera)
|
||||
{
|
||||
___isUnderWater = true;
|
||||
num = ___dataFogWater.x;
|
||||
t = ___dataFogWater.y;
|
||||
float num2 = 0.35f + SkyManager.dayPercent * 0.65f;
|
||||
b = new Color(___dataFogWaterColor.x * num2, ___dataFogWaterColor.y * num2, ___dataFogWaterColor.z * num2, 1f);
|
||||
}
|
||||
else if (___isUnderWater)
|
||||
{
|
||||
___isUnderWater = false;
|
||||
t = 1f;
|
||||
}
|
||||
if (___localPlayer.bPlayingSpawnIn)
|
||||
{
|
||||
t = 1f;
|
||||
}
|
||||
|
||||
if (!darkerNights)
|
||||
{
|
||||
fogColor = SkyManager.GetFogColor();
|
||||
}
|
||||
|
||||
if (darkerNights) // && !GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
/*Color fog = new Color(0f, 0f, 0f, 1f);
|
||||
SkyManager.SetFogColor(fog);*/
|
||||
color = WeatherManager.Instance.GetWeatherSpectrum(color, AtmosphereEffect.ESpecIdx.Fog, ___dayTimeScalar);
|
||||
color = Color.Lerp(color, fogColor, darknessFactor);
|
||||
SkyManager.SetFogColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.SetFogColor(Color.Lerp(fogColor, b, t));
|
||||
}
|
||||
|
||||
string optionWeatherFog = RebirthVariables.customWeatherFog;
|
||||
float fogDensity = SkyManager.GetFogDensity();
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate fogDensity" + fogDensity);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate BEFORE num" + num);
|
||||
|
||||
if (RebirthVariables.currentBiome == "wasteland")
|
||||
{
|
||||
if (optionWeatherFog == "lower")
|
||||
{
|
||||
num = 0.15f;
|
||||
}
|
||||
else if (optionWeatherFog == "higher")
|
||||
{
|
||||
num = 0.35f;
|
||||
}
|
||||
else if (optionWeatherFog == "highest")
|
||||
{
|
||||
num = 0.45f;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 0.25f;
|
||||
}
|
||||
}
|
||||
else if (RebirthVariables.currentBiome == "burnt_forest")
|
||||
{
|
||||
if (optionWeatherFog == "lower")
|
||||
{
|
||||
num = 0.2f;
|
||||
}
|
||||
else if (optionWeatherFog == "higher")
|
||||
{
|
||||
num = 0.5f;
|
||||
}
|
||||
else if (optionWeatherFog == "highest")
|
||||
{
|
||||
num = 0.6f;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 0.4f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (optionWeatherFog == "lower")
|
||||
{
|
||||
num = num / 2f;
|
||||
}
|
||||
else if (optionWeatherFog == "higher")
|
||||
{
|
||||
num = num * 1.3f;
|
||||
}
|
||||
else if (optionWeatherFog == "highest")
|
||||
{
|
||||
num = num * 1.6f;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate AFTER num" + num);
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate t" + t);
|
||||
|
||||
if (optionWeatherFog == "none" || (RebirthVariables.disableFogOnFlight && ___localPlayer.IsFlyMode.Value)) // || (darkerNights && RebirthUtilities.IsHordeNight()))
|
||||
{
|
||||
SkyManager.SetFogDensity(0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("WorldEnvironmentPatches-SpectrumsFrameUpdate Lerp" + Mathf.Lerp(fogDensity, num, t));
|
||||
SkyManager.SetFogDensity(Mathf.Lerp(fogDensity, num, t));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
namespace Harmony.XUiPatches
|
||||
{
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(XUi))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(XUi __instance)
|
||||
{
|
||||
bool optionOverrideOpacity = RebirthVariables.customOverrideOpacity;
|
||||
|
||||
if (optionOverrideOpacity)
|
||||
{
|
||||
GamePrefs.Set(EnumGamePrefs.OptionsBackgroundGlobalOpacity, 0.99f);
|
||||
foreach (XUi xui in UnityEngine.Object.FindObjectsOfType<XUi>())
|
||||
{
|
||||
xui.BackgroundGlobalOpacity = GamePrefs.GetFloat(EnumGamePrefs.OptionsBackgroundGlobalOpacity);
|
||||
xui.ForegroundGlobalOpacity = GamePrefs.GetFloat(EnumGamePrefs.OptionsForegroundGlobalOpacity);
|
||||
}
|
||||
__instance.BackgroundGlobalOpacity = GamePrefs.GetFloat(EnumGamePrefs.OptionsBackgroundGlobalOpacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.XUiC_BackpackWindowPatches
|
||||
{
|
||||
internal class XUiC_BackpackWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_BackpackWindow))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static bool Prefix(ref XUiC_BackpackWindow __instance, ref bool __result, ref string value, string bindingName,
|
||||
CachedStringFormatter<int> ___currencyFormatter
|
||||
)
|
||||
{
|
||||
if (bindingName != null)
|
||||
{
|
||||
if (bindingName == "numRows")
|
||||
{
|
||||
int numRows = 10;
|
||||
|
||||
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
float additionalRows = primaryPlayer.Buffs.GetCustomVar("$BackpackCapacityIncrease");
|
||||
if (additionalRows > 0)
|
||||
{
|
||||
numRows = numRows + (int)additionalRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = numRows.ToString();
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "currencyamount")
|
||||
{
|
||||
value = "0";
|
||||
if (XUi.IsGameRunning() && __instance.xui != null && __instance.xui.PlayerInventory != null)
|
||||
{
|
||||
value = ___currencyFormatter.Format(__instance.xui.PlayerInventory.CurrencyAmount);
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "currencyicon")
|
||||
{
|
||||
value = TraderInfo.CurrencyItem;
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "lootingorvehiclestorage")
|
||||
{
|
||||
bool flag = __instance.xui.vehicle != null && __instance.xui.vehicle.GetVehicle().HasStorage();
|
||||
bool flag2 = __instance.xui.lootContainer != null && __instance.xui.lootContainer.EntityId == -1;
|
||||
bool flag3 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is global::EntityDrone;
|
||||
bool flag4 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is EntityNPCRebirth;
|
||||
|
||||
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer != null: " + (__instance.xui.lootContainer != null));
|
||||
|
||||
value = (flag || flag2 || flag3 || flag4).ToString();
|
||||
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer.entityId: " + __instance.xui.lootContainer.entityId);
|
||||
|
||||
//Log.Out("XUiC_BackpackWindowRebirth-GetBindingValue __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
||||
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "quickstack")
|
||||
{
|
||||
value = (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null).ToString();
|
||||
|
||||
string optionQoL = RebirthVariables.customQualityOfLife;
|
||||
|
||||
if (optionQoL == "none")
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "moveVehicle")
|
||||
{
|
||||
value = "false";
|
||||
|
||||
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
||||
{
|
||||
string optionQoL = RebirthVariables.customQualityOfLife;
|
||||
|
||||
if (optionQoL == "none" || optionQoL == "quickstackonly")
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("perkPackMule");
|
||||
|
||||
if (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null && progressionValue.calculatedLevel >= 5)
|
||||
{
|
||||
int minMax = 50;
|
||||
List<Entity> entitiesInBounds = primaryPlayer.world.GetEntitiesInBounds(typeof(global::EntityVehicleRebirth), BoundsUtils.BoundsForMinMax(primaryPlayer.position.x - minMax, primaryPlayer.position.y - 50, primaryPlayer.position.z - minMax, primaryPlayer.position.x + minMax, primaryPlayer.position.y + 30, primaryPlayer.position.z + minMax), new List<Entity>());
|
||||
if (entitiesInBounds.Count > 0)
|
||||
{
|
||||
|
||||
for (int x = 0; x < entitiesInBounds.Count; x++)
|
||||
{
|
||||
global::EntityVehicleRebirth entityVehicle = (global::EntityVehicleRebirth)entitiesInBounds[x];
|
||||
|
||||
if (entityVehicle != null)
|
||||
{
|
||||
//Log.Out("RebirthUtilities-DumpVehicleDown VEHICLE: " + entityVehicle.EntityClass.entityClassName);
|
||||
|
||||
PersistentPlayerData playerData = primaryPlayer.world.GetGameManager().GetPersistentPlayerList().GetPlayerData(entityVehicle.GetOwner());
|
||||
|
||||
if (playerData.EntityId == primaryPlayer.entityId)
|
||||
{
|
||||
value = "true";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "moveFollower")
|
||||
{
|
||||
value = "false";
|
||||
|
||||
if (GameManager.Instance.gameStateManager.IsGameStarted())
|
||||
{
|
||||
string optionQoL = RebirthVariables.customQualityOfLife;
|
||||
|
||||
if (optionQoL == "none" || optionQoL == "quickstackonly")
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("perkPackMule");
|
||||
|
||||
if (!__instance.xui.playerUI.windowManager.IsWindowOpen("creative") && __instance.xui.lootContainer == null && __instance.xui.vehicle == null && progressionValue.calculatedLevel >= 3)
|
||||
{
|
||||
int minMax = 30;
|
||||
List<Entity> entitiesInBounds = primaryPlayer.world.GetEntitiesInBounds(typeof(EntityNPCRebirth), BoundsUtils.BoundsForMinMax(primaryPlayer.position.x - minMax, primaryPlayer.position.y - 30, primaryPlayer.position.z - minMax, primaryPlayer.position.x + minMax, primaryPlayer.position.y + 30, primaryPlayer.position.z + minMax), new List<Entity>());
|
||||
if (entitiesInBounds.Count > 0)
|
||||
{
|
||||
for (int x = 0; x < entitiesInBounds.Count; x++)
|
||||
{
|
||||
EntityNPCRebirth entityFollower = (EntityNPCRebirth)entitiesInBounds[x];
|
||||
|
||||
if (entityFollower != null)
|
||||
{
|
||||
float hidden = entityFollower.Buffs.GetCustomVar("$FR_NPC_Hidden");
|
||||
float respawned = entityFollower.Buffs.GetCustomVar("$FR_NPC_Respawn");
|
||||
|
||||
if (hidden == 0 && respawned == 0 && !entityFollower.HasAnyTags(FastTags<TagGroup.Global>.Parse("noinventory")) && entityFollower.LeaderUtils.Owner != null && entityFollower.LeaderUtils.Owner.entityId == primaryPlayer.entityId)
|
||||
{
|
||||
value = "true";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OwnedEntityData[] ownedEntities = primaryPlayer.GetOwnedEntities();
|
||||
|
||||
for (int j = 0; j < ownedEntities.Length; j++)
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ___dronesActive.Count: " + ___dronesActive.Count);
|
||||
|
||||
EntityDrone entityFollower = primaryPlayer.world.GetEntity(ownedEntities[j].entityId) as EntityDrone;
|
||||
|
||||
if (entityFollower != null)
|
||||
{
|
||||
value = "true";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "creativewindowopen")
|
||||
{
|
||||
value = __instance.xui.playerUI.windowManager.IsWindowOpen("creative").ToString();
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (bindingName == "userlockmode")
|
||||
{
|
||||
value = __instance.UserLockMode.ToString();
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
__result = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_BackpackWindow))]
|
||||
[HarmonyPatch("TryGetMoveDestinationInventory")]
|
||||
public class TryGetMoveDestinationInventoryPatch
|
||||
{
|
||||
public static bool Prefix(ref XUiC_BackpackWindow __instance, ref bool __result, out IInventory _dstInventory)
|
||||
{
|
||||
_dstInventory = null;
|
||||
XUiM_AssembleItem assembleItem = __instance.xui.AssembleItem;
|
||||
if (((assembleItem != null) ? assembleItem.CurrentItem : null) != null)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 1");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
bool flag = __instance.xui.vehicle != null && __instance.xui.vehicle.GetVehicle().HasStorage();
|
||||
bool flag2 = __instance.xui.lootContainer != null && __instance.xui.lootContainer.EntityId == -1;
|
||||
bool flag3 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is global::EntityDrone;
|
||||
bool flag4 = __instance.xui.lootContainer != null && GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) is EntityNPCRebirth;
|
||||
|
||||
if (!flag && !flag2 && !flag3 && !flag4)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 2");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
if (flag && __instance.xui.FindWindowGroupByName(XUiC_VehicleStorageWindowGroup.ID).GetChildByType<XUiC_VehicleContainer>() == null)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 3");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
if (flag3)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 4");
|
||||
_dstInventory = __instance.xui.lootContainer;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 5");
|
||||
IInventory inventory2;
|
||||
if (!flag2 & !flag4)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 6");
|
||||
IInventory inventory = __instance.xui.vehicle.bag;
|
||||
inventory2 = inventory;
|
||||
}
|
||||
else if (flag4)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 7");
|
||||
IInventory inventory = null;
|
||||
inventory2 = inventory;
|
||||
|
||||
EntityNPCRebirth entity = GameManager.Instance.World.GetEntity(__instance.xui.lootContainer.EntityId) as EntityNPCRebirth;
|
||||
if (entity != null)
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 8");
|
||||
inventory2 = entity.lootContainer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_BackpackWindowPatches-TryGetMoveDestinationInventory 9");
|
||||
IInventory inventory = __instance.xui.lootContainer;
|
||||
inventory2 = inventory;
|
||||
}
|
||||
_dstInventory = inventory2;
|
||||
}
|
||||
__result = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Quartz.Settings;
|
||||
|
||||
namespace Harmony.XUiC_CollectedItemListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_CollectedItemList))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static bool Prefix(XUiC_CollectedItemList __instance, float _dt,
|
||||
ref XUiView ___viewComponent
|
||||
)
|
||||
{
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
___viewComponent.Position = new Vector2i(-90, 270);
|
||||
}
|
||||
else
|
||||
{
|
||||
___viewComponent.Position = new Vector2i(-90, 32);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Harmony.XUiC_CompanionEntryListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_CompanionEntryList))]
|
||||
[HarmonyPatch("RefreshPartyList")]
|
||||
public class RefreshPartyListPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_CompanionEntryList __instance)
|
||||
{
|
||||
int index1 = 0;
|
||||
EntityPlayer entityPlayer = (EntityPlayer)__instance.xui.playerUI.entityPlayer;
|
||||
int num = 0;
|
||||
|
||||
if (entityPlayer.Party != null)
|
||||
{
|
||||
num = (entityPlayer.Party.MemberList.Count - 1) * 40;
|
||||
}
|
||||
|
||||
__instance.viewComponent.Position = new Vector2i(__instance.viewComponent.Position.x, (int)__instance.yOffset - num);
|
||||
__instance.viewComponent.UiTransform.localPosition = new Vector3((float)__instance.viewComponent.Position.x, (float)__instance.viewComponent.Position.y);
|
||||
if (entityPlayer.Companions != null)
|
||||
{
|
||||
for (int index2 = 0; index2 < entityPlayer.Companions.Count; ++index2)
|
||||
{
|
||||
EntityAlive companion = entityPlayer.Companions[index2];
|
||||
if (index1 < __instance.entryList.Count)
|
||||
__instance.entryList[index1++].SetCompanion(companion);
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (; index1 < __instance.entryList.Count; ++index1)
|
||||
__instance.entryList[index1].SetCompanion((EntityAlive)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index3 = 0; index3 < __instance.entryList.Count; ++index3)
|
||||
__instance.entryList[index3].SetCompanion((EntityAlive)null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
namespace Harmony.XUiC
|
||||
{
|
||||
public class XUiC_ContainerStandardControlsPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_ContainerStandardControls))]
|
||||
[HarmonyPatch("LockedSlots")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class LockedSlotsPatch
|
||||
{
|
||||
public static void Postfix(XUiC_ContainerStandardControls __instance, bool[] __result)
|
||||
{
|
||||
if (__instance.xui.playerUI.entityPlayer.bag.LockedSlots != null)
|
||||
{
|
||||
for (int i = 0; i < __instance.xui.playerUI.entityPlayer.bag.LockedSlots.Length; i++)
|
||||
{
|
||||
if (__instance.xui.playerUI.entityPlayer.bag.LockedSlots[i])
|
||||
{
|
||||
Log.Out("XUiC_ContainerStandardControlsPatches-LockedSlots SLOT #" + (i + 1) + " IS LOCKED");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public static void QuickStackOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackOnClick START");
|
||||
|
||||
//bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
//bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
//bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageQuickStack>().Setup(primaryPlayer.entityId, false), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, false);
|
||||
}
|
||||
/*if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackOnClick NOT Client");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, false);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackOnClick IS Client");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, false, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackOnClick IS P2P Host");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, false, true);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public static void QuickStackMineOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackMineOnClick START");
|
||||
|
||||
//bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
//bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
//bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageQuickStack>().Setup(primaryPlayer.entityId, true), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, true);
|
||||
}
|
||||
/*if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackMineOnClick NOT Client");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, true);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackMineOnClick IS Client");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, true, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-QuickStackMineOnClick IS P2P Host");
|
||||
RebirthUtilities.QuickStackOnClick(primaryPlayer, true, true);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public static void DumpFollowerDownOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerDownOnClick START");
|
||||
|
||||
bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerDownOnClick NOT Client");
|
||||
RebirthUtilities.DumpFollowerDown(primaryPlayer);
|
||||
RebirthUtilities.DumpDroneDown(primaryPlayer);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerDownOnClick IS Client");
|
||||
RebirthUtilities.DumpFollowerDown(primaryPlayer, true);
|
||||
RebirthUtilities.DumpDroneDown(primaryPlayer, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerDownOnClick IS P2P Host");
|
||||
RebirthUtilities.DumpFollowerDown(primaryPlayer, true);
|
||||
RebirthUtilities.DumpDroneDown(primaryPlayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DumpFollowerUpOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerUpOnClick START");
|
||||
|
||||
bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerUpOnClick NOT Client");
|
||||
RebirthUtilities.DumpFollowerUp(primaryPlayer);
|
||||
RebirthUtilities.DumpDroneUp(primaryPlayer);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerUpOnClick IS Client");
|
||||
RebirthUtilities.DumpFollowerUp(primaryPlayer, true);
|
||||
RebirthUtilities.DumpDroneUp(primaryPlayer, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpFollowerUpOnClick IS P2P Host");
|
||||
RebirthUtilities.DumpFollowerUp(primaryPlayer, true);
|
||||
RebirthUtilities.DumpDroneUp(primaryPlayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DumpVehicleDownOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleDownOnClick START");
|
||||
|
||||
bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleDownOnClick NOT Client");
|
||||
RebirthUtilities.DumpVehicleDown(primaryPlayer);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleDownOnClick IS Client");
|
||||
RebirthUtilities.DumpVehicleDown(primaryPlayer, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleDownOnClick IS P2P Host");
|
||||
RebirthUtilities.DumpVehicleDown(primaryPlayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DumpVehicleUpOnClick()
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleUpOnClick START");
|
||||
|
||||
bool isDedicated = GameManager.IsDedicatedServer;
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
bool isSinglePlayer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer;
|
||||
bool isServer = ConnectionManager.Instance.IsServer;
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleUpOnClick NOT Client");
|
||||
RebirthUtilities.DumpVehicleUp(primaryPlayer);
|
||||
}
|
||||
else if (isClient)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleUpOnClick IS Client");
|
||||
RebirthUtilities.DumpVehicleUp(primaryPlayer, true);
|
||||
}
|
||||
else if (isServer && !isDedicated)
|
||||
{
|
||||
//Log.Out("XUiC_ContainerStandardControlsPatches-DumpVehicleUpOnClick IS P2P Host");
|
||||
RebirthUtilities.DumpVehicleUp(primaryPlayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ContainerStandardControls))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(XUiC_ContainerStandardControls __instance
|
||||
)
|
||||
{
|
||||
XUiController childById = __instance.GetChildById("btnMoveQuickStack");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
QuickStackOnClick();
|
||||
};
|
||||
}
|
||||
|
||||
childById = __instance.GetChildById("btnMoveQuickStackMine");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
QuickStackMineOnClick();
|
||||
};
|
||||
}
|
||||
|
||||
childById = __instance.GetChildById("btnMoveVehicleDown");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
DumpVehicleDownOnClick();
|
||||
};
|
||||
}
|
||||
|
||||
childById = __instance.GetChildById("btnMoveVehicleUp");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
DumpVehicleUpOnClick();
|
||||
};
|
||||
}
|
||||
|
||||
childById = __instance.GetChildById("btnMoveFollowerDown");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
DumpFollowerDownOnClick();
|
||||
};
|
||||
}
|
||||
|
||||
childById = __instance.GetChildById("btnMoveFollowerUp");
|
||||
if (childById != null)
|
||||
{
|
||||
childById.OnPress += delegate (XUiController _sender, int _args)
|
||||
{
|
||||
DumpFollowerUpOnClick();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
namespace Harmony.XUiC_CraftingInfoWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_CraftingInfoWindow))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_CraftingInfoWindow __instance, ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "durabilitytext")
|
||||
{
|
||||
if (__instance.recipe != null && __instance.recipe.GetOutputItemClass().ShowQualityBar)
|
||||
{
|
||||
if (__instance.recipe.GetName() == "meleeToolAxeT1IronFireaxe" || __instance.recipe.GetName() == "meleeToolAxeT2SteelAxe")
|
||||
{
|
||||
if (__instance.selectedCraftingTier > 5)
|
||||
{
|
||||
__instance.selectedCraftingTier = 5;
|
||||
}
|
||||
value = __instance.durabilitytextFormatter.Format(__instance.selectedCraftingTier);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bindingName == "durabilitycolor")
|
||||
{
|
||||
if (__instance.recipe != null && __instance.recipe.GetOutputItemClass().ShowQualityBar)
|
||||
{
|
||||
if (__instance.recipe.GetName() == "meleeToolAxeT1IronFireaxe" || __instance.recipe.GetName() == "meleeToolAxeT2SteelAxe")
|
||||
{
|
||||
int craftingTier = __instance.selectedCraftingTier;
|
||||
|
||||
if (__instance.selectedCraftingTier > 5)
|
||||
{
|
||||
craftingTier = 5;
|
||||
}
|
||||
|
||||
Color32 _v1_1 = (Color32)Color.white;
|
||||
_v1_1 = (Color32)QualityInfo.GetTierColor(craftingTier);
|
||||
value = __instance.durabilitycolorFormatter.Format(_v1_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bindingName == "enableaddquality")
|
||||
{
|
||||
if (__instance.recipe != null && __instance.recipe.GetOutputItemClass().ShowQualityBar)
|
||||
{
|
||||
if (__instance.recipe.GetName() == "meleeToolAxeT1IronFireaxe" || __instance.recipe.GetName() == "meleeToolAxeT2SteelAxe")
|
||||
{
|
||||
int craftingTier = __instance.selectedCraftingTier;
|
||||
|
||||
if (__instance.selectedCraftingTier == 5)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
|
||||
|
||||
namespace Harmony.XUiC_EquipmentStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_EquipmentStack))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static void Postfix(XUiC_EquipmentStack __instance, float _dt)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (__instance.stackValue != null)
|
||||
{
|
||||
XUiV_Label viewComponent = (XUiV_Label)__instance.stackValue.ViewComponent;
|
||||
viewComponent.Text = "";
|
||||
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
|
||||
XUiV_Sprite bonusTypeIconSprite = (XUiV_Sprite)__instance.GetChildById("bonusTypeIcon").ViewComponent;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
bonusTypeIconSprite.SpriteName = "ui_game_symbol_" + (string)itemValue.GetMetadata("bonus");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!itemValue.IsMod)
|
||||
{
|
||||
bonusTypeIconSprite.SpriteName = "";
|
||||
}
|
||||
}
|
||||
|
||||
bonusTypeIconSprite.isDirty = true;
|
||||
|
||||
/*(__instance.lockTypeIcon.ViewComponent as XUiV_Sprite).SpriteName = "";
|
||||
(__instance.lockTypeIcon.ViewComponent as XUiV_Sprite).isDirty = true;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.XUiC_ItemInfoWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_ItemInfoWindow))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_ItemInfoWindow __instance, ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "itemtypeicon")
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue IS SPECIAL");
|
||||
value = (string)itemValue.GetMetadata("bonus");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bindingName == "hasitemtypeicon" && !__instance.itemStack.IsEmpty())
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue IS SPECIAL");
|
||||
value = "true";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bindingName == "itemdescription")
|
||||
{
|
||||
value = "";
|
||||
if (__instance.itemClass != null)
|
||||
{
|
||||
if (__instance.itemClass.IsBlock())
|
||||
{
|
||||
string descriptionKey = Block.list[__instance.itemClass.Id].DescriptionKey;
|
||||
if (Localization.Exists(descriptionKey))
|
||||
value = Localization.Get(descriptionKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
string descriptionKey = __instance.itemClass.DescriptionKey;
|
||||
if (Localization.Exists(descriptionKey))
|
||||
value = Localization.Get(descriptionKey);
|
||||
if (__instance.itemClass.Unlocks != "")
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItemClass(__instance.itemClass.Unlocks);
|
||||
if (itemClass != null)
|
||||
value = value + "\n\n" + Localization.Get(itemClass.DescriptionKey);
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
if ((int)itemValue.GetMetadata("active") == 1)
|
||||
{
|
||||
value = value + "\n\n" + Localization.Get("statBonus").ToUpper() + ": " + $"{Localization.Get("xui" + (string)itemValue.GetMetadata("bonus"))} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{(int)itemValue.GetMetadata("level")}[-][c9c7c7])[-]";
|
||||
|
||||
List<string> tagNames = itemValue.ItemClass.ItemTags.GetTagNames();
|
||||
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
||||
|
||||
float chance = RebirthUtilities.GetBonusChance(itemValue, isMelee, true);
|
||||
|
||||
value = value + "\n" + Localization.Get("statChanceToTrigger").ToUpper() + ": " + $"[e0dcab]{RebirthUtilities.FormatFloat(chance, 2)}[-]%";
|
||||
}
|
||||
else if ((int)itemValue.GetMetadata("active") == 2)
|
||||
{
|
||||
value = value + "\n\n" + Localization.Get("statBonus").ToUpper() + ": " + $"{Localization.Get((string)itemValue.GetMetadata("bonus") + "Name")} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{(int)itemValue.GetMetadata("level")}[-][c9c7c7])[-]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,750 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiC_ItemStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("AllowIconGrow")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public static class AllowIconGrowPatch
|
||||
{
|
||||
public static void Postfix(XUiC_ItemStack __instance, ref bool __result
|
||||
)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance, ref bool __result, ref string _value, string _bindingName,
|
||||
ItemStack ___itemStack
|
||||
)
|
||||
{
|
||||
if (_bindingName == "bonustypeicon")
|
||||
{
|
||||
_value = "";
|
||||
if (RebirthUtilities.ScenarioSkip() && !___itemStack.IsEmpty())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue bonustypeicon POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue IS SPECIAL");
|
||||
_value = "ui_game_symbol_" + (string)itemValue.GetMetadata("bonus");
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue bonustypeicon _value: " + _value);
|
||||
}
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Postfix(XUiC_ItemStack __instance, ref bool __result, ref string _value, string _bindingName,
|
||||
ItemStack ___itemStack
|
||||
)
|
||||
{
|
||||
if (_bindingName == "itemtypeicon" && !___itemStack.IsEmpty())
|
||||
{
|
||||
if (___itemStack.itemValue.ItemClass.AltItemTypeIcon != null && ___itemStack.itemValue.ItemClass.Properties.Values.ContainsKey("RelatedPerkName"))
|
||||
{
|
||||
string perkName = ___itemStack.itemValue.ItemClass.Properties.Values["RelatedPerkName"];
|
||||
|
||||
EntityPlayer player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue(perkName);
|
||||
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level > 0)
|
||||
{
|
||||
_value = ___itemStack.itemValue.ItemClass.AltItemTypeIcon;
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = ___itemStack.itemValue.ItemClass.ItemTypeIcon;
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_bindingName == "hasbonustypeicon" && !___itemStack.IsEmpty())
|
||||
{
|
||||
_value = "false";
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
ItemValue itemValue = __instance.itemStack.itemValue;
|
||||
Log.Out("XUiC_ItemStackPatches-GetBindingValue hasbonustypeicon POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
Log.Out("XUiC_ItemStackPatches-GetBindingValue hasbonustypeicon CAN SEE SPECIAL");
|
||||
_value = "true";
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_bindingName == "isDurabilityVisible")
|
||||
{
|
||||
_value = "false";
|
||||
if (!___itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue item: " + ___itemStack.itemValue.ItemClass.Name);
|
||||
if (___itemStack.itemValue.ItemClass.Name.ToLower().StartsWith("armor") ||
|
||||
___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("vehiclepart")) ||
|
||||
(___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("melee,ranged")) && !___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("heldTorch,ammo"))))
|
||||
{
|
||||
_value = "true";
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
}
|
||||
else if (_bindingName == "itemcount")
|
||||
{
|
||||
if (__instance.itemStack.IsEmpty())
|
||||
{
|
||||
_value = "";
|
||||
__result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue item: " + ___itemStack.itemValue.ItemClass.Name);
|
||||
|
||||
// Check if ShowDurability is false
|
||||
if (!__instance.ShowDurability)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 1, __instance.itemClassOrMissing.Stacknumber: " + __instance.itemClassOrMissing.Stacknumber);
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 1, __instance.itemStack.count: " + __instance.itemStack.count);
|
||||
// If Stacknumber is 1, assign an empty string
|
||||
if (__instance.itemClassOrMissing.Stacknumber == 1)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 2");
|
||||
_value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 3");
|
||||
// Otherwise, format the item stack count
|
||||
_value = __instance.itemcountFormatter.Format(__instance.itemStack.count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 4");
|
||||
// If ShowDurability is true, check the Quality value
|
||||
if (__instance.itemStack.itemValue.Quality > (ushort)0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 5");
|
||||
// Format the Quality value
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (!___itemStack.itemValue.ItemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("vehiclepart")))
|
||||
{
|
||||
_value = "";
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_value = __instance.itemcountFormatter.Format((int)__instance.itemStack.itemValue.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 6");
|
||||
// If Quality is not greater than 0, check if IsMod is true
|
||||
if (__instance.itemStack.itemValue.IsMod)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 7");
|
||||
_value = "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-GetBindingValue 8");
|
||||
// Default to an empty string
|
||||
_value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("HandleStackSwap")]
|
||||
public class HandleStackSwapPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.name: " + __instance.xui.name);
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
||||
}
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.StackLocation: " + __instance.StackLocation);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.ViewComponent.Controller.GetParentWindow().ID: " + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.LootContainer &&
|
||||
__instance.ViewComponent.Controller.GetParentWindow().ID == "windowLooting" &&
|
||||
__instance.xui.lootContainer != null
|
||||
)
|
||||
{
|
||||
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_ItemStack))]
|
||||
[HarmonyPatch("HandleMoveToPreferredLocation")]
|
||||
public class HandleMoveToPreferredLocationPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_ItemStack __instance)
|
||||
{
|
||||
EntityPlayer player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.name: " + __instance.xui.name);
|
||||
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.xui.lootContainer.lootListName: " + __instance.xui.lootContainer.lootListName);
|
||||
}
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.StackLocation: " + __instance.StackLocation);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation __instance.ViewComponent.Controller.GetParentWindow().ID: " + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack &&
|
||||
__instance.ViewComponent.Controller.GetParentWindow().ID == "windowBackpack" &&
|
||||
__instance.xui.lootContainer != null
|
||||
)
|
||||
{
|
||||
if (__instance.xui.lootContainer.lootListName == "FuriousRamsayLootGatherer")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__instance.xui.currentPopupMenu.ClearItems();
|
||||
if (__instance.ItemStack.IsEmpty() || __instance.StackLock)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 1");
|
||||
return false;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2");
|
||||
__instance.ItemStack.Deactivate();
|
||||
}
|
||||
int count = __instance.ItemStack.count;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2a, __instance.itemClass: " + __instance.itemClass.Name);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 2a, __instance.ItemStack: " + __instance.ItemStack.itemValue.ItemClass.Name);
|
||||
|
||||
switch (__instance.StackLocation)
|
||||
{
|
||||
case XUiC_ItemStack.StackLocationTypes.Backpack:
|
||||
case XUiC_ItemStack.StackLocationTypes.ToolBelt:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3, __instance.ViewComponent.Controller.GetParentWindow().ID:" + __instance.ViewComponent.Controller.GetParentWindow().ID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3, __instance.StackLocation:" + __instance.StackLocation);
|
||||
|
||||
bool isRepairWindow = false;
|
||||
XUiController[] itemControllers = null;
|
||||
|
||||
__instance.xui.GetOpenWindows(LocalPlayerUI.openWindows);
|
||||
foreach (XUiView openWindow in LocalPlayerUI.openWindows)
|
||||
{
|
||||
//Log.Out($"openWindow: {openWindow.id}");
|
||||
if (openWindow.id.ToLower().Contains("repairentity"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a1, openWindow.ID:" + openWindow.ID);
|
||||
isRepairWindow = true;
|
||||
|
||||
itemControllers = openWindow.controller.Parent.GetChildrenByType<XUiC_RepairableVehicleStack>();
|
||||
|
||||
break;
|
||||
}
|
||||
else if (openWindow.id.ToLower().Contains("repair"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a2, openWindow.ID:" + openWindow.ID);
|
||||
isRepairWindow = true;
|
||||
|
||||
itemControllers = openWindow.controller.Parent.GetChildrenByType<XUiC_RepairableVehicleStack>();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool flag = __instance.xui.AssembleItem?.CurrentItem != null;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a3, flag:" + flag);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a3, itemControllers != null:" + (itemControllers != null));
|
||||
|
||||
if (isRepairWindow && itemControllers != null && itemControllers.Length > 0)
|
||||
{
|
||||
RepairableVehicleSlotsEnum slotEnum = RepairableVehicleSlotsEnum.None;
|
||||
if (__instance.itemClass.Properties.Values.ContainsKey("VehicleSlot"))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3a4");
|
||||
slotEnum = (RepairableVehicleSlotsEnum)Enum.Parse(typeof(RepairableVehicleSlotsEnum), __instance.itemClass.Properties.Values["VehicleSlot"]);
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3b slotEnum: " + slotEnum);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3b (int)slotEnum: " + (int)slotEnum);
|
||||
|
||||
XUiC_RepairableVehicleStackGrid itemControllerGrid = itemControllers[0].parent as XUiC_RepairableVehicleStackGrid;
|
||||
|
||||
if (slotEnum != RepairableVehicleSlotsEnum.None)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3c");
|
||||
|
||||
bool shouldStop = false;
|
||||
|
||||
for (int i = 0; i < itemControllers.Length; i++)
|
||||
{
|
||||
XUiC_RepairableVehicleStack itemController = itemControllers[i] as XUiC_RepairableVehicleStack;
|
||||
|
||||
if (itemController != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3d i: " + i);
|
||||
|
||||
for (int index = 0; index < itemController.SlotIndices.Count; ++index)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3e itemController.SlotIndices[" + index + "]: " + itemController.SlotIndices[index]);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3e (int)slotEnum: " + (int)slotEnum);
|
||||
if (itemController.SlotIndices[index] == (int)slotEnum)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == ItemStack.Empty: " + (itemController.ItemStack == ItemStack.Empty));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == null: " + (itemController.ItemStack == null));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == ItemValue.None: " + (itemController.itemValue == ItemValue.None));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.ItemStack == null: " + (itemController.itemValue == null));
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue: " + itemController.itemValue);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.HasQuality: " + itemController.itemValue.HasQuality);
|
||||
if (itemController.itemValue.HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.Quality: " + itemController.itemValue.Quality);
|
||||
}
|
||||
|
||||
bool canAdd = false;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f itemController.itemValue.ItemClass != null: " + (itemController.itemValue.ItemClass != null));
|
||||
|
||||
if (itemController.itemValue.ItemClass != null)
|
||||
{
|
||||
string currentPart = itemController.itemValue.ItemClass.GetItemName().ToLower();
|
||||
string newPart = __instance.ItemStack.itemValue.ItemClass.GetItemName().ToLower();
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f currentPart: " + currentPart);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3f newPart: " + newPart);
|
||||
|
||||
if (currentPart != newPart)
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldStop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
|
||||
if (canAdd)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fa");
|
||||
itemController.ItemStack = __instance.ItemStack.Clone();
|
||||
Manager.PlayXUiSound(itemController.placeSound, 0.75f);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fb");
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fc");
|
||||
foreach (XUiC_VehicleFrameWindowRebirth window in primaryPlayer.PlayerUI.xui.GetWindowsByType<XUiC_VehicleFrameWindowRebirth>())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fd");
|
||||
if (window != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3fe");
|
||||
EntityVehicleRebirth vehicle = window.Vehicle;
|
||||
|
||||
if (vehicle != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3ff");
|
||||
int playerID = player.entityId;
|
||||
int currentVehicleID = vehicle.entityId;
|
||||
float currentItemUseTimes = __instance.ItemStack.itemValue.UseTimes;
|
||||
string currentItemName = __instance.ItemStack.itemValue.ItemClass.GetItemName();
|
||||
int quality = __instance.ItemStack.itemValue.Quality;
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation playerID: " + playerID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentVehicleID: " + currentVehicleID);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation quality: " + quality);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentItemUseTimes: " + currentItemUseTimes);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation currentItemName: " + currentItemName);
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation index: " + index);
|
||||
|
||||
NetPackageVehicleUpdatePartRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdatePartRebirth>().Setup(playerID, currentVehicleID, i, currentItemUseTimes, quality, currentItemName);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldStop)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 3g STOP");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((UnityEngine.Object)__instance.xui.vehicle != (UnityEngine.Object)null && !flag)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 4");
|
||||
string vehicleSlotType = __instance.ItemStack.itemValue.ItemClass.VehicleSlotType;
|
||||
ItemStack resultStack;
|
||||
if (vehicleSlotType != "" && __instance.xui.Vehicle.SetPart(__instance.xui, vehicleSlotType, __instance.ItemStack, out resultStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 5");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = resultStack;
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.vehicle.GetVehicle().HasStorage())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 6");
|
||||
XUiC_VehicleContainer childByType = __instance.xui.FindWindowGroupByName(XUiC_VehicleStorageWindowGroup.ID).GetChildByType<XUiC_VehicleContainer>();
|
||||
if (childByType != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 7");
|
||||
if (childByType.AddItem(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 8");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 9");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 10");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag && __instance.ItemStack.itemValue.ItemClass is ItemClassModifier)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation ItemClass is ItemClassModifier");
|
||||
ItemStack resultStack;
|
||||
if (__instance.xui.AssembleItem.AddPartToItem(__instance.ItemStack, out resultStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 12");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = resultStack;
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.PlayerEquipment != null && __instance.xui.PlayerEquipment.IsOpen && __instance.itemStack.itemValue.ItemClass.IsEquipment)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 13");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = __instance.xui.PlayerEquipment.EquipItem(__instance.ItemStack);
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.lootContainer != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 14");
|
||||
XUiC_LootContainer childByType = __instance.xui.FindWindowGroupByName(XUiC_LootWindowGroup.ID).GetChildByType<XUiC_LootContainer>();
|
||||
if (XUiM_LootContainer.AddItem(__instance.ItemStack, __instance.xui))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 15");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
childByType?.SetSlots(__instance.xui.lootContainer, __instance.xui.lootContainer.items);
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 16");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 17");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
childByType?.SetSlots(__instance.xui.lootContainer, __instance.xui.lootContainer.items);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.currentWorkstationToolGrid != null && __instance.xui.currentWorkstationToolGrid.TryAddTool(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 18");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.currentWorkstationFuelGrid != null && (object)__instance.itemClass.FuelValue != null && __instance.itemClass.FuelValue.Value > 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19, __instance.xui.currentWorkstation: " + __instance.xui.currentWorkstation);
|
||||
string fuelType = "";
|
||||
|
||||
Block workstation = Block.GetBlockByName(__instance.xui.currentWorkstation);
|
||||
|
||||
if (workstation != null)
|
||||
{
|
||||
fuelType = workstation.Properties.GetString("FuelType");
|
||||
}
|
||||
|
||||
if (fuelType != "" && __instance.itemClass.Name.ToLower() != fuelType.ToLower())
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19c CAN'T STACK");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if (__instance is XUiC_RequiredItemStack)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19a");
|
||||
XUiC_RequiredItemStack required = (XUiC_RequiredItemStack) __instance;
|
||||
|
||||
if (required != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19b");
|
||||
ItemStack stack = __instance.itemStack;
|
||||
|
||||
if (!required.CanSwap(stack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 19c CAN'T STACK");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (__instance.xui.currentWorkstationFuelGrid.AddItem(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 20");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 21");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 22");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.currentDewCollectorModGrid != null && __instance.xui.currentDewCollectorModGrid.TryAddMod(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 23");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.currentCombineGrid != null && __instance.xui.currentCombineGrid.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 24");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.powerSourceSlots != null && __instance.xui.powerSourceSlots.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 25");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (__instance.xui.powerAmmoSlots != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 26");
|
||||
if (__instance.xui.powerAmmoSlots.TryAddItemToSlot(__instance.itemClass, __instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 27");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 28");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 29");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (__instance.xui.Trader.Trader != null && (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack || __instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 30");
|
||||
__instance.HandleItemInspect();
|
||||
__instance.InfoWindow.SetMaxCountOnDirty = true;
|
||||
return false;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.Backpack)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 31");
|
||||
if (__instance.xui.PlayerInventory.AddItemToToolbelt(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 32");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 33");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 34");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (__instance.StackLocation == XUiC_ItemStack.StackLocationTypes.ToolBelt)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 35");
|
||||
if (__instance.xui.PlayerInventory.AddItemToBackpack(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 36");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 37");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 38");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XUiC_ItemStack.StackLocationTypes.LootContainer:
|
||||
case XUiC_ItemStack.StackLocationTypes.Workstation:
|
||||
case XUiC_ItemStack.StackLocationTypes.Merge:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 39");
|
||||
if (__instance.xui.PlayerInventory.AddItem(__instance.ItemStack))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 40");
|
||||
__instance.PlayPlaceSound();
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
__instance.HandleSlotChangeEvent();
|
||||
break;
|
||||
}
|
||||
if (count != __instance.ItemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 41");
|
||||
__instance.PlayPlaceSound();
|
||||
if (__instance.ItemStack.count == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 42");
|
||||
__instance.ItemStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
__instance.HandleSlotChangeEvent();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case XUiC_ItemStack.StackLocationTypes.Creative:
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 43");
|
||||
if (!__instance.xui.PlayerInventory.AddItem(__instance.itemStack.Clone()))
|
||||
{
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation 44");
|
||||
return false;
|
||||
}
|
||||
__instance.PlayPlaceSound();
|
||||
break;
|
||||
}
|
||||
__instance.xui.calloutWindow.UpdateCalloutsForItemStack(__instance.ViewComponent.UiTransform.gameObject, __instance.ItemStack, __instance.isOver);
|
||||
|
||||
//Log.Out("XUiC_ItemStackPatches-HandleMoveToPreferredLocation END");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.XUiC_LootWindowGroupPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_LootWindowGroup))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static bool Prefix(XUiC_LootWindowGroup __instance, float _dt
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update __instance.xui.playerUI.entityPlayer != null: " + (__instance.xui.playerUI.entityPlayer != null));
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update __instance.xui.playerUI.entityPlayer.hasBeenAttackedTime: " + __instance.xui.playerUI.entityPlayer.hasBeenAttackedTime);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update __instance.isOpening: " + __instance.isOpening);
|
||||
|
||||
if (__instance.viewComponent != null && __instance.windowGroup != null && __instance.windowGroup.isShowing && __instance.viewComponent.IsVisible)
|
||||
__instance.viewComponent.Update(_dt);
|
||||
if (__instance.curInputStyle != __instance.lastInputStyle)
|
||||
{
|
||||
PlayerInputManager.InputStyle lastInputStyle = __instance.lastInputStyle;
|
||||
__instance.lastInputStyle = __instance.curInputStyle;
|
||||
__instance.RefreshBindings();
|
||||
__instance.InputStyleChanged(lastInputStyle, __instance.lastInputStyle);
|
||||
}
|
||||
for (int index = 0; index < __instance.children.Count; ++index)
|
||||
{
|
||||
XUiController child = __instance.children[index];
|
||||
if (!child.IsDormant)
|
||||
child.Update(_dt);
|
||||
}
|
||||
|
||||
if (__instance.xui.playerUI.entityPlayer != null && __instance.xui.playerUI.entityPlayer.hasBeenAttackedTime > 0 && __instance.isOpening)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 1");
|
||||
GUIWindowManager windowManager = __instance.xui.playerUI.windowManager;
|
||||
windowManager.Close("timer");
|
||||
__instance.isOpening = false;
|
||||
__instance.isClosingFromDamage = true;
|
||||
windowManager.Close("looting");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 2");
|
||||
if (!__instance.isOpening)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity entity = GameManager.Instance.World.GetEntity(__instance.te.EntityId);
|
||||
EntitySupplyCrate supplyCrate = null;
|
||||
|
||||
bool forceTimer = false;
|
||||
bool isSupplyCrate = false;
|
||||
|
||||
if (entity != null && entity is EntitySupplyCrate)
|
||||
{
|
||||
supplyCrate = (EntitySupplyCrate)entity;
|
||||
|
||||
if (supplyCrate != null)
|
||||
{
|
||||
isSupplyCrate = true;
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update IS SUPPLY CRATE");
|
||||
|
||||
if (supplyCrate.Buffs.GetCustomVar("$WasOpened") == 0f)
|
||||
{
|
||||
forceTimer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((__instance.te.bWasTouched && !forceTimer) || (double)__instance.openTimeLeft <= 0.0))
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.te.lootListName: " + __instance.te.lootListName);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.te.bWasTouched: " + __instance.te.bWasTouched);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.openTimeLeft: " + __instance.openTimeLeft);
|
||||
if (!__instance.te.bWasTouched && !__instance.te.bPlayerStorage && !__instance.te.bPlayerBackpack)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 5");
|
||||
__instance.xui.playerUI.entityPlayer.Progression.AddLevelExp(__instance.xui.playerUI.entityPlayer.gameStage, "_xpFromLoot", Progression.XPTypes.Looting);
|
||||
}
|
||||
__instance.openTimeLeft = 0.0f;
|
||||
__instance.te.bWasTouched = true;
|
||||
if (isSupplyCrate && supplyCrate != null)
|
||||
{
|
||||
supplyCrate.Buffs.SetCustomVar("$WasOpened", 1f);
|
||||
}
|
||||
__instance.OpenContainer();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.te.lootListName: " + __instance.te.lootListName);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.te.bWasTouched: " + __instance.te.bWasTouched);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 4 __instance.openTimeLeft: " + __instance.openTimeLeft);
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 6");
|
||||
if (__instance.timerWindow != null)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update 7");
|
||||
__instance.timerWindow.UpdateTimer(__instance.openTimeLeft, __instance.openTimeLeft / __instance.totalOpenTime);
|
||||
}
|
||||
__instance.openTimeLeft -= _dt;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-Update END");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_LootWindowGroup))]
|
||||
[HarmonyPatch("OnOpen")]
|
||||
public class OnOpenPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_LootWindowGroup __instance
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen START");
|
||||
__instance.isClosingFromDamage = false;
|
||||
if (__instance.te.EntityId != -1)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen 1");
|
||||
if ((double)EffectManager.GetValue(PassiveEffects.DisableLoot, _entity: (EntityAlive)__instance.xui.playerUI.entityPlayer, tags: GameManager.Instance.World.GetEntity(__instance.te.EntityId).EntityClass.Tags) > 0.0)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen 2");
|
||||
Manager.PlayInsidePlayerHead("twitch_no_attack");
|
||||
GUIWindowManager windowManager = __instance.xui.playerUI.windowManager;
|
||||
__instance.ignoreCloseSound = true;
|
||||
windowManager.Close("timer");
|
||||
__instance.isOpening = false;
|
||||
__instance.isClosingFromDamage = true;
|
||||
windowManager.Close("looting");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ((double)EffectManager.GetValue(PassiveEffects.DisableLoot, _entity: (EntityAlive)__instance.xui.playerUI.entityPlayer, tags: __instance.te.blockValue.Block.Tags) > 0.0)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen 3");
|
||||
Manager.PlayInsidePlayerHead("twitch_no_attack");
|
||||
GUIWindowManager windowManager = __instance.xui.playerUI.windowManager;
|
||||
__instance.ignoreCloseSound = true;
|
||||
windowManager.Close("timer");
|
||||
__instance.isOpening = false;
|
||||
__instance.isClosingFromDamage = true;
|
||||
windowManager.Close("looting");
|
||||
return false;
|
||||
}
|
||||
__instance.ignoreCloseSound = false;
|
||||
__instance.xui.playerUI.windowManager.CloseIfOpen("backpack");
|
||||
__instance.lootWindow.ViewComponent.UiTransform.gameObject.SetActive(false);
|
||||
EntityPlayer entityPlayer = (EntityPlayer)__instance.xui.playerUI.entityPlayer;
|
||||
|
||||
float openTime = LootContainer.GetLootContainer(__instance.te.lootListName).openTime;
|
||||
|
||||
__instance.totalOpenTime = __instance.openTimeLeft = EffectManager.GetValue(PassiveEffects.ScavengingTime, _originalValue: entityPlayer.IsCrouching ? openTime * 1.5f : openTime, _entity: (EntityAlive)entityPlayer);
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen openTime: " + openTime);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen BEFORE __instance.totalOpenTime: " + __instance.totalOpenTime);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen __instance.openTimeLeft: " + __instance.openTimeLeft);
|
||||
|
||||
bool optionProtectCrate = RebirthVariables.customProtectCrate;
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen optionProtectCrate: " + optionProtectCrate);
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen __instance.te.lootListName.ToLower(): " + __instance.te.lootListName.ToLower());
|
||||
|
||||
if (optionProtectCrate && __instance.te.lootListName.ToLower().Contains("airdrop"))
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen AIR DROP");
|
||||
__instance.totalOpenTime = RebirthVariables.supplyCrateOpenTime;
|
||||
__instance.openTimeLeft = RebirthVariables.supplyCrateOpenTime;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen AFTER __instance.totalOpenTime: " + __instance.totalOpenTime);
|
||||
|
||||
if (__instance.nonPagingHeaderWindow != null)
|
||||
__instance.nonPagingHeaderWindow.SetHeader("LOOTING");
|
||||
__instance.xui.playerUI.windowManager.OpenIfNotOpen("CalloutGroup", false);
|
||||
__instance.xui.playerUI.windowManager.Open("timer", false);
|
||||
__instance.timerWindow = __instance.xui.GetChildByType<XUiC_Timer>();
|
||||
__instance.timerWindow.currentOpenEventText = Localization.Get("xuiOpeningLoot");
|
||||
__instance.isOpening = true;
|
||||
LootContainer lootContainer = LootContainer.GetLootContainer(__instance.te.lootListName);
|
||||
if (lootContainer == null || lootContainer.soundClose == null)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen 4");
|
||||
return false;
|
||||
}
|
||||
Vector3 position = __instance.te.ToWorldPos().ToVector3() + Vector3.one * 0.5f;
|
||||
if (__instance.te.EntityId != -1 && GameManager.Instance.World != null)
|
||||
{
|
||||
//Log.Out("XUiC_LootWindowGroupPatches-OnOpen 5");
|
||||
Entity entity = GameManager.Instance.World.GetEntity(__instance.te.EntityId);
|
||||
if (entity != null)
|
||||
position = entity.GetPosition();
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(position, lootContainer.soundOpen);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Harmony.XUiC_MainMenuPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_MainMenu))]
|
||||
[HarmonyPatch("Open")]
|
||||
public class OpenPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_MainMenu __instance, XUi _xuiInstance)
|
||||
{
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
IJoinSessionGameInviteListener gameInviteListener = PlatformManager.NativePlatform.JoinSessionGameInviteListener;
|
||||
if ((gameInviteListener != null ? (gameInviteListener.HasPendingIntent() ? 1 : 0) : 0) != 0)
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
if (!XUiC_MainMenu.shownNewsScreenOnce)
|
||||
{
|
||||
XUiC_NewsScreen.Open(_xuiInstance);
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_xuiInstance.playerUI.windowManager.Open(XUiC_MainMenu.ID, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Harmony.XUiC_MapSubPopupListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_MapSubPopupEntry))]
|
||||
[HarmonyPatch("onPressed")]
|
||||
public class XUiC_MapSubPopupEntry_onPressed
|
||||
{
|
||||
private static void Postfix(XUiC_MapSubPopupEntry __instance, int ___index)
|
||||
{
|
||||
var gridPosition = new Vector2i((___index / RebirthVariables.waypointIconRows + 1) * RebirthVariables.waypointIconWidth, (___index % RebirthVariables.waypointIconRows) * - RebirthVariables.waypointIconHeight);
|
||||
var waypointWindow = ((XUiController)__instance).xui.GetWindow("mapAreaEnterWaypointName");
|
||||
var baseWindowPosition = ((XUiController)__instance).xui.GetWindow("mapAreaChooseWaypoint").Position;
|
||||
|
||||
((XUiView)waypointWindow).Position = gridPosition + baseWindowPosition;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_MapPopupList))]
|
||||
[HarmonyPatch("onPressEntry2")]
|
||||
public static class onPressEntry2Patch
|
||||
{
|
||||
static bool Prefix(XUiC_MapPopupList __instance, XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (!(_sender is XUiC_MapPopupEntry))
|
||||
return false;
|
||||
XUiV_Window window1 = __instance.xui.GetWindow("mapAreaSetWaypoint");
|
||||
XUiV_Window window2 = __instance.xui.GetWindow("mapAreaChooseWaypoint");
|
||||
int num = RebirthVariables.waypointIconWidth;
|
||||
window2.Position = window1.Position + new Vector2i(199, -num);
|
||||
if (window2.Position.y < 0)
|
||||
window2.Position = new Vector2i(window2.Position.x, window2.Position.y + window2.Size.y);
|
||||
window2.IsVisible = true;
|
||||
window2.Controller.GetChildByType<XUiC_MapSubPopupListRebirth>().ResetList();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiC_MapWaypointListPatches
|
||||
{
|
||||
internal class XUiC_MapWaypointListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_MapWaypointList))]
|
||||
[HarmonyPatch("onWaypointRemovePressed")]
|
||||
public class onWaypointRemovePressedPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_MapWaypointList __instance, XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_MapWaypointListPatches-onWaypointRemovePressed START");
|
||||
EntityPlayerLocal entityPlayer = __instance.xui.playerUI.entityPlayer;
|
||||
Waypoint waypoint = __instance.GetSelectedWaypoint();
|
||||
if (waypoint != null)
|
||||
{
|
||||
//Log.Out("XUiC_MapWaypointListPatches-onWaypointRemovePressed 1");
|
||||
entityPlayer.Waypoints.Collection.Remove(waypoint);
|
||||
NavObjectManager.Instance.UnRegisterNavObject(waypoint.navObject);
|
||||
__instance.UpdateWaypointsList(null);
|
||||
__instance.SelectedWaypoint = null;
|
||||
if (__instance.SelectedWaypointEntry != null)
|
||||
{
|
||||
__instance.SelectedWaypointEntry.Selected = false;
|
||||
}
|
||||
Manager.PlayInsidePlayerHead("ui_waypoint_delete", -1, 0f, false);
|
||||
return false;
|
||||
}
|
||||
//Log.Out("XUiC_MapWaypointListPatches-onWaypointRemovePressed 2");
|
||||
Manager.PlayInsidePlayerHead("ui_denied", -1, 0f, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Harmony.XUiC
|
||||
{
|
||||
public class XUiC_NewContinueGamePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_NewContinueGame))]
|
||||
[HarmonyPatch("BtnConfirmDelete_OnPressed")]
|
||||
public class BtnConfirmDelete_OnPressedPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_NewContinueGame __instance, XUiController _sender, int _mouseButton)
|
||||
{
|
||||
XUiC_SavegamesList.ListEntry entry = __instance.savesList.SelectedEntry.GetEntry();
|
||||
|
||||
string SaveDataPath = SaveDataPath = GameIO.GetUserGameDataDir() + "/RebirthData/Scenarios";
|
||||
string scenarioPath = $"{SaveDataPath}/{entry.worldName}/{entry.saveName}";
|
||||
|
||||
if (System.IO.Directory.Exists(scenarioPath))
|
||||
{
|
||||
Directory.Delete(scenarioPath, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_NewContinueGame))]
|
||||
[HarmonyPatch("OnOpen")]
|
||||
public class OnOpenPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_NewContinueGame __instance)
|
||||
{
|
||||
//Log.Out("XUiC_NewContinueGamePatches-OnOpen START");
|
||||
CustomGameOptions.LoadGameOptions(null, __instance.isContinueGame);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HarmonyPatch(typeof(XUiC_NewContinueGame))]
|
||||
[HarmonyPatch("CbxWorldName_OnValueChanged")]
|
||||
public class CbxWorldName_OnValueChangedPatch
|
||||
{
|
||||
public static void Postfix(XUiC_NewContinueGame __instance, XUiController _sender, XUiC_NewContinueGame.LevelInfo _oldValue, XUiC_NewContinueGame.LevelInfo _newValue)
|
||||
{
|
||||
Log.Out("XUiC_NewContinueGamePatches-CbxWorldName_OnValueChanged world: " + GamePrefs.GetString(EnumGamePrefs.GameWorld));
|
||||
Log.Out("XUiC_NewContinueGamePatches-CbxWorldName_OnValueChanged game: " + GamePrefs.GetString(EnumGamePrefs.GameName));
|
||||
CustomGameOptions.LoadGameOptions(null);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.XUiC_PlayersListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_PlayersList))]
|
||||
[HarmonyPatch("updatePlayersList")]
|
||||
public class updatePlayersListPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_PlayersList __instance)
|
||||
{
|
||||
EntityPlayerLocal entityPlayer1 = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
bool hideGamestage = false;
|
||||
|
||||
if (RebirthVariables.customInfested == "hidesurprise"
|
||||
)
|
||||
{
|
||||
List<Quest> listCurrentQuests = entityPlayer1.QuestJournal.quests;
|
||||
|
||||
for (int index = 0; index < listCurrentQuests.Count; ++index)
|
||||
{
|
||||
if (listCurrentQuests[index].CurrentState == Quest.QuestState.InProgress && listCurrentQuests[index].RallyMarkerActivated)
|
||||
{
|
||||
hideGamestage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<XUiC_PlayersList.SEntityIdRef> sentityIdRefList = new List<XUiC_PlayersList.SEntityIdRef>();
|
||||
for (int index = 0; index < GameManager.Instance.World.Players.list.Count; ++index)
|
||||
{
|
||||
EntityPlayer _Ref = GameManager.Instance.World.Players.list[index];
|
||||
sentityIdRefList.Add(new XUiC_PlayersList.SEntityIdRef(_Ref.entityId, _Ref));
|
||||
}
|
||||
__instance.numberOfPlayers.Text = sentityIdRefList.Count.ToString();
|
||||
__instance.playerPager.SetLastPageByElementsAndPageLength(sentityIdRefList.Count, __instance.playerList.Rows);
|
||||
if (GameManager.Instance.persistentLocalPlayer.ACL != null)
|
||||
{
|
||||
foreach (PlatformUserIdentifierAbs _userIdentifier in GameManager.Instance.persistentLocalPlayer.ACL)
|
||||
{
|
||||
PersistentPlayerData playerData = GameManager.Instance.persistentPlayers.GetPlayerData(_userIdentifier);
|
||||
if (playerData != null && !((UnityEngine.Object)GameManager.Instance.World.GetEntity(playerData.EntityId) != (UnityEngine.Object)null))
|
||||
sentityIdRefList.Add(new XUiC_PlayersList.SEntityIdRef(playerData));
|
||||
}
|
||||
}
|
||||
sentityIdRefList.Sort((IComparer<XUiC_PlayersList.SEntityIdRef>)new XUiC_PlayersList.PlayersSorter(entityPlayer1));
|
||||
GameServerInfo gameServerInfo = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer ? SingletonMonoBehaviour<ConnectionManager>.Instance.LocalServerInfo : SingletonMonoBehaviour<ConnectionManager>.Instance.LastGameServerInfo;
|
||||
bool _showCrossplay = gameServerInfo != null && gameServerInfo.AllowsCrossplay;
|
||||
if (!_showCrossplay)
|
||||
{
|
||||
EPlayGroup playGroup1 = DeviceFlags.Current.ToPlayGroup();
|
||||
for (int index = 0; index < sentityIdRefList.Count; ++index)
|
||||
{
|
||||
EPlayGroup playGroup2 = sentityIdRefList[index].PlayerData.PlayGroup;
|
||||
if (playGroup2 != EPlayGroup.Unknown && playGroup2 != playGroup1)
|
||||
{
|
||||
_showCrossplay = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int index1;
|
||||
for (index1 = 0; index1 < __instance.playerList.Rows && index1 < sentityIdRefList.Count; ++index1)
|
||||
{
|
||||
int index2 = index1 + __instance.playerList.Rows * __instance.playerPager.GetPage();
|
||||
if (index2 < sentityIdRefList.Count)
|
||||
{
|
||||
XUiC_PlayersListEntry playerEntry = __instance.playerEntries[index1];
|
||||
if (playerEntry != null)
|
||||
{
|
||||
EntityPlayer entityPlayer2 = sentityIdRefList[index2].Ref;
|
||||
bool flag1 = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)null && (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1 && entityPlayer2.IsInPartyOfLocalPlayer;
|
||||
bool flag2 = (UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)null || (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1 && entityPlayer2.IsFriendOfLocalPlayer;
|
||||
if (!((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)null))
|
||||
{
|
||||
int entityId = entityPlayer2.entityId;
|
||||
}
|
||||
PersistentPlayerData persistentPlayerData = sentityIdRefList[index2].PlayerId != null ? GameManager.Instance.persistentPlayers.GetPlayerData(sentityIdRefList[index2].PlayerId) : GameManager.Instance.persistentPlayers.GetPlayerDataFromEntityID(entityPlayer2.entityId);
|
||||
if (persistentPlayerData != null)
|
||||
{
|
||||
foreach (EBlockType _blockType in (IEnumerable<EBlockType>)EnumUtils.Values<EBlockType>())
|
||||
playerEntry.playerBlockStateChanged(persistentPlayerData.PlatformData, _blockType, persistentPlayerData.PlatformData.Blocked[_blockType].State);
|
||||
if ((UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)null)
|
||||
{
|
||||
playerEntry.IsOffline = false;
|
||||
playerEntry.EntityId = entityPlayer2.entityId;
|
||||
playerEntry.PlayerData = persistentPlayerData;
|
||||
playerEntry.ViewComponent.IsVisible = true;
|
||||
playerEntry.PlayerName.UpdatePlayerData(persistentPlayerData.PlayerData, _showCrossplay, persistentPlayerData.PlayerName.DisplayName);
|
||||
playerEntry.AdminSprite.IsVisible = entityPlayer2.IsAdmin;
|
||||
playerEntry.TwitchSprite.IsVisible = entityPlayer2.TwitchEnabled && entityPlayer2.TwitchActionsEnabled == EntityPlayer.TwitchActionsStates.Enabled;
|
||||
playerEntry.TwitchDisabledSprite.IsVisible = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled || entityPlayer2.TwitchSafe;
|
||||
playerEntry.TwitchDisabledSprite.SpriteName = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled ? "ui_game_symbol_twitch_action_disabled" : "ui_game_symbol_brick";
|
||||
playerEntry.TwitchDisabledSprite.ToolTip = entityPlayer2.TwitchActionsEnabled != EntityPlayer.TwitchActionsStates.Enabled ? XUiC_PlayersList.twitchDisabled : XUiC_PlayersList.twitchSafe;
|
||||
XUiV_Label zombieKillsText = playerEntry.ZombieKillsText;
|
||||
int num = entityPlayer2.KilledZombies;
|
||||
string str1 = num.ToString();
|
||||
zombieKillsText.Text = str1;
|
||||
XUiV_Label playerKillsText = playerEntry.PlayerKillsText;
|
||||
num = entityPlayer2.KilledPlayers;
|
||||
string str2 = num.ToString();
|
||||
playerKillsText.Text = str2;
|
||||
XUiV_Label deathsText = playerEntry.DeathsText;
|
||||
num = entityPlayer2.Died;
|
||||
string str3 = num.ToString();
|
||||
deathsText.Text = str3;
|
||||
XUiV_Label levelText = playerEntry.LevelText;
|
||||
num = entityPlayer2.Progression.GetLevel();
|
||||
string str4 = num.ToString();
|
||||
levelText.Text = str4;
|
||||
XUiV_Label gamestageText = playerEntry.GamestageText;
|
||||
num = entityPlayer2.gameStage;
|
||||
string str5 = num.ToString();
|
||||
gamestageText.Text = str5;
|
||||
|
||||
if (hideGamestage)
|
||||
{
|
||||
gamestageText.Text = "N/A";
|
||||
}
|
||||
|
||||
playerEntry.PingText.Text = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) || !SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer ? (entityPlayer2.pingToServer < 0 ? "--" : entityPlayer2.pingToServer.ToString()) : "--";
|
||||
playerEntry.Voice.IsVisible = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
|
||||
playerEntry.Chat.IsVisible = (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
|
||||
playerEntry.IsFriend = flag2;
|
||||
playerEntry.ShowOnMapEnabled = flag2 | flag1;
|
||||
if (flag2 | flag1)
|
||||
{
|
||||
float magnitude = (entityPlayer2.GetPosition() - entityPlayer1.GetPosition()).magnitude;
|
||||
playerEntry.DistanceToFriend.Text = ValueDisplayFormatters.Distance(magnitude);
|
||||
}
|
||||
else
|
||||
playerEntry.DistanceToFriend.Text = "--";
|
||||
playerEntry.buttonReportPlayer.IsVisible = PlatformManager.MultiPlatform.PlayerReporting != null && (UnityEngine.Object)entityPlayer2 != (UnityEngine.Object)entityPlayer1;
|
||||
playerEntry.AllyStatus = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) ? (!flag2 ? (!__instance.invitesReceivedList.Contains(persistentPlayerData.PrimaryId) ? (!__instance.invitesSentList.Contains(persistentPlayerData.PrimaryId) ? XUiC_PlayersListEntry.EnumAllyInviteStatus.NA : XUiC_PlayersListEntry.EnumAllyInviteStatus.Sent) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Received) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Friends) : XUiC_PlayersListEntry.EnumAllyInviteStatus.LocalPlayer;
|
||||
if ((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1)
|
||||
playerEntry.PartyStatus = !entityPlayer1.partyInvites.Contains(entityPlayer2) ? (!entityPlayer1.IsInParty() ? XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_NoParty : ((UnityEngine.Object)entityPlayer1.Party.Leader == (UnityEngine.Object)entityPlayer1 ? XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_InPartyAsLead : XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_InParty)) : XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_Received;
|
||||
else if (entityPlayer1.IsInParty())
|
||||
{
|
||||
bool flag3 = entityPlayer1.IsPartyLead();
|
||||
playerEntry.PartyStatus = !entityPlayer1.Party.MemberList.Contains(entityPlayer2) ? (!entityPlayer2.IsInParty() || !entityPlayer2.Party.IsFull() ? (flag3 ? XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoParty) : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_PartyFullAsLead) : (!flag3 ? (entityPlayer2.IsPartyLead() ? XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InPartyIsLead : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InParty) : XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_InPartyAsLead);
|
||||
}
|
||||
else if (entityPlayer1.partyInvites.Contains(entityPlayer2))
|
||||
{
|
||||
if (entityPlayer2.IsInParty() && entityPlayer2.Party.IsFull())
|
||||
{
|
||||
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead;
|
||||
entityPlayer1.partyInvites.Remove(entityPlayer2);
|
||||
}
|
||||
else
|
||||
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.LocalPlayer_Received;
|
||||
}
|
||||
else
|
||||
{
|
||||
entityPlayer2.IsInParty();
|
||||
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.OtherPlayer_NoPartyAsLead;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
playerEntry.IsOffline = true;
|
||||
playerEntry.EntityId = -1;
|
||||
playerEntry.PlayerData = persistentPlayerData;
|
||||
playerEntry.PlayerName.UpdatePlayerData(persistentPlayerData.PlayerData, _showCrossplay, persistentPlayerData.PlayerName.DisplayName ?? sentityIdRefList[index2].PlayerId.CombinedString);
|
||||
playerEntry.AdminSprite.IsVisible = false;
|
||||
playerEntry.TwitchSprite.IsVisible = false;
|
||||
playerEntry.TwitchDisabledSprite.IsVisible = false;
|
||||
playerEntry.DistanceToFriend.IsVisible = true;
|
||||
playerEntry.DistanceToFriend.Text = "--";
|
||||
playerEntry.ZombieKillsText.Text = "--";
|
||||
playerEntry.PlayerKillsText.Text = "--";
|
||||
playerEntry.DeathsText.Text = "--";
|
||||
playerEntry.LevelText.Text = "--";
|
||||
playerEntry.GamestageText.Text = "--";
|
||||
playerEntry.PingText.Text = "--";
|
||||
playerEntry.Voice.IsVisible = false;
|
||||
playerEntry.Chat.IsVisible = false;
|
||||
playerEntry.IsOffline = true;
|
||||
playerEntry.AllyStatus = !((UnityEngine.Object)entityPlayer2 == (UnityEngine.Object)entityPlayer1) ? (!flag2 ? (!__instance.invitesReceivedList.Contains(persistentPlayerData.PrimaryId) ? (!__instance.invitesSentList.Contains(persistentPlayerData.PrimaryId) ? XUiC_PlayersListEntry.EnumAllyInviteStatus.NA : XUiC_PlayersListEntry.EnumAllyInviteStatus.Sent) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Received) : XUiC_PlayersListEntry.EnumAllyInviteStatus.Friends) : XUiC_PlayersListEntry.EnumAllyInviteStatus.LocalPlayer;
|
||||
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.Offline;
|
||||
playerEntry.labelPartyIcon.IsVisible = true;
|
||||
playerEntry.buttonReportPlayer.IsVisible = true;
|
||||
playerEntry.buttonShowOnMap.IsVisible = false;
|
||||
playerEntry.labelShowOnMap.IsVisible = true;
|
||||
}
|
||||
playerEntry.RefreshBindings();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (; index1 < __instance.playerList.Rows; ++index1)
|
||||
{
|
||||
XUiC_PlayersListEntry playerEntry = __instance.playerEntries[index1];
|
||||
if (playerEntry != null)
|
||||
{
|
||||
playerEntry.EntityId = -1;
|
||||
playerEntry.PlayerData = (PersistentPlayerData)null;
|
||||
playerEntry.PlayerName.ClearPlayerData();
|
||||
playerEntry.AdminSprite.IsVisible = false;
|
||||
playerEntry.TwitchSprite.IsVisible = false;
|
||||
playerEntry.TwitchDisabledSprite.IsVisible = false;
|
||||
playerEntry.ZombieKillsText.Text = string.Empty;
|
||||
playerEntry.PlayerKillsText.Text = string.Empty;
|
||||
playerEntry.DeathsText.Text = string.Empty;
|
||||
playerEntry.LevelText.Text = string.Empty;
|
||||
playerEntry.GamestageText.Text = string.Empty;
|
||||
playerEntry.PingText.Text = string.Empty;
|
||||
playerEntry.Voice.IsVisible = false;
|
||||
playerEntry.Chat.IsVisible = false;
|
||||
playerEntry.ShowOnMapEnabled = false;
|
||||
playerEntry.DistanceToFriend.IsVisible = false;
|
||||
playerEntry.AllyStatus = XUiC_PlayersListEntry.EnumAllyInviteStatus.Empty;
|
||||
playerEntry.PartyStatus = XUiC_PlayersListEntry.EnumPartyStatus.Offline;
|
||||
playerEntry.buttonReportPlayer.IsVisible = false;
|
||||
playerEntry.labelAllyIcon.IsVisible = false;
|
||||
playerEntry.labelPartyIcon.IsVisible = false;
|
||||
playerEntry.labelShowOnMap.IsVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.XUiC_PoiListPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_PoiList))]
|
||||
[HarmonyPatch("RebuildList")]
|
||||
public class RebuildListPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_PoiList __instance, bool _resetFilter)
|
||||
{
|
||||
__instance.allEntries.Clear();
|
||||
if ((UnityEngine.Object)GameManager.Instance != (UnityEngine.Object)null)
|
||||
{
|
||||
List<PrefabInstance> dynamicPrefabs = GameManager.Instance.GetDynamicPrefabDecorator()?.GetDynamicPrefabs();
|
||||
if (dynamicPrefabs != null)
|
||||
{
|
||||
foreach (PrefabInstance _prefabInstance in dynamicPrefabs)
|
||||
{
|
||||
if (!__instance.openedBefore)
|
||||
{
|
||||
__instance.MinTier = Mathf.Min((int)_prefabInstance.prefab.DifficultyTier, __instance.MinTier);
|
||||
__instance.MaxTier = Mathf.Max((int)_prefabInstance.prefab.DifficultyTier, __instance.MaxTier);
|
||||
}
|
||||
if ((!__instance.filterSmallPois || _prefabInstance.boundingBoxSize.Volume() >= 100) && (__instance.filterTier < 0 || (int)_prefabInstance.prefab.DifficultyTier == __instance.filterTier))
|
||||
{
|
||||
if (!_prefabInstance.prefab.Tags.Test_AnySet(FastTags<TagGroup.Poi>.Parse("rwgonly,streettile,hideui")))
|
||||
{
|
||||
__instance.allEntries.Add(new XUiC_PoiList.PoiListEntry(_prefabInstance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
__instance.allEntries.Sort();
|
||||
|
||||
__instance.SelectedEntry = null;
|
||||
if (__instance.filteredEntries != null)
|
||||
__instance.filteredEntries.Clear();
|
||||
__instance.RefreshView(_resetFilter);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Harmony.XUiC_QuestRewardsWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_QuestRewardsWindow))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_QuestRewardsWindow __instance, ref string value, string bindingName)
|
||||
{
|
||||
if (RebirthVariables.customInfested == "hidesurprise")
|
||||
{
|
||||
if (bindingName == "showempty"
|
||||
)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else if (bindingName == "showquest"
|
||||
)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.XUiC_QuestTurnInEntryPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_QuestTurnInRewardsWindow))]
|
||||
[HarmonyPatch("SetupOptions")]
|
||||
public class SetupOptionsPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_QuestTurnInRewardsWindow __instance)
|
||||
{
|
||||
float value = EffectManager.GetValue(PassiveEffects.QuestRewardOptionCount, null, (float)__instance.currentQuest.QuestClass.RewardChoicesCount, __instance.xui.playerUI.entityPlayer, null, default(FastTags<TagGroup.Global>), true, true, true, true, true, 1, true, false);
|
||||
__instance.optionCount = 0;
|
||||
int num = 0;
|
||||
if (__instance.selectedEntry != null)
|
||||
{
|
||||
__instance.SelectedEntry = null;
|
||||
}
|
||||
__instance.selectedEntryList.Clear();
|
||||
__instance.rewardList.Clear();
|
||||
for (int i = 0; i < __instance.entryList.Length; i++)
|
||||
{
|
||||
__instance.entryList[i].OnPress -= __instance.TurnInEntryPressed;
|
||||
__instance.entryList[i].SetBaseReward(null);
|
||||
}
|
||||
|
||||
Log.Out("XUiC_QuestTurnInEntryPatches-SetupOptions __instance.currentQuest.QuestClass.ID: " + __instance.currentQuest.QuestClass.ID);
|
||||
Log.Out("XUiC_QuestTurnInEntryPatches-SetupOptions __instance.currentQuest.QuestClass.DifficultyTier: " + __instance.currentQuest.QuestClass.DifficultyTier);
|
||||
|
||||
for (int j = 0; j < __instance.currentQuest.Rewards.Count; j++)
|
||||
{
|
||||
Log.Out("XUiC_QuestTurnInEntryPatches-SetupOptions Reward [" + j + "]: " + __instance.currentQuest.Rewards[j].ID);
|
||||
|
||||
__instance.rewardList.Add(__instance.currentQuest.Rewards[j]);
|
||||
}
|
||||
|
||||
//__instance.rewardList = __instance.rewardList.OrderBy<BaseReward, byte>((Func<BaseReward, byte>)(o => o.RewardIndex)).ToList<BaseReward>();
|
||||
|
||||
__instance.rewardList = (from o in __instance.rewardList
|
||||
orderby o.RewardIndex
|
||||
select o).ToList<BaseReward>();
|
||||
|
||||
for (int k = 0; k < __instance.rewardList.Count; k++)
|
||||
{
|
||||
BaseReward baseReward = __instance.rewardList[k];
|
||||
|
||||
Log.Out("XUiC_QuestTurnInEntryPatches-SetupOptions Reward [" + k + "]: " + __instance.rewardList[k].ID);
|
||||
|
||||
string itemName = "EMPTY GetRewardItem()";
|
||||
|
||||
if (baseReward.GetRewardItem() != null)
|
||||
{
|
||||
if (baseReward.GetRewardItem().itemValue != null)
|
||||
{
|
||||
if (baseReward.GetRewardItem().itemValue.ItemClass != null)
|
||||
{
|
||||
itemName = baseReward.GetRewardItem().itemValue.ItemClass.GetItemName();
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = "EMPTY ItemClass";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = "EMPTY itemValue";
|
||||
}
|
||||
}
|
||||
|
||||
Log.Out("XUiC_QuestTurnInEntryPatches-SetupOptions itemName[" + k + "]: " + itemName);
|
||||
}
|
||||
|
||||
for (int k = 0; k < __instance.rewardList.Count; k++)
|
||||
{
|
||||
BaseReward baseReward = __instance.rewardList[k];
|
||||
__instance.entryList[num].OnPress -= __instance.TurnInEntryPressed;
|
||||
if (baseReward.isChosenReward)
|
||||
{
|
||||
__instance.entryList[num].SetBaseReward(baseReward);
|
||||
__instance.entryList[num].Chosen = false;
|
||||
__instance.entryList[num++].OnPress += __instance.TurnInEntryPressed;
|
||||
__instance.optionCount++;
|
||||
if (value == (float)num || num >= __instance.entryList.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
__instance.entryList[0].SelectCursorElement(true);
|
||||
if (__instance.optionCount == 1)
|
||||
{
|
||||
XUiC_QuestTurnInEntry xuiC_QuestTurnInEntry = __instance.entryList[0];
|
||||
__instance.SelectedEntry = xuiC_QuestTurnInEntry;
|
||||
__instance.RefreshBindings(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_QuestTurnInEntry))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
/*public static bool Prefix(XUiC_QuestTurnInEntry __instance, ref bool __result, ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "rewardicon")
|
||||
{
|
||||
if (__instance.reward == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__instance.item == null || __instance.item.IsEmpty())
|
||||
{
|
||||
value = __instance.reward.Icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = __instance.item.itemValue.ItemClass.GetIconName();
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
public static void Postfix(XUiC_QuestTurnInEntry __instance, ref bool __result, ref string value, string bindingName)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (bindingName == "durabilityvalue")
|
||||
{
|
||||
value = "";
|
||||
|
||||
__result = true;
|
||||
}
|
||||
else if (bindingName == "itemtypeicon")
|
||||
{
|
||||
ItemValue itemValue = __instance.Item.itemValue;
|
||||
//Log.Out("XUiC_QuestTurnInEntryPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInEntryPatches-GetBindingValue IS SPECIAL");
|
||||
value = (string)itemValue.GetMetadata("bonus");
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (bindingName == "hasitemtypeicon")
|
||||
{
|
||||
ItemValue itemValue = __instance.Item.itemValue;
|
||||
//Log.Out("XUiC_QuestTurnInEntryPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInEntryPatches-GetBindingValue IS SPECIAL");
|
||||
value = "true";
|
||||
__result = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.XUiC_QuestTurnInRewardsWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_QuestTurnInRewardsWindow))]
|
||||
[HarmonyPatch("SetupOptions")]
|
||||
public class SetupOptionsPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_QuestTurnInRewardsWindow __instance)
|
||||
{
|
||||
float num = EffectManager.GetValue(PassiveEffects.QuestRewardOptionCount, _originalValue: (float)__instance.currentQuest.QuestClass.RewardChoicesCount, _entity: (EntityAlive)__instance.xui.playerUI.entityPlayer);
|
||||
__instance.optionCount = 0;
|
||||
int index1 = 0;
|
||||
if (__instance.selectedEntry != null)
|
||||
__instance.SelectedEntry = (XUiC_QuestTurnInEntry)null;
|
||||
__instance.selectedEntryList.Clear();
|
||||
__instance.rewardList.Clear();
|
||||
for (int index2 = 0; index2 < __instance.entryList.Length; ++index2)
|
||||
{
|
||||
__instance.entryList[index2].OnPress -= new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed);
|
||||
__instance.entryList[index2].SetBaseReward((BaseReward)null);
|
||||
}
|
||||
|
||||
EntityPlayer player = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkDaringAdventurer");
|
||||
float perkDaringAdventurer = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions perkDaringAdventurer: " + perkDaringAdventurer);
|
||||
|
||||
for (int index3 = 0; index3 < __instance.currentQuest.Rewards.Count; ++index3)
|
||||
{
|
||||
bool bAddReward = true;
|
||||
BaseReward reward = __instance.currentQuest.Rewards[index3];
|
||||
|
||||
if (reward != null)
|
||||
{
|
||||
string rewardID = __instance.currentQuest.Rewards[index3].ID;
|
||||
|
||||
//Log.Out($"XUiC_QuestTurnInRewardsWindowPatches-SetupOptions rewardID[{index3}]: " + rewardID);
|
||||
|
||||
if (__instance.currentQuest.Rewards[index3].ID != null)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
if (rewardID.Contains("FuriousRamsayGeneticBlueprintTier") && perkDaringAdventurer < 1)
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions A SKIP GENETIC BLUEPRINTS");
|
||||
bAddReward = false;
|
||||
}
|
||||
else if (rewardID == "groupFRPerks" && perkDaringAdventurer < 2)
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions A SKIP PERK BOOK");
|
||||
bAddReward = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rewardID.Contains("FuriousRamsayGeneticBlueprintTier") && perkDaringAdventurer < 1)
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP GENETIC BLUEPRINTS");
|
||||
bAddReward = false;
|
||||
}
|
||||
else if (rewardID.Contains("groupExpertiseXPQuestBundle") && perkDaringAdventurer < 2)
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP EXPERTISE BUNDLES");
|
||||
bAddReward = false;
|
||||
}
|
||||
else if (rewardID == "groupFRPerks" && perkDaringAdventurer < 3)
|
||||
{
|
||||
//Log.Out("XUiC_QuestTurnInRewardsWindowPatches-SetupOptions B SKIP PERK BOOK");
|
||||
bAddReward = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bAddReward)
|
||||
{
|
||||
__instance.rewardList.Add(__instance.currentQuest.Rewards[index3]);
|
||||
}
|
||||
}
|
||||
__instance.rewardList = __instance.rewardList.OrderBy<BaseReward, byte>((Func<BaseReward, byte>)(o => o.RewardIndex)).ToList<BaseReward>();
|
||||
|
||||
for (int index4 = 0; index4 < __instance.rewardList.Count; ++index4)
|
||||
{
|
||||
BaseReward reward = __instance.rewardList[index4];
|
||||
__instance.entryList[index1].OnPress -= new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed);
|
||||
if (reward.isChosenReward)
|
||||
{
|
||||
__instance.entryList[index1].SetBaseReward(reward);
|
||||
__instance.entryList[index1].Chosen = false;
|
||||
__instance.entryList[index1++].OnPress += new XUiEvent_OnPressEventHandler(__instance.TurnInEntryPressed);
|
||||
++__instance.optionCount;
|
||||
if ((double)num == (double)index1 || index1 >= __instance.entryList.Length)
|
||||
break;
|
||||
}
|
||||
}
|
||||
__instance.entryList[0].SelectCursorElement(true);
|
||||
if (__instance.optionCount != 1)
|
||||
return false;
|
||||
__instance.SelectedEntry = __instance.entryList[0];
|
||||
__instance.RefreshBindings();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
namespace Harmony.XUiC_QuestWindowGroupPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_QuestWindowGroup))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_QuestWindowGroup __instance, ref bool __result, ref string _value, string _bindingName)
|
||||
{
|
||||
if (_bindingName == "queststier")
|
||||
{
|
||||
EntityPlayerLocal entityPlayer = __instance.xui.playerUI.entityPlayer;
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
int currentFactionTier = entityPlayer.QuestJournal.GetCurrentFactionTier((byte)1);
|
||||
|
||||
int totalPoints = 0;
|
||||
|
||||
for (int i = 1; i <= currentFactionTier; i++)
|
||||
{
|
||||
totalPoints += i * RebirthVariables.customJobsToNextTier;
|
||||
}
|
||||
|
||||
_value = string.Format(Localization.Get("xuiQuestTierDescription"), (object)ValueDisplayFormatters.RomanNumber(entityPlayer.QuestJournal.GetCurrentFactionTier((byte)1)), (object)entityPlayer.QuestJournal.GetQuestFactionPoints((byte)1), totalPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
namespace Harmony.XUiC_RecipeStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation))]
|
||||
[HarmonyPatch("HandleRecipeQueue")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static MethodInfo cycleRecipeQueue = AccessTools.Method(typeof(TileEntityWorkstation), "cycleRecipeQueue", new Type[] { });
|
||||
public static MethodInfo hasRecipeInQueue = AccessTools.Method(typeof(TileEntityWorkstation), "hasRecipeInQueue", new Type[] { });
|
||||
|
||||
public static bool Prefix(TileEntityWorkstation __instance, float _timePassed,
|
||||
bool ___bUserAccessing,
|
||||
ref RecipeQueueItem[] ___queue,
|
||||
bool[] ___isModuleUsed,
|
||||
bool ___isBurning,
|
||||
ItemStack[] ___output
|
||||
)
|
||||
{
|
||||
if (___bUserAccessing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (___queue.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (___isModuleUsed[3] && !___isBurning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
RecipeQueueItem recipeQueueItem = ___queue[___queue.Length - 1];
|
||||
if (recipeQueueItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 1");
|
||||
|
||||
if (recipeQueueItem.CraftingTimeLeft >= 0f)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 2");
|
||||
recipeQueueItem.CraftingTimeLeft -= _timePassed;
|
||||
}
|
||||
while (recipeQueueItem.CraftingTimeLeft < 0f && (bool)hasRecipeInQueue.Invoke(__instance, new object[] { }))
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 3");
|
||||
if (recipeQueueItem.Multiplier > 0)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 4");
|
||||
ItemValue itemValue = new ItemValue(recipeQueueItem.Recipe.itemValueType, false);
|
||||
if (ItemClass.list[recipeQueueItem.Recipe.itemValueType] != null && ItemClass.list[recipeQueueItem.Recipe.itemValueType].HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 5");
|
||||
itemValue = new ItemValue(recipeQueueItem.Recipe.itemValueType, (int)recipeQueueItem.Quality, (int)recipeQueueItem.Quality, false, null, 1f);
|
||||
}
|
||||
if (ItemStack.AddToItemStackArray(___output, new ItemStack(itemValue, recipeQueueItem.Recipe.count), -1) == -1)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 6");
|
||||
return false;
|
||||
}
|
||||
GameSparksCollector.IncrementCounter(GameSparksCollector.GSDataKey.CraftedItems, itemValue.ItemClass.Name, 1, true, GameSparksCollector.GSDataCollection.SessionUpdates);
|
||||
RecipeQueueItem recipeQueueItem2 = recipeQueueItem;
|
||||
recipeQueueItem2.Multiplier -= 1;
|
||||
recipeQueueItem.CraftingTimeLeft += recipeQueueItem.OneItemCraftTime;
|
||||
|
||||
// ADD OUTPUT ITEMS TO WORKSTATION
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 7");
|
||||
RebirthUtilities.AddOutputItems(recipeQueueItem.Recipe, ___output);
|
||||
}
|
||||
if (recipeQueueItem.Multiplier <= 0)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 8");
|
||||
float craftingTimeLeft = recipeQueueItem.CraftingTimeLeft;
|
||||
cycleRecipeQueue.Invoke(__instance, new object[] { });
|
||||
|
||||
recipeQueueItem = ___queue[___queue.Length - 1];
|
||||
recipeQueueItem.CraftingTimeLeft += ((craftingTimeLeft < 0f) ? craftingTimeLeft : 0f);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue END");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_RecipeStack))]
|
||||
[HarmonyPatch("outputStack")]
|
||||
public class outputStackPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_RecipeStack __instance, ref bool __result,
|
||||
Recipe ___recipe,
|
||||
ref ItemValue ___originalItem,
|
||||
ref ItemValue ___outputItemValue,
|
||||
int ___outputQuality,
|
||||
int ___startingEntityId,
|
||||
ref int ___amountToRepair,
|
||||
bool ___playSound,
|
||||
XUiWindowGroup ___windowGroup,
|
||||
int ___recipeCount,
|
||||
ref bool ___isCrafting,
|
||||
ref float ___craftingTimeLeft,
|
||||
float ___oneItemCraftTime,
|
||||
ref bool ___isInventoryFull,
|
||||
ref XUiController ___lockIcon,
|
||||
ref XUiController ___overlay,
|
||||
ref XUiController ___itemIcon,
|
||||
ref XUiController ___timer,
|
||||
ref XUiController ___count,
|
||||
ref XUiController ___cancel,
|
||||
bool ___isOver,
|
||||
XUiController ___background,
|
||||
float ___totalCraftTimeLeft
|
||||
)
|
||||
{
|
||||
__result = RebirthUtilities.outputStack(__instance,
|
||||
___recipe,
|
||||
ref ___originalItem,
|
||||
ref ___outputItemValue,
|
||||
___outputQuality,
|
||||
___startingEntityId,
|
||||
ref ___amountToRepair,
|
||||
___playSound,
|
||||
___windowGroup,
|
||||
___recipeCount,
|
||||
ref ___isCrafting,
|
||||
ref ___craftingTimeLeft,
|
||||
___oneItemCraftTime,
|
||||
ref ___isInventoryFull,
|
||||
ref ___lockIcon,
|
||||
ref ___overlay,
|
||||
ref ___itemIcon,
|
||||
ref ___timer,
|
||||
ref ___count,
|
||||
ref ___cancel,
|
||||
___isOver,
|
||||
___background,
|
||||
___totalCraftTimeLeft);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Harmony.XUiC_RequiredItemStackPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_RequiredItemStack))]
|
||||
[HarmonyPatch("CanSwap")]
|
||||
public class CanSwapPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_RequiredItemStack __instance, ref bool __result, ItemStack stack)
|
||||
{
|
||||
if (__instance.TakeOnly && !stack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap START");
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap __instance.RequiredType: " + __instance.RequiredType);
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap XUiC_RequiredItemStack.RequiredTypes.ItemClass: " + XUiC_RequiredItemStack.RequiredTypes.ItemClass);
|
||||
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap __instance.RequiredItemClass == null: " + (__instance.RequiredItemClass == null));
|
||||
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap __instance.RequiredItemOnly: " + __instance.RequiredItemOnly);
|
||||
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap stack.itemValue.ItemClass: " + stack.itemValue.ItemClass);
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap __instance.RequiredItemClass: " + __instance.RequiredItemClass);
|
||||
|
||||
bool flag = __instance.RequiredType != XUiC_RequiredItemStack.RequiredTypes.ItemClass || __instance.RequiredItemClass == null || !__instance.RequiredItemOnly ? (__instance.RequiredType != XUiC_RequiredItemStack.RequiredTypes.IsPart ? (__instance.RequiredType != XUiC_RequiredItemStack.RequiredTypes.HasQuality ? __instance.RequiredType != XUiC_RequiredItemStack.RequiredTypes.HasQualityNoParts || stack.itemValue.HasQuality && !stack.itemValue.ItemClass.HasSubItems : stack.itemValue.HasQuality) : stack.itemValue.ItemClass.PartParentId != null) : stack.itemValue.ItemClass == __instance.RequiredItemClass;
|
||||
|
||||
//Log.Out("XUiC_RequiredItemStackPatches-CanSwap flag: " + flag);
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Harmony.XUiC_SkillAttributeLevelPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_SkillAttributeLevel))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_SkillAttributeLevel __instance, ref string _value, string _bindingName)
|
||||
{
|
||||
bool flag1 = __instance.CurrentSkill != null && __instance.CurrentSkill.ProgressionClass.MaxLevel >= __instance.level;
|
||||
EntityPlayerLocal entityPlayer = __instance.xui.playerUI.entityPlayer;
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
if (flag1)
|
||||
{
|
||||
flag3 = __instance.CurrentSkill.Level >= __instance.level;
|
||||
flag2 = __instance.CurrentSkill.Level + 1 == __instance.level && __instance.CurrentSkill.Level + 1 <= __instance.CurrentSkill.CalculatedMaxLevel((EntityAlive)entityPlayer);
|
||||
}
|
||||
if (_bindingName == "buyicon")
|
||||
{
|
||||
//_value = !flag3 ? (!flag2 ? "ui_game_symbol_lock" : "ui_game_symbol_shopping_cart") : "ui_game_symbol_check";
|
||||
_value = !flag3 ? (!flag2 ? "ui_game_symbol_lock" : "ui_game_symbol_lock") : "ui_game_symbol_check";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,779 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.XUiC_SkillCraftingInfoEntryPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_SkillCraftingInfoEntry))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static bool Prefix(XUiC_SkillCraftingInfoEntry __instance, ref bool __result,
|
||||
ref string _value, string _bindingName,
|
||||
string ___color_lbl_available,
|
||||
string ___color_bg_locked,
|
||||
string ___color_lbl_locked,
|
||||
ProgressionClass.DisplayData ___data,
|
||||
CachedStringFormatterXuiRgbaColor ___durabilitycolorFormatter,
|
||||
CachedStringFormatterXuiRgbaColor ___nextdurabilitycolorFormatter,
|
||||
bool ___isSelected
|
||||
)
|
||||
{
|
||||
bool flag = ___data != null;
|
||||
EntityPlayerLocal entityPlayer = __instance.xui.playerUI.entityPlayer;
|
||||
|
||||
if (_bindingName == "notcomplete")
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue (nextpoints) ___data.Owner.Name: " + ___data.Owner.Name);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue (nextpoints) progressionLevel: " + entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue (nextpoints) ___data.IsComplete: " + ___data.IsComplete(entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level));
|
||||
}
|
||||
|
||||
_value = flag ? (!___data.IsComplete(entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level)).ToString() : "false";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else if (_bindingName == "nextpoints")
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
int currentLevel = entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level;
|
||||
int nextLevel = ___data.GetNextPoints(currentLevel);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue ___data.Owner.Name: " + ___data.Owner.Name);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentLevel: " + currentLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue nextLevel: " + nextLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue ___data.ItemName: " + ___data.ItemName);
|
||||
|
||||
float currentFloor = 99999f;
|
||||
float currentCeiling = 0f;
|
||||
int numLevels = 0;
|
||||
|
||||
for (int i = 0; i < ___data.QualityStarts.Length; i++)
|
||||
{
|
||||
numLevels++;
|
||||
if (___data.QualityStarts[i] < currentFloor)
|
||||
{
|
||||
currentFloor = ___data.QualityStarts[i];
|
||||
}
|
||||
if (___data.QualityStarts[i] > currentCeiling)
|
||||
{
|
||||
currentCeiling = ___data.QualityStarts[i];
|
||||
}
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue ___data.QualityStarts[i]: " + ___data.QualityStarts[i]);
|
||||
}
|
||||
|
||||
foreach (var key in RebirthVariables.localOtherCrafting.Keys)
|
||||
{
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue key: " + key);
|
||||
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localOtherCrafting[key];
|
||||
foreach (var craftingList in CategoryCraftingList)
|
||||
{
|
||||
if (craftingList.craftingPerk.ToLower() == ___data.Owner.Name.ToLower())
|
||||
{
|
||||
float number = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
|
||||
float currentCategoryCeiling = RebirthUtilities.GetCraftingOtherCategoryValue(___data.Owner.Name, currentCeiling);
|
||||
float currentCategoryFloor = RebirthUtilities.GetCraftingOtherCategoryValue(___data.Owner.Name, currentFloor);
|
||||
|
||||
List<craftingLevels> craftingLevelsList = craftingList.levels;
|
||||
|
||||
float categoryCeiling = 0f;
|
||||
float craftingCeiling = 0f;
|
||||
float categoryFloor = 99999f;
|
||||
float craftingFloor = 99999;
|
||||
|
||||
foreach (var craftingLevel in craftingLevelsList)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.categoryLevel: " + craftingLevel.categoryLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.craftingLevel: " + craftingLevel.craftingLevel);
|
||||
// CATEGORY
|
||||
if (craftingLevel.categoryLevel > categoryCeiling)
|
||||
{
|
||||
categoryCeiling = craftingLevel.categoryLevel;
|
||||
}
|
||||
if (craftingLevel.categoryLevel < categoryFloor)
|
||||
{
|
||||
categoryFloor = craftingLevel.categoryLevel;
|
||||
}
|
||||
// CRAFTING
|
||||
if (craftingLevel.craftingLevel > craftingCeiling)
|
||||
{
|
||||
craftingCeiling = craftingLevel.craftingLevel;
|
||||
}
|
||||
if (craftingLevel.craftingLevel < craftingFloor)
|
||||
{
|
||||
craftingFloor = craftingLevel.craftingLevel;
|
||||
}
|
||||
}
|
||||
|
||||
craftingFloor = craftingFloor - 10f;
|
||||
|
||||
if (craftingFloor < 0)
|
||||
{
|
||||
craftingFloor = 0f;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue BEFORE categoryFloor: " + categoryFloor);
|
||||
categoryFloor = RebirthUtilities.GetCraftingOtherCategoryValue(___data.Owner.Name, craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue AFTER categoryFloor: " + categoryFloor);
|
||||
|
||||
float tempNumber = number - categoryFloor;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryFloor: " + categoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingFloor: " + craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingCeiling: " + craftingCeiling);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryCeiling: " + currentCategoryCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue numLevels: " + numLevels);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentLevel: " + currentLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue nextLevel: " + nextLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentFloor: " + currentFloor);
|
||||
|
||||
float perc = (float)(Math.Truncate((tempNumber / currentCategoryCeiling) * 100 * 100) / 100);
|
||||
|
||||
if ((nextLevel - 1) >= craftingFloor &&
|
||||
(nextLevel - 1) < craftingCeiling ||
|
||||
(numLevels == 1 && (currentFloor == nextLevel))
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C-A");
|
||||
|
||||
if (currentLevel >= craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC1-A");
|
||||
if (currentLevel >= currentFloor)
|
||||
{
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
}
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
float xp = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue xp: " + xp);
|
||||
|
||||
float diffXP = currentCategoryFloor - xp;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffXP: " + diffXP);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
|
||||
categoryCeiling = RebirthUtilities.GetOtherCategoryCeilingFromNetFloor(key, xp);
|
||||
|
||||
float diffCategory = currentCategoryFloor - categoryCeiling;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffCategory: " + diffCategory);
|
||||
|
||||
perc = (float)(Math.Truncate((1 - (diffXP / (currentCategoryFloor - categoryCeiling))) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue perc: " + perc);
|
||||
|
||||
_value = "[d1cd84]" + perc.ToString() + "[-]%";
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC2-A");
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentFloor <= nextLevel && numLevels > 1)
|
||||
{
|
||||
if (currentFloor < nextLevel)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-A");
|
||||
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-A, perc: " + perc);
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B3-A");
|
||||
|
||||
if (currentLevel == (currentFloor - 10))
|
||||
{
|
||||
float xp = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue xp: " + xp);
|
||||
|
||||
float diffXP = currentCategoryFloor - xp;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffXP: " + diffXP);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
|
||||
categoryCeiling = RebirthUtilities.GetOtherCategoryCeilingFromNetFloor(key, xp);
|
||||
|
||||
float diffCategory = currentCategoryFloor - categoryCeiling;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffCategory: " + diffCategory);
|
||||
|
||||
perc = (float)(Math.Truncate((1 - (diffXP / (currentCategoryFloor - categoryCeiling))) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue perc: " + perc);
|
||||
|
||||
_value = "[d1cd84]" + perc.ToString() + "[-]%";
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = "";
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel == craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C1-B");
|
||||
|
||||
if (craftingCeiling > currentFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C2-B");
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C3-B");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel < craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue D-B");
|
||||
if (nextLevel == craftingFloor && numLevels == 1)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue E-B");
|
||||
|
||||
tempNumber = categoryFloor - number;
|
||||
|
||||
float percDiff = 100 - (tempNumber / categoryFloor) * 100;
|
||||
percDiff = (float)Math.Truncate(percDiff * 100) / 100;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue percDiff: " + percDiff);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryFloor: " + categoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
_value = "[8fbd84]" + percDiff.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue F-B");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in RebirthVariables.localGeneticsCrafting.Keys)
|
||||
{
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue key: " + key);
|
||||
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localGeneticsCrafting[key];
|
||||
foreach (var craftingList in CategoryCraftingList)
|
||||
{
|
||||
if (craftingList.craftingPerk.ToLower() == ___data.Owner.Name.ToLower())
|
||||
{
|
||||
float number = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
|
||||
float currentCategoryCeiling = RebirthUtilities.GetCraftingGeneticsCategoryValue(___data.Owner.Name, currentCeiling);
|
||||
float currentCategoryFloor = RebirthUtilities.GetCraftingGeneticsCategoryValue(___data.Owner.Name, currentFloor);
|
||||
|
||||
List<craftingLevels> craftingLevelsList = craftingList.levels;
|
||||
|
||||
float categoryCeiling = 0f;
|
||||
float craftingCeiling = 0f;
|
||||
float categoryFloor = 99999f;
|
||||
float craftingFloor = 99999;
|
||||
|
||||
foreach (var craftingLevel in craftingLevelsList)
|
||||
{
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.categoryLevel: " + craftingLevel.categoryLevel);
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.craftingLevel: " + craftingLevel.craftingLevel);
|
||||
// CATEGORY
|
||||
if (craftingLevel.categoryLevel > categoryCeiling)
|
||||
{
|
||||
categoryCeiling = craftingLevel.categoryLevel;
|
||||
}
|
||||
if (craftingLevel.categoryLevel < categoryFloor)
|
||||
{
|
||||
categoryFloor = craftingLevel.categoryLevel;
|
||||
}
|
||||
// CRAFTING
|
||||
if (craftingLevel.craftingLevel > craftingCeiling)
|
||||
{
|
||||
craftingCeiling = craftingLevel.craftingLevel;
|
||||
}
|
||||
if (craftingLevel.craftingLevel < craftingFloor)
|
||||
{
|
||||
craftingFloor = craftingLevel.craftingLevel;
|
||||
}
|
||||
}
|
||||
|
||||
//craftingFloor = craftingFloor - 10f;
|
||||
|
||||
if (craftingFloor < 0)
|
||||
{
|
||||
craftingFloor = 0f;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue BEFORE categoryFloor: " + categoryFloor);
|
||||
categoryFloor = RebirthUtilities.GetCraftingGeneticsCategoryValue(___data.Owner.Name, craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue AFTER categoryFloor: " + categoryFloor);
|
||||
|
||||
float tempNumber = number - categoryFloor;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryFloor: " + categoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingFloor: " + craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingCeiling: " + craftingCeiling);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryCeiling: " + currentCategoryCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue numLevels: " + numLevels);
|
||||
|
||||
float perc = (float)(Math.Truncate((tempNumber / currentCategoryCeiling) * 100 * 100) / 100);
|
||||
|
||||
if ((nextLevel - 1) >= craftingFloor &&
|
||||
(nextLevel - 1) < craftingCeiling ||
|
||||
(numLevels == 1 && (currentFloor == nextLevel))
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C-C");
|
||||
|
||||
if (currentLevel >= craftingFloor && ___data.HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC1-C");
|
||||
if (currentLevel >= currentFloor)
|
||||
{
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
}
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC2-C");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentFloor <= nextLevel && numLevels > 1)
|
||||
{
|
||||
if (currentFloor < nextLevel)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-C");
|
||||
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-C, perc: " + perc);
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B3-C");
|
||||
|
||||
if (currentLevel == (currentFloor - 10))
|
||||
{
|
||||
float xp = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue xp: " + xp);
|
||||
|
||||
float diffXP = currentCategoryFloor - xp;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffXP: " + diffXP);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
|
||||
categoryCeiling = RebirthUtilities.GetGeneticsCategoryCeilingFromNetFloor(key, xp);
|
||||
|
||||
float diffCategory = currentCategoryFloor - categoryCeiling;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffCategory: " + diffCategory);
|
||||
|
||||
perc = (float)(Math.Truncate((1 - (diffXP / (currentCategoryFloor - categoryCeiling))) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue perc: " + perc);
|
||||
|
||||
_value = "[d1cd84]" + perc.ToString() + "[-]%";
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = "";
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel == craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C1-C");
|
||||
|
||||
if (craftingCeiling > currentFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C2-C");
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C3-C");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel < craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue D-C");
|
||||
if (nextLevel == craftingFloor && numLevels == 1)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue E-C");
|
||||
|
||||
tempNumber = categoryFloor - number;
|
||||
|
||||
float percDiff = 100 - (tempNumber / categoryFloor) * 100;
|
||||
percDiff = (float)Math.Truncate(percDiff * 100) / 100;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue percDiff: " + percDiff);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryFloor: " + categoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
_value = "[8fbd84]" + percDiff.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue F-C");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in RebirthVariables.localExpertiseCrafting.Keys)
|
||||
{
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue key: " + key);
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
foreach (var craftingList in CategoryCraftingList)
|
||||
{
|
||||
////Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingList.craftingPerk: " + craftingList.craftingPerk.ToLower());
|
||||
if (craftingList.craftingPerk.ToLower() == ___data.Owner.Name.ToLower())
|
||||
{
|
||||
float number = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
|
||||
float currentCategoryCeiling = RebirthUtilities.GetCraftingPerksCategoryValue(___data.Owner.Name, currentCeiling);
|
||||
float currentCategoryFloor = RebirthUtilities.GetCraftingPerksCategoryValue(___data.Owner.Name, currentFloor);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue key: " + key);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
|
||||
List<craftingLevels> craftingLevelsList = craftingList.levels;
|
||||
|
||||
float categoryCeiling = 0f;
|
||||
float craftingCeiling = 0f;
|
||||
float categoryFloor = 99999f;
|
||||
float craftingFloor = 99999;
|
||||
|
||||
foreach (var craftingLevel in craftingLevelsList)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.categoryLevel: " + craftingLevel.categoryLevel);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingLevel.craftingLevel: " + craftingLevel.craftingLevel);
|
||||
// CATEGORY
|
||||
if (craftingLevel.categoryLevel > categoryCeiling)
|
||||
{
|
||||
categoryCeiling = craftingLevel.categoryLevel;
|
||||
}
|
||||
if (craftingLevel.categoryLevel < categoryFloor)
|
||||
{
|
||||
categoryFloor = craftingLevel.categoryLevel;
|
||||
}
|
||||
// CRAFTING
|
||||
if (craftingLevel.craftingLevel > craftingCeiling)
|
||||
{
|
||||
craftingCeiling = craftingLevel.craftingLevel;
|
||||
}
|
||||
if (craftingLevel.craftingLevel < craftingFloor)
|
||||
{
|
||||
craftingFloor = craftingLevel.craftingLevel;
|
||||
}
|
||||
}
|
||||
|
||||
craftingFloor = craftingFloor - 10f;
|
||||
|
||||
if (craftingFloor < 0)
|
||||
{
|
||||
craftingFloor = 0f;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingFloor: " + craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue craftingCeiling: " + craftingCeiling);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue BEFORE categoryFloor: " + categoryFloor);
|
||||
categoryFloor = RebirthUtilities.GetCraftingPerksCategoryValue(___data.Owner.Name, craftingFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue AFTER categoryFloor: " + categoryFloor);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
|
||||
float tempNumber = number - categoryFloor;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
//float perc = (float)(Math.Truncate((tempNumber / categoryCeiling) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue nextLevel - 1 (" + (nextLevel - 1) + ") >= craftingFloor (" + craftingFloor + ")");
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue nextLevel - 1 (" + (nextLevel - 1) + ") < craftingCeiling (" + craftingCeiling + ")");
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentLevel (" + currentLevel + ") < craftingFloor (" + craftingFloor + ")");
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentFloor: " + currentFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCeiling: " + currentCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryCeiling: " + currentCategoryCeiling);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue numLevels: " + numLevels);
|
||||
|
||||
float perc = (float)(Math.Truncate((tempNumber / currentCategoryCeiling) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue perc: " + perc);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B-D");
|
||||
if ((nextLevel - 1) >= craftingFloor &&
|
||||
(nextLevel - 1) < craftingCeiling ||
|
||||
(numLevels == 1 && (currentFloor == nextLevel))
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C-D");
|
||||
|
||||
if (currentLevel >= craftingFloor && ___data.HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC1-D");
|
||||
if (currentLevel >= currentFloor)
|
||||
{
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
|
||||
string className = RebirthUtilities.GetClassFromPerk(key);
|
||||
|
||||
if (className != "")
|
||||
{
|
||||
float expertiseLevel = RebirthVariables.localConstants["$varFuriousRamsay" + key + "Lvl"];
|
||||
float classLevel = RebirthVariables.localConstants["$varFuriousRamsay" + className + "Lvl"];
|
||||
|
||||
if (classLevel == expertiseLevel)
|
||||
{
|
||||
float classPerc = RebirthVariables.localVariables["$varFuriousRamsay" + className + "PercUnit"];
|
||||
|
||||
perc = (float)(Math.Truncate((classPerc - classLevel) * 100 * 100) / 100);
|
||||
|
||||
_value = "[d1cd84]" + "CLASS" + "[-]: " + perc + "%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue CC2-D");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentFloor <= nextLevel && numLevels > 1)
|
||||
{
|
||||
if (currentFloor < nextLevel)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-D");
|
||||
|
||||
perc = (float)(Math.Truncate(((tempNumber - currentCategoryFloor) / (currentCategoryCeiling - currentCategoryFloor)) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B2-D, perc: " + perc);
|
||||
|
||||
string className = RebirthUtilities.GetClassFromPerk(key);
|
||||
|
||||
if (className != "")
|
||||
{
|
||||
float expertiseLevel = RebirthVariables.localConstants["$varFuriousRamsay" + key + "Lvl"];
|
||||
float classLevel = RebirthVariables.localConstants["$varFuriousRamsay" + className + "Lvl"];
|
||||
|
||||
if (classLevel == expertiseLevel)
|
||||
{
|
||||
float classPerc = RebirthVariables.localVariables["$varFuriousRamsay" + className + "PercUnit"];
|
||||
|
||||
perc = (float)(Math.Truncate((classPerc - classLevel) * 100 * 100) / 100);
|
||||
|
||||
_value = "[d1cd84]" + "CLASS" + "[-]: " + perc + "%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue B3-D");
|
||||
|
||||
string className = RebirthUtilities.GetClassFromPerk(key);
|
||||
|
||||
if (className != "")
|
||||
{
|
||||
float expertiseLevel = RebirthVariables.localConstants["$varFuriousRamsay" + key + "Lvl"];
|
||||
float classLevel = RebirthVariables.localConstants["$varFuriousRamsay" + className + "Lvl"];
|
||||
|
||||
if (classLevel == expertiseLevel && currentLevel == (currentFloor - 10))
|
||||
{
|
||||
float classPerc = RebirthVariables.localVariables["$varFuriousRamsay" + className + "PercUnit"];
|
||||
|
||||
perc = (float)(Math.Truncate((classPerc - classLevel) * 100 * 100) / 100);
|
||||
|
||||
_value = "[d1cd84]" + "CLASS" + "[-]: " + perc + "%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLevel == (currentFloor - 10))
|
||||
{
|
||||
float xp = RebirthVariables.localVariables["$varFuriousRamsay" + key + "PercUnit"];
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue xp: " + xp);
|
||||
|
||||
float diffXP = currentCategoryFloor - xp;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffXP: " + diffXP);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue currentCategoryFloor: " + currentCategoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryCeiling: " + categoryCeiling);
|
||||
|
||||
categoryCeiling = RebirthUtilities.GetExpertiseCategoryCeilingFromNetFloor(key, xp);
|
||||
|
||||
float diffCategory = currentCategoryFloor - categoryCeiling;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue diffCategory: " + diffCategory);
|
||||
|
||||
perc = (float)(Math.Truncate((1 - (diffXP / (currentCategoryFloor - categoryCeiling))) * 100 * 100) / 100);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue perc: " + perc);
|
||||
|
||||
_value = "[d1cd84]" + perc.ToString() + "[-]%";
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = "";
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel == craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C1-D");
|
||||
|
||||
if (craftingCeiling > currentFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C2-D");
|
||||
_value = "[8fbd84]" + perc.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue C3-D");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (currentLevel < craftingFloor)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue D-D");
|
||||
if (nextLevel == craftingFloor && numLevels == 1)
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue E-D");
|
||||
|
||||
tempNumber = categoryFloor - number;
|
||||
|
||||
float percDiff = 100 - (tempNumber / categoryFloor) * 100;
|
||||
percDiff = (float)Math.Truncate(percDiff * 100) / 100;
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue percDiff: " + percDiff);
|
||||
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue number: " + number);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue categoryFloor: " + categoryFloor);
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue tempNumber: " + tempNumber);
|
||||
|
||||
_value = "[8fbd84]" + percDiff.ToString() + "[-]%";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_SkillCraftingInfoEntryPatches-GetBindingValue F-D");
|
||||
_value = "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_value = flag ? string.Format("{0}/{1}", (object)entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level, (object)___data.GetNextPoints(entityPlayer.Progression.GetProgressionValue(___data.Owner.Name).Level).ToString()) : "";
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Harmony.XUiC_SkillPerkLevelPatches
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_SkillPerkLevel))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_SkillPerkLevel __instance, ref string _value, string _bindingName)
|
||||
{
|
||||
bool flag1 = __instance.CurrentSkill != null && __instance.CurrentSkill.ProgressionClass.MaxLevel >= __instance.level;
|
||||
EntityPlayerLocal entityPlayer = __instance.xui.playerUI.entityPlayer;
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
if (flag1)
|
||||
{
|
||||
flag3 = __instance.CurrentSkill.Level >= __instance.level;
|
||||
flag2 = __instance.CurrentSkill.Level + 1 == __instance.level && __instance.CurrentSkill.Level + 1 <= __instance.CurrentSkill.CalculatedMaxLevel((EntityAlive)entityPlayer);
|
||||
}
|
||||
if (_bindingName == "buyicon")
|
||||
{
|
||||
//_value = !flag3 ? (!flag2 ? "ui_game_symbol_lock" : "ui_game_symbol_shopping_cart") : "ui_game_symbol_check";
|
||||
_value = !flag3 ? (!flag2 ? "ui_game_symbol_lock" : "ui_game_symbol_lock") : "ui_game_symbol_check";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Harmony.XUiC_SpawnSelectionWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_SpawnSelectionWindow))]
|
||||
[HarmonyPatch("Open")]
|
||||
public class OpenPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_SpawnSelectionWindow __instance, LocalPlayerUI _playerUi, bool _chooseSpawnPosition, ref bool _enteringGame)
|
||||
{
|
||||
if (!_enteringGame || RebirthVariables.customSkipSpawnConfirmation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_enteringGame = false;
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
GameManager.Instance.canSpawnPlayer = true;
|
||||
return true;
|
||||
}
|
||||
GameManager.Instance.RequestToSpawn();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Harmony.XUiC_TraderItemEntryPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_TraderItemEntry))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_TraderItemEntry __instance, bool __result, ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "itemtypeicon")
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip() && __instance.item != null && !__instance.item.IsEmpty())
|
||||
{
|
||||
ItemValue itemValue = __instance.item.itemValue;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
value = (string)itemValue.GetMetadata("bonus");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bindingName == "hasitemtypeicon")
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip() && __instance.item != null && !__instance.item.IsEmpty())
|
||||
{
|
||||
ItemValue itemValue = __instance.item.itemValue;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Harmony.XUiC_TraderWindowPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_TraderWindow))]
|
||||
[HarmonyPatch("GetBindingValue")]
|
||||
public class GetBindingValuePatch
|
||||
{
|
||||
public static void Postfix(XUiC_TraderWindow __instance, ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "showrestock")
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiC_WorkstationFuelGridPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
|
||||
[HarmonyPatch("AddItem")]
|
||||
[HarmonyPatch(new[] { typeof(ItemClass), typeof(ItemStack) })]
|
||||
public class AddItemPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_WorkstationFuelGrid __instance, ref bool __result, ItemClass _itemClass, ItemStack _itemStack)
|
||||
{
|
||||
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem START");
|
||||
|
||||
string value = "";
|
||||
|
||||
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem START");
|
||||
|
||||
if (__instance.GetBindingValue(ref value, "required_fuels"))
|
||||
{
|
||||
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem value: " + value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
|
||||
[HarmonyPatch("TurnOn")]
|
||||
public class TurnOnPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_WorkstationFuelGrid __instance)
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridPatches-TurnOn START");
|
||||
|
||||
bool skipSound = false;
|
||||
|
||||
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values["HasAnim"] == "skipBurningSound")
|
||||
{
|
||||
skipSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!__instance.isOn && !skipSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("forge_burn_fuel", -1, 0f, false);
|
||||
}
|
||||
__instance.isOn = true;
|
||||
__instance.WorkstationData.SetIsBurning(__instance.isOn);
|
||||
((XUiV_Label)__instance.onOffLabel.ViewComponent).Text = __instance.turnOff;
|
||||
if (__instance.flameIcon != null)
|
||||
{
|
||||
((XUiV_Sprite)__instance.flameIcon.ViewComponent).Color = __instance.flameOnColor;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
|
||||
[HarmonyPatch("TurnOff")]
|
||||
public class TurnOffPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_WorkstationFuelGrid __instance)
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridPatches-TurnOff START");
|
||||
|
||||
bool skipSound = false;
|
||||
|
||||
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
|
||||
{
|
||||
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values["HasAnim"] == "skipBurningSound")
|
||||
{
|
||||
skipSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.isOn && !skipSound)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("forge_fire_die", -1, 0f, false);
|
||||
}
|
||||
__instance.isOn = false;
|
||||
__instance.WorkstationData.SetIsBurning(__instance.isOn);
|
||||
((XUiV_Label)__instance.onOffLabel.ViewComponent).Text = __instance.turnOn;
|
||||
XUiC_ItemStack xuiC_ItemStack = (XUiC_ItemStack)__instance.itemControllers[0];
|
||||
if (xuiC_ItemStack != null)
|
||||
{
|
||||
xuiC_ItemStack.UnlockStack();
|
||||
}
|
||||
if (__instance.flameIcon != null)
|
||||
{
|
||||
((XUiV_Sprite)__instance.flameIcon.ViewComponent).Color = __instance.flameOffColor;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
namespace Harmony.XUiM_LootContainerPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiM_LootContainer))]
|
||||
[HarmonyPatch("StashItems")]
|
||||
public class StashItemsPatch
|
||||
{
|
||||
public static bool Prefix(XUiM_LootContainer __instance, ref (bool _allMoved, bool _anyMoved) __result,
|
||||
XUiController _srcWindow,
|
||||
XUiC_ItemStackGrid _srcGrid,
|
||||
IInventory _dstInventory,
|
||||
int _ignoreSlots,
|
||||
bool[] _ignoredSlots,
|
||||
XUiM_LootContainer.EItemMoveKind _moveKind,
|
||||
bool _startBottomRight
|
||||
)
|
||||
{
|
||||
if (_srcGrid == null || _dstInventory == null)
|
||||
__result = (false, false);
|
||||
float unscaledTime = Time.unscaledTime;
|
||||
if (_moveKind == XUiM_LootContainer.EItemMoveKind.FillOnlyFirstCreateSecond && (double)unscaledTime - (double)XUiM_LootContainer.lastStashTime < 2.0)
|
||||
_moveKind = XUiM_LootContainer.EItemMoveKind.FillAndCreate;
|
||||
bool flag1 = true;
|
||||
bool flag2 = false;
|
||||
PreferenceTracker preferences = (PreferenceTracker)null;
|
||||
if (_srcWindow is XUiC_LootWindow xuiCLootWindow)
|
||||
preferences = xuiCLootWindow.GetPreferenceTrackerFromTileEntity();
|
||||
if (preferences != null && preferences.AnyPreferences && _dstInventory is XUiM_PlayerInventory mPlayerInventory)
|
||||
flag2 = mPlayerInventory.AddItemsUsingPreferenceTracker(_srcGrid, preferences);
|
||||
XUiController[] stackControllers = (XUiController[])_srcGrid.GetItemStackControllers();
|
||||
|
||||
Log.Out("XUiM_LootContainerPatches-StashItems _ignoreSlots: " + _ignoreSlots);
|
||||
|
||||
for (int _slot = _startBottomRight ? stackControllers.Length - 1 : 0; (_startBottomRight ? (_slot >= 0 ? 1 : 0) : (_slot < stackControllers.Length ? 1 : 0)) != 0; _slot = _startBottomRight ? _slot - 1 : _slot + 1)
|
||||
{
|
||||
if (_ignoredSlots[_slot])
|
||||
{
|
||||
Log.Out("XUiM_LootContainerPatches-StashItems SLOT [" + (_slot + 1) + "] IS IGNORED");
|
||||
}
|
||||
|
||||
if (!StackSortUtil.IsIgnoredSlot(_ignoreSlots, _ignoredSlots, _slot))
|
||||
{
|
||||
XUiC_ItemStack xuiCItemStack = (XUiC_ItemStack)stackControllers[_slot];
|
||||
if (!xuiCItemStack.StackLock)
|
||||
{
|
||||
ItemStack itemStack = xuiCItemStack.ItemStack;
|
||||
if (!xuiCItemStack.ItemStack.IsEmpty())
|
||||
{
|
||||
int count1 = itemStack.count;
|
||||
_dstInventory.TryStackItem(0, itemStack);
|
||||
if (itemStack.count > 0)
|
||||
{
|
||||
switch (_moveKind)
|
||||
{
|
||||
case XUiM_LootContainer.EItemMoveKind.All:
|
||||
if (_dstInventory.AddItem(itemStack))
|
||||
{
|
||||
itemStack = ItemStack.Empty.Clone();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XUiM_LootContainer.EItemMoveKind.FillAndCreate:
|
||||
if (!_dstInventory.HasItem(itemStack.itemValue))
|
||||
break;
|
||||
goto case XUiM_LootContainer.EItemMoveKind.All;
|
||||
}
|
||||
}
|
||||
if (itemStack.count == 0)
|
||||
itemStack = ItemStack.Empty.Clone();
|
||||
else
|
||||
flag1 = false;
|
||||
int count2 = itemStack.count;
|
||||
if (count1 != count2)
|
||||
{
|
||||
xuiCItemStack.ForceSetItemStack(itemStack);
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
XUiM_LootContainer.lastStashTime = unscaledTime;
|
||||
__result = (flag1, flag2);
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiM_PlayerInventoryPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiM_PlayerInventory))]
|
||||
[HarmonyPatch("DropItem")]
|
||||
public class DropItemPatch
|
||||
{
|
||||
public static bool Prefix(XUiM_PlayerInventory __instance, ItemStack stack)
|
||||
{
|
||||
GameManager instance = GameManager.Instance;
|
||||
if ((bool)(UnityEngine.Object)instance)
|
||||
{
|
||||
int playerid = __instance.localPlayer.entityId;
|
||||
|
||||
bool isArrow = stack.itemValue.ItemClass.Name.ToLower().Contains("ammoarrow") ||
|
||||
stack.itemValue.ItemClass.Name.ToLower().Contains("ammocrossbowbolt");
|
||||
|
||||
if (isArrow)
|
||||
{
|
||||
playerid = -1;
|
||||
}
|
||||
|
||||
instance.ItemDropServer(stack, __instance.localPlayer.GetDropPosition(), Vector3.zero, playerid, 60f, false);
|
||||
Manager.BroadcastPlay("itemdropped");
|
||||
}
|
||||
__instance.xui.CollectedItemList?.RemoveItemStack(stack);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace Harmony.XUiM_QuestPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiM_Quest))]
|
||||
[HarmonyPatch("GetQuestRewards")]
|
||||
public class GetQuestRewardsPatch
|
||||
{
|
||||
public static bool Prefix(XUiM_Quest __instance, ref string __result, Quest quest, EntityPlayer player, bool isChosen, string rewardItemFormat, string rewardItemBonusFormat, string rewardNumberFormat, string rewardNumberBonusFormat)
|
||||
{
|
||||
string questRewards = "";
|
||||
if (quest != null)
|
||||
{
|
||||
int num1 = isChosen ? (int)EffectManager.GetValue(PassiveEffects.QuestRewardOptionCount, _originalValue: 1f, _entity: (EntityAlive)player) + 1 : -1;
|
||||
for (int index = 0; index < quest.Rewards.Count; ++index)
|
||||
{
|
||||
if (quest.Rewards[index].isChosenReward == isChosen)
|
||||
{
|
||||
if (!isChosen || num1-- > 0)
|
||||
{
|
||||
if (quest.Rewards[index] is RewardItem)
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardItem");
|
||||
RewardItem reward = quest.Rewards[index] as RewardItem;
|
||||
int count = reward.Item.count;
|
||||
int num2 = Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.QuestBonusItemReward, _originalValue: (float)reward.Item.count, _entity: (EntityAlive)player));
|
||||
if (count == num2)
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardItem 1");
|
||||
questRewards = questRewards + string.Format(rewardItemFormat, (object)num2, (object)reward.Item.itemValue.ItemClass.GetLocalizedItemName()) + ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardItem 1");
|
||||
if (RebirthVariables.customInfested == "hidesurprise"
|
||||
)
|
||||
{
|
||||
questRewards = questRewards + reward.Item.itemValue.ItemClass.GetLocalizedItemName() + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
questRewards = questRewards + string.Format(rewardItemBonusFormat, (object)num2, (object)reward.Item.itemValue.ItemClass.GetLocalizedItemName(), (object)(num2 - count), (object)Localization.Get("bonus")) + ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (quest.Rewards[index] is RewardLootItem)
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardLootItem");
|
||||
RewardLootItem reward = quest.Rewards[index] as RewardLootItem;
|
||||
int count = reward.Item.count;
|
||||
|
||||
questRewards = questRewards + "test :" + string.Format(rewardItemFormat, (object)reward.Item.count, (object)reward.Item.itemValue.ItemClass.GetLocalizedItemName()) + ", ";
|
||||
}
|
||||
else if (quest.Rewards[index] is RewardExp)
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardExp");
|
||||
int num3 = 0 + Mathf.FloorToInt(EffectManager.GetValue(PassiveEffects.PlayerExpGain, _originalValue: (float)(Convert.ToInt32((quest.Rewards[index] as RewardExp).Value) * GameStats.GetInt(EnumGameStats.XPMultiplier) / 100), _entity: (EntityAlive)player, tags: XUiM_Quest.QuestTag));
|
||||
questRewards = questRewards + string.Format(rewardNumberFormat, (object)num3, (object)Localization.Get("RewardXP_keyword")) + ", ";
|
||||
}
|
||||
else if (quest.Rewards[index] is RewardSkillPoints)
|
||||
{
|
||||
//Log.Out("XUiM_QuestPatches-GetQuestRewards RewardSkillPoints");
|
||||
int int32 = Convert.ToInt32((quest.Rewards[index] as RewardSkillPoints).Value);
|
||||
questRewards = questRewards + string.Format(rewardNumberFormat, (object)int32, (object)Localization.Get("RewardSkillPoints_keyword")) + ", ";
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (questRewards != "")
|
||||
questRewards = questRewards.Remove(questRewards.Length - 2);
|
||||
}
|
||||
__result = questRewards;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
namespace Harmony.XUiM_RecipesPatches
|
||||
{
|
||||
|
||||
/*[HarmonyPatch(typeof(XUiM_Recipes))]
|
||||
[HarmonyPatch("FilterRecipesByWorkstation")]
|
||||
public class FilterRecipesByWorkstationPatch
|
||||
{
|
||||
public static bool Prefix(XUiM_Recipes __instance, ref List<Recipe> __result, string _workstation, IList<Recipe> recipeList)
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation _workstation: " + _workstation);
|
||||
|
||||
if (_workstation == "cntWoodBurningStove_PickedUp")
|
||||
{
|
||||
_workstation = "campfire";
|
||||
}
|
||||
|
||||
if (_workstation == null)
|
||||
_workstation = "";
|
||||
List<Recipe> recipeList1 = new List<Recipe>();
|
||||
for (int index1 = 0; index1 < recipeList.Count; ++index1)
|
||||
{
|
||||
if (recipeList[index1] != null)
|
||||
{
|
||||
if (_workstation != "")
|
||||
{
|
||||
Block blockByName = Block.GetBlockByName(_workstation);
|
||||
if (blockByName != null && blockByName.Properties.Values.ContainsKey("Workstation.CraftingAreaRecipes"))
|
||||
{
|
||||
string str = blockByName.Properties.Values["Workstation.CraftingAreaRecipes"];
|
||||
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation str: " + str);
|
||||
|
||||
string[] strArray = new string[1] { str };
|
||||
if (str.Contains(","))
|
||||
strArray = str.Replace(", ", ",").Replace(" ,", ",").Replace(" , ", ",").Split(',', StringSplitOptions.None);
|
||||
bool flag = false;
|
||||
for (int index2 = 0; index2 < strArray.Length; ++index2)
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation index2: " + index2);
|
||||
|
||||
if (recipeList[index1].craftingArea != null && recipeList[index1].craftingArea.EqualsCaseInsensitive(strArray[index2]))
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation 1");
|
||||
recipeList1.Add(recipeList[index1]);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
if ((recipeList[index1].craftingArea == null || recipeList[index1].craftingArea == "") && strArray[index2].EqualsCaseInsensitive("player"))
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation 2");
|
||||
recipeList1.Add(recipeList[index1]);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag && recipeList[index1].craftingArea != null && recipeList[index1].craftingArea.EqualsCaseInsensitive(_workstation))
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation 3");
|
||||
recipeList1.Add(recipeList[index1]);
|
||||
}
|
||||
}
|
||||
else if (recipeList[index1].craftingArea != null && recipeList[index1].craftingArea.EqualsCaseInsensitive(_workstation))
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation 4");
|
||||
recipeList1.Add(recipeList[index1]);
|
||||
}
|
||||
}
|
||||
else if (recipeList[index1].craftingArea == null || recipeList[index1].craftingArea == "")
|
||||
{
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation 5");
|
||||
recipeList1.Add(recipeList[index1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiM_RecipesPatches-FilterRecipesByWorkstation recipeList1.Count: " + recipeList1.Count);
|
||||
|
||||
__result = recipeList1;
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Audio;
|
||||
|
||||
namespace Harmony.XUiM
|
||||
{
|
||||
internal class XUiM_VehiclePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiM_Vehicle))]
|
||||
[HarmonyPatch("RepairVehicle")]
|
||||
public class RebirthUtilsXUiMFeatures
|
||||
{
|
||||
public static bool Prefix(XUi _xui, Vehicle vehicle = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Postfix(XUi _xui, Vehicle vehicle = null)
|
||||
{
|
||||
if (vehicle == null)
|
||||
{
|
||||
vehicle = _xui.vehicle.GetVehicle();
|
||||
}
|
||||
|
||||
ItemValue item;
|
||||
|
||||
string entityType = vehicle.GetName();
|
||||
//Log.Out("Entity Type: " + entityType);
|
||||
if (entityType == "vehiclebicycle")
|
||||
{
|
||||
//Log.Out("Is Bicycle");
|
||||
item = ItemClass.GetItem("FuriousRamsayBikeRepairKit", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("Is not Bicycle");
|
||||
item = ItemClass.GetItem("resourceRepairKit", false);
|
||||
}
|
||||
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
EntityPlayerLocal entityPlayer = _xui.playerUI.entityPlayer;
|
||||
LocalPlayerUI playerUI = _xui.playerUI;
|
||||
int itemCount = entityPlayer.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = entityPlayer.inventory.GetItemCount(item, false, -1, -1);
|
||||
int repairAmountNeeded = vehicle.GetRepairAmountNeeded();
|
||||
if (itemCount + itemCount2 > 0 && repairAmountNeeded > 0)
|
||||
{
|
||||
vehicle.RepairParts(itemClass.RepairAmount.Value, 100);
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
entityPlayer.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityPlayer.bag.DecItem(item, 1, false);
|
||||
}
|
||||
playerUI.xui.CollectedItemList.RemoveItemStack(new ItemStack(item, 1));
|
||||
Manager.PlayInsidePlayerHead("craft_complete_item", -1);
|
||||
}
|
||||
else if (repairAmountNeeded > itemCount + itemCount2)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(_xui.playerUI.entityPlayer, Localization.Get("xuiRepairMissingMats"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
_xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
using NCalc;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.XmlPatchConditionEvaluatorPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XmlPatchConditionEvaluator))]
|
||||
[HarmonyPatch("NCalcEvaluateFunction")]
|
||||
public class NCalcEvaluateFunctionPatch
|
||||
{
|
||||
public static void isediting(FunctionArgs _args, bool invert = false)
|
||||
{
|
||||
bool result = GameModeEditWorld.TypeName.Equals(GamePrefs.GetString(EnumGamePrefs.GameMode));
|
||||
//Log.Out("XmlPatchConditionEvaluatorPatches-isediting result: " + result);
|
||||
|
||||
if (invert)
|
||||
{
|
||||
result = !result;
|
||||
}
|
||||
|
||||
_args.Result = result;
|
||||
}
|
||||
|
||||
public static void scenario_selected(FunctionArgs _args, bool invert = false)
|
||||
{
|
||||
if (_args.Parameters.Length != 1)
|
||||
throw new ArgumentException(string.Format("Calling function {0} with invalid number of arguments ({1}, expected {2})", (object)nameof(scenario_selected), (object)_args.Parameters.Length, (object)1));
|
||||
if (!(_args.Parameters[0].Evaluate() is string str))
|
||||
throw new ArgumentException("Calling function scenario_selected: Expected string argument");
|
||||
|
||||
//Log.Out("XmlPatchConditionEvaluatorPatches-scenario_selected str: " + str);
|
||||
//Log.Out("XmlPatchConditionEvaluatorPatches-scenario_selected RebirthVariables.customScenario: " + RebirthVariables.customScenario);
|
||||
|
||||
bool result = RebirthVariables.customScenario == str.Trim();
|
||||
|
||||
if (invert)
|
||||
{
|
||||
result = !result;
|
||||
}
|
||||
|
||||
_args.Result = result;
|
||||
}
|
||||
|
||||
public static bool Prefix(string _name, FunctionArgs _args, bool _ignoreCase)
|
||||
{
|
||||
//Log.Out("XmlPatchConditionEvaluatorPatches-NCalcEvaluateFunction _name: " + _name);
|
||||
|
||||
if (_name.EqualsCaseInsensitive("isediting"))
|
||||
isediting(_args);
|
||||
|
||||
if (_name.EqualsCaseInsensitive("isnotediting"))
|
||||
isediting(_args, true);
|
||||
|
||||
if (_name.EqualsCaseInsensitive("rebirth_scenario"))
|
||||
scenario_selected(_args);
|
||||
|
||||
if (_name.EqualsCaseInsensitive("not_rebirth_scenario"))
|
||||
scenario_selected(_args, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.EntityLootContainerPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(EntityLootContainer))]
|
||||
[HarmonyPatch("OnUpdateEntity")]
|
||||
public class OnUpdateEntityPatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
public static IEnumerable<CodeInstruction> OnUpdateEntity(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
|
||||
for (int i = 0; i < codes.Count; i++)
|
||||
{
|
||||
if ((codes[i].opcode == OpCodes.Ldarg_0) && (codes[i+2].opcode == OpCodes.Ldc_I4_1))
|
||||
{
|
||||
codes[i+2].opcode = OpCodes.Ldc_I4_0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return codes;
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(EntityLootContainer))]
|
||||
[HarmonyPatch("OnUpdateEntity")]
|
||||
public class OnUpdateEntityPatch
|
||||
{
|
||||
public static bool Prefix(EntityLootContainer __instance)
|
||||
{
|
||||
Log.Out("EntityLootContainerPatches-OnUpdateEntity START");
|
||||
bool isInWater = __instance.isInWater;
|
||||
if (!__instance.isEntityStatic())
|
||||
__instance.TickInWater();
|
||||
if (__instance.isEntityRemote)
|
||||
return false;
|
||||
if (__instance.isInWater)
|
||||
{
|
||||
if (!isInWater && !__instance.firstUpdate && (double)__instance.fallDistance > 1.0)
|
||||
__instance.PlayOneShot("waterfallinginto");
|
||||
__instance.fallDistance = 0.0f;
|
||||
}
|
||||
if (!__instance.RootMotion && !__instance.IsDead() && __instance.CanBePushed())
|
||||
{
|
||||
List<Entity> entitiesInBounds = __instance.world.GetEntitiesInBounds(__instance, BoundsUtils.ExpandBounds(__instance.boundingBox, 0.2f, __instance.GetPushBoundsVertical(), 0.2f));
|
||||
if (entitiesInBounds != null && entitiesInBounds.Count > 0)
|
||||
{
|
||||
for (int index = 0; index < entitiesInBounds.Count; ++index)
|
||||
__instance.OnPushEntity(entitiesInBounds[index]);
|
||||
}
|
||||
}
|
||||
__instance.firstUpdate = false;
|
||||
|
||||
if (!__instance.bMeshCreated)
|
||||
__instance.createMesh();
|
||||
if (__instance.itemWorldData != null)
|
||||
__instance.itemClass.OnDroppedUpdate(__instance.itemWorldData);
|
||||
if ((double)Utils.FastAbs(__instance.position.y - __instance.prevPos.y) < 0.10000000149011612)
|
||||
{
|
||||
++__instance.onGroundCounter;
|
||||
if (__instance.onGroundCounter > 10)
|
||||
__instance.onGround = true;
|
||||
}
|
||||
if (__instance.isPhysicsMaster && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && (__instance.ticksExisted & 1) != 0)
|
||||
__instance.PhysicsMasterSendToServer(__instance.transform);
|
||||
__instance.checkGravitySetting(__instance.isPhysicsMaster);
|
||||
if (__instance.isEntityRemote)
|
||||
return false;
|
||||
if (!(bool)(UnityEngine.Object)__instance.itemTransform)
|
||||
__instance.lifetime = 0.0f;
|
||||
__instance.lifetime -= 0.05f;
|
||||
if ((double)__instance.lifetime <= 0.0)
|
||||
__instance.SetDead();
|
||||
if (__instance.itemClass != null && __instance.itemClass.IsEatDistraction && __instance.distractionLifetime > 0 && __instance.distractionEatTicks <= 0)
|
||||
__instance.SetDead();
|
||||
if ((double)__instance.transform.position.y + (double)Origin.position.y < 0.0)
|
||||
__instance.SetDead();
|
||||
if (__instance.IsDead())
|
||||
return false;
|
||||
__instance.tickDistraction();
|
||||
|
||||
if (__instance.lootContainer != null && __instance.deathUpdateTime > 0)
|
||||
{
|
||||
bool flag = GameManager.Instance.GetEntityIDForLockedTileEntity((TileEntity)__instance.lootContainer) != -1;
|
||||
if (!__instance.bRemoved && !__instance.lootContainer.IsUserAccessing() && !flag && (__instance.lootContainer.bTouched && __instance.lootContainer.IsEmpty() || __instance.deathUpdateTime >= __instance.timeStayAfterDeath - 1))
|
||||
__instance.removeBackpack();
|
||||
}
|
||||
++__instance.deathUpdateTime;
|
||||
if (__instance.world.IsRemote() || !__instance.forceInventoryCreate && __instance.lootContainer != null)
|
||||
return false;
|
||||
__instance.lootContainer = new TileEntityLootContainer((Chunk)null);
|
||||
__instance.lootContainer.bTouched = false;
|
||||
__instance.lootContainer.entityId = __instance.entityId;
|
||||
__instance.lootContainer.lootListName = __instance.GetLootList();
|
||||
__instance.lootContainer.SetContainerSize(LootContainer.GetLootContainer(__instance.lootContainer.lootListName).size, true);
|
||||
if (__instance.isInventory != null)
|
||||
{
|
||||
__instance.lootContainer.bTouched = false;
|
||||
Log.Out("EntityLootContainerPatches-OnUpdateEntity CREATING IVENTORY");
|
||||
for (int index = 0; index < __instance.isInventory.Length; ++index)
|
||||
{
|
||||
if (!__instance.isInventory[index].IsEmpty())
|
||||
__instance.lootContainer.AddItem(__instance.isInventory[index]);
|
||||
}
|
||||
}
|
||||
__instance.lootContainer.SetModified();
|
||||
__instance.forceInventoryCreate = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Harmony.GameModeAbstractPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GameModeAbstract))]
|
||||
[HarmonyPatch("Init")]
|
||||
public class InitPatch
|
||||
{
|
||||
public static void Postfix(GameModeAbstract __instance)
|
||||
{
|
||||
GameStats.Set(EnumGameStats.QuestProgressionDailyLimit, 999);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.GameStageDefinitionPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(GameStageDefinition))]
|
||||
[HarmonyPatch("CalcPartyLevel")]
|
||||
public class CalcPartyLevelPatch
|
||||
{
|
||||
public static void Postfix(GameStageDefinition __instance, ref int __result, List<int> playerGameStages)
|
||||
{
|
||||
float num = 0f;
|
||||
for (int i = playerGameStages.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (playerGameStages[i] > num)
|
||||
{
|
||||
num = playerGameStages[i];
|
||||
}
|
||||
}
|
||||
|
||||
__result = (int)num;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Audio;
|
||||
using HarmonyLib;
|
||||
using Platform;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using static ItemActionUseOther;
|
||||
|
||||
namespace Harmony.ItemActionEatPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemActionEat))]
|
||||
[HarmonyPatch("ExecuteAction")]
|
||||
public class ExecuteActionPatch
|
||||
{
|
||||
public static bool Prefix(ItemActionEat __instance, ItemActionData _actionData, bool _bReleased)
|
||||
{
|
||||
//Log.Out("ItemActionEatPatches-ExecuteAction START");
|
||||
if (_actionData.invData.itemValue.ItemClass != null)
|
||||
{
|
||||
if (_actionData.invData.item.HasAnyTags(FastTags<TagGroup.Global>.Parse("medical")))
|
||||
{
|
||||
//Log.Out("ItemActionEatPatches-ExecuteAction MEDICAL");
|
||||
global::EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
||||
|
||||
string itemName = _actionData.invData.itemValue.ItemClass.GetItemName();
|
||||
|
||||
if (!RebirthUtilities.CanHeal(itemName, _actionData.invData.holdingEntity, _actionData.invData.holdingEntity))
|
||||
{
|
||||
//Log.Out("ItemActionEatPatches-ExecuteAction Cannot heal");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
namespace Harmony.MultiBlockManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(MultiBlockManager))]
|
||||
[HarmonyPatch("TryRegisterPOIMultiBlock")]
|
||||
public class TryRegisterPOIMultiBlockPatch
|
||||
{
|
||||
public static bool Prefix(MultiBlockManager __instance, ref bool __result, Vector3i parentWorldPos, BlockValue blockValue)
|
||||
{
|
||||
if (!__instance.CheckFeatures(MultiBlockManager.FeatureFlags.POIMBTracking))
|
||||
return false;
|
||||
using (MultiBlockManager.s_MultiBlockManagerTryAddPOIMultiBlock.Auto())
|
||||
{
|
||||
lock (__instance.lockObj)
|
||||
{
|
||||
MultiBlockManager.TrackedBlockData trackedBlockData1;
|
||||
if (__instance.trackedDataMap.CrossChunkMultiBlocks.TryGetValue(parentWorldPos, out trackedBlockData1))
|
||||
{
|
||||
UnityEngine.Debug.LogError((object)(string.Format("[MultiBlockManager] Failed to register POI multiblock at {0} due to previously registered CrossChunk data.", (object)parentWorldPos) + string.Format("\nOld value: {0} ", (object)trackedBlockData1.rawData) + string.Format("\nNew value: {0}", (object)blockValue.rawData)));
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
MultiBlockManager.TrackedBlockData trackedBlockData2;
|
||||
if (__instance.trackedDataMap.PoiMultiBlocks.TryGetValue(parentWorldPos, out trackedBlockData2))
|
||||
{
|
||||
UnityEngine.Debug.LogError((object)(string.Format("[MultiBlockManager] Duplicate multiblock placement at {0}. New value will not be applied.", (object)parentWorldPos) + string.Format("\nOld value: {0} ", (object)trackedBlockData2.rawData) + string.Format("\nNew value: {0}", (object)blockValue.rawData)));
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
if (blockValue.ischild)
|
||||
{
|
||||
UnityEngine.Debug.LogError((object)"[MultiBlockManager] TryAddPOIMultiBlock failed: target block is not a parent: " + blockValue.Block.blockName);
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
RectInt flatChunkBounds;
|
||||
if (!blockValue.Block.isMultiBlock)
|
||||
{
|
||||
flatChunkBounds = new RectInt((UnityEngine.Vector2Int)World.toChunkXZ(parentWorldPos), UnityEngine.Vector2Int.zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3i minPos;
|
||||
Vector3i maxPos;
|
||||
MultiBlockManager.GetMinMaxWorldPositions(parentWorldPos, blockValue, out minPos, out maxPos);
|
||||
Vector2i chunkXz1 = World.toChunkXZ(minPos);
|
||||
Vector2i chunkXz2 = World.toChunkXZ(maxPos);
|
||||
flatChunkBounds = new RectInt((UnityEngine.Vector2Int)chunkXz1, (UnityEngine.Vector2Int)(chunkXz2 - chunkXz1));
|
||||
}
|
||||
__instance.trackedDataMap.AddOrMergeTrackedData(parentWorldPos, blockValue.rawData, flatChunkBounds, MultiBlockManager.TrackingTypeFlags.PoiMultiBlock);
|
||||
__instance.isDirty = true;
|
||||
__instance.UpdateProfilerCounters();
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Unity.Collections;
|
||||
|
||||
public class HarmonyOriginPatches
|
||||
{
|
||||
//[HarmonyPatch(typeof(Origin), nameof(Origin.Awake))]
|
||||
public class AwakePatch
|
||||
{
|
||||
public static bool Prefix(Origin __instance)
|
||||
{
|
||||
Log.Out($"Origin::Awake Prefix");
|
||||
|
||||
if (Origin.Instance == null)
|
||||
{
|
||||
Origin.Instance = __instance;
|
||||
}
|
||||
|
||||
__instance.isAuto = false;
|
||||
__instance.particles = new NativeArray<ParticleSystem.Particle>(512, Allocator.Persistent);
|
||||
__instance.physicsCheckT = __instance.transform.GetChild(0);
|
||||
Origin.Instance.Reposition(Vector3.zero);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//[HarmonyPatch(typeof(Origin), nameof(Origin.FixedUpdate))]
|
||||
public class FixedUpdatePatch
|
||||
{
|
||||
public static bool Prefix(Origin __instance)
|
||||
{
|
||||
if (__instance.isActiveAndEnabled)
|
||||
{
|
||||
Log.Out($"Origin::FixedUpdate - Disabling Origin");
|
||||
__instance.isAuto = false;
|
||||
__instance.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
namespace Harmony.ProgressionClassPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ProgressionClass))]
|
||||
[HarmonyPatch("ListSortOrder")]
|
||||
[HarmonyPatch(MethodType.Getter)]
|
||||
public class ListSortOrderPatch
|
||||
{
|
||||
public static bool Prefix(ProgressionClass __instance, ref float __result)
|
||||
{
|
||||
if (__instance.IsPerk)
|
||||
{
|
||||
__result = __instance.Parent.ListSortOrder + __instance.listSortOrder * (1f / 1000f);
|
||||
}
|
||||
__result = __instance.IsSkill ? __instance.Parent.ListSortOrder + __instance.listSortOrder : __instance.listSortOrder * 100f;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.ProgressionFromXmlPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ProgressionFromXml))]
|
||||
//[HarmonyPatch(new[] { typeof(XElement), typeof(int), typeof(int), typeof(int), typeof(float), typeof(float), typeof(float) })]
|
||||
[HarmonyPatch("parseProgressionItem")]
|
||||
public class parseProgressionItemPatch
|
||||
{
|
||||
public static bool Prefix(ProgressionFromXml __instance, XElement childElement, int max_level, int min_level, int base_cost, float cost_multiplier_per_level, float max_level_ratio_to_parent, ref float order)
|
||||
{
|
||||
ProgressionType progressionType = ProgressionType.None;
|
||||
if (childElement.Name == (XName)"attribute")
|
||||
progressionType = ProgressionType.Attribute;
|
||||
else if (childElement.Name == (XName)"skill")
|
||||
progressionType = ProgressionType.Skill;
|
||||
else if (childElement.Name == (XName)"perk")
|
||||
progressionType = ProgressionType.Perk;
|
||||
else if (childElement.Name == (XName)"book")
|
||||
progressionType = ProgressionType.Book;
|
||||
else if (childElement.Name == (XName)"book_group")
|
||||
progressionType = ProgressionType.BookGroup;
|
||||
else if (childElement.Name == (XName)"crafting_skill")
|
||||
progressionType = ProgressionType.Crafting;
|
||||
if (progressionType == ProgressionType.None)
|
||||
return false;
|
||||
if (childElement.HasAttribute((XName)nameof(min_level)))
|
||||
min_level = int.Parse(childElement.GetAttribute((XName)nameof(min_level)));
|
||||
if (childElement.HasAttribute((XName)nameof(max_level)))
|
||||
max_level = int.Parse(childElement.GetAttribute((XName)nameof(max_level)));
|
||||
if (childElement.HasAttribute((XName)nameof(max_level_ratio_to_parent)))
|
||||
max_level_ratio_to_parent = StringParsers.ParseFloat(childElement.GetAttribute((XName)nameof(max_level_ratio_to_parent)));
|
||||
if (childElement.HasAttribute((XName)"base_skill_point_cost"))
|
||||
base_cost = int.Parse(childElement.GetAttribute((XName)"base_skill_point_cost"));
|
||||
else if (childElement.HasAttribute((XName)"base_exp_cost"))
|
||||
base_cost = int.Parse(childElement.GetAttribute((XName)"base_exp_cost"));
|
||||
if (childElement.HasAttribute((XName)nameof(cost_multiplier_per_level)))
|
||||
cost_multiplier_per_level = StringParsers.ParseFloat(childElement.GetAttribute((XName)nameof(cost_multiplier_per_level)));
|
||||
if (!childElement.HasAttribute((XName)"name"))
|
||||
return false;
|
||||
|
||||
//Log.Out("ProgressionFromXmlPatches-parseProgressionItem SCENARIO: " + RebirthVariables.customScenario);
|
||||
|
||||
if (RebirthVariables.customScenario == "hive")
|
||||
{
|
||||
if (progressionType == ProgressionType.Attribute && !(childElement.GetAttribute((XName)"name").ToLower() == "attfortitude"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (progressionType == ProgressionType.Skill)
|
||||
{
|
||||
string skillName = childElement.GetAttribute((XName)"name");
|
||||
|
||||
bool isValid = skillName == "FuriousRamsaySkillStrength" ||
|
||||
skillName == "FuriousRamsaySkillDexterity" ||
|
||||
skillName == "FuriousRamsaySkillConstitution" ||
|
||||
skillName == "FuriousRamsaySkillIntelligence" ||
|
||||
skillName == "FuriousRamsaySkillCharisma";
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (progressionType == ProgressionType.Perk && !(childElement.GetAttribute((XName)"name").ToLower().StartsWith("perk")))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ProgressionClass progressionClass = new ProgressionClass(childElement.GetAttribute((XName)"name").ToLower())
|
||||
{
|
||||
MinLevel = min_level,
|
||||
MaxLevel = max_level,
|
||||
Type = progressionType,
|
||||
BaseCostToLevel = base_cost,
|
||||
CostMultiplier = (double)cost_multiplier_per_level > 0.0 ? cost_multiplier_per_level : 1f,
|
||||
ParentMaxLevelRatio = max_level_ratio_to_parent
|
||||
};
|
||||
progressionClass.ListSortOrder = order;
|
||||
++order;
|
||||
if (childElement.HasAttribute((XName)"parent"))
|
||||
progressionClass.ParentName = childElement.GetAttribute((XName)"parent").ToLower();
|
||||
if (childElement.HasAttribute((XName)"name_key"))
|
||||
progressionClass.NameKey = childElement.GetAttribute((XName)"name_key");
|
||||
if (childElement.HasAttribute((XName)nameof(max_level_ratio_to_parent)))
|
||||
progressionClass.ParentMaxLevelRatio = StringParsers.ParseFloat(childElement.GetAttribute((XName)nameof(max_level_ratio_to_parent)));
|
||||
if (childElement.HasAttribute((XName)"desc_key"))
|
||||
progressionClass.DescKey = childElement.GetAttribute((XName)"desc_key");
|
||||
if (childElement.HasAttribute((XName)"long_desc_key"))
|
||||
progressionClass.LongDescKey = childElement.GetAttribute((XName)"long_desc_key");
|
||||
if (childElement.HasAttribute((XName)"icon"))
|
||||
progressionClass.Icon = childElement.GetAttribute((XName)"icon");
|
||||
foreach (XElement element1 in childElement.Elements())
|
||||
{
|
||||
if (element1.Name == (XName)"level_requirements")
|
||||
{
|
||||
int _level = 0;
|
||||
if (element1.HasAttribute((XName)"level"))
|
||||
_level = StringParsers.ParseSInt32(element1.GetAttribute((XName)"level"));
|
||||
LevelRequirement _lr = new LevelRequirement(_level);
|
||||
if (element1.HasElements)
|
||||
{
|
||||
foreach (XElement element2 in element1.Elements((XName)"requirement"))
|
||||
{
|
||||
IRequirement requirement = RequirementBase.ParseRequirement(element2);
|
||||
if (requirement != null)
|
||||
_lr.AddRequirement(requirement);
|
||||
}
|
||||
}
|
||||
progressionClass.AddLevelRequirement(_lr);
|
||||
}
|
||||
else if (element1.Name == (XName)"display_entry")
|
||||
{
|
||||
string[] strArray1 = element1.GetAttribute((XName)"unlock_level").Split(',', StringSplitOptions.None);
|
||||
int[] _qualityStarts = new int[strArray1.Length];
|
||||
string str = "";
|
||||
string[] _customName = (string[])null;
|
||||
string[] _customIcon = (string[])null;
|
||||
string[] _customIconTint = (string[])null;
|
||||
bool _customHasQuality = false;
|
||||
for (int index = 0; index < strArray1.Length; ++index)
|
||||
_qualityStarts[index] = StringParsers.ParseSInt32(strArray1[index]);
|
||||
if (element1.HasAttribute((XName)"item"))
|
||||
str = element1.GetAttribute((XName)"item");
|
||||
if (element1.HasAttribute((XName)"has_quality"))
|
||||
_customHasQuality = StringParsers.ParseBool(element1.GetAttribute((XName)"has_quality"));
|
||||
if (element1.HasAttribute((XName)"icon"))
|
||||
_customIcon = element1.GetAttribute((XName)"icon").Split(',', StringSplitOptions.None);
|
||||
if (_customIcon != null)
|
||||
_customIconTint = !element1.HasAttribute((XName)"icontint") ? new string[_customIcon.Length] : element1.GetAttribute((XName)"icontint").Split(',', StringSplitOptions.None);
|
||||
if (element1.HasAttribute((XName)"name"))
|
||||
_customName = element1.GetAttribute((XName)"name").Split(',', StringSplitOptions.None);
|
||||
if (element1.HasAttribute((XName)"name_key"))
|
||||
{
|
||||
string[] strArray2 = element1.GetAttribute((XName)"name_key").Split(',', StringSplitOptions.None);
|
||||
for (int index = 0; index < strArray2.Length; ++index)
|
||||
strArray2[index] = Localization.Get(strArray2[index]);
|
||||
_customName = strArray2;
|
||||
}
|
||||
ProgressionClass.DisplayData displayData = progressionClass.AddDisplayData(str, _qualityStarts, _customIcon, _customIconTint, _customName, _customHasQuality);
|
||||
if (displayData.ItemName != "")
|
||||
displayData.AddUnlockData(displayData.ItemName, 0, (string[])null);
|
||||
if (element1.HasElements)
|
||||
{
|
||||
foreach (XElement element3 in element1.Elements((XName)"unlock_entry"))
|
||||
{
|
||||
int unlockTier = 0;
|
||||
if (element3.HasAttribute((XName)"unlock_tier"))
|
||||
unlockTier = StringParsers.ParseSInt32(element3.GetAttribute((XName)"unlock_tier")) - 1;
|
||||
string[] recipeList = (string[])null;
|
||||
if (element3.HasAttribute((XName)"recipes"))
|
||||
recipeList = element3.GetAttribute((XName)"recipes").Split(',', StringSplitOptions.None);
|
||||
if (element3.HasAttribute((XName)"item"))
|
||||
{
|
||||
foreach (string itemName in element3.GetAttribute((XName)"item").Split(',', StringSplitOptions.None))
|
||||
displayData.AddUnlockData(itemName, unlockTier, recipeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
progressionClass.Effects = MinEffectController.ParseXml(childElement, _type: MinEffectController.SourceParentType.ProgressionClass, _parentPointer: (object)progressionClass.Name);
|
||||
Progression.ProgressionClasses.Add(progressionClass.Name, progressionClass);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Video;
|
||||
|
||||
namespace Harmony.SplashScreenScriptPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SplashScreenScript))]
|
||||
[HarmonyPatch("Awake")]
|
||||
public class AwakePatch
|
||||
{
|
||||
public static bool Prefix(SplashScreenScript __instance, UnityEngine.Video.VideoPlayer ___videoPlayer)
|
||||
{
|
||||
if (!GameEntrypoint.EntrypointSuccess)
|
||||
return false;
|
||||
if (GameManager.IsDedicatedServer)
|
||||
SceneManager.LoadScene(SplashScreenScript.MainSceneName);
|
||||
else
|
||||
{
|
||||
GameOptionsManager.ApplyTextureQuality();
|
||||
__instance.labelEaWarning.text = Localization.Get("splashMessageEarlyAccessWarning");
|
||||
__instance.videoPlayer.prepareCompleted += new VideoPlayer.EventHandler(__instance.OnVideoPrepared);
|
||||
__instance.videoPlayer.loopPointReached += new VideoPlayer.EventHandler(__instance.OnVideoFinished);
|
||||
__instance.videoPlayer.errorReceived += new VideoPlayer.ErrorEventHandler(__instance.OnVideoErrorReceived);
|
||||
__instance.videoPlayer.url = Application.streamingAssetsPath + "/Video/TFP_Intro.webm";
|
||||
__instance.videoPlayer.Prepare();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Platform;
|
||||
|
||||
namespace Harmony.XUiC_MapAreaPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(XUiC_MapArea))]
|
||||
[HarmonyPatch("onMapPressedLeft")]
|
||||
public class onMapPressedLeftPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_MapArea __instance, XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft START");
|
||||
__instance.closeAllPopups();
|
||||
if (__instance.closestMouseOverNavObject != null)
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 1");
|
||||
__instance.closestMouseOverNavObject.hiddenOnCompass = !__instance.closestMouseOverNavObject.hiddenOnCompass;
|
||||
if (__instance.closestMouseOverNavObject.hiddenOnCompass)
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 2");
|
||||
GameManager.ShowTooltip(GameManager.Instance.World.GetPrimaryPlayer(), Localization.Get("compassWaypointHiddenTooltip"));
|
||||
}
|
||||
if (__instance.closestMouseOverNavObject.NavObjectClass.NavObjectClassName == "quick_waypoint")
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 3");
|
||||
__instance.xui.playerUI.entityPlayer.navMarkerHidden = __instance.closestMouseOverNavObject.hiddenOnCompass;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 4");
|
||||
Waypoint waypointForNavObject = __instance.xui.playerUI.entityPlayer.Waypoints.GetWaypointForNavObject(__instance.closestMouseOverNavObject);
|
||||
if (waypointForNavObject == null)
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 5");
|
||||
return false;
|
||||
}
|
||||
waypointForNavObject.hiddenOnCompass = __instance.closestMouseOverNavObject.hiddenOnCompass;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 6");
|
||||
if (PlatformManager.NativePlatform.Input.CurrentInputStyle == PlayerInputManager.InputStyle.Keyboard)
|
||||
{
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft 7");
|
||||
return false;
|
||||
}
|
||||
__instance.OpenWaypointPopup();
|
||||
}
|
||||
|
||||
Log.Out("XUiC_MapAreaPatches-onMapPressedLeft END");
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using static UIPopupList;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Harmony.XUiC_OnScreenIconsPatches
|
||||
{
|
||||
|
||||
/*[HarmonyPatch(typeof(XUiC_OnScreenIcons))]
|
||||
[HarmonyPatch("Instance_OnNavObjectAdded")]
|
||||
public class Instance_OnNavObjectAddedPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_OnScreenIcons __instance, NavObject newNavObject)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Instance_OnNavObjectAdded NavObjectClassName: " + newNavObject.NavObjectClass.NavObjectClassName);
|
||||
|
||||
if (!newNavObject.HasOnScreen && !(newNavObject.NavObjectClass.NavObjectClassName == "purge_waypoint"))
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Instance_OnNavObjectAdded HAS ON SCREEN");
|
||||
return false;
|
||||
}
|
||||
__instance.RegisterIcon(newNavObject);
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*[HarmonyPatch(typeof(XUiC_OnScreenIcons))]
|
||||
[HarmonyPatch("Update")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static void Postfix(XUiC_OnScreenIcons __instance, float _dt)
|
||||
{
|
||||
for (int index = __instance.screenIconList.Count - 1; index >= 0; --index)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update screenIconList name[" + index + "]: " + __instance.screenIconList[index].NavObject.name);
|
||||
//Log.Out("XUiC_OnScreenIconsPatches-Update position: " + __instance.screenIconList[index].NavObject.GetPosition());
|
||||
//Log.Out("XUiC_OnScreenIconsPatches-Update NavObjectClassList.Count: " + __instance.screenIconList[index].NavObject.NavObjectClassList.Count);
|
||||
|
||||
if (__instance.screenIconList[index].NavObject.OwnerEntity != null)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update screenIconList owner: " + __instance.screenIconList[index].NavObject.OwnerEntity.name);
|
||||
}
|
||||
|
||||
for (int x = 0; x < __instance.screenIconList[index].NavObject.NavObjectClassList.Count; ++x)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update NavObjectClassName [" + x + "]: " + __instance.screenIconList[index].NavObject.NavObjectClassList[x].NavObjectClassName);
|
||||
}
|
||||
}
|
||||
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update ================================================");
|
||||
|
||||
for (int index = __instance.disabledIcons.Count - 1; index >= 0; --index)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update disabledIcons name[" + index + "]: " + __instance.disabledIcons[index].NavObject.name);
|
||||
//Log.Out("XUiC_OnScreenIconsPatches-Update position: " + __instance.screenIconList[index].NavObject.GetPosition());
|
||||
//Log.Out("XUiC_OnScreenIconsPatches-Update NavObjectClassList.Count: " + __instance.screenIconList[index].NavObject.NavObjectClassList.Count);
|
||||
|
||||
if (__instance.disabledIcons[index].NavObject.OwnerEntity != null)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update disabledIcons owner: " + __instance.disabledIcons[index].NavObject.OwnerEntity.name);
|
||||
}
|
||||
|
||||
for (int x = 0; x < __instance.disabledIcons[index].NavObject.NavObjectClassList.Count; ++x)
|
||||
{
|
||||
Log.Out("XUiC_OnScreenIconsPatches-Update NavObjectClassName [" + x + "]: " + __instance.disabledIcons[index].NavObject.NavObjectClassList[x].NavObjectClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.XUiC_PowerSourceSlotsPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiC_PowerSourceSlots))]
|
||||
[HarmonyPatch("SetSlots")]
|
||||
public class SetSlotsPatch
|
||||
{
|
||||
public static void Postfix(XUiC_PowerSourceSlots __instance, ItemStack[] stacks)
|
||||
{
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.isPlayerPlaced: " + __instance.tileEntity.isPlayerPlaced);
|
||||
if (__instance.tileEntity.isPlayerPlaced)
|
||||
{
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots IS PLAYER PLACED");
|
||||
return;
|
||||
}
|
||||
|
||||
int numCells = 0;
|
||||
|
||||
for (int i = 0; i < stacks.Length; i++)
|
||||
{
|
||||
if (!stacks[i].IsEmpty())
|
||||
{
|
||||
numCells++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numCells > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameRandom gameRandom = GameManager.Instance.World.GetGameRandom();
|
||||
|
||||
ItemValue itemSolarCell = ItemClass.GetItem("solarCell", false);
|
||||
|
||||
int random = gameRandom.RandomRange(1, 7);
|
||||
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots Quality: " + random);
|
||||
|
||||
itemSolarCell.Quality = (ushort)random;
|
||||
|
||||
random = gameRandom.RandomRange(0, 6);
|
||||
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots Position: " + random);
|
||||
|
||||
//__instance.tileEntity.ItemSlots[random].itemValue = itemSolarCell;
|
||||
|
||||
stacks[random].itemValue = itemSolarCell;
|
||||
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots stacks[" + random + "].itemValue.IsEmpty(): " + stacks[random].itemValue.IsEmpty());
|
||||
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots stacks.Length: " + stacks.Length);
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.ItemSlots.Count: " + __instance.tileEntity.ItemSlots.Count());
|
||||
|
||||
/*Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.activateDirty: " + __instance.tileEntity.activateDirty);
|
||||
|
||||
for (int i = 0; i < stacks.Length; i++)
|
||||
{
|
||||
Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.ItemSlots[" + i + "].IsEmpty(): " + __instance.tileEntity.ItemSlots[i].IsEmpty());
|
||||
if (!__instance.tileEntity.ItemSlots[i].IsEmpty())
|
||||
{
|
||||
Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.ItemSlots[" + i + "].itemValue.Quality: " + __instance.tileEntity.ItemSlots[i].itemValue.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots __instance.tileEntity.ItemSlots[" + i + "].itemValue.Quality: IS EMPTY");
|
||||
}
|
||||
}*/
|
||||
|
||||
for (int i = 0; i < stacks.Length; i++)
|
||||
{
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots stacks[" + i + "].itemValue.IsEmpty(): " + stacks[i].itemValue.IsEmpty());
|
||||
if (!stacks[i].itemValue.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_PowerSourceSlotsPatches-SetSlots stacks[" + i + "].itemValue.Quality: " + stacks[i].itemValue.Quality);
|
||||
}
|
||||
}
|
||||
|
||||
__instance.items = stacks;
|
||||
__instance.SetStacks(stacks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Harmony.XUiM_ItemStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(XUiM_ItemStack))]
|
||||
[HarmonyPatch("CheckKnown")]
|
||||
public class CheckKnownPatch
|
||||
{
|
||||
public static void Postfix(XUiM_ItemStack __instance, ref bool __result, EntityPlayerLocal player, ItemClass itemClass, ItemValue itemValue)
|
||||
{
|
||||
string itemClassName = itemClass.Name;
|
||||
|
||||
if (player.Buffs.GetCustomVar(itemClassName) == 1f)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*using IntegratedConfigs.Harmony;
|
||||
using IntegratedConfigs.Scripts;*/
|
||||
using IntegratedConfigs.Harmony;
|
||||
using IntegratedConfigs.Scripts;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony
|
||||
{
|
||||
public class RebirthUtilsInit : IModApi
|
||||
{
|
||||
public void InitMod(Mod _modInstance)
|
||||
{
|
||||
Log.Out(" Loading Patch: " + GetType());
|
||||
|
||||
// Reduce extra logging stuff
|
||||
// disabled to prevent extra debugging info from getting stripped - Emu 12/07/2024
|
||||
//Application.SetStackTraceLogType(UnityEngine.LogType.Log, StackTraceLogType.None);
|
||||
//Application.SetStackTraceLogType(UnityEngine.LogType.Warning, StackTraceLogType.None);
|
||||
|
||||
var harmony = new HarmonyLib.Harmony(GetType().ToString());
|
||||
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||
|
||||
ReflectionHelpers.FindTypesImplementingBase(typeof(IIntegratedConfig), delegate (System.Type type)
|
||||
{
|
||||
IIntegratedConfig configRegistration = ReflectionHelpers.Instantiate<IIntegratedConfig>(type);
|
||||
Log.Out($"{Globals.LOG_TAG} Registering custom XML {configRegistration.RegistrationInfo.XmlName}");
|
||||
Harmony_WorldStaticData.RegisterConfig(configRegistration.RegistrationInfo);
|
||||
});
|
||||
|
||||
RebirthVariables.loadCommonParticles();
|
||||
RebirthVariables.LoadFactionStandings();
|
||||
RebirthVariables.LoadCustomParticles();
|
||||
|
||||
RebirthVariables.utilsPath = ModManager.GetMod("zzz_REBIRTH__Utils", true).Path;
|
||||
RebirthVariables.ignorePrefabs = XDocument.Load(RebirthVariables.utilsPath + "/IgnorePrefabs.xml");
|
||||
|
||||
/*var prefabNames = RebirthVariables.ignorePrefabs.Root
|
||||
.Elements("prefab")
|
||||
.Select(p => p.Attribute("name")?.Value)
|
||||
.Where(name => !string.IsNullOrEmpty(name));
|
||||
|
||||
foreach (var name in prefabNames)
|
||||
{
|
||||
Log.Out("RebirthUtilsInit-InitMod ignored prefab: " + name);
|
||||
}*/
|
||||
|
||||
if (RebirthVariables.testPurgeDiscovery)
|
||||
{
|
||||
RebirthVariables.discoveryUnlocks[0] = Tuple.Create(1f, 2f);
|
||||
RebirthVariables.discoveryUnlocks[1] = Tuple.Create(2f, 3f);
|
||||
RebirthVariables.discoveryUnlocks[2] = Tuple.Create(3f, 4f);
|
||||
RebirthVariables.discoveryUnlocks[3] = Tuple.Create(4f, 5f);
|
||||
RebirthVariables.discoveryUnlocks[4] = Tuple.Create(5f, 6f);
|
||||
RebirthVariables.discoveryUnlocks[5] = Tuple.Create(6f, 7f);
|
||||
RebirthVariables.discoveryUnlocks[6] = Tuple.Create(7f, 100f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DisableOrigin()
|
||||
{
|
||||
var _Origin = GameObject.Find("Origin");
|
||||
Log.Out($"Rebirth Init: Origin: {_Origin}");
|
||||
if (_Origin != null)
|
||||
{
|
||||
Log.Out($"Found Origin activeSelf: {_Origin.activeSelf}");
|
||||
Origin originObject = _Origin.GetComponent<Origin>();
|
||||
if (originObject != null)
|
||||
{
|
||||
Log.Out($"Disabling Origin script component...");
|
||||
originObject.enabled = false;
|
||||
originObject.isAuto = false;
|
||||
originObject.OriginPos = Vector3.zero;
|
||||
|
||||
if (Origin.Instance != null)
|
||||
{
|
||||
Log.Out($"Origin Instance found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out($"Origin Instance not set at this time.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
#pragma warning disable IDE0051 // Remove unused private members
|
||||
|
||||
namespace Harmony.StopFuelWastePatches
|
||||
{
|
||||
public class StopFuelWaste
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation), "HandleFuel")]
|
||||
public class TileEntityWorkstation_HandleFuel
|
||||
{
|
||||
static float GetAllRecipeTimes(TileEntityWorkstation __instance)
|
||||
{
|
||||
float crafting = 0;
|
||||
if (__instance.Queue == null) return crafting;
|
||||
foreach (RecipeQueueItem recipe in __instance.Queue)
|
||||
{
|
||||
if (recipe == null) continue;
|
||||
if (recipe.Multiplier > 1)
|
||||
{
|
||||
crafting += recipe.OneItemCraftTime * (recipe.Multiplier - 1f);
|
||||
}
|
||||
crafting += recipe.CraftingTimeLeft;
|
||||
}
|
||||
return crafting;
|
||||
}
|
||||
|
||||
static bool CanSmeltStackItemHere(
|
||||
TileEntityWorkstation __instance,
|
||||
ItemClass item)
|
||||
{
|
||||
if (item.MadeOfMaterial.ForgeCategory is string category)
|
||||
{
|
||||
foreach (string name in __instance.MaterialNames)
|
||||
{
|
||||
if (category.EqualsCaseInsensitive(name)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static float GetItemStackSmeltingTime(
|
||||
TileEntityWorkstation __instance,
|
||||
bool[] ___isModuleUsed,
|
||||
float timeLeft,
|
||||
ItemStack stack)
|
||||
{
|
||||
if (ItemClass.GetForId(stack.itemValue.type) is ItemClass item)
|
||||
{
|
||||
if (CanSmeltStackItemHere(__instance, item))
|
||||
{
|
||||
float smeltOneTime = item.GetWeight() * (item.MeltTimePerUnit > 0.0 ? item.MeltTimePerUnit : 1f);
|
||||
// Do we support tools?
|
||||
if (___isModuleUsed[0])
|
||||
{
|
||||
for (int n = 0; n < __instance.Tools.Length; ++n)
|
||||
{
|
||||
float modifier = 1f;
|
||||
__instance.Tools[n].itemValue.ModifyValue(null, null,
|
||||
PassiveEffects.CraftingSmeltTime,
|
||||
ref smeltOneTime, ref modifier,
|
||||
FastTags<TagGroup.Global>.Parse(item.Name));
|
||||
smeltOneTime *= modifier;
|
||||
}
|
||||
}
|
||||
if (timeLeft == int.MinValue)
|
||||
{
|
||||
return smeltOneTime * stack.count;
|
||||
}
|
||||
else if (stack.count > 1)
|
||||
{
|
||||
return smeltOneTime * (stack.count - 1f) + timeLeft;
|
||||
}
|
||||
else if (stack.count == 1)
|
||||
{
|
||||
return timeLeft;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Prefix(
|
||||
TileEntityWorkstation __instance,
|
||||
float[] ___currentMeltTimesLeft,
|
||||
bool[] ___isModuleUsed,
|
||||
ref float _timePassed)
|
||||
{
|
||||
float smelting = 0f;
|
||||
// Only check irregular deltas
|
||||
if (_timePassed < 10f) return;
|
||||
// Check if smelting is used
|
||||
if (___isModuleUsed[4])
|
||||
{
|
||||
for (int i = 0; i < __instance.InputSlotCount; i += 1)
|
||||
{
|
||||
smelting = System.Math.Max(
|
||||
GetItemStackSmeltingTime(
|
||||
__instance, ___isModuleUsed,
|
||||
___currentMeltTimesLeft[i],
|
||||
__instance.Input[i]),
|
||||
smelting);
|
||||
}
|
||||
}
|
||||
// Get summed up crafting time for all recipes
|
||||
float crafting = GetAllRecipeTimes(__instance);
|
||||
// Get maximum time for either crafting or smelting
|
||||
float timeNeeded = System.Math.Max(crafting, smelting);
|
||||
// If nothing to be done, we keep burning (feature)
|
||||
if (timeNeeded == 0) return;
|
||||
// Do not burn more fuel than needed for crafting or smelting
|
||||
_timePassed = System.Math.Min(_timePassed, timeNeeded);
|
||||
}
|
||||
}
|
||||
|
||||
// ####################################################################
|
||||
// ####################################################################
|
||||
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation), "UpdateTick")]
|
||||
public class TileEntityWorkstation_UpdateTick
|
||||
{
|
||||
|
||||
static bool HasWork(TileEntityWorkstation station,
|
||||
RecipeQueueItem[] queue,
|
||||
ItemStack[] input)
|
||||
{
|
||||
foreach (var item in queue)
|
||||
{
|
||||
if (item.IsCrafting) return true;
|
||||
}
|
||||
for (int i = 0; i < station.InputSlotCount; i += 1)
|
||||
{
|
||||
if (!input[i].IsEmpty()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Prefix(TileEntityWorkstation __instance,
|
||||
RecipeQueueItem[] ___queue,
|
||||
ItemStack[] ___input,
|
||||
out bool __state)
|
||||
{
|
||||
__state = false;
|
||||
if (!__instance.IsBurning) return;
|
||||
if (!HasWork(__instance, ___queue, ___input)) return;
|
||||
__state = true;
|
||||
}
|
||||
|
||||
static void Postfix(TileEntityWorkstation __instance,
|
||||
RecipeQueueItem[] ___queue,
|
||||
ItemStack[] ___input,
|
||||
bool __state)
|
||||
{
|
||||
if (__state == false) return;
|
||||
if (!__instance.IsBurning) return;
|
||||
if (HasWork(__instance, ___queue, ___input)) return;
|
||||
__instance.IsBurning = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ####################################################################
|
||||
// ####################################################################
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_WorkstationWindowGroup), "Update")]
|
||||
public class XUiC_WorkstationFuelGrid_Update
|
||||
{
|
||||
|
||||
static bool HasWork(XUiC_CraftingQueue craftingQueue,
|
||||
XUiC_WorkstationInputGrid inputWindow)
|
||||
{
|
||||
foreach (var item in craftingQueue.GetRecipesToCraft())
|
||||
{
|
||||
if (item.IsCrafting) return true;
|
||||
}
|
||||
// Not every station has input
|
||||
if (inputWindow == null) return false;
|
||||
XUiC_ItemStackGrid matInput = inputWindow.WindowGroup
|
||||
.Controller.GetChildByType<XUiC_ItemStackGrid>();
|
||||
int count = matInput.GetItemStackControllers().Length;
|
||||
var slots = inputWindow.GetSlots();
|
||||
for (int i = 0; i < count; i += 1)
|
||||
{
|
||||
if (!slots[i].IsEmpty()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Prefix(out bool __state,
|
||||
XUiC_CraftingQueue ___craftingQueue,
|
||||
XUiC_WorkstationInputGrid ___inputWindow)
|
||||
{
|
||||
__state = HasWork(___craftingQueue, ___inputWindow);
|
||||
}
|
||||
|
||||
static void Postfix(bool __state,
|
||||
XUiC_CraftingQueue ___craftingQueue,
|
||||
XUiC_WorkstationInputGrid ___inputWindow,
|
||||
XUiC_WorkstationFuelGrid ___fuelWindow)
|
||||
{
|
||||
if (__state == false) return;
|
||||
if (HasWork(___craftingQueue, ___inputWindow)) return;
|
||||
if (___fuelWindow != null)
|
||||
{
|
||||
___fuelWindow.TurnOff();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
using System.Collections.Generic;
|
||||
using Twitch;
|
||||
|
||||
namespace Harmony.ExplosionPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Explosion))]
|
||||
[HarmonyPatch("AttackEntites")]
|
||||
public class AttackEntitesPatch
|
||||
{
|
||||
public static bool Prefix(Explosion __instance, int _entityThatCausedExplosion, ItemValue _itemValueExplosionSource, EnumDamageTypes damageType)
|
||||
{
|
||||
EntityAlive entity1 = __instance.world.GetEntity(_entityThatCausedExplosion) as EntityAlive;
|
||||
FastTags<TagGroup.Global> explosionTag = Explosion.explosionTag;
|
||||
if (_itemValueExplosionSource != null)
|
||||
{
|
||||
ItemClass itemClass = _itemValueExplosionSource.ItemClass;
|
||||
explosionTag |= itemClass.ItemTags;
|
||||
}
|
||||
float num1 = EffectManager.GetValue(PassiveEffects.ExplosionEntityDamage, _itemValueExplosionSource, __instance.explosionData.EntityDamage, entity1, tags: explosionTag);
|
||||
float radius = EffectManager.GetValue(PassiveEffects.ExplosionRadius, _itemValueExplosionSource, (float)__instance.explosionData.EntityRadius, entity1, tags: explosionTag);
|
||||
Collider[] colliderArray = Physics.OverlapSphere(__instance.worldPos - Origin.position, radius, -538480645);
|
||||
bool flag1 = false;
|
||||
Vector3i blockPos = World.worldToBlockPos(__instance.worldPos);
|
||||
foreach (Collider collider in colliderArray)
|
||||
{
|
||||
if ((bool)collider)
|
||||
{
|
||||
Transform transform = collider.transform;
|
||||
if (transform.CompareTag("Item"))
|
||||
{
|
||||
EntityItem component1 = transform.GetComponent<EntityItem>();
|
||||
if (!(bool)component1)
|
||||
{
|
||||
RootTransformRefEntity component2 = transform.GetComponent<RootTransformRefEntity>();
|
||||
if ((bool)component2)
|
||||
component1 = component2.RootTransform.GetComponent<EntityItem>();
|
||||
}
|
||||
if ((bool)component1 && !component1.IsDead() && !Explosion.hitEntities.ContainsKey(component1.entityId))
|
||||
{
|
||||
Explosion.hitEntities.Add(component1.entityId, new Explosion.DamageRecord());
|
||||
component1.OnDamagedByExplosion();
|
||||
component1.SetDead();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string tag = transform.tag;
|
||||
if (tag.StartsWith("E_BP_"))
|
||||
{
|
||||
flag1 = true;
|
||||
Transform hitRootTransform = GameUtils.GetHitRootTransform(tag, transform);
|
||||
EntityAlive component = (bool)hitRootTransform ? hitRootTransform.GetComponent<EntityAlive>() : (EntityAlive)null;
|
||||
if ((bool)component)
|
||||
{
|
||||
component.ConditionalTriggerSleeperWakeUp();
|
||||
Vector3 direction = transform.position + Origin.position - __instance.worldPos;
|
||||
float magnitude = direction.magnitude;
|
||||
direction.Normalize();
|
||||
if (!Voxel.Raycast(__instance.world, new Ray(__instance.worldPos, direction), magnitude, 65536, 66, 0.0f))
|
||||
{
|
||||
EntityClass entityClass = EntityClass.list[component.entityClass];
|
||||
float num2 = transform.CompareTag("E_BP_LArm") || transform.CompareTag("E_BP_RArm") ? entityClass.ArmsExplosionDamageMultiplier : (transform.CompareTag("E_BP_LLeg") || transform.CompareTag("E_BP_RLeg") ? entityClass.LegsExplosionDamageMultiplier : (!transform.CompareTag("E_BP_Head") ? entityClass.ChestExplosionDamageMultiplier : entityClass.HeadExplosionDamageMultiplier));
|
||||
float num3 = (float)(int)EffectManager.GetValue(PassiveEffects.ExplosionIncomingDamage, _originalValue: num1 * num2 * (float)(1.0 - (double)magnitude / (double)radius), _entity: component);
|
||||
if ((double)num3 >= 3.0)
|
||||
{
|
||||
Explosion.DamageRecord damageRecord;
|
||||
if (!Explosion.hitEntities.TryGetValue(component.entityId, out damageRecord))
|
||||
damageRecord.entity = component;
|
||||
EnumBodyPartHit bodyPart = DamageSource.TagToBodyPart(tag);
|
||||
if ((double)num3 > (double)damageRecord.damage)
|
||||
{
|
||||
damageRecord.damage = num3;
|
||||
damageRecord.dir = direction;
|
||||
damageRecord.hitTransform = transform;
|
||||
damageRecord.mainPart = bodyPart;
|
||||
}
|
||||
damageRecord.parts |= bodyPart;
|
||||
Explosion.hitEntities[component.entityId] = damageRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<int, Explosion.DamageRecord> hitEntity in Explosion.hitEntities)
|
||||
{
|
||||
EntityAlive entity2 = hitEntity.Value.entity;
|
||||
if (entity2 != null)
|
||||
{
|
||||
bool flag2 = entity2.IsDead();
|
||||
int health = entity2.Health;
|
||||
bool _criticalHit = (double)hitEntity.Value.damage > (double)entity2.GetMaxHealth() * 0.10000000149011612;
|
||||
EnumBodyPartHit mainPart = hitEntity.Value.mainPart;
|
||||
EnumBodyPartHit enumBodyPartHit = hitEntity.Value.parts & ~mainPart;
|
||||
float num4 = flag2 ? 0.85f : 0.6f;
|
||||
for (int index = 0; index < 11; ++index)
|
||||
{
|
||||
int num5 = 1 << index;
|
||||
if ((enumBodyPartHit & (EnumBodyPartHit)num5) != EnumBodyPartHit.None && (double)entity2.rand.RandomFloat <= (double)num4)
|
||||
enumBodyPartHit &= (EnumBodyPartHit)~num5;
|
||||
}
|
||||
DamageSourceEntity _damageSource = new DamageSourceEntity(EnumDamageSource.External, damageType, _entityThatCausedExplosion, hitEntity.Value.dir, hitEntity.Value.hitTransform.name, Vector3.zero, Vector2.zero);
|
||||
_damageSource.bodyParts = mainPart | enumBodyPartHit;
|
||||
_damageSource.AttackingItem = _itemValueExplosionSource;
|
||||
_damageSource.DismemberChance = _criticalHit ? 0.5f : 0.0f;
|
||||
_damageSource.BlockPosition = blockPos;
|
||||
entity2.DamageEntity((DamageSource)_damageSource, (int)hitEntity.Value.damage, _criticalHit, 1f);
|
||||
if (entity1 != null)
|
||||
{
|
||||
MinEventTypes _eventType = health != entity2.Health ? MinEventTypes.onSelfExplosionDamagedOther : MinEventTypes.onSelfExplosionAttackedOther;
|
||||
entity1.MinEventContext.Self = entity1;
|
||||
entity1.MinEventContext.Other = entity2;
|
||||
entity1.MinEventContext.ItemValue = _itemValueExplosionSource;
|
||||
_itemValueExplosionSource?.FireEvent(_eventType, entity1.MinEventContext);
|
||||
entity1.FireEvent(_eventType, false);
|
||||
}
|
||||
if (__instance.explosionData.BuffActions != null)
|
||||
{
|
||||
for (int index = 0; index < __instance.explosionData.BuffActions.Count; ++index)
|
||||
{
|
||||
BuffClass buff = BuffManager.GetBuff(__instance.explosionData.BuffActions[index]);
|
||||
if (buff != null)
|
||||
{
|
||||
float num6 = EffectManager.GetValue(PassiveEffects.BuffProcChance, _originalValue: 1f, _entity: entity1, tags: FastTags<TagGroup.Global>.Parse(buff.Name));
|
||||
if ((double)entity2.rand.RandomFloat <= (double)num6)
|
||||
{
|
||||
int num7 = (int)entity2.Buffs.AddBuff(__instance.explosionData.BuffActions[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag2 && entity2.IsDead())
|
||||
{
|
||||
EntityPlayer entityPlayer = entity1 as EntityPlayer;
|
||||
if ((bool)entityPlayer)
|
||||
entityPlayer.AddKillXP(entity2);
|
||||
if (entity2 is EntityPlayer player)
|
||||
TwitchManager.Current.CheckKiller(player, entity1, blockPos);
|
||||
if (entity1 != null)
|
||||
{
|
||||
if (entity1.isEntityRemote)
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageMinEventFire>().Setup(entity1.entityId, entity2.entityId, MinEventTypes.onSelfKilledOther, _itemValueExplosionSource), _attachedToEntityId: entity1.entityId);
|
||||
else
|
||||
entity1.FireEvent(MinEventTypes.onSelfKilledOther);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag1 && entity1 != null)
|
||||
{
|
||||
if (entity1.isEntityRemote)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageMinEventFire>().Setup(entity1.entityId, -1, MinEventTypes.onSelfExplosionMissEntity, _itemValueExplosionSource), _attachedToEntityId: entity1.entityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity1.MinEventContext.Self = entity1;
|
||||
entity1.MinEventContext.Other = (EntityAlive)null;
|
||||
entity1.MinEventContext.ItemValue = _itemValueExplosionSource;
|
||||
entity1.FireEvent(MinEventTypes.onSelfExplosionMissEntity);
|
||||
}
|
||||
}
|
||||
Explosion.hitEntities.Clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.ItemActionEntryCraftPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemActionEntryCraft))]
|
||||
[HarmonyPatch("OnActivated")]
|
||||
public class OnActivatedPatch
|
||||
{
|
||||
public static bool Prefix(ItemActionEntryCraft __instance)
|
||||
{
|
||||
Recipe recipe = ((XUiC_RecipeEntry)__instance.ItemController).Recipe;
|
||||
XUi xui = __instance.ItemController.xui;
|
||||
List<XUiC_CraftingWindowGroup> childrenByType = xui.GetChildrenByType<XUiC_CraftingWindowGroup>();
|
||||
XUiC_CraftingWindowGroup craftingWindowGroup = (XUiC_CraftingWindowGroup)null;
|
||||
for (int index = 0; index < childrenByType.Count; ++index)
|
||||
{
|
||||
if (childrenByType[index].WindowGroup != null && childrenByType[index].WindowGroup.isShowing)
|
||||
{
|
||||
craftingWindowGroup = childrenByType[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (craftingWindowGroup == null)
|
||||
return false;
|
||||
if (XUiM_Recipes.GetRecipeIsUnlocked(__instance.ItemController.xui, recipe) && craftingWindowGroup.CraftingRequirementsValid(recipe))
|
||||
{
|
||||
Log.Out("ItemActionEntryCraftPatches-OnActivated __instance.craftingTier: " + __instance.craftingTier);
|
||||
Recipe _recipe = new Recipe()
|
||||
{
|
||||
itemValueType = recipe.itemValueType,
|
||||
count = XUiM_Recipes.GetRecipeCraftOutputCount(xui, recipe),
|
||||
craftingArea = recipe.craftingArea,
|
||||
craftExpGain = recipe.craftExpGain,
|
||||
craftingTime = XUiM_Recipes.GetRecipeCraftTime(xui, recipe),
|
||||
craftingToolType = recipe.craftingToolType,
|
||||
craftingTier = __instance.craftingTier,
|
||||
tags = recipe.tags
|
||||
};
|
||||
if (!__instance.HasItems(xui, recipe))
|
||||
return false;
|
||||
bool flag = false;
|
||||
for (int index = 0; index < recipe.ingredients.Count; ++index)
|
||||
{
|
||||
flag |= recipe.ingredients[index].itemValue.HasQuality;
|
||||
if (flag || __instance.tempIngredientList[index].count != recipe.ingredients[index].count)
|
||||
_recipe.scrapable = true;
|
||||
}
|
||||
_recipe.AddIngredients(__instance.tempIngredientList);
|
||||
XUiC_WorkstationInputGrid childByType = __instance.craftCountControl.WindowGroup.Controller.GetChildByType<XUiC_WorkstationInputGrid>();
|
||||
if (craftingWindowGroup.AddItemToQueue(_recipe))
|
||||
{
|
||||
if (flag)
|
||||
__instance.tempIngredientList.Clear();
|
||||
if (childByType != null)
|
||||
childByType.RemoveItems((IList<ItemStack>)_recipe.ingredients, __instance.craftCountControl.Count, (IList<ItemStack>)__instance.tempIngredientList);
|
||||
else
|
||||
xui.PlayerInventory.RemoveItems((IList<ItemStack>)_recipe.ingredients, __instance.craftCountControl.Count, (IList<ItemStack>)__instance.tempIngredientList);
|
||||
if (flag)
|
||||
{
|
||||
_recipe.ingredients.Clear();
|
||||
_recipe.AddIngredients(__instance.tempIngredientList);
|
||||
}
|
||||
if (recipe == xui.Recipes.TrackedRecipe)
|
||||
{
|
||||
xui.Recipes.TrackedRecipe = (Recipe)null;
|
||||
xui.Recipes.ResetToPreviousTracked(xui.playerUI.entityPlayer);
|
||||
}
|
||||
}
|
||||
else
|
||||
__instance.WarnQueueFull();
|
||||
}
|
||||
__instance.craftCountControl.IsDirty = true;
|
||||
craftingWindowGroup.WindowGroup.Controller.SetAllChildrenDirty();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Harmony.ItemClassesFromXmlPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ItemClassesFromXml))]
|
||||
[HarmonyPatch("parseItem")]
|
||||
public class parseItemPatch
|
||||
{
|
||||
public static bool Prefix(Block __instance, XElement _node)
|
||||
{
|
||||
XElement _element = _node;
|
||||
Log.Out("ItemClassesFromXmlPatches-parseItem Name: " + _element.GetAttribute((XName)"name"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user