Implementing "Formation" from UtBS

The place to post your WML questions and answers.

Moderator: Forum Moderators

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.
Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Implementing "Formation" from UtBS

Post by Cen7 »

I’m trying to implement the Formation ability from Under the Burning Sun on a custom unit I have inserted into the A New Land Era. (Formation adds +10% defense for each adjacent unit with the Formation ability.) From the UtBS folders, I’ve copied the code for #define SPECIAL_NOTES_FORMATION, #define ABILITY_FORMATION, and #define ABILITY_FORMATION_EVENTS. The first two are working fine: the unit will display with this ability and say what the ability is, but the event is not working: there is no change in defense for adjacent formation units.

I am probably missing something basic to make the game engine “see” the event, but my understanding of WML is sufficiently limited that I don’t know what. I notice that UtBS _main includes the code

Code: Select all

 [+campaign]
    {ABILITY_FORMATION_EVENTS}
[/campaign]
(And obviously, there’s a lot more than just that between the [campaign] tags, but I’m pretty confident this is all that relates to my formation problem.)

Is this something I need to do? If so, where would I put it?

(I’m feeling sure there’s no problem with the event coding, itself, as I did a simple cut-and-paste from UtBS. I’m happy to post the entire code here, but it’s long and didn’t seem relevant to the problem. I get no error messages. Using BfW version 1.14.7.)
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Implementing "Formation" from UtBS

Post by Ravana »

You can use [inspect] (:inspect) to check if game knows about your event.
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Implementing "Formation" from UtBS

Post by beetlenaut »

You should note that formation only works for side 1 the way it is currently written. If you are trying to use it on a different side, that would explain your trouble.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Re: Implementing "Formation" from UtBS

Post by Cen7 »

beetlenaut wrote: May 21st, 2020, 9:44 pm You should note that formation only works for side 1 the way it is currently written. If you are trying to use it on a different side, that would explain your trouble.
I haven’t thought about it, but nearly all of my tests were as side 1. Just for thoroughness, I tested with the unit on side 2, and still no luck.

I had noticed that filter in the UtBS formation event code and wondered about it. In the campaign, itself, one scenario has units with formation on both sides (i.e., other than just on side 1). I’ve not looked at it closely, but I assumed formation worked for the other side as well as the player’s side.
The bottom line, though, this doesn’t appear to explain the problem, as formation is not working even with units on side 1.

I have tried the inspect command, in debug mode. Looking at events, there’s nothing for formation there, so yeah, the game doesn’t know about this event. Why not – or how do I get the game to notice this event?
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Implementing "Formation" from UtBS

Post by beetlenaut »

Cen7 wrote: May 21st, 2020, 10:27 pm Looking at events, there’s nothing for formation there, so yeah, the game doesn’t know about this event.
If you can't figure out why, it's probably time to post the campaign. It's no fun for us to try to guess where the problem might be.
Cen7 wrote: May 21st, 2020, 10:27 pm I had noticed that filter in the UtBS formation event code and wondered about it. In the campaign, itself, one scenario has units with formation on both sides (i.e., other than just on side 1).
The way formation works is by modifying all the enemy units, not by changing the units that actually have the ability. Maybe that's what you saw on the other sides. Unless something has changed recently, there isn't a scenario with formation units on the other side.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Implementing "Formation" from UtBS

Post by gnombat »

beetlenaut wrote: May 21st, 2020, 10:54 pm there isn't a scenario with formation units on the other side.
What about Tanstafaal's side?

tanstafaal.png
tanstafaal.png (105.3 KiB) Viewed 2391 times
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Implementing "Formation" from UtBS

Post by beetlenaut »

gnombat wrote: May 22nd, 2020, 11:30 pm What about Tanstafaal's side?
I stand corrected. I completely forgot the rebel elves. But still, if you check, you will find that formation doesn't work for them.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Implementing "Formation" from UtBS

Post by WhiteWolf »

Not sure if it helps, but I too have a formation implementation, which works fine for any side, not just side 1. Note that it is reduced to a 5% defense increase though, but that should be easy enough to tweak where you want it.
Formation implementation:
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
Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Re: Implementing "Formation" from UtBS

Post by Cen7 »

