Setup/Scripts

* restructure setup to allow for self contained setup steps to self register (just the sql for now)
 * should ease adding new scripts in future
This commit is contained in:
Sarjuuk
2019-07-31 23:25:44 +02:00
parent 163e3d82b0
commit ccef11323b
51 changed files with 5345 additions and 4964 deletions

View File

@@ -17,6 +17,7 @@ define('ERR_MISSING_INCL', 'required function %s() could not be found at %s');
require_once 'setup/tools/CLISetup.class.php';
require_once 'setup/tools/setupScript.class.php';
require_once 'setup/tools/dbc.class.php';
require_once 'setup/tools/imagecreatefromblp.func.php';

View File

@@ -0,0 +1,76 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
trait TrDBCcopy
{
public function generate() : bool
{
if (!$this->dbcSourceFiles)
{
CLI::write(' SetupScript '.$this->command.' is set up for DBCcopy but has no source set!', CLI::LOG_ERROR);
return false;
}
else if (count($this->dbcSourceFiles) != 1)
CLI::write(' SetupScript '.$this->command.' is set up for DBCcopy but has multiple sources set!', CLI::LOG_WARN);
CLI::write('SqlGen::generate() - copying '.$this->dbcSourceFiles[0].'.dbc into aowow_'.$this->command);
$dbc = new DBC($this->dbcSourceFiles[0], ['temporary' => false, 'tableName' => 'aowow_'.$this->command]);
if ($dbc->error)
return false;
return !!$dbc->readFile();
}
}
trait TrCustomData
{
// apply post generator custom data
public function applyCustomData() : void
{
if (!$this->customData)
return;
foreach ($this->customData as $id => $data)
if ($data)
DB::Aowow()->query('UPDATE ?_'.$this->command.' SET ?a WHERE id = ?d', $data, $id);
}
}
abstract class SetupScript
{
protected $fileTemplatePath = '';
protected $fileTemplateFile = '';
protected $tblDependancyAowow = [];
protected $tblDependancyTC = [];
protected $dbcSourceFiles = [];
// abstract protected $command;
abstract public function generate() : bool;
public function getRequiredDBCs() : array
{
return $this->dbcSourceFiles;
}
public function getDependancies(bool $aowow) : array
{
return $aowow ? $this->tblDependancyAowow : $this->tblDependancyTC;
}
public function getName() : string
{
return $this->command;
}
}
?>

View File

