Compiler Basics
Use the injects
, shims
, or merges
keyword (see the injects.py, shims.py, and merges.py files).
in my repo folder I have BalancePS40.uc, which starts with this
class BalancePS40 injects WeaponHideAGun;
this tells the compiler to create these in the output folder
WeaponHideAGunBase.uc
// === was WeaponHideAGun ===
class WeaponHideAGunBase extends DeusExWeapon;
and
WeaponHideAGun.uc
// === was BalancePS40 ===
class WeaponHideAGun extends WeaponHideAGunBase;
shims
is similar to injects
, except instead of the new file taking the place of the old file, the old file keeps its name but all of the subclasses get modified for the new parent. So if you do
class FixScriptedPawn shims ScriptedPawn;
then it becomes
class FixScriptedPawn extends ScriptedPawn;
and the old subclasses of ScriptedPawn will now be changed to say extends FixScriptedPawn;
This also supports chains.
The merges keyword appends your code to the original file, any functions you overwrite will have the original function renamed to have an underscore in the front, for example the game requires DeusExLevelInfo
to inherit directly from Info
so we can't use injects
for it, we instead use merges
from my repo folder LevelInfo.uc
class DXRLevelInfo merges DeusExLevelInfo;
function SpawnScript()
{
local DXRando dxr;
local bool bFound;
bFound = False;
foreach AllActors(class'DXRando', dxr)
bFound = True;
if (!bFound) {
dxr = Spawn(class'DXRando');
dxr.SetdxInfo(Self);
}
_SpawnScript();
}
this results in the original SpawnScript
function in DeusExLevelInfo
to be renamed to _SpawnScript
, you can see my code calling that function, and then the compiler adds this to the bottom of the DeusExLevelInfo.uc
file
// === merged from .//DXRLevelInfo
/* class DXRLevelInfo merges DeusExLevelInfo; */
function SpawnScript()
{
local DXRando dxr;
local bool bFound;
bFound = False;
foreach AllActors(class'DXRando', dxr)
bFound = True;
if (!bFound) {
dxr = Spawn(class'DXRando');
dxr.SetdxInfo(Self);
}
_SpawnScript();
}