Modding, Mission Design, and Coding > The FRED Workshop

Is there a simpler way? (query-orders)

(1/1)

TopAce:
Here's the starting scenario: Command sends the customary initial message along the lines of "There's the target. Destroy it." After a little pause, I want a random wingmen to ask the player (Gold leader) to give out some sensible orders. ("What's the tactic, Gold leader?") Now, it is possible that 14 seconds in, some players have already issued some orders, so I want to make sure this random wingmen doesn't ask a superfluous question. Here's my current solution:


--- Code: ---$Formula: ( when-argument
   ( random-of
      "Gold 2"
      "Gold 3"
      "Gold 4"
      "Red 1"
      "Red 2"
      "Red 3"
      "Red 4"
   )
   ( and
      ( has-time-elapsed 14 )
      ( string-equals
         "@SubsysCommendation[no]"
         "no"
      )
      ( not
         ( query-orders
            "<all fighters>"
            "Destroy my target"
            0
            "Mandalorian"
         )
      )
      ( not
         ( query-orders
            "Gold"
            "Destroy my target"
            0
            "Mandalorian"
         )
      )
      ( not
         ( query-orders
            "Red"
            "Destroy my target"
            0
            "Mandalorian"
         )
      )
      ( not
         ( query-orders
            "Blue"
            "Destroy my target"
            0
            "Mandalorian"
         )
      )
      ( not
         ( query-orders
            "<all fighters>"
            "Cover me"
            0
         )
      )
      ( not
         ( query-orders "Gold" "Cover me" 0 )
      )
      ( not
         ( query-orders "Red" "Cover me" 0 )
      )
      ( not
         ( query-orders "Blue" "Cover me" 0 )
      )
      ( not
         ( query-orders
            "<all fighters>"
            "Engage enemy"
            0
         )
      )
      ( not
         ( query-orders
            "Gold"
            "Engage enemy"
            0
         )
      )
      ( not
         ( query-orders "Red" "Engage enemy" 0 )
      )
      ( not
         ( query-orders
            "Blue"
            "Engage enemy"
            0
         )
      )
   )
   ( send-message
      "<argument>"
      "Normal"
      "Any - General attk"
   )
)
+Name: Msg - Start orders inquiry
+Repeat Count: 1
+Interval: 1
--- End code ---

@SubsysCommendation[no] turns "yes" if the player issues orders to attack some particular subsystems whose destruction would be beneficial. Command commends the player for thinking ahead.

"Mandalorian" is a warship, the primary objective.

Now I could use the commands ("Destroy my target" etc) as arguments, but I want to randomize the wingmen AND have him ask the question at an appropriate time. Hence there is no "query-orders - Alpha 3 - form up on my wing" because it's not a tactic.

0rph3u5:
You can use nested when/when-argument to run off a variable which had its value altered/randomized previously in the same event.
All you would need is another variable.

Note, that if you do this you have to remember that <argument> is specific to the when-argument it is in.

On phone can't pull an example.

0rph3u5:
Okay, I don't have a perfect fit but I've got two that are two halves of the concept:

This is a load-out save event (to copy the loadout onto a reinforcement wing) - see the nested when-arguments

--- Code: ---$Formula: ( when
   ( has-time-elapsed 0 )
   ( when-argument
      ( any-of
         "HLF Anubis"
         "HLF Seth"
         "HLF Horus"
         "HLF Thoth"
         "HLB Osiris"
         "HLB Amun"
      )
      ( is-ship-class
         "<argument>"
         "Alpha 1"
      )
      ( modify-variable
         "@Loadout_A1-Shp[PVF Anubis]"
         "<argument>"
      )
   )
   ( when-argument
      ( any-of
         "ML-16 Laser"
         "VLL-9 Laser"
         "Disruptor"
         "Avenger"
         "Flail"
         "Prometheus"
      )
      ( has-primary-weapon
         "Alpha 1"
         "0"
         "<argument>"
      )
      ( modify-variable
         "@Loadout_A1P1[Avenger]"
         "<argument>"
      )
   )
   ( when-argument
      ( any-of
         "ML-16 Laser"
         "VLL-9 Laser"
         "Disruptor"
         "Avenger"
         "Flail"
         "Prometheus"
      )
      ( and
         ( not
            ( or
               ( is-ship-class
                  "HLF Anubis"
                  "Alpha 1"
               )
               ( is-ship-class "HLF Thoth" "Alpha 1" )
               ( is-ship-class
                  "HLB Osiris"
                  "Alpha 1"
               )
            )
         )
         ( has-primary-weapon
            "Alpha 1"
            "1"
            "<argument>"
         )
      )
      ( modify-variable
         "@Loadout_A1P2[Avenger]"
         "<argument>"
      )
   )
   ( when-argument
      ( any-of
         "MX-50"
         "Fury"
         "Fang"
         "Interceptor"
         "Hornet"
         "Phoenix V"
         "D-Missile"
         "Havoc"
         "Synaptic"
         "Stiletto"
         "Barracuda"
         "Tsunami"
      )
      ( has-secondary-weapon
         "Alpha 1"
         "0"
         "<argument>"
      )
      ( modify-variable
         "@Loadout_A1S1[MX-50]"
         "<argument>"
      )
   )
   ( when-argument
      ( any-of
         "MX-50"
         "Fury"
         "Fang"
         "Interceptor"
         "Hornet"
         "Phoenix V"
         "D-Missile"
         "Havoc"
         "Synaptic"
         "Stiletto"
         "Barracuda"
         "Tsunami"
      )
      ( and
         ( not
            ( or
               ( is-ship-class
                  "HLF Anubis"
                  "Alpha 1"
               )
               ( is-ship-class "HLF Thoth" "Alpha 1" )
            )
         )
         ( has-secondary-weapon
            "Alpha 1"
            "1"
            "<argument>"
         )
      )
      ( modify-variable
         "@Loadout_A1S2[MX-50]"
         "<argument>"
      )
   )
   ( when-argument
      ( any-of
         "MX-50"
         "Fury"
         "Fang"
         "Interceptor"
         "Hornet"
         "Phoenix V"
         "D-Missile"
         "Havoc"
         "Synaptic"
         "Stiletto"
         "Barracuda"
         "Tsunami"
      )
      ( and
         ( or
            ( is-ship-class
               "HLB Osiris"
               "Alpha 1"
            )
            ( is-ship-class "HLB Amun" "Alpha 1" )
         )
         ( has-secondary-weapon
            "Alpha 1"
            "2"
            "<argument>"
         )
      )
      ( modify-variable
         "@Loadout_A1S3[MX-50]"
         "<argument>"
      )
   )
)
+Name: save loadout A1
+Repeat Count: 1
+Interval: 1
--- End code ---

This is a randomized propaganda broadcast, not using send-random-message (because I wanted to keep the option open to add some functionality) - see how it works of the variable randomized on top of the nested whens

--- Code: ---$Formula: ( when
   ( and
      ( >
         ( mission-time-msecs )
         @a_timer[0]
      )
      ( has-arrived-delay
         20
         "Pronouncement"
      )
      ( not
         ( or
            ( destroyed-or-departed-delay
               0
               "Pronouncement"
            )
            ( is-subsystem-destroyed-delay
               "Pronouncement"
               "communications"
               0
            )
         )
      )
   )
   ( modify-variable
      @a_timer[0]
      ( +
         @a_timer[0]
         ( rand-multiple
            @a_timer_interval_min[8000]
            @a_timer_interval_max[12000]
         )
      )
   )
   ( modify-variable
      @a_msg_rng[35]
      ( rand-multiple 1 34 )
   )
   ( when
      ( = @a_msg_rng[35] 0 )
      ( send-message
         "Pronouncement"
         "Low"
         "DEBUG MESSAGE"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 1 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 1"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 2 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 2"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 3 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 3"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 4 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 4"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 5 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 5"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 6 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 6"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 7 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 7"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 8 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 8"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 9 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 9"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 10 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 10"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 11 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 11"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 12 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 12"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 13 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 13"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 14 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 14"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 15 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 15"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 16 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 16"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 17 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 17"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 18 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 18"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 19 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 19"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 20 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 20"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 21 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 21"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 22 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 22"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 23 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 23"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 24 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 24"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 25 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 25"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 26 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 26"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 27 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 27"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 28 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 28"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 29 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 29"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 30 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 30"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 31 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 31"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 32 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 32"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 33 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 33"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
   ( when
      ( = @a_msg_rng[35] 34 )
      ( send-message
         "Pronouncement"
         "Low"
         "Propagandist 34"
      )
      ( modify-variable @a_msg_rng[35] 35 )
   )
)
+Name: rmsg propagandist
+Repeat Count: -1
+Trigger Count: 9999999
+Interval: 1
--- End code ---

ps. sorry for the clutter, pulled my back earlier this morning, sitting difficult

Navigation

[0] Message Index

Go to full version