Example #1
0
        private void BotMainLoop()
        {
            try
            {
                if (SettingsManager.settings.champ && !SettingsManager.settings.Initialize())
                {
                    checkChamp.Checked = false;
                    checkChamp.Enabled = false;
                }

                BoxOpener.SetBoxes();

                if (SettingsManager.settings.boxTime.CompareTo(DateTime.Now) > 0)
                {
                    Logger.Log("Next box opens at: " + SettingsManager.settings.boxTime.ToString());
                }

                while (toogleState == CheckState.Checked && toogleStartStop.Checked)
                {
                    if (BoxOpener.Run() == Messages.Restart)
                    {
                        Game.RestartProtocol();
                    }

                    if (Championship.Run() == Messages.Restart)
                    {
                        Game.RestartProtocol();
                        Championship.SetChamp();
                    }

                    if (QuickFight.Run(loops: 5) == Messages.Restart)
                    {
                        Game.RestartProtocol();
                    }

                    if (Hibernate.Run() == Messages.Hibernate)
                    {
                        toogleState      = CheckState.Indeterminate;
                        this.WindowState = FormWindowState.Minimized;
                    }
                }

                toogleState             = CheckState.Unchecked;
                toogleStartStop.Checked = false;
                sw.Stop();
                TimeSpan ts = sw.Elapsed;
                SettingsManager.currentStatistics.working += ts.TotalHours;
            }
            catch (Exception e)
            {
                Logger.Log("BotMainLoop Exception: " + e.Message, debug: true);
            }
        }
Example #2
0
        // cast_spell_on
        internal static bool NonCombatSpellCast(QuickFight quick_fight, int spellId)
        {
            if (gbl.lastSelectetSpellTarget == null)
            {
                gbl.lastSelectetSpellTarget = gbl.SelectedPlayer;
            }

            gbl.spellTargets.Clear();
            gbl.spellTargets.Add(gbl.SelectedPlayer);

            bool castSpell = true;

            switch (gbl.spellCastingTable[spellId].targetType)
            {
                case SpellTargets.Self:
                    break;

                case SpellTargets.PartyMember:
                    ovr025.LoadPic();

                    ovr025.selectAPlayer(ref gbl.lastSelectetSpellTarget, true, "Cast Spell on whom");

                    gbl.spellTargets.Clear();
                    if (gbl.lastSelectetSpellTarget == null)
                    {
                        castSpell = false;
                    }
                    else
                    {
                        gbl.spellTargets.Add(gbl.lastSelectetSpellTarget);
                    }
                    break;

                case SpellTargets.WholeParty:
                    // prepend all players
                    gbl.spellTargets.AddRange(gbl.TeamList);
                    break;

                default:
                    castSpell = false;
                    break;
            }

            return castSpell;
        }
