sector attack script

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

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

Post Reply
Halpog
Posts: 424
Joined: Sat, 13. Feb 21, 14:09
x4

sector attack script

Post by Halpog » Fri, 24. Sep 21, 09:50

is there any script or mod arround , that let my fleet attack a whole sector without the need to klick on every single target and choose attack ?

basicaly iam looking for : klick on my fleet, choose a sector to attack and let them do there job. and they destroy everything in this sector, and can move to the next one after and do the same.

flywlyx
Posts: 952
Joined: Sat, 15. May 21, 03:45
x4

Re: sector attack script

Post by flywlyx » Sat, 25. Sep 21, 07:29

Attack area is enough in most cases.

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: sector attack script

Post by vonclausewitz » Sat, 25. Sep 21, 14:09

Does anyone know is radius of this 'attack in range' feature can be edited by changing xml file?

I 'd like to see that circle little bigger, too. If we know what is name of radius parameter it is easy to make mod. I I have unpacked X4 version, where should I look for it?

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: sector attack script

Post by j.harshaw » Sat, 25. Sep 21, 18:21

vonclausewitz wrote:
Sat, 25. Sep 21, 14:09
Does anyone know is radius of this 'attack in range' feature can be edited by changing xml file?
script is order.fight.attack.inrange. param 'radius'.

Halpog
Posts: 424
Joined: Sat, 13. Feb 21, 14:09
x4

Re: sector attack script

Post by Halpog » Sun, 26. Sep 21, 06:05

j.harshaw wrote:
Sat, 25. Sep 21, 18:21
vonclausewitz wrote:
Sat, 25. Sep 21, 14:09
Does anyone know is radius of this 'attack in range' feature can be edited by changing xml file?
script is order.fight.attack.inrange. param 'radius'.
anyone here is able to make with this script a mod for a "sector attack" ? i mean set hte radius for example to 500km so that most sectors can be attacked like that ?

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: sector attack script

Post by vonclausewitz » Sun, 26. Sep 21, 20:11

Apologies, I was following two other questions I had asked on forum.
i mean set hte radius for example to 500km so that most sectors can be attacked like that ?
I was thinking same. I managed to find related orders and I was naive thinking that this radius parameter is some nice number like 3 or 20 or whatever and it will be easy to change it.
This is how it looks in order.fight.attack.inrange.xml :

Code: Select all

<param name="radius" type="length" default="this.ship.maxradarrange" text="{1041, 10093}" comment="Radius">
        <input_param name="min" value="1km"/>
        <input_param name="max" value="[this.ship.maxradarrange, 1km].max"/>
        <input_param name="step" value="1km"/>
      </param>
so I have made a small mod to try to edit those values, by making own order.fight.attack.inrange.xml like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff>  
  <replace sel="//aiscript/order/param/@default">this.ship.maxradarrange * 50</replace>
  <replace sel="//aiscript/order/param/input_param/@value">[this.ship.maxradarrange * 50, 5km].max</replace>
   
</diff>
but I don't see any result in game. I am afraid that I don't have idea how to proceed with that.

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: sector attack script

Post by j.harshaw » Sun, 26. Sep 21, 20:25

<replace sel="//aiscript/order/param[@name='radius']/@default">this.ship.maxradarrange * 50</replace>

<replace sel="//aiscript/order/param[@name='radius']/input_param[@name='max']/@value">[this.ship.maxradarrange * 50, 5km].max</replace>

assuming the rest of the path is right, think that should work. haven't tested.

Halpog
Posts: 424
Joined: Sat, 13. Feb 21, 14:09
x4

Re: sector attack script

Post by Halpog » Mon, 27. Sep 21, 21:50

vonclausewitz wrote:
Sun, 26. Sep 21, 20:11
Apologies, I was following two other questions I had asked on forum.
i mean set hte radius for example to 500km so that most sectors can be attacked like that ?
I was thinking same. I managed to find related orders and I was naive thinking that this radius parameter is some nice number like 3 or 20 or whatever and it will be easy to change it.
This is how it looks in order.fight.attack.inrange.xml :

