Project

General

Profile

 

Also available in: PDF

How to determine group leader

Introduction

To determine the leader of the current group, a script will need to iterate through the GroupMembers Window eq2uielements associated with the names of players.   Then, when you come across the one which is not a Mercenary and has the text color in yellow (or faded yellow), then this indicates that the player is the group leader.   Since the character of the current player is not listed in the groupwindow, then check to see if that character is the group leader first (using ${Me.IsGroupLeader}.)

Sample

function main()
{
    variable int GroupCounter = 1
    variable int NumChildren
    variable string GMName
    variable string GMType
    variable string RBGAColor
    
    
    if (${Me.IsGroupLeader})
        echo "0. ${Me.Name} (GROUP LEADER)"
    else
        echo "0. ${Me.Name}"
    
    do
    {
        ; If the MemberInfo page doesn't have 8 children, then it's not valid (i.e., there is no group member in this slot or the structure of the file has changed.)
        NumChildren:Set[${EQ2UIPage[MainHUD,GroupMembers].Child[Page,GroupMember${GroupCounter}.MemberInfoPage.MemberInfo].NumChildren}]
        if (${NumChildren} < 8)
            continue
        
        ; Sanity Check (if this fails, then the structure of the xml file has changed)
        if (!${EQ2UIPage[MainHUD,GroupMembers].Child[Page,GroupMember1.MemberInfoPage.MemberInfo].ChildType[2].Equal["Text"]})
        {
            echo "CRITICAL ERROR - the eq2ui_mainhud_groupmembers.xml file must have changed."
            return
        }
        
        ; We should ignore mercenaries
        GMType:Set[${Me.Group[${GroupCounter}].ToActor.Type}]
        if (${GMType.Equal["Mercenary"]})
            continue
            
        GMName:Set[${EQ2UIPage[MainHUD,GroupMembers].Child[Page,GroupMember${GroupCounter}.MemberInfoPage.MemberInfo].Child[Text,2].GetProperty[Text]}]
        RBGAColor:Set[${EQ2UIPage[MainHUD,GroupMembers].Child[Page,GroupMember${GroupCounter}.MemberInfoPage.MemberInfo].Child[Text,2].GetProperty[TextColor].Right[6]}]
        
        ; if the TexTColor is ffff (bright yellow) or 7f7f (faded yellow or olive) then the player is the group leader
        if (${RBGAColor.Equal["ffff00"]} || ${RBGAColor.Equal["7f7f00"]})
            echo "${GroupCounter}. ${GMName} is a PC with a TextColor of ${RBGAColor} (GROUP LEADER)"
        else
            echo "${GroupCounter}. ${GMName} is a PC with a TextColor of ${RBGAColor}"
    }
    while ${GroupCounter:Inc} <= 5
}

Technical Notes

The most challenging thing about the snippet above is this call:  ${EQ2UIPage[MainHUD,GroupMembers].Child[Page,GroupMember${GroupCounter}.MemberInfoPage.MemberInfo]}.  It comes from analyzing the top portion of eq2ui_mainhud_groupmembers.xml:

<?xml version="1.0" encoding="utf-8"?>
        <Page eq2usescomwndcontrols="true" Location="0,94" MaximumSize="1060,490" MinimumSize="114,162" Name="GroupMembers" PackLocation="left,top" ScrollExtent="219,490" Size="219,490" UserMovable="true" UserResizable="true" version="1.2">
            <DataSource Name="CameraDistanceDS">
                ...
            </DataSource>
            <Page AbsorbsInput="false" Location="5,390" Name="GroupMember5" ScrollExtent="210,96" Size="210,96">
                <Page Name="PaperDollPage" ScrollExtent="96,96" Size="96,96">
                    <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="0,-2" Name="Frame" PackLocation="left,top" RStyleDefault="/WindowElements.DesktopWindowFrame.data.frame.rect" ScrollExtent="97,99" Size="97,99" />
                    <PaperDoll Location="3,3" Name="Paperdoll" PackLocation="left,top" paperdollbackgroundcolor="/ColorStyles.paperdoll_background" ScrollExtent="91,90" Size="91,90" />
                    <Page AbsorbsInput="false" BackgroundOpacity="1.000" Location="3,3" Name="Bkg" PackLocation="left,top" RStyleDefault="/WindowElements.DesktopWindowFrame.data.bkg.rect" ScrollExtent="91,90" Size="91,90" />
                </Page>
                <Page AbsorbsInput="false" Location="96,0" Name="MemberInfoPage" ScrollExtent="114,66" Size="114,66">
                    <Page Name="MemberInfo" ScrollExtent="114,31" Size="114,31">
                        <Icon DynamicData="/GameData.Group.Group_1.Speaking" IconRect="124,204,135,215" IconResource="/images/widgets01.dds" Location="101,5" Name="Speaking" OnPress="vivox_adjust_volume Parent.Name.FullName" ScrollExtent="10,10" Size="10,10" TreatAsButton="true" />
                        <Text AbsorbsInput="false" Font="/TextStyles.Normal.NormalStyle" Location="2,1" Margin="1,0,0,0" Name="Name" PackLocation="top,left" ScrollExtent="109,16" ShadowStyle="/ShadowStylesNew.Outline.style" Size="109,16" TextAlignmentVertical="Center">:4bb9327fd43f489d:GroupMember</Text>
                        <Image AbsorbsInput="false" Location="2,17" Name="HealthBubblesOverlay" ScrollExtent="109,6" Size="109,6" SourceRect="267,183,376,189" SourceResource="/images/window_elements_generic.dds" Stretch="false" />
                        <Progressbar AbsorbsInput="false" BackgroundColor="#000000" Color="#FE0417" Location="2,17" Name="HealthBar" PackLocation="top,left" Progress="0.500" ScrollExtent="109,6" Size="109,6" Style="/progressbarlist.progress_default" Tooltip=":4bb9327f3689d9da:Health" />
                        <Image AbsorbsInput="false" BackgroundColor="#440000" BackgroundOpacity="0.800" Location="2,17" Name="HealthBarBkg" ScrollExtent="109,6" Size="109,6" />
                        <Image AbsorbsInput="false" Location="2,25" Name="ManaBubblesOverlay" ScrollExtent="109,6" Size="109,6" SourceRect="267,183,376,189" SourceResource="/images/window_elements_generic.dds" Stretch="false" />
                        <Progressbar AbsorbsInput="false" Color="#6F64FE" Location="2,25" Name="ManaBar" PackLocation="top,left" Progress="1.000" ScrollExtent="109,6" Size="109,6" Style="/progressbarlist.progress_default" Tooltip=":4bb9327f3f1b16f3:Mana" />
                        <Image AbsorbsInput="false" BackgroundColor="#000044" BackgroundOpacity="0.800" Location="2,25" Name="ManaBarBkg" ScrollExtent="109,6" Size="109,6" />
                    </Page>
                    ...

The first arguments, [MainHUD,GroupMembers], comes from the file name.   Then, we want to get down to the "MemberInfo" Page that has the Name text element.  So, to do this, we simply follow the xml down level by level using [Page,GroupMember5.MemberInfoPage.MemberInfo].    (Of course, in the snippet, we use ${GroupCounter} instead of the actual number.)

Once you've gotten a handle on the "MemberInfo" page, then you can see that it has 8 children.   The second child is a Text element named "Name" -- and that's the one we're looking for.    Due to ISXEQ2 limitations, our script snippet needs to ensure that the design/structure of this xml file matches what we expect (i.e., that there are 8 children and the second one is a text element.)   If this changes, then the script snippet would need to change as well.