functions changin unit sight distance

functions changin unit sight distance

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
zyxar
Posts: 18
Joined: 18 Dec 2012, 04:39

functions changin unit sight distance

Post by zyxar »

Hi guys,

I've been looking at a way of making radio buttons in mod options that switch lines of sight like in OTA.

I'm trying to find a function that changes the distances units can see.
This is what I've found in the lua synced control documentation:
Unit LOS

Spring.SetUnitCloak

( number unitID,
boolean cloaked | number scriptCloak,
[ number decloakDistance | boolean decloakAbs ] ) -> nil


If the 2nd argument is a number, the value works like this:
1:=normal cloak
2:=for free cloak (cost no E)
3:=for free + no decloaking (except the unit is stunned)
4>=ultimative cloak (no ecost, no decloaking, no stunned decloak)

The decloak distance is only changed if the 3th argument is a number or a boolean.
If the boolean is false it takes the default decloak distance for that unitdef,
if the boolean is true it takes the absolute value of it.

Spring.SetUnitSonarStealth

( number unitID, boolean sonarStealth ) -> nil

Spring.SetUnitStealth

( number unitID, boolean stealth ) -> nil

Spring.SetUnitAlwaysVisible

( number unitID, boolean alwaysVisible ) -> nil

Spring.SetUnitLosMask

( number unitID, number allyTeam, number los | table losTypes ) -> nil

the 3th argument is either the bit-and combination of the following numbers:

LOS_INLOS = 1
LOS_INRADAR = 2
LOS_PREVLOS = 4
LOS_CONTRADAR = 8

or a table of the following form:

losTypes = {
[los = boolean,]
[radar = boolean,]
[prevLos = boolean,]
[contRadar = boolean,]
}

Spring.SetUnitLosState

( number unitID, number allyTeam, number los | table losTypes ) -> nil
see above for more info on the arguments

Spring.SetUnitSensorRadius

( number unitID, string type, number radius ) -> nil | number newRadius
type can be:
"los","airLos","radar","sonar","seismic","radarJammer","sonarJammer"
I'm not really sure what function I need to use, but I think it might be the last one.
Spring.SetUnitSensorRadius(unitID, "los", radius)
Even if this is the function I'm looking for, I'm not sure what designation it needs ("los", "airLos", "radar", or "seismic")
because I don't know what each of these exactly affect.
Thanks for help
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: functions changin unit sight distance

Post by Jools »

You mean like in OTA in the manu options: Line if sight:
0 - True
1 - Permanent
2 - Circular

I don't think you can set it to circular in spring. It is possible to set it to permanent. I think there are easier ways than to sewt all units to always visible. See knorke's map DownCount for an example.

http://springfiles.com/spring/spring-maps/downcount
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: functions changin unit sight distance

Post by knorke »

I'm not really sure what function I need to use, but I think it might be the last one.
Spring.SetUnitSensorRadius(unitID, "los", radius)
yes, that should work.

los: line of sight
airlos: distance used for some things like aircraft or explosions etc (generally such things are visible from further away)
radar: distance at which units are visible as icons
sonar: like radar under water or something
XYjammer: sonar and radar can be jammed to hide units
seismic: units become visible as some sort of "ring waves"

So you want "los" and "airLos".
with exception of seismic iirc all are blocked by terrain.

If you want LOS that is not affected by hills then there is no simple way to do it.

Btw when changing sight distances I noticed something funky?
http://springrts.com/phpbb/viewtopic.ph ... nsorRadius
Post Reply

Return to “Lua Scripts”