[HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

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

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

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Sun, 2. May 21, 19:03

schmollo wrote:
Sun, 2. May 21, 18:29
... SNIPPED ...is it right that it compares the syntax with the xsd files from Egosoft and shows errors? That would be an added value compared to Notepad++.
no. I'm sure there's a way to link the code to the definition files (XSDs). But I don't know how. You know that you can change your code and reload them in-game, right? By typing "/refreshmd" on the chat window. It won't work with new XMLs. But it reloads all the XMLs that already exist.
And the "reg-ex" search, does it search all Egosoft files? Because I don't know exactly what you mean by Egosoft's base code. Where is it? The common.xsd? Or the many files in the original MD folder? I have looked there, but it is very tedious and I have not found much...
Here's my Sublime Text X4 Project setup-up. And I find the reg-ex search results to be very informative in regards to how to use the functions found in the XSDs. look at the example of a search result that I posted in my previous reply.
Spoiler
Show
Image
For example, I'm desperately looking for the code for switching on a target directly ahead. This is so unreliable, surely it can be improved (and extend, why not switch on a destination that is known, even if it is far away, a gate for example)...
The targeting code that determines what is targeted is actually hard-coded and is not available to us modders. But you should be able to create a mod with your own key that determines what in front of the player is targeted. Just make sure the old target commands in the Settings is not bound to this new key. (I just released a mod, Surface Element Targeting, that goes about targeting the nearest surface element to the player but without the use of key commands (because that is hard coded). Instead, that mod targets the next nearest surface element AFTER the last one is destroyed. So ... that mod addresses the problem of needing to loop through all surface elements just to get to the surface element that you can target by solving it indirectly. That mod solves that problem by using code that is available to us: find nearest object, after destruction event.)
About the questions:1. thanks, sure, I could have thought of that myself, a pre-loop to sort out.... Damn :-) So there's no way to narrow it down already in the "find_..." command....
Maybe. I don't know how. Sometimes, there's no direct way of doing something, and doing it another way that works is never the wrong way because it works.
2 All right, great, I'll try it out. Just one question of understanding: Why does it say in the code "class, station" again, if I only need the concrete gates? Is that a definition of some kind? And: I use "player.sector" for the targets, which is the sector, i.e. everything you can fly to without gates, right? Is there any reason to do something different?
you can add all that you want to find in the list so that they are ordered by distance. if you search for them separately, then they won't be ordered by distance. i thought you wanted the gates to be ordered by distance along with the stations. if not, then do a separate find for the gates.
3 Exactly, only simpler. It's not about automation but about hotkeys. If I press, then it should find the next enemy missile that has me as a target. Better still an array (list) with something like "find_", then I can switch through that. Only: what are enemy missiles? objects with their own class?
Ahhh ... then you'll need to do a search ordered by distance, then do a loop to remove the currently targeted missile - similar to filtering out unknown stations. AFTER removing the currently targeted missile, the first missile in the search result must be the next nearest, right?
As always, thank you very much! Best regards for Sunday Schmollo
You're welcome. And it's Monday morning here. I'm in Sydney, always about 12 hours ahead.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Sun, 2. May 21, 19:59

Thank you very much!

The picture is not displayed, but there is no hurry, today I will continue with notepad++, there is even a way to match the syntax with the md.xsd, I am thrilled :-)
kuertee wrote:
Sun, 2. May 21, 19:03
The targeting code that determines what is targeted is actually hard-coded and is not available to us modders. But you should be able to create a mod with your own key that determines what in front of the player is targeted.
...
Yes, I have already looked at and analysed your mod. That was already helpful. But the challenge with "target ahead" is different. Because the current target capture is indeed not working well. It should specifically "capture" the target under the middle cursor according to my wish, so I guess I have to deal with 3d vectors. But that will have to wait. "Quick and dirty" would be to simply simulate a mouse click in the middle, which is how I currently do it with my HOTAS button :-)
Just one question of understanding: Why does it say in the code "class, station" again, if I only need the concrete gates?
you can add all that you want to find in the list so that they are ordered by distance.
...
That was a misunderstanding. I only need the gates for this hotkey. The stations are another. Nevertheless, the question with class="[class, station, class.highwayentrygate, class.gate]": why do I need the entry "class" at the beginning? Wouldn't "class.highwayentrygate, class.gate" be sufficient? Or is that some syntax rule that the umbrella term has to be at the beginning? Or could I just leave it out? I am trying to understand this.
Ahhh ... then you'll need to do a search ordered by distance, then do a loop to remove the currently targeted missile - similar to filtering out unknown stations. AFTER removing the currently targeted missile, the first missile in the search result must be the next nearest, right?
Sure, that's clear. Only: How do I search for rockets in the first place. I have not found a "find_missile" command. Do I have to use "find_object"? And what kind of class is that then? I have not been able to find that out yet...
And it's Monday morning here. I'm in Sydney, always about 12 hours ahead.
Ok, here in Leipzig / Germany it's almost 8 o'clock in the evening. Best regards to Sidney :-)

