private void OnHitEnemy(Projectile proj, SpeculativeRigidbody hitRigidBody, bool fatal) { if (proj) { proj.baseData.force = 0f; } AIActor aiActor = hitRigidBody.aiActor; KnockbackDoer knockbackDoer = hitRigidBody.knockbackDoer; if (aiActor) { if (aiActor.GetComponent <ExplodeOnDeath>()) { UnityEngine.Object.Destroy(aiActor.GetComponent <ExplodeOnDeath>()); } hitRigidBody.AddCollisionLayerOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox)); hitRigidBody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Combine(hitRigidBody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.HandleHitEnemyHitEnemy)); } if (knockbackDoer && proj) { float num = -1f; AIActor nearestEnemyInDirection = aiActor.ParentRoom.GetNearestEnemyInDirection(aiActor.CenterPosition, proj.Direction, this.AngleTolerance, out num, true); Vector2 direction = proj.Direction; if (nearestEnemyInDirection) { direction = nearestEnemyInDirection.CenterPosition - aiActor.CenterPosition; } knockbackDoer.ApplyKnockback(direction, this.KnockbackForce, true); } }
public static void SetupEntry(this AIActor enemy, string shortDesc, string longDesc, string portrait, string AmmonomiconSprite, string EnemyName) { SpriteBuilder.AddSpriteToCollection(AmmonomiconSprite, ammonomiconCollection); if (enemy.GetComponent <EncounterTrackable>() != null) { UnityEngine.Object.Destroy(enemy.GetComponent <EncounterTrackable>()); } enemy.encounterTrackable = enemy.gameObject.AddComponent <EncounterTrackable>(); enemy.encounterTrackable.journalData = new JournalEntry(); enemy.encounterTrackable.EncounterGuid = enemy.EnemyGuid; enemy.encounterTrackable.prerequisites = new DungeonPrerequisite[0]; enemy.encounterTrackable.journalData.SuppressKnownState = false; enemy.encounterTrackable.journalData.IsEnemy = true; enemy.encounterTrackable.journalData.SuppressInAmmonomicon = false; enemy.encounterTrackable.journalData.AmmonomiconSprite = AmmonomiconSprite; enemy.encounterTrackable.journalData.enemyPortraitSprite = ResourceExtractor.GetTextureFromResource(portrait + ".png"); enemy.encounterTrackable.ProxyEncounterGuid = ""; Strings.Enemies.Set("#" + EnemyName.ToUpper(), EnemyName); Strings.Enemies.Set("#" + shortDesc.ToUpper(), shortDesc); Strings.Enemies.Set("#" + longDesc.ToUpper(), longDesc); enemy.encounterTrackable.journalData.PrimaryDisplayName = "#" + EnemyName.ToUpper(); enemy.encounterTrackable.journalData.NotificationPanelDescription = "#" + shortDesc.ToUpper(); enemy.encounterTrackable.journalData.AmmonomiconFullEntry = "#" + longDesc.ToUpper(); enemy.encounterTrackable.journalData.SuppressKnownState = false; }
public static void Dismount(this AIActor self) { if (self.GetComponent <MountedBehaviour>() != null) { UnityEngine.Object.Destroy(self.GetComponent <MountedBehaviour>()); } }
public void AIActorMods(AIActor target) { if (target && target.healthHaver && !target.healthHaver.IsBoss && !target.healthHaver.IsSubboss && !target.IsSecretlyTheMineFlayer()) { if (target.GetComponent <CompanionController>() == null && target.GetComponent <HasBeenDoubledByWitchsBrew>() == null && target.GetComponent <DisplacedImageController>() == null && target.GetComponent <MirrorImageController>() == null) { if (target.EnemyGuid != "22fc2c2c45fb47cf9fb5f7b043a70122") { StartCoroutine(ToilEnemyDupe(target)); } } } }
public void EnemyScale(AIActor aiActor, Vector2 ScaleVector) { aiActor.transform.localScale = ScaleVector.ToVector3ZUp(1f); aiActor.HasShadow = false; // aiActor.CorpseObject.transform.localScale = actorSize.ToVector3ZUp(1f); int cachedLayer = aiActor.gameObject.layer; int cachedOutlineLayer = cachedLayer; aiActor.gameObject.layer = LayerMask.NameToLayer("Unpixelated"); cachedOutlineLayer = SpriteOutlineManager.ChangeOutlineLayer(aiActor.sprite, LayerMask.NameToLayer("Unpixelated")); if (aiActor.specRigidbody) { SpeculativeRigidbody specRigidbody = aiActor.GetComponent <SpeculativeRigidbody>(); // if (specRigidbody == null) { return; } specRigidbody.transform.localScale = ScaleVector.ToVector3ZUp(1f); for (int i = 0; i < specRigidbody.PixelColliders.Count; i++) { specRigidbody.PixelColliders[i].Regenerate(specRigidbody.transform, true, true); } specRigidbody.UpdateCollidersOnScale = true; specRigidbody.RegenerateColliders = true; specRigidbody.ForceRegenerate(true, true); specRigidbody.RegenerateCache(); } ChaosUtility.CorrectForWalls(aiActor); // aiActor.procedurallyOutlined = true; // aiActor.SetOutlines(true); }
private void HandleSpawn(AIActor spawnedActor) { if (!IsGlitchedLJ) { if (!string.IsNullOrEmpty(spawnAnim)) { spawnedActor.aiAnimator.PlayUntilFinished(spawnAnim, false, null, -1f, false); } } if (!IsGlitchedLJ) { ChaosSpawnGlitchEnemyOnDeath component = spawnedActor.GetComponent <ChaosSpawnGlitchEnemyOnDeath>(); if (component) { component.guaranteedSpawnGenerations = Mathf.Max(0f, guaranteedSpawnGenerations - 1f); } } if (!spawnsCanDropLoot) { spawnedActor.CanDropCurrency = false; spawnedActor.CanDropItems = false; } if (DoNormalReinforcement) { spawnedActor.HandleReinforcementFallIntoRoom(0.1f); } }
public static GameObject ReinstateBossObjectInfo(GameObject bossobject) { //After removing boss intro, need to reinstate behavior to have it active, awake and have specbody. //otherwise they stand there and don't take damage //this method also handles specific bosses bossobject = ReinstateAIActorObjectInfo(bossobject); AIActor bosscomponent = bossobject.GetComponent <AIActor>(); if (bosscomponent) { if (bosscomponent.EnemyGuid == "05b8afe0b6cc4fffa9dc6036fa24c8ec" | bosscomponent.EnemyGuid == "465da2bb086a4a88a803f79fe3a27677" | bosscomponent.EnemyGuid == "880bbe4ce1014740ba6b4e2ea521e49d" | bosscomponent.EnemyGuid == "b98b10fca77d469e80fb45f3c5badec5" | bosscomponent.EnemyGuid == "8b913eea3d174184be1af362d441910d" | bosscomponent.EnemyGuid == "8d441ad4e9924d91b6070d5b3438d066" | bosscomponent.EnemyGuid == "dc3cd41623d447aeba77c77c99598426") // advancedDragun | dragun | Last Human | Hyperion | Baldy | Frankenstein | InterdimensionalHorror {//need this to be able to shoot boss ObjectVisibilityManager objectvisibilitymanager = bosscomponent.GetComponent <ObjectVisibilityManager>(); objectvisibilitymanager.SuppressPlayerEnteredRoom = false; } if (bosscomponent.EnemyGuid == "2ccaa1b7ae10457396a1796decda9cf6") // agunim { bosscomponent.healthHaver.OnlyAllowSpecialBossDamage = false; } } return(bossobject); }
public static void On(string[] notused) { RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom; List <AIActor> activeenemies_typeall = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All); for (int e = 0; e < activeenemies_typeall.Count; e++) { AIActor enemy = activeenemies_typeall[e]; AIActor objectToInstantiate = activeenemies_typeall[e]; SpeculativeRigidbody custom_component = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); enemy.State = AIActor.ActorState.Normal; enemy.HasBeenEngaged = true; //if (custom_component != null) //{ // //ETGModConsole.Log("Turing On SpeculativeRigidBody"); // //custom_component.HitboxPixelCollider.IsTrigger = false; // //custom_component.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.Projectile)); // //enemy.IsNormalEnemy = true; // //custom_component.RemoveCollisionLayerOverride(CollisionMask.LayerToMask(CollisionLayer.Projectile)); //} } }
public void unhook() { if (Hooked_enemy != null) { Destroy(Hooked_enemy.GetComponent <ArbitraryCableDrawer>()); Hooked_enemy = null; } }
private void PickNewTarget() { if (this.m_aiActor != null) { if (this.Owner == null) { if (this.m_aiActor && this.m_aiActor.CompanionOwner) { Owner = this.m_aiActor.CompanionOwner; } else { Owner = GameManager.Instance.BestActivePlayer; } } this.Owner.CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear, ref this.roomEnemies); for (int i = 0; i < this.roomEnemies.Count; i++) { AIActor aiactor = this.roomEnemies[i]; if (aiactor.IsHarmlessEnemy || !aiactor.IsNormalEnemy || aiactor.healthHaver.IsDead || aiactor == this.m_aiActor || aiactor.EnemyGuid == "ba928393c8ed47819c2c5f593100a5bc") { this.roomEnemies.Remove(aiactor); } if (aiactor.GetComponent <ChromaGun.ChromaGunColoured>() == null) { this.roomEnemies.Remove(aiactor); } else if (aiactor.GetComponent <ChromaGun.ChromaGunColoured>().ColourType != droneColour) { this.roomEnemies.Remove(aiactor); } } if (this.roomEnemies.Count == 0) { this.m_aiActor.OverrideTarget = null; } else { AIActor aiActor = this.m_aiActor; AIActor aiactor2 = this.roomEnemies[UnityEngine.Random.Range(0, this.roomEnemies.Count)]; aiActor.OverrideTarget = ((aiactor2 != null) ? aiactor2.specRigidbody : null); } } }
{// this is the main class that handles the manipulation of all AIActor components public static GameObject HandleCompanions(GameObject enemyobject) { AIActor component = enemyobject.GetComponent <AIActor>(); component.IsNormalEnemy = true; component.healthHaver.SetHealthMaximum(15f); UnityEngine.Object.Destroy(component.GetComponent <CompanionController>()); return(enemyobject); }
public override void OnEffectApplied(GameActor actor, RuntimeGameActorEffectData effectData, float partialAmount = 1) { base.OnEffectApplied(actor, effectData, partialAmount); AIActor Grenade = EnemyDatabase.GetOrLoadByGuid("4d37ce3d666b4ddda8039929225b7ede"); ExplodeOnDeath DoYouWantToExplode = actor.gameObject.AddComponent <ExplodeOnDeath>(); ExplosionData explosionData = Grenade.GetComponent <ExplodeOnDeath>().explosionData; explosionData.damageToPlayer = 0; DoYouWantToExplode.explosionData = explosionData; }
protected override void DoEffect(PlayerController user) { AkSoundEngine.PostEvent("Play_OBJ_dead_again_01", base.gameObject); for (int i = 0; i < StaticReferenceManager.AllCorpses.Count; i++) { GameObject gameObject = StaticReferenceManager.AllCorpses[i]; if (gameObject && gameObject.GetComponent <tk2dBaseSprite>() && gameObject.transform.position.GetAbsoluteRoom() == user.CurrentRoom && gameObject.transform.position.GetAbsoluteRoom().IsSealed) { Vector2 worldCenter = gameObject.GetComponent <tk2dBaseSprite>().WorldCenter; string guid = "249db525a9464e5282d02162c88e0357"; if (user.PlayerHasActiveSynergy("Roll Dem Bones") && UnityEngine.Random.value <= 0.25f) { guid = "336190e29e8a4f75ab7486595b700d4a"; } AIActor Spent = CompanionisedEnemyUtility.SpawnCompanionisedEnemy(user, guid, worldCenter.ToIntVector2(), true, ExtendedColours.purple, 5, 2, false, true); if (Spent.GetComponent <SpawnEnemyOnDeath>()) { UnityEngine.Object.Destroy(Spent.GetComponent <SpawnEnemyOnDeath>()); } if (Spent.CorpseObject != null) { Spent.CorpseObject = null; } if (guid == "249db525a9464e5282d02162c88e0357") { Spent.OverrideHitEnemies = true; Spent.CollisionDamage = 1f; Spent.CollisionDamageTypes |= CoreDamageTypes.Electric; } if (user.PlayerHasActiveSynergy("The Sprinting Dead")) { Spent.MovementSpeed *= 2; } UnityEngine.Object.Destroy(gameObject.gameObject); } } }
private void MakeEnemyNPC(AIActor enemy) { HandleSpawnLoot(enemy); var CurrentRoom = enemy.transform.position.GetAbsoluteRoom(); UnityEngine.Object.Instantiate <GameObject>(EasyVFXDatabase.GundetaleSpareVFX, (enemy.sprite.WorldTopCenter + new Vector2(0, 0.25f)), Quaternion.identity); if (enemy.GetComponent <KillOnRoomUnseal>()) { UnityEngine.Object.Destroy(enemy.GetComponent <KillOnRoomUnseal>()); } CurrentRoom.DeregisterEnemy(enemy); CustomEnemyTagsSystem tags = enemy.gameObject.GetOrAddComponent <CustomEnemyTagsSystem>(); enemy.gameActor.DeleteOwnedBullets(); if (tags != null) { tags.isGundertaleFriendly = true; } if (enemy.specRigidbody) { UnityEngine.Object.Destroy(enemy.specRigidbody); } if (enemy.behaviorSpeculator) { UnityEngine.Object.Destroy(enemy.behaviorSpeculator); } if (enemy.healthHaver) { enemy.healthHaver.IsVulnerable = false; enemy.healthHaver.bossHealthBar = HealthHaver.BossBarType.None; enemy.healthHaver.EndBossState(false); } if (enemy.aiAnimator) { enemy.aiAnimator.PlayUntilCancelled("idle", false, null, -1f, false); } //GameUIBossHealthController bossUI = enemy.GetComponent<GameUIBossHealthController>() }
protected void ActivateDeath(AIActor randomActiveEnemy) { if (randomActiveEnemy && randomActiveEnemy.behaviorSpeculator) { randomActiveEnemy.PlayEffectOnActor(ResourceCache.Acquire("Global VFX/VFX_Curse") as GameObject, Vector3.zero, false, false, false); SpawnEnemyOnDeath component = randomActiveEnemy.GetComponent <SpawnEnemyOnDeath>(); if (component) { UnityEngine.Object.Destroy(component); } randomActiveEnemy.healthHaver.minimumHealth = 0f; randomActiveEnemy.healthHaver.ApplyDamage(10000f, Vector2.zero, "Cursed", CoreDamageTypes.None, DamageCategory.Unstoppable, true, null, false); } }
private void ProcessGunShader(AIActor g) { MeshRenderer component = g.GetComponent <MeshRenderer>(); if (!component) { return; } this.m_glintShader = Shader.Find("Brave/Internal/RainbowChestShader"); Material[] sharedMaterials = component.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (sharedMaterials[i].shader == this.m_glintShader) { return; } } Array.Resize <Material>(ref sharedMaterials, sharedMaterials.Length + 1); Material material = new Material(this.m_glintShader); material.SetFloat("_AllColorsToggle", 1f); material.SetTexture("_MainTex", sharedMaterials[0].GetTexture("_MainTex")); sharedMaterials[sharedMaterials.Length - 1] = material; component.sharedMaterials = sharedMaterials; sprite.renderer.material.shader = ShaderCache.Acquire("Brave/Internal/RainbowChestShader"); sprite.usesOverrideMaterial = true; MeshRenderer component2 = g.CorpseObject.GetComponent <MeshRenderer>(); if (!component2) { return; } for (int i = 0; i < sharedMaterials.Length; i++) { if (sharedMaterials[i].shader == this.m_glintShader) { return; } } Array.Resize <Material>(ref sharedMaterials, sharedMaterials.Length + 1); material.SetFloat("_AllColorsToggle", 1f); material.SetTexture("_MainTex", sharedMaterials[0].GetTexture("_MainTex")); sharedMaterials[sharedMaterials.Length - 1] = material; component2.sharedMaterials = sharedMaterials; sprite.renderer.material.shader = ShaderCache.Acquire("Brave/Internal/RainbowChestShader"); sprite.usesOverrideMaterial = true; return; }
public static void RoomStats2(string[] notused) { RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom; List <AIActor> activeenemies_typeall = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All); List <AIActor> activeenemies_typeroomclear = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear); ETGModConsole.Log(""); ETGModConsole.Log(string.Format("Current Room: {0}", currentRoom.GetRoomName())); //ETGModConsole.Log("ActorName: {0}, IsVulnerable: {1}, CurrentHealth: {2}, IsHarmlessEnemy: {3}, activeenabled: {4}, PreventAllDamage: {5}, " + // "CanBeKilled: {6}, FlashesOnDamage: {7}, IsNormalEnemy: {8}"); ETGModConsole.Log(" {0}:Guid, {1}:IsVulnerable, {2}:health, {3}:IsHarmlessEnemy, {4}:specialbossdamage, {5}:PreventAllDamage, " + "{6}:awoken, {7}:engaged, {8}:IsNormalEnemy, {9} cancurrentlybekilled"); for (int e = 0; e < activeenemies_typeall.Count; e++) { AIActor enemy = activeenemies_typeall[e]; bool vulnerable = enemy.healthHaver.IsVulnerable; float health = enemy.healthHaver.GetCurrentHealth(); bool isharmlessenemy = enemy.IsHarmlessEnemy; bool isbuffenemy = enemy.IsBuffEnemy; bool activeenabled = enemy.isActiveAndEnabled; bool preventalldamage = enemy.healthHaver.PreventAllDamage; bool flash = enemy.healthHaver.flashesOnDamage; bool awoken = enemy.HasBeenAwoken; bool engaged = enemy.HasBeenEngaged; bool playerentered = enemy.HasDonePlayerEnterCheck; bool specialbossdamage = enemy.healthHaver.OnlyAllowSpecialBossDamage; bool cancurrentlybekilled = enemy.healthHaver.CanCurrentlyBeKilled; //ETGModConsole.Log(string.Format("0{0}, 1{1}, 2{2}, 3{3}, 4{4}, 5{5}, 6{6}, 7{7}, 8{8} ", // enemy.GetActorName(), vulnerable.ToString(), health.ToString(), isharmlessenemy.ToString(), activeenabled.ToString(), preventalldamage.ToString(), // enemy.healthHaver.CanCurrentlyBeKilled.ToString(), flash.ToString(), enemy.IsNormalEnemy.ToString())); GenericIntroDoer genericIntroDoer = enemy.GetComponent <GenericIntroDoer>(); ETGModConsole.Log(string.Format("0{0}, 1{1}, 2{2}, 3{3}, 4{4}, 5{5}, 6{6}, 7{7}, 8{8}, 9{9} ", enemy.EnemyGuid, vulnerable.ToString(), health.ToString(), isharmlessenemy.ToString(), specialbossdamage.ToString(), preventalldamage.ToString(), awoken.ToString(), engaged.ToString(), enemy.IsNormalEnemy.ToString(), cancurrentlybekilled)); } }
public static void CollidesWithProjectiles(string[] notused) { RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom; List <AIActor> activeenemies_typeall = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All); for (int e = 0; e < activeenemies_typeall.Count; e++) { AIActor enemy = activeenemies_typeall[e]; AIActor objectToInstantiate = activeenemies_typeall[e]; SpeculativeRigidbody custom_component = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); ETGModConsole.Log(string.Format("Enemy: {0}, IsValid {1}: ", enemy.ActorName, enemy.IsValid.ToString())); //if (custom_component != null) //{ // ETGModConsole.Log("Has SpeculativeRigidBody"); // ETGModConsole.Log(string.Format("Enemy: {0}, Can Collide with others {1}: ", enemy.ActorName, custom_component.CollideWithOthers)); // List<PixelCollider> pixelColliders = custom_component.PixelColliders; // for (int i = 0; i < pixelColliders.Count; i++) // { // PixelCollider pixelCollider = pixelColliders[i]; // ETGModConsole.Log(string.Format("Enemy: {0}, pixelColliderEnabled {1}: ", enemy.ActorName, pixelCollider.Enabled.ToString())); // if ((CollisionLayerMatrix.GetMask(pixelCollider.CollisionLayer) & CollisionMask.LayerToMask(CollisionLayer.Projectile)) == CollisionMask.LayerToMask(CollisionLayer.Projectile)) // { // ETGModConsole.Log("Can be hit by projectiles"); // } // else if ((pixelCollider.CollisionLayerCollidableOverride & CollisionMask.LayerToMask(CollisionLayer.Projectile)) == CollisionMask.LayerToMask(CollisionLayer.Projectile)) // { // ETGModConsole.Log("Can be hit by projectiles2"); // } // else // { // ETGModConsole.Log("Can Not be hit by projectiles"); // } // } // //custom_component.RemoveCollisionLayerOverride(CollisionMask.LayerToMask(CollisionLayer.Projectile)); //} } }
private void EnemyModRandomizer(AIActor targetActor) { if (string.IsNullOrEmpty(targetActor.EnemyGuid)) { return; } if (GameManager.Instance.Dungeon.IsGlitchDungeon && !targetActor.IsBlackPhantom && !string.IsNullOrEmpty(targetActor.EnemyGuid)) { if (UnityEngine.Random.value <= 0.3 && targetActor.healthHaver != null && !ExpandLists.DontGlitchMeList.Contains(targetActor.EnemyGuid) && !ExpandLists.blobsAndCritters.Contains(targetActor.EnemyGuid) && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4") { if (!targetActor.healthHaver.IsBoss && !targetActor.sprite.usesOverrideMaterial && targetActor.optionalPalette == null) { float RandomIntervalFloat = UnityEngine.Random.Range(0.02f, 0.06f); float RandomDispFloat = UnityEngine.Random.Range(0.1f, 0.16f); float RandomDispIntensityFloat = UnityEngine.Random.Range(0.1f, 0.4f); float RandomColorProbFloat = UnityEngine.Random.Range(0.05f, 0.2f); float RnadomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f); ExpandShaders.Instance.BecomeGlitched(targetActor, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RnadomColorIntensityFloat); if (targetActor.GetComponent <ExpandSpawnGlitchObjectOnDeath>() == null) { if (UnityEngine.Random.value <= 0.25) { targetActor.gameObject.AddComponent <ExpandSpawnGlitchObjectOnDeath>(); } } ExpandGlitchedEnemies.GlitchExistingEnemy(targetActor); if (UnityEngine.Random.value <= 0.1f && targetActor.EnemyGuid != "4d37ce3d666b4ddda8039929225b7ede" && targetActor.EnemyGuid != "19b420dec96d4e9ea4aebc3398c0ba7a" && targetActor.GetComponent <ExplodeOnDeath>() == null && targetActor.GetComponent <ExpandSpawnGlitchObjectOnDeath>() == null && targetActor.GetComponent <ExpandSpawnGlitchEnemyOnDeath>() == null) { try { targetActor.gameObject.AddComponent <ExpandExplodeOnDeath>(); } catch (Exception) { } } } } return; } }
private void KillAllEnemies() { RoomHandler currentRoom = GameManager.Instance.BestActivePlayer.CurrentRoom; currentRoom.ClearReinforcementLayers(); List <AIActor> activeEnemies = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All); if (activeEnemies != null) { List <AIActor> list = new List <AIActor>(activeEnemies); for (int i = 0; i < list.Count; i++) { AIActor aiactor = list[i]; { if (!aiactor.healthHaver.IsBoss) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemyDeath(aiactor)); SpawnEnemyOnDeath component = aiactor.GetComponent <SpawnEnemyOnDeath>(); if (component) { UnityEngine.Object.Destroy(component); } aiactor.healthHaver.minimumHealth = 0f; aiactor.healthHaver.ApplyDamage(10000f, Vector2.zero, "Infinity Guontlet", CoreDamageTypes.None, DamageCategory.Unstoppable, true, null, false); } if (aiactor.healthHaver.IsBoss) { float maxhealth = aiactor.healthHaver.GetCurrentHealth(); aiactor.healthHaver.ApplyDamage(maxhealth / 2, Vector2.zero, "Infinity Guontlet", CoreDamageTypes.None, DamageCategory.Unstoppable, true, null, false); } } } } }
public static void CreateRainbowchestMimicPrefab() { AIActor aiactor = UnityEngine.Object.Instantiate <AIActor>(EnemyDatabase.GetOrLoadByGuid("d8fd592b184b4ac9a3be217bc70912a2")); aiactor.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(aiactor.gameObject); UnityEngine.Object.DontDestroyOnLoad(aiactor); aiactor.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar; MeshRenderer component = aiactor.GetComponent <MeshRenderer>(); Material[] sharedMaterials = component.sharedMaterials; Array.Resize <Material>(ref sharedMaterials, sharedMaterials.Length + 1); Material material = UnityEngine.Object.Instantiate <Material>(new Material(ShaderCache.Acquire("Brave/Internal/RainbowChestShader"))); material.SetTexture("_MainTex", sharedMaterials[0].GetTexture("_MainTex")); sharedMaterials[sharedMaterials.Length - 1] = material; component.sharedMaterials = sharedMaterials; aiactor.gameObject.AddComponent <RainbowmimicAwakenBehaviour>(); foreach (AttackBehaviorBase attackBehav in aiactor.behaviorSpeculator.AttackBehaviors) { if (attackBehav is AttackBehaviorGroup) { foreach (AttackBehaviorGroup.AttackGroupItem item in (attackBehav as AttackBehaviorGroup).AttackBehaviors) { if (item != null && item.Behavior != null) { if (item.Behavior is ShootBehavior) { (item.Behavior as ShootBehavior).BulletScript = new Toolbox.CustomBulletScriptSelector(typeof(MimicRainbowMiniguns1)); } } } } } if (aiactor.healthHaver != null) { aiactor.healthHaver.SetHealthMaximum(1000, null, true); } if (aiactor.bulletBank != null) { foreach (AIBulletBank.Entry entry in aiactor.bulletBank.Bullets) { if (entry.Name == "default") { entry.BulletObject = EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("gross").BulletObject; entry.Name = "gross"; } if (entry.Name == "bigBullet") { entry.BulletObject = EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("gross").BulletObject; entry.Name = "bigGross"; } } aiactor.bulletBank.Bullets.Add(EnemyDatabase.GetOrLoadByGuid("044a9f39712f456597b9762893fbc19c").bulletBank.bulletBank.GetBullet("default")); } aiactor.ActorName = "Rainbow Chest Mimic"; aiactor.EnemyGuid = "boss_rainbowchest_mimic"; customEnemies.Add(aiactor); SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/BossRainbowmimicIcon", SpriteBuilder.ammonomiconCollection); if (aiactor.GetComponent <EncounterTrackable>() != null) { UnityEngine.Object.Destroy(aiactor.GetComponent <EncounterTrackable>()); } aiactor.encounterTrackable = aiactor.gameObject.AddComponent <EncounterTrackable>(); aiactor.encounterTrackable.journalData = new JournalEntry(); aiactor.encounterTrackable.EncounterGuid = aiactor.EnemyGuid; aiactor.encounterTrackable.prerequisites = new DungeonPrerequisite[0]; aiactor.encounterTrackable.journalData.SuppressKnownState = false; aiactor.encounterTrackable.journalData.IsEnemy = true; aiactor.encounterTrackable.journalData.SuppressInAmmonomicon = false; aiactor.encounterTrackable.ProxyEncounterGuid = ""; aiactor.encounterTrackable.journalData.AmmonomiconSprite = "BossRainbowmimicIcon"; aiactor.encounterTrackable.journalData.enemyPortraitSprite = ResourceExtractor.GetTextureFromResource("SpecialItemPack/Resources/AmmonomiconPortraitRainbowmimic.png"); aiactor.OverrideDisplayName = "#SPECIAL_RAINBOWCHEST_MIMIC"; SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC", "Rainbow Chest Mimic"); SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC_SHORTDESC", "Deadly Surprise"); SpecialItemModule.Strings.Enemies.Set("#SPECIAL_RAINBOWCHEST_MIMIC_LONGDESC", "Evolution gave this mimic ability to change colors. With that ability, it can mimic valuable rainbow chests, that attract foolish gungeoneers so much. " + "Their miniguns are filled with flak shells and they are tougher than other mimics. Truly a terrifying foe to face."); aiactor.encounterTrackable.journalData.PrimaryDisplayName = "#SPECIAL_RAINBOWCHEST_MIMIC"; aiactor.encounterTrackable.journalData.NotificationPanelDescription = "#SPECIAL_RAINBOWCHEST_MIMIC_SHORTDESC"; aiactor.encounterTrackable.journalData.AmmonomiconFullEntry = "#SPECIAL_RAINBOWCHEST_MIMIC_LONGDESC"; AddEnemyToDatabase(aiactor.gameObject, "boss_rainbowchest_mimic", true, true, true); EnemyDatabase.GetEntry("boss_rainbowchest_mimic").ForcedPositionInAmmonomicon = 24; EnemyDatabase.GetEntry("boss_rainbowchest_mimic").isInBossTab = true; }
public static void BuildPrefab() { if (prefab == null || !EnemyBuilder.Dictionary.ContainsKey(guid)) { //Sets up the prefab of the enemy. The spritepath, "CakeMod/Resources/DemonGuy/Idle/milton_idle_001", determines the setup sprite for your enemy. vvvv This bool right here determines whether or not an enemy has an AiShooter or not. AIShooters are necessary if you want your enemy to hold a gun for example. An example of this can be seen in here. prefab = EnemyBuilder.BuildPrefab("DemonGuy", guid, "CakeMod/Resources/DemonGuy/Idle/bullet_demon_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), true); //This line extends a BraveBehavior called EnemyBehavior, this is a generic behavior I use for setting up things that can't be setup in BuildPrefab. var enemy = prefab.AddComponent <EnemyBehavior>(); //Here you can setup various things like movement speed, weight, and health. There's a lot you can do with the AiActor parameter so feel free to experiment. //For DemonGuy let's make him a flying enemy enemy.aiActor.MovementSpeed = 2f; enemy.aiActor.knockbackDoer.weight = 100; enemy.aiActor.IgnoreForRoomClear = false; enemy.aiActor.CollisionDamage = 1f; enemy.aiActor.healthHaver.ForceSetCurrentHealth(30f); enemy.aiActor.healthHaver.SetHealthMaximum(45f, null, false); //This is where you setup your animations. Most animations need specific frame names to be recognized like idle or die. //The AddAnimation lines gets sprites from the folder specified in second phrase of the this line. At the very least you need an animation that contains the word idle for the idle animations for example. //AnimationType determines what kind of animation your making. In Gungeon there are 7 different Animation Types: Move, Idle, Fidget, Flight, Hit, Talk, Other. For a majority of these animations, these play automatically, however specific animations need to be told when to play such as Attack. //DirectionType determines the amount of ways an animation can face. You'll have to change your animation names to correspond with the DirectionType. For example if you want an animation to face eight ways you'll have to name your animations something like ""attack_south_west", "attack_north_east", "attack_east", "attack_south_east", "attack_north", "attack_south", "attack_west", "attack_north_west" and change DirectionType to DirectionType.EightWayOrdinal. //I suggest looking at the sprites of base game enemies to determine the names for the different directions. prefab.AddAnimation("idle_left", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("idle_right", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("move_front_right", "CakeMod/Resources/DemonGuy/MoveFrontRight", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_back_right", "CakeMod/Resources/DemonGuy/MoveBackRight", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_front_left", "CakeMod/Resources/DemonGuy/MoveFrontLeft", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_back_left", "CakeMod/Resources/DemonGuy/MoveBackLeft", fps: 5, AnimationType.Move, DirectionType.FourWay); //Note that the "die"animations are only set to Move because they will be overwritten later. //tk2dSpriteAnimationClip.WrapMode.Once determines how an animation plays out. If you don't want it to loop, leave it to Once, otherwise you can change it to Loop or something. //Assign animation well, assigns an animation to an animation type. By default this is on, but since we're overwritting this set this to false. prefab.AddAnimation("die_left", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_right", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); //Here we create a new DirectionalAnimation for our enemy to pull from. //Make sure the AnimNames correspong to the AddAnimation names. DirectionalAnimation idle = new DirectionalAnimation() { AnimNames = new string[] { "idle_right", "idle_left" }, Flipped = new FlipType[] { FlipType.None, FlipType.None }, Type = DirectionType.TwoWayHorizontal, Prefix = string.Empty }; DirectionalAnimation die = new DirectionalAnimation() { AnimNames = new string[] { "die_right", "die_left" }, Flipped = new FlipType[] { FlipType.None, FlipType.None }, Type = DirectionType.TwoWayHorizontal, Prefix = string.Empty }; //Because Dodge Roll is Dodge Roll and there is no animation types for death, we have to assign them to the Other category. enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other); //This is where we get into the meat and potatoes of our enemy. This is where all the behaviors of our enemy are made. //this line adds a BehaviorSpeculator to our enemy which is the base for adding behaviors on to. var bs = prefab.GetComponent <BehaviorSpeculator>(); //We're also going to duplicate the bulletbank and aishooter from the Bullet Kin. //The "762" represents the the gun id we want our enemy to hold. For a list of all gun ids, look at the items file on this github. //For now let's give him the finished gun. GameObject m_CachedGunAttachPoint = enemy.transform.Find("GunAttachPoint").gameObject; Vector2 offset = new Vector2(1f, -0.50f); m_CachedGunAttachPoint.transform.position = enemy.sprite.WorldCenter + offset; AIActor SourceEnemy = EnemyDatabase.GetOrLoadByGuid("5f3abc2d561b4b9c9e72b879c6f10c7e5f3abc2d561b4b9c9e72b879c6f10c7e"); EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, SourceEnemy.aiShooter, SourceEnemy.GetComponent <AIBulletBank>(), 476, enemy.sprite.transform); //Here we will add some basic behaviors such as TargetPlayerBehavior and SeekTargetBehavior. //You can change many things in these behaviors so feel free to go nuts. bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f, } }; //Now this is one of the most important behaviors because it allows our enemy to shoot. //If we want our enemy to shoot out of a gun, use ShootGunBehavior bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, //With weapon type you can determine if you want your enemy to fire the gun directly or to use a bullet script. Let's use a Bullet Script for now. For the rest of code, let's modify it to be close to the Finished Gun. WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(DemonGuyScript)), FixTargetDuringAttack = true, StopDuringAttack = true, LeadAmount = 0, LeadChance = 1, RespectReload = true, MagazineCapacity = 6, ReloadSpeed = 2f, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = -1, PreventTargetSwitching = true, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.7f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = true, MaxUsages = 0, } }; bs.MovementBehaviors = new List <MovementBehaviorBase> { new SeekTargetBehavior { StopWhenInRange = false, CustomRange = 15f, LineOfSight = false, ReturnToSpawn = false, SpawnTetherDistance = 0f, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 0f, MaxActiveRange = 0f } }; //Adds the enemy to MTG spawn pool and spawn command Game.Enemies.Add("cak:greeddemon", enemy.aiActor); } }
private void ProcessEnemy(AIActor target, float distance) { if (target.GetComponent <AliveBullets.DumbEnemyBehavior>() == null) { if (this.m_owner.CurrentGun.AmmoType == GameUIAmmoType.AmmoType.CUSTOM) { if (BigChamber.customTypesEnemies.ContainsKey(this.m_owner.CurrentGun.DefaultModule.customAmmoType)) { if (BigChamber.customTypesEnemies[this.m_owner.CurrentGun.DefaultModule.customAmmoType].Contains(target.EnemyGuid)) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } } else if (this.m_owner.CurrentGun.DefaultModule.customAmmoType != "pot") { if (typesEnemies[GameUIAmmoType.AmmoType.SMALL_BULLET].Contains(target.EnemyGuid)) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } } } else { if (BigChamber.typesEnemies[this.m_owner.CurrentGun.DefaultModule.ammoType].Contains(target.EnemyGuid)) { if (BigChamber.typesEnemies[this.m_owner.CurrentGun.DefaultModule.ammoType].Contains(target.EnemyGuid)) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } else { if (typesEnemies[GameUIAmmoType.AmmoType.SMALL_BULLET].Contains(target.EnemyGuid)) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } } } } } else { if (target.GetComponent <AliveBullets.DumbEnemyBehavior>().usesNewUsesSynergy) { if (this.m_owner.CurrentGun.DefaultModule.ammoType == target.GetComponent <AliveBullets.DumbEnemyBehavior>().sourceAmmoType) { if (this.m_owner.CurrentGun.DefaultModule.ammoType == GameUIAmmoType.AmmoType.CUSTOM) { if (target.GetComponent <AliveBullets.DumbEnemyBehavior>().customAmmoType != null) { if (this.m_owner.CurrentGun.DefaultModule.customAmmoType == target.GetComponent <AliveBullets.DumbEnemyBehavior>().customAmmoType) { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } } } else { GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(target)); target.EraseFromExistence(true); } } } } }
private void DisplacedImageSpawnHook(Action <DisplaceBehavior> orig, DisplaceBehavior sourceBehaviour) { orig(sourceBehaviour); AIActor attkOwner = sourceBehaviour.GetAttackBehaviourOwner(); if (attkOwner != null) { if (attkOwner.GetComponent <CustomEnemyTagsSystem>() != null && attkOwner.GetComponent <CustomEnemyTagsSystem>().isKalibersEyeMinion) { AIActor image = OMITBReflectionHelpers.ReflectGetField <AIActor>(typeof(DisplaceBehavior), "m_image", sourceBehaviour); if (image != null) { PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(image.specRigidbody, null, false); CustomEnemyTagsSystem tags = image.gameObject.GetOrAddComponent <CustomEnemyTagsSystem>(); tags.isKalibersEyeMinion = true; tags.ignoreForGoodMimic = true; if (attkOwner.CompanionOwner != null) { CompanionController orAddComponent = image.gameObject.GetOrAddComponent <CompanionController>(); orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE; orAddComponent.Initialize(attkOwner.CompanionOwner); } image.OverrideHitEnemies = true; image.CollisionDamage = 0.5f; image.CollisionDamageTypes |= CoreDamageTypes.Electric; CompanionisedEnemyBulletModifiers companionisedBullets = image.gameObject.GetOrAddComponent <CompanionisedEnemyBulletModifiers>(); companionisedBullets.jammedDamageMultiplier = 2f; companionisedBullets.TintBullets = true; companionisedBullets.TintColor = ExtendedColours.honeyYellow; companionisedBullets.baseBulletDamage = 10f; companionisedBullets.scaleSpeed = true; companionisedBullets.scaleDamage = true; companionisedBullets.scaleSize = false; companionisedBullets.doPostProcess = false; if (attkOwner.CompanionOwner != null) { companionisedBullets.enemyOwner = attkOwner.CompanionOwner; } image.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null); image.gameObject.AddComponent <KillOnRoomClear>(); if (EasyEnemyTypeLists.MultiPhaseEnemies.Contains(image.EnemyGuid) || EasyEnemyTypeLists.EnemiesWithInvulnerablePhases.Contains(image.EnemyGuid)) { EraseFromExistenceOnRoomClear destroyTrickyEnemy = image.gameObject.AddComponent <EraseFromExistenceOnRoomClear>(); destroyTrickyEnemy.Delay = 1f; } image.IsHarmlessEnemy = true; image.RegisterOverrideColor(Color.grey, "Ressurection"); image.IgnoreForRoomClear = true; if (image.gameObject.GetComponent <SpawnEnemyOnDeath>()) { UnityEngine.Object.Destroy(image.gameObject.GetComponent <SpawnEnemyOnDeath>()); } } } } }
public static void BuildPrefab() { AIActor source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93"); bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = EnemyBuilder.BuildPrefab("AbyssKin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true); var companion = prefab.AddComponent <EnemyBehavior>(); companion.aiActor.knockbackDoer.weight = 200; companion.aiActor.MovementSpeed = 3f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0.05f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = true; companion.aiActor.healthHaver.ForceSetCurrentHealth(25f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.CanTargetPlayers = true; companion.aiActor.healthHaver.SetHealthMaximum(25f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; prefab.AddAnimation("idle_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/IdleRight/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("idle_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/IdleLeft/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("move_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/MoveRight/", fps: 8, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("move_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/MoveLeft/", fps: 8, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("death_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/DeathLeft/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("death_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/DeathRight/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("6e972cd3b11e4b429b888b488e308551").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; bs.MovementBehaviors = new List <MovementBehaviorBase>() { new SeekTargetBehavior() { StopWhenInRange = true, CustomRange = 6, LineOfSight = true, ReturnToSpawn = true, SpawnTetherDistance = 0, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 1, MaxActiveRange = 10 } }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(AbyssKinAttack)), FixTargetDuringAttack = false, StopDuringAttack = false, LeadAmount = 0, LeadChance = 0.62f, RespectReload = true, MagazineCapacity = 2, ReloadSpeed = 4, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = 0.5f, PreventTargetSwitching = false, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.2f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = false, MaxUsages = 0 } }; //Tools.DebugInformation(load); AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("1a78cfb776f54641b832e92c44021cf2"); bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject; EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), 45, m_CachedGunAttachPoint.transform); Game.Enemies.Add("bny:abyss_kin", companion.aiActor); } }
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); } } } } }
public static GameObject MainHook(GameObject objectToInstantiate, RoomHandler targetRoom, IntVector2 location, bool deferConfiguration, AIActor.AwakenAnimationType awakenAnimType = AIActor.AwakenAnimationType.Default, bool autoEngage = false) { //hooks into InstantiateDungeonPlaceable GameObject result; System.Random rnd = new System.Random(); int nu = 0; string enemyGuid; GRandomHook.wasBoss = false; bool isbossroom = false; if (targetRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS && targetRoom.area.PrototypeRoomBossSubcategory == PrototypeDungeonRoom.RoomBossSubCategory.FLOOR_BOSS) { isbossroom = true; } else if (GRandomRoomDatabaseHelper.AllSpecificDeathRooms.Contains(targetRoom.GetRoomName())) { isbossroom = true; } try { if (objectToInstantiate != null) { Vector3 vector = location.ToVector3(0f) + targetRoom.area.basePosition.ToVector3(); vector.z = vector.y + vector.z; AIActor component = objectToInstantiate.GetComponent <AIActor>(); //notused AIActor ogcomponent = component; if (component is AIActorDummy) { objectToInstantiate = (component as AIActorDummy).realPrefab; component = objectToInstantiate.GetComponent <AIActor>(); } SpeculativeRigidbody component2 = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); //notused if (component && component2) { if (component.EnemyGuid != null) { //Here gets enemyGuid based on room. Pulls from EnemyDatabase /////////////////////// if (isbossroom) { if (component.healthHaver.IsBoss) { GRandomHook.wasBoss = true; if (component.healthHaver.GetMaxHealth() != 60) //sometimes gets health as regular enemy health, 60 { GRandomHook.boss_health = component.healthHaver.GetMaxHealth(); //getting boss health to set for replacement boss } //replacement for Boss nu = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedBossRoomDatabase.Count); enemyGuid = GRandomEnemyDataBaseHelper.UsedBossRoomDatabase[nu]; } else { //normal enemies as bosses is off and the enemy is not a boss; pull from no bosses database for enemy spawnings nu = rnd.Next(0, GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly.Count); enemyGuid = GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly[nu]; } } else if (targetRoom.GetRoomName() == "ResourcefulRat_PitEntrance_01" | targetRoom.GetRoomName() == "ResourcefulRat_Entrance") { nu = rnd.Next(0, GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase.Count); enemyGuid = GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase[nu]; } else { nu = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase.Count); enemyGuid = GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase[nu]; } if (component.EnemyGuid == "479556d05c7c44f3b6abb3b2067fc778") //wallmimic { enemyGuid = "479556d05c7c44f3b6abb3b2067fc778"; } // //can add specific Guid here for debugging // if (enemyGuid == "465da2bb086a4a88a803f79fe3a27677") //replace DraGun, can't remove him from database or forge dragunroom breaks { enemyGuid = "05b8afe0b6cc4fffa9dc6036fa24c8ec"; } // End getting guid ////////////////////////////// //initializing new AIActor, not sure why they do it again below AIActor prefabActor = EnemyDatabase.GetOrLoadByGuid(enemyGuid); objectToInstantiate = prefabActor.gameObject; component = objectToInstantiate.GetComponent <AIActor>(); component2 = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); //bool specificdeathdoer = prefabActor.healthHaver.ManualDeathHandling; GenericIntroDoer genericIntroDoer = component.GetComponent <GenericIntroDoer>(); //if (genericIntroDoer) // is boss // handles initiated boss settings if (component.healthHaver.IsBoss) { if (isbossroom) { prefabActor.healthHaver.SetHealthMaximum(GRandomHook.boss_health); ETGModConsole.Log("Newbosshealth " + prefabActor.healthHaver.GetMaxHealth()); } else { prefabActor.healthHaver.SetHealthMaximum(60f); } objectToInstantiate = RandomHandleEnemyInfo.RemoveBossIntros(objectToInstantiate); objectToInstantiate = RandomHandleEnemyInfo.ReplaceSpecificBossDeathController(objectToInstantiate); objectToInstantiate = RandomHandleEnemyInfo.AttackBehaviorManipulator(objectToInstantiate); DemonWallController dwc = objectToInstantiate.GetComponent <DemonWallController>(); if (dwc) { Destroy(dwc); } } if (!component.IsNormalEnemy) { objectToInstantiate = RandomHandleEnemyInfo.HandleCompanions(objectToInstantiate); } } PixelCollider pixelCollider = component2.GetPixelCollider(ColliderType.Ground); if (pixelCollider.ColliderGenerationMode != PixelCollider.PixelColliderGeneration.Manual) { Debug.LogErrorFormat("Trying to spawn an AIActor who doesn't have a manual ground collider... do we still do this? Name: {0}", new object[] { objectToInstantiate.name }); } Vector2 a = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualOffsetX, pixelCollider.ManualOffsetY)); Vector2 vector2 = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualWidth, pixelCollider.ManualHeight)); Vector2 vector3 = new Vector2((float)Mathf.CeilToInt(vector2.x), (float)Mathf.CeilToInt(vector2.y)); Vector2 b = new Vector2((vector3.x - vector2.x) / 2f, 0f).Quantize(0.0625f); if (targetRoom.GetRoomName() == "DraGunRoom01" | targetRoom.GetRoomName() == "LichRoom02" | targetRoom.GetRoomName() == "LichRoom03" | targetRoom.GetRoomName() == "Bullet_End_Room_04" | targetRoom.GetRoomName() == "ResourcefulRatRoom01") { b -= new Vector2(0.0f, 5.0f); } Vector3 v3 = a - b; vector -= v3; //vector -= a - b; //Vector3 } if (component) { component.AwakenAnimType = awakenAnimType; } GameObject NewEnemyObject = UnityEngine.Object.Instantiate <GameObject>(objectToInstantiate, vector, Quaternion.identity); if (!deferConfiguration) { Component[] componentsInChildren = NewEnemyObject.GetComponentsInChildren(typeof(IPlaceConfigurable)); for (int i = 0; i < componentsInChildren.Length; i++) { IPlaceConfigurable placeConfigurable = componentsInChildren[i] as IPlaceConfigurable; if (placeConfigurable != null) { placeConfigurable.ConfigureOnPlacement(targetRoom); } } } ObjectVisibilityManager component3 = NewEnemyObject.GetComponent <ObjectVisibilityManager>(); if (component3 != null) { component3.Initialize(targetRoom, autoEngage); } MinorBreakable componentInChildren = NewEnemyObject.GetComponentInChildren <MinorBreakable>(); if (componentInChildren != null) { IntVector2 key = location + targetRoom.area.basePosition; CellData cellData = GameManager.Instance.Dungeon.data[key]; if (cellData != null) { cellData.cellVisualData.containsObjectSpaceStamp = true; } } PlayerItem component4 = NewEnemyObject.GetComponent <PlayerItem>(); if (component4 != null) { component4.ForceAsExtant = true; } //[Randomizer] Add AIActor GameObjectInfo AIActor enemy_component = NewEnemyObject.GetComponent <AIActor>(); if (enemy_component) { if (enemy_component.healthHaver.IsBoss) { if (isbossroom) { //Boss Room enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar; } else { enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.None; autoEngage = true; } NewEnemyObject = RandomHandleEnemyInfo.ReinstateBossObjectInfo(NewEnemyObject); //removes boss status if regular boss, needs hitbox stuff reinstated } if (GRandomEnemyDataBaseHelper.SpecificEnemyDatabase.Contains(enemy_component.EnemyGuid)) { NewEnemyObject = RandomHandleEnemyInfo.SpecificEnemyHelper(NewEnemyObject); } NewEnemyObject = UniqueBossRoomDeathHandler.SpecificRoomHandler(targetRoom, NewEnemyObject); } result = NewEnemyObject; } else { result = null; //return null; } } catch (Exception message) { Debug.Log("[RANDOMIZER ERROR] " + message.ToString()); result = null; } return(result); }
public static void GenerateGungeoneerMimicBoss(AssetBundle expandSharedAssets1, GameObject aiActorObject, PlayerController sourcePlayer = null) { if (sourcePlayer == null) { sourcePlayer = GameManager.Instance.PrimaryPlayer; } if (sourcePlayer == null) { return; } tk2dSprite playerSprite = aiActorObject.AddComponent <tk2dSprite>(); ExpandUtility.DuplicateSprite(playerSprite, (sourcePlayer.sprite as tk2dSprite)); // If Player sprite was flipped (aka, player aiming/facing towards the left), then this could cause sprite being shifted left on AIActor. // Always set false to ensure this doesn't happen. playerSprite.FlipX = false; ExpandUtility.GenerateAIActorTemplate(aiActorObject, out m_CorpseObject, aiActorObject.name, System.Guid.NewGuid().ToString(), GunAttachOffset: new Vector3(0.3f, 0.25f, 0), StartingGunID: 472); AIActor CachedEnemyActor = aiActorObject.GetComponent <AIActor>(); if (!aiActorObject | !CachedEnemyActor) { return; } if (ExpandStats.debugMode) { ETGModConsole.Log("Spawning '" + CachedEnemyActor.ActorName + "' with GUID: " + CachedEnemyActor.EnemyGuid + " .", false); } GameObject m_NewHandObject = new GameObject("PlayerMimicHand"); tk2dSprite m_HandSprite = m_NewHandObject.AddComponent <tk2dSprite>(); ExpandUtility.DuplicateSprite(m_HandSprite, sourcePlayer.primaryHand.gameObject.GetComponent <tk2dSprite>()); PlayerHandController m_HandController = m_NewHandObject.AddComponent <PlayerHandController>(); m_HandController.ForceRenderersOff = false; m_HandController.handHeightFromGun = 0.05f; CachedEnemyActor.aiShooter.handObject = m_HandController; // Generate BossCard based on current Player. Texture2D BossCardForeground = ExpandUtility.FlipTexture(Instantiate(sourcePlayer.BosscardSprites[0])); // Mirror thing will be used as static background. (will be the same for all possible boss cards) Texture2D BossCardBackground = expandSharedAssets1.LoadAsset <Texture2D>("MimicInMirror_BossCardBackground"); // Combine foreground boss card generated from PlayerController onto the static background image loased in earlier. Resolutions must match! Texture2D BossCardTexture = ExpandUtility.CombineTextures(BossCardBackground, BossCardForeground); GenericIntroDoer miniBossIntroDoer = aiActorObject.AddComponent <GenericIntroDoer>(); aiActorObject.AddComponent <ExpandGungeoneerMimicIntroDoer>(); miniBossIntroDoer.triggerType = GenericIntroDoer.TriggerType.PlayerEnteredRoom; miniBossIntroDoer.initialDelay = 0.15f; miniBossIntroDoer.cameraMoveSpeed = 14; miniBossIntroDoer.specifyIntroAiAnimator = null; miniBossIntroDoer.BossMusicEvent = "Play_MUS_Boss_Theme_Beholster"; miniBossIntroDoer.PreventBossMusic = false; miniBossIntroDoer.InvisibleBeforeIntroAnim = false; miniBossIntroDoer.preIntroAnim = string.Empty; miniBossIntroDoer.preIntroDirectionalAnim = string.Empty; miniBossIntroDoer.introAnim = "idle"; miniBossIntroDoer.introDirectionalAnim = string.Empty; miniBossIntroDoer.continueAnimDuringOutro = false; miniBossIntroDoer.cameraFocus = null; miniBossIntroDoer.roomPositionCameraFocus = Vector2.zero; miniBossIntroDoer.restrictPlayerMotionToRoom = false; miniBossIntroDoer.fusebombLock = false; miniBossIntroDoer.AdditionalHeightOffset = 0; miniBossIntroDoer.portraitSlideSettings = new PortraitSlideSettings() { bossNameString = "Dopplegunner", bossSubtitleString = "Imposter!", bossQuoteString = "Clone gone rogue...", bossSpritePxOffset = IntVector2.Zero, topLeftTextPxOffset = IntVector2.Zero, bottomRightTextPxOffset = IntVector2.Zero, bgColor = new Color(0, 0, 1, 1) }; if (BossCardTexture) { miniBossIntroDoer.portraitSlideSettings.bossArtSprite = BossCardTexture; miniBossIntroDoer.SkipBossCard = false; CachedEnemyActor.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar; } else { miniBossIntroDoer.SkipBossCard = true; CachedEnemyActor.healthHaver.bossHealthBar = HealthHaver.BossBarType.SubbossBar; } miniBossIntroDoer.HideGunAndHand = true; miniBossIntroDoer.SkipFinalizeAnimation = true; miniBossIntroDoer.RegenerateCache(); CachedEnemyActor.BaseMovementSpeed = 8f; CachedEnemyActor.MovementSpeed = 8f; CachedEnemyActor.healthHaver.SetHealthMaximum(1000); CachedEnemyActor.healthHaver.ForceSetCurrentHealth(1000); CachedEnemyActor.healthHaver.overrideBossName = "Dopplegunner"; CachedEnemyActor.healthHaver.RegenerateCache(); CachedEnemyActor.EnemyId = Random.Range(2000, 9999); CachedEnemyActor.EnemyGuid = System.Guid.NewGuid().ToString(); CachedEnemyActor.OverrideDisplayName = ("Dopplegunner"); CachedEnemyActor.ActorName = ("Dopplegunner"); CachedEnemyActor.name = ("Dopplegunner"); CachedEnemyActor.CanTargetEnemies = false; CachedEnemyActor.CanTargetPlayers = true; if (sourcePlayer.characterIdentity == PlayableCharacters.Bullet) { CachedEnemyActor.EnemySwitchState = "Metal_Bullet_Man"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Convict) { CachedEnemyActor.EnemySwitchState = "Convict"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.CoopCultist) { CachedEnemyActor.EnemySwitchState = "Cultist"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Cosmonaut) { CachedEnemyActor.EnemySwitchState = "Cosmonaut"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Guide) { CachedEnemyActor.EnemySwitchState = "Guide"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Gunslinger) { CachedEnemyActor.EnemySwitchState = "Gunslinger"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Ninja) { CachedEnemyActor.EnemySwitchState = "Ninja"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Pilot) { CachedEnemyActor.EnemySwitchState = "Rogue"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Robot) { CachedEnemyActor.EnemySwitchState = "Robot"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Soldier) { CachedEnemyActor.EnemySwitchState = "Marine"; } else if (sourcePlayer.characterIdentity == PlayableCharacters.Eevee) { CachedEnemyActor.EnemySwitchState = "Convict"; ExpandShaders.ApplyParadoxPlayerShader(CachedEnemyActor.sprite); } else { CachedEnemyActor.EnemySwitchState = "Gun Cultist"; } ExpandGungeoneerMimicBossController playerMimicController = aiActorObject.AddComponent <ExpandGungeoneerMimicBossController>(); playerMimicController.m_Player = sourcePlayer; aiActorObject.AddComponent <ExpandGungeoneerMimicDeathController>(); if (CachedEnemyActor.GetComponent <ExpandGungeoneerMimicIntroDoer>()) { GenericIntroDoer genericIntroDoer = CachedEnemyActor.gameObject.GetComponent <GenericIntroDoer>(); FieldInfo field = typeof(GenericIntroDoer).GetField("m_specificIntroDoer", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(genericIntroDoer, CachedEnemyActor.GetComponent <ExpandGungeoneerMimicIntroDoer>()); } CachedEnemyActor.aiAnimator.enabled = false; CachedEnemyActor.spriteAnimator.Stop(); CachedEnemyActor.spriteAnimator.DefaultClipId = 0; CachedEnemyActor.spriteAnimator.playAutomatically = false; List <tk2dSpriteAnimationClip> m_AnimationClips = new List <tk2dSpriteAnimationClip>(); foreach (tk2dSpriteAnimationClip clip in sourcePlayer.spriteAnimator.Library.clips) { if (!string.IsNullOrEmpty(clip.name)) { if (clip.name.ToLower() == "dodge") { m_AnimationClips.Add(clip); if (clip.frames != null && clip.frames.Length > 0) { if (!sourcePlayer.UseArmorlessAnim) { CachedEnemyActor.sprite.SetSprite(clip.frames[0].spriteId); } } } else if (clip.name.ToLower() == "dodge_armorless") { m_AnimationClips.Add(clip); if (clip.frames != null && clip.frames.Length > 0) { if (sourcePlayer.UseArmorlessAnim) { CachedEnemyActor.sprite.SetSprite(clip.frames[0].spriteId); } } } else if (clip.name.ToLower() == "run_down") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "run_down_armorless") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "death_shot") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "death_shot_armorless") { m_AnimationClips.Add(clip); } } } if (m_AnimationClips.Count > 0) { if (!CachedEnemyActor.spriteAnimator.Library) { CachedEnemyActor.spriteAnimator.Library = aiActorObject.AddComponent <tk2dSpriteAnimation>(); } CachedEnemyActor.spriteAnimator.Library.clips = m_AnimationClips.ToArray(); } CachedEnemyActor.healthHaver.RegenerateCache(); BehaviorSpeculator customBehaviorSpeculator = aiActorObject.AddComponent <BehaviorSpeculator>(); customBehaviorSpeculator.OverrideBehaviors = new List <OverrideBehaviorBase>(0); customBehaviorSpeculator.TargetBehaviors = new List <TargetBehaviorBase>(0); customBehaviorSpeculator.MovementBehaviors = new List <MovementBehaviorBase>(0); customBehaviorSpeculator.AttackBehaviors = new List <AttackBehaviorBase>(0); customBehaviorSpeculator.OtherBehaviors = new List <BehaviorBase>(0); customBehaviorSpeculator.InstantFirstTick = false; customBehaviorSpeculator.TickInterval = 0.1f; customBehaviorSpeculator.PostAwakenDelay = 0.5f; customBehaviorSpeculator.RemoveDelayOnReinforce = false; customBehaviorSpeculator.OverrideStartingFacingDirection = false; customBehaviorSpeculator.StartingFacingDirection = -90f; customBehaviorSpeculator.SkipTimingDifferentiator = false; customBehaviorSpeculator.RegenerateCache(); // BehaviorSpeculator is a serialized object. You must build these lists (or create new empty lists) and save them before the game can instantiate it correctly! ISerializedObject m_TargetBehaviorSpeculatorSeralized = customBehaviorSpeculator; m_TargetBehaviorSpeculatorSeralized.SerializedObjectReferences = new List <Object>(0); m_TargetBehaviorSpeculatorSeralized.SerializedStateKeys = new List <string>() { "OverrideBehaviors", "TargetBehaviors", "MovementBehaviors", "AttackBehaviors", "OtherBehaviors" }; m_TargetBehaviorSpeculatorSeralized.SerializedStateValues = new List <string>() { "[]", "[]", "[]", "[]", "[]" }; CachedEnemyActor.RegenerateCache(); return; }
public int SpawnWallMimic(Dungeon dungeon, RoomHandler currentRoom, int WallMimicsPerRoom = 1) { int SouthWallCount = 0; int NorthWallCount = 0; int WestWallCount = 0; int EastWallCount = 0; int WallMimicsPlaced = 0; int loopCount = 0; List <Tuple <IntVector2, DungeonData.Direction> > validWalls = new List <Tuple <IntVector2, DungeonData.Direction> >(); try { for (int Width = -1; Width <= currentRoom.area.dimensions.x; Width++) { for (int Height = -1; Height <= currentRoom.area.dimensions.y; Height++) { int X = currentRoom.area.basePosition.x + Width; int Y = currentRoom.area.basePosition.y + Height; // if (dungeon.data.isWall(X, Y) && X % 4 == 0 && Y % 4 == 0 && dungeon.data[new IntVector2(X, Y)].parentRoom != null && dungeon.data[new IntVector2(X, Y)].parentRoom == currentRoom) { // if (dungeon.data.isWall(X, Y) && X % 4 == 0 && Y % 4 == 0) { if (dungeon.data.isWall(X, Y) && X % 4 == 0 && Y % 4 == 0 && dungeon.data.GetAbsoluteRoomFromPosition(new IntVector2(X, Y)) != null && dungeon.data.GetAbsoluteRoomFromPosition(new IntVector2(X, Y)) == currentRoom) { int WallCount = 0; if (!dungeon.data.isWall(X - 1, Y + 2) && !dungeon.data.isWall(X, Y + 2) && !dungeon.data.isWall(X + 1, Y + 2) && !dungeon.data.isWall(X + 2, Y + 2) && !dungeon.data.isWall(X - 1, Y + 1) && !dungeon.data.isWall(X, Y + 1) && !dungeon.data.isWall(X + 1, Y + 1) && !dungeon.data.isWall(X + 2, Y + 1) && dungeon.data.isWall(X - 1, Y) && dungeon.data.isWall(X, Y) && dungeon.data.isWall(X + 1, Y) && dungeon.data.isWall(X + 2, Y) && dungeon.data.isWall(X - 1, Y - 1) && dungeon.data.isWall(X, Y - 1) && dungeon.data.isWall(X + 1, Y - 1) && dungeon.data.isWall(X + 2, Y - 1) && !dungeon.data.isPlainEmptyCell(X - 1, Y - 3) && !dungeon.data.isPlainEmptyCell(X, Y - 3) && !dungeon.data.isPlainEmptyCell(X + 1, Y - 3) && !dungeon.data.isPlainEmptyCell(X + 2, Y - 3)) { validWalls.Add(Tuple.Create(new IntVector2(X, Y), DungeonData.Direction.NORTH)); WallCount++; SouthWallCount++; } else if (dungeon.data.isWall(X - 1, Y + 2) && dungeon.data.isWall(X, Y + 2) && dungeon.data.isWall(X + 1, Y + 2) && dungeon.data.isWall(X + 2, Y + 2) && dungeon.data.isWall(X - 1, Y + 1) && dungeon.data.isWall(X, Y + 1) && dungeon.data.isWall(X + 1, Y + 1) && dungeon.data.isWall(X + 2, Y + 1) && dungeon.data.isWall(X - 1, Y) && dungeon.data.isWall(X, Y) && dungeon.data.isWall(X + 1, Y) && dungeon.data.isWall(X + 2, Y) && dungeon.data.isPlainEmptyCell(X, Y - 1) && dungeon.data.isPlainEmptyCell(X + 1, Y - 1) && !dungeon.data.isPlainEmptyCell(X, Y + 4) && !dungeon.data.isPlainEmptyCell(X + 1, Y + 4)) { validWalls.Add(Tuple.Create(new IntVector2(X, Y), DungeonData.Direction.SOUTH)); WallCount++; NorthWallCount++; } else if (dungeon.data.isWall(X, Y + 2) && dungeon.data.isWall(X, Y + 1) && dungeon.data.isWall(X - 1, Y) && dungeon.data.isWall(X, Y - 1) && dungeon.data.isWall(X, Y - 2) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 2) && !dungeon.data.isPlainEmptyCell(X - 2, Y + 1) && !dungeon.data.isPlainEmptyCell(X - 2, Y) && dungeon.data.isPlainEmptyCell(X + 1, Y) && dungeon.data.isPlainEmptyCell(X + 1, Y - 1) && !dungeon.data.isPlainEmptyCell(X - 2, Y - 1) && !dungeon.data.isPlainEmptyCell(X - 2, Y - 2)) { validWalls.Add(Tuple.Create(new IntVector2(X, Y), DungeonData.Direction.EAST)); WallCount++; WestWallCount++; } else if (dungeon.data.isWall(X, Y + 2) && dungeon.data.isWall(X, Y + 1) && dungeon.data.isWall(X + 1, Y) && dungeon.data.isWall(X, Y - 1) && dungeon.data.isWall(X, Y - 2) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 2) && !dungeon.data.isPlainEmptyCell(X + 2, Y + 1) && !dungeon.data.isPlainEmptyCell(X + 2, Y) && dungeon.data.isPlainEmptyCell(X - 1, Y) && dungeon.data.isPlainEmptyCell(X - 1, Y - 1) && !dungeon.data.isPlainEmptyCell(X + 2, Y - 1) && !dungeon.data.isPlainEmptyCell(X + 2, Y - 2)) { validWalls.Add(Tuple.Create(new IntVector2(X - 1, Y), DungeonData.Direction.WEST)); WallCount++; EastWallCount++; } if (WallCount > 0) { bool WallStillValid = true; int XPadding = -5; while (XPadding <= 5 && WallStillValid) { int YPadding = -5; while (YPadding <= 5 && WallStillValid) { int x = X + XPadding; int y = Y + YPadding; if (dungeon.data.CheckInBoundsAndValid(x, y)) { CellData cellData = dungeon.data[x, y]; if (cellData != null) { // if (cellData.type == CellType.PIT || cellData.diagonalWallType != DiagonalWallType.NONE) { WallStillValid = false; } if (cellData.type == CellType.PIT | cellData.diagonalWallType != DiagonalWallType.NONE) { WallStillValid = false; } } } YPadding++; } XPadding++; } if (!WallStillValid) { while (WallCount > 0) { validWalls.RemoveAt(validWalls.Count - 1); WallCount--; } } } } } } if (validWalls.Count <= 0) { if (ExpandSettings.debugMode) { ETGModConsole.Log("[DEBUG] No valid locations found for room: " + currentRoom.GetRoomName() + " while attempting Wall Mimic placement!", false); } return(0); } while (loopCount < WallMimicsPerRoom && validWalls.Count > 0) { if (validWalls.Count > 0) { Tuple <IntVector2, DungeonData.Direction> WallCell = BraveUtility.RandomElement(validWalls); IntVector2 Position = WallCell.First; DungeonData.Direction Direction = WallCell.Second; if (Direction != DungeonData.Direction.WEST) { currentRoom.RuntimeStampCellComplex(Position.x, Position.y, CellType.FLOOR, DiagonalWallType.NONE); } if (Direction != DungeonData.Direction.EAST) { currentRoom.RuntimeStampCellComplex(Position.x + 1, Position.y, CellType.FLOOR, DiagonalWallType.NONE); } AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GameManager.Instance.RewardManager.WallMimicChances.EnemyGuid); AIActor WallMimic = AIActor.Spawn(orLoadByGuid, Position, currentRoom, true, AIActor.AwakenAnimationType.Default, true); if (PlayerHasWallMimicItem) { if (WallMimic && WallMimic.GetComponent <ExpandWallMimicManager>()) { ExpandWallMimicManager wallMimicController = WallMimic.gameObject.GetComponent <ExpandWallMimicManager>(); if (wallMimicController) { wallMimicController.CursedBrickMode = true; } } } validWalls.Remove(WallCell); WallMimicsPlaced++; } loopCount++; } } catch (Exception ex) { if (ExpandSettings.debugMode) { ETGModConsole.Log("[DEBUG] Exception while trying to place WallMimic(s) in room: " + currentRoom.GetRoomName(), false); Debug.LogException(ex); } return(WallMimicsPlaced); } if (WallMimicsPlaced > 0) { if (ExpandSettings.debugMode) { ETGModConsole.Log("[DEBUG] Wall Mimic(s) succesfully placed in room: " + currentRoom.GetRoomName(), false); ETGModConsole.Log("[DEBUG] Number of Valid North Wall Mimics locations: " + NorthWallCount, false); ETGModConsole.Log("[DEBUG] Number of Valid South Wall Mimics locations: " + SouthWallCount, false); ETGModConsole.Log("[DEBUG] Number of Valid East Wall Mimics locations: " + EastWallCount, false); ETGModConsole.Log("[DEBUG] Number of Valid West Wall Mimics locations: " + WestWallCount, false); ETGModConsole.Log("[DEBUG] Number of Wall Mimics succesfully placed in room: " + WallMimicsPlaced, false); } return(WallMimicsPlaced); } else { ETGModConsole.Log("[DEBUG] No valid location found for room: " + currentRoom.GetRoomName() + " while attempting Wall Mimic placement!", false); return(0); } }
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; }