Author Topic: Directive problems  (Read 2841 times)

0 Members and 1 Guest are viewing this topic.

Directive problems
I feel like we need a 'Dumb FRED questions' thread, because of how simple my problem is I'm hesitant to make a whole topic for it in the first place. I've searched for the relevant data as best I could, to no avail, and I can't just say nothing because of how basic the problem is.

Anyway, the mission objective (as well as a directive which should show up immediately) is to destroy a bunch of ships, success is all being destroyed, failure is any ship escaping. A minor caveat is that more of these ships arrive from a station which is destroyed at some point during the mission, so any ships that could not leave the station before it was destroyed should also count favorably toward the objective. I've already attempted several arrangements of the directive and events which should control when it should show up, but it always ends up not showing up, or getting fulfilled immediately.

 
Hm... You could structure your condition like this:

Code: [Select]
( and
   ( is-destroyed-delay "Enemy Station" 5 )
    ( not ( is-in-mission ( "Target 1" "Target 2" "Target 3" ) )
    ( not ( or (
       ( has-departed-delay "Target 1" 0 )
       ( has-departed-delay "Target 2" 0 )
       ( has-departed-delay "Target 3" 0 )
    ) )
)

Basically, we fail it once any target jumps out, and succeed it when there are no targets and the station is dead. Because a jumping target fails the event, the only way there can be no targets in the mission is if every one that has launched is dead. :) Does that make sense?

This is by no means a dumb question, by the way! The peculiar way Freespace handles boolean values is more than slightly mindbending until you get your head around it. I can give a fuller explaination when I'm awake. :)

 

Offline herkie423

  • 29
  • Plunge into the chaos!
Basically, the directives are all about "destroyed" "disabled" and "departed" mostly although it can have other conditions. I did have missions that requires special complex conditions. My simple solution is to place an invisible "objective cue" ships. Uncheck the player orders, set to no collide, invulnerable, lock primaries and secondaries, protect ship, cloaked, stealth, does not move (do not disable engines), no warp effect, invisible to friendlies that sorts of things. Have them self destruct or depart (tied to the directive condition, of course) if the special condition is met. This mimics a boolean TRUE or FALSE. This way is also useful for main objectives.
« Last Edit: May 16, 2017, 11:49:00 pm by herkie423 »

 

Offline herkie423

  • 29
  • Plunge into the chaos!
... And Xeno is right. This is not a dumb question. This issue cracked my head in the past. This is something every Fredder must know.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Have you considered using a solution with "and-in-sequence"? - Ill show one later
"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 herkie423

  • 29
  • Plunge into the chaos!
Have you considered using a solution with "and-in-sequence"? - Ill show one later

Yes. That will work too. The "cue" ship solution apply if all else fails.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Sorry for the short reply before, getting up when it get bright outside so early in morning and all that...

Anyway, the mission objective (as well as a directive which should show up immediately) is to destroy a bunch of ships, success is all being destroyed, failure is any ship escaping. A minor caveat is that more of these ships arrive from a station which is destroyed at some point during the mission, so any ships that could not leave the station before it was destroyed should also count favorably toward the objective. I've already attempted several arrangements of the directive and events which should control when it should show up, but it always ends up not showing up, or getting fulfilled immediately.

How about these?





One problem remains: The counter of the directive might keep jumping to [n+x] as it has multiple "is-destroyed-delay"s in there which influence the counter.

EDIT: Sorry, still really early today...

Explaination:

While "and" only bundles conditions together, "and-in-squence" additionally checks if they happened in the right order. In this chase if the Station has been destroyed and only if the ship has not arrived - this effectively makes it "if the ship has not arrived yet".
« Last Edit: May 17, 2017, 12:41:20 am by 0rph3u5 »
"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."

 
Thank you for the replies!

I got varying degrees of success from 0rph3u5 and xenocartographer's methods, which I'll go into (rather than just post a single one-line reply "it works now kthx"). Firstly, I'll mention that neither of the two suggested events, when themselves the directive, would show up immediately. For both of them, I had a separate event which was the directive and uses an is-event-true-delay with the third argument set to true, to force it to show up.

For xenocartographer's method, I was able to get it working as I needed, but not without some small modifications. It would fail properly, but would also fulfill once the station was destroyed, even if there were still ships on the field. When I first saw is-in-mission, and that it could take multiple arguments, I was slightly annoyed it didn't mentioned whether it treated all of them as an AND or an OR. And based on this behavior I believe it's an OR. The station was destroyed, at least one of the ships was not in mission, and none of them had departed, and thus it fulfilled. The solution was simple, though, just replacing it with a big AND, individually asking not is-in-mission for each ship, and it then works fine.

And for 0rph3u5's method, it would also fail properly. But would never fulfill. My worry is that in the and-in-sequence, for every ship that starts out not on the field, not has-arrived-delay immediately returns true for them, and thus none of them go through since they all go out of order.

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Just FYI, if you want to take control of the little number that can show up next to "destroy" directives (e.g. if you want this directive to show the number of ships left to destroy, counting ones that may or may not still be docked with the station), you can use the directive-is-variable SEXP.
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 0rph3u5

  • 211
  • Oceans rise. Empires fall.
And for 0rph3u5's method, it would also fail properly. But would never fulfill. My worry is that in the and-in-sequence, for every ship that starts out not on the field, not has-arrived-delay immediately returns true for them, and thus none of them go through since they all go out of order.

That it didn't become true is odd...

And-in-sequence is is exactly made for that purpose, to make the check in the order they are entered. It would check "not" + "has-arrived-delay" unless "is-destroyed-delay" is true. For ship that are on the field at the start "not" + "has-arrived-delay" should evaluate as false as they "arrived" in the first frame of gameplay, so there is no instance they have not arrived.



Just FYI, if you want to take control of the little number that can show up next to "destroy" directives (e.g. if you want this directive to show the number of ships left to destroy, counting ones that may or may not still be docked with the station), you can use the directive-is-variable SEXP.

I knew it existed but could not find it earlier.
"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 karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
And for 0rph3u5's method, it would also fail properly. But would never fulfill. My worry is that in the and-in-sequence, for every ship that starts out not on the field, not has-arrived-delay immediately returns true for them, and thus none of them go through since they all go out of order.

That it didn't become true is odd...

And-in-sequence is is exactly made for that purpose, to make the check in the order they are entered. It would check "not" + "has-arrived-delay" unless "is-destroyed-delay" is true. For ship that are on the field at the start "not" + "has-arrived-delay" should evaluate as false as they "arrived" in the first frame of gameplay, so there is no instance they have not arrived.

I can tell you what's going on but lately I feel like it looks like I'm only posting on here to tell 0rph3u5 where he's gone wrong. I don't want you to feel I'm picking on you so I'll tell you if you really want to know. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
On the whole "it's not a stupid question" front... I'm no FRED veteran, but I've got a couple pretty complex missions under my belt, and still forgot that little wrinkle. is-departed-delay and friends prevent a directive from displaying until all the ships/wings involved have arrived, yup, hence the need to indirect it with is-event-true-delay.

Anyway... Freespace draws a distinction between true and false, and "known true" and "known false". An SEXP that has evaluated to a "known" state can never evaluate to another state, and so need not be evaluated any further. An event (or goal) becomes complete/true once it's conditions become true, but it does not become failed/false until it's conditions become known false.

This sounds complicated, but it's usually quite intuitive. Let's consider a directive set up as ( when ( is-destroyed-delay "NTC Primary Objective" 0 ) ( do-nothing ) ) . Let's suppose the Primary Objective is initially in the mission and wondering what's up with its name, anyway. Initially, the is-destroyed-delay SEXP returns false, but not known false, and so the event is incomplete. If the ship goes down, it becomes true (and known true, but mere truth is sufficient here) and the event is complete. If it jumps out... well, there's hardly a way to blow it up, so is-destroyed-delay is known false, the directive fails, and the event is no longer checked.

So, it makes sense why known false fails an event, but why does regular true make it succeed? Well, consider something like ( < ( distance "Alpha 1" "Navbouy 1" ) 200 ) in a directive about flying waypoints. You'd hate for that to go back to incomplete when Alpha moves onto the next waypoint, aye?as an aside, this can be used to "promote" regular true to known true via is-event-true-delay.

So what's known truth good for, anyway? Well, there are really two kinds of SEXPs that return known true/known false. Some represent discrete events, like is-destroyed-delay, is-departed-delay, or is-event-true-delay. Others are logical operators, like and, or, and not. These preserve the known status of their operands when possible - the and of logical and regular true is just regular true, but the or is known true, etc. So, the not of one of the first class is known false once the event has happened, and ( and ( destroyed-or-departed-delay "SC Stalker" 0 ) ( not ( is-destroyed-delay "GTC Protagonist" 0 ) ) will cause a directive to escort the Protagonist to turn red when it blows up.



...also, is-destroyed-delay and friends prevent directives from showing up until all the ships involved have arrived. I'm honestly not sure how.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
And for 0rph3u5's method, it would also fail properly. But would never fulfill. My worry is that in the and-in-sequence, for every ship that starts out not on the field, not has-arrived-delay immediately returns true for them, and thus none of them go through since they all go out of order.

That it didn't become true is odd...

And-in-sequence is is exactly made for that purpose, to make the check in the order they are entered. It would check "not" + "has-arrived-delay" unless "is-destroyed-delay" is true. For ship that are on the field at the start "not" + "has-arrived-delay" should evaluate as false as they "arrived" in the first frame of gameplay, so there is no instance they have not arrived.

I can tell you what's going on but lately I feel like it looks like I'm only posting on here to tell 0rph3u5 where he's gone wrong. I don't want you to feel I'm picking on you so I'll tell you if you really want to know. :)

