static bool Prefix(Vector3 position, string soundGoupName) { AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGoupName); AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGoupName.Split('/').Last()); SphereII_GiveBuffOrQuestBySound.CheckForBuffOrQuest(soundGoupName.Split('/').Last(), position); return(true); }
public static void Postfix(ItemActionAttack __instance, ItemActionAttack.AttackHitInfo _attackDetails, ref float _weaponCondition, int _attackerEntityId, ItemValue damagingItemValue) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return; } EntityAlive entityAlive = GameManager.Instance.World.GetEntity(_attackerEntityId) as EntityAlive; if (entityAlive) { bool isWearingGloves = false; // Throw weapon, skipping if (damagingItemValue != null && damagingItemValue.ItemClass.HasAnyTags(FastTags.Parse("thrownWeapon"))) { return; } // Check if its the player hand if (entityAlive.inventory.holdingItem.GetItemName() == "meleeHandPlayer" && _attackDetails.damageGiven > 0 && !isWearingGloves) { AdvLogging.DisplayLog(AdvFeatureClass, "Attacking Entity is an EntityAlive: " + entityAlive.inventory.holdingItemItemValue.ItemClass.GetItemName() + " Inflicting Damage"); DamageSource dmg = new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Bashing); entityAlive.DamageEntity(dmg, 1, false, 1f); } } return; }
// Loops around the instructions and removes the return condition. static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { int startIndex = -1; // Grab all the instructions var codes = new List <CodeInstruction>(instructions); // Only look at the first 15 IL codes for this change. int MaxIteration = 15; if (codes.Count < MaxIteration) { MaxIteration = codes.Count; } for (int i = 0; i < MaxIteration; i++) { if (codes[i].opcode == OpCodes.Ret) { AdvLogging.DisplayLog(AdvFeatureClass, "Enabling UnlockEnemyHealthBar"); startIndex = i; break; } } if (startIndex > -1) { codes.RemoveAt(startIndex); } return(codes.AsEnumerable()); }
public static FastNoise GetFastNoise(Chunk chunk) { int Octaves = int.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Octaves")); float Lacunarity = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Lacunarity")); float Gain = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Gain")); float Frequency = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Frequency")); FastNoise.FractalType fractalType = EnumUtils.Parse <FastNoise.FractalType>(Configuration.GetPropertyValue(AdvFeatureClass, "FractalType"), false); FastNoise.NoiseType noiseType = EnumUtils.Parse <FastNoise.NoiseType>(Configuration.GetPropertyValue(AdvFeatureClass, "NoiseType"), false); FastNoise fastNoise = new FastNoise(); fastNoise.SetFractalType(fractalType); fastNoise.SetNoiseType(noiseType); fastNoise.SetFractalOctaves(Octaves); fastNoise.SetFractalLacunarity(Lacunarity); fastNoise.SetFractalGain(Gain); fastNoise.SetFrequency(Frequency); fastNoise.SetSeed(chunk.GetHashCode()); var chunkPos = chunk.GetWorldPos(); String display = "Chunk and Seed: " + chunk.GetHashCode() + " Fractal Type: " + fractalType.ToString() + " Noise Type: " + noiseType.ToString() + " Position: " + chunkPos + " Octaves: " + Octaves + " Lacunarity: " + Lacunarity + " Gain: " + Gain + " Frequency: " + Frequency; AdvLogging.DisplayLog(AdvFeatureClass, display); return(fastNoise); }
public static void AddSoundData(XmlNode node) { SoundDataSDX newSoundData = new SoundDataSDX(); string SoundGroupName = node.Attributes[0].Value; foreach (object obj in node.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode.Name.EqualsCaseInsensitive("Buff")) { string text = xmlNode.Attributes[0].Value; AdvLogging.DisplayLog(AdvFeatureClass, SoundGroupName + " Adding Trigger Buff: " + text); newSoundData.Buff = text; } if (xmlNode.Name.EqualsCaseInsensitive("Quest")) { string text = xmlNode.Attributes[0].Value; AdvLogging.DisplayLog(AdvFeatureClass, SoundGroupName + " Adding Trigger Quest: " + text); newSoundData.Quest = text; } } // If it has a buff or a quest, add it to the monitored sound. if(newSoundData.Buff != null || newSoundData.Quest != null) { if(!SoundDataSDXInfo.ContainsKey(SoundGroupName)) SoundDataSDXInfo.Add(SoundGroupName, newSoundData); } }
public static void CheckForBuffOrQuest(string soundGroupName, Vector3 position) { AdvLogging.DisplayLog(AdvFeatureClass, "Searching for " + soundGroupName); // Dictionary search for substring if (SoundDataNodeClassSDX.SoundDataSDXInfo.ContainsKey(soundGroupName)) { AdvLogging.DisplayLog(AdvFeatureClass, "Found Sound Node. Checking for buffs"); // use xmlData to grab the sound node information, which can contain how far away the sound can be heard. XmlData xmlData; if (!Manager.audioData.TryGetValue(soundGroupName, out xmlData)) { return; } int Radius = Utils.Fastfloor(xmlData.distantFadeEnd); SoundDataNodeClassSDX.SoundDataSDX data = SoundDataNodeClassSDX.SoundDataSDXInfo[soundGroupName]; if (data.Buff != null) { AdvLogging.DisplayLog(AdvFeatureClass, ": Found Buff for Sound Node: " + data.Buff); EntityUtilities.AddBuffToRadius(data.Buff, position, Radius); } AdvLogging.DisplayLog(AdvFeatureClass, "Scanning for quest"); if (data.Quest != null) { AdvLogging.DisplayLog(AdvFeatureClass, "Adding Quest " + data.Quest + " to surrounding entities"); EntityUtilities.AddQuestToRadius(data.Quest, position, Radius); } } return; }
public static bool Prefix(EntityAlive __instance, ref DamageSource _damageSource, ref int _strength, bool _criticalHit, float _impulseScale) { // Apply a damage boost if there is a head shot. if (__instance is EntityZombie) { if (_strength > 999) { AdvLogging.DisplayLog(AdvFeatureClass, " Massive Damage Detected. Falling back to base"); return(true); } if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { EnumBodyPartHit bodyPart = _damageSource.GetEntityDamageBodyPart(__instance); if (bodyPart == EnumBodyPartHit.Head) { AdvLogging.DisplayLog(AdvFeatureClass, " Headshot Mode Active: Headshot! "); // Apply a damage multiplier for the head shot, and bump the dismember bonus for the head shot // This will allow the heads to go explode off, which according to legend, if the only want to truly kill a zombie. _damageSource.DamageMultiplier = 1f; // _strength = 1; _damageSource.DismemberChance = 0.8f; } // Reducing the damage to the torso will prevent the entity from being killed by torso shots, while also maintaining de-limbing. else { AdvLogging.DisplayLog(AdvFeatureClass, " Headshot Mode Active: Non-Headshot"); _damageSource.DamageMultiplier = 0.1f; _strength = 1; } } } return(true); }
public override bool CheckRequirement(EntityPlayer player) { int count = 0; if (string.IsNullOrEmpty(Value)) { Value = "1"; } float flValue = 1f; float.TryParse(Value, out flValue); LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal); XUiM_PlayerInventory playerInventory = uiforPlayer.xui.PlayerInventory; ItemValue item = ItemClass.GetItem(ID); if (item != null) { count = playerInventory.Backpack.GetItemCount(item, -1, -1, false); count += playerInventory.Toolbelt.GetItemCount(item, false, -1, -1); AdvLogging.DisplayLog(AdvFeatureClass, "HasItemSDX: " + item.ItemClass.GetItemName() + " Player has Count: " + count + " Needs: " + flValue); if (flValue <= count) { return(true); } } AdvLogging.DisplayLog(AdvFeatureClass, "HasItemSDX: Player does not have enough " + item.ItemClass.GetItemName() + " Count: " + count + " Needs: " + flValue); return(false); }
public static bool Prefix(ref string value, BindingItem binding, ItemClass ___itemClass) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } if (___itemClass == null) { return(true); } string text = binding.FieldName; if (text == "itemRepairDescription") { AdvLogging.DisplayLog(AdvFeatureClass, "Reading Custom Repair description"); string descriptionKey2 = ___itemClass.DescriptionKey; if (Localization.Exists(descriptionKey2, "")) { value = Localization.Get(descriptionKey2, ""); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Localization.Get("lblRepairItems", "")); List <ItemStack> stack = new List <ItemStack>(); // Check if ScrapItems is specified if (___itemClass.Properties.Classes.ContainsKey("RepairItems")) { DynamicProperties dynamicProperties3 = ___itemClass.Properties.Classes["RepairItems"]; stack = ItemsUtilities.ParseProperties(dynamicProperties3); } else if (___itemClass.Properties.Contains("RepairItems")) // to support <property name="RepairItems" value="resourceWood,10,resourceForgedIron,10" /> { string strData = ___itemClass.Properties.Values["RepairItems"].ToString(); stack = ItemsUtilities.ParseProperties(strData); } else if (___itemClass.RepairTools == null || ___itemClass.RepairTools.Length <= 0) { Recipe recipe = ItemsUtilities.GetReducedRecipes(___itemClass.GetItemName(), 2); stack = recipe.ingredients; } if (stack.Count > 0) { stringBuilder.Append(ItemsUtilities.GetStackSummary(stack)); value = stringBuilder.ToString(); } else { stringBuilder.Append(" You cannot repair this."); value = stringBuilder.ToString(); } return(false); } return(true); }
static bool Prefix(Audio.Manager __instance, Entity entity, string soundGroupName) { AdvLogging.DisplayLog(AdvFeatureClass, "AudioManager.Play(): Entity, String, float, bool: " + soundGroupName); if (entity == null) { return(true); } AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGroupName.Split('/').Last()); SphereII_GiveBuffOrQuestBySound.CheckForBuffOrQuest(soundGroupName.Split('/').Last(), entity.position); return(true); }
static void Postfix(EntityPlayerLocal __instance) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return; } AdvLogging.DisplayLog(AdvFeatureClass, "Activating One Block Crouch"); __instance.vp_FPController.PhysicsCrouchHeightModifier = 0.49f; __instance.vp_FPController.SyncCharacterController(); }
public static bool Prefix(AvatarController __instance, string _property) { if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { AdvLogging.DisplayLog(AdvFeatureClass, "Set Trigger(): " + _property); } // Provides a random index value to the default animator. __instance.SetInt("RandomIndex", UnityEngine.Random.Range(0, 10)); __instance.SetInt(_property, UnityEngine.Random.Range(0, 10)); return(true); }
public static bool Prefix(TileEntityWorkstation __instance, ref float ___currentBurnTimeLeft) { AdvLogging.DisplayLog(AdvFeatureClass, "UpdateTick()"); if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) return true; if (___currentBurnTimeLeft < 0.5f) { if (SphereII_PowerWorkstationHelper.CheckWorkstationForPower(__instance)) ___currentBurnTimeLeft = 5f; } AdvLogging.DisplayLog(AdvFeatureClass, "Current Burn Time: " + ___currentBurnTimeLeft); return true; }
static bool Prefix(XmlFile _targetFile, XmlElement _patchElement, string _patchName) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } String strDisplay = _patchName + ": Attempting to Patch: " + _patchElement.GetAttribute("xpath"); AdvLogging.DisplayLog(AdvFeatureClass, strDisplay); return(true); }
public static void Postfix(ref EntityAlive __instance) { // Check if this feature is enabled. if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { if (__instance is EntityPlayerLocal) { return; } if (RandomSizeHelper.AllowedRandomSize(__instance)) { // This is the distributed random heigh multiplier. Add or adjust values as you see fit. By default, it's just a small adjustment. float[] numbers = new float[9] { 0.7f, 0.8f, 0.9f, 0.9f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f }; System.Random random = new System.Random(); int randomIndex = random.Next(0, numbers.Length); float flScale = numbers[randomIndex]; AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: " + flScale); __instance.Buffs.AddCustomVar("RandomSize", flScale); // scale down the zombies, or upscale them __instance.gameObject.transform.localScale = new Vector3(flScale, flScale, flScale); } // Check if there's random ranges EntityClass entityClass = __instance.EntityClass; if (entityClass.Properties.Values.ContainsKey("RandomSizes")) { List <float> Ranges = new List <float>(); float flScale = 1f; foreach (string text in entityClass.Properties.Values["RandomSizes"].Split(new char[] { ',' })) { Ranges.Add(StringParsers.ParseFloat(text)); } System.Random random = new System.Random(); int randomIndex = random.Next(0, Ranges.Count); flScale = Ranges[randomIndex]; AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: " + flScale); __instance.Buffs.AddCustomVar("RandomSize", flScale); // scale down the zombies, or upscale them __instance.gameObject.transform.localScale = new Vector3(flScale, flScale, flScale); } } }
static bool Prefix(int playOnEntityId, string soundGoupName, float _occlusion) { AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): int, string, float: " + soundGoupName); EntityAlive myEntity = GameManager.Instance.World.GetEntity(playOnEntityId) as EntityAlive; if (myEntity == null) { return(true); } AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGoupName.Split('/').Last()); SphereII_GiveBuffOrQuestBySound.CheckForBuffOrQuest(soundGoupName.Split('/').Last(), myEntity.position); return(true); }
static void CheckTag(DynamicProperties dynamicProperties, String strTag) { String strDisplay = "Property: " + strTag; if (dynamicProperties.Contains(strTag)) { strDisplay += " Value: " + dynamicProperties.GetStringValue(strTag); } else { strDisplay += " Property is not set."; } AdvLogging.DisplayLog(AdvFeatureClass, strDisplay); }
static bool Prefix(Audio.Manager __instance, Vector3 position, string soundGroupName) { AdvLogging.DisplayLog(AdvFeatureClass, "AudioManager.Play(): Vector3, String, int: " + soundGroupName); if (String.IsNullOrEmpty(soundGroupName)) { return(true); } AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGroupName.Split('/').Last()); SphereII_GiveBuffOrQuestBySound.CheckForBuffOrQuest(soundGroupName.Split('/').Last(), position); return(true); }
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { if (_blockValue.Block.Properties.Values.ContainsKey("ActivateOnLook")) { bool ActivateOnLook = StringParsers.ParseBool(_blockValue.Block.Properties.Values["ActivateOnLook"], 0, -1, true); if (ActivateOnLook) { AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Activating Block on GetActivationText"); TriggerOnly = true; ActivateBlock(_world, _clrIdx, _blockPos, _blockValue, true, true); TriggerOnly = false; } } return(""); }
static bool Prefix(XmlElement _e) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, SecondFeature)) { return(true); } PhysicsBodyColliderConfiguration physicsBodyColliderConfiguration = new PhysicsBodyColliderConfiguration(); DynamicProperties dynamicProperties = new DynamicProperties(); foreach (object obj in _e.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode.NodeType == XmlNodeType.Element && xmlNode.Name.Equals("property")) { dynamicProperties.Add(xmlNode, true); } } AdvLogging.DisplayLog(AdvFeatureClass, "\n======= Physics Bodies ============"); CheckTag(dynamicProperties, "tag"); CheckTag(dynamicProperties, "path"); CheckTag(dynamicProperties, "collisionLayer"); CheckTag(dynamicProperties, "ragdollLayer"); CheckTag(dynamicProperties, "layer"); CheckTag(dynamicProperties, "ragdollScale"); CheckTag(dynamicProperties, "type"); CheckTag(dynamicProperties, "flags"); if (dynamicProperties.Contains("collisionLayer")) { if (!dynamicProperties.Contains("ragdollLayer")) { AdvLogging.DisplayLog(AdvFeatureClass, "\tWARNING: Collision Layer is set, but does not contain a ragdollLayer"); } } else { if (!dynamicProperties.Contains("layer")) { AdvLogging.DisplayLog(AdvFeatureClass, "\tWARNING: Collision Layer IS NOT SET. Falling back to layer property, but that is not found either! "); } } AdvLogging.DisplayLog(AdvFeatureClass, "======= End Physics Bodies ============"); return(true); }
public static bool Prefix(EntityAlive __instance) { if (__instance.Buffs.HasCustomVar("RandomSize")) { AdvLogging.DisplayLog(AdvFeatureClass, " Update()"); float scale = __instance.Buffs.GetCustomVar("RandomSize"); AdvLogging.DisplayLog(AdvFeatureClass, " Scale: " + scale + " Transform: " + __instance.gameObject.transform.localScale.x); // if (__instance.gameObject.transform.localScale.x != scale) { AdvLogging.DisplayLog(AdvFeatureClass, " Setting Scale: " + scale); __instance.gameObject.transform.localScale = new Vector3(scale, scale, scale); } } return(true); }
public static bool AllowedRandomSize(EntityAlive entity) { bool bRandomSize = false; if (entity is EntityZombie) { AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: Is A Zombie. Random size is true"); bRandomSize = true; } EntityClass entityClass = EntityClass.list[entity.entityClass]; if (entityClass.Properties.Values.ContainsKey("RandomSize")) { bRandomSize = StringParsers.ParseBool(entityClass.Properties.Values["RandomSize"], 0, -1, true); } AdvLogging.DisplayLog(AdvFeatureClass, "Entity: " + entity.DebugNameInfo + " Random Size: " + bRandomSize); return(bRandomSize); }
public static void GenerateCaveChunks(int CaveEntrances = 2) { string AdvFeatureClass = "CaveConfiguration"; if (caveChunks.Count == 0) { int MaxCount = int.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "CaveCluster")); int ClusterSize = int.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "CavesClusterSize")); String display = "Searching for " + MaxCount + " Cave Clusters. Each Cave Cluster will include " + ClusterSize + " chunks..."; AdvLogging.DisplayLog(AdvFeatureClass, display); Vector3i[] RandomCavePoints = FindRandomPoints(MaxCount); //for (int x = 0; x < 10; x++) //{ for (int i = 0; i < RandomCavePoints.Length; i++) { Vector3i randomChunkPosition = RandomCavePoints[i]; //vector3i world pos var caveRadius = ClusterSize; for (int x = 0; x < CaveEntrances; x++) { //find a random x/z inside the bounds of the cave int entranceX = Utils.Fastfloor(GameManager.Instance.World.GetGameRandom().RandomRange(randomChunkPosition.x, randomChunkPosition.x + (caveRadius * 16))); int entranceZ = Utils.Fastfloor(GameManager.Instance.World.GetGameRandom().RandomRange(randomChunkPosition.z, randomChunkPosition.z + (caveRadius * 16))); Vector3i entrance = new Vector3i(entranceX, x, entranceZ); caveEntrances.Add(new Vector3i(entranceX, x, entranceZ)); display = "Cave Spawn Area: " + randomChunkPosition + " Entrance: " + new Vector3i(entranceX, 0, entranceZ); AdvLogging.DisplayLog(AdvFeatureClass, display); Debug.Log(display); } for (var cX = 0; cX < caveRadius; cX++) { for (var cZ = 0; cZ < caveRadius; cZ++) { Vector3i cave = randomChunkPosition + new Vector3i(cX * 16, 0, cZ * 16); caveChunks.Add(randomChunkPosition + new Vector3i(cX * 16, 0, cZ * 16)); } } } } }
public static bool Prefix(ref UMA.UMAData ___umaData) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } ___umaData.AtlasSize = 512; // Changing the Atlas size down for all UMAs if (SkyManager.BloodMoon() || SkyManager.IsDark()) { ___umaData.AtlasSize = 128; } AdvLogging.DisplayLog(AdvFeatureClass, Feature + " - Atlas Size: " + ___umaData.AtlasSize); return(true); }
public static void Postfix(EntityAlive __instance, BinaryWriter _bw) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return; } try { if (RandomSizeHelper.AllowedRandomSize(__instance)) { float flScale = __instance.gameObject.transform.localScale.x; AdvLogging.DisplayLog(AdvFeatureClass, " Write Size: " + flScale); _bw.Write(flScale); } } catch (Exception) { } }
public override bool ActivateBlock(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, bool isOn, bool isPowered) { // If there's no transform, no sense on keeping going for this class. BlockEntityData _ebcd = _world.GetChunkFromWorldPos(_blockPos).GetBlockEntity(_blockPos); if (_ebcd == null || _ebcd.transform == null) { return(false); } Animator[] componentsInChildren = _ebcd.transform.GetComponentsInChildren <Animator>(); if (componentsInChildren != null) { for (int i = componentsInChildren.Length - 1; i >= 0; i--) { Animator animator = componentsInChildren[i]; AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Animator: " + animator.name + " : Active: " + isOn); if (isOn) { int random = UnityEngine.Random.Range(0, this.RandomIndex); AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Random Index for " + animator.name + " Value: " + random); animator.SetInteger("RandomIndex", random); AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Setting Bool for On: True " + animator.name); animator.SetBool("On", true); AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Trigger for On: " + animator.name); animator.SetTrigger("TriggerOn"); } if (isOn == false) { AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Setting Bool for On: false" + animator.name); animator.SetBool("On", false); // AdvLogging.DisplayLog(AdvFeatureClass, _blockValue.Block.GetBlockName() + ": Turning Off Animator " + animator.name); // animator.enabled = false; } } } return(true); }
public static bool Prefix(float __result, ItemActionAttack __instance, float _strength, float _condition) { // If it's full, then just work with the base class. if (_condition == 1f) { return(true); } // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } // Condition will be the Percent left of the item // Reduce damage based on durability left. __result = _strength * _condition; AdvLogging.DisplayLog(AdvFeatureClass, "New Calculated Damage: " + __result); return(false); }
public static void Postfix(EntityAlive __instance, BinaryReader _br) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return; } try { if (RandomSizeHelper.AllowedRandomSize(__instance)) { float flScale = _br.ReadSingle(); AdvLogging.DisplayLog(AdvFeatureClass, " Read Size: " + flScale); __instance.gameObject.transform.localScale = new Vector3(flScale, flScale, flScale); } } catch (Exception) { } }
public static bool Prefix(ItemActionAttack __instance, ItemActionAttack.AttackHitInfo _attackDetails, ref float _weaponCondition, int _attackerEntityId) { // Check if this feature is enabled. if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } EntityAlive entityAlive = GameManager.Instance.World.GetEntity(_attackerEntityId) as EntityAlive; if (entityAlive) { ItemValue itemValue = entityAlive.inventory.holdingItemItemValue; if (itemValue.HasQuality && entityAlive is EntityPlayerLocal) // this checks if it has any passive effects, like degradation { String strDisplay = ""; if (_attackDetails.WeaponTypeTag.Equals(ItemActionAttack.MeleeTag)) { strDisplay += " Melee "; float percent = itemValue.PercentUsesLeft; if (percent > 0.8f) { _weaponCondition = 1f; } else if (percent > 0) // Perfecent left will be 0 on non-degradation things { _weaponCondition = percent; } } else if (_attackDetails.WeaponTypeTag.Equals(ItemActionAttack.RangedTag)) { strDisplay += " Ranged "; } strDisplay += itemValue.ItemClass.GetItemName() + " Percent Left: " + itemValue.PercentUsesLeft + " Weapon Condition: " + _weaponCondition; AdvLogging.DisplayLog(AdvFeatureClass, strDisplay); } } return(true); }
public static void Postfix(EntityAlive __instance, ref int ___walkType) { // Check if this feature is enabled. if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { if ((___walkType != 4 && ___walkType != 8) && __instance is EntityZombie) { // Distribution of Walk Types in an array. Adjust the numbers as you want for distribution. The 9 in the default int[9] indicates how many walk types you've specified. int[] numbers = new int[9] { 1, 2, 2, 3, 4, 5, 6, 7, 7 }; System.Random random = new System.Random(); // Randomly generates a number between 0 and the maximum number of elements in the numbers. int randomNumber = random.Next(0, numbers.Length); // return the randomly selected walk type ___walkType = numbers[randomNumber]; AdvLogging.DisplayLog(AdvFeatureClass, " Random Walk Type: " + ___walkType); } EntityClass entityClass = __instance.EntityClass; if (entityClass.Properties.Values.ContainsKey("RandomWalkTypes")) { List <int> Ranges = new List <int>(); foreach (string text in entityClass.Properties.Values["RandomWalkTypes"].Split(new char[] { ',' })) { Ranges.Add(StringParsers.ParseSInt32(text)); } System.Random random = new System.Random(); int randomIndex = random.Next(0, Ranges.Count); ___walkType = Ranges[randomIndex]; AdvLogging.DisplayLog(AdvFeatureClass, " Random Walk Type: " + ___walkType); } } }