protected override void AttemptFillRandomly() { chrActing = ContTurns.Get().GetNextActingChr(); int nMaxSelectionAttempts = 5; int nCurSelectionAttempt = 0; //We'll attempt a few selections to see if we can find something legal while (nCurSelectionAttempt < nMaxSelectionAttempts) { nCurSelectionAttempt++; //Select a random skill we have that's off cooldown skillslotSelected = chrActing.arSkillSlots[Random.Range(0, Chr.nEquippedCharacterSkills)]; lstSelections = new List <object>(); //If the skill can't be activated for whatever reason (like being a passive), then skip to the next attempt if (skillslotSelected.chrOwner.curStateReadiness.CanSelectSkill(skillslotSelected.skill) == false) { continue; } //If the skill is on cooldown, then we'll skip to the next attempt if (skillslotSelected.IsOffCooldown() == false) { continue; } //For each target we have to fill out, get a random selectable for its targetting type bool bFailedSelection = false; for (int i = 0; i < skillslotSelected.skill.lstTargets.Count; i++) { //Debug.LogFormat("Skill {0} is asking for selections for its {1}th target, {2}", skillSelected, i, skillSelected.lstTargets[i]); if (skillSelected.lstTargets[i].HasAValidSelectable(this) == false) { bFailedSelection = true; break; } //If there's at least something selectable, then pick one of them randomly lstSelections.Add(skillSelected.lstTargets[i].GetRandomValidSelectable(this)); } if (bFailedSelection) { //If we failed finding a selection for some skill, then continue on in the loop to find a different skill selection //Before we move on to the next selection attempt, clear out any reserved mana amounts chrActing.plyrOwner.manapool.ResetReservedMana(); continue; } //If we reached this far without failing a selection, then we should have a fully filled out random selection so we can return Debug.AssertFormat(CanLegallyExecute(), "{0} is an invalid random selection", ToString()); return; } //If we tried many times and couldn't get a valid selection, then we'll just reset the default input ResetToDefaultInput(); }