[MOD] Automated Emergency Jump - v2.17 (5 jan 2016) - Comp. 3.61 / 4.00 beta 4

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

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

Post Reply
bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

[MOD] Automated Emergency Jump - v2.17 (5 jan 2016) - Comp. 3.61 / 4.00 beta 4

Post by bm01 » Sat, 27. Sep 14, 22:24

OBSOLETE SINCE 4.00 beta 6



Allows all capital ships to automatically do an emergency jump if they think they're about to die.
Don't hesitate to suggest or comment!

Important notice:
I won't provide any support if you download this mod through a package or compilation since I won't be able to control its content.

Steam Workshop link

~~ Features and description ~~
  • Capital ships attempt an emergency jump when they're below a certain amount of shield and hull. There's also a "Smart Jump" option (activated by default) that takes into account the DPS received, the remaining shield / hull amount and the time it takes to jump (at least 20s). Basically, instead of only using thresholds, they will jump only if they think that the danger is real.
  • The time it takes to jump is modified by the Captain's navigation and combat skill (+0~10 seconds).
  • They jump to the border (35km~40km) of a zone chosen randomly among those having a beacon (adjacent sectors only, however they can also do an in-sector jump if the beacon is in another zone). They then use their booster and get out of the zone.
  • After a jump, ships can either wait or move back to their previous location and resume their original task. They can also wait after some repair and their drones.
  • Jumps can be logged to the logbook and / or shown on the event monitor.
  • Enemy ships can jump too (except for mission ships since that could break them).
  • In-game configuration menu.
~~ Configuration ~~

Everything is done through the in-game menu (under "Informations").

Image
  • Thresholds
    Ships will consider doing an emergency jump if both their shield and hull amounts are below those values.
  • Smart Jump
    - Activated: If "No" is selected, only thresholds will be used. In that case, I highly recommend to lower them.
    - Time multiplier: To understand the second option you have to know how Smart Jump internally works. Instead of looking only at thresholds, ships will also compute how much time they have left to live and trigger an emergency jump if this time is shorter than the time it takes to make a jump MULTIPLIED by the "Time Multiplier" value. In short, The bigger the multiplier is, the sooner ships will jump. 1.5x is the default value and seems well balanced, weak ships might still die though.
  • Actions after jump
    - Resume previous task: If "No" is selected, ships will simply wait for new orders at the jump destination and enemy ships will just die.
    - Wait repair: Makes ships wait for repair before considering moving back to the previous zone and resuming their previous task.
    - Wait drones: Same, but with drones return.
  • Other
    - Fuel required: Pretty self explanatory. Also, enemy patrols do not have fuel cell, this option allow them to still jump. Note that this only affects jumps triggered by Automated Emergency Jump.
    - Log jumps: Records jumps to the logbook.
    - Show on event monitor: Notifies you of ships jumping by displaying informations on the monitor's cockpit.
~~ Installation ~~

Installation should ideally be done on a new game.

Installation on an already started game is possible, but in order for scripts to be compatible with your savefile, some AI scripts will be reset:
  • Player owned ships assigned to a station or a ship will keep doing what they're told to. They are technically reassigned to them.
  • Player owned ships that do not have any commander or that are in your squad (direct subordinates) will stop and start following you respectively.
  • Job ships (AI ships that spawn naturally and regularly) will be destroyed and respawn naturally after a while. Note that some of them might take more than one hour.
  • Nothing is done about mission ships. They won't be destroyed to prevent some missions from being impossible to complete, however I strongly suggest against uninstalling Automated Emergency Jump if you have any running mission.
Unfortunately patrols and trades will have to be resumed manually.

~~ Uninstallation ~~

