Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Rampage on December 27, 2002, 09:03:27 am

Title: Multiple Dockees per Ship
Post by: Rampage on December 27, 2002, 09:03:27 am
<>

There's a problem that should've been fixed a long time ago.  Ships such as the SFr Asmodeus can only dock with one cargo unit.  This severely limits the actual capabilities of the vessel because of a code glitch.

A Fix?
What I propose is simple.  Enable multiple docking for bulk freighters and other vessels with multiple docking points.  This I leave to you source code mages out there.  But there's also the targeting screen problem in-game.  Above the targeted ship, a reticle appears if the ship is docked with another specifying the name of the ship docked.  What we can do for ships with multiple- stuff docked should have the reticle display: "Docked With: [n]", where "n" is the number of ships currently docked with the vessel.  A key should be assigned to toggle the name of the docked ship to be displayed on the reticle.  The "~" key will be used for this example.  When the ~ key is hit, the reticle will cycle through the names of the ships docked with the target.

For example, a SFr Asmodeus is selected as the target.  The "Docked With" reticle will display the following:
1. Display "Docked With: 2"
2. Keyboard Action "Hit ~"
3. Then Display "Docked With: Cargo 1"
4. Keyboard Action "Hit ~"
5. Then Display "Docked With: Cargo 2"
6. Hit the ~ key again and the cycle will start over.


Rampage
Title: Multiple Dockees per Ship
Post by: Petrarch of the VBB on December 27, 2002, 01:57:07 pm
Hmm, this would indeed be useful, especially to we tappers, as we need to get the salvage oojah to work properly.
Title: Re: Multiple Dockees per Ship
Post by: ZylonBane on December 27, 2002, 07:45:44 pm
Quote
Originally posted by Rampage
What I propose is simple.  Enable multiple docking for bulk freighters
Wow, that IS simple! Let me take a look at the source code here.... hmmm.... aha! Yup, this line is the culprit--

Code: [Select]

int EnableMultiDocking = false;

Good work, Rampage! I don't know why no-one thought of this before. :yes:
Title: Multiple Dockees per Ship
Post by: Bobboau on December 27, 2002, 09:47:14 pm
I don't know how that was working at all,
it should have been a bool not an int
Title: Multiple Dockees per Ship
Post by: an0n on December 27, 2002, 09:51:56 pm
I truly expect ZB's life to end with the words "Oh, I've wasted my life." as a missile of some sort comes hurtling towards him.
Title: Re: Re: Multiple Dockees per Ship
Post by: Goober5000 on December 27, 2002, 10:21:46 pm
Quote
Originally posted by ZylonBane
Wow, that IS simple! Let me take a look at the source code here.... hmmm.... aha! Yup, this line is the culprit--

Code: [Select]

int EnableMultiDocking = false;

Good work, Rampage! I don't know why no-one thought of this before. :yes: [/B]


:lol: You can cut the sarcasm with a knife. ;)

But joking aside, I do think that this would be a fairly easy thing to do.  We just have to figure out a good way,
Title: Multiple Dockees per Ship
Post by: Bobboau on December 27, 2002, 11:04:46 pm
no, I think Zylon's last words would be something along the lines of, "you call that thing a knife" or "ya dumbass, you've got the safety on", though he would likely speak with the corect spellings
Title: Multiple Dockees per Ship
Post by: mikhael on December 27, 2002, 11:33:15 pm
Quote
Originally posted by Bobboau
I don't know how that was working at all,
it should have been a bool not an int


Realistically, an int can handle ture/false values very easy. Remember: in C and C++ only 0 (zero) is false, all other values are true. You can use a bool, a char, an int, any and every sort of pointer, etc--so long as when push comes to shove, you can get a 0 or a !0 when you read it. ;)
Title: Re: Re: Re: Multiple Dockees per Ship
Post by: ZylonBane on December 28, 2002, 10:21:06 am
Quote
Originally posted by Goober5000
But joking aside, I do think that this would be a fairly easy thing to do.  We just have to figure out a good way,
See, I think it'll be a fairly hard thing to do. Flexible systems tend to be an order of magnitude more complex to code than simple systems... and FS2's current one-docking-per-ship setup is quite simple.
Title: Multiple Dockees per Ship
Post by: Sesquipedalian on December 28, 2002, 03:54:42 pm
Well, Goober5000 does seem to know what he is doing with the code. I'd expect it to be a significant amount of coding to make this work, but if he thinks he can do it, I'm all in favour.  :D
Title: Multiple Dockees per Ship
Post by: ZylonBane on December 28, 2002, 05:42:07 pm
Oh I think multi-ship docking would be great too.

Rampage's PHB-style thinking just ticked me off. Perhaps someday he'll realize that there's a universe of difference between "enabling" and "implementing".
Title: Multiple Dockees per Ship
Post by: Rampage on December 28, 2002, 06:18:53 pm
Quote
Originally posted by ZylonBane
Rampage's PHB-style thinking just ticked me off. Perhaps someday he'll realize that there's a universe of difference between "enabling" and "implementing".


Arg[v]!  Talking behind back!  OH NO!!!  OHHH NOO!

Anyway, I was tired! :) [That's my excuse for everything.]
Title: Multiple Dockees per Ship
Post by: Goober5000 on December 29, 2002, 01:33:12 am
Quote
Originally posted by Sesquipedalian
Well, Goober5000 does seem to know what he is doing with the code. I'd expect it to be a significant amount of coding to make this work, but if he thinks he can do it, I'm all in favour.  :D


I sense that I'm being drafted again... :nervous:

I skimmed it, and it looks like most of the docking stuff will work no matter how many ships are docked - the rest is the problem of implementing arrays rather than scalars, plus changing all the docking sexps and AI, and cleaning up loose ends.

I'll have another look at it, but I'm not promising any quick results.  I need a wee break. :)
Title: Multiple Dockees per Ship
Post by: Sesquipedalian on December 29, 2002, 02:29:34 am
:D  I thought you were tentatively volunteering.
Thanks for all your sexp work.  You're my new best SCP friend. :D
Title: Multiple Dockees per Ship
Post by: diamondgeezer on December 29, 2002, 02:50:12 am
Goober, if this idea is possible to implement, please at least add it to the To Do list. Multiple docks would be really handy :nod:

Anyone remember the GTI Polaris? The spec said the GTVA would dock as many of them together as they needed, to get a base of the size they needed. If the multiple dock thing gets done, we could dock millions of things together and make... um... teh uber-docked thingie! Woo!
Title: Multiple Dockees per Ship
Post by: Goober5000 on December 29, 2002, 09:17:25 am
:)

Maybe I was (tentatively volunteering).  I'll add it to my To Do list.  I'll have to puzzle it over for a while, but I think I may be able to do it.

And Sesq: once I got a few sexps under my belt, they became extremely easy.  The only hard part was figuring out what extra struff needed to be coded outside of sexp.cpp. :)
Title: Multiple Dockees per Ship
Post by: ZylonBane on December 29, 2002, 10:59:46 am
Quote
Originally posted by diamondgeezer
If the multiple dock thing gets done, we could dock millions of things together and make... um... teh uber-docked thingie! Woo!
And imagine the physics nightmare when one of the ships decides it wants to move. Like I said, non-trivial.
Title: Multiple Dockees per Ship
Post by: Goober5000 on December 29, 2002, 02:35:23 pm
Just add up the respective components of mass and velocity.  I'm sure they do it that way already - suppose just two docked ships try to move?
Title: Multiple Dockees per Ship
Post by: aldo_14 on December 29, 2002, 02:49:08 pm
Quote
Originally posted by ZylonBane
And imagine the physics nightmare when one of the ships decides it wants to move. Like I said, non-trivial.


