Thread: qglobal timers
View Single Post
  #3  
Old 01-20-2013, 01:18 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

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
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote