Building new jobs instead of just spawning?

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

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

Dr Reed
Posts: 79
Joined: Fri, 30. Nov 18, 00:05
x4

Building new jobs instead of just spawning?

Post by Dr Reed »

Is there a way of making the first wave of a new job be built from a wharf/shipyard ?

I have tried adding the Startactive="false" flag in the job file and then starting the job with Set_job_active job="'mynewjob'" activate="true" in an md file. But alas, the first wave of the job just spawns in as it would normally.

So can you force buildatshipyard="true" for the first wave of a new job ?
User avatar
Shuulo
Posts: 1633
Joined: Mon, 14. Apr 08, 17:03
x4

Re: Building new jobs instead of just spawning?

Post by Shuulo »

Dr Reed wrote: Fri, 4. Feb 22, 20:05 Is there a way of making the first wave of a new job be built from a wharf/shipyard ?

I have tried adding the Startactive="false" flag in the job file and then starting the job with Set_job_active job="'mynewjob'" activate="true" in an md file. But alas, the first wave of the job just spawns in as it would normally.

So can you force buildatshipyard="true" for the first wave of a new job ?
you can try to set quota=0 and maxgalaxy quoat= soemthing else
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Re: Building new jobs instead of just spawning?

Post by BlackRain »

Dr Reed wrote: Fri, 4. Feb 22, 20:05 Is there a way of making the first wave of a new job be built from a wharf/shipyard ?

I have tried adding the Startactive="false" flag in the job file and then starting the job with Set_job_active job="'mynewjob'" activate="true" in an md file. But alas, the first wave of the job just spawns in as it would normally.

So can you force buildatshipyard="true" for the first wave of a new job ?
You must have done something wrong, probably you started the game with the md file with Set_job_active job="'mynewjob'" activate="true".

What you can do is, just remove the MD script you made and start a new game with all of the jobs with startactive="false". Then save your game, and then exit the game and add in the md script which activates all the jobs. Then it should start building them.
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Building new jobs instead of just spawning?

Post by DeadAirRT »

one solution could be to make the md only fire after the game has been started/loaded twice

I never really messed with activating jobs though
Dr Reed
Posts: 79
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Building new jobs instead of just spawning?

Post by Dr Reed »

Thanks for that guys.
I was making a faction that started with just a trading station, a wharf and a few jobs. Then over time once the Shipyard is built the faction would start building it's capship jobs and thus slowly building up it's power instead of being a threat to other factions from game start.

Shuulo wrote: Fri, 4. Feb 22, 20:50 you can try to set quota=0 and maxgalaxy quoat= soemthing else
I'll try that with another faction for it's carrier group since it should spawn only one at a time.

BlackRain wrote: Fri, 4. Feb 22, 22:34 You must have done something wrong, probably you started the game with the md file with Set_job_active job="'mynewjob'" activate="true".

What you can do is, just remove the MD script you made and start a new game with all of the jobs with startactive="false". Then save your game, and then exit the game and add in the md script which activates all the jobs. Then it should start building them.
The md file is part of a mod set up script and i was hoping that the activate="true" would result in the buildatshipyard thing happening.

DeadAirRT wrote: Sat, 5. Feb 22, 14:55 one solution could be to make the md only fire after the game has been started/loaded twice

I have no idea how to do that at the moment but i'll try. :)
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Building new jobs instead of just spawning?

Post by DeadAirRT »

Not sure if what I said would actually work, but basically make a cue that has condition of game started/loaded, sets a variable; then a second cue that has game started/loaded condition and checks the value.

Can be done with game time or something else as well
Dr Reed
Posts: 79
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Building new jobs instead of just spawning?

Post by Dr Reed »

I set up a script seperate from my mod initialisation script to make sure the game is loaded and running before starting the new jobs.
Here is a basic version of it

Code: Select all

    <cues>
    <cue name="StartJobs" checkinterval="1s" >
      <conditions>
        <check_value value="player.entity.exists"/>
      </conditions>
        <delay exact="10s"/>
        <actions>
        <write_incoming_message title="{1121075,121001}" text="{1121075,121002}" source="{20203,801}" highpriority="true" comment="send msg to notify job starts"/>
        <do_if value="player.galaxy.macro == macro.xu_ep2_universe_macro">
          <do_if value="faction.nhparanid.isactive">
            <set_job_active job="'nhparanid_dronecarrier_patrol_m_sector'" />
          </do_if>
        </do_if>
        </actions>
     </cue>
  </cues>
And the jobs still magically appear in space instead of being built from the shipyard. :gruebel:

So, i dug around some more and found some jobs being called by game time in the Split dlc. Yay here might be a way of making a job be built from a wharf instead of spawning.

