fix this scripts:
using Mirror;
using UnityEngine;

[RequireComponent(typeof(Animator))]
public class DragonController : NetworkBehaviour
{
    [Header("Dragon Settings")]
    public float takeOffHeight = 12f;
    public float takeOffSpeed = 5f;
    public float landingSpeed = 5f;
    public float animationSpeed = 1f;
    public float movementSpeed = 5f;

    [Header("Mouse Look Settings")]
    public Transform cameraTransform;  // Assign your camera here in the inspector
    public float mouseSensitivity = 2f;
    public float minPitch = -30f;
    public float maxPitch = 60f;

    [Header("BlendShape Settings")]
    [SerializeField] private SkinnedMeshRenderer skinnedMeshRenderer;
    public float blendShapeSmoothSpeed = 5f;

    private Animator animator;

    private bool isGrounded = true;
    private bool isFlying = false;
    private bool isLanding = false;

    private float targetY = 0f;

    private float[] targetBlendShapes;
    private int blendShapeCount;

    private float yaw;
    private float pitch;

    [Header("Networked Fire")]
    [Tooltip("Assign the fire collider GameObject here (e.g. MouthPoint)")]
    public GameObject fireObject;

    private void Start()
    {
        animator = GetComponent<Animator>();

        if (cameraTransform == null)
        {
            Debug.LogError("Assign a cameraTransform in the inspector!");
        }

        if (fireObject == null)
        {
            Debug.LogWarning("DragonController: fireObject (MouthPoint) not assigned! Fire effect will not work.");
        }
        else if (isServer)
        {
            fireObject.SetActive(false);
        }
        else
        {
            // Make sure fireObject is disabled at start on client
            fireObject.SetActive(false);
        }

        Vector3 angles = cameraTransform.localEulerAngles;
        yaw = angles.y;
        pitch = angles.x;

        // Start with hovering animation active instead of Idle
        animator.SetBool("IsIdle", false);
        animator.SetBool("IsHovering", true);
        animator.applyRootMotion = false;

        if (skinnedMeshRenderer && skinnedMeshRenderer.sharedMesh != null)
        {
            blendShapeCount = skinnedMeshRenderer.sharedMesh.blendShapeCount;
            targetBlendShapes = new float[blendShapeCount];
        }

        targetY = transform.position.y;

        if (isLocalPlayer)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
        }

