Esempio n. 1
0
 private bool CheckCanSee(ref MyCanSeeMemory mem, MyEntity target)
 {
     if (mem.m_ticksFromLastCheck >= FREQUENCY_FOR_RAYCAST_TICKS)
     {
         mem.m_result = CanSee(target) == null;
         mem.m_ticksFromLastCheck = 0;
     }
     mem.m_ticksFromLastCheck++;
     return mem.m_result;
 }
Esempio n. 2
0
 private bool CheckCanSeeIgnoreMovingObjects(ref MyCanSeeMemory mem, Vector3 target)
 {
     if (mem.m_ticksFromLastCheck >= FREQUENCY_FOR_RAYCAST_TICKS||true)
     {
         mem.m_result = CanSeeIgnoreMovingObj(target);
         mem.m_ticksFromLastCheck = 0;
     }
     mem.m_ticksFromLastCheck++;
     return mem.m_result;
 }
Esempio n. 3
0
        public virtual void Init(string hudLabelText, MyMwcObjectBuilder_SmallShip_Bot objectBuilder/*, Matrix matrix, float health*/)
        {
            System.Diagnostics.Debug.Assert(objectBuilder.Faction != 0);
            if (objectBuilder.Faction == 0)
            {
                Trace.SendMsgLastCall(objectBuilder.EntityId.ToString());
            }
            base.Init(hudLabelText, objectBuilder/*, matrix, health*/);

            Faction = objectBuilder.Faction;

            // Array of params for all weapons on ship 
            m_botWeaponParamsAllSlots = new MyBotParams[Enum.GetNames(typeof(MyMwcObjectBuilder_FireKeyEnum)).Length];

            //Assignment of constants for each weapon
            foreach (var item in objectBuilder.AssignmentOfAmmo)
            {
                //Set params for weapon in selected slot
                MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo = item.AmmoType;
                MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum? weaponTypeNullable = MyGuiSmallShipHelpers.GetWeaponType(item.AmmoType, item.Group);
                MyMwcObjectBuilder_FireKeyEnum fireKey = item.FireKey;

                if (weaponTypeNullable != null)
                {
                    var weaponType = (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum)weaponTypeNullable;
                    MyBotParams botParamsOneSlot = SettingsForWeaponType(weaponType, ammo);
                    botParamsOneSlot.FireKey = fireKey;
                    m_botWeaponParamsAllSlots[(int)fireKey - 1] = botParamsOneSlot;

                    //store all weapon types bot has
                    m_weaponTypesMounted |= weaponType;
                }
            }

            //always 0 super easy 1 max hard
            MyGameplayDifficultyEnum difficultyOfThisBot = GetBotDifficulty();

            DifficultyStrafingSpeed = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotStrafingSpeed;

            DifficultyMovingSpeed = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotMovingSpeed;

            DifficultyFireRatio = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotFireRatio;

            //HACK BECAUSE OF TEST BUILD..
	        DifficultyGunUsageRatio = 0.5f;
            //DifficultyGunUsageRatio = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotGunUsageRatio;

            DifficultyRaidAttackOccurrence = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotRaidAttackOccurrence;

            DifficultyFlyAroundTargetOccurrence = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotFlyAroundTargetOccurrence;

            DifficultyAttackReactDistance = MyGameplayConstants.GetGameplayDifficulty(difficultyOfThisBot).BotAttackReactDistance;

            DifficultyUseFireBurst = 1;

            MyHud.ChangeText(this, new StringBuilder(hudLabelText), null, 10000, MyHudIndicatorFlagsEnum.SHOW_ALL);

            NormalDecision = MyBotDecisionLogicsEnum.None;
            AttackDecision = MyBotDecisionLogicsEnum.None;

            //bot survival waypoints if getting lost
            m_rememberWaypoints = new MyWaypointMemory(this);
            m_temporaryWaypoints = new MyWaypointMemory(this);

            m_canSeeCheck = new MyCanSeeMemory(false);
            m_canSeeCheckForShoot = new MyCanSeeMemory(false);
            m_canSeeCheckForMove = new MyCanSeeMemory(false);

            //Set behavrior duration times
            SettingsForBehaviorTimers();

            //Inicialize timers
            ResetBehaviourTimer();
            ResetStrafeTimer();

            m_decisionTimeCounter = 0;
            m_lostCounter = 0;

            Threat = null;
            Target = null;
            FollowTarget = null;

            //Next inicialization should be done from input so every bot can do something different (shuold it be in object builder for bot?)
            //--------------------------------------------------------
            //Set default decision logic
            NormalDecision = MyBotDecisionLogicsEnum.Guard;
            AttackDecision = MyBotDecisionLogicsEnum.CasualFighter;

            m_survivalKit = new Dictionary<MyBotSurvivalAlertsEnum, MySurvivalDecision>();
            AddSurvivalAlert(MyBotSurvivalAlertsEnum.EnemyInsight, MyBotDecisionLogicsEnum.None, 1000);
            AddSurvivalAlert(MyBotSurvivalAlertsEnum.UnderAttack, MyBotDecisionLogicsEnum.CasualFighter, 1000);
            
            //Initialize waypoint memories
            m_savedWaypoints = new MyWaypointMemory(this);

            Trace.SendMsgLastCall("Init Bot " + base.Name);
        }