Author Topic: Rotating a moving warship  (Read 3731 times)

0 Members and 1 Guest are viewing this topic.

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Rotating a moving warship
So I've hit a bit of an obstacle.

I have a situation where when an enemy warship loses it's port-side beams, it rotates to bring it's starboard to bare. It works when it's stationary, but when the ship loses the beams while following a waypoint path it slows to a stop and remains still until the duration of the maneuver ends, then continues along the waypoint path.

Event is as follows:

Code: [Select]
When
        and
             is-subsystem-destroyed-delay
                  strider
                  turret12
                 0
             is-subsystem-destroyed-delay
                  strider
                  turret24
                 0
        ship-maneuver
             strider
             3000
             0
             0
             100
             true
             0
             0
             0
             true

I'm guessing there's a conflict between the waypoint and the sexp? I searched around and attempted a few changes to the sexp (when to every-when) but no dice.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: Rotating a moving warship
I'm guessing there's a conflict between the waypoint and the sexp? I searched around and attempted a few changes to the sexp (when to every-when) but no dice.

Quote from: ship-rot-maneuver SEXP
You may find it necessary to disable the ship AI (e.g. by issuing a play-dead order) before running this sexp.

That line is omitted from the description of ship-maneuver

A quick fix would be to have a copy of the original waypoint path, which has the coordinates of the first waypoint set to fixed position in front of the ship until/when the rotation is supposed to trigger. As soon as the maneuver is supposed to trigger, have the ship stop by clearing its orders and setting them to play-dead. Then perform the rotatation and then let the ship move on the copied path.
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
Made a test scenario, but unfortunately that did not work. The forward velocity worked (yay!), even when the ship hadn't received the first waypoint (going to need another event to keep it from moving I think), but the ship refused to roll. Here's what I did:

Code: [Select]
Waypoint 1
    when
        has-time-elapsed
            15
        add-goal
            Deimos
            ai-waypoint-once   
                Waypoint path 1
                89

Play dead
    when
        is-subsystem-destroyed-delay
            Deimos
            turret03
            0
        clear-goals
            Deimos
        add-goal
            Deimos
            ai-play-dead
                89

Deimos roll
    when
        is-event-true-delay
           play dead
           0
        ship-maneuver
             deimos
             30000
             0
             0
             100
             true
             0
             0
             100
             true
        send-message (used to double confirm the event fired)

Waypoint 2
    when
        and
            is-event-true-delay
                Waypoint 1
                0
            is-event-true-delay
                Deimos roll
                30
        add-goal
           Deimos
           ai-waypoint-once
               Waypoint path 2
               89

Also is there a easier way for me to post the events instead of typing them all down? I should've asked this earlier :p.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rotating a moving warship
Shooting from the hip here, I might be wrong, but did you specify a roll velocity AND a forward velocity in that ship-maneuver?

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
Shooting from the hip here, I might be wrong, but did you specify a roll velocity AND a forward velocity in that ship-maneuver?

Yup.

(Did I do something wrong?)

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rotating a moving warship
I don't have FRED handy and am probably just wasting your time, but make sure the '100' values are in the exact right place for a forward (z-axis) translation AND a roll, as specified by the sexp's help text.

 
Re: Rotating a moving warship
Here is the SEXP from INF Nostos for a similar maneuver to the one you described. It looks almost identical, my guess is that this SEXP is never executed when the ship has a goal (even ai-dead), but I'm not sure.

Code: [Select]
   ( clear-goals "Empress" )
   ( ship-maneuver
      "Empress"
      75000
      0
      0
      -100
      ( true )
      0
      0
      100
      ( true )
   )

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
Ah! That worked. Seemed I just needed that additional clear goals.

One problem remains though - If the ship's turret is destroyed before it's waypoint activates, the ship will rotate but then stop rotating when the waypoint activates, rather then finishing the complete roll (while preferably beginning to move too).

 

Offline Mito [PL]

  • 210
  • Proud Member of Slavicus Mechanicus
Re: Rotating a moving warship
Also is there a easier way for me to post the events instead of typing them all down? I should've asked this earlier :p.
You can open mission/campaign files in text editors. IIRC people even made some kind of FRED syntax support plugin for Notepad++.
How do you kill a hydra?

You starve it to death.

 
Re: Rotating a moving warship
Ah! That worked. Seemed I just needed that additional clear goals.

One problem remains though - If the ship's turret is destroyed before it's waypoint activates, the ship will rotate but then stop rotating when the waypoint activates, rather then finishing the complete roll (while preferably beginning to move too).

Easiest way would be to insert the delay (30 sec) into the condition for the waypoint events, if the player doesn't understand send a message "we have to complete our maneuver first" or try set-object-facing.

 

Offline DefCynodont119

  • 210
  • Ascended GTSC-Faustus Artist
    • Steam
Re: Rotating a moving warship
And then there is always the brute-force option of setting the turrets to be guardianed so they can only be destroyed when the mission allows.
My gift from Freespace to Cities Skylines:  http://steamcommunity.com/sharedfiles/filedetails/?id=639891299

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rotating a moving warship
Ah! That worked. Seemed I just needed that additional clear goals.

