public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            this.minduration = taskConfig["minduration"].AsInt(2000);
            this.maxduration = taskConfig["maxduration"].AsInt(4000);
            this.chance      = taskConfig["chance"].AsFloat(1.1f);
            string code = taskConfig["onBlockBelowCode"].AsString(null);

            tamingGenerations = taskConfig["tamingGenerations"].AsFloat(10f);

            if (code != null && code.Length > 0)
            {
                this.onBlockBelowCode = new AssetLocation(code);
            }

            stopRange           = taskConfig["stopRange"].AsFloat(0f);
            stopOnHurt          = taskConfig["stopOnHurt"].AsBool(false);
            duringDayTimeFrames = taskConfig["duringDayTimeFrames"].AsObject <DayTimeFrame[]>(null);

            if (taskConfig["stopOnNearbyEntityCodes"] != null)
            {
                string[] codes = taskConfig["stopOnNearbyEntityCodes"].AsArray <string>(new string[] { "player" });

                List <string> exact      = new List <string>();
                List <string> beginswith = new List <string>();

                for (int i = 0; i < codes.Length; i++)
                {
                    string ecode = codes[i];
                    if (ecode.EndsWith("*"))
                    {
                        beginswith.Add(ecode.Substring(0, ecode.Length - 1));
                    }
                    else
                    {
                        exact.Add(ecode);
                    }
                }

                stopOnNearbyEntityCodesExact      = exact.ToArray();
                stopOnNearbyEntityCodesBeginsWith = beginswith.ToArray();
            }



            idleUntilMs = entity.World.ElapsedMilliseconds + minduration + entity.World.Rand.Next(maxduration - minduration);

            int   generation          = entity.WatchedAttributes.GetInt("generation", 0);
            float fearReductionFactor = Math.Max(0f, (tamingGenerations - generation) / tamingGenerations);

            if (whenInEmotionState != null)
            {
                fearReductionFactor = 1;
            }

            stopRange *= fearReductionFactor;

            base.LoadConfig(taskConfig, aiConfig);
        }
Example #2
0
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            base.LoadConfig(taskConfig, aiConfig);

            this.durationMs  = taskConfig["durationMs"].AsInt(1500);
            this.releaseAtMs = taskConfig["releaseAtMs"].AsInt(1000);
            this.minDist     = taskConfig["minDist"].AsFloat(3f);
            this.minVertDist = taskConfig["minVertDist"].AsFloat(2f);
            this.maxDist     = taskConfig["maxDist"].AsFloat(15f);
        }
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            msLaunch = World.ElapsedMilliseconds;

            collisionTestBox = CollisionBox.Clone().OmniGrowBy(0.05f);

            if (api.Side == EnumAppSide.Server)
            {
                GetBehavior <EntityBehaviorPassivePhysics>().OnPhysicsTickCallback = onPhysicsTickCallback;

                ep = api.ModLoader.GetModSystem <EntityPartitioning>();
            }
        }
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            base.Initialize(properties, api, InChunkIndex3d);

            msLaunch = World.ElapsedMilliseconds;

            collisionTestBox = SelectionBox.Clone().OmniGrowBy(0.05f);

            if (api.Side == EnumAppSide.Server)
            {
                GetBehavior <EntityBehaviorPassivePhysics>().OnPhysicsTickCallback = onPhysicsTickCallback;
                ep = api.ModLoader.GetModSystem <EntityPartitioning>();
            }

            GetBehavior <EntityBehaviorPassivePhysics>().collisionYExtra = 0f; // Slightly cheap hax so that stones/arrows don't collid with fences
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            base.LoadConfig(taskConfig, aiConfig);

            tamingGenerations     = taskConfig["tamingGenerations"].AsFloat(10f);
            moveSpeed             = taskConfig["movespeed"].AsFloat(0.02f);
            seekingRange          = taskConfig["seekingRange"].AsFloat(25);
            executionChance       = taskConfig["executionChance"].AsFloat(0.1f);
            minDayLight           = taskConfig["minDayLight"].AsFloat(-1f);
            cancelOnHurt          = taskConfig["cancelOnHurt"].AsBool(false);
            ignoreDeepDayLight    = taskConfig["ignoreDeepDayLight"].AsBool(false);
            fleeingDistance       = taskConfig["fleeingDistance"].AsFloat(seekingRange + 15);
            fleeDurationMs        = taskConfig["fleeDurationMs"].AsInt(9000);
            lowStabilityAttracted = entity.World.Config.GetString("temporalStability").ToBool(true) && entity.Properties.Attributes?["spawnCloserDuringLowStability"].AsBool() == true;
        }