@@ -7,74 +7,14 @@ if (!CLI)
die('not in cli mode');
/* provide these with basic content
aowow_announcements
aowow_articles
aowow_config
aowow_home_featuredbox
aowow_home_featuredbox_overlay
aowow_home_oneliners
aowow_home_titles
aowow_sourcestrings
*/
class SqlGen
{
const MODE_NORMAL = 1;
const MODE_FIRSTRUN = 2;
const MODE_UPDATE = 3;
private static $tables = array( // [dbcName, saveDbc, AowowDeps, TCDeps]
'achievementcategory' => ['achievement_category', false, null, null],
'achievementcriteria' => ['achievement_criteria', false, null, null],
'itemenchantmentcondition' => ['spellitemenchantmentcondition', false, null, null],
'itemextendedcost' => ['itemextendedcost', false, null, null],
'itemlimitcategory' => ['itemlimitcategory', false, null, null],
'itemrandomproppoints' => ['randproppoints', false, null, null],
'lock' => ['lock', true, null, null],
'mailtemplate' => ['mailtemplate', false, null, null],
'scalingstatdistribution' => ['scalingstatdistribution', true, null, null],
'scalingstatvalues' => ['scalingstatvalues', true, null, null],
'spellfocusobject' => ['spellfocusobject', false, null, null],
'spelloverride' => ['overridespelldata', false, null, null],
'spellrange' => ['spellrange', false, null, null],
'spellvariables' => ['spelldescriptionvariables', false, null, null],
'totemcategory' => ['totemcategory', false, null, null],
'icons' => [null, null, null, null],
'glyphproperties' => [null, true, ['icons'], null],
'talents' => [null, null, null, null],
'classes' => [null, null, null, null],
'factions' => [null, null, null, null],
'factiontemplate' => [null, null, null, null],
'holidays' => [null, null, null, null],
'itemrandomenchant' => [null, null, null, null],
'races' => [null, null, null, null],
'shapeshiftforms' => [null, null, null, null],
'skillline' => [null, null, ['icons'], null],
'emotes' => [null, null, null, null],
'sounds' => [null, null, null, null],
'areatrigger' => [null, null, null, ['areatrigger_involvedrelation', 'areatrigger_scripts', 'areatrigger_tavern', 'areatrigger_teleport', 'quest_template', 'quest_template_addon']],
'itemenchantment' => [null, null, null, ['spell_enchant_proc_data']],
'achievement' => [null, null, ['icons'], ['dbc_achievement', 'disables']],
'creature' => [null, null, null, ['creature_template', 'creature_template_locale', 'creature_classlevelstats', 'instance_encounters']],
'currencies' => [null, null, null, ['item_template', 'item_template_locale']],
'events' => [null, null, null, ['game_event', 'game_event_prerequisite']],
'objects' => [null, null, null, ['gameobject_template', 'gameobject_template_locale', 'gameobject_questitem']],
'pet' => [null, null, ['icons'], ['creature_template', 'creature']],
'quests' => [null, null, null, ['quest_template', 'quest_template_addon', 'quest_template_locale', 'game_event', 'game_event_seasonal_questrelation', 'disables']],
'quests_startend' => [null, null, null, ['creature_queststarter', 'creature_questender', 'game_event_creature_quest', 'gameobject_queststarter', 'gameobject_questender', 'game_event_gameobject_quest', 'item_template']],
'spell' => [null, null, ['icons'], ['skill_discovery_template', 'item_template', 'creature_template', 'creature_template_addon', 'smart_scripts', 'npc_trainer', 'disables', 'spell_ranks', 'spell_dbc']],
'spelldifficulty' => [null, null, null, ['spelldifficulty_dbc']],
'taxi' /* nodes + paths */ => [null, null, null, ['creature_template', 'creature']],
'titles' => [null, null, null, ['quest_template', 'game_event_seasonal_questrelation', 'game_event', 'achievement_reward']],
'items' => [null, null, ['icons'], ['item_template', 'item_template_locale', 'spell_group', 'game_event']],
'spawns' /* + waypoints */ => [null, null, null, ['creature', 'creature_addon', 'gameobject', 'gameobject_template', 'vehicle_accessory', 'vehicle_accessory_template', 'script_waypoint', 'waypoints', 'waypoint_data']],
'zones' => [null, null, null, ['access_requirement']],
'itemset' => [null, null, ['spell'], ['item_template', 'game_event']],
'item_stats' /* + ench */ => [null, null, ['items', 'spell'], null],
'source' => [null, null, ['spell', 'achievement'], ['npc_vendor', 'game_event_npc_vendor', 'creature', 'quest_template', 'quest_template_addon', 'playercreateinfo_item', 'npc_trainer', 'skill_discovery_template', 'playercreateinfo_skills', 'achievement_reward', 'skill_perfect_item_template']]
);
private static $tables = [];
private static $tmpStore = [];
public static $cliOpts = [];
private static $shortOpts = 'h';
@@ -84,13 +24,61 @@ class SqlGen
public static $subScripts = [];
public static $defaultExecTime = 30;
public static $stepSize = 1000;
public static $sqlBatchSize = 1000;
public static function init($mode = self::MODE_NORMAL, array $updScripts = [])
public static function init(int $mode = self::MODE_NORMAL, array $updScripts = []) : void
{
self::$defaultExecTime = ini_get('max_execution_time');
$doScripts = null;
// register subscripts
foreach (glob('setup/tools/sqlgen/*.func.php') as $file)
include_once $file;
while (self::$tmpStore)
{
$nDepsMissing = count(self::$tmpStore);
foreach (self::$tmpStore as $idx => $ts)
{
$depsOK = true;
foreach ($ts->getDependancies(true) as $d)
{
if (isset(self::$tables[$d]))
continue;
$depsOK = false;
break;
}
if ($depsOK)
{
if (isset(self::$tables[$ssRef->getName()]))
{
CLI::write('a SetupScript named '.CLI::bold($ts->getName()).' was already registered. Skipping...', CLI::LOG_WARN);
unset(self::$tmpStore[$idx]);
continue;
}
self::$tables[$ts->getName()] = $ts;
unset(self::$tmpStore[$idx]);
}
}
if ($nDepsMissing == count(self::$tmpStore))
{
CLI::write('the flollowing SetupScripts have unresolved dependancies and have not been registered:', CLI::LOG_ERROR);
foreach (self::$tmpStore as $ts)
CLI::write(' * '.CLI::bold($ts->getName()).' => '.implode(', ', $ts->getDependancies(true)));
self::$tmpStore = [];
break;
}
}
// handle command prompts
if (getopt(self::$shortOpts, self::$longOpts) || $mode == self::MODE_FIRSTRUN)
self::handleCLIOpts($doScripts);
else if ($mode != self::MODE_UPDATE)
@@ -115,7 +103,50 @@ class SqlGen
self::$mode = $mode;
}
private static function handleCLIOpts(&$doTbls)
public static function register(SetupScript $ssRef) : bool
{
// if dependancies haven't been stored yet, put aside for later use
foreach ($ssRef->getDependancies(true) as $d)
{
if (isset(self::$tables[$d]))
continue;
self::$tmpStore[] = $ssRef;
return false;
}
if (isset(self::$tables[$ssRef->getName()]))
{
CLI::write('a SetupScript named '.CLI::bold($ssRef->getName()).' was already registered. Skipping...', CLI::LOG_WARN);
return false;
}
self::$tables[$ssRef->getName()] = $ssRef;
// recheck temp stored dependancies
foreach (self::$tmpStore as $idx => $ts)
{
$depsOK = true;
foreach ($ts->getDependancies(true) as $d)
{
if (isset(self::$tables[$d]))
continue;
$depsOK = false;
break;
}
if ($depsOK)
{
self::$tables[$ts->getName()] = $ts;
unset(self::$tmpStore[$idx]);
}
}
return true;
}
private static function handleCLIOpts(&$doTbls) : void
{
$doTbls = [];
$_ = getopt(self::$shortOpts, self::$longOpts);
@@ -130,13 +161,13 @@ class SqlGen
if (!empty($_['sync']))
{
$sync = explode(',', $_['sync']);
foreach (self::$tables as $name => $info)
if (!empty($info[3]) && array_intersect($sync, $info[3]))
foreach (self::$tables as $name => &$ssRef)
if (array_intersect($sync, $ssRef->getDependancies(false)))
$doTbls[] = $name;
// recursive dependencies
foreach (self::$tables as $name => $info)
if (!empty($info[2]) && array_intersect($doTbls, $info[2]))
foreach (self::$tables as $name => &$ssRef)
if (array_intersect($sync, $ssRef->getDependancies(true)))
$doTbls[] = $name;
$doTbls = $doTbls ? array_unique($doTbls) : null;
@@ -145,17 +176,17 @@ class SqlGen
$doTbls = explode(',', $_['sql']);
}
public static function printCLIHelp()
public static function printCLIHelp() : void
{
echo "\nusage: php aowow --sql=<tableList,> [-h --help]\n\n";
echo "--sql : available tables:\n";
foreach (self::$tables as $t => $info)
echo " * ".str_pad($t, 24).(isset($info[3]) ? ' - TC deps: '.implode(', ', $info[3]) : '').(isset($info[2]) ? ' - Aowow deps: '.implode(', ', $info[2]) : '')."\n";
foreach (self::$tables as $t => &$ssRef)
echo " * ".str_pad($t, 24).($ssRef->getDependancies(false) ? ' - TC deps: '.implode(', ', $ssRef->getDependancies(false)) : '').($ssRef->getDependancies(true) ? ' - Aowow deps: '.implode(', ', $ssRef->getDependancies(true)) : '')."\n";
echo "-h --help : shows this info\n";
}
public static function generate($tableName, array $updateIds = [])
public static function generate(string $tableName, array $updateIds = []) : bool
{
if (!isset(self::$tables[$tableName]))
{
@@ -163,50 +194,28 @@ class SqlGen
return false;
}
if (!empty(self::$tables[$tableName][0])) // straight copy from dbc source
{
$tbl = self::$tables[$tableName]; // shorthand
CLI::write('SqlGen::generate() - copying '.$tbl[0].'.dbc into aowow_'.$tableName);
$dbc = new DBC($tbl[0], ['temporary' => CLISetup::$tmpDBC, 'tableName' => 'aowow_'.$tableName]);
if ($dbc->error)
return false;
return !!$dbc->readFile();
}
else if (file_exists('setup/tools/sqlgen/'.$tableName.'.func.php'))
{
$customData = $reqDBC = [];
$ssRef = &self::$tables[$tableName];
CLI::write('SqlGen::generate() - filling aowow_'.$tableName.' with data');
require_once 'setup/tools/sqlgen/'.$tableName.'.func.php';
if (function_exists($tableName))
{
// check for required auxiliary DBC files
foreach ($reqDBC as $req)
if (!in_array('TrDBCcopy', class_uses($ssRef)))
foreach ($ssRef->getRequiredDBCs() as $req)
if (!CLISetup::loadDBC($req))
return false;
$success = $tableName($updateIds);
// apply post generator custom data
foreach ($customData as $id => $data)
if ($data)
DB::Aowow()->query('UPDATE ?_'.$tableName.' SET ?a WHERE id = ?d', $data, $id);
}
else
CLI::write(' - subscript \''.$tableName.'\' not defined in included file', CLI::LOG_ERROR);
return $success;
}
else
CLI::write(sprintf(ERR_MISSING_INCL, $tableName, 'setup/tools/sqlgen/'.$tableName.'.func.php'), CLI::LOG_ERROR);
if ($ssRef->generate($updateIds))
{
if (method_exists($ssRef, 'applyCustomData'))
$ssRef->applyCustomData();
return true;
}
public static function getMode()
return false;
}
public static function getMode() : int
{
return self::$mode;
}

View File

@@ -7,22 +7,21 @@ if (!CLI)
die('not in cli mode');
/* deps:
* dbc_achievement
* disables
*/
// Higher Learning - item rewarded through gossip
$customData = array(
1956 => ['itemExtra' => 44738]
);
$reqDBC = ['achievement_category', 'achievement', 'spellicon'];
function achievement(array $ids = [])
SqlGen::register(new class extends SetupScript
{
if ($ids)
DB::Aowow()->query('DELETE FROM ?_achievement WHERE id IN (?a)', $ids);
else
use TrCustomData;
protected $command = 'achievement';
protected $tblDependancyAowow = ['icons'];
protected $tblDependancyTC = ['dbc_achievement', 'disables'];
protected $dbcSourceFiles = ['achievement_category', 'achievement', 'spellicon'];
private $customData = array(
1956 => ['itemExtra' => 44738] // Higher Learning - item rewarded through gossip
);
public function generate(array $ids = []) : bool
{
DB::Aowow()->query('
REPLACE INTO
@@ -55,8 +54,8 @@ function achievement(array $ids = [])
dbc_spellicon si ON si.id = a.iconId
LEFT JOIN
?_icons i ON LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) = i.name
');
}
{ WHERE a.id IN (?a) }
', $ids ?: DBSIMPLE_SKIP);
// serverside achievements
$serverAchievements = DB::World()->select('SELECT ID, IF(requiredFaction = -1, 3, IF(requiredFaction = 0, 2, 1)) AS "faction", mapID, points, flags, count, refAchievement FROM achievement_dbc{ WHERE id IN (?a)}',
@@ -99,6 +98,7 @@ function achievement(array $ids = [])
DB::Aowow()->query('UPDATE aowow_achievement a JOIN aowow_achievementcriteria ac ON a.id = ac.refAchievementId SET a.cuFlags = ?d WHERE ac.id IN (?a)', CUSTOM_DISABLED, $criteria);
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'achievementcategory';
protected $dbcSourceFiles = ['achievement_category'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'achievementcriteria';
protected $dbcSourceFiles = ['achievement_criteria'];
});
?>

View File

@@ -7,21 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* areatrigger_tavern
* areatrigger_scripts
* areatrigger_involvedrelation
* quest_template
* quest_template_addon
* areatrigger_teleport
*/
$customData = array(
);
$reqDBC = ['areatrigger'];
function areatrigger(/*array $ids = [] */)
SqlGen::register(new class extends SetupScript
{
protected $command = 'areatrigger';
protected $tblDependancyTC = ['areatrigger_involvedrelation', 'areatrigger_scripts', 'areatrigger_tavern', 'areatrigger_teleport', 'quest_template', 'quest_template_addon'];
protected $dbcSourceFiles = ['areatrigger'];
public function generate(array $ids = []) : bool
{
DB::Aowow()->query('TRUNCATE ?_areatrigger');
DB::Aowow()->query('INSERT INTO ?_areatrigger SELECT id, 0, 0, NULL, orientation, NULL, NULL, NULL, NULL, NULL, NULL FROM dbc_areatrigger');
@@ -102,6 +96,7 @@ function areatrigger(/*array $ids = [] */)
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id);
return true;
}
}
});
?>

View File

@@ -7,8 +7,16 @@ if (!CLI)
die('not in cli mode');
// roles (1:heal; 2:mleDPS; 4:rngDPS; 8:tank)
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'classes';
protected $dbcSourceFiles = ['spell', 'charbaseinfo', 'skillraceclassinfo', 'skilllineability', 'chrclasses'];
// roles (1:heal; 2:mleDPS; 4:rngDPS; 8:tank)
private $customData = array(
1 => ['roles' => 0xA],
2 => ['roles' => 0xB],
3 => ['roles' => 0x4],
@@ -19,11 +27,10 @@ $customData = array(
8 => ['roles' => 0x4],
9 => ['roles' => 0x4],
11 => ['roles' => 0xF],
);
$reqDBC = ['spell', 'charbaseinfo', 'skillraceclassinfo', 'skilllineability', 'chrclasses'];
);
function classes()
{
public function generate(array $ids = []) : bool
{
$classes = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM dbc_chrclasses');
// add raceMask
@@ -45,6 +52,7 @@ function classes()
DB::Aowow()->query('REPLACE INTO ?_classes (?#) VALUES (?a)', array_keys($cl), array_values($cl));
return true;
}
}
});
?>

View File

@@ -7,20 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* creature_template
* creature_template_locale
* creature_classlevelstats
* instance_encounters
*/
$customData = array(
);
$reqDBC = ['creaturedisplayinfo', 'creaturedisplayinfoextra'];
function creature(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'creature';
protected $tblDependancyTC = ['creature_template', 'creature_template_locale', 'creature_classlevelstats', 'instance_encounters'];
protected $dbcSourceFiles = ['creaturedisplayinfo', 'creaturedisplayinfoextra'];
public function generate(array $ids = []) : bool
{
$baseQuery = '
SELECT
ct.entry,
@@ -132,7 +127,7 @@ function creature(array $ids = [])
c.humanoid = IF(cdie.id IS NULL, 0, 1)';
$lastMax = 0;
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$stepSize))
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($npcs, 'entry'));
@@ -157,6 +152,7 @@ function creature(array $ids = [])
DB::Aowow()->query('UPDATE ?_creature SET cuFlags = cuFlags | ?d WHERE name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(%" OR name_loc0 LIKE "%visual%" OR name_loc0 LIKE "%trigger%" OR name_loc0 LIKE "%credit%" OR name_loc0 LIKE "%marker%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
return true;
}
}
});
?>

View File

@@ -7,13 +7,18 @@ if (!CLI)
die('not in cli mode');
/* deps:
* item_template
* item_template_locale
*/
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
// hide test tokens and move them to unused
$customData = array(
protected $command = 'currencies';
protected $tblDependancyAowow = ['icons'];
protected $tblDependancyTC = ['item_template', 'item_template_locale'];
protected $dbcSourceFiles = ['itemdisplayinfo', 'currencytypes'];
// hide test tokens and move them to unused
private $customData = array(
1 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
2 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
4 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
@@ -21,11 +26,10 @@ $customData = array(
141 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3],
103 => ['cap' => 10000], // Arena Points
104 => ['cap' => 75000] // Honor Points
);
$reqDBC = ['itemdisplayinfo', 'currencytypes'];
);
function currencies(array $ids = [])
{
public function generate(array $ids = []) : bool
{
if (!$ids)
DB::Aowow()->query('REPLACE INTO ?_currencies (id, category, itemId) SELECT id, category, itemId FROM dbc_currencytypes');
@@ -83,6 +87,7 @@ function currencies(array $ids = [])
', $iconId, $itemId);
return true;
}
}
});
?>

