Esempio n. 1
0
        public TriggerProfile()
        {
            Type = "";

            UseTrigger               = false;
            TargetDistance           = 3000;
            InsideAntenna            = false;
            InsideAntennaName        = "";
            PlayerNearPositionOffset = Vector3D.Zero;
            MinCooldownMs            = 0;
            MaxCooldownMs            = 1;
            StartsReady              = false;
            MaxActions               = -1;
            Actions             = new List <ActionProfile>();
            DamageTypes         = new List <string>();
            ExcludedDamageTypes = new List <string>();
            Conditions          = new ConditionProfile();

            Triggered        = false;
            CooldownTime     = 0;
            TriggerCount     = 0;
            LastTriggerTime  = MyAPIGateway.Session.GameDateTime;
            DetectedEntityId = 0;

            Conditions = new ConditionProfile();
            ConditionCheckResetsTimer = false;

            MinPlayerReputation           = -1501;
            MaxPlayerReputation           = 1501;
            AllPlayersMustMatchReputation = false;
            CustomReputationRangeCheck    = 5000;

            InventoryBlockName        = "";
            InventoryItemDefinitionId = "";
            InventoryItemMin          = -1;
            InventoryItemMax          = -1;

            CommandReceiveCode           = "";
            CommandCodeType              = CommandType.DroneAntenna;
            AllowCommandCodePartialMatch = false;

            NextActionIndex = 0;
            ActionExecution = ActionExecutionEnum.All;

            SensorName = "";

            DespawnTypeFromSpawner = "";

            ProfileSubtypeId = "";


            Rnd = new Random();
        }