        // When starting, assume dragon is flying hovering in air above takeOffHeight:
        isFlying = true;
        isGrounded = false;
        isLanding = false;
        targetY = takeOffHeight; // start hovering at takeOffHeight
        Vector3 pos = transform.position;
        pos.y = takeOffHeight;
        transform.position = pos;
    }

    void Update()
    {
        if (!isLocalPlayer) return;

        animator.speed = animationSpeed;

        HandleMouseLook();
        HandleInput();
        SmoothBlendshape();
        HandleFlight();
        HandleFlamethrower();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (Cursor.lockState == CursorLockMode.Locked)
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible = true;
            }
            else
            {
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible = false;
            }
        }
    }

    private void HandleFlamethrower()
    {
        if (fireObject == null) return;

        if (Input.GetMouseButtonDown(0)) CmdSetFireActive(true);
        if (Input.GetMouseButtonUp(0)) CmdSetFireActive(false);

        animator.SetBool("IsGlidingFire", Input.GetMouseButton(0));
    }

    [Command]
    private void CmdSetFireActive(bool active)
    {
        if (fireObject == null) return;

        fireObject.SetActive(active);
        RpcSetFireActive(active);
    }

    [ClientRpc]
    private void RpcSetFireActive(bool active)
    {
        if (isLocalPlayer) return;

        if (fireObject != null)
            fireObject.SetActive(active);
    }

    private void HandleMouseLook()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;

        yaw += mouseX;
        pitch -= mouseY;

        pitch = Mathf.Clamp(pitch, minPitch, maxPitch);

        cameraTransform.localEulerAngles = new Vector3(pitch, yaw, 0f);
    }

    private void HandleInput()
    {
        if (isGrounded && !isFlying)
        {
            HandleGroundMovement();  // You may decide to disable ground movement while dragon is active
        }
        else
        {
            HandleFlyingMovement();
        }
    }

    private void HandleGroundMovement()
    {
        // If you want to disable ground movement when controlling the dragon, just leave empty or deactivate player controller:
        // Possibly disable player gun or movement here as well.
    }

    private void HandleFlyingMovement()
    {
        Vector3 camForward = cameraTransform.forward;
        camForward.y = 0f;
        camForward.Normalize();

        Vector3 camRight = cameraTransform.right;
        camRight.y = 0f;
        camRight.Normalize();

        // Always rotate dragon to face flight direction or camera forward if no input
        bool wPressed = Input.GetKey(KeyCode.W);
        bool sPressed = Input.GetKey(KeyCode.S);
        bool aPressed = Input.GetKey(KeyCode.A);
        bool dPressed = Input.GetKey(KeyCode.D);

        Vector3 flyDirection = Vector3.zero;

        // Movement and animation logic based on your description:

        if (wPressed)
        {
            // FlyingForward
            animator.SetBool("IsFlying", true);
            animator.SetBool("IsHovering", false);
            animator.SetBool("IsFlyingLeft", false);
            animator.SetBool("IsFlyingRight", false);

            flyDirection += camForward;
        }
        else if (sPressed)
        {
            // Hovering + backward movement
            animator.SetBool("IsHovering", true);
            animator.SetBool("IsFlying", false);
            animator.SetBool("IsFlyingLeft", false);
            animator.SetBool("IsFlyingRight", false);

            flyDirection -= camForward;
        }
        else if (aPressed)
        {
            // FlyingLeft + move left
            animator.SetBool("IsFlyingLeft", true);
            animator.SetBool("IsFlyingRight", false);
            animator.SetBool("IsFlying", false);
            animator.SetBool("IsHovering", false);

            flyDirection -= camRight;
        }
        else if (dPressed)
        {
            // FlyingRight + move right
            animator.SetBool("IsFlyingRight", true);
            animator.SetBool("IsFlyingLeft", false);
            animator.SetBool("IsFlying", false);
            animator.SetBool("IsHovering", false);

            flyDirection += camRight;
        }
        else
        {
            // If no input, play hovering animation
            animator.SetBool("IsHovering", true);
            animator.SetBool("IsFlying", false);
            animator.SetBool("IsFlyingLeft", false);
            animator.SetBool("IsFlyingRight", false);
        }

        // Rotate dragon to look in camera forward direction smoothly
        if (camForward.sqrMagnitude > 0.001f)
        {
            Quaternion targetRotation = Quaternion.LookRotation(camForward);
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 5f);
        }

        if (flyDirection != Vector3.zero)
        {
            flyDirection = flyDirection.normalized;
            Vector3 newPos = transform.position + flyDirection * movementSpeed * Time.deltaTime;

            // Maintain height above terrain level if needed:
            // Raycast down to terrain height (optional)
            if (Physics.Raycast(newPos + Vector3.up * 50f, Vector3.down, out RaycastHit hit, 100f))
            {
                newPos.y = Mathf.Max(newPos.y, hit.point.y + 5f); // Add offset so dragon stays above the ground
            }
            transform.position = newPos;
        }

        // Space to land or take off:
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (isFlying && !isLanding)
            {
                // Land
                animator.SetTrigger("Land");
                isLanding = true;

                if (Physics.Raycast(transform.position + Vector3.up * 10f, Vector3.down, out RaycastHit hitInfo, 20f))
                {
                    targetY = hitInfo.point.y;
                }
                else
                {
                    targetY = 0f; // fallback ground height
                }
            }
            else if (isGrounded && !isFlying)
            {
                // Take off
                animator.SetTrigger("TakeOff");
                isFlying = true;
                isGrounded = false;
                isLanding = false;
                targetY = takeOffHeight;
            }
        }
    }

    private void HandleFlight()
    {
        if (!isFlying && !isLanding) return;

        float step = (isLanding ? landingSpeed : takeOffSpeed) * Time.deltaTime;

        Vector3 position = transform.position;
        position.y = Mathf.MoveTowards(position.y, targetY, step);
        transform.position = position;

        if (isLanding && Mathf.Approximately(position.y, targetY))
        {
            isLanding = false;
            isFlying = false;
            isGrounded = true;

            animator.SetBool("IsFlying", false);
            animator.SetBool("IsHovering", false);
        }
    }

    private void SmoothBlendshape()
    {
        if (skinnedMeshRenderer == null || skinnedMeshRenderer.sharedMesh == null || blendShapeCount == 0) return;

        for (int i = 0; i < blendShapeCount; i++)
        {
            float currentWeight = skinnedMeshRenderer.GetBlendShapeWeight(i);
            float targetWeight = targetBlendShapes[i];
            float newWeight = Mathf.Lerp(currentWeight, targetWeight, Time.deltaTime * blendShapeSmoothSpeed);
            skinnedMeshRenderer.SetBlendShapeWeight(i, newWeight);
        }
    }

    public void SetTargetBlendShape(int index, float weight)
    {
        if (targetBlendShapes != null && index >= 0 && index < targetBlendShapes.Length)
            targetBlendShapes[index] = weight;
    }
}


