示例#1
0
        public override void GenerateStartingParty(Map map, ResolveParams rp)
        {
            ScatterOptions currentOptions = rp.GetCustom <ScatterOptions>(Constants.ScatterOptions);
            float          uncoveredCost  = currentOptions.uncoveredCost;

            int points       = (int)(uncoveredCost / (10 * militaryPower));
            int initialGroup = 0;

            if (points > 10000)
            {
                initialGroup = Rand.Range(5000, 10000);
            }
            else
            {
                initialGroup = points;
            }
            Debug.Log(Debug.ForceGen, "Military gen: uncoveredCost {0}, military power: {1}, total points allowed: {2}", uncoveredCost, militaryPower, points);

            points -= initialGroup;
            SpawnGroup((int)ScalePointsToDifficulty(initialGroup), rp.rect, rp.faction, map);
            Debug.Log(Debug.ForceGen, "Initial group of {0} spawned, {1} points left for triggers", initialGroup, points);

            while (points > 0)
            {
                IntVec3 mapLocation = rp.rect.RandomCell;
                if (!mapLocation.InBounds(map))
                {
                    continue;
                }

                ThingDef    raidTriggerDef = ThingDef.Named("RaidTrigger");
                RaidTrigger trigger        = ThingMaker.MakeThing(raidTriggerDef) as RaidTrigger;

                trigger.faction = rp.faction;
                trigger.SetTimeouts(0, 300);

                int   raidMaxPoints = (int)(10000 / Math.Max(Math.Sqrt(d: militaryPower), 1.0));
                float raidValue     = Math.Abs(Rand.Gaussian()) * raidMaxPoints + Rand.Value * raidMaxPoints + 250.0f;
                if (raidValue > 10000)
                {
                    raidValue = Rand.Range(8000, 11000);                    //sanity cap. against some beta-poly bases.
                }
                points -= (int)raidValue;

                trigger.value = ScalePointsToDifficulty(points);

                GenSpawn.Spawn(trigger, mapLocation, map);
                Debug.Log(Debug.ForceGen, "Spawned trigger at {0}, {1} for {2} points, autofiring after {3} rare ticks", mapLocation.x, mapLocation.z, trigger.value, 0);
            }
        }
示例#2
0
        public override void GenerateForces(Map map, ResolveParams rp)
        {
            ScatterOptions options = rp.GetCustom <ScatterOptions>(Constants.ScatterOptions);

            if (options == null)
            {
                return;
            }

            int   addedTriggers = 0;
            float ratio         = 10;
            float remainingCost = options.uncoveredCost * (Rand.Value + 0.5f); //cost estimation as seen by other factions

            float initialCost = remainingCost;

            int triggersAbsoluteMaximum = 100;

            while (remainingCost > 0)
            {
                IntVec3 mapLocation = rp.rect.RandomCell;
                if (!mapLocation.InBounds(map))
                {
                    continue;
                }

                ThingDef    raidTriggerDef = ThingDef.Named("RaidTrigger");
                RaidTrigger trigger        = ThingMaker.MakeThing(raidTriggerDef) as RaidTrigger;

                if (options.allowFriendlyRaids)
                {
                    if (Rand.Chance(0.2f))
                    {
                        trigger.faction = Find.FactionManager.RandomNonHostileFaction();
                    }
                    else
                    {
                        trigger.faction = Find.FactionManager.RandomEnemyFaction();
                    }
                }
                else
                {
                    trigger.faction = Find.FactionManager.RandomEnemyFaction();
                }

                int   raidMaxPoints = (int)(remainingCost / ratio);
                float raidValue     = Math.Abs(Rand.Gaussian()) * raidMaxPoints + Rand.Value * raidMaxPoints + 250.0f;
                if (raidValue > 10000)
                {
                    raidValue = Rand.Range(8000, 11000);                    //sanity cap. against some beta-poly bases.
                }
                remainingCost -= raidValue * ratio;

                trigger.value = ScalePointsToDifficulty(raidValue);

                GenSpawn.Spawn(trigger, mapLocation, map);
                Debug.Log(Debug.ForceGen, "Spawned trigger at {0}, {1} for {2} points, autofiring after {3} rare ticks", mapLocation.x, mapLocation.z, trigger.value, 0);
                addedTriggers++;

                options.uncoveredCost = Math.Abs(remainingCost);

                if (addedTriggers > triggersAbsoluteMaximum)
                {
                    if (remainingCost < initialCost * 0.2f)
                    {
                        if (Rand.Chance(0.1f))
                        {
                            if (remainingCost > 100000)
                            {
                                remainingCost = Rand.Range(80000, 110000);
                            }
                            return;
                        }
                    }
                }
            }
        }
示例#3
0
        public override void GenerateForces(Map map, ResolveParams rp, ScatterOptions options)
        {
            if (options == null)
            {
                return;
            }

            int   addedTriggers = 0;
            float ratio         = 10;
            float remainingCost = options.uncoveredCost * (Rand.Value + 0.5f); //cost estimation as seen by other factions

            Debug.Log(Debug.ForceGen, "Running citizen force generation with remaining cost of {0} (while uncovered is {1})", remainingCost, options.uncoveredCost);

            float initialCost = remainingCost;

            int triggersAbsoluteMaximum = 100;

            while (remainingCost > 0)
            {
                IntVec3 mapLocation = rp.rect.RandomCell;
                if (!mapLocation.InBounds(map))
                {
                    continue;
                }

                ThingDef    raidTriggerDef = ThingDef.Named("RaidTrigger");
                RaidTrigger trigger        = ThingMaker.MakeThing(raidTriggerDef) as RaidTrigger;

                trigger.faction = rp.faction;

                int   raidMaxPoints = (int)(remainingCost / ratio);
                float raidValue     = Math.Abs(Rand.Gaussian()) * raidMaxPoints + Rand.Value * raidMaxPoints + 250.0f;
                if (raidValue > 10000)
                {
                    raidValue = Rand.Range(8000, 11000);                    //sanity cap. against some beta-poly bases.
                }
                remainingCost -= raidValue * ratio;

                int timeout = (int)Math.Abs(Rand.Gaussian(0, 75));
                trigger.value = ScalePointsToDifficulty(raidValue);
                trigger.SetTimeouts(timeout, 200);

                GenSpawn.Spawn(trigger, mapLocation, map);
                Debug.Log(Debug.ForceGen, "Spawned trigger at {0}, {1} for {2} points, autofiring after {3} rare ticks", mapLocation.x, mapLocation.z, trigger.value, timeout);
                addedTriggers++;

                options.uncoveredCost = Math.Abs(remainingCost);

                if (addedTriggers > triggersAbsoluteMaximum)
                {
                    if (remainingCost < initialCost * 0.2f)
                    {
                        if (Rand.Chance(0.1f))
                        {
                            if (remainingCost > 100000)
                            {
                                remainingCost = Rand.Range(80000, 110000);
                            }
                            return;
                        }
                    }
                }
            }
        }