To answer the OP's question about cycling in reverse:
Lua Code:
-- cycle all the units in the party, including the player, in reverse order
local function ReverseParty()
for i = GetNumGroupMembers() + 1, -1 do
local unit = party..i
-- if unit is nil, it should be the player, but check anyway
if unit then
-- found party member
print("Found party member number party" .. party..i)
else
-- it is not partyN
print("Found the player")
end
end
end