Esempio n. 1
0
        public MonsterBrain(BrainFighter fighter)
        {
            this.Fighter = fighter;

            if (fighter.Template.BehaviorName != string.Empty && fighter.Template.BehaviorName != null)
            {
                this.Behavior = BehaviorManager.GetBehavior(fighter.Template.BehaviorName, this.Fighter);
            }
        }
Esempio n. 2
0
        private void panel_config_wiiimg_MouseClick(object sender, MouseEventArgs e)
        {
            var pos = e.Location;

            pos.Offset(-10, -10);
            pos = GetImagePos(picBox_wii, pos);

            var disabled = m_bMgr.GetBehavior(m_selectedProfile.Behavior).GetDisabledItem();

            if (m_dic_buttonRect.Any(x => !disabled.Contains(x.Key) && x.Value.Contains(pos)))
            {
                var joyIsVisible = m_dic_buttonRect[WiimoteModel._N_STICK].Contains(pos);
                panel_setJoystick.Visible = joyIsVisible;
                panel_setKeyMouse.Visible = !joyIsVisible;

                m_mousePos = pos;
                picBox_wii_Paint();
            }
        }
Esempio n. 3
0
        private void MenuItem_Profile_Item_Clicked(object sender, EventArgs e)
        {
            var name = (sender as ToolStripMenuItem).Text;

            labName.Text      = name;
            m_selectedProfile = m_profiles.First(x => x.Name == name);
            m_behavior        = m_bMgr.GetBehavior(m_selectedProfile.Behavior);

            var items = MenuItem_Profile.DropDownItems.Cast <ToolStripItem>();

            foreach (ToolStripMenuItem item in items.Where(x => (string)x.Tag != "Invulnerable"))
            {
                item.Checked = item.Text == name;
            }
        }
