Exemple #1
0
        public IEnumerator FireGAU()
        {
            isFiring = true;
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            //float direction = (hc_instance.cState.facingRight) ? 315 : 225;
            //DirectionalOrientation orientation = DirectionalOrientation.Diagonal;
            float direction = OrientationHandler.finalDegreeDirection;
            DirectionalOrientation orientation = OrientationHandler.directionOrientation;

            AudioHandler.instance.PlayGunSoundEffect("gatlinggun");
            for (int b = 0; b < 14; b++)
            {
                GameObject bullet = HollowPointPrefabs.SpawnBulletFromKnight(direction, orientation);
                HeatHandler.IncreaseHeat(1.5f);
                BulletBehaviour hpbb = bullet.GetComponent <BulletBehaviour>();
                hpbb.bulletOriginPosition = bullet.transform.position; //set the origin position of where the bullet was spawned
                hpbb.specialAttrib        = "DungExplosionSmall";
                hpbb.bulletSpeedMult     += 1.5f;

                HollowPointSprites.StartGunAnims();
                HollowPointSprites.StartFlash();
                HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 1);

                Destroy(bullet, 1f);
                yield return(new WaitForSeconds(0.03f)); //0.12f This yield will determine the time inbetween shots
            }

            yield return(new WaitForSeconds(0.02f));

            isFiring = false;
        }
Exemple #2
0
        //Delete soon, this is pretty much unused
        public IEnumerator ConcussShot()
        {
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            HeatHandler.IncreaseHeat(1.1f);


            //set the origin position of where the bullet was spawned

            HollowPointSprites.StartGunAnims();
            HollowPointSprites.StartFlash();
            HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 2);

            slowWalkDisableTimer = 14f;
            AudioHandler.PlayGunSounds("sniper");

            float direction = OrientationHandler.finalDegreeDirection; //90 degrees
            DirectionalOrientation orientation = OrientationHandler.directionOrientation;

            int   pellets                = 3;
            float coneDegree             = 15;
            float angleToSpawnBullet     = direction - (coneDegree / 2); //90 - (30 / 2) = 75, start at 75 degrees
            float angleIncreasePerPellet = coneDegree / (pellets + 2);   // 30 / (5 + 2) = 4.3, move angle to fire for every pellet by 4.3 degrees

            angleToSpawnBullet = angleToSpawnBullet + angleIncreasePerPellet;

            //Checks if the player is firing upwards, and enables the x offset so the bullets spawns directly ontop of the knight
            //from the gun's barrel instead of spawning to the upper right/left of them
            bool fixYOrientation = (direction == 270 || direction == 90) ? true : false;

            for (int i = 0; i < pellets; i++)
            {
                yield return(new WaitForEndOfFrame());

                GameObject      bullet = HollowPointPrefabs.SpawnBullet(angleToSpawnBullet, orientation);
                BulletBehaviour hpbb   = bullet.GetComponent <BulletBehaviour>();
                hpbb.fm = FireModes.Concuss;
                hpbb.bulletOriginPosition = bullet.transform.position;
                hpbb.pierce = true;
                //hpbb.pierce = PlayerData.instance.equippedCharm_13;
                bullet.transform.localScale = new Vector3(2f, 2f, 0.1f);


                angleToSpawnBullet += angleIncreasePerPellet;
                Destroy(bullet, 0.07f);
            }

            yield return(new WaitForSeconds(0.05f));

            isFiring = false;

            yield return(new WaitForSeconds(0.02f));

            isFiring = false;
        }
