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.
Post Reply
Cen7
Posts: 6
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: 2427
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: 2427
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: 6
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: 2427
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: 278
Joined: June 10th, 2010, 8:49 pm
Contact:

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 735 times

User avatar
beetlenaut
Developer
Posts: 2427
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 Regular
Posts: 617
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:
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: 6
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: 113
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: 71
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.

Post Reply