Jump to content

Recommended Posts

Posted (edited)

I don't see any getter methods for the Unit class to see if its set to invisible.  I see in the Controller class that there is a setCommand() method (which will allow you to use SetInvisible task), but not a similar getter method.  Any tips for determining if a Unit has been set to invisible?

Thanks.

Edited by 609_Relentov
Posted (edited)

DCS.getUnitProperty(unitID, DCS.UNIT_INVISIBLE_MAP_ICON) or DCS.UNIT_HIDDEN, depending on which invisible you're referring to, from the server env ( hooks ).

Edited by Sean B.
Posted

Thanks for the reply.  I hadn't used DCS.getUnitProperty()... unfortunately this is not what I was looking for, this is more for if units are hidden on the F10 map (so we/clients can't see them), I'm talking about units/groups that are invisible to the AI.  I see the Controller.setCommand() method, with the SetInvisible command/task that will set a unit to invisible (to AI), but I'm trying to find a way to determine if a unit has previously been set to invisible (e.g. via ME) and will thus not be seen by the AI.

Posted (edited)

My bad. Too many "invisible"'s to choose from. The Flags table of the unit object table provided in the export environment has it:

 

     Flags = {
		RadarActive = true if the unit has its radar on
		Human = true if the unit is human-controlled
		Jamming = true if the unit uses EMI jamming
		IRJamming = -- same for IR jamming
		Born = true if the unit is born (activated)
		AI_ON = true if the unit's AI is active
		Invisible = true if the unit is invisible  <<--------*******-----
		Static - true if the unit is a static object
        }

 

 

Edited by Sean B.
Posted

Hmm so far no luck; I found the function entry in the DCS Export Script on the Hoggit SSE site:

LoGetObjectById() -- (args - 1 (number), results - 1 (table))
Returned object table structure:
{ 
	Name = 
	Type =  {level1,level2,level3,level4},  ( see Scripts/database/wsTypes.lua) Subtype is absent  now
	Country   =   number ( see Scripts/database/db_countries.lua
	Coalition = 
	CoalitionID = number ( 1 or 2 )
	LatLongAlt = { Lat = , Long = , Alt = }
	Heading =   radians
	Pitch      =   radians
	Bank      =  radians
	Position = {x,y,z} -- in internal DCS coordinate system ( see convertion routnes below)
	-- only for units ( Planes,Hellicopters,Tanks etc)
	UnitName    = unit name from mission (UTF8)  
	GroupName = unit name from mission (UTF8)
		Flags = {
		RadarActive = true if the unit has its radar on
		Human = true if the unit is human-controlled
		Jamming = true if the unit uses EMI jamming
		IRJamming = -- same for IR jamming
		Born = true if the unit is born (activated)
		AI_ON = true if the unit's AI is active
		Invisible = true if the unit is invisible
		Static - true if the unit is a static object
		}
}

I don't see any other documentation, but it appears you call LoGetObjectById() with one parameter, passing the unit ID, and it returns a table.  Not clear if the returned table has just one entry (i.e. index = 1), and if the Flags table within that one entry has just one entry as well (i.e. index = 1).  So, it seems like to reference the "Invisible" boolean element, you could reference the table returned from LoGetObjectById via tblLoGetObjectById[1].Flags[1].Invisible, but I'm seeing an error in the dcs.log when I try this syntax (ERROR   SCRIPTING (Main): error in error handling) and my trigger.action.outText(...) commands are not writing anything out, it's exiting early.

@Sean B. do you have any examples of using this function and the resulting returned table?

Thanks!

 

 

Posted

It may be more of a pain to access that table than it's worth for you, as the unit object table isn't accessible from the mission environment. There would be 2 ways to get the value of that invisible variable:

One would be via the io package, using temp files to read/write info back and forth from/to either the hooks or export env. This wouldn't be difficult, and would be fine if the mission will only be run on a dedicated server instance. But it makes the mission non-portable sense, by default, the io package is sanitized from access by the mission env on client installations. 

The other would be to have a hooks script monitor a specific user flag that, when populated with the object ID of a unit ( NOT the unit ID ) by the mission env, gets the table from Export.LoGetObjectByID(ID), and send a true/false result back to the mission via a different user flag. 

In either case, access to LoGetObjectByID is dependent on the server export settings.

Unless something about your mission prevents it, I would suggest setting the units to invisible via scripting ( as opposed to selecting the option on the units in the ME ). This would allow you to keep track of what units have been set invisible simply by setting their ID's into a table when you set them invisible, then reference that table later as needed.

Posted (edited)

Hey Sean, thanks for the reply.  Yes, I was reading about access to this function possibly being prevented based on server settings (for multi player missions).  As for the last suggestion, that makes sense, although the reason I wanted to get this info is for my BluForAC script, which would be something that anyone could load in their mission, thus I would not have control of the invisible flag being set.

It's not the end of the world, it just means if someone used that script, if they attempted to call up some CAS aircraft to attack enemy ground units, if the ground units identified to be attacked by the friendly AI aircraft happened to be set to invisible, the AI aircraft would just return to base.  I will need to add that to the script readme/features so users know; here's the thread for that script:

 

Edited by 609_Relentov
Posted (edited)

Ah, gotcha. You could always try an force your way by using Controller.knowTarget(). I'm not sure if it overrides a target being invisible, but it might. Mission builders may not appreciate it though hah. Best of luck!

 

P.S.: Not sure why I didn't think of this in my last post, but luasocket would be an easy option for getting information from either the hooks or export env's as well.

Edited by Sean B.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...