Implementing "Formation" from UtBS
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.
Implementing "Formation" from UtBS
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
(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.)
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]
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.)
Re: Implementing "Formation" from UtBS
You can use [inspect] (:inspect) to check if game knows about your event.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Implementing "Formation" from UtBS
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
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Implementing "Formation" from UtBS
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.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 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?
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Implementing "Formation" from UtBS
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.
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
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Implementing "Formation" from UtBS
What about Tanstafaal's side?beetlenaut wrote: ↑May 21st, 2020, 10:54 pm there isn't a scenario with formation units on the other side.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Implementing "Formation" from UtBS
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
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Implementing "Formation" from UtBS
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
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
Re: Implementing "Formation" from UtBS
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.beetlenaut wrote: ↑May 23rd, 2020, 3:46 amI stand corrected. I completely forgot the rebel elves. But still, if you check, you will find that formation doesn't work for them.
White Wolf: that looks great, thanks! I will have to try it.
Re: Implementing "Formation" from UtBS
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.
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.
My campaign : Pax Romana : The Rise of Vespasian
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: Implementing "Formation" from UtBS
Yes, it is exist already in 1.15.3.
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.
Re: Implementing "Formation" from UtBS
So . . . I had a few mis-steps trying to implement this code but finally did get it working. 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!)
Re: Implementing "Formation" from UtBS
Once you get ability shut down past certain point, have ability which sets cth to constant value instead of add/sub.
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: Implementing "Formation" from UtBS
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]
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: Implementing "Formation" from UtBS
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.