EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   qglobal timers (https://www.eqemulator.org/forums/showthread.php?t=36285)

c0ncrete 01-19-2013 09:42 AM

qglobal timers
 
would there be an efficient way to expose the time left for a specific qglobal to perl without using a database query (e.g. an additional c++ to perl interface)?

i'm attempting to sort out a way to handle setting multiple lockout timers to a new value. i need to make sure i skip timers that have more than the new value remaining, but extend the ones that have less than the new value remaining (or don't exist at all).

is my best option to include a timestamp for the lockout in the value field along with the areas the client is locked out of?

lerxst2112 01-19-2013 07:17 PM

I suppose you could export another hash of name, expiration where the name, value hash is exported.

c0ncrete 01-20-2013 01:18 PM

update: going with something like this

Code:

use 5.012;

# NOTE: this is from a separate data file that will be read by Master_of_<...>
#      (truncated to only include what is needed for test)

# grouped by projection
our $trial = {
    mind => {
        fear => {              # 304004
            type => "group",
        },
        hatred => {            # not in db
            type => "raid",
        },
    },
    body => {
        weaponry => {          # not in db
            type => "group",
        },
        endurance => {        # not in db
            type => "raid",
        },
    },
    tactics => {
        subversion => {        # 306001
            type => "group",
        },
        foresight => {        # not in db
            type => "raid",
        },
    },
    arcana => {
        efficiency => {        # 307000
            type => "group",
        },
        specialization => {    # not in db
            type => "raid",
        },
    },
    realms => {
        ingenuity => {        # 308007
            type => "group",
        },
        adaptation => {        # not in db
            type => "raid",
        },
    },
    power => {
        destruction => {      # 309061
            type => "group",
        },
        corruption => {        # not in db
            type => "raid",
        },
    },
};

# NOTE: we'll do the following per participant in trial instance

my %qglobals = ( 'MPG_lockout_foresight:1234' => 2358708441 );    # testing
my $master_of    = "Corruption";    # plugin::fixNPCName() =~ /of (\w+)/
my $character_id = 1234;            # $client->GetCharcterID()
my $time_done    = time;
my $trial_type  = "raid";          # for testing
while ( my ( undef, $trial_data ) = each %$trial ) {
    foreach my $trial_name ( keys %{$trial_data} ) {

        # skip trial if not of same type as the one completed
        next if $trial_type ne $trial_data->{$trial_name}->{type};

        # default time to lock out of trials until (epoch time)
        my $lockout = $time_done + 7200;

        # construct qglobal name for current client
        my $varname = "MPG_lockout_$trial_name:$character_id";

        # skip if current lockout timer is further out than new one
        next if $qglobals{$varname} > $lockout;

        # default qglobal expiration timer
        my $expires = 2;

        # set current trial lockout to 72 hours if won
        # NOTE: 1 assumes win for the time being
        if ( $trial_name eq lc $master_of and 1 ) {
            $lockout += 252000;
            $expires += 70;
        }

        # set qglobal (available to all clients, npcs, and zones)
        say sprintf "quest::setglobal('%s', %d, 7, '%s');",
          $varname, $lockout, "H$expires";
    }
}

test output:

Code:

quest::setglobal('MPG_lockout_specialization:1234', 1358708441, 7, 'H2');
quest::setglobal('MPG_lockout_endurance:1234', 1358708441, 7, 'H2');
quest::setglobal('MPG_lockout_adaptation:1234', 1358708441, 7, 'H2');
quest::setglobal('MPG_lockout_corruption:1234', 1358960441, 7, 'H72');
quest::setglobal('MPG_lockout_hatred:1234', 1358708441, 7, 'H2');

foresight is skipped because the lockout is much longer already
corruption is set to 72 hours because of the win
all others set to 2 hour lockout

lerxst2112 01-20-2013 08:01 PM

Yeah, that'll work too. I thought you might want the expiration on arbitrary qglobals, but for values where you control the data this is a clever solution.


All times are GMT -4. The time now is 05:06 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.