コード例 #1
0
 internal void AddListener(EngineAction call)
 {
     if (!actions.Contains(call))
     {
         actions.Add(call);
     }
 }
コード例 #2
0
 internal void RemoveListener(EngineAction call)
 {
     if (actions.Contains(call))
     {
         actions.Remove(call);
     }
 }
コード例 #3
0
        public static void ExecuteAction(this EliteAPI api, EngineAction action)
        {
            if (!string.IsNullOrEmpty(action.JobAbility))
            {
                api.UseJobAbility(action.JobAbility);
            }

            if (!string.IsNullOrEmpty(action.Spell))
            {
                api.CastSpell(action.Spell, action.Target);
            }
        }
コード例 #4
0
        internal Engine CreateEngine()
        {
            var engine = new Engine()
                         .SetValue(JsConsts.InnerApiObjectName, JsCallWorker)
                         .SetValue("console", new
            {
                log = new Action <object[]>(Log)
            });

            EngineAction?.Invoke(engine);

            engine.Execute(ScriptResources.ScriptInit);

            return(engine);
        }
コード例 #5
0
        private EngineAction CureCalculator(PartyMember partyMember)
        {
            var actionResult = new EngineAction
            {
                Target = partyMember.Name
            };

            // Only do this is party member is alive.
            if (partyMember.CurrentHP > 0)
            {
                var cureSpell = PickCure(partyMember.HPLoss());

                if (cureSpell != Spells.Unknown)
                {
                    actionResult.Spell = cureSpell;

                    return(actionResult);
                }
            }

            return(null);
        }
コード例 #6
0
        private EngineAction CuragaCalculator(PartyMember member)
        {
            uint   hpLoss    = member.HPLoss();
            string cureSpell = Spells.Unknown;

            var actionResult = new EngineAction
            {
                Target = member.Name
            };

            for (int i = 4; i <= 0; i--)
            {
                if (_config.EnabledCuragaTiers[i] && hpLoss >= _config.CuragaTierThresholds[i] && PL.HasMPFor(Data.CuragaTiers[i]))
                {
                    cureSpell = Data.CuragaTiers[i];
                    break;
                }
            }

            if (cureSpell != Spells.Unknown)
            {
                // Check if we need to over/under cure.
                var curagaTier = PickCureTier(cureSpell, Data.CuragaTiers);

                actionResult.Spell = curagaTier;

                if (_config.CuragaSpecifiedEnabled)
                {
                    actionResult.Target = _config.CuragaSpecifiedName;
                }

                return(actionResult);
            }

            return(null);
        }
コード例 #7
0
 public void Log(object key, EngineAction action, Bet b, LogMode mode)
 {
     if (EngineLogger.CheckMode(mode))
     {
         string message = string.Format("{0}:{1}-->{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_{10}_{11}_{12}_{13}", new object[]
         {
             key,
             action,
             b.Id,
             b.Home,
             b.Away,
             (int)b.Type,
             b.Choice.ToString().ToLower(),
             b.Handicap,
             b.OddsValue,
             b.MinBetAllowed,
             b.MaxBetAllowed,
             b.Stake,
             b.Step,
             b.Status
         });
         this.Log(message, mode);
     }
 }
