This is a fork of WeaponMod with support for new GameDLL versions (8308+) and BugfixedHL-Rebased.
amxmodx/data/gamedata
).GetDispatch
hook. See below.The module currently supports the following games. Pull requests with other games and mods are welcome.
This version supports official ReHLDS release on Windows and Linux.
This guide provides some of the steps to add support for mods to WeaponMod. It will mostly focus on adding support for Linux (since there are absolutely no reasons to run servers on Windows).
.so
) must be compiled with debug information.WeaponMod uses AMXX 1.9's new "game config" feature. It allows plugins and
modules to read various offsets from a centralized mod-specific config file
instead of hardcoding them. WeaponMod's config is located in
amxmodx/data/gamedata/weaponmod.games
. This directory will later be refered
to as weaponmod.games
.
In this guide you will need to make copies of files in valve
for your mod.
amxmodx/data/gamedata/weaponmod.games
yourmod
master.games.txt
master.games.txt
.You need to select a reference weapon and a reference ammo box. WeaponMod will
use them as bases for custom weapons. Most mods can use weapon_crowbar
and
ammo_rpgclip
.
weaponmod.games/valve/settings.txt
to
weaponmod.games/yourmod/settings.txt
.weaponmod.games/master.games.txt
Basically, you need to generate amxmodx/data/gamedata/common.games/entities.games
for your
mod. It seems that AMXX devs used some private tool for that.
You can copy files from valve
and hope for the best.
You may try to parse the output from pahole
tool (reference).
Same as previous, but for amxmodx/data/gamedata/common.games/virtual.games
.
These offsets are not provided by AMXX and you will have to get them yourself.
You need to get VTable offsets for classes CBasePlayerWeapon
and CBasePlayerItem
.
pahole
pahole
on Linux.pahole ./hl.so > hl.so.symbols
Open the file. Find substring class EntityClassName :
class CBasePlayerWeapon : public CBasePlayerItem {
public:
/* class CBasePlayerItem <ancestor>; */ /* 0 140 */
virtual int Save(class CBasePlayerWeapon *, class CSave &);
virtual int Restore(class CBasePlayerWeapon *, class CRestore &);
/* vtable has XX entries:
. There's the VTable with
offsets Note that it isn't sorted (for some reason).
[3] = Save((null)),
[4] = Restore((null)),
[58] = AddToPlayer((null)),
[59] = AddDuplicate((null)),
[76] = ExtractAmmo((null)),
[77] = ExtractClipAmmo((null)),
[78] = AddWeapon((null)),
[65] = UpdateItemInfo((null)),
[79] = PlayEmptySound((null)),
[80] = ResetEmptySound((null)),
[81] = SendWeaponAnim((null)),
[61] = CanDeploy((null)),
[82] = IsUseable((null)),
[67] = ItemPostFrame((null)),
[83] = PrimaryAttack((null)),
[84] = SecondaryAttack((null)),
[85] = Reload((null)),
[86] = WeaponIdle((null)),
[73] = UpdateClientData((null)),
[87] = RetireWeapon((null)),
[88] = ShouldWeaponIdle((null)),
[64] = Holster((null)),
[89] = UseDecrement((null)),
[71] = PrimaryAmmoIndex((null)),
[72] = SecondaryAmmoIndex((null)),
[74] = GetWeaponPtr((null)),
gdb
We will use gdb
to print vtable as an array and then use line numbers as
offsets.
gdb
on Linux.gdb ./hl.so
EntityClassName
with class name):
set pagination off
set print array on
print *(int**)&'vtable for EntityClassName'@100
1. $1 = {0x0,
2. 0x1bba10 <typeinfo for CBasePlayerWeapon>,
3. 0x58738 <CBaseEntity::Spawn()>,
4. 0x5874c <CBaseEntity::Precache()>,
5. 0x129fc8 <CBaseDelay::KeyValue(KeyValueData_s*)>,
6. 0x149f2c <CBasePlayerWeapon::Save(CSave&)>,
7. 0x149f8c <CBasePlayerWeapon::Restore(CRestore&)>,
8. 0x533e4 <CBaseEntity::ObjectCaps()>,
...
0x0
, typeinfo
and the next element)
1. 0x5874c <CBaseEntity::Precache()>,
2. 0x129fc8 <CBaseDelay::KeyValue(KeyValueData_s*)>,
3. 0x149f2c <CBasePlayerWeapon::Save(CSave&)>,
4. 0x149f8c <CBasePlayerWeapon::Restore(CRestore&)>,
6. 0x533e4 <CBaseEntity::ObjectCaps()>,
...
"linux"
offset."windows"
.