Comment 9 for bug 1794959

Revision history for this message
kaputtnik (franku) wrote : Re: Scripting attack bans between players

In the scenario i am working on i have implemented a prevent_attack function. This uses just the field_action window and checks if the attack button is there. Whenever a player clicks on an attackable building a warning is shown:

function prevent_attack()
    local warn_level = 1
    while true do
        local w = wl.ui.MapView().windows.field_action
        if w and w.buttons.attack then
            print("Attacking not allowed!")
            if warn_level < 2 then
                campaign_message_box(no_attack_01)
                warn_level = warn_level + 1
            elseif warn_level < 3 then
                campaign_message_box(no_attack_02)
                warn_level = warn_level + 1
            elseif warn_level < 5 then
                campaign_message_box(no_attack_03)
                warn_level = 1
            end
            w:close()
        end
        sleep(100)
    end
end

This works just nicely and shows a dialog to the player which covers the field_action window. I use three warning levels here: On first show warning1 on second click warning2 and so on. I think such thing could also be adapted to show the warning when clicking on an attackable building of a specific player.