Articles

BaW Graphics Mod Manager

BaW Graphics Mod Manager is a system made for the creation (with extended capabilities) and loading of different Mods for Black & White. It also allows to change the colors of the players (this change can be made as part of a Mod). You can download it here.

INTRODUCTION

Hi everyone!
Like you probably know, a lot of different graphics mods for B&W exist. You can change the textures, you can change the color of things like fireballs and teleports... Now there is a better way of doing it.

.l3d files can only have 256 x 256 textures (16 bits per pixel, BGRA). The game is sending them without any changes, same quality like they are.

.raw textures are separated into two files each: one for RGB data (24 bits per pixel), another for Alpha data (8 bits per pixel). Technically it is a good quality and it allows to use square textures of any resolution. But the game opens both, gathers information and puts it together into one 256 x 256 texture (16 bits per pixel, BGRA).

If you would make texture mods, you would be limited by the low resolution and low quality. And when sending the .l3d files you would need to send them together with other data (for example vertex data, bones, other textures). And when sending .raw files they would weight twice as much as used. And the user of the mod would need to replace the game files. Which is very, very, very bad. I mean, very. Bad.

This project allows to use custom textures of practically any resolution and 32 bits per pixel. And allows doing it without replacing the game files. Allows even the replacement of textures in .l3d without storing any other data in the mod itself.

It also allows to change the color of vertices which can't be achieved by the editing of textures and is used, for example, in the coloring of fire and things which have the color of a player (temple beams, player symbol, influence rings, gestures and so on).

This project also allows to make simple modifications with the help of simple commands, so there would be no need in storing of big texture files.

Was tested in Windows XP, Windows 8.1, Windows 98.
In Windows 98 needed to rename ddraw.dll into fdraw.dll and edit the .exe file of the game with the help of the XVI32. Still worked not as intended. Everything was red.

Supported in CI.

HOW TO INSTALL

For the installation of the Mod it is needed to put its folder into the Mods folder (inside the game folder) and then add a line with LoadMod (with the folder name as a Parameter) into the Main.txt.
Example:
If the folder name is "Green Fire - Lant" then need to add "LoadMod('Green Fire - Lant');"

SOME TECHNICAL INFORMATION

All script files of Mods for this version need to begin with "ScriptVersion = 50;".

Objects
An Object is a number of Requirements and Redraws. If something that is being drawn meets the Object Requirements, then it is drawn using the Redraws of that Object.
Global Objects do not have Requirements, because of that everything that is being drawn is considered Global.
Currently Mods can create only Global Objects.

Requirements
A Requirement is a requirement to something that is being drawn, so that it could be considered an Object, to which this Requirement applies. For example, required can be a Texture choice, Texture coordinates and some other things.
Currently as a Requirement is mostly used only the Texture choice.
Two default Objects have additional Requirements to texture coordinates. EF_PLAYERCOLORED of "MAIN" Redraws of those two Objects is made "1". Changing those two Objects is forbidden.
Currently Mods can not add Requirements.

Redraws
Redraws are "commands" to draw an Object. By default every Object has a Redraw with name "MAIN". Redraws can have Effects added to them:
1) Main Effects (Only with ET_MAIN)
2) Matrix Effects (With ET_DIFFUSE, ET_SPECULAR and so on, but not with ET_MAIN).
Mods can add Redraws to Objects.

Effects
Effects are something like "settings". Currently there are Main Effects and Matrix Effects. Mods can add Effects to Redraws.

Effect Types
Effect Types can be chosen when adding Effects to the Redraws.
For adding Main Effects can use ET_MAIN.
For adding Matrix Effects can use:
1) ET_DIFFUSE       (for adding to Diffuse Color)
2) ET_SPECULAR      (for adding to Specular Color)
3) ET_TEXCOORD      (for adding to Texture Coordinates)
4) ET_POSITIONW     (for adding to Vertex Coordinates in World Space. Works not as intended for now, can be changed later)
5) ET_POSITIONW_BAD (for adding to Vertex Coordinates in World Space. Works not as intended, same as ET_POSITIONW. Not planned to be changed)
Effect Types can not be added.

