Author Topic: FRED Help Needed (Event triggering)  (Read 5661 times)

0 Members and 1 Guest are viewing this topic.

FRED Help Needed (Event triggering)
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.
GTI Rebellion FREDer

Dissident Theory

Permissum sacramentum non exsisto infractus , per fides exsisto led.

 

Offline Nuclear1

  • 211
Re: FRED Help Needed (Event triggering)
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.

Code: [Select]
-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:

Code: [Select]
--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. :)
Spoon - I stand in awe by your flawless fredding. Truely, never before have I witnessed such magnificant display of beamz.
Axem -  I don't know what I'll do with my life now. Maybe I'll become a Nun, or take up Macrame. But where ever I go... I will remember you!
Axem - Sorry to post again when I said I was leaving for good, but something was nagging me. I don't want to say it in a way that shames the campaign but I think we can all agree it is actually.. incomplete. It is missing... Voice Acting.
Quanto - I for one would love to lend my beautiful singing voice into this wholesome project.
Nuclear1 - I want a duet.
AndrewofDoom - Make it a trio!

 

Offline Shade

  • 211
Re: FRED Help Needed (Event triggering)
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.
Report FS_Open bugs with Mantis  |  Find the latest FS_Open builds Here  |  Interested in FRED? Check out the Wiki's FRED Portal | Diaspora: Website / Forums
"Oooooooooooooooooooooooooooooooooooooooh ****ing great. 2200 references to entry->index and no idea which is the one that ****ed up" - Karajorma
"We are all agreed that your theory is crazy. The question that divides us is whether it is crazy enough to have a chance of being correct." - Niels Bohr
<Cobra|> You play this mission too intelligently.

 
Re: FRED Help Needed (Event triggering)
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?
GTI Rebellion FREDer

Dissident Theory

Permissum sacramentum non exsisto infractus , per fides exsisto led.

 

Offline Nuclear1

  • 211
Re: FRED Help Needed (Event triggering)
Nope. Simply right click on any event and look for "Add Variable" in the selection.

Like myeh:

[attachment deleted by admin]
Spoon - I stand in awe by your flawless fredding. Truely, never before have I witnessed such magnificant display of beamz.
Axem -  I don't know what I'll do with my life now. Maybe I'll become a Nun, or take up Macrame. But where ever I go... I will remember you!
Axem - Sorry to post again when I said I was leaving for good, but something was nagging me. I don't want to say it in a way that shames the campaign but I think we can all agree it is actually.. incomplete. It is missing... Voice Acting.
Quanto - I for one would love to lend my beautiful singing voice into this wholesome project.
Nuclear1 - I want a duet.
AndrewofDoom - Make it a trio!

 

Offline Nuclear1

  • 211
Re: FRED Help Needed (Event triggering)
And from there, you'll get this next option.

Simply replace "VariableName" with "CargoScanned" and "Default Value" with 0.



[attachment deleted by admin]
Spoon - I stand in awe by your flawless fredding. Truely, never before have I witnessed such magnificant display of beamz.
Axem -  I don't know what I'll do with my life now. Maybe I'll become a Nun, or take up Macrame. But where ever I go... I will remember you!
Axem - Sorry to post again when I said I was leaving for good, but something was nagging me. I don't want to say it in a way that shames the campaign but I think we can all agree it is actually.. incomplete. It is missing... Voice Acting.
Quanto - I for one would love to lend my beautiful singing voice into this wholesome project.
Nuclear1 - I want a duet.
AndrewofDoom - Make it a trio!

 
Re: FRED Help Needed (Event triggering)
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?
GTI Rebellion FREDer

Dissident Theory

Permissum sacramentum non exsisto infractus , per fides exsisto led.

 

Offline Shade

  • 211
Re: FRED Help Needed (Event triggering)
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 :)

Code: [Select]
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.
Report FS_Open bugs with Mantis  |  Find the latest FS_Open builds Here  |  Interested in FRED? Check out the Wiki's FRED Portal | Diaspora: Website / Forums
"Oooooooooooooooooooooooooooooooooooooooh ****ing great. 2200 references to entry->index and no idea which is the one that ****ed up" - Karajorma
"We are all agreed that your theory is crazy. The question that divides us is whether it is crazy enough to have a chance of being correct." - Niels Bohr
<Cobra|> You play this mission too intelligently.

 
Re: FRED Help Needed (Event triggering)
Ah, I have it now, many thanks to everyone.  Hopefully I'll have this worked out soon.
GTI Rebellion FREDer

Dissident Theory

Permissum sacramentum non exsisto infractus , per fides exsisto led.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: FRED Help Needed (Event triggering)
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
« Last Edit: March 01, 2006, 05:51:31 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Shade

  • 211
Re: FRED Help Needed (Event triggering)
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 :)
Report FS_Open bugs with Mantis  |  Find the latest FS_Open builds Here  |  Interested in FRED? Check out the Wiki's FRED Portal | Diaspora: Website / Forums
"Oooooooooooooooooooooooooooooooooooooooh ****ing great. 2200 references to entry->index and no idea which is the one that ****ed up" - Karajorma
"We are all agreed that your theory is crazy. The question that divides us is whether it is crazy enough to have a chance of being correct." - Niels Bohr
<Cobra|> You play this mission too intelligently.

 

Offline Nuclear1

  • 211
Re: FRED Help Needed (Event triggering)
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.
Spoon - I stand in awe by your flawless fredding. Truely, never before have I witnessed such magnificant display of beamz.
Axem -  I don't know what I'll do with my life now. Maybe I'll become a Nun, or take up Macrame. But where ever I go... I will remember you!
Axem - Sorry to post again when I said I was leaving for good, but something was nagging me. I don't want to say it in a way that shames the campaign but I think we can all agree it is actually.. incomplete. It is missing... Voice Acting.
Quanto - I for one would love to lend my beautiful singing voice into this wholesome project.
Nuclear1 - I want a duet.
AndrewofDoom - Make it a trio!

 

Offline Slasher

  • 29
Re: FRED Help Needed (Event triggering)
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?

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: FRED Help Needed (Event triggering)
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.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: FRED Help Needed (Event triggering)
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
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: FRED Help Needed (Event triggering)
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.

 

Offline Slasher

  • 29
Re: FRED Help Needed (Event triggering)
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. 


 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: FRED Help Needed (Event triggering)
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.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: FRED Help Needed (Event triggering)
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 :)
« Last Edit: March 02, 2006, 03:58:21 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Slasher

  • 29
Re: FRED Help Needed (Event triggering)
I take it that's an SCP job?