Code: Select all

<param name="radius" type="length" default="this.ship.maxradarrange" text="{1041, 10093}" comment="Radius">
        <input_param name="min" value="1km"/>
        <input_param name="max" value="[this.ship.maxradarrange, 1km].max"/>
        <input_param name="step" value="1km"/>
      </param>
so I have made a small mod to try to edit those values, by making own order.fight.attack.inrange.xml like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff>  
  <replace sel="//aiscript/order/param/@default">this.ship.maxradarrange * 50</replace>
  <replace sel="//aiscript/order/param/input_param/@value">[this.ship.maxradarrange * 50, 5km].max</replace>
   
</diff>
but I don't see any result in game. I am afraid that I don't have idea how to proceed with that.
u got it working ?

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: sector attack script

Post by vonclausewitz » Tue, 28. Sep 21, 23:37

Hi, unfortunately not. I am not surprised, cause this file is bit more complicated. I have tested that double, but You may try yourself.

My skills are very basic, so maybe someone more experienced should see it.

I made a 2nd version of this, making a mini mod with index file referring to copy-pasted original file. Ie I have used original file, edited and then created reference in index. As I understand this way I am telling X4 to read my mod file instead of that vanilla's. And this didn't work too.
By didn't work I mean, that I don't see any change in radius during game.

But, it is possible (IDK how much) that visual representation (blue circle on galaxy map) is predefined (2D sprite?), and would not change even if radius of attack is indeed increased. However I wouldn't be surprised if it would be some kind silly mistake of my own.

Anyway, I have uploaded a zip file -> https://www.moddb.com/mods/turbo-lanzer ... tor-attack and there are both versions inside. (2 mini mods) I would appreciate if someone smarter looked into this, or anyone could confirm not working/working.

Halpog
Posts: 424
Joined: Sat, 13. Feb 21, 14:09
x4

Re: sector attack script

Post by Halpog » Sun, 24. Oct 21, 10:26

ok found a way to do it, not good but it works..
i just raised the radar range of a ship to 300KM and made it the fleet elader. than use attack all enemies and done ...

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: sector attack script

Post by vonclausewitz » Sat, 30. Oct 21, 00:33

Ha!

I just realized same thing, and wanted to announce that problem is solved... and here I see that
ok found a way to do it, not good but it works..
Cool.

So: attack in range is linked to a radar range. This is inside file in unpacked in library folder in the default.xml. Inside file there is dataset linked to all sizes of ships, ie. small, medium, large, xl.