Exemple #3
0
        public IEnumerator BurstShot(int burst)
        {
            hc_instance.TakeMP(Stats.instance.SoulCostPerShot());
            HeatHandler.IncreaseHeat(15);
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            float direction = OrientationHandler.finalDegreeDirection;
            DirectionalOrientation orientation = OrientationHandler.directionOrientation;

            for (int i = 0; i < burst; i++)
            {
                GameObject      bullet = HollowPointPrefabs.SpawnBulletFromKnight(direction, orientation);
                BulletBehaviour hpbb   = bullet.GetComponent <BulletBehaviour>();
                hpbb.bulletDamage          = Stats.instance.current_damagePerShot;
                hpbb.bulletDamageScale     = Stats.instance.current_damagePerLevel;
                hpbb.gunUsed               = Stats.instance.currentEquippedGun;
                hpbb.noDeviation           = (PlayerData.instance.equippedCharm_14 && HeroController.instance.cState.onGround) ? true : false;
                hpbb.piercesEnemy          = PlayerData.instance.equippedCharm_13;
                hpbb.bulletOriginPosition  = bullet.transform.position;
                hpbb.bulletSpeed           = Stats.instance.current_bulletVelocity;
                hpbb.bulletDegreeDirection = direction;
                hpbb.size = Stats.instance.currentEquippedGun.bulletSize;

                bool sapperBuffs = (Stats.instance.current_class == WeaponSubClass.SABOTEUR && Stats.instance.infusionActivated);
                hpbb.appliesDamageOvertime = (Stats.instance.infusionActivated && PlayerData.instance.equippedCharm_35);
                hpbb.bulletSpeed           = (sapperBuffs) ? Stats.instance.current_bulletVelocity * 1.20f : Stats.instance.current_bulletVelocity;
                hpbb.piercesEnemy          = (PlayerData.instance.equippedCharm_25);

                AudioHandler.instance.PlayGunSoundEffect(Stats.instance.currentEquippedGun.gunName.ToString());
                HollowPointSprites.StartGunAnims();
                HollowPointSprites.StartFlash();
                HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 1);

                Destroy(bullet, Stats.instance.current_bulletLifetime);

                yield return(new WaitForSeconds(0.055f));

                isFiring = false;

                if (h_state.dashing)
                {
                    break;
                }
            }
            HeatHandler.IncreaseHeat(Stats.instance.current_heatPerShot);

            isFiring = false;
        }
Exemple #4
0
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_HitHook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Alternative hit damages from other sources like weaver or explosions

            string srcName = hitInstance.Source.name;

            Log("[DamageOverride] Source Name is " + srcName);
            if (srcName.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 15 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Damager"))
            {
                //Glowing Womblings
                HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Slash"))
            {
                Log("Player is slashing!");
                hitInstance.DamageDealt = 2 + (PlayerData.instance.nailSmithUpgrades * 2);
                orig(self, hitInstance);
                return;
            }
            else if (!srcName.Contains("bullet"))
            {
                orig(self, hitInstance);
                return;
            }

            BulletBehaviour hpbb = hitInstance.Source.GetComponent <BulletBehaviour>();
            Vector3         bulletOriginPosition = hitInstance.Source.GetComponent <BulletBehaviour>().bulletOriginPosition;
            int             cardinalDirection    = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));

            int damage      = Stats.CalculateDamage(bulletOriginPosition, self.transform.position, hpbb);
            int soulGainAmt = Stats.CalculateSoulGain();

            //Log("DamageCalculator, damage dealt is " + damage + " against " + self.name);
            StartCoroutine(SplatterBlood(self.gameObject, 1, cardinalDirection * 90));

            HealthManagerOverride.HitEnemy(self, damage, BulletBehaviour.bulletDummyHitInstance, soulGainAmt, hpbb);
        }