Textures
(Note: this definition is not finished.)
Textures are images. Textures are defined by the comparison of a limited number of Pixels.
The Data folder in the game folder is being scanned for Textures in both .raw and .l3d files.
When the Textures are found, Objects with the same names are created with Requirements for such Texture choice.
The Textures of the .l3d files have the following names: "%.l3d file name%>%Texture Number%". For example, "waterfall3.l3d>1".
To Textures can be applied Matrix Effects for changing their texels.
Currently Mods can not add Texture detection.

SetModInfo(InfoType, Info);

Technically not being used yet, but later will probably be used when showing the installed Mod list. To use only in Main.txt of a Mod.

InfoType:
Type of information about Mod. Possible values are listed in the Mod Info Type Table. Example: MI_AUTHOR.
Info:
Information about Mod. String.

Example:

SetModInfo(MI_AUTHOR, 'Lant');

SetModInfo(MI_MODNAME, 'Green Fire');

SetModInfo(MI_RELEASEDATE, '01-01-2017');

SetModInfo(MI_VERSION, '1.00');

Mod Info Type Table

Effect NameDetailsDescription
MI_AUTHOR Info = Author name. String. Name of the Mod author.
MI_MODNAME Info = Mod name. String. Name of the Mod.
MI_RELEASEDATE Info = Release Date. String. Release date of the Mod. Preferable format DD-MM-YYYY. Can add any additional info after a space.
Example: "01-01-2017 sunday evening, after dinner, some more text, bonus information."
MI_UPDATEDATE Info = Update date. String. Date of the last Mod update (if different from the Mod release date, otherwise not needed). Preferable format DD-MM-YYYY. Can add any additional info after a space.
Example: "01-01-2017 10:15 random text, bonus information."
MI_VERSION Info = Mod version. String. Version of the Mod. Can use any String.
MI_ICON Info = Icon of the Mod. File name. Path to the image, which would be used as the Mod icon. Uncompressed .tga recommended. Can begin the path to the file with "." to point at the game folder and "#" to point at the current Mod folder.
MI_DESCRIPTION Info = Mod description. String. Description of the Mod. Multiple lines are ok.

EnableAlignInfoTest(State);

This function allows the player to see every instance of alignment change that is happening to the chosen player or players. Red numbers show alignment decrease, yellow numbers show alignment increase. Player symbols show the player which alignment is changing. For each of the players this can be enabled and disabled by clicking on the symbols in the side panel (black means enabled, white means disabled). That panel can be opened by clicking on the icon of black/white rectangle at the right. In it the current alignments of all players are shown. Useful for experimenting and to be sure what actions are actually good or evil in the game.
Works only in Black & White version 1.30 and Creature Isle version 1.23. Also, BaW Graphic Mod Manager version 0.51 is needed.

State:
State of the setting. Boolean.

Example:

EnableAlignInfoTest(1); //Enables this feature.

SetWindowSize(Width, Height);

Allows to set the size of the game window. Allows to see other windows while playing. Game resolution is still important.
Maybe can help with playing while using multi-monitor.
BaW Graphic Mod Manager version 0.51 is needed.

Width:
Chosen width of the game window.
Height:
Chosen height of the game window.

Example:

SetWindowSize(1920, 1040); //Allows to see the Taskbar with screen resolution 1920x1080. For best results need to set game resolution to 1920x1040 in the Registry.

SetFullScreenWindowed(State);

Allows to set the position and state of the game viewport. A good way to change how the game adapts to the screen size.
BaW Graphic Mod Manager version 0.51 is needed.

State:
Chosen state of the game viewport.

Example:

SetFullScreenWindowed(FW_CORNER); //Sets the game viewport to the top left corner of the screen, without stretching or resizing.
SetFullScreenWindowed(FW_STRETCH); //Makes game viewport stretch to full screen.

Viewport State Type Table

Position TypeDescription
NONE Disables the effect of this function.
FW_CORNER Sets the game viewport (in its chosen resolution) to the top left corner of the screen, without stretching or resizing (black border may be added).
FW_CENTER Sets the game viewport (in its chosen resolution) to the center of the screen, without stretching or resizing (black border may be added).
FW_FILL Sets the game viewport to fully fill the screen, without changing the proportions (parts of the viewport may end up outside of the screen).
FW_FIT Sets the game viewport to fit the screen without changing the proportions (adds black lines if needed).
FW_STRETCH Makes game viewport stretch to full screen (proportions may change).

