Modding guide

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Modding guide

Post by welk » Thu Oct 26, 2017 8:50 am

LAST UPDATE OF THIS THREAD IS : 29 OCTOBER 2017
UPDATE CONCERNS : ADDING INFOS ABOUT :CombatTools.BSF - How to modify fighting cavalery vs elephants
(Search details in the thread)


To try to rationalize knowledges in modding FOG2, I think it would be good to have this tool : I began to complete it, to show what it would be become after completing

I listed all scripts and others misc files that may be used.

Updated by rbodleyscott

________________________________________________________________
/Core

Core.BSF
Various functions performed in every battle

/Core/AI

AI.BSF
The main AI logic

________________________________________________________________
Data/Battle/Scripts (bsf files)

-------------
$DEFAULT
May be used :
To add additional script files to the build
-------------
Assault
May be used :
To modify the functioning of the Charge order
-------------
Callbacks
May be used :
=> to mod formation of units (in combination with Mancount parameter in Squad.csv)
See here post of a specialist for this aspect : http://www.slitherine.com/forum/viewtop ... 92&t=79856
-------------
CloseCombatLogic
May be used :
To modify the close combat logic
-------------
FallBack
May be used :
To modify the Fall Back order
-------------
FightMelee
May be used :
To modify the Fight Melee order
-------------
FormSquare
May be used :
To modify the form square and leave square orders.
-------------
Helpers
May be used :
To modify various tile displays and tooltips
-------------
Init
May be used :
To add additional unit "Attrib" variables that do not need to be in the squads file. Not that the number of these is finite, so if you add many it is possible that your mod will not work with future updates.
-------------
keys
May be used :
To add hotkeys. Use with caution - will cause issues if you try to use a key that is already in use elsewhere.
-------------
Load
May be used :
To allow certain types of units to be carried by others
-------------
MapGenerate
May be used :
To modify the setting up of random map battles
-------------
MapGenerateBattle
May be used :
To modify random map generation

-------------
Move
May be used :
To modify the functioning of the move order
-------------
Move_Command
May be used :
To modify the functioning of the Group movement order
-------------
Move_General
May be used :
To modify the functioning of the Move General (to another unit) order
-------------
MultiBattleCampaign
May be used :
To modify the functioning of multi-battle campaigns
-------------
PassThrough
May be used :
To modify the functioning of the Pass Through order
-------------
QuickBattles
May be used :
To modify the functioning of Quick Battles modules
-------------
Shooting
May be used :
To modify the functioning of the Shoot order
-------------
Shooting_Logic
May be used :
To modify Shooting
-------------
Slith_RandomMap2
May be used :

1°/ => to mod victory conditions
See here a post concerning this aspect : http://www.slitherine.com/forum/viewtop ... 92&t=79828

2°/ To mod the functioning of random map battles

-------------
StartTurn
May be used :
To mod stuff applying to each unit at the start of its turn
-------------
Switch_Command
May be used :
To mod the functioning of the Switch Command order
-------------
trigger
May be used :
To mod how projectile animations work
-------------
Turn
May be used :
To mod how the Turn order works
-------------
Turn_Command
To mod how the group turn order works
-------------
TurnAndShoot
May be used :
To mod how the Turn and Shoot order works

-------------
UI
May be used :
To mod the fundtioning of the unit UI panels at the bottom of the battle screen
-------------
Undo
May be used :
to mod the functioning of the Undo order




________________________________________________________________
Data/scripts (bsf files)
-------------
AITools
To mod the AI, also evades, routs and pursuits.
-------------
AnimationTools
To mod the unit animation logic
-------------
CampaignTools
May be used :
To mod the functioning of campaigns
-------------
CombatTools
May be used :
=>To alter the ranges of different weapons you would need to alter the following functions:
MaximumRange() - used for multiple purposes
OptimumRange() - used by the AI
GetShootingWeaponModifier() - this is what actually determines the effect of each weapon at different ranges

To mod all sorts of other functions affecting shooting and close combat

=> to modify fighting cavalry Vs Elephants
1) Code that disorders cavalry when close to elephants. The PercentDisordered() function in CombatTools.BSF
2) Effect of elephants on the various cavalry capabilities in GetImpactPOA() and GetMeleePOA() in CombatTools.BSF
If you want to disallow cavalry from ever charging elephants you would do it in ChargePermitted() function in CombatTool.BSF