Exemple #5
0
        public IEnumerator SpreadShot()
        {
            hc_instance.TakeMP(Stats.instance.SoulCostPerShot());
            //HeatHandler.IncreaseHeat(50);
            GameCameras.instance.cameraShakeFSM.SendEvent("SmallShake");
            int   pellets           = 6;
            float coneSpread        = 40;
            float coneSpreadDelta   = coneSpread / (pellets + 1);
            float direction         = OrientationHandler.finalDegreeDirection;
            float coneStart         = direction - (coneSpread / 2);
            float pelletSpawnDegree = coneStart + coneSpreadDelta;

            DirectionalOrientation orientation = OrientationHandler.directionOrientation;

            AudioHandler.instance.PlayGunSoundEffect(Stats.instance.currentEquippedGun.gunName.ToString());
            HollowPointSprites.StartGunAnims();
            HollowPointSprites.StartFlash();
            HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 1);

            for (int i = 0; i < pellets; i++)
            {
                GameObject      bullet = HollowPointPrefabs.SpawnBulletFromKnight(direction, orientation);
                BulletBehaviour hpbb   = bullet.GetComponent <BulletBehaviour>();
                hpbb.bulletDamage          = Stats.instance.current_damagePerShot;
                hpbb.bulletDamageScale     = Stats.instance.current_damagePerLevel;
                hpbb.gunUsed               = Stats.instance.currentEquippedGun;
                hpbb.bulletOriginPosition  = bullet.transform.position;
                hpbb.bulletSpeed           = Stats.instance.current_bulletVelocity;
                hpbb.bulletDegreeDirection = pelletSpawnDegree + UnityEngine.Random.Range(-3f, 3f);;  //direction + UnityEngine.Random.Range(-20f, 20f);
                pelletSpawnDegree         += coneSpreadDelta;
                hpbb.size         = Stats.instance.currentEquippedGun.bulletSize;
                hpbb.piercesEnemy = true;

                bool sapperBuffs = (Stats.instance.current_class == WeaponSubClass.SABOTEUR && Stats.instance.infusionActivated);
                hpbb.appliesDamageOvertime = (Stats.instance.infusionActivated && PlayerData.instance.equippedCharm_35);
                hpbb.bulletSpeed           = (sapperBuffs) ? Stats.instance.current_bulletVelocity * 1.20f : Stats.instance.current_bulletVelocity;

                Destroy(bullet, Stats.instance.current_bulletLifetime + UnityEngine.Random.Range(-0.03f, 0.03f));
            }
            //HeatHandler.IncreaseHeat(Stats.instance.current_heatPerShot);

            yield return(null);

            isFiring = false;
        }
Exemple #6
0
        public IEnumerator SingleShot()
        {
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            HeatHandler.IncreaseHeat(20f);

            float direction = OrientationHandler.finalDegreeDirection;
            DirectionalOrientation orientation = OrientationHandler.directionOrientation;
            GameObject             bullet      = HollowPointPrefabs.SpawnBullet(direction, orientation);

            BulletBehaviour hpbb = bullet.GetComponent <BulletBehaviour>();

            hpbb.fm = FireModes.Single;

            //Charm 14 Steady Body
            hpbb.noDeviation = (PlayerData.instance.equippedCharm_14 && HeroController.instance.cState.onGround) ? true : false;
            //Charm 13 Mark of Pride gives perfect accuracy and pierce
            hpbb.perfectAccuracy = (PlayerData.instance.equippedCharm_13 && (HeatHandler.currentHeat < 10)) ? true : false;
            hpbb.pierce          = PlayerData.instance.equippedCharm_13;

            //set the origin position of where the bullet was spawned
            hpbb.bulletOriginPosition = bullet.transform.position;

            Destroy(bullet, 0.3f);

            HollowPointSprites.StartGunAnims();
            HollowPointSprites.StartFlash();
            HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 1);

            slowWalkDisableTimer = 14f;

            string weaponType = PlayerData.instance.equippedCharm_13 ? "sniper" : "rifle";

            AudioHandler.PlayGunSounds("rifle");
            if (weaponType == "sniper")
            {
                bullet.transform.localScale = new Vector3(1.8f, 1.8f, 0.1f);
            }

            yield return(new WaitForSeconds(0.02f));

            isFiring = false;
        }
