Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Colt on May 22, 2019, 12:00:28 am
-
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:
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.
-
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.
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.
-
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:
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.
-
Shooting from the hip here, I might be wrong, but did you specify a roll velocity AND a forward velocity in that ship-maneuver?
-
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?)
-
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.
-
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.
( clear-goals "Empress" )
( ship-maneuver
"Empress"
75000
0
0
-100
( true )
0
0
100
( true )
)
-
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).
-
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++.
-
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.
-
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.
-
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.
-
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!
-
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?
-
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.
-
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.
-
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 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.
-
One way or another, heres my attempt (haven't tested it though so no guarantee!).
$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>
$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.
-
Use a numeric variable, not a string.
-
Use a numeric variable, not a string.
Whoops. Anyway, swapped it from string to number. No change however.
...
I probably did this wrong too, but I placed both events around the play dead event (the one with the is-destroyed-subsys). No change.
What I could do if I'm not fruitful here is, as mentioned earlier, guardian the turrets until the destroyer arrives and then have the corvette begin moving instead of waiting for the next attack force to arrive. Command/whoever can just tell the player to hold position/focus other targets until the destroyer arrives.
-
Okay let me be sure I have this right:
1. You want a ship to spin to bear fresh turrets when some turrets die - you have an event to order this
2. At some point the ship also runs waypoints
3. If the ship has NOT YET begun waypoints, it should spin first, then begin waypoints
4. If the ship is already running waypoints, it should spin while moving, then continue waypoints
-
Okay let me be sure I have this right:
1. You want a ship to spin to bear fresh turrets when some turrets die - you have an event to order this
2. At some point the ship also runs waypoints
3. If the ship has NOT YET begun waypoints, it should spin first, then begin waypoints
4. If the ship is already running waypoints, it should spin while moving, then continue waypoints
1. Correct.
2. Yup. This would happen when the 2nd allied wave enters the system.
3. Yes. If it's turrets are knocked out, it will spin. If it's in the middle of spinning when it receives the order to move, then it should at the same time continue it's spin (it takes 40 seconds total to spin) and begin moving to the waypoint.
4. Correct. This is assuming it still has at least 1 turret.
In summery:
Deimos is stationary - allied destroyer arrives, Deimos starts shooting destroyer - destroyer departs - 2nd allied wave arrives, Deimos begins to move parallel of them to engage with beamfire - If port beams are destroyed at any point in time, it spins to use starboard beams.
Currently it spins when the guns are destroyed, both when stationary and when on already on the move. However, if the Deimos receives the waypoint order as it's spinning, it cancels the spin, thus leaving it possible that it's starboard guns won't be able to fire on the allied ships of wave 2 as it goes past them.
-
It sounds like you have everything working, except you need it to finish spinning before it waypoints.
I have a fancy way to do this but it is too long to explain! The short version is: you have a variable that is only ==1 if the roll is underway. You need to tell the waypoint event that it needs to wait for that variable to ==0 to trigger.
-
It sounds like you have everything working, except you need it to finish spinning before it waypoints.
I have a fancy way to do this but it is too long to explain! The short version is: you have a variable that is only ==1 if the roll is underway. You need to tell the waypoint event that it needs to wait for that variable to ==0 to trigger.
I believe I have those variables down already. I'll post what I have so far.
Waypoint 1
when
has-time-elapsed
15
add-goal
Deimos
ai-waypoint-once
Waypoint path 1
89
modify-variable
rotation-in-progress(0)
0
Play dead
when
is-subsystem-destroyed-delay
Deimos
turret03
0
clear-goals
Deimos
add-goal
Deimos
ai-play-dead
100
Deimos roll
when
is-event-true-delay
play dead
0
ship-maneuver
deimos
40000
0
0
100
true
0
0
100
true
send-message (used to double confirm the event fired)
modify-variable
rotation-in-progress(0)
1
Deimos keep rolling (CHAINED TO DEIMOS ROLL)
when
is-event-true-delay
Deimos roll
40
modify-variable
rotation-in-progress
0
Waypoint 2
when
and
is-event-true-delay
Deimos roll
40
add-goal
Deimos
ai-waypoints-once
Waypoint path 2
89
modify-variable
rotation-in-progress(0)
0
-
None of your 'when' conditions check the value of the variable, do they? You need something to say "Hey, you can't do this unless the variable = 0." Use the arithmetic operator =.
So in the 'and' on your Waypoint 2 event, you need to add
=
(rotation-in-progress)
(0)
-
None of your 'when' conditions check the value of the variable, do they? You need something to say "Hey, you can't do this unless the variable = 0." Use the arithmetic operator =.
So in the 'and' on your Waypoint 2 event, you need to add
=
(rotation-in-progress)
(0)
:yes: BOOYAH! :yes: Got it working!
I tried it with the waypoint 2 event, but to no avail. However, upon using it in the waypoint 1 event I got the following:
-Ship losses turret, begins rotating. Upon finishing rotate it then proceeds to waypoint 1, then waypoint 2.
To fix this, I gave waypoint 2 a higher priority, and made an event that clear's the deimos' goals upon reaching waypoint 2.
Other things that happen:
-No turret lost? Ship stops at waypoint 1
-Turret lost while on way to waypoint 1? Rolls and then goes to waypoint 2
Basically everything is working as intended! Think all I need to do now is to make an event that turns the velocity from 100 to 0 when the ship hasn't received it's waypoint order. Thanks for the help so far guys!
Edit: Found and fixed a mistake that I overlooked. I've changed the has-time-elapsed to an is-event-true for another ship arrival because when I changed the original has-time-elapsed from 15 to 60, I found that that the Deimos would start travelling to waypoint 2 after it finished it's roll BEFORE the initial 60 seconds had finished. For a few minutes there I was terrified :shaking: