Your second request is already do-able with existing triggers from the Advanced Triggers Set:
#1: QV Set Unit OBJECT ID in Area (Center Unit) to detect the Janissary and save the unit's ID (NOT unit type ID) to a QV
#2: XS - Units in Area and plug the QV ID in as the center unit.
so basically #1 finds your janissary and #2 uses the janissary as the center for Units in Area.
There is an index feature in the QV Set - the index determines if it's the first unit found etc. You can have it loop and the index increase by one each time.
Just add in QV Modify (Add 1 to the QV each time you loop)
Then for the index field, you'd put trQuestVarGet("Name of your QV")
Of course, to stop the loop, you'd want the condition to be QV Check (make sure your QV is never higher than the number of times you want to loop)
There is no index feature in the QV. The index feature is in the QV Set Unit OBJECT ID in Area (Center Unit). You use the QV (a number) to determine the index of the Area effect.
Set up the trigger as I have shown and you'll have a better understanding of it (test it to figure out what's going on). .
I still don't follow how the Index plays out here.
These are the parms for "XS - QV Set Unit OBJECT ID in Area" effect.
<Effect name="XS - QV Set Unit OBJECT ID in Area (Center Unit)">
<Param name="QVName" dispName="QV" varType="string">QV1</Param>
<Param name="index" dispName="Index (first unit is 0)" varType="string">0</Param>
<Param name="Object" dispName="Center Unit OBJECT ID" varType="string">0</Param>
<Param name="FromPlayer" dispName="Player (99 for ALL)" varType="string">99</Param>
<Param name="UnitId" dispName="Unit Type ID (Optional)" varType="string">-1</Param>
<Param name="actionid" dispName="Action ID (Optional)" varType="string">-1</Param>
<Param name="Dst" dispName="Radius (-1 for ALL)" varType="string">10</Param>
Are you saying that the QV in this effect is actually an array because of the associated Index?
Do I run it once or do I put it in a loop according to the number of units on the map?
If so, how do I bump the index by 1 every time? Shouldn't I change the Index parm from a "String" to QV?
But that requires modifying the effect itself.
Then how do I make the 'XS - Convert/Change Units in Area' effect work?
After all the QV here has no Index.
I am assuming I need to pass the value from the QV with the index to the QV without the index but I don't have an "Effect" for that.
Also the "Center Unit OBJECT ID" here is a string NOT a QV which means that I need to modify this effect.
<Effect name="XS - Convert/Change Units in Area (Center Unit)">
<Param name="Object" dispName="Center Unit OBJECT ID" varType="string">0</Param>
<Param name="Dst" dispName="Radius" varType="string">10.0</Param>
<Param name="UnitId" dispName="Unit Type ID (Optional)" varType="string">-1</Param>
<Param name="FromPlayer" dispName="From Player or 99 for ALL" varType="string">99</Param>
<Param name="ToPlayer" dispName="To Player" varType="string">0</Param>
<Param name="ChangeUnit" dispName="Change Protounit Type" varType="string">Do Not</Param>
<Param name="Booler" dispName="Include Center Unit" varType="bool">false</Param>