Help with using create_ship with equipmentmods

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

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

hackthatmcu
Posts: 2
Joined: Fri, 2. Sep 22, 04:39

Help with using create_ship with equipmentmods

Post by hackthatmcu »

Hi, I'm new to modding and trying to modify the Cheat Menu extension so that the script for creating ships will also create the ships with equipment mods. I found that it uses create_ship, and looking at common.xsd, it seems that it can be used with equipmentmods so that it also creates the ship with mods. However, I'm having trouble understanding how to use it and getting it to work. Below is the create_ship code from the extension, unchanged with the exception of the equipmentmods node I added to try adding mod_engine_forwardthrust_02_mk1 to the ships it creates:

Code: Select all

		    <create_ship name="$ship" macro="md.$iseeu0create_ship_macro" zone="$ship_zone">
                        <owner exact="global.$iseeu0create_ship_set.{1}" overridenpc="true"/>
                        <show_notification text="global.$iseeu0create_ship_set.{1}.name + {1025,51} +md.$iseeu0create_ship_macro.name + '(' + 1 + ')'"/>
                        <loadout>
                            <level min="1" max="3"/>
                        </loadout>
                        <pilot>
                            <select race="[race.argon, race.paranid, race.teladi, race.xenon]" tags="tag.aipilot"/>
                        </pilot>
                        <people>
                            <fillpercent exact="$fillpercent"/>
                            <person role="service" weight="100">
                                <select race="[race.argon, race.paranid, race.teladi, race.xenon]" tags="tag.service"/>
                            </person>
                        </people>
                        <safepos object="$ship_object" value="$ship_position"/>
                        <equipmentmods>
                            <engine ware="mod_engine_forwardthrust_02_mk1"/>
                        </equipmentmods>
                    </create_ship>
I decided to try something simple like adding an engine mod since all ships can use them. It seems like modifications for shields and weapons will be more complicated since each ship has a different number of turrets/weapons.

I've looked around for any mods I could look at as a basis and learn from, but all the mods for ship modifications I've found are only for adding new ones to the game. Would appreciate any help from experienced modders out there, thanks in advance!
kuertee
EGOSOFT
EGOSOFT
Posts: 818
Joined: Sun, 14. Dec 03, 13:05
x4

Re: Help with using create_ship with equipmentmods

Post by kuertee »

DeadAir's Xenon Evolution adds equipment mods to newly built ships.
He hasn't released it "officially" on his forum thread.
But he's released it on the modding channel on Discord a couple of months ago: https://github.com/DeadAirRT/deadairevolution
hackthatmcu
Posts: 2
Joined: Fri, 2. Sep 22, 04:39

Re: Help with using create_ship with equipmentmods

Post by hackthatmcu »

kuertee wrote: Tue, 6. Sep 22, 09:33 DeadAir's Xenon Evolution adds equipment mods to newly built ships.
He hasn't released it "officially" on his forum thread.
But he's released it on the modding channel on Discord a couple of months ago: https://github.com/DeadAirRT/deadairevolution
Many many thanks @kuertee (and to DeadAir'!) - this is exactly what I needed! :) Turns out ''mod_engine_forwardthrust_02_mk1" just needed to be "ware.mod_engine_forwardthrust_02_mk1". DeadAir's code also showed me how to add the mods for turrets/weapon groups. I'll just leave what I ended up with here and hopefully it may help someone such as myself who was stuck with this:

(The wares I'm using here are from Scuffle's OP Ship Mods)

Code: Select all

<create_ship name="$ship" macro="md.$iseeu0create_ship_macro" zone="$ship_zone">
    <owner exact="global.$iseeu0create_ship_set.{1}" overridenpc="true"/>
    <show_notification text="global.$iseeu0create_ship_set.{1}.name + {1025,51} +md.$iseeu0create_ship_macro.name + '(' + 1 + ')'"/>
    <loadout>
        <level min="1" max="3"/>
    </loadout>
    <pilot>
        <select race="[race.argon, race.paranid, race.teladi, race.xenon]" tags="tag.aipilot"/>
    </pilot>
    <people>
        <fillpercent exact="$fillpercent"/>
        <person role="service" weight="100">
            <select race="[race.argon, race.paranid, race.teladi, race.xenon]" tags="tag.service"/>
        </person>
    </people>
    <equipmentmods>
        <engine ware="ware.mod_engine_scufflekerfuffle"/>
        <ship ware="ware.mod_ship_scufflekerfuffle"/>
        <shield ware="ware.mod_shield_scufflekerfuffle"/>
    </equipmentmods>
    <safepos object="$ship_object" value="$ship_position"/>
</create_ship>

<!-- Add mods to ship weapons -->
<set_value name="$WeaponGroupTags" exact="[]"/>
<do_for_each in="$ship.weapons.all.list" name="$Weapon">
    <do_if value="$Weapon.grouptag != null">
        <do_if value="$WeaponGroupTags.indexof.{$Weapon.grouptag} == 0">
            <add_equipment_mods object="$ship">
                <weapon ware="ware.mod_weapon_scufflekerfuffle_damage" context="'..'" group="$Weapon.grouptag"/>
                <shield ware="ware.mod_shield_scufflekerfuffle" context="'..'" group="$Weapon.grouptag"/>
            </add_equipment_mods>
        </do_if>
    </do_if>
    <do_else>
        <add_equipment_mods object="$ship">
            <weapon ware="ware.mod_weapon_scufflekerfuffle_damage" macro="$Weapon.macro"/>
        </add_equipment_mods>
    </do_else>
</do_for_each>

<remove_value name="$Weapon"/>
<remove_value name="$WeaponGroupTags"/>

Return to “X4: Foundations - Scripts and Modding”