Exemple #7
0
        //========================================FIRE SUPPORT SPAWN METHODS====================================

        //Regular steel rain (non tracking)
        public static IEnumerator StartSteelRainNoTrack(Vector3 targetCoordinates, int totalShells)
        {
            int artyDirection = (HeroController.instance.cState.facingRight) ? 1 : -1;

            Modding.Logger.Log("SPELL CONTROL STEEL RAIN NO TRACKING");
            float shellAimPosition = 5 * artyDirection; //Allows the shell to "walk" slowly infront of the player

            for (int shells = 0; shells < totalShells; shells++)
            {
                //GameObject shell = Instantiate(HollowPointPrefabs.bulletPrefab, targetCoordinates + new Vector3(Range(-5, 5), Range(25, 50), -0.1f), new Quaternion(0, 0, 0, 0));
                GameObject shell = HollowPointPrefabs.SpawnBulletAtCoordinate(270, HeroController.instance.transform.position + new Vector3(shellAimPosition, 30, -0.1f), 0);
                shellAimPosition += 3 * artyDirection;
                BulletBehaviour hpbb = shell.GetComponent <BulletBehaviour>();
                hpbb.isFireSupportBullet = true;
                hpbb.ignoreCollisions    = true;
                hpbb.targetDestination   = targetCoordinates + new Vector3(0, Range(3f, 6f), -0.1f);
                shell.SetActive(true);
                yield return(new WaitForSeconds(0.5f));
            }
        }
        public static IEnumerator QuakeAbility_DangerClose(int charges)
        {
            int     totalShells = 3 * charges;
            Vector3 knightPos   = HeroController.instance.transform.position;

            AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.MortarWhistleSFXGO, alteredPitch: false);
            yield return(new WaitForSeconds(0.65f));

            for (int shells = 0; shells < totalShells; shells++)
            {
                //GameObject shell = Instantiate(HollowPointPrefabs.bulletPrefab, targetCoordinates + new Vector3(Range(-5, 5), Range(25, 50), -0.1f), new Quaternion(0, 0, 0, 0));
                GameObject      shell = HollowPointPrefabs.SpawnBulletAtCoordinate(270, knightPos + new Vector3(Range(-6, 6), 80, -1f), 0);
                BulletBehaviour hpbb  = shell.GetComponent <BulletBehaviour>();
                hpbb.fuseTimerXAxis      = true;
                hpbb.targetDestination   = knightPos + new Vector3(0, Range(2f, 7f), -0.1f);
                hpbb.ignoreAllCollisions = true;
                shell.AddComponent <BulletIsExplosive>().explosionType = BulletIsExplosive.ExplosionType.DungExplosion;
                shell.SetActive(true);
                yield return(new WaitForSeconds(0.05f));
            }
        }