Esempio n. 4
0
        public bool AreConditionsMets()
        {
            if (!_gotWatchedBlocks)
            {
                SetupWatchedBlocks();
            }

            if (UseConditions == false)
            {
                return(true);
            }

            int usedConditions      = 0;
            int satisfiedConditions = 0;

            if (_behavior == null)
            {
                _behavior = BehaviorManager.GetBehavior(_remoteControl);

                if (_behavior == null)
                {
                    return(false);
                }
            }

            if (CheckAllLoadedModIDs == true)
            {
                usedConditions++;
                bool missingMod = false;

                foreach (var mod in AllModIDsToCheck)
                {
                    if (Utilities.ModIDs.Contains(mod) == false)
                    {
                        Logger.MsgDebug(ProfileSubtypeId + ": Mod ID Not Present", DebugTypeEnum.Condition);
                        missingMod = true;
                        break;
                    }
                }

                if (!missingMod)
                {
                    satisfiedConditions++;
                }
            }

            if (CheckAnyLoadedModIDs == true)
            {
                usedConditions++;

                foreach (var mod in AllModIDsToCheck)
                {
                    if (Utilities.ModIDs.Contains(mod))
                    {
                        Logger.MsgDebug(ProfileSubtypeId + ": A Mod ID was Found: " + mod.ToString(), DebugTypeEnum.Condition);
                        satisfiedConditions++;
                        break;
                    }
                }
            }

            if (CheckTrueBooleans == true)
            {
                usedConditions++;
                bool failedCheck = false;

                foreach (var boolName in TrueBooleans)
                {
                    if (!_settings.GetCustomBoolResult(boolName))
                    {
                        Logger.MsgDebug(ProfileSubtypeId + ": Boolean Not True: " + boolName, DebugTypeEnum.Condition);
                        failedCheck = true;
                        break;
                    }
                }

                if (!failedCheck)
                {
                    satisfiedConditions++;
                }
            }

            if (CheckCustomCounters == true)
            {
                usedConditions++;
                bool failedCheck = false;

                if (CustomCounters.Count == CustomCountersTargets.Count)
                {
                    for (int i = 0; i < CustomCounters.Count; i++)
                    {
                        try {
                            var compareType = CounterCompareEnum.GreaterOrEqual;

                            if (i <= CounterCompareTypes.Count - 1)
                            {
                                compareType = CounterCompareTypes[i];
                            }

                            if (_settings.GetCustomCounterResult(CustomCounters[i], CustomCountersTargets[i], compareType) == false)
                            {
                                Logger.MsgDebug(ProfileSubtypeId + ": Counter Amount Condition Not Satisfied: " + CustomCounters[i], DebugTypeEnum.Condition);
                                failedCheck = true;
                                break;
                            }
                        } catch (Exception e) {
                            Logger.MsgDebug("Exception: ", DebugTypeEnum.Condition);
                            Logger.MsgDebug(e.ToString(), DebugTypeEnum.Condition);
                        }
                    }
                }
                else
                {
                    Logger.MsgDebug(ProfileSubtypeId + ": Counter Names and Targets List Counts Don't Match. Check Your Condition Profile", DebugTypeEnum.Condition);
                    failedCheck = true;
                }

                if (!failedCheck)
                {
                    satisfiedConditions++;
                }
            }

            if (CheckTrueSandboxBooleans == true)
            {
                usedConditions++;
                bool failedCheck = false;

                for (int i = 0; i < TrueSandboxBooleans.Count; i++)
                {
                    try {
                        bool output = false;
                        var  result = MyAPIGateway.Utilities.GetVariable(TrueSandboxBooleans[i], out output);

                        if (!result || !output)
                        {
                            Logger.MsgDebug(ProfileSubtypeId + ": Sandbox Boolean False: " + TrueSandboxBooleans[i], DebugTypeEnum.Condition);
                            failedCheck = true;
                            break;
                        }
                    } catch (Exception e) {
                        Logger.MsgDebug("Exception: ", DebugTypeEnum.Condition);
                        Logger.MsgDebug(e.ToString(), DebugTypeEnum.Condition);
                    }
                }

                if (!failedCheck)
                {
                    satisfiedConditions++;
                }
            }

            if (CheckCustomSandboxCounters == true)
            {
                usedConditions++;
                bool failedCheck = false;

                if (CustomSandboxCounters.Count == CustomSandboxCountersTargets.Count)
                {
                    for (int i = 0; i < CustomSandboxCounters.Count; i++)
                    {
                        try {
                            int counter = 0;
                            var result  = MyAPIGateway.Utilities.GetVariable(CustomSandboxCounters[i], out counter);

                            var compareType = CounterCompareEnum.GreaterOrEqual;

                            if (i <= SandboxCounterCompareTypes.Count - 1)
                            {
                                compareType = SandboxCounterCompareTypes[i];
                            }

                            bool counterResult = false;

                            if (compareType == CounterCompareEnum.GreaterOrEqual)
                            {
                                counterResult = (counter >= CustomSandboxCountersTargets[i]);
                            }

                            if (compareType == CounterCompareEnum.Greater)
                            {
                                counterResult = (counter > CustomSandboxCountersTargets[i]);
                            }

                            if (compareType == CounterCompareEnum.Equal)
                            {
                                counterResult = (counter == CustomSandboxCountersTargets[i]);
                            }

                            if (compareType == CounterCompareEnum.NotEqual)
                            {
                                counterResult = (counter != CustomSandboxCountersTargets[i]);
                            }

                            if (compareType == CounterCompareEnum.Less)
                            {
                                counterResult = (counter < CustomSandboxCountersTargets[i]);
                            }

                            if (compareType == CounterCompareEnum.LessOrEqual)
                            {
                                counterResult = (counter <= CustomSandboxCountersTargets[i]);
                            }

                            if (!result || !counterResult)
                            {
                                Logger.MsgDebug(ProfileSubtypeId + ": Sandbox Counter Amount Condition Not Satisfied: " + CustomSandboxCounters[i], DebugTypeEnum.Condition);
                                failedCheck = true;
                                break;
                            }
                        } catch (Exception e) {
                            Logger.MsgDebug("Exception: ", DebugTypeEnum.Condition);
                            Logger.MsgDebug(e.ToString(), DebugTypeEnum.Condition);
                        }
                    }
                }
                else
                {
                    Logger.MsgDebug(ProfileSubtypeId + ": Sandbox Counter Names and Targets List Counts Don't Match. Check Your Condition Profile", DebugTypeEnum.Condition);
                    failedCheck = true;
                }

                if (!failedCheck)
                {
                    satisfiedConditions++;
                }
            }

            if (CheckGridSpeed == true)
            {
                usedConditions++;
                float speed = (float)_remoteControl.GetShipSpeed();

                if ((MinGridSpeed == -1 || speed >= MinGridSpeed) && (MaxGridSpeed == -1 || speed <= MaxGridSpeed))
                {
                    Logger.MsgDebug(ProfileSubtypeId + ": Grid Speed High Enough", DebugTypeEnum.Condition);
                    satisfiedConditions++;
                }
                else
                {
                    Logger.MsgDebug(ProfileSubtypeId + ": Grid Speed Not High Enough", DebugTypeEnum.Condition);
                }
            }

            if (MESApi.MESApiReady && CheckMESBlacklistedSpawnGroups)
            {
                var blackList = MESApi.GetSpawnGroupBlackList();

                if (SpawnGroupBlacklistContainsAll.Count > 0)
                {
                    usedConditions++;
                    bool failedCheck = false;

                    foreach (var group in SpawnGroupBlacklistContainsAll)
                    {
                        if (blackList.Contains(group) == false)
                        {
                            Logger.MsgDebug(ProfileSubtypeId + ": A Spawngroup was not on MES BlackList: " + group, DebugTypeEnum.Condition);
                            failedCheck = true;
                            break;
                        }
                    }

                    if (!failedCheck)
                    {
                        satisfiedConditions++;
                    }
                }

                if (SpawnGroupBlacklistContainsAny.Count > 0)
                {
                    usedConditions++;
                    foreach (var group in SpawnGroupBlacklistContainsAll)
                    {
                        if (blackList.Contains(group))
                        {
                            Logger.MsgDebug(ProfileSubtypeId + ": A Spawngroup was on MES BlackList: " + group, DebugTypeEnum.Condition);
                            satisfiedConditions++;
                            break;
                        }
                    }
                }
            }

            if (UseAccumulatedDamageWatcher)
            {
                usedConditions++;
                bool failedCheck = false;

                if (MinAccumulatedDamage >= 0 && MinAccumulatedDamage < _settings.TotalDamageAccumulated)
                {
                    failedCheck = true;
                }

                if (MaxAccumulatedDamage >= 0 && MaxAccumulatedDamage > _settings.TotalDamageAccumulated)
                {
                    failedCheck = true;
                }

                if (!failedCheck)
                {
                    satisfiedConditions++;
                }
            }

            if (UseRequiredFunctionalBlocks)
            {
                if (_watchingAllBlocks)
                {
                    usedConditions++;

                    if (_watchedAllBlocksResult)
                    {
                        satisfiedConditions++;
                    }
                }

                if (_watchingAnyBlocks)
                {
                    usedConditions++;

                    if (_watchedAnyBlocksResult)
                    {
                        satisfiedConditions++;
                    }
                }

                if (_watchingNoneBlocks)
                {
                    usedConditions++;

                    if (_watchedNoneBlocksResult)
                    {
                        satisfiedConditions++;
                    }
                }
            }

            if (CheckTargetAltitudeDifference)
            {
                usedConditions++;

                if (_behavior.AutoPilot.Targeting.HasTarget() && _behavior.AutoPilot.InGravity())
                {
                    var planetPos      = _behavior.AutoPilot.CurrentPlanet.PositionComp.WorldAABB.Center;
                    var targetCoreDist = _behavior.AutoPilot.Targeting.Target.Distance(planetPos);
                    var myCoreDist     = Vector3D.Distance(planetPos, _remoteControl.GetPosition());
                    var difference     = targetCoreDist - myCoreDist;

                    if (difference >= this.MinTargetAltitudeDifference && difference <= this.MaxTargetAltitudeDifference)
                    {
                        satisfiedConditions++;
                    }
                }
            }

            if (CheckTargetDistance)
            {
                usedConditions++;

                if (_behavior.AutoPilot.Targeting.HasTarget())
                {
                    var dist = _behavior.AutoPilot.Targeting.Target.Distance(_remoteControl.GetPosition());

                    if ((this.MinTargetDistance == -1 || dist >= this.MinTargetDistance) && (this.MaxTargetDistance == -1 || dist <= this.MaxTargetDistance))
                    {
                        satisfiedConditions++;
                    }
                }
            }

            if (CheckTargetAngleFromForward)
            {
                usedConditions++;

                if (_behavior.AutoPilot.Targeting.HasTarget())
                {
                    var dirToTarget = Vector3D.Normalize(_behavior.AutoPilot.Targeting.GetTargetCoords() - _remoteControl.GetPosition());
                    var myForward   = _behavior.AutoPilot.RefBlockMatrixRotation.Forward;
                    var angle       = VectorHelper.GetAngleBetweenDirections(dirToTarget, myForward);

                    if ((this.MinTargetAngle == -1 || angle >= this.MinTargetAngle) && (this.MaxTargetAngle == -1 || angle <= this.MaxTargetAngle))
                    {
                        satisfiedConditions++;
                    }
                }
            }

            if (CheckIfTargetIsChasing)
            {
                usedConditions++;

                if (_behavior.AutoPilot.Targeting.HasTarget())
                {
                    var dirFromTarget  = Vector3D.Normalize(_remoteControl.GetPosition() - _behavior.AutoPilot.Targeting.GetTargetCoords());
                    var targetVelocity = Vector3D.Normalize(_behavior.AutoPilot.Targeting.Target.CurrentVelocity());

                    if (targetVelocity.IsValid() && targetVelocity.Length() > 0)
                    {
                        var angle = VectorHelper.GetAngleBetweenDirections(dirFromTarget, targetVelocity);

                        if ((this.MinTargetChaseAngle == -1 || angle >= this.MinTargetChaseAngle) && (this.MaxTargetChaseAngle == -1 || angle <= this.MaxTargetChaseAngle))
                        {
                            satisfiedConditions++;
                        }
                    }
                }
            }

            if (CheckIfGridNameMatches)
            {
                usedConditions++;

                if (!string.IsNullOrWhiteSpace(_remoteControl.SlimBlock.CubeGrid.CustomName))
                {
                    bool pass = false;

                    foreach (var name in GridNamesToCheck)
                    {
                        if (AllowPartialGridNameMatches)
                        {
                            if (_remoteControl.SlimBlock.CubeGrid.CustomName.Contains(name))
                            {
                                pass = true;
                            }
                        }
                        else
                        {
                            if (_remoteControl.SlimBlock.CubeGrid.CustomName == name)
                            {
                                pass = true;
                            }
                        }
                    }

                    if (pass)
                    {
                        satisfiedConditions++;
                    }
                }
            }

            if (UnderwaterCheck)
            {
                usedConditions++;

                if (WaterHelper.UnderwaterAndDepthCheck(_remoteControl.GetPosition(), _behavior.AutoPilot.CurrentWater, IsUnderwater, MinDistanceUnderwater, MaxDistanceUnderwater))
                {
                    satisfiedConditions++;
                }
            }

            if (TargetUnderwaterCheck)
            {
                usedConditions++;

                if (WaterHelper.UnderwaterAndDepthCheck(_remoteControl.GetPosition(), _behavior.AutoPilot.CurrentWater, TargetIsUnderwater, MinTargetDistanceUnderwater, MaxTargetDistanceUnderwater))
                {
                    satisfiedConditions++;
                }
            }

            if (BehaviorModeCheck)
            {
                usedConditions++;

                if (_behavior.Mode == CurrentBehaviorMode)
                {
                    satisfiedConditions++;
                }
            }

            if (MatchAnyCondition == false)
            {
                bool result = satisfiedConditions >= usedConditions;
                Logger.MsgDebug(ProfileSubtypeId + ": All Condition Satisfied: " + result.ToString(), DebugTypeEnum.Condition);
                Logger.MsgDebug(string.Format("Used Conditions: {0} // Satisfied Conditions: {1}", usedConditions, satisfiedConditions), DebugTypeEnum.Condition);
                return(result);
            }
            else
            {
                bool result = satisfiedConditions > 0;
                Logger.MsgDebug(ProfileSubtypeId + ": Any Condition(s) Satisfied: " + result.ToString(), DebugTypeEnum.Condition);
                Logger.MsgDebug(string.Format("Used Conditions: {0} // Satisfied Conditions: {1}", usedConditions, satisfiedConditions), DebugTypeEnum.Condition);
                return(result);
            }
        }