[engine] Add filters for attack_ and defense_weight

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

Moderator: Forum Moderators

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

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf »

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. :)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Ravana
Forum Moderator
Posts: 2950
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Ravana »

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: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel »

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.
Former maintainer of Steelhive.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf »

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 :(
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel »

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.
Former maintainer of Steelhive.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf »

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.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [engine] Add filters for attack_ and defense_weight

Post by Celtic_Minstrel »

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.
Former maintainer of Steelhive.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Add filters for attack_ and defense_weight

Post by WhiteWolf »

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?
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Post Reply