Esempio n. 1
0
 public function getModelInfo($spellId = 0, $effIdx = 0)
 {
     $displays = [0 => []];
     foreach ($this->iterate() as $id => $__) {
         if ($spellId && $spellId != $id) {
             continue;
         }
         for ($i = 1; $i < 4; $i++) {
             $effMV = $this->curTpl['effect' . $i . 'MiscValue'];
             if (!$effMV) {
                 continue;
             }
             // GO Model from MiscVal
             if (in_array($this->curTpl['effect' . $i . 'Id'], [50, 76, 104, 105, 106, 107])) {
                 if (isset($displays[TYPE_OBJECT][$id])) {
                     $displays[TYPE_OBJECT][$id][0][] = $i;
                 } else {
                     $displays[TYPE_OBJECT][$id] = [[$i], $effMV];
                 }
             } else {
                 if (in_array($this->curTpl['effect' . $i . 'Id'], [28, 90, 134]) || in_array($this->curTpl['effect' . $i . 'AuraId'], [56, 78])) {
                     if (isset($displays[TYPE_NPC][$id])) {
                         $displays[TYPE_NPC][$id][0][] = $i;
                     } else {
                         $displays[TYPE_NPC][$id] = [[$i], $effMV];
                     }
                 } else {
                     if ($this->curTpl['effect' . $i . 'AuraId'] == 36) {
                         $subForms = array(892 => [892, 29407, 29406, 29408, 29405], 8571 => [8571, 29410, 29411, 29412], 2281 => [2281, 29413, 29414, 29416, 29417], 2289 => [2289, 29415, 29418, 29419, 29420, 29421]);
                         if ($st = DB::Aowow()->selectRow('SELECT *, displayIdA as model1, displayIdH as model2 FROM ?_shapeshiftforms WHERE id = ?d', $effMV)) {
                             foreach ([1, 2] as $j) {
                                 if (isset($subForms[$st['model' . $j]])) {
                                     $st['model' . $j] = $subForms[$st['model' . $j]][array_rand($subForms[$st['model' . $j]])];
                                 }
                             }
                             $displays[0][$id][$i] = array('typeId' => 0, 'displayId' => $st['model2'] ? $st['model' . rand(1, 2)] : $st['model1'], 'creatureType' => $st['creatureType'], 'displayName' => Util::localizedString($st, 'name'));
                         }
                     }
                 }
             }
         }
     }
     $results = $displays[0];
     if (!empty($displays[TYPE_NPC])) {
         $nModels = new CreatureList(array(['id', array_column($displays[TYPE_NPC], 1)]));
         foreach ($nModels->iterate() as $nId => $__) {
             $srcId = 0;
             foreach ($displays[TYPE_NPC] as $srcId => $set) {
                 if ($set[1] == $nId) {
                     break;
                 }
             }
             foreach ($set[0] as $idx) {
                 $results[$srcId][$idx] = array('typeId' => $nId, 'displayId' => $nModels->getRandomModelId(), 'displayName' => $nModels->getField('name', true));
             }
         }
     }
     if (!empty($displays[TYPE_OBJECT])) {
         $oModels = new GameObjectList(array(['id', array_column($displays[TYPE_OBJECT], 1)]));
         foreach ($oModels->iterate() as $oId => $__) {
             $srcId = 0;
             foreach ($displays[TYPE_OBJECT] as $srcId => $set) {
                 if ($set[1] == $oId) {
                     break;
                 }
             }
             foreach ($set[0] as $idx) {
                 $results[$srcId][$idx] = array('typeId' => $oId, 'displayId' => $oModels->getField('displayId'), 'displayName' => $oModels->getField('name', true));
             }
         }
     }
     if ($spellId && $effIdx) {
         return !empty($results[$spellId][$effIdx]) ? $results[$spellId][$effIdx] : 0;
     }
     return $results;
 }