That reminds me: If you need German translations somewhere, I'll be happy to help... Just let me know and send me a t-file / content.xml. e-mail if necessary via PN (is easiest without webspace)...

Greetings Schmollo

PS (EDIT):
You know that you can change your code and reload them in-game, right? By typing "/refreshmd" on the chat window.
But sure, I have already built a keyboard macro :-) Without it, it would be very... boring with the waiting...
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Mon, 3. May 21, 03:29

schmollo wrote:
Sun, 2. May 21, 19:59
The picture is not displayed, but there is no hurry, today I will continue with notepad++, there is even a way to match the syntax with the md.xsd, I am thrilled :-)
sorry. try this direct link: https://lh6.googleusercontent.com/yrwT9 ... 20-h880-rw
... That was a misunderstanding. I only need the gates for this hotkey. The stations are another. Nevertheless, the question with class="[class, station, class.highwayentrygate, class.gate]": why do I need the entry "class" at the beginning? Wouldn't "class.highwayentrygate, class.gate" be sufficient? Or is that some syntax rule ...
nah, it was an error from me. it's suppose to be class.station. but, nevermind, because you don't need it.
... How do I search for rockets in the first place. I have not found a "find_missile" command. Do I have to use "find_object"? And what kind of class is that then? I have not been able to find that out yet...
maybe ... class.bullet with find_object. search for "classlookup" in the XSDs for other classes.
... That reminds me: If you need German translations somewhere, I'll be happy to help... Just let me know and send me a t-file / content.xml. ...
Oh, Thank you! I will keep that in mind.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Mon, 3. May 21, 03:47

Ok, after a hard fight, everything is now going well for a start. I have hotkeys for the next enemy (which will be supplemented by missiles later), the next own ship, the next factory and the next gate. also a forward and backward key that switches through the respective target types depending on the "mode".... Fine. However, it looks like I'd want to swap Egosoft's forward-backward buttons for my own entirely....
That's why there's a 5th mode with no filter (so it allows everything in the vicinity), which is activated, for example, when you press the forward and back hotkeys with no active target. So it's like Egosoft.This mode should always become active when I have changed or deselected the target with the mouse or an Egosoft key function.
It seemed to me that "<event_player_changed_target/>" would be suitable for this, and I saw that you have also made your experiences with it. Is it possible that this event is somehow unreliable? Or am I missing something? Or are global variables written with maybe delay, which messes everything up?
I use a global variable ("global.$mhkchangetarget") that is always set (=true) by my own target switch before the Lua event to flag my own action - unlike mouse actions or those of egosoft. The event (target change) should both set the targeting mode to 0 and reset the flag ("global.$mhkchangetarget")... But it does not work. Sometimes it works briefly, then not again... What am I doing wrong?
Here is the code of this event:

Code: Select all

    <cue name="Mhk_TargetChangeBaseGame" instantiate="true">
      <conditions>
        <event_player_changed_target/>
      </conditions>
      <actions>
		<do_if value="global.$mhkchangetarget">
			<set_value name="global.$mhkchangetarget" exact="false" />
		</do_if>
		<do_else>
			<set_value name="global.$targetingmode" exact="null" />
		</do_else>
      </actions>
    </cue>
Thanks for any answers... again... :-)

Greetings Schmollo
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Mon, 3. May 21, 04:17

schmollo wrote:
Mon, 3. May 21, 03:47
...It seemed to me that "<event_player_changed_target/>" would be suitable for this, and I saw that you have also made your experiences with it. Is it possible that this event is somehow unreliable? Or am I missing something?
i found this event to work ok.
Or are global variables written with maybe delay, which messes everything up?
i don't know. but I don't think so.
I use a global variable ("global.$mhkchangetarget") that is always set (=true) by my own target switch before the Lua event to flag my own action - unlike mouse actions or those of egosoft. The event (target change) should both set the targeting mode to 0 and reset the flag ("global.$mhkchangetarget")... But it does not work. Sometimes it works briefly, then not again... What am I doing wrong?
hmmm ... i don't know again. sorry. but did you know that in Lua, false != 0? and true != 1? but in MD, when you set a variable to true it's set to 1 internally? try setting your var to 1 instead.
Here is the code of this event:
this code looks ok.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Mon, 3. May 21, 21:37

Hi, thanks as always :-)

I was obviously a bit blind with the missiles, there is indeed a class class.missile, you can certainly do something with it. The hint with "classlookup" was worth its weight in gold and also helps with other things!

Unfortunately, the image still can't be opened, error 403 - but as I said, that's not a priority for now.

The hint with Lua is interesting, especially as I want to do more there, including special menu calls via hotkey and, for example, opening the map with the player ship selected immediately. I will also need some help with Lua, do you know it well? But one thing at a time...

And as for my event_player_changed_target problem, I'll probably have to work my way into debugging, then I'm sure I'll get onto the track of it somehow. The behaviour is just strange because it's unreliable. Sometimes it works, sometimes not...
Just as an idea: was the event also triggered reliably when you changed the target with your own Lua routine ("C.SetSofttarget")? And how did you distinguish this triggering from other changes (e.g. via mouse)?

Finally, I need two tips from you on MODs in which you (a) started a waypoint mission (i.e. not softtarget but the yellow marker on the screen, which can also be used for navigation across sectors) and b) made a menu entry with sub-entries somewhere in the context menu for an object on the map... In one of the next steps, I want to define favourites that can then be activated as waypoint missions at the push of a button... Gladly with the hint where in the code I can find this or which command I have to search for...

Thanks for all the help... Think I'll upload an alpha version for download in a week or two....

Best regards Schmollo

Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Tue, 4. May 21, 01:34

UPDATE

HA! Who knows that "event_player_changed_target" is called twice when switching to a new target, once for deleting and once for the new target? Of course it doesn't work like that with the "flagging", I have limited it to only "zero", now it works!

Greetings
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Tue, 4. May 21, 03:11

schmollo wrote:
Mon, 3. May 21, 21:37
Unfortunately, the image still can't be opened, error 403 - but as I said, that's not a priority for now.
seems like Google restricts access to images on Drive - requiring the link to be its sharing link, and not the actual image URL. Try this: https://drive.google.com/file/d/19cfqsG ... sp=sharing
Finally, I need two tips from you on MODs in which you (a) started a waypoint mission (i.e. not softtarget but the yellow marker on the screen, which can also be used for navigation across sectors)
The orange HUD markers are guides and are created by adding the objects as mission targets of an objective with <create_mission />. Search for <create_mission /> in my Surface Element Targeting mod.
and b) made a menu entry with sub-entries somewhere in the context menu for an object on the map... In one of the next steps, I want to define favourites that can then be activated as waypoint missions at the push of a button... Gladly with the hint where in the code I can find this or which command I have to search for...
We need SirNuke's Support Mod API for this. This is called adding a menu entry to the Interact Menu. Look at the "InteractMenu_Add" and "InteractMenu_Action" of my Surface Element Targeting mod. I add the "Find: X" menu entry to the targeted surface element's Interact Menu.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Tue, 4. May 21, 03:27

Ok, thank you very much. Now the picture works. And the tips are great! I'll find out everything myself, I hope.

Unexpectedly I have a new, hopefully very small problem. I want to switch off the target with a hotkey, as if I would click with the mouse into an empty corner of the picture. For this I have called the Lua routine (c.setsofttarget) with "null", with "0", with "1" and with "" instead of with an object. Unfortunately, the target is not deleted. Is there perhaps another, direct command?

Or differently: I have just searched all .lua files in the game folder for "c.setsofttarget" - but without success.Softtarget" appears a few times, but I can't figure it out. Where did you get this command? Maybe I can find something equivalent nearby?

Thank you very much...

Greetings Schmollo



Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Tue, 4. May 21, 04:17

schmollo wrote:
Tue, 4. May 21, 03:27
Unexpectedly I have a new, hopefully very small problem. I want to switch off the target with a hotkey, as if I would click with the mouse into an empty corner of the picture. For this I have called the Lua routine (c.setsofttarget) with "null", with "0", with "1" and with "" instead of with an object. Unfortunately, the target is not deleted. Is there perhaps another, direct command?
hmmm ... i don't know, actually. I'm surprised that didn't work. Maybe search for "cancel.*softtarget" or "remove.*softtarget". I really don't know.
Or differently: I have just searched all .lua files in the game folder for "c.setsofttarget" - but without success.Softtarget" appears a few times, but I can't figure it out. Where did you get this command? Maybe I can find something equivalent nearby?
I found it just by doing a search. Several commands were returned in the result. And "Softtarget" was what worked. It's not documented anywhere. None of X4's API at the Lua level is documented. You'll just have to do a reg-ex search and look at the context of the search results. I found this command about this time last year.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Tue, 4. May 21, 05:14

Very cool! Forleyor knew what to do. I had already found "removeSofttarget" in the Lua files earlier, but it didn't work. Apparently that was the call, because the command was correct. In Lua it must look like this (in case you ever need it):

Code: Select all

function mhk_menu.removeTarget(_, event)
    if event == "onPress" then
		RemoveSofttarget()
    end
end
And this is the call:

Code: Select all

    <cue name="Mhk_NoTarget" instantiate="true" namespace="this">
      <conditions>
        <event_cue_signalled/>
      </conditions>
      <actions>
	     <raise_lua_event name="'MoreHotkeys.removeTarget'" param="event.param.$event"/>
      </actions>
    </cue>
Once again, I am thrilled by the cool community here. It's really fun and it's going well! Just 2 weeks ago I wouldn't have thought it was possible to do something like this...

Greetings, I have to go to sleep now. Have a nice day.

Trajan from Olb
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Fri, 7. May 21, 02:55

Hi, things are progressing and there are more and more hotkeys (you don't have to use them all).
Currently, however, I have two questions:

1. I want to search for incoming missiles. This already works, but I would like to check whether the missiles are really aimed at the player ship... How do I do that? What do I have to add to the following code?

Code: Select all

		<find_ship name="$things" class="[class.missile, class.mine]" space="player.sector" multiple="true" sortbydistanceto="player.entity">
			<match owner="faction.player" negate="true"/>
			<!-- <match_attention min="attention.visible"/> -->
		</find_ship>
        <set_value name="$thing" exact="null" />
		<do_all counter="$i" exact="$things.count">
			<do_if value="$things.{$i}.isknown and $things.{$i}.ishostileto.{faction.player}">
				<set_value name="$thing" exact="$things.{$i}" />
				<break />
			</do_if>
		</do_all>
I would like to search for the next own ship on which I can land with my current ship. To do this, I probably need to match my own ship size with the landing pads on the target ship. That must exist, because when landing, it is also compared somehow. But how do I do that? Any idea? I don't know what to look for at all... Here is the actual code, what do I have to set?

Code: Select all

		<find_ship_by_true_owner name="$things" faction="faction.player" class="[class.ship_s, class.ship_m, class.ship_l, class.ship_xl]" space="player.sector" multiple="true" sortbydistanceto="player.entity">
			<match owner="faction.player" negate="false"/>
		</find_ship_by_true_owner>
        <set_value name="$thing" exact="null" />
		<do_all counter="$i" exact="$things.count">
			<do_if value="$things.{$i} != player.ship">
				<set_value name="$thing" exact="$things.{$i}" />
				<break />
			</do_if>
		</do_all>
Many thanks for answers...

Greetings Schmollo aka Trajan from Olb



Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Fri, 7. May 21, 03:54

schmollo wrote:
Fri, 7. May 21, 02:55
1. ... I would like to check whether the missiles are really aimed at the player ship... How do I do that? ...
Hmmm. i don't know, sorry. Have you checked scriptproperties.xml if that object/component can have a "target" property?
I would like to search for the next own ship on which I can land with my current ship. To do this, I probably need to match my own ship size with the landing pads on the target ship.
You can use this match on any of the find functions: <match_dock size="$shipDockSize" free="true" />
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Sat, 8. May 21, 04:35

Hey Kuertee, thanks again!

Somehow I have only now really understood the meaning of the scriptproperties.xml, until now I thought everything was also in the common.xsd...

And also the hint with the "match" was great, because it helped me to find other such "matches", e.g. "match_is_in_view_of", which makes it possible for my new targeting to find a distant target super precisely, if it is only exactly under the cursor (you can specify the angle)... This solves another problem I thought I would have to fiddle with vectors. Should be a nice tool for those who not only like more hotkeys but also disagree with the imprecise targeting of Ego...

Greetings Trajan

Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Sat, 15. May 21, 00:40

Hi,

After a short break, things are progressing well. There is now a really well-functioning "line-of-sight" search that replaces the one from Egosoft. With it, you can also precisely aim at distant targets if you know them or if they are large. If necessary, several searches are carried out in which the search radius is always extended slightly if no target was found before. This way you always get exactly the target under the cursor, but if there is nothing there, then also more distant targets up to a search angle of 25 degrees. In addition, the switching on of missiles, enemies, capital ships, fighters, own things, astros, collectibles, gates, stations and even a nearby own ship for landing....
Plus, as a bonus, a teleport hotkey to the target (if allowed) and a laser point scanner to scan distant factories if you aim accurately.... But I might outsource both to another mod, also because I'd like to combine that with a commodity (long range scanner Mk3). Betty is also more talkative now, but that will also be a different MOD.

But now I'm cutting my teeth a bit on the subcomponents, it's not that easy. The kSET mod from you, Kuertee, helps only partially because it is a different approach. I don't want to define variables for it, but always associate everything from the current target.

A few questions about this:

1. if I read a subcomponent from the "player.target", how do I get the associated ship out (to find the next component of the ship, for example)? Haven't found anything on this... EDIT: I've figured it out in the meantime: ".parent" :-)

2. is there another way than find_object_component to find subcomponents? I tried it with find_object and added e.g. class.turret to the search, but that doesn't work. This is about adding subcomponents directly under the cursor, i.e. extending the "line-of-sight" search with subcomponents, which does not work yet...

3. do only wards, L and XL ships really have sub-components? You can also build turrets on an M... But I can't find them with the Egosoft search either...

4. in your mod, Kuertee, there is the line: "<find_object_component groupname="$surfaceElements" object="$lastDefensibleTarget" operational="true" surfaceelement="true" multiple="true">". However, an auto-check with common.xsd and scriptproperties says this is wrong, operational="true" is supposedly not supported there. You might also be able to check it with a do-loop, but I don't know which is better. The way you do it is more elegant, but does it work properly?

5th (slightly different topic): If I add a commodity, e.g. to make advanced target functions (missile unlocking e.g.) dependent on expensive software, then this is no longer save-compatible, or is such a commodity simply ignored when the MOD is deleted again? Is there any way to do this anyway and remain safegame compatible?

6. is there somewhere a good tutorial (written, video translate is very exhausting for me), where the cues etc. is well explained? How do I nest them? Where does the programme jump to when I call cancel_cue? What does "this" or "parent" mean? How do I share variables elegantly in a common namespace, at the moment I do everything via global.xxx, which is perhaps not so clean... Way too many questions to answer directly, therefore tutorial, I need a crash course :-)

As always, thanks for the answers...

Best regards

Schmollo aka Trajan von Olb.

Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by kuertee » Sat, 15. May 21, 11:42

schmollo wrote:
Sat, 15. May 21, 00:40
2. is there another way than find_object_component to find subcomponents? I tried it with find_object and added e.g. class.turret to the search, but that doesn't work. This is about adding subcomponents directly under the cursor, i.e. extending the "line-of-sight" search with subcomponents, which does not work yet...
Hmmm ... i don't know. If I have my assumptions correct, can't you get the ship or station under the cursor, find all their surface elements, then assume that the nearest one (i.e. $surfaceElement.distanceto.{player.entity}) to the player would be under the cursor.
3. do only wards, L and XL ships really have sub-components? You can also build turrets on an M... But I can't find them with the Egosoft search either...
nah, turrets on M ships should be findable. if <find_object_component /> is empty try: $ship.turrets
4. in your mod, Kuertee, there is the line: "<find_object_component groupname="$surfaceElements" object="$lastDefensibleTarget" operational="true" surfaceelement="true" multiple="true">". However, an auto-check with common.xsd and scriptproperties says this is wrong, operational="true" is supposedly not supported there. You might also be able to check it with a do-loop, but I don't know which is better. The way you do it is more elegant, but does it work properly?
it likely doesn't. the compiler didn't complain. but I do find that mod not targeting the next surface element. and on investigation, I found that its because the next surface element wasn't yet operational. so, I tried adding the "operational" parameter - which didn't work, because I'm still finding that mod not going to the next surface element.
5th (slightly different topic): If I add a commodity, e.g. to make advanced target functions (missile unlocking e.g.) dependent on expensive software, then this is no longer save-compatible, or is such a commodity simply ignored when the MOD is deleted again? Is there any way to do this anyway and remain safegame compatible?
sorry, I don't know. I've not attempted to add a new object type apart from new factions.
6. is there somewhere a good tutorial (written, video translate is very exhausting for me), where the cues etc. is well explained? How do I nest them? Where does the programme jump to when I call cancel_cue? What does "this" or "parent" mean? How do I share variables elegantly in a common namespace, at the moment I do everything via global.xxx, which is perhaps not so clean... Way too many questions to answer directly, therefore tutorial, I need a crash course :-)
unfortunately, no tutorial apart from X4's Wiki on the Mission Director.