One problem remains though - If the ship's turret is destroyed before it's waypoint activates, the ship will rotate but then stop rotating when the waypoint activates, rather then finishing the complete roll (while preferably beginning to move too).

Have the rotation event set a 'rotation in progress' var to 1, then, when the rotation's complete, set it back to 0 (probably a chained event is the easiest way).

Make the waypoint activation require the var to == 0.

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
And then there is always the brute-force option of setting the turrets to be guardianed so they can only be destroyed when the mission allows.

Yeah, I've been wanting to avoid that if possible. To be fair, I doubt the player would be able to disarm both turrets before the next wave of reinforcements arrive (the trigger for the deimos to follow it's path). Then again, last time I doubted such a thing someone disabled a Moloch that wasn't suppose to be caught :)

[/quote]

Have the rotation event set a 'rotation in progress' var to 1, then, when the rotation's complete, set it back to 0 (probably a chained event is the easiest way).

Make the waypoint activation require the var to == 0.

Gotta pop out for a a half hour, Ill give it a try when I get back!

 
Re: Rotating a moving warship
Ah! That worked. Seemed I just needed that additional clear goals.

One problem remains though - If the ship's turret is destroyed before it's waypoint activates, the ship will rotate but then stop rotating when the waypoint activates, rather then finishing the complete roll (while preferably beginning to move too).

Have the rotation event set a 'rotation in progress' var to 1, then, when the rotation's complete, set it back to 0 (probably a chained event is the easiest way).

Make the waypoint activation require the var to == 0.

Ain't that the same what I said, just in more complex?

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rotating a moving warship
No. The suggestion I gave allows the waypoints to begin if the rotation is already complete (as in yours) OR if the rotation has not yet begun.

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
Have the rotation event set a 'rotation in progress' var to 1, then, when the rotation's complete, set it back to 0 (probably a chained event is the easiest way).

Make the waypoint activation require the var to == 0.

No success so far. I made a string-type variable with the name "rotation-in-progress", with a default value of 0. In the first event and last events (waypoints 1 and 2) I added an operator (modify-variable) with the variable I made and a value of 0 (probably unnecessary?). In the "deimos roll" event I put an operator that modifies it to the value of 1, and in a chained event after it's reset back to 0.

 
Re: Rotating a moving warship
I can't help with the variable but one Q: is the Deimos supposed to complete Waypoint 1 even after its turret has been destroyed or is the ship immediatly heading for a "safer direction" away from enemy fire (Waypoint 2)? Because if it's supposed to the events (shown here) don't address that so far.

 

Offline Colt

  • 28
  • Needs more dakka
    • Steam
Re: Rotating a moving warship
I can't help with the variable but one Q: is the Deimos supposed to complete Waypoint 1 even after its turret has been destroyed or is the ship immediatly heading for a "safer direction" away from enemy fire (Waypoint 2)? Because if it's supposed to the events (shown here) don't address that so far.

I'm using Orpheus' suggestion. Both waypoints are on top of eachother. Basically after a fight with a destroyer, the corvette begins to follow path 1 when some more allied ships arrive so it can engage them with its port-side weapons. If the player takes out the portside beams either before those ships arrive (during the destroyer battle) or after they arrive, it'll then rotate (it'll trigger the play-dead and remove the 1st waypoint path it was taking). Completing the rotate would then send it onto waypoint path 2.

Waypoints are working right now, just need to get the variables to work so it won't stop rolling when the waypoint triggers.
« Last Edit: May 22, 2019, 05:13:31 pm by Colt »

 
Re: Rotating a moving warship
One way or another, heres my attempt (haven't tested it though so no guarantee!).

Code: [Select]
$Formula: ( when
   ( are-waypoints-done-delay
      "GTF Myrmidon 0"
      "Waypoint path 1"
      0
   )
   ( do-nothing )
)
+Name: Waypoint 1 Done
+Repeat Count: 1
+Interval: 1

<Subsystem Disabled Event Here>

Code: [Select]
$Formula: ( if-then-else
   ( or
      ( is-event-true-delay
         "Waypoint 1 Done"
         0
      )
      ( <
         ( distance
            "GTF Myrmidon 0"
            "Waypoint path 1"
         )
         150
      )
   )
   ( add-goal
      "GTF Myrmidon 0"
      ( ai-waypoints-once
         "Waypoint path 2"
         89
      )
   )
   ( add-goal
      "GTF Myrmidon 0"
      ( ai-waypoints-once
         "Waypoint path 1"
         89
      )
   )
)
+Name: Continue
+Repeat Count: 1
+Interval: 1
+Chained: 30

Undisturbed rolling around should be handled by the chain to the destroyed subsystem; the distance hopefully makes sure that the Deimos does not fly pirouettes when being disarmed close to the waypoint. As I said, hopefully.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Rotating a moving warship
Use a numeric variable, not a string.