Esempio n. 1
0
$v->combat_actions = array(2, 3, 4, 10, 15, 16, 19, 22, 23, 26);
//Log and line stuff.
$v->line = 0;
$v->byte_count = 0;
$v->killed_bosses = array();
$params = array();
$encounter = null;
//Now we need to parse it.
while ($parser->parseLine(true)) {
    $v->line++;
    $v->byte_count += $parser->getBytes();
    if ($v->line % 100000 == 0) {
        $params['milestone'][] = $v->byte_count;
    }
    //Check if time rolled over.
    $v->ts = $parser->getSeconds();
    if ($v->ts < $v->ts_last) {
        $v->date += 86400;
    }
    $v->timestamp = $v->date + ($v->ts_last = $v->ts);
    //We want to see if this is a permitted action to start combat.
    $is_action = in_array($parser->type_id, $v->combat_actions);
    //Starting condition to get us in combat.
    if (!$v->combat && $is_action) {
        $v->combat = true;
        $encounter = new Encounter($v->timestamp, $v->line, $encounter, $v->killed_bosses);
    }
    //Handle mid-combat events.
    if ($v->combat) {
        if ($is_action && $encounter->actor($parser)) {
            $encounter->last_active = $v->timestamp;
Esempio n. 2
0
 /**
  *
  */
 function getUserData($log_id, $lower, $upper, $name)
 {
     //Return data if it is already loaded.
     if (isset($this->data)) {
         return $this->data;
     }
     //Initialize stuff.
     $data =& $this->data;
     $parser =& $this->parser;
     //Init vars.
     $parser = new LogParser($log_id, $lower, $upper, $this->db);
     $user_id = $parser->getID($name);
     //Start up the data class.
     $data = new stdClass();
     $data->abilities = array('dmg' => array(), 'heal' => array(), 'taken' => array());
     $data->deaths = array();
     $data->totals = array('dmg' => 0, 'heal' => 0, 'taken' => 0, 'heal_modified' => 0);
     //Loop through the contents and prepare data.
     while ($status = $parser->parseLine()) {
         //Skip misread lines.
         if ($status != LogParser::SUCCESS) {
             continue;
         }
         //Load up a timestamp.
         $timestamp = $parser->getSeconds();
         //Set the initial value for the timer if it hasn't started.
         if (!isset($data->l)) {
             $data->l = $timestamp;
             $data->timestamp = $timestamp;
         }
         //Check if this is even the person we want.
         if ($parser->origin_id != $user_id && $parser->target_id != $user_id || in_array($parser->attack_id, $this->global_filter)) {
             continue;
         }
         //Capture the data types.
         switch ($parser->type_id) {
             //Damage |3=hit,4=suffers,10=miss,15=dodge,16=parry,19=resist,23=crit|
             case 3:
             case 4:
             case 10:
             case 15:
             case 16:
             case 19:
             case 23:
                 //Check if this is a player.
                 $is_player = $parser->origin_id == $user_id;
                 if ($is_player) {
                     $attack =& $data->abilities['dmg'][$parser->attack_name];
                 } else {
                     $attack =& $data->abilities['taken'][$parser->attack_name];
                 }
                 //Set the variable if necessary.
                 if (!isset($attack)) {
                     $attack = array('total' => 0, 'cast' => 0, 'max' => 0, 'crits' => 0, 'misses' => 0, 'id' => $parser->attack_id);
                     //If this isn't a player we want to add more accurate details.
                     if (!$is_player) {
                         $attack += array('parry' => 0, 'dodge' => 0, 'origin' => $parser->origin_name, 'block_count' => 0, 'block_total' => 0);
                     }
                 }
                 $total = $is_player ? $parser->damage + $parser->absorbed : $parser->damage;
                 $attack['total'] += $total;
                 $attack['cast'] += 1;
                 $attack['max'] = $attack['max'] > $total ? $attack['max'] : $total;
                 //Calculating minimum.
                 if (isset($attack['min'])) {
                     $attack['min'] = $attack['min'] < $total ? $attack['min'] : $total;
                 } else {
                     $attack['min'] = $total;
                 }
                 $attack['crits'] += $parser->type_id == 23 ? 1 : 0;
                 $attack['misses'] += in_array($parser->type_id, array(10, 15, 16, 19)) ? 1 : 0;
                 //Log parry and dodges.
                 if (!$is_player) {
                     switch ($parser->type_id) {
                         case 15:
                             $attack['dodge']++;
                             break;
                         case 16:
                             $attack['parry']++;
                             break;
                     }
                 }
                 //Log some block details.
                 if (!$is_player && $parser->blocked > 0) {
                     $attack['block_count']++;
                     $attack['block_total'] += $parser->blocked;
                 }
                 $data->totals[$is_player ? 'dmg' : 'taken'] += $total;
                 if (!$is_player) {
                     //Logging a hostile action against the player.
                     $this->logAction($parser->type_id == 23 ? 'crits' : $parser->type_id == 3 ? 'hits' : 'damages');
                     //We want to find the deathblow if the character is going to die.
                     if ($parser->overkill > 0 || $this->is_dying) {
                         $this->processDeath();
                     }
                 }
                 break;
                 //Healing |5=heal,28=crit|
             //Healing |5=heal,28=crit|
             case 5:
             case 28:
                 //Dave: For some reason disarm attacks appear in here so there's an extra statement in the if.
                 if ($parser->origin_id == $user_id && ($parser->overheal != 0 || $parser->damage != 0)) {
                     //Filter out stuff we don't want.
                     if (in_array($parser->attack_id, $this->heal_filter)) {
                         continue;
                     }
                     $heal =& $data->abilities['heal'][$parser->attack_name];
                     if (!isset($heal)) {
                         $heal = array('total' => 0, 'total_modified' => 0, 'cast' => 0, 'max' => 0, 'min' => 0, 'crits' => 0, 'overheal' => 0, 'id' => $parser->attack_id);
                     }
                     $heal['total'] += $parser->damage;
                     $heal['total_modified'] += $parser->damage + $parser->overheal;
                     $heal['cast'] += 1;
                     $heal['max'] = $heal['max'] > $parser->damage ? $heal['max'] : $parser->damage;
                     $heal['min'] = isset($heal['min']) ? $heal['min'] < $parser->damage ? $heal['min'] : $parser->damage : $parser->damage;
                     $heal['crits'] += $parser->type_id == 28 ? 1 : 0;
                     $heal['overheal'] += $parser->overheal;
                     $data->totals['heal'] += $parser->damage;
                     $data->totals['heal_modified'] += $parser->damage + $parser->overheal;
                 } else {
                     //Logging an incoming heal to the player.
                     $this->logAction('heals');
                 }
                 break;
                 //Deaths |11=slain,12=died|
             //Deaths |11=slain,12=died|
             case 11:
             case 12:
                 if ($parser->type_id == 11 && $parser->origin_id != $user_id || $parser->type_id == 12) {
                     $this->is_dying = true;
                 }
                 break;
         }
     }
     //Calculate the final length.
     $data->l = $parser->getSeconds() - $data->l;
     //Uset unneccesary data and sort.
     unset($this->parser, $this->actions);
     uasort($data->abilities['dmg'], array('Data_model', 'sort'));
     uasort($data->abilities['heal'], array('Data_model', 'sort'));
     uasort($data->abilities['taken'], array('Data_model', 'sort'));
     return $data;
 }