Question regarding creating a diff to a mod

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

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

Post Reply
xWolfzx
Posts: 181
Joined: Fri, 14. Aug 09, 07:46
x4

Question regarding creating a diff to a mod

Post by xWolfzx » Sun, 17. Jul 22, 04:16

Hello all,

I was wondering it anyone is able to advise. I'm trying to play around with one of the md files (Notification) in the starwars mod to play around with the figures, (to be more precise, the setting basechance amount from 11 to another figure as well as changing the text in $abandontext to something else).

So I tried creating a diff file, creating an extension with content etc for it so I can install it fine in X4. However, I'm not sure if the basechance amount was replaced correctly and the text did not seem to trigger. Would anyone know what I've done wrong?

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="/mdscript/cues/cue[1]/cues/cue[24]/actions/do_else/do_if/do_if[2]/do_if[2]/do_if[1]/set_value[1]/@exact">24</replace>
<replace sel="/mdscript/cues/cue[1]/cues/cue[24]/actions/do_else/do_if/do_if[4]/do_if[2]/do_if[2]/@exact">'This is a test - Satellite detected ship abandoned in sector %s'.[$target.pilot.sector.knownname]</replace>
</diff>

Snippet of the code I'm trying to edit

Code: Select all

?xml version="1.0" encoding="utf-8"?>
<diff> 
	<add sel="//mdscript[@name='Notifications']/cues/cue[@name='Init']/cues/cue[@name='BaseRelationChanged']/conditions"><check_value value="event.param3 != null" /></add>
	<remove sel="/mdscript/cues/cue[1]/cues/cue[24]/actions/do_if[3]"/>
	<add sel="/mdscript/cues/cue[1]/cues/cue[24]/actions/do_else" pos="after">
		<do_if value="$target.iscapturable">
			<do_if value="event.name == 'event_cue_signalled'">
				<set_value name="$Speak_Line" exact="5037" comment="(refusal to surrender - in danger)" />
			</do_if>
			<do_if value="if not $testcheat? then (((not $target.maxshield) or ($target.shieldpercentage lt 20)) and ($target.hullpercentage lt 75) and not $target.assigneddock and (not $target.iscapitalship or $target.people.count)) else true">
				<do_if value="not $target.pilot.$nextcapturechance?">
					<set_value name="$target.pilot.$nextcapturechance" exact="player.age - 1s" />
				</do_if>
				<do_if value="if not $testcheat? then ($target.pilot.$nextcapturechance lt player.age) else true">
					<do_if value="event.name != 'event_cue_signalled' or (($target.people.count)f / ($target.people.capacity)f) lt ((16 - $target.pilot.skill.morale)f / 16.0)">
						<set_value name="$basechance" exact="11"/>
						<set_value name="$minlifetime" exact="50min"/>
						<set_value name="$maxlifetime" exact="240min"/>		
				...
				...
				...
					<do_if value="$sat">
						<debug_to_file name="'EnhancedBail'" directory="'EnhancedBail'"  text="'Advanced Satellite present in sector send log to Player'"/>
						<!-- <set_value name="$abandontext" exact="'Satellite detected ship %s abandoned in sector %s'.[$target.knownname, $target.pilot.sector.knownname]"/> -->
						<set_value name="$abandontext" exact="'Satellite detected ship abandoned in sector %s'.[$target.pilot.sector.knownname]"/>
						<play_sound object="player.entity" sound="'notification_danger'"/>
						<show_notification text="$abandontext" timeout="10s"/>
						<write_to_logbook title="'Detected abondoned ship'" category="alerts" text="$abandontext" interaction="showonmap" object="$target"/>
					</do_if>	

user1679
Posts: 789
Joined: Fri, 20. Jul 18, 23:20

Re: Question regarding creating a diff to a mod

Post by user1679 » Tue, 19. Jul 22, 03:08

If you're trying to diff another mod that's already a diff (edit), you need to make sure your file is loaded after that other mod by making it a dependency
in your mod's content.xml:

<dependency id="OTHER_MOD_ID" optional="false" personal="TRUE_OR_FALSE" name="OTHER_MOD_NAME" />

id="OTHER_MOD_ID": This is obtained from the content.xml for the mod you're trying to diff. This is required.
personal="TRUE_OR_FALSE": This needs to be TRUE if the dependency is not located in the game's extensions folder. It can be FALSE or omitted entirely if it is.
name="OTHER_MOD_NAME": This is obtained from the content.xml for the mod you're trying to diff. This is optional but useful for when the mod author uses random numbers for ID.

For example, to make the Tides of Avarice DLC a required mod and loaded before yours:

<dependency id="ego_dlc_pirate" optional="false" personal="false" name="Tides of Avarice" />


Also, it's good to start your game with logging enabled because it will tell you in the debug log if there was an error in your syntax causing
your mod to not load or fail to execute:

x4.exe -debug all -logfile debugLog.txt

If you're using steam, debugLog.txt will be found in the folder under the game ID. For GOG, it's in your documents\Egosoft folder.

Post Reply

Return to “X4: Foundations - Scripts and Modding”