Patching XML - Revisited

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

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

Post Reply
user1679
Posts: 761
Joined: Fri, 20. Jul 18, 23:20

Patching XML - Revisited

Post by user1679 » Sun, 6. Jun 21, 22:46

I'm looking to expand a mod I worked on a while back but I'm not clear how to reintroduce code that was commented out in previous iterations
without making the player have to start a new game.

I know that I need to use the patch directive and I think it needs to come after the conditions block but before the first cue (though I'm not totally sure). The
problem I'm facing is I have a subcue that has some commented lines that I want to restore but I'm not sure where the patch needs to go and if I need
to include the entire subcue in the patch or only the lines I'm interested in changing.

Example:

In the code block below, rse_conversation is a subcue of a cue that places my NPC. The code I want to reintroduce is the commented out section located
under <do_if value="event.param == 'choose_amount'"> which adds new dialog to the NPC. Of course I need to add new code as well because in its current
form it doesn't work.

To summarize, I want to add new dialog options to my NPC while preventing existing users from having to start a new game.

Thanks!

Code: Select all

                        <cue name="rse_conversation" instantiate="true" version="200">
                            <conditions>
                                <event_conversation_next_section actor="$ROfficer" />
                            </conditions>
                            <actions>
                                <do_if value="event.param == 'bye'">  
                                    <do_any>
                                        <!-- bye -->
                                        <add_npc_line speaker="$ROfficer" line="1800" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1801" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1802" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1803" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1804" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1805" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1806" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1807" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1808" hidechoices="false"/>
                                        <add_npc_line speaker="$ROfficer" line="1809" hidechoices="false"/>                                       
                                        <add_npc_line speaker="$ROfficer" line="1810" hidechoices="false"/>
                                    </do_any>                              
                                </do_if>

                                <do_if value="event.param == 'choose_npc_type'">
                                    <add_npc_line line="1500" hidechoices="false" comment="which one?"/>                                   
                                    <add_player_choice_sub text="{88888881,1002} + ' (%s Cr)'.[$EngineerPrice.formatted.default]" section="choose_npc_gender" choiceparam="'engineer'" baseparam="event.param2"/>
                                    <add_player_choice_sub text="{88888881,1003} + ' (%s Cr)'.[$PilotPrice.formatted.default]"    section="choose_npc_gender" choiceparam="'pilot'" baseparam="event.param2"/>                                    
                                    <add_player_choice_sub text="{88888881,1004} + ' (%s Cr)'.[$ManagerPrice.formatted.default]"  section="choose_npc_gender" choiceparam="'manager'" baseparam="event.param2"/>   
                                    <add_player_choice_sub text="{88888881,1005} + ' (%s Cr)'.[$MarinePrice.formatted.default]"   section="choose_npc_gender" choiceparam="'marine'" baseparam="event.param2"/>                             
                                    <add_player_choice_sub text="{88888881,1012}" section="expensive" choiceparam="event.object" baseparam="event.param2"/>   
                                    <add_player_choice_sub text="{88888881,1013}" section="bye" choiceparam="event.object" baseparam="event.param2" position="bottom_right"/>
                                </do_if>

                                <do_if value="event.param == 'choose_npc_gender'">
                                    <!-- user2046 2021-03-10 - Allow player to select gender when hiring. See 0001.xml for correcponding entries (1002,1003...) -->
                                    <set_value name="$SelectedNPCType" exact="event.param2" />

                                    <add_npc_line line="1500" hidechoices="false" comment="which gender?"/>                                   
                                    <add_player_choice_sub text="{88888881,1006}" section="choose_ship" choiceparam="'male'" baseparam="event.param2"/>
                                    <add_player_choice_sub text="{88888881,1007}"    section="choose_ship" choiceparam="'female'" baseparam="event.param2"/>   
                                    <add_player_choice_sub text="{88888881,1008}"    section="choose_ship" choiceparam="'any'" baseparam="event.param2"/>
                                    <add_player_choice_sub text="{88888881,1012}" section="expensive" choiceparam="event.object" baseparam="event.param2"/>   
                                    <add_player_choice_sub text="{88888881,1013}" section="bye" choiceparam="event.object" baseparam="event.param2" position="bottom_right"/>
                                </do_if>

                                <do_if value="event.param == 'expensive'">
                                    <do_any>                              
                                        <add_npc_line line="1900" hidechoices="false"/>
                                        <add_npc_line line="1901" hidechoices="false"/>
                                        <add_npc_line line="1902" hidechoices="false"/>
                                        <add_npc_line line="1903" hidechoices="false"/>
                                        <add_npc_line line="1904" hidechoices="false"/>
                                        <add_npc_line line="1905" hidechoices="false"/>
                                        <add_npc_line line="1906" hidechoices="false"/>
                                        <add_npc_line line="1907" hidechoices="false"/>
                                        <add_npc_line line="1908" hidechoices="false"/>
                                        <add_npc_line line="1909" hidechoices="false"/>                                                                                
                                    </do_any>
                                </do_if>

                                <!-- UNUSED -->
                                <do_if value="event.param == 'choose_amount'">

                                    <!-- user2046 - Allow player to select gender when hiring -->
                                    <set_value name="$SelectedNPCGender" exact="event.param2" />

                                    <!-- user2046 - Assign random gender if player chose that option -->
                                    <do_if value="event.param2" exact="'any'">
                                        <set_value name="$SelectedNPCGender" exact="['male', 'female'].random" />
                                    </do_if>

                                    <add_npc_line line="1505" hidechoices="false" comment="how many?"/>                                   
                                    <add_player_choice_sub text="'1'" section="choose_ship" choiceparam="1" baseparam="event.param2"/>

                                    <!--
                                    <add_player_choice_sub text="'5'" section="choose_ship" choiceparam="5" baseparam="event.param2"/>
                                    <add_player_choice_sub text="'10'" section="choose_ship" choiceparam="10" baseparam="event.param2"/>
                                    <add_player_choice_sub text="'25'" section="choose_ship" choiceparam="25" baseparam="event.param2"/>
                                    <add_player_choice_sub text="'50'" section="choose_ship" choiceparam="50" baseparam="event.param2"/>
                                    -->

                                    <add_player_choice_sub text="{88888881,1014}" section="bye" choiceparam="event.object" baseparam="event.param2" position="bottom_right" comment="I changed my mind"/>
                                </do_if>

Post Reply

Return to “X4: Foundations - Scripts and Modding”