コード例 #8
0
        public EngineAction Run(PLConfig Config)
        {
            // FIRST IF YOU ARE SILENCED OR DOOMED ATTEMPT REMOVAL NOW
            if (PL.HasStatus(StatusEffect.Silence) && Config.PLSilenceItemEnabled)
            {
                var plSilenceItem = Items.SilenceRemoval[Config.PLSilenceItem];

                // Check to make sure we have echo drops
                if (PL.GetInventoryItemCount(PL.GetItemId(plSilenceItem)) > 0 || PL.GetTempItemCount(PL.GetItemId(plSilenceItem)) > 0)
                {
                    return(new EngineAction
                    {
                        Item = plSilenceItem
                    });
                }
            }
            else if (PL.HasStatus(StatusEffect.Doom) && Config.PLDoomItemEnabled)
            {
                var plDoomItem = Items.DoomRemoval[Config.PLDoomItem];

                // Check to make sure we have holy water
                if (PL.GetInventoryItemCount(PL.GetItemId(plDoomItem)) > 0 || PL.GetTempItemCount(PL.GetItemId(plDoomItem)) > 0)
                {
                    return(new EngineAction
                    {
                        Item = plDoomItem
                    });
                }
            }

            else if (Config.DivineSeal && PL.Player.MPP <= 11 && PL.AbilityAvailable(Ability.DivineSeal) && !PL.Player.Buffs.Contains((short)StatusEffect.Weakness))
            {
                return(new EngineAction
                {
                    Target = Target.Me,
                    JobAbility = Ability.DivineSeal
                });
            }
            else if (Config.Convert && (PL.Player.MP <= Config.ConvertMP) && PL.AbilityAvailable(Ability.Convert) && !PL.Player.Buffs.Contains((short)StatusEffect.Weakness))
            {
                return(new EngineAction
                {
                    Target = Target.Me,
                    JobAbility = Ability.Convert
                });
            }

            if (PL.Player.MP <= Config.MinCastingMP && PL.Player.MP != 0)
            {
                if (Config.LowMPEnabled && !LowMP && !Config.HealLowMPEnabled)
                {
                    PL.ThirdParty.SendString("/tell " + Monitored.Player.Name + " MP is low!");
                }

                LowMP = true;
            }
            if (PL.Player.MP > Config.MinCastingMP && PL.Player.MP != 0)
            {
                if (Config.LowMPEnabled && LowMP && !Config.HealLowMPEnabled)
                {
                    PL.ThirdParty.SendString("/tell " + Monitored.Player.Name + " MP OK!");
                }

                LowMP = false;
            }

            if (Config.HealLowMPEnabled && PL.Player.MP <= Config.HealMPThreshold && PL.Player.Status == 0)
            {
                if (Config.LowMPEnabled && !LowMP)
                {
                    PL.ThirdParty.SendString("/tell " + Monitored.Player.Name + " MP is seriously low, /healing.");
                }

                LowMP = true;

                return(new EngineAction
                {
                    CustomAction = "/heal"
                });
            }
            else if (Config.StandMPEnabled && PL.Player.MPP >= Config.StandMPThreshold && PL.Player.Status == 33)
            {
                if (Config.LowMPEnabled && !LowMP)
                {
                    PL.ThirdParty.SendString("/tell " + Monitored.Player.Name + " MP has recovered.");
                }

                LowMP = false;

                return(new EngineAction
                {
                    CustomAction = "/heal"
                });
            }

            if (Config.AfflatusSolaceEnabled && (!PL.HasStatus(StatusEffect.Afflatus_Solace)) && PL.AbilityAvailable(Ability.AfflatusSolace))
            {
                return(new EngineAction {
                    JobAbility = Ability.AfflatusSolace
                });
            }

            if (Config.AfflatusMiseryEnabled && (!PL.HasStatus(StatusEffect.Afflatus_Misery)) && PL.AbilityAvailable(Ability.AfflatusMisery))
            {
                return(new EngineAction {
                    JobAbility = Ability.AfflatusMisery
                });
            }

            if (Config.Composure && (!PL.HasStatus(StatusEffect.Composure)) && PL.AbilityAvailable(Ability.Composure))
            {
                return(new EngineAction
                {
                    JobAbility = Ability.Composure
                });
            }

            if (Config.LightArts && (!PL.HasStatus(StatusEffect.Light_Arts)) && (!PL.HasStatus(StatusEffect.Addendum_White)) && PL.AbilityAvailable(Ability.LightArts))
            {
                return(new EngineAction
                {
                    JobAbility = Ability.LightArts
                });
            }

            if (Config.AddendumWhite && (!PL.HasStatus(StatusEffect.Addendum_White)) && PL.HasStatus(StatusEffect.Light_Arts) && PL.CurrentSCHCharges() > 0)
            {
                return(new EngineAction
                {
                    JobAbility = Ability.AddendumWhite
                });
            }

            if (Config.DarkArts && (!PL.HasStatus(StatusEffect.Dark_Arts)) && (!PL.HasStatus(StatusEffect.Addendum_Black)) && PL.AbilityAvailable(Ability.DarkArts))
            {
                return(new EngineAction
                {
                    JobAbility = Ability.DarkArts
                });
            }

            if (Config.AddendumBlack && PL.HasStatus(StatusEffect.Dark_Arts) && (!PL.HasStatus(StatusEffect.Addendum_Black)) && PL.CurrentSCHCharges() > 0)
            {
                return(new EngineAction
                {
                    JobAbility = Ability.AddendumBlack
                });
            }
            if (Config.SublimationEnabled && (!PL.HasStatus(StatusEffect.Sublimation_Activated)) && (!PL.HasStatus(StatusEffect.Sublimation_Complete)) && (!PL.HasStatus(StatusEffect.Refresh)) && PL.AbilityAvailable(Ability.Sublimation))
            {
                return(new EngineAction {
                    JobAbility = Ability.Sublimation
                });
            }

            if (Config.SublimationEnabled && ((PL.Player.MPMax - PL.Player.MP) > Config.SublimationMPLossThreshold) && PL.HasStatus(StatusEffect.Sublimation_Complete) && PL.AbilityAvailable(Ability.Sublimation))
            {
                return(new EngineAction {
                    JobAbility = Ability.Sublimation
                });
            }

            if (Config.DivineCaressEnabled && Config.DebuffsEnabled && PL.AbilityAvailable(Ability.DivineCaress))
            {
                return(new EngineAction {
                    JobAbility = Ability.DivineCaress
                });
            }

            if (Config.DevotionEnabled && PL.AbilityAvailable(Ability.Devotion) && PL.Player.HPP > 80 && (!Config.DevotionWhenEngaged || (Monitored.Player.Status == 1)))
            {
                int plParty = PL.GetPartyRelativeTo(Monitored);

                // Get all active members who are in the PLs party.
                IEnumerable <PartyMember> cParty = Monitored.GetActivePartyMembers().Where(member => member.InParty(plParty) && member.Name != PL.Player.Name);

                // If we're set to only devotion a specific target, filter the list for that target.
                if (Config.DevotionSpecifiedTarget)
                {
                    cParty = cParty.Where(member => member.Name == Config.DevotionTargetName);
                }

                // Get the first member who's within range, and has enough missing MP to meet our config criteria.
                var devotionTarget = cParty.FirstOrDefault(member => member.CurrentMP <= Config.DevotionMPThreshold && PL.EntityWithin(10, member.TargetIndex));

                if (devotionTarget != default)
                {
                    return(new EngineAction
                    {
                        Target = devotionTarget.Name,
                        JobAbility = Ability.Devotion
                    });
                }
            }

            if (Config.ShellraEnabled && (!PL.HasStatus(StatusEffect.Shell)))
            {
                var shellraSpell = Data.ShellraTiers[Config.ShellraLevel - 1];
                if (PL.SpellAvailable(shellraSpell))
                {
                    return(new EngineAction
                    {
                        Spell = shellraSpell
                    });
                }
            }

            if (Config.ProtectraEnabled && (!PL.HasStatus(StatusEffect.Protect)))
            {
                var protectraSpell = Data.ProtectraTiers[Config.ProtectraLevel - 1];
                if (PL.SpellAvailable(protectraSpell))
                {
                    return(new EngineAction {
                        Spell = protectraSpell
                    });
                }
            }

            if (Config.BarElementEnabled && !PL.HasStatus(Data.SpellEffects[Config.BarElementSpell]) && PL.SpellAvailable(Config.BarElementSpell))
            {
                // TODO: Make this work properly, so it can figure out if there's 2 charges and return
                // an action that says: Do Accession + Perpetuance + Barspell.
                var result = new EngineAction
                {
                    Spell = Config.BarElementSpell
                };

                if (Config.AccessionEnabled && Config.BarElementAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !Config.AOEBarElementEnabled && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.BarElemenetPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.BarStatusEnabled && !PL.HasStatus(Data.SpellEffects[Config.BarStatusSpell]) && PL.SpellAvailable(Config.BarStatusSpell))
            {
                var result = new EngineAction
                {
                    Spell = Config.BarStatusSpell
                };

                if (Config.AccessionEnabled && Config.BarStatusAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !Config.AOEBarStatusEnabled && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.BarStatusPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.GainBoostSpellEnabled && !PL.HasStatus(Data.SpellEffects[Config.GainBoostSpell]) && PL.SpellAvailable(Config.GainBoostSpell))
            {
                return(new EngineAction {
                    Spell = Config.GainBoostSpell
                });
            }

            if (Config.StormSpellEnabled && !PL.HasStatus(Data.SpellEffects[Config.StormSpell]) && PL.SpellAvailable(Config.StormSpell))
            {
                var result = new EngineAction {
                    Spell = Config.StormSpell
                };
                if (Config.AccessionEnabled && Config.StormspellAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.StormspellPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.ProtectEnabled && (!PL.HasStatus(StatusEffect.Protect)))
            {
                var result = new EngineAction {
                    Spell = Config.ProtectSpell
                };

                if (Config.AccessionEnabled && Config.AccessionProtectShell && PL.Party.GetPartyMembers().Count() > 2 && PL.AbilityAvailable(Ability.Accession) && PL.CurrentSCHCharges() > 0)
                {
                    if (!PL.HasStatus(StatusEffect.Accession))
                    {
                        result.JobAbility = Ability.Accession;
                    }
                }

                return(result);
            }

            if (Config.ShellEnabled && (!PL.HasStatus(StatusEffect.Shell)))
            {
                var result = new EngineAction {
                    Spell = Config.ShellSpell
                };

                if (Config.AccessionEnabled && Config.AccessionProtectShell && PL.Party.GetPartyMembers().Count() > 2 && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession))
                {
                    if (!PL.HasStatus(StatusEffect.Accession))
                    {
                        result.JobAbility = Ability.Accession;
                    }
                }

                return(result);
            }

            if (Config.ReraiseEnabled && (!PL.HasStatus(StatusEffect.Reraise)))
            {
                var result = new EngineAction {
                    Spell = Config.ReraiseSpell
                };

                if (Config.EnlightenmentReraise && !PL.HasStatus(StatusEffect.Addendum_White) && PL.AbilityAvailable(Ability.Enlightenment))
                {
                    result.JobAbility = Ability.Enlightenment;
                }

                return(result);
            }

            if (Config.UtsusemiEnabled && PL.ShadowsRemaining() < 2)
            {
                if (PL.GetInventoryItemCount(PL.GetItemId(Items.Shihei)) > 0)
                {
                    if (PL.SpellAvailable(Spells.Utsusemi_Ni))
                    {
                        return(new EngineAction {
                            Spell = Spells.Utsusemi_Ni
                        });
                    }
                    else if (PL.SpellAvailable(Spells.Utsusemi_Ichi) && (PL.ShadowsRemaining() == 0))
                    {
                        return(new EngineAction {
                            Spell = Spells.Utsusemi_Ichi
                        });
                    }
                }
            }

            if (Config.BlinkEnabled && (!PL.HasStatus(StatusEffect.Blink)) && PL.SpellAvailable(Spells.Blink))
            {
                var result = new EngineAction {
                    Spell = Spells.Blink
                };

                if (Config.AccessionEnabled && Config.BlinkAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.BlinkPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.PhalanxEnabled && (!PL.HasStatus(StatusEffect.Phalanx)) && PL.SpellAvailable(Spells.Phalanx))
            {
                var result = new EngineAction {
                    Spell = Spells.Phalanx
                };

                if (Config.AccessionEnabled && Config.PhalanxAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.PhalanxPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.RefreshEnabled && (!PL.HasStatus(StatusEffect.Refresh)))
            {
                var result = new EngineAction {
                    Spell = Config.RefreshSpell
                };

                if (Config.AccessionEnabled && Config.RefreshAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.RefreshPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.RegenEnabled && (!PL.HasStatus(StatusEffect.Regen)))
            {
                var result = new EngineAction {
                    Spell = Config.RegenSpell
                };

                if (Config.AccessionEnabled && Config.RegenAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.RegenPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.AdloquiumEnabled && (!PL.HasStatus(StatusEffect.Regain)) && PL.SpellAvailable(Spells.Adloquium))
            {
                var result = new EngineAction {
                    Spell = Spells.Adloquium
                };

                if (Config.AccessionEnabled && Config.AdloquiumAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.AdloquiumPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.StoneskinEnabled && (!PL.HasStatus(StatusEffect.Stoneskin)) && PL.SpellAvailable(Spells.Stoneskin))
            {
                var result = new EngineAction {
                    Spell = Spells.Stoneskin
                };

                if (Config.AccessionEnabled && Config.StoneskinAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.StoneskinPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.AquaveilEnabled && (!PL.HasStatus(StatusEffect.Aquaveil)) && PL.SpellAvailable(Spells.Aquaveil))
            {
                var result = new EngineAction {
                    Spell = Spells.Aquaveil
                };

                if (Config.AccessionEnabled && Config.AquaveilAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                {
                    result.JobAbility = Ability.Accession;
                }
                else if (Config.PerpetuanceEnabled && Config.AquaveilPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                {
                    result.JobAbility = Ability.Perpetuance;
                }

                return(result);
            }

            if (Config.KlimaformEnabled && !PL.HasStatus(StatusEffect.Klimaform))
            {
                return(new EngineAction {
                    Spell = Spells.Klimaform
                });
            }

            if (Config.TemperEnabled && (!PL.HasStatus(StatusEffect.Multi_Strikes)))
            {
                return(new EngineAction {
                    Spell = Config.TemperSpell
                });
            }

            if (Config.HasteEnabled && (!PL.HasStatus(StatusEffect.Haste)))
            {
                return(new EngineAction {
                    Spell = Config.HasteSpell
                });
            }

            if (Config.SpikesEnabled && !PL.HasStatus(Data.SpellEffects[Config.SpikesSpell]))
            {
                return(new EngineAction {
                    Spell = Config.SpikesSpell
                });
            }

            if (Config.EnSpellEnabled && !PL.HasStatus(Data.SpellEffects[Config.EnSpell]) && PL.SpellAvailable(Config.EnSpell))
            {
                var result = new EngineAction {
                    Spell = Config.EnSpell
                };

                // Don't want to try and accession/perpetuance tier II.
                if (!Config.EnSpell.Contains("II"))
                {
                    if (Config.AccessionEnabled && Config.EnspellAccession && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Accession) && !PL.HasStatus(StatusEffect.Accession))
                    {
                        result.JobAbility = Ability.Accession;
                    }
                    else if (Config.PerpetuanceEnabled && Config.EnspellPerpetuance && PL.CurrentSCHCharges() > 0 && PL.AbilityAvailable(Ability.Perpetuance) && !PL.HasStatus(StatusEffect.Perpetuance))
                    {
                        result.JobAbility = Ability.Perpetuance;
                    }
                }

                return(result);
            }

            if (Config.AuspiceEnabled && (!PL.HasStatus(StatusEffect.Auspice)) && PL.SpellAvailable(Spells.Auspice))
            {
                return(new EngineAction {
                    Spell = Spells.Auspice
                });
            }

            // TODO: Rethink this whole logic.
            // Probably doesn't work at all right now, and need to figure out a better way
            // to find entities than iterating 2048 things...
            if (Config.AutoTargetEnabled && PL.SpellAvailable(Config.AutoTargetSpell))
            {
                if (Config.PartyBasedHateSpell)
                {
                    // PARTY BASED HATE SPELL
                    int enemyID = CheckEngagedStatus_Hate(Config);

                    if (enemyID != 0 && enemyID != lastKnownEstablisherTarget)
                    {
                        lastKnownEstablisherTarget = enemyID;

                        return(new EngineAction
                        {
                            Target = Config.AutoTargetTarget,
                            Spell = Config.AutoTargetSpell
                        });
                    }
                }
                else
                {
                    // ENEMY BASED TARGET
                    int enemyID = CheckEngagedStatus_Hate(Config);

                    if (enemyID != 0 && enemyID != lastKnownEstablisherTarget)
                    {
                        PL.Target.SetTarget(enemyID);

                        lastKnownEstablisherTarget = enemyID;

                        return(new EngineAction
                        {
                            Target = "<t>",
                            Spell = Config.AutoTargetSpell
                        });

                        //if (ConfigForm.config.DisableTargettingCancel == false)
                        //{
                        //    await Task.Delay(TimeSpan.FromSeconds((double)ConfigForm.config.TargetRemoval_Delay));
                        //    PL.Target.SetTarget(0);
                        //}
                    }
                }
            }

            return(null);
        }
コード例 #9
0
ファイル: SongEngine.cs プロジェクト: Sunderous/Cure-Please
        public EngineAction Run(SongConfig Config)
        {
            EngineAction actionResult = new EngineAction()
            {
                Target = Target.Me
            };

            PL_BRDCount = PL.Player.GetPlayerInfo().Buffs.Where(b => b == 195 || b == 196 || b == 197 || b == 198 || b == 199 || b == 200 || b == 201 || b == 214 || b == 215 || b == 216 || b == 218 || b == 219 || b == 222).Count();

            if (Config.SingingEnabled && PL.Player.Status != 33)
            {
                int songs_currently_up = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == 197 || b == 198 || b == 195 || b == 199 || b == 200 || b == 215 || b == 196 || b == 214 || b == 216 || b == 218 || b == 222).Count();

                // TODO: Add support for multiple JAs per cast, or else this will never work.
                // For now we just return the action with only the ability in it.
                // ie. If N + T were up, this would return once with Troub, then next cycle return Night,
                // then finally return the song cast.
                if (Config.TroubadourEnabled && PL.AbilityAvailable(Ability.Troubadour) && songs_currently_up == 0)
                {
                    actionResult.JobAbility = Ability.Troubadour;
                    return(actionResult);
                }
                else if (Config.NightingaleEnabled && PL.AbilityAvailable(Ability.Nightingale) && songs_currently_up == 0)
                {
                    actionResult.JobAbility = Ability.Nightingale;
                    return(actionResult);
                }

                SongData song_1 = SongInfo.Where(c => c.song_position == Config.Song1).FirstOrDefault();
                SongData song_2 = SongInfo.Where(c => c.song_position == Config.Song2).FirstOrDefault();
                SongData song_3 = SongInfo.Where(c => c.song_position == Config.Song3).FirstOrDefault();
                SongData song_4 = SongInfo.Where(c => c.song_position == Config.Song4).FirstOrDefault();

                SongData dummy1_song = SongInfo.Where(c => c.song_position == Config.Dummy1).FirstOrDefault();
                SongData dummy2_song = SongInfo.Where(c => c.song_position == Config.Dummy2).FirstOrDefault();

                // Check the distance of the Monitored player
                int Monitoreddistance = 50;


                XiEntity monitoredTarget = PL.Entity.GetEntity((int)Monitored.Player.TargetID);
                Monitoreddistance = (int)monitoredTarget.Distance;

                int Songs_Possible = 0;

                if (song_1.song_name.ToLower() != "blank")
                {
                    Songs_Possible++;
                }
                if (song_2.song_name.ToLower() != "blank")
                {
                    Songs_Possible++;
                }
                if (dummy1_song != null && dummy1_song.song_name.ToLower() != "blank")
                {
                    Songs_Possible++;
                }
                if (dummy2_song != null && dummy2_song.song_name.ToLower() != "blank")
                {
                    Songs_Possible++;
                }

                // List to make it easy to check how many of each buff is needed.
                List <int> SongDataMax = new List <int> {
                    song_1.buff_id, song_2.buff_id, song_3.buff_id, song_4.buff_id
                };

                // Check Whether e have the songs Currently Up
                int count1_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_1.buff_id).Count();
                int count2_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_2.buff_id).Count();
                int count3_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == dummy1_song.buff_id).Count();
                int count4_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_3.buff_id).Count();
                int count5_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == dummy2_song.buff_id).Count();
                int count6_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_4.buff_id).Count();

                int MON_count1_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_1.buff_id).Count();
                int MON_count2_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_2.buff_id).Count();
                int MON_count3_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == dummy1_song.buff_id).Count();
                int MON_count4_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_3.buff_id).Count();
                int MON_count5_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == dummy2_song.buff_id).Count();
                int MON_count6_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_4.buff_id).Count();


                if (ForceSongRecast == true)
                {
                    song_casting = 0; ForceSongRecast = false;
                }


                // SONG NUMBER #4
                if (song_casting == 3 && PL_BRDCount >= 3 && song_4.song_name.ToLower() != "blank" && count6_type < SongDataMax.Where(c => c == song_4.buff_id).Count() && Last_Song_Cast != song_4.song_name)
                {
                    if (PL_BRDCount == 3)
                    {
                        if (PL.SpellAvailable(dummy2_song.song_name))
                        {
                            actionResult.Spell = dummy2_song.song_name;
                        }
                    }
                    else
                    {
                        if (PL.SpellAvailable(song_4.song_name))
                        {
                            actionResult.Spell = song_4.song_name;

                            Last_Song_Cast         = song_4.song_name;
                            Last_SongCast_Timer[0] = DateTime.Now;
                            playerSong4[0]         = DateTime.Now;
                            song_casting           = 0;
                        }
                    }
                }
                else if (song_casting == 3 && song_4.song_name.ToLower() != "blank" && count6_type >= SongDataMax.Where(c => c == song_4.buff_id).Count())
                {
                    song_casting = 0;
                }


                // SONG NUMBER #3
                else if (song_casting == 2 && PL_BRDCount >= 2 && song_3.song_name.ToLower() != "blank" && count4_type < SongDataMax.Where(c => c == song_3.buff_id).Count() && Last_Song_Cast != song_3.song_name)
                {
                    if (PL_BRDCount == 2)
                    {
                        if (PL.SpellAvailable(dummy1_song.song_name))
                        {
                            actionResult.Spell = dummy1_song.song_name;
                        }
                    }
                    else
                    {
                        if (PL.SpellAvailable(song_3.song_name))
                        {
                            actionResult.Spell = song_3.song_name;

                            Last_Song_Cast         = song_3.song_name;
                            Last_SongCast_Timer[0] = DateTime.Now;
                            playerSong3[0]         = DateTime.Now;
                            song_casting           = 3;
                        }
                    }
                }
                else if (song_casting == 2 && song_3.song_name.ToLower() != "blank" && count4_type >= SongDataMax.Where(c => c == song_3.buff_id).Count())
                {
                    song_casting = 3;
                }


                // SONG NUMBER #2
                else if (song_casting == 1 && song_2.song_name.ToLower() != "blank" && count2_type < SongDataMax.Where(c => c == song_2.buff_id).Count() && Last_Song_Cast != song_4.song_name)
                {
                    if (PL.SpellAvailable(song_2.song_name))
                    {
                        actionResult.Spell = song_2.song_name;

                        Last_Song_Cast         = song_2.song_name;
                        Last_SongCast_Timer[0] = DateTime.Now;
                        playerSong2[0]         = DateTime.Now;
                        song_casting           = 2;
                    }
                }
                else if (song_casting == 1 && song_2.song_name.ToLower() != "blank" && count2_type >= SongDataMax.Where(c => c == song_2.buff_id).Count())
                {
                    song_casting = 2;
                }

                // SONG NUMBER #1
                else if ((song_casting == 0) && song_1.song_name.ToLower() != "blank" && count1_type < SongDataMax.Where(c => c == song_1.buff_id).Count() && Last_Song_Cast != song_4.song_name)
                {
                    if (PL.SpellAvailable(song_1.song_name))
                    {
                        actionResult.Spell = song_1.song_name;

                        Last_Song_Cast         = song_1.song_name;
                        Last_SongCast_Timer[0] = DateTime.Now;
                        playerSong1[0]         = DateTime.Now;
                        song_casting           = 1;
                    }
                }
                else if (song_casting == 0 && song_2.song_name.ToLower() != "blank" && count1_type >= SongDataMax.Where(c => c == song_1.buff_id).Count())
                {
                    song_casting = 1;
                }


                // ONCE ALL SONGS HAVE BEEN CAST ONLY RECAST THEM WHEN THEY MEET THE THRESHOLD SET ON SONG RECAST AND BLOCK IF IT'S SET AT LAUNCH DEFAULTS
                if (playerSong1[0] != DefaultTime && playerSong1_Span[0].Minutes >= Config.SongRecastMinutes)
                {
                    if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false)
                    {
                        if (PL.SpellAvailable(song_1.song_name))
                        {
                            actionResult.Spell = song_1.song_name;

                            playerSong1[0] = DateTime.Now;
                            song_casting   = 0;
                        }
                    }
                }
                else if (playerSong2[0] != DefaultTime && playerSong2_Span[0].Minutes >= Config.SongRecastMinutes)
                {
                    if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false)
                    {
                        if (PL.SpellAvailable(song_2.song_name))
                        {
                            actionResult.Spell = song_2.song_name;

                            playerSong2[0] = DateTime.Now;
                            song_casting   = 0;
                        }
                    }
                }
                else if (playerSong3[0] != DefaultTime && playerSong3_Span[0].Minutes >= Config.SongRecastMinutes)
                {
                    if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false)
                    {
                        if (PL.SpellAvailable(song_3.song_name))
                        {
                            actionResult.Spell = song_3.song_name;
                            playerSong3[0]     = DateTime.Now;
                            song_casting       = 0;
                        }
                    }
                }
                else if (playerSong4[0] != DefaultTime && playerSong4_Span[0].Minutes >= Config.SongRecastMinutes)
                {
                    if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false)
                    {
                        if (PL.SpellAvailable(song_4.song_name))
                        {
                            actionResult.Spell = song_4.song_name;
                            playerSong4[0]     = DateTime.Now;
                            song_casting       = 0;
                        }
                    }
                }
            }

            return(actionResult);
        }
