[help] MD Script Condition

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

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

Eagle_Four
Posts: 231
Joined: Wed, 6. Nov 02, 20:31
x3

[help] MD Script Condition

Post by Eagle_Four » Mon, 3. Jul 23, 09:28

I am currently trying in a MD Script to trigger an action block with a condition that is only true if the object is not a wreck.

I have tried the following in the condition block:

Code: Select all

<check_value value="not event.param.iswreck"/>
<check_value value="event.param.iswreck != 1"/>
<check_value value="event.param.iswreck == 0"/>
<check_value value="event.param.state =! 'wreck'"/>
<check_value value="event.param.iswreck" exact="0"/>
everything does not work. The condition is always 'true' by previous conditions.

The whole condition block looks like this:

Code: Select all

<conditions>
                        <check_any>
                            <check_all>
                                <event_player_owned_killed_object/>
				<check_any>
                                    <check_value value="event.param2.isclass.ship"/>
                                    <check_value value="event.param2.isclass.station"/>
                                    <check_value value="event.param2.isclass.module"/>
                                    <check_value value="event.param2.issurfaceelement"/>
     			            <check_value value="event.param2.islasertower"/>
				</check_any>
                            </check_all>
                            <check_all>
                                <event_player_owned_attacked_object/>
                                <check_value value="event.param2.isoperational"/>
                            </check_all>
                        </check_any>
 <!-- This is where the query should go in <check_value value="not event.param.iswreck"/> -->
   			<check_value value="not @event.param.hasrelation.enemy.{@event.param2.trueowner}"/>
                        <check_value value="event.param2.trueowner.knownname != {20203, 1001}"/>
</conditions>
Do I use in the action block but first

Code: Select all

<do_if value="not event.param.iswreck">
it works. This is how I got around it. I would be interested to know why I can't query wreck in the condition block.

(The code is mostly from Mycu, try to make some improvements).

User avatar
Dj_FRedy
Posts: 237
Joined: Mon, 27. Jun 11, 05:58
x4

Re: [help] MD Script Condition

Post by Dj_FRedy » Mon, 3. Jul 23, 11:05

Check to see what returns in case of doubt:

Code: Select all

<!-- This is where the query should go in <check_value value="not event.param.iswreck"/> -->
<debug_text text="'iswreck: ' + event.param.iswreck" debugchance="100"/>
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13308
Joined: Sun, 15. Feb 04, 20:12
x4

Re: [help] MD Script Condition

Post by euclid » Mon, 3. Jul 23, 12:08

I wonder whether there is a delay between destroying an object and updating its state? I saw it happening with station modules (Xenon) that it takes a few seconds to "replace" the destroyed part with a wreck. It would explain why your do_if in the action block works.
I've noticed that in your condition block you open a second check_all just after closing the first. It may be unrelated but any reason for that?

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Eagle_Four
Posts: 231
Joined: Wed, 6. Nov 02, 20:31
x3

Re: [help] MD Script Condition

Post by Eagle_Four » Mon, 3. Jul 23, 19:24

Dj_FRedy wrote:
Mon, 3. Jul 23, 11:05
Check to see what returns in case of doubt:

Code: Select all

<!-- This is where the query should go in <check_value value="not event.param.iswreck"/> -->
<debug_text text="'iswreck: ' + event.param.iswreck" debugchance="100"/>
The result is always 0, whether the attacker is already a wreck or not.
euclid wrote:
Mon, 3. Jul 23, 12:08
I wonder whether there is a delay between destroying an object and updating its state? I saw it happening with station modules (Xenon) that it takes a few seconds to "replace" the destroyed part with a wreck. It would explain why your do_if in the action block works.
I've noticed that in your condition block you open a second check_all just after closing the first. It may be unrelated but any reason for that?

Cheers Euclid
In the first check_all it is checked if the kill event triggered, in the second check_all it is checked if it was 'only' the attack event.

I also think that this is a time critical problem.
Between condition block and action block is a delay of 1 second.
The event is triggered by the destruction of docking modules, on which there are still ships from other factions, which are destroyed by this.
This leads to the triggering of the event, which is not desired.

Edit:
But now that I think about it, it's also logical. First the ships are destroyed, the event is triggered, but the module is not yet a wreck. Only a short time later the module becomes a wreck, but then it is already too late for the condition check.

User avatar
Dj_FRedy
Posts: 237
Joined: Mon, 27. Jun 11, 05:58
x4

Re: [help] MD Script Condition

Post by Dj_FRedy » Tue, 4. Jul 23, 03:46

Consider, if you haven't already, tracking everything to get a better view of what is happening and in what order - those two events together can be confusing:

Code: Select all

<debug_text text="'event_name=%1: param=%2 param_name=%3, param2=%4 param2_name=%5, method=%6'.[event.name, event.param, event.param.knownname, event.param2, event.param2.knownname, event.param3]" chance="100"/>
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

Eagle_Four
Posts: 231
Joined: Wed, 6. Nov 02, 20:31
x3

Re: [help] MD Script Condition

Post by Eagle_Four » Tue, 4. Jul 23, 11:37

Thanks for the tip. :)

Return to “X4: Foundations - Scripts and Modding”