-------------
CustomCampaignTools
May be used :
This is designed to be replaced in custom modules to mod various campaign functions
-------------
ForceSelectionTools
May be used :
To mod force selection
-------------
Functions
May be used :
Assorted functions for use in various places
-------------
GeneralTools
May be used :
To modify how generals work
In particular : allow to modify Generals range command

-------------
Globals
May be used :
To add additional global variables
-------------
HelperTools
May be used :
To mod various tooltip and tutorial functions
-------------
Macros
May be used :
To define new macros, or modify the existing ones. These can only be single integers.
-------------
MapTools
May be used :
To mod various functions used by random map generator.
-------------
MoraleTools
May be used :
To mod the morale rules
In particular : may be used to modify the routing effect of routed elephants on others units

-------------
MoreCampaignTools
May be used :
To mod multi-battle campaigns
-------------
MoreScenarioTools
May be used :
To mod various functions relating to random map and preset scenario battles
-------------
MoveCommandTools
May be used :
To mod the functioning of Group Movement
-------------
MPSShowArmyTools
May be used :
To mod the display of field army and garrison units between campaign battles
-------------
MultiPartSkirmishTools
May be used :
To mod the functioning of multi-battle campaigns
-------------
ObstacleTools
May be used :
To mod the functioning of obstacles
-------------
QuestControlsTools
May be used :
To mod the functioning of the campaign/sencario etc selection UI. Best left alone.
-------------
ScenarioTools
May be used :
NOT USED
-------------
StartTurnPreTools
May be used :
To mod various things that occur at the start of a turn.
-------------
Tools
May be used :
Assorted functions used in various places.
-------------
TournamentTools
Do not mod this!
-------------
TutorialTools
May be used :
To modify the display of tutorial popups
-------------
UITools
May be used :
To modify various UI functions
-------------
UndoTools
May be used :
To modify the functioning of the Undo order.


_____________________________________________________________________
DATA misc files

-------------
Terrain
May be used:
=> to change units move capacities on each terrain
-------------
Mapview
May be used :
=> to mod zoom functions
See here a post about this aspect : http://www.slitherine.com/forum/viewtop ... 92&t=79690

Squads files (Excel and csv)
May be used to modify units stats
See here for the complete units stats listing : http://www.slitherine.com/forum/viewtop ... 92&t=80096

You may work with excel page named Squads (stats are listed with rows and lines), and then, convert your excel page in a excel csv format
Explanations hre : http://www.slitherine.com/forum/viewtop ... 92&t=79680

For french players : les versions française et américaines de Excel étant incompatibles pour les séparateurs, il faut utiliser le processus indiqué ici :
http://www.slitherine.com/forum/viewtop ... 92&t=80110

________________________________________________________________
Other misc files : Data/UI/Textures/Battle files (images)
These files are images and may be edited with adapted program, they concern some aspects of interface of the game
(in particular effects of selections or actions on map : selected units, etc)
Sample : Unit_WaypointSelected.dds is the file that contents the image of the selected unit (gold square when you select one unit)
See this thread : http://www.slitherine.com/forum/viewtop ... 28#p683928

________________________________________________________________
Other misc file :/Documents/My Games/FieldOfGlory2/Options.txt
This file allows to modify some values options in game

In particular : speed of all move animations
Concerned value is :UnitSpeedHack
Min is 0, max is 10
Last edited by welk on Sun Oct 29, 2017 6:08 pm, edited 20 times in total.

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

Re: Modding guide

Post by rbodleyscott » Thu Oct 26, 2017 9:05 am

Hi welk. Will do this when time permits.
Richard Bodley Scott

Image

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Thu Oct 26, 2017 9:09 am

Ok, thanks a lot :wink:

In addition : would be good if all FOG2 modders participe to complete this modding guide tool (centralization of knowledges, to facilite work for all modders)


I suggest that :
each time a modder explores, finds or develops a way to work in these aspects (or new aspects : no limitation), he posts his knowledge in synthetic explanations in this thread and I update the list with the details he has given : in final step, we will have a complete modding guide
Last edited by welk on Thu Oct 26, 2017 9:47 am, edited 1 time in total.

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

