Army Lists

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

Re: Army Lists

Post by rbodleyscott »

kronenblatt wrote: Tue Jul 29, 2025 7:25 am
rbodleyscott wrote: Tue Jul 29, 2025 7:22 am
kronenblatt wrote: Tue Jul 29, 2025 6:35 am There also seems to be a cap (256) to the total number of units that are loaded/shown for unit selection. All the unit types and their maximum numbers show fine in the army selection stage (see first picture below), but when having created the battle, at unit selection stage (see second picture) the interface only shows 256 units in total, cutting off in the order set in armylist.txt. (Please note the Nubian Archers cutoff: Nubian Archers is the 13th unit type in an army list of 21 unit types (each with a max of 20 units), so cuts them off at 16 units to sum up to 256 units in total, 12*20 + 16 = 256.)

Can this be altered or is it hardcoded?
Not exactly hardcoded, but the problem is that the game stores units prior to unit selection in the border of the map behind the player's table-edge. There simply aren't enough squares in the border to store unlimited number of units.
Aha, I see. So can't really be altered by me in any way? (I'd ideally like twice that amount, e.g., 512, or at least something around 400.)
Well you might be able to increase it somewhat.

Try altering MAX_BATTLE_UNITS in Macros.bsf until it falls over. I think 512 would probably be doable.

The absolute maximum (I think) would be 896 and then only if the playable map width isn't less than 32.
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4736
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Army Lists

Post by kronenblatt »

rbodleyscott wrote: Tue Jul 29, 2025 8:18 am
kronenblatt wrote: Tue Jul 29, 2025 7:25 am
rbodleyscott wrote: Tue Jul 29, 2025 7:22 am

Not exactly hardcoded, but the problem is that the game stores units prior to unit selection in the border of the map behind the player's table-edge. There simply aren't enough squares in the border to store unlimited number of units.
Aha, I see. So can't really be altered by me in any way? (I'd ideally like twice that amount, e.g., 512, or at least something around 400.)
Well you might be able to increase it somewhat.

Try altering MAX_BATTLE_UNITS in Macros.bsf until it falls over. I think 512 would probably be doable.

The absolute maximum (I think) would be 896 and then only if the playable map width isn't less than 32.
Tried 400 and 512, but unfortunately neither seems to work. :(
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28375
Joined: Sun Dec 04, 2005 6:25 pm

Re: Army Lists

Post by rbodleyscott »

kronenblatt wrote: Tue Jul 29, 2025 8:46 am
rbodleyscott wrote: Tue Jul 29, 2025 8:18 am
kronenblatt wrote: Tue Jul 29, 2025 7:25 am

Aha, I see. So can't really be altered by me in any way? (I'd ideally like twice that amount, e.g., 512, or at least something around 400.)
Well you might be able to increase it somewhat.

Try altering MAX_BATTLE_UNITS in Macros.bsf until it falls over. I think 512 would probably be doable.