And I think that this solution is ideal. There was quite interesting discussion on reddit about ships in X4. Generally people complained that with small, and medium ships being so good, and handicaps of xl ships there is little use of CV at all. Slow, clumsy, not so powerful, can't use space highways, etc.
And we can, naturally, discuss how fair and accurate such arguments are, recently someone added another intersting point, which is: if I can buy for same prize fighters and swarm same value any large or xl ship, then there is no real point bothering with manufacturing them.
And it bothered me all time, that large and xl ships *should* have better something, not like just better hull, or resistance, but some feature that would make them handy, and that would be simulation-wise as well. And if we look at our times and see how imporant is seeing enemy on the battlefield (from Napoleon's baloons to modern tech) and exactly I think radar range may be that feature that can make L and XL ships very desirable.

Anyway, if someone is interested what is in this ship file here is an example:

Spoiler
Show

Code: Select all

 <dataset class="ship_xl">
    <properties>
      <radar range="256000"/>
      <explosioneffect strength="125000" />
      <effects>
        <scuttle ref="scuttle_l" />
        <collision light="light_collision_l" medium="medium_collision_l" strong="strong_collision_l" />
        <!--commented out: sustain="ongoing_collision_l" -->
        <explosion ref="ship_explosion_generator" />
        <damage>
          <effect chance="0.20" threshold="75" location="weapon" ref="sparkles_s" />
          <effect chance="0.30" threshold="40" location="hull" ref="surfaceexplosions_s" />
          <effect chance="1.0" threshold="15" location="hull" ref="surfaceexplosions_s" />
        </damage>
      </effects>
      <capture allow="true" />
      <docksize tag="dock_xl" />
      <relation>
        <attack>
          <tolerance threshold="-1.0" change="-0.25" decay="0.25" delay="5" />
          <boost absolute="-1.0" decay="0.02" delay="540" />
        </attack>
        <kill>
         <faction change="-0.3" bonus="0.1" />
        </kill>
        <police change="-0.05" bounty="6600000"/>
      </relation>
      <wreck deceleration="60" />
      <people capacity="200"/>
      <storage countermeasure="75" deployable="450"/>
      <statistics>
        <max>
          <hull value="1708000.000000" />
          <shield value="3376898.000000" delay="0.000000" rate="5473.000000" />
          <weapon burst="1271276.875000" sustained="115489.625000" />
          <turret burst="0.000000" sustained="0.000000" />
          <groups>
            <shield value="54734.046875" delay="0.570000" rate="350.349976" />
            <turret burst="24729.218750" sustained="24729.218750" />
          </groups>
          <dock ship_m="4" ship_s="21" />
          <engine forward="404.728424" acceleration="139.028397" boost="870.863770" travel="12671.474609" yaw="0.087344" pitch="0.063288" roll="0.068099"/>
          <thruster>
            <horizontal speed="21.898272" acceleration="6.214204"/>
            <vertical speed="21.898272" acceleration="6.214204"/>
          </thruster>
          <capacity crew="450" container="500000" solid="0" liquid="0" ship_m="30" ship_s="100" unit="300" missile="10000" countermeasure="300" deployable="500" />
          <radar range="148000.000000" />
        </max>
      </statistics>
      <internalsound engine="0.50" />
      <modification>
        <paint scale="32.0" />
      </modification>
    </properties>
    <connections>
      <connection name="con_playercontrol" tags="playercontrol" value="-1" match="all" />
      <connection name="defencenpc" tags="defence" value="-1" match="all" />
      <connection name="engineernpc" tags="engineer" value="-1" match="all" />
      <connection name="parking" tags="parking" value="1" />
      <connection name="tradecomputer" tags="tradecomputer" value="-1" match="all" />
    </connections>
  </dataset>
What is so cool in this part is the fact that you can take almost any property from defaults and use it to nuance particular units [ships]. So actually you can 'take' radar range and edit all small scouts and set their radar range to 40km and lower in defaults radar range for small ships to 20km (for example).

So let's say we edit ship_par_m_corvette_01_b_macro (paranid corvette) :
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--Exported by: Michael (192.168.3.81) at 21.11.2018_18-31-38-->
<macros>
  <macro name="ship_par_m_corvette_01_b_macro" class="ship_m">
    <component ref="ship_par_m_corvette_01" />
    <properties>
      <identification name="{20101,30303}" basename="{20101,30301}" description="{20101,30313}" variation="{20111,1201}" shortvariation="{20111,1203}" icon="ship_m_fight_01" />
      <software>
        <software ware="software_dockmk2" compatible="1" />
        <software ware="software_flightassistmk1" default="1" />
        <software ware="software_scannerlongrangemk1" default="1" />
        <software ware="software_scannerlongrangemk2" compatible="1" />
        <software ware="software_scannerobjectmk1" default="1" />
        <software ware="software_scannerobjectmk2" compatible="1" />
        <software ware="software_targetmk1" default="1" />
        <software ware="software_trademk1" compatible="1" />
      </software>
      <explosiondamage value="5000" />
      <storage missile="40" />
      <hull max="12000" />
      <secrecy level="2" />
      <purpose primary="fight" />
      <people capacity="6" />
      <physics mass="29.273">
        <inertia pitch="3.67" yaw="3.67" roll="2.936" />
        <drag forward="4.05" reverse="16.2" horizontal="15.624" vertical="15.624" pitch="8.836" yaw="8.836" roll="8.836" />
      </physics>
      <thruster tags="medium" />
      <ship type="corvette" />
      <sound_occlusion inside="0.4" />
    </properties>
    <connections>
      <connection ref="con_cockpit">
        <macro ref="cockpit_gen_virtual_01_macro" connection="ship" />
      </connection>
      <connection ref="con_dock_xs">
        <macro ref="dock_gen_xs_ship_01_macro" connection="Connection_component" />
      </connection>
      <connection ref="con_shipstorage_xs_01">
        <macro ref="shipstorage_gen_xs_01_macro" connection="object" />
      </connection>
      <connection ref="con_storage01">
        <macro ref="storage_par_m_corvette_01_b_macro" connection="ShipConnection" />
      </connection>
    </connections>
  </macro>
</macros>
so I can create my own xml and write smth like this:

Code: Select all

<diff> 
	
	<replace sel="//macros/macro/properties/radar/@range">52000</replace>
	 <add sel="//macros/macro/properties/storage" type="@countermeasure">50</add>
	 <add sel="//macros/macro/properties/storage" type="@deployable">60</add>
</diff> 
and heavy par corvette will have these exact values nuanced just for that ship. Really cool if you wanna personalize ships, etc. And thanks to the fact that operational range is linked to radars, and we can give better range to l and xl ships and increase their usefulness by making them kind of AWACS makes - I think - game more realistic. Anyway I am sure I will use it in my mod.

EDIT: My mistake, it seems that changing radar range for separate ship doesn't work. And

Code: Select all

<add sel="//macros/macro/properties/radar" type="@range">82000</add>
does not modify radar too...


Does anyone knows what is that part in defaults responsible for?

Code: Select all

<statistics>
        <max>
          <hull value="46800.000000" />
          <shield value="46914.902344" delay="0.570000" rate="300.299988" />
          <weapon burst="71850.734375" sustained="22198.152344" />
          <turret burst="947.849365" sustained="947.849365" />
          <groups>
            <shield value="0.000000" delay="0.000000" rate="0.000000" />
            <turret burst="0.000000" sustained="0.000000" />
          </groups>
          <dock ship_m="0" ship_s="1" />
          <engine forward="1881.833984" acceleration="539.586548" boost="18670.025391" travel="21003.779297" yaw="2.235139" pitch="2.737810" roll="3.724411"/>
          <thruster>
            <horizontal speed="467.768524" acceleration="116.942131"/>
            <vertical speed="467.768524" acceleration="116.942131"/>
          </thruster>
          <capacity crew="66" container="112240" solid="112000" liquid="112960" ship_m="0" ship_s="1" unit="64" missile="420" countermeasure="88" deployable="250" />
          <radar range="48000.000000" />
        </max>
      </statistics>
These statistics are for M ship and I am sure that my modded corvette is 64K hull so these are not maximum values for ships... Maybe these are some values related to the in-game modifications?

Halpog
Posts: 424
Joined: Sat, 13. Feb 21, 14:09
x4

Re: sector attack script

Post by Halpog » Sun, 31. Oct 21, 05:29

i have no clue what this values are for.
for example, i took the argon zyklops from nexus, set the radar range to 250km .....this will cover the whole sector between the gates for "attack everything.
so i gave him a fleet and used the repeatable command and right klick on map and choosed attack all enemies.. thats it.

the reason i use XL ships is the fact that some XL ships have a good ammount of L turrets and that some weapons are realy good. but to be honest .. vro or weapon pack or not. iam ending up always on every ship with the same combo of turrets and weapons.

Post Reply

Return to “X4: Foundations - Scripts and Modding”