SetPlayerColor(Player, Color);

Chooses the color of one player.

Player:
Number of player for color changing.
Color:
The code of needed color. Strings like "#FF0000" are working.

Example:

SetPlayerColor(0, '#FF8000'); //Makes the color of the first player orange.

SetPlayerColors(Color0 [, Color1, ..]);

Chooses the color/colors for a number of players (depends on how many parameters are listed). First parameter is for the first player, second for the second etc.

Color0 [, Color1, ..]:
Chooses the color/colors.

Example:

SetPlayerColors('#FF4646', '#47FF54', '#E347FF'); //Makes the colors of first three players the default colors.

LoadMod(ModName);

Loads another Mod.

ModName:
The name of the Mod that needs to be loaded.

Example:

LoadMod('NameOfMyMod - MyName'); //Loads Mod with directory name "NameOfMyMod - MyName".

UseModFile(FileName, FileType, MinVersion, MaxVersion);

Loads a file, has an ability to limit the allowed versions of the project. Useful for support of different versions.

FileName:
Name of the file in the folder of the Mod (only local files in this folder are allowed, "." and "#" at the beginning are not allowed). String.
FileType:
Type of the file. Currently only an empty String is allowed. String.
MinVersion:
Minimum allowed version of the project. If the version of the project is lower than specified then the file is not used (can use -1 to remove this limit).
MaxVersion:
Maximum allowed version of the project. If the version of the project is higher than specified then the file is not used (can use -1 to remove this limit).

Example:

UseModFile('ForOldVersion.txt', '', 50, 50); //Use only if the version of this project is 50.

UseModFile('ForNewVersions.txt', '', 51, -1); //Use only if the version is newer than 50.

UseModFile('BugFixFor60.txt', '', 60, 60); //Use only if the version is 60, to remove a bug that is present only in this version.

AddNewTexEffect(TextureName, Effect, Parameter0 [, Parameter1, ..]);

Adds an Effect to the texels of the chosen Texture.

TextureName:
Chooses to which Texture the Effect needs to be applied. Can use "GLOBAL" to add an Effect to every Texture.
Effect:
Chooses which Effect exactly needs to be applied. Possible values are listed in the Matrix Effect Table. Example: EF_GRAYSCALE.
Parameter0 [, Parameter1, ..]:
Parameters of the chosen Effect. Some Effects do not need it, some react differently on different amount of parameters.

Example:

AddNewTexEffect('Sky.raw', EF_GRAYSCALE); //Makes the texels of the Sky.raw Texture grayscale.

Matrix Effect Table

Effect NameDetailsDescription
EF_APPLY_MATRIX Applies the collected Matrix.
0 Parameters.
EF_MATRIX4X5 A, B, C, D
E, F, G, H
I, J, K, L
M, N, O, P
Q, R, S, T
Uses 4x5 Matrix specified by the Parameters.
20 Parameters.
EF_GRAYSCALE 0.333, 0.333, 0.333, 0.0
0.333, 0.333, 0.333, 0.0
0.333, 0.333, 0.333, 0.0
0.0  , 0.0  , 0.0  , 1.0
0.0  , 0.0  , 0.0  , 0.0
Makes the color grayscale.
0 Parameters.
EF_HUEROTATE si = Sin(A)
co = Cos(A)
a = 1.0/3.0 * (1.0 - c)
b = sqrt(1.0/3.0)
c = (1.0 - co) / 3.0

c     + co, a + b * si, a - b * si, 0.0
a - b * si, a     + co, a + b * si, 0.0
a + b * si, a - b * si, a     + co, 0.0
0.0       , 0.0       , 0.0       , 1.0
0.0       , 0.0       , 0.0       , 0.0
Applies a hue rotation.
1 Parameter.
Works like Hue in Adobe Photoshop.
EF_LIGHTNESS If A < 0
 a = A / 100.0 + 1.0
  a, 0, 0, 0
0, a, 0, 0
0, 0, a, 0
0, 0, 0, 1
0, 0, 0, 0

Else
 a = A / 100.0
 b = 1.0 - a
  b, 0, 0, 0
