Author Topic: Is there an easier way to do this?  (Read 4123 times)

0 Members and 1 Guest are viewing this topic.

Offline Doko

  • 26
Is there an easier way to do this?
So the other day I was messing around with fred and decided it would be really cool to have the player relay jump coordinates to a ship and make it spawn in front of you. Unfortunately the options to do this in FRED seem really lacking.... Near ship is not precise enough for big ships and in front of ship means "in a huge ass cone in front of a ship".

Since apparently you can't position objects present in the mission that have not yet arrived I decided to cheat and make it look like a ship is arriving with a warp effect, an object position change and some speed control.  SEXPs are a bit too long to post here so just check mission file if you are interested.

I'm glad I got it working, but there are some side effects, each ship requires tunning to keep the illusion of the warp effect and for larger capital ships I don't think it would look all that good if viewed from the side. Another problem I found with this method is that the game will not allow you to give Z speed (relative to object) if the engines are still working so I had to take those out for the duration.

Still I can't help but wonder if there's an easier way to do this that I totally missed.

Mission requires BP as I used a diomedes for the test.
-- ALT + X to trigger the warp.
-- ALT + R to reset the camera back to the player

edit: updated file!
Every-time was breaking weapon collision...

[attachment DELETED!! by Strong Bad]
« Last Edit: November 19, 2015, 06:34:30 am by Doko »

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Is there an easier way to do this?
You're right that you can't re-position a ship that hasn't arrived. You can, however, change it's arrival settings. You want Set-Arrival-Info. Specifically take a look at setting the arrival anchor and distance. My solution would be to position an invisible object as a marker (targettable for the player) in front of his ship every frame. Give him some distance choices, too. (Perhaps Press 1 to increase distance by 50m, 2 to decrease?)

Then some key press for the player to choose the position. At that frame, stop moving the invisible marker and set that as the new arrival anchor. I'm unsure if the ship will warp in directly on that spot, but it should be pretty close? Not something I can test while at work.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Is there an easier way to do this?
That's exactly what I'd do. Make the ship's arrival anchor a waypoint (if possible) or an invisible invulnerable no-collide ship, make the anchor move around with the player, let the player decide where to drop it.

Use 'when' with a high repeat count, don't use every-time, it's pretty scary and can **** up mission performance.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Is there an easier way to do this?
I use every-time every time... which causes problems every time...
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Is there an easier way to do this?
Use 'when' with a high repeat count
You should use infinite repeat counts instead :cool:
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Is there an easier way to do this?
Use 'when' with a high repeat count
You should use infinite repeat counts instead :cool:

Tell me how  :eek:

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Is there an easier way to do this?
-1 = infinite

currently FRED doesn't let you type "-" but doesn't stop you from copy&pasting it in (plus there's always editing the mission file directly).

EDIT: This isn't a new thing, by the way; it's been an undocumented feature for years. I just recently made an infinite trigger count work more like you'd expect, rather than behaving exactly like infinite repeat count.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Is there an easier way to do this?
I think my brain just exploded.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Doko

  • 26
Re: Is there an easier way to do this?
Set-Arrival-Info

4: Arrival path mask (optional; defaults to 0; note that this is a bitfield)

How do you use this?
« Last Edit: November 19, 2015, 09:32:57 pm by Doko »

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Is there an easier way to do this?
I have nooo idea what that is.

 

Offline Axem

  • 211
Re: Is there an easier way to do this?
Arrival/departure path masks are binary masks that let you decide which fighterbay launch paths to use from a mothership. For example in Diaspora, you don't want fighters to depart to the launch tubes. (Though it would save the chief a lot of time...)

So 0 means, use any path. Setting a specific bit to 1 will say "don't use this path number (minus 1, since the index starts at 0, not 1)".

I hope that makes sense...

 

Offline Doko

  • 26
Re: Is there an easier way to do this?
Unless set-arrival-info can provide an origin and target for the warp in, I don't see this being useful if you require any level of precision in the jump except to set roughly different points of arrival based on player input.
Someone write a "in front of ship (new)" that is actually in front! would make this so easy ;D

---
Axem replied as I wrote this:

Thanks for the explanation, that makes sense!

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Is there an easier way to do this?
Arrival/departure path masks are binary masks that let you decide which fighterbay launch paths to use from a mothership. For example in Diaspora, you don't want fighters to depart to the launch tubes. (Though it would save the chief a lot of time...)

So 0 means, use any path. Setting a specific bit to 1 will say "don't use this path number (minus 1, since the index starts at 0, not 1)".

I hope that makes sense...

That's correct but backwards.  Setting the path mask to anything but zero means use only the paths whose bits are set.  So setting it to 40 would mean to use only paths 3 and 5 (2^3 = 8 plus 2^5 = 32) but not path 4.

The reason zero means "use all paths" is because there's no point setting a ship to arrive from a mothership when no paths on that ship are allowed.  It's a special case.  The standard case is to use a number with all bits set to 1.

I think I'll update the sexp help.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Is there an easier way to do this?
What happens with that SEXP if we ever have a ship with more than 32 paths?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Is there an easier way to do this?
Divide by zero.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Is there an easier way to do this?
It only becomes a problem if you want to allow one of the paths at index 32 or higher without allowing them all.  In that case, you're out of luck.  Maybe we could convert that sexp argument to a string and use something like BigInteger.

Note that the bitfield only applies to hanger bay paths, not all possible paths.  The rest of the ship can have as many paths as it wants without affecting the bay path numbering.
« Last Edit: November 20, 2015, 08:46:11 pm by Goober5000 »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Is there an easier way to do this?
Yeah, I know that it only affects hanger bay paths but the problem is that the Theseus already has 24 and the Galactica and Pegasus supposedly have 80 viper launch tubes. Which probably will mean the SEXP as is would end up only working for one of the two flight pods.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Is there an easier way to do this?
Well, in that case the problem is broader in scope than the sexp.  The existing arrival_path_mask and departure_path_mask fields in p_object and wing only hold 32 bits.  This is enforced by MAX_SHIP_BAY_PATHS.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Is there an easier way to do this?
Yeah, I guessed that would be the case. I'll have to see about updating those at some point then.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]