Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: bomb3rman on October 12, 2016, 02:56:40 pm

Title: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 12, 2016, 02:56:40 pm
Hey Guys I'm trying to make a bonus goal for a mission: If a ship reaches a Waypoint and jumps out with its hull at 100, then the bonus goal should be achieved... But I just can't find a way to do it? Do I have to set a variable?

Sorry, I hope you get what I'm traing to say :)
Title: Re: Ship Health at 100 = bonus goal
Post by: X3N0-Life-Form on October 12, 2016, 03:19:19 pm
No need to use a variable for that, just setting the goal cue to has-departed and hits left = 100 should do the trick, unless I'm missing something.
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 13, 2016, 01:56:49 pm
Sorry thats not working for me (or I just can't get it right): The Point "has departed delay" can be chosen, but "damage" stays grey, can't use ist. Haven't been able to understand why, if I'm honest. Can you give me a hint?


Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 13, 2016, 02:14:59 pm
You need to select the equals sign under the list of arithmetic operators. Then one of the fields under equals can be the ship's hits-left.

It should be something like

and
—has-departed-delay (ship name) 0
— =
       — hits-left (ship name)
       — 100
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 13, 2016, 02:56:50 pm
If i build this I have to put two numeric arguments under the "="-sign like this:

and
—has-departed-delay (ship name) 0
— =
       — 0
       — 0

I can add anouther operator like "hits-left" under these like this:

and
—has-departed-delay (ship name) 0
— =
       — 0
       — 0
      op hits-left
            SHIPNAME

But this doesn't work in the game. I can change the 0s to 100, but nothing happens...
Title: Re: Ship Health at 100 = bonus goal
Post by: mjn.mixael on October 13, 2016, 03:11:42 pm
OK, so it would help to have a quick bit of of information here. The arguments in FRED can only ever return numbers or TRUE/FALSE. So as you get more familiar with FRED, you'll learn which SEXPs return which types. That governs which SEXPs are greyed out or not.

"Goal is true when hits left" doesn't make sense to the computer, you need the operator to say something more like "Goal is true when hits left equals 100". I hope that makes sense.. if not, it will become more clear as you use FRED, I promise!

In your particular case you need to do basically what General Battuta said. But now you know that "Hits-Left (shipname)" returns a number. You can probably figure out what's going on.

Code: [Select]
and
--has-departed-delay (shipname) 0
--=
-----hits-left (shipname)
-----100

"hits-left (shipname) gets translated to exactly that.. the percent damage remaining on the specified ship (AKA, a Number!). Then if that equals the second number you listed, it marks "Equals" portaion of the SEXP as True. If the "Has departed" also gets marked true, then the "And" overarching SEXP becomes true and the goal is achieved.
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 13, 2016, 03:39:01 pm
I'm slowly starting to understand  :lol: , thx for the patience by the way!
What I learned now is:
1. The ship's hull that is refered to is the one already defined in the "has departed delay" part. (is that correct?)
2. I should put all of this in the Goals-Editor, not the Events-Editor....  :lol:

But I still got a problem: Tested the mission, now the "Bonus objective complete" message is displayed if the ship reaches its destination and jumps out, but regardless if the hull is at 100 or not (I shot it down to 95 in one test and in the other one I let if fly away)...
Any ideas?
Title: Re: Ship Health at 100 = bonus goal
Post by: mjn.mixael on October 13, 2016, 03:47:23 pm
The ship's hull in hits-left is simply the ship you want to check. For your purposes, the answer is yes. However, I want you to be aware that it doesn't have to be if you want to do something different for a new mission.

If you put this in the events editor, you would simply put something like "is-event-true-delay" in the goals editor to turn it into a goal. Doesn't really matter here.

To debug that problem I'd like to see a screen of your event.
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 13, 2016, 04:02:38 pm
Well, I don't know anymore what I did... The attachment is my little "creation" under "Mission objectives"...
No it's not working anymore: Ship starts, with 100, ship departs with 100, no Message...
Now I'm confused...  :mad:

[attachment deleted by admin]
Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 13, 2016, 05:49:22 pm
Sure you got the Canberra's name right? Sure it hasn't taken ANY damage whatsoever? That looks at first glance like it should work.
Title: Re: Ship Health at 100 = bonus goal
Post by: Buff Skeleton on October 13, 2016, 06:06:59 pm
For the sake of debugging, try setting it to >= 1 hits left. See if that executes.
Title: Re: Ship Health at 100 = bonus goal
Post by: Spoon on October 13, 2016, 06:19:39 pm
I've tested this out of curiosity

bomb3rman's screenshot should work, but it straight up doesn't. If this is used with a primary objective it returns as failed.
So I tried doing several cases of < > <= >= with various hit left values etc and they all failed.

But you know what does works?
(http://i1054.photobucket.com/albums/s490/kingspoon/Junk/why_zpsqklswl28.jpg~original)
????
Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 13, 2016, 06:31:18 pm
Lmao what the ****
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 13, 2016, 06:36:31 pm
May be take two steps approach:

(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/random_advice_zpshbaupttw.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/random_advice_zpshbaupttw.png.html)

the condition of the 2nd event should of course be the condition of the bonus goal
Title: Re: Ship Health at 100 = bonus goal
Post by: AdmiralRalwood on October 13, 2016, 06:38:31 pm
Hrm... I think I see the problem. If a ship has departed, hits-left decides it can't evaluate and returns SEXP_NAN_FOREVER. When run through a comparison operator (like = or <), this becomes SEXP_KNOWN_FALSE. This causes the "and" to fail, but "not" turns SEXP_KNOWN_FALSE into SEXP_KNOWN_TRUE, so that's why that works.

What you really need to do is find a way to check the hull immediately before it departs, but that's slightly more involved (would take at least two events, off the top of my head).

And Orph3u5 posted while I was typing this, but that approach should probably work too (although I don't recommend the overhead of using every-time).
Title: Re: Ship Health at 100 = bonus goal
Post by: Axem on October 13, 2016, 06:54:18 pm
AdmiralRalwood has it. This is what you get for an equivalent event in the event log.

Code: [Select]
Event: hits left at mission time 19 seconds (19984 milliseconds)
when returned ALWAYS FALSE
and returned ALWAYS FALSE
= returned ALWAYS FALSE
hits-left returned -32763

Honestly what I would do is just have an event that triggers if HP goes below 100 (and has not departed) check to make sure it never fired.
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 07:28:25 am
Hey guys, thx for all the answers, though I can't follow anymore.

I tried to build the events 0rph3u5 showed here, but I just can't do it. I can't put this "White paper thing called hits left" in the first event. What do I have to do? For me it was only possible to create this "hits-left" thing by inserting an operator, then there was no red "op" but a white paper sign like this. But can't do it anymore, because I can't change the operator before that.

How do I change the one in the red circle whit the (variable?) like 0rph3u5 did?
Do I have to define all variables before creating the events?
Is there a good (and probably easy, self-explanatory) tutorial for the work with variables? I did the fredzone tutorial but it wasn't so much help for these problems....

Sorry for all the stupid questions, just trying to learn  :)
And sorry for the time-delay, I'm living in Germany, the Time-Zone makes the direct communication difficult :)

[attachment deleted by admin]
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 14, 2016, 07:35:46 am
And Orph3u5 posted while I was typing this, but that approach should probably work too (although I don't recommend the overhead of using every-time).

Well, it was 2 am ...

But yeah here is the correct way to do it:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/random_advice_corrected_zps0nktu3g1.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/random_advice_corrected_zps0nktu3g1.png.html)

I added the additional condition to only check between when the ship clears its waypoints and the when it actually departs, to cut down on the number of repeats for the event; so instead checking every x-milliseconds in the mission (or every frame in case of every-time) the event only checks when it really needs to.

EDIT: Silly question, but is it an oversight on my part that Trigger Count does not match the Repeat Count in this case? - I am always on the fence about that...
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 14, 2016, 07:44:32 am
I tried to build the events 0rph3u5 showed here, but I just can't do it. I can't put this "White paper thing called hits left" in the first event. What do I have to do? For me it was only possible to create this "hits-left" thing by inserting an operator, then there was no red "op" but a white paper sign like this. But can't do it anymore, because I can't change the operator before that.

How do I change the one in the red circle whit the (variable?) like 0rph3u5 did?
Do I have to define all variables before creating the events?

Yes, you have to define any variable before you can input it. Simply use "Add variable" in the Event Editor right-click menu:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice1_zps4lenf2ut.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice1_zps4lenf2ut.png.html)

Once you have defined it (Number will suffice for your use, name is a formality & for your purpose the value should be 100), you can add it in place of any data like this:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice2_zpsoswp5xga.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice2_zpsoswp5xga.png.html)

