[[], CLISetup::ARGV_PARAM, 'Compiles tameable hunter pets to file for the talent calculator tool.'] ); protected $dbcSourceFiles = ['creaturefamily']; protected $setupAfter = [['creature', 'factions', 'spawns'], []]; protected $requiredDirs = ['datasets/']; protected $localized = true; public function generate() : bool { $petList = DB::Aowow()->Select( 'SELECT cr.id, cr.name_loc0, cr.name_loc2, cr.name_loc3, cr.name_loc4, cr.name_loc6, cr.name_loc8, cr.minLevel, cr.maxLevel, ft.A, ft.H, cr.rank AS classification, cr.family, cr.displayId1 AS displayId, cr.textureString AS skin, LOWER(SUBSTRING_INDEX(cf.iconString, "\\\\", -1)) AS icon, cf.petTalentType AS type FROM ?_creature cr JOIN ?_factiontemplate ft ON ft.id = cr.faction JOIN dbc_creaturefamily cf ON cf.id = cr.family WHERE cr.typeFlags & 0x1 AND (cr.cuFlags & 0x2) = 0 ORDER BY cr.id ASC'); $locations = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, `areaId` AS ARRAY_KEY2, `areaId` FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) GROUP BY `typeId`, `areaId`', Type::NPC, array_column($petList, 'id')); foreach (CLISetup::$locales as $lId => $jsonStr) { User::useLocale($lId); Lang::load($lId); $petsOut = []; foreach ($petList as $pet) { $petsOut[$pet['id']] = array( 'id' => $pet['id'], 'name' => Util::localizedString($pet, 'name'), 'minlevel' => $pet['minLevel'], 'maxlevel' => $pet['maxLevel'], 'location' => $locations[$pet['id']] ?? [], 'react' => [$pet['A'], $pet['H']], 'classification' => $pet['classification'], 'family' => $pet['family'], 'displayId' => $pet['displayId'], 'skin' => $pet['skin'], 'icon' => $pet['icon'], 'type' => $pet['type'] ); } $toFile = "var g_pets = ".Util::toJSON($petsOut).";"; $file = 'datasets/'.$jsonStr.'/pets'; if (!CLISetup::writeFile($file, $toFile)) $this->success = false; } return $this->success; } }); ?>