First attempt at modding... could use some pointers. :)

The place to discuss scripting and game modifications for X Rebirth.

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

User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

First attempt at modding... could use some pointers. :)

Post by Simoom »

Hey guys! So I am not a coder or anything, so I have been shy about trying my hands at creating my own mods. But my recent needs have started me at looking into the md MXL files (to tweak some existing mods to my own liking), and I quickly realized it's something I can figure out.

So for starters I would like to create a fairly simple mod that spawns an NPC patrol group (of a faction of player's choosing). Here's what I have written so far...

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<mdscript name="Spawn_Patrol" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
   <cues>

	  <!--Spawn HOA Arawn with escort fighters-->
	  <cue name="Spawn_Patrol_heartofalbion">
         <conditions>
            <event_cue_signalled/>
         </conditions>
         <actions>

			<!--Adjust number of ships spawned-->
			<set_value name="$Num_HOA_Capship" exact="1"/>
			<set_value name="$Num_HOA_Escort_Leader" exact="2"/>
            <set_value name="$Num_HOA_Escort_Wingman" exact="3"/>
			
			<!--Spawn Capship-->
			<do_all exact="$Num_HOA_Capship">
              <create_ship name="$HOA_Capship" macro="units_size_xl_capital_destroyer_1_macro" zone="$player.zone">
                <owner exact="faction.heartofalbion" overridenpc="true"/>
                <pilot group="argon.commander">
                    <owner exact="faction.heartofalbion"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                </pilot>
				<defence group="argon.defence"/>
                    <owner exact="faction.heartofalbion"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</defence>
				<engineer group="argon.engineer"/>
                    <owner exact="faction.heartofalbion"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</engineer>
                <units>
                  <unit category="unitcategory.welder" mk="1" exact="40"/> <!--Construction URV-->
				  <unit category="unitcategory.transport" mk="1" exact="10"/> <!--Cargolifter URV-->
                  <unit category="unitcategory.defence" mk="4" exact="150"/> <!--Intrepid URV MK2-->
				  <unit category="unitcategory.defence" mk="6" exact="100"/> <!--Overrun URV MK2-->
                </units>
                <position object="player.primaryship" max="5km"/>
              </create_ship>
              <start_script object="$HOA_Capship.pilot" name="'move.patrol'">
              </start_script>
			  
              <!--Spawn Escort Fighters-->
              <do_all exact="$Num_HOA_Escort_Leader">
                <create_ship name="$HOA_Leader" group="hoa_heavy_fighter" zone="$player.zone">
				  <owner exact="faction.heartofalbion" overridenpc="true"/>
				  <pilot group="argon.pilot">
                    <owner exact="faction.heartofalbion"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                  </pilot>
                  <position object="$HOA_Capship" max="5km"/>
                </create_ship>
                <set_object_commander object="$HOA_Leader" commander="$HOA_Capship" />
                <start_script object="$HOA_Leader.pilot" name="'move.escort'">
                  <param name="target" value="$HOA_Capship"/>
                </start_script>
                <do_all exact="$Num_HOA_Escort_Wingman">
                  <create_ship name="$HOA_Follower" group="hoa_heavy_fighter" zone="$player.zone">
                    <owner exact="faction.heartofalbion" overridenpc="true"/>
                    <pilot group="argon.pilot">
                      <owner exact="faction.heartofalbion"/>
                      <skills>
                        <skill type="boarding" value="5"/>
                        <skill type="combat" value="5"/>
                        <skill type="engineering" value="5"/>
                        <skill type="leadership" value="5"/>
                        <skill type="management" value="5"/>
                        <skill type="morale" value="5"/>
                        <skill type="navigation" value="5"/>
                        <skill type="science" value="5"/>
                      </skills>
                    </pilot>
                    <position object="$HOA_Leader" max="2km"/>
                  </create_ship>
                  <set_object_commander object="$HOA_Follower" commander="$HOA_Leader" />
                  <start_script object="$HOA_Follower.pilot" name="'move.escort'">
                    <param name="target" value="$HOA_Leader" />
                  </start_script>
                </do_all>
              </do_all>
            </do_all>
         </actions>
      </cue>

	  <!--Spawn PMC Taranis with escort fighters-->
	  <cue name="Spawn_Patrol_plutarch">
         <conditions>
            <event_cue_signalled/>
         </conditions>
         <actions>

			<!--Adjust number of ships spawned-->
			<set_value name="$Num_PMC_Capship" exact="1"/>
			<set_value name="$Num_PMC_Escort_Leader" exact="2"/>
            <set_value name="$Num_PMC_Escort_Wingman" exact="3"/>

			<!--Spawn Capship-->
			<do_all exact="$Num_PMC_Capship">
              <create_ship name="$PMC_Capship" macro="units_size_xl_capital_destroyer_2_macro" zone="$player.zone">
                <owner exact="faction.plutarch" overridenpc="true"/>
                <pilot group="argon.commander">
                    <owner exact="faction.plutarch"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                </pilot>
				<defence group="argon.defence"/>
                    <owner exact="faction.plutarch"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</defence>
				<engineer group="argon.engineer"/>
                    <owner exact="faction.plutarch"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</engineer>
                <units>
                  <unit category="unitcategory.welder" mk="1" exact="40"/> <!--Construction URV-->
				  <unit category="unitcategory.transport" mk="1" exact="10"/> <!--Cargolifter URV-->
                  <unit category="unitcategory.defence" mk="4" exact="50"/> <!--Intrepid URV MK2-->
				  <unit category="unitcategory.defence" mk="6" exact="50"/> <!--Overrun URV MK2-->
                </units>
                <position object="player.primaryship" max="5km"/>
              </create_ship>
              <start_script object="$PMC_Capship.pilot" name="'move.patrol'">
              </start_script>

			  <!--Spawn Escort Fighters-->
              <do_all exact="$Num_PMC_Escort_Leader">
                <create_ship name="$PMC_Leader" group="pmc_heavy_fighter" zone="$player.zone">
				  <owner exact="faction.plutarch" overridenpc="true"/>
				  <pilot group="argon.pilot">
                    <owner exact="faction.plutarch"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                  </pilot>
                  <position object="$PMC_Capship" max="5km"/>
                </create_ship>
                <set_object_commander object="$PMC_Leader" commander="$PMC_Capship" />
                <start_script object="$PMC_Leader.pilot" name="'move.escort'">
                  <param name="target" value="$PMC_Capship"/>
                </start_script>
                <do_all exact="$Num_PMC_Escort_Wingman">
                  <create_ship name="$PMC_Follower" group="pmc_heavy_fighter" zone="$player.zone">
                    <owner exact="faction.plutarch" overridenpc="true"/>
                    <pilot group="argon.pilot">
                      <owner exact="faction.plutarch"/>
                      <skills>
                        <skill type="boarding" value="5"/>
                        <skill type="combat" value="5"/>
                        <skill type="engineering" value="5"/>
                        <skill type="leadership" value="5"/>
                        <skill type="management" value="5"/>
                        <skill type="morale" value="5"/>
                        <skill type="navigation" value="5"/>
                        <skill type="science" value="5"/>
                      </skills>
                    </pilot>
                    <position object="$PMC_Leader" max="2km"/>
                  </create_ship>
                  <set_object_commander object="$PMC_Follower" commander="$PMC_Leader" />
                  <start_script object="$PMC_Follower.pilot" name="'move.escort'">
                    <param name="target" value="$PMC_Leader" />
                  </start_script>
                </do_all>
              </do_all>
            </do_all>
         </actions>
      </cue>
	  
	  <!--Spawn Canteran Sucellus with escort fighters-->
	  <cue name="Spawn_Patrol_canteran">
         <conditions>
            <event_cue_signalled/>
         </conditions>
         <actions>

			<!--Adjust number of ships spawned-->
			<set_value name="$Num_ROC_Capship" exact="1"/>
			<set_value name="$Num_ROC_Escort_Leader" exact="2"/>
            <set_value name="$Num_ROC_Escort_Wingman" exact="3"/>

			<!--Spawn Capship-->
			<do_all exact="$Num_ROC_Capship">
              <create_ship name="$ROC_Capship" macro="units_size_xl_red_destroyer_macro" zone="$player.zone">
                <owner exact="faction.canteran" overridenpc="true"/>
                <pilot group="argon.commander">
                    <owner exact="faction.canteran"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                </pilot>
				<defence group="argon.defence"/>
                    <owner exact="faction.canteran"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</defence>
				<engineer group="argon.engineer"/>
                    <owner exact="faction.canteran"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
				</engineer>
				<units>
                  <unit category="unitcategory.welder" mk="1" exact="40"/> <!--Construction URV-->
				  <unit category="unitcategory.transport" mk="1" exact="10"/> <!--Cargolifter URV-->
                  <unit category="unitcategory.defence" mk="4" exact="50"/> <!--Intrepid URV MK2-->
				  <unit category="unitcategory.defence" mk="6" exact="50"/> <!--Overrun URV MK2-->
                </units>
                <position object="player.primaryship" max="5km"/>
              </create_ship>
              <start_script object="$ROC_Capship.pilot" name="'move.patrol'">
              </start_script>

			  <!--Spawn Escort Fighters-->
              <do_all exact="$Num_ROC_Escort_Leader">
                <create_ship name="$ROC_Leader" group="can_heavy_fighter" zone="$player.zone">
				  <owner exact="faction.canteran" overridenpc="true"/>
				  <pilot group="argon.pilot">
                    <owner exact="faction.canteran"/>
                    <skills>
                      <skill type="boarding" value="5"/>
                      <skill type="combat" value="5"/>
                      <skill type="engineering" value="5"/>
                      <skill type="leadership" value="5"/>
                      <skill type="management" value="5"/>
                      <skill type="morale" value="5"/>
                      <skill type="navigation" value="5"/>
                      <skill type="science" value="5"/>
                    </skills>
                  </pilot>
                  <position object="$ROC_Capship" max="5km"/>
                </create_ship>
                <set_object_commander object="$ROC_Leader" commander="$ROC_Capship" />
                <start_script object="$ROC_Leader.pilot" name="'move.escort'">
                  <param name="target" value="$ROC_Capship"/>
                </start_script>
                <do_all exact="$Num_ROC_Escort_Wingman">
                  <create_ship name="$ROC_Follower" group="can_heavy_fighter" zone="$player.zone">
                    <owner exact="faction.canteran" overridenpc="true"/>
                    <pilot group="argon.pilot">
                      <owner exact="faction.canteran"/>
                      <skills>
                        <skill type="boarding" value="5"/>
                        <skill type="combat" value="5"/>
                        <skill type="engineering" value="5"/>
                        <skill type="leadership" value="5"/>
                        <skill type="management" value="5"/>
                        <skill type="morale" value="5"/>
                        <skill type="navigation" value="5"/>
                        <skill type="science" value="5"/>
                      </skills>
                    </pilot>
                    <position object="$ROC_Leader" max="2km"/>
                  </create_ship>
                  <set_object_commander object="$ROC_Follower" commander="$ROC_Leader" />
                  <start_script object="$ROC_Follower.pilot" name="'move.escort'">
                    <param name="target" value="$ROC_Leader" />
                  </start_script>
                </do_all>
              </do_all>
            </do_all>
         </actions>
      </cue>
	  
	  
   </cues>
</mdscript>
So, I have a few questions:
  • Are the codes I have for spawning capship crews correct? I based my original code on a MD file from the game called "test_BigBattle". However, I wanted the spawned ship crew to have all 5-star skills. The "test_BigBattle" script also did not spawn Engineer or Defence Officer for the capships (how exactly is that handled? I don't imagine for that test the script spawns capships with only a Captain, that would be useless).

    So I compared the codes with ones from the XR Cheat Menu, and the author for that used a different method of crew spawning ("create_platform_actor"), which seems more lengthy and complicated...
  • Is there a way to automatically configure the spawned ship captain to Auto-Refuel and Auto-Resupply (defense drones and ammunition)? Ideally what I want this mod to do is for the player to be able to spawn NPC patrols that will not only keep sectors safe, but also help create economy sinks (by purchasing end products like drones and missiles).
  • If I want the spawned ship to have a full stock of fuel cells, would this be the correct code to do so?

    Code: Select all

    				<cargo>
    				  <wares list="[fuelcells]">
    				  <fillpercent exact="100"/>
    				  </wares>
    				</cargo>
Thanks in advance for anyone who can help me with my noob questions... :D Man, I do not look forward to figuring out how to create custom menus...
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Re: First attempt at modding... could use some pointers. :)

Post by w.evans »

finally! was wondering how long it would take before you take a dip.
Simoom wrote:automatically configure the spawned ship captain to Auto-Refuel
if i were working from an aiscript of that captain, i'd set it:

Code: Select all

<set_value name="this.$config_autorefuel"/>
doing it via md, writing something like:

Code: Select all

<set_value name="$HOA_Capship.pilot.$config_autorefuel"/>
any place after you create the ship should do it.

$config_attackenemies is the DO attack/defend setting

$config_unitstorage_automatic
$config_ammostorage_automatic

would set the old DO flags for drone and ammo resupply, respectively. don't think they ever did anything though. were taken out in 4.0.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

1. you set the Skill not with value="5" but with exact="5"

2. you closed the defence npc node too early:
<defence group="argon.defence"/>
(same for engineer)

apart from this the file is valid and the Game should accept it. now you only have to send the Signal to trigger these cues somehow.

hint: put the libraries/md.xsd and common.xsd into your mods md folder - this should enable xsd validation and in some xml editors even autocompletion ;) (i use xmlcopyedit for this)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

