December 22, 2024, 04:57:16

Author Topic: GetDockPoint not working?  (Read 13859 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
GetDockPoint not working?
« on: January 24, 2010, 16:50:53 »
Does this actually work for anyone? The syntax is supposedly:

Code: [Select]
GetDockPoint(ship, index, outer);
However, the game insists I'm givin an invalid dockpoint index, although I'm pretty sure it's the right one (since I receive that index from a docking boat with E.ship:dockpoint).

Any idea how to get the coordinates for a docking point then?

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #1 on: January 24, 2010, 17:16:50 »
I must say that I've never used it before, what is it for?

FYI: Coordinates for docking points are included in the mesh, but I guess you already know that.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #2 on: January 24, 2010, 17:26:50 »
The command should theoretically return the coordinates of a docking point, which I need to display a certain effect using PlayEfx... so I hooked up the Arriving event (which gets fired when boats start their docking approach) and tried something like that:

Code: [Select]
RULE event Arriving
:action
dock := GetDockPoint(E.ship:dockTarget, E.ship:dockPoint, 0);
PlayEfx(42, E.ship:radius, dock.x, dock.y, dock.z);
:end
END

But it fails at GetDockPoint every time telling me about an invalid dockpoint index. I also tried to supply the index manually, but it either gives me the same error when the value is less or equal than NumDockPoints(E.ship:dockTarget) or just 0, if it's greater than that.

Seems bugged to me :(

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #3 on: January 24, 2010, 17:36:08 »
what does it tell you if you debug those values? (e.ship:dockpoint, e.ship:docktarget)

nevermind, just tested it. Dunno why it happens... yeah, it does seem bugged

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #4 on: January 24, 2010, 22:38:25 »
Just a thought or two...

What exactly are you defining with the E.ship variable here? The strikecraft or the mothership?

What I'm wondering is...

With the 'E.ship:dockPoint' could the game be thinking that you're requesting a dockpoint on the docking strikecraft and not it's target dock?
Or alternatively could it be thinking that you're asking for the motherships dock target? And therefore needs you to define the docking strikecraft instead?

I could be completely wrong here, but it's a theory that came to mind.

P.S.

While we're discussing broken commands,  has anyone had any problems with the 'EndTraffic' command. Whenever I tried it, nothing happened.
Better to look the fool by asking, then prove them right with ignorance.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #5 on: January 24, 2010, 22:51:39 »
Quote from: The Old Dragon
What exactly are you defining with the E.ship variable here? The strikecraft or the mothership?
That's defined by the Arriving event: E.ship is the docking boat, E.location is the targetted capital ship. Of course, E.ship:dockTarget and E.location should be the same ship (they are in my case) and E.ship:dockPoint supposedly gives the index of the targetted docking point of the capital ship. Those values seem to be correct as I already had 8 fighters docking simultaneously and each reported a different index. But when feeding this index into the GetDockPoint command, I get the error about having given an invalid index. One of those "WTF?"-moments, it seems...

EndTraffic broken? I don't think so. I remember it having worked before, although the already active traffic will continue to fly to their destination. EndTraffic just stops any new shuttle launches. At least that's what I remember... haven't used it in quite a while.

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #6 on: January 25, 2010, 00:13:23 »
Done some experimenting and got a slightly different result.
By setting the 'index' value to zero, I got the a debug result of '(0,0,0)'.  Not sure if it helps or exactly what this result means, but at least it isn't an error message.

As for the 'EndTraffic', I've not used it for a long time either, I just remember it not appearing to  respond when I last did.
Better to look the fool by asking, then prove them right with ignorance.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #7 on: January 25, 2010, 00:23:25 »
Quote from: The Old Dragon
By setting the 'index' value to zero, I got the a debug result of '(0,0,0)'. Not sure if it helps or exactly what this result means, but at least it isn't an error message.
That's what I got, too, but it's hardly a valid value for one of the ship's docking points.

To elaborate further: you can get the total amount of docking points (including breaching points) using NumDockPoints(ship). This returns "18" for my shipclass. Now if I enter any index from 1 to 18 into the GetDockPoint(ship, index, outer) command, I'll get the error message about an invalid index. If I enter anything else like 0 or 5000, I'll get a result of 0. I also tried -999999, which surprisingly gives me SOME vector, but it's clearly nonsense and not an actual docking point... maybe it's in some way related to the real docking points, but I don't know how :(

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #8 on: January 25, 2010, 00:46:07 »
I looked at all the missions written by Mithis, but couldn't find any reference to this command... perhaps it was never used, hence never tested and that's why it's bugged..

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #9 on: January 25, 2010, 01:31:06 »
It is used... kinda... in universetacticssubroutinesmovie_camera.ini:

Code: [Select]
// csonak dokkolasanak figyelese
// Launching, vagy Arriving eventbol erdemes meghiVNi
// (ha a csonak epp nem dokkol, nem tortenik semmi)
// E.ship - a hajo
// E.target - a celobjektum
// E.time - az odamozgas ideje
RULE event MovieCam_Docking
condition E.ship:docking>=2
:action
LocalEvent(MovieCam_StopAll, 0);
CamGoRound(0);
din := GetDockPoint(E.ship:docktarget, E.ship:dockpoint, 0);
dout := GetDockPoint(E.ship:docktarget, E.ship:dockpoint, 1);
dir := VNorm(vsub(dout,din));
pos := VAdd(dout, VMul(3*E.ship:radius,dir));
pos := VAdd(pos, VMul(2*E.ship:radius,VRandomOrth(dir)));
CamLocate(E.ship:docktarget,2,pos,0,0, E.ship:docktarget,2,din,0,0, 0, E.time);
:end
END
That's more or less the same as my code, though, and a simple copy&paste test yielded the same results. This particular event (MovieCam_Docking) also isn't being used anywhere... guess they planned to use it at some point and later canned the idea. Or they used it once somewhere, when that command was still working as intended, but removed or rewrote that script afterwards before some other change broke the GetDockPoint command.

Damn, I really needed that to get the proper effect :(

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #10 on: January 25, 2010, 03:34:29 »
Yep. Just tested. Worked great on a campaign mission.

EDIT: I also tested it on the regular modification game view, not the editor, and it worked great, too. Perhaps the error is in the editor, only. Also, odd enough, if you press "ignore" on the editor's error message the command will work great.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #11 on: January 25, 2010, 08:14:47 »
Wait, what?  8|

*testing* ... damn, works indeed. I should have looked closer at that MovieCam_Docking code to notice the coordinates being used as relative coordinates in relation to the ship's center. I somehow assumed those were absolute coordinates and thought the EFX popping up next to the center of the map being the bugged GetDockPoint command... but the EFX were just misplaced, because of me interpreting the coordinates wrongly... ;)

Now it works like a charm, at least in the full game... still gives errors in the editor, though.

Code: [Select]
RULE event Arriving
:action
// get relative coordinates of targetted docking point
E.dock := GetDockPoint(E.ship:dockTarget, E.ship:dockPoint, 0);
// get rotational information about targetted ship
E.tran := XfRot(E.location:heading, E.location:pitch, E.location:bank);
// rotate relative coordinates of docking point and calculate absolute coordinates
E.pos := VAdd(VXform(E.dock, E.tran), E.ship:dockTarget:position);
// show warp effect
PlayEfx(42, E.ship:radius, pos, 0, 0);
:end
END

I'm using this to simulate fighters warping in and out of the scene. Nexus doesn't support fighters without having a carrier to launch them from, but only the biggest ships in Freespace actually have hangars. I wanted to have fighter wings also accompany smaller ships like cruisers without their own hangar bay, so I'm abusing the docking/undocking mechanism to look like a warp-in/warp-out effect. Works like a charm, with the missing warp-out effect now finally in place. Thanks, Mularac! :)

... btw, anyone knows how to recognize, if we're in the editor or not just using script commands?

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #12 on: January 25, 2010, 15:47:32 »
one thing dazzles me, how do you make the fighters appear from the warp or head to the warp position instead from/to the ship's hangar?

BTW: Excellent efx, it's the same as the one in Freespace! how did you do it? Efx and textures? or is it a mesh?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #13 on: January 25, 2010, 16:20:53 »
The Aeolus doesn't have a hangar bay, so I put the docking points in free space next to the ship's model. Right now there are 8 docking points, which allow at least two full squadrons to appear at once. Fighters appearing out of nowhere doesn't look right, though, so I use scripting to display an animated texture at the coordinates of the docking point (where the fighters appear or disappear). The texture contains the typical Freespace warp-in effect and is being displayed using a custom EFX and PARTICLE entry, which I insert in the scene using PlayEfx(#, size, x, y, z).

The rule for the warp-out is above, for the warp-in it's just one line of code:
Code: [Select]
RULE event Launching
:action
 PlayEfx(42, E.ship:radius, E.ship:position, 0, 0);
:end
END