Example #6
0
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            base.LoadConfig(taskConfig, aiConfig);

            leapAnimationCode     = taskConfig["leapAnimation"].AsString("jump");
            leapChance            = taskConfig["leapChance"].AsFloat(1);
            leapHeightMul         = taskConfig["leapHeightMul"].AsFloat(1);
            moveSpeed             = taskConfig["movespeed"].AsFloat(0.02f);
            extraTargetDistance   = taskConfig["extraTargetDistance"].AsFloat(0f);
            seekingRange          = taskConfig["seekingRange"].AsFloat(25);
            belowTempSeekingRange = taskConfig["belowTempSeekingRange"].AsFloat(25);
            belowTempThreshold    = taskConfig["belowTempThreshold"].AsFloat(-999);
            maxFollowTime         = taskConfig["maxFollowTime"].AsFloat(60);
            alarmHerd             = taskConfig["alarmHerd"].AsBool(false);
            leapAtTarget          = taskConfig["leapAtTarget"].AsBool(false);
            retaliateAttacks      = taskConfig["retaliateAttacks"].AsBool(true);
        }
Example #7
0
        public override void Initialize(EntityProperties properties, JsonObject attributes)
        {
            base.Initialize(properties, attributes);

            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            base.LoadConfig(taskConfig, aiConfig);


            if (taskConfig["leapAnimation"].Exists)
            {
                leapAnimationCode = taskConfig["leapAnimation"].AsString(null);
            }

            if (taskConfig["leapChance"].Exists)
            {
                leapChance = taskConfig["leapChance"].AsFloat(1);
            }

            if (taskConfig["leapHeightMul"].Exists)
            {
                leapHeightMul = taskConfig["leapHeightMul"].AsFloat(1);
            }

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["seekingRange"] != null)
            {
                seekingRange = taskConfig["seekingRange"].AsFloat(25);
            }

            if (taskConfig["belowTempSeekingRange"] != null)
            {
                belowTempSeekingRange = taskConfig["belowTempSeekingRange"].AsFloat(25);
            }

            if (taskConfig["belowTempThreshold"] != null)
            {
                belowTempThreshold = taskConfig["belowTempThreshold"].AsFloat(-999);
            }



            if (taskConfig["maxFollowTime"] != null)
            {
                maxFollowTime = taskConfig["maxFollowTime"].AsFloat(60);
            }

            if (taskConfig["alarmHerd"] != null)
            {
                alarmHerd = taskConfig["alarmHerd"].AsBool(false);
            }

            if (taskConfig["leapAtTarget"] != null)
            {
                leapAtTarget = taskConfig["leapAtTarget"].AsBool(false);
            }

            if (taskConfig["entityCodes"] != null)
            {
                string[] codes = taskConfig["entityCodes"].AsArray <string>(new string[] { "player" });

                List <string> exact      = new List <string>();
                List <string> beginswith = new List <string>();

                for (int i = 0; i < codes.Length; i++)
                {
                    string code = codes[i];
                    if (code.EndsWith("*"))
                    {
                        beginswith.Add(code.Substring(0, code.Length - 1));
                    }
                    else
                    {
                        exact.Add(code);
                    }
                }

                seekEntityCodesExact      = exact.ToArray();
                seekEntityCodesBeginsWith = beginswith.ToArray();
            }
        }
        public override void LoadConfig(JsonObject taskConfig, JsonObject aiConfig)
        {
            partitionUtil = entity.Api.ModLoader.GetModSystem <EntityPartitioning>();

            base.LoadConfig(taskConfig, aiConfig);

            if (taskConfig["movespeed"] != null)
            {
                moveSpeed = taskConfig["movespeed"].AsFloat(0.02f);
            }

            if (taskConfig["seekingRange"] != null)
            {
                seekingRange = taskConfig["seekingRange"].AsFloat(25);
            }

            if (taskConfig["executionChance"] != null)
            {
                executionChance = taskConfig["executionChance"].AsFloat(0.07f);
            }

            if (taskConfig["minDayLight"] != null)
            {
                minDayLight = taskConfig["minDayLight"].AsFloat(-1f);
            }

            if (taskConfig["cancelOnHurt"] != null)
            {
                cancelOnHurt = taskConfig["cancelOnHurt"].AsBool(false);
            }

            if (taskConfig["ignoreDeepDayLight"] != null)
            {
                ignoreDeepDayLight = taskConfig["ignoreDeepDayLight"].AsBool(false);
            }

            if (taskConfig["fleeingDistance"] != null)
            {
                fleeingDistance = taskConfig["fleeingDistance"].AsFloat(25f);
            }
            else
            {
                fleeingDistance = seekingRange + 6;
            }

            if (taskConfig["fleeDurationMs"] != null)
            {
                fleeDurationMs = taskConfig["fleeDurationMs"].AsInt(9000);
            }

            if (taskConfig["entityCodes"] != null)
            {
                string[] codes = taskConfig["entityCodes"].AsArray <string>(new string[] { "player" });

                List <string> exact      = new List <string>();
                List <string> beginswith = new List <string>();

                for (int i = 0; i < codes.Length; i++)
                {
                    string code = codes[i];
                    if (code.EndsWith("*"))
                    {
                        beginswith.Add(code.Substring(0, code.Length - 1));
                    }
                    else
                    {
                        exact.Add(code);
                    }
                }

                fleeEntityCodesExact      = exact.ToArray();
                fleeEntityCodesBeginsWith = beginswith.ToArray();
            }

            lowStabilityAttracted = entity.World.Config.GetString("temporalStability").ToBool(true) && entity.Properties.Attributes?["spawnCloserDuringLowStability"].AsBool() == true;
        }