Ejemplo 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 ActionProfile();
            DamageTypes = 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 = "";

            ProfileSubtypeId = "";


            Rnd = new Random();
        }
Ejemplo 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   = 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);
                        }
                    }

                    //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)
                                    {
                                        this.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);
                    }
                }
            }

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

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