Exemple #9
0
        public IEnumerator SpreadShot(int pellets)
        {
            GameCameras.instance.cameraShakeFSM.SendEvent("SmallShake"); //SmallShake
            HollowPointSprites.StartGunAnims();
            HollowPointSprites.StartFlash();
            HollowPointSprites.StartMuzzleFlash(OrientationHandler.finalDegreeDirection, 1);
            AudioHandler.PlayGunSounds("Shotgun");

            float direction = OrientationHandler.finalDegreeDirection; //90 degrees
            DirectionalOrientation orientation = OrientationHandler.directionOrientation;

            float coneDegree             = 40;
            float angleToSpawnBullet     = direction - (coneDegree / 2); //90 - (30 / 2) = 75, start at 75 degrees
            float angleIncreasePerPellet = coneDegree / (pellets + 2);   // 30 / (5 + 2) = 4.3, move angle to fire for every pellet by 4.3 degrees

            angleToSpawnBullet = angleToSpawnBullet + angleIncreasePerPellet;

            //Checks if the player is firing upwards, and enables the x offset so the bullets spawns directly ontop of the knight
            //from the gun's barrel instead of spawning to the upper right/left of them
            bool fixYOrientation = (direction == 270 || direction == 90) ? true : false;

            for (int i = 0; i < pellets; i++)
            {
                yield return(new WaitForEndOfFrame());

                GameObject      bullet = HollowPointPrefabs.SpawnBullet(angleToSpawnBullet, orientation);
                BulletBehaviour hpbb   = bullet.GetComponent <BulletBehaviour>();
                hpbb.bulletDegreeDirection += UnityEngine.Random.Range(-3, 3);
                //hpbb.pierce = PlayerData.instance.equippedCharm_13;
                bullet.transform.localScale = new Vector3(0.2f, 0.2f, 0.1f);
                hpbb.specialAttrib          = "Explosion";

                angleToSpawnBullet += angleIncreasePerPellet;
                Destroy(bullet, 0.7f);
            }

            yield return(new WaitForSeconds(0.3f));

            AttackHandler.isFiring = false;
        }
        public void State_DashSlash()
        {
            AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.ThrowDaggerSFXGO);
            float           startingDegree = HeroController.instance.cState.facingRight ? 0 : 180;
            GameObject      knife          = HollowPointPrefabs.SpawnBulletFromKnight(120, DirectionalOrientation.Horizontal);
            BulletBehaviour hpbb           = knife.GetComponent <BulletBehaviour>();

            hpbb.gunUsed               = Stats.instance.currentEquippedGun;
            hpbb.bulletDamage          = 25;
            hpbb.bulletDamageScale     = 5;
            hpbb.noDeviation           = true;
            hpbb.bulletOriginPosition  = knife.transform.position;
            hpbb.bulletSpeed           = 45f;
            hpbb.bulletDegreeDirection = startingDegree;
            hpbb.isDagger              = true;
            hpbb.piercesEnemy          = true;
            hpbb.size         = new Vector3(0.65f, 0.65f, 1);
            hpbb.bulletSprite = BulletBehaviour.BulletSpriteType.dagger;
            knife             = AddDaggerTrail(knife);
            Destroy(knife, 1f);
            Stats.instance.DisableNailArts(PlayerData.instance.equippedCharm_26 ? 6f : 12f);
        }
        public IEnumerator QuakeAbility_BulletSpray(int charges)
        {
            AudioHandler.instance.PlayGunSoundEffect("gatlinggun");
            for (int i = 0; i < 10 * charges; i++)
            {
                float           degreeDeviation = Range(0, 180);
                GameObject      bullet          = HollowPointPrefabs.SpawnBulletFromKnight(Range(0, 180), DirectionalOrientation.Center);
                BulletBehaviour hpbb            = bullet.GetComponent <BulletBehaviour>();
                hpbb.gunUsed               = Stats.instance.currentEquippedGun;
                hpbb.bulletDamage          = 2;
                hpbb.bulletDamageScale     = 1;
                hpbb.noDeviation           = true;
                hpbb.bulletOriginPosition  = bullet.transform.position;
                hpbb.bulletSpeed           = 50f;
                hpbb.bulletDegreeDirection = degreeDeviation;
                hpbb.piercesEnemy          = true;
                //hpbb.piercesWalls = true;
                hpbb.size = new Vector3(1f, 0.65f, 1);
                Destroy(bullet, 0.25f);

                yield return(new WaitForSeconds(0.01f));
            }
        }
        public static IEnumerator ScreamAbility_CreepingAirburst(int charges)
        {
            Vector3 targetCoordinates = HeroController.instance.transform.position;
            int     totalShells       = 2 + 1 * charges;
            int     artyDirection     = (HeroController.instance.cState.facingRight) ? 1 : -1;
            float   shellAimPosition  = 5 * artyDirection; //Allows the shell to "walk" slowly infront of the player

            AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.MortarWhistleSFXGO, alteredPitch: false);
            yield return(new WaitForSeconds(0.65f));

            for (int shells = 0; shells < totalShells; shells++)
            {
                GameObject shell = HollowPointPrefabs.SpawnBulletAtCoordinate(270, HeroController.instance.transform.position + new Vector3(shellAimPosition, 80, -1f), 0);
                shellAimPosition += 2 * artyDirection;
                BulletBehaviour hpbb = shell.GetComponent <BulletBehaviour>();
                hpbb.fuseTimerXAxis      = true;
                hpbb.ignoreAllCollisions = true;
                hpbb.targetDestination   = targetCoordinates + new Vector3(0, Range(5f, 6f), -0.1f);
                //shell.AddComponent<BulletIsExplosive>().explosionType = BulletIsExplosive.ExplosionType.ArtilleryShell;
                shell.AddComponent <BulletIsExplosive>().explosionType = BulletIsExplosive.ExplosionType.ArtilleryShell;
                shell.SetActive(true);
                yield return(new WaitForSeconds(0.30f));
            }
        }
