[engine] Add filters for attack_ and defense_weight

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
User avatar
WhiteWolf
Forum Regular
Posts: 470
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

[engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » January 27th, 2019, 6:28 pm

Hello,

I'll start with the reasoning:
In many UMC's, including mine, there are a couple of custom weapon specials that work through events, and behave differently with different enemy units.(the variations are endless).
Arming the player with such weapon specials is fine, because the player will know when to use them effectively.
However, there is currently no way (or at least that I know of) to tell the AI that against a certain unit this attack should be used, because the weapon special will be devastating.
There is attack_ and defense_weight, but it is universal, regardless of the specific enemy.

So my suggestion is to change attack_ and defense_weight from being attributes to new tags, where a [filter_opponent] is available.

Code: Select all

[attack]
    # some attack
    [modifications]
        {SOME_CUSTOM_SPECIAL}
    [/modifications]
    [attack_weight]
        [filter_opponent] # let's say don't use it against trolls
            race=troll
        [/filter_opponent]
        value=0
    [/attack_weight]
    [attack_weight]
        [filter_opponent] # but is really favourable against the undead
            race=undead
        [/filter_opponent]
        value=5
    [/attack_weight]
    [attack_weight]
        [filter_opponent] # again not so favourable against very damaged units for I don't know what reason this is just an example
            formula=hitpoints < 10
        [/filter_opponent]
        value=0.2
    [/attack_weight]
	# same could be done with a [defense_weight] tag
Maybe even make [filter_self] available? This could allow more a much more complex and precise AI play, where not only the player but the AI as well can use custom weapon specials effectively.
Opinions?
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
Ravana
Moderator
Posts: 2061
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Ravana » February 3rd, 2019, 2:01 pm

There is reason to believe that nonzero attack_weight is ignored viewtopic.php?p=638187#p638187.

User avatar
WhiteWolf
Forum Regular
Posts: 470
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 5th, 2019, 12:45 pm

Ravana wrote:
February 3rd, 2019, 2:01 pm
There is reason to believe that nonzero attack_weight is ignored viewtopic.php?p=638187#p638187.
Well, that explains the odd behaviour I've been experiencing at times with this attribute.
But it's completely misleading in the wiki then. Is this intended and will stay this way, or will this be fixed at some point?
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
octalot
Code Contributor
Posts: 305
Joined: July 17th, 2010, 7:40 pm

Re: [engine] Add filters for attack_ and defense_weight

Post by octalot » February 5th, 2019, 1:28 pm

Not the answer to WhiteWolf's question, but I just fixed the 'wiki is misleading' bit.

User avatar
Ravana
Moderator
Posts: 2061
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Ravana » February 5th, 2019, 5:17 pm

It has not been reported as issue so far.

User avatar
Celtic_Minstrel
Developer
Posts: 1447
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 19th, 2019, 4:12 am

I reported it as #3923.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

gfgtdf
Developer
Posts: 1153
Joined: February 10th, 2013, 2:25 pm

Re: [engine] Add filters for attack_ and defense_weight

Post by gfgtdf » February 19th, 2019, 1:19 pm

I think it'd be better to allow formula/Lua expressions in attack_weight. this is not only more flexible, it also avoids problems like "what should we do when multiple of those match"
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
Celtic_Minstrel
Developer
Posts: 1447
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 20th, 2019, 2:45 am

I'm not quite sure what you mean, but I'm against allowing attack_weight="(formula here)" - if you want or need that, just use formula="formula here" instead. If you're adding keys to the weapon filter to check attack and defense weight though, you certainly can't make do with just two keys. You'd probably want at least four, maybe six - attack_weight= (exact match), attack_weight_at_least=, attack_weight_at_most=, and likewise for defense weight (names can be changed, of course).
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

gfgtdf
Developer
Posts: 1153
Joined: February 10th, 2013, 2:25 pm

Re: [engine] Add filters for attack_ and defense_weight

Post by gfgtdf » February 20th, 2019, 5:10 am

Celtic_Minstrel wrote:
February 20th, 2019, 2:45 am
I'm not quite sure what you mean, but I'm against allowing attack_weight="(formula here)" - if you want or need that, just use formula="formula here" instead.
This is about allowing the already existing [attacks]attack_weight key to accept formula,I don't see how the could be done with the current formula= key .
Celtic_Minstrel wrote:
February 20th, 2019, 2:45 am

If you're adding keys to the weapon filter to check attack and defense weight though, you certainly can't make do with just two keys. You'd probably want at least four, maybe six - attack_weight= (exact match), attack_weight_at_least=, attack_weight_at_most=, and likewise for defense weight (names can be changed, of course).
I don't intend to change filters.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
Celtic_Minstrel
Developer
Posts: 1447
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 20th, 2019, 5:39 am

Ah, I see what you mean now, but... I don't get what the use of that would be?

Also, can you please explain this?
gfgtdf wrote:
February 19th, 2019, 1:19 pm
it also avoids problems like "what should we do when multiple of those match"
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
WhiteWolf
Forum Regular
Posts: 470
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 20th, 2019, 9:20 am

Celtic_Minstrel wrote:
February 20th, 2019, 5:39 am
Ah, I see what you mean now, but... I don't get what the use of that would be?

Also, can you please explain this?
gfgtdf wrote:
February 19th, 2019, 1:19 pm
it also avoids problems like "what should we do when multiple of those match"
I think we're talking about:

Code: Select all

[attack_weight]
    [filter_opponent]
        race=troll
    [/filter_opponent]
    value=5
[/attack_weight]
[attack_weight]
    [filter_opponent]
        [not]
            level=1,0
        [/not]
    [/filter_opponent]
    value=1.5
[/attack_weight]
... and we are attacking a level 2 troll, so both filters match. Right, I did not think of this when making the first proposition. Unless you specifically negate other cases with [not]'s in all other filters, multiple matches could be quite a common issue actually.

One proposition, if I understood correctly, is to not only have the value key, but also something like value_min and value_max. So if there is a conflict between a value and a value_min, then if value < value_min then the value_min is applied, and if value >= value_min then value is applied. And with likewise logics for all other cases.
It gives us the ability to avoid conflicts, but doesn't necessarily stop them from appearing (what if the designer doesn't use them, only value?). So yes, this is hardly resolved.