0, b, 0, 0
0, 0, b, 0
0, 0, 0, 1
a, a, a, 0
Works like Lightness in Adobe Photoshop.
1 Parameter.
EF_INVERT -1.0,  0.0,  0.0,  0.0
 0.0, -1.0,  0.0,  0.0
 0.0,  0.0,  0.0,  0.0
 0.0,  0.0,  0.0,  1.0
 1.0,  1.0,  1.0,  0.0
Makes the color inverted.
EF_MULTIPLY If !B
 B = A
 C = A
If !D
 D = 1

A, 0, 0, 0
0, B, 0, 0
0, 0, C, 0
0, 0, 0, D
0, 0, 0, 0
Multiplies a vector.
From 1 to 4 Parameters.

If using 1 Parameter,  multiplies X by A, Y by A, Z by A
If using 2 Parameters, multiplies X by A, Y by B, Z by 0
If using 3 Parameters, multiplies X by A, Y by B, Z by C
If using 4 Parameters, multiplies X by A, Y by B, Z by C, W by D
EF_ADD If !B
 B = A
 C = A
 D = 0

1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
0, 0, 0, 1
A, B, C, D
Adds a vector.
From 1 to 4 Parameters.

If using 1 Parameter,  adds A to X, A to Y, A to Z.
If using 2 Parameters, adds A to X, B to Y.
If using 3 Parameters, adds A to X, B to Y, C to Z.
If using 4 Parameters, adds A to X, B to Y, C to Z, D to W.
EF_REPLACE3 If !B
 B = A
 C = A

0, 0, 0, 0
0, 0, 0, 0
0, 0, 0, 0
0, 0, 0, 1
A, B, C, 0
Replaces the first 3 vector components (XYZ).
From 1 to 3 Parameters.

If using 1 Parameter, replaces X with A, Y with A, Z with A.
If using 1 Parameter, replaces X with A, Y with B, Z with 0.
If using 1 Parameter, replaces X with A, Y with B, Z with C.
EF_REPLACE4 If !B
 B = A
 C = A
If !D
 D = 1

0, 0, 0, 0
0, 0, 0, 0
0, 0, 0, 0
0, 0, 0, 0
A, B, C, D
Replaces the first 4 vector components (XYZW).
From 1 to 4 Parameters.

If using 1 Parameter,  replaces X with A, Y with A, Z with A, W with 1.
If using 2 Parameters, replaces X with A, Y with B, Z with 0, W with 1.
If using 3 Parameters, replaces X with A, Y with B, Z with C, W with 1.
If using 4 Parameters, replaces X with A, Y with B, Z with C, W with D.
EF_SWIZZLE 'zyxw':
0, 0, 1, 0
0, 1, 0, 0
1, 0, 0, 0
0, 0, 0, 1
0, 0, 0, 0

'yyyw':
0, 0, 0, 0
1, 1, 1, 0
0, 0, 0, 0
0, 0, 0, 1
0, 0, 0, 0

'rgbr':
1, 0, 0, 1
0, 1, 0, 0
0, 0, 1, 0
0, 0, 0, 0
0, 0, 0, 0

Uses a Swizzle mask, similar to a Swizzle mask in GLSL.
Can switch places of vector components.
1 Parameter, string.

Letters that can be used:
'xyzw', 'rgba', 'stpq'
These letter groups looks differently, but work the same way.
x = r = s, y = g = t, z = b = p, w = a = q.
Examples:
 'zyxw' switches places of X and Z. 'bgra' makes the same effect.
 'yyyw' Makes X and Z equal to Y.
 'rgbr' uses X(R, Red) instead of W(A, Alpha).

Can combine letters of different groups, which is not possible, for example, in GLSL.
Support of this in future versions is not guaranteed. Example:
 'baws' works the same way as 'baar' and 'zwwx' and 'pqqs', replacing X with Z, Y and Z with W, W with X.

If there are not enough letters, the end of "rgba" is used, to make the String length 4.
For example, if there will be a try to use "aa", then "aaba" will be used.

AddNewGlobalObject(ObjectName);

Adds a new Global Object
Everything that is drawn is considered a Global Object. If some Effect is applied to such Object, it is applied to everything that is drawn.

ObjectName:
Chooses the name of a new Global Object.