Easiest way (could? - depends if you can sort of set movement to 0 easily..maybe an AI switch to 'none'?) would be to lock the docked ships IMO.  So only the docked-to ship can move... actually, that sort of thing would be useful in fighter carrying (on pylon) ships...

actualkly, does the engine transfer the momentum of a capship to the fighters exiting from a fighterbay?  I've got a feeling that it doesn;t, but not too sure.....
Title: Multiple Dockees per Ship
Post by: ZylonBane on December 29, 2002, 07:13:43 pm
Quote
Originally posted by Goober5000
suppose just two docked ships try to move?
Suppose they tried to move in opposite directions. :eek:

The engine already has occasional glitches with docked ship movement. Realistically, any multi-docking scheme will have to assign movement privileges to just one ship in the docking chain. The problem will be determing which ship it gets to be. It may very well be necessary to create a new SEXP for this purpose.

Even in this simplified case, pity the poor guy who has to implement the movement-propagation code. With truly unlimited docking, you could easily end up with multiple branching linked lists of dockee data.
Title: Multiple Dockees per Ship
Post by: mikhael on December 29, 2002, 08:12:12 pm
Use the Iwar2 method for determining movement: compare ship mass.

This is by no means complete, but if you implement your dock chain as a list structure, you can traverse the list and total masses on the way until you hit an end point. If a ship tries to move, it has to  overcome the combined mass of objects to which it is docked. Traverse the list, total the masses, compare the total to the output of the attempted movement vector and you know if something gets to move or not.

Don't try to get fancy and calculate cumulative affects of multiple ships trying to overbear a larger ship (that way lies madness). If you force docking points to be oriented in the same direction on all ships (ie, ships always dock parallel with noses pointed in the same direction) you don't need to worry about tug of war situations. Either ship in a docked pair can break the dock any time (seperating the list into a pair of lists). Of course, to simplify further, player ships only need to have 1 ship-to-ship dock point (not much of an issue in Freespace, since no one is tugging cargo pods).

In other words, cheat.
Title: Multiple Dockees per Ship
Post by: Goober5000 on December 29, 2002, 08:12:54 pm
EDIT: This post is in response to ZylonBane--

That makes it sound very complicated; I don't think it needs to be.  Every docked ship acts as one mass, so all we need to do is take every ship's velocity component and apply it toward the one mass.

Maybe do it this way: Divide each ship's velocity by its mass, then add all of the vector results together.  Apply the final vector sum to the whole thing.

It's all physics; it shouldn't have anything to do with privilege.


EDIT: I think mikhael and I have approximately the same idea. :)
Title: Multiple Dockees per Ship
Post by: Sesquipedalian on December 30, 2002, 12:40:35 am
What happens now when two ships are docked and try to move in different directions?  The engine has to deal with it somehow.  Either the two ships already have a system in place for fighting it out, or one already is being given preference.  I'm not sure which scenario is true, but whichever it is, why should it suddenly no longer work?  In other words, I am questioning the assumption that we even have to come up with a system for this:  one is already there and works, and there seems no reason, according to either scenario, to think it would stop if we added another ship in.
Title: Multiple Dockees per Ship
Post by: Bobboau on December 30, 2002, 01:01:00 am
just have one parent ship that is the only thing that has the ability to move, if anyone else trys it does nothing
Title: Multiple Dockees per Ship
Post by: Anaz on December 30, 2002, 01:02:38 am
sesq has it right IMO. We have the docker and the dockee. Throw physics out the window, the dockee has control over the whole thing.
Title: Multiple Dockees per Ship
Post by: ZylonBane on December 30, 2002, 01:52:21 am
Well, no. Once you allow unlimited arbitrary docking, the whole concept of docker/dockee goes right out the window. If A is docked to B, but B is then docked to C, then B is both a docker AND a dockee.

