Example #1
0
        public ForagingJobSettings(string blockType, string npcTypeKey, ILootTable lootTable, int foragingTimeMinSec, int foragingTimeMaxSec, float lootLuckModifier = 0f)
        {
            ItemTypes.ItemType type = ItemTypes.GetType(blockType);
            if (type.RotatedXMinus != null)
            {
                BlockTypes = new ItemTypes.ItemType[5]
                {
                    type,
                    ItemTypes.GetType(type.RotatedXPlus),
                    ItemTypes.GetType(type.RotatedXMinus),
                    ItemTypes.GetType(type.RotatedZPlus),
                    ItemTypes.GetType(type.RotatedZMinus)
                };
            }
            else
            {
                BlockTypes = new ItemTypes.ItemType[5]
                {
                    type,
                    ItemTypes.GetType(blockType + "x+"),
                    ItemTypes.GetType(blockType + "x-"),
                    ItemTypes.GetType(blockType + "z+"),
                    ItemTypes.GetType(blockType + "z-")
                };
            }

            NPCType            = NPCType.GetByKeyNameOrDefault(npcTypeKey);
            RecruitmentItem    = new InventoryItem(LeafSash.NAME);
            LootTable          = lootTable;
            ForagingTimeMaxSec = foragingTimeMaxSec;
            ForagingTimeMinSec = foragingTimeMinSec;
            LuckMod            = lootLuckModifier;
        }
Example #2
0
        public ILootDefinition Drop(ILootTable lootTable)
        {
            if (lootTable == null || lootTable.Children.Count == 0)
            {
                return(null);
            }

            var item = Pick(lootTable.Children);

            if (item == null)
            {
                return(null);
            }

            var bonus = (Math.Round(GlobalRolls * 0.01, 3));

            lock (Common.Generator.Random)
            {
                var roll = Math.Abs((Common.Generator.Random.NextDouble() * 2.0) - 1.0);
                if (roll - bonus <= item.Weight || bonus > 0.05)
                {
                    GlobalRolls = 0;

                    if (item is ILootTable childTable)
                    {
                        return(Drop(childTable));
                    }

                    return(item);
                }
            }

            GlobalRolls++;
            return(null);
        }
Example #3
0
        public ILootDefinition Drop(ILootTable lootTable)
        {
            var item = Pick(lootTable.Children);

            if (item == null)
            {
                return(null);
            }

            GlobalRolls++;


            lock (Common.Generator.Random)
            {
                var roll = Math.Abs((Common.Generator.Random.NextDouble() * 2.0) - 1.0);
                if (roll <= item.Weight)
                {
                    Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);

                    Console.ForegroundColor = ConsoleColor.Gray;
                    if (item.Name == "Epic")
                    {
                        Console.ForegroundColor = ConsoleColor.DarkMagenta;
                        Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);
                    }
                    if (item.Name == "Rare")
                    {
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);
                    }
                    if (item.Name == "Legendary")
                    {
                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);
                    }
                    if (item.Name == "Godly")
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);
                    }
                    if (item.Name == "Forsaken")
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Won Roll: {0} - {1} - {2}", item.Name, roll, GlobalRolls);
                    }



                    if (item is ILootTable childTable)
                    {
                        return(Drop(childTable));
                    }

                    return(item);
                }
            }

            return(null);
        }
Example #4
0
 public ForagingGoal(IJob job, Vector3Int pos, ILootTable lootTable, int foragingTimeMinSec, int foragingTimeMaxSec, float lootLuckModifier = 0f)
 {
     Job                = job;
     JobPos             = pos;
     LootTable          = lootTable;
     ForagingTimeMaxSec = foragingTimeMaxSec;
     ForagingTimeMinSec = foragingTimeMinSec;
     LuckMod            = lootLuckModifier;
 }
Example #5
0
        public ILootDefinition Drop(ILootTable lootTable, string name)
        {
            var item = lootTable.Get(name);

            if (item is ILootTable childTable)
            {
                return(Drop(childTable));
            }

            return(item);
        }
Example #6
0
        public LevelEnemyUnitSetupProcessor(AgentFactory agentFactory, IItemTemplateRepository itemTemplateRepository, IRandomizer randomizer, IUnitIdPool unitIdPool, UnitBuilder unitBuilder, IAbilityRepository abilityRepository, ISpellRepository spellRepository, ICardEffectsRepository cardEffectsRepository)
        {
            AgentFactory           = agentFactory;
            ItemTemplateRepository = itemTemplateRepository;
            Randomizer             = randomizer;
            UnitIdPool             = unitIdPool;
            UnitBuilder            = unitBuilder;
            AbilityRepository      = abilityRepository;
            SpellRepository        = spellRepository;
            CardEffectsRepository  = cardEffectsRepository;

            GlobalLootTable = GenerateLootTable();
        }