Hey there w.evans and UniTrader! Thanks so much for helping me with this! I have a fairly ambitious project in mind for my first mod (the NPC patrol thing is just a part of it)... but I don't want to announce it until I have it all figured out, heheh! :D

Okay, a couple more questions if that's alright:
  1. UniTrader wrote:apart from this the file is valid and the Game should accept it. now you only have to send the Signal to trigger these cues somehow.
    I am writing a MainMenu.xml file for this exact purpose... I think I have the format of the menu system figured out. However, I am a bit at a loss about how the game incorporates additional menus from mods.
    For alexalsp's Cheat Menu mod, he has a ui folder in addition to a MainMenu.xml MD script. Inside the ui folder is a "ego_mainmenu.xml" file with the codes:

    Code: Select all

    <?xml version="1.0" encoding="utf-8"?>
    <diff>
      <add sel="/addon[@name='ego_mainmenu']/dependency" pos="before">
        <file name="mainmenu_alexalsp_CHEATMENU_1.lua" />
      </add>
    </diff>
    
    And a separate folder with a .lua file. I am not sure what all of this does? Is there a tutorial on how to incorporate a mod into the menu system?
  2. UniTrader wrote:hint: put the libraries/md.xsd and common.xsd into your mods md folder - this should enable xsd validation and in some xml editors even autocompletion ;) (i use xmlcopyedit for this)
    I was reading about that in the Egosoft MD Guide, but it was a bit overwhelming to me (all the terminologies are foreign.... xD "xml schemas" wuuuuut?)
    I am using Notepad++, looks like it does have xsd support through a plugin... I have no idea what this does but I'll tinker with it. xD
  3. So I have been looking through the MD scripts for alexalsp's Cheat Menu mod. He uses the following codes (from setup_ships_cheat_menu.xml) to add a capital ship with crew and cargo:

    Code: Select all

      	<cue name="alexalsp_cheats_Ship_0001" instantiate="true" namespace="this">
    	  <conditions>
    		<event_cue_signalled/>
          </conditions>
    	  <actions>
    		<create_ship name="$Ship" macro="units_size_xl_hunter_ship_01_macro" zone="player.zone">
             <safepos object="player.primaryship" max="2km" radius="3km"/>  
    		<owner exact="faction.player" overridenpc="true"/>
               <pilot actor="null"/>
                <defence actor="null"/>
                <engineer actor="null"/>
                 <units>
                  <unit category="unitcategory.welder" mk="1" exact="40"/><!--Строитель -->
                  <unit category="unitcategory.defence" mk="4" exact="100"/><!--Бла неустрашимый МК2-->
                </units>
    <!--                    <drop ref="ship_large_civilian"/>-->
            </create_ship>
    		<add_cargo object="$Ship" ware="ware.fuelcells" exact="2500"/><!--Топлево -->
    		<find_dock_location name="$Dock" container="$Ship" size="tag.dock_p"/>
            <create_platform_actor name="$Commander" type="entitytype.commander" dockingbay="$Dock.component" ref="trader_omicron_lyrae_random">
              <owner exact="faction.player"/>
    		  <skills>
                       <skill type="boarding" min="4" max="5" />
                       <skill type="combat" min="5" max="5" />
                       <skill type="engineering" min="4" max="5" />
                       <skill type="leadership" min="5" max="5" />
                       <skill type="management" min="4" max="4" />
                       <skill type="morale" min="5" max="5" />
                       <skill type="navigation" min="5" max="5" />
                       <skill type="science" min="5" max="5" />
                       </skills>
            </create_platform_actor>
            <create_platform_actor name="$DefenceNPC" type="entitytype.defencecontrol" dockingbay="$Dock.component" ref="fighter_omicron_lyrae_random">
              <owner exact="faction.player"/>
    		  <skills>
                       <skill type="boarding" min="4" max="5" />
                       <skill type="combat" min="5" max="5" />
                       <skill type="engineering" min="4" max="5" />
                       <skill type="leadership" min="5" max="5" />
                       <skill type="management" min="4" max="4" />
                       <skill type="morale" min="5" max="5" />
                       <skill type="navigation" min="4" max="5" />
                       <skill type="science" min="5" max="5" />
                       </skills>
            </create_platform_actor>
            <create_platform_actor name="$Engineer" type="entitytype.engineer" dockingbay="$Dock.component" ref="engineer_omicron_lyrae_random">
              <owner exact="faction.player"/>
    		  <skills>
                      <skill type="boarding" min="4" max="5" />
                       <skill type="combat" min="4" max="5" />
                       <skill type="engineering" min="5" max="5" />
                       <skill type="leadership" min="4" max="4" />
                       <skill type="management" min="4" max="4" />
                       <skill type="morale" min="5" max="5" />
                       <skill type="navigation" min="4" max="5" />
                       <skill type="science" min="5" max="5" />
              </skills>
            </create_platform_actor>
    			
            <assign_pilot actor="$Commander" object="$Ship"/>
            <assign_defence_manager actor="$DefenceNPC" object="$Ship"/>
            <assign_engineer actor="$Engineer" object="$Ship"/>
            
    <!--        <set_object_commander object="$Ship" commander="player.primaryship"/>-->
            <start_script object="$Commander" name="'player.default'"/>
            <start_script object="$DefenceNPC" name="'fight.defend.capital'"/>
            <start_script object="$Engineer" name="'engineer.ai'"/>
    
           <remove_value name="$Ship" />
           <remove_value name="$defencenpc"/>
           <remove_value name="$engineer"/>
           <remove_value name="$Commander"/>
    
           <reset_cue cue="this" />
    		</actions>
        </cue>
    Several questions regarding his methods:
    • He uses instantiated cues for each of his ship spawning scripts, instantiate="true". Is there an advantage in doing it this way? I notice that he also does a "clean up" script at the end of each cue. Is this necessary?

      Code: Select all

             <remove_value name="$Ship" />
             <remove_value name="$defencenpc"/>
             <remove_value name="$engineer"/>
             <remove_value name="$Commander"/>
      
             <reset_cue cue="this" />
    • For adding cargo, he used:

      Code: Select all

      <add_cargo object="$Ship" ware="ware.fuelcells" exact="2500"/>
      For my script I used instead:

      Code: Select all

      				<cargo>
      				  <wares list="[fuelcells]">
      				  <fillpercent exact="100"/>
      				  </wares>
      				</cargo>
      Does this create any sort of tangible difference? (His method spawns the ship then adds the cargo, mine just spawns the ship with the cargo already on board... am I correct in assuming so?)
    • For crew spawning, he used:

      Code: Select all

      <find_dock_location name="$Dock" container="$Ship" size="tag.dock_p"/>
              <create_platform_actor name="$Commander"[...]
      So similar to cargo, he's adding crew after the ship spawns, instead of spawning the ship with crew already on board. Is there an advantage to this method? I have noticed that the game sometimes spawn capital ships with crew that's in a "temporary" dock connection... as in if you dock on the capital ship, you won't actually find any crew on board, despite them showing under the ship's details. Is this a side effect of spawning the crew directly with the ship?
Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp »

I don't know if it will help with the specifics of this question but there is a lot of modding info on, of linked from, the wiki:

https://www.egosoft.com:8444/confluence ... ng+support
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

Thanks Sparky, I'll take a look... :)
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

sorry but cannt really help you with the UI stuff - the best i can manage there is changing existent Menus to fit my needs...
He uses instantiated cues for each of his ship spawning scripts, instantiate="true". Is there an advantage in doing it this way? I notice that he also does a "clean up" script at the end of each cue. Is this necessary?
Instantiated cues can be activated multiple times without needing to reset them. (so basically every time the conditions are met the actions are performed and each triggered instance creates its own set of sub-cues after this)
non-instantiated cues can only be executed one time (the first time conditions are met) but wont trigger after this (because they are complete) - but you can reset them so they trigger once more ;)

the cleanup depends on wheter a namespace="this" was specified or not - if it was specified its not necesary because the vars all disappear with the completed cue instance, if it was not specified the namespace of the parent cue is used which is also used by other cues, so a cleanup might be needed.

related to spawning: i think creating the Crew with the Ship doesnt trigger <event_platform_actor_created /> which is used to set up Dialogue Trees and starts default scripts on the Actor - this may have been fixed though..

Adding Cargo:
both methods work, result is the same. there are many ways to rome ;)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