Go ahead. No need to stop on my account. - I am always satisfied and reassured that I am still making mistakes.
« Last Edit: May 17, 2017, 06:33:44 am by 0rph3u5 »
"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 karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
For ship that are on the field at the start "not" + "has-arrived-delay" should evaluate as false as they "arrived" in the first frame of gameplay, so there is no instance they have not arrived.

That's not actually true. While it might sound strange, quite a few SEXPs work by checking the log. If you press F4 you'll notice that only ships that arrive after t=0 will appear on the log.

So using not has-arrived-delay for a ship that is present at the start of the mission will always evaluate to true at t=0


Which leads us to the problem with your suggestion. Asteroth is completely correct that the not has-arrived section is evaluating to true at the start of the mission. That means that the and-in-sequence section is never going to work.

This is actually one of the classic FREDding mistakes. If you never tried it before I'd suggest trying my Big FRED Quiz and Big FRED Quiz II as I went over a lot of the classic gotchas.

The quiz has questions for beginners as well as experts so it's worth a look for any FREDder. 
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Huh... then it is good that I don't use it for directives like that .... I swallowed a huge paragraph about how I would do it because it was basically aesthetic considerations all the way through.

The short notes were:
a) I no longer use directives which are equal to mission objective because I think it does not provide good player feedback.*
b) I'd have individual directives which only use "is-destroyed-delay"
c) For the overall functionality, I would use variables with 0 for default, 1 for has arrived and departed, 2 for has arrived and was destroyed and 3 for didn't arrive for each ship.
d) The "didn't arrive"-check I would do with "is-event-incomplete" (on an event triggered by the arrival) as secondary condition.