Esempio n. 2
0
        public void InitTags(string customData)
        {
            if (string.IsNullOrWhiteSpace(customData) == false)
            {
                var descSplit = customData.Split('\n');

                foreach (var tag in descSplit)
                {
                    //Type
                    if (tag.Contains("[Type:") == true)
                    {
                        Type = TagHelper.TagStringCheck(tag);
                    }

                    //UseTrigger
                    if (tag.Contains("[UseTrigger:") == true)
                    {
                        UseTrigger = TagHelper.TagBoolCheck(tag);
                    }

                    //InsideAntenna
                    if (tag.Contains("[InsideAntenna:") == true)
                    {
                        InsideAntenna = TagHelper.TagBoolCheck(tag);
                    }

                    //InsideAntennaName
                    if (tag.Contains("[InsideAntennaName:") == true)
                    {
                        InsideAntennaName = TagHelper.TagStringCheck(tag);
                    }

                    //TargetDistance
                    if (tag.Contains("[TargetDistance:") == true)
                    {
                        TargetDistance = TagHelper.TagDoubleCheck(tag, TargetDistance);
                    }

                    //MinCooldown
                    if (tag.Contains("[MinCooldownMs:") == true)
                    {
                        MinCooldownMs = TagHelper.TagFloatCheck(tag, MinCooldownMs);
                    }

                    //MaxCooldown
                    if (tag.Contains("[MaxCooldownMs:") == true)
                    {
                        MaxCooldownMs = TagHelper.TagFloatCheck(tag, MaxCooldownMs);
                    }

                    //StartsReady
                    if (tag.Contains("[StartsReady:") == true)
                    {
                        StartsReady = TagHelper.TagBoolCheck(tag);
                    }

                    //MaxActions
                    if (tag.Contains("[MaxActions:") == true)
                    {
                        MaxActions = TagHelper.TagIntCheck(tag, MaxActions);
                    }

                    //Actions
                    if (tag.Contains("[Actions:") == true)
                    {
                        var  tempValue = TagHelper.TagStringCheck(tag);
                        bool gotAction = false;

                        if (string.IsNullOrWhiteSpace(tempValue) == false)
                        {
                            byte[] byteData = { };

                            if (TagHelper.ActionObjectTemplates.TryGetValue(tempValue, out byteData) == true)
                            {
                                try {
                                    var profile = MyAPIGateway.Utilities.SerializeFromBinary <ActionProfile>(byteData);

                                    if (profile != null)
                                    {
                                        Actions.Add(profile);
                                        gotAction = true;
                                    }
                                } catch (Exception) {
                                }
                            }
                        }

                        if (!gotAction)
                        {
                            Logger.WriteLog("Could Not Find Action Profile Associated To Tag: " + tag);
                        }
                    }

                    //DamageTypes
                    if (tag.Contains("[DamageTypes:") == true)
                    {
                        var tempValue = TagHelper.TagStringCheck(tag);

                        if (!string.IsNullOrWhiteSpace(tempValue) && DamageTypes.Contains(tempValue) == false)
                        {
                            DamageTypes.Add(tempValue);
                        }
                    }

                    //ExcludedDamageTypes
                    if (tag.Contains("[ExcludedDamageTypes:") == true)
                    {
                        var tempValue = TagHelper.TagStringCheck(tag);

                        if (!string.IsNullOrWhiteSpace(tempValue) && ExcludedDamageTypes.Contains(tempValue) == false)
                        {
                            ExcludedDamageTypes.Add(tempValue);
                        }
                    }

                    //MinPlayerReputation
                    if (tag.Contains("[MinPlayerReputation:") == true)
                    {
                        MinPlayerReputation = TagHelper.TagIntCheck(tag, MinPlayerReputation);
                    }

                    //MaxPlayerReputation
                    if (tag.Contains("[MaxPlayerReputation:") == true)
                    {
                        MaxPlayerReputation = TagHelper.TagIntCheck(tag, MaxPlayerReputation);
                    }

                    //AllPlayersMustMatchReputation
                    if (tag.Contains("[AllPlayersMustMatchReputation:") == true)
                    {
                        AllPlayersMustMatchReputation = TagHelper.TagBoolCheck(tag);
                    }

                    //CustomReputationRangeCheck
                    if (tag.Contains("[CustomReputationRangeCheck:") == true)
                    {
                        CustomReputationRangeCheck = TagHelper.TagDoubleCheck(tag, CustomReputationRangeCheck);
                    }

                    //Conditions
                    if (tag.Contains("[Conditions:") == true)
                    {
                        var  tempValue    = TagHelper.TagStringCheck(tag);
                        bool gotCondition = false;

                        if (string.IsNullOrWhiteSpace(tempValue) == false)
                        {
                            byte[] byteData = { };

                            if (TagHelper.ConditionObjectTemplates.TryGetValue(tempValue, out byteData) == true)
                            {
                                try {
                                    var profile = MyAPIGateway.Utilities.SerializeFromBinary <ConditionProfile>(byteData);

                                    if (profile != null)
                                    {
                                        Conditions   = profile;
                                        gotCondition = true;
                                    }
                                } catch (Exception) {
                                }
                            }
                        }

                        if (!gotCondition)
                        {
                            Logger.WriteLog("Could Not Find Condition Profile Associated To Tag: " + tag);
                        }
                    }

                    //ConditionCheckResetsTimer
                    if (tag.Contains("[ConditionCheckResetsTimer:") == true)
                    {
                        ConditionCheckResetsTimer = TagHelper.TagBoolCheck(tag);
                    }

                    //CommandReceiveCode
                    if (tag.Contains("[CommandReceiveCode:") == true)
                    {
                        CommandReceiveCode = TagHelper.TagStringCheck(tag);
                    }

                    //PlayerNearPositionOffset
                    if (tag.Contains("[PlayerNearPositionOffset:") == true)
                    {
                        PlayerNearPositionOffset = TagHelper.TagVector3DCheck(tag);
                    }

                    //ActionExecution
                    if (tag.Contains("[ActionExecution:") == true)
                    {
                        ActionExecution = TagHelper.TagActionExecutionCheck(tag);
                    }

                    //SensorName
                    if (tag.Contains("[SensorName:") == true)
                    {
                        SensorName = TagHelper.TagStringCheck(tag);
                    }

                    //DespawnTypeFromSpawner
                    if (tag.Contains("[DespawnTypeFromSpawner:") == true)
                    {
                        DespawnTypeFromSpawner = TagHelper.TagStringCheck(tag);
                    }
                }
            }

            if (MinCooldownMs > MaxCooldownMs)
            {
                MinCooldownMs = MaxCooldownMs;
            }

            if (StartsReady == true)
            {
                CooldownTime = 0;
            }
            else
            {
                CooldownTime = Rnd.Next((int)MinCooldownMs, (int)MaxCooldownMs);
            }
        }