Example:

AddNewGlobalObject('MY_GLOBAL'); //Creates a new Global Object with the name "MY_GLOBAL", allowing to apply Effects to everything that is drawn, by applying them to this Global Object.

AddNewEffect(ObjectName, RedrawName, EffectType, Effect, Parameter0 [, Parameter1, ..]);

Adds an Effect to the chosen Redraw of the chosen Object.

ObjectName:
Chooses to Redraw of which Object the Effect needs to be applied.
RedrawName:
Chooses to which Redraw the Effect needs to be applied to. Can use "MAIN" for the main Redraw.
EffectType:
Chooses which type of Effect needs to be applied. Possible values are listed in the Effect Type Table. Example: ET_DIFFUSE.
Effect:
Chooses which Effect exactly needs to be applied. Possible values are listed in the Main Effect Table and Matrix Effect Table. Example: EF_GRAYSCALE.
Parameter0 [, Parameter1, ..]:
Parameters of the chosen Effect. Some Effects do not need it, some react differently on different amnount of parameters.

Example:

AddNewEffect('Sky.raw', 'MAIN', ET_MAIN, EF_SELECTTEXTURE, 0, '#\MyTexture.tga'); //Makes the texture with the name "MyTexture.tga" in the folder of the current Mod be used in the first Texture Slot when drawing Sky.raw Object.

Effect Type Table

Supported Effect Types
Main Effects ET_MAIN
Matrix Effects ET_DIFFUSE
ET_SPECULAR
ET_TEXCOORD
ET_POSITIONW
ET_POSITIONW_BAD

Main Effect Table

Effect NameDetailsDescription
EF_DEBUG A = Some number. Number. Probably, not used currently. Can be used for adding some "marks" for identification of Object and testing of something new.
EF_PLAYERCOLORED A = State of the setting. Boolean. Determines if the Object is using the Player color as own diffuse color.
EF_PLAYERSCOLORED A = State of the setting. Boolean. Determines if the Object is using the Player color as own specular color.
EF_SELECTTEXTURE A = Number of the Texture Slot. Number.
B = Name of the Texture File. File name.
Can begin the path to the file with "." to point at the game folder and "#" to point at the current Mod folder.
Makes the selected Texture be used instead of usual one in the selected Slot. Can use "NONE" to remove the Texture. Can use "DEFAULT" to use the default Texture.
EF_WIREFRAME A = State of the setting. Boolean. Makes the Wireframe be used, where only the triangle lines are drawn.
EF_NODRAW A = State of the setting. Boolean. Makes the geometry be not drawn.
EF_ANISOTROPIC A = Number of the Texture Slot. Number.
B = Level of the anisotropic filtering. Number.
Makes the chosen level of anisotropic filtering be used in the selected Slot.
EF_D3DBLEND A = Value for D3DRS_SRCBLEND. D3DBLEND.
B = Value for D3DRS_DESTBLEND. D3DBLEND.
Works only with two Parameters minimum.
Chooses the Blend Mode.
Possible values are not listed here, can search in Google for "D3DBLEND".
The last supported value is D3DBLEND_BOTHINVSRCALPHA.

AddNewRedraw(ObjectName, RedrawName);

Adds a Redraw to chosen Object.

ObjectName:
Chooses which Object the Redraw needs to be added to.
RedrawName:
Name of the Redraw.

Example:

AddNewRedraw('Sky.raw', 'MyRedraw'); //Adds Redraw with the name "MyRedraw" to the Sky.raw Object.

SetEffectAfter(ObjectName, RedrawName, State);

Chooses, whether to use the Effects of the chosen Redraw of the chosen Object after the other Effects.

ObjectName:
Chooses the Object which needs the decision if its Effects should be used later. String.
RedrawName:
Chooses to which Redraw needs to be chosen if the Effects of the chosen Object should be used later. String.
State:
The state of this setting. Boolean.

Example:

AddNewGlobalObject('MY_GLOBAL'); //Creates a new Global Object with the name "MY_GLOBAL", allowing to apply the Effects to everything that is being drawn, by applying it to this global Object.

AddNewRedraw('MY_GLOBAL', 'ExistingRedraw'); //Adds a Redraw, if it does no exist, otherwise simply allows to add Effects.