コード例 #10
0
        public EngineAction Run(GeoConfig Config)
        {
            _config = Config;

            EngineAction actionResult = new EngineAction
            {
                Target = Target.Me
            };

            if (Config.EntrustEnabled && !PL.HasStatus((StatusEffect)584) && CheckEngagedStatus() == true && PL.AbilityAvailable(Ability.Entrust))
            {
                actionResult.JobAbility = Ability.Entrust;
                return(actionResult);
            }
            else if (Config.DematerializeEnabled && CheckEngagedStatus() == true && PL.Player.Pet.HealthPercent >= 90 && PL.AbilityAvailable(Ability.Dematerialize))
            {
                actionResult.JobAbility = Ability.Dematerialize;
                return(actionResult);
            }
            else if (Config.EclipticAttritionEnabled && CheckEngagedStatus() == true && PL.Player.Pet.HealthPercent >= 90 && PL.AbilityAvailable(Ability.EclipticAttrition) && !PL.HasStatus(516) && EclipticStillUp != true)
            {
                actionResult.JobAbility = Ability.EclipticAttrition;
                return(actionResult);
            }
            else if (Config.LifeCycleEnabled && CheckEngagedStatus() == true && PL.Player.Pet.HealthPercent <= 30 && PL.Player.Pet.HealthPercent >= 5 && PL.Player.HPP >= 90 && PL.AbilityAvailable(Ability.LifeCycle))
            {
                actionResult.JobAbility = Ability.LifeCycle;
                return(actionResult);
            }

            // TODO: Fix up this logic, I think something was lost in the refactoring.
            // Need to see if there's a situation where both of these JA's would be activated for the cast.
            // For now the old logic seems to be use RA on it's own, or check for FC + Cast.
            if (Config.RadialArcanaEnabled && (PL.Player.MP <= Config.RadialArcanaMP) && PL.AbilityAvailable(Ability.RadialArcana) && !PL.Player.Buffs.Contains((short)StatusEffect.Weakness))
            {
                // Check if a pet is already active
                if (PL.Player.Pet.HealthPercent >= 1 && PL.Player.Pet.Distance <= 9)
                {
                    actionResult.JobAbility = Ability.RadialArcana;
                    return(actionResult);
                }
                else if (PL.Player.Pet.HealthPercent >= 1 && PL.Player.Pet.Distance >= 9 && PL.AbilityAvailable(Ability.FullCircle))
                {
                    actionResult.JobAbility = Ability.FullCircle;
                }

                actionResult.Spell = ReturnGeoSpell(Config.RadialArcanaSpell, 2);
            }
            else if (Config.FullCircleEnabled)
            {
                // When out of range Distance is 59 Yalms regardless, Must be within 15 yalms to gain
                // the effect

                //Check if "pet" is active and out of range of the monitored player
                if (PL.Player.Pet.HealthPercent >= 1)
                {
                    if (Config.FullCircleGeoTarget == true && Config.LuopanSpellTarget != "")
                    {
                        ushort PetsIndex = PL.Player.PetIndex;

                        XiEntity PetsEntity = PL.Entity.GetEntity(PetsIndex);

                        int FullCircle_CharID = 0;

                        for (int x = 0; x < 2048; x++)
                        {
                            XiEntity entity = PL.Entity.GetEntity(x);

                            if (entity.Name != null && entity.Name.ToLower().Equals(Config.LuopanSpellTarget.ToLower()))
                            {
                                FullCircle_CharID = Convert.ToInt32(entity.TargetID);
                                break;
                            }
                        }

                        if (FullCircle_CharID != 0)
                        {
                            XiEntity FullCircleEntity = PL.Entity.GetEntity(FullCircle_CharID);

                            float fX = PetsEntity.X - FullCircleEntity.X;
                            float fY = PetsEntity.Y - FullCircleEntity.Y;
                            float fZ = PetsEntity.Z - FullCircleEntity.Z;

                            float generatedDistance = (float)Math.Sqrt((fX * fX) + (fY * fY) + (fZ * fZ));

                            if (generatedDistance >= 10)
                            {
                                FullCircleTimer.Enabled = true;
                            }
                        }
                    }
                    else if (Config.FullCircleGeoTarget == false && Monitored.Player.Status == 1)
                    {
                        ushort PetsIndex = PL.Player.PetIndex;

                        XiEntity PetsEntity = Monitored.Entity.GetEntity(PetsIndex);

                        if (PetsEntity.Distance >= 10)
                        {
                            FullCircleTimer.Enabled = true;
                        }
                    }
                }
            }
            // ENTRUSTED INDI SPELL CASTING, WILL BE CAST SO LONG AS ENTRUST IS ACTIVE
            else if (Config.GeoSpellsEnabled && PL.HasStatus((StatusEffect)584) && PL.Player.Status != 33)
            {
                string SpellCheckedResult = ReturnGeoSpell(Config.EntrustSpell, 1);
                if (SpellCheckedResult == "SpellError_Cancel")
                {
                    Config.GeoSpellsEnabled = false;
                    actionResult.Error      = "An error has occurred with Entrusted INDI spell casting, please report what spell was active at the time.";
                }
                else if (SpellCheckedResult == "SpellRecast" || SpellCheckedResult == "SpellUnknown")
                {
                }
                else
                {
                    actionResult.Target = string.IsNullOrEmpty(Config.EntrustSpellTarget) ? Monitored.Player.Name : Config.EntrustSpellTarget;
                    actionResult.Spell  = SpellCheckedResult;
                }
            }
            // CAST NON ENTRUSTED INDI SPELL
            else if (Config.GeoSpellsEnabled && !PL.HasStatus(612) && PL.Player.Status != 33 && (CheckEngagedStatus() == true || !Config.IndiWhenEngaged))
            {
                string SpellCheckedResult = ReturnGeoSpell(Config.IndiSpell, 1);

                if (SpellCheckedResult == "SpellError_Cancel")
                {
                    Config.GeoSpellsEnabled = false;
                    actionResult.Error      = "An error has occurred with INDI spell casting, please report what spell was active at the time.";
                }
                else if (SpellCheckedResult == "SpellRecast" || SpellCheckedResult == "SpellUnknown")
                {
                }
                else
                {
                    actionResult.Spell = SpellCheckedResult;
                }
            }
            // GEO SPELL CASTING
            else if (Config.LuopanSpellsEnabled && (PL.Player.Pet.HealthPercent < 1) && (CheckEngagedStatus() == true))
            {
                // Use BLAZE OF GLORY if ENABLED
                if (Config.BlazeOfGloryEnabled && PL.AbilityAvailable(Ability.BlazeOfGlory) && CheckEngagedStatus() == true && GEO_EnemyCheck() == true)
                {
                    actionResult.JobAbility = Ability.BlazeOfGlory;
                    return(actionResult);
                }

                // Grab GEO spell name
                string SpellCheckedResult = ReturnGeoSpell(Config.GeoSpell, 2);

                if (SpellCheckedResult == "SpellError_Cancel")
                {
                    Config.GeoSpellsEnabled = false;
                    actionResult.Error      = "An error has occurred with GEO spell casting, please report what spell was active at the time.";
                }
                else if (SpellCheckedResult == "SpellRecast" || SpellCheckedResult == "SpellUnknown")
                {
                    // Do nothing and continue on with the program
                }
                else
                {
                    if (PL.Resources.GetSpell(SpellCheckedResult, 0).ValidTargets == 5)
                    { // PLAYER CHARACTER TARGET
                        actionResult.Target = string.IsNullOrEmpty(Config.LuopanSpellTarget) ? Monitored.Player.Name : Config.LuopanSpellTarget;

                        if (PL.HasStatus(516)) // IF ECLIPTIC IS UP THEN ACTIVATE THE BOOL
                        {
                            EclipticStillUp = true;
                        }

                        actionResult.Spell = SpellCheckedResult;
                    }
                    else
                    { // ENEMY BASED TARGET NEED TO ASSURE PLAYER IS ENGAGED
                        if (CheckEngagedStatus() == true)
                        {
                            int GrabbedTargetID = GrabGEOTargetID();

                            if (GrabbedTargetID != 0)
                            {
                                PL.Target.SetTarget(GrabbedTargetID);

                                if (PL.HasStatus(516)) // IF ECLIPTIC IS UP THEN ACTIVATE THE BOOL
                                {
                                    EclipticStillUp = true;
                                }

                                actionResult.Target = "<t>";
                                actionResult.Spell  = SpellCheckedResult;
                            }
                        }
                    }
                }
            }

            return(actionResult);
        }
