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
Adding combat capabilities
-
- Field of Glory 2
- Posts: 28084
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Adding combat capabilities
There would be several of them.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
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
Re: Adding combat capabilities
Thank you very much.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"
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?
-
- Field of Glory 2
- Posts: 28084
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Adding combat capabilities
Not if they are in the Squads file.
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.Another question: Is it possible to raise the cumulated maximum number of available units in the roster of the armylist above 256?
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
Re: Adding combat capabilities
Thank you for your reply.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?
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
-
- Field of Glory 2
- Posts: 28084
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Adding combat capabilities
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.
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
Re: Adding combat capabilities
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:
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:
The only line I could find which looks similar was:Hence line 634:
maxUnits = Min(maxUnits, 255);
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:
Maybe because the 0 is the actual 1?(I don't recall why this is 255 and not 256)
-
- Site Admin
- Posts: 9719
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Adding combat capabilities
The Min is because (assuming you are indexing into the work array) the values should be [0,255].
Cheers
Pip
Cheers
Pip
follow me on Twitter here
-
- Field of Glory 2
- Posts: 28084
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Adding combat capabilities
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.
Yes, I am of course aware of that.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
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
-
- Field of Glory 2
- Posts: 28084
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Adding combat capabilities
Ah yes, sorry, I was looking at the updated version for the forthcoming update on 16th Feb.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:
The only line I could find which looks similar was:Hence line 634:
maxUnits = Min(maxUnits, 255);
maxUnits = ((GetMapWidth() - 32) * 2) + numFixed;
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