[Question] Behavior of MD cancel_cue

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

[Question] Behavior of MD cancel_cue

Post by arshiba » Sun, 27. Jun 21, 12:25

There is a statement in the official Mission Director Guide which states:
Cancelling a cue with <cancel_cue> also cancels all its sub-cues, and cancelling a static cue stops it from instantiating more cues - but it does not cancel its instances.
After spending a lot of time debugging my mod, I realized that it is false. Cancelling a cue with <cancel_cue> also cancels all its sub-cues with all their instances.
Question: Is this by design or is there another use case (if the documentation is correct)?

I wrote following test example:

Code: Select all

    <cue name="Demo1">
      <delay exact="1ms" />
      <actions>
        <signal_cue cue="Demo2" />
      </actions>
      <delay exact="1s" />
      <actions>
        <cancel_cue cue="this" />
      </actions>
      <cues>
        <cue name="Demo2" instantiate="true">
          <conditions>
            <event_cue_signalled />
          </conditions>
          <actions>
            <debug_text text="'Active Demo2'" />
          </actions>
          <delay exact="10s" />
          <actions>
            <signal_cue cue="Demo3" />
          </actions>
          <cues>
            <cue name="Demo3">
              <conditions>
                <event_cue_signalled />
              </conditions>
              <actions>
                <debug_text text="'Active Demo3'" />
              </actions>
            </cue>
          </cues>
        </cue>
      </cues>
    </cue>
Then I checked the debug log and the savegame:

Code: Select all

[Scripts] 73920.78 *** Context:md.TFDronesLogic.Demo2<inst:4855b1b>: Active Demo2

Code: Select all

  <cue id="68368" name="Demo1" state="cancelled" index="1">
    <cue id="68369" name="Demo2" state="cancelled">
      <cue id="68370" name="Demo3" state="cancelled" />
    </cue>
  </cue>
The instance has been activated and vanished!

I commented out the <cancel_cue> action and ran example again.
Debug log and savegame after 2 sec (before activation of Demo3).

Code: Select all

[Scripts] 73920.73 *** Context:md.TFDronesLogic.Demo2<inst:601f11d>: Active Demo2

Code: Select all

  <cue id="68380" name="Demo1" state="complete" time="73920.732" index="1">
    <cue id="68381" name="Demo2" state="waiting">
      <cue id="68382" name="Demo3" />
      <instances>
        <cue id="68431" state="active" time="73920.732" index="1">
          <event name="event_cue_signalled">
            <object type="cue" value="68381" />
          </event>
          <cue id="68432" base="68382" state="waiting" />
        </cue>
      </instances>
    </cue>
  </cue>
Debug log and savegame after 10 sec.

Code: Select all

[Scripts] 73920.73 *** Context:md.TFDronesLogic.Demo2<inst:601f11d>: Active Demo2
[Scripts] 73930.77 *** Context:md.TFDronesLogic.Demo3<inst:601ed13>: Active Demo3

Code: Select all

  <cue id="68374" name="Demo1" state="complete" time="73920.732" index="1">
    <cue id="68375" name="Demo2" state="waiting">
      <cue id="68376" name="Demo3" />
    </cue>
  </cue>

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [Question] Behavior of MD cancel_cue

Post by SirNukes » Sun, 27. Jun 21, 19:51

The documentation looks right to me.

Instantiatable cues have a base version that has the conditions and template for creating the instances, called the static cue. Cancel that static cue, and existing instances of it will keep running (since they are their own objects after instantiating). Instances are just copies, and have the same parent cue, so cancel that parent cue and all the children are cancelled.

arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

Re: [Question] Behavior of MD cancel_cue

Post by arshiba » Sun, 27. Jun 21, 21:05

SirNukes wrote:
Sun, 27. Jun 21, 19:51
Cancel that static cue, and existing instances of it will keep running (since they are their own objects after instantiating).
Nope.
I change the line and the result is the same. The parent cue Demo1 is intact. The static cue Demo2 is cancelled. The instance of Demo2 is dead.

Code: Select all

        <cancel_cue cue="Demo2" />

Code: Select all

[Scripts] 73921.23 *** Context:md.TFDronesLogic.Demo2<inst:207905e>: Active Demo2

Code: Select all

  <cue id="68376" name="Demo1" state="complete" time="73921.226" index="1">
    <cue id="68377" name="Demo2" state="cancelled">
      <cue id="68378" name="Demo3" state="cancelled" />
    </cue>
  </cue>
Please give me an example when the instance survives when the static cue is canceled.

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [Question] Behavior of MD cancel_cue

Post by SirNukes » Sun, 27. Jun 21, 22:31

I think your code change just cancelled the instance, not the staticbase. See the "Access to instances" section. Try cancelling Demo2.staticbase (if I am reading the doc right).

arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

Re: [Question] Behavior of MD cancel_cue

Post by arshiba » Mon, 28. Jun 21, 07:58

SirNukes wrote:
Sun, 27. Jun 21, 22:31
I think your code change just cancelled the instance, not the staticbase. See the "Access to instances" section.
In the static tree: Cue names in expressions are always resolved to the static cues.
I can't access the instance from the outside because there are no references to it. Demo1 is static (base), so it only has access to other static cues.
SirNukes wrote:
Sun, 27. Jun 21, 22:31
Try cancelling Demo2.staticbase (if I am reading the doc right).
Tried it and nothing changed.

Code: Select all

        <cancel_cue cue="Demo2.staticbase" />

Post Reply

Return to “X4: Foundations - Scripts and Modding”