View File

@@ -7,12 +7,14 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['emotes', 'emotestext', 'emotestextdata'];
function emotes(/*array $ids = [] */)
SqlGen::register(new class extends SetupScript
{
protected $command = 'emotes';
protected $dbcSourceFiles = ['emotes', 'emotestext', 'emotestextdata'];
public function generate(array $ids = []) : bool
{
/**********/
/* Basics */
/**********/
@@ -94,6 +96,7 @@ function emotes(/*array $ids = [] */)
}
return $allOK;
}
}
});
?>

View File

@@ -7,18 +7,14 @@ if (!CLI)
die('not in cli mode');
/* deps:
* game_event
* game_event_prerequisite
*/
$customData = array(
);
$reqDBC = array(
);
function events(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'events';
protected $tblDependancyTC = ['game_event', 'game_event_prerequisite'];
public function generate(array $ids = []) : bool
{
$eventQuery = '
SELECT
ge.eventEntry,
@@ -47,6 +43,7 @@ function events(array $ids = [])
DB::Aowow()->query('REPLACE INTO ?_events VALUES (?a)', array_values($e));
return true;
}
}
});
?>

View File

@@ -7,7 +7,15 @@ if (!CLI)
die('not in cli mode');
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'factions';
protected $dbcSourceFiles = ['faction', 'factiontemplate'];
private $customData = array(
47 => ['qmNpcIds' => '33310'],
68 => ['qmNpcIds' => '33555'],
69 => ['qmNpcIds' => '33653'],
@@ -42,11 +50,10 @@ $customData = array(
1156 => ['qmNpcIds' => '37687'],
1082 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW],
952 => ['cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW],
);
$reqDBC = ['faction', 'factiontemplate'];
);
function factions()
{
public function generate(array $ids = []) : bool
{
$factionQuery = '
REPLACE INTO
?_factions
@@ -127,6 +134,7 @@ function factions()
DB::Aowow()->query($recursiveUpdateQuery, $p[0], $p[1], $p[0]);
return true;
}
}
});
?>

View File

@@ -7,12 +7,14 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['factiontemplate'];
function factiontemplate()
SqlGen::register(new class extends SetupScript
{
protected $command = 'factiontemplate';
protected $dbcSourceFiles = ['factiontemplate'];
public function generate(array $ids = []) : bool
{
$query = '
REPLACE INTO
?_factiontemplate
@@ -33,6 +35,7 @@ function factiontemplate()
DB::Aowow()->query($query);
return true;
}
}
});
?>

View File

@@ -6,15 +6,22 @@ if (!defined('AOWOW_REVISION'))
if (!CLI)
die('not in cli mode');
$reqDBC = ['glyphproperties', 'spellicon'];
function glyphproperties()
SqlGen::register(new class extends SetupScript
{
protected $command = 'glyphproperties';
protected $tblDependancyAowow = ['icons'];
protected $dbcSourceFiles = ['glyphproperties', 'spellicon'];
public function generate(array $ids = []) : bool
{
DB::Aowow()->query('REPLACE INTO ?_glyphproperties SELECT id, spellId, typeFlags, 0, iconId FROM dbc_glyphproperties');
DB::Aowow()->query('UPDATE ?_glyphproperties gp, ?_icons ic, dbc_spellicon si SET gp.iconId = ic.id WHERE gp.iconIdBak = si.id AND ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))');
return true;
}
}
});
?>

View File

@@ -7,7 +7,16 @@ if (!CLI)
die('not in cli mode');
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'holidays';
protected $dbcSourceFiles = ['holidays', 'holidaydescriptions', 'holidaynames'];
private $customData = array(
62 => ['iconString' => 'inv_misc_missilelarge_red' ],
141 => ['iconString' => 'calendar_winterveilstart', 'achievementCatOrId' => 156 ],
181 => ['iconString' => 'calendar_noblegardenstart', 'achievementCatOrId' => 159 ],
@@ -34,11 +43,10 @@ $customData = array(
420 => ['iconString' => 'achievement_bg_winwsg' ],
423 => ['iconString' => 'calendar_loveintheairstart', 'bossCreature' => 36296, 'achievementCatOrId' => 187 ],
424 => ['iconString' => 'calendar_fishingextravaganzastart' ],
);
$reqDBC = ['holidays', 'holidaydescriptions', 'holidaynames'];
);
function holidays()
{
public function generate(array $ids = []) : bool
{
$query = '
REPLACE INTO
?_holidays (id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, description_loc0, description_loc2, description_loc3, description_loc4, description_loc6, description_loc8, looping, scheduleType, textureString)
@@ -54,6 +62,7 @@ function holidays()
DB::Aowow()->query($query);
return true;
}
}
});
?>

View File

@@ -7,12 +7,14 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['spellicon', 'itemdisplayinfo', 'creaturefamily'];
function icons()
SqlGen::register(new class extends SetupScript
{
protected $command = 'icons';
protected $dbcSourceFiles = ['spellicon', 'itemdisplayinfo', 'creaturefamily'];
public function generate(array $ids = []) : bool
{
DB::Aowow()->query('TRUNCATE ?_icons');
DB::Aowow()->query('ALTER TABLE ?_icons AUTO_INCREMENT = 1');
@@ -33,6 +35,7 @@ function icons()
DB::Aowow()->query($baseQuery);
return true;
}
}
});
?>

View File

@@ -7,16 +7,6 @@ if (!CLI)
die('not in cli mode');
/* deps:
* ?_items finalized
* ?_spell finalized
* dbc_spellitemenchantment
*/
$customData = array(
);
$reqDBC = ['spellitemenchantment'];
class ItemStatSetup extends ItemList
{
private $statCols = [];
@@ -138,36 +128,15 @@ class ItemStatSetup extends ItemList
}
}
function item_stats(array $ids = [])
SqlGen::register(new class extends SetupScript
{
$offset = 0;
protected $command = 'item_stats'; // and enchantment stats
CLI::write(' - applying stats for enchantments');
$enchStats = enchantment_stats();
CLI::write(' '.count($enchStats).' enchantments parsed');
CLI::write(' - applying stats for items');
protected $tblDependancyAowow = ['items', 'spell'];
protected $dbcSourceFiles = ['spellitemenchantment'];
while (true)
private function enchantment_stats() : array
{
$items = new ItemStatSetup($offset, SqlGen::$stepSize, $ids, $enchStats);
if ($items->error)
break;
$max = max($items->getFoundIDs());
$num = count($items->getFoundIDs());
CLI::write(' * sets '.($offset + 1).' - '.($max));
$offset = $max;
$items->writeStatsTable();
}
return true;
}
function enchantment_stats()
{
$statCols = DB::Aowow()->selectCol('SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` LIKE "%item_stats"');
$enchants = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM dbc_spellitemenchantment');
$spells = [];
@@ -272,6 +241,35 @@ function enchantment_stats()
}
return $result;
}
}
public function generate(array $ids = []) : bool
{
$offset = 0;
CLI::write(' - applying stats for enchantments');
$enchStats = enchantment_stats();
CLI::write(' '.count($enchStats).' enchantments parsed');
CLI::write(' - applying stats for items');
while (true)
{
$items = new ItemStatSetup($offset, SqlGen::$sqlBatchSize, $ids, $enchStats);
if ($items->error)
break;
$max = max($items->getFoundIDs());
$num = count($items->getFoundIDs());
CLI::write(' * sets '.($offset + 1).' - '.($max));
$offset = $max;
$items->writeStatsTable();
}
return true;
}
});
?>

View File

