Implementing "Formation" from UtBS

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
WhiteWolf
Forum Regular
Posts: 624
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Implementing "Formation" from UtBS

Post by WhiteWolf »

Cen7 wrote:
June 19th, 2020, 12:53 am
The only thing that has me stumped now is properly implementing the 70% limit. (I.e., defense will not exceed 70%, regardless of terrain and number of adjacent formation units.) I'm just not understanding the correct use of the filter code for these clauses:

Code: Select all

                        [filter_base_value]
                            greater_than=60 # or whatever value
                        [/filter_base_value]

I've experimented with different values, but all I've managed to do is to make the ability shut down after a certain point.
Because this is actually a bug in my own implementation as well, I just didn't notice it before, I thought it was working flawlessly. Thanks for the report :lol: So the mistake I made is that the base value filters should indeed increase in increments of the formation defense value (I forgot to change this from 40 and up).
The second is the issue of shutting down past 70% instead of capping out at 70%. The problem in the structure is that the instance that is activated is always the one with the most units, but if the capping filter is not met, then it is ignored (instead of reverting to the case of 1 adjacent unit less). I see multiple possible fixes, by either somehow reordering the [chance_to_hit] tag order, or by some clever combination of AND and OR's with the two conditions (base_value and number of adjacent units), or by adding more tags which filter for specific defense values and set the defense precisely at 70% (as suggested by Ravana). But I'm just guessing though, I didn't try or test anything yet. I will do it eventually, but not very soon I'm afraid (lack of free time nowadays) - so it's likely that if you experiment and try to fix it yourself, you'll finish sooner ;)
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!

Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Re: Implementing "Formation" from UtBS

Post by Cen7 »

Wow! Yeah, newfrenchy83's code works. I just substituted it in, and I no longer have the original problem. I tried testing it in a few different contexts, and it correctly caps out the defensive bonus at 70%.

Please don't anyone take this the wrong way, because you are helping me with code that, frankly, I can hardly follow. There seems to be a new problem, in that formation ability now also affects magical attacks, which was not intended. It's hard to predict just how. For example, putting a formation unit on a keep with one or two neighbors, and an attacker's magical attack drops from 70% to 60%, no lower. On the other hand, put a formation unit in shallow water and surround it with three formation fellows, and I can drop a magical attacker's percentage all the way down to 40%!
Attachments
2p — Aethermaw Turn 7.gz
(65.65 KiB) Downloaded 18 times

newfrenchy83
Code Contributor
Posts: 77
Joined: October 6th, 2017, 12:57 pm

Re: Implementing "Formation" from UtBS

Post by newfrenchy83 »

for resolve formation affect magical atttacjs then what it is not that what you intended use this

Code: Select all

 [chance_to_hit]
                        id=formation_enemy_1
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=40
                        [/filter_base_value]
                        [filter_self]
                        [filter_weapon]
                            [not]
                                special_id=magical
                            [/not]
                        [/filter_weapon]
                        [/filter_self]
                        [filter_opponent]
                            ability=formation
                          
                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=1-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    

Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Re: Implementing "Formation" from UtBS

Post by Cen7 »

Great! I was just getting back to this problem and thinking that a filter for "magical" right up front was the solution, just uncertain of the correct way to code it. I will try this. :D

newfrenchy83
Code Contributor
Posts: 77
Joined: October 6th, 2017, 12:57 pm

Re: Implementing "Formation" from UtBS

Post by newfrenchy83 »

you can replace special_id or special_type by special_id_active or special_type_active if you want what filter applied what when special is active( magical is anytime but is not case for marksman(active in offense only))

Code: Select all

[not]
                                special_id_active=magical
                            [/not]

Post Reply