Skip to content

Commit

Permalink
Really fix ubercharge drain rate, cloak debuff
Browse files Browse the repository at this point in the history
Closes #95.
  • Loading branch information
nosoop committed Oct 25, 2024
1 parent 7f09a5c commit 20f7a49
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
34 changes: 28 additions & 6 deletions gamedata/tf2.cattr_starterpack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,20 @@
"return" "void"
"this" "address"
}
"CTFPlayerShared::UpdateCloakMeter().part.0"
{
"signature" "CTFPlayerShared::UpdateCloakMeter().part.0"
"callconv" "cdecl"
"return" "void"
"arguments"
{
"this"
{
"type" "objectptr"
"register" "eax"
}
}
}
"CTFProjectile_Flare::Explode_Air()"
{
"signature" "CTFProjectile_Flare::Explode_Air()"
Expand Down Expand Up @@ -876,16 +890,17 @@
}
"CTFPlayerShared::UpdateCloakMeter()::ModifyDebuffReduction"
{
"signature" "CTFPlayerShared::UpdateCloakMeter()"
"linux"
{
"signature" "CTFPlayerShared::UpdateCloakMeter().part.0"
"offset" "B7h"
"verify" "\xF3\x0F\x10\x2A\x2A\x2A\x2A\x2A"
"patch" "\xF3\x0F\x10\x05\x00\x00\x00\x00"
"preserve" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
}
"windows"
{
"signature" "CTFPlayerShared::UpdateCloakMeter()"
"offset" "256h"
"verify" "\xF3\x0F\x59\x05\x2A\x2A\x2A\x2A"
"patch" "\xF3\x0F\x59\x05\x00\x00\x00\x00"
Expand Down Expand Up @@ -928,18 +943,21 @@
}
"CWeaponMedigun::DrainCharge()::PatchExtraDrainRate"
{
"signature" "CWeaponMedigun::DrainCharge()"
"linux"
{
"offset" "CFh"
"verify" "\xF3\x0F\x59\x15\x2A\x2A\x2A\x2A"
"patch" "\xF3\x0F\x59\x15\x00\x00\x00\x00"
"signature" "CWeaponMedigun::DrainCharge().part.0"
"offset" "BBh"
"verify" "\xF3\x0F\x59\x0D\x2A\x2A\x2A\x2A"
"patch" "\xF3\x0F\x59\x0D\x00\x00\x00\x00"
"preserve" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
}
"windows"
{
"signature" "CWeaponMedigun::DrainCharge()"
"offset" "C1h"
"verify" "\xF3\x0F\x59\x05\x2A\x2A\x2A\x2A"
"patch" "\xF3\x0F\x59\x05\x00\x00\x00\x00"
"preserve" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
}
}
}
Expand Down Expand Up @@ -1196,9 +1214,13 @@
//Naydef's instructions: Find function UpdateRageBuffsAndRage "Invalid rage buff type %i for entindex %i\n", then look for the functions that call it, one of the functions should contain 5 consecutive "call"s, the second of those calls is CTFPlayerShared::UpdateCloakMeter()
// find raw contents of g_aDebuffConditions and jump to xref function with most references
"library" "server"
"linux" "@_ZN15CTFPlayerShared16UpdateCloakMeterEv"
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x56\x8B\xF1\x6A\x08\x8B"
}
"CTFPlayerShared::UpdateCloakMeter().part.0"
{
"library" "server"
"linux" "@_ZN15CTFPlayerShared16UpdateCloakMeterEv.part.0"
}
"CTFProjectile_Flare::Explode_Air()"
{
// contains unique xref "ExplosionCore_MidAir_Flare"
Expand Down
20 changes: 19 additions & 1 deletion scripting/cloak_debuff_time_scale.sp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ public void OnPluginStart() {

Handle dtUpdateCloakMeter = GetDHooksDefinition(hGameConf,
"CTFPlayerShared::UpdateCloakMeter()");
DHookEnableDetour(dtUpdateCloakMeter, false, OnUpdateCloakMeterPre);
if (dtUpdateCloakMeter) {
DHookEnableDetour(dtUpdateCloakMeter, false, OnUpdateCloakMeterPre);
} else {
Handle dtUpdateCloakMeterInline = DHookCreateFromConf(hGameConf,
"CTFPlayerShared::UpdateCloakMeter().part.0");
if (!dtUpdateCloakMeterInline) {
SetFailState("Failed to create detour "
... "CTFPlayerShared::UpdateCloakMeter().part.0");
}
DHookEnableDetour(dtUpdateCloakMeterInline, false, OnUpdateCloakMeterInlinePre);
}

ClearDHooksDefinitions();

Expand Down Expand Up @@ -101,6 +111,14 @@ MRESReturn OnUpdateCloakMeterPre(Address pShared) {
return MRES_Ignored;
}

/**
* Patches the per-client unique reduction rate into the function.
*/
MRESReturn OnUpdateCloakMeterInlinePre(DHookParam hParams) {
Address pShared = hParams.GetAddress(1);
return OnUpdateCloakMeterPre(pShared);
}

// the value that is injected into the game is the amount of time each debuff is reduced per
// second
//
Expand Down

0 comments on commit 20f7a49

Please sign in to comment.