Example #3
0
        // sub_5D2E1
        internal static void sub_5D2E1(ref bool arg_0, bool showCastingText, QuickFight quick_fight, int spell_id)
        {
            Player caster = gbl.SelectedPlayer;
            bool stillCast = true;

            if (gbl.game_state != GameState.Combat &&
                gbl.spellCastingTable[spell_id].targetType == SpellTargets.Combat)
            {
                if (gbl.spell_from_item == false)
                {
                    seg041.displayString(SpellNames[spell_id], 0, 10, 0x13, 1);
                    seg041.displayString("can't be cast here...", 0, 10, 0x14, 1);

                    if (ovr027.yes_no(gbl.defaultMenuColors, "Lose it? ") == 'Y')
                    {
                        caster.spellList.ClearSpell(spell_id);
                    }
                }
                else
                {
                    seg041.displayString("That Item", 0, 10, 0x13, 1);
                    seg041.displayString("is a combat-only item...", 0, 10, 0x14, 1);

                    if (ovr027.yes_no(gbl.defaultMenuColors, "Use it? ") == 'Y')
                    {
                        arg_0 = true;
                    }
                }

                showCastingText = false;
                stillCast = false;
            }

            if (caster.HasAffect(Affects.affect_4a) == true)
            {
                byte dice_roll = ovr024.roll_dice(2, 1);

                if (dice_roll == 1)
                {
                    DisplayCaseSpellText(spell_id, "miscasts", caster);
                    showCastingText = false;
                    stillCast = false;
                }
            }

            if (showCastingText == true && gbl.spell_from_item == false)
            {
                DisplayCaseSpellText(spell_id, "casts", caster);
            }

            while (stillCast == true)
            {
                arg_0 = gbl.SpellCastFunction(quick_fight, spell_id);

                if (arg_0 == true)
                {
                    stillCast = false;

                    if (gbl.game_state == GameState.Combat)
                    {
                        ovr025.load_missile_icons(0x12);
                        var casterPos = ovr033.PlayerMapPos(caster);

                        byte direction = ovr032.FindCombatantDirection(gbl.targetPos, casterPos);

                        gbl.focusCombatAreaOnPlayer = true;
                        ovr033.draw_74B3F(false, Icon.Attack, direction, caster);

                        if (spell_id == 0x2F)
                        {
                            seg044.PlaySound(Sound.sound_b);
                        }
                        else if (spell_id == 0x33)
                        {
                            seg044.PlaySound(Sound.sound_8);
                        }
                        else
                        {
                            seg044.PlaySound(Sound.sound_2);
                        }

                        ovr025.draw_missile_attack(0x1E, 4, gbl.targetPos, casterPos);

                        if (ovr033.PlayerOnScreen(false, caster) == true)
                        {
                            ovr033.draw_74B3F(true, Icon.Attack, caster.actions.direction, caster);
                            ovr033.draw_74B3F(false, Icon.Normal, caster.actions.direction, caster);
                        }
                    }

                    ovr024.remove_invisibility(caster);

                    if (gbl.spell_from_item == false)
                    {
                        caster.spellList.ClearSpell(spell_id);
                    }

                    gbl.spell_id = spell_id;

                    var func = gbl.spellTable[(Spells)spell_id];
                    func();

                    gbl.spell_id = 0;
                    gbl.byte_1D2C7 = false;
                }
                else
                {
                    if (gbl.game_state != GameState.Combat)
                    {
                        stillCast = false;
                    }
                    else if (quick_fight == QuickFight.True ||
                            ovr027.yes_no(gbl.alertMenuColors, "Abort Spell? ") == 'Y')
                    {
                        ovr025.string_print01("Spell Aborted");
                        if (gbl.spell_from_item == false)
                        {
                            caster.spellList.ClearSpell(spell_id);
                        }

                        stillCast = false;
                    }
                }
            }

            ovr025.ClearPlayerTextArea();

            if (gbl.game_state == GameState.Combat)
            {
                seg037.draw8x8_clear_area(0x17, 0x27, 0x17, 0);
            }
        }
Example #4
0
 // sub_5D2E1
 internal static void sub_5D2E1(bool showCastingText, QuickFight quick_fight, int spell_id)
 {
     bool dummy = false;
     sub_5D2E1(ref dummy, showCastingText, quick_fight, spell_id);
 }