Exemple #13
0
        //+++DAMAGE OVERRIDE+++
        public static void DamageEnemyOverride(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb)
        {
            //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more
            if (targetHP == null)
            {
                return;
            }

            int        cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));
            GameObject blockHitPrefab    = targetHP.GetAttr <GameObject>("blockHitPrefab");

            bool specialEnemy = (targetHP.name.Contains("Charger"));

            if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false);
                GameObject blockHit = blockHitPrefab.Spawn();
                blockHit.transform.position = targetHP.transform.position;
                blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection));
                return;
            }

            if (false && !targetHP.IsInvincible) //enable disable damage overtime
            {
                EnemyDamageOvertime dm = targetHP.gameObject.GetComponent <EnemyDamageOvertime>();
                if (dm == null)
                {
                    targetHP.gameObject.AddComponent <EnemyDamageOvertime>();
                }
                else
                {
                    dm.IncreaseStack();
                }
            }

            //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler"));

            /*
             * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25)
             * {
             *  GameObject blockHit = blockHitPrefab.Spawn();
             *  blockHit.transform.position = targetHP.transform.position;
             * return;
             * }
             */
            if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs
            {
                damageDealt = damageDealt * 4;
            }

            Recoil recoil = targetHP.gameObject.GetComponent <Recoil>();

            //if (recoil != null && PlayerData.instance.equippedCharm_15)
            if (recoil != null)
            {
                recoil.RecoilByDirection(cardinalDirection, 0.25f);
            }

            /*
             * Mostly code copied from the healthmanager class itself.
             */

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject HitPrefab    = targetHP.GetAttr <GameObject>("strikeNailPrefab");
            GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab");
            Vector3?   effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (HitPrefab != null && effectOrigin != null)
            {
                HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            if (ImpactPrefab != null && effectOrigin != null)
            {
                ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>();

            if (f != null)
            {
                f.flashWhiteQuick();
            }

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);

            // Actually do damage to target.
            LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + rand.Next(1, 4) + ".wav", out AudioClip hurtSound);
            HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound);

            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= damageDealt; // the actual damage
                if (hpbb.canGainEnergyCharges)
                {
                    HeroController.instance.AddMPCharge(Stats.instance.current_soulGainedPerHit);
                }
                Stats.instance.IncreaseAdrenalineChargeEnergy();
                //TODO: change this audio source location to the sound handler
                AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.EnemyHitSFXGO);
            }
            // Trigger Enemy Kill
            if (targetHP.hp <= 0f)
            {
                EnemyDeathEvent(targetHP, cardinalDirection, true);
                return;
            }

            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }

            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun");
            //if (stunControlFSM != null) stunControlFSM.SendEvent("STUN DAMAGE");
        }
        public IEnumerator ScreamAbility_SparkingBullets(int charges)
        {
            int        sparkAmount  = 20 * charges;
            GameObject closestEnemy = null;

            while (sparkAmount > 0)
            {
                yield return(new WaitForSeconds(0.12f));

                Stats.instance.enemyList.RemoveAll(enemy => enemy == null);

                //Create a list of valid targets from the enemy list, meaning anyone closer than 10 units
                List <GameObject> validTargets = new List <GameObject>();
                while (Stats.instance.enemyList.Count <= 0 || HeroController.instance.cState.transitioning)
                {
                    yield return(null);
                }
                foreach (GameObject enemy in Stats.instance.enemyList)
                {
                    Vector2 knightPos = HeroController.instance.transform.position;
                    Vector2 enemyPos  = enemy.transform.position;
                    float   enemyDistanceFromKnight = Vector3.Distance(knightPos, enemyPos);
                    if (enemyDistanceFromKnight < 8)
                    {
                        validTargets.Add(enemy);
                    }
                }

                if (validTargets.Count <= 0)
                {
                    continue;                          //If there is no valid tagets, start all over again;
                }
                //For each of the valid enemies, find the closest one to the knight
                closestEnemy = null;
                float closetEnemyDistance = float.MaxValue;
                foreach (GameObject validTarget in validTargets)
                {
                    Vector2 knightPos     = HeroController.instance.transform.position;
                    Vector2 enemyPos      = validTarget.transform.position;
                    float   enemyDistance = Vector3.Distance(knightPos, enemyPos);
                    if (Vector3.Distance(knightPos, enemyPos) < closetEnemyDistance)
                    {
                        closestEnemy        = validTarget;
                        closetEnemyDistance = enemyDistance;
                    }
                }

                Vector2 knightPos2        = HeroController.instance.transform.position;
                Vector2 enemyPos2         = closestEnemy.transform.position;
                double  fireBulletAtAngle = Math.Atan2(enemyPos2.y - knightPos2.y, enemyPos2.x - knightPos2.x) * 180 / Math.PI;

                AudioHandler.instance.PlayGunSoundEffect("shrapnel");
                GameObject      spark = HollowPointPrefabs.SpawnBulletFromKnight((float)fireBulletAtAngle, DirectionalOrientation.Center);
                BulletBehaviour hpbb  = spark.GetComponent <BulletBehaviour>();
                hpbb.gunUsed               = Stats.instance.currentEquippedGun;
                hpbb.bulletDamage          = 2;
                hpbb.bulletDamageScale     = 2;
                hpbb.noDeviation           = true;
                hpbb.bulletOriginPosition  = spark.transform.position;
                hpbb.bulletSpeed           = 40f;
                hpbb.bulletDegreeDirection = (float)fireBulletAtAngle + Range(-3, 3);
                hpbb.size         = new Vector3(0.8f, 0.8f, 1);
                hpbb.piercesWalls = true;
                Destroy(spark, 1);
                sparkAmount -= 1;

                HollowPointSprites.StartFlash();
            }
            yield return(null);
        }
