Beispiel #1
0
        public override void HoldItem(Player player)
        {
            ModSabres.HoldItemManager(player, item, mod.ProjectileType <RaidenSlash>(),
                                      default(Color), 1f, player.itemTime == 0 ? 0f : 1f, customCharge, 8);

            if (player.itemTime == 0)
            {
                float radius = RaidenUtils.GetFocusRadius(player);

                RaidenUtils.DrawDustRadius(player, radius, RaidenUtils.DustAmount(player));

                if (Main.myPlayer == player.whoAmI)
                {
                    Vector2    mouse   = new Vector2(Main.screenPosition.X + Main.mouseX, Main.screenPosition.Y + Main.mouseY);
                    List <NPC> targets = RaidenUtils.GetTargettableNPCs(player.Center, mouse, radius, RaidenUtils.focusTargets);
                    RaidenUtils.DrawOrderedTargets(player, targets);
                }
            }
        }
Beispiel #2
0
        public void ChargeSlashAI(Player player)
        {
            if (targets.Count == 1)
            {
                totalTargetTime = 15;
            }

            setAnimationAndImmunities(player);

            float countf          = targets.Count;
            int   framesPerTarget = (int)Math.Max(1, (float)totalTargetTime / countf);
            float oneFrame        = specialProjFrames / (framesPerTarget * countf); // calculates ro roughly 9 / 30 = 0.3

            // Get current frame, and current target in attack
            int i = (int)(FrameCheck / oneFrame);

            if (i >= framesPerTarget * countf)
            {
                // End frame
                player.Center       = (Vector2)endingPositionCenter;
                player.velocity     = new Vector2(projectile.direction * -7.5f, player.gravDir * -2);
                projectile.timeLeft = 0;

                return;
            }
            else
            {
                // Set camera lerp
                if (player.whoAmI == Main.myPlayer)
                {
                    Main.SetCameraLerp(0.1f, 10);
                }

                // Get the target position, or wait if the target is invalid
                int     iTarget = (int)MathHelper.Clamp((float)i / framesPerTarget, 0, countf - 1);
                NPC     target  = targets[iTarget];
                Vector2 targetBottom;
                if (target == null || !target.active || target.dontTakeDamage)
                {
                    targetBottom = player.Bottom; target = null;
                }
                else
                {
                    // Set target
                    targetBottom = target.Bottom;
                    // and rotate slash
                    Vector2 toTarget = targetBottom - player.Bottom;
                    projectile.rotation = (float)Math.Atan2(toTarget.Y, toTarget.X);
                }

                Vector2 oldBottom = new Vector2(player.Bottom.X, player.Bottom.Y);
                Vector2 vecHeight = new Vector2(0, Player.defaultHeight / -2);

                // Tweening if there is time
                if (framesPerTarget > 1)
                {
                    Vector2 dist = (targetBottom - player.Bottom) * (1f / Math.Max(1, framesPerTarget / 2f));
                    player.Bottom     = player.Bottom + dist;
                    player.velocity.Y = -player.gravDir * 1.5f;

                    int distFactor = (int)(dist.Length() / 4f);
                    RaidenUtils.DrawDustToBetweenVectors(oldBottom + vecHeight, player.Bottom + vecHeight, 106, distFactor, 2f);
                }

                int framesToNextKeyframe = Math.Max(0, ((iTarget + 1) * framesPerTarget - 1) - i);

                //// Snap to target on key frames, assuming they can be reached
                if (framesToNextKeyframe == 0)
                {
                    player.Bottom = targetBottom;

                    RaidenUtils.DrawDustToBetweenVectors(oldBottom + vecHeight, player.Bottom + vecHeight, 106, 2, 2f);
                }

                // Set slash
                ModSabres.RecentreSlash(projectile, player);


                // Clientside unstick code, don't bother for others in MP
                if (player.whoAmI == Main.myPlayer)
                {
                    UpdateValidEndingPosition(player);
                }
                else
                {
                    endingPositionCenter = player.Center;
                }

                FrameCheck += oneFrame;
            }
        }
Beispiel #3
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (ModSabres.AINormalSlash(projectile, SlashLogic))
            {
                FrameCheck += 1f;
                targets     = null;
            }
            else
            {
                // Charged attack
                ModSabres.AISetChargeSlashVariables(player, chargeSlashDirection);
                ModSabres.NormalSlash(projectile, player);

                // Play charged sound & set targets
                if (sndOnce)
                {
                    Vector2 mouse;
                    if (Main.myPlayer == player.whoAmI)
                    {
                        mouse = new Vector2(Main.screenPosition.X + Main.mouseX, Main.screenPosition.Y + Main.mouseY);
                    }
                    else
                    {
                        mouse = player.Center + new Vector2(player.direction * 256);
                    }                                                                // an estimation
                    targets = RaidenUtils.GetTargettableNPCs(player.Center, mouse, RaidenUtils.GetFocusRadius(player), RaidenUtils.focusTargets);
                    if (targets.Count > 0)
                    {
                        Main.PlaySound(SoundID.Item71, projectile.Center); sndOnce = false;


                        // Set up initial ending position as where we started
                        if (player.whoAmI == Main.myPlayer)
                        {
                            endingPositionCenter = player.Center;
                        }

                        // Set ending slash direction
                        if (targets.Last().Center.X > player.Center.X)
                        {
                            player.direction = 1;
                        }
                        else
                        {
                            player.direction = -1;
                        }
                    }
                }

                if (targets != null && targets.Count > 0)
                {
                    ChargeSlashAI(player);
                }
                else
                {
                    SlashLogic = 1;
                    ModSabres.AINormalSlash(projectile, SlashLogic);
                    FrameCheck += 1f;
                    targets     = null;
                }
            }
            projectile.damage = 0;
        }