Exemple #1
0
        public void HandleFiring(Player player, Vector2 mouseVector)
        {
            MyPlayer modPlayer = player.GetModPlayer <MyPlayer>();

            // minimum charge level is required to fire in the first place, but once you fire, you can keep firing.
            if (ShouldFireBeam(modPlayer))
            {
                // once fired, there's no going back.
                IsFired = true;

                // kill the charge sound if we're firing
                chargeSoundSlotId = SoundHelper.KillTrackedSound(chargeSoundSlotId);

                if (myProjectile == null)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient || Main.myPlayer == player.whoAmI)
                    {
                        // fire the laser!
                        myProjectile = Projectile.NewProjectileDirect(projectile.position + beamCreationOffset, projectile.velocity, mod.ProjectileType(beamProjectileName), GetBeamDamage(), projectile.knockBack, projectile.owner);
                    }
                }

                // increment the fire time, this handles "IsSustainingFire" as well as stating the beam is no longer firable (it is already being fired)
                CurrentFireTime++;

                // if the player has charge left, drain the ball
                if (ChargeLevel >= 0f)
                {
                    ChargeLevel = Math.Max(0f, ChargeLevel - FireDecayRate());

                    if (myProjectile != null) // TODO Temporary fix for two beams crossing
                    {
                        BaseBeam projectileAsBeam = myProjectile.modProjectile as BaseBeam;
                        projectileAsBeam.BeamIntensity = ChargeLevel;
                    }
                }

                // beam is no longer sustainable, and neither is the charge ball
                if (ChargeLevel <= 0f)
                {
                    KillBeam();
                }
            }
        }
        public override void AI()
        {
            if (!player.channel || (chargeLevel >= chargeLimit))
            {
                if (chargeLevel >= 1)
                {
                    float rot = (float)Math.Atan2((Main.mouseY + Main.screenPosition.Y) - projectile.Center.Y, (Main.mouseX + Main.screenPosition.X) - projectile.Center.X);
                    Projectile.NewProjectileDirect(new Vector2(projectile.Center.X, projectile.Center.Y), new Vector2((float)((Math.Cos(rot) * 15)), (float)((Math.Sin(rot) * 15))), mod.ProjectileType("BigBangKamehamehaBlast"), projectile.damage + (chargeLevel * 65), projectile.knockBack, projectile.owner);

                    //ChargeLevel = 0;
                    SoundHelper.PlayCustomSound("Sounds/BasicBeamFire", projectile.Center);

                    projectile.Kill();

                    for (int i = 0; i < 100; i++)
                    {
                        float   angle    = Main.rand.NextFloat(360);
                        float   angleRad = MathHelper.ToRadians(angle);
                        Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad));
                        Dust    tDust    = Dust.NewDustDirect(projectile.position + (position * (20 + 3.0f * projectile.scale)), projectile.width, projectile.height, dustType, 0f, 0f, 213, default(Color), 3.0f);
                        tDust.velocity  = -0.5f * Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2;
                        tDust.noGravity = true;
                    }
                }
                _chargeSoundSlotId = SoundHelper.KillTrackedSound(_chargeSoundSlotId);
            }

            if (!startingCharge)
            {
                startingCharge = true;
                if (!Main.dedServ)
                {
                    _chargeSoundSlotId = SoundHelper.PlayCustomSound("Sounds/EnergyWaveCharge", projectile.Center);
                }
            }

            SoundHelper.UpdateTrackedSound(_chargeSoundSlotId, projectile.Center);
        }
        //private bool _isInitialized = false;
        public override void AI()
        {
            Player    player    = Main.player[projectile.owner];
            ModPlayer modPlayer = player.GetModPlayer <ModPlayer>();

            /*if (!_isInitialized)
             * {
             *  modPlayer.isMassiveBlastCharging = true;
             *  //modPlayer.isMassiveBlastInUse = true;
             *  HeldTime = 1;
             *  _isInitialized = true;
             * }*/

            // cancel channeling if the projectile is maxed
            if (player.channel && projectile.scale > 2.5)
            {
                player.channel = false;
            }

            if (player.channel)
            {
                projectile.scale = BASE_SCALE + SCALE_INCREASE * HeldTime;
                Vector2 projectileOffset = new Vector2(-projectile.width * 0.5f, -projectile.height * 0.5f);
                projectileOffset   += new Vector2(0, -(80 + projectile.scale * 115f));
                projectile.position = player.Center + projectileOffset;
                HeldTime++;

                //Rock effect
                projectile.ai[1]++;
                if (projectile.ai[1] % 7 == 0)
                {
                    Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("StoneBlockDestruction"), projectile.damage, 0f, projectile.owner);
                }
                Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-500, 600), projectile.Center.Y + 1000, 0, -10, mod.ProjectileType("DirtBlockDestruction"), projectile.damage, 0f, projectile.owner);

                if (projectile.timeLeft < 399)
                {
                    projectile.timeLeft = 400;
                }

                MyPlayer.ModPlayer(player).AddKi(-2, true, false);
                player.ApplyChannelingSlowdown();

                // depleted check, release the ball
                if (MyPlayer.ModPlayer(player).IsKiDepleted())
                {
                    player.channel = false;
                }
                if (_soundtimer == 0)
                {
                    _soundInfo = SoundHelper.PlayCustomSound("Sounds/SuperNovaCharge", player, 0.6f);
                }
                _soundtimer++;
                if (_soundtimer > 120)
                {
                    _soundtimer = 0;
                }
            }
            else if (modPlayer.isMassiveBlastCharging)
            {
                modPlayer.isMassiveBlastCharging = false;
                float projectileWidthFactor = projectile.width * projectile.scale / TRAVEL_SPEED_COEFFICIENT;
                projectile.timeLeft    = (int)Math.Ceiling(projectileWidthFactor) + 180;
                projectile.velocity    = Vector2.Normalize(Main.MouseWorld - player.Center) * TRAVEL_SPEED_COEFFICIENT;
                projectile.tileCollide = false;
                projectile.damage     *= (int)Math.Ceiling(projectile.scale / 3f);
                _soundInfo             = SoundHelper.KillTrackedSound(_soundInfo);
                SoundHelper.PlayCustomSound("Sounds/SuperNovaThrow", player, 0.6f);
            }
            projectile.netUpdate  = true;
            projectile.netUpdate2 = true;
        }