Works in the Mission Goals Editor too...
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 08:27:43 am
Yes but how can I put the

             "hits-left"
                 SHIPNAME
?

I don't know how to create this "hits-left" variable (or is this not a variable but an operator?) and the step below....
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 14, 2016, 08:33:40 am
That's no varibale. /obiwan
It is indeed an operator which can replace any data-field for numbers.

Here is how you find it:
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice3_zpsbpdehj6u.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice3_zpsbpdehj6u.png.html)
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 08:47:28 am
And now we are at the bottom of my problem:

"insert operator" stays grey, can't use it. It cannot replace my data-field.

[attachment deleted by admin]
Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 14, 2016, 09:43:14 am
What the christ
Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 14, 2016, 09:44:01 am
Okay right can you use Replace Data to do the same thing?
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 10:31:00 am
What do you mean?

I can go to "Replace data" and get this (look at attachment).

Do I have to create a string with <variable name = hits-left> and "default value" = 100 ? And insert this?



[attachment deleted by admin]
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 14, 2016, 10:46:47 am
Can you go and check (via "Modify Variable" in the menu) if your variable is set to be the variable type "Number"? (Picture below, top left)
(http://i1020.photobucket.com/albums/af321/0rph3u5/FS%20Open/variable-advice4_zps4lsxodkc.png) (http://s1020.photobucket.com/user/0rph3u5/media/FS%20Open/variable-advice4_zps4lsxodkc.png.html)

If it is set to "String" you can not modify the variable with anything that isn't a Sting*; if you have to change that you have to make sure no event is referencing it before you make the change, otherwise FRED wont let you.

* Number = any number the engine can provide or read; Sting = the same but with text - String and Number are however multually exclusive even if the you can input a number in a String-variable or -data-field
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 10:58:38 am
Yes it (aka ShipHPper100)  is set string at the moment. Is that the problem? shall I delete it and make a new variable with "number" ?

EDIT: I looked after it and tried it (look at attachment). You were right, now I could replace the second variable via "replace operator"

[attachment deleted by admin]
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 14, 2016, 11:39:38 am
Yes it (aka ShipHPper100)  is set string at the moment. Is that the problem? shall I delete it and make a new variable with "number" ?

The Coders may correct me on this but the engine treats String and Number variables differently and categorically so.

A "Number" variable can replace any data of any SEXP that calls for a numerical value (e.g. the number of seconds for delay in "are-waypoints-done-delay") and using "modify-variable" only numerical data can be put in it. That numerical data includes all operators which return numerical data (e.g. "hits-left").

A "String" variable can replace any data of any SEXP that calls for non-numerical data to be input (e.g. the name of a ship in "has-departed-delay"). Any sequence of symbols can be input in it and using "modify-variable" can change it to any sequence of symbols. However even if that sequence is a number the engine will not accept it as numerical input or allow its value to be replaced with an operator.
Title: Re: Ship Health at 100 = bonus goal
Post by: General Battuta on October 14, 2016, 12:21:59 pm
Oh, right, that makes sense.
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 14, 2016, 02:07:28 pm
Yes it does and also already answered my next questions about Numbers and Strings  :D

By the way now I tested the mission and it's working. Ship Hull 100 = Bonus goal, Ship hull below 100 = nothing.

So thanks to everyone, I really learned something today!
Title: Re: Ship Health at 100 = bonus goal
Post by: karajorma on October 15, 2016, 03:33:48 am
EDIT: Silly question, but is it an oversight on my part that Trigger Count does not match the Repeat Count in this case? - I am always on the fence about that...

Repeat Count and Trigger Count are independent of each other but both use the value set in the Interval Time. In this case there would be no reason to set both and it would have no effect whatsoever.

Repeat Count works like this. After the first time the event becomes true the game then waits Interval Time and then checks again. If the result is true, it triggers again. Either way it then waits Interval Time again before testing.

Trigger Count on the other had waits Interval Time before checking again and then check every single frame until the event is true again.

The difference becomes clear if we have something like this.

when
- >
-- Distance
---Ship A
---Ship B
-- 400

If you have an interval time of 60 seconds then which one you set becomes very important. Trigger Count is probably the one you'd want. After the event occurs the first time the game waits 60 seconds and then triggers again the next time the two ships are close enough. If you instead used a repeat count the game would check the distance between the two ships every minute on the minute. You could actually have Ship A fly within 400m of Ship B at 1:30 and as long as it then moves away again before 2 minutes the event wouldn't repeat.


You can even set both repeat and trigger count. If we set the repeat to 5 and trigger to 2 for the above event you'd set up a situation where the game would check every minute on the minute if the ships are close together and trigger twice before stopping.
Title: Re: Ship Health at 100 = bonus goal
Post by: 0rph3u5 on October 15, 2016, 04:19:22 am
Repeat Count and Trigger Count are independent of each other but both use the value set in the Interval Time. In this case there would be no reason to set both and it would have no effect whatsoever.

Repeat Count works like this. After the first time the event becomes true the game then waits Interval Time and then checks again. If the result is true, it triggers again. Either way it then waits Interval Time again before testing.

Trigger Count on the other had waits Interval Time before checking again and then check every single frame until the event is true again.

Thanks, that clears up on the misconceptions I had since forever... (bookmarking this for future reference)
Title: Re: Ship Health at 100 = bonus goal
Post by: karajorma on October 15, 2016, 11:06:00 am
When you have a 1 second interval time, for the most part it's hard to tell the difference between the two. It's only when you have a longer interval and you are testing something like distance which may flip between true and false during the interval that it becomes really noticeable.
Title: Re: Ship Health at 100 = bonus goal
Post by: potterman28wxcv on October 16, 2016, 04:14:50 pm
A bonus goal that can be messed up with a single collision from your allies :doubt:
Title: Re: Ship Health at 100 = bonus goal
Post by: bomb3rman on October 18, 2016, 04:04:02 pm
Well maybe, you might have a point... Hmm I could switch to "more than 98 HP" to avoid that. Though in all my testings it didn't happen once. But I keep that in mind, thx!