UniTrader wrote:sorry but cannt really help you with the UI stuff - the best i can manage there is changing existent Menus to fit my needs...
No worries UniTrader! I am reading the tutorial for Sidebar Extender, I think I'll use that to hook my mod into the Sidebar (I already figured out how to integrate it into the legacy menu system, I may just create a shortcut on the Sidebar to trigger that until I learn how to do fancier stuffs).
UniTrader wrote:Instantiated cues can be activated multiple times without needing to reset them. (so basically every time the conditions are met the actions are performed and each triggered instance creates its own set of sub-cues after this)
non-instantiated cues can only be executed one time (the first time conditions are met) but wont trigger after this (because they are complete) - but you can reset them so they trigger once more ;)
Okay, so in the case of the NPC patrol scripts I wrote... does that mean if I spawned them once, I can't spawn them again even if I issue the menu command again? Should I switch to instantiated cues if I want to be able to spawn them multiple times?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

Simoom wrote:
UniTrader wrote:Instantiated cues can be activated multiple times without needing to reset them. (so basically every time the conditions are met the actions are performed and each triggered instance creates its own set of sub-cues after this)
non-instantiated cues can only be executed one time (the first time conditions are met) but wont trigger after this (because they are complete) - but you can reset them so they trigger once more ;)
Okay, so in the case of the NPC patrol scripts I wrote... does that mean if I spawned them once, I can't spawn them again even if I issue the menu command again? Should I switch to instantiated cues if I want to be able to spawn them multiple times?
yes they can only performed once and yes, instances might be better if you want to use them multiple times ;)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

