public IEnumerator ResizeEnemy(AIActor target, Vector2 ScaleValue, bool onlyDoRescale = true, bool isBigEnemy = false, bool delayed = false)
        {
            if (target == null | ScaleValue == null)
            {
                yield break;
            }

            if (delayed)
            {
                yield return(new WaitForSeconds(0.8f));
            }

            HealthHaver targetHealthHaver = target.GetComponent <HealthHaver>();
            float       knockBackValue    = 2f;

            int cachedLayer        = target.gameObject.layer;
            int cachedOutlineLayer = cachedLayer;

            target.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            cachedOutlineLayer      = SpriteOutlineManager.ChangeOutlineLayer(target.sprite, LayerMask.NameToLayer("Unpixelated"));
            // target.ClearPath();
            if (!onlyDoRescale)
            {
                if (target.knockbackDoer)
                {
                    if (isBigEnemy)
                    {
                        target.knockbackDoer.weight *= knockBackValue;
                    }
                    else
                    {
                        target.knockbackDoer.weight /= knockBackValue;
                    }
                }
                if (!isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!targetHealthHaver.IsBoss && !ChaosLists.DontDieOnCollisionWhenTinyGUIDList.Contains(target.EnemyGuid))
                    {
                        target.DiesOnCollison   = true;
                        target.EnemySwitchState = "Blobulin";
                    }

                    target.CollisionDamage          = 0f;
                    target.CollisionDamageTypes     = 0;
                    target.PreventFallingInPitsEver = false;
                    // target.CollisionKnockbackStrength = target.CollisionKnockbackStrength - 0.6f;
                    target.PreventBlackPhantom = true;

                    if (targetHealthHaver.IsBoss)
                    {
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 1.5f, null, false);
                        }
                        // aiActor.BaseMovementSpeed *= 1.1f;
                        // aiActor.MovementSpeed *= 1.1f;
                    }
                    else if (targetHealthHaver != null && !onlyDoRescale)
                    {
                        target.BaseMovementSpeed *= 1.15f;
                        target.MovementSpeed     *= 1.15f;
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 2f, null, false);
                        }
                    }
                    target.OverrideDisplayName = ("Tiny " + target.GetActorName());
                }
                else if (isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!target.IsFlying && !targetHealthHaver.IsBoss && !ChaosLists.OverrideFallIntoPitsList.Contains(target.EnemyGuid))
                    {
                        target.PreventFallingInPitsEver = true;
                    }
                    if (targetHealthHaver.IsBoss)
                    {
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.2f, null, false);
                        // aiActor.BaseMovementSpeed *= 0.8f;
                        // aiActor.MovementSpeed *= 0.8f;
                    }
                    else
                    {
                        target.BaseMovementSpeed /= 1.25f;
                        target.MovementSpeed     /= 1.25f;
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.5f, null, false);
                    }
                    target.OverrideDisplayName = ("Big " + target.GetActorName());
                }
            }
            Vector2 startScale = target.EnemyScale;
            float   elapsed    = 0f;
            float   ShrinkTime = 0.5f;

            while (elapsed < ShrinkTime)
            {
                elapsed          += BraveTime.DeltaTime;
                target.EnemyScale = Vector2.Lerp(startScale, ScaleValue, elapsed / ShrinkTime);
                if (target.specRigidbody)
                {
                    target.specRigidbody.UpdateCollidersOnScale = true;
                    target.specRigidbody.RegenerateColliders    = true;
                }
                yield return(null);
            }
            yield return(new WaitForSeconds(1.5f));

            ChaosUtility.CorrectForWalls(target);

            /*if (target.CorpseObject != null) {
             *  target.CorpseObject.transform.localScale = ScaleValue.ToVector3ZUp(1f);
             *  int cachedCorpseLayer = target.CorpseObject.layer;
             *  int cachedCorpseOutlineLayer = cachedCorpseLayer;
             *  target.CorpseObject.layer = LayerMask.NameToLayer("CorpseUnpixelated");
             *  cachedCorpseOutlineLayer = SpriteOutlineManager.ChangeOutlineLayer(target.CorpseObject.GetComponentInChildren<tk2dBaseSprite>(), LayerMask.NameToLayer("CorpseUnpixelated"));
             * }*/
            yield break;
        }
