[QUESTION] Jobs and startactive, set_job_active and request_job_ship

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

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

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

[QUESTION] Jobs and startactive, set_job_active and request_job_ship

Post by user1679 » Mon, 20. Feb 23, 03:19

.
Question: If I use "startactive=false" will the AI slowly build the ships over time even if I don't use set_job_active or request_job_ship?



I've been looking to slightly modify Ship Variation Expansion because I like some of the ships but it just tanks my FPS because there are so many.
The description on the mod page says that fleets spawn and are built by the AI.

First I went into jobs.xml and added "startactive=false" to all the job definitions. I presume this stops the ships from auto spawning
at the gamestart trigger since I didn't see the usual FPS hit on a new game.

Then I edited the activatejobs.xml file and took the approach where I broke the job activation down by faction. First I locate the faction's
shipyards or wharfs galaxy-wide to avoid draining the same facility of wares. Then I check to see if the found ships from each job are
less than the job's quota. If it is, I use request_job_ship to build it. Problem with this approach is I'm still swarmed with ships relatively
early in my game and my FPS drops.

Example:

Code: Select all

                <cue name="SVE_ActivateAllianceJobs" namespace="this" checktime="player.age + [1,2,3,4,5,6,7,8,9,10].random + 120s">
                    <actions>

                        <!-- Station is a Shipyard if it can build at least L ships -->
                        <find_station name="$foundSites" space="player.galaxy" owner="faction.alliance" canbuildclass="class.ship_l" functional="true" multiple="true">	
                            <match canbuildships="true"/>  
                        </find_station>	
                
                        <do_if value="$foundSites? and $foundSites.count gt 0">
                                                   
                            <find_ship name="$foundShips" job="'alliance_free_miner_xl_mineral_hatram_miner'" space="player.galaxy" multiple="true"/>
                            
                            <!-- TODO: instead of hard coding a value 2, can we get job quota as a variable? -->                            
                            <do_if value="$foundShips? and $foundShips.count lt 2">
                                <set_value name="$jobSite" exact="$foundSites.random" />                            
                                <request_job_ship job="'alliance_free_miner_xl_mineral_hatram_miner'" name="this.$Requested_Job_Ship" requester="player.galaxy" zone="$jobSite.zone"/>   
                            </do_if>
                        
                        </do_if>
                        
                        <remove_value name="$foundSites" />
                        <remove_value name="$jobSite" />                        
                        <remove_value name="$foundShips" />
                        
                    </actions>
                </cue>


Finally I noticed the set_job_active option but this seems like it is just a "build it now" command because it results in the same massive
quantities of ships patrolling the various sectors. I don't want to just disable the mod because I like a few of the ships it offers and I like
the additional derelict ships to find. But I do see a 20 fps drop in peformance when the mod is active.

Post Reply

Return to “X4: Foundations - Scripts and Modding”