Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace gbf.Scripts.Chi {
- public class WaterVaruna : QuestScript {
- static readonly string[] Touchmark = new [] {
- "3000_1011",
- "3000_1012",
- "3000_1013",
- "3000_1014",
- "3000_1015",
- "3000_1016",
- "3000_1017",
- "3000_1018",
- "3000_1019"
- };
- [Setting(Default: true, Label: "Use Debuffs")]
- public ScriptSetting<bool> UseDebuffs;
- [Setting(Default: 55, Label: "Pot character(s) below $ % hp")]
- public ScriptSetting<float> CharacterPotThreshold;
- [Setting(Default: 60, Label: "Pot if party below $ % hp")]
- public ScriptSetting<float> PartyPotThreshold;
- [Setting(Default: 3100000)]
- public ScriptSetting<float> ApproximateTurnDamage;
- [Setting(Default: 6500000)]
- public ScriptSetting<float> ApproximateFullchainDamage;
- [Setting(Default: true)]
- public ScriptSetting<bool> AutoCallForBackup;
- [Setting(Default: true)]
- public ScriptSetting<bool> CutTriggers;
- [Setting(Default: false, Label: "Request backup from Twitter")]
- public ScriptSetting<bool> TweetBackup;
- [Setting(Label: "Target enemy #: $", Default: 0)]
- public ScriptSetting<int> TargetEnemyNumber;
- [Setting(Default: true)]
- public ScriptSetting<bool> Clarity; //will spam clarity off CD
- [Setting(Default: false)]
- public ScriptSetting<bool> EnableBonito;
- [Setting(Default: false)]
- public ScriptSetting<bool> EnableVaruna;
- [Setting(Default: true)]
- public ScriptSetting<bool> GWPots;
- [Setting(Default: false)]
- public ScriptSetting<bool> FourthPursuit;
- bool HaveStickered, HaveCalledForBackup;
- float LastTurnStartBossHpPercent;
- protected int RequestingBackup;
- public const string BossCutUp = "1019_0_90";
- public const string WhyDoesThisThingHaveTwoBuffs = "1484";
- protected bool TappedTrigger;
- public WaterVaruna () {
- }
- public override string[] GetSummonSelectors () {
- var result = new List<string>();
- if (EnableVaruna) {
- // Varuna MLB
- result.Add("div.btn-supporter[data-supporter-max=\"1\"] div.prt-summon-image[data-image=\"2040100000\"]");
- // Varuna
- result.Add("div.btn-supporter div.prt-summon-image[data-image=\"2040100000\"]");
- }
- // Europa MLB
- result.Add("div.btn-supporter[data-supporter-max=\"1\"] div.prt-summon-image[data-image=\"2040225000\"]");
- // Europa
- result.Add("div.btn-supporter div.prt-summon-image[data-image=\"2040225000\"]");
- if (EnableBonito) {
- // Bonito MLB
- result.Add(
- "div.btn-supporter[data-supporter-max=\"1\"] div.prt-summon-image[data-image=\"2040167000\"]"
- );
- // Bonito
- result.Add(
- "div.btn-supporter div.prt-summon-image[data-image=\"2040167000\"]"
- );
- }
- // Macula MLB
- result.Add(
- "div.btn-supporter[data-supporter-max=\"1\"] div.prt-summon-image[data-image=\"2040002000\"]"
- );
- // Macula
- result.Add(
- "div.btn-supporter div.prt-summon-image[data-image=\"2040002000\"]"
- );
- return result.ToArray();
- }
- private List<int> WhoNeedsHealing () {
- var result = new List<int>();
- for (var i = 0; i < CombatState.party.Length; i++) {
- if (CombatState.party[i].hp / (float)CombatState.party[i].hpMax * 100 <= CharacterPotThreshold)
- result.Add(i);
- }
- return result;
- }
- private List<int> WhoNeedsClearing () {
- var result = new List<int>();
- for (var i = 0; i < CombatState.party.Length; i++) {
- if (CombatState.party[i].IsDebuffed(Touchmark))
- result.Add(i);
- }
- return result;
- }
- private async Task GetPotions () {
- if (!HaveStickered) {
- HaveStickered = true;
- await this.AutoSticker();
- }
- }
- private bool ShouldPartyHeal {
- get {
- var wnh = WhoNeedsHealing();
- return (wnh.Count > 1) || (AverageHp <= PartyPotThreshold);
- }
- }
- private async Task AutoHeal () {
- var wnc = WhoNeedsClearing();
- if (wnc.Count >= 1) {
- if (!await TryUseAbility("Clarity"))
- if (!await TryUseAbility("White Heal"))
- await TryUseSummon("Baal");
- }
- if (AverageHp < 91)
- if (await TryUseAbility("And the Seasons Go On"))
- await WaitForIdle();
- if (AverageHp < 91)
- if (await TryUseAbility("Panacea III"))
- await WaitForIdle();
- if (AverageHp < 91)
- if (await TryUseSummon("Lucifer"))
- await WaitForIdle();
- if (AverageHp < 95)
- if (await TryUseAbility("White Heal"))
- await WaitForIdle();
- if (ShouldPartyHeal) {
- await GetPotions();
- if (!await this.TryUseBluePotion(true))
- if (GWPots) {
- await this.TryUseGwBluePotion(true);
- await WaitForIdle();
- }
- }
- var wnh = WhoNeedsHealing();
- if (wnh.Count == 1) {
- if (!await TryUseAbility("Panacea III"))
- await this.TryUseGreenPotion(wnh[0], true);
- wnh = WhoNeedsHealing();
- }
- await this.CloseHealWindow();
- }
- private bool YodaHasShroud {
- get {
- return Party.Any(pm => pm.conditions.Any(c => Statuses.TripleShrouded.Contains(c)));
- }
- }
- private float AverageHp {
- get {
- return Party.Average(pm => pm.hp / (float)pm.hpMax * 100f);
- }
- }
- private async Task AutoSummon (bool isChainReady) {
- if (isChainReady)
- if (await TryUseSummons("Kaguya", "Bahamut"))
- return;
- var boss = CombatState.enemies[0];
- if (
- (boss.mode == EnemyModes.Break) &&
- !(
- boss.conditions.Contains(Statuses.BreakKeepTime) &&
- boss.conditions.Contains(Statuses.BreakKeepDamage)
- )
- )
- if (await TryUseSummon("Macula Marius"))
- return;
- if (!CombatState.party.Any(pm => pm.IsBuffed(Statuses.FireCarby, Statuses.LilyFireCut)))
- if (await TryUseSummon("Garnet Carbuncle"))
- return;
- if (!CombatState.party.Any(pm => pm.conditions.Contains(Statuses.WaterCarby)))
- if (await TryUseSummon("Aquamarine Carbuncle"))
- return;
- if (CombatState.party.All(pm => pm.ougi < 100))
- if (await TryUseSummon("Bonito"))
- return;
- if (Party.Sum(pm => pm.ougi) >= 340)
- await TryUseSummon("Bahamut");
- await TryUseSummon("Leviathan Omega");
- // await TryUseSummon("Varuna");
- }
- EnemyState Boss {
- get {
- return Enemies.First();
- }
- }
- private float PartyDamageCutPercentage {
- get {
- return (from pm in Party select GetDamageCutPercentage(pm)).Min();
- }
- }
- private float GetDamageCutPercentage (PartyMemberState pm) {
- var result = 0;
- if (pm.IsBuffed(Statuses.UnoFullCut))
- result = 100;
- else if (pm.IsBuffed(Statuses.UnoFullCut))
- result = 77;
- else if (pm.IsBuffed(Statuses.Athena))
- result = 30;
- if (pm.IsBuffed(Statuses.LilyFireCut))
- result += 70;
- if (pm.IsBuffed(Statuses.FireCarby))
- result += 50;
- else if (pm.IsBuffed(Statuses.WeakFireCarby))
- result += 25;
- return result;
- }
- public override async Task<bool> Step () {
- await WaitForIdle();
- var target = (await ScriptUtil.PickTarget(this)).GetValueOrDefault(0);
- if (TargetEnemyNumber > 0)
- {
- await TrySetTarget(TargetEnemyNumber);
- }
- if (!CombatState.canAct)
- return true;
- if (CombatState.turn == 1) {
- TappedTrigger = false;
- }
- if (CombatState.enemies[0].conditions.Contains("1019_0_90") ||
- CombatState.enemies[0].conditions.Contains("1484")) {
- if (!TappedTrigger) {
- await WaitForIdle();
- await SetOugiStatus(false);
- await WaitForIdle();
- await TryClickAttack();
- await Pause(30000);
- await WaitForIdle();
- TappedTrigger = true;
- return true;
- }
- if (await TryUseAbility("Dispel") ||
- await TryUseAbility("Dispel Deluge")) {
- await WaitForIdle();
- return true;
- }
- await Log("Damage cut buff detected, waiting for dispel...");
- await Engine.SetStatusMessage("Damage cut buff detected, waiting for dispel...");
- return true;
- }
- var turnStartBossHpPercent = Boss.hp / (float)Boss.hpMax * 100;
- if (CombatState.turn == 1)
- {
- HaveStickered = HaveCalledForBackup = false;
- LastTurnStartBossHpPercent = turnStartBossHpPercent;
- // HACK
- if (AutoCallForBackup)
- {
- HaveCalledForBackup = true;
- await this.RequestBackupAndWait(1, 1, true, true, true);
- }
- if (TweetBackup)
- {
- await this.TweetBackup();
- }
- await TryUseSummon("Leviathan Omega");
- }
- var readyToChain = Party.Count(pm => pm.ougi >= 100);
- var almostReady = Party.Count(pm => pm.ougi <= 80);
- if (
- Party.All(pm => pm.ougi <= 70) ||
- (almostReady <= 2) && (almostReady > 0)
- )
- if (await TryUseAbility("Wings Shall Deliver You"))
- await WaitForIdle();
- if (
- Party.All(pm => pm.ougi <= 70) ||
- (almostReady <= 2) && (almostReady > 0)
- )
- if (await TryUseAbility("Battleplan: Crescent Moon"))
- await WaitForIdle();
- var isChainReady = this.IsChainReady(fourthPursuit: FourthPursuit);
- var veilCount = Party.Count(pm => pm.conditions.Contains(Statuses.Veil));
- if (veilCount < 4) {
- if (!await TryUseSummon("Apollo")) {
- await TryUseAbilities(null, UseAbilitiesMode.StopAfterFirstSuccess, "Loengard +", "Veil");
- }
- }
- await AutoHeal();
- await AutoSummon(isChainReady);
- if (UseDebuffs)
- {
- await TryUseAbilities(
- "Defense Breach",
- "Rain of Arrows III",
- "Fair Trick +",
- "Miserable Mist",
- "Unpredictable",
- "Dark Haze",
- "Battleplan: Crane Down ++",
- "Pastoral Dance: Bizen",
- "Fool You Thrice",
- "Blind",
- "Niflheim"
- );
- }
- await TryUseAbilities(
- "Battleplan: Surround",
- "I Miss You So Much...",
- "Gammadion Cross",
- "Aether Blast III",
- "Frozen Gale"
- );
- await TryUseAbility("Fighting Spirit", pm => pm.ougi <= 80);
- if (Clarity)
- {
- await TryUseAbilities(
- "Peace of Mind",
- "Clarity"
- );
- }
- if (!YodaHasShroud) {
- await TryUseAbility("Awakening +");
- await TryUseAbility("Perpetual Rotation");
- }
- if (!this.IsChainReady(fourthPursuit: FourthPursuit)) {
- await TryUseAbility("Chaser");
- }
- if (
- !Boss.conditions.Contains(Statuses.Gravity) ||
- // Dispel ATK up
- Boss.conditions.Any(c => c.StartsWith("1001_4"))
- )
- await TryUseAbility("Carnage");
- await TryUseAbilities(
- (pm) => Boss.recast != Boss.recastMax, UseAbilitiesMode.WaitAfterUseIfPredicate,
- "Quadspell", "Stall II", "Stall III", "Closing Dance: Tokiyomi"
- );
- await TryUseAbility("Four-Sky's Sorrow");
- await TryUseAbility("Gammadion Cross");
- await TryUseAbility("Gammadion Cross");
- await TryUseAbility("Gammadion Cross");
- await TryUseAbility("Gammadion Cross");
- if (
- (AverageHp <= 50) ||
- (
- (Boss.hp <= (Boss.hpMax * 0.45f)) &&
- (AverageHp <= 80)
- )
- )
- await TryUseAbility("One-Rift's Benediction");
- await TryUseAbility("Opening Dance: Kagura", pm => pm.conditions.Contains(Statuses.AdventOfSerenity));
- await TryUseAbility("Immutable Faith", pm => pm.ougi <= 50);
- await TryUseAbility("Frozen Gale +");
- await TryUseAbility("Enchanted Lands +", pm => pm.ougi < 80);
- if (!CombatState.party.Any(pm => pm.IsBuffed(Statuses.FireCarby, Statuses.LilyFireCut))) {
- if (await TryUseAbility("Silverfrost Barrier"))
- await TryUseAbility("Avirati");
- }
- await WaitForIdle();
- isChainReady = this.IsChainReady(fourthPursuit: FourthPursuit);
- var isParalyzed = Boss.conditions.Contains(Statuses.PurplePara) ||
- Boss.conditions.Contains(Statuses.Paralyzed);
- var isOugiComing = (
- (Boss.recast <= 1) &&
- (Boss.mode != EnemyModes.Break)
- );
- var usedSpark = false;
- if (!isChainReady && !isOugiComing)
- usedSpark = await TryUseAbility("Fleeting Spark");
- await TryUseAbility("Spiral Spear", pm =>
- (usedSpark && (CombatState.turn <= 4)) ||
- (Boss.mode == EnemyModes.OD) ||
- (usedSpark && (Boss.mode == EnemyModes.Break))
- );
- /*
- var silvaMeter =
- (from pm in Party
- where pm.name == "Silva"
- select pm.ougi).FirstOrDefault();
- var isSilvaReady = (silvaMeter >= 100) && (Party.Count(pm => pm.ougi >= 90) < 3);
- if (await TryUseAbility("Dead Specimen", pm => pm.ougi < 30))
- isSilvaReady = true;
- if (!isChainReady && isSilvaReady)
- await Log("Silva solo ougi");
- else if (!isChainReady && shouldOugiHeal)
- await Log("Using ougi to heal");
- var willOugi = isChainReady || shouldOugiHeal || isSilvaReady;
- if (willOugi && silvaMeter > 77)
- await TryUseAbility("Eagle Eye +");
- */
- await WaitForIdle();
- var willOugi = isChainReady;
- var predictedHealth = Boss.hp - (willOugi ? ApproximateFullchainDamage : ApproximateTurnDamage);
- var predictedHealthPercentage = predictedHealth / (float)Boss.hpMax * 100;
- var isTriggerComing = (
- (LastTurnStartBossHpPercent >= 75) &&
- ((predictedHealthPercentage < 75) && (predictedHealthPercentage >= 60))
- ) ||
- (
- (LastTurnStartBossHpPercent >= 50) &&
- (predictedHealthPercentage < 50)
- ) ||
- (
- (LastTurnStartBossHpPercent >= 25) &&
- ((predictedHealthPercentage < 25) && (predictedHealthPercentage >= 10))
- );
- await Log("hp={0} predicted={1} isTriggerComing={2}", LastTurnStartBossHpPercent, predictedHealthPercentage, isTriggerComing);
- if (
- !isParalyzed &&
- (isOugiComing || isTriggerComing && CutTriggers)
- ) {
- await Log("Cutting for {0}", isTriggerComing ? "trigger" : "ougi");
- if (
- (
- (PartyDamageCutPercentage < 100) &&
- (isTriggerComing || (Boss.hp <= Boss.hpMax * 0.20f))
- ) || (PartyDamageCutPercentage < 60)
- ) {
- await TryUseAbilities(
- null, UseAbilitiesMode.StopAfterFirstSuccess,
- "Phalanx III", "Arm the Bastion", "Light Wall Divider"
- );
- await WaitForIdle();
- await TryUseSummon("Athena");
- }
- }
- await SetOugiStatus(willOugi);
- await WaitForIdle();
- LastTurnStartBossHpPercent = Boss.hp / (float)Boss.hpMax * 100;
- await TryClickAttack();
- if (isChainReady)
- await OugiRefresh();
- else
- await AttackRefresh();
- return true;
- }
- protected override void OnInitialize () {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement