Page 1 of 2

Modding guide

Posted: Thu Oct 26, 2017 8:50 am
by welk
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

Re: Modding guide

Posted: Thu Oct 26, 2017 9:05 am
by rbodleyscott
Hi welk. Will do this when time permits.

Re: Modding guide

Posted: Thu Oct 26, 2017 9:09 am
by welk
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

Re: Modding guide

Posted: Thu Oct 26, 2017 9:46 am
by rbodleyscott
Updated, and stickied.

Re: Modding guide

Posted: Thu Oct 26, 2017 9:50 am
by welk
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)

Re: Modding guide

Posted: Thu Oct 26, 2017 10:56 am
by Cumandante
Neat! Now I can find the files I need more easily.

Thanks for this, welk! :D

Re: Modding guide

Posted: Sat Oct 28, 2017 8:35 pm
by lapdog666
where can i modify general's command radius?

Re: Modding guide

Posted: Sat Oct 28, 2017 8:48 pm
by welk
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;
}

Re: Modding guide

Posted: Sun Oct 29, 2017 7:19 am
by lapdog666
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

Re: Modding guide

Posted: Sun Oct 29, 2017 9:06 am
by rbodleyscott
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

Re: Modding guide

Posted: Sun Oct 29, 2017 11:50 am
by rbodleyscott
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.

Re: Modding guide

Posted: Sun Oct 29, 2017 5:30 pm
by Paul59
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.

Re: Modding guide

Posted: Sun Oct 29, 2017 5:38 pm
by welk
ok, thanks a lot for infos :)

Re: Modding guide

Posted: Sun Oct 29, 2017 6:27 pm
by welk
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 ?

Re: Modding guide

Posted: Sun Oct 29, 2017 6:40 pm
by welk
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

Re: Modding guide

Posted: Sun Oct 29, 2017 7:28 pm
by welk
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:

Re: Modding guide

Posted: Mon Oct 30, 2017 8:05 am
by rbodleyscott
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é!

Re: Modding guide

Posted: Mon Oct 30, 2017 8:28 am
by welk
One consolation is that despite I can not follow my modding obsession with FOG2, I can follow my FOG2 obsession playing with :mrgreen:

Re: Modding guide

Posted: Mon Oct 30, 2017 6:18 pm
by Paul59
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

Re: Modding guide

Posted: Mon Oct 30, 2017 6:57 pm
by rbodleyscott
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.