Offset requests - ship spinning & docking speed
-
Wut, fox!?
-
FriendlyFire wrote:
Wut, fox!?!
-
I have some vague memory that Argh solved this… But he gave all the ships totally different stats, so I wouldn’t know if his solution could be implemented in just about every mod.
Besides, you would have to find his toolkit, version 1.2 iirc… In 1.3 he went over the top and had removed all light equipments because they caused bugs.
Anyway, the trick, iirc, was to make those ships incredibly heavy, and adjust all other stats to also keep them pilotable. But I was never really interested in that part of the game, so I don’t remember much, and could even be wrong too.
He was a pioneer in many things, Argh… I still use [my adaption of] his xml based modding method.
-
I don’t think this will work very good with the FlHook versions
beyond the 196.And for the v.196 I d recommend to use the
recompiled plugins from this thread:
2.0.0 Plugins/KosAcid Projects/Plugin PortsBtw
- would be cool, if someone would recompile those once more,
to meet the latest FlHook version.
- would be cool, if someone would recompile those once more,
-
adoxa wrote:
I thought kosacid fixed it (see SpinProtection).This is actually Kosacid’s plugin port of M0tah’s SpinProtection from FlakHook - it attempts to alleviate the issue by pushing away NPCs that come into contact with the player ship. However, the initial collision still causes some spin and it has no effect on player-player collisions, so it would still be ideal to solve the underlying cause directly (whatever is applying rotational force to the ship on collision).
If anyone hunts this down I will give them a cookie - and the last ones I baked were pretty damn good if I do say so myself.
-
even if you get a decent anti-spin plugin… I’d still highly recommend Startrader’s formula for overall ship value excellence.
It’s good to know, WHY things do things i was dubious having modded for a while (heavy emphasis on ships) by the time i finally took a look it didn’t just make sense, i kicked myself for not having that formula in my head for all those years.
It does go a long way to stopping spinning in big ships upon collision… but meh… if someone rams you with the osiris… your gonna move… hehe i’d feel cheated if i didn’t.
-
Except ST’s formula (and all similar formulae) lock your ships to a very narrow range of handling feel. It’s way too limitative in general and still doesn’t stop ship spinning in practice.
-
So I’m going to kind of resurrect this thread because I managed to get more data on Freelancer’s collision handling.
Unfortunately, I don’t have anything conclusive as of now, but I did figure out a chain of function calls that seem to be handling collisions.
The most interesting function is at 0x628fa40 in common.dll. I can’t tell what the function does in its entirety, but I do know that towards the end, it sets a vector of CollisionEvent objects in a hidden PhySys object. Those CollisionEvents are what is eventually read by the game to send SPObjCollision events to the server.
Walking up the call stack reveals another function at 0x628c410 which appears to be handling collisions in a more direct fashion (for instance, there’s a direct reference to MIN_TIME_BETWEEN_COLLISIONS), but a lot of what it is doing is unfortunately moving around member values which I can’t trace down.
The hidden PhySys object can be obtained by peeking at PhySys::GetCollisions’s source. The DWORD at 0x63fc09c seems to always contain the object, even though there’s actually a case in the code where another value is used.
Relatedly, GetCollisions requires an integer as its first parameter and the value must be very specific in order for it to work. As it turns out, that value is directly returned by the function at 0x554e90, which may be called as a uint(void) function.
Finally, I have partially reversed the CollisionEvent struct:
struct CollisionEvent { CObject* a; // This is the damaged object in my limited tests CObject* b; // This is the "other" object uint iDunno1[2]; Vector position; float fDunno2[3]; Vector velocity; };
Now, what isn’t done is actually fixing the collisions proper. I’m still not sure where the math is performed, but I’d hope that somewhere in the call stack we can at least hook the strength of the bounce to tone it down - I’d much rather see NPCs fly through the ship than bounce them around.
Anyone feel like taking a crack?
-
The most interesting function is at 0x628fa40 in common.dll.
This function appends a CollisionEvent to this vector of CollisionEvents (arg1 is [c]this.end()[/c], arg2 is [c]1[/c], arg3 is the [c]CollisionEvent*[/c] to append). Perhaps that means you could hook this function, see if the objects are capital ship and fighter, and then either ignore the collision altogether, or reduce the velocity (or, at a guess, the rotation that might be the unknown floats).
Relatedly, GetCollisions requires an integer as its first parameter and the value must be very specific in order for it to work. As it turns out, that value is directly returned by the function at 0x554e90, which may be called as a uint(void) function.
It’s the [c]ID_String[/c] of the current system.
-
I’m not sure what the floats are, but they’re always 0.707, -0.707, 0 from what I’ve seen.
The problem is that I’m pretty sure the collision’s velocity/position effect is already applied by the time the CollisionEvent is set, so I doubt intercepting it would be enough.
-
If the numbers are correct, then in looks like a normalized vector (0.707²~=0.5). Could be the collision normal for example. But this is just a guess, the numbers jumped at me because after a while you see the typical values and your “vector” (if it even is a sequence) would make perfectly sense then as it has the length of one.
-
You’re right, that’s where I remembered seeing those numbers from. Oddly though, the collisions were pretty much all full frontal and definitely not perfectly identical… I guess I’d have to test more.
Still, the idea here would be to prevent the collision from affecting the ship at all while still actually being processed as a collision and doing damage.
-
Oh, here’s the call stack I get from 0x628fa40 to PhySys::Update (ordered from last call to first call):
628fa40
634cf87
6358aa7
6358d36
63262799
634fe99
6360888
6360a9d
634ccbe
628cb63
62899f7 (in PhySys::Update)The last few calls in the stack don’t appear to matter, preventing their execution merely stops damage from occurring. As you go up, though, it becomes impossible to just prevent the call as the game just crashes.
I’m not sure if the function actually moving the ship after the collision is within that call stack, but if not, it’s most likely in one of the functions called throughout.
-
So I noticed some peculiar behavior and was hoping someone would be able to shed light on this.
PhySys::GetCollisions seems to return all collision events, even those that involve beam weapons. Oddly, though, it doesn’t put a CBeam pointer in the second slot, instead it puts a pointer to what appears to be garbage. All I could notice was that the pointer would point to another pointer which would point to another pointer and so on until the last pointer goes to 0x0. All data around those pointers is 0xcdcdcdcd, so invalid.
I tried looking into how FL handles the CollisionEvent list, but it doesn’t seem to make any special case for those events, even though the second pointer obviously doesn’t work. Is there a straightforward way of identifying those “broken” events short of just trying to cast them to a CObject and seeing if it breaks?
Even better would be figuring out a way of tracing back which CBeam did it.
EDIT: So apparently if a beam weapon’s ammo has zero mass, it shows up in the CollisionEvent list, but does not refer to the proper object instance.