FWGS / hlsdk-portable

Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
https://xash.su
Other
272 stars 125 forks source link

Toggling corpse physics? #190

Closed Sparktimus closed 2 years ago

Sparktimus commented 3 years ago

Was poking around in the HL1 SDK for a wee bit trying to figure out how I could get the same corpse physics that Sven Coop has and stumbled upon this within the combat.cpp:

// make the corpse fly away from the attack vector
pev->movetype = MOVETYPE_TOSS;
// pev->flags &= ~FL_ONGROUND;
// pev->origin.z += 2;
// pev->velocity = g_vecAttackDir * -1;
// pev->velocity = pev->velocity * RANDOM_FLOAT( 300, 400 );

Last four lines are commented out but uncommenting enabled there to be corpse physics similar to Sven's. Why they're disabled is a mystery to me, but I was wondering if it were possible for there to be a cvar of some kind that could toggle this option, or preferably, enable it by default but with the ability to set your own values.

nekonomicon commented 3 years ago

Probably, wrong repository for such issue. Need to move to: https://github.com/FWGS/hlsdk-xash3d

And if you want you can make PR.

Sparktimus commented 3 years ago

Alright, I will. Thanks for the heads up!

a1batross commented 3 years ago

@nekonomicon there is issue transfer btw.

Yes, I think it can be easily hidden under cvar.

I think I saw this feature in some mods before, so I don't think it's unique to SC.

Sparktimus commented 3 years ago

I know it's present in every compiled version of the game, but it's simply commented out for some reason. Another mod called Scientist Hunt also had this feature.

Sparktimus commented 3 years ago

Since pretty much every Goldsrc lib has that combat.cpp file by default, I wonder if there's a way Xash itself could override that setting globally so you wouldn't have to recompile every lib file you want to use it with

Velaron commented 3 years ago

Commenting out code means it's not compiled into the binary, so I don't think there is a good way to do this with existing libraries.

mittorn commented 3 years ago

Since pretty much every Goldsrc lib has that combat.cpp file by default, I wonder if there's a way Xash itself could override that setting globally so you wouldn't have to recompile every lib file you want to use it with

You may try write metamod/amxx plugin with binary analysis to do this. Engine does not do binary hacks and it is very untrivial to do this at all and maybe even impossible to do automaticly

Sparktimus commented 3 years ago

Since pretty much every Goldsrc lib has that combat.cpp file by default, I wonder if there's a way Xash itself could override that setting globally so you wouldn't have to recompile every lib file you want to use it with

You may try write metamod/amxx plugin with binary analysis to do this. Engine does not do binary hacks and it is very untrivial to do this at all and maybe even impossible to do automaticly

I never thought of using Metamod as a go-between but that could actually work. I have very minimal coding experience but I know enough to at least recompile the binaries I want to change. Most mods anymore use the updated SDK or SOHL libraries for their mod so I don't have too much of an issue just making the changes I need and recompiling, but it'd be nice to be able to do it globally for any mod I'm running at that time, and a plugin might be the only answer to that.

a1batross commented 3 years ago

It probably would be enough rewriting CBaseMonster vtable, finding BecomeDead method in it and replacing it with your implementation.

AMXModX's HamSandwich definitely does it.

Though you have to calculate BecomeDead position in vtable for every mod DLL. I don't think most of them modify CBaseMonster but if they do, it shouldn't be hard looking up this function in Ghidra.

FreeSlave commented 2 years ago

The cvar was added to toggle corpse physics. Should we close the issue?