internal override void Update(MySmallShipBot bot)
        {
            base.Update(bot);

            if (m_target != null && !m_target.IsDead())
            {
                MySmallShip         smallShipTarget   = m_target as MySmallShip;
                MyPrefabLargeWeapon largeWeaponTarget = m_target as MyPrefabLargeWeapon;

                if (largeWeaponTarget != null && !largeWeaponTarget.IsWorking())
                {
                    m_isInvalid = true;
                    return;
                }

                if (m_timeToAlarmCheck >= 0)
                {
                    m_timeToAlarmCheck -= MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
                    // When transition from curious behavior try raise alarm (if this doesn't work pass some flag curious behavior)
                    if (m_timeToAlarmCheck < 0 && smallShipTarget != null && smallShipTarget.HasRadarJammerActive())
                    {
                        bot.LaunchAlarm(smallShipTarget);
                    }
                }

                UpdateVisibility(bot);

                if (m_targetVisible)
                {
                    AttackTarget(bot, m_targetVisible);
                    findSmallship.Init(bot);

                    // Attack player to prevent his passivity when we have invicible wingmans
                    m_playerAttackDecisionTimer -= MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
                    if (smallShipTarget != null && smallShipTarget.Leader == MySession.PlayerShip && m_playerAttackDecisionTimer <= 0)
                    {
                        m_playerAttackDecisionTimer = 2.5f;
                        if (MyMwcUtils.GetRandomFloat(0, 1.0f) < 0.7f)
                        {
                            m_target = smallShipTarget.Leader;
                        }
                    }
                }
                else
                {
                    m_state = StateEnum.CLOSING;

                    findSmallship.Update(bot, m_target);

                    if (findSmallship.PathNotFound)
                    {
                        bot.IsSleeping = true;
                        m_isInvalid    = true;
                    }
                    else if (!findSmallship.GotPosition())
                    {
                        AttackTarget(bot, false);
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal override void Update(MySmallShipBot bot)
        {
            base.Update(bot);

            if (m_target != null && !m_target.IsDead())
            {
                MySmallShip smallShipTarget = m_target as MySmallShip;
                MyPrefabLargeWeapon largeWeaponTarget = m_target as MyPrefabLargeWeapon;

                if (largeWeaponTarget != null && !largeWeaponTarget.IsWorking())
                {
                    m_isInvalid = true;
                    return;
                }

                if (m_timeToAlarmCheck >= 0)
                {
                    m_timeToAlarmCheck -= MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
                    // When transition from curious behavior try raise alarm (if this doesn't work pass some flag curious behavior)
                    if (m_timeToAlarmCheck < 0 && smallShipTarget != null && smallShipTarget.HasRadarJammerActive())
                    {
                        bot.LaunchAlarm(smallShipTarget);
                    }
                }

                UpdateVisibility(bot);

                if (m_targetVisible)
                {
                    AttackTarget(bot, m_targetVisible);
                    findSmallship.Init(bot);

                    // Attack player to prevent his passivity when we have invicible wingmans
                    m_playerAttackDecisionTimer -= MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
                    if (smallShipTarget != null && smallShipTarget.Leader == MySession.PlayerShip && m_playerAttackDecisionTimer <= 0)
                    {
                        m_playerAttackDecisionTimer = 2.5f;
                        if (MyMwcUtils.GetRandomFloat(0, 1.0f) < 0.7f)
                        {
                            m_target = smallShipTarget.Leader;
                        }
                    }
                }
                else
                {
                    m_state = StateEnum.CLOSING;

                    findSmallship.Update(bot, m_target);

                    if (findSmallship.PathNotFound)
                    {
                        bot.IsSleeping = true;
                        m_isInvalid = true;
                    }
                    else if (!findSmallship.GotPosition())
                    {
                        AttackTarget(bot, false);
                    }
                }
            }
        }