Beispiel #2
0
        private void HandleTossedBallGrounded(DebrisObject obj)
        {
            obj.OnGrounded -= this.HandleTossedBallGrounded;
            MonsterBall component = obj.GetComponent <MonsterBall>();
            // component.spriteAnimator.Play("monster_ball_open");
            float   distance        = -1f;
            float   nearestDistance = float.MaxValue;
            AIActor nearestEnemy    = null;

            try
            {
                List <AIActor> activeEnemies = obj.transform.position.GetAbsoluteRoom().GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                if (activeEnemies == null)
                {
                    goto SKIP;
                }
                for (int i = 0; i < activeEnemies.Count; i++)
                {
                    AIActor enemy = activeEnemies[i];
                    if (!enemy.IsMimicEnemy && enemy.healthHaver && !enemy.healthHaver.IsBoss && enemy.healthHaver.IsVulnerable)
                    {
                        if (!enemy.healthHaver.IsDead)
                        {
                            if (!BannedMonsterBallEnemies.Contains(enemy.EnemyGuid))
                            {
                                float num = Vector2.Distance(obj.sprite.WorldCenter, enemy.CenterPosition);
                                if (num < nearestDistance)
                                {
                                    nearestDistance = num;
                                    nearestEnemy    = enemy;
                                }
                            }
                        }
                    }
                }
SKIP:
                if (nearestEnemy == null)
                {
                    AIActor[] AllEnemiesOnFloor = FindObjectsOfType <AIActor>();
                    if (AllEnemiesOnFloor == null)
                    {
                        if (component.m_Debug)
                        {
                            ETGModConsole.Log("[Monster_Ball] No Enemies present on the floor?");
                        }
                    }
                    else
                    {
                        for (int i = 0; i < AllEnemiesOnFloor.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(AllEnemiesOnFloor[i].name))
                            {
                                if (AllEnemiesOnFloor[i].name.ToLower().Contains("companionpet"))
                                {
                                    nearestEnemy    = AllEnemiesOnFloor[i];
                                    nearestDistance = component.EnemySearchRadius;
                                }
                            }
                        }
                    }
                }
                if (component.m_Debug && nearestEnemy == null)
                {
                    ETGModConsole.Log("[Monster_Ball] activeEnemies is null.");
                }
                if (nearestEnemy && distance <= component.EnemySearchRadius)
                {
                    if (component.m_Debug)
                    {
                        ETGModConsole.Log("Monster_Ball: Attempting to capture: " + nearestEnemy.GetActorName());
                    }
                    component.m_containsEnemy   = true;
                    component.m_storedEnemyGuid = nearestEnemy.EnemyGuid;
                    component.m_wasBlackPhantom = nearestEnemy.IsBlackPhantom;
                    GameManager.Instance.StartCoroutine(SuckUpEnemy(nearestEnemy, obj, this.LastOwner));
                }
                else
                {
                    component.m_containsEnemy   = false;
                    component.m_storedEnemyGuid = string.Empty;
                    component.m_wasBlackPhantom = false;
                    if (component.m_Debug && nearestEnemy == null)
                    {
                        ETGModConsole.Log("[Monster_Ball] No enemies in room!");
                    }
                    else if (component.m_Debug && nearestEnemy != null && distance > component.EnemySearchRadius)
                    {
                        ETGModConsole.Log("[Monster_Ball] No enemy in range!");
                    }
                    return;
                }
            }
            catch (Exception)
            {
                if (component.m_Debug)
                {
                    ETGModConsole.Log("[Monster Ball] Exception in HandleTossedBallGrounded!");
                }
                component.m_containsEnemy   = false;
                component.m_storedEnemyGuid = string.Empty;
                component.m_wasBlackPhantom = false;
            }
        }