UniTrader wrote:yes they can only performed once and yes, instances might be better if you want to use them multiple times ;)
Okay, thanks! :)

I think I read somewhere in the MD Guide that instantiated cues take up more memory though (since the parent cue basically stays in waiting mode). Is the reset_cue route more performance-friendly?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

shouldnt make any difference in this case - instatiated cues basically work like this:
the create a base cue which is always in waiting state, and every time the conditions are met the cue creates a copy of itself which is executed (meaning the base cue never changes) - and the instances are removed once completely done or canceled. since you dont have any sub-cues there is no difference between performance of both methods.. (instance method may require a few bytes more memory, but that only while its active, so only for one frame.. really nothing to worry about)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

UniTrader wrote:instatiated cues
and clean up's a lot easier since any variables stored in that cue are deleted along with the instance.

find that going with non-instantiated cues and resetting/cancelling/completing is more useful when you want additional control over when a particular cue runs. You could, for example, write a cue with no conditions, so that runs once then completes. You could then reset that cue from a different cue given certain conditions and further filtering with a do_if/do_elseif block.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

w.evans wrote:
UniTrader wrote:instatiated cues
and clean up's a lot easier since any variables stored in that cue are deleted along with the instance.
Only if you combine it with namespace="this" ;) otherwise the namespace of the parent cue or even root is used and the vars persist after this, although unused


