public bool PacketCreate()
    {
        if (!WieldBestItem())
        {
            return(false);
        }

        if (GameSystems.D20.D20Query(obj, D20DispatcherKey.QUE_Critter_Is_Afraid))
        {
            var fearedObj = GameSystems.D20.D20QueryReturnObject(obj, D20DispatcherKey.QUE_Critter_Is_Afraid);
            target        = fearedObj;
            aiFightStatus = GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FLEEING, fearedObj, ref soundMap);
            return(true);
        }

        // select heal spell & target from: self, leader, leader's followers
        if (SelectHealSpell())
        {
            return(true);
        }

        if (!LookForEquipment())
        {
            FightStatusUpdate();
        }

        return(true);
    }
    public void FleeingStatusRefresh()
    {
        var objBody     = obj;
        var fleeingFrom = objBody.GetObject(obj_f.critter_fleeing_from);

        if (fleeingFrom == null ||
            GameSystems.Critter.IsDeadNullDestroyed(fleeingFrom) ||
            GameSystems.Critter.IsDeadOrUnconscious(fleeingFrom))
        {
            aiFightStatus = GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.NONE, null);
        }
    }
    public void FightStatusUpdate()
    {
        if (GameSystems.Critter.IsSleeping(obj))
        {
            return;
        }
        GameObject focus = null;

        switch (aiFightStatus)
        {
        case AiFightStatus.FINDING_HELP:     // for AI with scout points
            focus = ConsiderCombatFocus();
            if (focus != null)
            {
                target = focus;
                if (!ScoutPointSetState())
                {
                    aiFightStatus =
                        GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
                    return;
                }

                break;
            }

            // slide into next case if focus == null
            goto case AiFightStatus.NONE;

        case AiFightStatus.NONE:
            focus = GameSystems.AI.FindSuitableTarget(obj);
            if (focus != null)
            {
                target = focus;
                if (HasScoutStandpoint())
                {
                    ScoutPointSetState();
                    aiFightStatus =
                        GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
                    return;
                }

                ChooseRandomSpell_RegardInvulnerableStatus();
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
            }

            break;

        case AiFightStatus.FIGHTING:
            focus = ConsiderCombatFocus();
            if (focus != null)
            {
                target = focus;
                ChooseRandomSpell_RegardInvulnerableStatus();
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
                return;
            }

            focus  = obj.GetObject(obj_f.npc_who_hit_me_last);
            target = focus;
            if (GameSystems.AI.ConsiderTarget(obj, focus))
            {
                ChooseRandomSpell_RegardInvulnerableStatus();
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
                return;
            }

            focus  = PickRandomFromAiList();
            target = focus;
            if (focus == null)
            {
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.NONE, null, ref soundMap);
                return;
            }

            ChooseRandomSpell_RegardInvulnerableStatus();
            aiFightStatus =
                GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.FIGHTING, target, ref soundMap);
            return;

        case AiFightStatus.FLEEING:
            if (target == null)
            {
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.NONE, null, ref soundMap);
            }
            break;

        case AiFightStatus.SURRENDERED:
            if (GameSystems.Critter.GetHpPercent(obj) >= 80 && GameSystems.Random.GetInt(1, 500) == 1)
            {
                aiFightStatus =
                    GameSystems.AI.UpdateAiFlags(obj, AiFightStatus.NONE, null, ref soundMap);
            }

            break;

        default:
            return;
        }
    }