Beispiel #1
0
    private void InitializeCampingSkills(int bonusSkills = 0)
    {
        CurrentCampingSkills = new CampingSkill[HeroClass.CampingSkills.Count];

        var availableGeneralSkills = HeroClass.CampingSkills.FindAll(skill => skill.Classes.Count > 4);
        int generalSkillsRequired  = HeroClass.Generation.NumberOfSharedCampingSkills;

        foreach (var skill in availableGeneralSkills.OrderBy(x => RandomSolver.NextDouble())
                 .Take(Mathf.Min(generalSkillsRequired, availableGeneralSkills.Count)))
        {
            int skillIndex = HeroClass.CampingSkills.IndexOf(skill);
            CurrentCampingSkills[skillIndex] = skill;
        }
        var availableSpecificSkills = HeroClass.CampingSkills.FindAll(skill => skill.Classes.Count <= 4);
        int specificSkillsRequired  = HeroClass.Generation.NumberOfSpecificCampingSkills + bonusSkills;

        foreach (var skill in availableSpecificSkills.OrderBy(x => RandomSolver.NextDouble())
                 .Take(Mathf.Min(specificSkillsRequired, availableSpecificSkills.Count)))
        {
            int skillIndex = HeroClass.CampingSkills.IndexOf(skill);
            CurrentCampingSkills[skillIndex] = skill;
        }

        var availableGeneratedSkills = new List <CampingSkill>(CurrentCampingSkills);

        availableGeneratedSkills.RemoveAll(skill => skill == null);

        SelectedCampingSkills = availableGeneratedSkills.OrderBy(x => RandomSolver.NextDouble())
                                .Take(Mathf.Min(4, availableGeneratedSkills.Count)).ToList();
    }
    private void Start()
    {
        HeroPool  = new List <Hero>();
        HeroSeeds = new List <int>();

        foreach (var heroClass in DarkestDungeonManager.Data.HeroClasses.Values.ToList())
        {
            for (int i = 0; i < 4; i++)
            {
                string generatedName = LocalizationManager.GetString("hero_name_" + RandomSolver.Next(0, 556).ToString());
                int    heroSeed      = GetInstanceID() + System.DateTime.Now.Millisecond + (int)System.DateTime.Now.Ticks + i + HeroPool.Count;
                RandomSolver.SetRandomSeed(heroSeed);
                HeroSeeds.Add(heroSeed);
                HeroPool.Add(new Hero(heroClass.StringId, generatedName));
            }
        }

        var initialParty = new List <Hero>(HeroPool).OrderBy(x => RandomSolver.NextDouble()).Take(4).ToList();

        multiplayerPartyPanel.LoadInitialComposition(initialParty);

        launcherPanel.ProgressLabel.text = "Disconnected!";
        CampaignSelectionManager.Instanse.RoomSelector.RegionLabel.text = "Region: " + RegionToString(selectedRegion);
    }
