[MOD] Reaction Force

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

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

BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7406
Joined: Mon, 15. Dec 03, 18:53
x4

Re: [MOD] Reaction Force

Post by BlackRain » Fri, 9. Apr 21, 16:17

Code: Select all

[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorspace'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'pursuetargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorpos'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'squad_attack'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'allowothertargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'Attack' via <create_order> with unexpected parameter 'timeout'
See, these are some of the errors popping up. This means none of those parameters are working as intended for that particular command. Not necessarily a big deal though in this case I guess.

Also, this too but this is from the original version and not new changes.

Code: Select all

Line 87712: [=ERROR=] 182200.14 extensions\shib_reactionforce\aiscripts\order.fight.reactionforce.xml(200): Script node 'resume' is not allowed in this context.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [MOD] Reaction Force

Post by Alkeena » Sun, 11. Apr 21, 06:40

BlackRain wrote:
Fri, 9. Apr 21, 16:17

Code: Select all

[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorspace'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'pursuetargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorpos'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'squad_attack'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'allowothertargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'Attack' via <create_order> with unexpected parameter 'timeout'
See, these are some of the errors popping up. This means none of those parameters are working as intended for that particular command. Not necessarily a big deal though in this case I guess.

Also, this too but this is from the original version and not new changes.

Code: Select all

Line 87712: [=ERROR=] 182200.14 extensions\shib_reactionforce\aiscripts\order.fight.reactionforce.xml(200): Script node 'resume' is not allowed in this context.
Those are all base attack parameters. He either meant to call the attack order (I believe the id is literally "Attack") OR he mistakenly believed protectship had the same params.

BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7406
Joined: Mon, 15. Dec 03, 18:53
x4

Re: [MOD] Reaction Force

Post by BlackRain » Sun, 11. Apr 21, 07:17

Alkeena wrote:
Sun, 11. Apr 21, 06:40
BlackRain wrote:
Fri, 9. Apr 21, 16:17

Code: Select all

[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorspace'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'pursuetargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorpos'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'squad_attack'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'allowothertargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'Attack' via <create_order> with unexpected parameter 'timeout'
See, these are some of the errors popping up. This means none of those parameters are working as intended for that particular command. Not necessarily a big deal though in this case I guess.

Also, this too but this is from the original version and not new changes.

Code: Select all

Line 87712: [=ERROR=] 182200.14 extensions\shib_reactionforce\aiscripts\order.fight.reactionforce.xml(200): Script node 'resume' is not allowed in this context.
Those are all base attack parameters. He either meant to call the attack order (I believe the id is literally "Attack") OR he mistakenly believed protectship had the same params.
Yeah, i was basically saying that but in less detail. Those params don’t work with that order. The resume start one is a little more serious but still not a big deal

monish_05m
Posts: 21
Joined: Wed, 10. Aug 05, 15:57
x3tc

Re: [MOD] Reaction Force

Post by monish_05m » Sun, 11. Apr 21, 10:30

Alkeena wrote:
Sun, 11. Apr 21, 06:40
BlackRain wrote:
Fri, 9. Apr 21, 16:17

Code: Select all

[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorspace'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'pursuetargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'radiusanchorpos'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'squad_attack'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'ProtectShip' via <create_order> with unexpected parameter 'allowothertargets'
[=ERROR=] 182200.14 Script warning: AI script 'reactionforce' references AI order 'Attack' via <create_order> with unexpected parameter 'timeout'
See, these are some of the errors popping up. This means none of those parameters are working as intended for that particular command. Not necessarily a big deal though in this case I guess.

Also, this too but this is from the original version and not new changes.

Code: Select all

Line 87712: [=ERROR=] 182200.14 extensions\shib_reactionforce\aiscripts\order.fight.reactionforce.xml(200): Script node 'resume' is not allowed in this context.
Those are all base attack parameters. He either meant to call the attack order (I believe the id is literally "Attack") OR he mistakenly believed protectship had the same params.
Hey, im the noob in question here, please help me out. My knowledge of code and modding is brand spanking new, so i accept all the mistakes.

this is my code generating the error:

Code: Select all

		<do_else>
                        <!-- Get some XP for responding -->
                        <apply_experience entity="this" experience="'ship_disable_easy'" chance="20"/>
                        <set_value name="$responseTime" exact="player.age"/>
                        <set_value name="$activeResponse" exact="true"/>
                        <!-- Handle notifications/Log -->
                        <do_if value="$notifyMe">
                            <show_notification text="'{7442342,30122}'.[this.ship.knownname, $responseTarget.knownname]" priority="9"/>
                        </do_if>
                        <write_to_logbook category="alerts" title="'{7442342,30123}:'" text="'{7442342,30124}'.[this.ship.knownname, $responseTarget.knownname, $responseTarget.sector.knownname]"/>
                        <set_value name="$responding" exact="true"/>
                        <set_value name="$responseTime" exact="player.age"/>
                        <set_value name="$idling" exact="null"/>
                        <!-- If it's a station protect the station -->
                        <do_if value="$responseTarget.isclass.station">
                            <debug_text text="'SHIB Reaction Force - %s - Responding to Station %s'.[this.ship.knownname, $responseTarget.knownname]"/>
                            <create_order object="this.ship" id="'ProtectStation'">
                                <param name="station" value="$responseTarget"/>
                                <param name="timeout" value="10s"/>
                            </create_order>
                        </do_if>
                        <!-- If it's a ship protect the ship -->
                        <do_elseif value="$responseTarget.isclass.ship">
							<debug_text text="'SHIB Reaction Force - %s - Responding to Ship %s'.[this.ship.knownname, $responseTarget.knownname]"/>
							<create_order object="this.ship" id="'AttackInRange'">
								<param name="target" value="$responseTarget"/>
								<param name="pursuetargets" value="true"/>
								<param name="allowothertargets" value="true"/>
								<param name="timeout" value="30s"/>
								<param name="radius" value="100"/>
								<param name="radiusanchorpos" value="$responseTarget.position"/>
								<param name="radiusanchorspace" value="$responseTarget.sector"/>
								<param name="squad_attack" value="this.ship.subordinates.count gt 0"/>
							</create_order>
                        </do_elseif>
                        <!-- New response -->
                        <do_if value="@$aggressor">
                            <create_order object="this.ship" id="'Attack'" immediate="true">
                                <param name="primarytarget" value="$aggressor"/>
                                <param name="pursuetargets" value="true"/>
                                <param name="escort" value="$responseTarget"/>
                                <param name="allowothertargets" value="true"/>
								<param name="squad_attack" value="this.ship.subordinates.count gt 0"/>
								<param name="timeout" value="30s"/>
                            </create_order>
                        </do_if>
                    </do_else>
Below is the original code that makes the fleet follow the protected ship for a long time, even if fixed this should not be the ideal behaviour as attacking the threats should be the goal and not following the protected ship, as there may be other ships in the area being attacked and in need of protection.

Code: Select all

	<do_else>
                        <!-- Get some XP for responding -->
                        <apply_experience entity="this" experience="'ship_disable_easy'" chance="20"/>
                        <set_value name="$responseTime" exact="player.age"/>
                        <set_value name="$activeResponse" exact="true"/>
                        <!-- Handle notifications/Log -->
                        <do_if value="$notifyMe">
                            <show_notification text="{7442342,30122}.[this.ship.knownname, $responseTarget.knownname]"
                                               priority="9"/>
                        </do_if>
                        <write_to_logbook category="alerts" title="{7442342,30123}"
                                          text="{7442342,30124}.[this.ship.knownname, $responseTarget.knownname, $responseTarget.sector.knownname]"/>
                        <set_value name="$responding" exact="true"/>
                        <set_value name="$responseTime" exact="player.age"/>
                        <set_value name="$idling" exact="null"/>
                        <!-- If it's a station protect the station -->
                        <do_if value="$responseTarget.isclass.station">
                            <debug_text text="'SHIB Reaction Force - %s - Responding to Station %s'.[this.ship.knownname, $responseTarget.knownname]"/>
                            <create_order object="this.ship" id="'ProtectStation'">
                                <param name="station" value="$responseTarget"/>
                                <param name="timeout" value="300s"/>
                            </create_order>
                        </do_if>
                        <!-- If it's a ship protect the ship -->
                        <do_elseif value="$responseTarget.isclass.ship">
                            <debug_text text="'SHIB Reaction Force - %s - Responding to Ship %s'.[this.ship.knownname, $responseTarget.knownname]"/>
                            <create_order object="this.ship" id="'ProtectShip'">
                                <param name="target" value="$responseTarget"/>
                                <param name="timeout" value="300s"/>
                            </create_order>
                        </do_elseif>
                        <!-- New response -->
                        <do_if value="@$aggressor">
                            <create_order object="this.ship" id="'Attack'" immediate="true">
                                <param name="primarytarget" value="$aggressor"/>
                                <param name="pursuetargets" value="false"/>
                                <param name="escort" value="$responseTarget"/>
                                <param name="allowothertargets" value="true"/>
                            </create_order>
                        </do_if>
                    </do_else>
what i want to achieve is to have the fleet get command to attack in range at the current position of the protected ship ,like the one we give in game by right click on an area on map view

these are the lines concerned with this

Code: Select all

		<!-- If it's a ship protect the ship -->
                        <do_elseif value="$responseTarget.isclass.ship">
							<debug_text text="'SHIB Reaction Force - %s - Responding to Ship %s'.[this.ship.knownname, $responseTarget.knownname]"/>
							<create_order object="this.ship" id="'AttackInRange'">
								<param name="target" value="$responseTarget"/>
								<param name="pursuetargets" value="true"/>
								<param name="allowothertargets" value="true"/>
								<param name="timeout" value="30s"/>
								<param name="radius" value="100"/>
								<param name="radiusanchorpos" value="$responseTarget.position"/>
								<param name="radiusanchorspace" value="$responseTarget.sector"/>
								<param name="squad_attack" value="this.ship.subordinates.count gt 0"/>
							</create_order>
                        </do_elseif>
Thanks

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

Re: [MOD] Reaction Force

Post by j.harshaw » Tue, 13. Apr 21, 00:58

I didn't follow the whole discussion, so pardon me if this is out of context and ignore if not useful.

These are the supported parameters in vanilla order.fight.attack.inrange:

Code: Select all

<params>
  <param name="destination" type="position" text="{1041, 10158}" comment="Center of area in which targets will be attacked. Position">
    <input_param name="class" value="class.sector"/>
  </param>
  <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>
  <param name="pursuetargets" default="false" type="bool" text="{1041, 10091}" advanced="true" comment="Pursue targets"/>
  <param name="debugchance" type="bool" default="0" advanced="true" text="{1041, 10086}" comment="Print debug output">
    <input_param name="truevalue" value="100"/>
  </param>
</params>
Translating that to your code, should be something like:

Code: Select all

<do_if value="$responseTarget.sector">
  <create_position name="$targetsectorpos" space="$responseTarget.sector" value="$responseTarget.position" object="$responseTarget.zone"/>
  <create_order id="'AttackInRange'" object="this.assignedcontrolled">
    <param name="destination" value="[$responseTarget.sector, $targetsectorpos]"/>
    <param name="radius" value="100km"/> <!-- at least, i assume you meant that in km? -->
    <param name="pursuetargets" value="true"/>
  </create_order>
  <remove_value name="$targetsectorpos"/>
</do_if>
Note that this precludes the use of squad_attack, though. For that, you'd have to call the Attack order directly, but the resulting behavior would be different. Depends on what you want it to do, of course. Code you posted won't trigger those errors mentioned earlier involving ProtectShip, though.

ShiBDiB
Posts: 78
Joined: Mon, 7. May 07, 00:12
x4

Re: [MOD] Reaction Force

Post by ShiBDiB » Tue, 20. Apr 21, 19:22

https://steamcommunity.com/sharedfiles/ ... 2463118472

Steam user I.C.E. has taken over the project. I don't play X4 enough to give something this popular the attention it needs.
-----
My Mods
Go Home Drone, Reaction Force, Disable Story, Pay The Builder, Landlord, Training Exercise
Github with the latest (Unstable) Versions
Nexus Page
Steam Workshop Page

Scoob
Posts: 9921
Joined: Thu, 27. Feb 03, 22:28
x4

Re: [MOD] Reaction Force

Post by Scoob » Fri, 1. Jul 22, 21:19

Hi, I'm using the updated version of this mod maintained by I.C.E. (Nexus link: https://www.nexusmods.com/x4foundations/mods/703) and I've run into an issue. As I have the GoG version of the game, I'm blocked from commenting on the Steam Workshop page for this mod (Workshop Link: https://steamcommunity.com/sharedfiles/ ... 2463118472) and it appears it's on Steam where I.C.E. is active.

I've run into quite a serious issue where, when calculating the threat factor for a Reaction Fleet group to respond to an enemy, it gets the values wrong. Basically, if a small group of ships - say a wing of Kha'ak - is attacking a player asset, their threat is a *total* of all ship's Hull, Shield and DPS. This makes sense. However, when the Reaction Force is assessed, only the *leader* of the group is taken into account.

In essence, I'm seeing (for example) three Kha'ak Fighters be "too risky" for a wing of 12 well-equipped Eclipse, because only the lead Eclipse's Shield, Hull and DPS is used in the calculation.

Now, I could just up the risk factor, but that defeats the point and the calculation is wrong. The game clearly posts to the Log *why* a response was cancelled, so I can clearly see the numbers. Example:

Threat level was too high.
Enemy ships amount: 3 (that small Kha'ak group)
With total 48481.227hp and 1640dps (sounds about right)
While RRF only has 20804hp and 1955dps (that's the figure for ONE ship, not all 12!)
Predicted LOSS (12.6854 VS 24.7872) is outside risk allowed.

With Lone ships - such as Destroyers - set as individual Reaction ships, they work great. Groups don't as subordinates are not counted.

Note: my Reaction fighter groups subordinates are set to "Attack" and they're also asked to remain docked at a station until needed.

Hoping posting here will get the attention of I.C.E.

Edit: After further testing, this is a quirky one, requiring a specific situation in order for it to get the calculation wrong. I've managed to get it working by changing ONE setting that shouldn't make any difference.

Basically, here are the settings that DON'T work, causing the calculation to be wrong, not accounting for subordinates:

Home: My station
Destination: blank
Dock (1/4) - so ships dock between sortees
Assign as Home base? Yes (de-clutter the Properly Owned list)
Response Range: 1/3
Allowed Threat level: 10/20
Respond to Ships: Yes
HP% Response Point: 100/100
Respond to C ships: Yes
HP% Response Point: 70/100
Respond to station: Yes
HP% Response Point: 100/100
Respond to Player: Yes
Respond to Distress: No
Silent Notifications: No
Attack S: Yes
Attack M: Yes
Attack L: Yes
Attack XL: No.

A fighter group with these settings will NOT respond to any attacks, giving the "too risky" reason, then give values ONLY for the group leader, not the entire group. Clearly shown in the Log.

If however, I set "Assign as Home base?" to NO, the fighter group will respond just fine in the same situation. Setting homebase for Fighter Groups is great as it keeps the Property Owned list tidy. However, subordinates being docked appears to break the calculation. Note: some subordinates were docked on the Pad, others in internal storage but the leader was in internal storage.


Cheers.

Post Reply

Return to “X4: Foundations - Scripts and Modding”