using System.Collections;
using UnityEngine;
using MarsFPSKit;
using Mirror;

[CreateAssetMenu(menuName = "MarsFPSKit/Plugins/Dragon Killstreak Plugin")]
public class DragonKillstreakPlugin : Kit_Plugin
{
    [Tooltip("Networked Dragon prefab (with NetworkIdentity)")]
    public GameObject dragonPrefab;

    [Tooltip("Duration in seconds the dragon killstreak lasts")]
    public float durationSeconds = 10f;

    [Tooltip("Key to activate killstreak")]
    public KeyCode activateKey = KeyCode.Alpha6;

    [Tooltip("Number of kills needed to activate the dragon killstreak")]
    [Min(1)]
    [SerializeField]
    private int requiredKillstreak = 2;

    public int RequiredKillstreak => requiredKillstreak;

    private int killstreakCount = 0;
    private bool killstreakReady = false;
    private bool isActive = false;

    private GameObject spawnedDragon;
    private Camera originalCamera;
    private Kit_PlayerBehaviour localPlayer;

    // References for disabling player first-person arms and weapon visuals
    private GameObject playerFirstPersonArms;
    private GameObject playerFirstPersonWeapon;

    public override void OnSetupDone()
    {
        base.OnSetupDone();

        localPlayer = null;

        killstreakCount = 0;
        killstreakReady = false;
        isActive = false;
        spawnedDragon = null;
        originalCamera = null;
        playerFirstPersonArms = null;
        playerFirstPersonWeapon = null;

        Debug.Log("[DragonKillstreakPlugin] OnSetupDone - states reset.");
    }

    private Kit_PlayerBehaviour GetLocalPlayer()
    {
        if (Kit_IngameMain.instance == null) return null;

        var players = Kit_IngameMain.instance.allActivePlayers;
        if (players == null) return null;

        for (int i = 0; i < players.Count; i++)
        {
            if (players[i] != null && players[i].isLocalPlayer)
                return players[i];
        }

        return null;
    }

    public override void PluginUpdate()
    {
        localPlayer = GetLocalPlayer();

        if (killstreakReady && !isActive &&
            !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() &&
            Input.GetKeyDown(activateKey))
        {
            if (localPlayer != null && localPlayer.isLocalPlayer)
            {
                Debug.Log("[DragonKillstreakPlugin] Activation key detected and localPlayer is local.");
                CmdRequestActivateDragon();
            }
            else
            {
                Debug.LogWarning("[DragonKillstreakPlugin] Activation key pressed but player is not local.");
            }
        }
    }

    public override void LocalPlayerScoredKill(bool botKilled, uint killed, int gunId, int thirdPersonPlayerModelId, int ragdollId)
    {
        if (isActive) return;
        AddKillAndCheck();
    }

    public override void BotScoredKill(Kit_Bot bot, bool botKilled, uint killed, int gunId, int thirdPersonPlayerModelId, int ragdollId)
    {
        if (isActive) return;
        if (localPlayer != null && botKilled)
        {
            AddKillAndCheck();
        }
    }

    private void AddKillAndCheck()
    {
        killstreakCount++;
        Debug.Log($"[DragonKillstreakPlugin] killstreakCount = {killstreakCount}");

        if (killstreakCount >= requiredKillstreak)
        {
            killstreakReady = true;
            Debug.Log("[DragonKillstreakPlugin] Killstreak ready!");
            ShowKillstreakIcon(true);
        }
    }

