Items/Filter

* implement 'effect text' filter
 * slight cleanup in itemset setup to match changes for effect text
This commit is contained in:
Sarjuuk 2026-02-12 12:11:00 +01:00
parent 84d2e30940
commit 68ca4973b1
10 changed files with 170 additions and 90 deletions

View file

@ -1460,6 +1460,12 @@ CREATE TABLE `aowow_items` (
`sheatheSoundId` smallint(5) unsigned NOT NULL DEFAULT 0,
`unsheatheSoundId` smallint(5) unsigned NOT NULL DEFAULT 0,
`flagsCustom` int(10) unsigned NOT NULL DEFAULT 0,
`effects_loc0` text DEFAULT NULL,
`effects_loc2` text DEFAULT NULL,
`effects_loc3` text DEFAULT NULL,
`effects_loc4` text DEFAULT NULL,
`effects_loc6` text DEFAULT NULL,
`effects_loc8` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `items_index` (`class`),
KEY `idx_model` (`displayId`),

View file

@ -71,7 +71,7 @@ UNLOCK TABLES;
LOCK TABLES `aowow_dbversion` WRITE;
/*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */;
INSERT INTO `aowow_dbversion` VALUES (1769622383,0,NULL,NULL);
INSERT INTO `aowow_dbversion` VALUES (1770889049,0,NULL,NULL);
/*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */;
UNLOCK TABLES;

View file

@ -1,5 +1,5 @@
ALTER TABLE `aowow_creature` ADD FULLTEXT `idx_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_items` ADD FULLTEXT `idx_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_objects` ADD FULLTEXT `idx_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_quests` ADD FULLTEXT `idx_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_spell` ADD FULLTEXT `idx_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_creature` ADD FULLTEXT `idx_ft_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_items` ADD FULLTEXT `idx_ft_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_objects` ADD FULLTEXT `idx_ft_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_quests` ADD FULLTEXT `idx_ft_name4` (`name_loc4`) WITH PARSER ngram;
ALTER TABLE `aowow_spell` ADD FULLTEXT `idx_ft_name4` (`name_loc4`) WITH PARSER ngram;

View file

@ -0,0 +1,9 @@
ALTER TABLE aowow_items
ADD COLUMN `effects_loc0` text DEFAULT NULL AFTER `flagsCustom`,
ADD COLUMN `effects_loc2` text DEFAULT NULL AFTER `effects_loc0`,
ADD COLUMN `effects_loc3` text DEFAULT NULL AFTER `effects_loc2`,
ADD COLUMN `effects_loc4` text DEFAULT NULL AFTER `effects_loc3`,
ADD COLUMN `effects_loc6` text DEFAULT NULL AFTER `effects_loc4`,
ADD COLUMN `effects_loc8` text DEFAULT NULL AFTER `effects_loc6`;
UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' items');

View file

