Beispiel #1
0
void __fastcall GameScreenRClickEvent(Event *event)
{
    if (IsOutsideGameScreen(event->x, event->y) || bw::client_selection_group2[0] == nullptr)
        return;
    Unit *highest_ranked = bw::selection_rank_order[0];
    if (highest_ranked == nullptr || !CanControlUnit(highest_ranked))
        return;

    unsigned i;
    for (i = 0; i < Limits::Selection; i++)
    {
        Unit *unit = bw::client_selection_group[i];
        if (unit == nullptr)
            return;
        if (unit->DoesAcceptRClickCommands())
            break;
    }
    if (i == Limits::Selection)
        return;

    int x = event->x + *bw::screen_x;
    int y = event->y + *bw::screen_y;
    Unit *target = FindUnitAtPoint(x, y);
    if (target == highest_ranked && *bw::client_selection_count == 1)
    {
        if (~highest_ranked->flags & UnitStatus::Building)
            return;
        if (!highest_ranked->HasRally())
            return;
    }
    else if (target == nullptr)
    {
        for (i = 0; i < Limits::Selection; i++)
        {
            Unit *unit = bw::client_selection_group[i];
            if (unit == nullptr)
                return;
            if (unit->CanRClickGround())
                break;
        }
        if (i == Limits::Selection)
            return;
    }
    if (target == nullptr)
    {
        Sprite *fow = ShowCommandResponse(x, y, 0);
        if (fow)
            SendRightClickCommand(0, x, y, fow->index, *bw::is_queuing_command);
        else
            SendRightClickCommand(0, x, y, Unit::None, *bw::is_queuing_command);
    }
    else
    {
        ShowCommandResponse(x, y, target->sprite);
        SendRightClickCommand(target, x, y, Unit::None, *bw::is_queuing_command);
    }

    if (ShowRClickErrorIfNeeded(target) == 1)
        PlayYesSoundAnim(highest_ranked);
}
Beispiel #2
0
void __fastcall GameScreenLClickEvent_Targeting(Event *event)
{
    if (IsOutsideGameScreen(event->x, event->y))
        return;

    int x = event->x + *bw::screen_x;
    int y = event->y + *bw::screen_y;
    Unit *target = FindUnitAtPoint(x, y);
    Sprite *fow;
    if (!target)
        fow = ShowCommandResponse(x, y, 0);
    else
        fow = ShowCommandResponse(x, y, target->sprite);

    if (fow)
        DoTargetedCommand(x, y, target, fow->index);
    else
        DoTargetedCommand(x, y, target, Unit::None);

    SetCursorSprite(0);
}
static Unit * __stdcall FindUnitAtPoint_Hook(int x, int y)
{
    return FindUnitAtPoint(x, y);
}