@Miguel
Secondly, and this is a lot harder. The Modifier_Remove() function requires a Modifier ID as an argument, however the Modifier_Create() function returns a Scar Modifier, which is not the same. If I want to remove a modifier I've created through SCAR, and Modifier_RemoveAllFromSGroup() doesn't work (possibly because it only removes modifiers that were originally applied to an Sgroup, mine are applied to a squad and entity in that Sgroup), then how do I do it?
Here's my guess without actually having tried it:
Open up gamedefaults.sga and check out simulation\scar\modifiers.scar lines 27-39 and 986-1006
modid = Modifier_ApplyToSquad(modifier, sid)
modifier = Modifier_Create(applicationType, modStr, MUT_Multiplication, false, factor, "")
sid = Squad_GetGameID(squad)
So then when you put this all together
modid = Modifier_ApplyToSquad( Modifier_Create(applicationType, modStr, MUT_Multiplication, false, factor, "") , Squad_GetGameID(squadID) )
To get the squadID you can use:
Code:
Void SGroup_Filter( SGroupID sgroup, String/ID/Table blueprint, Integer filtertype[, SGroupID splitgroup] )
Filters an SGroup by blueprint. Blueprints can be provided by name or by ID, and in a table if you want to filter on more than one type.
Setting filtertype to FILTER_KEEP results in the group only containing squads of the types listed in the blueprint table, while FILTER_REMOVE will strip those same squads out and leave those that aren't of the types listed. If you specify a splitgroup, then units that would have been removed get moved into this group instead. This group is cleared beforehand.
Then use:
Code:
SquadID SGroup_GetSpawnedSquadAt( SGroupID group, Integer index )
Returns the spawned squad at a certain position in the group.
This is a one-based index (use index 1 to get the first squad in the group.) It is an error if index > SGroup_GetSpawnedCount().
So then the full thing is:
Code:
--some variables to make it easier to read
player = World_GetPlayerAt( YOUR_PLAYER_NUMBER )
all_squads = Player_GetSquads( player )
blueprint = "sbps\\YOUR_BLUEPRINT"
sg_blueprint = SGroup_CreateIfNotFound( "sg_blueprint" )
--creates an SGroup that contains only the unit specified in the variable blueprint
sgroup_blueprint = SGroup_Filter( all_squads , blueprint , FILTER_REMOVE , sg_blueprint )
--gets the SquadID of the unit specified in the variable blueprint and gets its gameID (to be used later)
squadID_blueprint = SGroup_GetSpawnedSquadAt( "sg_blueprint" , 1 )
squad_blueprint_gameID = Squad_GetGameID( squad_ID_blueprint )
--design your modifier
modifier = Modifier_Create( Integer applicationType , String modtype , Integer usageType , Boolean exclusive , Real value )
--get your ModID
modID = Modifier_ApplyToSquad( modifier, squad_blueprint_gameID )
--now you actually create/apply/remove modifiers
Modifier_Create( Integer applicationType , String modtype , Integer usageType , Boolean exclusive , Real value )
Modifier_ApplyToSquad( modifier, squad_blueprint_gameID )
Modifier_Remove( modID )