Files
aowow/setup/tools/filegen/pets.func.php
Sarjuuk feaee59cd0 - converted articles for MorePages to use STATIC_URL (also neutralized some self-references)
- added config-option to restrict available locales
- fixed opensearch suggestions by generating strict json
- include TalentCalc.css as lowerCase (fixes display under *nix)
- some minor formating
- Setup:
 * added some additional files to be generated (they required STATIC_URL or HOST_URL to be set)
 * moved class Locale from global.js to own template and generate it with CFG_LOCALES
 * changed urlParam (?build=script): may be empty (builds everything) or specific scriptNames chained together with ; (?build=script1;script2)

you are required to run the following command to regenerate files affected by these cahnges
?build=demo;power;realmMenu;searchboxBody;searchboxScript;searchplugin;locales
2014-09-13 23:26:01 +02:00

120 lines
5.0 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
// builds 'pets'-file for available locales
// this script requires the following dbc-files to be parsed and available
// CreatureFamily, CreatureDisplayInfo, FactionTemplate, AreaTable
// Todo:
// locations are a tiny bit wide at the moment.
// I'm still undecided wether the old system is pure genius or pure madness. While building the zone-maps it also generated masks for that zone, using the alpha-channel in the *.blp
// When deciding what spawn lies where you could check against the relative coordinates of that mask. black => isInZone; white => notInZone
// Since i'm lacking other options this will probably be reimplemented.
/* Example data
30: {
id:30,
name:'Forest Spider',
minlevel:5,
maxlevel:6,
location:[12], // master-AreaTableId's (?)
react:[-1,-1],
classification:0, // 0:"Normal", 1:"Elite", 2:"Rar Elite", 3:"Boss", 4:"Rar"
family:3, // creatureFamily
displayId:382,
skin:'TarantulaSkinOrange',
icon:'Ability_Hunter_Pet_Spider', // from creatureFamily.dbc
type:2 // 0:Ferocity, 1:Tenacity, 2:Cunning
},
*/
function pets(&$log, $locales)
{
$success = true;
$locations = [];
$qZones = 'SELECT DISTINCT z.id
FROM creature c
JOIN ?_zones z ON z.xMin < c.position_x AND z.xMax > c.position_x AND z.yMin < c.position_y AND z.yMax > c.position_y AND z.mapId = c.map
WHERE c.id = ?d';
$qInstances = 'SELECT DISTINCT z.id
FROM creature c, ?_zones z
WHERE z.mapId = c.map AND c.id = ?d';
$petList = DB::Aowow()->Select(
'SELECT ct.entry AS id,
ct.name,
lc.*,
ct.minlevel,
ct.maxlevel,
CONCAT("[", ft.A, ", ", ft.H, "]") AS react,
ct.rank AS classification,
ct.family,
ct.modelId1 AS displayId,
cdi.skin1 AS skin,
SUBSTRING_INDEX(cf.iconFile, "\\\\", -1) AS icon,
cf.petTalentType AS type
FROM creature_template ct
JOIN ?_factiontemplate ft ON ft.Id = ct.faction
JOIN dbc.creaturefamily cf ON cf.Id = ct.family
LEFT JOIN locales_creature lc ON lc.entry = ct.entry
JOIN dbc.creaturedisplayinfo cdi ON cdi.id = ct.modelId1
WHERE cf.petTalentType <> -1 AND ct.type_flags & 0x1
ORDER BY ct.entry ASC');
// check directory-structure
foreach (Util::$localeStrings as $dir)
if (!writeDir('datasets/'.$dir, $log))
$success = false;
foreach ($locales as $lId)
{
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$petsOut = [];
foreach ($petList as $pet)
{
// get locations
// again: caching will save you time and nerves
if (!isset($locations[$pet['id']]))
{
$locations[$pet['id']] = DB::Aowow()->SelectCol($qZones, $pet['id']);
// probably instanced, map <=> areaId _should_ be bijective
if (empty($locations[$pet['id']]))
if ($z = DB::Aowow()->SelectCell($qInstances, $pet['id']))
$locations[$pet['id']][] = $z;
}
$petsOut[$pet['id']] = array(
'id' => $pet['id'],
'name' => Util::localizedString($pet, 'name'),
'minlevel' => $pet['minlevel'],
'maxlevel' => $pet['maxlevel'],
'location' => $locations[$pet['id']],
'react' => $pet['react'],
'classification' => $pet['classification'],
'family' => $pet['family'],
'displayId' => $pet['displayId'],
'skin' => $pet['skin'],
'icon' => $pet['icon'],
'type' => $pet['type']
);
}
$toFile = "var g_pets = ";
$toFile .= json_encode($petsOut, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK);
$toFile .= ";";
$file = 'datasets/'.User::$localeString.'/pets';
if (!writeFile($file, $toFile, $log))
$success = false;
}
return $success;
}
?>