コード例 #11
0
        internal void Execute(EngineAction action, string newConnectionString)
        {
            // Specify connection string for new database options; The following
            // tokens are valid:
            //      - Password
            //      - LCID
            //      - Encryption Mode
            //      - Case Sensitive
            //
            // All other SqlCeConnection.ConnectionString tokens are ignored
            //
            //  engine.Compact("Data Source=; Password =a@3!7f$dQ;");

            if (action != EngineAction.GetInfo)
            {
                using (SqlCeEngine engine = new SqlCeEngine(connectionString))
                {
                    switch (action)
                    {
                    case EngineAction.Undefined:
                        break;

                    case EngineAction.Shrink:
                        engine.Shrink();
                        Console.WriteLine("Database successfully shrunk");
                        break;

                    case EngineAction.Verify:
                        Console.WriteLine(engine.Verify(VerifyOption.Enhanced)
                                            ? "Database successfully verified"
                                            : "Database verification failed");
                        break;

                    case EngineAction.Compact:
                        engine.Compact(null);
                        Console.WriteLine("Database successfully compacted");
                        break;

                    case EngineAction.Upgrade:
                        engine.Upgrade();
                        Console.WriteLine("Database successfully upgraded");
                        break;

                    case EngineAction.Create:
                        engine.CreateDatabase();
                        Console.WriteLine("Database successfully created");
                        break;

                    case EngineAction.RepairDelete:
                        engine.Repair(null, RepairOption.DeleteCorruptedRows);
                        Console.WriteLine("Database successfully repaired");
                        break;

                    case EngineAction.RepairRecover:
                        engine.Repair(null, RepairOption.RecoverAllOrFail);
                        Console.WriteLine("Database successfully repaired");
                        break;

                    case EngineAction.SetOption:
                        engine.Compact(newConnectionString);
                        Console.WriteLine("Database option(s) successfully changed");
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (action == EngineAction.GetInfo)
            {
                using (SqlCeConnection cn = new SqlCeConnection(connectionString))
                {
                    cn.Open();
                    List <KeyValuePair <string, string> > valueList = new List <KeyValuePair <string, string> >();
                    // 3.5 or later only API

                    valueList = cn.GetDatabaseInfo();
                    valueList.Add(new KeyValuePair <string, string>("Database", cn.Database));
                    valueList.Add(new KeyValuePair <string, string>("ServerVersion", cn.ServerVersion));
                    if (System.IO.File.Exists(cn.Database))
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(cn.Database);
                        valueList.Add(new KeyValuePair <string, string>("DatabaseSize", fi.Length.ToString(CultureInfo.InvariantCulture)));
                        valueList.Add(new KeyValuePair <string, string>("Created", fi.CreationTime.ToShortDateString() + " " + fi.CreationTime.ToShortTimeString()));
                    }
                    valueList.Add(new KeyValuePair <string, string>(string.Empty, string.Empty));
                    valueList.Insert(0, new KeyValuePair <string, string>("SqlCeCmd", "Database Information"));

                    foreach (KeyValuePair <string, string> pair in valueList)
                    {
                        Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0}: {1}", pair.Key, pair.Value));
                    }
                }
            }
            return;
        }
コード例 #12
0
 internal void Execute(EngineAction action)
 {
     Execute(action, null);
 }
コード例 #13
0
		public void Log(object key, EngineAction action, Bet b, LogMode mode)
		{
			if (EngineLogger.CheckMode(mode))
			{
				string message = string.Format("{0}:{1}-->{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_{10}_{11}_{12}_{13}", new object[]
				{
					key,
					action,
					b.Id,
					b.Home,
					b.Away,
					(int)b.Type,
					b.Choice.ToString().ToLower(),
					b.Handicap,
					b.OddsValue,
					b.MinBetAllowed,
					b.MaxBetAllowed,
					b.Stake,
					b.Step,
					b.Status
				});
				this.Log(message, mode);
			}
		}