RDNWiki: DOWScar/Tutorials/Advanced/ProximityDetectionExample ...

RDN Wiki Home | Page Index | Recent Changes | Recently Commented | Users | Registration | Login:  Password:  

Proximity Detection


Contents


--[[ PROXIMITY DETECTION ]]
--[[ Sgroup to Marker ]]
function Rule_IsSquadinProximity_Marker()

	--[[ You should always check to see if a Sgroup exists and is not empty before comparing it to anything else ]]
	if SGroup_Exists("sgroup_name") and SGroup_IsEmpty("sgroup_name") == false and Prox_AllSquadsNearMarker("sgroup_name", "marker_name") then
		
		print("All squads near marker")
		
	elseif SGroup_Exists("sgroup_name") and SGroup_IsEmpty("sgroup_name") == false and  Prox_AnySquadNearMarker("sgroup_name", "marker_name") then
		
		print("At least one of the squads is near the marker")
		
	elseif SGroup_Exists("sgroup_name") and SGroup_IsEmpty("sgroup_name") == false then
		
		print("No squads are near the marker")
		
	elseif SGroup_Exists("sgroup_name") and SGroup_IsEmpty("sgroup_name") then
		
		print("The sgroup is empty")
		
	else
		
		print("the sgroup does not exist")
		
	end
	
end

--[[ Sgroup to Sgroup ]]
function Rule_IsSquadinProximity_Squad()

	--[[ The two sgroups being compared must exist and cannot be empty ]]
	if SGroup_Exists("sgroup_name1") 
		and SGroup_IsEmpty("sgroup_name1") == false 
		and SGroup_Exists("sgroup_name2")
		and SGroup_IsEmpty("sgroup_name2") == false  then
		
		if Prox_SGroupSGroup("sgroup_name1", "sgroup_name2", PROX_SHORTEST) == 10 then
			
			print("The two sgroups have members that are 10 meters apart")
			
		elseif Prox_SGroupSGroup("sgroup_name1", "sgroup_name2", PROX_SHORTEST) > 30 then
			
			print("The two sgroups are no closer than 30 meters from each other")
			
		end
		
	else
		
		if SGroup_Exists("sgroup_name1") and SGroup_IsEmpty("sgroup_name1") then
			
			print("Sgroup 1 exists but is empty")
			
		else
			
			print("Sgroup 1 does not exist")
			
		end
		
		if SGroup_Exists("sgroup_name2") and SGroup_IsEmpty("sgroup_name2") then
			
			print("Sgroup 2 exists but is empty")
			
		else
			
			print("Sgroup 2 does not exist")
			
		end
		
	end
	
end

Links


SCAR
Wiki Home

End of Page


Referring pages: DOWScar
DOWScar/Tutorials
DOWScar/Tutorials/Advanced

There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]