Adding combat capabilities

Post Reply
RLO92
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Sun Feb 05, 2017 6:15 pm

Adding combat capabilities

Post by RLO92 »

Hello,

I've read in the respective Squadfiles- Threat that it is indeed possible to add combat capabilities in the squads.bsf
However it is not described what exact other files (except the combattools.bsf, which I am aware of) I do need to respect.
May I receive a brief advice what the corresponding files are?

Thanks in advance.

Greetings,
RLo
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28084
Joined: Sun Dec 04, 2005 6:25 pm

Re: Adding combat capabilities

Post by rbodleyscott »

RLO92 wrote: Wed Feb 01, 2023 3:03 pm Hello,

I've read in the respective Squadfiles- Threat that it is indeed possible to add combat capabilities in the squads.bsf
However it is not described what exact other files (except the combattools.bsf, which I am aware of) I do need to respect.
May I receive a brief advice what the corresponding files are?

Thanks in advance.

Greetings,
RLo
There would be several of them.

At least:

CombatTools.BSF
UITools.BSF

If it is a missile capability, also:

Trigger.BSF
UnitInfoPop.bsf

But there may be others. I found the above by looking for "Swordsmen" and "Bow"
Richard Bodley Scott

Image
RLO92
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Sun Feb 05, 2017 6:15 pm

Re: Adding combat capabilities

Post by RLO92 »

There would be several of them.

At least:

CombatTools.BSF
UITools.BSF

If it is a missile capability, also:

Trigger.BSF
UnitInfoPop.bsf

But there may be others. I found the above by looking for "Swordsmen" and "Bow"
Thank you very much.
I also found by looking through the files there is the Init.BSF which adds the attribute in the first place. No idea if that is necessary.

Another question: Is it possible to raise the cumulated maximum number of available units in the roster of the armylist above 256?
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28084
Joined: Sun Dec 04, 2005 6:25 pm

Re: Adding combat capabilities

Post by rbodleyscott »

RLO92 wrote: Wed Feb 01, 2023 5:59 pm I also found by looking through the files there is the Init.BSF which adds the attribute in the first place. No idea if that is necessary.
Not if they are in the Squads file.
Another question: Is it possible to raise the cumulated maximum number of available units in the roster of the armylist above 256?
Probably, although I can't immediately get my head around what would be required. It is such a long time since that part of the game was programmed. And it is past my thinking time for today.

However, why do you need more than 256 units in an army list? The lists contain troop numbers for 2000 points. If the points are higher the available number of unit scales up automatically.

If you can tell me exactly what you are trying to achieve, and where you have encountered the limit, I may be able to give you a more coherent answer.

And is it for Custom Battles or Campaigns?
Richard Bodley Scott

Image
RLO92
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Sun Feb 05, 2017 6:15 pm

Re: Adding combat capabilities

Post by RLO92 »

Probably, although I can't immediately get my head around what would be required. It is such a long time since that part of the game was programmed. And it is past my thinking time for today.

However, why do you need more than 256 units in an army list? The lists contain troop numbers for 2000 points. If the points are higher the available number of unit scales up automatically.

If you can tell me exactly what you are trying to achieve, and where you have encountered the limit, I may be able to give you a more coherent answer.

And is it for Custom Battles or Campaigns?
Thank you for your reply.

So I already increased the the maximum possible points to 6000. Which multiplies the MAX possible number per unittype by 3. Now we had around 20 different unittypes in the roster with some having a MAX possible number of 40 (all in all to ensure the most possible variety in choosing our army composition). Thats were I ended up with a big question mark, when suddenly some unittypes disappeared from the roster. I found out through testing, that the maximum number is 256 and everything beyond gets canceled.

Best regards
RLo

EDIT: it is for custom battles / Multiplayer
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28084
Joined: Sun Dec 04, 2005 6:25 pm

Re: Adding combat capabilities

Post by rbodleyscott »

The problem is in the AddFromArmyList() and AddUnitsToMap() functions in MapGenerate.BSF.