Re: Modding guide

Post by rbodleyscott » Thu Oct 26, 2017 9:46 am

Updated, and stickied.
Richard Bodley Scott

Image

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Thu Oct 26, 2017 9:50 am

Ok Richards, lot of thanks : I think community can build a good modding guide without lot of work, if each modder gives here a little piece of knowledges he has worked (initial knowledges or complementary or precisions, etc)

Cumandante
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 117
Joined: Wed Sep 29, 2010 5:53 pm

Re: Modding guide

Post by Cumandante » Thu Oct 26, 2017 10:56 am

Neat! Now I can find the files I need more easily.

Thanks for this, welk! :D

lapdog666
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 319
Joined: Thu Dec 08, 2016 1:25 pm

Re: Modding guide

Post by lapdog666 » Sat Oct 28, 2017 8:35 pm

where can i modify general's command radius?

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Sat Oct 28, 2017 8:48 pm

I saw something concerning Generals radius in GeneralTools.BSF (Data/scripts) but I had no time to explore the script in details, I will do in the future : perhaps you may find here what you search

What I saw is that : (line 108 with notepad++)
// Returns general's command range - me is general's unit - function assumes that it has already been tested that unit does in fact have general
// type == 0 is for morale purposes, type == 1 is for movement purposes
FUNCTION GetGeneralRange(me, type)
{
int quality;
int range;

quality = GetAttrib(me, "GeneralQuality");

if (quality == 0) // TC
{
range = 4;
}
else
{
if (quality == 1) // FC
{
range = 8;
}
else // IC
{
range = 12;
}
}

if (type == 0)
{
range /= 4;
}

return range;
}

lapdog666
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 319
Joined: Thu Dec 08, 2016 1:25 pm

Re: Modding guide

Post by lapdog666 » Sun Oct 29, 2017 7:19 am

would it also be possible to add new features like units having 50% reduced AP or having limited actions if :

1. unit not in command range of its designated general
2. unit not in Line of sight of its designated general


or to make it when the general dies , that all units in X area get -% Poa , like -25 or -50

i feel that when generals die nothing much happens, its always better to have them in fight for bonuses

another example would be if general dies, 2 units next to him, unless Certain quality,instantly get fragmented


just had a very large mp game where general died and i got couple units disrupted, thats it , still fighting as if nothing happened manouvering like clockwork

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

Re: Modding guide

Post by rbodleyscott » Sun Oct 29, 2017 9:06 am

Just a quick heads up re adding extra sideIDs.

Obviously you need to add IDS_SIDENAME strings for each new side ID.

However, you also need to add code for new SideIDs in cloned versions of the following files:

1) GetRandomGeneralName() in /Data/scripts/GeneralTools.BSF, so they get the right randomly generated names.
2) BannerSideIDs.txt in /Core, so they get the right banners.
3) line 37 in /data/scripts/globals.bsf, so they get the right start of turn fanfare. Increase the size of the gBarbarian[71] array and list 1 for each barbarian sideId and 0 for civilised sideIDs
Richard Bodley Scott

Image

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

Re: Modding guide

Post by rbodleyscott » Sun Oct 29, 2017 11:50 am

welk wrote:But the pb is : when I have created my unique scenario Raphia, this operation did not create a Raphia.bsf file, just a Raphia.BAM
Have I to create this file myself manually ?
In the main directory of the game build is a file call SCENARIOTEMPLATE.BSF. Copy that to the /SCENARIOS subfolder of your custom folder, and rename the copy Raphia.BSF. Then you can add any scenario-specific code you want.
Richard Bodley Scott

Image

Paul59
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Tue Jul 21, 2015 11:26 pm

Re: Modding guide

Post by Paul59 » Sun Oct 29, 2017 5:30 pm

rbodleyscott wrote:
welk wrote:But the pb is : when I have created my unique scenario Raphia, this operation did not create a Raphia.bsf file, just a Raphia.BAM
Have I to create this file myself manually ?
In the main directory of the game build is a file call SCENARIOTEMPLATE.BSF. Copy that to the /SCENARIOS subfolder of your custom folder, and rename the copy Raphia.BSF. Then you can add any scenario-specific code you want.
The .BSF file is not essential to make a basic scenario, so the editor does not create one for you. But the .BSF does allow you to make a lot of cool scripted changes to the scenario, from simple things like turn limit and amended victory conditions, to more complicated stuff like complex reinforcements and AI orders.

