Beispiel #1
0
        public void HandleUnitJoinCombat(UnitEntityData unit)
        {
            //Main.logger.Log($"Unit joining combat: {unit.CharacterName}");
            var autoCastAbilities = unit.Brain.Actions.Where(action => action.Blueprint.name.StartsWith("SLE_PRECAST"));

            foreach (var autoCast in autoCastAbilities)
            {
                var spellCast   = autoCast.Blueprint as BlueprintAiCastSpell;
                var spellbook   = unit.Descriptor.Spellbooks.First();
                var abilityData = new AbilityData(spellCast.Ability, unit.Descriptor, unit.Descriptor.Spellbooks.First().Blueprint);
                //Main.logger.Log($"auto casting buff '{spellCast.Ability.name} at level {abilityData.CalculateParams().SpellLevel}' on combat join");
                //Main.logger.Log($"spellbook pre-cast: {spellbook.GetAvailableForCastSpellCount(abilityData)}");
                var proc = new AbilityExecutionContext(abilityData, abilityData.CalculateParams(), new Kingmaker.Utility.TargetWrapper(unit));
                AbilityExecutionProcess.ApplyEffectImmediate(proc, unit);
                abilityData.SpendFromSpellbook();
                //Main.logger.Log($"spellbook post-cast: {spellbook.GetAvailableForCastSpellCount(abilityData)}");
            }
        }