Beispiel #1
0
    private void EarnLootForCharacter(CharacterData inCharacter)
    {
        //REMOVED: local stat reporting

        if (inCharacter is EnemyCharacterData)
        {
            EnemyCharacterData enemy     = (EnemyCharacterData)inCharacter;
            LootBundle         enemyLoot = PoolManager.poolLootBundles.GetNext();

            //REMOVED: local stat reporting

            //only earn gold if the enemy isn't ore
            if (!enemy.isOre)
            {
                long goldDrop = enemy.GetGoldValue();
                goldDrop = adventure.BoostGoldByActiveMultipliers(goldDrop, true);
                enemyLoot.AddGold(goldDrop);
            }

            //were they holding essence?
            if (enemy.hasEssence)
            {
                long baseEssence  = enemy.GetEssence();
                long extraEssence = 0;

                //if the last skill used was strike, and it was from a player character, and they have an essence reaver equipped, +1 essence
                if ((activeSkillCommand.skill.id == SkillId.STRIKE || activeSkillCommand.skill.id == SkillId.DUAL_STRIKE) && activeSkillCommand.source is PlayerCharacterData)
                {
                    PlayerCharacterData pcd       = (PlayerCharacterData)activeSkillCommand.source;
                    int numEssenceReaversEquipped = pcd.NumItemOrVariantEquipped(ItemId.ESSENCE_REAVER);

                    //if the skill was a regular strike make sure we cap this back to 1: even if the character has two equipped they only get credit for both if dual strike was used
                    if (activeSkillCommand.skill.id == SkillId.STRIKE && numEssenceReaversEquipped > 1)
                    {
                        numEssenceReaversEquipped = 1;
                    }

                    if (numEssenceReaversEquipped > 0)
                    {
                        extraEssence += (long)(baseEssence * (numEssenceReaversEquipped * .15));
                    }
                }

                //check for essence boost from cook
                if (adventure.nextEnemyEssenceBoostPercent > 0)
                {
                    float extraFraction = (adventure.nextEnemyEssenceBoostPercent / 100f);
                    extraEssence += (long)(baseEssence * extraFraction);
                    adventure.nextEnemyEssenceBoostPercent = 0;
                }

                enemyLoot.AddEssence(baseEssence + extraEssence);
            }

            int dropChance = enemy.dropRate;

            //the default drop rate for enemies is currently 1 in 9
            //100 item find = an extra 10 drop chance (max 10)
            int additionalDropChance = playerTeam.teamItemFindBonus / 10;
            if (additionalDropChance > 10)
            {
                additionalDropChance = 10;
            }
            dropChance -= additionalDropChance;
            if (dropChance < 1)
            {
                dropChance = 1;
            }

            if (dropChance != 0)
            {
                //int roll = UnityEngine.Random.Range(1, dropChance);
                if (Utils.OneIn(dropChance))
                {
                    string itemDropId = "";

                    //chance to drop an item from this area. otherwise drop the enemy's material
                    bool enemyDropsAreaItem = Utils.PercentageChance(33);
                    if (enemy.dropRate == 1 || enemy.isOre)
                    {
                        enemyDropsAreaItem = false;                                     //ore always drops its material, and a native drop rate of "1" means the enemy is always meant to drop their item (1 in 1 chance)
                    }
                    if (enemy.HasItemDrops())
                    {
                        if (enemyDropsAreaItem)
                        {
                            itemDropId = adventure.RollItemForArea();
                        }
                        else
                        {
                            itemDropId = enemy.GetRandomItemDrop();
                        }
                    }
                    else
                    {
                        if (enemyDropsAreaItem)
                        {
                            itemDropId = adventure.RollItemForArea();
                        }
                        else
                        {
                            //no materials and no chance of area item drop? they get NOTHING
                        }
                    }

                    if (itemDropId != "")
                    {
                        int dropQuantity = 1;
                        if (enemy.isOre)
                        {
                            dropQuantity += adventure.nextOreBonusDrops;
                            adventure.nextOreBonusDrops = 0;
                        }
                        enemyLoot.AddLoot(LootType.ITEM, itemDropId, dropQuantity);
                    }
                }
            }

            int keysEarned = 0;
            if (curFile.FlagIsSet(Flag.SEEN_ADVENTURE_KEY))
            {
                if (enemy.rank == EnemyRank.MBOS || enemy.rank == EnemyRank.BOSS)
                {
                    int chance = 0;
                    if (adventure.battleNum < 100)
                    {
                        chance = 15;
                    }
                    else if (adventure.battleNum < 200)
                    {
                        chance = 10;
                    }
                    else if (adventure.battleNum < 250)
                    {
                        chance = 5;
                    }

                    if (enemy.rank == EnemyRank.BOSS)
                    {
                        chance += 10;
                    }

                    chance += adventure.playerTeam.teamKeyBonus;

                    //chance currently caps at 70%
                    if (chance > 70)
                    {
                        chance = 70;
                    }

                    if (Utils.PercentageChance(chance))
                    {
                        keysEarned++;
                    }
                }
            }
            else
            {
                //is it time to give them their first key?
                if (adventure.battleNum >= 25 && enemy.rank == EnemyRank.MBOS && curFile.FlagIsSet(Flag.SEEN_ALT_PATH) && !adventure.isInteractiveCutscene)
                {
                    keysEarned = 1;
                }
            }

            //chance to earn an enigmatic fragment/remnant?
            if (enemy.tempered && Utils.OneIn(100))
            {
                enemyLoot.AddLoot(LootType.ITEM, ItemId.ENIGMATIC_SHARD, 1);
            }

            //report what loot was earned
            if (EEnemyLootEarned != null)
            {
                EEnemyLootEarned(inCharacter, enemyLoot, keysEarned);
            }

            PoolManager.Recycle(enemyLoot);
        }
    }