This function was written before proper programmer-defined arrays were added to the engine. It uses the old global work arrays 0, 1,and 2, which have only 256 elements each.

Hence the list of units has to be truncated to prevent it from exceeding the bounds of the array.

Hence line 634:

maxUnits = Min(maxUnits, 255);

(I don't recall why this is 255 and not 256)

In order to expand the maximum number of units allowed, you would need to completely rewrite the AddFromArmyList() and AddUnitsToMap() functions to use a larger global array. It would have to be global rather than local or the data created in AddFromArmyList() will not be available to the AddUnitsToMap() function.

e.g.

int gArrayName[2048][3];

Defined in globals.bsf

and rewrite all of the code in the two functions to use that instead of the built in work arrays.
Richard Bodley Scott

Image
RLO92
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Sun Feb 05, 2017 6:15 pm

Re: Adding combat capabilities

Post by RLO92 »

Thank you very much for your work. I appreciate your time put into is. Unfortunately by the first look it seems like this task is beyond my capabilities. I already failed finding the suggested line:
Hence line 634:

maxUnits = Min(maxUnits, 255);
The only line I could find which looks similar was:

maxUnits = ((GetMapWidth() - 32) * 2) + numFixed;

But I cannot see any correlation what so ever. Nor could i find the lines where it uses the global work arrays or how they are called.
I will try to dig into it when I have some time; but I feel like I won't be able to manage that.

Thank you very much.

Greetings
RLo

Edit:
(I don't recall why this is 255 and not 256)
Maybe because the 0 is the actual 1?
pipfromslitherine
Site Admin
Site Admin
Posts: 9719
Joined: Wed Mar 23, 2005 10:35 pm

Re: Adding combat capabilities

Post by pipfromslitherine »

The Min is because (assuming you are indexing into the work array) the values should be [0,255].

Cheers

Pip
follow me on Twitter here
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28084
Joined: Sun Dec 04, 2005 6:25 pm

Re: Adding combat capabilities

Post by rbodleyscott »

RLO92 wrote: Thu Feb 02, 2023 3:42 pmEdit:
(I don't recall why this is 255 and not 256)
Maybe because the 0 is the actual 1?
Yes, but the array indices being 0 to 255, rather than 1 to 256, does not change the fact that the array can hold a maximum of 256 units.
pipfromslitherine wrote: Thu Feb 02, 2023 4:44 pm The Min is because (assuming you are indexing into the work array) the values should be [0,255].

Cheers

Pip
Yes, I am of course aware of that.

But maxUnits isn't supposed to be the max index, it is supposed to be the max units allowed in the array, i.e. 256

Unless there is something in the rest of the code that treats it as the max index. In which case it is confusingly named.
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28084
Joined: Sun Dec 04, 2005 6:25 pm

Re: Adding combat capabilities

Post by rbodleyscott »

RLO92 wrote: Thu Feb 02, 2023 3:42 pm Thank you very much for your work. I appreciate your time put into is. Unfortunately by the first look it seems like this task is beyond my capabilities. I already failed finding the suggested line:
Hence line 634:

maxUnits = Min(maxUnits, 255);
The only line I could find which looks similar was:

maxUnits = ((GetMapWidth() - 32) * 2) + numFixed;
Ah yes, sorry, I was looking at the updated version for the forthcoming update on 16th Feb.

Anyway, the long and the short of it is that unless you can code enough to replace the old work arrays with new larger global arrays, you will not be able to mod these functions to allow more than 256 units.

I would also mention that there are almost certainly other things in the code that won't work correctly if you allow more units than have previously been allowed. In particular if you have more than ((GetMapWidth() - 32) * 2) units (in v1.5.40), because they won't be deployed correctly in temporary storage in the blacked out map border. This will be increased to ((GetMapWidth() - 16) * 4) units in v1.6.6
Richard Bodley Scott

Image
Post Reply

Return to “Field of Glory II: Modding”