Esempio n. 1
0
        static void FreeAim(bool down)
        {
            if (crosshair == null)
            {
                crosshair = new Sumpfkraut.GUI.GUCWorldSprite(10, 10);
                crosshair.SetBackTexture("crosshair.tga");
                crosshair.ShowOutOfScreen = false;
            }

            var hero = NPCInst.Hero;

            string CamModFreeAim = "CAMMODRANGED_FREEAIM";

            if (hero.ModelDef.Visual == "ORC.MDS" || hero.ModelDef.Visual == "DRACONIAN.MDS")
            {
                CamModFreeAim += "_ORC";
            }

            if (down && hero != null && !hero.IsDead && hero.IsInFightMode &&
                !hero.Environment.InAir && !hero.ModelInst.IsInAnimation())
            {
                var drawnWeapon = hero.GetDrawnWeapon();
                if (drawnWeapon != null && drawnWeapon.IsWepRanged)
                {
                    if (!freeAim)
                    {
                        hero.SetMovement(NPCMovement.Stand);
                        NPCInst.Requests.Aim(hero, true);

                        // no auto-lock
                        PlayerFocus.SetLockedTarget(null);

                        // zoom in
                        FOVTransition(60, TimeSpan.TicksPerSecond / 2);

                        zCAICamera.CamModRanged.Set(CamModFreeAim);       // replace so gothic sets it to this while in bow mode
                        zCAICamera.CurrentCam.SetByScript(CamModFreeAim); // change camera
                        freeAim = true;
                    }
                    return;
                }
            }

            if (freeAim)
            {
                NPCInst.Requests.Aim(hero, false);
                crosshair.Hide();
                FOVTransition(90, TimeSpan.TicksPerSecond / 2);

                var cam = zCAICamera.CurrentCam;
                zCAICamera.CamModRanged.Set("CAMMODRANGED"); // reset
                if (cam.CurrentMode.ToString().Equals(CamModFreeAim, StringComparison.OrdinalIgnoreCase))
                {
                    cam.SetByScript("CAMMODRANGED"); // change camera
                }
                freeAim = false;
            }
        }
Esempio n. 2
0
        void PlayerUpdate()
        {
            if (ArenaClient.DetectSchinken)
            {
                fwdTelHelper.Update(GameTime.Ticks);
                upTelHelper.Update(GameTime.Ticks);
            }

            NPCInst hero = ScriptClient.Client.Character;
            var     gAI  = hero.BaseInst.gAI;

            if (hero.IsDead || hero.IsUnconscious)
            {
                LookAround(hero);
                return;
            }

            zCAICamera.CurrentCam.BestAzimuth = 0;

            if (freeAim)
            {
                FreeAiming(hero);
                return;
            }

            DoTurning(hero);

            if (KeyBind.Action.IsPressed() && hero.IsInFightMode)
            {
                var enemy = PlayerFocus.GetFocusNPC();
                if (enemy == null || !enemy.IsSpawned || enemy.IsDead)
                {
                    PlayerFocus.SetLockedTarget(null); // updates for new target
                }
                PlayerFocus.SetLockedTarget(PlayerFocus.GetFocusNPC());
            }
            else
            {
                PlayerFocus.SetLockedTarget(null);
            }

            NPCMovement state = NPCMovement.Stand;

            if (!KeyBind.Action.IsPressed() || hero.Movement != NPCMovement.Stand)
            {
                if (KeyBind.MoveForward.IsPressed()) // move forward
                {
                    state = NPCMovement.Forward;
                }
                else if (KeyBind.MoveBack.IsPressed()) // move backward
                {
                    var drawnWeapon = hero.GetDrawnWeapon();
                    if (hero.IsInFightMode && (drawnWeapon == null || drawnWeapon.IsWepMelee))
                    {
                        if (dodgeLock.IsReady) // don't spam
                        {
                            if (IsWarmup())
                            {
                                return;
                            }

                            NPCInst.Requests.Attack(hero, FightMoves.Dodge);
                        }
                        return;
                    }
                    else
                    {
                        state = NPCMovement.Backward;
                    }
                }
                else if (KeyBind.MoveLeft.IsPressed()) // strafe left
                {
                    state = NPCMovement.Left;
                }
                else if (KeyBind.MoveRight.IsPressed()) // strafe right
                {
                    state = NPCMovement.Right;
                }
                else
                {
                    state = NPCMovement.Stand;
                }
            }

            if (nextStrafeChange > GameTime.Ticks)
            {
                state = hero.Movement;
            }

            if (state == NPCMovement.Forward)
            {   // FIXME: use only a better CheckEnoughSpaceMoveForward
                if (hero.Movement == NPCMovement.Stand && !gAI.CheckEnoughSpaceMoveForward(true))
                {
                    state = NPCMovement.Stand;
                }
                else
                {
                    gAI.CalcForceModelHalt();
                    if ((gAI.Bitfield0 & zCAIPlayer.Flags.ForceModelHalt) != 0)
                    {
                        gAI.Bitfield0 &= ~zCAIPlayer.Flags.ForceModelHalt;
                        state          = NPCMovement.Stand;
                    }
                }
            }
            else if (state == NPCMovement.Backward)
            {
                if (!gAI.CheckEnoughSpaceMoveBackward(true))
                {
                    state = NPCMovement.Stand;
                }
            }
            else if (state == NPCMovement.Left)
            {
                if (!gAI.CheckEnoughSpaceMoveLeft(true))
                {
                    state = NPCMovement.Stand;
                }
            }
            else if (state == NPCMovement.Right)
            {
                if (!gAI.CheckEnoughSpaceMoveRight(true))
                {
                    state = NPCMovement.Stand;
                }
            }

            if (state != NPCMovement.Stand && IsWarmup())
            {
                state = NPCMovement.Stand;
            }

            if (state == NPCMovement.Left || state == NPCMovement.Right || (state == NPCMovement.Forward && hero.IsInFightMode))
            {
                if (hero.Movement != state)
                {
                    nextStrafeChange = GameTime.Ticks + StrafeInterval;
                }
            }
            else
            {
                nextStrafeChange = 0;
            }

            hero.SetMovement(state);
        }