Example #5
0
        internal static bool target(QuickFight quick_fight, int spellId)
        {
            Struct_1D183 var_C = new Struct_1D183();

            bool castSpell = true;
            gbl.spellTargets.Clear();
            gbl.byte_1D2C7 = false;

            gbl.targetPos = ovr033.PlayerMapPos(gbl.SelectedPlayer);

            int tmp1 = gbl.spellCastingTable[spellId].field_6 & 0x0F;

            if (tmp1 == 0)
            {
                gbl.spellTargets.Clear();
                gbl.spellTargets.Add(gbl.SelectedPlayer);
            }
            else if (tmp1 == 5)
            {
                int var_5 = 0;
                gbl.spellTargets.Clear();

                int var_4;

                if (spellId == 0x4F)
                {
                    var_4 = ovr025.spellMaxTargetCount(0x4F);
                }
                else
                {
                    var_4 = ovr024.roll_dice(4, 2);
                }

                bool stop_loop = false;

                do
                {
                    if (sub_4001C(var_C, false, quick_fight, spellId) == true)
                    {
                        bool found = gbl.spellTargets.Exists(st => st == var_C.target);

                        if (found == false)
                        {
                            Player target = var_C.target;
                            gbl.spellTargets.Add(target);

                            gbl.targetPos = ovr033.PlayerMapPos(var_C.target);

                            if (spellId != 0x4f)
                            {
                                byte hitDice = target.HitDice;

                                if (hitDice == 0 || hitDice == 1)
                                {
                                    var_5 += 1;
                                }
                                else if (hitDice == 2)
                                {
                                    var_5 += 2;
                                }
                                else if (hitDice == 3)
                                {
                                    var_5 += 4;
                                }
                                else
                                {
                                    var_5 += 8;
                                }
                            }
                            else
                            {
                                byte al = target.field_DE;

                                if (al == 1)
                                {
                                    var_5 += 1;
                                }
                                else if (al == 2 || al == 3)
                                {
                                    var_5 += 2;
                                }
                                else if (al == 4)
                                {
                                    var_5 += 4;
                                }
                            }

                            if (gbl.spellTargets.Count > 0 && var_5 > var_4)
                            {
                                stop_loop = true;
                            }
                        }
                        else
                        {
                            if (quick_fight != 0)
                            {
                                var_4 -= 1;
                            }
                            else
                            {
                                ovr025.string_print01("Already been targeted");
                            }
                        }

                        ovr033.RedrawPosition(ovr033.PlayerMapPos(var_C.target));
                    }
                    else
                    {
                        stop_loop = true;
                    }
                } while (stop_loop == false && var_4 != 0);
            }
            else if (tmp1 == 0x0F)
            {
                if (sub_4001C(var_C, false, quick_fight, spellId) == true)
                {
                    if (gbl.SelectedPlayer.actions.target != null)
                    {
                        gbl.spellTargets.Clear();
                        gbl.spellTargets.Add(gbl.SelectedPlayer.actions.target);
                    }
                    else
                    {
                        /* TODO it doesn't make sense to mask the low nibble then shift it out */
                        var scl = ovr032.Rebuild_SortedCombatantList(1, (gbl.spellCastingTable[spellId].field_6 & 0x0f) >> 4, gbl.targetPos, sc => true);

                        gbl.spellTargets.Clear();
                        foreach (var sc in scl)
                        {
                            gbl.spellTargets.Add(sc.player);
                        }
                        gbl.byte_1D2C7 = true;
                    }
                }
                else
                {
                    castSpell = false;
                }
            }
            else if (tmp1 >= 8 && tmp1 <= 0x0E)
            {
                if (sub_4001C(var_C, true, quick_fight, spellId) == true)
                {
                    var scl = ovr032.Rebuild_SortedCombatantList(1, gbl.spellCastingTable[spellId].field_6 & 7, gbl.targetPos, sc => true);

                    gbl.spellTargets.Clear();
                    foreach (var sc in scl)
                    {
                        gbl.spellTargets.Add(sc.player);
                    }

                    gbl.byte_1D2C7 = true;
                }
                else
                {
                    castSpell = false;
                }
            }
            else
            {
                int max_targets = (gbl.spellCastingTable[spellId].field_6 & 3) + 1;
                gbl.spellTargets.Clear();

                while (max_targets > 0)
                {
                    if (sub_4001C(var_C, false, quick_fight, spellId) == true)
                    {
                        bool found = gbl.spellTargets.Exists(st => st == var_C.target);

                        if (found == false)
                        {
                            gbl.spellTargets.Add(var_C.target);
                            max_targets -= 1;

                            gbl.targetPos = ovr033.PlayerMapPos(var_C.target);
                        }
                        else
                        {
                            if (quick_fight == 0)
                            {
                                ovr025.string_print01("Already been targeted");
                            }
                            else
                            {
                                max_targets -= 1;
                            }
                        }

                        ovr033.RedrawPosition(ovr033.PlayerMapPos(var_C.target));
                    }
                    else
                    {
                        max_targets = 0;
                    }
                }

                if (gbl.spellTargets.Count == 0)
                {
                    castSpell = false;
                    gbl.targetPos = new Point();
                }

                //gbl.targetPos = ovr033.PlayerMapPos(gbl.spellTargets[gbl.spellTargets.Count-1]);
            }

            return castSpell;
        }
