// Start is called before the first frame update public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { baseAi = animator.gameObject.GetComponent <BaseAi>(); otherUnits = baseAi.GetUnitsList(); piece = animator.gameObject.GetComponent <Piece>(); agent = animator.gameObject.GetComponent <NavMeshAgent>(); }
static void AdjustRanges(BaseAi inst, string animal) { // Debug.LogFormat("{0} {1} {2} {3} {4} {5}", animal, inst.m_SmellRange, inst.m_DetectionRange, inst.m_DetectionRangeWhileFeeding, inst.m_HearFootstepsRange, inst.m_HearFootstepsRangeWhileFeeding); if (m_animals[animal].enabled) { if (m_animals[animal].hear_range_while_feeding >= 0f) { inst.m_HearFootstepsRangeWhileFeeding = m_animals[animal].hear_range_while_feeding; } if (m_animals[animal].hear_range >= 0f) { inst.m_HearFootstepsRange = m_animals[animal].hear_range; } if (m_animals[animal].detection_range_while_feeding >= 0f) { inst.m_DetectionRangeWhileFeeding = m_animals[animal].detection_range_while_feeding; } if (m_animals[animal].detection_range >= 0f) { inst.m_DetectionRange = m_animals[animal].detection_range; } if (m_animals[animal].smell_range >= 0f) { inst.m_SmellRange = m_animals[animal].smell_range; } } }
public static void Postfix(BaseAi __instance) { if (__instance.m_AiRabbit != null && Settings.options.killOnHit) { __instance.EnterDead(); } }
private static bool Prefix(BearSpearItem __instance, BaseAi ___m_HitAi, ref float ___m_HitDamage, ref float ___m_HitBleedOutMinutes, LocalizedDamage ___m_LocalizedDamage, Vector3 ___m_HitPosition, Vector3 ___m_HitSourcePosition, GearItem ___m_GearItem) { var settings = nonStroyBearspearSettings.Instance; if (!___m_HitAi) { return(false); } if (GameManager.GetPlayerStruggleComponent().GetBearSpearStruggleOutcome() == BearSpearStruggleOutcome.Failed) { ___m_HitDamage = ___m_HitDamage * settings.Damagefailed; ___m_HitBleedOutMinutes = ___m_HitDamage * settings.Bleedfailed; } else { ___m_HitDamage = ___m_HitDamage * settings.DamageSuccess; ___m_HitBleedOutMinutes = ___m_HitDamage * settings.BleedSuccess; } if (___m_LocalizedDamage) { ___m_HitAi.SetupDamageForAnim(___m_HitPosition, ___m_HitSourcePosition, ___m_LocalizedDamage); } ___m_HitAi.ApplyDamage(___m_HitDamage, ___m_HitBleedOutMinutes, DamageSource.Player, string.Empty); if (___m_GearItem) { ___m_GearItem.DegradeOnUse(); } if (___m_GearItem.IsWornOut()) { AccessTools.Method(typeof(BearSpearItem), "Break").Invoke(__instance, null); } return(false); }
internal static void AdjustRanges(BaseAi inst, string animal) { //Implementation.Log("{0} {1} {2} {3} {4} {5}", animal, inst.m_SmellRange, inst.m_DetectionRange, inst.m_DetectionRangeWhileFeeding, inst.m_HearFootstepsRange, inst.m_HearFootstepsRangeWhileFeeding); if (Settings.m_animals[animal].enabled) { if (Settings.m_animals[animal].hear_range_while_feeding >= 0f) { inst.m_HearFootstepsRangeWhileFeeding = ApplyCustomMode(Settings.m_animals[animal].hear_range_while_feeding); } if (Settings.m_animals[animal].hear_range >= 0f) { inst.m_HearFootstepsRange = ApplyCustomMode(Settings.m_animals[animal].hear_range); } if (Settings.m_animals[animal].detection_range_while_feeding >= 0f) { inst.m_DetectionRangeWhileFeeding = ApplyCustomMode(Settings.m_animals[animal].detection_range_while_feeding); } if (Settings.m_animals[animal].detection_range >= 0f) { inst.m_DetectionRange = ApplyCustomMode(Settings.m_animals[animal].detection_range); } if (Settings.m_animals[animal].smell_range >= 0f) { inst.m_SmellRange = Settings.m_animals[animal].smell_range; } } }
void TriadBehaviorControl(BaseAi baseAi) { switch (baseAi.currentState) { case EnemyStates.Aggressive: Debug.Log("I am angry"); MoveTowardsPoint(baseAi.pointOfInterest, maxSpeed); break; case EnemyStates.Detect: Debug.Log("I am searching"); MoveTowardsPoint(baseAi.pointOfInterest, passiveSpeed); break; case EnemyStates.Passive: Debug.Log("I am passive"); //todo: add walk path nav.isStopped = true; break; } // if the AI is close to the player if (nav.remainingDistance <= nav.stoppingDistance) { baseAi.currentState = EnemyStates.Passive; //Debug.Log("Arrived at destination"); } }
public static void Postfix(BaseAi __instance) { switch (__instance.m_AiSubType) { case AiSubType.Wolf: Implementation.AdjustRanges(__instance, "wolf"); break; case AiSubType.Stag: Implementation.AdjustRanges(__instance, "deer"); break; case AiSubType.Moose: Implementation.AdjustRanges(__instance, "moose"); break; case AiSubType.Rabbit: Implementation.AdjustRanges(__instance, "rabbit"); break; case AiSubType.Bear: Implementation.AdjustRanges(__instance, "bear"); break; } }
public static void Prefix(BaseAi __instance) { if (__instance.m_AiRabbit != null && Settings.options.stunDuration >= 0f) { //MelonLogger.Log("TweakRabbits: stun duration {0}", __instance.m_StunSeconds); __instance.m_StunSeconds = Settings.options.stunDuration; } }
public static void Postfix(BaseAi __instance) { if (__instance.m_AiRabbit != null) { if (killOnHit) { __instance.EnterDead(); } } }
public static void Prefix(BaseAi __instance) { if (__instance.m_AiRabbit != null) { if (stunDuration >= 0f) { Debug.LogFormat("TweakRabbits: stun duration {0}", __instance.m_StunSeconds); __instance.m_StunSeconds = stunDuration; } } }
private static void Postfix(BaseAi __instance, BaseAiDataProxy proxy) { float num = GameManager.GetTimeOfDayComponent().GetHoursPlayedNotPaused() - proxy.m_HoursPlayed; num *= 60f; while (num > 1) { Implementation.UpdateWounds(__instance, 1); //small septs so the bleed reductions can update num -= 1; } Implementation.UpdateWounds(__instance, num); }
private static void Postfix(BaseAi __instance, float damage, float bleedOutMintues, DamageSource damageSource, string collider) { if (BleedOutMintuesTmp > 0) { float b1 = bleedOutMintues; float b2 = BleedOutMintuesTmp - __instance.m_ElapsedBleedingOutMinutes; float bn = b1 * b2 / (b1 + b2); bn += __instance.m_ElapsedBleedingOutMinutes; __instance.m_DeathAfterBleeingOutMinutes = bn; // Implementation.Log(bn.ToString() + " " + __instance.m_CurrentHP.ToString()); } //Implementation.Log(bleedOutMintues.ToString() + " " + __instance.m_CurrentHP.ToString()); }
private static void Postfix(BaseAi __instance) { if (!(bool)__instance.m_BearHuntAiRedux) { PlayerManager playerManagerComponent = GameManager.GetPlayerManagerComponent(); if ((bool)playerManagerComponent.m_ItemInHands) { BearSpearItem bearSpearItem = playerManagerComponent.m_ItemInHands.m_BearSpearItem; if ((bool)bearSpearItem && bearSpearItem.IsRaised()) { bearSpearItem.UpdateCollision(__instance); } } } }
public static void UpdateWounds(BaseAi ba, float mins) { if (ba.IsBleedingOut()) { float BleedOutMintues = ba.m_DeathAfterBleeingOutMinutes; ba.m_CurrentHP -= ba.m_MaxHP * mins / BleedOutMintues; BleedOutMintues *= Mathf.Exp(mins / (60f)); if (BleedOutMintues > 500000f) { ba.m_BleedingOut = false; BleedOutMintues = 0; ba.m_ElapsedBleedingOutMinutes = 0; } ba.m_DeathAfterBleeingOutMinutes = BleedOutMintues; //Implementation.Log(BleedOutMintues.ToString() + " " + ba.m_CurrentHP.ToString()); if (ba.m_CurrentHP <= 0) { ba.m_CurrentHP = 0; BaseAi.DamageSide damageSide = ba.m_LastDamageSide; int Part = ba.m_LastDamageBodyPart; ba.SetDamageImpactParameter(damageSide, Part, BaseAi.SetupDamageParamsOptions.None); //a copy the game code ba.SetAiMode(AiMode.Dead); // __instance.m_ElapsedBleedingOutMinutes = float.PositiveInfinity; //but tricking the base code did not work } } if (ba.m_Wounded) { ba.m_CurrentHP += ba.m_CurrentHP / ba.m_MaxHP * mins / 60f; //up to one HP 1 per hour if (ba.m_CurrentHP > ba.m_MaxHP) { ba.m_CurrentHP = ba.m_MaxHP; ba.m_Wounded = false; } } }
// Start is called before the first frame update void Start() { aiState = GetComponent <BaseAi>(); // get navigation component nav = GetComponent <NavMeshAgent>(); nav.isStopped = true; // set the max speed to be same as the player (temp) if (GameObject.FindGameObjectWithTag("Player") != null) { maxSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>().maxSpeed; } else { maxSpeed = 5f; } }
private static void Prefix(SpawnRegion __instance) { bool m_StartHasBeenCalled = (bool)startHasBeenCalled.GetValue(__instance); if (m_StartHasBeenCalled || (GameManager.IsStoryMode() && !WildlifeBegone.Config.enableInStoryMode)) { return; } GameObject spawnedObject = __instance.m_SpawnablePrefab; BaseAi ai = spawnedObject.GetComponent <BaseAi>(); if (ai == null) { return; } SpawnRateSetting spawnRates = WildlifeBegone.Config.spawnRates[(int)ai.m_AiSubType]; AdjustRegion(__instance, spawnRates); }
private static void Prefix(BaseAi __instance, float damage, ref float bleedOutMintues, DamageSource damageSource, string collider) { bleedOutMintues *= UnityEngine.Random.Range(0, 1f) + UnityEngine.Random.Range(0, 1f); BleedOutMintuesTmp = __instance.m_DeathAfterBleeingOutMinutes; //Implementation.Log($"BleedOutMintuesTmp: {BleedOutMintuesTmp}"); }
private static void FindInteractiveObject() { Debug.Log("FindInteractiveObject"); float maxRange = 2; int layerMask1 = 138383360; RaycastHit hitInfo; bool flag1 = Physics.Raycast(GameManager.GetMainCamera().transform.position, GameManager.GetMainCamera().transform.forward, out hitInfo, maxRange, layerMask1); Debug.Log("flag1 = " + flag1 + ", collision = " + (hitInfo.collider == null ? "null" : hitInfo.collider.name + ", " + hitInfo.collider.GetInstanceID())); if (!flag1) { flag1 = Physics.Raycast(GameManager.GetWeaponCamera().transform.position, GameManager.GetWeaponCamera().transform.forward, out hitInfo, maxRange, layerMask1); Debug.Log("flag1 = " + flag1 + ", collision = " + (hitInfo.collider == null ? "null" : hitInfo.collider.name)); if (flag1 && (UnityEngine.Object)Utils.GetTopParentWithLayer(hitInfo.collider.gameObject, 23) == (UnityEngine.Object)hitInfo.collider.gameObject) { flag1 = false; } } if (!flag1) { layerMask1 |= 16777216; flag1 = Physics.Raycast(GameManager.GetMainCamera().transform.position, GameManager.GetMainCamera().transform.forward, out hitInfo, maxRange, layerMask1); Debug.Log("flag1 = " + flag1 + ", collision = " + (hitInfo.collider == null ? "null" : hitInfo.collider.name)); } if (!flag1) { flag1 = Physics.Raycast(GameManager.GetWeaponCamera().transform.position, GameManager.GetWeaponCamera().transform.forward, out hitInfo, maxRange, layerMask1); Debug.Log("flag1 = " + flag1 + ", collision = " + (hitInfo.collider == null ? "null" : hitInfo.collider.name)); if (flag1 && (UnityEngine.Object)Utils.GetTopParentWithLayer(hitInfo.collider.gameObject, 23) == (UnityEngine.Object)hitInfo.collider.gameObject) { flag1 = false; } } if (!flag1) { Debug.Log("Exit 1: null"); return; } GameObject child1 = (GameObject)null; float distance = hitInfo.distance; GearItem gearItem = (GearItem)null; if (hitInfo.collider.gameObject.layer == 15) { if ((bool)((UnityEngine.Object)hitInfo.collider.transform.gameObject.GetComponent <Container>())) { child1 = hitInfo.collider.transform.gameObject.GetComponent <Container>().gameObject; } else { for (Transform parent = hitInfo.collider.transform.parent; (UnityEngine.Object)parent != (UnityEngine.Object)null; parent = parent.parent) { gearItem = parent.gameObject.GetComponent <GearItem>(); if ((UnityEngine.Object)gearItem != (UnityEngine.Object)null) { child1 = gearItem.gameObject; break; } } if ((UnityEngine.Object)child1 == (UnityEngine.Object)null) { Debug.Log("Exit2: null"); return; } } } else { child1 = hitInfo.transform.gameObject; gearItem = child1.GetComponent <GearItem>(); } //this.m_LocationOfLastInteractHit = hitInfo.point; if ((bool)((UnityEngine.Object)gearItem)) { if (gearItem.m_InPlayerInventory) { Debug.Log("Exit3: null"); return; } if (gearItem.m_NonInteractive) { Debug.Log("Exit4: null"); return; } } Rigidbody component1 = child1.GetComponent <Rigidbody>(); if ((UnityEngine.Object)component1 != (UnityEngine.Object)null) { if ((double)component1.velocity.sqrMagnitude > 25.0) { Debug.Log("Exit5: null"); return; } ArrowItem component2 = child1.GetComponent <ArrowItem>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && component2.InFlight(true)) { Debug.Log("Exit6: null"); return; } } int layerMask2 = (Utils.m_PhysicalCollisionLayerMask | 131072 | 1048576 | 134217728 | 16777216 | 32768) & -67108865; bool flag2 = Physics.Raycast(GameManager.GetMainCamera().transform.position, GameManager.GetMainCamera().transform.forward, out hitInfo, maxRange, layerMask2); if (!flag2) { flag2 = Physics.Raycast(GameManager.GetWeaponCamera().transform.position, GameManager.GetWeaponCamera().transform.forward, out hitInfo, maxRange, layerMask2); if (flag2 && (UnityEngine.Object)Utils.GetTopParentWithLayer(hitInfo.collider.gameObject, 23) == (UnityEngine.Object)hitInfo.collider.gameObject) { flag2 = false; } } if (!flag2) { Debug.Log("Exit7: null"); return; } if ((bool)((UnityEngine.Object)hitInfo.collider) && (bool)((UnityEngine.Object)hitInfo.transform.gameObject) && ((bool)((UnityEngine.Object)hitInfo.transform.gameObject.GetComponent <GearItem>()) && !hitInfo.transform.gameObject.GetComponent <GearItem>().m_InPlayerInventory) && child1.layer == 21) { child1 = hitInfo.transform.gameObject; } if ((double)hitInfo.distance > (double)distance) { Debug.Log("Exit8: " + Utils.GetTopParentWithLayer(child1, child1.layer)); return; } GameObject gameObject = hitInfo.transform.gameObject; if ((UnityEngine.Object)gameObject == (UnityEngine.Object)child1) { if (child1.layer == 27) { BaseAi componentInParent = child1.GetComponentInParent <BaseAi>(); if ((bool)((UnityEngine.Object)componentInParent)) { Debug.Log("Exit9: " + componentInParent.gameObject); return; } Debug.Log("Exit10: " + Utils.GetTopParentWithLayer(child1, child1.transform.parent.gameObject.layer)); return; } if (child1.layer != 18) { Debug.Log("Exit11: " + Utils.GetTopParentWithLayer(child1, child1.layer)); return; } for (int index = 0; index < child1.transform.childCount; ++index) { Transform child2 = child1.transform.GetChild(index); if ((UnityEngine.Object)child2 != (UnityEngine.Object)null && child2.gameObject.activeInHierarchy) { MeshCollider[] componentsInChildren = child2.GetComponentsInChildren <MeshCollider>(false); if (componentsInChildren != null && componentsInChildren.Length > 0) { Debug.Log("Exit12: null"); return; } } } Debug.Log("Exit13: " + Utils.GetTopParentWithLayer(child1, child1.layer)); return; } foreach (UnityEngine.Object componentsInChild in child1.GetComponentsInChildren <Transform>()) { if (componentsInChild == (UnityEngine.Object)gameObject.transform) { Debug.Log("Exit14: " + Utils.GetTopParentWithLayer(child1, child1.layer)); return; } } if (gameObject.gameObject.layer == 24) { Debug.Log("Exit15: " + Utils.GetTopParentWithLayer(child1, child1.layer)); return; } Debug.Log("Exit16: null"); return; }
private static void Postfix(BaseAi __instance, float realtimeSeconds) { float Minutes = GameManager.GetTimeOfDayComponent().GetTODMinutes(realtimeSeconds); Implementation.UpdateWounds(__instance, Minutes); }