Jump to content

Recommended Posts

Posted

Hello,

 

I'm currently using this code to update a globally declared table (named KnownEnemyList), that work as a repository of known enemy information used for some kind of purposes.

 

	DGWS.integrateKnownEnemyList = function()
	totKnownEnemyList = {}
	for _,enemyData in pairs(mist.DBs.aliveUnits) do
		if enemyData.category == "vehicle" then
			local isLOS = false
			local EarthMaxVisRange = 0
			
			local rEnemyID = enemyData.unitId
			local rEnemyGroupName = enemyData.groupName
			local rEnemyName = enemyData.unitName
			local rEnemyData = Unit.getByName(rEnemyName) -- 2014.08.15 changed adding "r" to EnemyName
			local rEnemyX = enemyData.pos.x
			local rEnemyZ = enemyData.pos.z
			local rEnemyY = enemyData.pos.y+2
			local rEnemyType = enemyData.type
			local rEnemyCoalition = enemyData.coalition
			local rEnemyCategory = enemyData.category
			
			-- additional info
			local rEnemyClass = "Unsorted"
			local rEnemyattacklvl = 0
			local rEnemydefencelvl = 0
			local rEnemyrangeatklvl = 0
			local rOwnPos = ""
			local rOwnAGL = ""
			local rOwnGroup = ""
			
			-- compose position table
			local rEnemyPos = { 
							x = rEnemyX,
							y = rEnemyY, 
							z = rEnemyZ 
							}
			
			-- overwrite "unsorted" class with correct one.
			for class, classData in pairs(UnitsClass) do
				local identifier = classData.type
				if typeMatch(identifier, rEnemyType ) then
					rEnemyClass = class
					rEnemyattacklvl = classData.attacklvl
					rEnemydefencelvl = classData.defencelvl
					rEnemyrangeatklvl = classData.rangeatklvl
				end
			end							

	
			for _,unitData in pairs(mist.DBs.aliveUnits) do
				local rOwnCoalition = unitData.coalition
				local rOwnName = unitData.unitName
				rOwnGroup = unitData.groupName
				local rOwnX = unitData.pos.x
				local rOwnZ = unitData.pos.z
				local rOwnY = unitData.pos.y
				local rOwnCategory = unitData.category
				rOwnAGL = (rOwnY - land.getHeight({x = rOwnX, y = rOwnZ}))
									
				rOwnPos = { 
								x = rOwnX,
								y = rOwnY, 
								z = rOwnZ 
								}
				
				if rEnemyCoalition ~= rOwnCoalition and rEnemyCategory == "vehicle" then
					if rEnemyClass ~= "INFANTRY" then
						isLOS = land.isVisible(rOwnPos, rEnemyPos)
						EarthMaxVisRange = 6371009*math.acos(6371009/(6371009+2+rOwnAGL))
						if isLOS == true then
							local rDistance = mist.utils.get3DDist(rOwnPos,rEnemyPos)
							if rDistance < EarthMaxVisRange then
								--NEW DA QUI
								--for KnownID,KnownData in pairs (KnownEnemyList) do    --//COMMENTED TO TRY IF IT WORKS THIS WAY
									--if rEnemyID ~= KnownData.EnemyID then				--//COMMENTED TO TRY IF IT WORKS THIS WAY
										totKnownEnemyList[#totKnownEnemyList + 1] = { EnemyID = rEnemyID, EnemyCoalition = rEnemyCoalition, EnemyGroupName = rEnemyGroupName, EnemyName = rEnemyName, EnemyType = rEnemyType, EnemyClass = rEnemyClass, Enemyattacklvl = rEnemyattacklvl, Enemydefencelvl = rEnemydefencelvl, Enemyrangeatklvl = rEnemyrangeatklvl, EnemyX = rEnemyX, EnemyZ = rEnemyZ, EnemyY = rEnemyY, OwnGroup = rOwnGroup, ReportTime = math.floor(timer.getTime()), Distance = rDistance}
									--end
								--end
								--END NEW
							end
						end
					end
				end
			end
		end
	end
	
	-- update duplicates
	for _,entryData in pairs(totKnownEnemyList) do
		local EnID = entryData.EnemyID
			
		for existID,existingData in pairs(KnownEnemyList) do
			local ExID = existingData.EnemyID
			
			if ExID == EnID then
				KnownEnemyList[existID] = nil
			end
		end
		
		KnownEnemyList[#KnownEnemyList + 1] = entryData
		
	end		

end

 

however, as you may see, this code rely on LOS function and combine it with earth curvature limits... nothing more. It's a mock up of what i would really use.

 

What I would use is the same function that determinee which enemy unit is visible in the F10 Fog of war map and witch is not. I may think that is the "detection function" kindly explained here at hoggit wiki: http://wiki.hoggit.us/view/Part_2 (down in the page).

 

Has anyone suggestions about how to use it or any other solution to my problem?

 

Thanks in advance :)

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

  • 3 weeks later...
Posted
I couldn´t get it to work on AWACS planes, but for ground Radar it returns true.

 

Interesting, thank you!

 

That should confirm what Grimes said about F10 map updates... it seems to be some kind of sensor-related for Flying things. I may say radar-related, but Predator MQ-1 isn't fitted with radar, isn't it?

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

  • Recently Browsing   0 members

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