If you wish to no longer use Automated Emergency Jump, you'll have to uninstall it through the menu:
1- Open Automated Emergency Jump's menu and clic on Uninstall.
2- Read carefully then click on "Accept".
3- Game's main menu will open and you'll be asked to save your game without closing the menu (otherwise you'll have to start over because scripts will resume).
4- Quit the game.
5- Remove Automated Emergency Jump.
6- Load the previously saved game.

Note that this will reset some AI scripts:
  • Player owned ships assigned to a station or a ship will keep doing what they're told to. They are technically reassigned to them.
  • Player owned ships that do not have any commander or that are in your squad (direct subordinates) will stop and start following you respectively.
  • Job ships (AI ships that spawn naturally and regularly) will be destroyed and respawn naturally after a while. Note that some of them might take more than one hour.
  • Nothing is done about mission ships. They won't be destroyed to prevent some missions from being impossible to complete, however I strongly suggest against uninstalling Automated Emergency Jump if you have any running mission.
Unfortunately patrols and trades will have to be resumed manually.

~~ Updating ~~

Be warned that during some updates of Automated Emergency Jump, what is described in "Installation" and "Uninstallation" (see above) might be performed. This only happens during major updates of Automated Emergency Jump.

Do not hesitate to ask me for the previous version if you do not wish this to happen.

~~ Compatibility ~~

Automated Emergency Jump triggers jumps by interrupting captain's scripts, calling its own scripts then resuming the interrupted script. As a consequence, mods that replace vanilla scripts entirely and mods that add custom jobs (with custom scripts) might not be fully compatible. In that case, you can still use Automated Emergency Jump but some ships won't be handled.

If you find a mod being incompatible and wish for it to be, you should contact its authors and tell them to include a small portion of code into their scripts. It most cases, it should work. Here's the code as of 2.16:

1- In the interrupt node ("start" should be replaced with the main loop label's name).

Code: Select all

<handler>
  <conditions>
    <event_object_signalled object="this.ship" param="'AEJ_jump_initiated'"/>
  </conditions>
  <actions>
    <set_value name="$AEJ_emergencyjumpinitiated" exact="true"/>
    <set_value name="$AEJ_jumpparameters" exact="event.param2"/>
    <!-- don't replace the previous zone if we jump again -->
    <do_if value="not this.$AEJ_afterjump?">
      <set_value name="$AEJ_previouszone" exact="this.zone"/>
    </do_if>
    <abort_called_scripts resume="start"/>
  </actions>
</handler>
2- In the action node, right at the start of the main loop, after its label.

Code: Select all

<do_if value="$AEJ_emergencyjumpinitiated?">
  <run_script name="'AEJ.jump'">
    <param name="beacon" value="$AEJ_jumpparameters.{1}"/>
    <param name="usefuel" value="$AEJ_jumpparameters.{2}"/>
    <param name="calculationduration" value="$AEJ_jumpparameters.{3}"/>
  </run_script>
  <remove_value name="$AEJ_emergencyjumpinitiated"/>
  <remove_value name="$AEJ_jumpparameters"/>
  <do_if value="$AEJ_previouszone != this.zone">
    <run_script name="'AEJ.afterjump'">
      <param name="destination" value="$AEJ_previouszone"/>
    </run_script>
  </do_if>
  <remove_value name="$AEJ_previouszone"/>
</do_if>
~~ Known issues ~~
~~ Future plans (or just ideas) ~~
  • Ability to choose preferred destinations (in order to avoid dangerous zones for example).
  • Cancel jump if there's no longer any threat.
  • ... Suggestions?
~~ Change log ~~

2.17
- Fixed menu button not appearing with X Rebirth 3.61.

2.16
- Added ship sorting in the menu.
- Changed how ships behave when given a direct attack order, they should no longer chase their target across the universe after an emergency jump (from both the owned ship and the target).
- Fixed (again) jump getting aborted for some NPCs.

2.15
- Updated for 4.00 beta 4.
- Fixed default global values not being set properly on a new game (it prevented the menu from working properly and required a save - reload).

2.14
- Improved performances.
- Made Smart Jump slightly more accurate during the first seconds of a fight.
- Fixed various potential errors during captain and engineer reassignment.
- Fixed ships becoming unable to jump after assigning a new captain.
-- Parameters from the old captain should now be moved to the new captain.
- Fixed ships being stuck waiting for repair after the removal of the engineer.
-- They will now move to the next step if they detect that the engineer is missing.

2.13
- Fixed player ships with "hold position" command being unable to jump.
- Fixed player ships with "refuel" command being unable to jump.
- Attempted to fix ships not using their boosters to get out of the zone after an emergency jump.
- Attempted to fix NPC Titurels and NPC Marauder Phoenixes from doing weird stuff after an emergency jump.

2.12
- Ships waiting for repairs after an emergency jump will now immediately boost away until they've gotten out of the zone. This should prevent them from being chosen as mission targets and make them invisible from the zone they have jumped in (makes boarding more difficult, lowers lag...).
/!\ This update will stop all ships that are waiting for repairs and cancel their previous order. Be sure to not have any ships in that state upon updating if you do not wish that to happen.
/!\ If you have the debug window activated, some errors might appear during the first loading. They are harmless and won't reappear again.

2.11
- New "command" messages for the captain.
-- "Withdraw from battle" + "Calculating" before charging the jumpdrive.
-- "Withdraw from battle" + "Jumping" when jumping.
-- "Repair" + "Reparing Ship" when waiting repairs.
-- "Wait" + "Waiting drones" when waiting for drones to return (if there is any).
-- "Move to Zone" + "Fly to Zone" / "Jumping" when moving back to the previous zone.
- Fixed ships being indefinitely ignored by Automated Emergency Jump after some events (if no valid beacon could be found or if the jumpdrive was destroyed).
- Fixed jumps or after jump operations being canceled for ships having "following the player" as an original command (it happened if the player got attacked while being in the same zone as the ship).
- Fixed ships that failed at jumping (for whatever reason) attempting to do after jump operations.

2.10
- Improved performances (smoother framerate for users experiencing lag spikes every seconds since 2.00).
- Fixed errors occuring after loading if the saving was done during a ship's jump.

2.09
- Fixed some code errors that did bad things (introduced in 2.08).
- Removed debug message from 2.08.

2.08
- Fixed ships aborting their jump and trying to resume it again and again. It mostly affected NPC "pirate" ships (Titurels, Phoenix).
- Fixed "find destination" code giving an invalid beacon in some cases (mostly affected Xenon ships in Maelstrom).
- Made ships refueling because of a player command able to jump.
- Made mining ships following the player in mining mode no longer able to jump (will be readded later in a better way and affect all mining ships that are directly ordered to mine, instead of just this particular case).
- Made ships that do not rely on Smart Jump less prompt to jump (the presence of a civilian ship made them jump, it should no longer be the case).
- Removed debug messages related to jump destinations, added a new one related to jump abortion.
- Improved jump position, maybe. The position should now be out of range of any turret.

2.07
- Fixed ships trying to jump multiple times in a row due to a missing jumpdrive (destroyed?).

2.06
- Attempted to fix ships jumping or trying to jump multiple times in a row.

2.05
- Restored shield collision damage since it no longer affect capital ships (X Rebirth 3.51).

2.04
- Attempted to fix trader ships occasionally moving back to their previous position by slowly strafing (no jump, no boost).
- Fixed "wait repair" waiting too long for ships having an unskilled engineer (previously the limit of hull repair was 75%, but since some patch it can be higher or lower, AEJ now uses current vanilla calculation to know if a ship has finished repairing or not).
- Changed "Smart jump time multiplier" min and max values to 1x and 2x respectively (partially reverted 2.03 change, value below 1x didn't really make sense).

2.03
- Added two new options, "Log jumps" and "Show on event monitor". Both can be used for enemy ships (for debugging purpose for example).
- Changed "Smart jump time multiplier" min and max values to 0x and 2x respectively.

2.02
- Fixed installation / update messages being wrongly displayed on some cases (bug introduced in 2.01).

2.01
- Construction Ships attached to a station should no longer be able to jump and will disappear from the configuration menu. Yay!
-- If they get detached for some reason (probably through a mod since the vanilla game doesn't allow that), it should become able to jump again and reappear in the menu.
- Fixed Jump calculation duration (the value modified by the captain skills and added to the jump charge duration) not being updated during gameplay even by replacing the captain (it updated only after a game load in 2.00).
- Fixed potential errors due to ships not having a captain (captured capital ships for example).
- Improved removal of non longer used cue instances (script stuff).

2.00
This is a major update, many parts of the mod has been rewritten. As a consequence some scripts will be reset. See installation / uninstallation instruction for a description of what is to be expected. Sorry in advance for those of you who have many ships.
- AI (enemy ships) are now configurable.
- Each ships are now independently configurable.
- New "Fuel required" option.
- New "Wait drones" option.
- Added informations about uninstallation process.
- Improved compatibility with other mods ("fight.attack.object.capital" is no longer modified).
- Checks are more consistent, previously ships could skip checks for about 10 seconds.
- Many minor bugs fixed.

1.23
- Updated for Beta RC1.
- The ui.xml file should now be automatically included, if you already have created it yourself be sure to delete it or it might prevent the new one from loading.

1.20, 1.21 and 1.22
- Fixed some bugs caused by 1.19.

1.19
- Fixed menu for 3.50 Beta 3 (edit: still not fixed, a required file still can't be uploaded to the workshop).

1.18
- Fixed menu for 3.20 RC2

1.17
- Fixed Defense Officer order changes freezing the game (wut).
- Fixed unintentional removal of 3.00 feature (which basically improves target acquisition).
- Improved handling of ships without commander / squad during installation on a non-new game and uninstallation. For example, traders that aren't in player's squad should now resume their pending trades. However player patrols are unfortunately still not resumed properly (ships will either stop of follow the player).

1.16
Updated for X Rebirth 3.10:
- Fixed menu not appearing
- Fixed ships not jumping
- Ships running "move.plunder" (script) should now be able to perform "after jump" actions properly
/!\ To prevent potential bugs, AI scripts will be reset automatically after updating Automated Emergency Jump. If you notice something unusual (ships not moving for example) please let me know.

1.15
- Minor bug fixes.

1.14
- Support for X Rebirth 3.00 Beta 2.
- Fixed jump abortion putting ships into an infinite loop (extremely rare bug).
- Fixed potential incompatibility with mods modifying jumpdrives charge duration.

1.13
- Ships spawned by missions are no longer able to do an emergency jump (bug fix).

1.12
- Installation on a non-new game is now supported and less likely to cause errors.
- Improved uninstallation procedure, it now resumes scripts of player owned ships.
- Reformated some notifications and log messages for better readability.

1.11
- Fixed uninstallation procedure not taking docked ships (usually M sized traders) into account.

1.10
- Added the possibility to uninstall the mod. Please read the instructions carefully (mod's topic on Egosoft's forums).

1.01 and 1.02
- Fixed bugs introduced in 1.00.

1.00
- Ships spawned by missions should no longer be able to do an emergency jump.
This should increase compatibility with the plot and avoid possible bugs during missions. NPCs ships spawned by jobs (patrols or traders for example) are still able to jump if you have a mod that adds fuel cells to them.
- Added "resume previous task after jump" option.
If "No" is selected, ships will simply wait after an emergency jump.
Please open the menu at least once after updating, otherwise the variable will not be found and will be treated as "No". Sorry for the inconvenience.
- Added "After Jump" handling (such as repair and moving back to previous position) for ships jumping during a "Wait" (also known as "Hold position") command.

0.07
- Minor fix

0.06
- Completely redone Smart Jump. It no longer asks the game for the DPS of enemies (which were incorrect) but calculates the received DPS itself. Damage actually received are what matters now, instead of potential damage of all enemies around.
- A new option has been added for Smart Jump, called "time multiplier". The higher it is, the sooner ships will jump (if Smart Jump is activated). At 2, ships should always have the time to jump; at 1, it's pretty even. NPC uses a value of 1.5.
- All ships should now be able to resume their task after a jump. If you notice that isn't the case, please let me know.
- Ships can now wait for the engineer to repair after a jump (at least 90% shield and 75% hull).
- Jump delay is now based on both Defense Officer and Captain's navigation skill (50% each).
- Emergency Jump checks are now done more frequently, let me know if you have performance issues because of that.
- Updated default values for new users.
- Fixed Defense Officer staying in fight mode after a jump when it shouldn't.
- Fixed bad handling of sectors that don't have a beacon.

0.05
- Fixed emergency jumps no longer registering in the logbook.
- Fixed ships in player's squad not stopping their actions after an emergency jump.
- Minor modification to logbook messages.

0.04
- Added a configuration menu under "Informations" (side bar). It will be extended in the future.
- Fixed double jump occurring when an emergency jump started during a normal jump.
- Fixed division by zero occurring when an enemy didn't have any weapon.

0.03
- Removed a dependency that wasn't used yet and prevented the mod from loading if it was missing.

0.02
- Ships are now able to jump to other sectors. Only adjacent sectors are eligible. Sector is chosen randomly (for now).
- Ships are now able to jump if their commander is a station.
- Fixed Smart Jump, ships should now check enemies DPS before jumping, so that they won't jump if they still have a good amount of hull and only one fighter is passing nearby.
- Fixed jumpdrive check (exists, operational, cooldown)
- Lowered hull threshold (75% -> 70%) due to popular demand.

0.01
- \o/
Last edited by bm01 on Sat, 23. Jan 16, 00:10, edited 161 times in total.

User avatar
YorrickVander
Posts: 2672
Joined: Tue, 29. Oct 13, 22:59
x4

Post by YorrickVander » Sat, 27. Sep 14, 22:38

Sweet idea :) We need some I in the AI
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Vim Razz
Posts: 1837
Joined: Tue, 2. Nov 10, 03:20
x4

Post by Vim Razz » Sat, 27. Sep 14, 23:42

Very cool, and I like the idea of having jump time based on the Def Officer's nav skill. It forces you to consider the trade-off between their primary and secondary abilities.

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Sun, 28. Sep 14, 21:23

Vim Razz wrote:Very cool, and I like the idea of having jump time based on the Def Officer's nav skill. It forces you to consider the trade-off between their primary and secondary abilities.
Well that was because my script was called by the defense officer and not the captain (took me a few hours to understand that), but I kept it that way (especially because otherwise I would have to modify many "move." scripts I think). I could use any crew / skill though.

Also, it's not really important but since it's the defense officer who's doing the jump, the ship should continue to move* for a few seconds, while still shooting with all its weapons. Only target acquisition is stopped (which is pretty much what the defense officer only does).

*Fight pattern for ships that were on patrol.
*Traders will keep their random movement or continue in the same direction while seeking for new trade, docking or undocking, etc.
*Capital ship escorting another ship that just fled should try to fight if I'm understanding this correctly but it's possible that they try to jump to it. Haven't tested that yet, but it would be a vanilla behavior anyway.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 7519
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Mon, 29. Sep 14, 09:18

Looks good :thumb_up: :) :thumb_up:

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Mon, 29. Sep 14, 11:13

I'm currently trying to find a way to let players configure the shield and hull threshold (+ the use of smart jump).

Originally I thought it would be nice to have those parameters in the ship details window, but I have absolutely no idea how to deal with *.xpl files and it wouldn't be convenient anyway, too much clicking. Also, I would like to let default values configurable, for people who don't want to configure each ship.

So... I'll create my own window. I had a look at Multi Assignment and I'll try to achieve the same result (Sidebar Extender dependency), with a list of ship and each opening a sub-window allowing to configure thresholds and smart jump independently. On the main window though, will be default thresholds and smart jump. I'm still unsure about where the switch between default and independent values will be placed, but I'll find something.

I still need to find how I can access those values from my aiscript though. Might need some help (after all I don't know anything about cues yet, or even Lua :p).

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13926
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Mon, 29. Sep 14, 11:20

bm01 wrote:I still need to find how I can access those values from my aiscript though.
thats usually what global variables ( "global.$variablename" ) and Variables on the Entitys Blackboard ( "$entity.$variablename", "this.$variablename" ) are for, but no idea how to set them from the lua menus since i didnt use them yet (but they are the same for AI and MDscript ) - hope this helps
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 ;)

swatti
Posts: 1255
Joined: Sun, 7. Dec 03, 13:03
x4

Post by swatti » Mon, 29. Sep 14, 17:46

Not working in 2.5B - No-one is jumping anywhere when damaged.

EDIT: im fairly sure i dont have any mods that could conflict.

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Mon, 29. Sep 14, 17:59

It was made with 2.50 RC2. Make sure your ship has fuel cells and isn't in the same zone as the beacon. Also shooting a friendly (green) ship won't make it jump.

swatti
Posts: 1255
Joined: Sun, 7. Dec 03, 13:03
x4

Post by swatti » Mon, 29. Sep 14, 18:06

Aah, theres my problem... Its in the same zone as the beacon. That explains it.

EDIT: is there a way to improve on that? AKA: check for beacon in the zone, if one found, jump to any other.

bm01
Posts: 421
Joined: Wed, 22. Jul 09, 22:31
x4

Post by bm01 » Mon, 29. Sep 14, 18:12

Should be doable but I'd like to find a "lore friendly" solution, and ships aren't supposed to be able to jump to another system (like from Albion to DeVries for example, they have to pass through the gate).

I might make them able to jump near a gate though.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 7519
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Mon, 29. Sep 14, 18:27

I think it would be lore-friendly to jump to a beacon in a different sector within the same system. No need to change systems.

swatti
Posts: 1255
Joined: Sun, 7. Dec 03, 13:03
x4

Post by swatti » Mon, 29. Sep 14, 18:32

As long as they jump "out of trouble" im happy.

MINOR ISSUE & REQUEST: Vanilla engi repairs ships up to 75% so when my ships ARE at that 75%, they jump out as soon as they see too much nasties in radar, REGARDLESS of shields being 100% or not.

I'd imagine "checking for shields" is easier but i have a bigger request. Can you make a mini-mod for engineer to repair ships to 100%? Maybe a small standalone mod. I havent found anyone willing to do this.

User avatar
YorrickVander
Posts: 2672
Joined: Tue, 29. Oct 13, 22:59
x4

Post by YorrickVander » Mon, 29. Sep 14, 18:35

Just an idea, but you could also set a random point out of the static zone, say 45km away (ie out of radar of attacking station/capship) where the ai can start repairs and perhaps re-evaluate a full jump away from the action, or head back to previous location.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Phipsz
Posts: 245
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Mon, 29. Sep 14, 19:46

bm01 wrote:I'm currently trying to find a way to let players configure the shield and hull threshold (+ the use of smart jump).

Originally I thought it would be nice to have those parameters in the ship details window, but I have absolutely no idea how to deal with *.xpl files and it wouldn't be convenient anyway, too much clicking. Also, I would like to let default values configurable, for people who don't want to configure each ship.

So... I'll create my own window. I had a look at Multi Assignment and I'll try to achieve the same result (Sidebar Extender dependency), with a list of ship and each opening a sub-window allowing to configure thresholds and smart jump independently. On the main window though, will be default thresholds and smart jump. I'm still unsure about where the switch between default and independent values will be placed, but I'll find something.

I still need to find how I can access those values from my aiscript though. Might need some help (after all I don't know anything about cues yet, or even Lua :p).
I might help understanding the MultiAssignment, if you're interested. And if you have questions on how to implement your menu I can try to help, if I know where your problem is. By now I've been fiddling around with some more complex lua already than in MultiAssignment

Post Reply

Return to “X Rebirth - Scripts and Modding”