public void AIActorMods(AIActor target) { if (!target.healthHaver.IsBoss) { if (target.GetAbsoluteParentRoom().area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS && (!target.IsHarmlessEnemy || target.EnemyGuid == EnemyGuidDatabase.Entries["mine_flayers_claymore"]) && target.GetAbsoluteParentRoom().IsSealed) { if (Owner.PlayerHasActiveSynergy("Frenemies")) { target.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null); target.IsHarmlessEnemy = true; } else { target.EraseFromExistenceWithRewards(true); } if (Owner.PlayerHasActiveSynergy("Dirty Tricks")) { List <AIActor> activeEnemies = target.GetAbsoluteParentRoom().GetActiveEnemies(RoomHandler.ActiveEnemyType.All); if (activeEnemies != null) { for (int i = 0; i < activeEnemies.Count; i++) { AIActor aiactor = activeEnemies[i]; if (aiactor.healthHaver.IsBoss) { aiactor.healthHaver.ApplyDamage(50, Vector2.zero, "Dirty Tricks", CoreDamageTypes.None, DamageCategory.Unstoppable, true, null, true); } } } } } } }
public void Start() { if (!m_Player) { m_Player = GameManager.Instance.PrimaryPlayer; } m_AIActor = aiActor; m_IntroDoer = gameObject.GetComponent <ExpandGungeoneerMimicIntroDoer>(); if (!m_AIActor | !m_Player) { Destroy(gameObject); return; } m_RandomRefresh = Random.Range(15, 30); m_RandomFireRate = Random.Range(0.4f, 0.8f); m_ParentRoom = m_AIActor.GetAbsoluteParentRoom(); if (m_StartingGuns != null && m_StartingGuns.Count > 0) { foreach (int GunID in m_StartingGuns) { ChangeOrAddGun(m_AIActor.aiShooter.Inventory, GunID); } } if (UseGlitchShader) { SetupPlayerGlitchShader(); } ; }
public override void PlayerWalkedIn(PlayerController player, List <tk2dSpriteAnimator> animators) { if (m_AIActor) { if (m_GungeoneerMimicController) { m_GungeoneerMimicController.m_Player = player; m_GungeoneerMimicController.Init(); } m_AIActor.GetAbsoluteParentRoom().CompletelyPreventLeaving = true; m_AIActor.ToggleRenderers(false); m_AIActor.IsGone = true; m_AIActor.State = AIActor.ActorState.Inactive; } DoInitialConfiguration(player); if (MirrorBase && MirrorBase.GetComponent <tk2dSprite>()) { MirrorBase.GetComponent <tk2dSprite>().HeightOffGround += 2f; MirrorBase.GetComponent <tk2dSprite>().UpdateZDepth(); } m_MirrorHasShattered = false; }
public override void OnEffectApplied(GameActor actor, RuntimeGameActorEffectData effectData, float partialAmount = 1) { base.OnEffectApplied(actor, effectData, partialAmount); effectData.OnActorPreDeath = delegate(Vector2 dir) { if (actor is AIActor) { AIActor aiActor = actor as AIActor; if (aiActor.GetAbsoluteParentRoom() == GameManager.Instance.GetActivePlayerClosestToPoint(actor.CenterPosition).CurrentRoom&& !aiActor.IgnoreForRoomClear && !noNoGUIDs.Contains(aiActor.EnemyGuid)) { Vector2 dirVec = UnityEngine.Random.insideUnitCircle; GameObject gameObject = SpawnManager.SpawnProjectile(((Gun)ETGMod.Databases.Items[39]).DefaultModule.projectiles[0].gameObject, actor.CenterPosition, Quaternion.Euler(0, 0, 0)); Projectile proj = gameObject.GetComponent <Projectile>(); if (proj != null) { proj.Owner = actor; proj.Shooter = aiActor.specRigidbody; proj.collidesWithEnemies = false; proj.collidesWithPlayer = true; proj.MakeLookLikeEnemyBullet(true); proj.gameObject.AddComponent <PierceDeadActors>(); PlayerController closestToPos = BraveUtility.GetClosestToPosition <PlayerController>(GameManager.Instance.AllPlayers.ToList(), aiActor.CenterPosition); if (closestToPos) { dirVec = closestToPos.CenterPosition - proj.transform.position.XY(); } proj.SendInDirection(dirVec, false, true); } } } }; actor.healthHaver.OnPreDeath += effectData.OnActorPreDeath; }
private IEnumerator EatEnemy(AIActor targetEnemy) { float elapsed = 0f; float duration = 0.5f; Vector3 startPos = targetEnemy.transform.position; Vector3 finalOffset = sprite.WorldCenter - startPos.XY(); tk2dSprite targetSprite = targetEnemy.GetComponentInChildren <tk2dSprite>(); if (targetEnemy.behaviorSpeculator) { targetEnemy.behaviorSpeculator.enabled = false; } RoomHandler m_ParentRoom = targetEnemy.GetAbsoluteParentRoom(); if (m_ParentRoom != null) { m_ParentRoom.DeregisterEnemy(targetEnemy); } // Destroy(targetEnemy); // Destroy(targetEnemy.specRigidbody); targetEnemy.specRigidbody.CollideWithOthers = false; spriteAnimator.PlayForDuration("baby_dragun_weak_eat", -1f, "baby_dragun_weak_idle", false); AkSoundEngine.PostEvent("Play_NPC_BabyDragun_Munch_01", gameObject); while (elapsed < duration) { elapsed += BraveTime.DeltaTime; if (!targetSprite || !targetSprite.transform) { m_currentlyEatingEnemy = false; yield break; } targetSprite.transform.localScale = Vector3.Lerp(Vector3.one, new Vector3(0.01f, 0.01f, 1f), elapsed / duration); targetSprite.transform.position = Vector3.Lerp(startPos, startPos + finalOffset, elapsed / duration); yield return(null); } if (!targetSprite || !targetSprite.transform) { m_currentlyEatingEnemy = false; yield break; } yield return(null); // Destroy(targetSprite.gameObject); m_ParentRoom.DeregisterEnemy(targetEnemy); targetEnemy.EraseFromExistence(true); m_enemiesEaten++; if (m_enemiesEaten >= RequiredEnemies) { while (spriteAnimator.IsPlaying("baby_dragun_weak_eat")) { yield return(null); } LootEngine.GivePrefabToPlayer(PickupObjectDatabase.GetById(ItemID).gameObject, GameManager.Instance.BestActivePlayer); Destroy(gameObject); } yield return(null); m_currentlyEatingEnemy = false; yield break; }
public override void PlayerWalkedIn(PlayerController player, List <tk2dSpriteAnimator> animators) { if (MirrorBase && MirrorBase.GetComponent <tk2dSprite>()) { MirrorBase.GetComponent <tk2dSprite>().HeightOffGround += 2f; MirrorBase.GetComponent <tk2dSprite>().UpdateZDepth(); } m_MirrorDepthUpdated = false; m_MirrorHasShattered = false; m_AIActor = aiActor; if (m_AIActor) { m_GungeoneerMimicController = m_AIActor.gameObject.GetComponent <ExpandGungeoneerMimicBossController>(); m_AIActor.GetAbsoluteParentRoom().CompletelyPreventLeaving = true; m_AIActor.ToggleRenderers(false); m_AIActor.aiShooter.handObject.gameObject.SetActive(false); m_AIActor.IsGone = true; m_AIActor.State = AIActor.ActorState.Inactive; } }
public override void OnEffectApplied(GameActor actor, RuntimeGameActorEffectData effectData, float partialAmount = 1) { base.OnEffectApplied(actor, effectData, partialAmount); try { effectData.OnActorPreDeath = delegate(Vector2 dir) { if (actor is AIActor) { AIActor aiActor = actor as AIActor; if (aiActor.GetAbsoluteParentRoom() == GameManager.Instance.GetRandomActivePlayer().CurrentRoom&& !aiActor.IgnoreForRoomClear && !noNoGUIDs.Contains(aiActor.EnemyGuid)) { GameManager.Instance.StartCoroutine(DelayedSpawnSpent(actor.CenterPosition)); } } }; actor.healthHaver.OnPreDeath += effectData.OnActorPreDeath; } catch (Exception e) { ETGModConsole.Log(e.ToString()); } }
private static IEnumerator ToilEnemyDupe(AIActor AIActor) { yield return(null); string guid = AIActor.EnemyGuid; var enemyPrefab = EnemyDatabase.GetOrLoadByGuid(guid); AIActor aiactor = AIActor.Spawn(enemyPrefab, AIActor.gameActor.CenterPosition.ToIntVector2(VectorConversions.Floor), AIActor.GetAbsoluteParentRoom(), true, AIActor.AwakenAnimationType.Default, true); HasBeenAffectedByCurrentChallenge challengitude = aiactor.gameObject.AddComponent <HasBeenAffectedByCurrentChallenge>(); challengitude.linkedOther = AIActor; HasBeenAffectedByCurrentChallenge challengitude2 = AIActor.gameObject.AddComponent <HasBeenAffectedByCurrentChallenge>(); challengitude2.linkedOther = aiactor; aiactor.procedurallyOutlined = true; AIActor.procedurallyOutlined = true; aiactor.IsWorthShootingAt = AIActor.IsWorthShootingAt; aiactor.IgnoreForRoomClear = AIActor.IgnoreForRoomClear; aiactor.AssignedCurrencyToDrop = AIActor.AssignedCurrencyToDrop; aiactor.AdditionalSafeItemDrops = AIActor.AdditionalSafeItemDrops; aiactor.AdditionalSimpleItemDrops = AIActor.AdditionalSimpleItemDrops; aiactor.CanTargetEnemies = AIActor.CanTargetEnemies; aiactor.CanTargetPlayers = AIActor.CanTargetPlayers; if (AIActor.IsInReinforcementLayer) { aiactor.HandleReinforcementFallIntoRoom(0f); } if (AIActor.GetComponent <KillOnRoomClear>() != null) { KillOnRoomClear kill = aiactor.gameObject.GetOrAddComponent <KillOnRoomClear>(); kill.overrideDeathAnim = AIActor.GetComponent <KillOnRoomClear>().overrideDeathAnim; kill.preventExplodeOnDeath = AIActor.GetComponent <KillOnRoomClear>().preventExplodeOnDeath; } if (aiactor.EnemyGuid == "22fc2c2c45fb47cf9fb5f7b043a70122") { aiactor.CollisionDamage = 0f; aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.PlayerHitBox)); aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.Projectile)); } else if (aiactor.EnemyGuid == "249db525a9464e5282d02162c88e0357") { if (aiactor.gameObject.GetComponent <SpawnEnemyOnDeath>()) { UnityEngine.Object.Destroy(aiactor.gameObject.GetComponent <SpawnEnemyOnDeath>()); } } else if (EasyEnemyTypeLists.VanillaMimics.Contains(aiactor.EnemyGuid)) { if (AIActor.AdditionalSafeItemDrops != null && aiactor.AdditionalSafeItemDrops != null) { List <PickupObject> newDrops = new List <PickupObject>(); PickupObject.ItemQuality qual = PickupObject.ItemQuality.D; int itemsToReAdd = 0; for (int i = (aiactor.AdditionalSafeItemDrops.Count - 1); i >= 0; i--) { if (!BabyGoodChanceKin.lootIDlist.Contains(aiactor.AdditionalSafeItemDrops[i].PickupObjectId)) { qual = aiactor.AdditionalSafeItemDrops[i].quality; itemsToReAdd++; } else { newDrops.Add(PickupObjectDatabase.GetById(aiactor.AdditionalSafeItemDrops[i].PickupObjectId)); } } if (itemsToReAdd > 0) { for (int i = 0; i < itemsToReAdd; i++) { PickupObject item = LootEngine.GetItemOfTypeAndQuality <PassiveItem>(qual, null, false); if (UnityEngine.Random.value <= 0.5f) { item = LootEngine.GetItemOfTypeAndQuality <Gun>(qual, null, false); } newDrops.Add(item); } aiactor.AdditionalSafeItemDrops = newDrops; } } } GameManager.Instance.StartCoroutine(Shrimk(aiactor)); GameManager.Instance.StartCoroutine(Shrimk(AIActor)); aiactor.specRigidbody.Reinitialize(); yield break; }
public static void AIActorPostSpawn(AIActor AIActor) { if (CurrentChallenge == ChallengeType.WHAT_ARMY) { bool isParachuting = (AIActor.gameObject.transform.parent != null && AIActor.gameObject.transform.parent.gameObject.name.Contains("EX_Parachute")); if (AIActor && AIActor.healthHaver && !AIActor.healthHaver.IsBoss && !AIActor.healthHaver.IsSubboss && !AIActor.IsSecretlyTheMineFlayer()) { if (AIActor.gameObject.GetComponent <HasBeenAffectedByCurrentChallenge>() == null && AIActor.gameObject.GetComponent <CompanionController>() == null && !isParachuting) { float proc = 1; if (AIActor.GetAbsoluteParentRoom().area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS && AIActor.GetAbsoluteParentRoom().RoomContainsMineFlayer()) { proc = 0.2f; } if (UnityEngine.Random.value <= proc) { List <string> ChaosPalette = GenerateChaosPalette(); string guid = BraveUtility.RandomElement(ChaosPalette); var enemyPrefab = EnemyDatabase.GetOrLoadByGuid(guid); AIActor aiactor = AIActor.Spawn(enemyPrefab, AIActor.gameActor.CenterPosition.ToIntVector2(VectorConversions.Floor), AIActor.GetAbsoluteParentRoom(), true, AIActor.AwakenAnimationType.Default, true); aiactor.gameObject.AddComponent <HasBeenAffectedByCurrentChallenge>(); aiactor.AssignedCurrencyToDrop = AIActor.AssignedCurrencyToDrop; aiactor.AdditionalSafeItemDrops = AIActor.AdditionalSafeItemDrops; aiactor.AdditionalSimpleItemDrops = AIActor.AdditionalSimpleItemDrops; aiactor.CanTargetEnemies = AIActor.CanTargetEnemies; aiactor.CanTargetPlayers = AIActor.CanTargetPlayers; if (aiactor.EnemyGuid == "556e9f2a10f9411cb9dbfd61e0e0f1e1") { aiactor.HandleReinforcementFallIntoRoom(0f); } else if (AIActor.IsInReinforcementLayer) { aiactor.invisibleUntilAwaken = true; aiactor.specRigidbody.CollideWithOthers = false; aiactor.IsGone = true; aiactor.HandleReinforcementFallIntoRoom(0f); } if (aiactor.EnemyGuid == "22fc2c2c45fb47cf9fb5f7b043a70122") { aiactor.CollisionDamage = 0f; } if (AIActor.GetComponent <ExplodeOnDeath>() != null) { UnityEngine.Object.Destroy(AIActor.GetComponent <ExplodeOnDeath>()); } AIActor.EraseFromExistence(true); } } } } else if (CurrentChallenge == ChallengeType.TOIL_AND_TROUBLE) { if (AIActor && AIActor.healthHaver && !AIActor.healthHaver.IsBoss && !AIActor.healthHaver.IsSubboss && !AIActor.IsSecretlyTheMineFlayer()) { if (AIActor.GetComponent <CompanionController>() == null && AIActor.GetComponent <HasBeenAffectedByCurrentChallenge>() == null && AIActor.GetComponent <DisplacedImageController>() == null && AIActor.GetComponent <WitchsBrew.HasBeenDoubledByWitchsBrew>() == null && AIActor.GetComponent <MirrorImageController>() == null) { GameManager.Instance.StartCoroutine(ToilEnemyDupe(AIActor)); } } else if (AIActor && AIActor.healthHaver && (AIActor.healthHaver.IsBoss || AIActor.healthHaver.IsSubboss) && !AIActor.IsSecretlyTheMineFlayer()) { if (AIActor.GetComponent <HasBeenAffectedByCurrentChallenge>() == null) { if (ValidDoubleableBosses.Contains(AIActor.EnemyGuid)) { string guid = AIActor.EnemyGuid; var enemyPrefab = EnemyDatabase.GetOrLoadByGuid(guid); AIActor aiactor = AIActor.Spawn(enemyPrefab, AIActor.gameActor.CenterPosition.ToIntVector2(VectorConversions.Floor), AIActor.GetAbsoluteParentRoom(), true, AIActor.AwakenAnimationType.Default, true); HasBeenAffectedByCurrentChallenge challengitude = aiactor.gameObject.AddComponent <HasBeenAffectedByCurrentChallenge>(); challengitude.linkedOther = AIActor; HasBeenAffectedByCurrentChallenge challengitude2 = AIActor.gameObject.AddComponent <HasBeenAffectedByCurrentChallenge>(); challengitude2.linkedOther = aiactor; aiactor.AssignedCurrencyToDrop = AIActor.AssignedCurrencyToDrop; aiactor.AdditionalSafeItemDrops = AIActor.AdditionalSafeItemDrops; aiactor.AdditionalSimpleItemDrops = AIActor.AdditionalSimpleItemDrops; if (AIActor.GetComponent <BroController>()) { aiactor.gameObject.GetOrAddComponent <BroController>(); } float actorOrigHP = AIActor.healthHaver.GetMaxHealth(); float actorNewHP = aiactor.healthHaver.GetMaxHealth(); AIActor.healthHaver.SetHealthMaximum(actorOrigHP * 0.5f); AIActor.healthHaver.ForceSetCurrentHealth(actorOrigHP * 0.5f); aiactor.healthHaver.SetHealthMaximum(actorNewHP * 0.5f); aiactor.healthHaver.ForceSetCurrentHealth(actorNewHP * 0.5f); } else { float actorHP = AIActor.healthHaver.GetMaxHealth(); AIActor.healthHaver.SetHealthMaximum(actorHP * 1.5f); AIActor.healthHaver.ForceSetCurrentHealth(actorHP * 1.5f); } } } } }
private void LateUpdate() { if (m_IsDisconnected) { return; } if (!m_IntroDoer.m_finished | !IntroDone | m_AIActor.healthHaver.IsDead) { return; } m_RandomRefresh -= BraveTime.DeltaTime; if (m_DelayedActive && !m_IsPathfindingToCenter) { if (m_ParentRoom != null) { Vector2 RoomCenterPosition = m_ParentRoom.area.UnitCenter; float MaxDistanceFromCenterX = (m_ParentRoom.area.dimensions.x / 2f); float MaxDistanceFromCenterY = (m_ParentRoom.area.dimensions.y / 2f); Vector2 CurrentPosition = m_AIActor.gameObject.transform.position; if (Vector2.Distance(CurrentPosition, RoomCenterPosition) > MaxDistanceFromCenterX | Vector2.Distance(CurrentPosition, RoomCenterPosition) > MaxDistanceFromCenterY) { m_IsPathfindingToCenter = true; StartCoroutine(PathBackToCenter(m_AIActor, RoomCenterPosition)); } } } if (m_DelayedActive) { if (EnableFallBackAttacks && m_RandomRefresh <= 0) { if (m_MirrorGunToggle) { m_MirrorGunToggle = false; m_RandomRefresh = Random.Range(15, 30); } else { m_MirrorGunToggle = true; m_RandomRefresh = Random.Range(10, 18); } } if (m_BeamSweepingBack) { m_BeamSweepAngle -= (BraveTime.DeltaTime * 30); if (m_BeamSweepAngle <= 0) { m_BeamSweepingBack = false; if (!m_InvertSweepAngle) { m_InvertSweepAngle = true; } else if (m_InvertSweepAngle) { m_InvertSweepAngle = false; } } } else { m_BeamSweepAngle += (BraveTime.DeltaTime * 30); if (m_BeamSweepAngle >= 15) { m_BeamSweepingBack = true; } } } if (m_DelayedActive && m_Player && m_Player.GetAbsoluteParentRoom() != null && m_AIActor.GetAbsoluteParentRoom() != null && m_Player.GetAbsoluteParentRoom() == m_AIActor.GetAbsoluteParentRoom()) { bool m_MovementStutter = false; if (!m_AIActor.BehaviorOverridesVelocity && !m_IsPathfindingToCenter) { m_AIActor.BehaviorOverridesVelocity = true; } if (!m_IsPathfindingToCenter && UsesRotationInsteadOfInversion) { if (!m_MirrorGunToggle) { if (Random.value <= 0.995f) { m_MovementStutter = true; } } if (!m_MovementStutter) { if (m_MirrorGunToggle) { m_AIActor.BehaviorVelocity = (Quaternion.Euler(0f, 0f, RotationAngle) * m_AIActor.TargetRigidbody.Velocity).XY(); } else { Vector2 m_CurrentVector = (Quaternion.Euler(0f, 0f, RotationAngle) * m_AIActor.TargetRigidbody.Velocity).XY(); float Div = 1.1f; if (GameManager.IsTurboMode) { Div = 1.25f; } float X = (m_CurrentVector.x / Div); float Y = (m_CurrentVector.y / Div); m_AIActor.BehaviorVelocity = new Vector2(X, Y); } } } else if (!m_IsPathfindingToCenter) { if (!m_MirrorGunToggle) { if (Random.value <= 0.995f) { m_MovementStutter = true; } } if (!m_MovementStutter) { if (m_MirrorGunToggle) { m_AIActor.BehaviorVelocity = (m_AIActor.TargetRigidbody.Velocity * -1f); } else { Vector2 m_CurrentVector = (m_AIActor.TargetRigidbody.Velocity * -1f); float Div = 1.1f; if (GameManager.IsTurboMode) { Div = 1.25f; } float X = (m_CurrentVector.x / Div); float Y = (m_CurrentVector.y / Div); m_AIActor.BehaviorVelocity = m_CurrentVector; } } } } }