    public override void LocalPlayerWasKilled()
    {
        Debug.Log("[DragonKillstreakPlugin] Local player died, resetting killstreak.");
        ResetKillstreak();

        if (isActive)
        {
            localPlayer?.StopCoroutine(DeactivateKillstreak());
            CmdDeactivateDragon();
        }
    }

    private void ResetKillstreak()
    {
        killstreakCount = 0;
        killstreakReady = false;
        ShowKillstreakIcon(false);
    }

    [Command]
    private void CmdRequestActivateDragon(NetworkConnectionToClient sender = null)
    {
        if (isActive) return;

        localPlayer = Kit_IngameMain.instance?.myPlayer;
        if (dragonPrefab == null || localPlayer == null) return;

        var dragonInstance = Instantiate(dragonPrefab, localPlayer.transform.position, localPlayer.transform.rotation);

        NetworkServer.Spawn(dragonInstance, sender);

        var netId = dragonInstance.GetComponent<NetworkIdentity>().netId;

        isActive = true;
        killstreakReady = false;
        killstreakCount = 0;

        TargetActivateDragon(sender, netId);
    }

    [TargetRpc]
    private void TargetActivateDragon(NetworkConnection target, uint dragonNetId)
    {
        if (localPlayer == null)
            localPlayer = GetLocalPlayer();

        if (localPlayer == null)
        {
            Debug.LogError("[DragonKillstreakPlugin] Local player null in TargetActivateDragon!");
            return;
        }

        localPlayer.canControlPlayer = false;

        if (localPlayer.thirdPersonPlayerModel != null)
            localPlayer.thirdPersonPlayerModel.gameObject.SetActive(false);

        playerFirstPersonArms = localPlayer.playerCameraTransform?.Find("FirstPersonArms")?.gameObject;
        if (playerFirstPersonArms != null) playerFirstPersonArms.SetActive(false);

        playerFirstPersonWeapon = localPlayer.playerCameraTransform?.Find("CurrentWeapon")?.gameObject;
        if (playerFirstPersonWeapon != null) playerFirstPersonWeapon.SetActive(false);

        originalCamera = localPlayer.playerCameraTransform.GetComponent<Camera>();
        if (originalCamera != null) originalCamera.enabled = false;

        localPlayer.StartCoroutine(WaitForDragonAndActivate(dragonNetId));
    }

    private IEnumerator WaitForDragonAndActivate(uint dragonNetId)
    {
        float timeout = 5f;
        float elapsed = 0f;

        while (elapsed < timeout)
        {
            if (NetworkClient.spawned.TryGetValue(dragonNetId, out var dragonIdentity) && dragonIdentity != null)
            {
                spawnedDragon = dragonIdentity.gameObject;

                if (!spawnedDragon.activeSelf)
                    spawnedDragon.SetActive(true);

                var controller = spawnedDragon.GetComponent<DragonKillstreakController>();
                if (controller != null)
                {
                    controller.Activate(originalCamera, localPlayer.transform.position, durationSeconds);
                }
                else
                {
                    Debug.LogWarning("[DragonKillstreakPlugin] DragonKillstreakController component missing on prefab!");
                }
                yield break;
            }

            elapsed += Time.deltaTime;
            yield return null;
        }

        Debug.LogError($"[DragonKillstreakPlugin] Failed to find dragon by netId {dragonNetId} after waiting {timeout} seconds.");
    }

    [Command]
    private void CmdDeactivateDragon(NetworkConnectionToClient sender = null)
    {
        if (!isActive) return;

        if (spawnedDragon != null)
        {
            var netId = spawnedDragon.GetComponent<NetworkIdentity>().netId;
            if (netId != 0 && NetworkServer.spawned.TryGetValue(netId, out var identity))
            {
                NetworkServer.Destroy(identity.gameObject);
            }
            spawnedDragon = null;
        }

        isActive = false;

        TargetDeactivateDragon(sender);
    }