AddNewEffect('MY_GLOBAL', 'ExistingRedraw', EF_WIREFRAME, 1); //Causes this Redraw being drawn with lines.

SetEffectAfter('MY_GLOBAL', 'ExistingRedraw', 1); //Causes the Effects to be used on MY_GLOBAL later than others,...

SetEffectEnable(ObjectName, RedrawName, State);

Chooses, whether to use the Effects of the chosen Redraw of the chosen Object.
"Enabled" by default.

ObjectName:
Chooses the Object which needs the decision if its Effects should be used for the chosen Redraw. String.
RedrawName:
Chooses to which Redraw needs to be chosen if the Effects of the chosen Object should be used. String.
State:
The state of this setting. Boolean.

Example:

SetEffectEnable('Sky.raw', 'Redraw_Name', 0); //Disables the Effects for Redraw_Name Redraw of the Sky.raw Object.

SetEffectEnableKey('Sky.raw', 'Redraw_Name', 'W'); //Allows to enable the Effects for Redraw_Name Redraw of the Sky.raw Object by pressing the W Key.

SetEffectEnableKey(ObjectName, RedrawName, Key);

Chooses a Key for enabling and/or disabling of the Effects of the chosen Redraw of the chosen Object.
Can use the code of the Key, but also can use String with one letter.

Target:
Chooses the Object which needs the Key choice for the Redraw. String.
RedrawName:
Chooses the Redraw that needs the Key choice. String.
Key:
Key. Number or String.

Example:

SetEffectEnable('Sky.raw', 'Redraw_Name', 0); //Disables the Effects for Redraw_Name Redraw of the Sky.raw Object.

SetEffectEnableKey('Sky.raw', 'Redraw_Name', 'W'); //Allows to enable the Effects for Redraw_Name Redraw of the Sky.raw Object by pressing the W Key.

SetRedrawEnable(ObjectName, RedrawName, State);

Chooses, whether to use the chosen Redraw of the chosen Object.
"Enabled" by default.

ObjectName:
Chooses the Object which needs the decision if its Redraw should be used. String.
RedrawName:
Chooses the Redraw, which needs the choice whether it should be used. String.
State:
State of this setting. Boolean.

Example:

SetRedrawEnable('Sky.raw', 'Redraw_Name', 0); //Disables Redraw_Name Redraw of the Sky.raw Object.

SetRedrawEnableKey('Sky.raw', 'Redraw_Name', 'W'); //Allows to enable the Redraw_Name Redraw of the Sky.raw Object by pressing the W Key.

SetRedrawEnableKey(ObjectName, RedrawName, Key);

Chooses a Key for enabling and/or disabling of the chosen Redraw of the chosen Object.
Can use the code of the Key, but also can use a String with one letter.

ObjectName:
Chooses the Object which needs the Key choice for the Redraw. String.
RedrawName:
Chooses the Redraw that needs the Key choice. String.
Key:
Key. Number or String.

Example:

SetRedrawEnable('Sky.raw', 'Redraw_Name', 0); //Disables Redraw_Name Redraw of the Sky.raw Object.

SetRedrawEnableKey('Sky.raw', 'Redraw_Name', 'Q'); //Allows to enable the Redraw_Name Redraw of the Sky.raw Object by pressing the Q Key.

AutoSetEffects(DirName, Details);

Automatically scans the DirName directory and then uses the information from the files of this directory to add the Effects.
Currently works only with "RAW_TEXTURES" in the Details parameter.
With "RAW_TEXTURES" in Details searches for .raw files and then automatically adds EF_SELECTTEXTURE to Object with the same names as of the found files, to use those found files as textures.
AutoSetEffects can be used for lowering the amount of lines in the script file.

DirName:
Name of the folder that needs to be scanned for the files, based on which the Effects should be added. File name. Can begin the path to the file with "." to point at the game folder and "#" to point at the current Mod folder.
Details:
Additional information. String.
Currently only the "RAW_TEXTURES" String is allowed in this parameter.

Example:

AutoSetEffects('.\Data', 'RAW_TEXTURES'); //Looks for the .raw Textures in the Data folder (in the game folder) and makes them being used instead of those textures that the game is sending (and the game makes their quality worse).