@@ -7,12 +7,15 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['spellitemenchantment'];
function itemenchantment()
SqlGen::register(new class extends SetupScript
{
protected $command = 'itemenchantment';
protected $tblDependancyTC = ['spell_enchant_proc_data'];
protected $dbcSourceFiles = ['spellitemenchantment'];
public function generate(array $ids = []) : bool
{
$baseQuery = '
REPLACE INTO
?_itemenchantment
@@ -32,6 +35,7 @@ function itemenchantment()
DB::Aowow()->query('UPDATE ?_itemenchantment SET cuFlags = ?d WHERE name_loc0 LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'itemenchantmentcondition';
protected $dbcSourceFiles = ['spellitemenchantmentcondition'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'itemextendedcost';
protected $dbcSourceFiles = ['itemextendedcost'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'itemlimitcategory';
protected $dbcSourceFiles = ['itemlimitcategory'];
});
?>

View File

@@ -7,12 +7,14 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['itemrandomsuffix', 'itemrandomproperties'];
function itemrandomenchant()
SqlGen::register(new class extends SetupScript
{
protected $command = 'itemrandomenchant';
protected $dbcSourceFiles = ['itemrandomsuffix', 'itemrandomproperties'];
public function generate(array $ids = []) : bool
{
$query = '
REPLACE INTO ?_itemrandomenchant
SELECT -id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, nameINT, enchantId1, enchantId2, enchantId3, enchantId4, enchantId5, allocationPct1, allocationPct2, allocationPct3, allocationPct4, allocationPct5 FROM dbc_itemrandomsuffix
@@ -22,6 +24,7 @@ function itemrandomenchant()
DB::Aowow()->query($query);
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'itemrandomproppoints';
protected $dbcSourceFiles = ['itemrandomproperties'];
});
?>

View File

@@ -7,14 +7,17 @@ if (!CLI)
die('not in cli mode');
/* deps:
* item_template
* item_template_locale
* spell_group
* game_event
*/
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
$customData = array(
protected $command = 'items';
protected $tblDependancyAowow = ['icons'];
protected $tblDependancyTC = ['item_template', 'item_template_locale', 'spell_group', 'game_event'];
protected $dbcSourceFiles = ['gemproperties', 'itemdisplayinfo', 'spell', 'glyphproperties', 'durabilityquality', 'durabilitycosts'];
private $customData = array(
33147 => ['class' => 9, 'subClass' => 8], // one stray enchanting recipe .. with a strange icon
7948 => ['itemset' => 221], // v unsure if this should be fixed v
7949 => ['itemset' => 221],
@@ -22,12 +25,18 @@ $customData = array(
7951 => ['itemset' => 221],
7952 => ['itemset' => 221],
7953 => ['itemset' => 221]
);
);
$reqDBC = ['gemproperties', 'itemdisplayinfo', 'spell', 'glyphproperties', 'durabilityquality', 'durabilitycosts'];
private $skill2cat = array(
773 => 11, // inscription
356 => 9, // fishing
186 => 12, // mining
185 => 5, // cooking
171 => 6 // alchemy
);
function items(array $ids = [])
{
public function generate(array $ids = []) : bool
{
$baseQuery = '
SELECT
it.entry,
@@ -143,7 +152,7 @@ function items(array $ids = [])
?d';
$lastMax = 0;
while ($items = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$stepSize))
while ($items = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($items, 'entry'));
@@ -218,15 +227,7 @@ function items(array $ids = [])
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.class = 0, i.subClass = 6 WHERE s.id = i.spellId1 AND s.effect1Id = 53 AND i.classBak = 12');
// move some generic recipes into appropriate sub-categories
$skillz = array(
773 => 11, // inscription
356 => 9, // fishing
186 => 12, // mining
185 => 5, // cooking
171 => 6 // alchemy
);
foreach ($skillz as $skill => $cat)
foreach ($this->skill2cat as $skill => $cat)
DB::Aowow()->query('UPDATE ?_items SET subClass = ?d WHERE classBak = 9 AND subClassBak = 0 AND requiredSkill = ?d', $cat, $skill);
// calculate durabilityCosts
@@ -253,6 +254,7 @@ function items(array $ids = [])
durability > 0 AND ((classBak = 4 AND subClassBak IN (1, 2, 3, 4, 6)) OR (classBak = 2 AND subClassBak <> 9))');
return true;
}
}
});
?>

View File

@@ -8,39 +8,35 @@ if (!CLI)
/*
note: the virtual set-ids wont match the ones of wowhead
since there are some unused itemsets and and items flying around in a default database this script will create about 20 sets more than you'd expect.
since there are some unused itemsets and items flying around in a default database this script will create about 20 sets more than you'd expect.
and i have no idea how to merge the prefixes/suffixes for wotlk-raidsets and arena-sets in gereral onto the name.. at least not for all locales and i'll be damned if i have to skip one
*/
/* deps:
* item_template
* game_event
*/
$customData = array(
221 => ['item1' => 7948, 'item2' => 7949, 'item3' => 7950, 'item4' => 7951, 'item5' => 7952, 'item6' => 7953]
);
$reqDBC = ['itemset'];
function itemset()
SqlGen::register(new class extends SetupScript
{
$setToHoliday = array (
use TrCustomData;
protected $command = 'itemset';
protected $tblDependancyAowow = ['spell'];
protected $tblDependancyTC = ['item_template', 'game_event'];
protected $dbcSourceFiles = ['itemset'];
private $customData = array(
221 => ['item1' => 7948, 'item2' => 7949, 'item3' => 7950, 'item4' => 7951, 'item5' => 7952, 'item6' => 7953]
);
private $setToHoliday = array (
761 => 141, // Winterveil
762 => 372, // Brewfest
785 => 341, // Midsummer
812 => 181, // Noblegarden
);
// find events associated with holidayIds
if ($pairs = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($setToHoliday)))
foreach ($setToHoliday as &$hId)
$hId = !empty($pairs[$hId]) ? $pairs[$hId] : 0;
// tags where refId == virtualId
// in pve sets are not recycled beyond the contentGroup
$tagsById = array(
private $tagsById = array(
// "Dungeon Set 1"
1 => [181, 182, 183, 184, 185, 186, 187, 188, 189],
// "Dungeon Set 2"
@@ -88,7 +84,7 @@ function itemset()
);
// well .. fuck
$tagsByNamePart = array(
private $tagsByNamePart = array(
17 => ['gladiator'], // "Arena Season 1 Set",
19 => ['merciless'], // "Arena Season 2 Set",
20 => ['vengeful'], // "Arena Season 3 Set",
@@ -99,6 +95,13 @@ function itemset()
30 => ['wrathful'] // "Arena Season 8 Set",
);
public function generate(array $ids = []) : bool
{
// find events associated with holidayIds
if ($pairs = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($this->setToHoliday)))
foreach ($this->setToHoliday as &$hId)
$hId = !empty($pairs[$hId]) ? $pairs[$hId] : 0;
DB::Aowow()->query('TRUNCATE TABLE ?_itemset');
$vIdx = 0;
@@ -111,7 +114,7 @@ function itemset()
$classMask = $type = 0;
$hasRing = false;
$holiday = isset($setToHoliday[$setId]) ? $setToHoliday[$setId] : 0;
$holiday = $this->setToHoliday[$setId] ?? 0;
$canReuse = !$holiday; // can't reuse holiday-sets
$slotList = [];
$pieces = DB::World()->select('SELECT *, IF(InventoryType = 15, 26, IF(InventoryType = 5, 20, InventoryType)) AS slot, entry AS ARRAY_KEY FROM item_template WHERE itemset = ?d AND (class <> 4 OR subclass NOT IN (1, 2, 3, 4) OR armor > 0 OR Quality = 1) ORDER BY itemLevel, subclass, slot ASC', $setId);
@@ -309,7 +312,7 @@ function itemset()
foreach ($items as $vId => $vSet)
{
$note = 0;
foreach ($tagsById as $tag => $sets)
foreach ($this->tagsById as $tag => $sets)
{
if (!in_array($setId, $sets))
continue;
@@ -319,7 +322,7 @@ function itemset()
if (!$note && $min > 120 && $classMask && $classMask != CLASS_MASK_ALL)
{
foreach ($tagsByNamePart as $tag => $strings)
foreach ($this->tagsByNamePart as $tag => $strings)
{
foreach ($strings as $str)
{
@@ -365,6 +368,6 @@ function itemset()
DB::Aowow()->query('UPDATE ?_itemset SET cuFlags = cuFlags | ?d WHERE item1 = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'lock';
protected $dbcSourceFiles = ['lock'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'mailtemplate';
protected $dbcSourceFiles = ['mailtemplate'];
});
?>

View File

@@ -7,19 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* gameobject_template
* gameobject_template_locale
* gameobject_questitem
*/
$customData = array(
);
$reqDBC = ['lock'];
function objects(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'objects';
protected $tblDependancyTC = ['gameobject_template', 'gameobject_template_locale', 'gameobject_questitem'];
protected $dbcSourceFiles = ['lock'];
public function generate(array $ids = []) : bool
{
$baseQuery = '
SELECT
go.entry,
@@ -109,7 +105,7 @@ function objects(array $ids = [])
}';
$lastMax = 0;
while ($objects = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$stepSize))
while ($objects = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($objects, 'entry'));
@@ -125,6 +121,7 @@ function objects(array $ids = [])
DB::Aowow()->query($updateQuery, $ids ?: DBSIMPLE_SKIP);
return true;
}
}
});
?>

View File

@@ -7,18 +7,16 @@ if (!CLI)
die('not in cli mode');
/* deps:
* creature_template
* creature
*/
$customData = array(
);
$reqDBC = ['talent', 'spell', 'skilllineability', 'creaturefamily'];
function pet(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'pet';
protected $tblDependancyAowow = ['icons'];
protected $tblDependancyTC = ['creature_template', 'creature'];
protected $dbcSourceFiles = ['talent', 'spell', 'skilllineability', 'creaturefamily'];
public function generate(array $ids = []) : bool
{
$baseQuery = '
REPLACE INTO
?_pet
@@ -122,6 +120,7 @@ function pet(array $ids = [])
DB::Aowow()->query('UPDATE ?_pet SET ?a WHERE id = ?d', $row, $pId);
return true;
}
}
});
?>

View File

@@ -7,22 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* quest_template
* quest_template_addon
* quest_template_locale
* game_event
* game_event_seasonal_questrelation
* disables
*/
$customData = array(
);
$reqDBC = ['questxp', 'questfactionreward'];
function quests(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'quests';
protected $tblDependancyTC = ['quest_template', 'quest_template_addon', 'quest_template_locale', 'game_event', 'game_event_seasonal_questrelation', 'disables'];
protected $dbcSourceFiles = ['questxp', 'questfactionreward'];
public function generate(array $ids = []) : bool
{
$baseQuery = '
SELECT
q.ID,
@@ -178,7 +171,7 @@ function quests(array $ids = [])
$lastMax = 0;
while ($quests = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$stepSize))
while ($quests = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($quests, 'ID'));
@@ -267,6 +260,7 @@ function quests(array $ids = [])
DB::Aowow()->query('UPDATE ?_quests SET zoneOrSort = ?d WHERE (specialFlags & ?d OR id IN (?a)){ AND id IN (?a)}', -1010, QUEST_FLAG_SPECIAL_DUNGEON_FINDER, [24789, 24791, 24923], $ids ?: DBSIMPLE_SKIP);
return true;
}
}
});
?>

View File

@@ -7,24 +7,14 @@ if (!CLI)
die('not in cli mode');
/* deps:
* creature_queststarter
* creature_questender
* game_event_creature_quest
* gameobject_queststarter
* gameobject_questender
* game_event_gameobject_quest
* item_template
*/
$customData = array(
);
$reqDBC = array(
);
function quests_startend(/* array $ids = [] */)
SqlGen::register(new class extends SetupScript
{
protected $command = 'quests_startend';
protected $tblDependancyTC = ['creature_queststarter', 'creature_questender', 'game_event_creature_quest', 'gameobject_queststarter', 'gameobject_questender', 'game_event_gameobject_quest', 'item_template'];
public function generate(array $ids = []) : bool
{
$query['creature'] = '
SELECT 1 AS type, id AS typeId, quest AS questId, 1 AS method, 0 AS eventId FROM creature_queststarter UNION
SELECT 1 AS type, id AS typeId, quest AS questId, 2 AS method, 0 AS eventId FROM creature_questender UNION
@@ -52,6 +42,7 @@ function quests_startend(/* array $ids = [] */)
Db::Aowow()->query('UPDATE ?_quests q LEFT JOIN ?_quests_startend qse ON qse.questId = q.id AND qse.method & 1 SET q.cuFlags = q.cuFlags | ?d WHERE qse.questId IS NULL', CUSTOM_UNAVAILABLE);
return true;
}
}
});
?>

View File

@@ -7,7 +7,15 @@ if (!CLI)
die('not in cli mode');
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'races';
protected $dbcSourceFiles = ['chrraces', 'charbaseinfo'];
private $customData = array(
null,
['leader' => 29611, 'factionId' => 72, 'startAreaId' => 12],
['leader' => 4949, 'factionId' => 76, 'startAreaId' => 14],
@@ -20,11 +28,10 @@ $customData = array(
null,
['leader' => 16802, 'factionId' => 911, 'startAreaId' => 3430],
['leader' => 17468, 'factionId' => 930, 'startAreaId' => 3524]
);
$reqDBC = ['chrraces', 'charbaseinfo'];
);
function races()
{
public function generate(array $ids = []) : bool
{
/**********/
/* Basics */
/**********/
@@ -46,6 +53,7 @@ function races()
DB::Aowow()->query('UPDATE ?_races SET cuFlags = ?d WHERE flags & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1);
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'scalingstatdistribution';
protected $dbcSourceFiles = ['scalingstatdistribution'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'scalingstatvalues';
protected $dbcSourceFiles = ['scalingstatvalues'];
});
?>

View File

@@ -7,22 +7,40 @@ if (!CLI)
die('not in cli mode');
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'shapeshiftforms';
protected $dbcSourceFiles = ['spellshapeshiftform'];
private $customData = array(
1 => ['displayIdH' => 8571],
15 => ['displayIdH' => 8571],
5 => ['displayIdH' => 2289],
8 => ['displayIdH' => 2289],
14 => ['displayIdH' => 2289],
27 => ['displayIdH' => 21244],
29 => ['displayIdH' => 20872],
);
$reqDBC = ['spellshapeshiftform'];
29 => ['displayIdH' => 20872]
);
function shapeshiftforms()
{
DB::Aowow()->query('REPLACE INTO ?_shapeshiftforms SELECT id, flags, creatureType, displayIdA, displayIdH, spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8, IF(name_loc0 = "", IF(name_loc2 = "", IF(name_loc3 = "", IF(name_loc6 = "", IF(name_loc8 = "", "???", name_loc8), name_loc6), name_loc3), name_loc2), name_loc0) FROM dbc_spellshapeshiftform');
public function generate(array $ids = []) : bool
{
DB::Aowow()->query('
REPLACE INTO
?_shapeshiftforms
SELECT
id, flags, creatureType,
displayIdA, displayIdH,
spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8,
IF(name_loc0 = "", IF(name_loc2 = "", IF(name_loc3 = "", IF(name_loc6 = "", IF(name_loc8 = "", "???", name_loc8), name_loc6), name_loc3), name_loc2), name_loc0)
FROM
dbc_spellshapeshiftform'
);
return true;
}
}
});
?>

View File

@@ -6,7 +6,17 @@ if (!defined('AOWOW_REVISION'))
if (!CLI)
die('not in cli mode');
$customData = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'skillline';
protected $tblDependancyAowow = ['icons'];
protected $dbcSourceFiles = ['skillline', 'spell', 'skilllineability'];
private $customData = array(
393 => ['professionMask' => 0x0000], // Skinning
171 => ['professionMask' => 0x0001, 'recipeSubClass' => 6, 'specializations' => '28677 28675 28672'], // Alchemy
164 => ['professionMask' => 0x0002, 'recipeSubClass' => 4, 'specializations' => '9788 9787 17041 17040 17039'], // Blacksmithing
@@ -25,11 +35,10 @@ $customData = array(
781 => ['name_loc2' => 'Familier - diablosaure exotique'], // Pet - Exotic Devilsaur
758 => ['name_loc6' => 'Mascota: Evento - Control remoto', 'name_loc3' => 'Tier - Ereignis Ferngesteuert', 'categoryId' => 7], // Pet - Event - Remote Control
788 => ['categoryId' => 7], // Pet - Exotic Spirit Beast
);
$reqDBC = ['skillline', 'spell', 'skilllineability'];
);
function skillline()
{
public function generate(array $ids = []) : bool
{
$baseQuery = '
REPLACE INTO
?_skillline
@@ -71,6 +80,7 @@ function skillline()
DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_key_03', 633);
return true;
}
}
});
?>

View File

@@ -7,10 +7,13 @@ if (!CLI)
die('not in cli mode');
$customData = array(
15407 => ['cat' => 10] // UR_Algalon_Summon03 (this is not an item pickup)
);
$reqDBC = array(
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
protected $command = 'sounds';
protected $dbcSourceFiles = array(
// base emotes race
'soundentries', 'emotestextsound', 'vocaluisounds',
// creatures
@@ -21,11 +24,14 @@ $reqDBC = array(
'soundambience', 'zonemusic', 'zoneintromusictable', 'worldstatezonesounds', 'areatable',
// items
'material', 'itemgroupsounds', 'itemdisplayinfo', 'weaponimpactsounds', 'itemsubclass', 'weaponswingsounds2' /*, 'sheathesoundlookups' data is redundant with material..? */
);
);
private $customData = array(
15407 => ['cat' => 10] // UR_Algalon_Summon03 (this is not an item pickup)
);
function sounds(/*array $ids = [] */)
{
public function generate(array $ids = []) : bool
{
/*
okay, here's the thing. WMOAreaTable.dbc references WMO-files to get its position in the world (AreTable) and has sparse information on the related AreaTables themself.
Though it has sets for ZoneAmbience, ZoneMusic and ZoneIntroMusic, these can't be linked for this very reason and are omitted for now.
@@ -70,7 +76,7 @@ function sounds(/*array $ids = [] */)
$lastMax = 0;
$soundFileIdx = 0;
$soundIndex = [];
while ($sounds = DB::Aowow()->select($query, $lastMax, SqlGen::$stepSize))
while ($sounds = DB::Aowow()->select($query, $lastMax, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($sounds, 'id'));
@@ -403,7 +409,6 @@ function sounds(/*array $ids = [] */)
}
}
DB::Aowow()->query('
INSERT INTO
?_items_sounds
@@ -422,6 +427,7 @@ function sounds(/*array $ids = [] */)
');
return true;
}
}
});
?>

View File

