Help moving ship to position

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

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

thomasbkdk
Posts: 180
Joined: Wed, 8. Jan 20, 07:34
x4

Help moving ship to position

Post by thomasbkdk »

I'm trying to move a ship to a destination relative to a current position.
As an example 15km added to player.ship.position on z axis.

I use the MoveWait order, but the order is sending the ship to somewhere most unexpected in the sector.
I get the impression that the position feed to the movewait order isn't correct or is handled how i would expect.

Can anyone give me hand in how i accomplish this?

EDIT:
So i managed to figure out to use this instead (relative position)
<set_value name="$PlayershipCurrentPos" exact="player.ship.relativeposition.{player.sector}"/>
However it does not give me a movement forward in the ship that i would like.
So i need to still ask, how do i make the ship move relative to it's own current orientation?

Code: Select all

<do_if value="event.param == 'ShipOrderTest'"  >    <!-- test order -->

					<cancel_all_orders object="player.ship"/>
					
					<!--<create_position name="$PlayershipCurrentPos" space="player.sector" x="player.ship.position.x" y="player.ship.position.y" z="player.ship.position.z"/>-->
					<set_value name="$PlayershipCurrentPos" exact="player.ship.position"/>
					<create_position name="$PlayershipMoveToPos1" space="player.ship" x="$PlayershipCurrentPos.x" y="$PlayershipCurrentPos.y" z="$PlayershipCurrentPos.z + 10km"/>
					<create_position name="$PlayershipMoveToPos2" space="player.ship" x="$PlayershipMoveToPos1.x" y="$PlayershipMoveToPos1.y" z="$PlayershipMoveToPos1.z + 15km"/>

					<create_order id="'MoveWait'" object="player.ship"  immediate="true" >
						<param name="destination" value="[player.sector, $PlayershipMoveToPos1]"/>
                        			<param name="noboost" value="true"/>
                        
                    			</create_order>
					
					<create_order id="'AttackInRange'" object="player.ship">
					  <param name="destination" value="[player.sector, $PlayershipMoveToPos2]"/>
					  <param name="radius" value="30km"/>
					  <param name="pursuetargets" value="false" />
					</create_order>

					<show_help custom="'Yes Commander, initiating'
					+ ' player sector  ' + player.sector
					+ ' ship velocity ' + player.ship.velocity
					+ ' player ship position  ' + player.ship.position
					+ ' player ship position xyz ' + player.ship.position.x + ' ' + player.ship.position.y + ' ' + player.ship.position.z
					+ ' CurrentPos  ' + $PlayershipCurrentPos
					+ ' CurrentPos xyz ' + $PlayershipCurrentPos.x + ' ' + $PlayershipCurrentPos.y + ' ' + $PlayershipCurrentPos.z
					+ ' MoveToPos1 xyz  ' + $PlayershipMoveToPos1.x + ' ' + $PlayershipMoveToPos1.y + ' ' + $PlayershipMoveToPos1.z
					+ ' MoveToPos1  ' + $PlayershipMoveToPos1
					+ ' MoveToPos2  ' + $PlayershipMoveToPos2
					" log="false" position="1" force="true" duration="5s" allowclose="0" comment="order response" />
					
			</do_if>
AMD 3700X|GSKILL 2x32GB 3600C17|MSI X570 UNIFY|MSI RX 6800|SAMSUNG NVME 990 PRO|RAZER TARTARUS PRO|AOC AGON AG273QX 2560x1440@165|STREAM DECK XL+PEDAL|CORSAIR K95 PLATINUM RGB
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13486
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Help moving ship to position

Post by euclid »

Maybe I miss your point but I'd use move_to command (which works fine in the AutoMiner script) rather than create_order without any move command.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Return to “X4: Foundations - Scripts and Modding”