Extra Modding Notes
Extra mod notes.
BGCache
To sync the GSC and the LUA scripts, eventstring
is used, they need to be cached on both side by the host and the clients. To allow that, a cache
section in the metadata.json to register elements inside the cache.
A custom element can be defined with a type, name and the hooks.
The list of the available types is available here.
eventstrings
will be required for custom models, weapons, strings, etc.
The hooks are via the mode, the map or the gametype, the available modes are "mp"
, "wz"
,"zm"
or "cp"
.
The GSC api function precache(type, hash)
is to allow adding elements to the cache, it's not working with multiplayer, but it allows to quickly test things.
Separator in stringtables
For the stringtable custom assets (CSV) there is an option in the metadata.json to select the separator. It can be useful with files with a lot of comas. Example with a TSV:
Localized entries
Localizeentry xasset
With the cache it can be used between players, it can be used to create custom trigger messages.
Note: You only need the cache for things asking for a client-server connection. they are also not needed if its only for Frontend.
XAsset redirects
Simply change the name of an asset at runtime, it allows to use another asset by replacing the asked name. (here the list of the pools)
Using the redirect
field in the metadata config.
GSC/CSC ShieldToJson/ShieldFromJson functions
This allow for things to be saved from game using GSC/CSC.
Functions :
Json File Name
The json filename is project-bo4/saved/{server/client}/{name}.json
, name can't contain a /
or a \
(for obvious reasons)
The json locations are vm dependent, so if the a script executed by the client vm can't see the jsons from the server vm.
Small Note :
If used in csc
> Saved to client folder
if used in gsc
> Saved to server folder
GSC stacktrace and hash lookups
The game shows the stacktrace when a GSC error occurs, because everything is hashed, theres a map to store the hashes.
The names in the mods are loaded automatically, other hashes can be add by reading a hash file using one of these 3 formats:
"string"
, each line is a string, better for fast add/remove, but less accurate, it is the format used in my gsc decompiler."common"
, each line is<hash>,<string>
, it is used by the greyhound package indexindex."serious_compiler"
, each line is0x<hash>, <string>
, it is generated automatically by the serious' t8-compiler.
The dll will load the default files:
project-bo4/strings.txt
(string format)project-bo4/hashes.csv
(common format)
But a mod can register custom files in the metadata using
LUA Reading and Writing JSON
This allow for things to be saved from game using LUA with Dvars (Engine Execute Command).
Functions :
Note: if path is not specified, it will use project's/shield's json instead. readjson
can write a value if missing/invalid only if readonly is false. If anything goes wrong it will use the given default value.
Example Usage:
Last updated