Beispiel #3
0
        private void EnemyModRandomizer(AIActor targetActor)
        {
            // Finding too many issues being caused with Bosses to allow shader modifications on them.
            if (targetActor.healthHaver != null && targetActor.healthHaver.IsBoss)
            {
                return;
            }

            bool hasAltSkin = false;
            bool hasShader  = false;

            if (GameManager.Instance.Dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.PHOBOSGEON)
            {
                if (targetActor.EnemyGuid == "ba928393c8ed47819c2c5f593100a5bc")
                {
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.StoneCubeCollection_West);
                }
            }

            if (ChaosConsole.isHardMode | ChaosConsole.isUltraMode)
            {
                if (ChaosLists.PreventBeingJammedOverrideList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventBlackPhantom = true;
                }
                if (ChaosLists.PreventDeathOnBossKillList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventAutoKillOnBossDeath = true;
                }
                if (targetActor.EnemyGuid == "eeb33c3a5a8e4eaaaaf39a743e8767bc")
                {
                    targetActor.AlwaysShowOffscreenArrow = true;
                }

                if ((targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | targetActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259") && UnityEngine.Random.value < 0.3f)
                {
                    if (RedShotGunMan.BootlegRedShotGunManCollection == null)
                    {
                        RedShotGunMan.Init();
                    }
                    targetActor.optionalPalette             = null;
                    targetActor.procedurallyOutlined        = false;
                    targetActor.sprite.OverrideMaterialMode = tk2dBaseSprite.SpriteMaterialOverrideMode.NONE;
                    targetActor.sprite.renderer.material.SetTexture("_PaletteTex", null);
                    FieldInfo field = typeof(AIActor).GetField("m_isPaletteSwapped", BindingFlags.Instance | BindingFlags.NonPublic);
                    field.SetValue(targetActor, false);
                    if (targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47")
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RedShotGunMan.BootlegRedShotGunManCollection);
                    }
                    else
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BlueShotGunMan.BootlegBlueShotGunManCollection);
                    }
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if ((targetActor.EnemyGuid == "01972dee89fc4404a5c408d50007dad5" | targetActor.EnemyGuid == "db35531e66ce41cbb81d507a34366dfe") && UnityEngine.Random.value < 0.3f)
                {
                    float Selector = UnityEngine.Random.Range(0, 3);
                    if (Selector < 1)
                    {
                        if (BulletMan.BootlegBulletManCollection == null)
                        {
                            BulletMan.Init(targetActor);
                        }
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManMonochromeCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("1-Bit " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 1)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManUpsideDownCollection);
                        targetActor.OverrideDisplayName = ("Bizarro " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 2)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletMan.BootlegBulletManCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    return;
                }
                if (targetActor.EnemyGuid == "88b6b6a93d4b4234a67844ef4728382c" && UnityEngine.Random.value < 0.32f)
                {
                    if (BulletManBandana.BootlegBulletManBandanaCollection == null)
                    {
                        BulletManBandana.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletManBandana.BootlegBulletManBandanaCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if (targetActor.EnemyGuid == "14ea47ff46b54bb4a98f91ffcffb656d" && BraveUtility.RandomBool())
                {
                    if (RatGrenade.RatGrenadeCollection == null)
                    {
                        RatGrenade.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RatGrenade.RatGrenadeCollection);
                    targetActor.healthHaver.gameObject.AddComponent <ChaosExplodeOnDeath>();
                    ExplodeOnDeath RatExplodeComponent = targetActor.healthHaver.gameObject.GetComponent <ExplodeOnDeath>();
                    RatExplodeComponent.explosionData            = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().explosionData;
                    RatExplodeComponent.deathType                = OnDeathBehavior.DeathType.Death;
                    RatExplodeComponent.triggerName              = string.Empty;
                    RatExplodeComponent.immuneToIBombApp         = false;
                    RatExplodeComponent.LinearChainExplosion     = false;
                    RatExplodeComponent.LinearChainExplosionData = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().LinearChainExplosionData;
                    targetActor.CorpseObject = null;
                    hasAltSkin = true;
                    return;
                }

                if (targetActor.EnemyGuid == "2feb50a6a40f4f50982e89fd276f6f15" && BraveUtility.RandomBool())
                {
                    if (Bullat.BootlegBullatCollection == null)
                    {
                        Bullat.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: Bullat.BootlegBullatCollection);
                    AIActor TinyBlobulord = EnemyDatabase.GetOrLoadByGuid("d1c9781fdac54d9e8498ed89210a0238");
                    targetActor.behaviorSpeculator.OtherBehaviors    = TinyBlobulord.behaviorSpeculator.OtherBehaviors;
                    targetActor.behaviorSpeculator.TargetBehaviors   = TinyBlobulord.behaviorSpeculator.TargetBehaviors;
                    targetActor.behaviorSpeculator.OverrideBehaviors = TinyBlobulord.behaviorSpeculator.OverrideBehaviors;
                    targetActor.behaviorSpeculator.AttackBehaviors   = TinyBlobulord.behaviorSpeculator.AttackBehaviors;
                    targetActor.behaviorSpeculator.MovementBehaviors = TinyBlobulord.behaviorSpeculator.MovementBehaviors;
                    targetActor.DiesOnCollison       = true;
                    targetActor.procedurallyOutlined = false;
                    targetActor.OverrideDisplayName  = ("Bootleg " + targetActor.GetActorName());
                    hasAltSkin = true;
                    return;
                }

                if (!hasAltSkin && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4")
                {
                    if (UnityEngine.Random.value <= 0.2f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeHologram(targetActor, BraveUtility.RandomBool());
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.16f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.ApplySpaceShader(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.15f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeRainbow(targetActor);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.1f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeCosmicHorror(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.065f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeGalaxy(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                }
            }

            if (!hasAltSkin && !hasShader && ChaosConsole.GlitchEnemies && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4" && !targetActor.IsBlackPhantom && UnityEngine.Random.value <= ChaosConsole.GlitchRandomActors)
            {
                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);

                if (!targetActor.sprite.usesOverrideMaterial && !ChaosLists.DontGlitchMeList.Contains(targetActor.EnemyGuid))
                {
                    ChaosShaders.Instance.BecomeGlitched(targetActor, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RnadomColorIntensityFloat);
                    if (!targetActor.healthHaver.IsBoss && !ChaosLists.blobsAndCritters.Contains(targetActor.EnemyGuid) && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null)
                    {
                        if (UnityEngine.Random.value <= 0.25)
                        {
                            targetActor.gameObject.AddComponent <ChaosSpawnGlitchObjectOnDeath>();
                        }
                    }
                    ChaosGlitchedEnemies.GlitchExistingEnemy(targetActor);
                    if (!ChaosConsole.randomEnemySizeEnabled)
                    {
                        if (targetActor.healthHaver != null)
                        {
                            if (!targetActor.healthHaver.IsBoss)
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.5f, null, false);
                            }
                            else
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.25f, null, false);
                            }
                        }
                    }
                    if (UnityEngine.Random.value <= 0.1f && targetActor.EnemyGuid != "4d37ce3d666b4ddda8039929225b7ede" && targetActor.EnemyGuid != "19b420dec96d4e9ea4aebc3398c0ba7a" && targetActor.GetComponent <ExplodeOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchEnemyOnDeath>() == null)
                    {
                        try { targetActor.gameObject.AddComponent <ChaosExplodeOnDeath>(); } catch (Exception) { }
                    }
                }
                return;
            }
        }