[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: 473
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 21st, 2019, 4:25 pm

It doesn't seem to work.
Whatever the formula, the number of attacks is always 0. At first I was experimenting with attributes of the self variable - do note that there was never a crash or a warning of trying to access non-existent stuff, but the number of attacks was always 0.
Then I tried this trivial stuff as in the attachment in the spoiler, and still 0. Regardless of extra ""-s or ()-s.
(This is on 1.14.5 on Debian)
example:
Celtic_Minstrel wrote:
February 21st, 2019, 2:02 pm
So anyway, what you're saying is that if the weighting could be accessed through specials, then you wouldn't need this feature?
I guess so. Provided that the specials tag has access to [filter_opponent] and [filter_self].
I mean, it's suitable for my case - to help the AI choose weapons enhanced with custom weapon specials:
The macro of the special could consist of the tag(s) that's doing the actual effects, and next to it a tag, an enhanced disable then?... to modify the attack_weight and defense_weight if different filters match.

There is still the question of multiple matches then, but I think that's solved with the specials? I mean for example I can already put in as many non-cumulative [damage]'s as I want, and have half of them match at the same time. I think the first match is applied and the rest is ignored? Or the other way around, the last is on and the others are ignored, I'm not sure now, but the point is that there's a fixed approach.

In conclusion yes, if there was a specials tag that could modify weighting and had access to filters, that would also be a satisfactory solution. :)
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: 2064
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, 4:50 pm

I use calculated strikes amount as https://github.com/ProditorMagnus/Agele ... rn.cfg#L35

(Use base value of 0 and add instead of multiply for some use cases)

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

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 22nd, 2019, 1:04 am

Ah, I see, Ravana is talking about something different — formulas in weapon special keys. That was added for 1.14, yes, but in [attack] directly it won't work.

If [disable] were allowed to change an attack's weighting arbitrarily, the final weighting would most likely be some form of cumulation of all [disable] specials, similar to how it's done for other specials like [damage]. If I recall correctly, that means:
  1. The last special with value= wins.
  2. After that, all specials with multiply= or divide= are applied.
  3. Then all specials with add= and sub= are applied.
I might have the order wrong for the last two, not quite sure, but suffice to say it's not as simple as just taking the first or last matching one. Maybe there's also a cumulative= key? Or one could be added to [disable] specifically.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

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

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 22nd, 2019, 11:44 am

Yes, I misunderstood then.
I'd like to note, that it still wasn't in the wiki that formulas are accepted there, it is now. :)
Celtic_Minstrel wrote:
February 22nd, 2019, 1:04 am

If [disable] were allowed to change an attack's weighting arbitrarily, the final weighting would most likely be some form of cumulation of all [disable] specials, similar to how it's done for other specials like [damage]. If I recall correctly, that means:
  1. The last special with value= wins.
  2. After that, all specials with multiply= or divide= are applied.
  3. Then all specials with add= and sub= are applied.
It's what I meant, that there exists a fixed approach, and there won't be any ambiguity. A cumulative might also make sense in this context, just as well as it does with [damage].

I still have no idea what is easier to implement - make weighting accept formulas, or allow [disable] to access weighting and filters :(
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: 1449
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 22nd, 2019, 1:39 pm

I clarified the requirement of enclosing parentheses, but... I'm not sure if that was the best place to put this. It likely also works in swarm_attacks_max for example (I haven't tested though), and it works in special abilities as well, not just weapon specials.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

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

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 22nd, 2019, 2:33 pm

Hmm, is it safe to declare that all keys that expect a numeric value accept formula's as well? If that's the case, then this statement could go into the header.
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: 1449
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel » February 23rd, 2019, 4:33 am

In abilities and weapon specials, I believe it's indeed the case that any key that expects a numeric value can also take a formula enclosed in parentheses. However, I'm not 100% certain of this, so maybe check with gfgtdf or something. In theory, even non-numeric keys could accept a formula if we wanted to implement that (though I don't think it'd be much use for enumerative keys).
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

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

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf » February 27th, 2019, 5:57 pm

gfgtdf says he knows of no exceptions, so I edited the wiki accordingly. I placed the note on formulas into the "headers" of the ability and special keys.

Returning to the original topic - would it then be possible in the near or not-so near future to implement the feature for [disable] to access weighting?
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!

Post Reply