Example #7
0
        public IEnumerable <IItem> GetLoot(ILootTable lootTable)
        {
            var droppedLoot = new List <IItem>();

            var possibleLootGroups = lootTable.LootGroups
                                     .Where(g => g.IsPossible && RandomGenerationHelper.RandomNumber(0, 10000) <= g.LootGroupRollProbability);

            foreach (var lootGroup in possibleLootGroups)
            {
                droppedLoot.AddRange(ProcessLootGroup(lootGroup));
            }

            return(droppedLoot.Any() ? droppedLoot : Enumerable.Empty <IItem>());
        }
Example #8
0
        public IEnumerable <ILootDefinition> Drop(ILootTable lootTable, int amount, string name)
        {
            if (amount <= 0)
            {
                return(new List <ILootDefinition>());
            }

            var drops = new List <ILootDefinition>();

            for (var i = 0; i < amount; i++)
            {
                drops.Add(Drop(lootTable, name));
            }

            return(drops);
        }
        public void Calculate(ILootTable lootTable)
        {
            int groupIterator = 1;

            foreach (var lootGroup in lootTable.LootGroups)
            {
                Console.WriteLine($"Group {groupIterator}");
                Console.WriteLine($"Group probability: {Math.Round((double)lootGroup.LootGroupRollProbability, 2)}");

                foreach (var lootItem in lootGroup.LootItems)
                {
                    double probability = (lootGroup.LootGroupRollProbability * (double)lootItem.Probability) / 100;
                    Console.WriteLine($"Id: {lootItem.Id}\tBase probability: {Math.Round((double)lootItem.Probability, 2)}%\tCalculated probability: {Math.Round(probability, 2)}%");
                }

                groupIterator++;
            }
        }
Example #10
0
        public IEnumerable <ILootDefinition> Drop(ILootTable lootTable, int amount)
        {
            if (amount <= 0)
            {
                return(new List <ILootDefinition>());
            }

            OnDropStarted?.Invoke(this, EventArgs.Empty);

            var drops = new List <ILootDefinition>();

            for (var i = 0; i < amount; i++)
            {
                drops.Add(Drop(lootTable));
            }

            OnDropCompleted?.Invoke(this, EventArgs.Empty);

            return(drops);
        }
Example #11
0
 /// <summary>
 /// Spawns loot into the world at the given location
 /// </summary>
 /// <param name="coords">The location to spawn the loot</param>
 /// <param name="loot">the <see cref="LootTable"/> to spawn in</param>
 public void Loot(Vector coords, ILootTable loot)
 {
     ForFunction.AddCommand(new LootCommand(new LootTargets.SpawnTarget(coords), new LootSources.LoottableSource(loot)));
 }
 public HumanoidLootTableDecorator(ILootTable lootTable) : base(lootTable)
 {
 }
 protected Creature(int hitpoints, IItemManager itemManager, string name, bool removable, Position position, ILootTable lootTable) : base(name, removable, position)
 {
     Hitpoints   = hitpoints;
     ItemManager = itemManager;
     LootTable   = lootTable;
 }
Example #14
0
 public AbstractLootTableDecorator(ILootTable lootTable)
 {
     LootTable = lootTable;
 }
 public BoarLootTableDecorator(ILootTable lootTable) : base(lootTable)
 {
 }
 public RawMeatLootTable(ILootTable lootTable) : base(lootTable)
 {
 }
 public TuskLootTable(ILootTable lootTable) : base(lootTable)
 {
 }
Example #18
0
 /// <summary>
 /// Puts the item from the loot table into the players hotbar
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="loot">the <see cref="LootTable"/> to give the player</param>
 /// <param name="slot">The hotbar slot to put the item in</param>
 public void GiveHotbar(BaseSelector player, ILootTable loot, int slot)
 {
     ForFunction.AddCommand(new LootCommand(new LootTargets.EntityTarget(player, new Slots.HotbarSlot(slot)), new LootSources.LoottableSource(loot)));
 }
Example #19
0
 /// <summary>
 /// Gives the loot from a loottable to the selected players
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="loot">the <see cref="LootTable"/> to give the player</param>
 public void GiveItem(BaseSelector player, ILootTable loot)
 {
     ForFunction.AddCommand(new LootCommand(new LootTargets.GiveTarget(player), new LootSources.LoottableSource(loot)));
 }
 public HumanoidCreature(int level, int hitpoints, IItemManager itemManager, string name, bool removable,
                         Position position, ILootTable lootTable) : base(hitpoints, itemManager, name, removable, position, lootTable, level)
 {
 }
 public LeatherLootTable(ILootTable lootTable) : base(lootTable)
 {
 }
Example #22
0
 public ChestController(ILootTable lootTable, ILogger logger)
 {
     _lootTable = lootTable;
     _logger    = logger;
 }
 protected CreatureCombatBehavior(int hitpoints, IItemManager itemManager, string name, bool removable, Position position, ILootTable lootTable, int level) : base(hitpoints, itemManager, name, removable, position, lootTable)
 {
     Level = level;
 }