Exemple #15
0
        // This function does damage to the enemy using the damage numbers given by the weapon type
        public static void HitEnemy(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb)
        {
            //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more
            if (targetHP == null)
            {
                return;
            }

            int        cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));
            GameObject blockHitPrefab    = targetHP.GetAttr <GameObject>("blockHitPrefab");

            bool specialEnemy = (targetHP.name.Contains("Charger"));

            if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy || damageDealt <= 0)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false);
                GameObject blockHit = blockHitPrefab.Spawn();
                blockHit.transform.position = targetHP.transform.position;
                blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection));
                return;
            }

            if (damageDealt <= 0)
            {
                return;
            }
            //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler"));

            /*
             * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25)
             * {
             *  GameObject blockHit = blockHitPrefab.Spawn();
             *  blockHit.transform.position = targetHP.transform.position;
             * return;
             * }
             */

            if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs
            {
                damageDealt = damageDealt * 4;
            }

            Recoil recoil = targetHP.gameObject.GetComponent <Recoil>();

            //if (recoil != null && PlayerData.instance.equippedCharm_15)
            if (recoil != null)
            {
                recoil.RecoilByDirection(cardinalDirection, 0.25f);
            }

            /*
             * Mostly code copied from the healthmanager class itself.
             */

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject HitPrefab    = targetHP.GetAttr <GameObject>("strikeNailPrefab");
            GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab");
            Vector3?   effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (HitPrefab != null && effectOrigin != null)
            {
                HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            if (ImpactPrefab != null && effectOrigin != null)
            {
                ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }

            SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>();

            if (f != null)
            {
                f.flashWhiteQuick();
            }

            //Log("SEVERITY: " + ds + " DAMAGE: " + damageDealt);

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false);

            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);

            // Actually do damage to target.

            LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + soundRandom.Next(1, 4) + ".wav", out AudioClip hurtSound);
            HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound);

            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= damageDealt; // the actual damage

                //int sg = (ds.Equals(DamageSeverity.Minor)) ? 0 : soulGain;
                HeroController.instance.AddMPCharge(6);
                Stats.IncreaseAdrenalinePoints(damageDealt);
            }

            // Trigger Kill animation
            if (targetHP.hp <= 0f)
            {
                LoadAssets.sfxDictionary.TryGetValue("enemydead" + soundRandom.Next(1, 4) + ".wav", out AudioClip deadSound);
                HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(deadSound);
                targetHP.Die(cardinalDirection * 90, AttackTypes.Spell, true);
                HeroController.instance.AddMPCharge(4);
                GameManager.instance.FreezeMoment(1);
                return;
            }

            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }


            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component =>
                                                                                                            component.FsmName == "Stun Control" || component.FsmName == "Stun");

            if (stunControlFSM != null)
            {
                //stunControlFSM.SendEvent("STUN DAMAGE");
            }

            /*
             * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake.
             */
        }
