Naming objects created by md (specifically, beacons)

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

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

Post Reply
Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Naming objects created by md (specifically, beacons)

Post by Realspace » Thu, 25. Aug 22, 16:50

I am preparing the setup for removing all superhighways from my Galaxy Mod and having open extra large sectors, 500.000km wide
While travel mod can be used, navigating such a large space is impossible without coordinates.
My idea is to fill this huge space with things and having zones in specific spots. But without superhighways it is impossible to see them so far. So concluded that the best solution is to create nav beacons at the most important places (other than the center of a sector). I think I managed to do it but can't rename them. Indeed a nav beacon close to the planet should take the name of the planet, what currently my mod does for (multi)sectors.
I created a file called spawnbeacons.xml in md folder with this code as example for Nopileous:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<mdscript name="XRSGENavBeacons" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="Place_Nav_Beacons">
			<conditions>
				<event_player_created/>
			</conditions>
			<delay exact="10s"/>
			<actions>
				<!-- Nopileous -->
				<find_sector name="$sector" macro="sector04_cluster001_macro"/>
				<do_if value="$sector.exists">
				   <create_object name="$NavBeacon" macro="[macro.env_deco_nav_beacon_t1_macro].random" owner="faction.player" sector="$sector">
                <position x="400000000" y="1000" z="8000" />
				<identification name="{5120004,40011}" description="{5120004,40012}" />
					</create_object>
				</do_if>
				
			</actions>
		</cue>
	</cues>
</mdscript>
All ok but <identification name="{5120004,40011}" description="{5120004,40012}" /> is the part that is not working. The beacon appears but has not the name I referenced. Yes you can change it in the game, but I'd like to have it with a fixed name.
Also, any idea how to make the beacon NOT player-owned still visible by the player and somehow un-destructible?
Thanks!

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13296
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Naming objects created by md (specifically, beacons)

Post by euclid » Thu, 25. Aug 22, 18:32

Did you try faction.ownerless? For the name change I'd use set_object_name after create_object is closed. Concerning invulnerability the only way I know is to create a "new" beacon type and then add to the macro

Code: Select all

<properties>
      <hull invulnerable="1" />
</properties>
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

Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Naming objects created by md (specifically, beacons)

Post by Realspace » Thu, 25. Aug 22, 20:27

Thank you Euclid, it worked!
I added this line:
<set_object_name object="$NavBeacon" page="5120004" line="40011" comment="Nopileous alpha planet"/>
Now can refer to any text line I created...next step is using a different icon for the beacon, for instance a small planet icon. This simple trick adds much more to the map, an icon showing the planet that you can target.
Oc this has sense only when having very large sectors.
I tried setting to ownerless but of course this makes the icon invisible up to when you get close. My aim is having travel icons on the map that you can click from 500.000km to set a destination. Otherwise the zone close to the planet could be anywhere. Still I'd like to make them not player's but universal. Isn't there any command to make the object visible (already known by the player)?

p.s. I am experimenting with a 500.000 km wide sector, as told in the other post...it kinda works...but things get a bit strange. I placed a station at the edge, 400.000km east. When you target it or get there the map adjusts, otherwise it is outside of map (but can find it on object list)...but station stutters when you move close there or rotate camera, also fps go down. Seems like the engine calculates your position and has some jumps in rendering because of the distance the object is from the center...weird :gruebel:

Second, the map tends to resize back to its starting size of about 1000km :sceptic: I think this feature was introduced with one patch. But if we want large sectors somehow to work it is better that the map remains "stretched" otherwise it is impossible to target anything except things in the list

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13296
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Naming objects created by md (specifically, beacons)

Post by euclid » Thu, 25. Aug 22, 21:52

......... Isn't there any command to make the object visible (already known by the player)? .......
Yes, there is <set_known object="$NavBeacon" known="true"/> which you could add just after the set_object_name. And concerning problems in large sectors, I've mentioned that in another thread: The game engine has problems calculating distances/positions (unfortunately). If you ever find a solution please let me know and I may have another go on modelling the Solar system ;-)

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

Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Naming objects created by md (specifically, beacons)

Post by Realspace » Thu, 25. Aug 22, 22:17

euclid wrote:
Thu, 25. Aug 22, 21:52
......... Isn't there any command to make the object visible (already known by the player)? .......
Yes, there is <set_known object="$NavBeacon" known="true"/> which you could add just after the set_object_name. And concerning problems in large sectors, I've mentioned that in another thread: The game engine has problems calculating distances/positions (unfortunately). If you ever find a solution please let me know and I may have another go on modelling the Solar system ;-)

Cheers Euclid
I think I found the limit for decent calculations. I set 4 stations, at: 40.000, 80.000, 120.000, 180.000 and 400.000 kms
At 180 already flickering is unacceptable. At 120 it is noticeble. At 80.000 not an issue. I don't think it depends on the lights, I overcame all the issue of small sectors, meshes and light sources. It is more a stuttering than flickering, when you are close to the station. So this puts the ending stone, engine's limit: 80.000/100.000 kms, not bad anyway, better than the 4000kms of X3
My quest for huge sectors ends here... :(

p.s. you could make a sector so large to go all around at least one planet even a huge one but there is another limit that comes exactly the same as was in X3: sunlight always remains in front of the planet, no matter how distant you put it :|

Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Naming objects created by md (specifically, beacons)

Post by Realspace » Thu, 1. Sep 22, 11:00

Placing beacons as faction.ownerless and known to the player does not work for my aim.
They are known but INVISIBLE on map up to when you have them in the radar range, which is pointless

I need to place beacons even 30.000 kms out of the map and the only way to make them visible is making them owned by the player, but I don't like this solution. This little beacon is very important for how I am changing the sectors where some resources are 30/50.000 kms far away and there is no superhighway

I tried making them owned by the faction, does not work either.

This is the working code:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<mdscript name="XRSGENavBeacons" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="Place_Nav_Beacons">
			<conditions>
				<event_player_created/>
			</conditions>
			<delay exact="10s"/>
			<actions>

					<!-- grand exchange low orbit -->
				<find_sector name="$sector" macro="sector_01_cluster001_macro"/>
				<do_if value="$sector.exists">
				   <create_object name="$NavBeacon" macro="[macro.env_deco_nav_beacon_t1_macro].random" known="true" owner="faction.player" sector="$sector">
                <position x="-59200000" y="10000" z="-59600000" />
				 
					</create_object>
					<set_object_name object="$NavBeacon" page="5120004" line="20011" comment="(grand exchange alpha)"/>
					<set_known object="$NavBeacon" known="true"/>
				</do_if>
				
					<!-- trinity sanctum low orbit-->
				<find_sector name="$sector" macro="sector_47_cluster001_macro"/>
				<do_if value="$sector.exists">
				   <create_object name="$NavBeacon" macro="[macro.env_deco_nav_beacon_t1_macro].random" known="true" owner="faction.player" sector="$sector">
                 <position x="38620000" y="-50000" z="53635320" />
				 
					</create_object>
					<set_object_name object="$NavBeacon" page="5120004" line="470031" comment="(Trinity Sanctum VI alpha)"/>
					<set_known object="$NavBeacon" known="true"/>
				</do_if>
				
			</actions>
		</cue>
	</cues>
</mdscript>
Any other string I can use to make them always visible, or some similar solution? :?
Maybe another object instead, as a station belonging to a faction that is always visible?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13296
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Naming objects created by md (specifically, beacons)

Post by euclid » Thu, 1. Sep 22, 14:26

Again, I'm guessing here, but try set_object_radar_visible. It should also apply to the UI map.

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

User avatar
Moonrat
Posts: 1353
Joined: Sun, 20. Apr 08, 16:20
x4

Re: Naming objects created by md (specifically, beacons)

Post by Moonrat » Fri, 2. Sep 22, 21:58

Sorry if this seems like a shameless plug!! My mod "Encounters" creates named beacons that are visible to the radar... they are named and have faction ownership (usually the sector's owner which seems logical) but not always.
I create the object using one of three standard macros with a pre-calculated faction name, set the object name, and then adjust its hull value... the position is either a relative position in front of the player or tied to another object like a wreck or crate or something...

Here is the code, contact me if you need any further assistance.

Code: Select all

							<do_if value="$EncounterAnchorExists?">
								<create_object name="$EncounterSubObj" macro="$EncounterObjMacro" owner="if $EncounterAnchor.isclass.station then $EncounterAnchor.owner else $EncounterFactionList.random" sector="player.sector">
									<safepos object="$EncounterAnchor" min="[10m,$EncounterAnchor.size/3m].max" max="[20m,[$EncounterAnchor.size/2m,1km].min].max"/>
									<rotation pitch="$Pitch" yaw="$Yaw" roll="$Roll"/>
								</create_object>
								<set_value name="$EncounterProbeDistance" exact="($EncounterAnchor.distanceto.{$EncounterSubObj})i"/>
							</do_if>
							<do_else>
								<set_value name="$EncounterAnchor" exact="$EncounterObjMacro"/>
								<include_actions ref="EncounterSetWarpPosition"/>
								<create_object name="$EncounterSubObj" macro="$EncounterObjMacro" owner="$EncounterFactionList.random" sector="player.sector">
									<safepos object="player.ship" x="$X2" y="$Y2" z="$Z2"/>
									<rotation pitch="$Pitch" yaw="$Yaw" roll="$Roll"/>
								</create_object>
								<set_value name="$EncounterProbeDistance" exact="0"/>
							</do_else>
							<do_if value="$EncounterSubObj.isclass.navbeacon">
								<do_if value="$EncounterObjName?">
									<set_object_name object="$EncounterSubObj" name="$EncounterObjName"/>
								</do_if>
								<do_else>
									<include_actions ref="EncounterCreateName"/>
									<set_value name="$EncounterNameIndex" min="1" max="999"/>
									<set_object_name object="$EncounterSubObj" name="'Beacon ' + $EncounterNameType1 + $EncounterNameIndex"/>
								</do_else>
							</do_if>
							<set_object_hull object="$EncounterSubObj" min="[10 + stat.fight_rank + ($ProbeHullFactor)i,100].min" max="[30 + stat.fight_rank + (2 * $ProbeHullFactor)i,100].min"/>
[ external image ]
IEX Download Statistics - LUVi / XRMi ( 3115 / 5415 )
X4 Crexit 324 ; X4 Encounters 3193 (STEAM Unique/Current 6341/3412)

Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Naming objects created by md (specifically, beacons)

Post by Realspace » Mon, 5. Sep 22, 09:49

Thank you Moonrat! I'm going trying this code :)
Hope I don't need further assistance or will bother you in pm :mrgreen:

Sorry for the sily question, I am still learning..but defining <set_value name="$EncounterAnchor" exact="$EncounterObjMacro"/> instead of a beacon, links to an object you created in your mod or simply sets a new object already in this code?

Can I rename it as another object? What is the part that makes the beacon known and visible? The code I tried works, it places the beacon and renames it but only if is faction.player. Any idea how that part is not working with faction.xxx?

User avatar
Moonrat
Posts: 1353
Joined: Sun, 20. Apr 08, 16:20
x4

Re: Naming objects created by md (specifically, beacons)

Post by Moonrat » Fri, 9. Sep 22, 00:29

The first line is just to set up stuff I need to do later within my mod and shouldn't be required in your code. Sorry for any red herrings... in fact looking at the code now (which I wrote so long ago when I was still learning) I'm not sure why that line is there at all !! :lol: ( I think I need to see if I can remove it)

Code: Select all

    <set_value name="$EncounterAnchor" exact="$EncounterObjMacro"/>
    <include_actions ref="EncounterSetWarpPosition"/>
    <create_object name="$EncounterSubObj" macro="$EncounterObjMacro" owner="$EncounterFactionList.random" sector="player.sector">
         <safepos object="player.ship" x="$X2" y="$Y2" z="$Z2"/>
         <rotation pitch="$Pitch" yaw="$Yaw" roll="$Roll"/>
   </create_object>
You need to use the "owner=" within "create_object" to set an object's faction, for example...

Code: Select all

<create_object name="$EncounterAdSign" macro="$EncounterObjMacro" owner="player.sector.trueowner" sector="player.sector">
<create_object name="$EncounterAdSign" macro="$EncounterObjMacro" owner="faction.teladi" sector="player.sector">
I haven't had any issues with invisible satellites, nav-beacons etc. I have not had to do anything to make them visible on the radar ??
Have you looked in the x4 log file to see if there are any errors occurring?
[ external image ]
IEX Download Statistics - LUVi / XRMi ( 3115 / 5415 )
X4 Crexit 324 ; X4 Encounters 3193 (STEAM Unique/Current 6341/3412)

Realspace
Posts: 1374
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Naming objects created by md (specifically, beacons)

Post by Realspace » Fri, 9. Sep 22, 02:27

Yes it gives me error, not at start but in-game. It says "macro attribute is neither a macro nor a list of macros: null *Expression: cluster_47_sector001_macro
And so on for any beacon/sector.

This way of expressing location for a script works for spawn ships and stations (btw I am placing stations instead, in the far points).

Post Reply

Return to “X4: Foundations - Scripts and Modding”