@@ -7,49 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* reference_loot_template
* item_loot_template
* creature_loot_template
* gameobject_loot_template
* mail_loot_template
* disenchant_loot_template
* fishing_loot_template
* skinning_loot_template
* milling_loot_template
* prospecting_loot_template
* pickpocketing_loot_template
* item_template
* creature_template
* gameobject_template
* quest_template
* quest_template_addon
* skill_perfect_item_template
* npc_trainer
* npc_vendor
* game_event_npc_vendor
* creature
* playercreateinfo_item
* playercreateinfo_skill
* achievement_reward
* skill_discovery_template
*/
$customData = array(
);
$reqDBC = ['charstartoutfit', 'talent', 'spell', 'skilllineability', 'itemextendedcost', 'lock'];
function source(array $ids = [])
SqlGen::register(new class extends SetupScript
{
$insBasic = 'INSERT INTO ?_source (`type`, typeId, src?d) VALUES [V] ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
$insMore = 'INSERT INTO ?_source (`type`, typeId, src?d, moreType, moreTypeId) VALUES [V] ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
$insSub = 'INSERT INTO ?_source (`type`, typeId, src?d, moreType, moreTypeId) ?s ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
protected $command = 'source';
// please note, this workes without checks, because we do not use strings here
function queryfy($ph, array $data, $query)
protected $tblDependancyAowow = ['spell', 'achievement'];
protected $tblDependancyTC = ['playercreateinfo_skills', 'playercreateinfo_item', 'skill_discovery_template', 'achievement_reward', 'skill_perfect_item_template', 'item_template', 'gameobject_template', 'quest_template', 'quest_template_addon', 'creature_template', 'creature', 'npc_trainer', 'npc_vendor', 'game_event_npc_vendor', 'reference_loot_template', 'item_loot_template', 'creature_loot_template', 'gameobject_loot_template', 'mail_loot_template', 'disenchant_loot_template', 'fishing_loot_template', 'skinning_loot_template', 'milling_loot_template', 'prospecting_loot_template', 'pickpocketing_loot_template'];
protected $dbcSourceFiles = ['charstartoutfit', 'talent', 'spell', 'skilllineability', 'itemextendedcost', 'lock'];
private function queryfy(array $data, string $query) : string
{
$buff = [];
@@ -61,10 +27,10 @@ function source(array $ids = [])
foreach ($data as $d)
$buff[] = '('.implode(', ', $d ?: 'NULL').')';
return str_replace($ph, implode(', ', $buff), $query);
return str_replace('[V]', implode(', ', $buff), $query);
}
function pushBuffer(&$buff, $type, $typeId, $mType = 0, $mTypeId = 0, $src = 1)
private function pushBuffer(array &$buff, int $type, int $typeId, int $mType = 0, int $mTypeId = 0, int $src = 1) : void
{
$b = &$buff[$typeId];
@@ -81,7 +47,7 @@ function source(array $ids = [])
$b = [$type, $typeId, $src, null, null];
}
function taughtSpell($item)
private function taughtSpell(array $item) : int
{
# spelltrigger_X (0: onUse; 6: onLearnSpell)
# spell: 483 & 55884 are learn spells
@@ -101,6 +67,12 @@ function source(array $ids = [])
return 0;
}
public function generate(array $ids = []) : bool
{
$insBasic = 'INSERT INTO ?_source (`type`, typeId, src?d) VALUES [V] ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
$insMore = 'INSERT INTO ?_source (`type`, typeId, src?d, moreType, moreTypeId) VALUES [V] ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
$insSub = 'INSERT INTO ?_source (`type`, typeId, src?d, moreType, moreTypeId) ?s ON DUPLICATE KEY UPDATE moreType = NULL, moreTypeId = NULL, src?d = VALUES(src?d)';
// cant update existing rows
if ($ids)
DB::Aowow()->query('DELETE FROM ?_source WHERE `type` = ?d AND typeId IN (?a)', $well, $wellll);
@@ -188,17 +160,17 @@ function source(array $ids = [])
foreach ($spellItems as $iId => $si)
{
if ($_ = taughtSpell($si))
if ($_ = $this->taughtSpell($si))
$spellBuff[$_] = [TYPE_SPELL, $_, 1, TYPE_SPELL, $itemSpells[$iId]];
$itemBuff[$iId] = [TYPE_ITEM, $iId, 1, TYPE_SPELL, $itemSpells[$iId]];
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 1, 1, 1);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 1, 1, 1);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 1, 1, 1);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 1, 1, 1);
############
@@ -232,19 +204,19 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry'] /*, $lootmode */);
}
$objectOT = [];
@@ -274,21 +246,21 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$objectOT[] = $iId;
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$objectOT[] = $roi;
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
}
$itemOT = [];
@@ -316,28 +288,28 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
$itemOT[] = $iId;
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
$itemOT[] = $roi;
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_ITEM, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 2, 2, 2);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 2, 2, 2);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 2, 2, 2);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 2, 2, 2);
DB::Aowow()->query('UPDATE ?_items SET cuFLags = cuFlags | ?d WHERE id IN (?a)', ITEM_CU_OT_ITEMLOOT, $itemOT);
DB::Aowow()->query('UPDATE ?_items SET cuFLags = cuFlags | ?d WHERE id IN (?a)', ITEM_CU_OT_OBJECTLOOT, $objectOT);
@@ -348,11 +320,11 @@ function source(array $ids = [])
###########
CLI::write(' * #3 PvP');
// var g_sources_pvp = {
// var g_sources_pvp = {
// 1: 'Arena',
// 2: 'Battleground',
// 4: 'World' basicly the tokens you get for openPvP .. manual data
// };
// };
$spellBuff = [];
$itemBuff = [];
@@ -367,7 +339,7 @@ function source(array $ids = [])
foreach (DB::World()->select($vendorQuery, $xCostA, $xCostA) as $iId => $v)
{
if ($_ = taughtSpell($v))
if ($_ = $this->taughtSpell($v))
$spellBuff[$_] = [TYPE_SPELL, $_, 1];
$itemBuff[$iId] = [TYPE_ITEM, $iId, 1];
@@ -375,17 +347,17 @@ function source(array $ids = [])
foreach (DB::World()->select($vendorQuery, $xCostH, $xCostH) as $iId => $v)
{
if ($_ = taughtSpell($v))
if ($_ = $this->taughtSpell($v))
$spellBuff[$_] = [TYPE_SPELL, $_, 2];
$itemBuff[$iId] = [TYPE_ITEM, $iId, 2];
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insBasic), 3, 3, 3);
DB::Aowow()->query($this->queryfy($itemBuff, $insBasic), 3, 3, 3);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insBasic), 3, 3, 3);
DB::Aowow()->query($this->queryfy($spellBuff, $insBasic), 3, 3, 3);
#############
@@ -413,10 +385,10 @@ function source(array $ids = [])
);
foreach ($quests as $iId => $q)
{
if ($_ = taughtSpell($q))
pushBuffer($spellBuff, TYPE_SPELL, $_, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']);
if ($_ = $this->taughtSpell($q))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $q['qty'] > 1 ? 0 : TYPE_QUEST, $q['quest'], $q['side']);
}
$mailLoot = DB::World()->select('
@@ -446,28 +418,28 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
$itemOT[] = $iId;
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
$itemOT[] = $roi;
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_QUEST, $l['entry'], $l['side']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 4, 4, 4);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 4, 4, 4);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 4, 4, 4);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 4, 4, 4);
##############
@@ -491,17 +463,17 @@ function source(array $ids = [])
foreach ($vendors as $iId => $v)
{
if ($_ = taughtSpell($v))
pushBuffer($spellBuff, TYPE_SPELL, $_, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']);
if ($_ = $this->taughtSpell($v))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $v['qty'] > 1 ? 0 : TYPE_NPC, $v['npc']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 5, 5, 5);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 5, 5, 5);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 5, 5, 5);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 5, 5, 5);
###############
@@ -510,7 +482,7 @@ function source(array $ids = [])
CLI::write(' * #10 Starter');
if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', TYPE_ITEM))
DB::Aowow()->query(queryfy('[V]', $pcii, $insBasic), 10, 10, 10);
DB::Aowow()->query($this->queryfy($pcii, $insBasic), 10, 10, 10);
for ($i = 1; $i < 21; $i++)
DB::Aowow()->query($insSub, 10, DB::Aowow()->subquery('SELECT ?d, item?d, 1, NULL AS m, NULL AS mt FROM dbc_charstartoutfit WHERE item?d > 0', TYPE_ITEM, $i, $i), 10, 10);
@@ -544,10 +516,10 @@ function source(array $ids = [])
$extraItems = DB::World()->select('SELECT entry AS ARRAY_KEY, class, subclass, spellid_1, spelltrigger_1, spellid_2, spelltrigger_2 FROM item_template WHERE entry IN (?a)', array_keys($xItems));
foreach ($extraItems as $iId => $l)
{
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $xItems[$iId]['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $xItems[$iId]['entry']);
}
foreach ($rewItems as $iId => $l)
@@ -556,26 +528,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $l['qty'] > 1 ? 0 : TYPE_ACHIEVEMENT, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 12, 12, 12);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 12, 12, 12);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 12, 12, 12);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 12, 12, 12);
####################
@@ -609,26 +581,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $iId);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $roi);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 15, 15, 15);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 15, 15, 15);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 15, 15, 15);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 15, 15, 15);
##############
@@ -660,26 +632,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_OBJECT, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 16, 16, 16);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 16, 16, 16);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 16, 16, 16);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 16, 16, 16);
################
@@ -715,26 +687,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 17, 17, 17);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 17, 17, 17);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 17, 17, 17);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 17, 17, 17);
##############
@@ -766,26 +738,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $iId);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $roi);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 18, 18, 18);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 18, 18, 18);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 18, 18, 18);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 18, 18, 18);
#############
@@ -821,26 +793,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : $l['srcType'], $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 19, 19, 19);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 19, 19, 19);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 19, 19, 19);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 19, 19, 19);
##################
@@ -872,26 +844,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $iId);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_);
pushBuffer($itemBuff, TYPE_ITEM, $roi);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 20, 20, 20);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 20, 20, 20);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 20, 20, 20);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 20, 20, 20);
##################
@@ -922,26 +894,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 21, 21, 21);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 21, 21, 21);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 21, 21, 21);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 21, 21, 21);
################
@@ -973,26 +945,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 22, 22, 22);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 22, 22, 22);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 22, 22, 22);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 22, 22, 22);
###############
@@ -1024,26 +996,26 @@ function source(array $ids = [])
{
foreach ($refLoot[-$roi] as $iId => $r)
{
if ($_ = taughtSpell($r))
pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($r))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $iId, $r['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
continue;
}
if ($_ = taughtSpell($l))
pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
if ($_ = $this->taughtSpell($l))
$this->pushBuffer($spellBuff, TYPE_SPELL, $_, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
$this->pushBuffer($itemBuff, TYPE_ITEM, $roi, $l['qty'] > 1 ? 0 : TYPE_NPC, $l['entry']);
}
if ($itemBuff)
DB::Aowow()->query(queryfy('[V]', $itemBuff, $insMore), 23, 23, 23);
DB::Aowow()->query($this->queryfy($itemBuff, $insMore), 23, 23, 23);
if ($spellBuff)
DB::Aowow()->query(queryfy('[V]', $spellBuff, $insMore), 23, 23, 23);
DB::Aowow()->query($this->queryfy($spellBuff, $insMore), 23, 23, 23);
// flagging aowow_items for source (note: this is not exact! creatures dropping items may not be spawnd, quests granting items may be disabled)
@@ -1077,11 +1049,11 @@ function source(array $ids = [])
if ($spell['effect'.$i.'Id'] != 36) // effect: learnSpell
continue;
pushBuffer($buff, TYPE_SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : TYPE_QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']);
$this->pushBuffer($buff, TYPE_SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : TYPE_QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']);
}
}
DB::Aowow()->query(queryfy('[V]', $buff, $insMore), 4, 4, 4);
DB::Aowow()->query($this->queryfy($buff, $insMore), 4, 4, 4);
}
# 6: Trainer
@@ -1107,21 +1079,21 @@ function source(array $ids = [])
continue;
$triggered = true;
pushBuffer($buff, TYPE_SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? TYPE_NPC : 0, $trainerId);
$this->pushBuffer($buff, TYPE_SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? TYPE_NPC : 0, $trainerId);
}
if (!$triggered)
pushBuffer($buff, TYPE_SPELL, $spellId, $trainerId ? TYPE_NPC : 0, $trainerId);
$this->pushBuffer($buff, TYPE_SPELL, $spellId, $trainerId ? TYPE_NPC : 0, $trainerId);
}
DB::Aowow()->query(queryfy('[V]', $buff, $insMore), 6, 6, 6);
DB::Aowow()->query($this->queryfy($buff, $insMore), 6, 6, 6);
}
# 7: Discovery
CLI::write(' * #7 Discovery');
// 61756: Northrend Inscription Research (FAST QA VERSION);
if ($disco = DB::World()->select('SELECT ?d, spellId, 1 FROM skill_discovery_template WHERE reqSpell <> ?d', TYPE_SPELL, 61756))
DB::Aowow()->query(queryfy('[V]', $disco, $insBasic), 7, 7, 7);
DB::Aowow()->query($this->queryfy($disco, $insBasic), 7, 7, 7);
# 9: Talent
CLI::write(' * #9 Talent');
@@ -1158,7 +1130,7 @@ function source(array $ids = [])
$tSpells = DB::Aowow()->select('SELECT id AS ARRAY_KEY, effect1Id, effect2Id, effect3Id, effect1TriggerSpell, effect2TriggerSpell, effect3TriggerSpell FROM dbc_spell WHERE id IN (?a)', array_keys($recurse));
}
DB::Aowow()->query(queryfy('[V]', $buff, $insBasic), 9, 9, 9);
DB::Aowow()->query($this->queryfy($buff, $insBasic), 9, 9, 9);
# 10: Starter
CLI::write(' * #10 Starter');
@@ -1181,7 +1153,7 @@ function source(array $ids = [])
# 4: Quest
CLI::write(' * #4 Quest');
if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', TYPE_TITLE, TYPE_QUEST))
DB::Aowow()->query(queryfy('[V]', $quests, $insMore), 4, 4, 4);
DB::Aowow()->query($this->queryfy($quests, $insMore), 4, 4, 4);
# 12: Achievement
CLI::write(' * #12 Achievement');
@@ -1194,7 +1166,7 @@ function source(array $ids = [])
);
foreach ($sets as $tId => $set)
{
DB::Aowow()->query(queryfy('[V]', [[TYPE_TITLE, $tId, 1, TYPE_ACHIEVEMENT, $set['srcId']]], $insMore), 12, 12, 12);
DB::Aowow()->query($this->queryfy([[TYPE_TITLE, $tId, 1, TYPE_ACHIEVEMENT, $set['srcId']]], $insMore), 12, 12, 12);
if ($set['altSrcId'])
DB::Aowow()->query('UPDATE ?_titles SET src12Ext = ?d WHERE id = ?d', $set['altSrcId'], $tId);
@@ -1205,9 +1177,10 @@ function source(array $ids = [])
$src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177];
foreach ($src13 as $src => $tId)
if ($tId)
DB::Aowow()->query(queryfy('[V]', [[TYPE_TITLE, $tId, $src]], $insBasic), 13, 13, 13);
DB::Aowow()->query($this->queryfy([[TYPE_TITLE, $tId, $src]], $insBasic), 13, 13, 13);
return true;
}
}
});
?>

View File

@@ -7,28 +7,60 @@ if (!CLI)
die('not in cli mode');
// requires https://github.com/TrinityCore/TrinityCore/commit/f989c7182c4cc30f1d0ffdc566c7624a5e108a2f
// requires https://github.com/TrinityCore/TrinityCore/commit/f989c7182c4cc30f1d0ffdc566c7624a5e108a2f to have been used at least once
/* deps:
* creature
* creature_addon
* gameobject
* gameobject_template
* vehicle_accessory
* vehicle_accessory_template
* script_waypoint
* waypoints
* waypoint_data
*/
$customData = array(
);
$reqDBC = ['worldmaparea', 'map', 'dungeonmap', 'taxipathnode', 'soundemitters', 'areatrigger'];
function spawns() // and waypoints
SqlGen::register(new class extends SetupScript
{
$alphaMapCache = [];
$alphaMapCheck = function ($areaId, array &$set) use (&$alphaMapCache)
protected $command = 'spawns'; // and waypoints
protected $tblDependancyTC = ['creature', 'creature_addon', 'gameobject', 'gameobject_template', 'vehicle_accessory', 'vehicle_accessory_template', 'script_waypoint', 'waypoints', 'waypoint_data'];
protected $dbcSourceFiles = ['worldmaparea', 'map', 'dungeonmap', 'taxipathnode', 'soundemitters', 'areatrigger'];
private $querys = array(
1 => ['SELECT c.guid, 1 AS "type", c.id AS typeId, c.spawntimesecs AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, IFNULL(ca.path_id, 0) AS pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
'FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid',
' - assembling creature spawns'],
2 => ['SELECT c.guid, 2 AS "type", c.id AS typeId, ABS(c.spawntimesecs) AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, 0 as pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
'FROM gameobject c',
' - assembling gameobject spawns'],
3 => ['SELECT id AS "guid", 19 AS "type", soundId AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
'FROM dbc_soundemitters',
' - assembling sound emitter spawns'],
4 => ['SELECT id AS "guid", 503 AS "type", id AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
'FROM dbc_areatrigger',
' - assembling areatrigger spawns'],
5 => ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, w.waittime AS "wait", w.location_y AS `posX`, w.location_x AS `posY` ' .
'FROM creature c JOIN script_waypoint w ON c.id = w.entry',
' - assembling waypoints from table script_waypoint'],
6 => ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, 0 AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
'FROM creature c JOIN waypoints w ON c.id = w.entry',
' - assembling waypoints from table waypoints'],
7 => ['SELECT c.guid, -w.id AS "npcOrPath", w.point, c.zoneId AS areaId, c.map, w.delay AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
'FROM creature c JOIN creature_addon ca ON ca.guid = c.guid JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.path_id <> 0',
' - assembling waypoints from table waypoint_data']
);
private $queryPost =
'SELECT dm.id, wma.areaId, IFNULL(dm.floor, 0) AS floor, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)), 1) AS `posY`, ' .
'((abs(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)) - 50) / 50) * ' .
' (abs(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)) - 50) / 50)) AS quality ' .
'FROM dbc_worldmaparea wma ' .
'LEFT JOIN dbc_dungeonmap dm ON dm.mapId = IF(?d AND (wma.mapId NOT IN (0, 1, 530, 571) OR wma.areaId = 4395), wma.mapId, -1) ' .
'WHERE wma.mapId = ?d AND IF(?d, wma.areaId = ?d, wma.areaId <> 0) ' .
'HAVING (`posX` BETWEEN 0.1 AND 99.9 AND `posY` BETWEEN 0.1 AND 99.9) ' . // AND (dm.id IS NULL OR ?d) ' .
'ORDER BY quality ASC';
private $alphaMapCache = [];
private function alphaMapCheck(int $areaId, array &$set) : bool
{
$file = 'setup/generated/alphaMaps/'.$areaId.'.png';
if (!file_exists($file)) // file does not exist (probably instanced area)
@@ -41,17 +73,17 @@ function spawns() // and waypoints
return true;
}
if (empty($alphaMapCache[$areaId]))
$alphaMapCache[$areaId] = imagecreatefrompng($file);
if (empty($this->alphaMapCache[$areaId]))
$this->alphaMapCache[$areaId] = imagecreatefrompng($file);
// alphaMaps are 1000 x 1000, adapt points [black => valid point]
if (!imagecolorat($alphaMapCache[$areaId], $set['posX'] * 10, $set['posY'] * 10))
if (!imagecolorat($this->alphaMapCache[$areaId], $set['posX'] * 10, $set['posY'] * 10))
$set = null;
return true;
};
}
$checkCoords = function ($points) use($alphaMapCheck)
private function checkCoords(array $points) : array
{
$result = [];
$capitals = array( // capitals take precedence over their surroundings
@@ -62,7 +94,7 @@ function spawns() // and waypoints
foreach ($points as $res)
{
if ($alphaMapCheck($res['areaId'], $res))
if ($this->alphaMapCheck($res['areaId'], $res))
{
if (!$res)
continue;
@@ -88,48 +120,10 @@ function spawns() // and waypoints
}
return $result[1];
};
$query[1] = ['SELECT c.guid, 1 AS "type", c.id AS typeId, c.spawntimesecs AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, IFNULL(ca.path_id, 0) AS pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
'FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid',
' - assembling '.CLI::bold('creature').' spawns'];
$query[2] = ['SELECT c.guid, 2 AS "type", c.id AS typeId, ABS(c.spawntimesecs) AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, 0 as pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
'FROM gameobject c',
' - assembling '.CLI::bold('gameobject').' spawns'];
$query[3] = ['SELECT id AS "guid", 19 AS "type", soundId AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
'FROM dbc_soundemitters',
' - assembling '.CLI::bold('sound emitter').' spawns'];
$query[4] = ['SELECT id AS "guid", 503 AS "type", id AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
'FROM dbc_areatrigger',
' - assembling '.CLI::bold('areatrigger').' spawns'];
$query[5] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, w.waittime AS "wait", w.location_y AS `posX`, w.location_x AS `posY` ' .
'FROM creature c JOIN script_waypoint w ON c.id = w.entry',
' - assembling waypoints from '.CLI::bold('script_waypoint')];
$query[6] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, 0 AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
'FROM creature c JOIN waypoints w ON c.id = w.entry',
' - assembling waypoints from '.CLI::bold('waypoints')];
$query[7] = ['SELECT c.guid, -w.id AS "npcOrPath", w.point, c.zoneId AS areaId, c.map, w.delay AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
'FROM creature c JOIN creature_addon ca ON ca.guid = c.guid JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.path_id <> 0',
' - assembling waypoints from '.CLI::bold('waypoint_data')];
$queryPost = 'SELECT dm.id, wma.areaId, IFNULL(dm.floor, 0) AS floor, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)), 1) AS `posY`, ' .
'((abs(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)) - 50) / 50) * ' .
' (abs(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)) - 50) / 50)) AS quality ' .
'FROM dbc_worldmaparea wma ' .
'LEFT JOIN dbc_dungeonmap dm ON dm.mapId = IF(?d AND (wma.mapId NOT IN (0, 1, 530, 571) OR wma.areaId = 4395), wma.mapId, -1) ' .
'WHERE wma.mapId = ?d AND IF(?d, wma.areaId = ?d, wma.areaId <> 0) ' .
'HAVING (`posX` BETWEEN 0.1 AND 99.9 AND `posY` BETWEEN 0.1 AND 99.9) ' . // AND (dm.id IS NULL OR ?d) ' .
'ORDER BY quality ASC';
}
public function generate(array $ids = []) : bool
{
/*********************/
/* truncate old data */
/*********************/
@@ -151,7 +145,7 @@ function spawns() // and waypoints
/* perform... */
/**************/
foreach ($query as $idx => $q)
foreach ($this->querys as $idx => $q)
{
CLI::write($q[1]);
@@ -166,9 +160,9 @@ function spawns() // and waypoints
foreach ($queryResult as $spawn)
{
if (!$n)
CLI::write(' * sets '.($sum + 1).' - '.($sum += SqlGen::$stepSize));
CLI::write(' * sets '.($sum + 1).' - '.($sum += SqlGen::$sqlBatchSize));
if ($n++ > SqlGen::$stepSize)
if ($n++ > SqlGen::$sqlBatchSize)
$n = 0;
// npc/object is on a transport -> apply offsets to path of transport
@@ -181,9 +175,9 @@ function spawns() // and waypoints
$spawn['map'] = $transports[$spawn['map']]['mapId'];
}
$points = DB::Aowow()->select($queryPost, $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], 1, $spawn['map'], $spawn['areaId'], $spawn['areaId'] /*, $spawn['areaId'] ? 1 : 0*/);
$points = DB::Aowow()->select($this->queryPost, $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], 1, $spawn['map'], $spawn['areaId'], $spawn['areaId'] /*, $spawn['areaId'] ? 1 : 0*/);
if (!$points) // retry: TC counts pre-instance subareas as instance-maps .. which have no map file
$points = DB::Aowow()->select($queryPost, $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], 0, $spawn['map'], 0, 0 /*, 1*/);
$points = DB::Aowow()->select($this->queryPost, $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], $spawn['posX'], $spawn['posX'], $spawn['posY'], $spawn['posY'], 0, $spawn['map'], 0, 0 /*, 1*/);
if (!$points) // still impossible (there are areas that are intentionally off the map (e.g. the isles south of tanaris))
{
@@ -280,6 +274,7 @@ function spawns() // and waypoints
DB::Aowow()->query('UPDATE ?_spawns s, dbc_worldmaparea wma, dbc_map m SET s.spawnMask = 0 WHERE s.areaId = wma.areaId AND wma.mapId = m.id AND m.areaType IN (0, 3, 4)');
return true;
}
}
});
?>