Example #6
0
        internal static bool sub_4001C(Struct_1D183 arg_0, bool canTargetEmptyGround, QuickFight quick_fight, int spellId)
        {
            bool var_2 = false;
            if (quick_fight == QuickFight.False)
            {
                bool allowTarget = spellId != 0x53;

                var_2 = aim_menu(arg_0, allowTarget, canTargetEmptyGround, false, ovr023.SpellRange(spellId), gbl.SelectedPlayer);
                gbl.SelectedPlayer.actions.target = arg_0.target;
            }
            else if (gbl.spellCastingTable[spellId].field_E == 0)
            {
                arg_0.target = gbl.SelectedPlayer;

                if (spellId != 3 || find_healing_target(out arg_0.target, gbl.SelectedPlayer))
                {
                    arg_0.map = ovr033.PlayerMapPos(arg_0.target);
                    var_2 = true;
                }
            }
            else
            {
                int var_9 = 1;

                while (var_9 > 0 &&
                        var_2 == false)
                {
                    bool var_3 = true;

                    if (find_target(true, 0, ovr023.SpellRange(spellId), gbl.SelectedPlayer) == true)
                    {
                        Player target = gbl.SelectedPlayer.actions.target;

                        if (target.IsHeld() == true)
                        {
                            for (int i = 1; i <= 4; i++)
                            {
                                if (gbl.spellCastingTable[spellId].affect_id == unk_18ADB[i])
                                {
                                    var_3 = false;
                                }
                            }
                        }

                        if (var_3 == true)
                        {
                            arg_0.target = gbl.SelectedPlayer.actions.target;
                            arg_0.map = ovr033.PlayerMapPos(arg_0.target);
                            var_2 = true;
                        }
                    }

                    var_9 -= 1;
                }
            }

            if (var_2 == true)
            {
                gbl.targetPos = arg_0.map;
            }
            else
            {
                arg_0.Clear();
            }

            return var_2;
        }
Example #7
0
        internal static void spell_menu3(out bool casting_spell, QuickFight quick_fight, int spell_id)
        {
            Player player = gbl.SelectedPlayer;
            bool var_6 = true;
            int var_5 = -1;
            casting_spell = false;

            if (spell_id == 0)
            {
                spell_id = ovr020.spell_menu2(out var_6, ref var_5, SpellSource.Cast, SpellLoc.memory);
            }

            if (spell_id > 0 &&
                gbl.spellCastingTable[spell_id].whenCast == SpellWhen.Camp)
            {
                ovr025.string_print01("Camp Only Spell");
                spell_id = 0;
            }

            if (quick_fight == QuickFight.False)
            {
                ovr025.RedrawCombatScreen();
                gbl.focusCombatAreaOnPlayer = true;
                gbl.display_hitpoints_ac = true;

                ovr033.RedrawCombatIfFocusOn(true, 3, player);
                ovr025.CombatDisplayPlayerSummary(player);
            }

            if (spell_id > 0)
            {
                sbyte delay = (sbyte)(gbl.spellCastingTable[spell_id].castingDelay / 3);

                if (delay == 0)
                {
                    ovr023.sub_5D2E1(true, quick_fight, spell_id);

                    casting_spell = true;
                    ovr025.clear_actions(player);
                }
                else
                {
                    casting_spell = true;
                    ovr025.DisplayPlayerStatusString(true, 10, "Begins Casting", player);

                    player.actions.spell_id = spell_id;

                    if (player.actions.delay > delay)
                    {
                        player.actions.delay = delay;
                    }
                    else
                    {
                        player.actions.delay = 1;
                    }
                }
            }
        }