Code: Select all

 
  <job id="nhparanid_dronecarrier_patrol_m_sector" name="{20204,5001}" startactive="false">
    <modifiers commandeerable="true"/>
    <orders>
      <order order="Patrol" default="true">
        <param name="range" value="class.sector"/>
      </order>
    </orders>
    <category faction="nhparanid" tags="[factionlogic, military, frigate]" size="ship_m"/>
	<quota galaxy="12" maxgalaxy="20" sector="4"/>
	<time start="1800"  interval="60"/>
    <location class="galaxy" macro="xu_ep2_universe_macro" faction="nhparanid" relation="self" comparison="exact"/>
    <environment buildatshipyard="true"/>
    <ship>
      <select faction="nhparanid" tags="[military, frigate]" size="ship_m"/>
      <loadout>
        <level min="0.4" max="1.0"/>
      </loadout>
      <units>
        <unit category="unitcategory.defence" min="5" max="8"/>
      </units>
      <owner exact="nhparanid" overridenpc="true"/>
    </ship>
  </job>
The <time start="1800" interval="60"/> starts the first instance of the job at 30 minutes from the first job call and starts a new one every minute untill the quota is met.

I set it to 30 minutes so that i could get to a suitable location and drop adv sats to observe the area and watch what was hepppening.

So, at the end of the day i set the following conditions,
1: Required jobs are set to Startactive "false" in the jobs file
2: Jobs are then set to active 10 seconds after the player spawns
3: the first job call is then triggered 30 minutes later and appears in the game.

And they still just spawn in instead of being built. :cry:
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Re: Building new jobs instead of just spawning?

Post by BlackRain »

Dr Reed wrote: Sat, 12. Feb 22, 18:20 I set up a script seperate from my mod initialisation script to make sure the game is loaded and running before starting the new jobs.
Here is a basic version of it

Code: Select all

    <cues>
    <cue name="StartJobs" checkinterval="1s" >
      <conditions>
        <check_value value="player.entity.exists"/>
      </conditions>
        <delay exact="10s"/>
        <actions>
        <write_incoming_message title="{1121075,121001}" text="{1121075,121002}" source="{20203,801}" highpriority="true" comment="send msg to notify job starts"/>
        <do_if value="player.galaxy.macro == macro.xu_ep2_universe_macro">
          <do_if value="faction.nhparanid.isactive">
            <set_job_active job="'nhparanid_dronecarrier_patrol_m_sector'" />
          </do_if>
        </do_if>
        </actions>
     </cue>
  </cues>
And the jobs still magically appear in space instead of being built from the shipyard. :gruebel:

So, i dug around some more and found some jobs being called by game time in the Split dlc. Yay here might be a way of making a job be built from a wharf instead of spawning.

Code: Select all

 
  <job id="nhparanid_dronecarrier_patrol_m_sector" name="{20204,5001}" startactive="false">
    <modifiers commandeerable="true"/>
    <orders>
      <order order="Patrol" default="true">
        <param name="range" value="class.sector"/>
      </order>
    </orders>
    <category faction="nhparanid" tags="[factionlogic, military, frigate]" size="ship_m"/>
	<quota galaxy="12" maxgalaxy="20" sector="4"/>
	<time start="1800"  interval="60"/>
    <location class="galaxy" macro="xu_ep2_universe_macro" faction="nhparanid" relation="self" comparison="exact"/>
    <environment buildatshipyard="true"/>
    <ship>
      <select faction="nhparanid" tags="[military, frigate]" size="ship_m"/>
      <loadout>
        <level min="0.4" max="1.0"/>
      </loadout>
      <units>
        <unit category="unitcategory.defence" min="5" max="8"/>
      </units>
      <owner exact="nhparanid" overridenpc="true"/>
    </ship>
  </job>
The <time start="1800" interval="60"/> starts the first instance of the job at 30 minutes from the first job call and starts a new one every minute untill the quota is met.

I set it to 30 minutes so that i could get to a suitable location and drop adv sats to observe the area and watch what was hepppening.

So, at the end of the day i set the following conditions,
1: Required jobs are set to Startactive "false" in the jobs file
2: Jobs are then set to active 10 seconds after the player spawns
3: the first job call is then triggered 30 minutes later and appears in the game.

And they still just spawn in instead of being built. :cry:
You are doing something wrong. I have never had an issue with ships spawning which should be built. You made every job ship in jobs startactive=false? Try starting a new game with all job ships set to startactive=false without the script that activates them. Save the game and then exit the game. Try creating a separate mod for the script that will activate jobs and then turn it on and load your game. See what happens then.
User avatar
Shuulo
Posts: 1633
Joined: Mon, 14. Apr 08, 17:03
x4

Re: Building new jobs instead of just spawning?

Post by Shuulo »

activating job will always spawn ships up to galaxy quota, thats just how it works.
you should set galaxy=0 and maxgalaxy whatever you want, in this way those ships will be able to built only if needed by faction logic, and they are usually requested soon
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Re: Building new jobs instead of just spawning?