View File

@@ -7,37 +7,16 @@ if (!CLI)
die('not in cli mode');
/* deps:
* item_template
* creature_template
* creature_template_addon
* smart_scripts
* npc_trainer
* disables
* spell_ranks
* spell_dbc
* skill_discovery_template
*/
$customData = array(
);
$reqDBC = [
'spell',
'spellradius',
'spellduration',
'spellrunecost',
'spellcasttimes',
'skillline',
'skilllineability',
'skillraceclassinfo',
'talent',
'talenttab',
'glyphproperties',
'spellicon'
];
function spell()
SqlGen::register(new class extends SetupScript
{
protected $command = 'spell';
protected $tblDependancyAowow = ['icons'];
protected $tblDependancyTC = ['item_template', 'creature_template', 'creature_template_addon', 'smart_scripts', 'npc_trainer', 'disables', 'spell_ranks', 'spell_dbc', 'skill_discovery_template'];
protected $dbcSourceFiles = ['spell', 'spellradius', 'spellduration', 'spellrunecost', 'spellcasttimes', 'skillline', 'skilllineability', 'skillraceclassinfo', 'talent', 'talenttab', 'glyphproperties', 'spellicon'];
public function generate(array $ids = []) : bool
{
$ssQuery = '
SELECT
id AS ARRAY_KEY,
@@ -225,7 +204,7 @@ function spell()
// merge serverside spells into dbc_spell (should not affect other scripts)
$lastMax = 0;
CLI::write(' - merging serverside spells into spell.dbc');
while ($spells = DB::World()->select($ssQuery, $lastMax, SqlGen::$stepSize))
while ($spells = DB::World()->select($ssQuery, $lastMax, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($spells, 'id'));
@@ -243,7 +222,7 @@ function spell()
// merge everything into aowow_spell
$lastMax = 0;
CLI::write(' - filling aowow_spell');
while ($spells = DB::Aowow()->select($baseQuery, $lastMax, SqlGen::$stepSize))
while ($spells = DB::Aowow()->select($baseQuery, $lastMax, SqlGen::$sqlBatchSize))
{
$newMax = max(array_column($spells, 'id'));
@@ -771,6 +750,7 @@ function spell()
DB::Aowow()->query('UPDATE ?_spell SET skillLine1 = 0, iconIdAlt = 0, cuFlags = cuFlags | ?d WHERE id IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, [60460, 58166, 58239, 58240, 58261, 58262, 54910]);
return true;
}
}
});
?>

View File

@@ -7,16 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps:
* spelldifficulty_dbc
*/
$customData = array(
);
$reqDBC = ['spelldifficulty'];
function spelldifficulty(array $ids = [])
SqlGen::register(new class extends SetupScript
{
protected $command = 'spelldifficulty';
protected $tblDependancyTC = ['spelldifficulty_dbc'];
protected $dbcSourceFiles = ['spelldifficulty'];
public function generate(array $ids = []) : bool
{
// has no unique keys..
DB::Aowow()->query('TRUNCATE TABLE ?_spelldifficulty');
@@ -27,6 +26,7 @@ function spelldifficulty(array $ids = [])
DB::Aowow()->query('INSERT INTO ?_spelldifficulty VALUES (?a)', array_values($r));
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'spellfocusobject';
protected $dbcSourceFiles = ['spellfocusobject'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'spelloverride';
protected $dbcSourceFiles = ['overridespelldata'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'spellrange';
protected $dbcSourceFiles = ['spellrange'];
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'spellvariables';
protected $dbcSourceFiles = ['spelldescriptionvariables'];
});
?>

View File

@@ -7,12 +7,14 @@ if (!CLI)
die('not in cli mode');
$customData = array(
);
$reqDBC = ['talent', 'talenttab'];
function talents()
SqlGen::register(new class extends SetupScript
{
protected $command = 'talents';
protected $dbcSourceFiles = ['talent', 'talenttab'];
public function generate(array $ids = []) : bool
{
// class: 0 => hunter pets
for ($i = 1; $i < 6; $i++)
DB::Aowow()->query('
@@ -36,6 +38,7 @@ function talents()
', $i, $i, $i);
return true;
}
}
});
?>

View File

@@ -7,17 +7,15 @@ if (!CLI)
die('not in cli mode');
/* deps
* creature_template
* creature
*/
$customData = array(
);
$reqDBC = ['taxipath', 'taxinodes', 'worldmaparea', 'worldmaptransforms', 'factiontemplate'];
function taxi() // path & nodes
SqlGen::register(new class extends SetupScript
{
protected $command = 'taxi'; // path & nodes
protected $tblDependancyTC = ['creature', 'creature_template'];
protected $dbcSourceFiles = ['taxipath', 'taxinodes', 'worldmaparea', 'worldmaptransforms', 'factiontemplate'];
public function generate(array $ids = []) : bool
{
/*********/
/* paths */
/*********/
@@ -171,6 +169,7 @@ function taxi() // path & nodes
return true;
}
}
});
?>

View File

@@ -6,22 +6,22 @@ if (!defined('AOWOW_REVISION'))
if (!CLI)
die('not in cli mode');
/* deps:
* quest_template
* game_event_seasonal_questrelation
* game_event
* achievement_reward
*/
$customData = array(
137 => ['gender' => 2],
138 => ['gender' => 1],
);
$reqDBC = ['chartitles'];
function titles()
SqlGen::register(new class extends SetupScript
{
$titleHoliday = array(
use TrCustomData;
protected $command = 'titles';
protected $tblDependancyTC = ['quest_template', 'game_event_seasonal_questrelation', 'game_event', 'achievement_reward'];
protected $dbcSourceFiles = ['chartitles'];
private $customData = array(
137 => ['gender' => 2],
138 => ['gender' => 1]
);
private $titleHoliday = array(
137 => 201,
138 => 201,
124 => 324,
@@ -35,6 +35,8 @@ function titles()
168 => 404
);
public function generate(array $ids = []) : bool
{
$questQuery = '
SELECT
qt.RewardTitle AS ARRAY_KEY,
@@ -67,8 +69,8 @@ function titles()
DB::Aowow()->query('UPDATE ?_titles SET category = 3 WHERE id IN (53, 64, 120, 121, 122, 129, 139, 140, 141, 142) OR (id >= 158 AND category = 0)');
// update event
if ($assoc = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($titleHoliday)))
foreach ($titleHoliday as $tId => $hId)
if ($assoc = DB::World()->selectCol('SELECT holiday AS ARRAY_KEY, eventEntry FROM game_event WHERE holiday IN (?a)', array_values($this->titleHoliday)))
foreach ($this->titleHoliday as $tId => $hId)
if (!empty($assoc[$hId]))
DB::Aowow()->query('UPDATE ?_titles SET eventId = ?d WHERE id = ?d', $assoc[$hId], $tId);
@@ -98,6 +100,7 @@ function titles()
DB::Aowow()->query('UPDATE ?_titles SET side = 1 WHERE id <= 14 OR id IN (111, 115, 112, 114, 126)');
return true;
}
}
});
?>

View File

@@ -0,0 +1,18 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
use TrDBCcopy;
protected $command = 'totemcategory';
protected $dbcSourceFiles = ['totemcategory'];
});
?>

View File

@@ -7,29 +7,33 @@ if (!CLI)
die('not in cli mode');
/* deps
* access_requirement
*/
SqlGen::register(new class extends SetupScript
{
use TrCustomData;
$customData = array(
protected $command = 'zones';
protected $tblDependancyTC = ['access_requirement'];
protected $dbcSourceFiles = ['worldmaptransforms', 'worldmaparea', 'map', 'mapdifficulty', 'areatable', 'lfgdungeons', 'battlemasterlist'];
private $customData = array(
2257 => ['cuFlags' => 0, 'category' => 0, 'type' => 1], // deeprun tram => type: transit
3698 => ['expansion' => 1], // arenas
3702 => ['expansion' => 1],
3968 => ['expansion' => 1],
4378 => ['expansion' => 2],
4406 => ['expansion' => 2],
2597 => ['maxPlayer' => 40], // is 5 in battlemasterlist ... dafuque?
2597 => ['maxPlayer' => 40], // is 5 in battlemasterlist ... dafuq?
4710 => ['maxPlayer' => 40],
3456 => ['parentAreaId' => 65, 'parentX' => 87.3, 'parentY' => 51.1], // has no coordinates set in map.dbc
3849 => ['parentAreaId' => 3523, 'parentX' => 70.5, 'parentY' => 69.6],
3847 => ['parentAreaId' => 3523, 'parentX' => 71.7, 'parentY' => 55.1],
3848 => ['parentAreaId' => 3523, 'parentX' => 74.3, 'parentY' => 57.8],
3845 => ['parentAreaId' => 3523, 'parentX' => 73.5, 'parentY' => 63.7]
);
$reqDBC = ['worldmaptransforms', 'worldmaparea', 'map', 'mapdifficulty', 'areatable', 'lfgdungeons', 'battlemasterlist'];
);
function zones()
{
public function generate(array $ids = []) : bool
{
// base query
DB::Aowow()->query('
REPLACE INTO ?_zones
@@ -228,6 +232,7 @@ function zones()
}
return true;
}
}
});
?>