*In old soon to be re-released missions they will still be there because once I start taking these missions apart I fear will not be able to stop.
"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."

 
Lest we get prematurely off-topic... OP, it sounds like my solution, plus an is-event-true for the directive, worked for you. Is that true, or do you have further questions?

 
Yes it seems to be working fine now, all the replies have been massively helpful. That's not to say that implementing a chunk of scripting for every single one of 32 ships was particularly fun, the programmer in me balks at that amount of repetition, but I'm not sure whether to pin that on FRED's inadequacies, or simply forcing situations which it wasn't quite designed for onto it.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Actually there are methods that involve the use of the when-argument SEXPs that would work for cases like this. I didn't realise you needed this for so many ships or I would have suggested one.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
I was aware of their existence, but I don't have a ton of experience with them, and It would change the current structure quite a bit. My immediate impression is something like this?

Code: [Select]
fail condtions
    when-argument
        any-of
            ships
            ships
            ships
        has-departed-delay
            <argument>
        do-nothing

success condtions
    when-argument
        every-of
            ships
            ships
            ships
        not
            is-in-mission
                <argument>
        do-nothing

actual directive
    when
        and
            is-event-false-delay
                fail conditions
            is-event-true-delay
                success conditions
        do-nothing

  
That should work. Just make sure to include your station in the second list :)