2 include_once("include/simple_cacher.php");
4 function generateCharacterBild($guid, $class, $spec)
6 global $talentTabId, $cDB, $wDB;
7 $tab_set = $wDB->selectCol('SELECT `id` FROM `wowd_talent_tab` WHERE `class_mask` & ?d ORDER BY `tab` ', 1<<($class-1));
11 $tinfo = $wDB->select(
14 `TalentTab` AS ARRAY_KEY_1,
22 FROM `wowd_talents` WHERE `TalentTab` IN (?a) ORDER BY `TalentTab`, `Row`, `Col`', $tab_set);
23 $points = array(0, 0, 0);
27 foreach($tab_set as $i=>$tab)
29 foreach($tinfo[$tab] as $row=>$rows)
30 foreach($rows as $col=>$data)
32 $rank = $cDB->selectCell('SELECT `current_rank` FROM `character_talent` WHERE `guid` = ?d and `spec` = ?d AND `talent_id`=?d', $guid, $spec, $data['TalentID']);
33 if (isset($rank)) ++
$rank;
39 if ($points[$i] > $max) {$max = $points[$i]; $name = getTalentName($tab);}
41 return array('calc_bild'=>$bild, 'points'=>$points, 'total'=>$total, 'name'=>$name);
44 function includeTalentScript($class, $petId, $maxLevel, $header, $ver = "322")
46 global $wDB, $game_text, $config;
52 $tab_set = $wDB->selectCol('SELECT `id` FROM `wowd_talent_tab` WHERE `class_mask` & ?d ORDER BY `tab` ', 1<<($class-1));
56 // For pets (need get pet_talent_type from creature_family)
57 $talent_type = $wDB->selectCell('SELECT `pet_talent_type` FROM `wowd_creature_family` WHERE `category` = ?d', $petId);
58 if (isset($talent_type) && $talent_type>=0)
59 $tab_set = $wDB->selectCol('SELECT `id` FROM `wowd_talent_tab` WHERE `pet_mask` & ?d ORDER BY `tab`', 1<<$talent_type);
63 // Создаём кэш для калькулятора (если его нет или устарел)
64 $data_file = "tc_".$class.$petId."_".$config['lang']."_".$ver.".js";
65 if (checkUseCacheJs($data_file, 60*60*24))
67 // Подготаливаем данные для скрипта
68 $tab_name = array(); // Имена веток талантов
69 $tid_to_tab = array(); // Преборазователь TalentId => TabId
70 $tabs = array(); // Тут уже будут данные для JS скрипта
71 $spell_desc = array(); // Тут хранятся описания спеллов
72 $t_row = 0; // Максимум строк
73 $t_col = 0; // Максимум колонок
75 // Стрелки зависимосей описаны тут
77 '0_1' =>array('img'=>'right', 'x'=>-14,'y'=>12),
78 '0_-1'=>array('img'=>'left', 'x'=> 40,'y'=>12),
79 '1_-1'=>array('img'=>'down-left', 'x'=> 14,'y'=>-40),
80 '1_0' =>array('img'=>'down-1', 'x'=> 13,'y'=>-12),
81 '2_0' =>array('img'=>'down-2', 'x'=> 13,'y'=>-70),
82 '2_1' =>array('img'=>'down2-right','x'=>-13,'y'=>-94),
83 '2_-1'=>array('img'=>'down2-left','x'=>14,'y'=>-94),
84 '3_0' =>array('img'=>'down-3', 'x'=> 13,'y'=>-128),
85 '4_0' =>array('img'=>'down-4', 'x'=> 13,'y'=>-188),
86 '1_1' =>array('img'=>'down-right','x'=>-13,'y'=>-40)
88 // Получаем данные о ветках из базы и переводим их в нужный формат
92 $talents = $wDB->select(
94 `TalentID` AS ARRAY_KEY,
107 WHERE `TalentTab` IN (?a)', $tab_set);
109 else if ($petId >= 0)
114 if ($petId < 32) $petMask1=1<<($petId );
115 else $petMask2=1<<($petId-32);
116 $talents = $wDB->select(
118 `TalentID` AS ARRAY_KEY,
132 `TalentTab` IN (?a) AND ((`petflag1`=0 AND `petflag2`=0) OR (`petflag1`& ?d) OR (`petflag2`& ?d))', $tab_set, $petMask1, $petMask2);
135 // Заполняем преборазователь TalentId => TabId и Имена веток талантов
136 foreach ($tab_set as $id=>$tid)
138 $tid_to_tab[$tid]=$id;
139 $tab_name[$id] = getTalentName($tid);
142 foreach($talents as $id=>$t)
144 $tabId = $tid_to_tab[$t['TalentTab']];
151 if ($t_row <= $row) $t_row = $row+
1;
152 if ($t_col <= $col) $t_col = $col+
1;
156 $spellid = $t['Rank_'.$i];
160 $spells[$i-1] = $spellid;
161 $spell = getSpell($spellid);
162 if ($icon==0) $icon = getSpellIconName($spell['SpellIconID']);
163 $name = $spell['SpellName'];
164 $spell_desc[$spellid]=array('name'=>$name, 'desc'=>getSpellDesc($spell));
166 $tabs[$tabId.'_'.$row.'_'.$col]=array('id'=>$id, 'spells'=>$spells, 'icon'=>$icon, 'max'=>$max);
168 if ($t['DependsOn'] && isset($talents[$t['DependsOn']]))
170 $d = $talents[$t['DependsOn']];
171 $dx = $t['Row']-$d['Row'];
172 $dy = $t['Col']-$d['Col'];
173 $a = $arrows[$dx."_".$dy];
174 $tabs[$tabId.'_'.$row.'_'.$col]['depend'] = array(
175 'id'=>$tid_to_tab[$d['TalentTab']]."_".$d['Row']."_".$d['Col'],
176 'rank'=>$t['DependsOnRank'],
178 'x'=>intval($a['x']),
179 'y'=>intval($a['y']));
185 var tc_showclass ="'.($class?
$class:$tab_set[0]).'";
186 var tc_name = '.php2js($tab_name).';
187 var tc_tabs = '.count($tab_set).';
188 var tc_row = '.$t_row.';
189 var tc_col = '.$t_col.';
190 var tc_tab = '.php2js($tabs).';
191 var tc_point_per_row = '.$ppr.';
192 var tc_spell_desc = '.php2js($spell_desc).';
193 var lang_rank = "'.$game_text['talent_rank'].'";
194 var lang_next_rank = "'.$game_text['talent_next_rank'].'";
195 var lang_req_points = "'.$game_text['talent_req_points'].'";';
196 flushJsCache($data_file);
199 <script type="text/javascript" id = "talent_calc">
200 var tc_maxlevel = '.$maxLevel.';
201 var lang_header = \''.$header.'\';
203 <script type="text/javascript" src="js/talent_calc_base.js"></script>';