@ -19,9 +19,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['gemproperties', 'itemdisplayinfo', 'spell', 'glyphproperties', 'durabilityquality', 'durabilitycosts'];
protected $worldDependency = ['item_template', 'item_template_locale', 'spell_group', 'game_event'];
protected $setupAfter = [['icons'], []];
protected $setupAfter = [['icons', 'spell', 'spellvariables', 'spellrange'], []];
private $skill2cat = array(
private const /* array */ SKILL_CATG = array(
SKILL_INSCRIPTION => 11,
SKILL_FISHING => 9,
SKILL_MINING => 12,
@ -118,7 +118,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
0 AS dropDownSoundId,
0 AS sheatheSoundId,
0 AS unsheatheSoundId,
flagsCustom
flagsCustom,
null AS effects_loc0, null AS effects_loc2, null AS effects_loc3, null AS effects_loc4, null AS effects_loc6, null AS effects_loc8
FROM item_template it
LEFT JOIN item_template_locale itl2 ON it.entry = itl2.ID AND itl2.locale = "frFR"
LEFT JOIN item_template_locale itl3 ON it.entry = itl3.ID AND itl3.locale = "deDE"
@ -136,12 +137,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$i = 0;
while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
{
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')', CLI::LOG_BLANK, true, true);
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')', tmpRow: true);
foreach ($items as $item)
DB::Aowow()->query('INSERT INTO ?_items VALUES (?a)', array_values($item));
}
CLI::write('[items] - applying misc data & fixes');
// merge with gemProperties
DB::Aowow()->query('UPDATE ?_items i, dbc_gemproperties gp SET i.gemEnchantmentId = gp.enchantmentId, i.gemColorMask = gp.colorMask WHERE i.gemColorMask = gp.id');
@ -205,7 +208,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
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
foreach ($this->skill2cat as $skill => $cat)
foreach (self::SKILL_CATG as $skill => $cat)
DB::Aowow()->query('UPDATE ?_items SET subClass = ?d WHERE classBak = 9 AND subClassBak = 0 AND requiredSkill = ?d', $cat, $skill);
// assign slot from onUse spell to item (todo (med): handle multi slot enchantments (like armor kits))
@ -262,6 +265,58 @@ CLISetup::registerSetup("sql", new class extends SetupScript
foreach ($checks as [$slots, $subclasses])
DB::Aowow()->query('UPDATE ?_items SET `cuFlags` = `cuFlags` | ?d WHERE `class`= ?d AND `slotBak` IN (?a) AND `subClass` NOT IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, ITEM_CLASS_WEAPON, $slots, $subclasses);
CLI::write('[items] - collecting spell descriptions');
CLI::write(' * fetching', tmpRow: true);
$itemSpellData = DB::Aowow()->select(
'SELECT `id` AS "0", `spellId1` AS "1" FROM ?_items WHERE `spellId1` > 0 UNION
SELECT `id` AS "0", `spellId2` AS "1" FROM ?_items WHERE `spellId2` > 0 UNION
SELECT `id` AS "0", `spellId3` AS "1" FROM ?_items WHERE `spellId3` > 0 UNION
SELECT `id` AS "0", `spellId4` AS "1" FROM ?_items WHERE `spellId4` > 0 UNION
SELECT `id` AS "0", `spellId5` AS "1" FROM ?_items WHERE `spellId5` > 0'
);
$itemSpells = new SpellList(array(['id', array_column($itemSpellData, 1)]), ['interactive' => SpellList::INTERACTIVE_NONE]);
$items = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `spellId1`, `spellId2`, `spellId3`, `spellId4`, `spellId5` FROM ?_items WHERE `id` IN (?a)', array_column($itemSpellData, 0));
if (!$itemSpells->error)
{
$i = 0;
$total = count($items) * count(CLISetup::$locales);
$update = [];
foreach (CLISetup::$locales as $locId => $loc)
{
Lang::load($loc);
foreach ($items as $itemId => $spells)
{
CLI::write(' * applying ' . str_pad(++$i, strlen($total), pad_type: STR_PAD_LEFT) . ' / ' . $total . str_pad('('.number_format(100 * $i / $total, 1).'%)', 8, pad_type: STR_PAD_LEFT), tmpRow: true);
foreach ($spells as $spellId)
{
if (!$itemSpells->getEntry($spellId))
continue;
if ($_ = $itemSpells->parseText('description'))
{
if (!isset($update[$itemId]['effects_loc'.$locId]))
$update[$itemId]['effects_loc'.$locId] = '';
$update[$itemId]['effects_loc'.$locId] .= $_[0]."\n";
}
}
}
}
$i = 0;
$total = count($update);
foreach ($update as $itemId => $upd)
{
CLI::write(' * writing ' . str_pad(++$i, strlen($total), pad_type: STR_PAD_LEFT) . ' / ' . $total . str_pad('('.number_format(100 * $i / $total, 1).'%)', 8, pad_type: STR_PAD_LEFT), tmpRow: true);
DB::Aowow()->query('UPDATE ?_items SET ?a WHERE `id` = ?d', $upd, $itemId);
}
}
$this->reapplyCCFlags('items', Type::ITEM);
return true;

View file

@ -196,6 +196,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$virtualId = 0;
$sets = DB::Aowow()->select('SELECT *, `id` AS ARRAY_KEY FROM dbc_itemset');
$spells = array_merge(
array_column($sets, 'spellId1'), array_column($sets, 'spellId2'), array_column($sets, 'spellId3'),
array_column($sets, 'spellId4'), array_column($sets, 'spellId5'), array_column($sets, 'spellId6'),
array_column($sets, 'spellId7'), array_column($sets, 'spellId8'), array_column($sets, 'spellId9')
);
$bonusSpells = new SpellList(array(['s.id', array_unique($spells)]), ['interactive' => SpellList::INTERACTIVE_NONE]);
$pieces = DB::World()->select('SELECT `itemset` AS ARRAY_KEY, `entry` AS ARRAY_KEY2, `entry`, `name`, `class`, `subclass`, `Quality`, `AllowableClass`, `ItemLevel`, `RequiredLevel`, `itemset`, IF (`Flags` & ?d, 1, 0) AS "heroic", IF(`InventoryType` = 15, 26, IF(`InventoryType` = 5, 20, `InventoryType`)) AS "slot" FROM item_template WHERE `itemset` > 0', ITEM_FLAG_HEROIC);
foreach ($sets as $setId => $setData)
{
@ -210,25 +219,16 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if ($setData['reqSkillLevel'])
$row['skillLevel'] = $setData['reqSkillLevel'];
/********************/
/* calc statbonuses */
/********************/
$spells = [];
$j = 1;
for ($i = 1; $i < 9; $i++)
if ($setData['spellId'.$i] > 0 && $setData['itemCount'.$i] > 0)
$spells[$i] = [$setData['spellId'.$i], $setData['itemCount'.$i]];
{
if ($setData['spellId'.$i] <= 0 || $setData['itemCount'.$i] <= 0)
continue;
$bonusSpells = new SpellList(array(['s.id', array_column($spells, 0)]));
$spells = array_pad($spells, 8, [0, 0]);
foreach (array_column($spells, 0) as $idx => $spellId)
$row['spell'.($idx+1)] = $spellId;
foreach (array_column($spells, 1) as $idx => $nItems)
$row['bonus'.($idx+1)] = $nItems;
$row['spell'.$j] = $setData['spellId'.$i];
$row['bonus'.$j] = $setData['itemCount'.$i];
$j++;
}
/**************************/
@ -243,16 +243,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$row['name_loc'.$locId] = Util::localizedString($setData, 'name');
foreach ($bonusSpells->iterate() as $__)
for ($i = 1; $i < 9; $i++)
{
if (!$setData['spellId'.$i] || !$bonusSpells->getEntry($setData['spellId'.$i]))
continue;
if (!isset($descText[$locId]))
$descText[$locId] = '';
$descText[$locId] .= $bonusSpells->parseText()[0]."\n";
}
// strip rating blocks - e.g. <!--rtg19-->14&nbsp;<small>(<!--rtg%19-->0.30%&nbsp;@&nbsp;L<!--lvl-->80)</small>
$row['bonusText_loc'.$locId] = preg_replace('/<!--rtg\d+-->(\d+)&nbsp.*?<\/small>/i', '\1', $descText[$locId]);
$row['bonusText_loc'.$locId] = $descText[$locId];
}
@ -260,8 +262,6 @@ CLISetup::registerSetup("sql", new class extends SetupScript
/* determine type and reuse from pieces */
/****************************************/
$pieces = DB::World()->select('SELECT `entry`, `name`, `class`, `subclass`, `Quality`, `AllowableClass`, `ItemLevel`, `RequiredLevel`, `itemset`, IF (`Flags` & ?d, 1, 0) AS "heroic", IF(`InventoryType` = 15, 26, IF(`InventoryType` = 5, 20, `InventoryType`)) AS "slot", `entry` AS ARRAY_KEY FROM item_template WHERE `itemset` = ?d', ITEM_FLAG_HEROIC, $setId);
/*
possible cases:
1) unused entry (empty data)
@ -269,7 +269,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
3) one itemset from one dbc entry (basic case). duplicate items per slot possible
*/
if (count($pieces) < 2)
if (count($pieces[$setId] ?? []) < 2)
{
$row['cuFlags'] = CUSTOM_EXCLUDE_FOR_LISTVIEW;
DB::Aowow()->query('INSERT INTO ?_itemset (?#) VALUES (?a)', array_keys($row), array_values($row));
@ -279,7 +279,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$sorted = [];
// sort available items by slot, sort slot by itemID ASC
foreach ($pieces as $data)
foreach ($pieces[$setId] as $data)
{
$data['note'] = $this->getContentGroup($data);
if (in_array($data['note'], [23, 25, 27, 29, 17, 19, 20, 22, 24, 26, 28, 30]))