Exemple #16
0
        public static int CalculateDamage(Vector3 bulletOriginPosition, Vector3 enemyPosition, BulletBehaviour hpbb)
        {
            int dam = 3 + (PlayerData.instance.nailSmithUpgrades * 3);

            return(dam);
        }
Exemple #17
0
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_HitHook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Alternative hit damages from other sources like weaver or explosions
            string srcName = hitInstance.Source.name;

            if (srcName.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 3 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            if (srcName.Contains("Dung"))
            {
                //Explosion damage
                Log("Dung damage!");
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Damager"))
            {
                //Glowing Womblings
                //HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Great Slash") || srcName.Contains("Dash Slash"))
            {
                Log("Player is nail art... ing?");


                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Slash"))
            {
                Log("Player is slashing!");
                hitInstance.DamageDealt = 3 + (PlayerData.instance.nailSmithUpgrades * 3);
                orig(self, hitInstance);
                return;
            }
            else if (!srcName.Contains("bullet"))
            {
                orig(self, hitInstance);
                return;
            }

            BulletBehaviour hpbb = hitInstance.Source.GetComponent <BulletBehaviour>();
            Vector3         bulletOriginPosition = hitInstance.Source.GetComponent <BulletBehaviour>().bulletOriginPosition;
            int             cardinalDirection    = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));

            int damage      = hpbb.bulletDamage + (PlayerData.instance.nailSmithUpgrades * hpbb.bulletDamageScale);
            int soulGainAmt = Stats.SoulGainPerHit();

            //StartCoroutine(SplatterBlood(self.gameObject.transform.position, 1, cardinalDirection * 90));
            if (hpbb.appliesDamageOvertime)
            {
                EnemyDamageOvertime edo = self.gameObject.GetComponent <EnemyDamageOvertime>();

                if (edo == null)
                {
                    self.gameObject.AddComponent <EnemyDamageOvertime>();
                }
                else
                {
                    edo.IncreaseStack();
                }
            }
            DamageEnemyOverride(self, damage, BulletBehaviour.bulletDummyHitInstance, soulGainAmt, hpbb);
        }