Author Topic: Rotation and subsystem positions  (Read 1539 times)

0 Members and 1 Guest are viewing this topic.

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Rotation and subsystem positions
I have a question ,how to get and set rotation in FRED.
I would like to:
1. Get the rotation of the ship.
2. Make this ship disappear. (ship vanish)
3. Move the player ship to it's location. (set object x ,y and z)
4. Set the rotation of player ship to the same as previous ship had.
5. Change the class of a player ship. (change ship class)

This will enable taking control of another ship.
I would like also to be able to reverse the process ,by doing this:
1. Get subsystem position of a player ship.
2. Get rotation of a player ship.
3. Move the player ship to subsystem location. (set object x ,y and z again)
4. Change class of a player ship. (change ship class)
5. Create ship of the same class as previous class of player ship ,on the same place and with the same rotation. (ship create ,though it will not resolve rotation problem)

I would like to make the player ship to appear in a fighterbay of a ship player previously piloted ,leaving in place ship left by player and I have no idea how to do it.
I hope somebody will respond ,I think it's a very difficult or maybe even impossible idea.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Rotation and subsystem positions
Sounds like you've got an exact handle on what to do. All you need to do is turn your bullet points into SEXPs.

I will agree with you that it isn't easy. There's some fairly complicated SEXPing involved here. You're probably going to need to use variables to store information in. What you describe is definitely possible however. I did something similar (but more complex) in MindGames years ago. The only SEXP you need that I didn't see you name was set-object-facing (which if used correctly will get you the rotations you want).

Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Rotation and subsystem positions
In fact ,I done it before but it didn't worked as I desired.
I tried with set-object-facing ,but I simply got lost in those SEXPs.
Can you tell me how exactly you did it?
I tried to make ship face point 10m ahead of it's center ,it's quite difficult for
me to explain so I will just post the code:

Code: [Select]
$Formula: ( every-time
   ( and
      ( = @Ident[0] 1 )
      ( key-pressed "1" )
   )
   ( set-object-position
      "ISS Colossus"
      0
      0
      0
   )
   ( set-object-facing
      "ISS Colossus"
      ( get-object-x
         "Alpha 1"
         "<none>"
         ( get-object-x "Alpha 1" )
         ( get-object-y "Alpha 1" )
         ( get-object-z "Alpha 1" )
      )
      ( get-object-y
         "Alpha 1"
         "<none>"
         ( get-object-x "Alpha 1" )
         ( get-object-y "Alpha 1" )
         ( get-object-z "Alpha 1" )
      )
      ( +
         ( get-object-z
            "Alpha 1"
            "<none>"
            ( get-object-x "Alpha 1" )
            ( get-object-y "Alpha 1" )
            ( get-object-z "Alpha 1" )
         )
         100
      )
   )
   ( set-object-position
      "Alpha 1"
      ( get-object-x
         "ISS Colossus"
         "<none>"
         ( get-object-x "ISS Colossus" )
         ( get-object-y "ISS Colossus" )
         ( get-object-z "ISS Colossus" )
      )
      ( -
         ( get-object-y
            "ISS Colossus"
            "<none>"
            ( get-object-x "ISS Colossus" )
            ( get-object-y "ISS Colossus" )
            ( get-object-z "ISS Colossus" )
         )
         160
      )
      ( +
         ( get-object-z
            "ISS Colossus"
            "<none>"
            ( get-object-x "ISS Colossus" )
            ( get-object-y "ISS Colossus" )
            ( get-object-z "ISS Colossus" )
         )
         70
      )
   )
   ( change-ship-class
      "TIE Avenger"
      "Alpha 1"
   )
   ( change-ship-class
      "Imperial Star Destroyer"
      "ISS Colossus"
   )
   ( ship-unstealthy "ISS Colossus" )
)
+Name: LaunchColly
+Repeat Count: 1
+Interval: 1
+Team: 0

$Formula: ( every-time
   ( <
      ( distance-ship-subsystem
         "Alpha 1"
         "ISS Colossus"
         "Fighterbay"
      )
      20
   )
   ( set-object-position
      "Alpha 1"
      ( get-object-x "ISS Colossus" )
      ( get-object-y "ISS Colossus" )
      ( get-object-z "ISS Colossus" )
   )
   ( set-object-facing
      "Alpha 1"
      ( +
         ( get-object-x
            "ISS Colossus"
            "<none>"
            ( get-object-x "ISS Colossus" )
            ( get-object-y "ISS Colossus" )
            ( get-object-z "ISS Colossus" )
         )
         100
      )
      ( +
         ( get-object-y
            "ISS Colossus"
            "<none>"
            ( get-object-x "ISS Colossus" )
            ( get-object-y "ISS Colossus" )
            ( get-object-z "ISS Colossus" )
         )
         100
      )
      ( +
         ( get-object-z
            "ISS Colossus"
            "<none>"
            ( get-object-x "ISS Colossus" )
            ( get-object-y "ISS Colossus" )
            ( get-object-z "ISS Colossus" )
         )
         0
      )
   )
   ( change-ship-class
      "Marker"
      "ISS Colossus"
   )
   ( change-ship-class
      "Imperial Star Destroyer"
      "Alpha 1"
   )
   ( modify-variable @Ident[0] 1 )
   ( ship-stealthy "ISS Colossus" )
)
+Name: DockColly
+Repeat Count: 1
+Interval: 1
+Team: 0