Exemple #4
0
        public override void AI()
        {
            Player   player    = Main.player[projectile.owner];
            MyPlayer modPlayer = player.GetModPlayer <MyPlayer>();

            if (!_isInitialized)
            {
                modPlayer.isMassiveBlastCharging = true;
                //modPlayer.isMassiveBlastInUse = true;
                HeldTime       = 1;
                _isInitialized = true;
            }

            if (player.channel && modPlayer.isMassiveBlastCharging)
            {
                projectile.scale    = BASE_SCALE + SCALE_INCREASE * (HeldTime / 3f);
                projectile.position = player.Center + new Vector2(0, -40 - (projectile.scale * 17));
                HeldTime++;

                // reduced from 25.
                for (int d = 0; d < 15; d++)
                {
                    // loop hitch for variance.
                    if (Main.rand.NextFloat() < 0.3f)
                    {
                        continue;
                    }

                    float   angle    = Main.rand.NextFloat(360);
                    float   angleRad = MathHelper.ToRadians(angle);
                    Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad));

                    Dust tDust = Dust.NewDustDirect(projectile.position + (position * (20 + 12.5f * projectile.scale)), projectile.width, projectile.height, 230, 0f, 0f, 213, default(Color), 2.0f);
                    tDust.velocity  = Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2;
                    tDust.noGravity = true;
                }

                //Rock effect
                if (DBZMOD.IsTickRateElapsed(10) && _rocksFloating < MAX_ROCKS)
                {
                    // only some of the time, keeps it a little more varied.
                    if (Main.rand.NextFloat() < 0.6f)
                    {
                        _rocksFloating++;
                        BaseFloatingDestructionProj.SpawnNewFloatingRock(player, projectile);
                    }
                }

                if (projectile.timeLeft < 399)
                {
                    projectile.timeLeft = 400;
                }

                MyPlayer.ModPlayer(player).AddKi(-5, true, false);
                player.ApplyChannelingSlowdown();

                // depleted check, release the ball
                if (MyPlayer.ModPlayer(player).IsKiDepleted())
                {
                    player.channel = false;
                }
                if (_soundtimer == 0)
                {
                    _soundInfo = SoundHelper.PlayCustomSound("Sounds/SpiritBombCharge", player, 0.5f);
                }
                _soundtimer++;
                if (_soundtimer > 120)
                {
                    _soundtimer = 0;
                }
            }
            else if (modPlayer.isMassiveBlastCharging)
            {
                modPlayer.isMassiveBlastCharging = false;
                float projectileWidthFactor = projectile.width * projectile.scale / TRAVEL_SPEED_COEFFICIENT;
                projectile.timeLeft    = (int)Math.Ceiling(projectileWidthFactor) + 180;
                projectile.velocity    = Vector2.Normalize(Main.MouseWorld - player.Center) * TRAVEL_SPEED_COEFFICIENT;
                projectile.tileCollide = false;
                projectile.damage     *= (int)projectile.scale / 2;
                _soundInfo             = SoundHelper.KillTrackedSound(_soundInfo);
                SoundHelper.PlayCustomSound("Sounds/SpiritBombFire", player);
            }
            projectile.netUpdate  = true;
            projectile.netUpdate2 = true;
        }
