Skip to content

[Quest API] Add GetMemberRole method to Perl/Lua#4963

Merged
Kinglykrab merged 4 commits intoEQEmu:masterfrom
Barathos:group_role_api
Jul 10, 2025
Merged

[Quest API] Add GetMemberRole method to Perl/Lua#4963
Kinglykrab merged 4 commits intoEQEmu:masterfrom
Barathos:group_role_api

Conversation

@Barathos
Copy link
Copy Markdown
Contributor

@Barathos Barathos commented Jul 2, 2025

Description

Adds scripting support to retrieve group member roles (Leader, Main Tank, Main Assist, Puller) using the new GetMemberRole(member) method in both Perl and Lua.

This exposes previously internal role bitmasks from groups.h to scripting languages.

Fixes # (n/a – enhancement)

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

Clients tested: RoF2

Tested with a group containing both player characters and bots. Verified output from both Lua and Perl via event_say.

All role bitmask constants verified against groups.h. Functions return correctly based on assignment via in-game group window.

Perl Output:

sub EVENT_SAY {
    return unless $client;              
    return unless $text =~ /roles/i;

    my $group = $client->GetGroup();
    unless ($group) {
        quest::say("You are not in a group.");
        return;
    }

    for (my $i = 0; $i < $group->GroupCount(); $i++) {
        my $member = $group->GetMember($i);
        next unless $member;            # empty slot

        my $flags = $group->GetMemberRole($member);
        my @roles;
        push(@roles, "Leader")      if $flags & 8;  # RoleLeader
        push(@roles, "Main Assist") if $flags & 1;  # RoleAssist
        push(@roles, "Main Tank")   if $flags & 2;  # RoleTank
        push(@roles, "Puller")      if $flags & 4;  # RolePuller

        quest::say($member->GetCleanName() . ": " . join(', ', @roles)) if @roles;
    }
}

image

=== Perl Script $group->GetMemberRole(member) output ===
Aybekais - Role Mask 8 => Leader
Warrbot - Role Mask 2 => Main Tank

Lua Output:

local ROLE_ASSIST  = 1
local ROLE_TANK    = 2
local ROLE_PULLER  = 4
local ROLE_LEADER  = 8

function event_say(e)
    if e.message:findi("roles") then
        PrintGroupRoles(e)
    end
end

function PrintGroupRoles(e)
    local cl = e.self
    local g  = cl:GetGroup()

    if not g.valid then
        cl:Message(15, "You are not in a group.")
        return
    end

    cl:Message(15, "=== LUA Script: g:GetMemberRole(member) output ===")

    for i = 0, g:GroupCount() - 1 do
        local member = g:GetMember(i)
        if member.valid then
            local mask = g:GetMemberRole(member)
            local roles = {}

            if bit.band(mask, ROLE_LEADER) ~= 0 then table.insert(roles, "Leader") end
            if bit.band(mask, ROLE_TANK)   ~= 0 then table.insert(roles, "Main Tank") end
            if bit.band(mask, ROLE_ASSIST) ~= 0 then table.insert(roles, "Main Assist") end
            if bit.band(mask, ROLE_PULLER) ~= 0 then table.insert(roles, "Puller") end

            local role_str = (#roles > 0) and table.concat(roles, ", ") or "None"
            cl:Message(15, member:GetCleanName() .. " - Role Mask: " .. mask .. " => " .. role_str)
        end
    end

    cl:Message(15, "==============================================")
end

image

=== LUA Script g:GetMemberRole(member) output ===
Aybekais - Role Mask 8 => Leader
Warrbot - Role Mask 2 => Main Tank

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I have made corresponding changes to the documentation (if applicable)
  • I own the changes of my code and take responsibility for the potential issues that occur
  • This change does not require any database schema changes

@Barathos Barathos changed the title Group role api [Quest API] Add GetMemberRole method to Perl/Lua Jul 2, 2025
@Barathos
Copy link
Copy Markdown
Contributor Author

Barathos commented Jul 2, 2025

The group role does not persist across zones, it has to be reset each time you zone, not sure of how to fix that :( .

@Kinglykrab Kinglykrab merged commit b8884d6 into EQEmu:master Jul 10, 2025
1 check passed
@Akkadius Akkadius mentioned this pull request Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants