Bug with bots if the master left and returned

Report bugs of MFPS 2.0 here
Post Reply
User avatar
Moor
Member
Member
Posts: 23
Joined: Thu Apr 11, 2019 2:38 pm

MFPS version 1.8.2

I know the cause of the error, but I don’t know how to fix it.

Master launched the game*
Image


Game started.
Master leaves the game room*
Image

Cheking rom client.
Image

Master connects back*
Image

Bug on Master*
Image
Image

Bug on Client*
Image
User avatar
Lovatto
Admin
Admin
Posts: 1755
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Hi,

Although the error is annoying it doesn't interfere with the game,
the error is caused by how the bots are destroyed, I have fixed this error but I have refactored a lot of code.

You can try this, I have resume the fix to these changes but I'm not sure if this will work as intended with just this:

in bl_AIManager.cs -> SpawnPendingBot() -> change this line:
Destroy(SpawningBots[0].gameObject);
with:

Code: Select all

PhotonNetwork.Destroy(SpawningBots[0].gameObject);
in bl_AIShooterAgent.cs -> replace the function DestroyBot(...) -> with this:

Code: Select all

public void DestroyBot(NetHashTable data, PhotonMessageInfo info)
    {
        if (data.ContainsKey("instant"))
        {
            if(PhotonNetwork.IsMasterClient) PhotonNetwork.Destroy(gameObject);
            return;
        }

        Vector3 position = (Vector3)data["direction"];
        AIAnim.Ragdolled(position, data.ContainsKey("explosion"));

        if ((PhotonNetwork.Time - info.SentServerTime) > bl_GameData.Instance.PlayerRespawnTime + 1)
        {
            Debug.LogWarning("The death call get with too much delay.");
        }
        this.InvokeAfter(bl_GameData.Instance.PlayerRespawnTime + 2, () =>
         {
             if(GetGameMode.GetGameModeInfo().onRoundStartedSpawn != GameModeSettings.OnRoundStartedSpawn.WaitUntilRoundFinish)
             Debug.LogWarning("For some reason, this bot has not been destroyed yet.");
         });
    }
in bl_AIShooterHealth.cs -> Die(...) -> at the very bottom of the function -> replace these lines:

Code: Select all

if (PhotonNetwork.IsMasterClient)
        {
            if (!isOneTeamMode)
            {
                if (m_AIShooter.AITeam == PhotonNetwork.LocalPlayer.GetPlayerTeam())
                {
                    GameObject di = bl_ObjectPooling.Instance.Instantiate("deathicon", transform.position, transform.rotation);
                    di.GetComponent<bl_ClampIcon>().SetTempIcon(DeathIcon, 5, 20);
                }
            }
            AIManager.OnBotDeath(m_AIShooter, killerBot);
        }
        var deathData = bl_UtilityHelper.CreatePhotonHashTable();
        deathData.Add("type", AIRemoteCallType.DestroyBot);
        deathData.Add("direction", direction);
        if (weaponName.Contains("Grenade"))
        {
            deathData.Add("explosion", true);
        }
        this.photonView.RPC(bl_AIShooterAgent.RPC_NAME, RpcTarget.AllBuffered, deathData);//callback is in bl_AIShooterAgent.cs
with these:

Code: Select all

if (bl_PhotonNetwork.IsMasterClient)
        {
            //respawn management here
            //only master client called it since the spawn will be sync by PhotonNetwork.Instantiate()
            AIManager.OnBotDeath(m_AIShooter, killerBot);

            //Only Master client should send the RPC
            var deathData = bl_UtilityHelper.CreatePhotonHashTable();
            deathData.Add("type", AIRemoteCallType.DestroyBot);
            deathData.Add("direction", direction);
            if (weaponName.Contains("Grenade"))
            {
                deathData.Add("explosion", true);
            }

            //Should buffer this RPC?
            this.photonView.RPC(bl_AIShooterAgent.RPC_NAME, RpcTarget.All, deathData);//callback is in bl_AIShooterAgent.cs -> DestroyBot(...)
        }
That should do it.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
Moor
Member
Member
Posts: 23
Joined: Thu Apr 11, 2019 2:38 pm

Hallo, your code has fixed errors
Only throws a small error: (But I have already fixed)

bot BOT Xuan has not team
UnityEngine.Debug:LogError(Object)
bl_AIMananger:SpawnBot(bl_AIShooter, Team) (at Assets/MFPS/Scripts/GamePlay/AI/bl_AIMananger.cs:246)
bl_AIMananger:SpawnPendingBot() (at Assets/MFPS/Scripts/GamePlay/AI/bl_AIMananger.cs:411)

Thank u for help Lovatto.
Post Reply