Post by BlackRain »

Shuulo wrote: Sat, 12. Feb 22, 20:38 activating job will always spawn ships up to galaxy quota, thats just how it works.
you should set galaxy=0 and maxgalaxy whatever you want, in this way those ships will be able to built only if needed by faction logic, and they are usually requested soon
It won't spawn the ships if startactive is set to false so I am not really sure why you are saying they will always spawn? Unless I am misunderstanding something here ?
User avatar
Shuulo
Posts: 1633
Joined: Mon, 14. Apr 08, 17:03
x4

Re: Building new jobs instead of just spawning?

Post by Shuulo »

BlackRain wrote: Sun, 13. Feb 22, 00:33
Shuulo wrote: Sat, 12. Feb 22, 20:38 activating job will always spawn ships up to galaxy quota, thats just how it works.
you should set galaxy=0 and maxgalaxy whatever you want, in this way those ships will be able to built only if needed by faction logic, and they are usually requested soon
It won't spawn the ships if startactive is set to false so I am not really sure why you are saying they will always spawn? Unless I am misunderstanding something here ?
Yeah, but as soon as it will be activated it will be spawned up to galaxy quota, thats the issue OP wants to counter.
He wants the ships to be built instead, IMO setting quota to 0 and maxquota to something else will counter this, but there can be less ships if factionlogic will not order them.
Dr Reed
Posts: 79
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Building new jobs instead of just spawning?

Post by Dr Reed »

BlackRain wrote: Sun, 13. Feb 22, 00:33 It won't spawn the ships if startactive is set to false so I am not really sure why you are saying they will always spawn? Unless I am misunderstanding something here ?
I agree, ships do not spawn if set to startactive false. There will be no ships from that job on the map.
And yes you can then save/exit/reload the game and set the job to active with a script and the job will run. Ships from the job will now appear in the game and carry out their business and get replaced by the wharf/shipyard if they get destroyed. More ships will also be built if the faction expands territory.

But what appears to be happening is that the very first quota of the newly activated job does not get built by the shipyard/wharf. It gets spawned into the map.

My game is not fully up to date due to internet problems and maybe Egosoft have updated the way jobs are handled in a recent patch which i do not have access to at the moment.

Shuulo wrote: Sun, 13. Feb 22, 13:42 IMO setting quota to 0 and maxquota to something else will counter this, but there can be less ships if factionlogic will not order them.
Yes, i tried this as well after you suggested it and it works reasonably well.
You don't even need to go as low on the initial quota as 0 but the results I have been getting seem to be very random. With some game starts running very well with the faction pushing into a new sector very quickly and building a heap of new ships to cover zones and sectors, then there are other starts where they sit there and do nothing but fill the wharf stores to capacity.


I even thought about trying to make a script to destroy the first quota of each job to force the faction to build up its fleets organically but, nope. that almost seems a bit too much. :)
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Re: Building new jobs instead of just spawning?

Post by BlackRain »

Dr Reed wrote: Sun, 13. Feb 22, 18:36
BlackRain wrote: Sun, 13. Feb 22, 00:33 It won't spawn the ships if startactive is set to false so I am not really sure why you are saying they will always spawn? Unless I am misunderstanding something here ?
I agree, ships do not spawn if set to startactive false. There will be no ships from that job on the map.
And yes you can then save/exit/reload the game and set the job to active with a script and the job will run. Ships from the job will now appear in the game and carry out their business and get replaced by the wharf/shipyard if they get destroyed. More ships will also be built if the faction expands territory.

But what appears to be happening is that the very first quota of the newly activated job does not get built by the shipyard/wharf. It gets spawned into the map.

My game is not fully up to date due to internet problems and maybe Egosoft have updated the way jobs are handled in a recent patch which i do not have access to at the moment.

Shuulo wrote: Sun, 13. Feb 22, 13:42 IMO setting quota to 0 and maxquota to something else will counter this, but there can be less ships if factionlogic will not order them.
Yes, i tried this as well after you suggested it and it works reasonably well.
You don't even need to go as low on the initial quota as 0 but the results I have been getting seem to be very random. With some game starts running very well with the faction pushing into a new sector very quickly and building a heap of new ships to cover zones and sectors, then there are other starts where they sit there and do nothing but fill the wharf stores to capacity.


I even thought about trying to make a script to destroy the first quota of each job to force the faction to build up its fleets organically but, nope. that almost seems a bit too much. :)
There is a way to accomplish what you want but it might take a little work. You can set all job ships to start active = false and never activate them. Then use my FOCW mod and make some changes to it. Increase the thresholds so more fleets are ordered then default customized in my mod (to make up for the lack of vanilla jobs). Also, maybe make the timers shorter or longer depending on what you want. This should give you relatively what you want, but you might need to edit it to really fine tune it.

Return to “X4: Foundations - Scripts and Modding”