(Note to self: check my dialogue trees for occurences of this and add cleanup)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

Hey guys, quick question if that's alright... :)

I was looking at the ware spawning scripts from the Cheat Menu, and am a bit confused about when to use the expression "amount", and when to use "exact".

For example, for spawning missiles onto the Skunk, the script goes:

Code: Select all

<add_ammo object="player.primaryship" macro="macro.missile_player_torpedo_02_macro" amount="100"/>
But for adding marines, the script is:

Code: Select all

<add_units object="player.primaryship" category="unitcategory.marine" exact="50" mk="3"/>
I am confused because I was under the impression that "exact" dictates a percentage. For example the following code installs up to 100% of the selected shield type the Skunk can hold (which is two).

Code: Select all

<upgrade_object_by_macro object="player.primaryship" macro="macro.engine_player_bal_mk5_macro" exact="100"/>
However, the Marine spawning script does create the specified number of marines (50), in my test. Is there a reason "exact" is used instead of "amount"?

I am trying to write a script that would add a specified drone type to the Skunk. Should it be this:

Code: Select all

<add_units object="player.primaryship" macro="macro.unit_player_scanner_drone_mk3_macro" exact="1"/>
or

Code: Select all

<add_units object="player.primaryship" macro="macro.unit_player_scanner_drone_mk3_macro" amount="1"/>
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

