Implement independent stance from every tribe to every other tribe

Bug #1794959 reported by Benedikt Straub on 2018-09-28
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Wishlist
Benedikt Straub

Bug Description

It should be possible to set via scripting that player x may/mustn't attack player y.
This will be necessary to fix an issue in the second frisian scenario (see also bug 1792478, #28).

Tags: lua Edit Tag help
TiborB (tiborb95) wrote :

This was discussed some time ago - perhaps putting the players into teams would do the trick... Might be available via LUA interface...

Benedikt Straub (nordfriese) wrote :

I´ve been using teams as a workaround in fri02, but they can´t work as desired there. It is necessary there that two players are enemies (different teams or teamless) while still unable to attack each other, and that p3 can attack p2 but p2 can´t attack p3. This can´t be implemented with the current team system.

TiborB (tiborb95) wrote :

Well if you look at:

https://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/ai/defaultai_warfare.cc#L167

you see that AI gets the information if building is attackable from the "core". If the response was "false" it would do the trick, though I am not sure how would AI cope with changed status of such building (when you decide to change it with LUA)...

But the bottom line is where your new information (who is attackable for whom) should be stored...

TiborB (tiborb95) wrote :

Well I can imagine new variable for Player class like: std::set no_attack_players and then AI (and UI for human player) could read and follow this... should not be complicated on AI's side

GunChleoc (gunchleoc) wrote :

We could have 3 states: enemy, ally, neutral. Neutral won't attack, but also not share the other player's vision.

TiborB (tiborb95) wrote :

But it would interfere with current team stuff.

What about new "pacifist" flag? He would never attack and would not interfere with team stuff.

But I am afraid, next request will be like: I want player A to be able to attack B who is in the same member, but not attack C who is in different team...

GunChleoc (gunchleoc) wrote :

Why would it interfere with the current team stuff? team = ally. What I'm proposing is that we keep teams and enemies as they are and add a 3rd state.

Benedikt Straub (nordfriese) wrote :

Implementing this as a third state would go both ways, wouldn´t it? If the "neutral" state was set so p2 can´t attack p3, then p3 won´t be able to attack p2.
IMHO the best way to solve this would be to have for each player individually a list of players he mustn´t attack. p1 can then attack p2 if and only if they are on different teams (or teamless) AND p2 is not on p1´s ban list.
So, all team-related stuff would be unchanged and the new feature is merely a way to override the ''attackable==true'' state between enemies.
Also, this would provide a way to account for every imaginable constellation of player relations, so there won´t be need to implement something again for other very special cases…

kaputtnik (franku) wrote :

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.

GunChleoc (gunchleoc) wrote :

So, you want the player to be able to attack the enemy, and the enemy can never retaliate, because the settings forbid it? Or would the other player automatically change their state after being attacked? The latter case sounds like a war declaration, in which case we would not need individual states, but some diplomacy UI instead.

Benedikt Straub (nordfriese) wrote :

@kaputtnik: That´s an elegant fix! Unfortunately it works only for human player, right? Since AI doesn´t use UI elements.
@GunChleoc: Yes, I want the Barbarians to be able to attack the Empire, but the Empire must be helpless unless I explicitly allow them to strike back, which would be the case if and only of the barbarians have conquered a sizeable number of buildings. (Checking that is as easy as checking for the number of "empire_*" militarysites the barbarians own.). I want to allow the Empire to reconquer buildings they have lost, but not much more than that; especially they must not defeat the barbarians.

ypopezios (ypopezios) wrote :

The tested (in other strategy games) solution is to have an independent stance from every tribe to every other tribe. Everything else is suboptimal.

GunChleoc (gunchleoc) wrote :

OK, independent stance it is, those are valid reasons :)

ypopezios (ypopezios) on 2018-09-30
Changed in widelands:
status: New → Triaged
summary: - Scripting attack bans between players
+ Implement independent stance from every tribe to every other tribe
Changed in widelands:
assignee: nobody → Benedikt Straub (nordfriese)
status: Triaged → In Progress
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers