Ship scanning ROM

A place to discuss mods in development and concepts for new mods.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

From Derakon's idea in this topic: https://forums.kronosaur.com/viewtopic.php?f=3&t=8525
Use a ROM to scan a ship and find out what it is equipped with.

I remember the Advanced Sensors mod as being really good (thanks for the link, sjf, I couldn't remember the mod name) and it still works. It uses 'objSendMessage' to show the weapon, shield and combat power of the ship that is currently targeted. See top left section of the attached image. But these messages do fade fairly quickly and can be shunted off the screen by other messages. And there is a limit of 4 lines.

The top right section of the image shows RPC's Speedometer mod from xelerus. It's a very clever mod. It uses a <StationType> to show the playership's speed.
Something like this could be used as the duration could be set but the text is fairly small. The station/device info text could be made to appear at a set point on the screen, say just above the playership, so the text shows without interfering with the HUDs and plyMessages. RPC's code can also make the text move with the playership rather than disappearing off the side of the screen.
The effect would need to be fairly limited anyway as this sort of thing can cause a lot of lag, so clutter won't be a problem.
I gave it a try and a very basic result can be seen in the bottom left of the image. The text is line-breaking at a certain width and I don't know how to format the text to stop this, if it's possible at all. This method shows the most promise. EDIT: the text appears to fit inside the width of the playership image so this may determine text width. If so another non-real station of wider width (transparent or something, not sure) could allow the text to be wider.

Using objSendMessage with the target ship as the source of the message works. See bottom right of image. But it seems there can be only one line of text. The messages don't stack 4 high like 'plyMessage's. Also the text can get mixed up and underneath stations if you are within visual range of the targeted ship, which looks messy. And there is no control of duration either. The example shown is ignoring "\n" as well unfortunately as I feel this would look much better if stacked.
I've attached a mod that uses this method, ROMSensorExample.xml (needs 1.8b1). 'U'se the Ship Scan ROM which has been added to the playership hold. It needs a ship to be targeted by the playership targeting ROM (also in the hold but not identified). The mod is based on FAD's Advanced Sensors mod.

Possibly a text-only overlay could be placed over a virtual station which stays directly above the playership. I suspect only one line of text could be shown at a time but 4 overlays placed correctly would allow a 'stack' of text. I don't know much about overlays though.

The ideal layout would seem to be something like:
Four lines of text stacked vertically above the playership but not covering it. Staying in the same spot relative to the playership as it moves is also desirable.This keeps the info out of the way of the HUDs and plyMessages.
The info could be ship name on line 1, then weapon name, shield name and armor name. More could be added, eg secondary weapon or max speed if the text size could be regulated to keep the whole display to a size which didn't overlap the HUDs or playership
Slightly larger text than the Speedo mod uses would be good but it doesn't need to be as large as the message text.
A slightly longer duration than used by standard messages would be good too.

Anyone got any other ideas or info on how to make it work?
ROMSensorExample.xml
(2.45 KiB) Downloaded 297 times
final image use.jpg
final image use.jpg (65 KiB) Viewed 14159 times
Stupid code. Do what I want, not what I typed in!
User avatar
DigaRW
Militia Captain
Militia Captain
Posts: 517
Joined: Thu Jul 30, 2015 3:10 pm
Location: The place where I belong
Contact:

Maybe, we could use ship interior dockscreen for analyze the ship target rather than sending long messages to player.
Download Transcendence mods from Reinvented Workbench Project!
Click this link!
User avatar
DigaRW
Militia Captain
Militia Captain
Posts: 517
Joined: Thu Jul 30, 2015 3:10 pm
Location: The place where I belong
Contact:

If you want to use objSendMessages, you should use addObjTimerEvent to delay messages. It may long code, but I think it should be works definitely.
You could make something like Smart Target Assistance.
Last edited by DigaRW on Wed Mar 21, 2018 1:30 pm, edited 1 time in total.
Download Transcendence mods from Reinvented Workbench Project!
Click this link!
User avatar
DigaRW
Militia Captain
Militia Captain
Posts: 517
Joined: Thu Jul 30, 2015 3:10 pm
Location: The place where I belong
Contact:

I has just made a device that analyze ship targets (Yeah!)
With OnUpdates events and data, it will send messages orderly. So every player targeting ship or station, it will describe armor, shield, and weapon without any problem.
Attachments
Untitled.jpg
Untitled.jpg (141.07 KiB) Viewed 14143 times
Smart Target Assistance.xml
(2.83 KiB) Downloaded 309 times
Download Transcendence mods from Reinvented Workbench Project!
Click this link!
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

Now you Knew you were going to wake the Dinosaur........However, I think you might have something there, Here are earlier pioneers into that area that you might find some trinkets to expand on or update.

"A revision of digdug's cool shield sensor mod."
http://xelerus.de/index.php?s=mod&id=78

"First example of code for a remote sensor."
http://xelerus.de/index.php?s=mod&id=43
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

The "Smart Target Assistance" is really good, DigaRW. You get enough time to read the info without it getting in the way. Nice.

I like your dockscreen idea as well. That would allow a lot more info to be shown.
If I can't get text to format how I like on the screen, I'll do a mod ROM that shows a dockscreen with class name, ship name, devices, speed and maybe a few more things (there is some really good new dockscreen stuff that I want to play around with as well).

And sjf, you are now officially the "Unofficial Xelerus Archivist", because you can always find the link while I'm sitting there thinking "Hmm, now what was the name of the mod that did that?".:lol:

The text width didn't vary in the speedometer based mod when 'plyChangeShip'ing to an Aquila. So there must be something else limiting it. Overlays now seem the easiest way to go.
Stupid code. Do what I want, not what I typed in!
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

relanat wrote:
Tue Mar 27, 2018 4:44 pm
The "Smart Target Assistance" is really good, DigaRW. You get enough time to read the info without it getting in the way. Nice.

I like your dockscreen idea as well. That would allow a lot more info to be shown.
If I can't get text to format how I like on the screen, I'll do a mod ROM that shows a dockscreen with class name, ship name, devices, speed and maybe a few more things (there is some really good new dockscreen stuff that I want to play around with as well).

And sjf, you are now officially the "Unofficial Xelerus Archivist", because you can always find the link while I'm sitting there thinking "Hmm, now what was the name of the mod that did that?".:lol:

The text width didn't vary in the speedometer based mod when 'plyChangeShip'ing to an Aquila. So there must be something else limiting it. Overlays now seem the easiest way to go.

Well, TY, TY, very much.. :)