As Richard said, you just add the .BSF file yourself to your scenario folder, see the structure of one of my scenarios to see where it goes, it needs to have exactly the same name as the .bam file.
Scenario Designer - Age of Belisarius, Rise of Persia, and Wolves at the Gate.

TT Mod Creator

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Sun Oct 29, 2017 5:38 pm

ok, thanks a lot for infos :)

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Sun Oct 29, 2017 6:27 pm

Paul59 wrote:
rbodleyscott wrote:
welk wrote:But the pb is : when I have created my unique scenario Raphia, this operation did not create a Raphia.bsf file, just a Raphia.BAM
Have I to create this file myself manually ?
In the main directory of the game build is a file call SCENARIOTEMPLATE.BSF. Copy that to the /SCENARIOS subfolder of your custom folder, and rename the copy Raphia.BSF. Then you can add any scenario-specific code you want.
The .BSF file is not essential to make a basic scenario, so the editor does not create one for you. But the .BSF does allow you to make a lot of cool scripted changes to the scenario, from simple things like turn limit and amended victory conditions, to more complicated stuff like complex reinforcements and AI orders.

As Richard said, you just add the .BSF file yourself to your scenario folder, see the structure of one of my scenarios to see where it goes, it needs to have exactly the same name as the .bam file.

Ok, Paul : I explored as sample your HERACLEA.BSF file
and I found in this file that, concerning elephants : (elephants are my obession :mrgreen: )

FUNCTION CustomImpactPOA(me, enemy, charging, print, test, any_printed)
{
int ret;

ret = 0;

if (enemy != -1)
{
if (IsUnitSquadType(enemy, "Elephants") == 1)
{
ret = -100;

if (print == 1)
{
PrintStringLiteralX(1, test, ", ");

PrintStringX(1, test, "IDS_FIGHTING_ELEPHANTS");
PrintStringLiteralX(1, test, ":");

PrintStringLiteralX(1, test, " ");
PrintIntX(1, test, ret);
}
}
}

return ret;
}

So, searching, I have founded that this function CustomImpactPOA is used in some scripts fils of the game

So, I deduct that :
1- In "MYSCENARIO".BSF (sample of name), I can "declare" and use and modify (or create ?) a function that is used in the script files of the game
2- And the function I have "declared" in MYSCENARIO.BSF file will be applied by the game for this special scenario
3- So, I have not to modify each script file of vanilla game : I just have to enter my modified funtions in this MYSCENARIO.BSF file

Is it right or mistake from my interpretation ?

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Sun Oct 29, 2017 6:40 pm

And in addition, the study of your function cause me some trouble (sorry for poor english: its diffcult to explain in other langage than native, and in a technical subject where I have no any knowledges)

Supposing I would have wanted to do the same you did : how could I know what is int ret; , and what is (enemy != -1) and what is (print == 1) ?


// Custom POA to represent drastic effect of elephants in this battle
FUNCTION CustomImpactPOA(me, enemy, charging, print, test, any_printed)
{
int ret;

ret = 0;

if (enemy != -1)
{
if (IsUnitSquadType(enemy, "Elephants") == 1)
{
ret = -100;

if (print == 1)
{
PrintStringLiteralX(1, test, ", ");

PrintStringX(1, test, "IDS_FIGHTING_ELEPHANTS");
PrintStringLiteralX(1, test, ":");

PrintStringLiteralX(1, test, " ");
PrintIntX(1, test, ret);
}
}
}

return ret;
}

We are here in the limit modding of this game : yes, us, players, we can mod the game. But it supposes to know elements of C++. It confirms my first opinion about FOG2 : it's not a moddable game, it's a codable game. And moddabkle and codable are not exactly the same :mrgreen: Hubert Cater, for Strategic Command 3, solved the problem when he provided a minimal stock of explanations for scripting work : without the minimum of explanations, only a few specialists will be able to "mod/code" the game