Beispiel #3
0
    public static void ExecuteSkill(FormationUnit performerUnit, FormationUnit targetUnit, CombatSkill skill, SkillArtInfo artInfo)
    {
        SkillResult.Skill   = skill;
        SkillResult.ArtInfo = artInfo;

        var target    = targetUnit.Character;
        var performer = performerUnit.Character;

        ApplyConditions(performerUnit, targetUnit, skill);

        if (skill.Move != null && !performerUnit.CombatInfo.IsImmobilized)
        {
            if (skill.Move.Pullforward > 0)
            {
                performerUnit.Pull(skill.Move.Pullforward, false);
            }
            else if (skill.Move.Pushback > 0)
            {
                performerUnit.Push(skill.Move.Pushback, false);
            }
        }

        if (skill.Category == SkillCategory.Heal || skill.Category == SkillCategory.Support)
        {
            #region Heal

            if (skill.Heal != null)
            {
                float initialHeal = RandomSolver.Next(skill.Heal.MinAmount, skill.Heal.MaxAmount + 1) *
                                    (1 + performer.GetSingleAttribute(AttributeType.HpHealPercent).ModifiedValue);

                if (skill.IsCritValid)
                {
                    float critChance = performer[AttributeType.CritChance].ModifiedValue + skill.CritMod / 100;
                    if (RandomSolver.CheckSuccess(critChance))
                    {
                        int critHeal = target.Heal(initialHeal * 1.5f, true);
                        targetUnit.OverlaySlot.UpdateOverlay();
                        SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, critHeal, SkillResultType.CritHeal));

                        ApplyEffects(performerUnit, targetUnit, skill);
                        if (targetUnit.Character.IsMonster == false)
                        {
                            DarkestDungeonManager.Data.Effects["crit_heal_stress_heal"].ApplyIndependent(targetUnit);
                        }
                        return;
                    }
                }

                int heal = target.Heal(initialHeal, true);
                targetUnit.OverlaySlot.UpdateOverlay();

                SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, heal, SkillResultType.Heal));
                ApplyEffects(performerUnit, targetUnit, skill);
            }
            else
            {
                SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, SkillResultType.Utility));
                ApplyEffects(performerUnit, targetUnit, skill);
            }

            #endregion
        }
        else
        {
            #region Damage

            float accuracy  = skill.Accuracy + performer.Accuracy;
            float hitChance = Mathf.Clamp(accuracy - target.Dodge, 0, 0.95f);
            float roll      = (float)RandomSolver.NextDouble();
            if (target.BattleModifiers != null && target.BattleModifiers.CanBeHit == false)
            {
                roll = float.MaxValue;
            }

            if (roll > hitChance)
            {
                if (!(skill.CanMiss == false || (target.BattleModifiers != null && target.BattleModifiers.CanBeMissed == false)))
                {
                    if (roll > Mathf.Min(accuracy, 0.95f))
                    {
                        SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, SkillResultType.Miss));
                    }
                    else
                    {
                        SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, SkillResultType.Dodge));
                    }

                    ApplyEffects(performerUnit, targetUnit, skill);
                    return;
                }
            }

            float initialDamage = performer is Hero?
                                  Mathf.Lerp(performer.MinDamage, performer.MaxDamage, (float)RandomSolver.NextDouble()) * (1 + skill.DamageMod) :
                                  Mathf.Lerp(skill.DamageMin, skill.DamageMax, (float)RandomSolver.NextDouble()) * performer.DamageMod;

            int damage = Mathf.CeilToInt(initialDamage * (1 - target.Protection));
            if (damage < 0)
            {
                damage = 0;
            }

            if (target.BattleModifiers != null && target.BattleModifiers.CanBeDamagedDirectly == false)
            {
                damage = 0;
            }

            if (skill.IsCritValid)
            {
                float critChance = performer.GetSingleAttribute(AttributeType.CritChance).ModifiedValue + skill.CritMod;
                if (RandomSolver.CheckSuccess(critChance))
                {
                    int critDamage = target.TakeDamage(damage * 1.5f);
                    targetUnit.OverlaySlot.UpdateOverlay();

                    if (target.HasZeroHealth)
                    {
                        SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, critDamage, true, SkillResultType.Crit));
                    }
                    else
                    {
                        SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, critDamage, SkillResultType.Crit));
                    }

                    ApplyEffects(performerUnit, targetUnit, skill);
                    if (targetUnit.Character.IsMonster == false)
                    {
                        DarkestDungeonManager.Data.Effects["Stress 2"].ApplyIndependent(targetUnit);
                    }
                    return;
                }
            }
            damage = target.TakeDamage(damage);
            targetUnit.OverlaySlot.UpdateOverlay();
            if (target.HasZeroHealth)
            {
                SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, damage, true, SkillResultType.Hit));
            }
            else
            {
                SkillResult.AddResultEntry(new SkillResultEntry(targetUnit, damage, SkillResultType.Hit));
            }

            ApplyEffects(performerUnit, targetUnit, skill);

            #endregion
        }
    }
Beispiel #4
0
    public int NextRound(BattleGround battleground)
    {
        RoundStatus = RoundStatus.Start;
        OrderedUnits.Clear();

        if (RoundNumber == 0 || RoundNumber == 1)
        {
            battleground.HeroFormation.UpdateBuffRule(BuffRule.FirstRound);
            battleground.MonsterFormation.UpdateBuffRule(BuffRule.FirstRound);
        }

        foreach (var unit in battleground.HeroParty.Units)
        {
            unit.CombatInfo.UpdateNextRound();
            OrderedUnits.Add(unit);

            if (SceneManagerHelper.ActiveSceneName == "DungeonMultiplayer")
            {
                if (unit.Character.Class == "antiquarian")
                {
                    OrderedUnits.Add(unit);
                }
            }
        }

        foreach (var unit in battleground.MonsterParty.Units)
        {
            unit.CombatInfo.UpdateNextRound();
            if (unit.Character.IsMonster)
            {
                for (int i = 0; i < unit.Character.Initiative.NumberOfTurns; i++)
                {
                    OrderedUnits.Add(unit);
                }
            }
            else
            {
                OrderedUnits.Add(unit);
            }

            if (SceneManagerHelper.ActiveSceneName == "DungeonMultiplayer")
            {
                if (unit.Character.Class == "antiquarian")
                {
                    OrderedUnits.Add(unit);
                }
            }
        }

        if (RoundNumber == 0)
        {
            if (RaidSceneManager.BattleGround.SurpriseStatus == SurpriseStatus.HeroesSurprised)
            {
                OrderedUnits = new List <FormationUnit>(OrderedUnits.OrderByDescending(unit => unit.Character.IsMonster ?
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble() :
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble() - 100));
            }
            else if (RaidSceneManager.BattleGround.SurpriseStatus == SurpriseStatus.MonstersSurprised)
            {
                OrderedUnits = new List <FormationUnit>(OrderedUnits.OrderByDescending(unit => unit.Character.IsMonster ?
                                                                                       unit.Character.BattleModifiers != null && unit.Character.BattleModifiers.CanBeSurprised ?
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble() - 100 :
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble() :
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble()));
            }
            else
            {
                OrderedUnits = new List <FormationUnit>(OrderedUnits.OrderByDescending(unit =>
                                                                                       unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble()));
            }
        }
        else
        {
            OrderedUnits = new List <FormationUnit>(OrderedUnits.OrderByDescending(unit =>
                                                                                   unit.Character.Speed + RandomSolver.Next(0, 3) + RandomSolver.NextDouble()));
        }

        return(++RoundNumber);
    }