I am a Huge Fan of the creativity of the community, it will not always fit into my game, but I love to at least keep up to speed on what is going on in their parts of the universe ( as much as I can, some things you guys do is way over my head ).
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Using overlays to show the device info shows real promise. The Nav Signs in SOTP use text inside of the effect code of an overlay.

Code: Select all

<OverlayType UNID="&ovNavSignText;"
            attributes=         "effect"
            >
	<Effect>
		<Text text="Nav Sign"
			font="SmallBold"
			primaryColor="0xc4, 0xdf, 0x9b"
			/>
	</Effect>
</OverlayType>
Using the LargeBold font gives a good text size and duration can be controlled by removing the overlays after a set time.

But I'm having trouble getting more than just text to display. Any method I've tried gives an error. Backslashes, 'cat'ing, Text ids in a Language block. Getting '= expected', 'must be quoted' and similar errors.
Having something like

Code: Select all

"Ship name: " (objGetName targetObj 0x100) \n
"Weapon: " (objGetWeapon (:lol:) targetObj) \n
"Shield : " etc, etc
"Armor: " etc,
as the text would work but how is it formatted?

If line breaking can't happen then 4 single-line overlays could be stacked but the variables still need to be inserted somehow.

Anyone know if this can happen and how to do it?
Attachments
ShipScanOverlayUse.JPG
ShipScanOverlayUse.JPG (45.49 KiB) Viewed 13990 times
Stupid code. Do what I want, not what I typed in!
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

The ' \n ' s need to be in quotes. If you still get the '= expected' error, it means there's an XML element that isn't correctly formatted. Are you trying to put the code to generate the text inside an XML attribute? That's tricky to format, especially when strings are involved, and should usually be avoided. If you look at stCommonwealthNavSign, it uses this code to set the text:

Code: Select all

(objSetOverlayEffectProperty gSource theID 'text signText)
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Ah, I might be able to make that work. It certainly makes more sense than what I was trying. I was looking at the Nav Signs, among other overlays, but had tried so many things that nothing made sense anymore. Not that I understood overlays to begin with.

I was trying to put the text and code into the <Text> XML of &ovNavSignText;. Thats where the XML and other errors were coming from. Either there or in an <InitialData> block.

But I couldn't work out if I needed to set the effect. I was looking for objSetOverlayEffect or something. But I think it is the attribute inside the overlay type.

It really didn't help that just about every overlay I looked at was completely different.

So use a station, objSetData the text from translating a Text id, then use objSetOverlayEffectProperty to set the text into the overlay. Hopefully the overlay will accept the output from the Text id code and if it won't line-break, multiple overlays can be used.

Thanks. I'll give that a try whenever theTaipan mod isn't sucking up all my free time.
Stupid code. Do what I want, not what I typed in!
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Success. Using 'objSetOverlayEffectProperty' made it (relatively) easy. Thanks, NMS. It was confusing initially until I realized the NavSigns get their text from outside of the NavSign type.

There are two ROMs and a mnemomic cube which scan devices up to level 4, 7 and 10 respectively.
Using a ROM/cube shows ship name, class name if different to ship name, weapon, launcher, shield and armor for any ship which is targeted by the playership. "...Too advanced..." shows if the device level is above the ROM scan level.
This info is an overlay on a StationType which is repositioned every tick by an event so it remains directly above the playership.
It shows for 300 ticks and if the ROM is used again the old overlay is removed and the new one shown.

PROBLEM:
'objDestroy' is giving me trouble again.

Code: Select all

04/18/2018 15:23:03	Crash in CSystem::RemoveObject
04/18/2018 15:23:03	Crash in CSpaceObject::Destroy
04/18/2018 15:23:03	Exception in objDestroy; arg = (517364552)
04/18/2018 15:23:03	Exception in objDestroy; arg = (517364552) [(517364552)] ### (objDestroy theStation) ###
This is happening in the <Invoke> section of the ROM ItemType but it also happened when I tried it in the <OnCreate> section of stD789OverlayStation. I've had "Exception" errors when updating one of the 'scrAddAction mods' but had assumed it was my code. Possibly a bug or can 'objDestroy' only be used in certain circumstances? Maybe the event needs to be cancelled first?
ATM the overlays are removed instead of the stations being destroyed to remove the old info display. But this means the old stations still exist and are cluttering up the game.

QUERIES:
What is the best way to destroy the overlay stations after 300 ticks?

The station/overlay is kept above the playership by a 'sysAddObjRecurringEvent'. Does this need to be cancelled afterwards? And if so where should this happen? Or does destroying the station cancel the event anyway?

The overlay persists if the targeted ship is destroyed. It would be better IMO if it disappeared when the targeted ship is destroyed. I think that the overlay can be cancelled in an event that detects that the target ship has been destroyed. But I don't know how or where to do this. Is anyone able to provide info on how to do this?

GENERAL:
Suggestions on frequency so that the ROMs/cubes aren't too common and also what info they need to be available for sale and resale would be appreciated.
As would opinions as to whether they should have unknown types, what prices to charge, whether they should have charges (they are currently consumed as they scan) and any other relevant info.

FOR INFO:
Making the overlay station virtual resulted in no overlay being shown. So unless I fouled up the code I assume that virtual stations can't have overlays.

Using an overlay on the playership didn't work very well. Although the information appeared as expected using 'objSetOverlayPos' to reset the overlay every 1 tick resulted in very jerky, erratic movements of the overlay. When using the overlay station the overlay hardly moves at all from directly above the playership. Better results could possibly be achieved if an overlay can be placed on the playership which doesn't rotate with the playership but I don't know if this is possible.

An overlay on a non-visible ship which was repostioned every 1 tick caused the overlay to appear sometimes but also to vanish for varied lengths of time and reappear at irregular intervals. Possibly related to the rotation of the non-visible ship as it moves about. That is a guess though.

TODO maybe:
Add secondary weapons to cube.
Charges.
Try \n at the beginning of strings/text. H/t to the auton bay code.
Attachments
Ship Scan ROMs.xml
(9.91 KiB) Downloaded 264 times
Stupid code. Do what I want, not what I typed in!
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

I did some tests. Several points, in no particular order:

- The exception is not entirely a problem with your code, but is caused by destroying a world-scale station. However, it is successfully destroyed.
- Using a star-scale station instead also prevents it from appearing on LRS and avoids the exception, but does cause perceptible lag when destroying it.
- Any non-virtual station, even if it has no hittable pixels, could possibly make the AI think their line of fire is blocked, and interact with code that does things for each station in the system.
- Virtual stations can have overlays; they just aren't visible. Probably the best solution is to make them visible, since it seems useful and I don't see how a virtual station would end up with an overlay that the coder doesn't want to be visible. It's not like they can be hit by neuroplague pods.
- When an object is destroyed, overlays on it stop existing and timers on it are canceled, so you don't have to do those things manually.
- The easiest way to destroy an object after a certain amount of time is probably to use sysAddObjTimerEvent in the code that creates it or its OnCreate event to fire an event that destroys it. I think the timer won't run while the player isn't in the system, but that doesn't seem very important here. If it is, you could use a recurring timer event that checks if some number of ticks have passed since it was created.
- If you're not going to destroy the station when it's done displaying the info, you should reuse the existing station if it exists when creating a new overlay, rather than create a new station each time. In case the previous timer hasn't expired, remove the existing overlay and cancel the existing timer, then add the new ones.
- Your OnCreate event creates a bunch of global variables. Generally when you add a new variable, you should immediately add it to the local variables list of the block that you expect to contain all the code that uses it. In addition to avoiding the chance of interfering with other code, this allows you to assume that any variable you haven't set yet is Nil. If a block begins with a series of setq calls, it may be clearer to use syntax like this:

Code: Select all

	(block (
		(var1 value1)
		(var2 value2)
		...
		)
		(statement 1)
		...
You can often convert to this just by strategically deleting the rest of the block line and the "setq "s, and closing the variables list further down.
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

NMS wrote:
Mon Jul 09, 2018 7:12 am
- Your OnCreate event creates a bunch of global variables.
:lol: :lol: :lol:
As I posted the mod I thought "I wonder what NMS would think of all those 'setq's". :D
I started using local variables when writing mods but consistently had to go back and globalize them so I could check which bit of code wasn't working. It takes me less time to work with globals in development versions of a mod rather than either print them all to the debug screen or go back and unlocalize them to find the problem. Thanks to the 'sysGlobals' code you and AP supplied any of my mods released in the future shouldn't have any globals floating around. 'Find and Replace' makes things easy.

Thank you very much for the testing. It has given me info I could never have worked out on my own. From a quick read; I'll try a one-pixel station with no scale code set 150ls above the station and set the overlay 140ls below that.
So the LRS icon will never be visible and the station can be destroyed without an error message.
The ODM Speedometer mod, the source of the station positioning code, does cause lag although it takes speedos on a dozen or more NPC ships for it to happen. So destroying the stations seems the best way to go although I'll probably reuse them if they are there. Thanks, another idea I never would have thought of.

Visible overlays on virtual stations would be good. That'll be version 2!
Stupid code. Do what I want, not what I typed in!
Post Reply