Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: freespacegundam on March 01, 2006, 03:15:52 pm
-
Okay, to make a long story short I'm designing a mission (I can't say what its for so bear with me) where the player is instructed to scan a group of cargo containers in order to locate three that contain a valuable resource out of thirteen available containers. The trouble comes when I want the blasted thing to send messages. Basically, this is how I want it to work.
First: Player finds any 1 of the cargo containers before the other two, command sends one message.
Two: Player finds one of the other two cargo containers after already finding the first one, different message.
Three: Player finds the last container after finding the first two in any order, final message sent.
The problem is that the way I've FREDed it makes all the messages display everytime any of the three containers is found. This is how I have it set up for most of the events.
Find 1
-when
-and
-or
Cargo1 is known
-or
Cargo 2 is known
-or
Cargo 3 is known
-is-event-incomplete
-Find 2
-send message
-message 1
Find 2
-when
-and
-or
Cargo1 is known
-or
Cargo 2 is known
-or
Cargo 3 is known
-is-event-true
-Find 1
-send message
-message 2
Find 3
-when
-and
-or
Cargo1 is known
-or
Cargo 2 is known
-or
Cargo 3 is known
-is-event-true
-Find 1
-Find 2
-send message 3
I need to figure out a way to do this so that the messages will trigger at the right time rather than all at once. I desperately need assistance.
-
This should be nice and easy to do. Easiest option here I can see would be to use variables. You would need two different sets of events for this, but it is easy.
-when
--cargo-known-delay
---Cargo 1
---0
--modify-variable
---CargoScanned
----+
----1
Make two other identical events, interchanging the cargo names for each of the special containers.
Second step:
--when
---=
----CargoScanned
----1
--send-message
---<message data>
Do this three times, but using 2 and 3 in the next two events in place of the one. When the player scans each of the containers, it will add one to the counter, and when the counter equals a certain number, a message will be played at that moment.
Hope this helps. :)
-
Your problem is that because the only difference between the events is that the previous events have to be true for the next one to happen, once 'Find 1' becomes true, 'Find 2' immediately becomes true, and once 'Find 2' becomes true, 'Find 3' becomes true. So all 3 messages will be displayed whenever any of the cargoes are scanned.
What you can do if you have enough events to spare, is to have 3 events for each message, dealing with only one cargo at a time instead of lumping all 3 together. The 'not' operant can help you make sure each event applies to only one possible combination of known cargo. All this is doable in retail FRED. Another possibility is to mess around with variables, which is neater, but some people have a hard time with them.
-
Eh, yes, some people do have problems with variables, aka me. How do I go about creating the CargoScanned part of that? Is it just another event?
-
Nope. Simply right click on any event and look for "Add Variable" in the selection.
Like myeh:
[attachment deleted by admin]
-
And from there, you'll get this next option.
Simply replace "VariableName" with "CargoScanned" and "Default Value" with 0.
[attachment deleted by admin]
-
Ah I see, but how do I get FRED to do + and then 1 below it? Everytime I change it to add 1 its always add and then two zeros, or do I simply ignore the second one?
-
Thought that might be the case or you'd have used variables in the first place. I'll just show you how the events should look :)
Add a variable called 'scancount' and initialize it to 0
Scan1
-when
-is-cargo-known-delay
-cargo 1
-0
-modify-variable
-scancount
-+
-scancount
-1
Scan2
-when
-is-cargo-known-delay
-cargo 2
-0
-modify-variable
-scancount
-+
-scancount
-1
Scan3
-when
-is-cargo-known-delay
-cargo 3
-0
-modify-variable
-scancount
-+
-scancount
-1
What this does is it adds one to the scancount variable when a cargo is scanned. So if one is scanned, regarless of which, scancount = 1, if all 3 are scanned, scancount =3. So for the messages, you simply check what scancount is and send the appropriate message.
-
Ah, I have it now, many thanks to everyone. Hopefully I'll have this worked out soon.
-
My FAQ has a nice long explaination of how to use variables which hopefully isn't too technical. Anyone who has problems with them should check it out.
While I'm at it if you're using SCP you could replace the three events with
Scaned Crates (Repeat count 3)
when-argument
-any-of
--Cargo 1
--Cargo 2
--Cargo 3
-is-cargo-known-delay
-- < argument >
-modify-variable
--Scancount(0)
-- +
---Scancount(0)
---1
-invalidate-argument
--< argument >
Looks more complicated I know and it's probably not worth it in this case unless you fany experimenting with the new conditionals but if you wanted to add three more crates all you'd have to do is add their names below the other 3. :D
-
Now that's handy. Knew about when-argument, but not about the invalidate argument sexp until now. That's definitely the best way of doing it :)
-
IIRC, FG uses retail FRED, so when-argument wouldn't be applicable in his case. Still, it's a good answer, kara. I've never used any of the new conditionals myself, so I'll have to go this a try later.
-
Sorry for the thread hijack, but while we're on the topic of new conditionals I was wondering if anyone could help me out. I've got an event set up like this:
Event Name
every-time-argument
number-of
3
<ship 1>
<ship 2>
<ship 3>
<ship 4>
<ship 5>
<ship 6>
<ship 7>
<ship 8>
key-pressed
1
add-goal
<argument>
ai-warp
89
My goal was to make it so any 3 of the 8 ships would depart whenever the player presses the 1 key. It has never worked. I've tried this with a when-argument with a repeat count despite knowing it wouldn't work, and sure enough, it didn't. I haven't even bothered trying a key-reset SEXP because on the few times I did get ships to jump out by pressing 1, they all warped out, thereby precluding pressing the 1 key again. I'm obviously missing something, what is it?
-
My goal was to make it so any 3 of the 8 ships would depart whenever the player presses the 1 key. It has never worked. I've tried this with a when-argument with a repeat count despite knowing it wouldn't work, and sure enough, it didn't. I haven't even bothered trying a key-reset SEXP because on the few times I did get ships to jump out by pressing 1, they all warped out, thereby precluding pressing the 1 key again. I'm obviously missing something, what is it?
That ... won't work ... for so many reasons. :lol: Try using different sexps.
-
Sorry for the thread hijack, but while we're on the topic of new conditionals I was wondering if anyone could help me out. I've got an event set up like this:
Event Name
every-time-argument
number-of
3
<ship 1>
<ship 2>
<ship 3>
<ship 4>
<ship 5>
<ship 6>
<ship 7>
<ship 8>
key-pressed
1
add-goal
<argument>
ai-warp
89
My goal was to make it so any 3 of the 8 ships would depart whenever the player presses the 1 key. It has never worked. I've tried this with a when-argument with a repeat count despite knowing it wouldn't work, and sure enough, it didn't. I haven't even bothered trying a key-reset SEXP because on the few times I did get ships to jump out by pressing 1, they all warped out, thereby precluding pressing the 1 key again. I'm obviously missing something, what is it?
There are quite a few problems with the SEXP. The biggest one is that you've used number-of but haven't specified any conditional to figure out how many of them have actually fulfilled the trigger conditions. As a result all of them are valid and they all jump out.
I would suggest solving the problem using the random-of SEXP like this.
Event Name
every-time-argument
random-of
<ship 1>
<ship 2>
<ship 3>
<ship 4>
<ship 5>
<ship 6>
<ship 7>
<ship 8>
and
key-pressed
1
<
ShipCounter(0)
3
add-goal
<argument>
ai-warp
89
modify-variable
ShipCounter(0)
+
ShipCounter(0)
1
invalidate-argument
<argument>
The changes I've added should ensure that only 3 ships are every selected
-
Hmm... that actually won't work. The problem is that it's possible for random-of to choose one of the invalidated arguments and thus not do anything. Perhaps it should only choose randomly from among the valid arguments as opposed to all of them.
-
Well, I got three ships to jump out which is a big improvement over having all of them fly away, but it only worked once. I thought a lack of a key-reset might be the culprit so I put it in the above event thinking it would reset whenever 1 was pressed but it still wouldn't come through.
-
Well, I got three ships to jump out which is a big improvement over having all of them fly away, but it only worked once. I thought a lack of a key-reset might be the culprit so I put it in the above event thinking it would reset whenever 1 was pressed but it still wouldn't come through.
I dunno, but key-reset won't work for that. You'd need key-reset-multiple.
-
Hmm... that actually won't work. The problem is that it's possible for random-of to choose one of the invalidated arguments and thus not do anything. Perhaps it should only choose randomly from among the valid arguments as opposed to all of them.
That's why I used every-time. If it picks an invalidated argument it should simply pick again next frame without incrementing the count or executing any of the other action operators. Eventually it will pick one that is valid.
As for picking a valid argument only that's definitely a good idea.
Well, I got three ships to jump out which is a big improvement over having all of them fly away, but it only worked once. I thought a lack of a key-reset might be the culprit so I put it in the above event thinking it would reset whenever 1 was pressed but it still wouldn't come through.
Using key reset would be a bad idea as that's part of the trigger for the event. I suppose you could try using key-reset (or key-reset-multiple) if you used it like this
Event Name
every-time-argument
random-of
<ship 1>
<ship 2>
<ship 3>
<ship 4>
<ship 5>
<ship 6>
<ship 7>
<ship 8>
and
or
key-pressed
1
>
ShipCounter(0)
0
<
ShipCounter(0)
3
add-goal
<argument>
ai-warp
89
modify-variable
ShipCounter(0)
+
ShipCounter(0)
1
invalidate-argument
<argument>
Key-reset
1
As for why you didn't get everything to jump out I think I'm going to have to investigate this one :)
-
I take it that's an SCP job?
-
Yep. :)
-
Okay, thanks for the help you two. :cool:
-
Well, I got three ships to jump out which is a big improvement over having all of them fly away, but it only worked once. I thought a lack of a key-reset might be the culprit so I put it in the above event thinking it would reset whenever 1 was pressed but it still wouldn't come through.
Odd. I just built a mission to test that and it worked fine with both the most recent CVS (using random-multiple-of) and the 02/02-06 build (using random-of) and it worked fine with both.
Are you using a very recent CVS build? Be warned that any mission built using random-of to do this will break as soon as you start using a build that supports random-multiple-of since that does what random-of appeared to do in earlier builds. More info on the subject is here (http://www.hard-light.net/forums/index.php/topic,38643.0.html).
-
I used the 2-27 build of FSO for my test. Just to clarify, the variable was a regular number variable, there was no repeat count, and I used the first event you listed above, the one without the key-reset.
-
Give this mission a try. Press 1. Three ships should jump out.
[attachment deleted by admin]
-
I've downloaded it but have yet to take a look at it. Thanks in any event for the test mission though. :yes:
-
Shouldn't take more than a minute to test. Press 1 and see if the ships jump out :)
I'd already made the test mission anyway so I figured it's a good idea to see if you can reproduce your problem with my mission :)