All cues are actioned once only (except if it instantiates) - until they are reset. And all sub-cues are inactive (doesn't receive signals) until their parent cue is active or completed (i.e. actions in the parent cue have executed, but all its sub-cues are waiting for their signals). When a cue is reset it returns to its waiting state. All its subcues become disabled (and all variables and properties declared in the cue and its subcues are garbage collected).
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Trajan von Olb
Posts: 545
Joined: Wed, 4. Feb 04, 21:39
x3tc

Re: [HELP / REQUEST / PROJECT] improved target activation with SirNuke's hotkeys

Post by Trajan von Olb » Sat, 15. May 21, 22:12

Thanks as always, Kuertee!
kuertee wrote:
Sat, 15. May 21, 11:42
schmollo wrote:
Sat, 15. May 21, 00:40
2. is there another way than find_object_component to find subcomponents? I tried it with find_object and added e.g. class.turret to the search, but that doesn't work. This is about adding subcomponents directly under the cursor, i.e. extending the "line-of-sight" search with subcomponents, which does not work yet...
Hmmm ... i don't know. If I have my assumptions correct, can't you get the ship or station under the cursor, find all their surface elements, then assume that the nearest one (i.e. $surfaceElement.distanceto.{player.entity}) to the player would be under the cursor.
Unfortunately, this doesn't work so well for several reasons, because the next object is not automatically the line of sight, not even the next ship - for example, if I hide behind a thick ship, but then want to target the engines of another ship from there. It should also feel like a direct selection under the cursor, like a mouse click in the middle.
After some trial and error, it now works quite well with the line-of-sight component search. However, the larger cannons are somehow sometimes obscured by some clipping and thus difficult to find, which is exactly what happens when you have an oblique viewing angle.
I will therefore experiment with "find_object_surface" at some point in the future. If I'm right, then you can target any point on the surface in the line of sight, which results in a position. I would then define this as the search centre point and start a component search from there. This way, the object closest to the point of view should always be found, even if it is not directly in line of sight. But that's so much trial and error, and I don't yet know how to define the player's angle of view as the starting point, that I'll move it for now, otherwise the MOD will never be finished :-)
kuertee wrote:
Sat, 15. May 21, 11:42
3. do only wards, L and XL ships really have sub-components? You can also build turrets on an M... But I can't find them with the Egosoft search either...
nah, turrets on M ships should be findable. if <find_object_component /> is empty try: $ship.turrets
I'll try that. But I was sceptical because even the Egosoft targeting doesn't find any subcomponents at an M... But that would be an added value if I could do it... Great tip in any case!
kuertee wrote:
Sat, 15. May 21, 11:42
4. in your mod, Kuertee, there is the line: "<find_object_component groupname="$surfaceElements" object="$lastDefensibleTarget" operational="true" surfaceelement="true" multiple="true">". However, an auto-check with common.xsd and scriptproperties says this is wrong, operational="true" is supposedly not supported there. You might also be able to check it with a do-loop, but I don't know which is better. The way you do it is more elegant, but does it work properly?
it likely doesn't. the compiler didn't complain. but I do find that mod not targeting the next surface element. and on investigation, I found that its because the next surface element wasn't yet operational. so, I tried adding the "operational" parameter - which didn't work, because I'm still finding that mod not going to the next surface element.
Maybe I can be of help here for a change. I have found the following way to check whether a surface element is operating, which seems to work very well:

Code: Select all

			<do_if value="$ptargetparent">
				<find_object_component groupname="$things" object="$ptargetparent" surfaceelement="true" multiple="true" sortbydistanceto="player.entity">
				</find_object_component>
				<do_all counter="$i" exact="$things.count">
					<do_if value="$things.{$i}.issurfaceelement and $things.{$i}.isoperational">
						<add_to_group groupname="$knownThings" object="$things.{$i}" />
					</do_if>
				</do_all>
			</do_if>
kuertee wrote:
Sat, 15. May 21, 11:42
6. is there somewhere a good tutorial (written, video translate is very exhausting for me), where the cues etc. is well explained? How do I nest them? Where does the programme jump to when I call cancel_cue? What does "this" or "parent" mean? How do I share variables elegantly in a common namespace, at the moment I do everything via global.xxx, which is perhaps not so clean... Way too many questions to answer directly, therefore tutorial, I need a crash course :-)
unfortunately, no tutorial apart from X4's Wiki on the Mission Director.

All cues are actioned once only (except if it instantiates) - until they are reset. And all sub-cues are inactive (doesn't receive signals) until their parent cue is active or completed (i.e. actions in the parent cue have executed, but all its sub-cues are waiting for their signals). When a cue is reset it returns to its waiting state. All its subcues become disabled (and all variables and properties declared in the cue and its subcues are garbage collected).
Just so I understand this correctly: I can, for example, put the entire MOD in a cue, whereby the initialisation, e.g. the definition of hotkeys and variables, happens in the main cue. The individual functions (after pressing a key, for example) are then sub-cues. And instead of the "global.$var" variables, I can then use "parent.$var"? Or instead of "parent" the name of the main cue? Do I then always have to check the wait state before a cue is executed so that the initialisation is completed? A new initialisation is then carried out with "Reset", for example, right?
And what about the instances? Isn't there a danger when I instantiate that a new cue is opened each time while the old one is still in the wait state? Doesn't that clutter up the memory?
Last question: What happens (when I instantiate) when the last command of a cue is processed, does the cue then go into the wait state? And if it is then called again (directly or by a condition), does that happen in the waiting cue or is a new one opened? (This actually belongs to the previous thought)...

Thanks as always for answers! Super RESPECT for that and for your MODs, you are really busy :-)

Schmollo aka Trajan von Olb


Translated with www.DeepL.com/Translator (free version)
Mein Traum vom Glück ist der Traum von einer anderen Menschheit. (S. Lem)

Post Reply

Return to “X4: Foundations - Scripts and Modding”