Esempio n. 1
0
        public static void HostileChase(ulong millis, HostileWildlifeAI HWAI)
        {
            try
            {
                if (HWAI != null)
                {
                    if (millis != null)
                    {
                        if (HWAI._targetTD == null)
                        {
                            if (ignoringAIList.Contains(HWAI))
                            {
                                HWAI.GoScentBlind(10f);
                                HWAI.ExitCurrentState();
                                HWAI.idleClock.ResetRandomDurationSeconds(0, 0);
                                HWAI._state = 1;
                                if (!HWAI.idleSoundRefireClock.once)
                                {
                                    HWAI.idleSoundRefireClock.ResetRandomDurationSeconds(2.0, 4.0);
                                }
                                ignoringAIList.Remove(HWAI);
                            }
                            else
                                HWAI.LoseTarget();

                            if (hadTarget.Contains(HWAI))
                                hadTarget.Remove(HWAI);
                        }
                        else
                        {
                            bool b = false;
                            if (!hadTarget.Contains(HWAI))
                            {
                                try
                                {
                                    foreach (PlayerClient pc in AllPlayerClients)
                                    {
                                        if (pc.controllable != null)
                                        {
                                            if (pc.controllable.GetComponent<TakeDamage>() != null)
                                            {
                                                if (pc.controllable.GetComponent<TakeDamage>() == HWAI._targetTD)
                                                {
                                                    PlayerClient playerClient = pc;
                                                    b = hiddenList.Contains(playerClient.userID.ToString()) && HWAI._targetTD == playerClient.controllable.GetComponent<TakeDamage>();

                                                    try
                                                    {
                                                        if (!b)
                                                        {
                                                            if (isPlayer(HWAI._targetTD.idMain))
                                                            {
                                                                Character character = HWAI._targetTD.idMain as Character;
                                                                foreach (string UID in hiddenList)
                                                                {
                                                                    if (UID == character.playerClient.userID.ToString() && HWAI._targetTD == character.playerClient.controllable.GetComponent<TakeDamage>())
                                                                        b = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Vars.conLog.Error("HC #3: " + ex.ToString());
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Vars.conLog.Error("HC #2: " + ex.ToString());
                                }
                                hadTarget.Add(HWAI);
                            }

                            if (!b)
                            {
                                float num = HWAI.TargetRange();
                                if (num > HWAI.loseTargetRange)
                                {
                                    HWAI.LoseTarget();
                                }
                                else
                                {
                                    Vector3 vector = HWAI._targetTD.transform.position - HWAI.transform.position;
                                    vector.y = 0f;
                                    if (num <= HWAI.attackRange)
                                    {
                                        HWAI._wildMove.SetLookDirection(vector.normalized);
                                        HWAI.ExitCurrentState();
                                        HWAI.EnterState_Attack();
                                    }
                                    else
                                    {
                                        if (HWAI._wildMove.IsStuck())
                                        {
                                            if (HWAI.wasStuck)
                                            {
                                                if (HWAI.stuckClock.IntegrateTime_Reached(millis))
                                                {
                                                    Vector3 position = HWAI._targetTD.transform.position;
                                                    HWAI.LoseTarget();
                                                    HWAI.ExitCurrentState();
                                                    HWAI.EnterState_Flee(position, 0x2710L);
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                HWAI.wasStuck = true;
                                                HWAI.stuckClock.ResetRandomDurationSeconds(1.0, 2.0);
                                            }
                                        }
                                        else
                                        {
                                            HWAI.wasStuck = false;
                                        }
                                        if (HWAI.chaseSoundClock.IntegrateTime_Reached(millis))
                                        {
                                            BasicWildLifeAI.AISound chase = BasicWildLifeAI.AISound.Chase;
                                            if (num < 5f)
                                            {
                                                chase = BasicWildLifeAI.AISound.ChaseClose;
                                            }
                                            HWAI.NetworkSound(chase);
                                            HWAI.chaseSoundClock.ResetRandomDurationSeconds(1.5, 2.5);
                                        }
                                        HWAI._wildMove.SetMoveTarget(HWAI._targetTD.gameObject, HWAI.runSpeed);
                                        if (HWAI.targetReachClock.IntegrateTime_Reached(millis))
                                        {
                                            HWAI.LoseTarget();
                                            HWAI.ExitCurrentState();
                                            HWAI.EnterState_Idle();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                conLog.Error("HC #1: " + ex.ToString());
            }
        }