Exemple #5
0
        public override void PostUpdate()
        {
            hitStunManager.Update();

            if (kiLantern)
            {
                player.AddBuff(mod.BuffType("KiLanternBuff"), 2);
            }
            else
            {
                player.ClearBuff(mod.BuffType("KiLanternBuff"));
            }

            if (isTransforming)
            {
                ssjAuraBeamTimer++;
            }

            if (IsPlayerTransformed())
            {
                lightningFrameTimer += 2;
            }

            if (lightningFrameTimer >= 15)
            {
                lightningFrameTimer = 0;
            }

            //if (!player.IsPlayerTransformed())
            //{
            //    kiDrainAddition = 0;
            //}

            if (TransformationDefinitionManager.IsKaioken(ActiveTransformations))
            {
                kaiokenTimer += 1.5f;
            }

            #region Mastery Messages

            // TODO Reduce CPU time by only handling the current transformation.
            if (player.whoAmI == Main.LocalPlayer.whoAmI && PlayerTransformations.Count > 0 && ActiveTransformations.Count > 0)
            {
                for (int i = 0; i < ActiveTransformations.Count; i++)
                {
                    HandleMasteryEvents(ActiveTransformations[i]);
                }
            }

            #endregion

            if (adamantiteBonus)
            {
                kiDamage += 7;
            }

            if (PlayerTrait != null && PlayerTrait.BuffName != null)
            {
                if (PlayerTrait.CanSee(this))
                {
                    player.AddBuff(PlayerTrait.GetBuffType(mod), 3);
                    player.ClearBuff(mod.BuffType <UnknownTraitBuff>());
                }
                else
                {
                    player.AddBuff(mod.BuffType <UnknownTraitBuff>(), 3);
                }
            }

            if (IsLegendary() && !LSSJAchieved && NPC.downedBoss1)
            {
                player.AddBuff(mod.BuffType("UnknownLegendary"), 3);
            }
            else if (IsLegendary() && LSSJAchieved)
            {
                player.AddBuff(mod.BuffType("LegendaryTrait"), 3);
                player.ClearBuff(mod.BuffType("UnknownLegendary"));
            }

            if (kiRegen >= 1)
            {
                kiRegenTimer++;
            }

            if (kiRegenTimer > 2)
            {
                AddKi(kiRegen, false, false);
                kiRegenTimer = 0;
            }

            if (demonBonusActive)
            {
                demonBonusTimer++;
                if (demonBonusTimer > 300)
                {
                    demonBonusActive = false;
                    demonBonusTimer  = 0;
                    player.AddBuff(mod.BuffType("ArmorCooldown"), 3600);
                }
            }

            if (player.dead && IsPlayerTransformed())
            {
                EndTransformations();
                isTransforming = false;
            }

            if (rageCurrent > 5)
            {
                rageCurrent = 5;
            }

            HandleOverloadCounters();

            overallFormUnlockChance = formUnlockChance - rageCurrent;

            if (overallFormUnlockChance < 2)
            {
                overallFormUnlockChance = 2;
            }

            if (!player.HasBuff(mod.BuffType("ZenkaiBuff")) && zenkaiCharmActive)
            {
                player.AddBuff(mod.BuffType("ZenkaiCooldown"), 7200);
            }

            if (isDashing)
            {
                player.invis = true;
            }

            HandleBlackFusionMultiplier();

            // neuters flight if the player gets immobilized. Note the lack of Katchin Feet buff.
            if (IsPlayerImmobilized() && isFlying)
            {
                isFlying = false;
            }

            HandleMouseOctantAndSyncTracking();

            // flight system moved to PostUpdate so that it can benefit from not being client sided!
            FlightSystem.Update(player);

            // charge activate and charge effects moved to post update so that they can also benefit from not being client sided.
            HandleChargeEffects();

            // aura frame effects moved out of draw pass to avoid being tied to frame rate!

            currentAura = this.GetAuraEffectOnPlayer();

            // save the charging aura for last, and only add it to the draw layer if no other auras are firing
            if (isCharging)
            {
                if (!wasCharging)
                {
                    var chargeAuraEffects = AuraAnimations.createChargeAura;
                    HandleAuraStartupSound(chargeAuraEffects, true);
                }
            }

            if (currentAura != previousAura)
            {
                auraSoundInfo = SoundHelper.KillTrackedSound(auraSoundInfo);
                HandleAuraStartupSound(currentAura, false);
                // reset aura frame and audio timers to 0, this is important
                auraSoundTimer = 0;
                auraFrameTimer = 0;
            }

            IncrementAuraFrameTimers(currentAura);
            HandleAuraLoopSound(currentAura);

            wasCharging  = isCharging;
            previousAura = currentAura;

            CheckPlayerForTransformationStateDebuffApplication();

            ThrottleKi();

            // fires at the end of all the things and makes sure the user is synced to the server with current values, also handles initial state.
            CheckSyncState();

            // Handles nerfing player defense when in Kaioken States
            HandleKaiokenDefenseDebuff();

            // if the player is in mid-transformation, totally neuter horizontal velocity
            // also handle the frame counter advancement here.
            if (isTransformationAnimationPlaying)
            {
                player.velocity = new Vector2(0, player.velocity.Y);

                transformationFrameTimer++;
            }
            else
            {
                transformationFrameTimer = 0;
            }

            KiBar.visible = true;

            if (player.IsCarryingAllDragonBalls() && !wishActive)
            {
                int soundTimer = 0;
                soundTimer++;
                if (soundTimer > 300)
                {
                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/DBReady"));
                    soundTimer = 0;
                }
            }
        }