I tried several code changes to both move.generic and move.gate in aiscripts but after days (!) cleaning the code to have no error, I always get massive lag and not working.
The move file in X4 are very bloated with conditions and a real pain to change (Rebirth's files are leaner).
So a workaround solution I came up with is making a mission script that simply acts as "god" on top of ai scripts. Every some time (a long check interval) it looks for ships having a long route and a destination that is, say, at least 3 sectors far away, and warp them closer to destination. I'd like to add various conditions of course and the blacklist, not critical state, not fighting, so on. I totally give up the idea of making AI ships use the portal as the player (it'd be nice thou). So also a differentiation between player's subordinates and other ships is needed.
First, the condition to have jumpdrive installed. I added it with success in the move.autopilot but it generates errors every time in md file if for subordinates.
This is the code that works fine for player's ship, in both aiscripts and md:
Code: Select all
<do_if value="(player.ship.isclass.[class.ship_l, class.ship_xl] and player.ship.software.installed.{ware.xrsge_software_jump_l}.exists) or (player.ship.isclass.[class.ship_xl] and player.ship.software.installed.{ware.xrsge_software_jump_xl}.exists) or (player.ship.isclass.[class.ship_s, class.ship_m] and player.ship.software.installed.{ware.xrsge_software_jump_s}.exists)">
Tried in the check conditions:
Code: Select all
<check_any>
<check_value value="player.ship.subordinates.{ware.xrsge_software_jump_s}.exists"/>
<check_value value="player.ship.subordinates.{ware.xrsge_software_jump_l}.exists"/>
<check_value value="player.ship.subordinates.{ware.xrsge_software_jump_xl}.exists"/>
</check_any>
Or tried adding conditions afterwards as
Code: Select all
<do_all exact="player.ship.subordinates.count" counter="$i">
<do_if value="player.ship.subordinates.{$i}.parent.isclass.space and player.ship.subordinates.{$i}.order.state != orderstate.critical and player.ship.subordinates.{$i}.sector != player.sector">
<set_value name="$Subordinates" exact="player.ship.subordinates.{$i}"/>
<append_to_list name="$SubordinateList" exact="$Subordinates"/>
<do_for_each name="$SubordinateShip" in="$SubordinateList">
<do_if value="$SubordinateShip.{ware.xrsge_software_jump_s}.any.exists or $SubordinateShip.{ware.xrsge_software_jump_l}.any.exists or $SubordinateShip.{ware.xrsge_software_jump_xl}.any.exists">
<warp object="$SubordinateShip" zone="global.$JumpTarget" >
<safepos value="global.$JumpPosition"/>
</warp>
<add_effect object="player.ship.subordinates.{$i}" effect="'jump_jumpin_khaak'" />
<signal_cue_instantly cue="SquadClean" param="player.ship.subordinates.{$i}"/>
</do_if>
</do_for_each>
</do_if>
</do_all>
Also, how to find ships in the universe that have a particular custom software installed?
Using TAG? I added jumpdrive tag to the new software.
Tried this:
Code: Select all
<get_ware_definition result="$jumpdrives" tags="tag.jumpdrive"/>
<do_if value="player.ship.subordinates.{$i}.cargo.{$jumpdrives}.exists"> etc
Code: Select all
[=ERROR=] 108.73 Error in MD cue md.xrsge_npc_squad_jump.SquadWarp<inst:2199e6b>: Property lookup failed: player.ship.subordinates.{1}.cargo.[ware.xrsge_software_jump_s,ware.xrsge_software_jump_l,ware.xrsge_software_jump_xl]
* player.ship.subordinates.{1} == component.{0x11cf77L} (name='New Titan New Titan', class=ship_xl)
* Expression: player.ship.subordinates.{$i}.cargo.{$jumpdrives}.exists
btw, what is FLAG? (tag...flag

edit: found answer here, so is the tag for mesh only? I see it used as a tag in the scripts
https://wiki.egosoft.com:1337/X4%20Foun ... d%20flags/
I only used tag in the mesh file..
Any idea on a starting lean code to make the check for ai ships and warp them?
I am open to other ideas around this, maybe an even cheaper solution I did not come up with.
Thank you