The absolute maximum (I think) would be 896 and then only if the playable map width isn't less than 32.
Tried 400 and 512, but unfortunately neither seems to work. :(
It is probably because some of the functions involved make use of the system Array SetArray() and GetArray() functions which use the system array that only has 256 elements.

This could be got around by substituting a global array, but that might be a lot of work. (Which I don't really have time to do).
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4736
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Army Lists

Post by kronenblatt »

rbodleyscott wrote: Thu Jul 31, 2025 9:38 am
kronenblatt wrote: Tue Jul 29, 2025 8:46 am
rbodleyscott wrote: Tue Jul 29, 2025 8:18 am

Well you might be able to increase it somewhat.

Try altering MAX_BATTLE_UNITS in Macros.bsf until it falls over. I think 512 would probably be doable.

The absolute maximum (I think) would be 896 and then only if the playable map width isn't less than 32.
Tried 400 and 512, but unfortunately neither seems to work. :(
It is probably because some of the functions involved make use of the system Array SetArray() and GetArray() functions which use the system array that only has 256 elements.

This could be got around by substituting a global array, but that might be a lot of work. (Which I don't really have time to do).
That’s fine, Richard. I will work with what I have, in this case 256 units in each army list: good sometimes to have scarce resources. Thanks for having looked into this anyway! :)
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
RLO92
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 9
Joined: Sun Feb 05, 2017 6:15 pm

Re: Army Lists

Post by RLO92 »

Hey there,

me and my brother ran into the exact same problem. I already altered a lot of different variables in different files, including:
Macro.bsf
Slith_RandomMap2.bsf
Map_Generate.bsf
UI_Tools.bsf
Tools.bsf
Liaison_Tools.bsf
ForceSelectionTools.bsf
MPSShowArmyTools.bsf

Apparently, nothing did the job. The only thing I achieved was, when selecting Force Army Selection, that the excess units where still considered, although not being in the army list, since they got pushed out due to the 256 limit, which is reached pretty fast, especially when raising the maximum army points beyond 3000. And now I got to the limits of my very basic scripting skills and was glad I found this post in the forum.
Now, I understand, that you don't have the time to dig into this issue. Though you wrote, that it is not hardcoded and there might be a solution to it. Could you tell us, in what files to look or at least a crude direction how we could approach this issue. Imagine how awesome a battle with 8000 points or more would be.
Looking forward to your response. Thank you in advance.

Best regards
RLo
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28375
Joined: Sun Dec 04, 2005 6:25 pm

Re: Army Lists

Post by rbodleyscott »

RLO92 wrote: Fri Jan 02, 2026 11:36 am Hey there,

me and my brother ran into the exact same problem. I already altered a lot of different variables in different files, including:
Macro.bsf
Slith_RandomMap2.bsf
Map_Generate.bsf
UI_Tools.bsf
Tools.bsf
Liaison_Tools.bsf
ForceSelectionTools.bsf
MPSShowArmyTools.bsf

Apparently, nothing did the job. The only thing I achieved was, when selecting Force Army Selection, that the excess units where still considered, although not being in the army list, since they got pushed out due to the 256 limit, which is reached pretty fast, especially when raising the maximum army points beyond 3000. And now I got to the limits of my very basic scripting skills and was glad I found this post in the forum.
Now, I understand, that you don't have the time to dig into this issue. Though you wrote, that it is not hardcoded and there might be a solution to it. Could you tell us, in what files to look or at least a crude direction how we could approach this issue. Imagine how awesome a battle with 8000 points or more would be.
Looking forward to your response. Thank you in advance.

Best regards
RLo
The problem is that the code uses the old GetArray() and SetArray() functions which work on a single system array that has a maximum of 256 elements.

You could re-write them all using the more recently implemented global variables, but that is a whole masterclass, and not one I can really give on the forum.

Examples of the use of global arrays can be found as definitions in /Data/scripts/globals.bsf and in other scripts where those defined global arrays are used.
Richard Bodley Scott

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

Re: Army Lists

Post by RLO92 »

Thanks for the quick reply.

I looked through Globals.bsf, but I couldn't really identify which of these are a propper suit for the given task, except maybe the ForceSelection[] ones. Can I just add my own globalvariable(array)?

And I don't know if that's just what I want to understand, but are you saying that I basically "just" have to work through every bsf. file and replace every GetArray() with globalvariableY() and every SetArray() with globalvariableX()? And maybe some corresponding stuff like i and SortArrays capped at 255/56?
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28375
Joined: Sun Dec 04, 2005 6:25 pm

Re: Army Lists

Post by rbodleyscott »

RLO92 wrote: Sat Jan 03, 2026 9:37 am Thanks for the quick reply.

I looked through Globals.bsf, but I couldn't really identify which of these are a propper suit for the given task, except maybe the ForceSelection[] ones. Can I just add my own globalvariable(array)?
Yes
And I don't know if that's just what I want to understand, but are you saying that I basically "just" have to work through every bsf. file and replace every GetArray() with globalvariableY() and every SetArray() with globalvariableX()? And maybe some corresponding stuff like i and SortArrays capped at 255/56?
You only need to change the ones that are involved in setting up forces for force selection. As for which ones would need to be included, I cannot tell you off the top of my head. If it was a simple task to replace the old System arrys, I would have done it myself in the interest of programming hygiene. I did replace them in several places, but not where the old system worked OK, because there were more important things to spend the development time on.

And for self-defined global arrays you use the Sort() function, not the SortArray() function which only works on the old system arrays. You will find examples of my use of Stort() in the scripts.

As I said before, this is going to be a complex task, and I can't really fully explain it to you without effectively writing the mod myself. Which I do not have time to do.

If you can manage to work it out for yourself, I salute you. But I suspect it will be hard.
Richard Bodley Scott

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

Re: Army Lists

Post by RLO92 »

Thank you very much for the explanation.
I will look into it in the coming weeks when I finished our mod.
I can see the biggest dangers being overlooking something or destroying something else completely on the way.
I will let you know, if I managed to do it. If you don't hear from me I probably died trying.


For now I found an ad hoc kind of work around for anybody interested. Not very nice, but it is something.

You can change the "max = ((max * points) + 1000) / 2000 ;" in ArmyListTools.bsf to "max = max" Then setting up the armylist MaxUnits to whatever you want to see on the field for your selected force points. Doing that seperately for both players respectivley both army lists. Then selecting in the skirmish options Force Selection: Auto.
That way you would have to calculate your army composition preemptively (e.g. with excel) depending on the force points selected and then insert your numbers into the army list as MaxUnits. That means it is possible to field up to 256 units (per player I assume), which is translated to a max of probably around 8.000 to 10.000 force points (depending on the overall unit costs of a given armylist). That way the amount of different units in you army list is not affected by the 256 unit cap, but you still cannot exceed it.
However, that also means you make the deployment blind - so without seeing the map first.

It's a bit of work upfront, but it works.
Post Reply

Return to “Field of Glory II: Modding”