$Formula: ( every-time
   ( <
      ( distance-ship-subsystem
         "Alpha 1"
         "PVS Privateer"
         "Fighterbay"
      )
      20
   )
   ( set-object-position
      "Alpha 1"
      ( get-object-x "PVS Privateer" )
      ( get-object-y "PVS Privateer" )
      ( get-object-z "PVS Privateer" )
   )
   ( set-object-facing
      "Alpha 1"
      ( get-object-x
         "PVS Privateer"
         "<none>"
         ( get-object-x "PVS Privateer" )
         ( get-object-y "PVS Privateer" )
         ( get-object-z "PVS Privateer" )
      )
      ( get-object-y
         "PVS Privateer"
         "<none>"
         ( get-object-x "PVS Privateer" )
         ( get-object-y "PVS Privateer" )
         ( get-object-z "PVS Privateer" )
      )
      ( +
         ( get-object-z
            "PVS Privateer"
            "<none>"
            ( get-object-x "PVS Privateer" )
            ( get-object-y "PVS Privateer" )
            ( get-object-z "PVS Privateer" )
         )
         100
      )
   )
   ( ship-vanish "PVS Privateer" )
   ( change-ship-class
      "Imperial Star Destroyer"
      "Alpha 1"
   )
   ( modify-variable @Ident[0] 2 )
)
+Name: DockPriv
+Repeat Count: 1
+Interval: 1
+Team: 0

$Formula: ( every-time
   ( and
      ( = @Ident[0] 2 )
      ( key-pressed "1" )
   )
   ( ship-create
      "PVS Privateer"
      "Imperial Star Destroyer"
      ( get-object-x "Alpha 1" )
      ( get-object-y "Alpha 1" )
      ( get-object-z "Alpha 1" )
      0
      0
      0
   )
   ( set-object-facing
      "PVS Privateer"
      ( get-object-x
         "Alpha 1"
         "<none>"
         ( get-object-x "Alpha 1" )
         ( get-object-y "Alpha 1" )
         ( get-object-z "Alpha 1" )
      )
      ( get-object-y
         "Alpha 1"
         "<none>"
         ( get-object-x "Alpha 1" )
         ( get-object-y "Alpha 1" )
         ( get-object-z "Alpha 1" )
      )
      ( +
         ( get-object-z
            "Alpha 1"
            "<none>"
            ( get-object-x "Alpha 1" )
            ( get-object-y "Alpha 1" )
            ( get-object-z "Alpha 1" )
         )
         100
      )
   )
   ( set-object-position
      "Alpha 1"
      ( get-object-x
         "Alpha 1"
         "<none>"
         ( get-object-x "Alpha 1" )
         ( get-object-y "Alpha 1" )
         ( get-object-z "Alpha 1" )
      )
      ( -
         ( get-object-y
            "Alpha 1"
            "<none>"
            ( get-object-x "Alpha 1" )
            ( get-object-y "Alpha 1" )
            ( get-object-z "Alpha 1" )
         )
         160
      )
      ( +
         ( get-object-z
            "Alpha 1"
            "<none>"
            ( get-object-x "Alpha 1" )
            ( get-object-y "Alpha 1" )
            ( get-object-z "Alpha 1" )
         )
         70
      )
   )
   ( change-ship-class
      "TIE Avenger"
      "Alpha 1"
   )
)
+Name: LaunchPriv
+Repeat Count: 1
+Interval: 1
+Team: 0


This made either ship face really weird direction after docking ,can you tell me what I done wrong?
I'm using modified TIE Avenger from IA multiplayer demo and ISD from the same place (also modified).
It has been made on an old Inferno build (the most recent one at the time before you made mulltiplayer INF build)

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Rotation and subsystem positions
( set-object-position
      "Alpha 1"
      ( get-object-x
         "ISS Colossus"
         "<none>"
         ( get-object-x "ISS Colossus" )
         ( get-object-y "ISS Colossus" )
         ( get-object-z "ISS Colossus" )
      )
)

Returns the same point as

( set-object-position
      "Alpha 1"
      ( get-object-x
         "ISS Colossus"
      )
)

What you need to do is pick a point in front of the Colossus and make the ship point to that.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Rotation and subsystem positions
Yes ,it worked well on a stationary ship ,but if player will fly around a bit ,launch and then will want to get back to ship ,this ship may be in completely different position ,so I need to find a method of getting it's rotation regardless of it's current position. Adding 10 to one coordinate and setting it to relative to ship also won't help ,because of situation when ship is pointing ,for exapmle upward.
And thanks for pointing this unnessesary complication ,it will help me when FREDing.