Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Deora11 on November 03, 2014, 01:59:26 am

Title: Message sending from multiple sources
Post by: Deora11 on November 03, 2014, 01:59:26 am
Me again.

I wanted to know how to send a message from multiple sources, so anyone can say it. Say I have a message concerning, i don't know, how bad beta wing is.

I want it to be sent from Alpha wing, but from any-one part of alpha wing. Same goes for if one of them dies, it goes to another pilot, not just default to the #Command sender.

P.S Expect to see a little more of me, I'm far from a pro mission designer and enjoy learning Mission Design techniques.

:)
Title: Re: Message sending from multiple sources
Post by: procdrone on November 03, 2014, 04:37:50 am
that situation screams for when-argument usage.
Title: Re: Message sending from multiple sources
Post by: TopAce on November 03, 2014, 05:26:03 am
I'd use if-then-else here. If Alpha 2 isn't present, then Alpha 3 will talk; then if Alpha 3 isn't present, Alpha 4 will send the message, and so on.

Unless you want to ranzomize it, in which case, when-argument might be one option. You still need to check if the ship that the event picks is present, though.
Title: Re: Message sending from multiple sources
Post by: Deora11 on November 03, 2014, 06:29:55 pm
Well, I want it random, so I went with the (when-argument), but how do I set it so if one gets destroyed, it removes it from the list. Otherwise, if alpha 2 gets destroyed, he can still be chosen from the list, even though his not present.

Would I need a separate event where if any argument is destroyed, they become invalid?
Title: Re: Message sending from multiple sources
Post by: karajorma on November 03, 2014, 07:25:24 pm
I've not tested it but this should work.

when-argument
-random-multiple-of
--Alpha 2
--Alpha 3
--Alpha 4
- Whatever your trigger is that makes the message need to be sent
- if-then-else
-- is-destroyed-delay
--- <argument>
--- 0
--- invalidate-argument
---- <argument>
--- send-message
---- <argument>
---- high
---- Message Name
--- Invalidate-all-arguments

Set the repeat count the same as the number of ships and the repeat interval to 0. This event may actually take up to 3 frames to actually find the correct ship and send the message but for something like this, it won't matter at all since the game is running at 60 frames per second on most PCs and even at a ridiculously slow 10 FPS it's still going to trigger in under half a second.

What the event does is check if it is the right time to play the message. It then uses if-then-else to check if the wingman has been destroyed and invalidates it if it has. The event will then repeat the next frame. If the wingman hasn't been destroyed the game plays the message and then invalidates all the entries on the list so that none of the other wingmen who are still alive can send the message.
Title: Re: Message sending from multiple sources
Post by: Droid803 on November 04, 2014, 12:36:10 pm
Isn't there a builtin system where if a message assigned to one fighter is dead, if the message priority is high enough it'll be sent by another pilot with the same persona?
Title: Re: Message sending from multiple sources
Post by: AdmiralRalwood on November 04, 2014, 12:38:36 pm
Yes, but that (obviously) requires you to give all of the fighters identical personae.
Title: Re: Message sending from multiple sources
Post by: Nagrach on November 13, 2014, 10:03:03 am
I have a similiar Problem. I want that several Cap Ships are sending the same Message when they are Dying, but I have no clue how do to this, the Persona thing doesn't, so I consider if-than-else? Like posted before?
Title: Re: Message sending from multiple sources
Post by: Cyborg17 on November 13, 2014, 10:51:31 am
I have a similiar Problem. I want that several Cap Ships are sending the same Message when they are Dying, but I have no clue how do to this, the Persona thing doesn't, so I consider if-than-else? Like posted before?

To clarify, you want different cap ships to send the same message when they die or if their health is below a certain point?
Title: Re: Message sending from multiple sources
Post by: karajorma on November 13, 2014, 05:20:23 pm
What I've written will work perfectly well for capships but since the player tends to take more notice of capships than fighters, it's probably a good idea to give each ship its own message.
Title: Re: Message sending from multiple sources
Post by: AdmiralRalwood on November 13, 2014, 05:25:05 pm
If the message needs to be sent on death, it makes more sense to use when-argument with any-of and a condition that checks if <argument> is dying.
Title: Re: Message sending from multiple sources
Post by: Rheyah on November 15, 2014, 02:01:32 pm
$Formula: ( when-argument
   ( any-of
      "Delta 1"
      "Delta 2"
      "Delta 3"
   )
   ( is-destroyed-delay 0 "<argument>" )
   ( when
      ( and
         ( is-destroyed-delay 0 "Delta 1" )
         ( not
            ( is-destroyed-delay 0 "Delta 2" )
         )
      )
      ( send-message
         "Delta 2"
         "Low"
         "Delta1DownD2-1"
      )
   )
   ( when
      ( and
         ( is-destroyed-delay
            0
            "Delta 1"
            "Delta 2"
         )
         ( not
            ( is-destroyed-delay 0 "Delta 3" )
         )
      )
      ( send-message
         "Delta 3"
         "Normal"
         "Delta12DownD3-1"
      )
      ( training-msg
         "Delta12DownPCT-2"
         "Delta12DownPCT-2"
         3
      )
   )
   ( when
      ( and
         ( is-destroyed-delay 0 "Delta 2" )
         ( not
            ( is-destroyed-delay 0 "Delta 1" )
         )
      )
      ( send-message
         "Delta 1"
         "Low"
         "Delta2DownD1-1"
      )
   )
   ( when
      ( and
         ( is-destroyed-delay 0 "Delta 3" )
         ( not
            ( is-destroyed-delay 0 "Delta 1" )
         )
      )
      ( send-message
         "Delta 1"
         "Low"
         "Delta3DownD1-1"
      )
   )
   ( when
      ( is-destroyed-delay
         0
         "Delta 3"
         "Delta 1"
         "Delta 2"
      )
      ( send-message-list
         "Delta 4"
         "Normal"
         "DeltaAllDownPC-1"
         0
         "Ephesus"
         "Normal"
         "DeltaAllDownEP-2"
         6000
         "Alpha 3"
         "Normal"
         "DeltaAllDownA3-3"
         6000
      )
   )
   ( invalidate-argument "<argument>" )
)
+Name: MSG:  Delta Death Messages
+Repeat Count: -1
+Trigger Count: 3
+Interval: 10


This is a more complicated example which provides seperate, updating messages for four personas as members of the wing die.  It is just given as an example of the kind of when-argument combined with when conditions which let you seperate out pilot personas.

Hope this helps :)
Title: Re: Message sending from multiple sources
Post by: karajorma on November 15, 2014, 07:51:57 pm
I'd probably have separated them into 4 different events (one for each member of Delta wing) but this works too. :)

To be honest, what I would do now is use the SEXP container feature. But since that's not in trunk yet, I don't blame anyone for waiting for it to hit trunk.