    [TargetRpc]
    private void TargetDeactivateDragon(NetworkConnection target)
    {
        localPlayer = GetLocalPlayer();
        if (localPlayer == null)
        {
            Debug.LogError("[DragonKillstreakPlugin] Local player null in TargetDeactivateDragon!");
            return;
        }

        localPlayer.canControlPlayer = true;

        if (localPlayer.thirdPersonPlayerModel != null)
            localPlayer.thirdPersonPlayerModel.gameObject.SetActive(true);

        if (playerFirstPersonArms != null)
            playerFirstPersonArms.SetActive(true);

        if (playerFirstPersonWeapon != null)
            playerFirstPersonWeapon.SetActive(true);

        if (originalCamera != null)
        {
            if (!originalCamera.enabled)
                originalCamera.enabled = true;

            Kit_IngameMain.instance.activeCameraTransform = originalCamera.transform;
        }

        if (localPlayer.isLocalPlayer)
        {
            localPlayer.CmdSuicide(); // Use respawn or suitable logic here
        }
    }

    private IEnumerator DeactivateKillstreak()
    {
        yield return new WaitForSeconds(durationSeconds);
        CmdDeactivateDragon();
    }

    private void ShowKillstreakIcon(bool show)
    {
        Debug.Log($"[DragonKillstreakPlugin] ShowKillstreakIcon({show})");
        // Hook your UI killstreak icon display here
    }
}

using System.Collections;
using UnityEngine;

[RequireComponent(typeof(DragonController))]  // Reference your dragon movement script here
public class DragonKillstreakController : MonoBehaviour
{
    [Tooltip("Dragon's Camera")]
    public Camera dragonCamera;

    private Camera originalCamera;
    private bool isActive;
    private DragonController dragonController;

    private void Awake()
    {
        dragonController = GetComponent<DragonController>();
        if (dragonController == null)
        {
            Debug.LogError("[DragonKillstreakController] DragonController component not found on dragon prefab.");
        }
        gameObject.SetActive(false);
    }

    public void Activate(Camera playerCamera, Vector3 spawnPosition, float duration)
    {
        if (isActive) return;
        isActive = true;

        originalCamera = playerCamera;

        transform.position = spawnPosition;

        // Enable dragon camera and disable original player camera
        if (dragonCamera != null)
        {
            dragonCamera.enabled = true;
        }
        if (originalCamera != null)
        {
            originalCamera.enabled = false;
        }

        // Activate the dragon GameObject and enable movement/input
        gameObject.SetActive(true);

        if (dragonController != null)
        {
            dragonController.enabled = true;
        }

        // Start duration countdown coroutine
        StartCoroutine(DeactivateAfterSeconds(duration));
    }

    private IEnumerator DeactivateAfterSeconds(float time)
    {
        yield return new WaitForSeconds(time);
        Deactivate();
    }

    public void Deactivate()
    {
        if (!isActive) return;
        isActive = false;

        // Disable dragon camera and enable player camera back
        if (dragonCamera != null)
            dragonCamera.enabled = false;

        if (originalCamera != null)
            originalCamera.enabled = true;

        if (dragonController != null)
            dragonController.enabled = false;

        // Hide dragon GameObject
        gameObject.SetActive(false);
    }

    private void Update()
    {
        if (!isActive) return;

        // Optionally, you can process input here or leave that to the DragonController script
        // For example, you could forward input to dragonController or handle generic input here.
    }
}


The dragon should be controllable like in Call of Duty. The center of the screen should be the point where the dragon is facing to. It should be by default in Hovering Animation state when pressing 6. When pressing "W" it should use FlyingForward Animation and it should move over the terrain forward. This should work as long as the "W" key is hold down. Same functionality should apply for A (FlyingLeft) animation, D (FlyingRight) Animation and S with Hovering Animation but flying backwards. When pressing and holding down the Left mouse button it should activate the "MouthPoint" child prefab which I can set in the inspector. As long as the left mouse button is pressed this child object should get activated. When releasing the left mouse button it shoudl get deactivated. After 10 Seconds I should be able to play again as the MMFPSE player. When killing again enought enemies (which I can set in the inspector) by default it is 2, I should be able to press "6" again to play as the Dragon. This should work unlimited times as long as i killed enough players or bots.

Fix all scripts and just show me the updated 100% fixed whole scripts in order to copy and paste