Other problemn is : in your MYSCENARIO.BSF file, I founded functions. OK. But how to know what we can include or not incluide in these .BSF files ? We are absolutly blind for this aspect, the only thing we can do is imitating what it was made, like :mrgreen: ouistitisAnd it is not exactly a satisfaisant situation :roll:

As conclusion, I think that the FOG2 staff would have to provide a minimal manuel modding guide, if not there will lot of work and attemps made, but no massive effective modding results : FOG2 staff can not say :" FOG2 is a moddable game" without providing the way to mod the game without learning C++

I precise that I do modding from some years, I love modding and I modded lot of games, and it's the first time I see a game that is moddable but moddable if you have learn C++ :mrgreen: the verity is that this game is codable by C++ specialists, not moddable by ordinary modders, and in comparison with FOG 1, it's for me a real disappointment => I think I will stop to attempt to mod this game, I will just playing : without appropriated tools and basic knowledges, nothing correct may be made

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Sun Oct 29, 2017 7:28 pm

And the problem is that I can not stop my desire to mod this game ! :mrgreen:

Actually, after deciding to not mod more this game, I am searching how to mod the collective move limit. Modding obsession is modding obsessions... :roll:

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

Re: Modding guide

Post by rbodleyscott » Mon Oct 30, 2017 8:05 am

It isn't C++, it is C script, which is a subset of C, and very much simpler to learn.

However, it is true that you won't get very far with modding the mechanics of this game without a rudimentary knowledge of coding.
it's not a moddable game, it's a codable game. And moddable and codable are not exactly the same
I take your point, although I am fairly sure that the definition of moddable can include coding. Anyway, I guess that the bottom line is that the game isn't completely data driven.

Désolé!
Richard Bodley Scott

Image

welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 293
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding guide

Post by welk » Mon Oct 30, 2017 8:28 am

One consolation is that despite I can not follow my modding obsession with FOG2, I can follow my FOG2 obsession playing with :mrgreen:

Paul59
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Tue Jul 21, 2015 11:26 pm

Re: Modding guide

Post by Paul59 » Mon Oct 30, 2017 6:18 pm

rbodleyscott wrote:Just a quick heads up re adding extra sideIDs.

Obviously you need to add IDS_SIDENAME strings for each new side ID.

However, you also need to add code for new SideIDs in cloned versions of the following files:

1) GetRandomGeneralName() in /Data/scripts/GeneralTools.BSF, so they get the right randomly generated names.
2) BannerSideIDs.txt in /Core, so they get the right banners.
3) line 37 in /data/scripts/globals.bsf, so they get the right start of turn fanfare. Increase the size of the gBarbarian[71] array and list 1 for each barbarian sideId and 0 for civilised sideIDs
Hi Richard,

I would guess that the 71 in brackets refers to the total number of side ids. Therefore if I add more side ids I will have to increase that number in the brackets to whatever the new total is, and also add in the appropriate 0 or 1 in the sequence?

regards

Paul
Scenario Designer - Age of Belisarius, Rise of Persia, and Wolves at the Gate.

TT Mod Creator

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

Re: Modding guide

Post by rbodleyscott » Mon Oct 30, 2017 6:57 pm

Paul59 wrote:
rbodleyscott wrote:Just a quick heads up re adding extra sideIDs.

Obviously you need to add IDS_SIDENAME strings for each new side ID.

However, you also need to add code for new SideIDs in cloned versions of the following files:

1) GetRandomGeneralName() in /Data/scripts/GeneralTools.BSF, so they get the right randomly generated names.
2) BannerSideIDs.txt in /Core, so they get the right banners.
3) line 37 in /data/scripts/globals.bsf, so they get the right start of turn fanfare. Increase the size of the gBarbarian[71] array and list 1 for each barbarian sideId and 0 for civilised sideIDs
Hi Richard,

I would guess that the 71 in brackets refers to the total number of side ids. Therefore if I add more side ids I will have to increase that number in the brackets to whatever the new total is, and also add in the appropriate 0 or 1 in the sequence?

regards

Paul
Errm, yes. The number in square brackets has to be 1 higher than the highest numbered sideID, because it defines the number of elements in the array, and the first element index is 0.
Richard Bodley Scott

Image

Post Reply

Return to “Field of Glory II: Modding”