beetlenaut wrote: May 23rd, 2020, 3:46 am
gnombat wrote: May 22nd, 2020, 11:30 pm What about Tanstafaal's side?
I stand corrected. I completely forgot the rebel elves. But still, if you check, you will find that formation doesn't work for them.
Yeah, Beetlenaut is correct: although Tanstafaal's side has formation units, I checked after reading his comment, and sure enough, two units with formation standing side-by-side get no formation boost. So the built-in code does indeed work as advertised.

White Wolf: that looks great, thanks! I will have to try it. :D
nenau
Posts: 114
Joined: May 12th, 2017, 5:46 pm

Re: Implementing "Formation" from UtBS

Post by nenau »

Just being curious : is there any project for adding `[chance_to_hit]` to the `[abilities]` tag ?
That would ease things a lot since UtBs is mainline.
And by the way, that could correct the main problem of this ability (at least last time I tried it) which is that one does not see the defence bonus when moving units.
newfrenchy83
Code Contributor
Posts: 165
Joined: October 6th, 2017, 12:57 pm

Re: Implementing "Formation" from UtBS

Post by newfrenchy83 »

nenau wrote: May 28th, 2020, 5:13 am Just being curious : is there any project for adding `[chance_to_hit]` to the `[abilities]` tag ?
That would ease things a lot since UtBs is mainline.
Yes, it is exist already in 1.15.3.
nenau wrote: May 28th, 2020, 5:13 am And by the way, that could correct the main problem of this ability (at least last time I tried it) which is that one does not see the defence bonus when moving units.
NO, the defense bonus in map don't use abilities or weapon specials in calculation, but terrain only, too coimplex to implement this, and too many calculation for CPU.
Cen7
Posts: 15
Joined: February 2nd, 2020, 11:16 pm

Re: Implementing "Formation" from UtBS

Post by Cen7 »

WhiteWolf wrote: May 24th, 2020, 2:37 pm Not sure if it helps, but I too have a formation implementation, which works fine for any side, not just side 1. Note that it is reduced to a 5% defense increase though, but that should be easy enough to tweak where you want it.
Formation implementation:
So . . . I had a few mis-steps trying to implement this code but finally did get it working. :D I've also successfully modified it to make the increments 10% rather than 5%. 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. Tried solving the problem by referring to the corresponding UtBS code (which uses a greater_than_equal_to argument, instead) without success. What I get is defenses going beyond the 70% mark (up to 90%) and/or shutting off completely at some point. For example, a formation unit may be on 60% terrain; adding one formation unit increases defense to 70%, but then adding another and any additional formation units drops defense back to 60%, as if the formation ability were turned off.

How is this piece of code supposed to work? I thought it should be a reference to the attacker's starting chance_to_hit, whether before the current iteration of formation or any formation iterations, yet if that were the case, we'd just use the same value all the way along, instead of altering it with each iteration. You have me puzzled, and I hope my explanation makes sense.

(Still, having even a mostly-working formation ability is a huge step forward for me!)
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Implementing "Formation" from UtBS

Post by Ravana »

Once you get ability shut down past certain point, have ability which sets cth to constant value instead of add/sub.
newfrenchy83
Code Contributor
Posts: 165
Joined: October 6th, 2017, 12:57 pm

Re: Implementing "Formation" from UtBS

Post by newfrenchy83 »

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_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=1-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_2
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=50
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=2-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_3
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=60
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=3-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_4
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=70
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=4-5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [chance_to_hit]
                        id=formation_enemy_5
                        name=""
                        description=""
                        sub=10
                        [filter_base_value]
                            greater_than_equal_to=80
                        [/filter_base_value]
                        [filter_opponent]
                            ability=formation

                            [filter_adjacent]
                                ability=formation
                                is_enemy=no
                                count=5
                            [/filter_adjacent]
                        [/filter_opponent]
                    [/chance_to_hit]
formation ability work with original code? all sub must be have same value and count=value-5 for that value cumul
newfrenchy83
Code Contributor
Posts: 165
Joined: October 6th, 2017, 12:57 pm

Re: Implementing "Formation" from UtBS

Post by newfrenchy83 »

witht that when value lowest than 70 but greaterof 60 with count=4 the value of cth for count=3-5(3 or 4 or 5) and lowest are applied else, the code is too rigid and you must be have greater_than_equal_to=60 AND count=3(not 2, nor 4 but 3) for condition was matched.
Post Reply