it depends on what is defined as valid in the xsd files ;) add ammo has the following possible attributes:
<add_ammo amount chance comment macro object weight />
and add units has these:
<add_units category chance comment exact faction list macro max min mk object tags unavailable weight />

i agree that add_ammo is the odd one here, since all other commands accepting numerical values would use random (range) which is either min + max or exact (exact can also be used in eg set_value to set the var to a non-numerical datatype)
how this numerical value is interpreted depends on the individual command. no idea why EGO used percentages in the upgrade commands instead of the total amount - maybe to easily prevent over-equipment attempts?
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

UniTrader wrote:it depends on what is defined as valid in the xsd files ;) add ammo has the following possible attributes:
<add_ammo amount chance comment macro object weight />
and add units has these:
<add_units category chance comment exact faction list macro max min mk object tags unavailable weight />
Ahhh, thank you so much! That explains a lot. :D
UniTrader wrote:no idea why EGO used percentages in the upgrade commands instead of the total amount - maybe to easily prevent over-equipment attempts?
Hmm, speaking of this, a follow-up technical question...
If I were using the upgrade command to add equipment to the Skunk, would I need to do a "cleanup" script beforehand to prevent duplicates?

Example:

Code: Select all

		  <upgrade_object_by_macro object="player.primaryship" macro="macro.software_target_computer_mk1_macro" exact="0"/>
		  <upgrade_object_by_macro object="player.primaryship" macro="macro.software_target_computer_mk2_macro" exact="0"/>
		  <upgrade_object_by_macro object="player.primaryship" macro="macro.software_target_computer_mk1_macro" exact="100"/>
Say the above code is tied into a button on a cheat menu... if the player presses that button twice, would the Skunk end up with two copies of Target Computer Mk1 if I didn't have that first line to "remove" any pre-existing Mk1?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

dont think so, you would end up with all slots filed as planned. the problem is only when a slot can be filled with multiple difftent upgrades - you have to remove the old one before installing a diffrent one or you end up with both..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

Thanks so much UniTrader. :D

Okay, hmmm a related question back to the mod at hand... if I wanted the XL ship jump-in animation to play before the ship is created, how should I do so?

I was digging around the campaign MD files for clues, but it looks like the authors for those files chose an alternate method (they spawn the ships somewhere else, then jump them in... which is fine I guess, but wouldn't the other way be simpler?)
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

you would have to do at least 2 <add_effect/> for proper animation, and this would circumvent cooldown so the ship could jump awa immediately if it wanted to... doing a real jump is better because it takes care of this - and would take possibly modded effects into account
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
Simoom
Posts: 1110
Joined: Sat, 30. Oct 10, 14:14
x4

Post by Simoom »

Okay, thanks again. :) I'll dig into this...

Return to “X Rebirth - Scripts and Modding”