Allowing formulas could be one way to do this.

Code: Select all

attack_weight=if(level > 1, 5, if(...))
Here if I understand correctly, even if any else brach would match, always the first matching then branch is applied, which resolves ambiguity.
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
Celtic_Minstrel
Developer
Posts: 1447
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 21st, 2019, 4:26 am

I see, somehow I missed (or didn't properly read) the original post. Certainly a formula might be preferable to changing the weighting to a tag... so what would the formula be called on? The weapon? That's clearly not what you're expecting, at least. The weapon's owner? The battle context, containing both opponents and their chosen weapon is probably the ideal here...

And if you're adding formula support to attack weight and defense weight, you might want to think about why (or if) they should be special. What about formulas for damage, number of strikes, etc?
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
Ravana
Moderator
Posts: 2061
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Ravana » February 21st, 2019, 7:04 am

There is formula support for strikes at least.

User avatar
WhiteWolf
Forum Regular
Posts: 470
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 21st, 2019, 9:03 am

Celtic_Minstrel wrote:
February 21st, 2019, 4:26 am
The battle context, containing both opponents and their chosen weapon is probably the ideal here...
Exactly what I think. Note however, I haven't got a clue about just exactly how difficult it would be to implement it in the engine.
And if you're adding formula support to attack weight and defense weight, you might want to think about why (or if) they should be special. What about formulas for damage, number of strikes, etc?
Without further thinking, I think it would be a nice addition, but maybe unnecessary: The original reasoning was custom weapon specials, and [damage] and [attacks] weapon specials can already access and modify these values, and also have the appropriate filters at their disposal. The weighting however can't be accessed through the specials in this way.
Ravana wrote:
February 21st, 2019, 7:04 am
There is formula support for strikes at least.
It's not in the wiki. Does it simply work like this?

Code: Select all

[attack]
    number="formula here"
[/attack]
If yes, I'll add this to the wiki then.
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
Celtic_Minstrel
Developer
Posts: 1447
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 21st, 2019, 2:02 pm

If it works I assume it would be:

Code: Select all

[attack]
    number="(formula here)"
[/attack]
Note the extra set of parentheses around the formula, which is used to signal to the engine that it is a formula rather than just a number. This is always needed when placing a formula in a key that normally just takes a value. If it does work here, I wonder what the "self" is though... the attack? The unit? The battle context as I mentioned above?

So anyway, what you're saying is that if the weighting could be accessed through specials, then you wouldn't need this feature? I suppose the [disable] special could always be extended to allow setting the weights to something other than 0... not sure if that would interfere with its functioning though.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply