Selection_FilerInclude / Selection_FilterExclude


(Taiidan Republic Mod) #1

Does anyone know the possible values for the third argument of the Selection_FilerInclude / Selection_FilterExclude functions?

In tai_defensefighter.lua it is:

Selection_FilterExclude("IncomingMissiles", "AllMissiles", "PlayerOwner", ""..playerID, "")
Selection_FilterInclude("IncomingMissiles", "IncomingMissiles", "NearPoint", defensePointString, ""..4500)

In kasutil.lua it is:

filter = ATTRIBUTES_VelToMothership + ATTRIBUTES_DontApplyFriction
Selection_Create("KillerAsteroids")
count = Selection_FilterInclude("KillerAsteroids", "AllAsteroids", "ScriptFlagsSetAll", ""..filter.."", "") 

But are there any other possibilities, and what exactly is the filter doing in the kasutil.lua example?

@pdeupree @EatThePath @shadowwinterknig

EDIT: found this in specialflags.lua:

-- Special flags.  These are stored in the m_scriptingFlags member of Sob.
-- They are mostly queried/manipulated on a per-squad level.
ATTRIBUTES_VelToMothership         = 2 ^ 2  --0x0004
ATTRIBUTES_DontApplyFriction       = 2 ^ 3  --0x0008

(Liuruoyang1995=Lone Wolf Akela) #2
	SobGroup_FilterInclude(<sSobGroupNameOut>, <sSobGroupNameIn>, <sFilterTypeString>,     <sFilterParam>)
	FilterType              FilterParam
	========================================
	"Ability"
	                        "SalCapCommand"
	                        "RepairCommand"
	                        "CustomCommand"
	                        "MoveCommand"
	                        "CloakAbility"
	                        "CanDock"
	                        "HyperSpaceCommand"
	                        "ParadeCommand"
	                        "CanBuildShips"
	                        
	"CurrentCommand"        
	                        "COMMAND_Attack"
	                        "COMMAND_SalCap"
	                        "COMMAND_Hyperspace"
	                        "COMMAND_Dock"
	                        "COMMAND_Launch"
	                        
	"CurrentCommandState"
	                        "SALCAPSTATE_ReturningToBaseWithTech"
	                        "LAUNCHSTATE_Queue"
	                        
	"NoFilter"
	                        ""

	"attackFamily"
	                        (attackFamily)
	                        
	"displayFamily"
	                        (displayFamily)
	                        
	"ShipType"              
	                        (ShipType)
	                        
	"PlayerOwner"
	                        (""..iPlayerIndex)
	                        
	"Docked"
	                        ""

Above is all the possible values that I found which have been used in Gearbox’s scripts.
Texts extracted from Homworldrm.exe indicates that the values below may also be used as <sFilterTypeString>, but I haven’t tested them myself so they might work or not:

ShipClass
AutoformationFamily
UnitCapsFamily
ScriptFlagsSetAll
ScriptFlagsSetAny
Health
Awake
ScriptFlagsUnset
NearPoint
SquadronList

(Taiidan Republic Mod) #3

Thanks, but I’m trying to use selections, not sob groups. I want to select all asteroids of a certain type, or by location…


(Liuruoyang1995=Lone Wolf Akela) #4

Oh sorry, I misread your post and thought you were asking about sobgroup. Anyway it seems that selections work very similar to sobgroups, so you may still try those filters and see if it will work.
And as for asteroids, I can confirm that “NearPoint” filter works, so you can use it to select asteroids by their location.


(Liuruoyang1995=Lone Wolf Akela) #5

And below is a demo code to make a RU tractor I wrote some time ago:

Ben_RuCarrier_Speed = 150
salvagerNum = 0
detection_radius = "200"

function Start_Ben_RuCarrier(CustomGroup, playerIndex, shipID)
	local salvagerGroup = CustomGroup..shipID.."salvager"
	SobGroup_CreateIfNotExist(salvagerGroup)
	SobGroup_Clear(salvagerGroup)  
	SobGroup_FillShipsByType(salvagerGroup, "Player_Ships"..playerIndex, "ben_salvager")
	salvagerNum = SobGroup_Count(salvagerGroup)
	for i = 0, salvagerNum - 1 do
		SobGroup_CreateIfNotExist(salvagerGroup..i)
		SobGroup_Clear(salvagerGroup..i)  
		SobGroup_FillShipsByIndexRange(salvagerGroup..i, salvagerGroup, i, 1)		
	end
	
	Volume_AddSphere(salvagerGroup.."VCar", SobGroup_GetPosition(CustomGroup), 0)
end

function Do_Ben_RuCarrier(CustomGroup, playerIndex, shipID)
	local salvagerGroup = CustomGroup..shipID.."salvager"
	salvagerEffectsList = salvagerEffectsList or {}

	local carrierPoint = SobGroup_GetPosition(CustomGroup)
	Volume_Delete(salvagerGroup.."VCar")
	Volume_AddSphere(salvagerGroup.."VCar", carrierPoint, 0)
	
	for i = 0, salvagerNum - 1 do
		if salvagerEffectsList[i+1] then
			FX_StopEffect(salvagerEffectsList[i+1])
			salvagerEffectsList[i+1] = nil
			Volume_Delete(salvagerGroup.."VSal"..i)
		end
		if SobGroup_IsDoingAbility(salvagerGroup..i, AB_Harvest) == 1 then
			Selection_Create("tmpAsteroids")
			if Selection_GetResources("tmpAsteroids", "Asteroid") > 0 then
				local salvagerPoint = SobGroup_GetPosition(salvagerGroup..i)
				local salvagerPointString = salvagerPoint[1]..","..salvagerPoint[2]..","..salvagerPoint[3]
				local numberOfNearbyRu = Selection_FilterInclude(
		    	"tmpAsteroids", 
		    	"tmpAsteroids", 
		    	"NearPoint", 
		    	salvagerPointString,
		    	detection_radius
	    	)
	    	if numberOfNearbyRu > 0 then	    		
		    	local heading = 
		    	{
		    		carrierPoint[1] - salvagerPoint[1],
		    		carrierPoint[2] - salvagerPoint[2],
		    		carrierPoint[3] - salvagerPoint[3],
		    	}
		    	local headingLen = sqrt(heading[1]^2 + heading[2]^2 + heading[3]^2)
		    	heading = 
		    	{
		    		heading[1] * Ben_RuCarrier_Speed / headingLen,
		    		heading[2] * Ben_RuCarrier_Speed / headingLen,
		    		heading[3] * Ben_RuCarrier_Speed / headingLen,
		    	}
		    	Selection_SetVelocity("tmpAsteroids", heading)
		    	
		    	Volume_AddSphere(salvagerGroup.."VSal"..i, salvagerPoint, 0)
		    	salvagerEffectsList[i+1] = FX_PlayEffectBetweenPoints("pro_tech_beam_combo", salvagerGroup.."VCar", salvagerGroup.."VSal"..i, 0.5)
	    	else
	    		_ALERT("No Nearby Asteroid: "..i)
	    	end
			else
				_ALERT("No Asteroid: "..i)
			end
		end
	end
end

function Finish_Ben_RuCarrier(CustomGroup, playerIndex, shipID)	
	local salvagerGroup = CustomGroup..shipID.."salvager"
	Volume_Delete(salvagerGroup.."VCar")
	for i = 0, salvagerNum - 1 do
		if salvagerEffectsList[i+1] then
			FX_StopEffect(salvagerEffectsList[i+1])
			salvagerEffectsList[i+1] = nil
			Volume_Delete(salvagerGroup.."VSal"..i)
		end
	end
end

(Taiidan Republic Mod) #6

Wow that’s awesome! Thanks for sharing that. I had wondered if something like that might be possible…