View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0004927 | Spring engine | General | public | 2015-08-07 18:02 | 2015-11-29 09:00 | ||||
Reporter | silentwings | ||||||||
Assigned To | jK | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | 100.0 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0004927: unitDef.losRange returns the wrong value | ||||||||
Description | The value returned by UnitDefs[uDID].losRange is incorrect. The value returned by Spring.GetUnitSensorRadius(test[n][1], 'los') is correct, and always about (not but exactly) 31.5 times that returned by UnitDefs[uDID].losRange. | ||||||||
Steps To Reproduce | Use widget code below, and give a unit. | ||||||||
Additional Information | local test = {} function widget:UnitCreated(unitID, unitDefID, unitTeam, builderID) local f = Spring.GetGameFrame() test[f+1] = {unitID, unitDefID} end function widget:GameFrame(n) if test[n] then local ud_los = UnitDefs[test[n][2]].losRadius local lua_los = Spring.GetUnitSensorRadius(test[n][1], 'los') Spring.Echo(ud_los, lua_los, lua_los/ud_los) end end | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | |||||||||
Attached Files |
|
![]() |
|
silentwings (reporter) 2015-08-07 18:04 Last edited: 2015-08-07 18:05 |
Ops, meant to write losRadius (code is correct, subject is not) Also, test[n][1]==unitID |
jK (developer) 2015-08-09 15:38 |
it is not wrong the UnitDefs table is 1. not the things you put in in defs.lua stage 2. not in always in the units you expect it to be 3. it is the _raw_ data the engine uses itself |
silentwings (reporter) 2015-08-09 17:45 |
Then, obviously, how to convert between the two? Also, afaik every other tag listed on https://springrts.com/wiki/Gamedev:UnitDefs returned distances in elmos unless otherwise specified, so this is imo inconsistent/confusing. |
Kloot (developer) 2015-08-09 20:00 |
UnitDefs[i].losRadius is (sightDistance * modInfo.losMul) / K GetUnitSensorRadius("los") is UnitDefs[i].losRadius * K == sightDistance * modInfo.losMul the constant K is SQUARE_SIZE * (1 << modInfo.losMipLevel) and it might also be helpful to keep the following snippet around local modRules = VFS.Include("gamedata/modrules.lua") local losResMult = modRules["sensors"]["los"]["losMul" ] local losMipLevel = modRules["sensors"]["los"]["losMipLevel"] local losSqSize = Game.squareSize * math.pow(2, losMipLevel) local losToElmos = losSqSize / losResMult -- in elmos local udefBaseSightDist = unitDef.losRadius * losToElmos -- assuming you have not called Spring.SetUnitSensorRadius assert(Spring.GetUnitSensorRadius(123, "los") / losSqSize == unitDef.losRadius) assert(Spring.GetUnitSensorRadius(123, "los") == unitDef.losRadius * losSqSize) (feel free to put this in the wiki) |
silentwings (reporter) 2015-08-10 15:32 |
Ok, thanks very much, I'll add to the wiki. Fwiw, literally all other los/sensor radius tags are in elmos, in both unit def files and the lua table, so imo it would be better if this one was too. |
jK (developer) 2015-11-29 09:00 |
with the next release the returned values are in elmos |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2015-08-07 18:02 | silentwings | New Issue | |
2015-08-07 18:04 | silentwings | Note Added: 0015052 | |
2015-08-07 18:05 | silentwings | Note Edited: 0015052 | View Revisions |
2015-08-09 15:38 | jK | Note Added: 0015058 | |
2015-08-09 15:38 | jK | Status | new => closed |
2015-08-09 15:38 | jK | Assigned To | => jK |
2015-08-09 15:38 | jK | Resolution | open => no change required |
2015-08-09 17:45 | silentwings | Note Added: 0015059 | |
2015-08-09 17:45 | silentwings | Status | closed => feedback |
2015-08-09 17:45 | silentwings | Resolution | no change required => reopened |
2015-08-09 20:00 | Kloot | Note Added: 0015060 | |
2015-08-10 15:32 | silentwings | Note Added: 0015061 | |
2015-08-10 15:32 | silentwings | Status | feedback => assigned |
2015-11-29 09:00 | jK | Note Added: 0015350 | |
2015-11-29 09:00 | jK | Status | assigned => resolved |
2015-11-29 09:00 | jK | Resolution | reopened => fixed |