Hmmm.... I suppose you could determine the "owner" of a docking group by recursively walking the docked ships tree and finding the one ship that's not a docker. Assuming that dockers are one-to-one, and dockees are one-to-many, I think it's impossible to dock multiple ships in such a way that more than one is a dockee but not a docker. To save CPU time, this could be calculated only every time a docking/undocking occurs, and stored as part of each docked ship's local data.

Under this scheme, each docker would effectively be docked to two ships-- the ship it's logically attached to, and the ship it gives up its physics to. Hopefully the code that makes docked ships appear physically attached (eg, translates their parent's movement & rotation) can be extended to multiple ships in this fashion without too much pain.

Hmmm...
Title: Multiple Dockees per Ship
Post by: Rampage on January 01, 2003, 02:04:04 pm
Yes, the problems with physics...

So how about it, a release for fs_open3.5? :nod:
Title: Multiple Dockees per Ship
Post by: Goober5000 on January 01, 2003, 02:16:46 pm
Mebbe. :)

I'll look into it.  Later. ;)
Title: Multiple Dockees per Ship
Post by: Rampage on February 11, 2003, 05:38:37 pm
Okay...  We should revive this.  All we want is simple:

1. For a freighter with multiple points dock with multiple cargo.
2. For a ship with multiple points dock with multiple vessels when NOT MOVING!!!!  (Forget the centripetal forces and related physics problems that deal with moving targets.)

Rampage
Title: Multiple Dockees per Ship
Post by: Galemp on February 11, 2003, 07:56:02 pm
OK, I've got an idea. We have singledock ships, and multidock ships. Multidock ships are not allowed to dock with other multidock ships. This way no ship can be both a docker and dockee.

Multidocks include capital ships (cruiser and above,) installations and freighters. We can have the code read a 'multidock' tag or something in the table. Everything else is single docking like it is now.

This would prevent chain docking, and you're not going to have a Fenris and an Arcadia actually dock with each other, so that's OK. Is this feasable?
Title: Multiple Dockees per Ship
Post by: StratComm on February 11, 2003, 08:40:22 pm
How about, rather than prevent a capital ship and installation from docking with each other, not allow other ships to dock to either if one is docked to the other.  I have a particular drydock mod that relies on Capital ship docking, and I'd like the source to allow that if possible.
Title: Multiple Dockees per Ship
Post by: Stryke 9 on February 11, 2003, 09:26:41 pm
How 'bout you just tell people not to do anything fantastically stupid, and you won't have any problems?

I don't see a situation in which you'd have, say, a freighter docked to a cargo pod docked to a fighter docked to another freighter docked to a capship and the Volition Bravos, anyway. Capships dock to fighters and other capships, but you wouldn't have huge branching chains of capships, anyway, you'd have only one on one (and maybe on one on one on one on one), because you'd have to go out of your way from modeling the ship on up to make it able to dock to two or three capships at once, and since it'd look as silly as it'd really be, nobody would do that anyway. And capships don't need more than a couple dock points anyway. Freighters only dock to their cargo.

Honestly, the only reason someone would try to make a long, awkward, branching chain of docked vessels, and then try to move them, is if they were looking for trouble in the first place. You can make the SCP idiot-proof, but you can't account for the creativity of idiots, or the extent they'll go to to **** themselves over, and I don't recommend you try. I can guarantee that if the sort who stick paperclips in wall sockets got their hands on a copy of the current SCP, they'd find a way to make it crash.



You're overcomplicating this. If you want, you can include a stern warning in the readme to make branched docking chains at one's own risk, but seeing as it's an extremely unlikely use to ever come up, and at worst the program will just crash, not leap off their hard drive, kill their dog, and schtup their mother, I think it's fair to say it's okay if someone tries once and learns their lesson.



And that's my contribution for the year.:D
Title: Multiple Dockees per Ship
Post by: Sesquipedalian on February 11, 2003, 09:44:59 pm
Well said.